tiles: modifier tiles can now be drawn
authorLukas Krickl <lukas@krickl.dev>
Thu, 13 Nov 2025 13:35:48 +0000 (14:35 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 13 Nov 2025 13:35:48 +0000 (14:35 +0100)
src/map.s
src/tiles.s
src/ui.s
src/wram.s
tiles/bank8000.inc
tiles/bank8800.inc

index 0b8f5539440c60fa5e321d7b27a17abf33db346c..d07361733fd5b126495d120b637e563aa2894b59 100644 (file)
--- 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
index af25ea852fcfdfd80397200d9277841a7786479a..547bf34d7056ca52029c869137cc8434f708e101 100644 (file)
@@ -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
        
index d46c74b7cc9e9336d8ecf6c8a4719e57661d4c90..45e61077398720c0e443f4dfd9da4800f9724fa0 100644 (file)
--- 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:
index f5a454b6b30f127410aa70a779b3544274148806..4ecf2be58193e47d1c992cb41a971fdf37a1b45d 100644 (file)
@@ -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
index 7c8a206e602b7a584eaac38c214814978549d59d..e75f707430964e093bb024cf2db8b2a89f7bfeb8 100644 (file)
@@ -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
 .chr 00000000
 .chr 00000000
 .chr 00000000
-.chr 00333000
+.chr 00000000
 .chr 00000000
 .chr 00000000
 .chr 00000000
index b5988ef5560cf2e5a688c4aad683aefe9b1d955e..abaa57a6405a0f6b875b9396e7827dcc693029c2 100644 (file)
@@ -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
 .chr 00000000
 .chr 00000000
 .chr 00000000
-.chr 00000000
+.chr 00333000
 .chr 00000000
 .chr 00000000
 .chr 00000000