Alchemy
Loading...
Searching...
No Matches

system.c File Reference

Power-up, the cartridge's language, the build stamp and code loading. More...

Go to the source code of this file.

Data Structures

struct  BuildStampCopy
 The build stamp's twelve digit characters copied to IWRAM, and a zero word after them that ends the string. More...

Functions

void System_Initialize (void)
 Powers the game up: stops any HBlank DMA left running, sets the cartridge wait states, clears IWRAM, installs the interrupt handlers and the resident IWRAM code, loads the window graphics and the sound driver, then starts a new game.
UNUSED void Runtime_IdleForever (void)
 Waits out frames forever; the frame loop still runs the scheduled tasks.
UNUSED void RuntimeDispatch_ReservedNoOpA (void)
 Reserved empty export A in the runtime far-call table; no source caller.
UNUSED void RuntimeDispatch_ReservedNoOpB (void)
 Reserved empty export B 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.
UNUSED void RuntimeDispatch_ReservedNoOpD (void)
 Reserved empty export D in the runtime far-call table; no source caller.
UNUSED void RuntimeDispatch_ReservedNoOpE (void)
 Reserved empty export E in the runtime far-call table; no source caller.
s32 RuntimeDispatch_ReturnZero (s32 unused0, const u8 *unused1)
 An exported stub that ignores its arguments and reports 0.
void System_CopyBuildStamp (void)
 Copies the build stamp resource (twelve digits) into gBuildStamp in high IWRAM and writes the zero word that ends it.
void RuntimeDispatch_NoOpHook (s32 unused)
 An exported stub that does nothing with its argument.
void * Resource_GetTableEntry (s32 index)
 Returns the ROM address of resource index from the resource directory.
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 the start of the block.
void Resource_LoadCode (u32 index, void *destination)
 Decodes the compressed code resource index to destination and resolves its long branches there, with a RAM copy of the ARM routine that does what Code_ResolveLongBranches does; the copy is allocated and freed again.
void Runtime_IgnoreInterrupt (void)
 The handler of every interrupt nobody has claimed.
void Runtime_InstallIwramAndIrqs (void)
 Copies the resident code to IWRAM, points the BIOS interrupt vector (gIrqVector) at its dispatcher, installs the default handler table and enables the VBlank and keypad interrupts (and, outside Japan and England, the cartridge-removed interrupt, which halts the game).

Detailed Description

Power-up, the cartridge's language, the build stamp and code loading.

Part of runtime.c, the runtime object, compiled only through it.

Definition in file system.c.

Function Documentation

◆ System_Initialize()

void System_Initialize ( void )

Powers the game up: stops any HBlank DMA left running, sets the cartridge wait states, clears IWRAM, installs the interrupt handlers and the resident IWRAM code, loads the window graphics and the sound driver, then starts a new game.

It never returns. Called once by System_Entry after it has set the stacks; it clears the debug switches, enables the OAM copy and sleep, and clears gCartridgeResetMarker, which a soft reset leaves set.

Definition at line 17 of file system.c.

Referenced by System_Initialize().

◆ Runtime_IdleForever()

UNUSED void Runtime_IdleForever ( void )

Waits out frames forever; the frame loop still runs the scheduled tasks.

Nothing in ☀️ calls it.

Definition at line 64 of file system.c.

Referenced by Runtime_IdleForever().

◆ RuntimeDispatch_ReservedNoOpA()

UNUSED void RuntimeDispatch_ReservedNoOpA ( void )

Reserved empty export A in the runtime far-call table; no source caller.

Definition at line 109 of file system.c.

Referenced by RuntimeDispatch_ReservedNoOpA(), and System_GetLanguage().

◆ RuntimeDispatch_ReservedNoOpB()

UNUSED void RuntimeDispatch_ReservedNoOpB ( void )

Reserved empty export B in the runtime far-call table; no source caller.

Definition at line 112 of file system.c.

Referenced by RuntimeDispatch_ReservedNoOpB(), and System_GetLanguage().

◆ RuntimeDispatch_ReservedNoOpC()

UNUSED void RuntimeDispatch_ReservedNoOpC ( void )

Reserved empty export C in the runtime far-call table; no source caller.

Definition at line 115 of file system.c.

Referenced by RuntimeDispatch_ReservedNoOpC(), and System_GetLanguage().

◆ RuntimeDispatch_ReservedNoOpD()

UNUSED void RuntimeDispatch_ReservedNoOpD ( void )

Reserved empty export D in the runtime far-call table; no source caller.

Definition at line 118 of file system.c.

Referenced by RuntimeDispatch_ReservedNoOpD(), and System_GetLanguage().

◆ RuntimeDispatch_ReservedNoOpE()

UNUSED void RuntimeDispatch_ReservedNoOpE ( void )

Reserved empty export E in the runtime far-call table; no source caller.

Definition at line 121 of file system.c.

Referenced by RuntimeDispatch_ReservedNoOpE(), and System_GetLanguage().

◆ RuntimeDispatch_ReturnZero()

s32 RuntimeDispatch_ReturnZero ( s32 unused0,
const u8 * unused1 )

An exported stub that ignores its arguments and reports 0.

Definition at line 124 of file system.c.

Referenced by RuntimeDispatch_ReturnZero(), System_GetLanguage(), and Ui_RunIconMonitor().

◆ System_CopyBuildStamp()

void System_CopyBuildStamp ( void )

Copies the build stamp resource (twelve digits) into gBuildStamp in high IWRAM and writes the zero word that ends it.

Called by System_Initialize.

Definition at line 135 of file system.c.

Referenced by System_CopyBuildStamp(), System_GetLanguage(), and System_Initialize().

◆ RuntimeDispatch_NoOpHook()

void RuntimeDispatch_NoOpHook ( s32 unused)

An exported stub that does nothing with its argument.

Definition at line 146 of file system.c.

Referenced by LuckyDice_Run(), ReelGame_Run(), RuntimeDispatch_NoOpHook(), System_GetLanguage(), and Title_Run().

◆ Resource_GetTableEntry()

void * Resource_GetTableEntry ( s32 index)

Returns the ROM address of resource index from the resource directory.

Called throughout the game before decoding a resource.

Definition at line 150 of file system.c.

Referenced by BattleBackground_Load(), BattleFx_InitializeStarField(), BattleFx_RunAstralBlast(), BattleFx_RunAtalanta(), BattleFx_RunBeamSequence(), BattleFx_RunBind(), BattleFx_RunBreak(), BattleFx_RunBurstScene(), BattleFx_RunBurstShower(), BattleFx_RunCondemn(), BattleFx_RunDjinnBeams(), BattleFx_RunDjinniEntrance(), BattleFx_RunDragonCloud(), BattleFx_RunDrain(), BattleFx_RunElementBurst(), BattleFx_RunElementPillar(), BattleFx_RunEruption(), BattleFx_RunFroth(), BattleFx_RunGaia(), BattleFx_RunGatheringLights(), BattleFx_RunHaunt(), BattleFx_RunHealingMotes(), BattleFx_RunJudgment(), BattleFx_RunLobbedShells(), BattleFx_RunMars(), BattleFx_RunMirroredWall(), BattleFx_RunMoteFountain(), BattleFx_RunNereid(), BattleFx_RunOrbitingSkulls(), BattleFx_RunOrbitingSpirals(), BattleFx_RunPaletteParticles(), BattleFx_RunParticleStreams(), BattleFx_RunPlanetDiver(), BattleFx_RunPlasma(), BattleFx_RunProcne(), BattleFx_RunProjectileVolley(), BattleFx_RunRingAndSparkScene(), BattleFx_RunRushingStrike(), BattleFx_RunShiningStar(), BattleFx_RunSparkGroups(), BattleFx_RunStatBoost(), BattleFx_RunStatReduction(), BattleFx_RunStreakVolley(), BattleFx_RunSwirlSwipe(), BattleFx_RunTargetBursts(), BattleFx_RunTargetMotes(), BattleFx_RunTargetStrike(), BattleFx_RunThor(), BattleFx_RunTriangleStrike(), BattleFx_RunVolcano(), BattleFx_RunWhirlwind(), BattleFx_StartElementStreaks(), BattleFx_StepPaletteToResource(), Colosso_LoadLettering(), Colosso_StartRival(), ColossoWall_StartRivalPath(), Graphics_LoadCharacterBlockAndPalette(), LuckyDice_Run(), Map_InitializePerspectiveScene(), Map_LoadAreaGraphics(), Map_LoadDefaultCellsAndUpdateBlock(), Map_LoadLayeredScene(), Map_ShowWorldMap(), Menu_LoadResourceSlot(), OptionMenu_AnimateCursors(), Palette_StepTowardResource(), ReelGame_Run(), RenderResource_LoadFrame(), Resource_GetTableEntry(), Resource_LoadAndDecompress(), Resource_LoadCode(), Resource_LoadIndexedIntoBuffer(), ResourceSlot_Load(), Runtime_GetBuildStampTime(), SelectionScreen_LoadLargeIcon(), System_CopyBuildStamp(), System_GetLanguage(), Title_LoadBackground(), Title_LoadIntroBackgrounds(), Title_LoadSprites(), Title_ShowAnimatedSplash(), Title_ShowIntro(), Title_ShowSplashScreen(), Ui_LoadWindowGraphics(), UiGlyph_LoadEntryWithPalette(), UiText_DrawGlyph(), UiText_LoadRemappedGlyph(), UiText_RenderStringTiles(), UiWindow_OverlayTilePattern(), and WorldMap_LoadGraphics().

◆ Code_ResolveLongBranches()

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 the start of the block.

A BL is two halfwords: the first carries the marker bits 0xf000 and the high eleven bits of the offset, the second the marker 0xf800 and the low eleven bits of the halfword offset. Each pair's offset is reduced by the pair's own position in the block, which turns it into the pc-relative offset the CPU expects; the pairs are rewritten in place. byteLength is the code size. Nothing calls it: Resource_LoadCode uses the ARM routine that does the same.

Definition at line 162 of file system.c.

Referenced by Code_ResolveLongBranches(), and System_GetLanguage().

◆ Resource_LoadCode()

void Resource_LoadCode ( u32 index,
void * destination )

Decodes the compressed code resource index to destination and resolves its long branches there, with a RAM copy of the ARM routine that does what Code_ResolveLongBranches does; the copy is allocated and freed again.

Called by Scene_LoadOverlay for each scene's overlay, and through the far-call table.

Definition at line 228 of file system.c.

Referenced by Resource_LoadCode(), Scene_LoadOverlay(), and System_GetLanguage().

◆ Runtime_IgnoreInterrupt()

void Runtime_IgnoreInterrupt ( void )

The handler of every interrupt nobody has claimed.

Definition at line 240 of file system.c.

Referenced by Runtime_IgnoreInterrupt(), Runtime_SetIrqHandler(), and System_GetLanguage().

◆ Runtime_InstallIwramAndIrqs()

void Runtime_InstallIwramAndIrqs ( void )

Copies the resident code to IWRAM, points the BIOS interrupt vector (gIrqVector) at its dispatcher, installs the default handler table and enables the VBlank and keypad interrupts (and, outside Japan and England, the cartridge-removed interrupt, which halts the game).

Called by System_Initialize with IME cleared; it sets IME again at the end.

Definition at line 247 of file system.c.

Referenced by Runtime_InstallIwramAndIrqs(), System_GetLanguage(), and System_Initialize().