map: Added proof of concept for linking rooms in ram
authorLukas Krickl <lukas@krickl.dev>
Tue, 31 Dec 2024 16:19:21 +0000 (17:19 +0100)
committerLukas Krickl <lukas@krickl.dev>
Tue, 31 Dec 2024 16:19:21 +0000 (17:19 +0100)
src/map.s

index 2558ad2366007fd24a71e3dc2329d7e26e27b95c..d00b28018898b493ff34a30473ab612198d0071a 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -505,7 +505,10 @@ map_gen_next:
   push hl
 
   ; load base room ptr
-  ; TODO we are simply loading base_room_header every time 
+
+  ; TODO begin test
+  ; TODO we are simply loading base_room_header every time
+  ; TODO for now we are just copying room1 and room2 and linking them
   ld hl, base_room_table
   ld a, [hl+]
   ld e, a
@@ -516,7 +519,42 @@ map_gen_next:
   ; now we copy
   push hl ; save original ptr for now
   call map_gen_copy_base_room
-  pop hl 
+  ; hl = next room 
+  push hl
+  pop bc ; bc = next room ptr
+  pop hl
+
+  ; set up link to room 2 
+  ld de, room_exit_table 
+  add hl, de ; hl = exit table ptr 
+  ld a, [hl+]
+  ld e, a
+  ld a, [hl]
+  ld d, a 
+
+  ; de = NORTH exit
+
+  ; store bc in north exit 
+  ld a, c
+  ld [de], a
+  inc de
+  ld a, b
+  ld [de], a
+
+  push bc
+
+  ; load base room from table
+  ld hl, base_room_table
+  ld de, 2
+  add hl, de ; hl = second room entry
+  ld a, [hl+]
+  ld e, a
+  ld a, [hl]
+  ld d, a
+  pop hl ; hl = next room ptr again
+  call map_gen_copy_base_room
+
+  ; TODO end test 
 
   ; select a direction to walk into and call again 
   ; and set up pointers