Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support for gSPFogPosition command & inaccurate combine/LERP #19

Closed
MegaMech opened this issue Dec 8, 2021 · 3 comments
Closed

No support for gSPFogPosition command & inaccurate combine/LERP #19

MegaMech opened this issue Dec 8, 2021 · 3 comments

Comments

@MegaMech
Copy link

MegaMech commented Dec 8, 2021

F3DEX1
Issue 1

Machine code: BC00000800000000

From hack64:

G_MW_FOG | 0x08 | Specifies the multiplier and offset for fog effects.

Byte-matching C code:

gSPFogPosition(gDisplayListHead++, (s16)0-1000, (s16)0-1000);

In mk64 the args match as two s16s. iirc they are minimum and maximum values for fog thickness.
Dunno if it actually asks for s16. That's just what mk64 does.

Issue 2
Mips to C output:

    temp_v0_11->unk4 = -0x7C8;
    temp_v0_11->unk0 = 0xFC127FFF;

gfxdis: FC127FFF00000000
output:

gDPSetCombineLERP(gDisplayListHead++, TEXEL0, COMBINED, SHADE, COMBINED, 0, COMBINED, 0, COMBINED, 0, COMBINED, 0, COMBINED, COMBINED, COMBINED, LOD_FRACTION, COMBINED);

Matching C:

gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATERGB, G_CC_PASS2);

Note that G_CC_MODULATEIA appears to be the default flag that gfxdis outputs. This case required G_CC_MODULATERGB dunno if that's a thing that gfxdis can realize (I'm assuming not, so we can ignore that. Just wanted to point that out in-case that's important)

@glankk
Copy link
Owner

glankk commented Dec 8, 2021

Issue 1 happens because gfxdis is rejecting SPFogPosition macros with a zero in the z multiplier as invalid, since there's no input in the normal range that can produce that output. This has been fixed in libgfxd, where a macro with invalid values for SPFogPosition is replaced by an equivalent SPFogFactor. I'll port the fix over to gfxdis.

For issue 2, substituting -0x7C8 for the second half of the input produces the correct output:

$ gfxdis.f3dex -d FC127FFF FFFFF838
{
    gsDPSetCombineMode(G_CC_MODULATEI, G_CC_PASS2),
}

Note that G_CC_MODULATEI is equivalent to G_CC_MODULATERGB, and FFFFF838 is equal to -0x7C8.

@MegaMech
Copy link
Author

MegaMech commented Dec 8, 2021

Should I be using libgfxd instead of gfxdis?

@glankk
Copy link
Owner

glankk commented Dec 8, 2021

No, libgfxd is just a library based on gfxdis, but its a separate thing at the moment when ideally gfxdis would be built on top of libgfxd.

@glankk glankk closed this as completed in 96a6a18 Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants