Parcourir la source

update private, fix more overworld stuff, change script location

SBird1337 il y a 7 ans
Parent
révision
a1c7e5b1ba

+ 2
- 1
makefile Voir le fichier

@@ -37,6 +37,7 @@ MAPROOT	  := sots-private/map
37 37
 MAPMAPS	  := $(MAPROOT)/maps
38 38
 MAPTS	  := $(MAPROOT)/tileset
39 39
 MAP_PROJ	:= $(MAPROOT)/sots.json
40
+SCRIPTROOT := $(MAPROOT)/script
40 41
 
41 42
 MAIN_OBJ  := $(BLDPATH)/linked.o
42 43
 B_ENGINE  := battle_engine/build/linked.o
@@ -67,7 +68,7 @@ C_SRC       := $(call rwildcard,src/,*.c)
67 68
 DATA_SRC    := $(call rwildcard,data/,*.s)
68 69
 STRING		:= $(call rwildcard,string/$(LAN)/,*.txt)
69 70
 STRING_SRC	:= $(STRING:%.txt=%.s)
70
-SCRIPT_SRC	:= $(call rwildcard,$(MAPMAPS)/,*.s)
71
+SCRIPT_SRC	:= $(call rwildcard,$(SCRIPTROOT)/,*.s)
71 72
 
72 73
 MAP_PROJ_S	:= $(MAP_PROJ:%.json=%.s)
73 74
 MAP_PROJ_O	:= $(MAP_PROJ:%.json=$(BLDPATH)/%.o)

+ 10
- 5
patches/dynamic_overworld_hooks.asm Voir le fichier

@@ -255,10 +255,10 @@ bx r5
255 255
 
256 256
 .pool
257 257
 
258
-.org 0x08007280
258
+/*.org 0x08007280
259 259
 ldr r1, =obj_delete_and_free_tiles_hook|1
260 260
 bx r1
261
-.pool
261
+.pool*/
262 262
 
263 263
 .org 0x0800779A
264 264
 ldr r1, =obj_delete_all_hook|1
@@ -278,10 +278,10 @@ bxr4:
278 278
 bx r4
279 279
 .pool
280 280
 
281
-.org 0x0808265C
281
+/*.org 0x0808265C
282 282
 ldr r3, =ov_emot_load|1
283 283
 bx r3
284
-.pool
284
+.pool*/
285 285
 
286 286
 /*.org 0x08083614
287 287
 ldr r1, =oec01_load_pal_impl|1
@@ -291,4 +291,9 @@ bx r1
291 291
 .org 0x0808365C
292 292
 ldr r1, =oec02_load_pal_impl|1
293 293
 bx r1
294
-.pool*/
294
+.pool*/
295
+
296
+.org 0x0805E510
297
+ldr r1, =npc_delete_obj_and_free_tiles_for_npc_hack|1
298
+bx r1
299
+.pool

+ 2
- 2
patches/overworlds/overworld.asm Voir le fichier

@@ -16,10 +16,10 @@ strb r0, [r4]
16 16
 ldrb r0, [r5, #3]
17 17
 strb r0, [r4, #0x1A]
18 18
 
19
-.org 0x0805E510
19
+/*.org 0x0805E510
20 20
     ldr r1, =overworld_h_two+1
21 21
     bx r1
22
-    .pool
22
+    .pool*/
23 23
 
24 24
 .org 0x0805E744
25 25
     lsl r4, r4, #0x10

+ 1
- 1
sots-private

@@ -1 +1 @@
1
-Subproject commit 1824abff46e5206961d42a691f6235f8c82e125d
1
+Subproject commit 50f15740eefbb1757648d648c46e2b50a1170f62

+ 19
- 10
src/overworld/dynamic_overworld.c Voir le fichier

@@ -81,14 +81,12 @@ void npc_dynamic_reset() {
81 81
     }
82 82
 }
83 83
 
84
-void npc_dynamic_remove_entry(u8 id, u16 tag) {
85
-    if (stored_palettes[id].tag == tag) {
86
-        if (stored_palettes[id].reference_count > 0) {
87
-            stored_palettes[id].reference_count--;
88
-            dprintf("npc_dynamic: removed entry #%d\n", id);
89
-            if (stored_palettes[id].reference_count == 0)
90
-                stored_palettes[id].tag = 0;
91
-        }
84
+void npc_dynamic_remove_entry(u8 id) {
85
+    if (stored_palettes[id].reference_count > 0) {
86
+        stored_palettes[id].reference_count--;
87
+        dprintf("npc_dynamic: removed entry #%d\n", id);
88
+        if (stored_palettes[id].reference_count == 0)
89
+            stored_palettes[id].tag = 0;
92 90
     }
93 91
 }
94 92
 
@@ -106,8 +104,7 @@ void npc_restore_state(u8 id, u16 x, u16 y) {
106 104
 
107 105
     struct Template template_to_load;
108 106
     u32 f14;
109
-    npc_to_objtemplate__with_indexed_objfunc(type_id, npc_to_load->running_behavior, &template_to_load,
110
-                                             &f14);
107
+    npc_to_objtemplate__with_indexed_objfunc(type_id, npc_to_load->running_behavior, &template_to_load, &f14);
111 108
     template_to_load.pal_tag = 0xFFFF;
112 109
     s8 pal_slot = npc_dynamic_load_palette(type_to_load->pal_num);
113 110
 
@@ -222,3 +219,15 @@ void oec02_load_pal_impl(u32 *oe_script) {
222 219
     }
223 220
     *oe_script += 4;
224 221
 }
222
+
223
+void npc_delete_obj_and_free_tiles_for_npc_hack(struct NpcState *state) {
224
+    struct SpriteTiles tiles;
225
+    u16 npc_id = ((u16)state->type_id) | (((u16)state->field1A << 8));
226
+    struct NpcType *type = npc_get_type(npc_id);
227
+    tiles.size = type->field_6;
228
+    objects[state->oam_id].gfx_table = &tiles;
229
+    u8 pal_num = objects[state->oam_id].final_oam.palette_num;
230
+    obj_delete_and_free(&objects[state->oam_id]);
231
+    npc_dynamic_remove_entry(pal_num);
232
+    dprintf("deleted npc state at x: %d y: %d\n", state->to.x, state->to.y);
233
+}