Decompile code_0x800AF710.c

This commit is contained in:
rozlette
2020-03-19 22:59:03 -05:00
parent adc18f10e2
commit b1dda27053
5 changed files with 328 additions and 9 deletions
+3 -3
View File
@@ -566,13 +566,13 @@ void EffectTireMark_InitVertices(F3DVertexColor* vertices, EffTireMarkParticle*
void EffectTireMark_Draw(EffTireMarkParams* params, GraphicsContext* gCtxt); // func_800AF310
GlobalContext* Effect_GetContext(void); // func_800AF710
void* Effect_GetParams(s32 index); // func_800AF720
void Effect_InitCommon(UNK_PTR param_1); // func_800AF87C
void Effect_InitCommon(EffCommon* common); // func_800AF87C
void Effect_Init(GlobalContext* ctxt); // func_800AF890
void Effect_Create(GlobalContext* ctxt, s32* index, s32 type, UNK_TYPE1 param_4, UNK_TYPE1 param_5, void* initParams); // func_800AF960
void Effect_Add(GlobalContext* ctxt, s32* index, s32 type, u8 param_4, u8 param_5, void* initParams); // func_800AF960
void Effect_DrawAll(GraphicsContext* gCtxt); // func_800AFB24
void Effect_UpdateAll(GlobalContext* ctxt); // func_800AFC60
void Effect_Destroy(GlobalContext* ctxt, s32 index); // func_800AFDCC
void Effect_DestroyAll(void); // func_800AFF24
void Effect_DestroyAll(GlobalContext* ctxt); // func_800AFF24
void EffectSS_Init(GlobalContext* ctxt, s32 numEntries); // func_800B0050
void EffectSS_Clear(GlobalContext* ctxt); // func_800B0140
LoadedParticleEntry* EffectSS_GetTable(void); // func_800B0200
+3 -1
View File
@@ -304,7 +304,9 @@ typedef struct {
typedef struct {
/* 0x0 */ u8 active;
/* 0x1 */ UNK_TYPE1 pad1[0x3];
/* 0x1 */ u8 unk1;
/* 0x2 */ u8 unk2;
/* 0x3 */ UNK_TYPE1 pad3[0x1];
} EffCommon; // size = 0x4
typedef struct {
+3 -3
View File
@@ -322,7 +322,7 @@ SECTIONS
build/asm/z_eff_spark.o(.text)
build/asm/z_eff_ss_dead.o(.text)
build/asm/z_eff_tire_mark.o(.text)
build/asm/code_0x800AF710.o(.text)
build/src/code/code_0x800AF710.o(.text)
build/src/code/z_effect_soft_sprite.o(.text)
build/asm/z_effect_soft_sprite_old_init.o(.text)
build/asm/flg_set.o(.text)
@@ -459,7 +459,7 @@ SECTIONS
build/asm/code_data_z_en_item00.o(.text)
build/asm/code_data_z_eff_blure.o(.text)
build/asm/code_data_z_eff_shield_particle.o(.text)
build/asm/code_data_0x800AF710.o(.text)
build/src/code/code_0x800AF710.o(.data)
build/asm/code_data_z_effect_soft_sprite.o(.text)
build/asm/code_data_z_effect_soft_sprite_old_init.o(.text)
build/asm/code_data_flg_set_table.o(.text)
@@ -536,7 +536,7 @@ SECTIONS
build/asm/code_rodata_z_eff_shield_particle.o(.text)
build/asm/code_rodata_z_eff_spark.o(.text)
build/asm/code_rodata_z_eff_ss_dead.o(.text)
build/asm/code_rodata_0x800AF710.o(.text)
build/src/code/code_0x800AF710.o(.rodata)
build/asm/code_rodata_z_effect_soft_sprite_old_init.o(.text)
build/asm/code_rodata_flg_set.o(.text)
build/asm/code_rodata_z_actor.o(.text)
+317
View File
@@ -0,0 +1,317 @@
#include <ultra64.h>
#include <global.h>
EffInfo sEffInfoTable[] = {
{
sizeof(EffSparkParams),
(eff_init_func)EffectSpark_Init,
(eff_destroy_func)EffectSpark_Destroy,
(eff_update_func)EffectSpark_Update,
(eff_draw_func)EffectSpark_Draw,
},
{
sizeof(EffBlureParams),
(eff_init_func)EffectBlure_Init1,
(eff_destroy_func)EffectBlure_Destroy,
(eff_update_func)EffectBlure_Update,
(eff_draw_func)EffectBlure_Draw,
},
{
sizeof(EffBlureParams),
(eff_init_func)EffectBlure_Init2,
(eff_destroy_func)EffectBlure_Destroy,
(eff_update_func)EffectBlure_Update,
(eff_draw_func)EffectBlure_Draw,
},
{
sizeof(EffShieldParticleParams),
(eff_init_func)EffectShieldParticle_Init,
(eff_destroy_func)EffectShieldParticle_Destroy,
(eff_update_func)EffectShieldParticle_Update,
(eff_draw_func)EffectShieldParticle_Draw,
},
{
sizeof(EffTireMarkParams),
(eff_init_func)EffectTireMark_Init,
(eff_destroy_func)EffectTireMark_Destroy,
(eff_update_func)EffectTireMark_Update,
(eff_draw_func)EffectTireMark_Draw,
},
};
GlobalContext* Effect_GetContext(void) {
return sEffTable.ctxt;
}
void* Effect_GetParams(s32 index) {
if (index == 46) {
return NULL;
}
if (index < 3) {
if (sEffTable.sparks[index].base.active == 1) {
return &sEffTable.sparks[index].params;
} else {
return NULL;
}
}
index -= 3;
if (index < 25) {
if (sEffTable.blures[index].base.active == 1) {
return &sEffTable.blures[index].params;
} else {
return NULL;
}
}
index -= 25;
if (index < 3) {
if (sEffTable.shieldParticles[index].base.active == 1) {
return &sEffTable.shieldParticles[index].params;
} else {
return NULL;
}
}
index -= 3;
if (index < 15) {
if (sEffTable.tireMarks[index].base.active == 1) {
return &sEffTable.tireMarks[index].params;
} else {
return NULL;
}
}
return NULL;
}
void Effect_InitCommon(EffCommon* common) {
common->active = 0;
common->unk1 = 0;
common->unk2 = 0;
}
void Effect_Init(GlobalContext* ctxt) {
s32 i;
for (i = 0; i < 3; i++) {
Effect_InitCommon(&sEffTable.sparks[i].base);
}
for (i = 0; i < 25; i++) {
Effect_InitCommon(&sEffTable.blures[i].base);
}
//! @bug This is probably supposed to loop over shieldParticles, not blures again
for (i = 0; i < 3; i++) {
Effect_InitCommon(&sEffTable.blures[i].base);
}
for (i = 0; i < 15; i++) {
Effect_InitCommon(&sEffTable.tireMarks[i].base);
}
sEffTable.ctxt = ctxt;
}
void Effect_Add(GlobalContext* ctxt, s32* index, s32 type, u8 param_4, u8 param_5, void* initParams) {
u32 slotFound;
s32 i;
void* params;
EffCommon* common;
params = NULL;
*index = 46;
common = NULL;
if (func_8016A01C(ctxt) != 1) {
slotFound = 0;
switch (type) {
case 0:
for (i = 0; i < 3; i++) {
if (sEffTable.sparks[i].base.active == 0) {
slotFound = 1;
*index = i;
params = &sEffTable.sparks[i].params;
common = &sEffTable.sparks[i].base;
break;
}
}
break;
case 1:
case 2:
for (i = 0; i < 25; i++) {
if (sEffTable.blures[i].base.active == 0) {
slotFound = 1;
*index = i + 3;
params = &sEffTable.blures[i].params;
common = &sEffTable.blures[i].base;
break;
}
}
break;
case 3:
for (i = 0; i < 3; i++) {
if (sEffTable.shieldParticles[i].base.active == 0) {
slotFound = 1;
*index = i + 28;
params = &sEffTable.shieldParticles[i].params;
common = &sEffTable.shieldParticles[i].base;
break;
}
}
break;
case 4:
for (i = 0; i < 15; i++) {
if (sEffTable.tireMarks[i].base.active == 0) {
slotFound = 1;
*index = i + 31;
params = &sEffTable.tireMarks[i].params;
common = &sEffTable.tireMarks[i].base;
break;
}
}
break;
}
if (slotFound) {
sEffInfoTable[type].init(params, initParams);
common->unk2 = param_4;
common->unk1 = param_5;
common->active = 1;
}
}
}
#ifdef NON_MATCHING
// Contents of s2 and s3 swapped
void Effect_DrawAll(GraphicsContext* gCtxt) {
s32 i;
for (i = 0; i < 3; i++) {
if (sEffTable.sparks[i].base.active) {
sEffInfoTable[0].draw(&sEffTable.sparks[i].params, gCtxt);
}
}
for (i = 0; i < 25; i++) {
if (sEffTable.blures[i].base.active) {
sEffInfoTable[1].draw(&sEffTable.blures[i].params, gCtxt);
}
}
for (i = 0; i < 3; i++) {
if (sEffTable.shieldParticles[i].base.active) {
sEffInfoTable[3].draw(&sEffTable.shieldParticles[i].params, gCtxt);
}
}
for (i = 0; i < 15; i++) {
if (sEffTable.tireMarks[i].base.active) {
sEffInfoTable[4].draw(&sEffTable.tireMarks[i].params, gCtxt);
}
}
}
#else
GLOBAL_ASM("./asm/non_matchings/code_0x800AF710/Effect_DrawAll.asm")
#endif
#ifdef NON_MATCHING
// 15 is being placed in s5 instead of at
void Effect_UpdateAll(GlobalContext* ctxt) {
s32 i;
for (i = 0; i < 3; i++) {
if (sEffTable.sparks[i].base.active) {
if (sEffInfoTable[0].update(&sEffTable.sparks[i].params) == 1) {
Effect_Destroy(ctxt, i);
}
}
}
for (i = 0; i < 25; i++) {
if (sEffTable.blures[i].base.active) {
if (sEffInfoTable[1].update(&sEffTable.blures[i].params) == 1) {
Effect_Destroy(ctxt, i + 3);
}
}
}
for (i = 0; i < 3; i++) {
if (sEffTable.shieldParticles[i].base.active) {
if (sEffInfoTable[3].update(&sEffTable.shieldParticles[i].params) == 1) {
Effect_Destroy(ctxt, i + 28);
}
}
}
for (i = 0; i < 15; i++) {
if (sEffTable.tireMarks[i].base.active) {
if (sEffInfoTable[4].update(&sEffTable.tireMarks[i].params) == 1) {
Effect_Destroy(ctxt, i + 31);
}
}
}
}
#else
GLOBAL_ASM("./asm/non_matchings/code_0x800AF710/Effect_UpdateAll.asm")
#endif
void Effect_Destroy(GlobalContext* ctxt, s32 index) {
if (index == 46) {
return;
}
if (index < 3) {
sEffTable.sparks[index].base.active = 0 ;
sEffInfoTable[0].destroy(&sEffTable.sparks[index].params);
return;
}
index -= 3;
if (index < 25) {
sEffTable.blures[index].base.active = 0 ;
sEffInfoTable[1].destroy(&sEffTable.blures[index].params);
return;
}
index -= 25;
if (index < 3) {
sEffTable.shieldParticles[index].base.active = 0 ;
sEffInfoTable[3].destroy(&sEffTable.shieldParticles[index].params);
return;
}
index -= 3;
if (index < 15) {
sEffTable.tireMarks[index].base.active = 0 ;
sEffInfoTable[4].destroy(&sEffTable.tireMarks[index].params);
return;
}
}
void Effect_DestroyAll(GlobalContext* ctxt) {
s32 i;
for (i = 0; i < 3; i++) {
sEffTable.sparks[i].base.active = 0;
sEffInfoTable[0].destroy(&sEffTable.sparks[i].params);
}
for (i = 0; i < 25; i++) {
sEffTable.blures[i].base.active = 0;
sEffInfoTable[1].destroy(&sEffTable.blures[i].params);
}
for (i = 0; i < 3; i++) {
sEffTable.shieldParticles[i].base.active = 0;
sEffInfoTable[3].destroy(&sEffTable.shieldParticles[i].params);
}
for (i = 0; i < 15; i++) {
sEffTable.tireMarks[i].base.active = 0;
sEffInfoTable[4].destroy(&sEffTable.tireMarks[i].params);
}
}
+2 -2
View File
@@ -563,9 +563,9 @@
0x800AF310:("EffectTireMark_Draw","void","EffTireMarkParams* params, GraphicsContext* gCtxt"),
0x800AF710:("Effect_GetContext","GlobalContext*","void"),
0x800AF720:("Effect_GetParams","void*","s32 index"),
0x800AF87C:("Effect_InitCommon","void","UNK_PTR param_1"),
0x800AF87C:("Effect_InitCommon","void","EffCommon* common"),
0x800AF890:("Effect_Init","void","GlobalContext* ctxt"),
0x800AF960:("Effect_Create","void","GlobalContext* ctxt, s32* index, s32 type, UNK_TYPE1 param_4, UNK_TYPE1 param_5, void* initParams"),
0x800AF960:("Effect_Add","void","GlobalContext* ctxt, s32* index, s32 type, u8 param_4, u8 param_5, void* initParams"),
0x800AFB24:("Effect_DrawAll","void","GraphicsContext* gCtxt"),
0x800AFC60:("Effect_UpdateAll","void","GlobalContext* ctxt"),
0x800AFDCC:("Effect_Destroy","void","GlobalContext* ctxt, s32 index"),