Skip to Content
The Alchemy Project

struct MAIN_ROUTINE_STATE

The main routine's state: the transition data the main routine reads between engines (the scene and entrance it runs next, engineResult, the return point, the after-battle and defeat destinations and the restart point), and what every engine shares (the party, coins, Djinn, play time and options).

Declared in main_routine_state.h.

Fields

NameDescription
Uint32buildStampgmBuildStampGetTime's value when the game was last saved; its low half goes into the file's summary.
Uint32playTimeTicks, copied from PlayTimeTicks when saving.
Uint8unused [4]
PARTY_HOLDINGSholdings
Uint8unusedAfterPrizes [132]
Sint16nextWhat the main routine runs next: a scene (a SceneId row of ScenesWork), which means the field engine running that scene, or an ENGINE_ value above the table's rows for another engine.
Sint16entranceThe destination's entrance; in ENGINE_BATTLE, the formation to fight.
Sint16restartSceneThe restart point, usually the last Sanctum: read after a defeat with no defeat destination, and by the File Screen.
Sint16restartEntranceThe restart point's entrance.
Sint16returnSceneThe return point: the scene that was running when a battle or minigame started, where gmReturnFromEngine returns unless an after-battle destination is set.
Sint16returnEntranceThe return point's entrance.
Sint16areaThe current scene's area; a new one resets its flags.
Sint16afterBattleSceneThe after-battle destination, -1 for none: read by gmReturnFromEngine when the party was not defeated, before the return point (a minigame's return reads it too), and cleared as each scene starts.
Sint16afterBattleEntranceIts entrance; -1 for none.
Sint16defeatSceneThe defeat destination, -1 for none: read by gmReturnFromEngine after a defeat, before the restart point.
Sint16defeatEntranceIts entrance; -1 for none.
Sint16battleBgThe battle background chosen for the
Uint8unusedAfterBg [2]scene or battle environment.
Sint16mapIdThe scene's map (SCENE.mapIndex); the World Map's is MAP_INDEX_WORLD.
FIXEDx16.16 fixed-point pixels.
FIXEDy16.16 fixed-point pixels.
FIXEDz16.16 fixed-point pixels.
Uint32heading1/65536 turns.
Uint16layerThe leader's layer, kept with its position.
Sint16battleMusicThe battle music chosen for the encounter.
Sint16sceneMusicThe current scene's field music.
Uint8movementMode1 while the leader is climbing, 0 otherwise.
Sint32leaderActorIdThe leader: its unit and its actor.
Uint8party [8]The party in order.
Uint8unusedAfterParty [5]
Uint8windowHueThe "Window color" setting, 0 to 23.
Uint8windowBrightnessThe "Window brightness" setting, 0 to
Uint8unusedAfterBrightness [3]14.
Uint8speechThe voice sound option: 1, as on a new game, plays each speaker's voice sound as their message types (fdSpeakerGetVoice).
Uint8unusedAfterSpeech1 on a new game; nothing reads it.
Uint8msgSpeed0 to 2; 1 on a new game.
Uint8unusedAfterMsgSpeed [2]
Uint8sendFlagSet on saving at the end of the game, marking the file cleared: its data can be sent.
Uint16aKeysExamine; KEY_A.
Uint16bKeys
Uint16selectKeysThe menu; KEY_SELECT.
Uint16startKeys
Uint16firstShortcutKeys
Uint16secondShortcutKeys
Uint16dashKeys
Sint16returnMusicMusic playing when the field left; -1 for none.
Uint16firstShortcutThe shortcuts' assignments. bits: 15..14
Uint16secondShortcutkind (0 Psynergy, 1 an item) | 13..0 which one.
Uint8perspectiveMapSet to 1 on the world map.
Uint8unusedAfterPerspective [5]
Uint8idleSleepEnabledThe option, saved from IdleSleepEnabled.
Uint8battleTypeAn BATTLE_TYPE.
Sint16hazardLimitHazardous ground (the Lamakan Desert's heat): when hazardSteps reaches hazardLimit the party takes hazardDamage and the count starts again.
Sint16hazardModeAn HAZARD_MODE.
Sint16hazardDamagebits: 8 the amount is a percentage of maximum HP | 7..0 the amount
Sint16hazardStepsReset on entering a new area.
Sint16pendingDjinniThe Djinni battle pending (DJINNI_BATTLE_SCRIPT_FIRST plus its number, flags in bits 15 to 11), resolved on returning to the field.
Sint16engineResultThe last battle's result; -1 for a defeat.
Sint32encounterStepsThe encounter count, reset with a new area.
Uint16pendingItemGiven on returning to the field if the party has room.
Sint16sceneTypeThe current scene's variant from its row in ScenesWork.
Sint16retreatSceneWhere Retreat goes: the scene and
Sint16retreatEntranceentrance the party came into the area by.
FIXEDavoidDistanceDistance left of Avoid, 16.16 pixels; 0 when off.
Sint8avoidByItemAvoid came from an item (the Sacred Feather).
Sint8haltedColorModeHalt: the stopped actor's sprite colour mode, which Halt flickers and puts back when the actor resumes.
Sint16haltedActorHalt: the stopped actor; -1 for none.
Sint16cloaked1 under Cloak, which prevents battles.
Uint32haltedUpdateHalt: the stopped actor's per-tick
Uint8unusedAfterHalt [80]update, put back when it resumes.
Uint16linkTallies [8]The Battle Arena's tallies: 4 the total
Uint8unusedAfterTallies [4]wins and 7 the consecutive wins it reports, 3 cleared on choosing a monster battle; the others not named by the game.
Uint32startStampgmBuildStampGetTime's value at a new
Uint8unusedAfterStartStamp [4]game.

Description

The main routine's state: the transition data the main routine reads between engines (the scene and entrance it runs next, engineResult, the return point, the after-battle and defeat destinations and the restart point), and what every engine shares (the party, coins, Djinn, play time and options).

struct MAIN_ROUTINE_STATE

Referenced by fdDjinnResolvePending(), fdPsynergyResumeHaltedActor(), fdRequestDjinnBattle(), fdScriptAskYesNoAndShowResponse(), fdUsePsynergy(), gmPartyAdjustCoins(), MainRoutineStateWork, offsetof, scColosseumNavampaMatchRideMovingSidewalk(), scCrossboneIsleKeysCheckFifthStatueCue(), scInit(), scKalayTolbiDocksTalkToWomanSellingTickets(), scTolbiSpringRunSpringGame(), scWorldMapMeetCorona() and scWorldMapMeetHail().

Definition at line 85 of file main_routine_state.h.

Fields in detail

buildStamp

Uint32 buildStamp

gmBuildStampGetTime's value when the game was last saved; its low half goes into the file's summary.

playTime

Uint32 playTime

Ticks, copied from PlayTimeTicks when saving.

unused

Uint8 unused[4]

holdings

PARTY_HOLDINGS holdings

unusedAfterPrizes

Uint8 unusedAfterPrizes[132]

next

Sint16 next

What the main routine runs next: a scene (a SceneId row of ScenesWork), which means the field engine running that scene, or an ENGINE_ value above the table's rows for another engine.

entrance

Sint16 entrance

The destination's entrance; in ENGINE_BATTLE, the formation to fight.

restartScene

Sint16 restartScene

The restart point, usually the last Sanctum: read after a defeat with no defeat destination, and by the File Screen.

restartEntrance

Sint16 restartEntrance

The restart point's entrance.

returnScene

Sint16 returnScene

The return point: the scene that was running when a battle or minigame started, where gmReturnFromEngine returns unless an after-battle destination is set.

returnEntrance

Sint16 returnEntrance

The return point's entrance.

area

Sint16 area

The current scene's area; a new one resets its flags.

afterBattleScene

Sint16 afterBattleScene

The after-battle destination, -1 for none: read by gmReturnFromEngine when the party was not defeated, before the return point (a minigame's return reads it too), and cleared as each scene starts.

afterBattleEntrance

Sint16 afterBattleEntrance

Its entrance; -1 for none.

defeatScene

Sint16 defeatScene

The defeat destination, -1 for none: read by gmReturnFromEngine after a defeat, before the restart point.

defeatEntrance

Sint16 defeatEntrance

Its entrance; -1 for none.

battleBg

Sint16 battleBg

The battle background chosen for the

unusedAfterBg

Uint8 unusedAfterBg[2]

scene or battle environment.

mapId

Sint16 mapId

The scene's map (SCENE.mapIndex); the World Map's is MAP_INDEX_WORLD.

x

FIXED x

16.16 fixed-point pixels.

y

FIXED y

16.16 fixed-point pixels.

z

FIXED z

16.16 fixed-point pixels.

heading

Uint32 heading

1/65536 turns.

layer

Uint16 layer

The leader's layer, kept with its position.

battleMusic

Sint16 battleMusic

The battle music chosen for the encounter.

sceneMusic

Sint16 sceneMusic

The current scene's field music.

movementMode

Uint8 movementMode

1 while the leader is climbing, 0 otherwise.

leaderActorId

Sint32 leaderActorId

The leader: its unit and its actor.

party

Uint8 party[8]

The party in order.

unusedAfterParty

Uint8 unusedAfterParty[5]

windowHue

Uint8 windowHue

The "Window color" setting, 0 to 23.

windowBrightness

Uint8 windowBrightness

The "Window brightness" setting, 0 to

unusedAfterBrightness

Uint8 unusedAfterBrightness[3]

speech

Uint8 speech

The voice sound option: 1, as on a new game, plays each speaker's voice sound as their message types (fdSpeakerGetVoice).

unusedAfterSpeech

Uint8 unusedAfterSpeech

1 on a new game; nothing reads it.

msgSpeed

Uint8 msgSpeed

0 to 2; 1 on a new game.

unusedAfterMsgSpeed

Uint8 unusedAfterMsgSpeed[2]

sendFlag

Uint8 sendFlag

Set on saving at the end of the game, marking the file cleared: its data can be sent. Copied to the file's summary as sendFlag.

aKeys

Uint16 aKeys

Examine; KEY_A.

bKeys

Uint16 bKeys

selectKeys

Uint16 selectKeys

The menu; KEY_SELECT.

startKeys

Uint16 startKeys

firstShortcutKeys

Uint16 firstShortcutKeys

secondShortcutKeys

Uint16 secondShortcutKeys

dashKeys

Uint16 dashKeys

returnMusic

Sint16 returnMusic

Music playing when the field left; -1 for none.

firstShortcut

Uint16 firstShortcut

The shortcuts' assignments. bits: 15..14

secondShortcut

Uint16 secondShortcut

kind (0 Psynergy, 1 an item) | 13..0 which one.

perspectiveMap

Uint8 perspectiveMap

Set to 1 on the world map.

unusedAfterPerspective

Uint8 unusedAfterPerspective[5]

idleSleepEnabled

Uint8 idleSleepEnabled

The option, saved from IdleSleepEnabled.

battleType

Uint8 battleType

An BATTLE_TYPE.

hazardLimit

Sint16 hazardLimit

Hazardous ground (the Lamakan Desert's heat): when hazardSteps reaches hazardLimit the party takes hazardDamage and the count starts again. Pixels walked on hazard metatiles, or ticks, by hazardMode.

hazardMode

Sint16 hazardMode

An HAZARD_MODE.

hazardDamage

Sint16 hazardDamage

bits: 8 the amount is a percentage of maximum HP | 7..0 the amount

hazardSteps

Sint16 hazardSteps

Reset on entering a new area.

pendingDjinni

Sint16 pendingDjinni

The Djinni battle pending (DJINNI_BATTLE_SCRIPT_FIRST plus its number, flags in bits 15 to 11), resolved on returning to the field.

engineResult

Sint16 engineResult

The last battle's result; -1 for a defeat.

encounterSteps

Sint32 encounterSteps

The encounter count, reset with a new area.

pendingItem

Uint16 pendingItem

Given on returning to the field if the party has room.

sceneType

Sint16 sceneType

The current scene's variant from its row in ScenesWork.

retreatScene

Sint16 retreatScene

Where Retreat goes: the scene and

retreatEntrance

Sint16 retreatEntrance

entrance the party came into the area by.

avoidDistance

FIXED avoidDistance

Distance left of Avoid, 16.16 pixels; 0 when off.

avoidByItem

Sint8 avoidByItem

Avoid came from an item (the Sacred Feather).

haltedColorMode

Sint8 haltedColorMode

Halt: the stopped actor's sprite colour mode, which Halt flickers and puts back when the actor resumes.

haltedActor

Sint16 haltedActor

Halt: the stopped actor; -1 for none.

cloaked

Sint16 cloaked

1 under Cloak, which prevents battles.

haltedUpdate

Uint32 haltedUpdate

Halt: the stopped actor's per-tick

unusedAfterHalt

Uint8 unusedAfterHalt[80]

update, put back when it resumes.

linkTallies

Uint16 linkTallies[8]

The Battle Arena's tallies: 4 the total

unusedAfterTallies

Uint8 unusedAfterTallies[4]

wins and 7 the consecutive wins it reports, 3 cleared on choosing a monster battle; the others not named by the game.

startStamp

Uint32 startStamp

gmBuildStampGetTime's value at a new

unusedAfterStartStamp

Uint8 unusedAfterStartStamp[4]

game.