De-duplicate the first of the recursive prim functions (#1323)

Fairly straightforward de-duplication. If anyone has better names for
either the function or the array it uses, feel free to suggest them, but
with this thing being so weird and its purpose being unknown, I had to
keep the names pretty generic.
This commit is contained in:
bismurphy 2024-06-14 22:15:15 -04:00 committed by GitHub
parent 704ca622ba
commit 782fdfd32e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 127 additions and 114 deletions

View File

@ -24,6 +24,7 @@ unk15_yVel = 0x80180FCC;
g_Rooms = 0x80181130;
g_eRedDoorTiles = 0x80180594;
g_olroxDroolCollOffsets = 0x80181008;
g_UnkRecursPrimVecOrder = 0x80181020;
g_pStrObjLayout0 = 0x801811D4;
g_pStrObjLayout1 = 0x801811E8;
g_pStrObjLayout2 = 0x80181206;

View File

@ -24,6 +24,7 @@ unk14_yVel = 0x80181148;
unk14_startFrame = 0x80181160;
unk14_lifetime = 0x80181164;
g_olroxDroolCollOffsets = 0x8018116C;
g_UnkRecursPrimVecOrder = 0x80181184;
g_ESoulStealOrbAngles = 0x801811C8;
g_ESoulStealOrbSprt = 0x801811D8;
g_ESoulStealOrbAnim = 0x80181238;

View File

@ -30,6 +30,7 @@ unk14_yVel = 0x8018130C;
unk14_startFrame = 0x80181324;
unk14_lifetime = 0x80181328;
g_olroxDroolCollOffsets = 0x80181330;
g_UnkRecursPrimVecOrder = 0x80181348;
g_ESoulStealOrbAngles = 0x8018138C;
g_ESoulStealOrbSprt = 0x8018139C;
g_ESoulStealOrbAnim = 0x801813FC;

View File

@ -30,6 +30,7 @@ unk14_yVel = 0x80182650;
unk14_startFrame = 0x80182668;
unk14_lifetime = 0x8018266C;
g_olroxDroolCollOffsets = 0x80182674;
g_UnkRecursPrimVecOrder = 0x8018268C;
g_ESoulStealOrbAngles = 0x801826D0;
g_ESoulStealOrbSprt = 0x801826E0;
g_ESoulStealOrbAnim = 0x80182740;

View File

@ -30,6 +30,7 @@ unk14_yVel = 0x80181FDC;
unk14_startFrame = 0x80181FF4;
unk14_lifetime = 0x80181FF8;
g_olroxDroolCollOffsets = 0x80182000;
g_UnkRecursPrimVecOrder = 0x80182018;
g_ESoulStealOrbAngles = 0x8018205C;
g_ESoulStealOrbSprt = 0x8018206C;
g_ESoulStealOrbAnim = 0x801820CC;

View File

@ -24,6 +24,7 @@ unk14_yVel = 0x80181F04;
unk14_startFrame = 0x80181F1C;
unk14_lifetime = 0x80181F20;
g_olroxDroolCollOffsets = 0x80181F28;
g_UnkRecursPrimVecOrder = 0x80181F40;
g_eBlueDoorUV = 0x801826B8;
g_eBlueDoorTiles = 0x801826D0;
g_Rooms = 0x8018272C;

View File

@ -23,6 +23,7 @@ unk14_yVel = 0x80181020;
unk14_startFrame = 0x80181038;
unk14_lifetime = 0x8018103C;
g_olroxDroolCollOffsets = 0x80181044;
g_UnkRecursPrimVecOrder = 0x8018105C;
g_ESoulStealOrbAngles = 0x801810A0;
g_ESoulStealOrbSprt = 0x801810B0;
g_ESoulStealOrbAnim = 0x80181110;

View File

@ -22,6 +22,7 @@ unk14_yVel = 0x80181ED8;
unk14_startFrame = 0x80181EF0;
unk14_lifetime = 0x80181EF4;
g_olroxDroolCollOffsets = 0x80181EFC;
g_UnkRecursPrimVecOrder = 0x80181F14;
g_ESoulStealOrbAngles = 0x80181F54;
g_ESoulStealOrbSprt = 0x80181F64;
g_ESoulStealOrbAnim = 0x80181FC4;

View File

@ -281,7 +281,7 @@ void func_801991C0(void) {
#include "../entity_big_red_fireball.h"
INCLUDE_ASM("st/cen/nonmatchings/18084", func_80199450);
#include "../unk_recursive_primfunc_1.h"
INCLUDE_ASM("st/cen/nonmatchings/18084", func_80199A30);

View File

@ -282,7 +282,7 @@ void func_8019F304(void) {
#include "../entity_big_red_fireball.h"
INCLUDE_ASM("st/dre/nonmatchings/1E1C8", func_8019F594);
#include "../unk_recursive_primfunc_1.h"
INCLUDE_ASM("st/dre/nonmatchings/1E1C8", func_8019FB74);

View File

@ -354,7 +354,7 @@ void func_80196934(void) {
#include "../entity_big_red_fireball.h"
INCLUDE_ASM("asm/us/st/mad/nonmatchings/15520", func_80196BC4);
#include "../unk_recursive_primfunc_1.h"
INCLUDE_ASM("asm/us/st/mad/nonmatchings/15520", func_801971A4);

View File

@ -275,7 +275,7 @@ void func_801C9BC0(void) {
#include "../entity_big_red_fireball.h"
INCLUDE_ASM("st/no3/nonmatchings/48A84", func_801C9E50);
#include "../unk_recursive_primfunc_1.h"
INCLUDE_ASM("st/no3/nonmatchings/48A84", func_801CA430);

View File

@ -279,7 +279,7 @@ void func_801C1848(void) {
#include "../entity_big_red_fireball.h"
INCLUDE_ASM("st/np3/nonmatchings/402F4", func_801C16C0);
#include "../unk_recursive_primfunc_1.h"
INCLUDE_ASM("st/np3/nonmatchings/402F4", func_801C1CA0);

View File

@ -313,7 +313,7 @@ void func_801C1848(void) {
#include "../entity_big_red_fireball.h"
INCLUDE_ASM("st/nz0/nonmatchings/4070C", func_801C1AD8);
#include "../unk_recursive_primfunc_1.h"
INCLUDE_ASM("st/nz0/nonmatchings/4070C", func_801C20B8);

View File

@ -212,7 +212,7 @@ void func_801924DC(void) {
}
#include "../entity_big_red_fireball.h"
INCLUDE_ASM("st/rwrp/nonmatchings/113A0", func_8019276C);
#include "../unk_recursive_primfunc_1.h"
INCLUDE_ASM("st/rwrp/nonmatchings/113A0", func_80192D4C);

View File

@ -704,7 +704,7 @@ void func_801B8C48(void) {
#include "../entity_big_red_fireball.h"
INCLUDE_ASM("st/st0/nonmatchings/36358", func_801B8ED8);
#include "../unk_recursive_primfunc_1.h"
INCLUDE_ASM("st/st0/nonmatchings/36358", func_801B94B8);

View File

@ -0,0 +1,108 @@
extern u16 g_UnkRecursPrimVecOrder[];
// arg7 holds, in order:
// a Primitive, an array of 9 SVECTORs, an array of 10 uvPairs, and a pointer to
// another of arg7.
// arg7 is not actually u8* but windows doesn't like void* I guess?
Primitive* UnkRecursivePrimFunc1(
SVECTOR* arg0, SVECTOR* arg1, SVECTOR* arg2, SVECTOR* arg3, Primitive* arg4,
s32 arg5, Primitive* arg6, u8* arg7) {
s32 unused1;
s32 unused2;
s32 i;
Primitive* prim1;
Primitive* prim2;
s32 vecIdx1;
s32 vecIdx2;
s32 vecIdx3;
s32 vecIdx4;
s16* vecIndices;
s32 rotTransResult;
SVECTOR* vectors;
uvPair* uv_values;
Primitive* nextArg6;
if (arg6 == NULL) {
return NULL;
}
prim2 = arg7;
arg7 += 0x34;
vectors = arg7;
arg7 += 0x48;
vectors[0] = *arg0;
vectors[2] = *arg1;
vectors[6] = *arg2;
vectors[8] = *arg3;
uv_values = arg7;
arg7 += 0x14; // This is effectively arg7 = arg7->next, since this covers
// the full size of arg7.
prim1 = prim2;
vectors[1].vx = (vectors[0].vx + vectors[2].vx + 1) >> 1;
vectors[1].vy = (vectors[0].vy + vectors[2].vy + 1) >> 1;
vectors[1].vz = (vectors[0].vz + vectors[2].vz + 1) >> 1;
vectors[7].vx = (vectors[6].vx + vectors[8].vx + 1) >> 1;
vectors[7].vy = (vectors[6].vy + vectors[8].vy + 1) >> 1;
vectors[7].vz = (vectors[6].vz + vectors[8].vz + 1) >> 1;
vectors[3].vx = (vectors[0].vx + vectors[6].vx + 1) >> 1;
vectors[3].vy = (vectors[0].vy + vectors[6].vy + 1) >> 1;
vectors[3].vz = (vectors[0].vz + vectors[6].vz + 1) >> 1;
vectors[5].vx = (vectors[2].vx + vectors[8].vx + 1) >> 1;
vectors[5].vy = (vectors[2].vy + vectors[8].vy + 1) >> 1;
vectors[5].vz = (vectors[2].vz + vectors[8].vz + 1) >> 1;
vectors[4].vx = (vectors[3].vx + vectors[5].vx + 1) >> 1;
vectors[4].vy = (vectors[3].vy + vectors[5].vy + 1) >> 1;
vectors[4].vz = (vectors[3].vz + vectors[5].vz + 1) >> 1;
uv_values[0] = *(uvPair*)&arg4->u0;
uv_values[2] = *(uvPair*)&arg4->u1;
uv_values[6] = *(uvPair*)&arg4->u2;
uv_values[8] = *(uvPair*)&arg4->u3;
uv_values[1].u = (uv_values[0].u + uv_values[2].u + 1) >> 1;
uv_values[1].v = (uv_values[0].v + uv_values[2].v + 1) >> 1;
uv_values[7].u = (uv_values[6].u + uv_values[8].u + 1) >> 1;
uv_values[7].v = (uv_values[6].v + uv_values[8].v + 1) >> 1;
uv_values[3].u = (uv_values[0].u + uv_values[6].u + 1) >> 1;
uv_values[3].v = (uv_values[0].v + uv_values[6].v + 1) >> 1;
uv_values[5].u = (uv_values[2].u + uv_values[8].u + 1) >> 1;
uv_values[5].v = (uv_values[2].v + uv_values[8].v + 1) >> 1;
uv_values[4].u = (uv_values[3].u + uv_values[5].u + 1) >> 1;
uv_values[4].v = (uv_values[3].v + uv_values[5].v + 1) >> 1;
*prim1 = *arg4;
vecIndices = &g_UnkRecursPrimVecOrder;
for (i = 0; i < 4; i++) {
vecIdx1 = *vecIndices++;
vecIdx2 = *vecIndices++;
vecIdx3 = *vecIndices++;
vecIdx4 = *vecIndices++;
rotTransResult = RotTransPers4(
&vectors[vecIdx1], &vectors[vecIdx2], &vectors[vecIdx3],
&vectors[vecIdx4], &prim2->x0, &prim2->x1, &prim2->x2, &prim2->x3,
&unused1, &unused2);
*(uvPair*)&prim2->u0 = uv_values[vecIdx1];
*(uvPair*)&prim2->u1 = uv_values[vecIdx2];
*(uvPair*)&prim2->u2 = uv_values[vecIdx3];
*(uvPair*)&prim2->u3 = uv_values[vecIdx4];
if (arg5 == 1) {
prim1 = arg6;
if (rotTransResult > 0) {
nextArg6 = arg6->next;
*prim1 = *prim2;
arg6->next = nextArg6;
arg6 = nextArg6;
if (arg6 == NULL) {
return NULL;
}
}
} else {
arg6 = UnkRecursivePrimFunc1(
&vectors[vecIdx1], &vectors[vecIdx2], &vectors[vecIdx3],
&vectors[vecIdx4], prim2, arg5 - 1, arg6, arg7);
}
}
return arg6;
}

View File

@ -407,114 +407,11 @@ void func_8019055C(void) {
}
extern u8 g_bigRedFireballAnim[];
u16 D_8018105C[] = {0, 1, 3, 4, 1, 2, 4, 5, 3, 4, 6, 7, 4, 5, 7, 8};
u16 g_UnkRecursPrimVecOrder[] = {
0, 1, 3, 4, 1, 2, 4, 5, 3, 4, 6, 7, 4, 5, 7, 8};
#include "../entity_big_red_fireball.h"
// arg7 holds, in order:
// a Primitive, an array of 9 SVECTORs, an array of 10 uvPairs, and a pointer to
// another of arg7.
// arg7 is not actually u8* but windows doesn't like void* I guess?
Primitive* func_801907EC(
SVECTOR* arg0, SVECTOR* arg1, SVECTOR* arg2, SVECTOR* arg3, Primitive* arg4,
s32 arg5, Primitive* arg6, u8* arg7) {
s32 unused1;
s32 unused2;
s32 i;
Primitive* prim1;
Primitive* prim2;
s32 vecIdx1;
s32 vecIdx2;
s32 vecIdx3;
s32 vecIdx4;
s16* vecIndices;
s32 rotTransResult;
SVECTOR* vectors;
uvPair* uv_values;
Primitive* nextArg6;
if (arg6 == NULL) {
return NULL;
}
prim2 = arg7;
arg7 += 0x34;
vectors = arg7;
arg7 += 0x48;
vectors[0] = *arg0;
vectors[2] = *arg1;
vectors[6] = *arg2;
vectors[8] = *arg3;
uv_values = arg7;
arg7 += 0x14; // This is effectively arg7 = arg7->next, since this covers
// the full size of arg7.
prim1 = prim2;
vectors[1].vx = (vectors[0].vx + vectors[2].vx + 1) >> 1;
vectors[1].vy = (vectors[0].vy + vectors[2].vy + 1) >> 1;
vectors[1].vz = (vectors[0].vz + vectors[2].vz + 1) >> 1;
vectors[7].vx = (vectors[6].vx + vectors[8].vx + 1) >> 1;
vectors[7].vy = (vectors[6].vy + vectors[8].vy + 1) >> 1;
vectors[7].vz = (vectors[6].vz + vectors[8].vz + 1) >> 1;
vectors[3].vx = (vectors[0].vx + vectors[6].vx + 1) >> 1;
vectors[3].vy = (vectors[0].vy + vectors[6].vy + 1) >> 1;
vectors[3].vz = (vectors[0].vz + vectors[6].vz + 1) >> 1;
vectors[5].vx = (vectors[2].vx + vectors[8].vx + 1) >> 1;
vectors[5].vy = (vectors[2].vy + vectors[8].vy + 1) >> 1;
vectors[5].vz = (vectors[2].vz + vectors[8].vz + 1) >> 1;
vectors[4].vx = (vectors[3].vx + vectors[5].vx + 1) >> 1;
vectors[4].vy = (vectors[3].vy + vectors[5].vy + 1) >> 1;
vectors[4].vz = (vectors[3].vz + vectors[5].vz + 1) >> 1;
uv_values[0] = *(uvPair*)&arg4->u0;
uv_values[2] = *(uvPair*)&arg4->u1;
uv_values[6] = *(uvPair*)&arg4->u2;
uv_values[8] = *(uvPair*)&arg4->u3;
uv_values[1].u = (uv_values[0].u + uv_values[2].u + 1) >> 1;
uv_values[1].v = (uv_values[0].v + uv_values[2].v + 1) >> 1;
uv_values[7].u = (uv_values[6].u + uv_values[8].u + 1) >> 1;
uv_values[7].v = (uv_values[6].v + uv_values[8].v + 1) >> 1;
uv_values[3].u = (uv_values[0].u + uv_values[6].u + 1) >> 1;
uv_values[3].v = (uv_values[0].v + uv_values[6].v + 1) >> 1;
uv_values[5].u = (uv_values[2].u + uv_values[8].u + 1) >> 1;
uv_values[5].v = (uv_values[2].v + uv_values[8].v + 1) >> 1;
uv_values[4].u = (uv_values[3].u + uv_values[5].u + 1) >> 1;
uv_values[4].v = (uv_values[3].v + uv_values[5].v + 1) >> 1;
*prim1 = *arg4;
vecIndices = &D_8018105C;
for (i = 0; i < 4; i++) {
vecIdx1 = *vecIndices++;
vecIdx2 = *vecIndices++;
vecIdx3 = *vecIndices++;
vecIdx4 = *vecIndices++;
rotTransResult = RotTransPers4(
&vectors[vecIdx1], &vectors[vecIdx2], &vectors[vecIdx3],
&vectors[vecIdx4], &prim2->x0, &prim2->x1, &prim2->x2, &prim2->x3,
&unused1, &unused2);
*(uvPair*)&prim2->u0 = uv_values[vecIdx1];
*(uvPair*)&prim2->u1 = uv_values[vecIdx2];
*(uvPair*)&prim2->u2 = uv_values[vecIdx3];
*(uvPair*)&prim2->u3 = uv_values[vecIdx4];
if (arg5 == 1) {
prim1 = arg6;
if (rotTransResult > 0) {
nextArg6 = arg6->next;
*prim1 = *prim2;
arg6->next = nextArg6;
arg6 = nextArg6;
if (arg6 == NULL) {
return NULL;
}
}
} else {
arg6 = func_801907EC(
&vectors[vecIdx1], &vectors[vecIdx2], &vectors[vecIdx3],
&vectors[vecIdx4], prim2, arg5 - 1, arg6, arg7);
}
}
return arg6;
}
#include "../unk_recursive_primfunc_1.h"
u16 D_8018107C[] = {0, 1, 3, 4, 1, 2, 4, 5, 3, 4, 6, 7, 4, 5, 7, 8, 0, 0};
INCLUDE_ASM("st/wrp/nonmatchings/e_misc", func_80190DCC);