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:
| Work | Start with | Supporting layer |
|---|---|---|
| Boot, panic, interrupts and frame timing | psx-rt | psx-io for hardware access, psx-tick for fixed-rate game logic |
| Draw primitives and submit a frame | psx-gpu | psx-vram for texture and palette layout |
| Transform and project geometry | psx-gte | psx-gte-core, psx-math |
| Read controls and build a UI | psx-pad, psx-font | psx-osk, psx-settings |
| Play sounds and effects | psx-spu, psx-sfx | psx-asset for cooked audio |
| Load and manage assets | psx-asset, psx-pack | psx-cache for residency |
| Stream data from the disc while the game runs | psx-cdstream | psx-residency for what to keep resident, psx-residency-sim to check a route on the host |
| Save player data | psx-mc | psx-settings for preferences |
| Add visual effects or video | psx-fx, psx-fmv | GPU, SPU and CD services |
| Instrument a program | psx-telemetry | Emulator 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
| Crate | Purpose |
|---|---|
psx-rt | Bare-metal runtime: _start, BIOS calls, panic, heap, VBlank IRQ counter, corrected i64 builtins, scratchpad regions and scratchpad stacks. |
psx-io | Volatile MMIO primitives for target code, plus the CD-ROM command surface. |
psx-gpu | High-level GPU API: init, primitives, framebuffers, display-window shifting. |
psx-vram | Typed VRAM layout primitives: color, rect, tpage, CLUT, upload helpers. |
psx-spu | High-level SPU API: typed voices, volume, pitch, ADSR, ADPCM upload, key-on/off, loop chaining, noise. |
psx-sfx | One-shot sample banks, voice allocation and playback cutoff for SPU effects. |
psx-settings | Versioned game preferences with optional memory-card persistence. |
psx-gte | GTE (COP2) wrappers. MIPS emits inline-asm coprocessor ops; host routes through psx-gte-core. |
psx-gte-core | Pure-Rust GTE state machine and fixed-point math. Shared by psx-gte and the emulator; bit-exact against a real-console conformance corpus. |
psx-math | Fixed-point math: Q0.12 angles + sin/cos/atan2, int32 helpers, decimal text formatting. |
psx-pad | SIO0 controller polling: digital + DualShock analog, PadTracker edges/repeat, diagnostic pacing. |
psx-tick | Fixed-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-font | Bitmap-font atlas: 1bpp source → 4bpp CLUT VRAM texture, GP0 textured-rect draw path. |
psx-fx | Arcade-style visual effects: particle pools, screen shake, deterministic RNG. |
psx-asset | Runtime parsers for cooked-asset blobs. Consumes psxed-format layouts produced by the editor. |
psx-cache | Generic no_std slot cache: keyed residency pool with LRU eviction and pinning. |
psx-mc | Memory-card driver: SIO0 transport, on-card filesystem format interoperable with the console's card manager, optional LZSS compression. |
psx-osk | On-screen keyboard for pad-driven text entry: QWERTY/symbols pages, shift, PS4-style boxed keys. |
psx-pack | Guest-side WORLD.PAK parsing + in-place HLZC/LZ4 decompression (reader half of psx-iso). |
psx-cdstream | Interrupt-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-residency | Residency 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-sim | Host-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-telemetry | Shared guest/host telemetry id tables for the emulator profiling hooks. |
psx-fmv | FMV 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.
| Example | Shows |
|---|---|
hello-tri | A single GPU triangle. |
hello-tex | Textured primitives + CLUT upload. |
hello-ot | Ordering-table depth sorting. |
hello-input | Controller polling via psx-pad. |
hello-gte | GTE-accelerated transforms. |
hello-audio | SPU voice playback. |
hello-cdda | CD-DA audio tracks. |
hello-xa | XA-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-spstack | A call tree run on a scratchpad stack under VBlank IRQs, checked against the RAM stack; stack-guard (tools/psoxide-hazard) proves it fits. |
hello-gteirq | RTPS 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-present | psx-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-queue | psx-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-fmv | FMV console test: streams a 2x STR with XA audio, decodes it with psx-fmv, and shows sector counts (LOST/BAD) over the video. |
hello-memcard | Non-destructive memory-card diagnostic: reads and hashes all 1024 frames, then (L1+R1+Cross) writes and verifies one test save. |
hello-memprobe | Checks psx-rt's memcpy/memset/memcmp against reference loops for every size and alignment; prints MEMPROBE PASS or FAIL. |
hello-pack | psx_pack::cd smoke test: streams raw and compressed WORLD.PAK chunks off the disc and checks them. |
hello-cdstream | psx-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-i64probe | Runs software 64-bit multiply/divide/modulo on the target and checks the results; covers psx-rt's __divdi3/__moddi3 overrides. |
hello-icache | Rewrites 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-contention | CD-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:
mkisopsxmasters a BIN/CUE disc image, with optional CD audio tracks and aWORLD.PAKof streamed data.psx-audio-cookconverts 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-cookencodes skeletal animation for the engine's model format.psoxide-pgoturns 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.
Crates, formats and APIs still change. Games pin an exact SDK revision, and so should yours.