Browse Source

tileset animation routines

SBird1337 7 years ago
parent
commit
a4f71e3596

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit e4bae938451a8cf98b0175876872107ada2d7842
1
+Subproject commit cb245518f41d5d508f7c1e70e7b751a2ae4546e8

+ 5
- 0
patches/hooks.asm View File

@@ -106,6 +106,11 @@ _call_via_r1 equ 0x081E3BAC
106 106
     bx r3
107 107
     .pool
108 108
 
109
+.org 0x0806E568
110
+    ldr r3, =var_get_hack|1
111
+    bx r3
112
+    .pool
113
+
109 114
 .org 0x0806E680
110 115
     ldr r1, =flag_set_hack|1
111 116
     bx r1

+ 1
- 1
sots-private

@@ -1 +1 @@
1
-Subproject commit 7d71ecc8ff4f5bf88e8568320f0311a4a15b3ed0
1
+Subproject commit ad49274282816597ff3b487345aba78c68354212

src/overworld/grass_animation.c → src/overworld/tileset_animation/grass_animation.c View File


+ 52
- 0
src/overworld/tileset_animation/main_animator.c View File

@@ -0,0 +1,52 @@
1
+#include <pokeagb/pokeagb.h>
2
+#include <tileset_animation/smoke.h>
3
+
4
+struct TilesetAnimation {
5
+    u16 tile_start;
6
+    u16 frame_lenght;
7
+    u16 tile_length;
8
+    u16 frame_count;
9
+    const void *image;
10
+};
11
+
12
+const struct TilesetAnimation hesperia_second_animations[] = {
13
+    {0x114, 7, 4, 5, smokeTiles}, {0, 0, 0, 0, (void *)0xFFFFFFFF},
14
+};
15
+
16
+void animate_from_structure(const struct TilesetAnimation *anim, u16 tile_skip, u16 current_frame) {
17
+    void *vram_address = (void *)(0x06000000 + (tile_skip * 0x20));
18
+    u8 current_animation = 0;
19
+    while (anim[current_animation].image != (void*)0xFFFFFFFF) {
20
+        void *current_vram = vram_address + (0x20 * anim[current_animation].tile_start);
21
+        u16 max_frame = anim[current_animation].frame_lenght * anim[current_animation].frame_count;
22
+        current_frame = current_frame % max_frame;
23
+        current_frame /= anim[current_animation].frame_lenght;
24
+        memcpy(current_vram,
25
+               anim[current_animation].image + (0x20 * anim[current_animation].tile_length * current_frame),
26
+               anim[current_animation].tile_length * 0x20);
27
+        current_animation++;
28
+    }
29
+}
30
+
31
+void main_animator(u16 current_frame) {
32
+    (void)current_frame;
33
+}
34
+
35
+extern struct MapBlockset maptileset128;
36
+extern struct MapBlockset maptileset0;
37
+
38
+void main_second_animator(u16 current_frame) {
39
+    animate_from_structure(hesperia_second_animations, 0x280, current_frame);
40
+}
41
+
42
+void main_animator_init(void) {
43
+    blockset_one_current_tile = 0;
44
+    blockset_one_max_tile = 0x280;
45
+    blockset_one_animator = main_animator;
46
+}
47
+
48
+void main_second_animator_init(void) {
49
+    blockset_two_current_tile = 0;
50
+    blockset_two_max_tile = 0x100;
51
+    blockset_two_animator = main_second_animator;
52
+}

+ 9
- 3
src/savefile/flag_manipulation.c View File

@@ -100,6 +100,13 @@ void flag_set_hack(u16 flag) {
100 100
     }
101 101
 }
102 102
 
103
+u16 var_get_hack(u16 var) {
104
+    u16 *ptr = var_access(var);
105
+    if (ptr != NULL)
106
+        return *ptr;
107
+    return var;
108
+}
109
+
103 110
 bool var_set_hack(u16 var, u16 val) {
104 111
     u16 *ptr = var_access(var);
105 112
     if (ptr != NULL) {
@@ -110,10 +117,9 @@ bool var_set_hack(u16 var, u16 val) {
110 117
     return false;
111 118
 }
112 119
 
113
-bool var_set_script_hack(struct ScriptEnvironment *env)
114
-{
120
+bool var_set_script_hack(struct ScriptEnvironment *env) {
115 121
     u16 var = script_read_halfword(env);
116 122
     u16 val = script_read_halfword(env);
117
-    var_set_hack(var,val);
123
+    var_set_hack(var, val);
118 124
     return 0;
119 125
 }