From bc99a273aa4c1cce4087a0127d61d53b04ab9f40 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 2 Aug 2025 12:05:37 +0200 Subject: [PATCH] actor saving: Added stubs for actor savegame calls --- src/actsave.s | 18 ++++++++++++++++++ src/defs.s | 4 ++++ src/main.s | 1 + src/map.s | 5 +++++ src/wram.s | 3 ++- 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/actsave.s diff --git a/src/actsave.s b/src/actsave.s new file mode 100644 index 0000000..a236e9c --- /dev/null +++ b/src/actsave.s @@ -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 diff --git a/src/defs.s b/src/defs.s index c22aa1e..d2ea1a6 100644 --- a/src/defs.s +++ b/src/defs.s @@ -230,6 +230,8 @@ .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 @@ -237,6 +239,8 @@ .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 diff --git a/src/main.s b/src/main.s index 14b36b3..fb5c0dd 100644 --- a/src/main.s +++ b/src/main.s @@ -74,6 +74,7 @@ main: #include "exittables.s" #include "demos.s" #include "mainmenu.s" +#include "actsave.s" ; fill bank .fill 0xFF, 0x4000 - $ diff --git a/src/map.s b/src/map.s index ebd1d7b..d59ea47 100644 --- 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 diff --git a/src/wram.s b/src/wram.s index 93fd1d8..65491e1 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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: -- 2.30.2