Alchemy
Loading...
Searching...
No Matches

frame.c

Go to the documentation of this file.
1/// @file
2/// Interrupt handlers, the frame wait, key repeat and the VBlank handler.
3/// Part of runtime.c, the runtime object, compiled only through it.
4
6
7/// Restarts the game from the cartridge entry point. The marker word it leaves
8/// in IWRAM is cleared again by System_Initialize; nothing else reads it.
9static __inline__ void System_SoftReset(void) {
10 /* FAKEMATCH: the restart entry is called as returning s32, so its address is
11 * built in r0 as the native does at both resets; through a void (*)(void)
12 * pointer it is built in r1 (differ 4 in all six editions). */
13 s32 (*reset)(void) = (s32 (*)(void))Cart_Restart;
14
15 gCartridgeResetMarker = 0x19670704;
17 reset();
18}
19
20/// Sleeps in the BIOS Halt until the VBlank handler has run once.
21#define VBlankIntrWait() \
22 { \
23 gVBlankDone &= ~1; \
24 do { \
25 CAMELOT_ASM("Halt, which no C compiles to") \
26 __asm__ volatile("swi 2"); \
27 } while (!(gVBlankDone & 1)); \
28 }
29
30/// Installs `handler` for interrupt `irq` and enables that interrupt, or with a
31/// null handler disables it and installs the do-nothing handler. The three
32/// display interrupts are also switched in DISPSTAT; for VCount, `vcount` is
33/// the line it fires on. Writes REG_IE, REG_DISPSTAT and gIrqHandlers with
34/// interrupts disabled. Called by System_Initialize, the link cable and save
35/// code for their timer and serial interrupts, and the battle transitions for
36/// their HBlank and VCount effects.
37void Runtime_SetIrqHandler(u32 irq, s32 vcount, InterruptHandler handler) {
38 if (irq <= IRQ_GAMEPAK) {
39 u32 ime;
40 u32 bit;
41 u32 ie;
42
43 IRQ_LOCK(ime);
44 bit = 1 << irq;
45 ie = REG_IE & ~bit;
46 if (handler != 0)
47 ie |= bit;
48 REG_IE = ie;
49 if (irq <= IRQ_VCOUNT) {
50 // The display interrupts also need their DISPSTAT enable
51 u32 enable = DISPSTAT_VBLANK_INTR << irq;
52 u32 keep = ~enable;
53 u32 stat;
54
55 if (irq == IRQ_VCOUNT) {
56 enable |= DISPSTAT_VCOUNT_LINE(vcount);
57 // Keep only the low byte, so the old line goes too
58 keep &= 0xff;
59 }
60 stat = REG_DISPSTAT & keep;
61 if (handler != 0)
62 stat |= enable;
63 REG_DISPSTAT = stat;
64 }
65 if (handler != 0)
66 gIrqHandlers[irq] = handler;
67 else
69 IRQ_UNLOCK(ime);
70 }
71}
72
73/// Frame counts used by the sleep transitions and the CPU-load peak display.
74enum {
75 SLEEP_IDLE_FRAMES = 3 * 60 * 60,
80};
81
82/// The game's frame loop: runs `frames` frames and returns. Each frame runs the
83/// scheduled main-loop tasks, builds the OAM list, measures CPU load for the
84/// debug display, counts idle time for sleep, steps the debug pause, waits for
85/// VBlank and then reads the keys. Holding L and R for three seconds, or three
86/// idle minutes with idle sleep on, puts the system into Stop until L and R are
87/// pressed again. A soft reset requested by the keypad interrupt happens here.
88/// Called everywhere the game waits: every scene, menu and battle step that
89/// lets time pass goes through it.
90///
91/// Code may call WaitFrames deep inside its own call chains, so a caller
92/// whose stack has grown below the frame-wait stack top has its stack copied
93/// aside into gSavedStack first, and the loop runs at that top; the copy is
94/// put back on return. Each frame it allocates and releases the frame scratch
95/// heap slot, sets gFrameRenderPending, and counts up gFrameCount and
96/// gPlayTimeFrames.
97void WaitFrames(s32 frames) {
98 u8 *sp;
99 u32 frameIndex;
100 u8 *base;
101 u32 line;
102 s32 delayFrame;
103 s16 savedDisplayControl;
104 s16 savedBackdropColor;
105
106 CAMELOT_ASM("read the hardware stack pointer for the proven stack switch")
107 __asm__ volatile("mov %0, sp" : "=r"(sp));
108
109 // Save the caller's stack and continue at the frame-wait stack top
110 base = sp;
111 if (base < Ram_FrameWaitStackTop) {
113
114 gSavedStackSize = top - base;
116 CAMELOT_ASM("the stack switch, a write to sp no C can express")
117 __asm__ volatile("mov sp, %0" : : "r"(top) : "memory");
118 }
119 for (frameIndex = 0; frameIndex < frames; frameIndex++) {
120 // Run the main-loop tasks and build this frame's sprites
128 // CPU load: the scanline the frame's work ended on, counted from the
129 // last VBlank, plus 256 for each frame it overran; the peak is held
130 // for 30 frames
131 line = *(u16 *)&REG_VCOUNT;
132 if (line >= 160)
133 line -= 160;
134 else
135 line += 68;
136 line += (gLagFrameCount - 1) << 8;
137 if (gCpuLoadTimer == 0)
138 gCpuLoadPeak = 0;
139 else
141 if (gCpuLoadPeak < line) {
142 gCpuLoadPeak = line;
144 }
145 }
146 // Count idle frames and the L+R hold that request sleep
147 if (gSleepDisabled == 0) {
148 if (gIdleSleepEnabled) {
149 if (gKeysHeld)
150 gIdleFrames = 0;
151 else {
152 gIdleFrames++;
154 gSleepRequested = 1;
155 }
156 }
157 if (gKeysHeld == KEYS_SHOULDERS) {
161 gSleepRequested = 1;
162 }
163 } else {
165 }
166 }
167 // Debug builds: Start+Select pauses the game; while paused, A, B,
168 // Select or the D-pad advances one frame and Start resumes
169 if (gDebugMode) {
170 for (;;) {
171 if (gDebugPaused) {
172 if (gKeysRepeat & (KEY_A | KEY_B | KEY_SELECT))
173 break;
174 if (gKeysHeld & KEYS_DPAD)
175 break;
176 if (gKeysRepeat & KEY_START) {
177 gDebugPaused = 0;
178 break;
179 }
180 } else {
181 if (gKeysHeld != (KEY_START | KEY_SELECT))
182 break;
183 gDebugPaused = 1;
184 }
185 CAMELOT_ASM("Halt in VBlankIntrWait")
188 if (gResetRequested) {
189 gResetRequested = 0;
191 }
192 }
193 }
194 // Wait for VBlank, then start the next frame
196 gLagFrameCount = 0;
197 CAMELOT_ASM("Halt in VBlankIntrWait")
201 gFrameCount++;
208 }
209 // Sleep: after a second of white screen, Stop the CPU until L and R wake
210 // it, then restore the screen. A request above 1 counts down first.
211 if (gSleepRequested && gSleepDisabled == 0) {
212 savedDisplayControl = REG_DISPCNT;
213 savedBackdropColor = PLTT_BACKDROP;
214 if (gSleepRequested == 1) {
216 Io_Write16(RGB(31, 31, 31), &PLTT_BACKDROP);
217 for (delayFrame = 0; delayFrame < SLEEP_WHITE_FRAMES; delayFrame++) {
218 CAMELOT_ASM("Halt in VBlankIntrWait")
220 }
221 gSleepActive = 1;
224 CAMELOT_ASM("Stop, which no C compiles to")
225 __asm__ volatile("swi 3");
228 gSleepActive = 0;
229 Io_Write16((u16)savedDisplayControl, &REG_DISPCNT);
230 Io_Write16((u16)savedBackdropColor, &PLTT_BACKDROP);
231 for (delayFrame = 0; delayFrame < SLEEP_WAKE_FRAMES; delayFrame++) {
232 CAMELOT_ASM("Halt in VBlankIntrWait")
234 }
235 gSleepRequested = 0;
236 gIdleFrames = 0;
237 } else {
239 }
240 }
241 if (gResetRequested) {
242 gResetRequested = 0;
244 }
245 }
246 // Put the caller's stack back
247 {
248 u32 *size = &gSavedStackSize;
249
250 if (*size) {
251 /* FAKEMATCH: tying the old base to the hardware read keeps the 8-byte
252 * frame and no copy through ip; as an output only ("=r"), 67
253 * instructions differ in tbs-en. */
254 CAMELOT_ASM("read the hardware stack pointer for its restore copy")
255 __asm__ volatile("mov %0, sp" : "+r"(base));
256 /* FAKEMATCH: needed to match: the volatile reread keeps this saved-size
257 * load separate from the conditional read (7 aligned differences
258 * without this qualification). */
259 base -= *(volatile u32 *)size;
260 sp = base;
262 "restore the hardware stack pointer after the proven stack copy")
263 __asm__ volatile("mov sp, %0" : : "r"(sp) : "memory");
264 /* FAKEMATCH: complementary conditions, which emit nothing, end the
265 * restore CSE block and keep the size-address reload in r3; reusing size
266 * for nextSize, 4 instructions differ in tbs-en. */
267 size = NULL;
268 {
269 u32 *nextSize = NULL;
270
271 if (sp)
272 nextSize = &gSavedStackSize;
273 if (!sp)
274 nextSize = &gSavedStackSize;
275 Dma_Set(gSavedStack, base, DMA_COPY_WORDS(*nextSize >> 2), REG_DMA3);
276 }
277 while (DMA3->control & (DMA_ENABLE << 16))
278 ;
279 gSavedStackSize = 0;
280 }
281 }
282}
283
284/// Frames a key is held before it first repeats, and between later repeats
285#define INPUT_KEY_REPEAT_FIRST 19
286#define INPUT_KEY_REPEAT_NEXT 6
287
288/// Restarts the key repeat delay, so held keys wait the full delay again.
290
291/// Runs once a frame after VBlank, called by WaitFrames. When the repeat timer
292/// has run out, the held keys repeat into gKeysRepeat. gKeysRepeatDirected is
293/// the same keys with at most one D-pad direction: of several held directions
294/// it keeps the one added last (gKeysDirection remembers it), and with all
295/// four it keeps none. Last, the keys newly held since the previous frame go
296/// to gKeysPressed, and gKeysHeldLast takes gKeysHeld.
298 s32 delay = gKeyRepeatTimer;
299 u32 keys;
300 u32 axis = 0;
301 u32 directionCount;
302 u32 mask;
303
304 if (delay <= 0) {
306 keys = gKeysRepeat;
307 if (delay == 0)
309 else
311 } else {
312 gKeysRepeat = 0;
313 keys = gKeysRepeat;
314 }
315
316 if (keys != 0) {
317 // Count the D-pad directions in the repeat
318 directionCount = 0;
319 if (keys & KEY_UP)
320 directionCount = 1;
321 if (keys & KEY_DOWN)
322 directionCount++;
323 if (keys & KEY_LEFT)
324 directionCount++;
325 if (keys & KEY_RIGHT)
326 directionCount++;
327
328 gKeysRepeatDirected = keys;
329 switch (directionCount) {
330 default:
332 mask = 0xffff & ~KEYS_DPAD;
333 gKeysRepeatDirected &= mask;
334 break;
335 case 0:
337 break;
338 case 1:
339 gKeysDirection = keys & KEYS_DPAD;
340 break;
341 case 2:
345 break;
346 case 3:
348 axis = KEYS_HORIZONTAL;
350 axis = KEYS_VERTICAL;
351 mask = 0xffff ^ axis;
352 gKeysDirection = keys & mask;
353 gKeysRepeatDirected &= mask;
354 break;
355 }
356 } else {
357 gKeysRepeatDirected = keys;
358 }
359
362}
363
364#define SOUND_PRESET_COUNT 5
365#define SOUND_PRESET_SIZE 152
366
367/// The VBlank interrupt handler, installed by System_Initialize. It trades the
368/// link cable payloads, steps the music fades and the screen fade, and when
369/// the frame loop has finished a frame copies its OAM list and BG scroll
370/// registers, flushes the queued register writes and clears
371/// gFrameRenderPending. Then it runs and clears the one-shot gVBlankHook, runs
372/// the VBlank tasks, reads the keypad into gKeysHeld and gKeysPressed, sets
373/// gVBlankDone and finally mixes the next sound buffer.
375 u32 keys;
376 void (*hook)(void);
377
378 // Stop any HBlank DMA effect left running from the last frame
379 {
380 volatile u16 *dma0 = REG_DMA0;
381
383 dma0[5] &= ~DMA_ENABLE;
384 dma0[5];
385 }
386 if (gSerialExchangeActive != 0) {
387 u16 *status = (u16 *)&gLinkStatus;
391 }
393 Fade_Update();
394 if (gFrameRenderPending != 0) {
395 if (gOamCopyEnabled != 0)
401 }
402 // The hook runs once: it is cleared before it is called
403 hook = gVBlankHook;
404 if (hook != 0) {
405 gVBlankHook = 0;
406 hook();
407 }
409
410 // Read the keypad (its bits are 0 while pressed). A newly held key restarts
411 // the repeat at once; letting go of all keys restarts the full delay.
412 keys = REG_KEYINPUT ^ KEYS_MASK;
413 {
414 u32 pressed = keys & ~gKeysHeld;
415
416 gKeysPressed = pressed;
417 gKeysPressedLatch |= pressed;
418 }
419 gKeysHeld = keys;
420 if (keys == 0) {
422 gKeysRepeat = keys;
423 } else if (gKeysHeld & (gKeysHeldAtVBlank ^ 0xffff)) {
424 gKeyRepeatTimer = -1;
425 gKeysRepeat = keys;
426 } else if (gKeyRepeatTimer > 0) {
428 }
429 gKeysHeldAtVBlank = keys;
430 gFrameTick++;
432 gVBlankDone = 1;
434}
435
436/// Copies the mixer code for sound preset `preset` (0 to 4; anything else is 0)
437/// from ROM into IwramSoundPresetCode. Called by the battle and the link lobby
438/// for their music, and by the audio test. Always returns 0.
440 s32 index;
441
442 index = preset;
443 if ((u32)preset > SOUND_PRESET_COUNT - 1) {
444 index = 0;
445 }
448 return 0;
449}
450
451/// Nothing calls it.
453
454/// Nothing calls it.
456
457/// The keypad interrupt, from the handler table: A+B+Select+Start was pressed,
458/// so it sets gResetRequested for the frame loop and disarms the interrupt.
459/// During sleep the same interrupt only wakes the CPU.
461 if (gSleepActive == 0) {
463 gResetRequested = 1;
464 }
465}
466
467#undef VBlankIntrWait
468#undef INPUT_KEY_REPEAT_FIRST
469#undef INPUT_KEY_REPEAT_NEXT
470#undef SOUND_PRESET_COUNT
471#undef SOUND_PRESET_SIZE
#define SCHEDULER_KEY_VBLANK
A task's order: the high byte picks the pass that runs it, the low byte ranks it within the pass (hig...
volatile u8 gSchedulerStatus
#define SCHEDULER_KEY_MAIN_LOOP
#define Cart_Restart
Definition cartboot.h:9
#define DMA3
DMA3, the channel the game copies with, as its three registers.
Definition dma.h:18
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...
Definition dma.h:62
void Fade_Update(void)
Steps the screen fade once a frame, called by System_VBlankHandler: sets BLDCNT to brighten or darken...
Definition fade.c:20
void MusicPlayer_StepVolumeAndPitchTowardTargetsFar(void)
void Input_HandleKeyInterrupt(void)
The keypad interrupt, from the handler table: A+B+Select+Start was pressed, so it sets gResetRequeste...
Definition frame.c:460
UNUSED void Sound_ReservedNoOpB(void)
Nothing calls it.
Definition frame.c:455
void Input_ResetKeyRepeat(void)
Restarts the key repeat delay, so held keys wait the full delay again.
Definition frame.c:289
#define INPUT_KEY_REPEAT_NEXT
Definition frame.c:286
#define SOUND_PRESET_COUNT
Definition frame.c:364
#define VBlankIntrWait()
Sleeps in the BIOS Halt until the VBlank handler has run once.
Definition frame.c:21
#define SOUND_PRESET_SIZE
Definition frame.c:365
#define INPUT_KEY_REPEAT_FIRST
Frames a key is held before it first repeats, and between later repeats.
Definition frame.c:285
@ SLEEP_WAKE_FRAMES
Definition frame.c:78
@ CPU_LOAD_PEAK_FRAMES
Definition frame.c:79
@ SLEEP_IDLE_FRAMES
Definition frame.c:75
@ SLEEP_COMBO_FRAMES
Definition frame.c:76
@ SLEEP_WHITE_FRAMES
Definition frame.c:77
void System_VBlankHandler(void)
The VBlank interrupt handler, installed by System_Initialize.
Definition frame.c:374
UNUSED void Sound_ReservedNoOpA(void)
Nothing calls it.
Definition frame.c:452
static __inline__ void System_SoftReset(void)
Restarts the game from the cartridge entry point.
Definition frame.c:9
s32 Sound_LoadPresetParameters(s32 preset)
Copies the mixer code for sound preset preset (0 to 4; anything else is 0) from ROM into IwramSoundPr...
Definition frame.c:439
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...
Definition frame.c:37
void Input_UpdateKeyRepeatAndDirection(void)
Runs once a frame after VBlank, called by WaitFrames.
Definition frame.c:297
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
u32 gCpuLoadPeak
The highest CPU load in the last 30 frames: the scanline the frame's work ended on,...
volatile u8 gCpuLoadDisplayEnabled
Debug: WaitFrames measures the CPU load into gCpuLoadPeak when set.
volatile u8 gSleepDisabled
Nonzero: WaitFrames counts no idle time and ignores sleep requests.
u32 gFrameTick
Counted up by every VBlank.
u32 gPlayTimeFrames
The play time clock, in frames.
u8 gFrameRenderPending
Set by WaitFrames once it has built a frame's OAM list; the VBlank handler then copies the list,...
u8 gSavedStack[]
The caller's stack below the frame-wait stack top, while WaitFrames runs.
volatile u16 gIdleFrames
Frames since a key was last held.
volatile u8 gSleepRequested
1: sleep this frame; more: count down to it.
u32 gCpuLoadTimer
Frames gCpuLoadPeak is still held.
u8 gResetRequested
Set by the keypad interrupt; WaitFrames performs the soft reset.
volatile u16 gVBlankDone
Bit 0 is set by the VBlank handler; WaitFrames clears it and halts until it is set again.
void(*) gVBlankHook(void)
Run once by the next VBlank handler, which clears it first.
u8 gDebugMode
Debug builds: Start+Select pauses the frame loop.
u8 gOamCopyEnabled
The VBlank handler copies the OAM list only while it is set; scenes clear it to keep their own sprite...
volatile u16 gLagFramesShown
gLagFrameCount as the last frame left it; the text typing paces itself by it.
u32 gCartridgeResetMarker
Written by the soft reset just before it restarts the cartridge, and cleared by System_Initialize; no...
u32 gSavedStackSize
Bytes of the caller's stack WaitFrames has copied into gSavedStack, or 0.
u16 gLagFrameCount
VBlanks since WaitFrames last started a frame: 1 when the frame took one.
u8 gDebugPaused
The debug pause is on.
volatile u16 gSleepComboFrames
Frames L and R have been held together; three seconds request sleep.
volatile u32 gFrameCount
Frames WaitFrames has finished.
volatile u8 gIdleSleepEnabled
Sleep after three idle minutes.
void * Runtime_AllocateHeapBlock(s32 kind, s32 size)
Returns heap slot kind's block, first allocating size bytes for it (rounded up to words),...
Definition heap.c:47
@ HEAP_SLOT_FRAME_SCRATCH
Lives for one frame: WaitFrames builds the OAM list in it, and the field sprite decoder keeps its cod...
Definition heap_state.h:53
void IoWriteQueue_FlushPending(void)
Runs the queued register writes and empties the queue, with a copy of the executor routine on the sta...
Definition io_queue.c:40
#define REG_KEYCNT
Definition io_reg.h:184
#define KEYCNT_DISARMED
Requires all ten keys together to prevent the reset chord retriggering it.
Definition io_reg.h:313
#define KEYCNT_SOFT_RESET
A, B, Select and Start.
Definition io_reg.h:311
#define REG_BG0HOFS
Definition io_reg.h:149
#define RGB(r, g, b)
A 15-bit colour from its red, green and blue levels (0 to 31 each), as the palette stores it: blue in...
Definition io_reg.h:164
#define OAM
Definition io_reg.h:239
#define REG_IE
Definition io_reg.h:305
#define REG_DMA0
Definition io_reg.h:151
#define DMA_START_TIMING_DRQ_REPEAT
A DMA control's start timing (bits 12 and 13), cartridge request (bit 11) and repeat (bit 9): the bit...
Definition io_reg.h:220
#define OAM_SIZE
OAM's size in bytes: 128 sprites of 8 bytes.
Definition io_reg.h:241
#define DISPSTAT_VCOUNT_LINE(line)
DISPSTAT's high byte: the line the VCount interrupt fires on (the LYC compare).
Definition io_reg.h:18
@ KEY_UP
Definition io_reg.h:249
@ KEY_B
Definition io_reg.h:244
@ KEY_SELECT
Definition io_reg.h:245
@ KEYS_DPAD
Definition io_reg.h:255
@ KEY_LEFT
Definition io_reg.h:248
@ KEY_START
Definition io_reg.h:246
@ KEY_RIGHT
Definition io_reg.h:247
@ KEYS_HORIZONTAL
Definition io_reg.h:253
@ KEYS_VERTICAL
Definition io_reg.h:254
@ KEY_A
Definition io_reg.h:243
@ KEY_DOWN
Definition io_reg.h:250
@ KEYS_SHOULDERS
Definition io_reg.h:256
#define REG_KEYINPUT
Definition io_reg.h:183
#define REG_VCOUNT
Definition io_reg.h:19
#define REG_DISPCNT
Definition io_reg.h:9
#define DISPSTAT_VBLANK_INTR
Definition io_reg.h:13
#define PLTT_BACKDROP
Definition io_reg.h:155
#define REG_IME
Definition io_reg.h:308
#define REG_DMA3
Definition io_reg.h:153
#define REG_DISPSTAT
Definition io_reg.h:10
#define KEYS_MASK
Definition io_reg.h:259
#define DMA_COPY_WORDS(n)
Definition io_reg.h:226
#define KEYCNT_SHOULDERS_WAKE
L and R, which wake the sleep.
Definition io_reg.h:314
#define DMA_ENABLE
Definition io_reg.h:217
#define Io_Write16(v, reg)
Writes a value to a 16-bit register or memory location.
Definition iowrite.h:14
InterruptHandler gIrqHandlers[IRQ_COUNT]
The handler the IWRAM dispatcher calls for each interrupt source.
@ IRQ_GAMEPAK
Definition irq.h:26
@ IRQ_VCOUNT
Definition irq.h:15
void(*) InterruptHandler(void)
Definition irq.h:36
#define IRQ_UNLOCK(saved)
Restores the IME value saved by IRQ_LOCK.
Definition irqlock.h:50
#define IRQ_LOCK(saved)
Disables interrupts and saves IME in saved; IRQ_UNLOCK restores it.
Definition irqlock.h:38
volatile u32 gKeysDirection
The D-pad direction gKeysRepeatDirected keeps: of several held, the one added last.
volatile u32 gKeysHeld
Keys down now.
volatile u32 gKeysPressed
Keys that went down this frame.
u32 gKeysPressedLatch
Presses since a reader last cleared it.
volatile u32 gKeysRepeat
Pressed keys, repeating while held: after 19 frames, then every 6.
volatile u32 gKeysRepeatDirected
gKeysRepeat with at most one D-pad direction.
u32 gKeysHeldLast
gKeysHeld when the frame loop last read it.
u32 gKeysHeldAtVBlank
gKeysHeld at the previous VBlank.
s32 gKeyRepeatTimer
Frames until the held keys repeat; -1 makes them repeat at once.
struct BgScroll gBgScroll[]
void Runtime_ReleaseHeapBlock(s32 slot)
#define Ram_FrameWaitStackTop
Definition ram_buffer.h:24
void Render_ResetFrame(void)
Starts a new frame of sprites: frees the affine matrices and empties the 256 depth slots sprites are ...
Definition render.c:12
void Render_BuildOamList(void *work)
Builds this frame's OAM list in work from the sprites linked into the depth slots,...
Definition render.c:96
What every part of the runtime object shares: its includes and the library call two parts make.
void Scheduler_RunPass(s32 key)
Runs one pass of the scheduler: every task whose order's high byte matches key's (SCHEDULER_KEY_MAIN_...
Definition scheduler.c:289
s32 SerialRuntime_PollStatus(void)
As SerialRuntime_PollAndTransfer, without exchanging data: WaitFrames calls it once a frame while gSe...
Definition serial.c:168
void SerialRuntime_StepBlockTransfer(void)
Runs each VBlank after the exchange, called by System_VBlankHandler: moves the bulk transfer on by on...
Definition serial.c:548
s32 SerialRuntime_ExchangePayloads(void *send, void *receive)
Once connected (phase 1), gathers the received payloads into receive and builds the next packet from ...
Definition serial.c:218
volatile u16 gLinkStatus
Link status, updated by the VBlank exchange handler.
struct SerialRuntime gSerialRuntime
u16 gSerialExchangeActive
u8 gSerialPeerPayloads[4][24]
struct SerialTransferState gSerialTransfer
#define NULL
Definition bilibin.h:6
void * gWorkSlot[]
u8 mode
SIOCNT's bits 7 and 3 when this console armed timer 3 to clock the transfers: 8 then,...
u8 transferEnabled
Nonzero lets a new packet restart timer 3.
void Runtime_IgnoreInterrupt(void)
The handler of every interrupt nobody has claimed.
Definition system.c:240
u16 gSleepActive
u8 IwramSoundPresetCode[]
void Bios_SoundBiasOn(void)
u8 IwramCodeRecords[]
void Bios_SoundBiasOff(void)
void SoundDriver_EnterMixer(void)
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
#define UNUSED
Definition types.h:22
unsigned char u8
Definition types.h:11
#define CAMELOT_ASM(proof)
Definition types.h:46
The heap's 64 work slots, the first two holding the next free EWRAM and IWRAM addresses.
Definition heap_state.h:18