Browse Source

oe_images grass animation

SBird1337 7 years ago
parent
commit
820cf9fa40
5 changed files with 52 additions and 8 deletions
  1. 13
    1
      data/overworld/oe_effect_table.s
  2. 1
    1
      g3headers
  3. 1
    1
      makefile
  4. 1
    1
      sots-private
  5. 36
    4
      src/overworld/grass_animation.c

+ 13
- 1
data/overworld/oe_effect_table.s View File

@@ -9,7 +9,7 @@ oe_effect_table:
9 9
 .word 0x081D97CA @0x01
10 10
 .word 0x081D97D0 @0x02
11 11
 .word 0x081D97D6 @0x03
12
-.word 0x081D97DC @0x04 grass animation
12
+.word oea_grass @0x04 grass animation
13 13
 .word 0x081D97E6 @0x05
14 14
 .word 0x081D97F0 @0x06
15 15
 .word 0x081D97F6 @0x07
@@ -75,3 +75,15 @@ oe_effect_table:
75 75
 .word 0x081D999E @0x43
76 76
 .word 0x081D99A4 @0x44
77 77
 .word 0x081D99AA @0x45
78
+
79
+oea_grass:
80
+.byte 7
81
+.word oe_pal_grass_normal
82
+.word oei_grass_normal+1
83
+.byte 4
84
+
85
+.align 2
86
+
87
+oe_pal_grass_normal:
88
+.word oea_grass_normalPal
89
+.hword 0x1005

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit acea6cc201acf0d81a5fd8367f6af9a136e0eab4
1
+Subproject commit e4bae938451a8cf98b0175876872107ada2d7842

+ 1
- 1
makefile View File

@@ -1,7 +1,7 @@
1 1
 AS      := @arm-none-eabi-as
2 2
 LD      := @arm-none-eabi-ld
3 3
 OBJCOPY := @arm-none-eabi-objcopy
4
-GRIT    := @grit
4
+GRIT    := grit
5 5
 CC      := @arm-none-eabi-gcc
6 6
 ARS     := @armips
7 7
 MAKE    := make

+ 1
- 1
sots-private

@@ -1 +1 @@
1
-Subproject commit 4824651293b7e65aab39bff4896bea38ada05a84
1
+Subproject commit 9717c500152f71b9888b0a7da8b973592680c0ca

+ 36
- 4
src/overworld/grass_animation.c View File

@@ -1,7 +1,21 @@
1
+#include <oe_images/oea_grass_normal.h>
1 2
 #include <pokeagb/pokeagb.h>
2 3
 
3
-void grass_step_general(struct NpcState *npc)
4
-{
4
+struct SpriteTiles sprite_tiles_grass_normal[5] = {{.data = oea_grass_normalTiles + (0x80/4) * 0, .tag = 0, .size = 0x80},
5
+                                                   {.data = oea_grass_normalTiles + (0x80/4) * 1, .tag = 0, .size = 0x80},
6
+                                                   {.data = oea_grass_normalTiles + (0x80/4) * 2, .tag = 0, .size = 0x80},
7
+                                                   {.data = oea_grass_normalTiles + (0x80/4) * 3, .tag = 0, .size = 0x80},
8
+                                                   {.data = oea_grass_normalTiles + (0x80/4) * 4, .tag = 0, .size = 0x80}};
9
+
10
+struct Template grass_template_normal = {.tiles_tag = 0xFFFF,
11
+                                         .pal_tag = 0x1005,
12
+                                         .oam = &oam_data_grass,
13
+                                         .animation = &anim_image_grass,
14
+                                         .graphics = sprite_tiles_grass_normal,
15
+                                         .rotscale = &rotscale_empty,
16
+                                         .callback = oac_grass};
17
+
18
+void grass_step_general(struct NpcState *npc) {
5 19
     oe_state.effect_pos.x = npc->to.x;
6 20
     oe_state.effect_pos.y = npc->to.y;
7 21
     oe_state.priority = (npc->height) >> 4;
@@ -13,8 +27,7 @@ void grass_step_general(struct NpcState *npc)
13 27
     (void)oe_exec(4);
14 28
 }
15 29
 
16
-void grass_step_elastic(struct NpcState *npc)
17
-{
30
+void grass_step_elastic(struct NpcState *npc) {
18 31
     oe_state.effect_pos.x = npc->to.x;
19 32
     oe_state.effect_pos.y = npc->to.y;
20 33
     oe_state.priority = (npc->height) >> 4;
@@ -28,3 +41,22 @@ void grass_step_elastic(struct NpcState *npc)
28 41
     (void)oe_exec(4);
29 42
 }
30 43
 
44
+void oei_grass_normal(void) {
45
+    s16 x = (s16)oe_state.effect_pos.x;
46
+    s16 y = (s16)oe_state.effect_pos.y;
47
+    oe_adjust_coordinates(&x, &y, 8, 8);
48
+    u8 objid = template_instanciate_reverse_search(&grass_template_normal, x, y, 0);
49
+    if (objid != 64) {
50
+        struct Object *obj = &objects[objid];
51
+        obj->bitfield2 |= 2;
52
+        obj->final_oam.priority = oe_state.field_c & 3;
53
+        obj->priv[0] = oe_state.priority;
54
+        obj->priv[1] = oe_state.effect_pos.x;
55
+        obj->priv[2] = oe_state.effect_pos.y;
56
+        obj->priv[3] = oe_state.local_id_and_mapnumber;
57
+        obj->priv[4] = oe_state.local_mapbank;
58
+        obj->priv[5] = oe_state.sav1_location;
59
+        if (oe_state.field_1c)
60
+            obj_anim_image_seek(obj, 4);
61
+    }
62
+}