Skip to Content
The Alchemy Project

struct MAIN_ROUTINE_STATE

The game's blocks the system library's RAM holds, complete here so that each variable globals.h declares has its whole type. More…

Declared in definitions.h.

Fields

NameDescription
Uint32buildStampgmBuildStampGetTime's value when the game was last saved; 0 on a new game.
Uint32playTimeTicks.
Uint8unused [4]
Uint32summonMaskThe summons the party can call, bit n for summon n: the first word of the party's DJINN_RECOVERY_TABLE, which gmDjinnGetRecoveryTable returns from here, its next word running over coins.
Uint32coinsAt most COIN_MAX (gmPartyAdjustCoins).
Uint8djinnRecovery [292]The party's Djinn recovery list (DJINN_RECOVERY_TABLE from its offers on), read through gmDjinnGetRecoveryTable.
Sint32shopCreditShop credit, at most COIN_MAX (gmPartyAdjustShopCredit).
Sint8shopGiftsShop gifts, 0 to SHOP_GIFTS_MAX (gmPartyAdjustShopGifts).
Uint8prizeWeights [15]The weights of the spring game's 15 prizes: three each of 4, 8, 16, 32 and 64 on a new game; Lemuria's spring halves a prize's weight each time it is won.
Sint8wheelsPrizes [8]The icons matched on the Lucky Wheels, a prize each, ended by WHEELS_PRIZES_END, for Contigo's attendant to hand out.
Sint8wheelsPrizeCursors [6]For each icon, which of its three prizes it gave last (scContigoSelectLuckyWheelsPrize).
Uint8unusedAfterWheelsPrizes [134]No code names it.
Sint16nextThe scene the party is in, or bound for once gmTakeExit has chosen an exit.
Sint16entranceIts entrance, a number of that scene's entrance list.
Uint16restartSceneWhere a defeat returns to without a defeat point.
Uint16restartEntranceWhere a defeat returns to without a defeat point.
Sint16returnSceneThe default scene: the fallback of both destinations.
Sint16returnEntranceThe default entrance: the fallback of both destinations.
Sint16areaThe current scene's group; a new group resets its state.
Uint16afterBattleSceneThe after-battle destination, -1 for none: read by gmReturnFromEngine when the party was not defeated, before the default scene and entrance.
Uint16afterBattleEntranceIts entrance; -1 for none.
Uint16defeatSceneThe defeat destination, -1 for none: read by gmReturnFromEngine after a defeat.
Uint16defeatEntranceIts entrance; -1 for none.
Sint16battleBgThe battle background chosen for the
Uint8unusedAfterBg [2]scene or terrain.
Sint16mapIdThe current scene's map, a row of MapsWork.
FIXEDxThe leader's position in 16.16 pixels and facing (an angle), set from the entrance taken and noted again each time the field handles a request.
FIXEDy
FIXEDz
Sint32heading
Uint16layerThe leader's layer; 0 on taking an entrance.
Sint16battleMusicThe battle music chosen for the encounter.
Sint16sceneMusicThe current scene's field music.
Uint8movementModeHow the leader moves, an LEADER_MOVEMENT_MODE.
Sint32leaderActorIdThe leader.
Uint8party [8]The party in order.
Uint8unusedAfterParty [5]No code names it.
Uint8windowHueThe "Window color" setting (option 0).
Uint8windowBrightnessThe "Window brightness" setting (option 1).
Uint8unusedAfterBrightness [3]
Uint8speechOption 3, on or off; 1 on a new game.
Uint8unusedAfterSpeech1 on a new game; nothing reads it.
Uint8msgSpeedOption 2, the message speed, 0 to 2: 1 on a
Uint8unusedAfterMsgSpeed [2]new game; some scenes set 2 and restore it after.
Uint8sendFlagSet on saving at the end of the game, marking the file cleared: its data can be sent.
Uint16aKeysExamine; KEY_A.
Uint16bKeysKEY_B; held with aKeys, it makes flight climb.
Uint16selectKeysThe menu; KEY_SELECT.
Uint16startKeysKEY_START.
Uint16firstShortcutKeysKEY_L.
Uint16secondShortcutKeysKEY_R.
Uint16dashKeysKEY_B.
Sint16returnMusicThe music to play on returning, -1 for the scene's own.
Uint16firstShortcutThe shortcuts' assignments, run by
Uint16secondShortcutfirstShortcutKeys and secondShortcutKeys (mnPsynergyMenuSetShortcut: kind << 10 | id).
Uint8perspectiveMapSet to 1 on the world map.
Uint8unusedAfterPerspective [5]
Uint8idleSleepEnabledOption 4, Auto-Sleep, saved from IdleSleepEnabled.
Uint8battleTypeAn BATTLE_TYPE, set back to BATTLE_TYPE_NORMAL at the end.
Sint16hazardLimitHazardous ground: when hazardSteps reaches hazardLimit the party takes hazardDamage and the count starts again.
Sint16hazardMode
Sint16hazardDamage
Uint16hazardStepsReset on entering a new scene group.
Sint16pendingDjinniThe Djinni battle pending (DJINNI_BATTLE_SCRIPT_FIRST plus its number, flags in bits 15 to 11), or a Mimic's flag with CONDITION_FLAG_SET, resolved on returning to the field.
Sint16engineResultThe last battle's result: the enemies defeated, BATTLE_OUTCOME_FLED or BATTLE_OUTCOME_LOST.
Sint32encounterStepsReset on entering a new scene group.
Uint16pendingItemCleared with the battle's spoils; no code reads it by name.
Sint16sceneTypeThe current scene's SCENE_TYPE.
Sint16retreatSceneWhere Retreat goes; the group's first entrance.
Sint16retreatEntranceWhere Retreat goes; the group's first entrance.
FIXEDavoidDistanceDistance left of Avoid, 16.16 pixels; 0 when off.
Sint8avoidByItemAvoid came from an item (FLAG_PSYNERGY_FROM_ITEM).
Uint8pausedColorModeThe paused object's first animation param.
Sint16haltedActorThe object field Psynergy has stopped, -1 for none.
Sint8sandActiveNonzero while the leader is sand (fdPsynergySand): ending the pending actions ends Sand too, and the field's push and button handler idles.
Sint8cloakedCloak: the leader is hidden.
Uint8unusedAfterCloaked [2]
void *pausedUpdateThe paused object's update, restored on resuming.
Uint8weirdAnswersThe weird answers Felix gives, counted up by fdScriptCountAnswer from 0 on a new game: telling Kraden on Idejima that the Western Sea is not where they go, agreeing with Alhafra's mayor that the party owes him, and others.
Sint16ownerOverrideNonzero makes actor 8, not leaderActorId, the one scripts control.
Sint32shipXThe ship's x on the world map, where it is moored.
Sint32shipZThe ship's z on the world map.
Sint32shipFacingThe ship's facing on the world map.
Uint8unusedAfterShipFacing [2]No code names it.
Uint8clearedFileAtStartAnyFileCleared as the new game began (gmMainRoutineStateInitDefaults): 1 when a file on the cartridge had been cleared.
Uint8difficultyThe level chosen from a cleared game (Difficulty).
Uint8unusedAfterDifficulty [4]No code names it.
Sint32transferredCoinsThe Broken Seal's coins, kept from the data transfer (gmDataTransferApply) until Isaac's party joins and gmPartyAddIsaacsParty adds them.
Uint8unusedAfterTransferredCoins [44]No code names it.
Uint16forgeItemThe item left at the forge (mnForgeSetItem).
Sint16teleportSceneTeleport's destination: SCENE_WORLD_MAP once a place is chosen on the map screen (fdMapScreenShow), -1 after cancelling.
Sint16teleportEntranceThe chosen place's flag, which the world map takes as its entrance; -1 after cancelling.
Sint8teleportStateAn TELEPORT_STATE: the scene the party lands in plays the arrival and clears it.
Sint8onUpperLevelSet while the leader stands on the upper level of the Alhafran Cave, where Sand ends; cleared on entering a scene.
Uint16linkTallies [8]The Link Lobby's records
Uint8unusedAfterTallies [4](LINK_TALLY): the wins, losses, best streak and current streak of its monster battles, then the same four of its battles against another player.
Uint32startStampgmBuildStampGetTime's value at a
Uint8unusedAfterStartStamp [4]new game.

Description

The game's blocks the system library's RAM holds, complete here so that each variable globals.h declares has its whole type. MainRoutineStateWork, the state a save file keeps: play time, coins, the scene and the leader's position, the active party and the options.

struct MAIN_ROUTINE_STATE

Referenced by btDebugBattleRunMenu(), fdActorStartMovementModeScript(), fdDjinnResolvePending(), fdDjinnRestoreActorAfterBattle(), fdEncounterResolveWorldMapZoneAndBackdrop(), fdEngineRun(), fdFindActorTalkCue(), fdGetPartyActor(), fdLeaderStepOntoTightrope(), fdMapScreenShow(), fdPartyApplyPoisonDamage(), fdPartyGetLeaderActor(), fdPlaceAtEntrance(), fdPsynergyDispatch(), fdPsynergyRun(), fdPsynergyWatchSandGround(), fdScriptEnd(), fdScriptSetRestartPoint(), fdScriptStart(), fdSetRestartPoint(), fdTightropeUpdate(), fdUsePsynergy(), fdWorldMapZoomOutWhileLHeld(), gmClearDataApply(), gmDataTransferApply(), gmPartyAdjustCoins(), gmPartyTakeFallDamage(), KNOCK_BACK(), MainRoutineStateWork, mnAreaNameWindowShow(), mnDebugShortcutRun(), mnDebugWarpArafura2(), mnDebugWarpArafura3(), mnDebugWarpChampa2(), mnPsynergyMenuSetShortcut(), scAirsRockWhirlwindClearsWall(), scAnemosInnerSanctumDullahanStepWhilePushing(), scAquaRockArriveFromInside(), scAquaRockDropDownFalls(), scAttekaInletSetUpTheHarbor(), scCavernsJumpAcross(), scClearEnterPassword(), scClearIsRetreatBlocked(), scClearReceiveByLink(), scContigoSelectLuckyWheelsPrize(), scEffectAdvanceMotionAtLeaderPriority(), scGabombaStatueChamberInitIdol(), scGabombaStatueEndRide(), scGaiaRockInsidePlaceDollOnEntranceAltar(), scGetCues() and 40 more.

Definition at line 1350 of file definitions.h.

Fields in detail

buildStamp

Uint32 buildStamp

gmBuildStampGetTime's value when the game was last saved; 0 on a new game.

playTime

Uint32 playTime

Ticks.

unused

Uint8 unused[4]

summonMask

Uint32 summonMask

The summons the party can call, bit n for summon n: the first word of the party's DJINN_RECOVERY_TABLE, which gmDjinnGetRecoveryTable returns from here, its next word running over coins.

coins

Uint32 coins

At most COIN_MAX (gmPartyAdjustCoins).

djinnRecovery

Uint8 djinnRecovery[292]

The party's Djinn recovery list (DJINN_RECOVERY_TABLE from its offers on), read through gmDjinnGetRecoveryTable.

shopCredit

Sint32 shopCredit

Shop credit, at most COIN_MAX (gmPartyAdjustShopCredit).

shopGifts

Sint8 shopGifts

Shop gifts, 0 to SHOP_GIFTS_MAX (gmPartyAdjustShopGifts).

prizeWeights

Uint8 prizeWeights[15]

The weights of the spring game's 15 prizes: three each of 4, 8, 16, 32 and 64 on a new game; Lemuria's spring halves a prize's weight each time it is won.

wheelsPrizes

Sint8 wheelsPrizes[8]

The icons matched on the Lucky Wheels, a prize each, ended by WHEELS_PRIZES_END, for Contigo's attendant to hand out.

wheelsPrizeCursors

Sint8 wheelsPrizeCursors[6]

For each icon, which of its three prizes it gave last (scContigoSelectLuckyWheelsPrize).

unusedAfterWheelsPrizes

Uint8 unusedAfterWheelsPrizes[134]

No code names it.

next

Sint16 next

The scene the party is in, or bound for once gmTakeExit has chosen an exit.

entrance

Sint16 entrance

Its entrance, a number of that scene's entrance list.

restartScene

Uint16 restartScene

Where a defeat returns to without a defeat point.

restartEntrance

Uint16 restartEntrance

Where a defeat returns to without a defeat point.

returnScene

Sint16 returnScene

The default scene: the fallback of both destinations.

returnEntrance

Sint16 returnEntrance

The default entrance: the fallback of both destinations.

area

Sint16 area

The current scene's group; a new group resets its state.

afterBattleScene

Uint16 afterBattleScene

The after-battle destination, -1 for none: read by gmReturnFromEngine when the party was not defeated, before the default scene and entrance.

afterBattleEntrance

Uint16 afterBattleEntrance

Its entrance; -1 for none.

defeatScene

Uint16 defeatScene

The defeat destination, -1 for none: read by gmReturnFromEngine after a defeat.

defeatEntrance

Uint16 defeatEntrance

Its entrance; -1 for none.

battleBg

Sint16 battleBg

The battle background chosen for the

unusedAfterBg

Uint8 unusedAfterBg[2]

scene or terrain.

mapId

Sint16 mapId

The current scene's map, a row of MapsWork.

x

FIXED x

The leader's position in 16.16 pixels and facing (an angle), set from the entrance taken and noted again each time the field handles a request.

y

FIXED y

z

FIXED z

heading

Sint32 heading

layer

Uint16 layer

The leader's layer; 0 on taking an entrance.

battleMusic

Sint16 battleMusic

The battle music chosen for the encounter.

sceneMusic

Sint16 sceneMusic

The current scene's field music.

movementMode

Uint8 movementMode

How the leader moves, an LEADER_MOVEMENT_MODE.

leaderActorId

Sint32 leaderActorId

The leader.

party

Uint8 party[8]

The party in order.

unusedAfterParty

Uint8 unusedAfterParty[5]

No code names it.

windowHue

Uint8 windowHue

The "Window color" setting (option 0).

windowBrightness

Uint8 windowBrightness

The "Window brightness" setting (option 1).

unusedAfterBrightness

Uint8 unusedAfterBrightness[3]

speech

Uint8 speech

Option 3, on or off; 1 on a new game.

unusedAfterSpeech

Uint8 unusedAfterSpeech

1 on a new game; nothing reads it.

msgSpeed

Uint8 msgSpeed

Option 2, the message speed, 0 to 2: 1 on a

unusedAfterMsgSpeed

Uint8 unusedAfterMsgSpeed[2]

new game; some scenes set 2 and restore it after.

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

KEY_B; held with aKeys, it makes flight climb.

selectKeys

Uint16 selectKeys

The menu; KEY_SELECT.

startKeys

Uint16 startKeys

KEY_START.

firstShortcutKeys

Uint16 firstShortcutKeys

KEY_L.

secondShortcutKeys

Uint16 secondShortcutKeys

KEY_R.

dashKeys

Uint16 dashKeys

KEY_B.

returnMusic

Sint16 returnMusic

The music to play on returning, -1 for the scene's own.

firstShortcut

Uint16 firstShortcut

The shortcuts' assignments, run by

secondShortcut

Uint16 secondShortcut

firstShortcutKeys and secondShortcutKeys (mnPsynergyMenuSetShortcut: kind << 10 | id).

perspectiveMap

Uint8 perspectiveMap

Set to 1 on the world map.

unusedAfterPerspective

Uint8 unusedAfterPerspective[5]

idleSleepEnabled

Uint8 idleSleepEnabled

Option 4, Auto-Sleep, saved from IdleSleepEnabled.

battleType

Uint8 battleType

An BATTLE_TYPE, set back to BATTLE_TYPE_NORMAL at the end.

hazardLimit

Sint16 hazardLimit

Hazardous ground: when hazardSteps reaches hazardLimit the party takes hazardDamage and the count starts again.

hazardMode

Sint16 hazardMode

hazardDamage

Sint16 hazardDamage

hazardSteps

Uint16 hazardSteps

Reset on entering a new scene group.

pendingDjinni

Sint16 pendingDjinni

The Djinni battle pending (DJINNI_BATTLE_SCRIPT_FIRST plus its number, flags in bits 15 to 11), or a Mimic's flag with CONDITION_FLAG_SET, resolved on returning to the field.

engineResult

Sint16 engineResult

The last battle's result: the enemies defeated, BATTLE_OUTCOME_FLED or BATTLE_OUTCOME_LOST.

encounterSteps

Sint32 encounterSteps

Reset on entering a new scene group.

pendingItem

Uint16 pendingItem

Cleared with the battle's spoils; no code reads it by name.

sceneType

Sint16 sceneType

The current scene's SCENE_TYPE.

retreatScene

Sint16 retreatScene

Where Retreat goes; the group's first entrance.

retreatEntrance

Sint16 retreatEntrance

Where Retreat goes; the group's first entrance.

avoidDistance

FIXED avoidDistance

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

avoidByItem

Sint8 avoidByItem

Avoid came from an item (FLAG_PSYNERGY_FROM_ITEM).

pausedColorMode

Uint8 pausedColorMode

The paused object's first animation param.

haltedActor

Sint16 haltedActor

The object field Psynergy has stopped, -1 for none.

sandActive

Sint8 sandActive

Nonzero while the leader is sand (fdPsynergySand): ending the pending actions ends Sand too, and the field's push and button handler idles.

cloaked

Sint8 cloaked

Cloak: the leader is hidden.

unusedAfterCloaked

Uint8 unusedAfterCloaked[2]

pausedUpdate

void *pausedUpdate

The paused object's update, restored on resuming.

weirdAnswers

Uint8 weirdAnswers

The weird answers Felix gives, counted up by fdScriptCountAnswer from 0 on a new game: telling Kraden on Idejima that the Western Sea is not where they go, agreeing with Alhafra's mayor that the party owes him, and others. Past four, as Felix answers Ancient Lemuria's guards' "Do we have your word?", Kraden says "Sometimes, you can say the weirdest things..." to a yes and "Are you INSANE!?" to a no.

ownerOverride

Sint16 ownerOverride

Nonzero makes actor 8, not leaderActorId, the one scripts control.

shipX

Sint32 shipX

The ship's x on the world map, where it is moored.

shipZ

Sint32 shipZ

The ship's z on the world map.

shipFacing

Sint32 shipFacing

The ship's facing on the world map.

unusedAfterShipFacing

Uint8 unusedAfterShipFacing[2]

No code names it.

clearedFileAtStart

Uint8 clearedFileAtStart

AnyFileCleared as the new game began (gmMainRoutineStateInitDefaults): 1 when a file on the cartridge had been cleared. Nothing reads it back.

difficulty

Uint8 difficulty

The level chosen from a cleared game (Difficulty).

unusedAfterDifficulty

Uint8 unusedAfterDifficulty[4]

No code names it.

transferredCoins

Sint32 transferredCoins

The Broken Seal's coins, kept from the data transfer (gmDataTransferApply) until Isaac's party joins and gmPartyAddIsaacsParty adds them.

unusedAfterTransferredCoins

Uint8 unusedAfterTransferredCoins[44]

No code names it.

forgeItem

Uint16 forgeItem

The item left at the forge (mnForgeSetItem).

teleportScene

Sint16 teleportScene

Teleport's destination: SCENE_WORLD_MAP once a place is chosen on the map screen (fdMapScreenShow), -1 after cancelling.

teleportEntrance

Sint16 teleportEntrance

The chosen place's flag, which the world map takes as its entrance; -1 after cancelling.

teleportState

Sint8 teleportState

An TELEPORT_STATE: the scene the party lands in plays the arrival and clears it.

onUpperLevel

Sint8 onUpperLevel

Set while the leader stands on the upper level of the Alhafran Cave, where Sand ends; cleared on entering a scene.

linkTallies

Uint16 linkTallies[8]

The Link Lobby's records

unusedAfterTallies

Uint8 unusedAfterTallies[4]

(LINK_TALLY): the wins, losses, best streak and current streak of its monster battles, then the same four of its battles against another player.

startStamp

Uint32 startStamp

gmBuildStampGetTime's value at a

unusedAfterStartStamp

Uint8 unusedAfterStartStamp[4]

new game.