Gfx GX Fn GXSetTevColor - wowjinxy/libPorpoise GitHub Wiki

GXSetTevColor

  • Category: Texture Environment
  • Matrix Status: Implemented
  • Matrix Notes: Implemented typed register-color upload (GXColor) for TEV color registers.
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: reference/man/gfx/gx/Tev/GXSetTevColor.html
  • SDK source: reference/ACGC-PC-Port/src/static/dolphin/gx/GXTev.c (GXSetTevColor)
  • SDK behavior:
    • Writes one TEV color register (id) using unsigned 8-bit RGBA inputs from GXColor.
    • Intended for constant TEV register colors; signed 10-bit path is GXSetTevColorS10.
    • SDK debug path checks GX-begin state (no explicit id range assert in this function).

libPorpoise Implementation

  • Public API declaration: include/dolphin/gx/GXTev.h
  • Runtime implementation: src/gx/pc_gx.c (GXSetTevColor)
  • Behavior:
    • Stores GXColor into per-register TEV constant color state and marks TEV-color state dirty.
    • Uses normalized float storage (0..1) for shader consumption.
    • Applies id < GX_MAX_TEVREG guard.

SDK vs Porpoise Diff

  • Signature parity:
    • Signatures match (GXTevRegID, GXColor).
  • Behavioral parity:
    • TEV constant register color update behavior matches intended TEV usage.
  • Known divergence:
    • SDK uses BP register writes directly; Porpoise stores normalized float state for shader path.
    • Porpoise adds explicit id bound guard; SDK code path does not include a dedicated id assert in this routine.

Validation Checklist

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

Working Notes

  • No runtime code change required in this pass.