Alchemy
Loading...
Searching...
No Matches

frame.h

Go to the documentation of this file.
1#ifndef ALCHEMY_FRAME_H
2#define ALCHEMY_FRAME_H
3
4/// @file
5/// The frame loop's globals: lag counts, the CPU load display and the VBlank
6/// flags.
7///
8/// WaitFrames (runtime/frame.c) and the VBlank handler share these cells.
9/// Several are volatile, a device: each tag names the function that differs
10/// without it.
11
12#include "types.h"
13
14/// Set by WaitFrames once it has built a frame's OAM list; the VBlank handler
15/// then copies the list, the BG scroll and the queued register writes, and
16/// clears it.
18/// Debug: WaitFrames measures the CPU load into gCpuLoadPeak when set.
19/* FAKEMATCH(volatile): as plain u8, 88 of 438 instructions differ in tbs-en
20 * (Title_ShowIntro). */
21extern volatile u8 gCpuLoadDisplayEnabled;
22/// The VBlank handler copies the OAM list only while it is set; scenes clear
23/// it to keep their own sprites on screen.
24extern u8 gOamCopyEnabled;
25/// VBlanks since WaitFrames last started a frame: 1 when the frame took one.
26extern u16 gLagFrameCount;
27/// gLagFrameCount as the last frame left it; the text typing paces itself by
28/// it.
29/* FAKEMATCH(volatile): as plain u16, 33 of 628 instructions differ in tbs-en
30 * (UiWork_StepChannelScript). */
31extern volatile u16 gLagFramesShown;
32/// Bit 0 is set by the VBlank handler; WaitFrames clears it and halts until
33/// it is set again.
34/* FAKEMATCH(volatile): as plain u16, 119 of 403 instructions differ in tbs-en
35 * (WaitFrames). */
36extern volatile u16 gVBlankDone;
37extern u32 gCpuLoadTimer; ///< Frames gCpuLoadPeak is still held.
38/// The highest CPU load in the last 30 frames: the scanline the frame's work
39/// ended on, plus 256 for each frame it overran.
40extern u32 gCpuLoadPeak;
41/// Frames WaitFrames has finished.
42/* FAKEMATCH(volatile): as plain u32, 27 functions differ in tbs-en, most
43 * Ui_RunOwnerStatusScreen (529), ItemList_SelectEntry (346). */
44extern volatile u32 gFrameCount;
45extern u32 gFrameTick; ///< Counted up by every VBlank.
46/// Run once by the next VBlank handler, which clears it first.
47extern void (*gVBlankHook)(void);
48
49/// Nonzero: WaitFrames counts no idle time and ignores sleep requests.
50/* FAKEMATCH(volatile): as plain u8, 82 of 403 instructions differ in tbs-en
51 * (WaitFrames). */
52extern volatile u8 gSleepDisabled;
53/// Sleep after three idle minutes.
54/* FAKEMATCH(volatile): as plain u8, 45 of 203 instructions differ in tbs-en
55 * (GameState_InitDefaults). */
56extern volatile u8 gIdleSleepEnabled;
57/// 1: sleep this frame; more: count down to it.
58/* FAKEMATCH(volatile): as plain u8, 26 of 403 instructions differ in tbs-en
59 * (WaitFrames). */
60extern volatile u8 gSleepRequested;
61/// Debug builds: Start+Select pauses the frame loop.
62extern u8 gDebugMode;
63extern u8 gDebugPaused; ///< The debug pause is on.
64/// Set by the keypad interrupt; WaitFrames performs the soft reset.
65extern u8 gResetRequested;
66/// Frames since a key was last held.
67/* FAKEMATCH(volatile): as plain u16, 89 of 403 instructions differ in tbs-en
68 * (WaitFrames). */
69extern volatile u16 gIdleFrames;
70/// Frames L and R have been held together; three seconds request sleep.
71/* FAKEMATCH(volatile): as plain u16, 117 of 403 instructions differ in tbs-en
72 * (WaitFrames). */
73extern volatile u16 gSleepComboFrames;
74/// Written by the soft reset just before it restarts the cartridge, and
75/// cleared by System_Initialize; nothing else reads it.
77extern u32 gPlayTimeFrames; ///< The play time clock, in frames.
78/// Bytes of the caller's stack WaitFrames has copied into gSavedStack, or 0.
79extern u32 gSavedStackSize;
80/// The caller's stack below the frame-wait stack top, while WaitFrames runs.
81extern u8 gSavedStack[];
82
83#endif
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.
The integer types, TRUE, UNUSED and the fixed-address macros.
unsigned int u32
Definition types.h:15
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11