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.
| Field | Declared as | |
|---|---|---|
next | struct BattlePromptSprite *next | |
y | u16 y : 8 | pixels |
flags | u16 flags : 8 | |
x | u16 x : 9 | pixels |
size | u16 size : 7 | |
tile | u16 tile : 10 | |
palette | u16 palette : 6 | |
unk0a | u16 unk0a | cleared with the tile word each frame; not named |
Used by BattleEvent_Playback.
BattleDisplayOffset
struct BattleDisplayOffset
The battle message's text channel, as far as its offset in the window.
| Field | Declared as | |
|---|---|---|
unk00 | s32 unk00 | not named by TBS code |
x | u16 x | 1/256 pixels |
y | u16 y | 1/256 pixels |
Used by BattleEvent_Playback, BattlePresentation_WaitForAdvance, UiText_PrepareMessageWork.
BattleDisplayWork
struct BattleDisplayWork
The battle message display: its window, its text channel and whether the next message is marked.
| Field | Declared as | |
|---|---|---|
window | struct UiWindow *window | the message window |
offset | struct BattleDisplayOffset *offset | its text channel |
marked | s32 marked | set by BATTLE_EVENT_MARK; passed to the next message |
Used by BattleEvent_Playback, Battle_RunEncounter, UiText_DrawGlyph, UiText_PrepareMessageWork, UiWork_FinalizeSharedSlot, gBattleDisplayWork.
BattleEventState
struct BattleEventState
The battle event queue and the state of its playback: the phase, the event playing and the advance arrow.
| Field | Declared as | |
|---|---|---|
queue | struct BattleEventQueue queue | |
phase | s32 phase | enum BattlePlaybackPhase, or a message phase |
eventIndex | s32 eventIndex | the next queued event to play |
timer | s32 timer | frames to wait, or frames waited for the advance key |
displayEntry | struct BattlePromptSprite displayEntry | the advance arrow |
displaySource | s32 displaySource | the arrow's resource entry; -1 until it is shown |
actorId | s32 actorId | the unit of the hit or defeat being played |
pendingCue | s32 pendingCue | hit sound (an SE_ id), played on the next hit |
flags | s32 flags | bits: 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.
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.
| Field | Declared as | |
|---|---|---|
enemyGroup | s32 enemyGroup | the encounter's enemy formation |
spriteSlots | s16 spriteSlots[6] | the unit in each enemy sprite slot, 0 when free |
enemyClasses | u16 enemyClasses[6] | The enemy classes met so far, for their name letters, and the first class to fall (firstDefeated). |
summonMasks | u32 summonMasks[6] | Name letters in use by each class in enemyClasses, a bit per letter. |
summonChannels | s8 summonChannels[6] | The letter each class in enemyClasses gave out last; -1 for none yet. |
unk03a | u8 unk03a[2] | not named by TBS code |
firstDefeated | u16 firstDefeated | The enemyClasses index of the first class to fall; 6 for none. |
defeatState | u16 defeatState | DEFEAT_ONE, DEFEAT_SEVERAL or DEFEAT_BY_PARTY_MEMBER |
summonCount | u8 summonCount | classes listed in enemyClasses, at most 5 |
partyStatus | u8 partyStatus | PARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS |
battleType | u8 battleType | FORMATION_SHUFFLED or FORMATION_INTERLEAVED |
challengeFlag | u8 challengeFlag | bits: 1 a party unit was challenged; nonzero, the party cannot run |
twoSided | u8 twoSided | 1 in a link battle |
encounterMode | u8 encounterMode | BATTLE_ENCOUNTER_: who strikes first |
escapeFailures | u8 escapeFailures | Failed attempts to run; each adds 2000 to the base chance of 5000. |
unk047 | u8 unk047 | not named by TBS code |
ownerSlots | u8 ownerSlots[8] | For each party unit, its slot as a link opponent's enemy, minus FIRST_ENEMY_UNIT; 0xff for none. |
linkSide | u8 linkSide | this console's multiplayer id |
linkMisses | u8 linkMisses | frames the link has been down |
linkPaused | u8 linkPaused | set when the link drops or the console's id changes |
unk053 | u8 unk053 | not named by TBS code |
promptSlot | s32 promptSlot | resource entry of the advance arrow's tiles; -1 for none |
partyUnits | s16 partyUnits[7] | ends with BATTLE_UNIT_LIST_END |
enemyIds | s16 enemyIds[BATTLE_ENEMY_CAPACITY + 1] | ends with BATTLE_UNIT_LIST_END |
slots | struct BattleObj slots[14] | |
placement | u8 placement[14] | Each unit's index in slots, enemies from 8; 0xff for none. |
unk2ea | u8 unk2ea[2] | not named by TBS code |
actions | struct BattleActionRecord actions[BATTLE_ACTION_CAPACITY] | The actions chosen for the turn. |
unk42c | u8 unk42c[0x104] | not named by TBS code |
spoils | struct BattleSpoils spoils | |
palette | u16 palette[128] | the backdrop's colours, before scaling |
brightness | s32 brightness | the backdrop's brightness, 16.16, 0x10000 full |
background | u16 background | the battle background's id |
unk64a | u8 unk64a[4] | not named by TBS code |
highlightStep | u16 highlightStep | index into gBattleFx_HighlightBlendRamp |
highlightMode | u16 highlightMode | nonzero while the units are highlighted |
unk652 | u8 unk652[2] | not named by TBS code |
plan | struct BattlePlan plan | |
events | struct BattleEventState events | |
debugValue | s32 debugValue | A 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.
Globals, without a comment: gBattleDisplayWork, gBattleWork.