Skip to Content
The Alchemy Project

src/system/system_start_up.c

Included by system.c.

Structures

NameDescription
structBUILD_STAMP_COPYThe build stamp's twelve digit characters copied to IWRAM, and a zero word after them that ends the string.

Macros

NameDescription
#defineTHUMB_BL_HIGH 0xf000A Thumb long branch (BL) is two halfwords: the first carries the marker THUMB_BL_HIGH and the offset's high eleven bits, from THUMB_BL_HIGH_SHIFT, the second the marker THUMB_BL_LOW and the low eleven bits of the halfword offset (THUMB_BL_OFFSET_BITS each).
#defineTHUMB_BL_LOW 0xf800
#defineTHUMB_BL_OFFSET_BITS 0x7ff
#defineTHUMB_BL_HIGH_SHIFT 12

Functions

NameDescription
voidsyInit (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 enters gmMainRoutineRun and never returns.
voidsyIdleForever (void)Unused: waits out ticks forever; the tick loop still runs the events.
Sint32syGetLanguage (void)Returns the language of this cartridge from the header's game code letter, an CARTRIDGE_LANGUAGE.
voidsyDummyReservedNoOperationA (void)Unused: five empty exports of the system library's stub table, which nothing calls.
voidsyDummyReservedNoOperationB (void)
voidsyDummyReservedNoOperationC (void)
voidsyDummyReservedNoOperationD (void)
voidsyDummyReservedNoOperationE (void)
Sint32syDummyReturnZero (Sint32 resourceId, const Uint8 *table)An exported stub that ignores its arguments and reports 0.
voidsyCopyBuildStamp (void)Copies the build stamp resource (twelve digits) into BuildStampWork in high IWRAM and writes the zero word that ends it.
voidsyResourceReservedNoOperation (Sint32 unused)An exported stub that does nothing with its argument.
void *syResourceGetTableEntry (Sint32 index)Returns the ROM address of resource index from the resource directory.
voidsyCodeResolveLongBranches (Uint16 *pair, Sint32 byteLength)Unused: resolves the Thumb long branches (BL pairs) of a block of code whose branch offsets are stored from the start of the block.
voidsyOverlayLoad (Uint32 index, void *dest)Decodes the compressed code resource index to dest and resolves its long branches there, with a RAM copy of the ARM function that does what syCodeResolveLongBranches does; the copy is allocated and freed again.
voidsyIRQIgnore (void)The handler of every interrupt nobody has claimed.
voidsyInstallIWRAMAndIRQs (void)Copies the resident code to IWRAM, points the BIOS interrupt vector (IrqVector) at its dispatcher, installs the default handler table and enables the VBlank and keypad interrupts (and, in the German, French, Spanish and Italian editions, the cartridge-removed interrupt, which halts the game).

Macros in detail

THUMB_BL_HIGH

#define THUMB_BL_HIGH 0xf000

A Thumb long branch (BL) is two halfwords: the first carries the marker THUMB_BL_HIGH and the offset's high eleven bits, from THUMB_BL_HIGH_SHIFT, the second the marker THUMB_BL_LOW and the low eleven bits of the halfword offset (THUMB_BL_OFFSET_BITS each).

Referenced by syCodeResolveLongBranches().

Definition at line 143 of file system_start_up.c.

THUMB_BL_LOW

#define THUMB_BL_LOW 0xf800

Referenced by syCodeResolveLongBranches().

Definition at line 144 of file system_start_up.c.

THUMB_BL_OFFSET_BITS

#define THUMB_BL_OFFSET_BITS 0x7ff

Referenced by syCodeResolveLongBranches().

Definition at line 145 of file system_start_up.c.

THUMB_BL_HIGH_SHIFT

#define THUMB_BL_HIGH_SHIFT 12

Referenced by syCodeResolveLongBranches().

Definition at line 146 of file system_start_up.c.

Functions in detail

syInit

void syInit(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 enters gmMainRoutineRun and never returns.

References CartridgeResetMarker, CpuLoadDisplayEnabled, DebugMode, DebugTextEnabled, gmMainRoutineRunStub(), IoWriteQueueWork, OamCopyEnabled, SleepDisabled, syCopyBuildStamp(), syHalt(), syHeapInit(), syInitEvent(), syInstallIWRAMAndIRQs(), syIntFunction(), syPrintClear(), sySoundInitStub(), sySynch(), syVBlankHandler(), syVRAMCacheReset() and syWindowLoadGraphics().

Definition at line 7 of file system_start_up.c.

syIdleForever

void syIdleForever(void)

Unused: waits out ticks forever; the tick loop still runs the events.

References PerPush and sySynch().

Definition at line 49 of file system_start_up.c.

syGetLanguage

Sint32 syGetLanguage(void)

Returns the language of this cartridge from the header's game code letter, an CARTRIDGE_LANGUAGE. Only the Spanish and Italian editions have it.

References RomLanguageCode and Sint32.

Referenced by mnBattleStatusScreenRun() and mnBattleTargetRunSelection().

Definition at line 62 of file system_start_up.c.

syDummyReservedNoOperationA

void syDummyReservedNoOperationA(void)

Unused: five empty exports of the system library's stub table, which nothing calls.

Definition at line 80 of file system_start_up.c.

syDummyReservedNoOperationB

void syDummyReservedNoOperationB(void)

Definition at line 84 of file system_start_up.c.

syDummyReservedNoOperationC

void syDummyReservedNoOperationC(void)

Definition at line 88 of file system_start_up.c.

syDummyReservedNoOperationD

void syDummyReservedNoOperationD(void)

Definition at line 92 of file system_start_up.c.

syDummyReservedNoOperationE

void syDummyReservedNoOperationE(void)

Definition at line 96 of file system_start_up.c.

syDummyReturnZero

Sint32 syDummyReturnZero(Sint32 resourceId, const Uint8 *table)

An exported stub that ignores its arguments and reports 0.

References Sint32.

Referenced by fdSpriteViewerRun().

Definition at line 101 of file system_start_up.c.

syCopyBuildStamp

void syCopyBuildStamp(void)

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

References BuildStampWork, syDMAXCopy() and syResourceGetTableEntry().

Referenced by syInit().

Definition at line 116 of file system_start_up.c.

syResourceReservedNoOperation

void syResourceReservedNoOperation(Sint32 unused)

An exported stub that does nothing with its argument. The Title, Lucky Dice and Lucky Wheels (fdLuckyWheelsRun) call it with a stub call resource id.

References Sint32.

Referenced by fdLuckyDiceRun(), fdLuckyWheelsRun() and scInit().

Definition at line 129 of file system_start_up.c.

syResourceGetTableEntry

void *syResourceGetTableEntry(Sint32 index)

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

References ResourceDirectoryTable and Sint32.

Referenced by btBackgroundLoad(), btEffectRunAstralBlast(), btEffectRunAtalanta(), btEffectRunAttackSlash(), btEffectRunBind(), btEffectRunBreak(), btEffectRunBurstShower(), btEffectRunCondemn(), btEffectRunCriticalHit(), btEffectRunDjinnBeams(), btEffectRunDjinniEntrance(), btEffectRunDragonCloud(), btEffectRunDragonFire(), btEffectRunDrain(), btEffectRunElementBurst(), btEffectRunElementPillar(), btEffectRunEruption(), btEffectRunFlurry(), btEffectRunFroth(), btEffectRunGaia(), btEffectRunGatheringLights(), btEffectRunHaunt(), btEffectRunHealingMotes(), btEffectRunJudgment(), btEffectRunLobbedShells(), btEffectRunMars(), btEffectRunMirroredWall(), btEffectRunMoteFountain(), btEffectRunNereid(), btEffectRunOrbitingSkulls(), btEffectRunPlanetDiver(), btEffectRunPlasma(), btEffectRunProcne(), btEffectRunProjectileVolley(), btEffectRunRushingStrike(), btEffectRunShiningStar(), btEffectRunSparkGroups(), btEffectRunStarfieldFall(), btEffectRunStatBoost(), btEffectRunStatReduction(), btEffectRunStreakVolley(), btEffectRunSwirlSwipe(), btEffectRunTargetBursts(), btEffectRunTargetMotes(), btEffectRunTargetStrike(), btEffectRunThor(), btEffectRunUnusedOrbitingSpirals(), btEffectRunUnusedTriangleStrike(), btEffectRunVolcano(), btEffectRunWhirlwind() and 38 more.

Definition at line 134 of file system_start_up.c.

syCodeResolveLongBranches

void syCodeResolveLongBranches(Uint16 *pair, Sint32 byteLength)

Unused: resolves the Thumb long branches (BL pairs) of a block of code whose branch offsets are stored from the start of the block. 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: syOverlayLoad uses the ARM function that does the same.

References Sint32.

Definition at line 154 of file system_start_up.c.

syOverlayLoad

void syOverlayLoad(Uint32 index, void *dest)

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

References Sint32, syDecompressTaggedLZ(), syHeapRelease(), syResourceGetTableEntry(), syResourcePatchThumbBranch and syResourcePatchThumbBranchCodeSize.

Referenced by gmLoadOverlay().

Definition at line 226 of file system_start_up.c.

syIRQIgnore

void syIRQIgnore(void)

The handler of every interrupt nobody has claimed.

Referenced by syIntFunction().

Definition at line 240 of file system_start_up.c.

syInstallIWRAMAndIRQs

void syInstallIWRAMAndIRQs(void)

Copies the resident code to IWRAM, points the BIOS interrupt vector (IrqVector) at its dispatcher, installs the default handler table and enables the VBlank and keypad interrupts (and, in the German, French, Spanish and Italian editions, the cartridge-removed interrupt, which halts the game).

References DefaultIrqHandlers, IrqHandlers, IrqVector, IwramResidentRom, syDMAXCopy() and syIWRAMIRQMain.

Referenced by syInit().

Definition at line 248 of file system_start_up.c.