map: Refactored actor table in base maps
authorLukas Krickl <lukas@krickl.dev>
Thu, 2 Jan 2025 14:52:04 +0000 (15:52 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 2 Jan 2025 14:52:04 +0000 (15:52 +0100)
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
maps/base_room2.s
src/map.s
tools/tms2map.py

index dab76f7afdb8fd08ca20aacfb79cb65d0863576e..c4f830829872692431cb2916839b30ae8a78c6bd 100644 (file)
@@ -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:
index 810a460e2d3d98f9e9932f6ee0da265acd689651..c4ea98083301b3569696882db31c4f90f9660eb7 100644 (file)
@@ -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:
index 117259b5f3108a594f533b9880ab06c3d80a37a3..b018614ea97a431321007dbba77daad3bd793448 100644 (file)
--- 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
index f834fb3461a4464bbf17f3fdd9cd9d02c5051ab8..a79d7b10436610a89d509f6e10583cf08d5af33b 100755 (executable)
@@ -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)