; 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
.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
#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...
; 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