Added a few constants for save game size
authorLukas Krickl <lukas@krickl.dev>
Thu, 26 Dec 2024 07:40:32 +0000 (08:40 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 26 Dec 2024 07:40:32 +0000 (08:40 +0100)
src/sram.s
src/wram.s

index 81e48dea6df03e0589236cc25143d8177074b539..dd3786d0287c6678ed7f6b96658b01207aa12533 100644 (file)
@@ -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
index b7f3773d51f00542a8e65be2b9779b1d64afc403..870a4cf6e3e9b6c368f7763a4510b86982db6c20 100644 (file)
@@ -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