Skip to Content
The Alchemy Project

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

NameDescription
#defineHAZARD_LIMIT_DEFAULT 16The hazard count's limit each scene starts with, in steps on hazard metatiles: the hazard deals its damage each time the count reaches it.
#defineFIELD_TALK_REQUEST (1 << 12)FIELD_STATE.talk's request bit, set above the actor id so that a talk to actor 0 is still a request (The Lost Age sets bit 14).
#defineANIM_LEADER_LIE_FLAT 37Isaac's pose when the whole party has fallen: lying flat, the picture ANIM_LEADER_FALL ends on (isaac.tsv); any other leader plays ANIM_COLLAPSE.
#defineISAAC_CHILD_ANIMATION_STAND_BRACED 21Isaac's pose for the same as a child (FLAG_CHILDHOOD): standing feet apart, the picture isaac_child.tsv's ANIM_LEADER_STRIDE holds.
#definePAUSE_MENU_VRAM_BLOCKS 136The sprite VRAM blocks the Pause menu needs free, or the field's sprites stop drawing while it runs.

Functions

NameDescription
Sint32fdEngineRun (Sint32 entrance)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.
Sint32fdActorGetCueMetatileAheadOfCurrent (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 64 pixels above it, or a behavior the scene has an examine cue for.
voidfdApplyEntrance (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.

Description

The field engine: running a scene until the party leaves it, and its entrance. Part of field_engine.c.

Macros in detail

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 8 of file field_engine_run.c.

FIELD_TALK_REQUEST

#define FIELD_TALK_REQUEST (1 << 12)

FIELD_STATE.talk's request bit, set above the actor id so that a talk to actor 0 is still a request (The Lost Age sets bit 14).

Referenced by fdEngineRun().

Definition at line 11 of file field_engine_run.c.

ANIM_LEADER_LIE_FLAT

#define ANIM_LEADER_LIE_FLAT 37

Isaac's pose when the whole party has fallen: lying flat, the picture ANIM_LEADER_FALL ends on (isaac.tsv); any other leader plays ANIM_COLLAPSE.

Referenced by fdEngineRun().

Definition at line 14 of file field_engine_run.c.

ISAAC_CHILD_ANIMATION_STAND_BRACED

#define ISAAC_CHILD_ANIMATION_STAND_BRACED 21

Isaac's pose for the same as a child (FLAG_CHILDHOOD): standing feet apart, the picture isaac_child.tsv's ANIM_LEADER_STRIDE holds.

Referenced by fdEngineRun().

Definition at line 17 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 20 of file field_engine_run.c.

Functions in detail

fdEngineRun

Sint32 fdEngineRun(Sint32 entrance)

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, fdActorGetCueMetatileAheadOfCurrent(), fdActorResetForLeader(), fdActorRestore(), fdActorSelectAnimationStub(), fdActorSnapshot(), fdActorStartIdleStub(), fdActorStartKeyCheckStub(), fdActorStartMoveByKeysStub(), fdActorStartPlayerControlStub(), fdActorStartWorldMapControlStub(), fdActorSystemInitStub(), fdApplyEntrance(), fdClearRequests(), fdCountRequests(), fdDjinnResolvePending(), fdDjinnRestoreActorAfterBattle(), fdEncounterSelectMapZones(), fdEndBusyAndReveal(), fdEntrancePlayArrival(), fdExamineMetatile(), fdFindActorTalkCue(), fdFindNearbyTalkTarget(), fdLeaderStopMoving(), fdMapGridCenterOnFollowedPointStub(), fdMapGridLoadMapStub(), fdMapScreenShow(), fdPaletteEditorRun(), fdPaletteFadeInit(), fdPaletteFadeSetTarget(), fdPartyCheckItemLimit(), fdPartyInventoryGiveItem(), fdPlaceTreasureSpots(), fdPsynergyResumeCloakCheck(), fdRunPushMetatile(), fdRunRaisedCue(), fdRunStepCueOrExit(), fdScreenTransitionFinish(), fdScreenTransitionStart(), fdSetRestartPoint(), fdStartEncounterTransition(), fdTalkToActor(), fdUpdateWalking(), fdUseItem(), fdUsePsynergy(), fdWorldMapFreeze(), fdWorldMapInitPerspectiveStub(), fdWorldMapLoadGraphicsStub(), fdWorldMapUnfreeze(), fdWorldMapUpdateCurrentTileBlockStub() and 27 more.

Referenced by gmMainRoutineRun().

Definition at line 27 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 64 pixels above it, or a behavior the scene has an examine cue for. Returns 0 otherwise.

References fdActorLookup(), fdFindCue(), fdMapGridGetTerrainHeightStub(), MainRoutineStateWork, Sint32, state and syVectorAddPolarOffset().

Referenced by fdEngineRun().

Definition at line 494 of file field_engine_run.c.

fdApplyEntrance

void fdApplyEntrance(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.

References gmFlagGetStub(), MainRoutineStateWork, OverlayArea and Sint32.

Referenced by fdEngineRun().

Definition at line 560 of file field_engine_run.c.