22 for (channelIndex = 0; channelIndex <= 15; channelIndex++) {
24 u32 sourceTileOrOpcode;
29 if ((mapState->
anim + channelIndex)->start ==
NULL ||
30 (mapState->
anim + channelIndex)->paused != 0)
35 if ((mapState->
anim + channelIndex)->timer == 0) {
36 commands = (mapState->
anim + channelIndex)->cursor;
37 sourceTileOrOpcode = *commands++;
38 if (sourceTileOrOpcode == 0xffff) {
39 (mapState->
anim + channelIndex)->cursor =
40 (mapState->
anim + channelIndex)->start;
46 if ((sourceTileOrOpcode & 0xff00) == 0xfe00) {
47 if ((sourceTileOrOpcode & 0xff) == 0xff)
49 (mapState->
anim + channelIndex)->cursor =
50 (mapState->
anim + channelIndex)->start +
51 (sourceTileOrOpcode & 0xff) * 2;
54 tileCount = *commands++;
55 destinationTile = commands[0];
56 (mapState->
anim + channelIndex)->timer = commands[1];
61 if (sourceTileOrOpcode >= 0x600)
70 if (sourceTileOrOpcode >= 0x200)
80 (mapState->
anim + channelIndex)->cursor += 4;
83 (mapState->
anim + channelIndex)->timer--;
126 while (marker != 0xffff) {
127 if ((marker & 0xff00) == 0xfd00) {
129 u32 channelIndex = marker & 15;
133 channel = &mapState->
anim[channelIndex];
134 channel->
start = script;
143 if (channelsStarted != 0)
176 u32 delayOrJumpIndex;
179 blend = &mapState->
blend;
188 delayOrJumpIndex = blend->
delay;
189 delay16 = delayOrJumpIndex;
192 instruction = *commands;
194 if (instruction == 0xffff) {
199 if ((instruction & 0xff00) == 0xfe00) {
200 delayOrJumpIndex = instruction & 0xff;
201 if (delayOrJumpIndex == 0xff)
210 if ((instruction & 0xf000) == 0x3000) {
223 blend->
delay = commands[0];
228 blend->
delay = delayOrJumpIndex + 0xffff;
246 if (*script != 0xffff) {
277 cycle = paletteCycles->
entries;
279 for (cycleIndex = 0; cycleIndex != 4; cycleIndex++) {
285 for (colorIndex = 0; colorIndex != 16; colorIndex++) {
286 cycle->
colors[colorIndex] = 0;
290 paletteCycles->
count = 0;
306 cycleIndex = paletteQueue->
count;
311 cycle = &paletteQueue->
entries[cycleIndex];
312 paletteColors = (
u16 *)
BG_PLTT + (((
u16)paletteBank << 4) + (
u16)firstColor);
313 colorCount16 = colorCount;
316 cycle->
count = colorCount16;
317 cycle->
source = paletteColors;
321 paletteQueue->
count++;
344 u16 activeCycles = paletteQueue->
count & 3;
345 u16 rotatedColors[16];
347 for (cycleIndex = 0; cycleIndex < activeCycles; cycleIndex++) {
349 if (cycle->
timer == 0) {
352 void *paletteColors = cycle->
source;
358 for (colorIndex = colorCount - rotationOffset; colorIndex < colorCount;
360 rotatedColors[colorIndex] = *savedColors++;
361 for (colorIndex = 0; colorIndex < colorCount - rotationOffset;
363 rotatedColors[colorIndex] = *savedColors++;
369 if (rotationOffset >= colorCount)
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...
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
What every part of the field object shares: its includes and the few names more than one part uses.
struct PaletteSnapshotWork * gPaletteWork
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
void DisplayBlend_SuspendScript(void)
Suspends the blend script.
UNUSED void PaletteQueue_Initialize(void)
Allocates the palette cycling queue (heap slot 28) with its four entries cleared.
UNUSED s32 PaletteQueue_Add(s16 paletteBank, s16 firstColor, s16 delay, s16 colorCount)
Adds a palette cycle: colorCount colours of background palette paletteBank from firstColor,...
void Map_SetLayerEntryFlag(u32 channelIndex)
Pauses tile animation channel channelIndex by setting its paused byte.
void MapAnimation_Update(void)
Each frame: runs the 16 tile animation channels.
void DisplayBlend_StartScript(u16 *script)
Starts a map's blend script, unless it is empty.
UNUSED void PaletteQueue_Stop(void)
Stops the palette cycles and frees their queue (heap slot 28).
void MapAnimation_Resume(void)
Resumes the tile animations, unless the world map's still view is shown.
void Map_ClearLayerEntryFlag(u32 channelIndex)
Resumes tile animation channel channelIndex by clearing its paused byte.
void PaletteQueue_StepCycles(void)
Each frame: advances each palette cycle whose timer has run out by one colour, writing the rotated co...
void DisplayBlend_ResumeScript(void)
Resumes the blend script, through DisplayBlend_ResumeScriptFar.
UNUSED void PaletteQueue_Start(void)
Starts running the palette cycles each frame.
void DisplayBlend_RunScript(void)
Each frame: runs the map's blend script.
void MapAnimation_StartChannels(const u16 *script)
Starts the tile animation channels a map's animation script lists: each 0xfdNN marker starts channel ...
void MapAnimation_Suspend(void)
Suspends the tile animations, unless the world map's still view is shown.
void Runtime_ReleaseHeapBlock(s32 slot)
s32 Scheduler_ResumeTasks(SchedulerCallback callback)
Resumes the task running callback, or every task when callback is null, by clearing bit 0 of its orde...
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_SuspendTasks(SchedulerCallback callback)
Suspends the task running callback, or every task when callback is null, by setting bit 0 of its orde...
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
The map's running blend script, which sets the blend registers over time.
One of the 16 tile animation channels, which copy tiles into VRAM by script.
The map work in heap slot 8 (struct MapScrollWork), seen as its tile animation channels,...
u8 blendControl
The last BLDCNT the blend script wrote; with mode 1 in bits 7..6 its values go to BLDALPHA,...
struct MapAnimation anim[16]
struct BlendScriptState blend
u8 wideTiles
nonzero: tile animations copy 64-byte tiles
The palette cycling queue (heap slot 28): four cycles and how many are in use.
struct PaletteSnapshot entries[4]
u16 count
Cycles in use, 0 to 4; PaletteQueue_StepCycles masks four to none.
A palette cycle: a run of up to 16 background palette colours, saved and rotated by one colour every ...
s16 delay
frames; the timer restarts from it
u16 count
colours in the run
u16 colors[16]
the run's colours as saved when the cycle was added
u16 * source
the first colour of the run, in BG palette RAM
u16 position
colours rotated so far, 0 to count - 1
u16 timer
frames until the next rotation