De-duplicate UnkLoopFunc (#479)

I'm open to ideas on the name.
This commit is contained in:
sozud 2023-08-18 16:57:00 -07:00 committed by GitHub
parent 10b0cb99ba
commit 3c3ff441e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 56 additions and 199 deletions

View File

@ -51,4 +51,5 @@ EntityStageNamePopup = 0x8019A5F0;
EntitySoulStealOrb = 0x8019B274;
EntityEnemyBlood = 0x8019B608;
EntityUnkId08 = 0x8019BAB8;
UnkLoopFunc = 0x8019C6A0;
UNK_Update0 = 0x8019D42C;

View File

@ -71,6 +71,7 @@ EntitySoulStealOrb = 0x801A13B8;
EntityEnemyBlood = 0x801A174C;
EntityRoomForeground = 0x801A1BFC;
func_801A2018 = 0x801A2018;
UnkLoopFunc = 0x801A27E4;
EntityUnkId17 = 0x801A2E20;
Entity3DBackgroundHouse = 0x801A2F10;
UNK_Update0 = 0x801A3F8C;

View File

@ -139,4 +139,5 @@ EntityBoneScimitarParts = 0x801D615C;
EntityBat = 0x801D6264;
EntityZombie = 0x801D64B0;
EntityZombieSpawner = 0x801D6710;
UnkLoopFunc = 0x801D704C;
UNK_Update0 = 0x801D7DD8;

View File

@ -98,4 +98,5 @@ EntityGurkhaBodyParts = 0x801CF254;
EntityHammerWeapon = 0x801CF5B8;
EntityGurkha = 0x801CF94C;
EntityGurkhaSword = 0x801D0730;
UnkLoopFunc = 0x801D2704;
UNK_Update0 = 0x801D33F4;

View File

@ -129,5 +129,6 @@ EntitySubWeaponContainer = 0x801C7048;
EntityBloodSkeleton = 0x801C7958;
EntityMagicallySealedDoor = 0x801C7D68;
EntityStageNamePopup = 0x801C8CAC;
UnkLoopFunc = 0x801CA0FC;
EntityLifeUpSpawn = 0x801CA160;
UNK_Update0 = 0x801CB740;

View File

@ -20,4 +20,5 @@ EntityIntenseExplosion = 0x80192248;
ClutLerp = 0x8019344C;
EntitySoulStealOrb = 0x80194590;
func_801951F0 = 0x801951F0;
UnkLoopFunc = 0x801959BC;
UNK_Update0 = 0x801966A8;

View File

@ -70,6 +70,7 @@ EntityClockTower3D = 0x801BB2AC;
EntityCutscenePhotograph = 0x801BB764;
EntityCutscenePhotographFire = 0x801BC4D0;
func_801BC5C0 = 0x801BC5C0;
UnkLoopFunc = 0x801BD88C;
func_801BD8F0 = 0x801BD8F0;
EntityBackgroundVortex = 0x801BE1B4;
g_Dialogue = 0x801C24CC;

View File

@ -111,4 +111,5 @@ EntitySoulStealOrb = 0x80192610;
EntityEnemyBlood = 0x801929A4;
EntityRoomForeground = 0x80192E54;
func_80193270 = 0x80193270;
UnkLoopFunc = 0x80193A3C;
UNK_Update0 = 0x80194728;

View File

@ -1199,7 +1199,7 @@ void func_8019A420(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 + xPos;
prim->x1 = prim->x1 + xPos;
prim->x3 = prim->x0;
func_8019C6A0(prim, 4);
UnkLoopFunc(prim, 4);
break;
case 2:
if (prim->p2 < 0x14) {
@ -1209,7 +1209,7 @@ void func_8019A420(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 - xPos;
prim->x1 = prim->x1 - xPos;
prim->x3 = prim->x0;
func_8019C6A0(prim, 4);
UnkLoopFunc(prim, 4);
break;
}
}

View File

@ -368,30 +368,4 @@ void func_8019C674(POLY_GT4* poly) {
((POLY_GT4*)poly->tag)->pad3 = 8;
}
s32 func_8019C6A0(s32 arg0, u8 arg1) {
s32 var_v0;
s32 ret = 0;
u8* var_a0 = arg0 + 4;
u8* var_v1;
s32 i;
for (i = 0; i < 4; i++) {
var_v1 = var_a0;
do {
var_v0 = *var_v1 - arg1;
if (var_v0 < 0) {
var_v0 = 0;
} else {
ret |= 1;
}
*var_v1 = var_v0;
var_v1++;
} while (((s32)var_v1 < ((s32)var_a0 + 3)));
var_a0 += 0xC;
}
return ret;
}
#include "../unk_loop_func.h"

View File

@ -711,7 +711,7 @@ void func_801A0564(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 + xPos;
prim->x1 = prim->x1 + xPos;
prim->x3 = prim->x0;
func_801A27E4(prim, 4);
UnkLoopFunc(prim, 4);
break;
case 2:
if (prim->p2 < 0x14) {
@ -721,7 +721,7 @@ void func_801A0564(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 - xPos;
prim->x1 = prim->x1 - xPos;
prim->x3 = prim->x0;
func_801A27E4(prim, 4);
UnkLoopFunc(prim, 4);
break;
}
}
@ -1078,33 +1078,7 @@ void func_801A27B8(POLY_GT4* poly) {
((POLY_GT4*)poly->tag)->pad3 = 8;
}
s32 func_801A27E4(s32 arg0, u8 arg1) {
s32 var_v0;
s32 ret = 0;
u8* var_a0 = arg0 + 4;
u8* var_v1;
s32 i;
for (i = 0; i < 4; i++) {
var_v1 = var_a0;
do {
var_v0 = *var_v1 - arg1;
if (var_v0 < 0) {
var_v0 = 0;
} else {
ret |= 1;
}
*var_v1 = var_v0;
var_v1++;
} while (((s32)var_v1 < ((s32)var_a0 + 3)));
var_a0 += 0xC;
}
return ret;
}
#include "../unk_loop_func.h"
INCLUDE_ASM("asm/us/st/dre/nonmatchings/1C7DC", func_801A2848);

View File

@ -980,7 +980,7 @@ void func_801CAE20(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 + xPos;
prim->x1 = prim->x1 + xPos;
prim->x3 = prim->x0;
func_801D704C(prim, 4);
UnkLoopFunc(prim, 4);
break;
case 2:
if (prim->p2 < 0x14) {
@ -990,7 +990,7 @@ void func_801CAE20(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 - xPos;
prim->x1 = prim->x1 - xPos;
prim->x3 = prim->x0;
func_801D704C(prim, 4);
UnkLoopFunc(prim, 4);
break;
}
}

View File

@ -236,30 +236,4 @@ void func_801D7020(POLY_GT4* arg0) {
((POLY_GT4*)arg0->tag)->pad3 = 8;
}
s32 func_801D704C(s32 arg0, u8 arg1) {
s32 var_v0;
s32 ret = 0;
u8* var_a0 = arg0 + 4;
u8* var_v1;
s32 i;
for (i = 0; i < 4; i++) {
var_v1 = var_a0;
do {
var_v0 = *var_v1 - arg1;
if (var_v0 < 0) {
var_v0 = 0;
} else {
ret |= 1;
}
*var_v1 = var_v0;
var_v1++;
} while ((s32)var_v1 < ((s32)var_a0 + 3));
var_a0 += 0xC;
}
return ret;
}
#include "../unk_loop_func.h"

View File

@ -1101,7 +1101,7 @@ void func_801C2690(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 + xPos;
prim->x1 = prim->x1 + xPos;
prim->x3 = prim->x0;
func_801D2704(prim, 4);
UnkLoopFunc(prim, 4);
break;
case 2:
if (prim->p2 < 0x14) {
@ -1111,7 +1111,7 @@ void func_801C2690(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 - xPos;
prim->x1 = prim->x1 - xPos;
prim->x3 = prim->x0;
func_801D2704(prim, 4);
UnkLoopFunc(prim, 4);
break;
}
}

View File

@ -555,30 +555,4 @@ void func_801D26D8(POLY_GT4* arg0) {
((POLY_GT4*)arg0->tag)->pad3 = 8;
}
s32 func_801D2704(s32 arg0, u8 arg1) {
s32 var_v0;
s32 ret = 0;
u8* var_a0 = arg0 + 4;
u8* var_v1;
s32 i;
for (i = 0; i < 4; i++) {
var_v1 = var_a0;
do {
var_v0 = *var_v1 - arg1;
if (var_v0 < 0) {
var_v0 = 0;
} else {
ret |= 1;
}
*var_v1 = var_v0;
var_v1++;
} while (((s32)var_v1 < ((s32)var_a0 + 3)));
var_a0 += 0xC;
}
return ret;
}
#include "../unk_loop_func.h"

View File

@ -41,7 +41,7 @@ void func_801C8ADC(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 + xPos;
prim->x1 = prim->x1 + xPos;
prim->x3 = prim->x0;
func_801CA0FC(prim, 4);
UnkLoopFunc(prim, 4);
break;
case 2:
if (prim->p2 < 0x14) {
@ -51,7 +51,7 @@ void func_801C8ADC(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 - xPos;
prim->x1 = prim->x1 - xPos;
prim->x3 = prim->x0;
func_801CA0FC(prim, 4);
UnkLoopFunc(prim, 4);
break;
}
}

View File

@ -113,32 +113,7 @@ void func_801CA0D0(Primitive* poly) {
poly->next->blendMode = BLEND_VISIBLE;
}
//! FAKE
s32 func_801CA0FC(s32 arg0, u8 arg1) {
s32 var_v0;
s32 ret = 0;
s32 j = arg0 + 4;
u8* var_v1;
s32 i;
for (i = 0; i < 4; i++, j += 12) {
var_v1 = (u8*)j;
do {
var_v0 = *var_v1 - arg1;
if (var_v0 < 0) {
var_v0 = 0;
} else {
ret |= 1;
}
*var_v1 = var_v0;
var_v1++;
} while ((s32)var_v1 < (s32)j + 3);
}
return ret;
}
#include "../unk_loop_func.h"
// particle effect that spawns life up item
// Probably it's own file

View File

@ -777,4 +777,4 @@ INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/A59C", func_8019593C);
INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/A59C", func_80195990);
INCLUDE_ASM("asm/us/st/rwrp/nonmatchings/A59C", func_801959BC);
#include "../unk_loop_func.h"

View File

@ -370,8 +370,8 @@ void EntityStageTitleCard(Entity* self) {
v++;
}
func_801BD88C(prim, 4);
if (func_801BD88C(prim->next, 3) == 0) {
UnkLoopFunc(prim, 4);
if (UnkLoopFunc(prim->next, 3) == 0) {
PreventEntityFromRespawning(fakeEntity);
D_8003C8B8 = 1;
DestroyEntity(fakeEntity);

View File

@ -438,7 +438,7 @@ void EntityDracula(Entity* self) {
break;
case 7:
if (func_801BD88C(self->ext.dracula.prim, 7) == 0) {
if (UnkLoopFunc(self->ext.dracula.prim, 7) == 0) {
self->step_s++;
}
break;

View File

@ -1174,31 +1174,7 @@ void func_801BD860(POLY_GT4* arg0) {
((POLY_GT4*)arg0->tag)->pad3 = 8;
}
s32 func_801BD88C(s32 arg0, u8 arg1) {
s32 var_v0;
s32 ret = 0;
s32 j = arg0 + 4;
u8* var_v1;
s32 i;
for (i = 0; i < 4; i++, j += 12) {
var_v1 = (u8*)j;
do {
var_v0 = *var_v1 - arg1;
if (var_v0 < 0) {
var_v0 = 0;
} else {
ret |= 1;
}
*var_v1 = var_v0;
var_v1++;
} while ((s32)var_v1 < (s32)j + 3);
}
return ret;
}
#include "../unk_loop_func.h"
INCLUDE_ASM("asm/us/st/st0/nonmatchings/36358", func_801BD8F0);

25
src/st/unk_loop_func.h Normal file
View File

@ -0,0 +1,25 @@
s32 UnkLoopFunc(s32 arg0, u8 arg1) {
s32 var_v0;
s32 ret = 0;
s32 j = arg0 + 4;
u8* var_v1;
s32 i;
for (i = 0; i < 4; i++, j += 12) {
var_v1 = (u8*)j;
do {
var_v0 = *var_v1 - arg1;
if (var_v0 < 0) {
var_v0 = 0;
} else {
ret |= 1;
}
*var_v1 = var_v0;
var_v1++;
} while ((s32)var_v1 < (s32)j + 3);
}
return ret;
}

View File

@ -1196,7 +1196,7 @@ void func_801917BC(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 + xPos;
prim->x1 = prim->x1 + xPos;
prim->x3 = prim->x0;
func_80193A3C(prim, 4);
UnkLoopFunc(prim, 4);
break;
case 2:
if (prim->p2 < 0x14) {
@ -1206,7 +1206,7 @@ void func_801917BC(Primitive* prim) {
prim->x2 = prim->x0 = prim->x0 - xPos;
prim->x1 = prim->x1 - xPos;
prim->x3 = prim->x0;
func_80193A3C(prim, 4);
UnkLoopFunc(prim, 4);
break;
}
}
@ -1747,27 +1747,4 @@ void func_80193A10(POLY_GT4* poly) {
((POLY_GT4*)poly->tag)->pad3 = 8;
}
s32 func_80193A3C(u8* arg0, u8 value) {
s32 ret = 0;
u8* phi_a0 = arg0 + 4;
s32 i;
for (i = 0; i < 4; i++) {
u8* ptrCur = phi_a0;
s32 ptrEnd = (s32)phi_a0 + 3;
do {
s32 phi_v0 = *ptrCur - value;
if (phi_v0 < 0) {
phi_v0 = 0;
} else {
ret |= 1;
}
*ptrCur++ = phi_v0;
} while ((s32)ptrCur < ptrEnd);
phi_a0 += 0xC;
}
return ret;
}
#include "../unk_loop_func.h"