Skip to Content
The Alchemy Project

include/game/main_routine_state.h

The main routine's state: the transition data the main routine reads between engines and the state every engine shares, which a save file keeps.

Included by lucky_dice.c, lucky_wheels.c, menu_internal.h, shop_internal.h, script.h and inventory.h.

Structures

NameDescription
structPARTY_HOLDINGSWhat the party holds apart from its items: its summons, coins and Djinn, and what Tolbi's shops and games keep for it.
structMAIN_ROUTINE_STATEThe 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).

Macros

NameDescription
#defineHAZARD_DAMAGE_PERCENT 0x100MainRoutineStateWork.hazardDamage's bit 8: its low byte is a percentage of maximum HP rather than HP.
#defineCOIN_MAX 999999The most coins the party carries, and the most shop credit.
#defineSHOP_GIFTS_MAX 28The most Game Tickets counted in PARTY_HOLDINGS.shopGifts, the last of the Game Ticket's credit costs that is used.
#defineSET_BATTLE_TYPE (mode)Says what kind of battle comes next (a BATTLE_TYPE_), as a script or a battle cue does before starting one.

Enumerations

NameDescription
enumSCENE_TYPE { SCENE_TYPE_OTHER, SCENE_TYPE_TOWN }A scene's type (SCENE.sceneType, copied to MAIN_ROUTINE_STATE.sceneType).
enumHAZARD_MODE { HAZARD_COUNT_ON_METATILES, HAZARD_COUNT_TICKS }MainRoutineStateWork.hazardMode: what advances the hazard count (fdUpdateWalking).
enumBATTLE_TYPE { BATTLE_TYPE_NORMAL, BATTLE_TYPE_NO_ESCAPE, BATTLE_TYPE_SCRIP … }MainRoutineStateWork.battleType: how the next battle starts (SET_BATTLE_TYPE); it is set back to BATTLE_TYPE_NORMAL as the battle ends.

Variables

NameDescription
STATIC_ASSERT(offsetof (MAIN_ROUTINE_STATE, holdings.coins)
extern MAIN_ROUTINE_STATEMainRoutineStateWorkThe game's state (system/ewram.s).
extern UNITCharacterUnits [8]The eight characters' units, which follow it (gmUnitGet).

Description

The main routine's state: the transition data the main routine reads between engines and the state every engine shares, which a save file keeps.

Macros in detail

HAZARD_DAMAGE_PERCENT

#define HAZARD_DAMAGE_PERCENT 0x100

MainRoutineStateWork.hazardDamage's bit 8: its low byte is a percentage of maximum HP rather than HP.

Referenced by fdUpdateWalking() and scInit().

Definition at line 34 of file main_routine_state.h.

COIN_MAX

#define COIN_MAX 999999

The most coins the party carries, and the most shop credit.

Referenced by gmPartyAdjustCoins().

Definition at line 53 of file main_routine_state.h.

SHOP_GIFTS_MAX

#define SHOP_GIFTS_MAX 28

The most Game Tickets counted in PARTY_HOLDINGS.shopGifts, the last of the Game Ticket's credit costs that is used.

Referenced by mnShopOpenDebugShop().

Definition at line 57 of file main_routine_state.h.

SET_BATTLE_TYPE

#define SET_BATTLE_TYPE(mode)

Says what kind of battle comes next (a BATTLE_TYPE_), as a script or a battle cue does before starting one.

Referenced by btDebugBattleRunMenu(), btRun(), fdExamineMetatile(), scAltinPeakFightFirstWaterBeast(), scAltinPeakFightSecondWaterBeast(), scAltinPeakFightThirdWaterBeast(), scAltinPeakStartHydrosBattle(), scBattleArenaEnterBattle(), scColossoReachArena(), scCrossboneIsleFightDeadbeard(), scCrossboneIsleOpenEastDoor(), scLamakanDesertFightManticore(), scLogRoomsAFightThievesAgain(), scLogRoomsAFreeVillagerAndFightThieves(), scLunpaFortressFightCellKeyRoomGuard(), scLunpaFortressFightDonpasDoorGuard(), scLunpaFortressFightMiddleHallGuard(), scLunpaFortressFightThreeGuards(), scLunpaFortressFindHammet(), scMercuryLighthouseAerieConfrontSaturos(), scMercuryLighthouseEntranceFightLizardMan(), scMogallForestFirstAreaApeAttacks(), scMogallForestKillerApeAttacks(), scMogallForestThirdAreaApeAttacks(), scShipRoomsFightRowingDeckMonsters(), scSuhallaDesertDouseStorm(), scTolbiShipDeckJumpIntoKrakenBattle(), scTreeRoomsFightTret(), scValePlazaFightTravelers(), scVenusLighthouseAerieCombineSaturosAndMenardi(), scVenusLighthouseAerieConfrontSaturosAndMenardi() and scWorldMapDouseMapStorm().

Definition at line 266 of file main_routine_state.h.

Enumerations in detail

SCENE_TYPE

enum SCENE_TYPE

A scene's type (SCENE.sceneType, copied to MAIN_ROUTINE_STATE.sceneType).

EnumeratorValueDescription
SCENE_TYPE_OTHER1every other scene: dungeons, the world map
SCENE_TYPE_TOWN2Towns and their rooms, where walking restores no PP, recovers no Djinn and does no poison damage, Retreat is blocked, Avoid does not wear off and FLAG_IN_TOWN is set.

Definition at line 13 of file main_routine_state.h.

HAZARD_MODE

enum HAZARD_MODE

MainRoutineStateWork.hazardMode: what advances the hazard count (fdUpdateWalking).

EnumeratorValueDescription
HAZARD_COUNT_ON_METATILES0The distance the leader walks on METATILE_BEHAVIOR_DESERT_SAND ground.
HAZARD_COUNT_TICKS1One each tick the field engine runs; no code in the game sets it.

Definition at line 24 of file main_routine_state.h.

BATTLE_TYPE

enum BATTLE_TYPE

MainRoutineStateWork.battleType: how the next battle starts (SET_BATTLE_TYPE); it is set back to BATTLE_TYPE_NORMAL as the battle ends.

EnumeratorValueDescription
BATTLE_TYPE_NORMAL0
BATTLE_TYPE_NO_ESCAPE2A battle the party cannot run from: a Mimic's (field/field_engine_cues.c) and the travelers' fight in Vale (scValePlazaFightTravelers, scene/vale_plaza.c).
BATTLE_TYPE_SCRIPTED3The battles a script starts.
BATTLE_TYPE_LINK4a link battle (btRun, scene/battle_arena.c)
BATTLE_TYPE_DEBUG5The debug battle menu's mark (btDebugBattleRunMenu), which no code tests by value; it still lets the party run.

Definition at line 38 of file main_routine_state.h.

Variables in detail

offsetof

STATIC_ASSERT(offsetof(MAIN_ROUTINE_STATE, holdings.coins)

STATIC_ASSERT(offsetof(MAIN_ROUTINE_STATE, holdings.shopCredit)

STATIC_ASSERT(offsetof(MAIN_ROUTINE_STATE, holdings.shopGifts)

STATIC_ASSERT(offsetof(MAIN_ROUTINE_STATE, holdings.wonPrizes)

Definition at lines 234, 235, 236 and 238 of file main_routine_state.h.

MainRoutineStateWork

extern MAIN_ROUTINE_STATE MainRoutineStateWork

The game's state (system/ewram.s).

Referenced by btDebugBattleRunMenu(), btDebugBattleViewMessages(), btFleeCheckSuccess(), btPartyPrepareMembers(), btRun(), btSpoilsClear(), dbIncreaseItemAndLevelRunLevelEditor(), dbMenuTestBrowseMessageRange(), fdActorGetCueMetatileAheadOfCurrent(), fdActorLaunchFromLeader(), fdActorMoveOnWorldMap(), fdActorResetForLeader(), fdActorRestore(), fdActorSetMovementType(), fdActorUpdatePlayerControl(), fdApplyEntrance(), fdBattleBackgroundGetSelected(), fdBattleBackgroundSelectForEnvironment(), fdBattleBackgroundSelectForMap(), fdCheckConfiguredKeys(), fdChooseMusic(), fdClimbDown(), fdClimbUp(), fdDjinnResolvePending(), fdDjinnRestoreActorAfterBattle(), fdDjinnRunBattleStartHop(), fdDjinnRunJupiterJoinEffect(), fdDjinnRunMarsJoinEffect(), fdDjinnRunMercuryJoinEffect(), fdDjinnRunVenusJoinEffect(), fdEffectBlinkAvoidCaster(), fdEffectRunAngledApproachPhases(), fdEffectSpawnRevealMarkers(), fdEffectStartGroundMask(), fdEffectUpdateAvoidCaster(), fdEffectUpdateDescendingOrbitActor(), fdEffectUpdateDescendingParticleNegativeArc(), fdEffectUpdateDescendingParticlePositiveArc(), fdEffectUpdateMarsSpark(), fdEffectUpdateRadialSpread(), fdEffectUpdateRandomTargetParticle(), fdEncounterCountStepsAndSelectFormation(), fdEncounterSelectBattleMusic(), fdEncounterSelectMapZones(), fdEngineRun(), fdEntrancePlayArrival(), fdEntrancePlayArrivalAnimation(), fdExamineMetatile(), fdExitPrepareAnimation(), fdFindActorTalkCue() and 308 more.

Definition at line 260 of file main_routine_state.h.

CharacterUnits

extern UNIT CharacterUnits[8]

The eight characters' units, which follow it (gmUnitGet).

Referenced by gmMainRoutineStateInitDefaults() and gmUnitGet().

Definition at line 262 of file main_routine_state.h.