Skip to Content
The Alchemy Project

src/battle/battle_setup.c

The battle camera each tick, the opening announcement, the unit lists, the tile pattern, and the party's battle state and Djinn as a battle starts. More…

Included by battle.c.

Macros

NameDescription
#defineCAMERA_YAW_EASE 16Each tick of a turn the camera closes this share of the gap to its target yaw, one sixteenth, so it slows as it nears it.
#defineSUMMON_MASK_LEARNED (~0u << SUMMON_ZAGAN)The summon mask's bits of the summons from SUMMON_ZAGAN on, which the party learns ("can now summon") rather than earns by its Djinn: btSummonUpdateAvailability keeps them as they are.

Functions

NameDescription
voidbtCameraUpdate (void)Runs each tick of a battle: pauses a link battle whose connection is lost, turns the camera a sixteenth of the way toward its target yaw, places it, and refreshes the background's zoom.
voidbtIntroAnnounceEncounter (Sint32 enemyCount)Announces the enemies at the start of a battle, "<enemy> appeared!" for each, then whether the party strikes first or is caught by surprise.
voidbtUnitCollect (void)Fills the battle's two unit lists: the party in its order, and the enemies left to right, or for a fixed formation out from the centre.
Sint32btShiftVRAMTiles (void)Unused: moves 16 bytes of VRAM down by 16 and clears the 20 from 12 bytes past where they land.
voidbtClearBg0Vofs (void)Unused: clears BG0's vertical scroll.
voidbtPartyBattleSetupNoOperation (Sint32 unused)Does nothing; btRun calls it with 1 as the battle is set up.
UNREAD_RESULTbtPartyClearBattleStatuses (void)Clears the party's battle-only statuses, and works their stats out again, as a battle ends.
voidbtPartyClearGuards (void)Clears every unit's guard and Ground's hold at the end of a turn: the party's members and reserves and the opponents.
voidbtDjinnRecoveryReconcile (void)As a battle starts, lists every Djinni a fighting party member holds unset that its side's Djinn recovery list lacks, on standby: the party's on the party's list, a link opponent's (past ALLY_MAX) on the opponent's.
voidbtSummonUpdateAvailability (void)Works out which of the summons up to SUMMON_THOR the party can call: those whose Djinn of every element the party holds (djinnHeldCounts, set or not), all members together, and stores them in the party's summon mask beside the ones learned.
voidbtSummonReservedNoOperation (void)Unused: does nothing.

Description

The battle camera each tick, the opening announcement, the unit lists, the tile pattern, and the party's battle state and Djinn as a battle starts. Part of battle.c.

Macros in detail

CAMERA_YAW_EASE

#define CAMERA_YAW_EASE 16

Each tick of a turn the camera closes this share of the gap to its target yaw, one sixteenth, so it slows as it nears it.

Referenced by btCameraUpdate().

Definition at line 7 of file battle_setup.c.

SUMMON_MASK_LEARNED

#define SUMMON_MASK_LEARNED (~0u << SUMMON_ZAGAN)

The summon mask's bits of the summons from SUMMON_ZAGAN on, which the party learns ("can now summon") rather than earns by its Djinn: btSummonUpdateAvailability keeps them as they are.

Referenced by btSummonUpdateAvailability().

Definition at line 295 of file battle_setup.c.

Functions in detail

btCameraUpdate

void btCameraUpdate(void)

Runs each tick of a battle: pauses a link battle whose connection is lost, turns the camera a sixteenth of the way toward its target yaw, places it, and refreshes the background's zoom.

References btCameraSetRange(), LinkStatusWork, Sint32, syCalcPoint(), syMatrixRewindStack(), syMatrixSetRotateY(), syMatrixSetTranslation() and syRotX().

Referenced by btRun().

Definition at line 12 of file battle_setup.c.

btIntroAnnounceEncounter

void btIntroAnnounceEncounter(Sint32 enemyCount)

Announces the enemies at the start of a battle, "<enemy> appeared!" for each, then whether the party strikes first or is caught by surprise.

References btEnemyList(), btMessageWaitForAdvance(), mnBattleMessageCloseStub(), mnBattleMessageShowAndWaitStub(), mnMessageArgumentClearAllStub(), mnMessageArgumentPushStub() and Sint32.

Referenced by btTransitionRun().

Definition at line 76 of file battle_setup.c.

btUnitCollect

void btUnitCollect(void)

Fills the battle's two unit lists: the party in its order, and the enemies left to right, or for a fixed formation out from the centre.

References BattleFormationCenteredOffsets, btEnemyList(), btPartyPrepareMembers() and Sint32.

Referenced by btRun().

Definition at line 120 of file battle_setup.c.

btShiftVRAMTiles

Sint32 btShiftVRAMTiles(void)

Unused: moves 16 bytes of VRAM down by 16 and clears the 20 from 12 bytes past where they land.

References Sint32, syDMAXCopy() and syWordsClear().

Definition at line 159 of file battle_setup.c.

btClearBg0Vofs

void btClearBg0Vofs(void)

Unused: clears BG0's vertical scroll.

Definition at line 171 of file battle_setup.c.

btPartyBattleSetupNoOperation

void btPartyBattleSetupNoOperation(Sint32 unused)

Does nothing; btRun calls it with 1 as the battle is set up.

References Sint32.

Referenced by btRun().

Definition at line 177 of file battle_setup.c.

btPartyClearBattleStatuses

UNREAD_RESULT btPartyClearBattleStatuses(void)

Clears the party's battle-only statuses, and works their stats out again, as a battle ends.

References btPartyPrepareMembers(), btPartyPrepareReserveOwners(), gmUnitCalculateStub(), gmUnitGet() and Sint32.

Referenced by btRun().

Definition at line 183 of file battle_setup.c.

btPartyClearGuards

void btPartyClearGuards(void)

Clears every unit's guard and Ground's hold at the end of a turn: the party's members and reserves and the opponents. btRun calls it once the turn's actions have played.

References btPartyPrepareMembers(), btPartyPrepareReserveOwners(), btUnitListIds(), gmUnitGet() and Sint32.

Referenced by btRun().

Definition at line 230 of file battle_setup.c.

btDjinnRecoveryReconcile

void btDjinnRecoveryReconcile(void)

As a battle starts, lists every Djinni a fighting party member holds unset that its side's Djinn recovery list lacks, on standby: the party's on the party's list, a link opponent's (past ALLY_MAX) on the opponent's.

References btPartyPrepareMembers(), gmDjinnCanSetStub(), gmDjinnGetRecoveryTableStub(), gmDjinnRecoveryAddStandbyStub() and Sint32.

Referenced by btRun().

Definition at line 255 of file battle_setup.c.

btSummonUpdateAvailability

void btSummonUpdateAvailability(void)

Works out which of the summons up to SUMMON_THOR the party can call: those whose Djinn of every element the party holds (djinnHeldCounts, set or not), all members together, and stores them in the party's summon mask beside the ones learned. Whether enough are on standby is checked as a summon is chosen (mnBattleSummonMenuRun) and built (btActionRunBuild). btRun calls it as the battle is set up and at the start of each turn.

References btPartyPrepareMembers(), gmDjinnGetRecoveryTableStub(), gmSummonDefinitionGetNearStub(), gmUnitGet() and Sint32.

Referenced by btRun().

Definition at line 303 of file battle_setup.c.

btSummonReservedNoOperation

void btSummonReservedNoOperation(void)

Unused: does nothing.

Definition at line 365 of file battle_setup.c.