map: Added randomness to room linking to make sure all linking cases
authorLukas Krickl <lukas@krickl.dev>
Thu, 2 Jan 2025 14:15:31 +0000 (15:15 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 2 Jan 2025 14:15:31 +0000 (15:15 +0100)
work

BUGS.md
src/map.s

diff --git a/BUGS.md b/BUGS.md
index dd14ea8d19a72ffe3db56a3d90b154f9e26f561a..6700309df09f0543b5f015fe9161411ae0d2d373 100644 (file)
--- 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 
index b096b68d32320e94ff3e0d5b58ded0a4309ea068..9b8113bd2f2d03d5e8a25e290b4af072ca982ad7 100644 (file)
--- 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: