Gfx GX Fn GXInitLightColor - wowjinxy/libPorpoise GitHub Wiki

GXInitLightColor

  • Category: Lighting
  • Matrix Status: Implemented
  • Matrix Notes: Verified color storage/packing in light object.
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: reference/man/gfx/gx/Lighting/GXInitLightColor.html
  • Reference source: reference/gx/GXLight.c (GXInitLightColor)
  • SDK behavior:
    • Signature: void GXInitLightColor(GXLightObj* lt_obj, GXColor color).
    • Writes the light color into the light object only (no hardware register load).
    • Reference implementation stores GXColor bytes as a packed u32 in object color storage.

libPorpoise Implementation

  • Public API declaration: include/dolphin/gx/GXLighting.h
  • Runtime implementation: src/gx/pc_gx.c (GXInitLightColor)
  • Behavior:
    • Packs GXColor {r,g,b,a} into internal 32-bit color storage and writes into light object state.
    • Loaded to active backend light state later via GXLoadLightObjImm/Indx.
    • Getter path (GXGetLightColor) returns the stored bytes back to GXColor.

SDK vs Porpoise Diff

  • Signature parity:
    • SDK: typed GXLightObj*.
    • Porpoise: typed in public header; runtime definition uses internal void* ABI-equivalent pointer.
  • Behavioral parity:
    • SDK: store RGBA color in light object memory.
    • Porpoise: same RGBA storage semantics.
  • Known divergence:
    • Porpoise calls pc_gx_lightobj_sanitize before setting color; SDK reference path directly writes color field.

Validation Checklist

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

Working Notes

  • Verified manual semantics in reference/man/gfx/gx/Lighting/GXInitLightColor.html.
  • Verified reference storage behavior in reference/gx/GXLight.c (obj->Color = *(u32*)(&color)).