Alchemy
Loading...
Searching...
No Matches

battle_work.h

Go to the documentation of this file.
1#ifndef ALCHEMY_BATTLE_WORK_H
2#define ALCHEMY_BATTLE_WORK_H
3
4/// @file
5/// BattleWork, the battle's own work, and the battle display work.
6
8#include "types.h"
9#include "static_assert.h"
10#include "battle_type.h"
11#include "battle_event.h"
12#include "battle_session.h"
13
14/// One OAM entry in a sprite list: the arrow that waits for the player to
15/// advance a battle message.
18 u16 y : 8; ///< pixels
20 u16 x : 9; ///< pixels
21 u16 size : 7;
22 u16 tile : 10;
24 u16 unk0a; ///< cleared with the tile word each frame; not named
25};
26
27struct UiWindow;
28
29/// The battle message's text channel, as far as its offset in the window.
31 s32 unk00; ///< not named by TBS code
32 u16 x; ///< 1/256 pixels
33 u16 y; ///< 1/256 pixels
34};
35
36/// The battle message display: its window, its text channel and whether the
37/// next message is marked.
39 struct UiWindow *window; ///< the message window
40 struct BattleDisplayOffset *offset; ///< its text channel
41 s32 marked; ///< set by BATTLE_EVENT_MARK; passed to the next message
42};
43
45STATIC_ASSERT(sizeof(struct BattleDisplayWork) == 12);
48
49/// The battle event queue and the state of its playback: the phase, the event
50/// playing and the advance arrow.
53 s32 phase; ///< enum BattlePlaybackPhase, or a message phase
54 s32 eventIndex; ///< the next queued event to play
55 s32 timer; ///< frames to wait, or frames waited for the advance key
56 struct BattlePromptSprite displayEntry; ///< the advance arrow
57 s32 displaySource; ///< the arrow's resource entry; -1 until it is shown
58 s32 actorId; ///< the unit of the hit or defeat being played
59 s32 pendingCue; ///< hit sound (an SE_ id), played on the next hit
60 /// bits: 0 Djinn bonus (EVENT_FLAG_DJINN_BONUS), for the enemies that fall
61 /// during the action
63};
64
65/// Six enemies at most, and a turn's queue of up to 20 actions.
67
68/// The battle's own work: its enemies, units and their objects, the turn's
69/// actions, the spoils, the background palette, the plan and the events. It
70/// lives in the HEAP_SLOT_BATTLE work slot.
71struct BattleWork {
72 s32 enemyGroup; ///< the encounter's enemy formation
73 s16 spriteSlots[6]; ///< the unit in each enemy sprite slot, 0 when free
74 /// The enemy classes met so far, for their name letters, and the first
75 /// class to fall (firstDefeated).
77 /// Name letters in use by each class in enemyClasses, a bit per letter.
79 /// The letter each class in enemyClasses gave out last; -1 for none yet.
81 u8 unk03a[2]; ///< not named by TBS code
82 /// The enemyClasses index of the first class to fall; 6 for none.
84 u16 defeatState; ///< DEFEAT_ONE, DEFEAT_SEVERAL or DEFEAT_BY_PARTY_MEMBER
85 u8 summonCount; ///< classes listed in enemyClasses, at most 5
86 u8 partyStatus; ///< PARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS
87 u8 battleType; ///< FORMATION_SHUFFLED or FORMATION_INTERLEAVED
88 /// bits: 1 a party unit was challenged; nonzero, the party cannot run
90 u8 twoSided; ///< 1 in a link battle
91 u8 encounterMode; ///< BATTLE_ENCOUNTER_: who strikes first
92 /// Failed attempts to run; each adds 2000 to the base chance of 5000.
94 u8 unk047; ///< not named by TBS code
95 /// For each party unit, its slot as a link opponent's enemy, minus
96 /// FIRST_ENEMY_UNIT; 0xff for none.
98 u8 linkSide; ///< this console's multiplayer id
99 u8 linkMisses; ///< frames the link has been down
100 u8 linkPaused; ///< set when the link drops or the console's id changes
101 u8 unk053; ///< not named by TBS code
102 s32 promptSlot; ///< resource entry of the advance arrow's tiles; -1 for none
103 s16 partyUnits[7]; ///< ends with BATTLE_UNIT_LIST_END
104 s16 enemyIds[BATTLE_ENEMY_CAPACITY + 1]; ///< ends with BATTLE_UNIT_LIST_END
105 struct BattleObj slots[14];
106 /// Each unit's index in slots, enemies from 8; 0xff for none.
108 u8 unk2ea[2]; ///< not named by TBS code
109 /// The actions chosen for the turn.
111 u8 unk42c[0x104]; ///< not named by TBS code
113 u16 palette[128]; ///< the backdrop's colours, before scaling
114 s32 brightness; ///< the backdrop's brightness, 16.16, 0x10000 full
115 u16 background; ///< the battle background's id
116 u8 unk64a[4]; ///< not named by TBS code
117 u16 highlightStep; ///< index into gBattleFx_HighlightBlendRamp
118 u16 highlightMode; ///< nonzero while the units are highlighted
119 u8 unk652[2]; ///< not named by TBS code
122 /// A value Runtime_AdjustDebugValueWithButtons edits with the d-pad while
123 /// Start is held.
125};
126
127STATIC_ASSERT(sizeof(struct BattleWork) == 0x82c);
128
129STATIC_ASSERT(offsetof(struct BattleWork, partyStatus) == 0x041);
130STATIC_ASSERT(offsetof(struct BattleWork, challengeFlag) == 0x043);
131STATIC_ASSERT(offsetof(struct BattleWork, partyUnits) == 0x058);
132STATIC_ASSERT(offsetof(struct BattleWork, enemyIds) == 0x066);
133STATIC_ASSERT(offsetof(struct BattleWork, slots) == 0x074);
134STATIC_ASSERT(offsetof(struct BattleWork, placement) == 0x2dc);
135STATIC_ASSERT(offsetof(struct BattleWork, actions) == 0x2ec);
136STATIC_ASSERT(offsetof(struct BattleWork, spoils) == 0x530);
137STATIC_ASSERT(offsetof(struct BattleWork, palette) == 0x544);
138STATIC_ASSERT(offsetof(struct BattleWork, brightness) == 0x644);
139STATIC_ASSERT(offsetof(struct BattleWork, background) == 0x648);
140STATIC_ASSERT(offsetof(struct BattleWork, plan) == 0x654);
141STATIC_ASSERT(offsetof(struct BattleWork, events) == 0x6b8);
144
145extern struct BattleWork *gBattleWork;
146
147#endif
The battle event queue: the events BattleEvPush queues and the playback phases that play them.
A battle's objects and sprites, each unit's command and action record, and the spoils.
BattlePlan, an action planned for its targets: the hits, criticals and multipliers rolled.
struct BattleWork * gBattleWork
struct BattleDisplayWork * gBattleDisplayWork
@ BATTLE_ENEMY_CAPACITY
Definition battle_work.h:66
@ BATTLE_ACTION_CAPACITY
Definition battle_work.h:66
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
A unit's chosen action for the turn: its command, the command's parameter, its target and range,...
The battle message's text channel, as far as its offset in the window.
Definition battle_work.h:30
u16 x
1/256 pixels
Definition battle_work.h:32
u16 y
1/256 pixels
Definition battle_work.h:33
s32 unk00
not named by TBS code
Definition battle_work.h:31
The battle message display: its window, its text channel and whether the next message is marked.
Definition battle_work.h:38
s32 marked
set by BATTLE_EVENT_MARK; passed to the next message
Definition battle_work.h:41
struct UiWindow * window
the message window
Definition battle_work.h:39
struct BattleDisplayOffset * offset
its text channel
Definition battle_work.h:40
The battle event queue: up to 64 events, each an opcode (enum BattleEventOpcode) and one operand,...
The battle event queue and the state of its playback: the phase, the event playing and the advance ar...
Definition battle_work.h:51
struct BattleEventQueue queue
Definition battle_work.h:52
s32 timer
frames to wait, or frames waited for the advance key
Definition battle_work.h:55
struct BattlePromptSprite displayEntry
the advance arrow
Definition battle_work.h:56
s32 actorId
the unit of the hit or defeat being played
Definition battle_work.h:58
s32 phase
enum BattlePlaybackPhase, or a message phase
Definition battle_work.h:53
s32 pendingCue
hit sound (an SE_ id), played on the next hit
Definition battle_work.h:59
s32 displaySource
the arrow's resource entry; -1 until it is shown
Definition battle_work.h:57
s32 eventIndex
the next queued event to play
Definition battle_work.h:54
s32 flags
bits: 0 Djinn bonus (EVENT_FLAG_DJINN_BONUS), for the enemies that fall during the action
Definition battle_work.h:62
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
One action, as BattleCommand_BuildPlan lays it out for BattleTargetExec to apply target by target.
Definition battle_type.h:26
One OAM entry in a sprite list: the arrow that waits for the player to advance a battle message.
Definition battle_work.h:16
u16 unk0a
cleared with the tile word each frame; not named
Definition battle_work.h:24
struct BattlePromptSprite * next
Definition battle_work.h:17
A battle's spoils so far: coins, experience, enemies defeated and up to four items.
The battle's own work: its enemies, units and their objects, the turn's actions, the spoils,...
Definition battle_work.h:71
u8 partyStatus
PARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS.
Definition battle_work.h:86
s32 promptSlot
resource entry of the advance arrow's tiles; -1 for none
u16 highlightStep
index into gBattleFx_HighlightBlendRamp
u16 firstDefeated
The enemyClasses index of the first class to fall; 6 for none.
Definition battle_work.h:83
struct BattlePlan plan
u16 background
the battle background's id
u8 unk652[2]
not named by TBS code
u8 twoSided
1 in a link battle
Definition battle_work.h:90
s32 enemyGroup
the encounter's enemy formation
Definition battle_work.h:72
u8 ownerSlots[8]
For each party unit, its slot as a link opponent's enemy, minus FIRST_ENEMY_UNIT; 0xff for none.
Definition battle_work.h:97
u8 encounterMode
BATTLE_ENCOUNTER_: who strikes first.
Definition battle_work.h:91
u8 summonCount
classes listed in enemyClasses, at most 5
Definition battle_work.h:85
u16 enemyClasses[6]
The enemy classes met so far, for their name letters, and the first class to fall (firstDefeated).
Definition battle_work.h:76
struct BattleObj slots[14]
u8 unk2ea[2]
not named by TBS code
s8 summonChannels[6]
The letter each class in enemyClasses gave out last; -1 for none yet.
Definition battle_work.h:80
struct BattleEventState events
s16 partyUnits[7]
ends with BATTLE_UNIT_LIST_END
u8 challengeFlag
bits: 1 a party unit was challenged; nonzero, the party cannot run
Definition battle_work.h:89
u8 placement[14]
Each unit's index in slots, enemies from 8; 0xff for none.
u16 defeatState
DEFEAT_ONE, DEFEAT_SEVERAL or DEFEAT_BY_PARTY_MEMBER.
Definition battle_work.h:84
s32 brightness
the backdrop's brightness, 16.16, 0x10000 full
u8 unk053
not named by TBS code
u8 unk03a[2]
not named by TBS code
Definition battle_work.h:81
u8 escapeFailures
Failed attempts to run; each adds 2000 to the base chance of 5000.
Definition battle_work.h:93
u8 battleType
FORMATION_SHUFFLED or FORMATION_INTERLEAVED.
Definition battle_work.h:87
s32 debugValue
A value Runtime_AdjustDebugValueWithButtons edits with the d-pad while Start is held.
u32 summonMasks[6]
Name letters in use by each class in enemyClasses, a bit per letter.
Definition battle_work.h:78
struct BattleActionRecord actions[BATTLE_ACTION_CAPACITY]
The actions chosen for the turn.
u8 linkPaused
set when the link drops or the console's id changes
u8 linkSide
this console's multiplayer id
Definition battle_work.h:98
struct BattleSpoils spoils
u8 linkMisses
frames the link has been down
Definition battle_work.h:99
u8 unk047
not named by TBS code
Definition battle_work.h:94
u16 palette[128]
the backdrop's colours, before scaling
s16 enemyIds[BATTLE_ENEMY_CAPACITY+1]
ends with BATTLE_UNIT_LIST_END
u8 unk64a[4]
not named by TBS code
u8 unk42c[0x104]
not named by TBS code
u16 highlightMode
nonzero while the units are highlighted
s16 spriteSlots[6]
the unit in each enemy sprite slot, 0 when free
Definition battle_work.h:73
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
Definition uiwindow.h:11
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed char s8
Definition types.h:10
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11