Alchemy

battle_work.h

games/tbs/include/battle_work.h on GitHub

Structures

BattlePromptSprite

struct BattlePromptSprite

One OAM entry in a sprite list: the arrow that waits for the player to advance a battle message.

FieldDeclared as
nextstruct BattlePromptSprite *next
yu16 y : 8pixels
flagsu16 flags : 8
xu16 x : 9pixels
sizeu16 size : 7
tileu16 tile : 10
paletteu16 palette : 6
unk0au16 unk0acleared with the tile word each frame; not named

Used by BattleEvent_Playback.

Line 16

BattleDisplayOffset

struct BattleDisplayOffset

The battle message's text channel, as far as its offset in the window.

FieldDeclared as
unk00s32 unk00not named by TBS code
xu16 x1/256 pixels
yu16 y1/256 pixels

Used by BattleEvent_Playback, BattlePresentation_WaitForAdvance, UiText_PrepareMessageWork.

Line 30

BattleDisplayWork

struct BattleDisplayWork

The battle message display: its window, its text channel and whether the next message is marked.

FieldDeclared as
windowstruct UiWindow *windowthe message window
offsetstruct BattleDisplayOffset *offsetits text channel
markeds32 markedset by BATTLE_EVENT_MARK; passed to the next message

Used by BattleEvent_Playback, Battle_RunEncounter, UiText_DrawGlyph, UiText_PrepareMessageWork, UiWork_FinalizeSharedSlot, gBattleDisplayWork.

Line 38

BattleEventState

struct BattleEventState

The battle event queue and the state of its playback: the phase, the event playing and the advance arrow.

FieldDeclared as
queuestruct BattleEventQueue queue
phases32 phaseenum BattlePlaybackPhase, or a message phase
eventIndexs32 eventIndexthe next queued event to play
timers32 timerframes to wait, or frames waited for the advance key
displayEntrystruct BattlePromptSprite displayEntrythe advance arrow
displaySources32 displaySourcethe arrow's resource entry; -1 until it is shown
actorIds32 actorIdthe unit of the hit or defeat being played
pendingCues32 pendingCuehit sound (an SE_ id), played on the next hit
flagss32 flagsbits: 0 Djinn bonus (EVENT_FLAG_DJINN_BONUS), for the enemies that fall during the action

Used by BattleEv_DispatchQueued, BattleEv_GrantDjinnBonus, BattleEventRuntime_BeginPhase, BattleEventRuntime_Reset, BattleEventRuntime_SchedulePhase, BattleEvent_Playback.

Line 51

BattleWork

struct BattleWork

The battle's own work: its enemies, units and their objects, the turn's actions, the spoils, the background palette, the plan and the events. It lives in the HEAP_SLOT_BATTLE work slot.

FieldDeclared as
enemyGroups32 enemyGroupthe encounter's enemy formation
spriteSlotss16 spriteSlots[6]the unit in each enemy sprite slot, 0 when free
enemyClassesu16 enemyClasses[6]The enemy classes met so far, for their name letters, and the first class to fall (firstDefeated).
summonMasksu32 summonMasks[6]Name letters in use by each class in enemyClasses, a bit per letter.
summonChannelss8 summonChannels[6]The letter each class in enemyClasses gave out last; -1 for none yet.
unk03au8 unk03a[2]not named by TBS code
firstDefeatedu16 firstDefeatedThe enemyClasses index of the first class to fall; 6 for none.
defeatStateu16 defeatStateDEFEAT_ONE, DEFEAT_SEVERAL or DEFEAT_BY_PARTY_MEMBER
summonCountu8 summonCountclasses listed in enemyClasses, at most 5
partyStatusu8 partyStatusPARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS
battleTypeu8 battleTypeFORMATION_SHUFFLED or FORMATION_INTERLEAVED
challengeFlagu8 challengeFlagbits: 1 a party unit was challenged; nonzero, the party cannot run
twoSidedu8 twoSided1 in a link battle
encounterModeu8 encounterModeBATTLE_ENCOUNTER_: who strikes first
escapeFailuresu8 escapeFailuresFailed attempts to run; each adds 2000 to the base chance of 5000.
unk047u8 unk047not named by TBS code
ownerSlotsu8 ownerSlots[8]For each party unit, its slot as a link opponent's enemy, minus FIRST_ENEMY_UNIT; 0xff for none.
linkSideu8 linkSidethis console's multiplayer id
linkMissesu8 linkMissesframes the link has been down
linkPausedu8 linkPausedset when the link drops or the console's id changes
unk053u8 unk053not named by TBS code
promptSlots32 promptSlotresource entry of the advance arrow's tiles; -1 for none
partyUnitss16 partyUnits[7]ends with BATTLE_UNIT_LIST_END
enemyIdss16 enemyIds[BATTLE_ENEMY_CAPACITY + 1]ends with BATTLE_UNIT_LIST_END
slotsstruct BattleObj slots[14]
placementu8 placement[14]Each unit's index in slots, enemies from 8; 0xff for none.
unk2eau8 unk2ea[2]not named by TBS code
actionsstruct BattleActionRecord actions[BATTLE_ACTION_CAPACITY]The actions chosen for the turn.
unk42cu8 unk42c[0x104]not named by TBS code
spoilsstruct BattleSpoils spoils
paletteu16 palette[128]the backdrop's colours, before scaling
brightnesss32 brightnessthe backdrop's brightness, 16.16, 0x10000 full
backgroundu16 backgroundthe battle background's id
unk64au8 unk64a[4]not named by TBS code
highlightStepu16 highlightStepindex into gBattleFx_HighlightBlendRamp
highlightModeu16 highlightModenonzero while the units are highlighted
unk652u8 unk652[2]not named by TBS code
planstruct BattlePlan plan
eventsstruct BattleEventState events
debugValues32 debugValueA value Runtime_AdjustDebugValueWithButtons edits with the d-pad while Start is held.

Used by BattleActor_RemoveFromLists, BattleBackground_Load, BattleCommand_BuildPlan, BattleEnemy_ClaimNameLetter, BattleEnemy_RecordDefeat, BattleEnemy_ReleaseNameLetter, BattleEscape_CheckSuccess, BattleEvent_Playback, BattleFormation_BuildEnemyList, BattleFx_BeginCanvasLayer, BattleFx_EndCanvasLayer, BattleFx_HideBg1AndRestoreBackdrop, BattleFx_OpenCanvasLayer, BattleFx_RunShatteringOpening, BattleFx_SetupBlendedDisplay, BattleFx_SetupCanvasTileMap, BattleIntro_AnnounceEncounter, BattleLayout_HighlightPartyPanels, BattleObjGet, BattleParty_CollectUnitList, BattleParty_ListActorIds, BattlePres_BuildOpponentEntries, BattlePres_RunEntryTransition, BattlePres_RunEscape, BattlePres_RunItem, BattlePresentation_AppendLinkedActions, BattlePresentation_BuildActions, BattlePresentation_DispatchAction, BattlePresentation_SetPaletteLevel, BattlePresentation_UpdateCamera, BattleSpoils_Clear, BattleTarget_RunSelection, BattleTarget_SelectForAction, BattleTarget_SelectRandomPosition, Battle_CollectPartyCommands, Battle_FindTaggedSlotByValue, Battle_GetTaggedSlotValue, Battle_GetWorkEntryPair, Battle_RunEncounter, EnemyCheck and 5 more.

Line 71

Globals, without a comment: gBattleDisplayWork, gBattleWork.

On this page