map: tiles are now loaded from the actual tile table
authorLukas Krickl <lukas@krickl.dev>
Sun, 11 Jan 2026 04:51:04 +0000 (05:51 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 11 Jan 2026 04:51:04 +0000 (05:51 +0100)
src/map.s

index b81a11386410e4c3fc90ac21f0f9274f8f9d7b40..95727bb7ef73c903899b286350055700c187ef14 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -92,14 +92,34 @@ map_tiles_load:
        add hl, de
        ; hl = first tile to load
        
-       ; hl = first tile in buffer
-       ld de, tiles+t_flags0 ; load flags
+       ; de = first tile in buffer
+       ld de, tiles ; start at first tile
        
        ld bc, MAP_TILES ; loop counter
 @load_loop:
                ; load a tile
                ld a, [hl+] ; load and tile++
-               ld [de], a ; write flags
+               add a, a ; * 2 for table offset
+               
+               push_all
+
+               push de ; de = destination tile...
+
+               ld hl, tile_table
+               ld d, 0
+               ld e, a 
+               add hl, de ; hl = correct tile ptr
+               ld a, [hl+]
+               ld h, [hl]
+               ld l, a ; hl = tile ptr
+               push hl
+               pop de ; de = src tile
+
+               pop hl ; hl = destination tile
+               ld bc, t_size
+               call memcpy
+
+               pop_all
 
                ; next tile
 .rep i, t_size, 1, inc de