Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Module ops

Module ops 

Source
Expand description

GTE function-op wrappers.

Each op corresponds to one COP2 cofun instruction. The constants below are the exact 32-bit encodings PSX-SPX documents – the same bits the MIPS CPU would dispatch on hardware and the same bits the emulator’s Gte::execute decodes. On host we hand them straight to the per-thread software GTE in crate::host; on MIPS we emit them as .word instructions so LLVM’s integrated assembler can’t reject the COP2 mnemonics it doesn’t recognise.

Encoding (per PSX-SPX, “GTE Coprocessor Opcodes”):

  bits 31..26 = 0x12 (010010)      -- COP2
  bit  25     = 1                   -- `cop2 cofun` prefix
  bit  19     = sf                  -- fraction-shift
  bits 18..17 = mx                  -- MVMVA matrix select
  bits 16..15 = vx                  -- MVMVA vector select
  bits 14..13 = cv                  -- MVMVA translation select
  bit  10     = lm                  -- IR lower-bound mode
  bits 5..0   = opcode              -- function id

The 0x4A000000 base (0x12<<26 | 1<<25) is common to every op.

Functions§

average_z3⚠
Average SZ1..SZ3 weighted by ZSF3 into OTZ and MAC0 (AVSZ3).
average_z4⚠
Average SZ0..SZ3 weighted by ZSF4 into OTZ and MAC0 (AVSZ4).
color_color⚠
Light IR through the light color matrix and modulate by RGBC (CC).
color_depth_cue⚠
color_color followed by a depth cue toward the far color (CDP).
depth_cue_light⚠
Depth-cue a lit color: RGBC*IR toward FC by IR0 (DCPL).
depth_cue_single⚠
Depth-cue RGBC toward the far color by IR0 (DPCS).
depth_cue_triple⚠
depth_cue_single run three times against the RGB FIFO (DPCT).
interpolate_far_color⚠
Interpolate IR toward the far color by IR0, then push the color FIFO (INTPL).
light_color_depth_single⚠
Light, color and depth-cue one vertex normal (NCDS, sf=1, lm=0).
light_color_depth_triple⚠
light_color_depth_single for V0, V1 and V2 (NCDT).
light_color_single⚠
Light and color one vertex normal, no depth cue (NCCS).
light_color_triple⚠
light_color_single for V0, V1 and V2 (NCCT).
light_single⚠
Light one vertex normal, without the RGBC modulate (NCS).
light_triple⚠
light_single for V0, V1 and V2 (NCT).
nccs⚠Deprecated
Renamed to light_color_single.
ncct⚠Deprecated
Renamed to light_color_triple.
outer_product⚠
Outer product of IR with the rotation matrix diagonal (OP, sf=1).
project_single⚠
Perspective-project V0 (RTPS, sf=1, lm=0).
project_triple⚠
Perspective-project V0, V1 and V2 in sequence (RTPT, sf=1, lm=0).
rotate_translate_v0⚠
Rotate V0 by RT and add TR, without the perspective divide (MVMVA with mx=RT, vx=V0, cv=TR, sf=1, lm=0).
rotate_v0_far_color⚠
Rotate V0 by RT with the far color as the translation (MVMVA with mx=RT, vx=V0, cv=FC, sf=1, lm=0).
rtps⚠Deprecated
Renamed to project_single.
rtpt⚠Deprecated
Renamed to project_triple.
scale_vector⚠
Scale the IR vector by IR0 into MAC, then push the color FIFO (GPF, sf=1).
scale_vector_accumulate⚠
Add the IR vector scaled by IR0 to MAC, then push the color FIFO (GPL, sf=1).
scale_vector_unshifted⚠
Scale the IR vector by IR0 into MAC, then push the color FIFO, without the fractional right shift (GPF, sf=0).
screen_winding⚠
Winding of the three SXY entries (NCLIP): the Z component of (SXY1-SXY0) × (SXY2-SXY0) into MAC0.
square⚠
Square the current IR vector into MAC1/2/3 (SQR, sf=1).
square_unshifted⚠
Square the current IR vector into MAC1/2/3 without the fractional right shift (SQR, sf=0).