Use psx-math for integer and fixed-point calculations that recur in gameplay, rendering and user interfaces.
How the crate is organized
sincos provides angle and trigonometric helpers. int32 covers scalar arithmetic, integer square roots and wide multiply/divide operations. fmt writes decimal text without core::fmt. color contains colour scaling and interpolation helpers. attributed_clip supplies allocation-free clipping traversal with caller-defined attributes.
Integration notes
Choose arithmetic by its rounding and overflow contract. Saturation, wrapping, truncation toward zero and arithmetic shifts can produce different results, especially for negative values. The clipping traversal leaves distance calculations and attribute interpolation to your adapter; it does not choose a game's coordinate format.
The ordering-table example uses the math crate alongside rendering. A complete host-side calculation looks like this:
fn main() {
assert_eq!(psx_math::int32::isqrt_u32(81), 9);
assert_eq!(psx_math::int32::isqrt_u32(80), 8);
}
Place this in a host binary with a path dependency on sdk/crates/psx-math.
API, dependencies and source structure
SDK revision 80d1c329e977. Structure, dependencies and features below come from this revision.
The PS1 reference includes all Cargo features. The manifest below shows which features are enabled by default.
Dependencies
No runtime Cargo dependencies.
Cargo features
| Feature | Enables |
|---|---|
asm-kernels | No additional dependency features |
default | No additional dependency features |
Read the complete manifest and feature comments.
Source layout
The list includes internal implementation and test files. Public modules, types, functions and their signatures are indexed in the API reference above.
12 source and manifest files
Cargo.tomlREADME.mdsrc/asm_kernels.rs: Hand-scheduled R3000 kernels (featureasm-kernels).src/attributed_clip.rs: Allocation-free convex clipping shared by the PS1 renderers.src/clip_lanes.rs: One-plane convex clip of eight-lanei32vertices.src/color.rs: RGB arithmetic with explicit rounding contracts.src/fmt.rs: Integer-to-decimal ASCII withoutcore::fmt.src/int32.rs: Saturating 32-bit integer scalar helpers.src/lib.rs: Fixed-point math primitives for the PS1 SDK.src/sincos.rs: Compact sin/cos lookup for Q0.12 angles.src/wide.rs: The one sanctioned wide-arithmetic type for guest code.src/wide_div.rs: Exact division of aWide/WideUvalue, in 32-bit instructions only.