pop de
ret
+
+ ; performs fix by checking if a tile
+ ; at a certain offset relative to a door
+ ; is a collider
+ ; inputs:
+ ; $1: the offset relative to the current map position
+ ; $2: the wall pattern to use if a collider is found
+ ; hl: map_ptr
+ ; a: pattern entry
+ ;
+ ; preserves:
+ ; hl, bc, de
+#macro mapgen_fix_door_fixup
+ push hl
+ push de
+
+ ; move left one tile
+ ; and check for colliders
+ ld de, ($1) & 0xFFFF
+ add hl, de
+ ; hl = tile to the left
+
+ inc hl ; go to flags
+ ld d, a ; store a for later
+ ld a, [hl]
+ and a, CF_COLLISION
+ ld a, d ; restore a's value
+
+ ; if not collider do not fix
+ jr z, @no_fix REL
+ ; otherwise load left wall into a
+ ld a, $2
+ @no_fix:
+
+ pop de
+ pop hl
+#endmacro
+
+
; fixed door tile if it is adjacent to
; a collider tile
; inputs:
@down_door:
ret
@left_door:
- push hl
- push de
-
- ; move left one tile
- ; and check for colliders
- ld de, (-c_size) & 0xFFFF
- add hl, de
- ; hl = tile to the left
-
- inc hl ; go to flags
- ld d, a ; store a for later
- ld a, [hl]
- and a, CF_COLLISION
- ld a, d ; restore a's value
-
- ; if not collider do not fix
- jr z, @no_left_fix REL
- ; otherwise load left wall into a
- ld a, RPLW
-
-@no_left_fix:
-
- pop de
- pop hl
-
+ mapgen_fix_door_fixup -c_size, RPLW
ret
@right_door:
+
+
ret