Create BOARDEVENT_END_TURN as a transition between turns after landing on space (#25)

This commit is contained in:
xCrystal 2023-10-14 21:45:48 +02:00
parent b9ac41feb6
commit 7448da8380
3 changed files with 34 additions and 8 deletions

View File

@ -328,4 +328,5 @@ DEF NUM_UNOWN_PUZZLES EQU const_value
const_def 1 const_def 1
const BOARDEVENT_DISPLAY_MENU ; 1 const BOARDEVENT_DISPLAY_MENU ; 1
const BOARDEVENT_HANDLE_BOARD ; 2 const BOARDEVENT_HANDLE_BOARD ; 2
const BOARDEVENT_END_TURN ; 3
DEF NUM_BOARD_EVENTS EQU const_value - 1 DEF NUM_BOARD_EVENTS EQU const_value - 1

View File

@ -2,20 +2,23 @@ BoardSpaceScripts:: ; used only for BANK(BoardSpaceScripts)
BlueSpaceScript:: BlueSpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .done iftrue .not_landed
.done scall LandedInRegularSpaceScript
.not_landed
end end
RedSpaceScript:: RedSpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .done iftrue .not_landed
.done scall LandedInRegularSpaceScript
.not_landed
end end
GreySpaceScript:: GreySpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .done iftrue .not_landed
.done scall LandedInRegularSpaceScript
.not_landed
end end
ArriveToRegularSpaceScript: ArriveToRegularSpaceScript:
@ -33,3 +36,12 @@ ArriveToRegularSpace:
ld hl, wDisplaySecondarySprites ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_SPACES_LEFT_F, [hl] res SECONDARYSPRITES_SPACES_LEFT_F, [hl]
ret ret
LandedInRegularSpaceScript:
callasm LandedInRegularSpace
end
LandedInRegularSpace:
ld a, BOARDEVENT_END_TURN
ldh [hCurBoardEvent], a
ret

View File

@ -266,7 +266,7 @@ PlayerEvents:
call CheckBoardEvent call CheckBoardEvent
jr c, .ok jr c, .ok
call CheckTrainerBattle_GetPlayerEvent call CheckTrainerEvent
jr c, .ok jr c, .ok
call CheckTileEvent call CheckTileEvent
@ -281,6 +281,18 @@ PlayerEvents:
call CheckTimeEvents call CheckTimeEvents
jr c, .ok jr c, .ok
; BOARDEVENT_END_TURN is used as turn cleanup after BOARDEVENT_HANDLE_BOARD.
; when we make it here, it means there's finally nothing else to do (e.g. a trainer),
; so return with BOARDEVENT_DISPLAY_MENU for the next MapEvents iteration.
ldh a, [hCurBoardEvent]
cp BOARDEVENT_END_TURN
jr nz, .continue
ld a, BOARDEVENT_DISPLAY_MENU
ldh [hCurBoardEvent], a
xor a
ret
.continue
call OWPlayerInput call OWPlayerInput
jr c, .ok jr c, .ok
@ -305,6 +317,7 @@ CheckBoardEvent:
dw .none dw .none
dw .menu ; BOARDEVENT_DISPLAY_MENU dw .menu ; BOARDEVENT_DISPLAY_MENU
dw .board ; BOARDEVENT_HANDLE_BOARD dw .board ; BOARDEVENT_HANDLE_BOARD
dw .none ; BOARDEVENT_END_TURN
assert_table_length NUM_BOARD_EVENTS + 1 assert_table_length NUM_BOARD_EVENTS + 1
.none .none
@ -352,7 +365,7 @@ CheckBoardEvent:
dw GreySpaceScript ; COLL_GREY_SPACE dw GreySpaceScript ; COLL_GREY_SPACE
assert_table_length NUM_COLL_SPACES assert_table_length NUM_COLL_SPACES
CheckTrainerBattle_GetPlayerEvent: CheckTrainerEvent:
call CheckTrainerBattle call CheckTrainerBattle
jr nc, .nope jr nc, .nope