map: reworked tile bank in map header to use a bank table instead
authorLukas Krickl <lukas@krickl.dev>
Sun, 14 Dec 2025 15:47:46 +0000 (16:47 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 14 Dec 2025 15:47:46 +0000 (16:47 +0100)
src/defs.s
src/levels.s
src/macros.inc
src/map.s

index 895f1bbd107bc6fbb824e6304573a51de3a9588f..c016454034d40ddf30e565f8f4c424875f5a80fe 100644 (file)
   ; maps to map property tile_bank0, tile_bank1, tile_bank2, tile_bank3
   ; note that tile_bank1 and tile_bank2 are 128 bytes each
   ; whereas bank0 and bank3 are 256 bytes
-.de map_tile_bank0_ptr, 2
-.de map_tile_bank1_ptr, 2
-.de map_tile_bank2_ptr, 2
-.de map_tile_bank3_ptr, 2
+.de map_tile_bank_table, 2
 .de map_tile_id_table, 2
 .de map_header_size, 0
        ; the map header is followed by MAP_W * MAP_H bytes
index 45c803b6d8c5f4416fe48d9041a33002656f848e..a4757ffee4f20dc0735ff0241b74c8414d59b8be 100644 (file)
        ; where each tile has values and its current state. The map can be drawn from this.
 
 l1:
-       mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, 0, l1_exits, bank8000, bank8800, bank8C00, bank9000, tile_id_table
+       mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, 0, l1_exits, tile_banks_default, tile_id_table
 #include "spawn.inc"
 
+tile_banks_default:
+       dw bank8000
+       dw bank8800
+       dw bank8C00 
+       dw bank9000 
+
 l1_exits:
        dw l1
        dw l1
@@ -25,5 +31,5 @@ l1_exits:
        dw l1
 
 l2:
-       mapdef 0, map_r_nop, 0, l1_exits, bank8000, bank8800, bank8C00, bank9000, tile_id_table
+       mapdef 0, map_r_nop, 0, l1_exits, tile_banks_default, tile_id_table
 #include "spawn.inc"
index 30e048fe7fad6c09a0dc20073c486f5badcb7bc9..f811cc640a54d122797345c3f061c3a74355b38d 100644 (file)
@@ -156,11 +156,8 @@ $1:
        ;               $2: map routine
        ;               $3: actors
        ;               $4: exits
-       ;               $5: tile bank 0
-       ;               $6: tile bank 1
-       ;               $7: tile bank 2
-       ;               $8: tile bank 3
-       ;               $9: tile id table
+       ;               $5: tile bank table
+       ;               $6: tile id table
 #macro mapdef
        .db $1
        dw $2
@@ -168,9 +165,6 @@ $1:
        dw $4
        dw $5
        dw $6
-       dw $7
-       dw $8
-       dw $9
 #endmacro
        
        ; define a tile
index 11f48ba2a8cc02b172f78eff6aff50d5a753dc7d..e530571a2046a060a32dc453a6a478132f85b641 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -181,8 +181,13 @@ map_tiles_load:
        ; inputs:
        ;               de: map ptr
 map_tile_banks_load:
-  ld hl, map_tile_bank0_ptr
-  add hl, de ; hl = bank0 ptr
+  ld hl, map_tile_bank_table
+       add hl, de
+       
+       ld a, [hl+]
+       ld h, [hl]
+       ld l, a
+  ; hl = bank0 ptr
 
        ; load ptr 
        ld a, [hl+]