From cc0709c0d15e45d54d7f11c2fa1a73e71af0761b Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 2 Jan 2025 15:52:04 +0100 Subject: [PATCH] map: Refactored actor table in base maps Base maps now always include the entire actor table to make the copy operatin easier and more clear. This now allows us to save the actor table back. The initial copy is now also easier :^) --- maps/base_room.s | 7 ++++++- maps/base_room2.s | 7 ++++++- src/map.s | 13 +++---------- tools/tms2map.py | 5 ++++- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/maps/base_room.s b/maps/base_room.s index dab76f7..c4f8308 100644 --- a/maps/base_room.s +++ b/maps/base_room.s @@ -5,9 +5,14 @@ dw base_room_flags dw base_room_actors dw room_empty_exits base_room_actors: -.db 8 .db 1 , 64 , 72 , 0 .db 1 , 48 , 56 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 base_room_bg: .db 0x60, 0x62, 0x62, 0x64, 0x62, 0x62, 0x66, 0x62, 0x62, 0x68, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x46, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe0, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x48, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe2, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x6c, 0x4a, 0x4a, 0x42, 0x4a, 0x4a, 0x44, 0x4a, 0x4a, 0x6e base_room_flags: diff --git a/maps/base_room2.s b/maps/base_room2.s index 810a460..c4ea980 100644 --- a/maps/base_room2.s +++ b/maps/base_room2.s @@ -5,9 +5,14 @@ dw base_room2_flags dw base_room2_actors dw room_empty_exits base_room2_actors: -.db 8 .db 1 , 64 , 72 , 0 .db 1 , 48 , 56 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 +.db 0 , 16 , 8 , 0 base_room2_bg: .db 0x60, 0x62, 0x62, 0x64, 0x62, 0x62, 0x66, 0x62, 0x62, 0x68, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x46, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe0, 0x4c, 0x40, 0x40, 0x40, 0x4e, 0x4e, 0x40, 0x40, 0x40, 0x6a, 0x4c, 0x40, 0x40, 0x40, 0x4e, 0x4e, 0x40, 0x40, 0x40, 0x6a, 0x48, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe2, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x6c, 0x4a, 0x4a, 0x42, 0x4a, 0x4a, 0x44, 0x4a, 0x4a, 0x6e base_room2_flags: diff --git a/src/map.s b/src/map.s index 117259b..b018614 100644 --- a/src/map.s +++ b/src/map.s @@ -160,7 +160,6 @@ room_goto_player_pos: ; curr_room_exits: ptr to exits table ; a: direction EAST, WEST, NORTH, SOUTH, EXIT_SPECIAL room_goto: - ; TODO: save current tables back push af ; dst = original actor table @@ -174,8 +173,7 @@ room_goto: ; src = actor_table ld de, actor_table ld bc, ACTOR_TABLE_SIZE - ; TODO fix actor table saving - ; call memcpy + call memcpy pop af @@ -252,18 +250,13 @@ room_load_actors: ld e, a ld a, [hl] ld d, a - ; de = length...source table - - ld b, 0 - ld a, [de] - ld c, a ; bc = len + ; de = source table + ld bc, ACTOR_TABLE_SIZE - inc de ; de = source table ; hl = dst ld hl, actor_table call memcpy - ret ; maps are collections of rooms diff --git a/tools/tms2map.py b/tools/tms2map.py index f834fb3..a79d7b1 100755 --- a/tools/tms2map.py +++ b/tools/tms2map.py @@ -60,7 +60,7 @@ def convert(src, name): print_data(data.text, name, child.attrib['name']) elif child.tag == "objectgroup": print(name + '_actors:') - print(".db ", len(child) * 4) + actors_printed = 0 for data in child: flags = 0 atype = 0 @@ -71,6 +71,9 @@ def convert(src, name): elif prop.attrib['name'] == 'flags': flags = prop.attrib['value'] print_actor(atype, data.attrib['y'], data.attrib['x'], flags) + actors_printed += 1 + for not_filled in range(actors_printed, 8, 1): + print_actor(0, 0, 0, 0) -- 2.30.2