10#define TRANSITION_STORM_FORMATION 0x15b
13#define TRANSITION_CURTAIN_ENTRY(n) (0xf080 + (n))
31 volatile u16 *registerCursor;
36 bg1cnt = *++registerCursor;
38 bg2cnt = *++registerCursor;
40 bg3cnt = *++registerCursor;
43 registerCursor += 0x21;
50 for (mosaicSize = 0; mosaicSize <= 15; mosaicSize++) {
62 *registerCursor++ = bg0cnt;
63 *registerCursor++ = bg1cnt;
64 *registerCursor++ = bg2cnt;
65 *registerCursor = bg3cnt;
76 s32 *destination = tilemap;
81 packedIndices = 0x03020100;
85 *destination++ = packedIndices;
86 packedIndices += 0x04040404U;
87 }
while (wordIndex >= 0 && wordIndex <= 63);
89 packedIndices = 0x03020100;
93 *destination++ = packedIndices;
94 packedIndices += 0x04040404U;
95 }
while (wordIndex >= 0 && wordIndex <= 55);
107 s32 *destination = tilemap;
115 entry = (0x0201 << 16) | 0x0200;
120 *destination++ = entry;
122 }
while (index <= 239);
139 line = scanlines->
lines[scanlines->
page];
178 scroll = 0x34 - frame;
187 camera->
yaw = 45 * frame * 8 + 0xaf80;
188 next = (*timer = *timer + 1);
210 transitionFrame = *
gDisp;
211 if (transitionFrame >= 0 && transitionFrame <= 79) {
212 tileEntry = (7 & transitionFrame) + 0xf081;
215 if (transitionFrame >= 0) {
216 alignedFrame = transitionFrame;
218 alignedFrame = transitionFrame + 7;
220 tileRow = 13 - (alignedFrame >> 3);
225 *tilemap = tileEntry;
227 }
while (column != 32);
231 alignedFrame = transitionFrame;
232 if (transitionFrame < 0) {
235 tileRow = (alignedFrame >> 3) + 13;
241 *tilemap = tileEntry;
243 }
while (column != 32);
276 u16 visibleUnitIds[14];
316 asm volatile(
"" :
"+l"(dma));
322 background->
mode = 1;
323 background->
busy = 0;
328 background->
mode = 2;
331 for (index = 0; index <= 31; index++) {
336 for (column = 0; column <= 31; column++)
383 background->
busy = 0;
385 for (index = 0; index != count; index++) {
395 object->scale = 0xb333;
425 visibleUnits = visibleUnitIds;
432 for (index = 0; index != visibleCount; index++)
434 for (index = 0; index != 16; index++) {
438 for (index = 0; index != visibleCount; index++)
457#undef TRANSITION_CURTAIN_ENTRY
458#undef TRANSITION_STORM_FORMATION
void BattlePres_SetActorRecordMode(s32 actorId, s32 mode)
Sets the OBJ mode (1 semi-transparent, 0 normal) of every sprite of a unit's battle object,...
void BattlePres_SetupTransitionScene(s32 x, s32 depth, s32 y, s32 zoom)
Points the battle camera at (x, depth, y) with a zoom in percent, and lines the perspective plane up ...
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...
void BattleActor_SpawnObjectsForList(s16 *unitIds, s32 refreshPoses)
Readies the sprites of the units in list: releases those of every place list lacks,...
struct BattleObj * BattleObjGet(s32 unitId)
Returns unitId's battle object, through its place, or null for a unit with no place.
void BattleIntro_AnnounceEncounter(s32 enemyCount)
Announces the enemies at the start of a battle, then whether the party strikes first or is caught by ...
void BattlePresentation_BuildTilemap(void *tilemap)
Builds BG1's flat map of the same picture: rows 0 to 3 0xffff, rows 4 and 5 tile 0x3ff,...
void BattlePres_AdvanceTransitionTimer(void)
Advances the curtain opening by a frame: scrolls BG0 from 32 pixels to 0 over frames 20 to 52,...
#define TRANSITION_STORM_FORMATION
The formation the Fusion Dragon leads (row 347 of formatn.tsv, whose first member is enemy 140),...
void BattlePresentation_UploadTileVariant(void)
Copies one of eight curtain tiles from gBattlePres_TileVariants into CURTAIN_TILE(0),...
void BattlePres_UpdateHBlankScroll(void)
Shows the perspective plane's finished page each frame while the background is in mode 2: its first l...
void Graphics_ClearBg0Vofs(void)
Clears REG_BG0VOFS, so that BG0's scroll applies only above the line the interrupt fires on.
void BattlePres_RunEntryTransition(s32 enemyCount, s32 encounterId)
Opens a battle: the curtain opening, or for the Fusion Dragon the storm on the Venus Lighthouse aerie...
#define TRANSITION_CURTAIN_ENTRY(n)
The curtain's map entries: tile 128 + n of CURTAIN_TILE, palette 15.
void BattlePres_DrawTransitionRows(void)
Draws a frame of the curtain opening on BG1: over 80 frames a row moves up from row 13 to row 4 and i...
void Graphics_BuildSequentialTileTable(void *tilemap)
Builds the perspective plane's 32 by 32 affine map: tiles 0 to 255 in its first eight rows,...
s32 BattlePres_RunMosaicFadeOut(void)
Fades the screen to black over sixteen frames as every background's mosaic grows, then shows no layer...
const u8 gBattlePres_TileVariants[]
const u8 gBattlePres_CurtainTiles[]
What every part of the battle object shares: its includes, in their original order,...
#define CURTAIN_TILE(n)
The opening curtain's tiles: 4-bit tiles 128 to 136 of character block 1, which BG1 shows from its ma...
#define BLEND_SPRITES_OVER_ALL
REG_BLDCNT: blend the semi-transparent sprites (OBJ mode 1) over every layer, to fade them.
#define BATTLE_WININ
The battle's windows: window 0 shows BG0 to BG2, sprites and blending, window 1 BG0,...
#define BATTLE_BG1CNT
BG1 during a battle: 256 colours, priority 3, its map in screen block 31.
@ BATTLE_UNIT_LIST_END
ends the list
struct BattleWork * gBattleWork
#define Dma_Fill32Cell(cell, value, destination, size)
Dma_Fill32 through the caller's own volatile word cell, so a function that fills several blocks keeps...
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...
void Fade_ToBlack(s32 frames)
Fades out to black.
void BattleFx_RunShatteringOpeningFar(struct BattleEffectArgument *effect)
struct BattleUnit * UnitGetFar(u32 owner)
void UiWindow_CreateWithLayoutBoundsFar(s32 flags)
void Runtime_SetIrqHandler(u32 irq, s32 vcount, InterruptHandler handler)
Installs handler for interrupt irq and enables that interrupt, or with a null handler disables it and...
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
s32 * gDisp
Slot 42: transition timer.
void * Runtime_AllocateHeapBlock(s32 kind, s32 size)
Returns heap slot kind's block, first allocating size bytes for it (rounded up to words),...
@ HEAP_SLOT_BATTLE_BACKGROUND
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
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.
void IoWriteQueue_Store16(u32 address, u32 value)
Queues a halfword store.
#define BGCNT_CHAR_BASE(block)
#define BGCNT_PRIORITY(n)
#define BG_SCREEN_BLOCK(n)
#define DMA_HBLANK_HALFWORD_PER_LINE
#define BLDCNT_EFFECT_DARKEN
towards black by REG_BLDY
@ DISPCNT_MODE_1
BG0 and BG1 text, BG2 affine.
#define BLEND_ALPHA(top, bottom)
A REG_BLDALPHA value: top and bottom are the two targets' weights, out of 16.
#define BGCNT_SCREEN_BASE(block)
#define DMA_COPY_WORDS(n)
#define WIN_RANGE(start, end)
A REG_WINxH or REG_WINxV value: the window covers start up to, but not including, end.
#define IO_WRITE_QUEUE_PUSH(address, value, control)
Disables interrupts to add one register write or DMA to the queue; a write to a full queue is dropped...
#define Io_Write16(v, reg)
Writes a value to a 16-bit register or memory location.
static s32 Iwram_FillWords(void *destination, s32 size, u32 value)
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void Runtime_ReleaseHeapBlock(s32 slot)
char ResourceId_VenusLighthouseAerieStormBackdrop
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,...
The battle background's scanline work in heap slot 10: two pages of per-line BG2CNT values,...
u32 page
the page of lines shown; the other one is built
struct BattleAffine affine
The battle background's work slot as the background code reads it: its display mode (2 draws it as an...
s32 mode
2 draws the affine plane; 1 sets BG1's scroll too
s32 busy
while set, BattleCamera_SetRange leaves BG1's scroll
s32 secondMode
1 also sets BG1's scroll; one effect sets it
The battle camera: its eye, the focus it turns about, and its pitch, yaw and distance.
s16 actors[8]
the targets' unit ids, count of them
s32 count
targets in actors, at least 1
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
struct MotionObject * object
NULL once released.
The effect updates its command while the presentation keeps animation state.
struct BattleEffectArgument effect
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.
u16 background
the battle background's id
The display control and green swap registers, REG_DISPCNT onward.
u16 greenSwap
the undocumented green swap register after it