55 events->
timer = frames;
67#define PLAY_MESSAGE_ADD 13
71#define FELLED_FLASH 0x400
73#define FELLED_FLASH_FRAMES 30
130 if (events->
timer != 0) {
205 for (recordIndex = 0;
277 ((
u32 *)prompt)[1] = 0xa000;
278 ((
u32 *)prompt)[2] =
x;
280 x = window->
x * 8 + (offset->
x >> 8) + 4;
283 (offset->
y >> 8) + 6;
298 if (events->
timer & 1) {
299 if (events->
timer & 2) {
307 selection[0] = events->
actorId;
315 if (events->
timer <= 8)
329 if (events->
timer == 0 && events->
flags != 0) {
343 if (events->
timer == 0) {
359 for (recordIndex = 0,
slot = records, lastFrameMask = 0xff;
368 previousFrame = child->
frame;
369 child->
param = colorMode;
370 child->
frame = previousFrame | lastFrameMask;
376 if (events->
timer == 4) {
381 if (events->
timer > 4) {
395 records[
count] = record;
396 base = events->
timer * 4;
401 for (recordIndex = 0; recordIndex <
count; recordIndex++)
402 BattleSprite_ClearTiles(records[recordIndex], 0);
411 for (recordIndex = 0; recordIndex <
count; recordIndex++) {
464 state = events->
phase;
478#undef FELLED_FLASH_FRAMES
@ SPRITE_COLOR_WHITE
solid colour 15, white
@ SPRITE_COLOR_GREY
greyscale
u32 BattleClass_GetDefeatSoundKind(s32 index)
Returns the class's defeat-sound kind, 0 to 4, or -1 for none; a fallen enemy's sound is SE_146 plus ...
s32 BattleActor_ResetRuntimeFields(s32 unitId)
Clears every ailment and stat change of a unit that goes down, recalculates its stats and rebuilds it...
s32 BattleActor_DestroyTemporaryObject(s32 unitId)
Takes an enemy out of the battle at once (one that leaves rather than falls): its HP to 0,...
void BattleEv_GrantDjinnBonus(struct BattleEventState *runtime, u32 operand)
The BATTLE_EVENT_DJINN_BONUS event: grants the Djinn bonus for the rest of the action.
s32 BattlePres_SetActorModeAndAction(s32 unitId)
Sets unit id's pose to match its state: held (asleep, stunned or unable to move) or down,...
struct BattleObj * BattleObjGet(s32 unitId)
Returns unitId's battle object, through its place, or null for a unit with no place.
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 * 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...
s32 BattleMotion_GetSlotPalette(s32 id)
Returns the palette of unit id's battle object.
@ POSE_PARTY_HELD
asleep, stunned or held; also a downed member
@ POSE_ENEMY_DOWN
a downed enemy stays in its damage pose
@ POSE_DAMAGE
taking damage
u8 gBattlePres_AdvanceArrowTiles[]
void _call_via_r0(u32 routine)
@ BATTLE_PLAYBACK_RESOLVE_TARGET
resolves the next target's events
@ BATTLE_PLAYBACK_READY
every target has been played
@ BATTLE_PLAYBACK_IDLE
paused until the effect resumes it
@ BATTLE_PLAYBACK_DISPATCH
plays the queued events in order
@ BATTLE_EVENT_DEFEAT
the unit falls; an enemy fades out
@ BATTLE_EVENT_UNIT_NAME
a unit's name for the next message
@ BATTLE_EVENT_MARK
sets gBattleDisplayWork->marked
@ BATTLE_EVENT_DRAW_STATUS
redraws the party's status
@ BATTLE_EVENT_DJINN_BONUS
later defeats give the Djinn bonus
@ BATTLE_EVENT_HIT
the unit flinches and flashes
@ BATTLE_EVENT_CLEAR_ARGUMENTS
forgets the names and numbers pushed
@ BATTLE_EVENT_ABILITY_NAME
an ability's name for the next message
@ BATTLE_EVENT_REFRESH_UNIT
the unit's status icons, colour, pose
@ BATTLE_EVENT_REMOVE_UNIT
an enemy leaves the battle
@ BATTLE_EVENT_MESSAGE
a message, waiting for the player
@ BATTLE_EVENT_MESSAGE_NO_WAIT
a message, going straight on
@ BATTLE_EVENT_ITEM_NAME
an item's name for the next message
@ BATTLE_EVENT_NUMBER
a number for the next message
@ BATTLE_EVENT_SOUND
plays a sound
What every part of the battle object shares: its includes, in their original order,...
#define VALUE_ABILITY_NAME
#define KEY_ADVANCE
The keys that take the player on past a message: A, B, L and R.
@ BATTLE_UNIT_LIST_END
ends the list
struct BattleWork * gBattleWork
struct BattleDisplayWork * gBattleDisplayWork
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
s32 AnimationObjects_SelectAnimationFar(struct AnimationObject *state, s32 flags)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void render_animated_tile_frameFar(u8 *obj, u32 pos)
Far call to Map_RenderAnimatedTileFrame.
struct BattleUnit * UnitGetFar(u32 owner)
void AudioCommand_PlayFar(s32 id)
s32 BattleLayout_HighlightPartyPanelsFar(u16 *ids)
void PartyStatusDrawFar(s32 flags)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
s32 UiWork_IsCompleteFar(void)
void UiWork_ClearValueNameTablesFar(void)
void UiText_PrepareMessageWorkFar(s32 argument)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
u32 gFrameTick
Counted up by every VBlank.
volatile u32 gFrameCount
Frames WaitFrames has finished.
void IoWriteQueue_ClearBits16(u32 address, u32 value)
Queues clearing a halfword register's bits.
void IoWriteQueue_SetBits16(u32 address, u32 value)
Queues setting a halfword register's bits.
#define OBJ_VRAM0
Sprite tile memory, as pret names it: the 32 KB from 0x06010000.
#define DMA_COPY_WORDS(n)
const u32 IwramIrqModeWord
static s32 Iwram_ClearWords(void *destination, s32 size)
u32 gKeysPressedLatch
Presses since a reader last cleared it.
#define PLAY_FELLED
greys a fallen enemy and dissolves it
s32 BattleEventRuntime_SchedulePhase(s32 frames)
Empties the event queue and schedules playback of the events queued next, with no targets to resolve.
s32 BattleEventRuntime_WaitForReady(void)
Waits, a frame at a time, until BattleEvent_Playback has played every target, then removes the callba...
void BattleEventRuntime_Reset(void)
Stops playback and empties the event queue.
#define PLAY_ADVANCE
shows the arrow and waits for the player
#define FELLED_FLASH_FRAMES
The Djinn bonus's colour cycle lasts 30 frames.
#define FELLED_FLASH
PLAY_FELLED's timer from here counts the Djinn bonus's colour cycle, kept apart from the counts of th...
void BattleEventRuntime_BeginPhase(s32 cue)
Starts playback of the plan's targets when the effect's blow lands.
void BattleEvent_Playback(void)
Plays the plan's targets one at a time: resolves the next target with BattleTargetExec,...
#define PLAY_HIT
flashes the unit that was hit
#define PLAY_MESSAGE_ADD
waits for the message, then goes straight on
#define PLAY_MESSAGE
waits for the message, then for the player
void Dma_StopAllThenRunHook(void)
Sets DMA3 three times over, stopping it, then calls the IRQ return instruction's word as a routine.
void Runtime_PushSlotEntry(void *slotEntry, s32 slot)
Links a sprite entry into depth slot slot (clamped to 0..255) for this frame.
s32 Scheduler_AddOrUpdateCallback(SchedulerCallback callback, s32 order)
Schedules callback with order, or gives a task already running it the new order, and re-sorts the tab...
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
#define SE_MENU_CURSOR_MOVE
s32 BattleEnemy_RecordDefeat(s32 unitId, s32 djinnBonus)
Counts a fallen enemy and adds its coins, experience and perhaps its item to the spoils.
s32 BattleMotion_SetRecordChildValues(struct MotionObject *object, s32 colorMode)
Draws every sprite of an object in a colour mode (enum SpriteColorMode): colorMode on each sprite's f...
void BattleActor_RemoveFromLists(s32 unitId)
Takes unit id out of the party's or the enemies' list and out of this round's actions,...
One animation layer of a sprite: its animation id, frames, running script and timer.
u8 param
SpriteColorMode its pixels are drawn with; 0 when taken.
u8 frame
frame shown, frameBase plus the facing offset; 255 none
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
u8 width
pixels; zero marks a free sprite
u8 slot
VRAM cache entry holding its tiles.
struct AnimationEntry * entries[4]
its layers; empty ones null
u8 count
layers in use, up to the last one present
The battle message's text channel, as far as its offset in the window.
The battle message display: its window, its text channel and whether the next message is marked.
s32 marked
set by BATTLE_EVENT_MARK; passed to the next message
struct UiWindow * window
the message window
struct BattleDisplayOffset * offset
its text channel
s32 targetIndex
the plan's next target to resolve
u32 operands[BATTLE_EVENT_CAPACITY]
u8 opcodes[BATTLE_EVENT_CAPACITY]
The battle event queue and the state of its playback: the phase, the event playing and the advance ar...
struct BattleEventQueue queue
s32 timer
frames to wait, or frames waited for the advance key
struct BattlePromptSprite displayEntry
the advance arrow
s32 actorId
the unit of the hit or defeat being played
s32 phase
enum BattlePlaybackPhase, or a message phase
s32 pendingCue
hit sound (an SE_ id), played on the next hit
s32 displaySource
the arrow's resource entry; -1 until it is shown
s32 eventIndex
the next queued event to play
s32 flags
bits: 0 Djinn bonus (EVENT_FLAG_DJINN_BONUS), for the enemies that fall during the action
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
struct MotionObject * object
NULL once released.
s8 targetCount
targets in targetIds
One OAM entry in a sprite list: the arrow that waits for the player to advance a battle message.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 side
BATTLE_UNIT_ABSENT (0), BATTLE_UNIT_ENEMY (1) or BATTLE_UNIT_PARTY (2).
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
The battle's own work: its enemies, units and their objects, the turn's actions, the spoils,...
u8 partyStatus
PARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS.
s32 promptSlot
resource entry of the advance arrow's tiles; -1 for none
struct BattleEventState events
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
u16 offset
bytes from the start of OBJ VRAM
s32 BattleTargetExec(struct BattlePlan *plan, s32 slot)
Applies the planned ability to one of its targets: first its damage or healing, then its added effect...
s32 VramCache_Reload(s32 no, s32 src)
Copies src again into entry no's VRAM, keeping its size.
struct VramBlockCacheEntry gVramBlockCache[]