21 s32 sidePriorities[2];
45 s32 effectPriority = 0;
51 if (effect->
priority != effectPriority) {
67 sidePriorities[0] = 1;
68 sidePriorities[1] = 2;
70 sidePriorities[0] = 2;
71 sidePriorities[1] = 1;
77 for (unitIndex = 0; unitIndex < count; unitIndex++) {
85 record =
object->records;
107 for (unitIndex = 0; unitIndex <
count; unitIndex++) {
115 record =
object->records;
136#define ICON_POISON 0x01
137#define ICON_VENOM 0x02
138#define ICON_STUN 0x04
139#define ICON_PSY_SEAL 0x08
140#define ICON_SLEEP 0x10
141#define ICON_DELUSION 0x20
142#define ICON_HAUNT 0x40
143#define ICON_GRIM_REAPER 6
168 if (unit->
stun != 0) {
179 if (unit->
haunt != 0)
181 if (unit->
sleep != 0)
189#define ICON_CYCLE_FRAMES 80
192#define ICON_ANIM_NARROW 340
193#define ICON_ANIM_WIDE 355
212 s32 previousCondition;
227 owner = battleObject->
object;
231 for (iconAnimation = previousCondition + 1;; iconAnimation++) {
238 if (previousCondition != iconAnimation || shownIcon == 0) {
252 if (iconAnimation >= 0) {
253 if (record->
width == 32)
265 if (iconAnimation >= 0 && changed != 0) {
269 if (iconHandle == -1)
279 if (iconAnimation >= 0)
307 s32 notEnemy = unit->
side ^ pose;
308 pose = (
u32)(-notEnemy | notEnemy) >> 31;
328 if (battleObject !=
NULL) {
329 object = battleObject->
object;
330 if (
object !=
NULL) {
339 object->records =
NULL;
345#define NARROW_EFFECT_SPRITE 0x1ff
368 for (unitIndex = 0; unitIndex <
UNIT_MAX; unitIndex++) {
372 releasedUnitId = unitIndex;
382 for (unitIndex = 0; unitIndex <
UNIT_MAX &&
388 if (battleObject == 0)
391 object = battleObject->
object;
408 object->records = records;
430 object->records = record;
435 if ((spriteId = battleObject->
overlay) != 0) {
440 if ((spriteId = battleObject->
animation) != 0) {
447 if ((spriteId = battleObject->
effect) != 0) {
448 if (record->
width == 32)
467 (
object = battleObject->
object) != 0)
488 placementIndex = unitId;
489 if (battle->
placement[placementIndex] == 0xFF) {
492 return &objects[battle->
placement[placementIndex]];
501 if (record !=
NULL) {
502 for (entryIndex = 0; entryIndex < 4; entryIndex++) {
517 if (
object !=
NULL) {
519 switch (storageKind) {
524 recordGroups =
object->records;
527 recordGroup = *recordGroups++;
528 if (recordGroup !=
NULL) {
532 }
while (remaining >= 0);
566 if (placementIndex <= 7) {
567 unitId = placementIndex;
570 if ((battleObject !=
NULL) && (battleObject->
active != 0)) {
576 }
while (placementIndex <
UNIT_MAX);
631 if (recordIndex == 0) {
632 return object->records;
635 return ((
void **)object->
records)[recordIndex];
649 camera->
yaw = 192 << 6;
650 camera->
pitch = 254 << 8;
s32 BattleParty_ListActorIds(s32 sideMask, u16 *unitIds)
Lists the units in the battle's unit lists on the sides in sideMask, party first, skipping those remo...
s32 BattleMotion_ProjectPosition(s32 unitId, s32 *projected)
Projects unit id's position onto the screen, into projected.
void Camera_InitDefaultTransform(void)
Puts the battle camera at its default view of the battlefield's centre.
void BattleActor_UpdateSpritePriorities(void)
Runs each frame of a battle: advances every unit's status icon, lifts an airborne unit's effect sprit...
#define UNIT_MAX
the party's and the enemies' units together
void ResetMotionRecordGroup(void *recordGroup)
Detaches the scripts from the four sprite entries of one sprite.
void BattleActor_SpawnObjectsForList(s16 *unitIds, s32 refreshPoses)
Readies the sprites of the units in list: releases those of every place list lacks,...
s32 BattlePres_SetActorModeAndAction(s32 unitId)
Sets unit id's pose to match its state: held (asleep, stunned or unable to move) or down,...
s32 Battle_GetWorkEntryPair(s32 place, struct FixedPointPosition *position)
Writes the battlefield spot of place (its anchor, on the ground) to position.
struct BattleObj * BattleObjGet(s32 unitId)
Returns unitId's battle object, through its place, or null for a unit with no place.
s32 BattleStatusIcon_Cycle(struct BattleObj *battleObject)
Shows a unit's status icons one after another, each for ICON_CYCLE_FRAMES frames, switching at once w...
#define NARROW_EFFECT_SPRITE
The sprite unit 32 pixels wide use for an effect.
void ResetBattleObjectRecordGroups(struct MotionObject *object)
Detaches the scripts from every sprite of a battle object.
s32 Camera_ApplyTransformByFlag(void)
Sets up the camera's view for projecting points; under FLAG_CHOOSING_COMMANDS, through the extra tran...
s32 BattleUnit_BuildStatusFlags(s32 unitId, struct BattleObj *battleObject)
Builds the status icon bits of unit id's ailments into its battle object's activeConditions,...
s32 BattleObj_MarkForRelease(s32 unitId)
Frees the enemy sprite slots unitId holds and marks its object for release at the end of the round (B...
void * BattleMotion_DestroyAllSlotObjects(void)
Releases the object of every unit marked by BattleObj_MarkForRelease, leaving its battle object with ...
#define ICON_GRIM_REAPER
the curse's turns left, 1 to 7, as bits 7 to 13
#define ICON_CYCLE_FRAMES
The frames each status icon shows before the next one's turn.
void * GetMotionRecord(struct MotionObject *object, s32 recordIndex)
Returns sprite recordIndex of an object (0 only, for a single sprite), or null when it has no such sp...
#define ICON_MAX
the kinds of icon
void ReleaseBattleObjectRecords(s32 unitId)
Releases every sprite unitId's object holds and leaves it with none, clearing the battle object's ani...
#define ICON_ANIM_NARROW
The icons' first animations, for units 32 pixels wide and for the rest.
s32 BattleMotion_ReleaseObjectSlotByValue(s32 unitId)
Frees every enemy sprite slot unit unitId holds, unloading its sprite.
u8 gCamera_FlagTransformWork[]
@ POSE_PARTY_HELD
asleep, stunned or held; also a downed member
@ POSE_ENEMY_DOWN
a downed enemy stays in its damage pose
struct BattleCamera * gCameraWork
What every part of the battle object shares: its includes, in their original order,...
#define RECORDS_KIND_MASK
#define FIRST_ENEMY_UNIT
Unit ids from 128 are the enemies'; in a link battle the opponent's party takes the first three.
#define SPRITE_WITH_SECOND_PART_B
#define RECORDS_TABLE_SIZE
#define POISON_NORMAL
BattleUnit.poison: the poison takes a tenth of the maximum HP at the end of each turn,...
#define SPRITE_WITH_SECOND_PART_A
The two battle sprites whose next sprite is loaded with them (into a second free place),...
@ BATTLE_UNIT_LIST_END
ends the list
@ BATTLE_UNIT_REMOVED
a place whose unit has left the battle
struct BattleWork * gBattleWork
volatile u8 gSchedulerStatus
void ResourceMetadata_UnregisterFar(struct AnimationObject *state, s32 handle)
void ObjectDispatch_ReleaseFar(struct DispatchObject *obj)
struct AnimationObject * ResourceObject_CreateFar(s32 id)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
s32 ResourceMetadata_RegisterFar(struct AnimationObject *state, s32 id)
void ObjectDispatch_SetAnimationSpeedFar(struct DispatchObject *obj, s32 val)
void ResourceObject_ReleaseFar(struct AnimationObject *sprite)
void Animation_SetWorkEntryFar(struct AnimationEntry *work, s32 no)
struct BattleUnit * UnitGetFar(u32 owner)
s32 GameFlag_TestFar(s32 flag)
struct AnimationMetadata * Resource_GetMetadataRecordFar(u32 number)
#define FLAG_CHOOSING_COMMANDS
set while the commands are chosen
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
#define SPRITE_SECOND_PART
#define SPRITE_ID_MASK
A battle sprite id's low twelve bits; the two-part sprites' second part is their id + 0x2001.
#define Iwram_MulQ16(left, right)
static s32 Iwram_TransformVector(const void *vector, s32 *result)
static s32 Iwram_ClearWords(void *destination, s32 size)
static void Iwram_TransformMatrix(const s32 *matrix)
#define SET_POSITION(p, px, py, pz)
Sets the position or the velocity of a particle, a piece of debris or an object in one statement.
#define SET_VECTOR(v, x, y, z)
Sets the x, y and z of a three-part vector: a position about to be projected, a per-frame step,...
s32 BattlePlacement_ContainsId(s16 *list, s32 place)
Returns 1 if the unit at place is in list.
One animation layer of a sprite: its animation id, frames, running script and timer.
u8 * script
the running script; null when stopped (ANIM_CMD_END)
u8 priority
drawing order 0 to 3 among the layers; above 3 not drawn
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationSpritePart image
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
u8 width
pixels; zero marks a free sprite
struct AnimationEntry * entries[4]
its layers; empty ones null
u8 count
layers in use, up to the last one present
s32 scale
16.16 fixed point, 0x10000 full size
u8 dirty
nonzero redraws its pixels into VRAM when next drawn
u16 priority
2 when created
The battle camera: its eye, the focus it turns about, and its pitch, yaw and distance.
s32 distance
eye to focus, 16.16 fixed-point pixels
s32 * followPos
when set, the focus followed instead of pos
s32 pos[3]
the focus, 16.16 fixed-point pixels
s32 eye[3]
The eye, 16.16 fixed-point pixels: written each frame distance behind the focus along the turned view...
s32 unk18
cleared beside followPos; not read by name in TBS
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
struct SpriteEntry * effectEntry
the effect sprite, or NULL
struct MotionObject * object
NULL once released.
u16 animation
the status icon's animation shown; 0 for none
u16 activeConditions
a bit per status with an icon (ICON_)
u8 selectedCondition
the status whose icon is shown
s8 cycleTimer
frames until the next status icon
u16 resource
the unit's sprite
s32 palette
the unit sprite's palette
s32 scale
16.16 fixed point, 0x10000 full size
u16 effect
an effect sprite drawn with the unit
s16 active
Set by BattleObj_MarkForRelease: the object is released with the others by BattleMotion_DestroyAllSlo...
struct SpriteEntry * animationEntry
the status icon's sprite, or NULL
s32 anchorZ
16.16 fixed-point pixels
u16 overlay
a second sprite drawn over it, the weapon; 0 for none
s32 anchorX
16.16 fixed-point pixels
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 immobile
set by Ground: the next action is lost
u8 grimReaper
The Grim Reaper's countdown: 7 when cursed, down one at each turn's end; at 0 the unit falls.
u8 psySeal
bits: 7..3 Luff (16 when cast, minus 8 a turn) | 2..0 Bind's turns (7 when cast).
u8 side
BATTLE_UNIT_ABSENT (0), BATTLE_UNIT_ENEMY (1) or BATTLE_UNIT_PARTY (2).
s8 poison
1 poisoned, 2 deadly poison
u8 haunt
set while an evil spirit grips the unit
s16 hp
current HP, 0 when downed
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
u8 delusion
Delusion to sleep: the turns each status has left, 7 when it lands; each may end sooner at the end of...
The battle's own work: its enemies, units and their objects, the turn's actions, the spoils,...
struct BattleObj slots[14]
u8 placement[14]
Each unit's index in slots, enemies from 8; 0xff for none.
A field object as the object dispatcher's far calls take it.
A position in three coordinates, each in 16.16 fixed point.
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
s32 z
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
void * records
one sprite, or a table of up to four (recordStorageKind)
u8 recordStorageKind
bits: 3..0 RECORDS_NONE, RECORDS_SINGLE or RECORDS_TABLE
s32 x
16.16 fixed-point pixels
s32 count
sprite group tables taken from unk08
u8 unk08[0x10]
the sprite group tables, taken in turn by count
A sprite of an animation record, as battle objects set its palette and drawing priority.