DSP-1 coprocessor (NEC µPD77C25) — fixed-point 3D math from C. More...
#include <snes/types.h>Go to the source code of this file.
Functions | |
| void | dsp1Attitude (u16 scale, u16 az, u16 ay, u16 ax) |
| Build a 3D rotation matrix into slot A (DSP-1 command $01, "Attitude"). | |
| void | dsp1Init (void) |
| Resynchronise the DSP-1 to a known command-wait state. | |
| u16 | dsp1Multiply (u16 a, u16 b) |
| Signed 1.15 × 1.15 multiply (DSP-1 command $00). | |
| void | dsp1Objective (s16 x, s16 y, s16 z) |
| Transform a point by matrix A: local → world (DSP-1 command $0D, "Objective"). | |
| void | dsp1Rotate (u16 angle, s16 x, s16 y) |
| Rotate a 2D point about the origin (DSP-1 command $0C, "Rotate"). | |
| void | dsp1Triangle (u16 angle, s16 radius) |
| Scaled sine and cosine of an angle (DSP-1 command $04, "Triangle"). | |
Variables | |
| volatile s16 | dsp1_o0 |
| Multi-word DSP-1 result registers (written by multi-output commands). | |
| volatile s16 | dsp1_o1 |
| volatile s16 | dsp1_o2 |
DSP-1 coprocessor (NEC µPD77C25) — fixed-point 3D math from C.
The DSP-1 is a fixed-function math coprocessor found in Pilotwings, Super Mario Kart and other pseudo-3D games. It runs Sony's fixed firmware; you do not program it — you invoke its ~30 built-in commands (matrix, vector, projection, trig) over a two-register port. This module wraps that command interface as ordinary C calls.
Build a 3D rotation matrix into slot A (DSP-1 command $01, "Attitude").
| scale | matrix scale (T, signed 1.15; 0x7FFF ≈ 1.0) |
| az | rotation about Z (A) |
| ay | rotation about Y (A) |
| ax | rotation about X (A) |
Produces no output — it loads the matrix the transform commands consume. Call once per frame (or whenever the orientation changes), then transform your points with dsp1Objective.
| void dsp1Init | ( | void | ) |
Resynchronise the DSP-1 to a known command-wait state.
Issues the $80 Sync/Reset byte repeatedly (128×, matching the stock-game boot handshake). $80 flushes any pending command, so this recovers the chip even if a previous command was interrupted mid-parameter. Call once at startup before your first DSP-1 command; harmless to call again to recover.
|
extern |