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

gsSP1Triangle not parsed correctly #15

Closed
mkst opened this issue Jun 16, 2021 · 5 comments
Closed

gsSP1Triangle not parsed correctly #15

mkst opened this issue Jun 16, 2021 · 5 comments

Comments

@mkst
Copy link

mkst commented Jun 16, 2021

Tested against 9ed2a74f3190d223aab88ceef0f896e04c559890:

./n64/src/gfxdis/gfxdis.f3dex -d BF 00 00 00 00 2C 3A 3E
{
    gsSP1Triangle(0, 0, 0, 0),
}

but it should be

{
    gsSP1Triangle(30, 28, 31, 0),
}

currently compiling latest master, will close the issue if this is already fixed :)

@glankk
Copy link
Owner

glankk commented Jun 16, 2021

Where did you get this input data? It seems to be malformed, the vertex indices are supposed to go in the high word for F3DEX.

glank@glank-pc:~$ cat test.c
#include <stdio.h>
#define F3DEX_GBI
#include "gbi.h"

int main()
{
        Gfx gfx = gsSP1Triangle(30, 28, 31, 0);

        printf("%08X %08X\n", gfx.hi, gfx.lo);
}
glank@glank-pc:~$ gcc -o test test.c && ./test
BF3C383E 00000000
glank@glank-pc:~$ gfxdis.f3dex -d BF3C383E 00000000
{
    gsSP1Triangle(30, 28, 31, 0),
}

It's possible that this is meant to be Fast3D GBI, which does have vertex indices in the low word, but even then it seems to be malformed because the indices are multiplied by ten in the macro, and therefore need to be multiples of ten in the binary;

glank@glank-pc:~$ gfxdis.f3d -i -d BF000000 002C3A3E
{
    gsSP1Triangle(4 /* INVALID */, 5 /* INVALID */, 6 /* INVALID */, 0),
}

@krimtonz
Copy link
Contributor

It's not the best source, but the project 64 f3dex source reads it from the lo word for f3dex.

@mkst
Copy link
Author

mkst commented Jun 16, 2021

I'm working on decompiling Space Station Silicon Valley.

In the US 1.0 ROM:

006924a0: 0400 81ff 802e e650 b100 0204 0006 0008  .......P........
006924b0: b102 000a 0000 060c b10e 1012 0006 1416  ................
006924c0: b118 0e1a 0010 021c b11e 2022 0024 1e26  .......... ".$.&
006924d0: b128 242a 001e 242c b120 2e30 0020 1e32  .($*..$,. .0. .2
006924e0: b134 2836 0038 343a bf00 0000 003c 383e  .4(6.84:.....<8>
006924f0: 0400 81ff 802e e850 b100 0204 0006 0208  .......P........
00692500: b102 000a 000c 0e10 b100 1214 0016 0c18  ................
00692510: b10e 061a 001c 1e20 b122 1c24 0026 2228  ....... .".$.&"(
00692520: b11c 222a 001e 2c2e b11e 1c30 0032 2634  .."*..,....0.2&4
00692530: b136 3238 003a 363c bf00 0000 002c 3a3e  .628.:6<.....,:>

@krimtonz
Copy link
Contributor


/***
 ***  1 Triangle
 ***/	
#define gSP1Triangle(pkt, v0, v1, v2, flag)				\
{									\
	Gfx *_g = (Gfx *)(pkt);						\
									\
	_g->words.w0 = _SHIFTL(G_TRI1, 24, 8);				\
	_g->words.w1 = __gsSP1Triangle_w1f(v0, v1, v2, flag);		\
}
#define gsSP1Triangle(v0, v1, v2, flag)					\
{									\
	_SHIFTL(G_TRI1, 24, 8),						\
	__gsSP1Triangle_w1f(v0, v1, v2, flag)				\
}

@glankk
Copy link
Owner

glankk commented Jun 16, 2021

You're right, this seems to stem from a incorrect implementation of SP1Triangle for F3DEX in the GBI header.

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

3 participants