mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Add anchor points to support manual movement between spaces (#26)
This commit is contained in:
parent
8b9d731c5c
commit
6613cd5386
@ -107,6 +107,7 @@ DEF NUM_PLAYER_MOVEMENTS EQU const_value
|
|||||||
DEF SCENE_SCRIPT_SIZE EQU 4 ; scene_script
|
DEF SCENE_SCRIPT_SIZE EQU 4 ; scene_script
|
||||||
DEF CALLBACK_SIZE EQU 3 ; callback
|
DEF CALLBACK_SIZE EQU 3 ; callback
|
||||||
DEF WARP_EVENT_SIZE EQU 5 ; warp_event
|
DEF WARP_EVENT_SIZE EQU 5 ; warp_event
|
||||||
|
DEF ANCHOR_EVENT_SIZE EQU 3 ; anchor_event
|
||||||
DEF COORD_EVENT_SIZE EQU 8 ; coord_event
|
DEF COORD_EVENT_SIZE EQU 8 ; coord_event
|
||||||
DEF BG_EVENT_SIZE EQU 5 ; bg_event
|
DEF BG_EVENT_SIZE EQU 5 ; bg_event
|
||||||
; An object_event is a map_object without its initial MAPOBJECT_OBJECT_STRUCT_ID or final padding
|
; An object_event is a map_object without its initial MAPOBJECT_OBJECT_STRUCT_ID or final padding
|
||||||
|
@ -3,6 +3,14 @@ DEF FIRST_SPACE_METATILE EQU $80
|
|||||||
DEF FIRST_GREY_SPACE_METATILE EQU $e0
|
DEF FIRST_GREY_SPACE_METATILE EQU $e0
|
||||||
DEF UNIQUE_SPACE_METATILES_MASK EQU %11111
|
DEF UNIQUE_SPACE_METATILES_MASK EQU %11111
|
||||||
|
|
||||||
|
; reserved next space values that signal movement towards anchor point rather than towards space
|
||||||
|
const_def -1, -1
|
||||||
|
const GO_DOWN ; 255
|
||||||
|
const GO_UP ; 254
|
||||||
|
const GO_LEFT ; 253
|
||||||
|
const GO_RIGHT ; 252
|
||||||
|
DEF NEXT_SPACE_IS_ANCHOR_POINT EQU const_value + 1
|
||||||
|
|
||||||
; Branch Space special direction values
|
; Branch Space special direction values
|
||||||
DEF BRANCH_DIRECTION_INVALID EQU -1
|
DEF BRANCH_DIRECTION_INVALID EQU -1
|
||||||
DEF BRANCH_DIRECTION_UNAVAILABLE EQU -2
|
DEF BRANCH_DIRECTION_UNAVAILABLE EQU -2
|
Binary file not shown.
@ -1,5 +1,7 @@
|
|||||||
StepTowardsNextSpace::
|
StepTowardsNextSpace::
|
||||||
ld a, [wCurSpaceNextSpace]
|
ld a, [wCurSpaceNextSpace]
|
||||||
|
cp NEXT_SPACE_IS_ANCHOR_POINT
|
||||||
|
jr nc, .move_towards_anchor_point
|
||||||
call LoadTempSpaceData
|
call LoadTempSpaceData
|
||||||
ld a, [wTempSpaceXCoord]
|
ld a, [wTempSpaceXCoord]
|
||||||
ld c, a
|
ld c, a
|
||||||
@ -27,3 +29,19 @@ StepTowardsNextSpace::
|
|||||||
.done
|
.done
|
||||||
ld [wCurInput], a
|
ld [wCurInput], a
|
||||||
ret
|
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
|
||||||
|
@ -357,6 +357,32 @@ CheckBoardEvent:
|
|||||||
.board
|
.board
|
||||||
call CheckSpaceEffectsScriptFlag
|
call CheckSpaceEffectsScriptFlag
|
||||||
jr z, .no_space_effect
|
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]
|
ld a, [wPlayerTile]
|
||||||
and $f0
|
and $f0
|
||||||
cp HI_NYBBLE_SPACES
|
cp HI_NYBBLE_SPACES
|
||||||
|
74
home/map.asm
74
home/map.asm
@ -244,12 +244,12 @@ GetDestinationWarpNumber::
|
|||||||
ld a, [wPlayerMapX]
|
ld a, [wPlayerMapX]
|
||||||
sub 4
|
sub 4
|
||||||
ld d, a
|
ld d, a
|
||||||
ld a, [wCurMapWarpCount]
|
ld a, [wCurMapWarpEventCount]
|
||||||
and a
|
and a
|
||||||
ret z
|
ret z
|
||||||
|
|
||||||
ld c, a
|
ld c, a
|
||||||
ld hl, wCurMapWarpsPointer
|
ld hl, wCurMapWarpEventsPointer
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld h, [hl]
|
ld h, [hl]
|
||||||
ld l, a
|
ld l, a
|
||||||
@ -282,7 +282,7 @@ GetDestinationWarpNumber::
|
|||||||
call .IncreaseHLTwice
|
call .IncreaseHLTwice
|
||||||
ret nc ; never encountered
|
ret nc ; never encountered
|
||||||
|
|
||||||
ld a, [wCurMapWarpCount]
|
ld a, [wCurMapWarpEventCount]
|
||||||
inc a
|
inc a
|
||||||
sub c
|
sub c
|
||||||
ld c, a
|
ld c, a
|
||||||
@ -309,7 +309,7 @@ CopyWarpData::
|
|||||||
|
|
||||||
.CopyWarpData:
|
.CopyWarpData:
|
||||||
push bc
|
push bc
|
||||||
ld hl, wCurMapWarpsPointer
|
ld hl, wCurMapWarpEventsPointer
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld h, [hl]
|
ld h, [hl]
|
||||||
ld l, a
|
ld l, a
|
||||||
@ -390,7 +390,8 @@ ReadMapEvents::
|
|||||||
ld l, a
|
ld l, a
|
||||||
inc hl
|
inc hl
|
||||||
inc hl
|
inc hl
|
||||||
call ReadWarps
|
call ReadWarpEvents
|
||||||
|
call ReadAnchorEvents
|
||||||
call ReadCoordEvents
|
call ReadCoordEvents
|
||||||
call ReadBGEvents
|
call ReadBGEvents
|
||||||
|
|
||||||
@ -500,14 +501,14 @@ ReadMapCallbacks::
|
|||||||
call AddNTimes
|
call AddNTimes
|
||||||
ret
|
ret
|
||||||
|
|
||||||
ReadWarps::
|
ReadWarpEvents::
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld c, a
|
ld c, a
|
||||||
ld [wCurMapWarpCount], a
|
ld [wCurMapWarpEventCount], a
|
||||||
ld a, l
|
ld a, l
|
||||||
ld [wCurMapWarpsPointer], a
|
ld [wCurMapWarpEventsPointer], a
|
||||||
ld a, h
|
ld a, h
|
||||||
ld [wCurMapWarpsPointer + 1], a
|
ld [wCurMapWarpEventsPointer + 1], a
|
||||||
ld a, c
|
ld a, c
|
||||||
and a
|
and a
|
||||||
ret z
|
ret z
|
||||||
@ -515,6 +516,23 @@ ReadWarps::
|
|||||||
call AddNTimes
|
call AddNTimes
|
||||||
ret
|
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::
|
ReadCoordEvents::
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld c, a
|
ld c, a
|
||||||
@ -1783,6 +1801,44 @@ GetBlockLocation::
|
|||||||
add hl, bc
|
add hl, bc
|
||||||
ret
|
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::
|
CheckFacingBGEvent::
|
||||||
call GetFacingTileCoord
|
call GetFacingTileCoord
|
||||||
; Load facing into b.
|
; Load facing into b.
|
||||||
|
@ -56,11 +56,11 @@ HandleStoneQueue::
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.check_on_warp
|
.check_on_warp
|
||||||
ld hl, wCurMapWarpsPointer
|
ld hl, wCurMapWarpEventsPointer
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld h, [hl]
|
ld h, [hl]
|
||||||
ld l, a
|
ld l, a
|
||||||
ld a, [wCurMapWarpCount]
|
ld a, [wCurMapWarpEventCount]
|
||||||
and a
|
and a
|
||||||
jr z, .nope2
|
jr z, .nope2
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ HandleStoneQueue::
|
|||||||
.found_warp
|
.found_warp
|
||||||
pop af
|
pop af
|
||||||
ld d, a
|
ld d, a
|
||||||
ld a, [wCurMapWarpCount]
|
ld a, [wCurMapWarpEventCount]
|
||||||
sub d
|
sub d
|
||||||
inc a
|
inc a
|
||||||
scf
|
scf
|
||||||
|
@ -62,6 +62,21 @@ MACRO warp_event
|
|||||||
DEF {_NUM_WARP_EVENTS} += 1
|
DEF {_NUM_WARP_EVENTS} += 1
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
|
MACRO def_anchor_events
|
||||||
|
REDEF _NUM_ANCHOR_EVENTS EQUS "_NUM_ANCHOR_EVENTS_\@"
|
||||||
|
db {_NUM_ANCHOR_EVENTS}
|
||||||
|
DEF {_NUM_ANCHOR_EVENTS} = 0
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
MACRO anchor_event
|
||||||
|
;\1: x coord
|
||||||
|
;\2: y coord
|
||||||
|
;\3: next space
|
||||||
|
; there is no \4. An anchor point can't act as an space with an effect (neither as a branch space)
|
||||||
|
db \1, \2, \3
|
||||||
|
DEF {_NUM_ANCHOR_EVENTS} += 1
|
||||||
|
ENDM
|
||||||
|
|
||||||
MACRO def_coord_events
|
MACRO def_coord_events
|
||||||
REDEF _NUM_COORD_EVENTS EQUS "_NUM_COORD_EVENTS_\@"
|
REDEF _NUM_COORD_EVENTS EQUS "_NUM_COORD_EVENTS_\@"
|
||||||
db {_NUM_COORD_EVENTS}
|
db {_NUM_COORD_EVENTS}
|
||||||
|
@ -16,6 +16,8 @@ DebugLevel1_Map1_MapEvents:
|
|||||||
def_warp_events
|
def_warp_events
|
||||||
warp_event 7, 0, LEVEL_1_MAP_1, 1
|
warp_event 7, 0, LEVEL_1_MAP_1, 1
|
||||||
|
|
||||||
|
def_anchor_events
|
||||||
|
|
||||||
def_coord_events
|
def_coord_events
|
||||||
|
|
||||||
def_bg_events
|
def_bg_events
|
||||||
|
@ -10,6 +10,8 @@ DebugLevel2_Map1_MapEvents:
|
|||||||
|
|
||||||
def_warp_events
|
def_warp_events
|
||||||
|
|
||||||
|
def_anchor_events
|
||||||
|
|
||||||
def_coord_events
|
def_coord_events
|
||||||
|
|
||||||
def_bg_events
|
def_bg_events
|
||||||
|
@ -10,6 +10,8 @@ DebugLevel3_Map1_MapEvents:
|
|||||||
|
|
||||||
def_warp_events
|
def_warp_events
|
||||||
|
|
||||||
|
def_anchor_events
|
||||||
|
|
||||||
def_coord_events
|
def_coord_events
|
||||||
|
|
||||||
def_bg_events
|
def_bg_events
|
||||||
|
@ -10,6 +10,8 @@ DebugLevel4_Map1_MapEvents:
|
|||||||
|
|
||||||
def_warp_events
|
def_warp_events
|
||||||
|
|
||||||
|
def_anchor_events
|
||||||
|
|
||||||
def_coord_events
|
def_coord_events
|
||||||
|
|
||||||
def_bg_events
|
def_bg_events
|
||||||
|
@ -10,6 +10,10 @@ DebugLevel5_Map1_MapEvents:
|
|||||||
|
|
||||||
def_warp_events
|
def_warp_events
|
||||||
|
|
||||||
|
def_anchor_events
|
||||||
|
anchor_event 10, 1, GO_RIGHT
|
||||||
|
anchor_event 12, 1, 39
|
||||||
|
|
||||||
def_coord_events
|
def_coord_events
|
||||||
|
|
||||||
def_bg_events
|
def_bg_events
|
||||||
@ -58,7 +62,7 @@ DebugLevel5_Map1_MapSpaces:
|
|||||||
space 6, 2, $0, 36 ; 35
|
space 6, 2, $0, 36 ; 35
|
||||||
space 6, 0, $0, 37 ; 36
|
space 6, 0, $0, 37 ; 36
|
||||||
space 8, 0, $0, 38 ; 37
|
space 8, 0, $0, 38 ; 37
|
||||||
space 10, 0, $0, 39 ; 38
|
space 10, 0, $0, GO_DOWN ; 38
|
||||||
space 12, 0, $0, 40 ; 39
|
space 12, 0, $0, 40 ; 39
|
||||||
space 14, 0, $0, 41 ; 40
|
space 14, 0, $0, 41 ; 40
|
||||||
space 16, 0, $0, 42 ; 41
|
space 16, 0, $0, 42 ; 41
|
||||||
|
@ -1 +1 @@
|
|||||||
€Ã€°Â<EFBFBD>°¡ÿ€~€°Ã¡±¡¡¡Ã€€°€À<02>¡°Á€€€Â°Ã<C2B0>¡±¡¡
|
€Ã„°Â<EFBFBD>°¡ÿ€~€°Ã¡±¡¡¡Ã€€°€À<02>¡°Á€€€Â°Ã<C2B0>¡±¡¡
|
@ -1 +0,0 @@
|
|||||||
555$%
|
|
@ -16,6 +16,8 @@ Level1_Map1_MapEvents:
|
|||||||
def_warp_events
|
def_warp_events
|
||||||
warp_event 7, 0, LEVEL_1_MAP_1, 1
|
warp_event 7, 0, LEVEL_1_MAP_1, 1
|
||||||
|
|
||||||
|
def_anchor_events
|
||||||
|
|
||||||
def_coord_events
|
def_coord_events
|
||||||
|
|
||||||
def_bg_events
|
def_bg_events
|
||||||
|
13
ram/wram.asm
13
ram/wram.asm
@ -1597,6 +1597,13 @@ wElevatorPointer:: dw
|
|||||||
wElevatorOriginFloor:: db
|
wElevatorOriginFloor:: db
|
||||||
wElevatorDataEnd::
|
wElevatorDataEnd::
|
||||||
|
|
||||||
|
NEXTU
|
||||||
|
; anchor event data
|
||||||
|
wCurAnchorEvent::
|
||||||
|
wCurAnchorEventXCoord:: db
|
||||||
|
wCurAnchorEventYCoord:: db
|
||||||
|
wCurAnchorEventNextSpace:: db
|
||||||
|
|
||||||
NEXTU
|
NEXTU
|
||||||
; coord event data
|
; coord event data
|
||||||
wCurCoordEvent::
|
wCurCoordEvent::
|
||||||
@ -2434,8 +2441,10 @@ wBikeFlags::
|
|||||||
wCurMapSceneScriptPointer:: dw
|
wCurMapSceneScriptPointer:: dw
|
||||||
|
|
||||||
wCurCaller:: dw
|
wCurCaller:: dw
|
||||||
wCurMapWarpCount:: db
|
wCurMapWarpEventCount:: db
|
||||||
wCurMapWarpsPointer:: dw
|
wCurMapWarpEventsPointer:: dw
|
||||||
|
wCurMapAnchorEventCount:: db
|
||||||
|
wCurMapAnchorEventsPointer:: dw
|
||||||
wCurMapCoordEventCount:: db
|
wCurMapCoordEventCount:: db
|
||||||
wCurMapCoordEventsPointer:: dw
|
wCurMapCoordEventsPointer:: dw
|
||||||
wCurMapBGEventCount:: db
|
wCurMapBGEventCount:: db
|
||||||
|
Loading…
Reference in New Issue
Block a user