From 9aad2e9db41e124aef40f6b14a0c6b517688503d Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 25 Jan 2025 11:55:03 +0100 Subject: [PATCH] map: Added the ability to have branching paths in rooms This is simply done by following door pointers when a direction with an existing door is picked. --- src/map.s | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/map.s b/src/map.s index 5849584..dbd8d3d 100644 --- a/src/map.s +++ b/src/map.s @@ -557,10 +557,10 @@ map_gen_next: ; if not done link to next room pop de ; de = previous room ptr - push de ; save it again ; for now just pick a direction call map_gen_pick_direction + push de ; save it again push hl call map_gen_link_rooms @@ -650,8 +650,22 @@ map_gen_pick_direction: add a, e ; this must be 0 pop de ; get de back before jumping :^) cp a, 0 - jr nz, @again REL + jr z, @good_pick REL + + ; if it was not a good pick we + ; move the room ptr from [hl] to de + dec hl ; hl = exit ptr + ld a, [hl+] + ld e, a + ld a, [hl] + ld d, a + ; fix value on the stack + pop bc + push de + + jr @again REL +@good_pick: ; get original result ld a, [tmp] -- 2.30.2