mirror of
https://github.com/zeldaret/mm.git
synced 2024-11-23 12:59:44 +00:00
EffectSsLightning OK (#800)
* OK * Document and gameplay keep * cleanup * Rotate -> Rot * Update description
This commit is contained in:
parent
a6e90d144c
commit
c2afdf6eb0
@ -1062,15 +1062,15 @@
|
||||
<Texture Name="gEffStone7Tex" OutName="eff_stone_7" Format="ia8" Width="32" Height="32" Offset="0x3B990" />
|
||||
<Texture Name="gEffStone8Tex" OutName="eff_stone_8" Format="ia8" Width="32" Height="32" Offset="0x3BD90" />
|
||||
<DList Name="gEffStoneDL" Offset="0x3C190" />
|
||||
<Texture Name="gameplay_keep_Tex_03C230" OutName="tex_03C230" Format="i4" Width="32" Height="96" Offset="0x3C230" />
|
||||
<Texture Name="gameplay_keep_Tex_03C830" OutName="tex_03C830" Format="i4" Width="32" Height="96" Offset="0x3C830" />
|
||||
<Texture Name="gameplay_keep_Tex_03CE30" OutName="tex_03CE30" Format="i4" Width="32" Height="96" Offset="0x3CE30" />
|
||||
<Texture Name="gameplay_keep_Tex_03D430" OutName="tex_03D430" Format="i4" Width="32" Height="96" Offset="0x3D430" />
|
||||
<Texture Name="gameplay_keep_Tex_03DA30" OutName="tex_03DA30" Format="i4" Width="32" Height="96" Offset="0x3DA30" />
|
||||
<Texture Name="gameplay_keep_Tex_03E030" OutName="tex_03E030" Format="i4" Width="32" Height="96" Offset="0x3E030" />
|
||||
<Texture Name="gameplay_keep_Tex_03E630" OutName="tex_03E630" Format="i4" Width="32" Height="96" Offset="0x3E630" />
|
||||
<Texture Name="gameplay_keep_Tex_03EC30" OutName="tex_03EC30" Format="i4" Width="32" Height="96" Offset="0x3EC30" />
|
||||
<DList Name="gameplay_keep_DL_03F230" Offset="0x3F230" />
|
||||
<Texture Name="gEffLightning1Tex" OutName="eff_lightning_1" Format="i4" Width="32" Height="96" Offset="0x3C230" />
|
||||
<Texture Name="gEffLightning2Tex" OutName="eff_lightning_2" Format="i4" Width="32" Height="96" Offset="0x3C830" />
|
||||
<Texture Name="gEffLightning3Tex" OutName="eff_lightning_3" Format="i4" Width="32" Height="96" Offset="0x3CE30" />
|
||||
<Texture Name="gEffLightning4Tex" OutName="eff_lightning_4" Format="i4" Width="32" Height="96" Offset="0x3D430" />
|
||||
<Texture Name="gEffLightning5Tex" OutName="eff_lightning_5" Format="i4" Width="32" Height="96" Offset="0x3DA30" />
|
||||
<Texture Name="gEffLightning6Tex" OutName="eff_lightning_6" Format="i4" Width="32" Height="96" Offset="0x3E030" />
|
||||
<Texture Name="gEffLightning7Tex" OutName="eff_lightning_7" Format="i4" Width="32" Height="96" Offset="0x3E630" />
|
||||
<Texture Name="gEffLightning8Tex" OutName="eff_lightning_8" Format="i4" Width="32" Height="96" Offset="0x3EC30" />
|
||||
<DList Name="gEffLightningDL" Offset="0x3F230" />
|
||||
<Texture Name="gameplay_keep_Tex_03F300" OutName="tex_03F300" Format="i8" Width="32" Height="64" Offset="0x3F300" />
|
||||
<Texture Name="gameplay_keep_Tex_03FB00" OutName="tex_03FB00" Format="i8" Width="32" Height="64" Offset="0x3FB00" />
|
||||
<Texture Name="gameplay_keep_Tex_040300" OutName="tex_040300" Format="i8" Width="32" Height="64" Offset="0x40300" />
|
||||
|
3
spec
3
spec
@ -1857,8 +1857,7 @@ beginseg
|
||||
name "ovl_Effect_Ss_Lightning"
|
||||
compress
|
||||
include "build/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.o"
|
||||
include "build/data/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning.data.o"
|
||||
include "build/data/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning.reloc.o"
|
||||
include "build/src/overlays/effects/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning_reloc.o"
|
||||
endseg
|
||||
|
||||
beginseg
|
||||
|
@ -1,29 +1,157 @@
|
||||
/*
|
||||
* File: z_eff_ss_lightning.c
|
||||
* Overlay: ovl_Effect_Ss_Lightning
|
||||
* Description:
|
||||
* Description: Electric Discharge
|
||||
*/
|
||||
|
||||
#include "z_eff_ss_lightning.h"
|
||||
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||
|
||||
#define rPrimColorR regs[0]
|
||||
#define rPrimColorG regs[1]
|
||||
#define rPrimColorB regs[2]
|
||||
#define rPrimColorA regs[3]
|
||||
#define rEnvColorR regs[4]
|
||||
#define rEnvColorG regs[5]
|
||||
#define rEnvColorB regs[6]
|
||||
#define rEnvColorA regs[7]
|
||||
#define rNumBolts regs[8]
|
||||
#define rScale regs[9]
|
||||
#define rYaw regs[10]
|
||||
#define rLifespan regs[11]
|
||||
|
||||
#define PARAMS ((EffectSsLightningInitParams*)initParamsx)
|
||||
|
||||
s32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx);
|
||||
u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx);
|
||||
void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this);
|
||||
void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this);
|
||||
|
||||
#if 0
|
||||
TexturePtr sLightningTextures[] = {
|
||||
gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex,
|
||||
gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex,
|
||||
};
|
||||
|
||||
const EffectSsInit Effect_Ss_Lightning_InitVars = {
|
||||
EFFECT_SS_LIGHTNING,
|
||||
EffectSsLightning_Init,
|
||||
};
|
||||
|
||||
#endif
|
||||
static s32 sIsDesegmented = false;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Init.s")
|
||||
u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) {
|
||||
EffectSsLightningInitParams* initParams = PARAMS;
|
||||
s32 i;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/func_8097A794.s")
|
||||
this->pos = initParams->pos;
|
||||
this->gfx = gEffLightningDL;
|
||||
this->life = initParams->life;
|
||||
this->draw = EffectSsLightning_Draw;
|
||||
this->update = EffectSsLightning_Update;
|
||||
this->rPrimColorR = initParams->primColor.r;
|
||||
this->rPrimColorG = initParams->primColor.g;
|
||||
this->rPrimColorB = initParams->primColor.b;
|
||||
this->rPrimColorA = initParams->primColor.a;
|
||||
this->rEnvColorR = initParams->envColor.r;
|
||||
this->rEnvColorG = initParams->envColor.g;
|
||||
this->rEnvColorB = initParams->envColor.b;
|
||||
this->rEnvColorA = initParams->envColor.a;
|
||||
this->rNumBolts = initParams->numBolts;
|
||||
this->rScale = initParams->scale;
|
||||
this->rYaw = initParams->yaw;
|
||||
this->rLifespan = initParams->life;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Draw.s")
|
||||
if (!sIsDesegmented) {
|
||||
for (i = 0; i < ARRAY_COUNT(sLightningTextures); i++) {
|
||||
sLightningTextures[i] = Lib_SegmentedToVirtual(sLightningTextures[i]);
|
||||
}
|
||||
sIsDesegmented = true;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Update.s")
|
||||
return 1;
|
||||
}
|
||||
|
||||
void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s32 yaw, EffectSs* this) {
|
||||
EffectSs newLightning;
|
||||
|
||||
EffectSS_Delete(&newLightning);
|
||||
newLightning = *this;
|
||||
newLightning.pos = *pos;
|
||||
newLightning.rNumBolts--;
|
||||
newLightning.rYaw = yaw;
|
||||
newLightning.life = newLightning.rLifespan;
|
||||
|
||||
EffectSS_Copy(globalCtx, &newLightning);
|
||||
}
|
||||
|
||||
void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) {
|
||||
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
|
||||
MtxF mfResult;
|
||||
MtxF mfTrans;
|
||||
MtxF mfScale;
|
||||
MtxF mfRot;
|
||||
MtxF mfTransBillboard;
|
||||
MtxF mfTransBillboardRot;
|
||||
Mtx* mtx;
|
||||
f32 yScale;
|
||||
s32 texIndex;
|
||||
f32 xzScale;
|
||||
|
||||
OPEN_DISPS(gfxCtx);
|
||||
|
||||
yScale = this->rScale * 0.01f;
|
||||
texIndex = this->rLifespan - this->life;
|
||||
|
||||
if (texIndex >= ARRAY_COUNT(sLightningTextures)) {
|
||||
texIndex = ARRAY_COUNT(sLightningTextures) - 1;
|
||||
}
|
||||
|
||||
SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z);
|
||||
xzScale = yScale * 0.6f;
|
||||
SkinMatrix_SetScale(&mfScale, xzScale, yScale, xzScale);
|
||||
SkinMatrix_SetRotateRPY(&mfRot, this->vec.x, this->vec.y, this->rYaw);
|
||||
SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTransBillboard);
|
||||
SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRot, &mfTransBillboardRot);
|
||||
SkinMatrix_MtxFMtxFMult(&mfTransBillboardRot, &mfScale, &mfResult);
|
||||
|
||||
gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult);
|
||||
|
||||
if (mtx != NULL) {
|
||||
gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
func_8012C9BC(gfxCtx);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x08, sLightningTextures[texIndex]);
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB,
|
||||
this->rPrimColorA);
|
||||
gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA);
|
||||
gSPDisplayList(POLY_XLU_DISP++, this->gfx);
|
||||
}
|
||||
|
||||
CLOSE_DISPS(gfxCtx);
|
||||
}
|
||||
|
||||
void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) {
|
||||
s32 pad;
|
||||
Vec3f pos;
|
||||
s32 yaw;
|
||||
f32 scale;
|
||||
s32 sign;
|
||||
|
||||
if ((this->rNumBolts != 0) && ((this->life + 1) == this->rLifespan)) {
|
||||
sign = (Rand_ZeroOne() < 0.5f) ? -1 : 1;
|
||||
yaw = this->rYaw + sign * ((s32)((Rand_ZeroOne() * 3640.0f)) + 0xE38);
|
||||
scale = (this->rScale * 0.01f) * 80.0f;
|
||||
|
||||
pos.y = this->pos.y + (Math_SinS(this->rYaw - 0x4000) * scale);
|
||||
|
||||
scale = Math_CosS(this->rYaw - 0x4000) * scale;
|
||||
pos.x = this->pos.x - (Math_CosS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale);
|
||||
pos.z = this->pos.z + (Math_SinS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale);
|
||||
|
||||
EffectSsLightning_NewLightning(globalCtx, &pos, yaw, this);
|
||||
|
||||
if (Rand_ZeroOne() < 0.1f) {
|
||||
EffectSsLightning_NewLightning(globalCtx, &pos, (this->rYaw * 2) - yaw, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8165,7 +8165,7 @@
|
||||
0x8097A548:("EffectSsGFire_Draw",),
|
||||
0x8097A5F0:("EffectSsGFire_Update",),
|
||||
0x8097A680:("EffectSsLightning_Init",),
|
||||
0x8097A794:("func_8097A794",),
|
||||
0x8097A794:("EffectSsLightning_NewLightning",),
|
||||
0x8097A838:("EffectSsLightning_Draw",),
|
||||
0x8097AA98:("EffectSsLightning_Update",),
|
||||
0x8097AD60:("EffectSsDtBubble_Init",),
|
||||
|
Loading…
Reference in New Issue
Block a user