Improve NZ0 func_801C3F9C (#1301)

This is an old function which is decompiled, but is messy. It had an
Unkstruct, which I determined to be a variant of the Primitive.
Therefore, we add a new Primitive version to Primitive.h, and delete the
Unkstruct, rewriting this function.

Hopefully decompiling the caller will help to determine what this
function does, as well as what the unknown primitive members are.
This commit is contained in:
bismurphy 2024-06-11 13:27:17 -04:00 committed by GitHub
parent 6b4fcfff9f
commit 00d07f6a10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 57 additions and 43 deletions

View File

@ -146,4 +146,31 @@ typedef struct {
/* 0x32 */ u16 drawMode;
} draculaPrimitive;
typedef struct AxePrim {
struct AxePrim* next;
/* 0x04 */ u8 r0;
/* 0x05 */ u8 g0;
/* 0x06 */ u8 b0;
/* 0x07 */ u8 type; // PrimitiveType
/* 0x08 */ s16 x0;
/* 0x0A */ s16 y0;
/* 0x0C */ s32 unk0C;
/* 0x10 */ s32 unk10;
/* 0x14 */ s16 x1;
/* 0x16 */ s16 y1;
/* 0x18 */ u8 u1;
/* 0x19 */ u8 v1;
/* 0x1A */ u16 tpage;
/* 0x1C */ s16 unk1C;
/* 0x1E*/ s16 unk1E;
/* 0x20 */ s16 x2;
/* 0x22 */ s16 y2;
/* 0x24 */ u8 step;
/* 0x26 */ u16 priority;
/* 0x2A */ s32 pad;
/* 0x2C */ s16 timer;
/* 0x2E */ s16 unk2E;
/* 0x30 */ s16 unk30;
/* 0x32 */ u16 drawMode;
} AxePrim;
#endif

View File

@ -92,20 +92,6 @@ typedef struct {
s32 unkC;
} Unkstruct_800FDB18;
typedef struct Unkstruct_801C3F9C {
/* 0x00 */ char pad0[0xA];
/* 0x0A */ s16 unk0A;
/* 0x0C */ s32 unk0C;
/* 0x10 */ s32 unk10;
/* 0x14 */ s16 unk14;
/* 0x16 */ char pad16[0x8];
/* 0x1E */ s16 unk1E;
/* 0x20 */ char pad20[0x4];
/* 0x24 */ u8 unk24;
/* 0x25 */ char pad25[0x7];
/* 0x2C */ s16 unk2C;
} Unkstruct_801C3F9C;
typedef struct {
s32 D_8003C908;
s32 D_8003C90C;

View File

@ -6,43 +6,44 @@
#include "nz0.h"
void func_801C3F9C(Unkstruct_801C3F9C** self) {
// Weirdly, this function ONLY acts on prim->next, it does not act on prim.
// However, it does call functions on prim.
void func_801C3F9C(AxePrim* prim) {
Collider collider;
Entity* newEntity;
s16 temp;
Entity* newEnt;
s16 yVar;
UnkPrimHelper();
switch ((*self)->unk24) {
UnkPrimHelper((Primitive*)prim);
switch (prim->next->step) {
case 0:
(*self)->unk0C = 0;
(*self)->unk10 = -0x10000;
(*self)->unk24 = 1;
(*self)->unk2C = 0x100;
break;
prim->next->unk0C = 0;
prim->next->unk10 = -0x10000;
prim->next->step = 1;
prim->next->timer = 0x100;
return;
case 1:
temp = (*self)->unk0A + ((*self)->unk1E / 3);
g_api.CheckCollision((*self)->unk14, temp, &collider, 0);
if (collider.effects % 2) {
(*self)->unk0A = (*self)->unk0A + collider.unk18;
if ((*self)->unk10 < 0x4000) {
(*self)->unk2C = 1;
yVar = prim->next->y0 + (prim->next->unk1E / 3);
g_api.CheckCollision(prim->next->x1, yVar, &collider, 0);
if (collider.effects & EFFECT_SOLID) {
prim->next->y0 += collider.unk18;
if (prim->next->unk10 < 0x4000) {
prim->next->timer = 1;
}
(*self)->unk10 = -(*self)->unk10;
(*self)->unk10 -= (*self)->unk10 / 2;
prim->next->unk10 = -prim->next->unk10;
prim->next->unk10 -= prim->next->unk10 / 2;
}
(*self)->unk10 += 0x1800;
(*self)->unk2C--;
if ((*self)->unk2C == 0) {
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (newEntity != NULL) {
CreateEntityFromCurrentEntity(E_EXPLOSION, newEntity);
newEntity->posX.i.hi = (*self)->unk14;
newEntity->posY.i.hi = (*self)->unk0A;
newEntity->params = 0;
prim->next->unk10 += 0x1800;
prim->next->timer--;
if (prim->next->timer == 0) {
newEnt = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (newEnt != NULL) {
CreateEntityFromCurrentEntity(E_EXPLOSION, newEnt);
newEnt->posX.i.hi = prim->next->x1;
newEnt->posY.i.hi = prim->next->y0;
newEnt->params = 0;
}
func_801C29B0(0x655);
UnkPolyFunc0(self);
UnkPolyFunc0((Primitive*)prim);
}
return;
}