maps: Fixed bug that caused the mapgen script to palce actors wrongly.
authorLukas Krickl <lukas@krickl.dev>
Wed, 26 Feb 2025 19:10:38 +0000 (20:10 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 26 Feb 2025 19:10:38 +0000 (20:10 +0100)
Actor position rounding was incorrect causing actors to be in the wrong
spot.

BUGS.md
maps/base_room.s
maps/base_room2.s
maps/base_room3.s
maps/base_room4.s
src/actor.s
tools/tms2map.py

diff --git a/BUGS.md b/BUGS.md
index c593fa004ccc10bbcd30cea87e3039aee07167f7..34d27a22a4f54bd9fc545f97d73c754512e79794 100644 (file)
--- a/BUGS.md
+++ b/BUGS.md
@@ -2,4 +2,3 @@
 
 - When rooms are linked it is possible to overwrite exits
 - anim_move does not actually move the way it was intended. anim_move should have another parameter that allows configuration of the loop step. Currently this is only a `dec operation`.
-- Actor positions are off and are fixed implicitly by obj arrangement code. This makes it so player collision code will not work for actors even though it should.
index c26859fdfcecae617479ee2dda7192f298d3c11e..eec9211886fa3694aa55021f528c08b773681f99 100644 (file)
@@ -5,14 +5,14 @@ dw base_room_flags
 dw base_room_actors
 dw room_empty_exits
 base_room_actors:
-.db  1 , 96 , 104 , 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
+.db  1 , 0x50 , 0x60 , 0
+.db  1 , 0x10 , 0x10 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 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, 0x82, 0x40, 0x40, 0x40, 0x40, 0x82, 0x40, 0xe0, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x48, 0x40, 0x82, 0x40, 0x40, 0x40, 0x40, 0x82, 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 ef75f7af150c0daf08cd9223772cd8de349c1440..85a0ef8fed94902b66b7056ed15e20b1d7f978b1 100644 (file)
@@ -5,14 +5,14 @@ dw base_room2_flags
 dw base_room2_actors
 dw room_empty_exits
 base_room2_actors:
-.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
+.db  1 , 0x30 , 0x40 , 0
+.db  1 , 0x20 , 0x30 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
 base_room2_bg:
 .db 0x60, 0x62, 0x62, 0x64, 0x62, 0x62, 0x66, 0x62, 0x62, 0x68, 0x4c, 0x40, 0x40, 0x82, 0x40, 0x40, 0x82, 0x40, 0x40, 0x6a, 0x46, 0x82, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x82, 0xe0, 0x4c, 0x40, 0x40, 0x82, 0xe8, 0xe8, 0x82, 0x40, 0x40, 0x6a, 0x4c, 0x40, 0x40, 0x82, 0xe8, 0xe8, 0x82, 0x40, 0x40, 0x6a, 0x48, 0x82, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x82, 0xe2, 0x4c, 0x40, 0x40, 0x82, 0x40, 0x40, 0x82, 0x40, 0x40, 0x6a, 0x6c, 0x4a, 0x4a, 0x42, 0x4a, 0x4a, 0x44, 0x4a, 0x4a, 0x6e
 base_room2_flags:
index 53127f18450138a4476bab038dc0b12221ee8369..fb7ab7ee393e413bc63929f287c9c40419a64498 100644 (file)
@@ -5,14 +5,14 @@ dw base_room3_flags
 dw base_room3_actors
 dw room_empty_exits
 base_room3_actors:
-.db  1 , 112 , 136 , 0
-.db  1 , 48 , 40 , 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
+.db  1 , 0x60 , 0x80 , 0
+.db  1 , 0x10 , 0x10 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
 base_room3_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, 0x82, 0x82, 0x40, 0x40, 0x40, 0xe0, 0x4c, 0x40, 0x82, 0x40, 0x40, 0x40, 0x40, 0x82, 0x40, 0x6a, 0x4c, 0x40, 0x82, 0x40, 0x40, 0x40, 0x40, 0x82, 0x40, 0x6a, 0x48, 0x40, 0x40, 0x40, 0x82, 0x82, 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_room3_flags:
index 0f5422ade73a438caaa09369cfcc63e6d136777e..7924f24b94d7b1aec3d89de86921a27c92bc7f0a 100644 (file)
@@ -5,14 +5,14 @@ dw base_room4_flags
 dw base_room4_actors
 dw room_empty_exits
 base_room4_actors:
-.db  1 , 112 , 136 , 0
-.db  1 , 48 , 24 , 0
-.db  1 , 48 , 136 , 0
-.db  1 , 112 , 40 , 0
-.db  0 , 16 , 8 , 0
-.db  0 , 16 , 8 , 0
-.db  0 , 16 , 8 , 0
-.db  0 , 16 , 8 , 0
+.db  1 , 0x60 , 0x80 , 0
+.db  1 , 0x10 , 0x10 , 0
+.db  1 , 0x10 , 0x80 , 0
+.db  1 , 0x60 , 0x10 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
+.db  0 , 0x0 , 0x0 , 0
 base_room4_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, 0x82, 0x82, 0x82, 0x82, 0x40, 0x40, 0xe0, 0x4c, 0x40, 0x82, 0x40, 0x40, 0x40, 0x40, 0x82, 0x40, 0x6a, 0x4c, 0x40, 0x82, 0x40, 0x40, 0x40, 0x40, 0x82, 0x40, 0x6a, 0x48, 0x40, 0x40, 0x40, 0x82, 0x82, 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_room4_flags:
index fc948804fd928f5baec8a0fe57d7fed8e54bc93e..2a1d4b7f99d6ab3c10719fb539d58eb4919660f0 100644 (file)
@@ -296,10 +296,12 @@ actor_update_bat:
 
   ; tile 1
   ld a, [bc] ; a = y
+  add a, OBJ_OFF_Y
   ld [hl+], a ; set y
   inc bc ; bc = actor_x
 
   ld a, [bc] ; a = x
+  add a, OBJ_OFF_X
   ld [hl+], a ; set x
 
   ld a, [tmp] 
@@ -311,10 +313,12 @@ actor_update_bat:
   ; tile 2
   dec bc ; bc = actor_y
   ld a, [bc]
+  add a, OBJ_OFF_Y
   ld [hl+], a ; set y
 
   inc bc ; bc = actor_x 
   ld a, [bc]
+  add a, OBJ_OFF_X
   add a, 8 
   ld [hl+], a ; set x
 
index a79d7b10436610a89d509f6e10583cf08d5af33b..17ba3624155c78c2edad42711dd538626432a849 100755 (executable)
@@ -5,8 +5,8 @@ import os
 import xml.etree.ElementTree as ET
 
 TILE_SIZE = 16
-ACTOR_OFFSET_X = 8
-ACTOR_OFFSET_Y = 16
+ACTOR_OFFSET_X = 0
+ACTOR_OFFSET_Y = 0
 
 if len(sys.argv) < 3:
     print("Usage: tmx2map.py <source> <map name>")
@@ -35,10 +35,10 @@ def print_data(data, name, layer):
         print(hex(val), end=end)
 
 def actor_round(n, base=TILE_SIZE):
-    return base * round(n/base)
+    return (round(n)) & 0xF0
 
 def print_actor(atype, y, x, flags):
-    print(".db ", int(atype), ",", int(actor_round(float(y))) + ACTOR_OFFSET_Y, ",", int(actor_round(float(x)))  + ACTOR_OFFSET_X, ",", int(flags))
+    print(".db ", int(atype), ",", hex(int(actor_round(float(y))) + ACTOR_OFFSET_Y), ",", hex(int(actor_round(float(x)))  + ACTOR_OFFSET_X), ",", int(flags))
 
 def print_struct(name):
     print(" ; struct for ", name)