SDK crate

psx-math

Fixed-point numbers, clipping and text formatting

On this page

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