runtime
games/tbs/src/runtime on GitHub
The Runtime guide explains this folder.
Folders
math_table.c
games/tbs/src/runtime/math_table.c
Globals
gMath_TwoPiSteps
const u16 gMath_TwoPiSteps[8]
floor(i * 2π)
gMath_QuadrantSin
const s32 gMath_QuadrantSin[4]
The sine at 0, 90, 180 and 270 degrees, in Q16.
gMath_TanTable
const u16 gMath_TanTable[258]
Tangents scaled by 256: index i is tan(i * 45 / 128 degrees), so index 128 is tan(45 degrees). ArcTan2 starts its binary search at index 127.
Used by ArcTan2.
Also, globals without a comment: gMath_SinQuarter.
numtext.c
games/tbs/src/runtime/numtext.c
Globals, without a comment: gText_HexDigits, gText_PowersOfTen.
runtime.c
games/tbs/src/runtime/runtime.c
The runtime object: what every other part of the game stands on. Power-up and the interrupt handlers, the frame wait and VBlank, input, the register write queue, fades, the sprite lists and VRAM cache, the task scheduler, maths, debug text, the heap, the 3D transform, saving and the link cable.
runtime_internal.h holds what every part shares (its includes); the code is in the files under runtime/, included here in the order it has in the ROM. Camelot's own files are not recoverable: the ROM shows one object, and these parts are ours, cut where one family ends and the next begins. README.md in this folder gives the words and prefixes the parts use. Where to start:
Power-up system.c: System_Initialize
Frames frame.c: WaitFrames, System_VBlankHandler,
Runtime_SetIrqHandler; scheduler.c:
Scheduler_AddOrUpdateCallback
Screen fade.c: Fade_Start; render.c: Render_BuildOamList;
vram_cache.c: VramCache_Load
Memory heap.c: Runtime_AllocateHeapBlock, MemAlloc
3D transform.c: SceneTransform_ApplyRotationTranslation,
Render_ProjectPoint
Saving save.c: SaveState_WriteRecord,
SaveState_ReadRecordPayload
Link cable serial.c: SerialRuntime_Initialize,
SerialRuntime_ExchangePayloadsruntime_internal.h
games/tbs/src/runtime/runtime_internal.h
Declarations
_call_via_r3
s32 _call_via_r3(s32, s32, s32, s32)
The compiler library's call through r3, which render.c and save.c use to run code copied to RAM with four arguments.