8#define SYSTEM_HALT_ON_GAMEPAK_IRQ 1
47#if defined(SYSTEM_HALT_ON_GAMEPAK_IRQ)
73enum CartridgeLanguage {
74 CARTRIDGE_LANGUAGE_ENGLISH,
75 CARTRIDGE_LANGUAGE_GERMAN,
76 CARTRIDGE_LANGUAGE_FRENCH,
77 CARTRIDGE_LANGUAGE_SPANISH,
78 CARTRIDGE_LANGUAGE_ITALIAN
89 language = CARTRIDGE_LANGUAGE_GERMAN;
92 language = CARTRIDGE_LANGUAGE_FRENCH;
95 language = CARTRIDGE_LANGUAGE_SPANISH;
98 language = CARTRIDGE_LANGUAGE_ITALIAN;
101 language = CARTRIDGE_LANGUAGE_ENGLISH;
166 entryCount = byteLength >> 1;
171 if (entryIndex < entryCount) {
173 u32 currentMarkerMask;
174 u32 payloadMask = 0x7ff;
175 nextMarkerMask = 0xf800;
176 currentMarkerMask = 0xf000;
186 u32 currentMarkerBits;
189 nextEntry = entries[1];
191 nextEntry = entries[2];
193 nextMarkerBits = nextEntry & nextMarkerMask;
197 if (nextMarkerBits == nextMarkerMask) {
198 currentEntry = entries[0];
199 currentMarkerBits = currentEntry & nextMarkerBits;
200 if (currentMarkerBits == currentMarkerMask) {
205 packedOffset = (((currentEntry & payloadMask) << 12) |
206 ((nextEntry & payloadMask) * 2)) -
209 ((packedOffset >> 12) & payloadMask) | currentMarkerBits;
210 adjustedNext = ((packedOffset >> 1) & payloadMask) | nextMarkerBits;
211 entries[0] = adjustedCurrent;
212 entries[1] = adjustedNext;
219 }
while (entryIndex < entryCount);
229 void (*patchBranches)(
void *,
s32);
235 patchBranches(destination, codeSize);
261#if defined(SYSTEM_HALT_ON_GAMEPAK_IRQ)
269#undef SYSTEM_HALT_ON_GAMEPAK_IRQ
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.
void Game_ResetForNewGameFar(s32 mode)
void Audio_InitializeRuntimeDefaultsFar(void)
void System_VBlankHandler(void)
The VBlank interrupt handler, installed by System_Initialize.
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.
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.
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...
u32 gCartridgeResetMarker
Written by the soft reset just before it restarts the cartridge, and cleared by System_Initialize; no...
void Runtime_InitializeHeap(void)
Empties the heap: clears the 64 words of gWorkSlot (both pool pointers and every named slot) and sets...
#define KEYCNT_DISARMED
Requires all ten keys together to prevent the reset chord retriggering it.
#define KEYCNT_SOFT_RESET
A, B, Select and Start.
#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...
#define DMA_COPY_WORDS(n)
struct IoWriteQueue gIoWriteQueue
#define Io_Write16(v, reg)
Writes a value to a 16-bit register or memory location.
InterruptHandler gIrqHandlers[IRQ_COUNT]
The handler the IWRAM dispatcher calls for each interrupt source.
#define INTR_FLAG_GAMEPAK
const u8 IwramRuntime_Rom[]
const u32 gRuntime_IrqHandlers[IRQ_COUNT]
The handlers installed at power-on, copied into gIrqHandlers.
volatile u32 gKeysPressed
Keys that went down this frame.
void MemFree(void *buffer)
#define RamCode_Load(to, code, bytes)
Allocates a heap copy; release it with MemFree when finished.
char ResourceId_BuildStamp
s32 Resource_DecodeType01(const void *source, void *destination)
Decodes a type-01 resource and returns its unpacked byte count.
What every part of the runtime object shares: its includes and the library call two parts make.
void Scheduler_ResetTaskTable(void)
Empties the task table: every slot gets no routine, order 0xffff (sorted last) and no flags.
s32 gBuildStamp[]
The build stamp System_CopyBuildStamp copies to IWRAM at power-on: twelve digits and a zero word,...
The build stamp's twelve digit characters copied to IWRAM, and a zero word after them that ends the s...
u16 count
Entries waiting, at most 32.
UNUSED void RuntimeDispatch_ReservedNoOpA(void)
Reserved empty export A in the runtime far-call table; no source caller.
void Runtime_IgnoreInterrupt(void)
The handler of every interrupt nobody has claimed.
void System_Initialize(void)
Powers the game up: stops any HBlank DMA left running, sets the cartridge wait states,...
void System_CopyBuildStamp(void)
Copies the build stamp resource (twelve digits) into gBuildStamp in high IWRAM and writes the zero wo...
UNUSED void RuntimeDispatch_ReservedNoOpB(void)
Reserved empty export B in the runtime far-call table; no source caller.
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
UNUSED void RuntimeDispatch_ReservedNoOpD(void)
Reserved empty export D in the runtime far-call table; no source caller.
UNUSED void RuntimeDispatch_ReservedNoOpC(void)
Reserved empty export C in the runtime far-call table; no source caller.
void RuntimeDispatch_NoOpHook(s32 unused)
An exported stub that does nothing with its argument.
void Resource_LoadCode(u32 index, void *destination)
Decodes the compressed code resource index to destination and resolves its long branches there,...
UNUSED void Code_ResolveLongBranches(u16 *entries, s32 byteLength)
Resolves the Thumb long branches (BL pairs) of a block of code whose branch offsets are stored from t...
UNUSED void RuntimeDispatch_ReservedNoOpE(void)
Reserved empty export E in the runtime far-call table; no source caller.
void Runtime_InstallIwramAndIrqs(void)
Copies the resident code to IWRAM, points the BIOS interrupt vector (gIrqVector) at its dispatcher,...
UNUSED void Runtime_IdleForever(void)
Waits out frames forever; the frame loop still runs the scheduled tasks.
s32 RuntimeDispatch_ReturnZero(s32 unused0, const u8 *unused1)
An exported stub that ignores its arguments and reports 0.
const u8 gRom_LanguageCode
void * Resource_DirectoryTable[]
u8 Resource_PatchThumbBranchCodeSize[]
const u8 Resource_PatchThumbBranch[]
void Ui_LoadWindowGraphics(void)
Loads the window font and frame tiles into BG character block 0, the window palette into BG palette 1...
void DebugText_Clear(void)
Blanks the debug text screen, homes the cursor and points BG0 at it.
s32 System_GetLanguage(void)
void VramCache_Reset(void)
Frees every block and every cache entry.