scene.c
Scene changes: exits, returns from battle, the main loop, entering.
games/tbs/src/object/object/scene.c on GitHub
Scene changes: exits, returns from battle, the main loop, entering. Part of object.c, the field object, compiled only through it.
Functions
Scene_TakeExit
void Scene_TakeExit(s32 exitKind)
Chooses the scene and entrance to go to when the party leaves the current scene. exitKind is the kind of exit Field_RunScene ended on; the scene's exit table gives the first exit of that kind (or of any kind) whose flag, if it has one, is not set. An exit of kind 0 or the end of the scene's exits falls back to the scene of its first exit. Called by Game_ResetForNewGame with Field_RunScene's result; sets gGameState.scene and .entrance, and leaves them alone for EXIT_NONE or a scene with no header in the table.
Used by Game_ResetForNewGame.
Scene_ReturnFromBattle
void Scene_ReturnFromBattle(s32 result)
Chooses where the game continues after a battle or another scene that is not a field map (see Game_ResetForNewGame). result is that scene's result: -1 when the party was defeated, which revives the leader with 1 HP (and, with FLAG_CHILDHOOD, fully heals the first two characters) and returns to the defeat point, or to the last saved point when none is set. Any other result goes to the next scene the event set, or to the default scene with the party keeping its position (FLAG_KEEP_PARTY_POSITION). Called by Game_ResetForNewGame after each scene above SCENE_BLANK; stores result in gGameState.sceneChangeReason and sets gGameState.scene and .entrance.
Used by Game_ResetForNewGame.
BattleFx_GetResourceGroup
s32 BattleFx_GetResourceGroup(s32 scene)
Returns the group scene belongs to. The scenes of one place share a group, which selects their music, area name and the flags kept while inside it. Called by Scene_ResolveInteractionResult.
Used by Scene_GetAreaNameIndex.
RunLuckyDice
static __inline__ s32 RunLuckyDice(s32 entrance)
Runs the Lucky Dice minigame, preserving BG palettes 14 and 15.
Used by Game_ResetForNewGame.
RunReelGame
static __inline__ s32 RunReelGame(s32 entrance)
Runs the slot machine, preserving BG palettes 14 and 15.
Used by Game_ResetForNewGame.
Game_ResetForNewGame
void Game_ResetForNewGame(s32 mode)
The game's main loop, which never returns. mode chooses the first scene: 0 starts at the title screen with a fresh game state; in debug mode, 1 starts in Isaac's home in Vale and 2 at the clear screen. Each pass resets the runtime, then either runs a battle or minigame and picks the scene to return to, or loads a field scene's code, starts its music and runs it until the party takes an exit. Called with mode 0 through Game_ResetForNewGameFar by System_Initialize at power-on and by Game_Restart.
Scene_LoadOverlay
void Scene_LoadOverlay(s32 unused)
Loads the current scene's overlay code (its resource) into gOverlayArea. Called by Game_ResetForNewGame before Field_RunScene.
Used by Game_ResetForNewGame.
Scene_ResetFlagsOnEnter
void Scene_ResetFlagsOnEnter(s32 unused, s32 keep)
Updates the flags and state that last for one scene or one group of scenes, on entering the current scene. Unless keep is set (the party returns to where it was, as after a battle), the flags of the last scene are cleared, and on entering a new group so are the group's flags and step counters, the location name is shown and the entrance becomes the point Retreat returns to. Then the group's visited flag (0x180 + group) is set. Called by Game_ResetForNewGame before each field scene, with keep from FLAG_KEEP_PARTY_POSITION; sets gGameState.sceneGroup and .sceneVariant.
Used by Game_ResetForNewGame.
Audio_PlayCueFromEventWork
void Audio_PlayCueFromEventWork(void)
Starts the current scene's field music, chosen by Scene_ResolveInteractionResult. Called by Game_ResetForNewGame, and by 34 scene overlays through Audio_PlayCueFromEventWorkFar.
Used by AltmillerCave_MeetInvisibleBabi, AltmillerCave_RestoreBabiAndInviteParty, BabiPalace_MeetBabiAfterColosso, ColossoLogRollingStage_RunScriptedTransition, ColossoRiver_ShowRoundIntroduction, ColossoWall_ShowRoundStartLettering, Event_IodemQuestionsWoundedSoldiers, Event_MeetIvan, Event_MeetSaturosAndMenardi, Fuchin_LightDragonWithEye, Game_ResetForNewGame, Kalay_WatchTourGroupDeparture, KolimaForestBridge_WitnessForestCurse, KolimaForestTree_RejectHermesWater, Kolima_WitnessForestCurse, MercuryLighthouseAerie_AlexAppears, TolbiShipInteriors_DiscussLaunchingWithoutAnchor, VaultInteriors_DiscussMindReading.
Macros, without a comment: EXIT_SCENE_MASK, EXIT_ENTRANCE, EXIT_KIND, EXIT_HAS_FLAG, EXIT_TABLE_END, EXIT_KIND_ANY, SCENE_RECORD.