From: Lukas Krickl Date: Wed, 26 Feb 2025 19:10:38 +0000 (+0100) Subject: maps: Fixed bug that caused the mapgen script to palce actors wrongly. X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=c91395f555eda5860ec92b174e607a7b181c8271;p=gbrg%2F.git maps: Fixed bug that caused the mapgen script to palce actors wrongly. Actor position rounding was incorrect causing actors to be in the wrong spot. --- diff --git a/BUGS.md b/BUGS.md index c593fa0..34d27a2 100644 --- 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. diff --git a/maps/base_room.s b/maps/base_room.s index c26859f..eec9211 100644 --- a/maps/base_room.s +++ b/maps/base_room.s @@ -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: diff --git a/maps/base_room2.s b/maps/base_room2.s index ef75f7a..85a0ef8 100644 --- a/maps/base_room2.s +++ b/maps/base_room2.s @@ -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: diff --git a/maps/base_room3.s b/maps/base_room3.s index 53127f1..fb7ab7e 100644 --- a/maps/base_room3.s +++ b/maps/base_room3.s @@ -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: diff --git a/maps/base_room4.s b/maps/base_room4.s index 0f5422a..7924f24 100644 --- a/maps/base_room4.s +++ b/maps/base_room4.s @@ -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: diff --git a/src/actor.s b/src/actor.s index fc94880..2a1d4b7 100644 --- a/src/actor.s +++ b/src/actor.s @@ -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 diff --git a/tools/tms2map.py b/tools/tms2map.py index a79d7b1..17ba362 100755 --- a/tools/tms2map.py +++ b/tools/tms2map.py @@ -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 ") @@ -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)