From 58e648488f98b6b274c0d4ef309e03542b32b582 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 25 Oct 2024 16:55:21 +0200 Subject: [PATCH] room load now directly loads the room structs into its respective ptrs --- maps/base_room.s | 7 ++++--- src/macros.inc | 7 +++++++ src/map.s | 8 ++++++-- src/video.s | 3 ++- src/wram.s | 10 +++++++--- tools/tms2map.py | 7 ++++--- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/maps/base_room.s b/maps/base_room.s index 35b5d66..efccf5e 100644 --- a/maps/base_room.s +++ b/maps/base_room.s @@ -1,7 +1,8 @@ ; struct for base_room -dw base_room_bg -dw base_room_flags -dw base_room_actors +base_room_struct: +dwb base_room_bg +dwb base_room_flags +dwb base_room_actors base_room_actors: .db 8 .db 1 , 67 , 54 , 0 diff --git a/src/macros.inc b/src/macros.inc index 887ddbd..7275e50 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -42,4 +42,11 @@ #macro dw .db $1 & 0xFF .db ($1 >> 8) & 0xFF +#endmacro + + ; same as dw but + ; stores in big endian +#macro dwb +.db ($1 >> 8) & 0xFF +.db $1 & 0xFF #endmacro diff --git a/src/map.s b/src/map.s index ae9cd8a..8b32313 100644 --- a/src/map.s +++ b/src/map.s @@ -28,9 +28,13 @@ ; loads a map ; inputs: - ; curr_room: ptr to current room - ; curr_room_init_act: ptr to initial actors to be loaded + ; de: ptr to room struct room_load_from: + ; copy de to current room struct + ; and then load the room + ld hl, curr_room_struct + ld bc, room_size + call room_draw call room_load_actors ret diff --git a/src/video.s b/src/video.s index 40fe54f..60d9786 100644 --- a/src/video.s +++ b/src/video.s @@ -97,7 +97,8 @@ video_init: ld [curr_room_init_act], a ldhi a, base_room_actors ld [curr_room_init_act+1], a - + + ld de, base_room_struct call room_load_from ; set up bgp diff --git a/src/wram.s b/src/wram.s index 9451b3b..72cca69 100644 --- a/src/wram.s +++ b/src/wram.s @@ -77,16 +77,20 @@ damage_anim: .adv 1 #define ROOM_H 8 ; struct room +; FIXME: thse ptrs are currently in big endian... .se 0 -.de room_tiles, 2 ; ptr to tiles -.de room_flags, 2 ; ptr to flags -.de room_actor_table, 2 ; actor table ot be used +.de room_tiles, 2 ; be ptr to tiles +.de room_flags, 2 ; be ptr to flags +.de room_actor_table, 2 ; be ptr of actor table to be used .de room_size, 0 ; room flags .se 1 .de RF_WALL, 1 + ; current room struct + ; same layout as room struct itself +curr_room_struct: ; pointer to current room struct curr_room: .adv 2 ; flags for current tiles diff --git a/tools/tms2map.py b/tools/tms2map.py index 46a862d..c7248d4 100755 --- a/tools/tms2map.py +++ b/tools/tms2map.py @@ -35,9 +35,10 @@ def print_actor(atype, y, x, flags): def print_struct(name): print(" ; struct for ", name) - print("dw " + name + '_bg') - print("dw " + name + '_flags') - print("dw " + name + '_actors') + print(name + "_struct:") + print("dwb " + name + '_bg') + print("dwb " + name + '_flags') + print("dwb " + name + '_actors') def convert(src, name): tree = ET.parse(src) -- 2.30.2