Skip to content

Gfx GX Fn GXGetLightColor

wowjinxy edited this page Apr 9, 2026 · 2 revisions

GXGetLightColor

  • Category: Lighting
  • Matrix Status: Implemented
  • Matrix Notes: Verified light color getter returns RGBA channels from light object state.
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: reference/man/gfx/gx/Lighting/GXGetLightColor.html
  • Reference source: reference/gx/GXLight.c (GXGetLightColor)
  • SDK behavior:
    • Signature (manual): void GXGetLightColor(GXLightObj* lt_obj, GXColor* color).
    • Reference source uses const GXLightObj* and copies packed color (obj->Color) into output GXColor.
    • Getter only; no GX/XF register writes.

libPorpoise Implementation

  • Public API declaration: include/dolphin/gx/GXGet.h
  • Runtime implementation: src/gx/pc_gx.c (GXGetLightColor)
  • Behavior:
    • Reads packed internal light color and writes color->r/g/b/a explicitly by byte.
    • Matches SDK intent of round-tripping color set by GXInitLightColor.
    • Performs output null check (if (color)) before write.

SDK vs Porpoise Diff

  • Signature parity:
    • SDK manual: GXLightObj*; SDK source often const GXLightObj*.
    • Porpoise header: GXLightObj*; runtime uses internal void* ABI-compatible implementation.
  • Behavioral parity:
    • SDK: copies packed light color to output color struct.
    • Porpoise: returns same RGBA channel values from internal packed representation.
  • Known divergence:
    • SDK source uses raw packed copy (*(u32*)color = obj->Color) with platform-layout assumption.
    • Porpoise performs explicit per-byte field assignment, which is safer across compilers while preserving values.
    • SDK debug path asserts invalid inputs; Porpoise fail-soft skips write when color == NULL.

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 SDK stores/gets color through packed u32 path in GXLight.c.
  • Verified Porpoise packs with pc_pack_gxcolor_u32 and unpacks by explicit byte assignment in getter.

Clone this wiki locally