Add anchor points to support manual movement between spaces (#26)

This commit is contained in:
xCrystal
2023-11-16 17:20:13 +01:00
parent 8b9d731c5c
commit 6613cd5386
17 changed files with 164 additions and 18 deletions

View File

@@ -1,5 +1,7 @@
StepTowardsNextSpace::
ld a, [wCurSpaceNextSpace]
cp NEXT_SPACE_IS_ANCHOR_POINT
jr nc, .move_towards_anchor_point
call LoadTempSpaceData
ld a, [wTempSpaceXCoord]
ld c, a
@@ -27,3 +29,19 @@ StepTowardsNextSpace::
.done
ld [wCurInput], a
ret
.move_towards_anchor_point
ld c, D_DOWN
cp GO_DOWN
jr z, .done2
ld c, D_UP
cp GO_UP
jr z, .done2
ld c, D_LEFT
cp GO_LEFT
jr z, .done2
ld c, D_RIGHT
.done2
ld a, c
ld [wCurInput], a
ret

View File

@@ -357,6 +357,32 @@ CheckBoardEvent:
.board
call CheckSpaceEffectsScriptFlag
jr z, .no_space_effect
; anchor point handler
; if wCurSpaceNextSpace is not an anchor point, override any anchor point we pass though
ld a, [wCurSpaceNextSpace]
cp NEXT_SPACE_IS_ANCHOR_POINT
jr c, .next
ld a, [wCurMapAnchorEventCount]
and a
jr z, .next
; if we have arrived to an anchor point, load its associated next space to wCurSpaceNextSpace right now.
; don't queue a script so that it happens transparently from the point of view of the player's movement.
; note that the next space of an anchor point could be another anchor point.
ld c, a
ld hl, wCurMapAnchorEventsPointer
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wXCoord]
ld d, a
ld a, [wYCoord]
ld e, a
call CheckAndApplyAnchorPoint
ret nc ; if we applied an anchor point, we're done here (we're not in a space)
.next
; space handler
ld a, [wPlayerTile]
and $f0
cp HI_NYBBLE_SPACES