From: Lukas Krickl Date: Wed, 12 Nov 2025 04:51:26 +0000 (+0100) Subject: tiles: wip refactoring tile drawing X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=c357d57c073953ce50bd44150e365acde9ce9d30;p=gbrg%2F.git tiles: wip refactoring tile drawing --- diff --git a/src/map.s b/src/map.s index 28259b9..7ec22cb 100644 --- a/src/map.s +++ b/src/map.s @@ -222,8 +222,25 @@ map_get_tile: ; hl = tile now ret + + ; prepares tile draw + ; by writing the expected tiles + ; to tile_to_draw[0] to [3] + ; inputs: + ; b/c: y/x position +map_draw_tile_prep: + call map_get_tile + ; hl = tile + + ld de, update_tile_to_draw + + ; TODO: + ret #macro map_draw_row_inc_c + push bc + call map_draw_tile_prep + pop bc push bc call map_draw_tile pop bc diff --git a/src/tiles.s b/src/tiles.s index a3222dd..996c325 100644 --- a/src/tiles.s +++ b/src/tiles.s @@ -66,6 +66,13 @@ tile_update_selected: call tile_update + ; prepare the tile for drawing + ld a, [update_tile_y] + ld b, a + ld a, [update_tile_x] + ld c, a + call map_draw_tile_prep + ret ; draws the recently updated tile @@ -248,8 +255,7 @@ tile_update_empty: add hl, de ld a, [hl] inc a - ld [hl], a - ret + ; ld [hl], a ret ; updates controlled tile diff --git a/src/ui.s b/src/ui.s index f703abd..d46c74b 100644 --- a/src/ui.s +++ b/src/ui.s @@ -8,6 +8,9 @@ #define UI_TILE_HP_2 0xCA #define UI_TILE_HP_1 0xCB +#define UI_TILE_PLUS 0x01 +#define UI_TILE_MINUS 0x11 + ; inits UI ui_init: ld hl, ui_draw_nop diff --git a/src/wram.s b/src/wram.s index 2dd960e..ec8ce4a 100644 --- a/src/wram.s +++ b/src/wram.s @@ -101,7 +101,8 @@ current_tile: .adv 2 update_tile_y: .adv 1 update_tile_x: .adv 1 update_tile: .adv 2 - ; previpus frame's update tile - ; used for drawing the recently updated tile -update_tile_prev_y: .adv 1 -update_tile_prev_x: .adv 1 + + ; space for 4 tile ids + ; that represent the current tile + ; this gets drawn during the next blank +update_tile_to_draw: .adv 4 diff --git a/tiles/bank8000.inc b/tiles/bank8000.inc index e75f707..7c8a206 100644 --- a/tiles/bank8000.inc +++ b/tiles/bank8000.inc @@ -10,9 +10,9 @@ ; tile 1 .chr 00000000 .chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 00030000 +.chr 00333000 +.chr 00030000 .chr 00000000 .chr 00000000 .chr 00000000 @@ -155,7 +155,7 @@ .chr 00000000 .chr 00000000 .chr 00000000 -.chr 00000000 +.chr 00333000 .chr 00000000 .chr 00000000 .chr 00000000