You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-12-11 05:02:16 -08:00
7.0 KiB
Executable File
7.0 KiB
Executable File
Overworld workflow
OverworldLoopis called fromGameMenu_Worldwith eitherhMapEntryMethod=MAPSETUP_ENTERLEVELorhMapEntryMethod=MAPSETUP_CONTINUE.StartMapresetswCurTurnandwCurSpaceifMAPSETUP_ENTERLEVEL.StartMapsetshCurBoardEventtoBOARDEVENT_DISPLAY_MENU.wEnabledPlayerEventsis cleared.wMapStatusis set toMAPSTATUS_HANDLEcausingHandleMapto be called.MapEvents(fromHandleMap) callsPlayerEvents.CheckBoardEventqueuesBoardMenuScriptwhich is executed byScriptEvents.BoardMenuScript.Upkeepsaves the game, clearswTurnData[], increaseswCurTurn, and loads current space towCurSpaceStruct[].- If player exits, the
exitoverworldscript setswMapStatustoMAPSTATUS_DONE. This causesOverworldLoopto return back to the game menu. Exit this workflow.
- If player exits, the
- Player rolls die and the animation plays. After the animation,
wDisplaySecondarySprites.SECONDARYSPRITES_SPACES_LEFT_Fis set andhCurBoardEventis set toBOARDEVENT_HANDLE_BOARD. At the end of thisHandleMapiteration,CheckPlayerStatesetswMapEventStatustoMAPEVENTS_ON(wEnabledPlayerEventsis not touched so it remains cleared). - In the next
HandleMapiteration,CheckBoardEventfromPlayerEventsjumps to.boardand then to.no_space_effectdue towEnabledPlayerEvents[4]not being set. - Execution continues in
PlayerEvents;OWPlayerInputis eventually called, and thusDoPlayerMovement. Here,StepTowardsNextSpacecomputes based onwCurSpaceNextSpacewhat direction key to write towCurInput, causing the player to begin a movement in that direction. - The player may need to turn to a different direction through the
ChangeDirectionScript(whenDoPlayerMovementreturns withPLAYERMOVEMENT_TURN). Otherwise or after that,CheckPlayerStatesetswMapEventStatustoMAPEVENTS_OFF, - When the step finishes (i.e.
PLAYERSTEP_STOP_Fbecomes set) in someHandleMapiteration,CheckPlayerStatesetswEnabledPlayerEventsto $ff andwMapEventStatustoMAPEVENTS_ON. - In the next
HandleMapiteration,CheckBoardEvent.boardis called withwEnabledPlayerEvents[4]set.- If
wCurSpaceNextSpacematchesNEXT_SPACE_IS_ANCHOR_POINT: If player is at a tile with an anchor event,wCurSpaceNextSpaceis updated with the next space byte of salid anchor event.wEnabledPlayerEvents[4]is reset. Go back to 7. - If player is not above a tile (
wPlayerTileCollision) with a space collision:wEnabledPlayerEvents[4]is reset. Go back to 7. - If player is above a tile, the corresponding space script is queued to be executed by
ScriptEventsin the currentHandleMapiteration.wEnabledPlayerEvents[4]is reset. Continue to 11.
- If
- The space script loads the value of
wCurSpaceNextSpaceintowCurSpace, and loads the new space data towCurSpaceStruct[]. Unless the space is a Branch Space or a Union Space,wSpacesLeftis decreased.- If the space is a Branch Space, the branch data is loaded to
wTempSpaceBranchStruct. Then the player is prompted to choose a valid direction.wCurSpaceNextSpaceis populated with the next space that corresponds to the chosen direction. Go back to 6. - If the space is an End Space, a fading out animation plays and then the
exitoverworldscript setswMapStatustoMAPSTATUS_DONE. This causesOverworldLoopto return back to the game menu. Exit this workflow.
- If the space is a Branch Space, the branch data is loaded to
- If
wSpacesLeftis non-0, go back to 6. - The script code specific to the space type of the landed-on space is executed.
- If player whites out in battle,
Script_BattleWhiteoutexecutesexitoverworld. Exit this workflow.
- If player whites out in battle,
- The landed-on space is disabled by executing a block change that converts it into a Grey Space.
hCurBoardEventis set toBOARDEVENT_END_PLAYER_TURN.CheckBoardEventdoes nothing in this state. In the first subsequentHandleMapiteration where no other kind of event triggers causingPlayerEventsto return early,hCurBoardEventis set toBOARDEVENT_DISPLAY_MENU. - Go back to 3
View Map mode workflow
- Pressing SELECT in the board menu triggers View Map mode.
hCurBoardEventis set toBOARDEVENT_VIEW_MAP_MODE, player state (coordinates as well as current map in order to support connected maps) is backed up,wPlayerFlags[INVISIBLE_F]is set, and a static mockup of the player object is loaded to the lastwMapObjectand, in the background, to the firstwObjectStructis available. - The board event handler in
CheckBoardEventlistens for the B button being pressed (except when a DPAD key is simultaneously held). When B is pressed, a script (a singlereloadmapafterviewmapmode) to exit from View Map mode is queued to be executed byScriptEvents. Otherwise,DoPlayerMovement.ViewMapModehandles movement input in this mode. - When requested exit of View Map mode via B button,
reloadmapafterviewmapmodesetshMapEntryMethodtoMAPSETUP_EXITVIEWMAP,hMapEntryMethodtoSPAWN_FROM_RAM(required by the map setup commandEnterMapSpawnPointto restore the backed up player state), loadsMAPSTATUS_ENTERtpwMapStatus, and resetswPlayerFlags[INVISIBLE_F](the mocked player object naturally disappears when the map reloads). - Then:
a) If View Map mode was entered from the board menu,
BOARDEVENT_REDISPLAY_MENUis loaded. It is the same asBOARDEVENT_DISPLAY_MENUbut skipsBoardMenuScript.Upkeep. b) If View Map mode was entered from the branch menu, insteadBOARDEVENT_RESUME_BRANCHis loaded, usingwPlayerSpriteSetupFlags[PLAYERSPRITESETUP_CUSTOM_FACING_F]to maintain the facing direction according to the direction (SPRITEMOVEDATA_*) of the mocked player object.BOARDEVENT_RESUME_BRANCHmakes sure to shortcut the branch space script by callingBranchSpaceScript_PromptPlayerdirectly and avoiding the recomputation of the branch struct that would cause corruption.BOARDEVENT_HANDLE_BOARDis loaded immediately byBOARDEVENT_RESUME_BRANCH.
- In View Map mode, regular collisions except for
COLL_OUT_OF_BOUNDSare ignored whereas going off-limits (i.e. outside of the map limits in a direction where there is no connected map) or off-range is accounted for. - Events other than warpless connections are ignored in View Map mode (as well as button actions, like while in
BOARDEVENT_HANDLE_BOARD). wTileDown,wTileUp, etc., otherwise unused, are borrowed by in order to signal valid directions toInitSecondarySprites(e.g.wTileDown=COLL_OUT_OF_BOUNDSmeans that DOWN direction is not valid).- In View Map mode, the overworld delay is 1 rather than 2.
UpdatePlayerCoordstracks the displacement during View Map mode in the X and Y axes in order to monitor the allowed range.