Gfx GX Fn GXSetTevColorS10 - wowjinxy/libPorpoise GitHub Wiki

GXSetTevColorS10

  • Category: Texture Environment
  • Matrix Status: Implemented
  • Matrix Notes: Implemented signed-10-bit TEV register semantics (& 0x7FF packing + sign extension) with backend float normalization for shader path.
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: reference/man/gfx/gx/Tev/GXSetTevColorS10.html
  • SDK source: reference/ACGC-PC-Port/src/static/dolphin/gx/GXTev.c (GXSetTevColorS10)
  • SDK behavior:
    • Accepts signed 10-bit style inputs (GXColorS10) and asserts each component is in [-1024, +1023].
    • Packs each component into 11-bit register fields via component & 0x7FF before BP writes.
    • Writes the TEV constant color register pair for the selected GXTevRegID.

libPorpoise Implementation

  • Public API declaration: include/dolphin/gx/GXTev.h
  • Runtime implementation: src/gx/pc_gx.c (GXSetTevColorS10)
  • Behavior:
    • Marks TEV color state dirty and writes into backend float state.
    • Wraps each component to TEV signed-11 storage domain via & 0x7FF + sign extension, matching BP register packing behavior.
    • Converts wrapped signed values with / 255.0f normalization for shader use.
    • Guards writes with id < GX_MAX_TEVREG.

SDK vs Porpoise Diff

  • Signature parity:
    • Signatures match (GXTevRegID, GXColorS10).
  • Behavioral parity:
    • Both update TEV constant color register state for a selected TEV register ID.
    • Signed-10-bit values now follow TEV register wrapping semantics before use.
  • Known divergence:
    • SDK debug path asserts if inputs are outside [-1024, +1023]; Porpoise remains fail-soft and applies wrapped register semantics without assert.

Validation Checklist

  • GX demo coverage checked
  • Pikmin usage path checked
  • Matrix status updated if needed
  • Notes updated with concrete file/function references

Working Notes

  • Runtime behavior updated in this pass to match TEV signed-10 register wrapping semantics.