Alchemy
Loading...
Searching...
No Matches

run_scene.c File Reference

Running a field scene until the party leaves it, and its entrance. More...

Go to the source code of this file.

Data Structures

struct  MenuCtrl
 The object system's work (struct ObjectSystemWork), seen as the flag that suspends sprite projection while the menu opens. More...
struct  Object
 A field actor (struct FieldActor), seen with its position as one vector. More...

Functions

s32 Field_RunScene (s32 entrance)
 Runs the current field scene, which the party entered by entrance, until it leaves; returns the exit kind it left by (for Scene_TakeExit), or 999 when the party fell outside battle.
s32 Object_GetTriggerTileAheadOfCurrent (void)
 Returns the collision code of the map cell 16 pixels ahead of the party leader when there is something to search there: a tile code from 242 to 247 whose ground is no more than 64 pixels above the leader, or a code the scene has a search event for.
void Scene_ApplyEntrance (void)
 Places the party at the entrance it came in by (the first matching entry, or the scene's first one) unless it keeps its position, and sets the map's scroll bounds, at least a screen (240 x 160 pixels) wide and tall.

Detailed Description

Running a field scene until the party leaves it, and its entrance.

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

Definition in file run_scene.c.

Function Documentation

◆ Field_RunScene()

s32 Field_RunScene ( s32 entrance)

Runs the current field scene, which the party entered by entrance, until it leaves; returns the exit kind it left by (for Scene_TakeExit), or 999 when the party fell outside battle.

Sets the scene up (map, actors, encounters, return points), runs its initialization, fades it in, then runs the field loop: the party walks (Field_ProcessStep each frame) until a request is made, and then the requests are handled until none is left.

Called from Game_ResetForNewGame's main loop for every field scene, which passes the result to Scene_TakeExit. Allocates the field work in heap slot 27 (HEAP_SLOT_EVENT) and frees it on the way out, sets gGameState's default, next and defeat destinations, and clears FLAG_IN_BATTLE and, once the scene has started, FLAG_KEEP_PARTY_POSITION.

Definition at line 26 of file run_scene.c.

Referenced by Field_RunScene(), and Game_ResetForNewGame().

◆ Object_GetTriggerTileAheadOfCurrent()

s32 Object_GetTriggerTileAheadOfCurrent ( void )

Returns the collision code of the map cell 16 pixels ahead of the party leader when there is something to search there: a tile code from 242 to 247 whose ground is no more than 64 pixels above the leader, or a code the scene has a search event for.

Returns 0 otherwise.

Called by Field_RunScene for the A button (a non-zero result becomes work->tile, for Field_SearchTile), and by Menu_RunTopSelection's search entry through Object_GetTriggerTileAheadOfCurrentFar. Changes nothing.

Definition at line 407 of file run_scene.c.

Referenced by Field_RunScene(), and Object_GetTriggerTileAheadOfCurrent().

◆ Scene_ApplyEntrance()

void Scene_ApplyEntrance ( void )

Places the party at the entrance it came in by (the first matching entry, or the scene's first one) unless it keeps its position, and sets the map's scroll bounds, at least a screen (240 x 160 pixels) wide and tall.

Called by Field_RunScene once the scene's events are set. Writes gGameState's position, heading and turn, and the map's minX to maxY.

Definition at line 461 of file run_scene.c.

Referenced by Field_RunScene(), and Scene_ApplyEntrance().