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 f2fec1c301f1. 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
This crate declares no Cargo 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.
7 source and manifest files
Cargo.tomlsrc/attributed_clip.rs: Allocation-free convex clipping shared by the PS1 renderers.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.