From: Lukas Krickl Date: Tue, 16 Dec 2025 05:46:55 +0000 (+0100) Subject: maps: Changed map layout loader X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=5856a63ccf7b27d382075524c795203c84d3c6fb;p=gbrg%2F.git maps: Changed map layout loader The map data now contains only flags. The loader only loads flags into memory. All other tile data is cleared on load. --- diff --git a/maps/spawn.inc b/maps/spawn.inc index c51b3aa..9a0e205 100644 --- a/maps/spawn.inc +++ b/maps/spawn.inc @@ -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, 0x1, 0x1, 0x1, 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, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0x6 diff --git a/src/map.s b/src/map.s index 418bcd6..9f382e0 100644 --- 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 diff --git a/src/tiles.s b/src/tiles.s index ec7f643..a9648db 100644 --- a/src/tiles.s +++ b/src/tiles.s @@ -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 diff --git a/tools/tmx2map.py b/tools/tmx2map.py index 82cc34f..2d95728 100755 --- a/tools/tmx2map.py +++ b/tools/tmx2map.py @@ -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 = ''