From fa312f81e4ba2ddc47fdf816aa544e9c392fd55b Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 2 Jan 2025 15:15:31 +0100 Subject: [PATCH] map: Added randomness to room linking to make sure all linking cases work --- BUGS.md | 5 +---- src/map.s | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/BUGS.md b/BUGS.md index dd14ea8..6700309 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,6 +1,3 @@ # Known Bugs -- When moving a player sometimes gains an extra pixel -- When loading a map sometimes a double load is caused -- When moving off-screen NORTH the movement behaves weird -- Map loads can occur when the player is moving off a door tile +- When rooms are linked it is possible to overwrite exits diff --git a/src/map.s b/src/map.s index b096b68..9b8113b 100644 --- a/src/map.s +++ b/src/map.s @@ -549,8 +549,15 @@ map_gen_next: ; if not done link to next room pop de ; de = previous room ptr - push de ; save it again - ld a, SOUTH ; link south for now + push de ; save it again + + ; for now just pick a direction + push hl + push de + call rand + pop de + pop hl + and a, 3 ; discard remaining bits push hl call map_gen_link_rooms @@ -711,15 +718,58 @@ map_gen_fix_room_door: cp a, EAST jr nz, @not_east REL - ; TODO + ld de, 39 + add hl, de ; go to door tile + + ld a, TEXIT1 + ld [hl], a + + push hl ; we need this again for flags + ld de, 10 + add hl, de ; next row + ld [hl], a + + pop hl + ; now set flags + + ld de, ROOM_TILES_SIZE + add hl, de ; hl = flags area + + ld a, RF_DOOR + ld [hl], a + ld de, 10 + add hl, de ; next row + ld [hl], a jp @done @not_east: cp a, WEST jr nz, @not_west REL - - ; TODO + + ld de, 30 + add hl, de ; go to door tile + + ld a, TEXIT1 + ld [hl], a + + push hl ; we need this again for flags + ld de, 10 + add hl, de ; next row + ld [hl], a + + pop hl + ; now set flags + + ld de, ROOM_TILES_SIZE + add hl, de ; hl = flags area + + ld a, RF_DOOR + ld [hl], a + ld de, 10 + add hl, de ; next row + ld [hl], a + ; no need to jp @done here @not_west: -- 2.30.2