Dedupe FindFirstUnkPrim (#852)

Follows discussion on https://github.com/Xeeynamo/sotn-decomp/pull/848,
not too sure about interim function name.
This commit is contained in:
ser-pounce 2023-12-16 17:53:28 +01:00 committed by GitHub
parent f640b1a936
commit 126a3dcaff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 27 additions and 91 deletions

View File

@ -252,16 +252,7 @@ void BottomCornerText(u8* str, u8 lower_left) {
INCLUDE_ASM("asm/us/st/cen/nonmatchings/1B274", func_8019C2BC);
POLY_GT4* func_8019C40C(POLY_GT4* poly) {
while (poly != NULL) {
if (poly->p3 != 0) {
poly = (POLY_GT4*)poly->tag;
} else {
return poly;
}
}
return NULL;
}
#include "../find_first_unk_prim.h"
POLY_GT4* func_8019C43C(POLY_GT4* poly, u8 index) {
if (poly) {

View File

@ -752,16 +752,7 @@ void BottomCornerText(u8* str, u8 lower_left) {
INCLUDE_ASM("asm/us/st/dre/nonmatchings/1E1C8", func_801A2400);
POLY_GT4* func_801A2550(POLY_GT4* poly) {
while (poly != NULL) {
if (poly->p3 != 0) {
poly = (POLY_GT4*)poly->tag;
} else {
return poly;
}
}
return NULL;
}
#include "../find_first_unk_prim.h"
INCLUDE_ASM("asm/us/st/dre/nonmatchings/1E1C8", func_801A2580);

View File

@ -0,0 +1,10 @@
Primitive* FindFirstUnkPrim(Primitive* poly) {
while (poly != NULL) {
if (poly->p3 != 0) {
poly = poly->next;
} else {
return poly;
}
}
return NULL;
}

View File

@ -567,16 +567,7 @@ INCLUDE_ASM("asm/us/st/mad/nonmatchings/15520", func_80198BC8);
INCLUDE_ASM("asm/us/st/mad/nonmatchings/15520", func_80199388);
POLY_GT4* func_801994D8(POLY_GT4* poly) {
while (poly != NULL) {
if (poly->p3 != 0) {
poly = (POLY_GT4*)poly->tag;
} else {
return poly;
}
}
return NULL;
}
#include "../find_first_unk_prim.h"
INCLUDE_ASM("asm/us/st/mad/nonmatchings/15520", func_80199508);

View File

@ -726,7 +726,8 @@ void EntityCavernDoor(Entity* self) {
}
if (!(g_Timer & 1)) {
poly = func_801D6DB8((POLY_GT4*)(*(s32*)&self->ext.generic.unk7C));
poly =
FindFirstUnkPrim((Primitive*)(*(s32*)&self->ext.generic.unk7C));
if (poly != NULL) {
poly->p3 = 1;
}
@ -1699,7 +1700,8 @@ void EntityHeartRoomGoldDoor(Entity* self) {
}
if (!(g_Timer & 1)) {
poly = func_801D6DB8((POLY_GT4*)(*(s32*)&self->ext.generic.unk7C));
poly =
FindFirstUnkPrim((POLY_GT4*)(*(s32*)&self->ext.generic.unk7C));
if (poly != NULL) {
poly->p3 = 1;
}

View File

@ -127,16 +127,7 @@ void EntityZombieSpawner(Entity* self) {
INCLUDE_ASM("asm/us/st/no3/nonmatchings/564B0", func_801D6C68);
POLY_GT4* func_801D6DB8(POLY_GT4* poly) {
while (poly != NULL) {
if (poly->p3 != 0) {
poly = (POLY_GT4*)poly->tag;
} else {
return poly;
}
}
return NULL;
}
#include "../find_first_unk_prim.h"
POLY_GT4* func_8019C43C(POLY_GT4* poly, u8 index) {
if (poly) {

View File

@ -81,7 +81,7 @@ typedef enum EntityIDs {
extern void CreateEntityFromCurrentEntity(u16, Entity*);
extern void ReplaceBreakableWithItemDrop(Entity*);
extern s32 func_801C5D18(Entity* entity, s32 arg1, s32 arg2, s32 arg3);
extern POLY_GT4* func_801D6DB8(POLY_GT4* poly);
extern Primitive* FindFirstUnkPrim(Primitive* poly);
extern LayoutEntity* D_80180850[];
extern u16 g_InitializeData0[];

View File

@ -667,7 +667,8 @@ void func_801B40F8(Entity* self) {
}
if (!(g_Timer & 1)) {
poly = func_801D2470((POLY_GT4*)(*(s32*)&self->ext.generic.unk7C));
poly =
FindFirstUnkPrim((Primitive*)(*(s32*)&self->ext.generic.unk7C));
if (poly != NULL) {
poly->p3 = 1;
}
@ -1577,7 +1578,7 @@ void EntityHeartRoomGoldDoor(Entity* self) {
}
if (!(g_Timer & 1)) {
prim = func_801D2470(self->ext.heartRoomGoldDoor.prim);
prim = FindFirstUnkPrim(self->ext.heartRoomGoldDoor.prim);
if (prim != NULL) {
prim->p3 = 1;
}

View File

@ -465,16 +465,7 @@ void EntityBladeSword(Entity* self) {
INCLUDE_ASM("asm/us/st/np3/nonmatchings/4E69C", func_801D2320);
Primitive* func_801D2470(Primitive* prim) {
while (prim != NULL) {
if (prim->p3 != 0) {
prim = prim->next;
} else {
return prim;
}
}
return NULL;
}
#include "../find_first_unk_prim.h"
Primitive* func_801D24A0(Primitive* prim, u8 index) {
if (prim) {

View File

@ -4,16 +4,7 @@
INCLUDE_ASM("asm/us/st/nz0/nonmatchings/49930", func_801C9D18);
Primitive* func_801C9E68(Primitive* poly) {
while (poly != NULL) {
if (poly->p3 != 0) {
poly = poly->next;
} else {
return poly;
}
}
return NULL;
}
#include "../find_first_unk_prim.h"
Primitive* func_801C9E98(Primitive* prim, u8 index) {
if (prim) {

View File

@ -116,16 +116,7 @@ INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/14590", BottomCornerText);
INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/14590", func_801955D8);
POLY_GT4* func_80195728(POLY_GT4* poly) {
while (poly != NULL) {
if (poly->p3 != 0) {
poly = (POLY_GT4*)poly->tag;
} else {
return poly;
}
}
return NULL;
}
#include "../find_first_unk_prim.h"
INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/14590", func_80195758);

View File

@ -1058,14 +1058,7 @@ INCLUDE_ASM("asm/us/st/st0/nonmatchings/36358", func_801BC5C0);
INCLUDE_ASM("asm/us/st/st0/nonmatchings/36358", func_801BD4A8);
POLY_GT4* func_801BD5F8(POLY_GT4* poly) {
while (poly) {
if (poly->p3 == 0)
return poly;
poly = (POLY_GT4*)poly->tag;
}
return NULL;
}
#include "../find_first_unk_prim.h"
POLY_GT4* func_801BD628(POLY_GT4* poly, u8 index) {
if (poly) {

View File

@ -1039,14 +1039,7 @@ void BottomCornerText(u8* str, u8 lower_left) {
INCLUDE_ASM("asm/us/st/wrp/nonmatchings/F420", func_80193658);
POLY_GT4* func_801937A8(POLY_GT4* poly) {
while (poly) {
if (poly->p3 == 0)
return poly;
poly = (POLY_GT4*)poly->tag;
}
return NULL;
}
#include "../find_first_unk_prim.h"
POLY_GT4* func_801937D8(POLY_GT4* poly, u8 index) {
if (poly) {