Removed test room loader code and replaced it with an actual memcpy call
authorLukas Krickl <lukas@krickl.dev>
Sun, 15 Dec 2024 10:00:21 +0000 (11:00 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 15 Dec 2024 10:00:21 +0000 (11:00 +0100)
The test loader for a hard coded room was still present in video init.
This lead to an incorrect assumption being made in the map converter.
Rooms are now loaded directly from the actual base struct.
The base struct now also always points to an empty room exit table.

maps/base_room.s
src/map.s
src/video.s
tools/tms2map.py

index a94d4c8593bb0a7372700b840712f544382d8e63..56d34664d4f01f9f1da196c29ae65098a323c03e 100644 (file)
@@ -1,8 +1,9 @@
  ; struct for  base_room
 base_room_struct:
-dwb base_room_bg
-dwb base_room_flags
-dwb base_room_actors
+dw base_room_bg
+dw base_room_flags
+dw base_room_actors
+dw room_empty_exits
 base_room_actors:
 .db  8
 .db  1 , 64 , 72 , 0
index 3e95fa0720da6ce2627bcb1ad6b95748eb781f97..675cfbd483ba85ab251f43322f5f945136100e7c 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -43,11 +43,20 @@ room_load_from:
   ; and then load the room 
   ld hl, curr_room_struct  
   ld bc, room_size
+  call memcpy
 
   call room_draw
   call room_load_actors
   ret
 
+  ; sets the current room
+  ; inputs:
+  ;   de: ptr to room struct
+  ; sets curr_room entries 
+  ; as expected by room loader 
+room_set_curr:
+  ret
+
   ; loads actors from 
   ; [curr_room_init_act] 
   ; into the active actor table 
@@ -295,3 +304,10 @@ room_get_flag_masked:
   ; this can be copied and modified 
   ; by the map gen
 #include "./maps/base_room.s"
+
+  ; exit table for empty exits 
+room_empty_exits:
+.db 0x00, 0x00
+.db 0x00, 0x00
+.db 0x00, 0x00
+.db 0x00, 0x00
index 60d9786e8aa3590d0b31ba61e8f2a9710a697b0c..035ce8c6a7f58a24edf405fdb23b53f60abb931a 100644 (file)
@@ -83,21 +83,6 @@ video_init:
 
 
   ; initial test map
-  ldlo a, base_room_bg 
-  ld [curr_room], a
-  ldhi a, base_room_bg
-  ld [curr_room+1], a
-  
-  ldlo a, base_room_flags 
-  ld [curr_room_flags], a
-  ldhi a, base_room_flags 
-  ld [curr_room_flags+1], a 
-
-  ldlo a, base_room_actors
-  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 
   
index 50e917720a6a344e797dc046f1753b7f69711783..f60d9fbaa8aaaddcd310efbc8f60a36a7227c5fe 100755 (executable)
@@ -43,9 +43,10 @@ def print_actor(atype, y, x, flags):
 def print_struct(name):
     print(" ; struct for ", name)
     print(name + "_struct:")
-    print("dwb " + name + '_bg')
-    print("dwb " + name + '_flags')
-    print("dwb " + name + '_actors')
+    print("dw " + name + '_bg')
+    print("dw " + name + '_flags')
+    print("dw " + name + '_actors')
+    print("dw room_empty_exits")
 
 def convert(src, name):
     tree = ET.parse(src)