benilla-re systems structs docs

TextureChooseFormat

function · gx · primitive

Address
0x44a790 · 321 bytes, up to 0x44a8d0
Signature
void __fastcall (uint32_t *typeCode, uint32_t *format, uint32_t alphaType, uint32_t alphaDepth)
Meaning
Chooses the pixel type code and GxTex format of a BLP from its alpha type byte, alpha depth and the device DXT flags
Confidence
verified, proof one
Finding
gx/texturesize#blp-format-chooser
Test
gx::texture_format_choice_difftest

Finding: BLP format chooser in gx: texture sizes and formats

0x44a790(alphaType, alphaDepth) chooses a pixel type code and a GxTex format for the BLP callback 0x44a560. It reads the header byte at reader +0x0e (0 to 8) and the alpha depth, never the compression byte, and the device flags +0x40 (DXT1), +0x44 (DXT3) and +0x48 (DXT5) as non-zero words. A byte of 6 or above 8 stores nothing. The code goes to the first output (ecx) and the format to the second (edx). Bytes 0, 1 and 7 depend on the device:

bytedevice flagtype codeformat
0+0x40 set0Dxt1
0clear, depth 05Rgb565
0clear, depth above 03Argb1555
1+0x44 set1Dxt3
1clear4Argb4444
7+0x48 set7Dxt5
7clear4Argb4444

The derivation is in the doc.

Callers 1

Callees 1

Calls and jumps by a bare address, from tables/calls.tsv.