From d0f73990e236c5614e2d0303b8b227846aaecd71 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 26 Nov 2025 05:51:59 +0100 Subject: [PATCH] map: vram origin is now configurable --- src/map.s | 19 +++++++++++++++++-- src/mem.s | 3 +++ src/wram.s | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/map.s b/src/map.s index a457a80..ce2eb49 100644 --- a/src/map.s +++ b/src/map.s @@ -1,4 +1,14 @@ #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 @@ -230,8 +240,13 @@ map_draw_tile_prep: ; 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 diff --git a/src/mem.s b/src/mem.s index 60da28e..00662ef 100644 --- a/src/mem.s +++ b/src/mem.s @@ -4,6 +4,8 @@ mem_init: ld hl, WRAM ld bc, WRAMLEN call memset + + call map_globals_init ; set up shadow IE ld a, IVBLANK | ILCD @@ -29,6 +31,7 @@ mem_init: ld hl, new_game call game_set_state + ret ; copies memory from one location to another diff --git a/src/wram.s b/src/wram.s index 4dcc26c..026b41d 100644 --- a/src/wram.s +++ b/src/wram.s @@ -84,6 +84,9 @@ tmp_x: .adv 1 ; 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 -- 2.30.2