; cartride type
; MBC1+RAM+Battery
-.db 0x02
-.fill 0, 0x14D - $
+.db 0x03
+ ; rom size 32K
+.db 0x00
+ ; ram size 8k
+.db 0x02
+.fill 0, 0x14B - $
.chksm
.fill 0, 0x150 - $
; MBC1 registers
; write 0xA here to enable sram
-#define SRAM_ENABLE 0x0000
-#define ROM_BANKSEL 0x2000
-#define SRAM_BANKSEL 0x4000
+#define MBC1_SRAM_ENABLE 0x0000
+#define MBC1_ROM_BANKSEL 0x2000
+#define MBC1_SRAM_BANKSEL 0x4000
; maps:
- ; a map is a collection of room struct pointers
+ ; a map is a collection of room structs
; of n*m rooms. when a player leaves a room
; they will transition to the map to the north/south/east/west
+ ; a map also contains a memory region for all the room's tables
; room:
; a room is a collection of tiles, falgs and actor tables
ld a, GM_GAME
ld [game_mode], a
+ call mbc1_ram_enable
+
ret
; copies memory from one location to another
jr nz, @wait REL
ret
shadow_oam_to_oam_end:
+
+; MBC1 functions
+
+ ; ram enable mbc1
+ ; TODO: it is reccomended to disable ram when not
+ ; using it!
+mbc1_ram_enable:
+ ld a, 0xA
+ ld [MBC1_SRAM_ENABLE], a
+ ret
+
+
+mbc1_ram_disable:
+ xor a, a
+ ld [MBC1_SRAM_ENABLE], a
+ ret
; pause all other update execution until then
damage_anim: .adv 1
+; map region
+
#define MAP_W 10
#define MAP_H 10
#define MAP_TOTAL_ROOMS MAP_W * MAP_H
-; struct map
-.se 0
-; list of room pointers
-.de map_room_ptrs, 2 * MAP_TOTAL_ROOMS
-.de map_size, 0
-
; rooms are 9x9 meta tiles
#define ROOM_W 10
#define ROOM_H 8
; current room struct
; same layout as room struct itself
+ ; always should point at the current map's memory region
curr_room_struct:
; pointer to current room struct
curr_room: .adv 2