Reference · SDK

PSoXide SDK documentation

24 crate guides, searchable Rust APIs and 20 complete example programs for building PS1 homebrew.

On this page

The SDK is a set of small Rust crates for the PlayStation's hardware. There's no umbrella crate and no framework on top: a program depends on the subsystems it uses and calls them directly. Everything here targets mipsel-sony-psx and runs without an operating system. The engine and editor, which add scenes and an asset pipeline, live in the editor repository.

Start with the first-program walkthrough, run the browser examples, or browse the complete example sources. Every crate below has its own guide, dependency list, feature flags, source layout and API reference.

How the SDK fits together

Pick the crates your program needs:

WorkStart withSupporting layer
Boot, panic, interrupts and frame timingpsx-rtpsx-io for hardware access, psx-tick for fixed-rate game logic
Draw primitives and submit a framepsx-gpupsx-vram for texture and palette layout
Transform and project geometrypsx-gtepsx-gte-core, psx-math
Read controls and build a UIpsx-pad, psx-fontpsx-osk, psx-settings
Play sounds and effectspsx-spu, psx-sfxpsx-asset for cooked audio
Load and manage assetspsx-asset, psx-packpsx-cache for residency
Stream data from the disc while the game runspsx-cdstreampsx-residency for what to keep resident, psx-residency-sim to check a route on the host
Save player datapsx-mcpsx-settings for preferences
Add visual effects or videopsx-fx, psx-fmvGPU, SPU and CD services
Instrument a programpsx-telemetryEmulator profiling support

psx-hw and psxed-format are shared dependencies in the repository's root crates/ directory. Keep the repository layout intact: sdk/ alone is not a self-contained copy of all dependencies. The engine's scene and application framework is a separate layer and is not required for these examples.

Build the documented revision

The crate structures, full example listings and API reference use the same SDK revision as the embedded players: f2fec1c301f1b37cd14e3a2571c0e598fcc6dc00. After installing the tools:

git clone https://github.com/EBonura/PSoXide.git
cd PSoXide
git checkout f2fec1c301f1b37cd14e3a2571c0e598fcc6dc00
make disc EXAMPLE=hello-tri

The output is build/examples/mipsel-sony-psx/release/hello-tri.exe, plus a BIN and CUE. Open the CUE to load the disc image. The build also runs the instruction hazard and scratchpad-stack checks; retain those steps when adapting the build.

Project structure

The small examples live in their own Cargo workspaces. Start by reading the complete hello-tri manifest and source:

PSoXide/
  rust-toolchain.toml         pinned compiler and components
  crates/                    shared formats and host tools
  sdk/
    Cargo.toml               workspace containing the 24 SDK crates
    psoxide.ld               target linker script
    crates/<crate>/src/      subsystem implementations
    examples/hello-tri/
      Cargo.toml             standalone example workspace and dependencies
      Cargo.lock             resolved dependencies
      src/main.rs            no_std/no_main entry and frame loop
  tools/sdk-examples.mk      compile, check and disc-mastering rules

The example manifest selects subsystem dependencies by path. Its main.rs links psx-rt, initializes the hardware it uses and runs a frame loop. Assets embedded with include_bytes! must be available at the referenced paths when compiling. Other examples keep data on the disc and load it at runtime; an EXE download alone does not contain those files or CD audio tracks.

For a separate game repository, use the repository's pinned component bootstrap workflow to retain the shared dependencies and matching SDK revision.

API reference

Each crate guide links to its searchable Rust API: public modules, types, functions, signatures, safety contracts, examples and source. The primary reference is built for mipsel-sony-psx with all Cargo features enabled, so PS1-only APIs such as the runtime BIOS calls and MDEC driver are included. Check each crate's feature list before using an optional API in your program.

psx-gte and psx-gte-core also have a host API reference, because their software simulation backend is not part of a PS1 build. API search is available on every generated reference page. Use the PSoXide link above that reference to return to the guides.

The inventory tables follow the SDK README; the detailed structures and complete source listings are checked against the pinned code during publishing.

Device crates

CratePurpose
psx-rtBare-metal runtime: _start, BIOS calls, panic, heap, VBlank IRQ counter, corrected i64 builtins, scratchpad regions and scratchpad stacks.
psx-ioVolatile MMIO primitives for target code, plus the CD-ROM command surface.
psx-gpuHigh-level GPU API: init, primitives, framebuffers, display-window shifting.
psx-vramTyped VRAM layout primitives: color, rect, tpage, CLUT, upload helpers.
psx-spuHigh-level SPU API: typed voices, volume, pitch, ADSR, ADPCM upload, key-on/off, loop chaining, noise.
psx-sfxOne-shot sample banks, voice allocation and playback cutoff for SPU effects.
psx-settingsVersioned game preferences with optional memory-card persistence.
psx-gteGTE (COP2) wrappers. MIPS emits inline-asm coprocessor ops; host routes through psx-gte-core.
psx-gte-corePure-Rust GTE state machine and fixed-point math. Shared by psx-gte and the emulator; bit-exact against a real-console conformance corpus.
psx-mathFixed-point math: Q0.12 angles + sin/cos/atan2, int32 helpers, decimal text formatting.
psx-padSIO0 controller polling: digital + DualShock analog, PadTracker edges/repeat, diagnostic pacing.
psx-tickFixed-timestep game clock: per-game tick rate and catch-up policy, a render phase for interpolation, and consistency counters. Callers pass the VBlank count, so every rule is host-testable.
psx-fontBitmap-font atlas: 1bpp source → 4bpp CLUT VRAM texture, GP0 textured-rect draw path.
psx-fxArcade-style visual effects: particle pools, screen shake, deterministic RNG.
psx-assetRuntime parsers for cooked-asset blobs. Consumes psxed-format layouts produced by the editor.
psx-cacheGeneric no_std slot cache: keyed residency pool with LRU eviction and pinning.
psx-mcMemory-card driver: SIO0 transport, on-card filesystem format interoperable with the console's card manager, optional LZSS compression.
psx-oskOn-screen keyboard for pad-driven text entry: QWERTY/symbols pages, shift, PS4-style boxed keys.
psx-packGuest-side WORLD.PAK parsing + in-place HLZC/LZ4 decompression (reader half of psx-iso).
psx-cdstreamInterrupt-driven CD streaming: a queue of read requests drained one sector per drive interrupt, seek-first, abortable at the next sector, contiguous requests chained without a seek, and a drive arbiter for CD-DA. The state machine is host-tested against a scripted drive.
psx-residencyResidency policy for streamed data: contiguous page pools with generation handles, priority classes, pinning, distance-then-LRU eviction, retry backoff, and a fixed-slot policy. It decides what to load and what to evict and never touches the drive; reads go out through a trait. Host-tested, no heap.
psx-residency-simHost-only route simulator for psx-residency: replays a route through a region graph against the real policy and a drive model built from the silicon seek and read measurements, and reports deadline slack and misses.
psx-telemetryShared guest/host telemetry id tables for the emulator profiling hooks.
psx-fmvFMV playback building blocks: STR sector demux, BS v2 bitstream to MDEC run-length decode, MDEC upload/decode via DMA0/DMA1 (guest only), ISO9660 root-file lookup.

Examples

Run six examples in your browser, with how-tos for input, textures, drawing order, 3D and sound.

Each example is its own small workspace. Build any of them into a disc image with make disc EXAMPLE=<name>, as in the first-program walkthrough. The first six are the ones to read when learning. The rest are console tests that check a specific piece of the runtime or the hardware and print a result, so they work better as references. Checking code against PlayStation hardware explains what several of them found. hello-cdda, cdda-read-contention, hello-fmv and hello-pack need more on the disc than the program (CD audio tracks, a movie or a WORLD.PAK), which the generic disc target doesn't add.

ExampleShows
hello-triA single GPU triangle.
hello-texTextured primitives + CLUT upload.
hello-otOrdering-table depth sorting.
hello-inputController polling via psx-pad.
hello-gteGTE-accelerated transforms.
hello-audioSPU voice playback.
hello-cddaCD-DA audio tracks.
hello-xaXA-ADPCM music: four generated songs interleaved in one file, played through psx_io::cd::xa with a pad-driven switch (make hello-xa-disc).
hello-spstackA call tree run on a scratchpad stack under VBlank IRQs, checked against the RAM stack; stack-guard (tools/psoxide-hazard) proves it fits.
hello-gteirqRTPS run under VBlank IRQs, checking that psx-rt's handler never runs a GTE command twice. The emulator models this since its commit c7e3ea8; a console run remains the reference.
hello-presentpsx-rt's queued display flip, held until the frame's closing GP0(1Fh) sets GPUSTAT bit 24 (arm_draw_done, end_with_draw_done, signal_draw_done).
hello-present-queuepsx-rt's VBlank-kicked present queue (present-queue feature): whole frames published as one chain each, preamble and HUD recorded with psx_io::gpu::start_recording_raw, kicked and flipped by the VBlank handler.
hello-fmvFMV console test: streams a 2x STR with XA audio, decodes it with psx-fmv, and shows sector counts (LOST/BAD) over the video.
hello-memcardNon-destructive memory-card diagnostic: reads and hashes all 1024 frames, then (L1+R1+Cross) writes and verifies one test save.
hello-memprobeChecks psx-rt's memcpy/memset/memcmp against reference loops for every size and alignment; prints MEMPROBE PASS or FAIL.
hello-packpsx_pack::cd smoke test: streams raw and compressed WORLD.PAK chunks off the disc and checks them.
hello-cdstreampsx-cdstream on a disc: single, chained, prioritised, aborted-and-resumed and sustained reads of a known file checked byte for byte, an audio lease taken mid-read, and the foreground cost of a long read (make hello-cdstream-disc, make hello-cdstream-gate).
hello-i64probeRuns software 64-bit multiply/divide/modulo on the target and checks the results; covers psx-rt's __divdi3/__moddi3 overrides.
hello-icacheRewrites a function in cached RAM and checks that psx_rt::cache::flush_instruction_cache makes the CPU run the new code; prints ICACHE PASS, INCONCLUSIVE (nothing was stale) or FAIL.
cdda-read-contentionCD-ROM conformance probe: issues a data read while CD-DA is playing and records which IRQ the drive raises.

Host tools

The same repository holds the tools that run on your computer rather than on the console:

  • mkisopsx masters a BIN/CUE disc image, with optional CD audio tracks and a WORLD.PAK of streamed data.
  • psx-audio-cook converts audio to the SPU's ADPCM format. It resamples, encodes against an exact model of the SPU decoder, keeps loops seamless, and can share out a fixed amount of sound RAM between samples.
  • psx-anim-cook encodes skeletal animation for the engine's model format.
  • psoxide-pgo turns an emulator profile of a game into a profile-guided optimisation build.
  • psoxide-hazard (hazard-patch, hazard-scan, stack-guard) checks every linked program for instruction-ordering hazards and stack overflows before it reaches a disc.
Pre-1.0

Crates, formats and APIs still change. Games pin an exact SDK revision, and so should yours.