WIP: room loader
authorLukas Krickl <lukas@krickl.dev>
Mon, 23 Dec 2024 13:46:51 +0000 (14:46 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 23 Dec 2024 13:46:51 +0000 (14:46 +0100)
src/map.s

index acd54c101daa757a0d024f29528551352f9168ae..fa030de106654b2692c294a57f06a085d8ea5fa4 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -110,6 +110,32 @@ room_goto_player_pos:
   ;   curr_room_exits: ptr to exits table
   ;   a: direction EAST, WEST, NORTH, SOUTH, EXIT_SPECIAL
 room_goto:
+
+  ; TODO: save current tables back 
+  ; TODO: weird oob reads when calling room_load_from
+
+  ld hl, curr_room_exits ; ptr to exit table 
+  ld a, [hl+]
+  ld c, a
+  ld a, [hl]
+  ld b, a ; bc = exit table 
+  
+  ld h, 0
+  ld l, a 
+  add hl, bc ; hl = exit table + exit direction
+
+  ; load room ptr into de
+  ld a, [hl+] 
+  ld d, a
+  ld a, [hl]
+  ld e, a
+
+  call room_load_from
+
+  ; its player's turn again
+  ld a, WHO_PLAYER
+  ld [who], a 
+
   ret
 
   ; loads actors from