room load now directly loads the room structs into its respective ptrs
authorLukas Krickl <lukas@krickl.dev>
Fri, 25 Oct 2024 14:55:21 +0000 (16:55 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 25 Oct 2024 14:55:21 +0000 (16:55 +0200)
maps/base_room.s
src/macros.inc
src/map.s
src/video.s
src/wram.s
tools/tms2map.py

index 35b5d6640199956f163c9b2802d6228f58eb24bd..efccf5e9e3416af1784d2e4136eee9b4cf03d405 100644 (file)
@@ -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
index 887ddbdac6ca7034cb4a9d8ebdf81bcdd3abdb2c..7275e50e1e015d98d9ac1580f255cd84e72aa218 100644 (file)
 #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
index ae9cd8abd6da28c7dfbb19631c5699e08ecbb066..8b323134519e270f60635f2c23cca67dee85737e 100644 (file)
--- a/src/map.s
+++ b/src/map.s
 
   ; 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
index 40fe54f7bacea0607be66c5adb9ac49374ecd59d..60d9786e8aa3590d0b31ba61e8f2a9710a697b0c 100644 (file)
@@ -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
index 9451b3be5b5733a8beadd0a54179d2025e8184e1..72cca69b653c83bf0dbc391a9ac25ab8e7311422 100644 (file)
@@ -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
index 46a862dc73cecaa261eeaaaef1eb0f1ae07f8ae4..c7248d4fd7e482ba0073c3dc7d85a7b049ed63e0 100755 (executable)
@@ -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)