From 0ff62d09cd5365b1d9a1bb074093aad16e42eaef Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 31 Dec 2024 17:19:21 +0100 Subject: [PATCH] map: Added proof of concept for linking rooms in ram --- src/map.s | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/map.s b/src/map.s index 2558ad2..d00b280 100644 --- 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 -- 2.30.2