TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/HarbourMasters/Starship/llms.txt
Use this file to discover all available pages before exploring further.
GameEngine class is the central runtime object for Starship. It owns the libultraship context, drives the audio and graphics pipelines, and exposes a dual-language surface — a static C++ class for engine code and a flat C API (extern "C") for logic that runs in the original ported C translation units. Both surfaces are declared in src/port/Engine.h.
SF64Version Enum
Before calling any version-gated API, use theSF64Version enum to identify which ROM the loaded archive originated from.
| Constant | Value | Region |
|---|---|---|
SF64_VER_US | 0x94F1D5A7 | North America |
SF64_VER_EU | 0x6EE9ADE7 | Europe (English/French/German) |
SF64_VER_EU_SPA | 0x3964945f | Europe (Spanish/Dutch) |
SF64_VER_JP | 0x3728D3E1 | Japan |
GameEngine C++ Class
GameEngine is a singleton. Access it via GameEngine::Instance after GameEngine::Create() has been called during boot.
Lifecycle Methods
GameEngine::Create()
GameEngine::Instance). Registers all resource importers, sets up the libultraship context, and opens the sf64.o2r / starship.o2r archives. Call this exactly once at startup before any other engine function.
GameEngine::Destroy()
StartFrame()
GenAssetFile(bool exitOnFail)
sf64.o2r from a ROM if it is missing or stale. When exitOnFail is true (default) the process terminates if extraction fails. Returns true on success.
Graphics Methods
RunCommands()
FrameInterpolation_Interpolate(). This is the main rendering entry point called once per rendered frame.
Pointer to the root display list command buffer.
Per-frame matrix replacement maps returned by
FrameInterpolation_Interpolate(). Pass an empty vector to skip interpolation.ProcessGfxCommands()
RunCommands() for normal gameplay rendering; use this only for HUD or debug overlays that must not be interpolated.
GetInterpolationFPS()
gInterpolationFPS (default 60), but respects gMatchRefreshRate and gVsyncEnabled overrides. Use this value to drive per-frame timing logic in mods that need to be framerate-aware.
GetInterpolationFrameCount()
⌈GetInterpolationFPS() / (60 / gVIsPerFrame)⌉. Useful for distributing per-tick work across sub-frames.
Audio Methods
AudioInit() / AudioExit()
Create() / Destroy(). Do not call from mod code unless you are replacing the entire audio subsystem.
HandleAudioThread()
StartAudioFrame() / EndAudioFrame()
StartAudioFrame acquires the audio mutex and advances internal timing; EndAudioFrame releases it and triggers sample generation.
Utility Methods
HasVersion()
true when the loaded archive was built from the specified ROM version. Use this to gate version-specific asset paths or behavior differences.
ShowYesNoBox()
IDYES (6) or IDNO (7). Blocks the calling thread.
Dialog window title.
Message body text.
ShowMessage()
type controls the icon: SDL_MESSAGEBOX_ERROR, SDL_MESSAGEBOX_WARNING, or SDL_MESSAGEBOX_INFORMATION.
C API (extern "C")
All functions below are declared with C linkage and are callable from both C and C++ translation units.
Memory
GameEngine_Malloc()
size bytes from the engine memory pool. The engine tracks every allocation and frees the entire pool on Destroy(). Prefer this over raw malloc for temporary mod allocations so memory is always reclaimed on shutdown.
Version Check
GameEngine_HasVersion()
GameEngine::HasVersion(). Returns true when the loaded archive matches ver.
Graphics
GameEngine_ProcessGfxCommands()
GameEngine_GetAspectRatio()
float (e.g. 1.7778 for 16:9). Use when manually computing projection matrices in mod code.
GameEngine_GetInterpolationFrameCount()
GameEngine::GetInterpolationFrameCount().
Texture Info
GameEngine_GetTextureInfo()
custom is set to true when the asset was loaded from a player-installed mod rather than the base sf64.o2r.
Archive-relative asset path, e.g.
"gfx/sprites/arwing.tex".Receives the texture width in pixels.
Receives the texture height in pixels.
Receives the stored scale factor (1.0 for unscaled assets).
Receives
true if the texture originates from a mod pack.Archive Check
GameEngine_OTRSigCheck()
imgData is a path that exists in the loaded .o2r archive. Used internally by LOAD_ASSET to decide whether to redirect an asset pointer into the archive or pass it through as-is (e.g. a raw ROM pointer).
Viewport / Resolution
OTRGetCurrentWidth() / OTRGetCurrentHeight()
OTRGetGameRenderWidth() / OTRGetGameRenderHeight()
HUD Layout
The HUD layout helpers translate N64 fixed-screen coordinates (320 × 240) into the actual viewport, accounting for widescreen, custom HUD aspect ratio overrides, and pillarbox/letterbox regions.All
float-returning variants operate on sub-pixel positions. The int16_t-returning OTRGetRectDimension* variants are drop-in replacements for the Rect macro calls found in the original rendering code.OTRGetHUDAspectRatio()
gHUDAspectRatio.Enabled is set and both gHUDAspectRatio.X / gHUDAspectRatio.Y are non-zero, returns the custom ratio; otherwise falls back to the game render aspect ratio.
OTRConvertHUDXToScreenX()
OTRGetDimensionFromLeftEdge() / OTRGetDimensionFromRightEdge()
v from the left or right edge of the safe HUD area. Use for anchoring HUD elements to screen edges regardless of aspect ratio.
OTRGetRectDimensionFromLeftEdge() / OTRGetRectDimensionFromRightEdge()
Rect/gSPScisTextureRectangle calls.
Forced Aspect Ratio Variants
aspectRatio instead of the detected render ratio. Pass 4.0f / 3.0f to force original N64 layout.
Override Variants
Tile Size Interpolation
gDPSetTileSizeInterp()
gDPSetTileSize command with sub-pixel UV coordinates for use inside interpolated display lists. The standard macro only accepts integer UV values; this variant accepts floats so the interpolation system can produce smooth UV animation.
Pointer to the current display list write position.
Tile descriptor index (0–7).
Upper-left S coordinate in 10.2 fixed-point units.
Upper-left T coordinate in 10.2 fixed-point units.
Lower-right S coordinate in 10.2 fixed-point units.
Lower-right T coordinate in 10.2 fixed-point units.