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