#define SCRN0_END 0x9BF3
+
+ ; inits map globals
+ ; such as map_vram_tl
+map_globals_init:
+ ld hl, SCRN0
+ ld a, h
+ ld [map_vram_tl], a
+ ld a, l
+ ld [map_vram_tl+1], a
+ ret
; loads a map
; including the required tileset
; load tile into a
ld a, [hl] ; a = tile
push af ; save tile gfx
-
- ld hl, SCRN0
+
+ ; TODO: this needs to wrap around
+ ; if hl goes oob in y-loop
+ ld a, [map_vram_tl]
+ ld h, a
+ ld a, [map_vram_tl+1]
+ ld l, a
ld de, ((MAP_W * 2) + 12) * 2 ; * 4 because tiles are 8x8
; skip y loop if b is 0
ld hl, WRAM
ld bc, WRAMLEN
call memset
+
+ call map_globals_init
; set up shadow IE
ld a, IVBLANK | ILCD
ld hl, new_game
call game_set_state
+
ret
; copies memory from one location to another
; current map ptr
map: .adv 2
+ ; ptr to top left corner of SCRN
+ ; where the map should be drawn
+map_vram_tl: .adv 2
; ptr to current tile to be updated
tiles: .adv t_size * MAP_TILES