maps: Changed map layout loader
authorLukas Krickl <lukas@krickl.dev>
Tue, 16 Dec 2025 05:46:55 +0000 (06:46 +0100)
committerLukas Krickl <lukas@krickl.dev>
Tue, 16 Dec 2025 05:46:55 +0000 (06:46 +0100)
The map data now contains only flags.
The loader only loads flags into memory. All other tile data is cleared on load.

maps/spawn.inc
src/map.s
src/tiles.s
tools/tmx2map.py

index c51b3aadcb7bcf56a1390f9661b813921668a9ba..9a0e2052e36779e631634f44686dff58aee4b1af 100644 (file)
@@ -1,16 +1,16 @@
 ; this map was generated by tmx2map.py
 
-.db 0x10, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xa
-.db 0xe, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x10
-.db 0xe, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x10
-.db 0xe, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x10
-.db 0xe, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x10
-.db 0xe, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x10
-.db 0xe, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x10
-.db 0xe, 0x1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+.db 0xa, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0x6
index 418bcd6ee8b219960901a1f141b66106896fc782..9f382e0ff94b204a4f7dbfc1b01175b4c8a95d96 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -99,53 +99,42 @@ map_settings_load:
        ; load actors
        ret
        
-       ; loads a tileset
+       ; loads a tile buffer
+       ; tile buffers from maped only contain tile flags 
        ; into the tile buffer
        ; inputs:
        ;               de: map ptr
 map_tiles_load:
+       push de
+       ; first clear all tiles
+       ; to 0
+       ld hl, tiles
+       ld bc, (tiles_end - tiles)
+       ld d, 0
+       call memset
+       pop de
+
+
        ld hl, map_tiles
        add hl, de
-       push hl
-       pop de
-       ; de = first tile to load
+       ; hl = first tile to load
        
        ; hl = first tile in buffer
-       ld hl, tiles
+       ld de, tiles+t_flags ; load flags
        
        ld bc, MAP_TILES ; loop counter
 @load_loop:
                ; load a tile
-               ld a, [de]
-               inc de ; next tile
-
-               ; load tile ptr from map
-               push de
-               push bc
-               
-               push hl
-               add a, a ; * 2 because it is a ptr table
-               ld b, 0
-               ld c, a
+               ld a, [hl+] ; load and tile++
+               ld [de], a ; write flags
 
-               ld hl, tile_id_table
-               add hl, bc ; hl = ptr offset
+               ; next tile
+               inc de
+               inc de
+               inc de
+               inc de
+               inc de
 
-               ; load ptr into de (source)
-               ld a, [hl+]
-               ld e, a
-               ld a, [hl+]
-               ld d, a
-               pop hl ; hl = destination
-
-               ; copy a tile
-               ld bc, t_size
-               call memcpy
-               ; hl is now next 
-               pop bc
-               pop de
-
-       
                ; loop counter--
                dec bc
                ld a, b
index ec7f6435e47467f4b50c144e1d1171d428a7c4d3..a9648dbe3d2897c43bd8da8c46cdad634255b67b 100644 (file)
@@ -1,100 +1,6 @@
        ; tile definitions
 
        
-       ; maps from tile ids 
-       ; to tile presets (tile index)
-tile_id_table:
-       ; 0
-       dw tile_no_exits
-       ; 1 
-       dw tile_all_exit
-       ; 2
-       dw tile_south_exit
-       ; 3
-       dw tile_north_exit
-       ; 4
-       dw tile_west_exit
-       ; 5
-       dw tile_east_exit
-
-       ; 6
-       dw tile_north_south_exit
-       ; 7
-       dw tile_north_east_exit
-       ; 8
-       dw tile_north_west_exit
-       
-       ; 9 
-       dw tile_south_west_exit
-       ; A
-       dw tile_south_east_exit
-
-       ; B
-       dw tile_east_west_exit
-
-       ; C
-       dw tile_north_south_west_exit
-
-       ; D
-       dw tile_south_west_east_exit
-       
-       ; E
-       dw tile_north_south_east_exit
-
-       ; F
-       dw tile_north_east_west_exit
-
-       ; 10
-       dw tile_north_west_south_exit
-
-       
        ; fallback tile 
 tile_null:
        tiledef 0, 0, 0, 0
-
-
-tile_all_exit:
-       tiledef TT_WALL, TF_SE | TF_NE | TF_EE | TF_WE, 0 
-
-tile_no_exits:
-       tiledef TT_WALL, 0, 0 
-tile_south_exit:
-       tiledef TT_WALL, TF_SE, 0 
-tile_north_exit:
-       tiledef TT_WALL, TF_NE, 0 
-tile_west_exit:
-       tiledef TT_WALL, TF_WE, 0 
-tile_east_exit:
-       tiledef TT_WALL, TF_EE, 0 
-
-tile_north_south_exit:
-       tiledef TT_WALL, TF_NE | TF_SE, 0 
-tile_east_west_exit:
-       tiledef TT_WALL, TF_EE | TF_WE, 0 
-       
-tile_north_east_exit:
-       tiledef TT_WALL, TF_EE | TF_NE, 0 
-
-tile_north_west_exit:
-       tiledef TT_WALL, TF_WE | TF_NE, 0 
-
-tile_south_east_exit:
-       tiledef TT_WALL, TF_EE | TF_SE, 0 
-
-tile_south_west_exit:
-       tiledef TT_WALL, TF_SE | TF_WE, 0 
-
-tile_north_south_east_exit:
-       tiledef TT_WALL, TF_NE | TF_SE | TF_EE, 0 
-
-tile_north_south_west_exit:
-       tiledef TT_WALL, TF_NE | TF_SE | TF_WE, 0 
-
-tile_south_west_east_exit:
-       tiledef TT_WALL, TF_SE | TF_WE | TF_EE, 0 
-
-tile_north_east_west_exit:
-       tiledef TT_WALL, TF_EE | TF_WE | TF_NE, 0 
-
-tile_north_west_south_exit:
-       tiledef TT_WALL, TF_SE | TF_NE | TF_WE, 0 
index 82cc34fb9101081e6298f1557a7c4f17161600b0..2d95728e1854ec212946285c523d167727fed3fe 100755 (executable)
@@ -13,7 +13,7 @@ if len(sys.argv) < 2:
 
 src = sys.argv[1]
 
-default_tile_id = 0
+tile_offset = 97
 
 def print_bg_data(data):
        print("; this map was generated by tmx2map.py")
@@ -25,7 +25,7 @@ def print_bg_data(data):
                        print("\n.db ", end = '')
 
 
-               val = int(b.strip()) - 1
+               val = int(b.strip()) - tile_offset
 
                if (i+1) % MAP_W  == 0:
                        end = ''