From 7a3115918902187da9a9044c67be66ed29a421d7 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 13 Nov 2025 14:35:48 +0100 Subject: [PATCH] tiles: modifier tiles can now be drawn --- src/map.s | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/tiles.s | 3 ++- src/ui.s | 4 ++-- src/wram.s | 3 +++ tiles/bank8000.inc | 8 ++++---- tiles/bank8800.inc | 8 ++++---- 6 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/map.s b/src/map.s index 0b8f553..d073617 100644 --- a/src/map.s +++ b/src/map.s @@ -203,6 +203,36 @@ map_get_tile: ; hl = tile now ret + ; modifies the status gfx of a tile + ; based on flags + ; inputs: + ; update_tile_ptr: ptr to tile + ; a: current gfx + ; returns: + ; a: gfx to display +map_draw_tile_modify_status: + push af + ld a, [update_tile_ptr] + ld h, a + ld a, [update_tile_ptr+1] + ld l, a + ; a = original gfx + pop af + + inc hl ; hl = flags + bit 0, [hl] ; test bit 0 (TF_INC) + jr nz, @inc REL + + bit 1, [hl] ; test bit 1 (TF_DEC) + jr nz, @dec REL + ret +@inc: + ld a, UI_TILE_PLUS + ret +@dec: + ld a, UI_TILE_MINUS + ret + ; prepares tile draw ; by writing the expected tiles ; to tile_to_draw[0] to [3] @@ -215,6 +245,11 @@ map_draw_tile_prep: ; find tile to draw push bc call map_get_tile + ld a, h + ld [update_tile_ptr], a + ld a, l + ld [update_tile_ptr+1], a + ld bc, t_tile add hl, bc ; hl = tile gfx pop bc @@ -259,7 +294,17 @@ map_draw_tile_prep: ; draw 2x2 tile ld [hl+], a inc a + + push af + ; top left corner of tile + ; may display status effects + ; based on flags + push hl + call map_draw_tile_modify_status + pop hl + ld [hl+], a + pop af ; move down one tile row as well diff --git a/src/tiles.s b/src/tiles.s index af25ea8..547bf34 100644 --- a/src/tiles.s +++ b/src/tiles.s @@ -271,7 +271,8 @@ tile_update_hive: ; de: tile tile_update_food: inc de ; flags - ld a, TF_INC + ld a, [de] + inc a ld [de], a ret diff --git a/src/ui.s b/src/ui.s index d46c74b..45e6107 100644 --- a/src/ui.s +++ b/src/ui.s @@ -8,8 +8,8 @@ #define UI_TILE_HP_2 0xCA #define UI_TILE_HP_1 0xCB -#define UI_TILE_PLUS 0x01 -#define UI_TILE_MINUS 0x11 +#define UI_TILE_PLUS 0x81 +#define UI_TILE_MINUS 0xA0 ; inits UI ui_init: diff --git a/src/wram.s b/src/wram.s index f5a454b..4ecf2be 100644 --- a/src/wram.s +++ b/src/wram.s @@ -108,3 +108,6 @@ update_tile: .adv 2 update_tile_to_draw: .adv 4 ; ptr to vram for the next update tile update_tile_vram: .adv 2 + + ; ptr to last draw_tile_prep +update_tile_ptr: .adv 2 diff --git a/tiles/bank8000.inc b/tiles/bank8000.inc index 7c8a206..e75f707 100644 --- a/tiles/bank8000.inc +++ b/tiles/bank8000.inc @@ -10,9 +10,9 @@ ; tile 1 .chr 00000000 .chr 00000000 -.chr 00030000 -.chr 00333000 -.chr 00030000 +.chr 00000000 +.chr 00000000 +.chr 00000000 .chr 00000000 .chr 00000000 .chr 00000000 @@ -155,7 +155,7 @@ .chr 00000000 .chr 00000000 .chr 00000000 -.chr 00333000 +.chr 00000000 .chr 00000000 .chr 00000000 .chr 00000000 diff --git a/tiles/bank8800.inc b/tiles/bank8800.inc index b5988ef..abaa57a 100644 --- a/tiles/bank8800.inc +++ b/tiles/bank8800.inc @@ -9,9 +9,9 @@ .chr 00000000 .chr 00000000 .chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 00030000 +.chr 00333000 +.chr 00030000 .chr 00000000 .chr 00000000 .chr 00000000 @@ -274,7 +274,7 @@ .chr 00000000 .chr 00000000 .chr 00000000 -.chr 00000000 +.chr 00333000 .chr 00000000 .chr 00000000 .chr 00000000 -- 2.30.2