# 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
; 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
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: