From 4f983c01dc6dff0e70697725cff1c9e26689ecb7 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 26 Dec 2024 08:40:32 +0100 Subject: [PATCH] Added a few constants for save game size --- src/sram.s | 10 ++++++++++ src/wram.s | 21 ++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/sram.s b/src/sram.s index 81e48de..dd3786d 100644 --- a/src/sram.s +++ b/src/sram.s @@ -9,3 +9,13 @@ ; flag for init of sram sram_magic: .adv 1 + + ; checksum of save game + ; this is simply all bytes in the save game added +save_game_chksm: .adv 1 + +save_game: .adv SAVE_GAME_SIZE + + ; this is a canary value to detect out of bounds reads in sram + ; if this value is not SRAM_MAGIC then the save game is corrupted +save_game_overflow_canary: .adv 1 diff --git a/src/wram.s b/src/wram.s index b7f3773..870a4cf 100644 --- a/src/wram.s +++ b/src/wram.s @@ -31,7 +31,9 @@ prev_inputs: .adv 1 .de actor_flags, 1 .de actor_size, 0 -actor_table: .adv ACTORS_MAX * actor_size +#define ACTOR_TABLE_SIZE ACTORS_MAX * actor_size + +actor_table: .adv ACTOR_TABLE_SIZE actor_soam_ptr: .adv 2 @@ -79,14 +81,17 @@ damage_anim: .adv 1 #define WEST 3 #define EXIT_SPECIAL 4 -#define MAP_W 10 -#define MAP_H 10 -#define MAP_TOTAL_ROOMS MAP_W * MAP_H +#define ROOMS_TOTAL 16 ; rooms are 9x9 meta tiles #define ROOM_W 10 #define ROOM_H 8 -#define ROOM_EXITS_MAX 4 +#define ROOM_EXITS_MAX 5 + ; table of ptrs +#define ROOM_EXIT_TABLE_SIZE ROOM_EXITS_MAX * 2 + +#define ROOM_TILES_SIZE (ROOM_W * ROOM_H) +#define ROOM_FLAGS_SIZE (ROOM_W * ROOM_H) ; struct room ; FIXME: thse ptrs are currently in big endian... @@ -131,6 +136,12 @@ curr_room_init_act: .adv 2 ; ptr to exits curr_room_exits: .adv 2 + ; total size of a room including the struct header + ; tiles, flags, actors and exits +#define ROOM_SIZE_TOTAL ROOM_TILES_SIZE + ROOM_FLAGS_SIZE + ACTOR_TABLE_SIZE + ROOM_EXIT_TABLE_SIZE + +#define SAVE_GAME_SIZE ROOM_SIZE_TOTAL * ROOMS_TOTAL + player_size + ; drawing related flags ; UI flags -- 2.30.2