src/field/field_engine_run.c
The field engine: running a scene until the party leaves it, and its entrance. More…
Included by field_engine.c.
Macros
| Name | Description | |
|---|---|---|
#define | NIBBLE_LOW (value) ((value) & 15) | The two nibbles of a scene's attributes (gmFieldGetSceneAttributes). |
#define | NIBBLE_HIGH (value) (((value) >> 4) & 15) | |
#define | HAZARD_LIMIT_DEFAULT 16 | The hazard count's limit each scene starts with, in steps on hazard metatiles: the hazard deals its damage each time the count reaches it. |
#define | PLACE_MARKER_ON_FOOT (1 << 4) | A Teleport destination's map screen marker (WORLD_MAP_PLACE.markers' high nibble): 1 for a place the party walks to; 2 for Lemuria's, which it reaches aboard the ship. |
#define | PLACE_MARKER_ABOARD (2 << 4) | |
#define | PAUSE_MENU_VRAM_BLOCKS 136 | The sprite VRAM blocks the Pause menu needs free, or the field's sprites stop drawing while it runs. |
#define | MAP_ENTRANCE_ROW_BYTES 6 | A map entrance stream's row: the entrance, its x and z, and its flags byte. |
#define | MAP_ENTRANCE_FACING_MASK 15 | A map entrance's flags byte: the party's facing in sixteenths of a turn, then whether it stands 8 pixels up and whether the camera keeps the bounds it has. |
#define | MAP_ENTRANCE_RAISED (1 << 4) | |
#define | MAP_ENTRANCE_KEEP_BOUNDS (1 << 5) |
Functions
| Name | Description | |
|---|---|---|
Sint16 | gmFieldGetSceneAttributes (Sint32 scene) | Returns the scene's attributes, the last halfword of its ScenesWork row, which The Broken Seal leaves 0; the field engine splits it into two nibbles. |
Bool | fdLeaderStepOntoRope (void) | Hops the leader onto the nearest crossable rope node, to cross the rope (LEADER_MOVEMENT_ROPE); returns 0 when none is in reach. |
Bool | fdLeaderStepOffRope (void) | Hops the leader off a tied rope a metatile in the direction the pad holds, when that metatile is open; returns 0 otherwise. |
Bool | fdLeaderStepOntoTightrope (void) | Hops the leader onto the nearest crossable tightrope node (LEADER_MOVEMENT_TIGHTROPE); returns 0 when none is in reach. |
Bool | fdLeaderStepOffTightrope (void) | Hops the leader off a tightrope a metatile in the direction the pad holds, when that metatile is open; returns 0 otherwise. |
Sint32 | fdEngineRun (void) | The field engine: runs the current scene, which the party entered by entrance, until it leaves; returns the exit kind it left by, for gmTakeExit, or EXIT_KEEP_DESTINATION when the next scene is already in MainRoutineStateWork: a random battle, a party that fell outside battle, Retreat or a script's destination. |
Sint32 | fdActorGetCueMetatileAheadOfCurrent (void) | Returns the metatile behavior of the map metatile 16 pixels ahead of the party leader when there is something to search there: a fixed search spot (METATILE_BEHAVIOR_JAR to METATILE_BEHAVIOR_WELL) whose ground is level with the leader or up to 16 pixels above it, or a behavior the scene has an examine cue for; aboard the ship on the World Map, SHIP_SEA_EXAMINE_CODE before sea of collision 3. |
Bool | fdPlaceAtEntranceRow (Sint32 findEntrance) | Places the party at the entrance it came in by, from the scene's entrance rows, unless it keeps its position, and sets the map's scroll bounds, at least a screen (240 x 160 pixels) wide and tall. |
Bool | fdPlaceAtEntrance (void) | Reads the map's entrance stream (MapScene) for the current entrance, places the party there unless FLAG_KEEP_PARTY_POSITION keeps it, then sets the camera bounds from the first box that holds it. |
Uint32 | fdStreamReadU16 (Uint8 **cursor) | Reads a little-endian halfword at *cursor and moves the cursor past it. |
Sint16 | fdStreamReadS16 (Uint8 **cursor) | Reads a signed little-endian halfword at *cursor and moves the cursor past it. |
void | fdApplyEntrance (void) | Places the party where it enters: by the scene's entrance row for MainRoutineStateWork.entrance, else on a map by the map's own entrance stream (fdPlaceAtEntrance), else by the scene's first entrance row. |
Variables
| Name | Description | |
|---|---|---|
extern Uint8 | MapGridMetatileBuffer [] | The map cell buffer at its own address, which the effects borrow: no map is loaded during a battle. |
Description
The field engine: running a scene until the party leaves it, and its
entrance. Part of field_engine.c.
Macros in detail
NIBBLE_LOW
#define NIBBLE_LOW(value) ((value) & 15)
The two nibbles of a scene's attributes (gmFieldGetSceneAttributes).
Referenced by fdEngineRun().
Definition at line 21 of file field_engine_run.c.
NIBBLE_HIGH
#define NIBBLE_HIGH(value) (((value) >> 4) & 15)
Referenced by fdEngineRun().
Definition at line 22 of file field_engine_run.c.
HAZARD_LIMIT_DEFAULT
#define HAZARD_LIMIT_DEFAULT 16
The hazard count's limit each scene starts with, in steps on hazard metatiles: the hazard deals its damage each time the count reaches it.
Referenced by fdEngineRun().
Definition at line 25 of file field_engine_run.c.
PLACE_MARKER_ON_FOOT
#define PLACE_MARKER_ON_FOOT (1 << 4)
A Teleport destination's map screen marker (WORLD_MAP_PLACE.markers' high
nibble): 1 for a place the party walks to; 2 for Lemuria's, which it reaches
aboard the ship.
Referenced by fdEngineRun().
Definition at line 29 of file field_engine_run.c.
PLACE_MARKER_ABOARD
#define PLACE_MARKER_ABOARD (2 << 4)
Referenced by fdEngineRun().
Definition at line 30 of file field_engine_run.c.
PAUSE_MENU_VRAM_BLOCKS
#define PAUSE_MENU_VRAM_BLOCKS 136
The sprite VRAM blocks the Pause menu needs free, or the field's sprites stop
drawing while it runs.
Referenced by fdEngineRun().
Definition at line 33 of file field_engine_run.c.
MAP_ENTRANCE_ROW_BYTES
#define MAP_ENTRANCE_ROW_BYTES 6
A map entrance stream's row: the entrance, its x and z, and its flags byte.
Referenced by fdPlaceAtEntrance().
Definition at line 35 of file field_engine_run.c.
MAP_ENTRANCE_FACING_MASK
#define MAP_ENTRANCE_FACING_MASK 15
A map entrance's flags byte: the party's facing in sixteenths of a turn, then whether it stands 8 pixels up and whether the camera keeps the bounds it has.
Referenced by fdPlaceAtEntrance().
Definition at line 766 of file field_engine_run.c.
MAP_ENTRANCE_RAISED
#define MAP_ENTRANCE_RAISED (1 << 4)
Referenced by fdPlaceAtEntrance().
Definition at line 767 of file field_engine_run.c.
MAP_ENTRANCE_KEEP_BOUNDS
#define MAP_ENTRANCE_KEEP_BOUNDS (1 << 5)
Referenced by fdPlaceAtEntrance().
Definition at line 768 of file field_engine_run.c.
Functions in detail
fdEngineRun
Sint32 fdEngineRun(void)
The field engine: runs the current scene, which the party entered by
entrance, until it leaves; returns the exit kind it left by, for gmTakeExit,
or EXIT_KEEP_DESTINATION when the next scene is already in
MainRoutineStateWork: a random battle, a party that fell outside battle,
Retreat or a script's destination.
References DebugMode, fdActorGetById(), fdActorGetCueMetatileAheadOfCurrent(), fdActorResetForLeader(), fdActorRestore(), fdActorSelectAnimationStub(), fdActorSetSpriteFlagsStub(), fdActorStartMovementModeScriptStub(), fdActorSystemInitStub(), fdActorTableSnapshot(), fdApplyEntrance(), fdClearRequests(), fdCountRequests(), fdDjinnResolvePending(), fdDjinnRestoreActorAfterBattle(), fdEncounterSelectMapZones(), fdEntrancePlayArrival(), fdExamineMetatile(), fdFindActorTalkCue(), fdFindNearbyTalkTarget(), fdFlagEntriesGetValue(), fdGetPartyActor(), fdLeaderStepOffRope(), fdLeaderStepOffTightrope(), fdLeaderStepOntoRope(), fdLeaderStepOntoTightrope(), fdLeaderStopMoving(), fdMapApplySetFlagEditsStub(), fdMapGridCenterOnFollowedPointStub(), fdMapGridLoadMapStub(), fdMapScreenShow(), fdPaletteEditorRun(), fdPaletteFadeInit(), fdPaletteFadeSetTarget(), fdPartyCheckItemLimit(), fdPartyGetLeaderActor(), fdPartyInventoryGiveItem(), fdPlaceTreasureSpots(), fdPsynergyResumeCloakCheck(), fdRunPushMetatile(), fdRunRaisedCue(), fdRunStepCueOrExit(), fdScreenTransitionFinish(), fdScreenTransitionStart(), fdScriptEndAllLastingPsynergy(), fdScriptSetDestination(), fdSetRestartPoint(), fdStartEncounterTransition(), fdTalkToActor(), fdTeleportPlaySparksAndFade() and 41 more.
Referenced by gmMainRoutineRun().
Definition at line 42 of file field_engine_run.c.
fdActorGetCueMetatileAheadOfCurrent
Sint32 fdActorGetCueMetatileAheadOfCurrent(void)
Returns the metatile behavior of the map metatile 16 pixels ahead of the
party leader when there is something to search there: a fixed search spot
(METATILE_BEHAVIOR_JAR to METATILE_BEHAVIOR_WELL) whose ground is level with
the leader or up to 16 pixels above it, or a behavior the scene has an
examine cue for; aboard the ship on the World Map, SHIP_SEA_EXAMINE_CODE
before sea of collision 3. Returns 0 otherwise.
References fdFindCue(), fdGetPartyActor(), fdMapGridGetTerrainHeightStub(), fdWorldMapGetCollisionStub(), MainRoutineStateWork, result, Sint32 and syVectorAddPolarOffset().
Referenced by fdEngineRun().
Definition at line 630 of file field_engine_run.c.
fdPlaceAtEntranceRow
Bool fdPlaceAtEntranceRow(Sint32 findEntrance)
Places the party at the entrance it came in by, from the scene's entrance rows, unless it keeps its position, and sets the map's scroll bounds, at least a screen (240 x 160 pixels) wide and tall. With findEntrance it looks the entrance up and returns 0 when there is none; without, it takes the scene's first row.
References MainRoutineStateWork, Sint32 and syGameFlagGet().
Referenced by fdApplyEntrance().
Definition at line 712 of file field_engine_run.c.
fdPlaceAtEntrance
Bool fdPlaceAtEntrance(void)
Reads the map's entrance stream (MapScene) for the current entrance, places
the party there unless FLAG_KEEP_PARTY_POSITION keeps it, then sets the
camera bounds from the first box that holds it.
References fdMapGridGetTerrainHeightStub(), fdStreamReadS16(), fdStreamReadU16(), MainRoutineStateWork, MapScene, MapSceneBoundsOffset, Sint32 and syGameFlagGet().
Referenced by fdApplyEntrance().
Definition at line 773 of file field_engine_run.c.
fdStreamReadU16
Uint32 fdStreamReadU16(Uint8 **cursor)
Reads a little-endian halfword at *cursor and moves the cursor past it.
Referenced by fdPlaceAtEntrance() and fdScenePointGetPos().
Definition at line 870 of file field_engine_run.c.
fdStreamReadS16
Sint16 fdStreamReadS16(Uint8 **cursor)
Reads a signed little-endian halfword at *cursor and moves the cursor past it.
Referenced by fdPlaceAtEntrance().
Definition at line 880 of file field_engine_run.c.
fdApplyEntrance
void fdApplyEntrance(void)
Places the party where it enters: by the scene's entrance row for
MainRoutineStateWork.entrance, else on a map by the map's own entrance stream
(fdPlaceAtEntrance), else by the scene's first entrance row.
References fdPlaceAtEntrance(), fdPlaceAtEntranceRow() and Sint32.
Referenced by fdEngineRun().
Definition at line 892 of file field_engine_run.c.