From 3a75831e5b9a3bc018ddf07aef290e754720ee99 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 1 Jan 2025 12:14:10 +0100 Subject: [PATCH] map: room linking is now generic --- src/map.s | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/src/map.s b/src/map.s index 288a251..20f004c 100644 --- a/src/map.s +++ b/src/map.s @@ -500,8 +500,8 @@ map_generate: ; a: 0 == stop recursion ; a: 1 == continue recurions map_gen_next: - push hl ; save current room push de ; save previous room + push hl ; save current room ; depth ++ ld a, [mapgen_depth] @@ -511,7 +511,6 @@ map_gen_next: ; select a room ; and copy it to the current position ; linking back NULL on all exits initially - push hl ; load base room ptr @@ -524,43 +523,29 @@ map_gen_next: ld a, [hl] ld d, a pop hl ; hl = room dst + push hl ; now we copy - push hl ; save original ptr for now call map_gen_copy_base_room ; hl = next room + pop de ; de = previous room ptr + push de ; save it again + ld a, SOUTH ; link south for now 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 + call map_gen_link_rooms - push bc - - ; load base room from table ld hl, base_room_table - ld de, 2 - add hl, de ; hl = second room entry + ld b, 0 + ld c, 2 ; add 2 to load next base room + add hl, bc + ld a, [hl+] ld e, a ld a, [hl] ld d, a - pop hl ; hl = next room ptr again + + pop hl + call map_gen_copy_base_room ; TODO end test @@ -580,8 +565,8 @@ map_gen_next: ld [mapgen_depth], a ; pop saved registers - pop de pop hl + pop de ret -- 2.30.2