tiles: wip refactoring tile drawing
authorLukas Krickl <lukas@krickl.dev>
Wed, 12 Nov 2025 04:51:26 +0000 (05:51 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 12 Nov 2025 04:51:26 +0000 (05:51 +0100)
src/map.s
src/tiles.s
src/ui.s
src/wram.s
tiles/bank8000.inc

index 28259b9762ed4af73e59980e8d21d15aae9092b0..7ec22cb22c592d4c9d2cfc1b707890f23026a818 100644 (file)
--- 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
index a3222ddff60c06fb47eb30148d828a51099b25b2..996c325d291539a9b7df985fd45108a8cc94790c 100644 (file)
@@ -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
index f703abd32dbe613ed5e41fc89c47297d0d2ad15e..d46c74b7cc9e9336d8ecf6c8a4719e57661d4c90 100644 (file)
--- 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
index 2dd960e3524f2d58ea28a1fab58def18e3099e07..ec8ce4ad979839a847c598f10a783948cb9d3bb8 100644 (file)
@@ -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
index e75f707430964e093bb024cf2db8b2a89f7bfeb8..7c8a206e602b7a584eaac38c214814978549d59d 100644 (file)
@@ -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
 .chr 00000000
 .chr 00000000
 .chr 00000000
-.chr 00000000
+.chr 00333000
 .chr 00000000
 .chr 00000000
 .chr 00000000