1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-05 15:34:41 +00:00

Decompile most effect files in "code" (#144)

- `z_effect`: Matched and essentially all documented.
- `z_eff_spark.c`: Decompiled (1 non matching left) and mostly documented.
- `z_eff_shield_particle.c`: Matched and mostly documented.
- `z_eff_blure.c`: Decompiled (5 non matchings left) and partially documented.
- `z_effect_soft_sprite.c`: Matched and mostly documented.
- `z_eff_ss_dead.c`: Matched but not documented.
- `z_effect_soft_sprite_dlftbls.c`: "Matched" (only data, contains the effect ss overlay table).
- `z_effect_soft_sprite_old_init.c`: Not decompiled, but functions are categorized by effect ss overlay. And they should be decompiled at the same time as their corresponding effect ss in the future.

Other changes:
- Added a lot of types/enums to `z64effect.h`and moved+renamed some structs from `z64.h` to this header
- Added effect ss overlay segments to `segment_symbols.h` and effect ss init vars to `initvars.h`
- Added a macro called `VTX_T` to generate a `Vtx_t` in the same style as `VTX`
- Fixed `flg_set.c` .bss to be in the right file
- Removed `tools/overlayhelpers/batchdisasm` since it's no longer relevant
- Removed unused leftover asm from recent PRs
This commit is contained in:
Roman971 2020-05-18 20:24:00 +02:00 committed by GitHub
parent 785011c33c
commit e29b77919b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
227 changed files with 3739 additions and 8132 deletions

View file

@ -22,8 +22,8 @@ void Math_Rand_Seed(u32 seed) {
}
/**
* Returns a pseudo-random floating-point number between 0.0f and 1.0f, by generating
* the next integer and masking it to an IEEE-754 compliant floating-point number
* Returns a pseudo-random floating-point number between 0.0f and 1.0f, by generating
* the next integer and masking it to an IEEE-754 compliant floating-point number
* between 1.0f and 2.0f, returning the result subtract 1.0f.
*/
f32 Math_Rand_ZeroOne() {

View file

@ -1795,7 +1795,7 @@ void func_8002FA60(GlobalContext* globalCtx) {
Lights_InitType0PositionalLight(&D_8015BC00, lightPos.x, lightPos.y, lightPos.z, 0xFF, 0xFF, 0xFF, -1);
D_8015BC10 = Lights_Insert(globalCtx, &globalCtx->lightCtx, (LightInfo*)&D_8015BC00);
D_8015BC10 = Lights_Insert(globalCtx, &globalCtx->lightCtx, &D_8015BC00);
D_8015BC14 = 0;
D_8015BC18 = 0.0f;
}
@ -2038,7 +2038,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
if (0) {
// This assert is optimized out but it exists due to its presence in rodata
if (gMaxProfile != ACTOR_DLF_MAX) {
if (gMaxActorId != ACTOR_ID_MAX) {
__assert("MaxProfile == ACTOR_DLF_MAX", "../z_actor.c", UNK_LINE);
}
}
@ -2459,11 +2459,11 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) {
}
if ((HREG(64) != 1) || (HREG(73) != 0)) {
func_80026E74(globalCtx->state.gfxCtx);
Effect_DrawAll(globalCtx->state.gfxCtx);
}
if ((HREG(64) != 1) || (HREG(74) != 0)) {
func_80027BDC(globalCtx);
EffectSs_DrawAll(globalCtx);
}
if ((HREG(64) != 1) || (HREG(72) != 0)) {
@ -2683,7 +2683,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId
overlayEntry = &gActorOverlayTable[actorId];
if (actorId >= ACTOR_DLF_MAX) {
if (actorId >= ACTOR_ID_MAX) {
__assert("profile < ACTOR_DLF_MAX", "../z_actor.c", 6883);
}
@ -3134,7 +3134,7 @@ void func_80032E24(struct_80032E24* arg0, s32 arg1, GlobalContext* globalCtx) {
}
void func_80032F54(struct_80032E24* arg0, s32 arg1, s32 arg2, s32 arg3, u32 arg4, s32* arg5, s16 arg6) {
GlobalContext* globalCtx = func_80026B00();
GlobalContext* globalCtx = Effect_GetGlobalCtx();
if ((globalCtx->actorCtx.unk_00 == 0) && (arg0->unk_10 > 0)) {
if ((arg1 >= arg2) && (arg3 >= arg1) && (*arg5 != 0)) {

View file

@ -488,7 +488,7 @@ ActorOverlay gActorOverlayTable[] = {
ACTOR_OVERLAY(Obj_Warp2block, ALLOCTYPE_NORMAL),
};
s32 gMaxProfile = 0;
s32 gMaxActorId = 0;
static FaultClient sFaultClient;
@ -496,10 +496,10 @@ void ActorOverlayTable_LogPrint(void) {
ActorOverlay* overlayEntry;
u32 i;
osSyncPrintf("actor_dlftbls %u\n", gMaxProfile);
osSyncPrintf("actor_dlftbls %u\n", gMaxActorId);
osSyncPrintf("RomStart RomEnd SegStart SegEnd allocp profile segname\n");
for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxProfile; i++, overlayEntry++) {
for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) {
osSyncPrintf("%08x %08x %08x %08x %08x %08x %s\n", overlayEntry->vromStart, overlayEntry->vromEnd,
overlayEntry->vramStart, overlayEntry->vramEnd, overlayEntry->loadedRamAddr,
&overlayEntry->initInfo->id, overlayEntry->name != NULL ? overlayEntry->name : "?");
@ -513,10 +513,10 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) {
FaultDrawer_SetCharPad(-2, 0);
FaultDrawer_Printf("actor_dlftbls %u\n", gMaxProfile);
FaultDrawer_Printf("actor_dlftbls %u\n", gMaxActorId);
FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n");
for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxProfile; i++, overlayEntry++) {
for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) {
overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart;
if (overlayEntry->loadedRamAddr != NULL) {
FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", i, overlayEntry->loadedRamAddr,
@ -527,11 +527,11 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) {
}
void ActorOverlayTable_Init(void) {
gMaxProfile = ACTOR_DLF_MAX;
gMaxActorId = ACTOR_ID_MAX;
Fault_AddClient(&sFaultClient, ActorOverlayTable_FaultPrint, NULL, NULL);
}
void ActorOverlayTable_Cleanup(void) {
Fault_RemoveClient(&sFaultClient);
gMaxProfile = 0;
gMaxActorId = 0;
}

View file

@ -1232,17 +1232,17 @@ void func_8005DF9C(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
}
#ifdef NON_MATCHING
// Blue EffSpark
//.bss problems
// Blue EffectSpark
// .bss problems
void func_8005DFAC(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
static EffectSparkInit D_8015D8A0;
s32 sp24;
static EffSparkParams D_8015D8A0;
D_8015D8A0.position.x = (s32)v->x;
D_8015D8A0.position.y = (s32)v->y;
D_8015D8A0.position.z = (s32)v->z;
D_8015D8A0.particleFactor1 = 5;
D_8015D8A0.particleFactor2 = 5;
D_8015D8A0.uDiv = 5;
D_8015D8A0.vDiv = 5;
D_8015D8A0.colorStart[0].r = 0x0A;
D_8015D8A0.colorStart[0].g = 0x0A;
D_8015D8A0.colorStart[0].b = 0xC8;
@ -1275,11 +1275,12 @@ void func_8005DFAC(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
D_8015D8A0.colorEnd[3].g = 0x00;
D_8015D8A0.colorEnd[3].b = 0x40;
D_8015D8A0.colorEnd[3].a = 0x00;
D_8015D8A0.age = 0;
D_8015D8A0.timer = 0;
D_8015D8A0.duration = 16;
D_8015D8A0.velocity = 8.0f;
D_8015D8A0.speed = 8.0f;
D_8015D8A0.gravity = -1.0f;
Effect_Add(globalCtx, &sp24, 0, 0, 1, &D_8015D8A0);
Effect_Add(globalCtx, &sp24, EFFECT_SPARK, 0, 1, &D_8015D8A0);
}
#else
void func_8005DFAC(GlobalContext* globalCtx, Collider* collider, Vec3f* v);
@ -1287,17 +1288,17 @@ void func_8005DFAC(GlobalContext* globalCtx, Collider* collider, Vec3f* v);
#endif // NON_MATCHING
#ifdef NON_MATCHING
// Green EffSpark
//.bss problems
// Green EffectSpark
// .bss problems
void func_8005E10C(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
static EffectSparkInit D_8015DD68;
s32 sp24;
static EffSparkParams D_8015DD68;
// D_8015DD68
D_8015DD68.position.x = (s32)v->x;
D_8015DD68.position.y = (s32)v->y;
D_8015DD68.position.z = (s32)v->z;
D_8015DD68.particleFactor1 = 5;
D_8015DD68.particleFactor2 = 5;
D_8015DD68.uDiv = 5;
D_8015DD68.vDiv = 5;
D_8015DD68.colorStart[0].r = 0x0A;
D_8015DD68.colorStart[0].g = 0xC8;
D_8015DD68.colorStart[0].b = 0x0A;
@ -1330,11 +1331,12 @@ void func_8005E10C(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
D_8015DD68.colorEnd[3].g = 0x40;
D_8015DD68.colorEnd[3].b = 0x00;
D_8015DD68.colorEnd[3].a = 0x00;
D_8015DD68.age = 0;
D_8015DD68.timer = 0;
D_8015DD68.duration = 16;
D_8015DD68.velocity = 8.0f;
D_8015DD68.speed = 8.0f;
D_8015DD68.gravity = -1.0f;
Effect_Add(globalCtx, &sp24, 0, 0, 1, &D_8015DD68);
Effect_Add(globalCtx, &sp24, EFFECT_SPARK, 0, 1, &D_8015DD68);
}
#else
void func_8005E10C(GlobalContext* globalCtx, Collider* collider, Vec3f* v);
@ -2936,17 +2938,17 @@ void func_800628A4(s32 arg0, ColliderJntSph* collider) {
#endif // NON_MATCHING
#ifdef NON_MATCHING
// Purple EffSpark
//.bss section problems
// Purple EffectSpark
// .bss section problems
void func_80062A28(GlobalContext* globalCtx, Vec3f* v) {
static EffectSparkInit D_8015CF10;
s32 sp24;
static EffSparkParams D_8015CF10;
D_8015CF10.position.x = (s32)v->x;
D_8015CF10.position.y = (s32)v->y;
D_8015CF10.position.z = (s32)v->z;
D_8015CF10.particleFactor1 = 5;
D_8015CF10.particleFactor2 = 5;
D_8015CF10.uDiv = 5;
D_8015CF10.vDiv = 5;
D_8015CF10.colorStart[0].r = 0x80;
D_8015CF10.colorStart[0].g = 0x00;
D_8015CF10.colorStart[0].b = 0x40;
@ -2979,28 +2981,29 @@ void func_80062A28(GlobalContext* globalCtx, Vec3f* v) {
D_8015CF10.colorEnd[3].g = 0x00;
D_8015CF10.colorEnd[3].b = 0x40;
D_8015CF10.colorEnd[3].a = 0x00;
D_8015CF10.age = 0;
D_8015CF10.timer = 0;
D_8015CF10.duration = 16;
D_8015CF10.velocity = 8.0f;
D_8015CF10.speed = 8.0f;
D_8015CF10.gravity = -1.0f;
Effect_Add(globalCtx, &sp24, 0, 0, 1, &D_8015CF10);
Effect_Add(globalCtx, &sp24, EFFECT_SPARK, 0, 1, &D_8015CF10);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/func_80062A28.s")
#endif // NON_MATCHING
#ifdef NON_MATCHING
// White EffSpark (Bubbles?)
//.bss section problems
// White EffectSpark (Bubbles?)
// .bss section problems
void func_80062B80(GlobalContext* globalCtx, Vec3f* v) {
static EffectSparkInit D_8015D3D8;
s32 sp24;
static EffSparkParams D_8015D3D8;
D_8015D3D8.position.x = (s32)v->x;
D_8015D3D8.position.y = (s32)v->y;
D_8015D3D8.position.z = (s32)v->z;
D_8015D3D8.particleFactor1 = 5;
D_8015D3D8.particleFactor2 = 5;
D_8015D3D8.uDiv = 5;
D_8015D3D8.vDiv = 5;
D_8015D3D8.colorStart[0].r = 0xFF;
D_8015D3D8.colorStart[0].g = 0xFF;
D_8015D3D8.colorStart[0].b = 0xFF;
@ -3033,27 +3036,27 @@ void func_80062B80(GlobalContext* globalCtx, Vec3f* v) {
D_8015D3D8.colorEnd[3].g = 0x00;
D_8015D3D8.colorEnd[3].b = 0x00;
D_8015D3D8.colorEnd[3].a = 0x00;
D_8015D3D8.age = 0;
D_8015D3D8.timer = 0;
D_8015D3D8.duration = 16;
D_8015D3D8.velocity = 8.0f;
D_8015D3D8.speed = 8.0f;
D_8015D3D8.gravity = -1.0f;
Effect_Add(globalCtx, &sp24, 0, 0, 1, &D_8015D3D8);
Effect_Add(globalCtx, &sp24, EFFECT_SPARK, 0, 1, &D_8015D3D8);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/func_80062B80.s")
#endif // NON_MATCHING
void func_80062CD4(GlobalContext* globalCtx, Vec3f* v) {
s32 sp24;
static EffShieldParticleInit init = {
static EffectShieldParticleInit init = {
16,
{ 0, 0, 0 },
{ { 0x00, 0xC8, 0xFF, 0xFF } },
{ { 0xFF, 0xFF, 0xFF, 0xFF } },
{ { 0xFF, 0xFF, 0x80, 0xFF } },
{ { 0xFF, 0xFF, 0x00, 0xFF } },
{ { 0xFF, 0x40, 0x00, 0xC8 } },
{ { 0xFF, 0x00, 0x00, 0xFF } },
{ 0.0f, 0.0f, 0.0f },
{ 0x00, 0xC8, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0x80, 0xFF },
{ 0xFF, 0xFF, 0x00, 0xFF },
{ 0xFF, 0x40, 0x00, 0xC8 },
{ 0xFF, 0x00, 0x00, 0xFF },
2.1f,
35.0f,
30.0f,
@ -3061,6 +3064,7 @@ void func_80062CD4(GlobalContext* globalCtx, Vec3f* v) {
{ 0, 0, 0, 0x00, 0x80, 0xFF, 0x00, 300 },
1,
};
s32 sp24;
init.position.x = (s32)v->x;
init.position.y = (s32)v->y;
@ -3068,7 +3072,8 @@ void func_80062CD4(GlobalContext* globalCtx, Vec3f* v) {
init.lightParams.posX = init.position.x;
init.lightParams.posY = init.position.y;
init.lightParams.posZ = init.position.z;
Effect_Add(globalCtx, &sp24, 3, 0, 1, &init);
Effect_Add(globalCtx, &sp24, EFFECT_SHIELD_PARTICLE, 0, 1, &init);
}
void func_80062D60(GlobalContext* globalCtx, Vec3f* v) {
@ -3086,16 +3091,15 @@ void func_80062DF4(GlobalContext* globalCtx, Vec3f* v) {
}
void func_80062E14(GlobalContext* globalCtx, Vec3f* v, Vec3f* arg2) {
s32 sp24;
static EffShieldParticleInit init = {
static EffectShieldParticleInit init = {
16,
{ 0, 0, 0 },
{ { 0x00, 0xC8, 0xFF, 0xFF } },
{ { 0xFF, 0xFF, 0xFF, 0xFF } },
{ { 0xFF, 0xFF, 0x80, 0xFF } },
{ { 0xFF, 0xFF, 0x00, 0xFF } },
{ { 0xFF, 0x40, 0x00, 0xC8 } },
{ { 0xFF, 0x00, 0x00, 0xFF } },
{ 0.0f, 0.0f, 0.0f },
{ 0x00, 0xC8, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0x80, 0xFF },
{ 0xFF, 0xFF, 0x00, 0xFF },
{ 0xFF, 0x40, 0x00, 0xC8 },
{ 0xFF, 0x00, 0x00, 0xFF },
2.1f,
35.0f,
30.0f,
@ -3103,6 +3107,7 @@ void func_80062E14(GlobalContext* globalCtx, Vec3f* v, Vec3f* arg2) {
{ 0, 0, 0, 0x00, 0x80, 0xFF, 0x00, 300 },
0,
};
s32 sp24;
init.position.x = (s32)v->x;
init.position.y = (s32)v->y;
@ -3111,7 +3116,7 @@ void func_80062E14(GlobalContext* globalCtx, Vec3f* v, Vec3f* arg2) {
init.lightParams.posY = init.position.y;
init.lightParams.posZ = init.position.z;
Effect_Add(globalCtx, &sp24, 3, 0, 1, &init);
Effect_Add(globalCtx, &sp24, EFFECT_SHIELD_PARTICLE, 0, 1, &init);
Audio_PlaySoundGeneral(NA_SE_IT_REFLECTION_WOOD, arg2, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,228 @@
#include <ultra64.h>
#include <global.h>
#include <vt.h>
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/func_80023450.s")
static Vtx sVertices[5] = {
VTX(-32, -32, 0, 0, 1024, 0xFF, 0xFF, 0xFF, 0xFF),
VTX(32, 32, 0, 1024, 0, 0xFF, 0xFF, 0xFF, 0xFF),
VTX(-32, 32, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF),
VTX(32, -32, 0, 1024, 1024, 0xFF, 0xFF, 0xFF, 0xFF),
};
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/func_800236B4.s")
// original name: "EffectShieldParticle_ct"
void EffectShieldParticle_Init(void* thisx, void* initParamsx) {
EffectShieldParticle* this = (EffectShieldParticle*)thisx;
EffectShieldParticleInit* initParams = (EffectShieldParticleInit*)initParamsx;
EffectShieldParticleElement* elem;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/func_8002389C.s")
if ((this != NULL) && (initParams != NULL)) {
this->numElements = initParams->numElements;
if (this->numElements > ARRAY_COUNT(this->elements)) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("EffectShieldParticle_ct():パーティクル数がオーバしてます。\n");
osSyncPrintf(VT_RST);
return;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/func_800245BC.s")
this->position = initParams->position;
this->primColorStart = initParams->primColorStart;
this->envColorStart = initParams->envColorStart;
this->primColorMid = initParams->primColorMid;
this->envColorMid = initParams->envColorMid;
this->primColorEnd = initParams->primColorEnd;
this->envColorEnd = initParams->envColorEnd;
this->deceleration = initParams->deceleration;
this->maxInitialSpeed = initParams->maxInitialSpeed;
this->lengthCutoff = initParams->lengthCutoff;
this->duration = initParams->duration;
this->timer = 0;
for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) {
elem->initialSpeed =
(Math_Rand_ZeroOne() * (this->maxInitialSpeed * 0.5f)) + (this->maxInitialSpeed * 0.5f);
elem->endX = 0.0f;
elem->startXChange = 0.0f;
elem->startX = 0.0f;
elem->endXChange = elem->initialSpeed;
elem->yaw = Math_Rand_ZeroOne() * 65534.0f;
elem->pitch = Math_Rand_ZeroOne() * 65534.0f;
}
this->lightDecay = initParams->lightDecay;
if (this->lightDecay == true) {
this->lightInfo.type = 0;
this->lightInfo.params = initParams->lightParams;
this->light = Lights_Insert(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, &this->lightInfo);
} else {
this->light = NULL;
}
}
}
void EffectShieldParticle_Destroy(void* thisx) {
EffectShieldParticle* this = (EffectShieldParticle*)thisx;
if ((this != NULL) && (this->lightDecay == true)) {
if (this->light == Effect_GetGlobalCtx()->lightCtx.lightsHead) {
Effect_GetGlobalCtx()->lightCtx.lightsHead = this->light->next;
}
Lights_Remove(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, this->light);
}
}
s32 EffectShieldParticle_Update(void* thisx) {
EffectShieldParticle* this = (EffectShieldParticle*)thisx;
EffectShieldParticleElement* elem;
if (this == NULL) {
return 0;
}
for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) {
elem->endXChange -= this->deceleration;
if (elem->endXChange < 0.0f) {
elem->endXChange = 0.0f;
}
if (elem->startXChange > 0.0f) {
elem->startXChange -= this->deceleration;
if (elem->startXChange < 0.0f) {
elem->startXChange = 0.0f;
}
}
elem->endX += elem->endXChange;
elem->startX += elem->startXChange;
if ((elem->startXChange == 0.0f) && (this->lengthCutoff < (elem->endX - elem->startX))) {
elem->startXChange = elem->initialSpeed;
}
}
if (this->lightDecay == true) {
this->lightInfo.params.radius /= 2;
}
this->timer++;
if (this->duration < this->timer) {
return 1;
}
return 0;
}
void EffectShieldParticle_GetColors(EffectShieldParticle* this, Color_RGBA8_n* primColor, Color_RGBA8_n* envColor) {
s32 halfDuration;
f32 ratio;
halfDuration = this->duration * 0.5f;
if (halfDuration == 0) {
primColor->r = this->primColorStart.r;
primColor->g = this->primColorStart.g;
primColor->b = this->primColorStart.b;
primColor->a = this->primColorStart.a;
envColor->r = this->envColorStart.r;
envColor->g = this->envColorStart.g;
envColor->b = this->envColorStart.b;
envColor->a = this->envColorStart.a;
} else if (this->timer < halfDuration) {
ratio = this->timer / (f32)halfDuration;
primColor->r = this->primColorStart.r + (this->primColorMid.r - this->primColorStart.r) * ratio;
primColor->g = this->primColorStart.g + (this->primColorMid.g - this->primColorStart.g) * ratio;
primColor->b = this->primColorStart.b + (this->primColorMid.b - this->primColorStart.b) * ratio;
primColor->a = this->primColorStart.a + (this->primColorMid.a - this->primColorStart.a) * ratio;
envColor->r = this->envColorStart.r + (this->envColorMid.r - this->envColorStart.r) * ratio;
envColor->g = this->envColorStart.g + (this->envColorMid.g - this->envColorStart.g) * ratio;
envColor->b = this->envColorStart.b + (this->envColorMid.b - this->envColorStart.b) * ratio;
envColor->a = this->envColorStart.a + (this->envColorMid.a - this->envColorStart.a) * ratio;
} else {
ratio = (this->timer - halfDuration) / (f32)halfDuration;
primColor->r = this->primColorMid.r + (this->primColorEnd.r - this->primColorMid.r) * ratio;
primColor->g = this->primColorMid.g + (this->primColorEnd.g - this->primColorMid.g) * ratio;
primColor->b = this->primColorMid.b + (this->primColorEnd.b - this->primColorMid.b) * ratio;
primColor->a = this->primColorMid.a + (this->primColorEnd.a - this->primColorMid.a) * ratio;
envColor->r = this->envColorMid.r + (this->envColorEnd.r - this->envColorMid.r) * ratio;
envColor->g = this->envColorMid.g + (this->envColorEnd.g - this->envColorMid.g) * ratio;
envColor->b = this->envColorMid.b + (this->envColorEnd.b - this->envColorMid.b) * ratio;
envColor->a = this->envColorMid.a + (this->envColorEnd.a - this->envColorMid.a) * ratio;
}
}
void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) {
EffectShieldParticle* this = (EffectShieldParticle*)thisx;
EffectShieldParticleElement* elem;
Color_RGBA8_n primColor;
Color_RGBA8_n envColor;
Gfx* dispRefs[5];
Mtx* mtx;
Graph_OpenDisps(dispRefs, gfxCtx, "../z_eff_shield_particle.c", 272);
if (this != NULL) {
gfxCtx->polyXlu.p = Gfx_CallSetupDL(gfxCtx->polyXlu.p, 0x26);
gDPSetCycleType(gfxCtx->polyXlu.p++, G_CYC_2CYCLE);
gDPPipeSync(gfxCtx->polyXlu.p++);
gSPTexture(gfxCtx->polyXlu.p++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
gDPLoadTextureBlock(gfxCtx->polyXlu.p++, D_04038FB0, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD);
if (1) {} // Both necessary to match
if (1) {}
gDPSetCombineLERP(gfxCtx->polyXlu.p++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, 0,
0, 0, COMBINED, 0, 0, 0, COMBINED);
gDPSetRenderMode(gfxCtx->polyXlu.p++, G_RM_PASS, G_RM_ZB_CLD_SURF2);
gSPClearGeometryMode(gfxCtx->polyXlu.p++,
G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR);
gSPSetGeometryMode(gfxCtx->polyXlu.p++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH);
if (1) {} // Also necessary to match
EffectShieldParticle_GetColors(this, &primColor, &envColor);
gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, primColor.r, primColor.g, primColor.b, primColor.a);
gDPSetEnvColor(gfxCtx->polyXlu.p++, envColor.r, envColor.g, envColor.b, envColor.a);
gDPPipeSync(gfxCtx->polyXlu.p++);
for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) {
MtxF sp104;
MtxF spC4;
MtxF sp84;
f32 temp1;
f32 temp2;
f32 temp3;
temp1 = (s16)((elem->endX + elem->startX) * 0.5f);
temp2 = elem->endX - elem->startX;
temp3 = (s16)((temp2 * (1.0f / 64.0f)) / 0.02f);
if (temp3 < 1.0f) {
temp3 = 1.0f;
}
func_800A7A24(&spC4, this->position.x, this->position.y, this->position.z);
func_800A7704(&sp104, 0, elem->yaw, 0);
func_800A6FA0(&spC4, &sp104, &sp84);
func_800A7704(&sp104, 0, 0, elem->pitch);
func_800A6FA0(&sp84, &sp104, &spC4);
func_800A7A24(&sp104, temp1, 0.0f, 0.0f);
func_800A6FA0(&spC4, &sp104, &sp84);
func_800A76A4(&sp104, temp3 * 0.02f, 0.02f, 0.02f);
func_800A6FA0(&sp84, &sp104, &spC4);
mtx = func_800A7E70(gfxCtx, &spC4);
if (mtx == NULL) {
break;
}
gSPMatrix(gfxCtx->polyXlu.p++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPVertex(gfxCtx->polyXlu.p++, sVertices, 4, 0);
gSP2Triangles(gfxCtx->polyXlu.p++, 0, 1, 2, 0, 0, 3, 1, 0);
}
}
Graph_CloseDisps(dispRefs, gfxCtx, "../z_eff_shield_particle.c", 359);
}

View file

@ -1,11 +1,289 @@
#include <ultra64.h>
#include <global.h>
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_spark/func_80024B00.s")
// original name: "spark"
void EffectSpark_Init(void* thisx, void* initParamsx) {
EffectSpark* this = (EffectSpark*)thisx;
EffectSparkInit* initParams = (EffectSparkInit*)initParamsx;
EffectSparkElement* elem;
f32 velocityNorm;
s32 i;
void func_80024F0C(UNK_TYPE arg0) {
if ((this != NULL) && (initParams != NULL)) {
if ((initParams->uDiv == 0) || (initParams->vDiv == 0)) {
// Translates to: "u_div,v_div 0 is not good."
osSyncPrintf("spark():u_div,v_div 0では困る。\n");
return;
}
this->position = initParams->position;
this->speed = initParams->speed;
this->gravity = initParams->gravity;
this->uDiv = initParams->uDiv;
this->vDiv = initParams->vDiv;
this->colorStart[0].r = initParams->colorStart[0].r;
this->colorStart[0].g = initParams->colorStart[0].g;
this->colorStart[0].b = initParams->colorStart[0].b;
this->colorStart[0].a = initParams->colorStart[0].a;
this->colorStart[1].r = initParams->colorStart[1].r;
this->colorStart[1].g = initParams->colorStart[1].g;
this->colorStart[1].b = initParams->colorStart[1].b;
this->colorStart[1].a = initParams->colorStart[1].a;
this->colorStart[2].r = initParams->colorStart[2].r;
this->colorStart[2].g = initParams->colorStart[2].g;
this->colorStart[2].b = initParams->colorStart[2].b;
this->colorStart[2].a = initParams->colorStart[2].a;
this->colorStart[3].r = initParams->colorStart[3].r;
this->colorStart[3].g = initParams->colorStart[3].g;
this->colorStart[3].b = initParams->colorStart[3].b;
this->colorStart[3].a = initParams->colorStart[3].a;
this->colorEnd[0].r = initParams->colorEnd[0].r;
this->colorEnd[0].g = initParams->colorEnd[0].g;
this->colorEnd[0].b = initParams->colorEnd[0].b;
this->colorEnd[0].a = initParams->colorEnd[0].a;
this->colorEnd[1].r = initParams->colorEnd[1].r;
this->colorEnd[1].g = initParams->colorEnd[1].g;
this->colorEnd[1].b = initParams->colorEnd[1].b;
this->colorEnd[1].a = initParams->colorEnd[1].a;
this->colorEnd[2].r = initParams->colorEnd[2].r;
this->colorEnd[2].g = initParams->colorEnd[2].g;
this->colorEnd[2].b = initParams->colorEnd[2].b;
this->colorEnd[2].a = initParams->colorEnd[2].a;
this->colorEnd[3].r = initParams->colorEnd[3].r;
this->colorEnd[3].g = initParams->colorEnd[3].g;
this->colorEnd[3].b = initParams->colorEnd[3].b;
this->colorEnd[3].a = initParams->colorEnd[3].a;
this->duration = initParams->duration;
this->numElements = (this->uDiv * this->vDiv) + 2;
if (this->numElements > ARRAY_COUNT(this->elements)) {
osSyncPrintf("table_sizeオーバー\n"); // "over table_size"
return;
}
for (i = 0; i < this->numElements; i++) {
elem = &this->elements[i];
elem->position.x = this->position.x;
elem->position.y = this->position.y;
elem->position.z = this->position.z;
elem->velocity.x = Math_Rand_ZeroOne() - 0.5f;
elem->velocity.y = Math_Rand_ZeroOne() - 0.5f;
elem->velocity.z = Math_Rand_ZeroOne() - 0.5f;
velocityNorm = sqrtf(SQ(elem->velocity.x) + SQ(elem->velocity.y) + SQ(elem->velocity.z));
if (!(fabsf(velocityNorm) < 0.008f)) {
elem->velocity.x *= this->speed * (1.0f / velocityNorm);
elem->velocity.y *= this->speed * (1.0f / velocityNorm);
elem->velocity.z *= this->speed * (1.0f / velocityNorm);
} else {
elem->velocity.x = elem->velocity.z = 0.0f;
elem->velocity.y = this->speed;
}
elem->unkVelocity.x = 30000.0f - Math_Rand_ZeroOne() * 15000.0f;
elem->unkVelocity.y = 30000.0f - Math_Rand_ZeroOne() * 15000.0f;
elem->unkVelocity.z = 30000.0f - Math_Rand_ZeroOne() * 15000.0f;
elem->unkPosition.x = Math_Rand_ZeroOne() * 65534.0f;
elem->unkPosition.y = Math_Rand_ZeroOne() * 65534.0f;
elem->unkPosition.z = Math_Rand_ZeroOne() * 65534.0f;
}
this->timer = 0;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_spark/func_80024F14.s")
void EffectSpark_Destroy(void* thisx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_spark/func_80025000.s")
// original name: "EffectSparkInfo_proc"
s32 EffectSpark_Update(void* thisx) {
EffectSpark* this = (EffectSpark*)thisx;
EffectSparkElement* elem;
s32 i;
if (this == NULL) {
osSyncPrintf("EffectSparkInfo_proc():Spark Pointer is NULL\n");
}
for (i = 0; i < this->numElements; i++) {
elem = &this->elements[i];
elem->position.x += elem->velocity.x;
elem->position.y += elem->velocity.y;
elem->position.z += elem->velocity.z;
elem->velocity.y += this->gravity;
elem->unkPosition.x += elem->unkVelocity.x;
elem->unkPosition.y += elem->unkVelocity.y;
elem->unkPosition.z += elem->unkVelocity.z;
}
this->timer++;
if (this->duration < this->timer) {
return 1;
} else {
return 0;
}
}
// original name: "EffectSparkInfo_disp"
#ifdef NON_MATCHING
// minor ordering and saved register usage differences
void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
Vtx* vertices;
EffectSpark* this = (EffectSpark*)thisx; // sp1E0
EffectSparkElement* elem;
GlobalContext* globalCtx;
f32 ratio;
u8 sp1D3;
u8 sp1D2;
u8 sp1D1;
u8 sp1D0;
u8 sp1CF;
u8 sp1CE;
u8 sp1CD;
u8 sp1CC;
u8 sp1CB;
u8 sp1CA;
u8 sp1C9;
u8 sp1C8;
u8 sp1C7;
u8 sp1C6;
u8 sp1C5;
u8 sp1C4;
s32 i;
s32 j;
Gfx* dispRefs[4]; // sp1AC
globalCtx = Effect_GetGlobalCtx();
Graph_OpenDisps(dispRefs, gfxCtx, "../z_eff_spark.c", 293);
if (this != NULL) {
gSPMatrix(gfxCtx->polyXlu.p++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gfxCtx->polyXlu.p = Gfx_CallSetupDL(gfxCtx->polyXlu.p, 0x26);
gDPSetCycleType(gfxCtx->polyXlu.p++, G_CYC_2CYCLE);
gDPPipeSync(gfxCtx->polyXlu.p++);
gSPTexture(gfxCtx->polyXlu.p++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
gDPLoadTextureBlock(gfxCtx->polyXlu.p++, D_04038FB0, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD);
gDPSetCombineMode(gfxCtx->polyXlu.p++, G_CC_SHADEDECALA, G_CC_PASS2);
gDPSetRenderMode(gfxCtx->polyXlu.p++, G_RM_PASS, G_RM_ZB_CLD_SURF2);
gSPClearGeometryMode(gfxCtx->polyXlu.p++,
G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR);
gSPSetGeometryMode(gfxCtx->polyXlu.p++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH);
gDPPipeSync(gfxCtx->polyXlu.p++);
vertices = Graph_Alloc(gfxCtx, this->numElements * sizeof(Vtx[4]));
if (vertices == NULL) {
// Translates to: "Memory Allocation Failure graph_malloc"
osSyncPrintf("EffectSparkInfo_disp():メモリー確保失敗 graph_malloc\n");
return;
}
j = 0;
ratio = (f32)this->timer / (f32)this->duration;
sp1D3 = this->colorStart[0].r + ((f32)this->colorEnd[0].r - (f32)this->colorStart[0].r) * ratio;
sp1D2 = this->colorStart[0].g + ((f32)this->colorEnd[0].g - (f32)this->colorStart[0].g) * ratio;
sp1D1 = this->colorStart[0].b + ((f32)this->colorEnd[0].b - (f32)this->colorStart[0].b) * ratio;
sp1D0 = this->colorStart[0].a + ((f32)this->colorEnd[0].a - (f32)this->colorStart[0].a) * ratio;
sp1CF = this->colorStart[1].r + ((f32)this->colorEnd[1].r - (f32)this->colorStart[1].r) * ratio;
sp1CE = this->colorStart[1].g + ((f32)this->colorEnd[1].g - (f32)this->colorStart[1].g) * ratio;
sp1CD = this->colorStart[1].b + ((f32)this->colorEnd[1].b - (f32)this->colorStart[1].b) * ratio;
sp1CC = this->colorStart[1].a + ((f32)this->colorEnd[1].a - (f32)this->colorStart[1].a) * ratio;
sp1CB = this->colorStart[2].r + ((f32)this->colorEnd[2].r - (f32)this->colorStart[2].r) * ratio;
sp1CA = this->colorStart[2].g + ((f32)this->colorEnd[2].g - (f32)this->colorStart[2].g) * ratio;
sp1C9 = this->colorStart[2].b + ((f32)this->colorEnd[2].b - (f32)this->colorStart[2].b) * ratio;
sp1C8 = this->colorStart[2].a + ((f32)this->colorEnd[2].a - (f32)this->colorStart[2].a) * ratio;
sp1C7 = this->colorStart[3].r + ((f32)this->colorEnd[3].r - (f32)this->colorStart[3].r) * ratio;
sp1C6 = this->colorStart[3].g + ((f32)this->colorEnd[3].g - (f32)this->colorStart[3].g) * ratio;
sp1C5 = this->colorStart[3].b + ((f32)this->colorEnd[3].b - (f32)this->colorStart[3].b) * ratio;
sp1C4 = this->colorStart[3].a + ((f32)this->colorEnd[3].a - (f32)this->colorStart[3].a) * ratio;
for (i = 0; i < this->numElements; i++) {
MtxF sp12C;
MtxF spEC;
MtxF spAC;
MtxF sp6C;
Mtx* mtx;
f32 temp;
elem = &this->elements[i];
func_800A7A24(&spEC, elem->position.x, elem->position.y, elem->position.z);
temp = ((Math_Rand_ZeroOne() * 2.5f) + 1.5f) * 0.015625f;
func_800A76A4(&spAC, temp, temp, 1.0f);
func_800A6FA0(&spEC, &globalCtx->mf_11DA0, &sp6C);
func_800A6FA0(&sp6C, &spAC, &sp12C);
vertices[j].v.ob[0] = -32;
vertices[j].v.ob[1] = -32;
vertices[j].v.ob[2] = 0;
vertices[j].v.cn[0] = sp1D3;
vertices[j].v.cn[1] = sp1D2;
vertices[j].v.cn[2] = sp1D1;
vertices[j].v.cn[3] = sp1D0;
vertices[j].v.tc[0] = 0;
vertices[j].v.tc[1] = 1024;
vertices[j].v.flag = 0;
vertices[j + 1].v.ob[0] = 32;
vertices[j + 1].v.ob[1] = 32;
vertices[j + 1].v.ob[2] = 0;
vertices[j + 1].v.cn[0] = sp1CF;
vertices[j + 1].v.cn[1] = sp1CE;
vertices[j + 1].v.cn[2] = sp1CD;
vertices[j + 1].v.cn[3] = sp1CC;
vertices[j + 1].v.tc[0] = 1024;
vertices[j + 1].v.tc[1] = 0;
vertices[j + 1].v.flag = 0;
vertices[j + 2].v.ob[0] = -32;
vertices[j + 2].v.ob[1] = 32;
vertices[j + 2].v.ob[2] = 0;
vertices[j + 2].v.cn[0] = sp1CB;
vertices[j + 2].v.cn[1] = sp1CA;
vertices[j + 2].v.cn[2] = sp1C9;
vertices[j + 2].v.cn[3] = sp1C8;
vertices[j + 2].v.tc[0] = 0;
vertices[j + 2].v.tc[1] = 0;
vertices[j + 2].v.flag = 0;
vertices[j + 3].v.ob[0] = 32;
vertices[j + 3].v.ob[1] = -32;
vertices[j + 3].v.ob[2] = 0;
vertices[j + 3].v.cn[0] = sp1C7;
vertices[j + 3].v.cn[1] = sp1C6;
vertices[j + 3].v.cn[2] = sp1C5;
vertices[j + 3].v.cn[3] = sp1C4;
vertices[j + 3].v.tc[0] = 1024;
vertices[j + 3].v.tc[1] = 1024;
vertices[j + 3].v.flag = 0;
j += 4;
if (this) {}
mtx = func_800A7E70(gfxCtx, &sp12C);
if (mtx == NULL) {
break;
}
gSPMatrix(gfxCtx->polyXlu.p++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPVertex(gfxCtx->polyXlu.p++, &vertices[4 * i], 4, 0);
gSP2Triangles(gfxCtx->polyXlu.p++, 2, 0, 3, 0, 2, 3, 1, 0);
}
gDPPipeSync(gfxCtx->polyXlu.p++);
}
Graph_CloseDisps(dispRefs, gfxCtx, "../z_eff_spark.c", 498);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_spark/EffectSpark_Draw.s")
#endif

View file

@ -1,14 +1,140 @@
#include <ultra64.h>
#include <global.h>
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_80026230.s")
void func_80026230(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
f32 absCos;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_80026400.s")
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 113);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_80026608.s")
displayListHead = gfxCtx->polyOpa.p;
cos = Math_Coss((0x8000 / arg3) * arg2);
absCos = ABS(cos);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_80026690.s")
gDPPipeSync(displayListHead++);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_80026860.s")
if (color == NULL) {
gDPSetFogColor(displayListHead++, 0xFF, 0x00, 0x00, 0x00);
} else {
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_80026A6C.s")
gSPFogPosition(displayListHead++, 0, (s16)(absCos * 3000.0f) + 1500);
gfxCtx->polyOpa.p = displayListHead;
if (1) {} // Necessary to match
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 129);
}
void func_80026400(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
Gfx* displayListHead;
f32 cos;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
if (arg3 != 0) {
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 141);
cos = Math_Coss((0x4000 / arg3) * arg2);
displayListHead = gfxCtx->polyOpa.p;
gDPPipeSync(displayListHead++);
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
gSPFogPosition(displayListHead++, 0, (s16)(2800.0f * ABS(cos)) + 1700);
gfxCtx->polyOpa.p = displayListHead;
if (1) {} // Necessary to match
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 153);
}
}
void func_80026608(GlobalContext* globalCtx) {
s32 pad;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 159);
gDPPipeSync(gfxCtx->polyOpa.p++);
gfxCtx->polyOpa.p = func_800BC8A0(globalCtx, gfxCtx->polyOpa.p);
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 164);
}
void func_80026690(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
f32 absCos;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 178);
displayListHead = gfxCtx->polyXlu.p;
cos = Math_Coss((0x8000 / arg3) * arg2);
absCos = ABS(cos);
gDPPipeSync(displayListHead++);
if (color == NULL) {
gDPSetFogColor(displayListHead++, 0xFF, 0x00, 0x00, 0x00);
} else {
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
}
gSPFogPosition(displayListHead++, 0, (s16)(absCos * 3000.0f) + 1500);
gfxCtx->polyXlu.p = displayListHead;
if (1) {} // Necessary to match
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 194);
}
void func_80026860(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 201);
displayListHead = gfxCtx->polyXlu.p;
cos = Math_Coss((0x4000 / arg3) * arg2);
gDPPipeSync(displayListHead++);
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
gSPFogPosition(displayListHead++, 0, (s16)(2800.0f * ABS(cos)) + 1700);
gfxCtx->polyXlu.p = displayListHead;
if (1) {} // Necessary to match
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 212);
}
void func_80026A6C(GlobalContext* globalCtx) {
s32 pad;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 217);
gDPPipeSync(gfxCtx->polyXlu.p++);
gfxCtx->polyXlu.p = func_800BC8A0(globalCtx, gfxCtx->polyXlu.p);
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 222);
}

View file

@ -1,26 +1,264 @@
#include <ultra64.h>
#include <global.h>
GlobalContext* func_80026B00(void) {
return D_80157DA0;
EffectContext sEffectContext;
EffectInfo sEffectInfoTable[] = {
{
sizeof(EffectSpark),
EffectSpark_Init,
EffectSpark_Destroy,
EffectSpark_Update,
EffectSpark_Draw,
},
{
sizeof(EffectBlure),
EffectBlure_Init1,
EffectBlure_Destroy,
EffectBlure_Update,
EffectBlure_Draw,
},
{
sizeof(EffectBlure),
EffectBlure_Init2,
EffectBlure_Destroy,
EffectBlure_Update,
EffectBlure_Draw,
},
{
sizeof(EffectShieldParticle),
EffectShieldParticle_Init,
EffectShieldParticle_Destroy,
EffectShieldParticle_Update,
EffectShieldParticle_Draw,
},
};
GlobalContext* Effect_GetGlobalCtx(void) {
return sEffectContext.globalCtx;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_80026B0C.s")
void* Effect_GetByIndex(s32 index) {
if (index == TOTAL_EFFECT_COUNT) {
return NULL;
}
void func_80026C1C(u8* arg0) {
arg0[0] = 0;
arg0[1] = 0;
arg0[2] = 0;
if (index < SPARK_COUNT) {
if (sEffectContext.sparks[index].status.active == true) {
return &sEffectContext.sparks[index].effect;
} else {
return NULL;
}
}
index -= SPARK_COUNT;
if (index < BLURE_COUNT) {
if (sEffectContext.blures[index].status.active == true) {
return &sEffectContext.blures[index].effect;
} else {
return NULL;
}
}
index -= BLURE_COUNT;
if (index < SHIELD_PARTICLE_COUNT) {
if (sEffectContext.shieldParticles[index].status.active == true) {
return &sEffectContext.shieldParticles[index].effect;
} else {
return NULL;
}
}
return NULL;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_80026C2C.s")
void Effect_InitStatus(EffectStatus* status) {
status->active = false;
status->unk_01 = 0;
status->unk_02 = 0;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/Effect_Add.s")
void Effect_InitContext(GlobalContext* globalCtx) {
s32 i;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_80026E74.s")
for (i = 0; i < SPARK_COUNT; i++) {
Effect_InitStatus(&sEffectContext.sparks[i].status);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_80026F70.s")
for (i = 0; i < BLURE_COUNT; i++) {
Effect_InitStatus(&sEffectContext.blures[i].status);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_8002709C.s")
for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) {
//! @bug This is supposed to initialize shieldParticles, not blures again
Effect_InitStatus(&sEffectContext.blures[i].status);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_800271A8.s")
sEffectContext.globalCtx = globalCtx;
}
void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) {
s32 i;
u32 slotFound;
void* effect;
EffectStatus* status;
effect = NULL;
status = NULL;
*pIndex = TOTAL_EFFECT_COUNT;
if (func_800C0D28(globalCtx) != 1) {
slotFound = false;
switch (type) {
case EFFECT_SPARK:
for (i = 0; i < SPARK_COUNT; i++) {
if (sEffectContext.sparks[i].status.active == false) {
slotFound = true;
*pIndex = i;
effect = &sEffectContext.sparks[i].effect;
status = &sEffectContext.sparks[i].status;
break;
}
}
break;
case EFFECT_BLURE1:
case EFFECT_BLURE2:
for (i = 0; i < BLURE_COUNT; i++) {
if (sEffectContext.blures[i].status.active == false) {
slotFound = true;
*pIndex = i + SPARK_COUNT;
effect = &sEffectContext.blures[i].effect;
status = &sEffectContext.blures[i].status;
break;
}
}
break;
case EFFECT_SHIELD_PARTICLE:
for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) {
if (sEffectContext.shieldParticles[i].status.active == false) {
slotFound = true;
*pIndex = i + SPARK_COUNT + BLURE_COUNT;
effect = &sEffectContext.shieldParticles[i].effect;
status = &sEffectContext.shieldParticles[i].status;
break;
}
}
break;
}
if (!slotFound) {
// Translates to: "EffectAdd(): I cannot secure it. Be careful. Type %d"
osSyncPrintf("EffectAdd():確保できません。注意してください。Type%d\n", type);
// Translates to: "Exit without adding the effect."
osSyncPrintf("エフェクト追加せずに終了します。\n");
} else {
sEffectInfoTable[type].init(effect, initParams);
status->unk_02 = arg3;
status->unk_01 = arg4;
status->active = true;
}
}
}
void Effect_DrawAll(GraphicsContext* gfxCtx) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {
if (sEffectContext.sparks[i].status.active) {
sEffectInfoTable[EFFECT_SPARK].draw(&sEffectContext.sparks[i].effect, gfxCtx);
}
}
for (i = 0; i < BLURE_COUNT; i++) {
do {
if (1) {} // Necessary to match
if (sEffectContext.blures[i].status.active) {
sEffectInfoTable[EFFECT_BLURE1].draw(&sEffectContext.blures[i].effect, gfxCtx);
}
} while (0); // Necessary to match
}
for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) {
if (sEffectContext.shieldParticles[i].status.active) {
if (gfxCtx) {} // Necessary to match
sEffectInfoTable[EFFECT_SHIELD_PARTICLE].draw(&sEffectContext.shieldParticles[i].effect, gfxCtx);
}
}
}
void Effect_UpdateAll(GlobalContext* globalCtx) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {
if (sEffectContext.sparks[i].status.active) {
if (sEffectInfoTable[EFFECT_SPARK].update(&sEffectContext.sparks[i].effect) == 1) {
Effect_Delete(globalCtx, i);
}
}
}
for (i = 0; i < BLURE_COUNT; i++) {
if (sEffectContext.blures[i].status.active) {
if (sEffectInfoTable[EFFECT_BLURE1].update(&sEffectContext.blures[i].effect) == 1) {
Effect_Delete(globalCtx, i + SPARK_COUNT);
}
}
}
for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) {
if (sEffectContext.shieldParticles[i].status.active) {
if (sEffectInfoTable[EFFECT_SHIELD_PARTICLE].update(&sEffectContext.shieldParticles[i].effect) == 1) {
Effect_Delete(globalCtx, i + SPARK_COUNT + BLURE_COUNT);
}
}
}
}
void Effect_Delete(GlobalContext* globalCtx, s32 index) {
if (index == TOTAL_EFFECT_COUNT) {
return;
}
if (index < SPARK_COUNT) {
sEffectContext.sparks[index].status.active = false;
sEffectInfoTable[EFFECT_SPARK].destroy(&sEffectContext.sparks[index].effect);
return;
}
index -= SPARK_COUNT;
if (index < BLURE_COUNT) {
sEffectContext.blures[index].status.active = false;
sEffectInfoTable[EFFECT_BLURE1].destroy(&sEffectContext.blures[index].effect);
return;
}
index -= BLURE_COUNT;
if (index < SHIELD_PARTICLE_COUNT) {
sEffectContext.shieldParticles[index].status.active = false;
sEffectInfoTable[EFFECT_SHIELD_PARTICLE].destroy(&sEffectContext.shieldParticles[index].effect);
return;
}
}
void Effect_DeleteAll(GlobalContext* globalCtx) {
s32 i;
osSyncPrintf("エフェクト総て解放\n"); // "All effect release"
for (i = 0; i < SPARK_COUNT; i++) {
sEffectContext.sparks[i].status.active = false;
sEffectInfoTable[EFFECT_SPARK].destroy(&sEffectContext.sparks[i].effect);
}
for (i = 0; i < BLURE_COUNT; i++) {
sEffectContext.blures[i].status.active = false;
sEffectInfoTable[EFFECT_BLURE1].destroy(&sEffectContext.blures[i].effect);
}
for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) {
sEffectContext.shieldParticles[i].status.active = false;
sEffectInfoTable[EFFECT_SHIELD_PARTICLE].destroy(&sEffectContext.shieldParticles[i].effect);
}
osSyncPrintf("エフェクト総て解放 終了\n"); // "All effects release End"
}

View file

@ -1,139 +1,343 @@
#include <ultra64.h>
#include <global.h>
#include <vt.h>
extern ParticleOverlay sParticleOverlayTable[37];
EffectSsInfo sEffectSsInfo = { 0 }; // "EffectSS2Info"
void Effect_SS_Delete(LoadedParticleEntry* particle);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite/func_800272B0.s")
void Effect_SS_Clear(GlobalContext* globalCtx) {
void EffectSs_InitInfo(GlobalContext* globalCtx, s32 tableSize) {
u32 i;
LoadedParticleEntry* iter;
ParticleOverlay* iter2;
EffectSs* effectSs;
EffectSsOverlay* overlay;
for (i = 0; i < ARRAY_COUNT(gEffectSsOverlayTable); i++) {
overlay = &gEffectSsOverlayTable[i];
osSyncPrintf("effect index %3d:size=%6dbyte romsize=%6dbyte\n", i,
(u32)overlay->vramEnd - (u32)overlay->vramStart, overlay->vromEnd - overlay->vromStart);
}
sEffectSsInfo.table =
GameState_AllocEnd(&globalCtx->state, tableSize * sizeof(EffectSs), "../z_effect_soft_sprite.c", 289);
if (sEffectSsInfo.table == NULL) {
__assert("EffectSS2Info.data_table != NULL", "../z_effect_soft_sprite.c", 290);
}
sEffectSsInfo.searchStartIndex = 0;
sEffectSsInfo.tableSize = tableSize;
for (effectSs = &sEffectSsInfo.table[0]; effectSs < &sEffectSsInfo.table[sEffectSsInfo.tableSize]; effectSs++) {
EffectSs_Reset(effectSs);
}
overlay = &gEffectSsOverlayTable[0];
for (i = 0; i < ARRAY_COUNT(gEffectSsOverlayTable); i++) {
overlay->loadedRamAddr = NULL;
overlay++;
}
}
void EffectSs_ClearAll(GlobalContext* globalCtx) {
u32 i;
EffectSs* effectSs;
EffectSsOverlay* overlay;
void* addr;
EffectSS2Info.data_table = NULL;
EffectSS2Info.searchIndex = 0;
EffectSS2Info.size = 0;
sEffectSsInfo.table = NULL;
sEffectSsInfo.searchStartIndex = 0;
sEffectSsInfo.tableSize = 0;
for (iter = EffectSS2Info.data_table; iter < EffectSS2Info.data_table + EffectSS2Info.size; iter++) {
Effect_SS_Delete(iter);
// This code doesn't actually work, since table was just set to NULL and tableSize to 0
for (effectSs = &sEffectSsInfo.table[0]; effectSs < &sEffectSsInfo.table[sEffectSsInfo.tableSize]; effectSs++) {
EffectSs_Delete(effectSs);
}
// Free memory from loaded particle overlays
iter2 = &sParticleOverlayTable[0];
for (i = 0; i < ARRAY_COUNT(sParticleOverlayTable); i++) {
addr = iter2->loadedRamAddr;
overlay = &gEffectSsOverlayTable[0];
for (i = 0; i < ARRAY_COUNT(gEffectSsOverlayTable); i++) {
addr = overlay->loadedRamAddr;
if (addr != NULL) {
ZeldaArena_FreeDebug(addr, D_801357DC, 337);
ZeldaArena_FreeDebug(addr, "../z_effect_soft_sprite.c", 337);
}
(iter2++)->loadedRamAddr = NULL;
overlay->loadedRamAddr = NULL;
overlay++;
}
}
void Effect_SS_Delete(LoadedParticleEntry* particle) {
if (particle->flags & 2) {
func_800F89E8(&particle->position);
void EffectSs_Delete(EffectSs* effectSs) {
if (effectSs->flags & 2) {
func_800F89E8(&effectSs->pos);
}
if (particle->flags & 4) {
func_800F89E8(&particle->unk_2C);
if (effectSs->flags & 4) {
func_800F89E8(&effectSs->unk_2C);
}
Effect_SS_ResetEntry(particle);
EffectSs_Reset(effectSs);
}
void Effect_SS_ResetEntry(LoadedParticleEntry* particle) {
void EffectSs_Reset(EffectSs* effectSs) {
u32 i;
particle->type = 0x25;
particle->acceleration.z = 0;
particle->acceleration.y = 0;
particle->acceleration.x = 0;
particle->velocity.z = 0;
particle->velocity.y = 0;
particle->velocity.x = 0;
particle->unk_34 = 0;
particle->unk_30 = 0;
particle->unk_2C = 0;
particle->position.z = 0;
particle->position.y = 0;
particle->position.x = 0;
particle->life = -1;
particle->flags = 0;
particle->priority = 128;
particle->draw = NULL;
particle->update = NULL;
particle->unk_38 = 0;
particle->unk_3C = 0;
effectSs->type = EFFECT_SS_TYPE_MAX;
effectSs->accel.x = effectSs->accel.y = effectSs->accel.z = 0;
effectSs->velocity.x = effectSs->velocity.y = effectSs->velocity.z = 0;
effectSs->unk_2C.x = effectSs->unk_2C.y = effectSs->unk_2C.z = 0;
effectSs->pos.x = effectSs->pos.y = effectSs->pos.z = 0;
effectSs->life = -1;
effectSs->flags = 0;
effectSs->priority = 128;
effectSs->draw = NULL;
effectSs->update = NULL;
effectSs->unk_38 = 0;
effectSs->unk_3C = 0;
for (i = 0; i != 13; i++) {
particle->unk_40[i] = 0;
for (i = 0; i < ARRAY_COUNT(effectSs->regs); i++) {
effectSs->regs[i] = 0;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite/func_800275D0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite/func_80027704.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite/func_80027798.s")
void Effect_SS_UpdateParticle(GlobalContext* globalCtx, s32 index) {
LoadedParticleEntry* particle = &EffectSS2Info.data_table[index];
if (particle->update != NULL) {
particle->velocity.x += particle->acceleration.x;
particle->velocity.y += particle->acceleration.y;
particle->velocity.z += particle->acceleration.z;
particle->position.x += particle->velocity.x;
particle->position.y += particle->velocity.y;
particle->position.z += particle->velocity.z;
particle->update(globalCtx, index, particle);
}
}
void Effect_SS_UpdateAllParticles(GlobalContext* globalCtx) {
s32 EffectSs_FindSlot(s32 priority, s32* pIndex) {
s32 foundFree;
s32 i;
for (i = 0; i < EffectSS2Info.size; i++) {
if (EffectSS2Info.data_table[i].life > -1) {
EffectSS2Info.data_table[i].life--;
if (sEffectSsInfo.searchStartIndex >= sEffectSsInfo.tableSize) {
sEffectSsInfo.searchStartIndex = 0;
}
if (EffectSS2Info.data_table[i].life < 0) {
Effect_SS_Delete(&EffectSS2Info.data_table[i]);
// Search for a free slot
i = sEffectSsInfo.searchStartIndex;
foundFree = false;
while (true) {
if (sEffectSsInfo.table[i].life == -1) {
foundFree = true;
break;
}
i++;
if (i >= sEffectSsInfo.tableSize) {
i = 0; // Loop around the whole table
}
// After a full loop, break out
if (i == sEffectSsInfo.searchStartIndex) {
break;
}
}
if (foundFree == true) {
*pIndex = i;
return 0;
}
// If all slots are in use, search for a slot with a lower priority
// Note that a lower priority is representend by a higher value
i = sEffectSsInfo.searchStartIndex;
while (true) {
// Equal priority should only be considered "lower" if flag 0 is set
if ((priority <= sEffectSsInfo.table[i].priority) &&
!((priority == sEffectSsInfo.table[i].priority) && (sEffectSsInfo.table[i].flags & 1))) {
break;
}
i++;
if (i >= sEffectSsInfo.tableSize) {
i = 0; // Loop around the whole table
}
// After a full loop, return 1 to indicate that we failed to find a suitable slot
if (i == sEffectSsInfo.searchStartIndex) {
return 1;
}
}
*pIndex = i;
return 0;
}
void EffectSs_Insert(GlobalContext* globalCtx, EffectSs* effectSs) {
s32 index;
if (func_800C0D28(globalCtx) != 1) {
if (EffectSs_FindSlot(effectSs->priority, &index) == 0) {
sEffectSsInfo.searchStartIndex = index + 1;
sEffectSsInfo.table[index] = *effectSs;
}
}
}
// original name: "EffectSoftSprite2_makeEffect"
void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initParams) {
s32 index;
u32 overlaySize;
EffectSsOverlay* overlayEntry;
EffectSsInit* initInfo;
overlayEntry = &gEffectSsOverlayTable[type];
if (type >= EFFECT_SS_TYPE_MAX) {
__assert("type < EFFECT_SS2_TYPE_LAST_LABEL", "../z_effect_soft_sprite.c", 556);
}
if (EffectSs_FindSlot(priority, &index) != 0) {
// Abort because we couldn't find a suitable slot to add this effect in
return;
}
sEffectSsInfo.searchStartIndex = index + 1;
overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart;
if (overlayEntry->vramStart == NULL) {
// Translates to: "Not an overlay"
osSyncPrintf("EffectSoftSprite2_makeEffect():オーバーレイではありません。\n");
initInfo = overlayEntry->initInfo;
} else {
if (overlayEntry->loadedRamAddr == NULL) {
overlayEntry->loadedRamAddr = ZeldaArena_MallocRDebug(overlaySize, "../z_effect_soft_sprite.c", 585);
if (overlayEntry->loadedRamAddr == NULL) {
osSyncPrintf(VT_FGCOL(RED));
// Translates to: "The memory of %d byte cannot be secured. Therefore, the program cannot be loaded.
// What a dangerous situation! Naturally, effects will not produced either."
osSyncPrintf("EffectSoftSprite2_makeEffect():zelda_malloc_r()により,%"
"dbyteのメモリ確保ができま\nせん。そのため、プログラムのロードも\n出来ません。ただいま危険"
"な状態です!\nもちろん,エフェクトも出ません。\n",
overlaySize);
osSyncPrintf(VT_RST);
return;
}
Overlay_Load(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd,
overlayEntry->loadedRamAddr);
osSyncPrintf(VT_FGCOL(GREEN));
osSyncPrintf("EFFECT SS OVL:SegRom %08x %08x, Seg %08x %08x, RamStart %08x, type: %d\n",
overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd,
overlayEntry->loadedRamAddr, type);
osSyncPrintf(VT_RST);
}
initInfo = (void*)(u32)((overlayEntry->initInfo != NULL)
? (void*)((u32)overlayEntry->initInfo -
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr))
: NULL);
}
if (initInfo->init == NULL) {
// Translates to: "Effects have already been loaded, but the constructor is NULL so the addition will not occur.
// Please fix this. (Waste of memory) %08x %d"
osSyncPrintf("EffectSoftSprite2_makeEffect():すでにエフェクトはロード済みで\nすが,"
"コンストラクターがNULLなので追加をやめます。\n直してください。(メモリーの無駄) %08x %d\n",
initInfo, type);
return;
}
// Delete the previous effect in the slot, in case the slot wasn't free
EffectSs_Delete(&sEffectSsInfo.table[index]);
sEffectSsInfo.table[index].type = type;
sEffectSsInfo.table[index].priority = priority;
if (initInfo->init(globalCtx, index, &sEffectSsInfo.table[index], initParams) == 0) {
osSyncPrintf(VT_FGCOL(GREEN));
// Translates to: "Construction failed for some reason. The constructor returned an error.
// Ceasing effect addition."
osSyncPrintf("EffectSoftSprite2_makeEffect():"
"何らかの理由でコンストラクト失敗。コンストラクターがエラーを返しました。エフェクトの追加を中"
"止します。\n");
osSyncPrintf(VT_RST);
EffectSs_Reset(&sEffectSsInfo.table[index]);
}
}
void EffectSs_Update(GlobalContext* globalCtx, s32 index) {
EffectSs* effectSs = &sEffectSsInfo.table[index];
if (effectSs->update != NULL) {
effectSs->velocity.x += effectSs->accel.x;
effectSs->velocity.y += effectSs->accel.y;
effectSs->velocity.z += effectSs->accel.z;
effectSs->pos.x += effectSs->velocity.x;
effectSs->pos.y += effectSs->velocity.y;
effectSs->pos.z += effectSs->velocity.z;
effectSs->update(globalCtx, index, effectSs);
}
}
void EffectSs_UpdateAll(GlobalContext* globalCtx) {
s32 i;
for (i = 0; i < sEffectSsInfo.tableSize; i++) {
if (sEffectSsInfo.table[i].life > -1) {
sEffectSsInfo.table[i].life--;
if (sEffectSsInfo.table[i].life < 0) {
EffectSs_Delete(&sEffectSsInfo.table[i]);
}
}
if (EffectSS2Info.data_table[i].life > -1) {
Effect_SS_UpdateParticle(globalCtx, i);
if (sEffectSsInfo.table[i].life > -1) {
EffectSs_Update(globalCtx, i);
}
}
}
void Effect_SS_DrawParticle(GlobalContext* globalCtx, s32 index) {
LoadedParticleEntry* particle = &EffectSS2Info.data_table[index];
void EffectSs_Draw(GlobalContext* globalCtx, s32 index) {
EffectSs* effectSs = &sEffectSsInfo.table[index];
if (particle->draw != NULL) {
particle->draw(globalCtx, index, particle);
if (effectSs->draw != NULL) {
effectSs->draw(globalCtx, index, effectSs);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite/func_80027BDC.s")
// original name: "EffectSoftSprite2_disp"
void EffectSs_DrawAll(GlobalContext* globalCtx) {
LightMapper* lightMapper;
s32 i;
lightMapper = Lights_CreateMapper(&globalCtx->lightCtx, globalCtx->state.gfxCtx);
func_8007A474(lightMapper, globalCtx->lightCtx.lightsHead, 0);
func_80079EFC(lightMapper, globalCtx->state.gfxCtx);
for (i = 0; i < sEffectSsInfo.tableSize; i++) {
if (sEffectSsInfo.table[i].life > -1) {
if ((sEffectSsInfo.table[i].pos.x > 32000.0f) || (sEffectSsInfo.table[i].pos.x < -32000.0f) ||
(sEffectSsInfo.table[i].pos.y > 32000.0f) || (sEffectSsInfo.table[i].pos.y < -32000.0f) ||
(sEffectSsInfo.table[i].pos.z > 32000.0f) || (sEffectSsInfo.table[i].pos.z < -32000.0f)) {
osSyncPrintf(VT_FGCOL(RED));
// Translates to: "Since the position is outside the area, delete it.
// Effect label No. %d: Please respond by the program.
// Here is ==> pos (%f, %f, %f) and the label is in z_effect_soft_sprite_dlftbls.decl."
osSyncPrintf("EffectSoftSprite2_disp():位置が領域外のため "
"削除します。エフェクトラベルNo.%d:プログラムの方で対応をお願いします。ここです ==> "
"pos(%f, %f, %f)で、ラベルはz_effect_soft_sprite_dlftbls.declにあります。\n",
sEffectSsInfo.table[i].type, sEffectSsInfo.table[i].pos.x, sEffectSsInfo.table[i].pos.y,
sEffectSsInfo.table[i].pos.z);
osSyncPrintf(VT_FGCOL(GREEN));
// Translates to: "If you are using pos for something else, consult me."
osSyncPrintf("もし、posを別のことに使っている場合相談に応じます。\n");
osSyncPrintf(VT_RST);
EffectSs_Delete(&sEffectSsInfo.table[i]);
} else {
EffectSs_Draw(globalCtx, i);
}
}
}
}
s16 func_80027DD4(s16 arg0, s16 arg1, s32 arg2) {
s16 ret = !arg2 ? arg1 : (arg0 + (s32)((f32)(arg1 - arg0) / arg2));
s16 ret = (arg2 == 0) ? arg1 : (arg0 + (s32)((arg1 - arg0) / (f32)arg2));
return ret;
}
s16 func_80027E34(s16 a0, s16 a1, f32 a2) {
return (a1 - a0) * a2 + a0;
s16 func_80027E34(s16 arg0, s16 arg1, f32 arg2) {
return (arg1 - arg0) * arg2 + arg0;
}
u8 func_80027E84(u8 a0, u8 a1, f32 a2) {
return a2 * ((f32)a1 - (f32)a0) + a0;
u8 func_80027E84(u8 arg0, u8 arg1, f32 arg2) {
return arg2 * ((f32)arg1 - (f32)arg0) + arg0;
}

View file

@ -0,0 +1,55 @@
#include <ultra64.h>
#include <global.h>
#include <initvars.h>
#define EFFECT_SS_OVERLAY(name) \
{ \
(u32) _ovl_##name##SegmentRomStart, (u32)_ovl_##name##SegmentRomEnd, _ovl_##name##SegmentStart, \
_ovl_##name##SegmentEnd, NULL, &name##_InitVars, 1, \
}
#define EFFECT_SS_OVERLAY_INTERNAL(name) \
{ 0, 0, NULL, NULL, NULL, &name##_InitVars, 1 }
#define EFFECT_SS_OVERLAY_UNSET \
{ 0 }
EffectSsOverlay gEffectSsOverlayTable[] = {
EFFECT_SS_OVERLAY(Effect_Ss_Dust),
EFFECT_SS_OVERLAY(Effect_Ss_KiraKira),
EFFECT_SS_OVERLAY(Effect_Ss_Bomb),
EFFECT_SS_OVERLAY(Effect_Ss_Bomb2),
EFFECT_SS_OVERLAY(Effect_Ss_Blast),
EFFECT_SS_OVERLAY(Effect_Ss_G_Spk),
EFFECT_SS_OVERLAY(Effect_Ss_D_Fire),
EFFECT_SS_OVERLAY(Effect_Ss_Bubble),
EFFECT_SS_OVERLAY_UNSET,
EFFECT_SS_OVERLAY(Effect_Ss_G_Ripple),
EFFECT_SS_OVERLAY(Effect_Ss_G_Splash),
EFFECT_SS_OVERLAY(Effect_Ss_G_Magma),
EFFECT_SS_OVERLAY(Effect_Ss_G_Fire),
EFFECT_SS_OVERLAY(Effect_Ss_Lightning),
EFFECT_SS_OVERLAY(Effect_Ss_Dt_Bubble),
EFFECT_SS_OVERLAY(Effect_Ss_Hahen),
EFFECT_SS_OVERLAY(Effect_Ss_Stick),
EFFECT_SS_OVERLAY(Effect_Ss_Sibuki),
EFFECT_SS_OVERLAY(Effect_Ss_Sibuki2),
EFFECT_SS_OVERLAY(Effect_Ss_G_Magma2),
EFFECT_SS_OVERLAY(Effect_Ss_Stone1),
EFFECT_SS_OVERLAY(Effect_Ss_HitMark),
EFFECT_SS_OVERLAY(Effect_Ss_Fhg_Flash),
EFFECT_SS_OVERLAY(Effect_Ss_K_Fire),
EFFECT_SS_OVERLAY(Effect_Ss_Solder_Srch_Ball),
EFFECT_SS_OVERLAY(Effect_Ss_Kakera),
EFFECT_SS_OVERLAY(Effect_Ss_Ice_Piece),
EFFECT_SS_OVERLAY(Effect_Ss_En_Ice),
EFFECT_SS_OVERLAY(Effect_Ss_Fire_Tail),
EFFECT_SS_OVERLAY(Effect_Ss_En_Fire),
EFFECT_SS_OVERLAY(Effect_Ss_Extra),
EFFECT_SS_OVERLAY(Effect_Ss_Fcircle),
EFFECT_SS_OVERLAY(Effect_Ss_Dead_Db),
EFFECT_SS_OVERLAY(Effect_Ss_Dead_Dd),
EFFECT_SS_OVERLAY(Effect_Ss_Dead_Ds),
EFFECT_SS_OVERLAY(Effect_Ss_Dead_Sound),
EFFECT_SS_OVERLAY(Effect_Ss_Ice_Smoke),
};

View file

@ -1,8 +1,11 @@
#include <ultra64.h>
#include <global.h>
// Draw utility for some G effects
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80027F80.s")
// EffectSsDust Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800281E8.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002829C.s")
@ -41,6 +44,8 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028A54.s")
// EffectSsKiraKira Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028B18.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028B74.s")
@ -49,12 +54,18 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028CEC.s")
// EffectSsBomb Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028DC4.s")
// EffectSsBomb2 Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028E1C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028E84.s")
// EffectSsBlast Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028EF4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80028F84.s")
@ -63,6 +74,8 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029024.s")
// EffectSsGSpk Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029060.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800290F0.s")
@ -73,94 +86,154 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800292DC.s")
// EffectSsDFire Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029320.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800293A0.s")
// EffectSsBubble Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800293E4.s")
// EffectSsGRipple Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029444.s")
// EffectSsGSplash Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002949C.s")
// EffectSsGMagma Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029530.s")
// EffectSsGFire Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029568.s")
// EffectSsLightning Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800295A0.s")
// EffectSsDtBubble Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029618.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029694.s")
// EffectSsHahen Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029724.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800297A4.s")
// EffectSsStick Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800298EC.s")
// EffectSsSibuki Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002993C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800299AC.s")
// EffectSsSibuki2 Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029B30.s")
// EffectSsGMagma2 Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029B90.s")
// EffectSsStone1 Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029C00.s")
// EffectSsHitMark Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029C50.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029CA4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029CC8.s")
// EffectSsFhgFlash Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029CF0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029D5C.s")
// EffectSsKFire Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029DBC.s")
// EffectSsSolderSrchBall Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029E24.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/Effect_SpawnFragment.s")
// EffectSsKakera Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029E8C.s")
// EffectSsIcePiece Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029F44.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_80029FAC.s")
// EffectSsEnIce Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A140.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A1DC.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A2A4.s")
// EffectSsFireTail Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A32C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A3C4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A484.s")
// EffectSsEnFire Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A4D4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A54C.s")
// EffectSsExtra Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A5F4.s")
// EffectSsFCircle Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A65C.s")
// EffectSsDeadBb Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A6B8.s")
// EffectSsDeadDd Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A770.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A824.s")
// EffectSsDeadDs Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A894.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A90C.s")
// EffectSsDeadSound Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A95C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002A9F4.s")
// EffectSsIceSmoke Spawn Functions
#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/func_8002AA44.s")

View file

@ -151,7 +151,7 @@ void Lights_RemoveAll(GlobalContext* globalCtx, LightingContext* lightCtx) {
}
}
z_Light* Lights_Insert(GlobalContext* globalCtx, LightingContext* lightCtx, LightInfo* info) {
z_Light* Lights_Insert(GlobalContext* globalCtx, LightingContext* lightCtx, void* info) {
z_Light* light;
light = Lights_FindFreeSlot();

View file

@ -157,8 +157,8 @@ void Gameplay_Destroy(GlobalContext* globalCtx) {
R_PAUSE_MENU_MODE = 0;
func_800C0F08(&globalCtx->preRenderCtx);
func_800271A8(globalCtx);
Effect_SS_Clear(globalCtx);
Effect_DeleteAll(globalCtx);
EffectSs_ClearAll(globalCtx);
CollisionCheck_DestroyContext(globalCtx, &globalCtx->colChkCtx);
if (gTrnsnUnkState == 3) {
@ -240,8 +240,8 @@ void Gameplay_Init(GlobalContext* globalCtx) {
func_80110F68(globalCtx);
func_80110450(globalCtx);
func_8006BA00(globalCtx);
func_80026C2C(globalCtx);
func_800272B0(globalCtx, 0x55);
Effect_InitContext(globalCtx);
EffectSs_InitInfo(globalCtx, 0x55);
func_8005D3BC(globalCtx, &globalCtx->colChkCtx);
SkelAnime_AnimationCtxReset(&globalCtx->animationCtx);
func_8006450C(globalCtx, &globalCtx->csCtx);
@ -891,13 +891,13 @@ void Gameplay_Update(GlobalContext* globalCtx) {
LOG_NUM("1", 1, "../z_play.c", 3651);
}
func_80026F70(globalCtx);
Effect_UpdateAll(globalCtx);
if (1 && HREG(63)) {
LOG_NUM("1", 1, "../z_play.c", 3657);
}
Effect_SS_UpdateAllParticles(globalCtx);
EffectSs_UpdateAll(globalCtx);
if (1 && HREG(63)) {
LOG_NUM("1", 1, "../z_play.c", 3662);