gonetz / GLideN64

A new generation, open-source graphics plugin for N64 emulators.
Other
754 stars 174 forks source link

gSPDMATriangles #2831

Closed olivieryuyu closed 1 month ago

olivieryuyu commented 2 months ago

Checking out the ucode of Mickey Speedway USA, i went through command 0x05.

I am not sure that the implementation in Gliden64 matches it.

At the start of the command, the code checks this nibble:

05110020

if 0, texturing is set off.

if 1, texturing is set on

The number of triangles managed by this command is this nibble + 1

0x05110020

in this example it is therefore 2.

The code goes to the list retrieved from RDRAM to DMEM, decrementing the number of triangles to draw till 0.

data retrieved from RDRAM to DMEM has this structure

byte: mode byte: vtx0 byte: vtx1 byte: vtx2 word0: S&T0 word1: S&T1 word2: S1T2

the higher nibble of byte mode is either 4 or 0.

4 means that G_CULL_BACK in geomode is getting off.

0 means that G_CULL_BACK in geomode is getting on.

This is all what this command does for what i can understand from the code.

gonetz commented 2 months ago

The current code uses the second nibble of the command to get the number of triangles. As you can see, in command 0x05110020, it is also 2. I checked, for command cmd, the second nibble is always equal to the sixth nibble + 1: ((cmd>>20)&15)+1) == ((cmd>>4)&15) But if the ucode actually uses value of the sixth nibble, ok.

if 0, texturing is set off. if 1, texturing is set on

I was not used. I added that code.

The rest is already implemented exactly as you described, see gSPDMATriangles function.

Fixed in commit b021d8ee4372. I don't expect any changes in Mickey Speedway USA and JFG, which use that ucode.

olivieryuyu commented 2 months ago

Super :)

I am going through the whole ucode actually. Interesting code, mainly when it comes to matrix and vertex.

There is not much difference with current implementation but there is some details which we can add, even if it won't lead i guess to much changes :)

olivieryuyu commented 1 month ago

@gonetz

actually DKR has exactly the same code for gSPDMATriangles. No distinction should be made here so between DRK and JFG.

gonetz commented 1 month ago

actually DKR has exactly the same code for gSPDMATriangles. No distinction should be made here so between DRK and JFG.

Done.