diff --git a/.gitignore b/.gitignore index 66f9179..1179299 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,6 @@ ctx.c.m2c .vscode/* !.vscode/c_cpp_properties.json tools/vtxdis -tools/permuter/ +tools/permuter +tools/n64 .DS_Store diff --git a/src/334D0.h b/src/334D0.h index ee2f21a..4aaf041 100644 --- a/src/334D0.h +++ b/src/334D0.h @@ -6,5 +6,7 @@ void func_800328D0(s32); s32 func_800328D8(s32); void func_80032A34(s32); +void func_80032D28(void); +Gfx* func_80032F94(Gfx*); #endif // _334D0_H_ diff --git a/src/fragments/1/fragment1_86CB0.c b/src/fragments/1/fragment1_86CB0.c index a06bef6..f14c0ea 100644 --- a/src/fragments/1/fragment1_86CB0.c +++ b/src/fragments/1/fragment1_86CB0.c @@ -185,7 +185,7 @@ u16 func_81207C5C_Empty(void) { } #ifdef NON_MATCHING -// Does match but won't generate correct checksum +// Matching but won't generate correct checksum u16 func_81207DF8(void) { static s32 D_8120EB6C; u16 temp_v0; diff --git a/src/fragments/31/fragment31.h b/src/fragments/31/fragment31.h index 9cf9bac..de15ea9 100644 --- a/src/fragments/31/fragment31.h +++ b/src/fragments/31/fragment31.h @@ -4,10 +4,16 @@ #include "global.h" #include "30640.h" -typedef struct GraphicState { - /* 0x00 */ char unk00[0x18]; +typedef struct DisplayListAddresses { + /* 0x00 */ u32 segments[2]; + /* 0x08 */ u32 textures[1]; +} DisplayListAddresses; // size = 0xC + +typedef struct DisplayListState { + /* 0x00 */ char unk00[0x14]; + /* 0x14 */ DisplayListAddresses* addresses; /* 0x18 */ Gfx* gfx; -} GraphicState; // size >= 0x1C +} DisplayListState; // size = 0x1C void func_810007A8(unk_D_86002F58_004_000*); void func_810007F8(void); diff --git a/src/fragments/31/fragment31_2554C0.c b/src/fragments/31/fragment31_2554C0.c index 551281f..0155133 100644 --- a/src/fragments/31/fragment31_2554C0.c +++ b/src/fragments/31/fragment31_2554C0.c @@ -1,34 +1,64 @@ #include "fragment31.h" #include "src/6A40.h" #include "src/12D80.h" +#include "src/32D10.h" +#include "src/334D0.h" -typedef struct unk_arg1_func_81000200 { - /* 0x00 */ u32 unk_00; - /* 0x04 */ u32 unk_04; - /* 0x04 */ u32 unk_08; -} unk_arg1_func_81000200; // size >= 0xC +Gfx* func_81000200(Gfx* gfx, DisplayListAddresses* addresses, s32 index) { + gSPDisplayList(gfx++, addresses->segments[0]); + // TODO: Convert to gDPLoadTextureBlock + { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xFD900000; _gfx->words.w1 = addresses->textures[index]; } + { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xF5900000; _gfx->words.w1 = 0x07080200; } + { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xE6000000; _gfx->words.w1 = 0; } + { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xF3000000; _gfx->words.w1 = 0x073FF200; } + { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xE7000000; _gfx->words.w1 = 0; } + { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xF5880800; _gfx->words.w1 = 0x80200; } + { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xF2000000; _gfx->words.w1 = 0x7C0FC; } + gSPDisplayList(gfx++, addresses->segments[1]); + gSPEndDisplayList(gfx++); + return gfx; +} -typedef struct unk_arg1_func_810002DC { - /* 0x00 */ char unk00[0x14]; - /* 0x14 */ unk_arg1_func_81000200* unk_14; - /* 0x18 */ Gfx* unk_18; -} unk_arg1_func_810002DC; // size >= 0x1C - -// Gfx* func_81000200(Gfx* gfx, unk_arg1_func_81000200* arg1, s32 index); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2554C0/func_81000200.s") - -void func_810002DC(s32 arg0, unk_arg1_func_810002DC* arg1) { +void func_810002DC(s32 arg0, DisplayListState* state) { Gfx* gfx; - unk_arg1_func_81000200* sp18; + DisplayListAddresses* addresses; if (arg0 == 2) { - sp18 = arg1->unk_14; + addresses = state->addresses; gfx = func_80005F5C(0x50); - arg1->unk_18 = gfx; - func_81000200(gfx, sp18, D_8006F084 & 7); + state->gfx = gfx; + func_81000200(gfx, addresses, D_8006F084 & 7); } } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2554C0/func_81000330.s") +Gfx* func_81000330(Gfx* gfx, DisplayListAddresses* addresses, s32 index) { + gDPLoadTextureBlock(gfx++, addresses->textures[index], G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + func_80032D28(); + { + Gfx* gfx2 = func_80032F94(gfx); + gSPSetGeometryMode(gfx2++, 0x00020000); + gSPEndDisplayList(gfx2++); + return gfx2; + } +} +#ifdef NON_MATCHING +// Matching but issue with .data +void func_81000420(s32 arg0, DisplayListState* state) { + static s32 D_81003FD0; // .data + Gfx* gfx; + DisplayListAddresses* addresses; + u8 temp_v1; + + temp_v1 = func_800325B4(); + if (arg0 == 2) { + addresses = state->addresses; + gfx = func_80005F5C(0x140); + state->gfx = gfx; + func_81000330(gfx, addresses, ((D_800AF7B0[temp_v1 & 1] * 3) + D_81003FD0) % 8); + D_81003FD0 += 1; + } +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2554C0/func_81000420.s") +#endif diff --git a/src/fragments/31/fragment31_2557A0.c b/src/fragments/31/fragment31_2557A0.c index 23d53ad..4975025 100644 --- a/src/fragments/31/fragment31_2557A0.c +++ b/src/fragments/31/fragment31_2557A0.c @@ -1,9 +1,40 @@ #include "fragment31.h" +#include "src/6A40.h" +#include "src/12D80.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2557A0/func_810004E0.s") +void func_810004E0(Gfx* gfx, DisplayListAddresses* addresses) { + gSPDisplayList(gfx++, addresses->segments[0]); + gSPDisplayList(gfx++, addresses->segments[1]); + gSPEndDisplayList(gfx++); +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2557A0/func_81000518.s") +void func_81000518(s32 arg0, DisplayListState* state) { + Gfx* gfx; + DisplayListAddresses* addresses; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2557A0/func_81000560.s") + if (arg0 == 2) { + addresses = state->addresses; + gfx = func_80005F5C(0x18); + state->gfx = gfx; + func_810004E0(gfx, addresses); + } +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2557A0/func_8100059C.s") +void func_81000560(Gfx* gfx, s32* address) { + if (D_8006F09C->unk_01C == 0) { + gSPDisplayList(gfx++, *address); + } + gSPEndDisplayList(gfx++); +} + +void func_8100059C(s32 arg0, DisplayListState* state) { + Gfx* gfx; + DisplayListAddresses* addresses; + + if (arg0 == 2) { + addresses = state->addresses; + gfx = func_80005F5C(0x50); + state->gfx = gfx; + func_81000560(gfx, addresses); + } +} diff --git a/src/fragments/31/fragment31_257750.c b/src/fragments/31/fragment31_257750.c index afaebcd..188e7c9 100644 --- a/src/fragments/31/fragment31_257750.c +++ b/src/fragments/31/fragment31_257750.c @@ -1,33 +1,22 @@ #include "fragment31.h" #include "12D80.h" -typedef struct unk_arg1_func_81002490 { - /* 0x00 */ u32 unk_00; - /* 0x04 */ u32 unk_04; -} unk_arg1_func_81002490; // size >= 0x8 - -typedef struct unk_arg1_func_81002968 { - /* 0x00 */ char unk00[0x14]; - /* 0x14 */ unk_arg1_func_81002490* unk_14; - /* 0x18 */ Gfx* unk_18; -} unk_arg1_func_810024E4; // size >= 0x1C - -void func_81002490(Gfx* gfx, unk_arg1_func_81002490* arg1) { +void func_81002490(Gfx* gfx, DisplayListAddresses* addresses) { if (D_8006F09C->unk_01C == 0) { - gSPDisplayList(gfx++, arg1->unk_00); + gSPDisplayList(gfx++, addresses->segments[0]); } - gSPDisplayList(gfx++, arg1->unk_04); + gSPDisplayList(gfx++, addresses->segments[1]); gSPEndDisplayList(gfx++); } -void func_810024E4(s32 arg0, unk_arg1_func_810024E4* arg1) { - s32 temp_v0; - s32 sp18; +void func_810024E4(s32 arg0, DisplayListState* state) { + Gfx* gfx; + DisplayListAddresses* addresses; if (arg0 == 2) { - sp18 = arg1->unk_14; - temp_v0 = func_80005F5C(0x50); - arg1->unk_18 = temp_v0; - func_81002490(temp_v0, sp18); + addresses = state->addresses; + gfx = func_80005F5C(0x50); + state->gfx = gfx; + func_81002490(gfx, addresses); } } diff --git a/src/fragments/31/fragment31_2577F0.c b/src/fragments/31/fragment31_2577F0.c index 04cb74f..d05330a 100644 --- a/src/fragments/31/fragment31_2577F0.c +++ b/src/fragments/31/fragment31_2577F0.c @@ -2,28 +2,17 @@ #include "32D10.h" #include "12D80.h" -typedef struct unk_arg1_func_81002530 { - /* 0x00 */ u32 unk_00; - /* 0x04 */ u32 unk_04; -} unk_arg1_func_81002530; // size >= 0x8 - -typedef struct unk_arg1_func_810027E0 { - /* 0x00 */ char unk00[0x14]; - /* 0x14 */ unk_arg1_func_81002530* unk_14; - /* 0x18 */ Gfx* unk_18; -} unk_arg1_func_810027E0; // size >= 0x1C - -void func_81002530(Gfx*, unk_arg1_func_81002530*); +void func_81002530(Gfx*, DisplayListAddresses*); #pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2577F0/func_81002530.s") -void func_810027E0(s32 arg0, unk_arg1_func_810027E0* arg1) { +void func_810027E0(s32 arg0, DisplayListState* state) { Gfx* gfx; - s32 sp18; + DisplayListAddresses* addresses; if (arg0 == 2) { - sp18 = arg1->unk_14; - gfx = (Gfx*)func_80005F5C(0xF0); - arg1->unk_18 = gfx; - func_81002530(gfx, sp18); + addresses = state->addresses; + gfx = func_80005F5C(0xF0); + state->gfx = gfx; + func_81002530(gfx, addresses); } } diff --git a/src/fragments/31/fragment31_257DE0.c b/src/fragments/31/fragment31_257DE0.c index 3511e65..1454adc 100644 --- a/src/fragments/31/fragment31_257DE0.c +++ b/src/fragments/31/fragment31_257DE0.c @@ -10,11 +10,11 @@ void func_81002B20(Gfx* gfx) { angle = D_8006F09C->unk_0A6 & 3; mtx = (Mtx*)func_80005F5C(sizeof(Mtx)); guRotate(mtx, D_800AF778[angle], 1.0f, 0.0f, 0.0f); - { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xDA380001; _gfx->words.w1 = mtx; } + gSPMatrix(gfx++, mtx, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPEndDisplayList(gfx++); } -void func_81002BC0(s32 arg0, GraphicState* state) { +void func_81002BC0(s32 arg0, DisplayListState* state) { Gfx* gfx; if (arg0 == 2) { diff --git a/src/fragments/31/fragment31_257EC0.c b/src/fragments/31/fragment31_257EC0.c index 58077ef..ef798d9 100644 --- a/src/fragments/31/fragment31_257EC0.c +++ b/src/fragments/31/fragment31_257EC0.c @@ -10,11 +10,11 @@ void func_81002C00(Gfx* gfx) { angle = D_8006F09C->unk_0A6 & 3; mtx = func_80005F5C(0x40); guRotate(mtx, D_800AF780[angle], 1.0f, 0.0f, 0.0f); - { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xDA380001; _gfx->words.w1 = mtx; } + gSPMatrix(gfx++, mtx, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPEndDisplayList(gfx++); } -void func_81002CA0(s32 arg0, GraphicState* state) { +void func_81002CA0(s32 arg0, DisplayListState* state) { Gfx* gfx; if (arg0 == 2) { diff --git a/src/fragments/31/fragment31_257FA0.c b/src/fragments/31/fragment31_257FA0.c index cc183d0..a3de669 100644 --- a/src/fragments/31/fragment31_257FA0.c +++ b/src/fragments/31/fragment31_257FA0.c @@ -10,11 +10,11 @@ void func_81002CE0(Gfx* gfx) { angle = D_8006F09C->unk_0A6 & 3; mtx = (Mtx*)func_80005F5C(0x40); guRotate(mtx, D_800AF788[angle], 1.0f, 0.0f, 0.0f); - { Gfx *_gfx = (Gfx *)(gfx++); _gfx->words.w0 = 0xDA380001; _gfx->words.w1 = mtx; } + gSPMatrix(gfx++, mtx, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPEndDisplayList(gfx++); } -void func_81002D80(s32 arg0, GraphicState* state) { +void func_81002D80(s32 arg0, DisplayListState* state) { Gfx* gfx; if (arg0 == 2) { diff --git a/src/fragments/31/fragment31_259030.c b/src/fragments/31/fragment31_259030.c index faef9f9..88ec6e1 100644 --- a/src/fragments/31/fragment31_259030.c +++ b/src/fragments/31/fragment31_259030.c @@ -2,7 +2,7 @@ #include "src/6A40.h" #include "src/fragments/10/fragment10.h" -void func_81003D70(s32 arg0, GraphicState* state) { +void func_81003D70(s32 arg0, DisplayListState* state) { Gfx* gfx; if (arg0 == 2) { diff --git a/src/fragments/31/fragment31_2590C0.c b/src/fragments/31/fragment31_2590C0.c index 1fb87dc..7d33a7a 100644 --- a/src/fragments/31/fragment31_2590C0.c +++ b/src/fragments/31/fragment31_2590C0.c @@ -70,4 +70,16 @@ void func_81003E90(s32 arg0, unk_arg1_func_81003E00* arg1) { } } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/31/fragment31_2590C0/func_81003F20.s") +void func_81003F20(s32 arg0, DisplayListState* state) { + Gfx* gfx; + + if (arg0 == 2) { + gfx = func_80005F5C(0xA0); + state->gfx = gfx; + gDPSetAlphaDither(gfx++, G_AD_NOISE); + gDPSetPrimColor(gfx++, 0, 0, 10, 10, 10, D_8006F09C->unk_0A6 & 0xFF); + gDPSetEnvColor(gfx++, 0x37, 0x14, 0x14, 0xB4); + gDPSetCombineLERP(gfx++, 0, 0, 0, 0, TEXEL0, 1, PRIMITIVE, 1, 0, 0, 0, 0, COMBINED, 0, ENVIRONMENT, 0); + gSPEndDisplayList(gfx++); + } +}