actor saving: Added stubs for actor savegame calls
authorLukas Krickl <lukas@krickl.dev>
Sat, 2 Aug 2025 10:05:37 +0000 (12:05 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sat, 2 Aug 2025 10:05:37 +0000 (12:05 +0200)
src/actsave.s [new file with mode: 0644]
src/defs.s
src/main.s
src/map.s
src/wram.s

diff --git a/src/actsave.s b/src/actsave.s
new file mode 100644 (file)
index 0000000..a236e9c
--- /dev/null
@@ -0,0 +1,18 @@
+       ; init the actor saves
+       ; sets everything to 0xFF
+act_save_init:
+       ld hl, act_sg
+       ld bc, act_sg_end - act_sg
+       ld d, ACT_SG_DEFAULT_VALUE
+       call memset
+       ret
+       
+       ; stores actor save game
+       ; based on the current map's seed offset
+act_sg_store:
+       ret
+       
+       ; restores actor save game based on
+       ; current map's seed offset
+act_sg_restore:
+       ret
index c22aa1eadb9884d3f0d8f47398e8280bd8707d4a..d2ea1a689b71a79874d79b16e6a73f9cca7b5d8c 100644 (file)
 .de act_size, 0
   
        ; actor save game data
+       ; if pos y and x is 0xFF 
+       ; it is not restored
 .se 0
 .de act_sg_pos_y, 1
 .de act_sg_pos_x, 1
 .de act_sg_p0, 1
 .de act_sg_size, 0
 
+#define ACT_SG_DEFAULT_VALUE 0xFF
+
 #define MAP_BG_TILE_OFFSET 0
 #define MAP_BG_FLAGS_OFFSET 1
 
index 14b36b339f9dbedb8966dd3544c696256fd5fcf9..fb5c0dd63d585bc2aeae7941bc96cd269321eadc 100644 (file)
@@ -74,6 +74,7 @@ main:
 #include "exittables.s"
 #include "demos.s"
 #include "mainmenu.s"
+#include "actsave.s"
 
 ; fill bank
 .fill 0xFF, 0x4000 - $
index ebd1d7b898d6028ad86ae1caa8b1288ec5d68a74..d59ea47042ed09444c79b4512262ab2ca3a6c1cc 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -11,6 +11,11 @@ map_init:
   ; TODO: do not touch lcd or interrupts if 
   ; they were not enabled!
 map_load:
+       ; clear act save data
+       push hl
+       call act_save_init
+       pop hl
+
        ; backup the map header
        ld a, l
        ld [map_header], a
index 93fd1d8401de9b453370f67ac8b37610e8f2e60f..65491e1292f68cde4f0ee22f8e91cd571aeabec9 100644 (file)
@@ -165,7 +165,8 @@ map_header: .adv 2
        ; actor savegame data;
        ; store actor data here on map load 
        ; and re-load on map restore
-       ; if pos y and pos x are both 0 do not restore
+       ; if pos y and pos x are both 0xFF do not restore
 act_sg: .adv act_sg_size * UNITS_MAX * FLOOR_MAP_COUNT
+act_sg_end:
 
 state_end: