Alchemy
Loading...
Searching...
No Matches

scene.c File Reference

Scene changes: exits, returns from battle, the main loop, entering. More...

Go to the source code of this file.

Macros

#define EXIT_SCENE_MASK   0xfff
#define EXIT_ENTRANCE(word)
#define EXIT_KIND(word)
#define EXIT_HAS_FLAG   0x10000000
#define EXIT_TABLE_END   0x1ff
#define EXIT_KIND_ANY   0xff
#define SCENE_RECORD(id)

Enumerations

enum  { MINIGAME_PALETTE_FIRST = 14 , MINIGAME_PALETTE_BYTES = 64 }
 The minigames borrow the final two 16-colour background palettes. More...

Functions

void Scene_TakeExit (s32 exitKind)
 Chooses the scene and entrance to go to when the party leaves the current scene.
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).
s32 BattleFx_GetResourceGroup (s32 scene)
 Returns the group scene belongs to.
static __inline__ s32 RunLuckyDice (s32 entrance)
 Runs the Lucky Dice minigame, preserving BG palettes 14 and 15.
static __inline__ s32 RunReelGame (s32 entrance)
 Runs the slot machine, preserving BG palettes 14 and 15.
void Game_ResetForNewGame (s32 mode)
 The game's main loop, which never returns.
void Scene_LoadOverlay (s32 unused)
 Loads the current scene's overlay code (its resource) into gOverlayArea.
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.
void Audio_PlayCueFromEventWork (void)
 Starts the current scene's field music, chosen by Scene_ResolveInteractionResult.

Detailed Description

Scene changes: exits, returns from battle, the main loop, entering.

Part of object.c, the field object, compiled only through it.

Definition in file scene.c.

Macro Definition Documentation

◆ EXIT_SCENE_MASK

#define EXIT_SCENE_MASK   0xfff

Definition at line 11 of file scene.c.

Referenced by Scene_TakeExit().

◆ EXIT_ENTRANCE

#define EXIT_ENTRANCE ( word)
Value:
(((word) & 0xff000) >> 12)

Definition at line 12 of file scene.c.

Referenced by Scene_TakeExit().

◆ EXIT_KIND

#define EXIT_KIND ( word)
Value:
(((word) & 0x0ff00000) >> 20)

Definition at line 13 of file scene.c.

Referenced by Scene_TakeExit().

◆ EXIT_HAS_FLAG

#define EXIT_HAS_FLAG   0x10000000

Definition at line 14 of file scene.c.

Referenced by Scene_TakeExit().

◆ EXIT_TABLE_END

#define EXIT_TABLE_END   0x1ff

Definition at line 15 of file scene.c.

Referenced by Scene_TakeExit().

◆ EXIT_KIND_ANY

#define EXIT_KIND_ANY   0xff

Definition at line 16 of file scene.c.

Referenced by Scene_TakeExit().

◆ SCENE_RECORD

#define SCENE_RECORD ( id)
Value:
const struct SceneRecord gField_SceneTable[]

Definition at line 301 of file scene.c.

Referenced by Scene_ResetFlagsOnEnter().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

The minigames borrow the final two 16-colour background palettes.

Enumerator
MINIGAME_PALETTE_FIRST 
MINIGAME_PALETTE_BYTES 

Definition at line 161 of file scene.c.

Function Documentation

◆ 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.

Definition at line 25 of file scene.c.

Referenced by Game_ResetForNewGame(), and Scene_TakeExit().

◆ 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.

Definition at line 95 of file scene.c.

Referenced by Game_ResetForNewGame(), and Scene_ReturnFromBattle().

◆ 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.

Definition at line 156 of file scene.c.

Referenced by BattleFx_GetResourceGroup(), and Scene_GetAreaNameIndex().

◆ RunLuckyDice()

__inline__ s32 RunLuckyDice ( s32 entrance)
static

Runs the Lucky Dice minigame, preserving BG palettes 14 and 15.

Definition at line 164 of file scene.c.

Referenced by Game_ResetForNewGame(), and RunLuckyDice().

◆ RunReelGame()

__inline__ s32 RunReelGame ( s32 entrance)
static

Runs the slot machine, preserving BG palettes 14 and 15.

Definition at line 181 of file scene.c.

Referenced by Game_ResetForNewGame(), and RunReelGame().

◆ 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.

Definition at line 204 of file scene.c.

Referenced by Game_ResetForNewGame().

◆ 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.

Definition at line 294 of file scene.c.

Referenced by Game_ResetForNewGame(), and Scene_LoadOverlay().

◆ 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.

Definition at line 311 of file scene.c.

Referenced by Game_ResetForNewGame(), and Scene_ResetFlagsOnEnter().

◆ Audio_PlayCueFromEventWork()