You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Add anchor points to support manual movement between spaces (#26)
This commit is contained in:
74
home/map.asm
74
home/map.asm
@@ -244,12 +244,12 @@ GetDestinationWarpNumber::
|
||||
ld a, [wPlayerMapX]
|
||||
sub 4
|
||||
ld d, a
|
||||
ld a, [wCurMapWarpCount]
|
||||
ld a, [wCurMapWarpEventCount]
|
||||
and a
|
||||
ret z
|
||||
|
||||
ld c, a
|
||||
ld hl, wCurMapWarpsPointer
|
||||
ld hl, wCurMapWarpEventsPointer
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
@@ -282,7 +282,7 @@ GetDestinationWarpNumber::
|
||||
call .IncreaseHLTwice
|
||||
ret nc ; never encountered
|
||||
|
||||
ld a, [wCurMapWarpCount]
|
||||
ld a, [wCurMapWarpEventCount]
|
||||
inc a
|
||||
sub c
|
||||
ld c, a
|
||||
@@ -309,7 +309,7 @@ CopyWarpData::
|
||||
|
||||
.CopyWarpData:
|
||||
push bc
|
||||
ld hl, wCurMapWarpsPointer
|
||||
ld hl, wCurMapWarpEventsPointer
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
@@ -390,7 +390,8 @@ ReadMapEvents::
|
||||
ld l, a
|
||||
inc hl
|
||||
inc hl
|
||||
call ReadWarps
|
||||
call ReadWarpEvents
|
||||
call ReadAnchorEvents
|
||||
call ReadCoordEvents
|
||||
call ReadBGEvents
|
||||
|
||||
@@ -500,14 +501,14 @@ ReadMapCallbacks::
|
||||
call AddNTimes
|
||||
ret
|
||||
|
||||
ReadWarps::
|
||||
ReadWarpEvents::
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
ld [wCurMapWarpCount], a
|
||||
ld [wCurMapWarpEventCount], a
|
||||
ld a, l
|
||||
ld [wCurMapWarpsPointer], a
|
||||
ld [wCurMapWarpEventsPointer], a
|
||||
ld a, h
|
||||
ld [wCurMapWarpsPointer + 1], a
|
||||
ld [wCurMapWarpEventsPointer + 1], a
|
||||
ld a, c
|
||||
and a
|
||||
ret z
|
||||
@@ -515,6 +516,23 @@ ReadWarps::
|
||||
call AddNTimes
|
||||
ret
|
||||
|
||||
ReadAnchorEvents::
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
ld [wCurMapAnchorEventCount], a
|
||||
ld a, l
|
||||
ld [wCurMapAnchorEventsPointer], a
|
||||
ld a, h
|
||||
ld [wCurMapAnchorEventsPointer + 1], a
|
||||
|
||||
ld a, c
|
||||
and a
|
||||
ret z
|
||||
|
||||
ld bc, ANCHOR_EVENT_SIZE
|
||||
call AddNTimes
|
||||
ret
|
||||
|
||||
ReadCoordEvents::
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
@@ -1783,6 +1801,44 @@ GetBlockLocation::
|
||||
add hl, bc
|
||||
ret
|
||||
|
||||
CheckAndApplyAnchorPoint::
|
||||
; c = [wCurMapAnchorEventCount] (non-0)
|
||||
; d = [wXCoord]
|
||||
; e = [wYCoord]
|
||||
; hl = [wCurMapAnchorEventsPointer]
|
||||
; if currently at coords of any anchor point, copy its next space byte to wCurSpaceNextSpace.
|
||||
; return carry if anchor point matched, nc otherwise.
|
||||
ldh a, [hROMBank]
|
||||
push af
|
||||
call SwitchToMapScriptsBank
|
||||
|
||||
.loop
|
||||
ld a, [hli]
|
||||
cp d ; x
|
||||
jr nz, .next1
|
||||
ld a, [hli]
|
||||
cp e ; y
|
||||
jr nz, .next2
|
||||
|
||||
; found anchor point in current player coords
|
||||
ld a, [hl]
|
||||
ld [wCurSpaceNextSpace], a
|
||||
pop af
|
||||
rst Bankswitch
|
||||
xor a
|
||||
ret
|
||||
|
||||
.next1
|
||||
inc hl
|
||||
.next2
|
||||
inc hl
|
||||
dec c
|
||||
jr nz, .loop
|
||||
pop af
|
||||
rst Bankswitch
|
||||
scf
|
||||
ret
|
||||
|
||||
CheckFacingBGEvent::
|
||||
call GetFacingTileCoord
|
||||
; Load facing into b.
|
||||
|
@@ -56,11 +56,11 @@ HandleStoneQueue::
|
||||
ret
|
||||
|
||||
.check_on_warp
|
||||
ld hl, wCurMapWarpsPointer
|
||||
ld hl, wCurMapWarpEventsPointer
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
ld a, [wCurMapWarpCount]
|
||||
ld a, [wCurMapWarpEventCount]
|
||||
and a
|
||||
jr z, .nope2
|
||||
|
||||
@@ -94,7 +94,7 @@ HandleStoneQueue::
|
||||
.found_warp
|
||||
pop af
|
||||
ld d, a
|
||||
ld a, [wCurMapWarpCount]
|
||||
ld a, [wCurMapWarpEventCount]
|
||||
sub d
|
||||
inc a
|
||||
scf
|
||||
|
Reference in New Issue
Block a user