PeterLemon / N64

N64 Bare Metal Mips Assembly Programming
294 stars 43 forks source link

Shade Coefficients #38

Open bryanperris opened 4 years ago

bryanperris commented 4 years ago

From this test: https://github.com/PeterLemon/N64/blob/105fd6cfc3f863f0a128802a20ee1137907ba78e/RDP/16BPP/Triangle/ShadeTriangle320x240/Cycle1ShadeTriangle16BPP320X240.asm

You'll find this line: Shade_Coefficients 256.0,0,0,0, 5.12,5.12,-5.12,0, 256.0<<16,0<<16,0<<16,0<<16, 5.12<<16,5.12<<16,-5.12<<16,0<<16, -5.12,5.12,0,0, 0,0,0,0, -5.12<<16,5.12<<16,0<<16,0<<16, 0<<16,0<<16,0<<16,0<<16 // Generated By N64LeftMajorShadeTriangleCalc.py

N64LeftMajorShadeTriangleCalc.py only generates the Shade_Triangle edge coefficients but not the shade coefficients command that should follow after the triangle command. It would be helpful if the comment showed the triangle inputs used to generate the command asm.

The RDP doc does not describe the fields being fixed point, just 16 bits wide. The bass assembler truncates all decimal values into integers. Also why do the fraction fields need to be shifted to the left by 16 bits? The color fields come in pairs of integer, fraction fields, so it seems none of them need to be fixed point.

I want to assemble the correct values that aren't going to be truncated by the assembler and then disassemble the command back into the equivalent asm.

bryanperris commented 4 years ago

I have verified through the software RDP that decimal points are simply not needed.

Updated source file: https://gist.github.com/bryanperris/c4023a03c71ceedaaff6ebc73ffff996

Screenshot_20200816_215423