mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-08-13 17:03:47 -04:00
a5df9dddf0
* First batch some overlay
* Almost all overlay
* effect & gamestate
* kaleido stuffs
* more overlay
* more left over from code folder
* remaining hardcoded line and file
* Open & Close _DISP __FILE__ & __LINE__ clean up
* Some if (1) {} remove
* LOG_xxxx __FILE__ , __LINE__ cleaned
* ASSERT macro __FILE__ __LINE__
* mtx without line/file in functions
* " if (1) {} " & "if (0) {}" and tab/white place
* LogUtils as macro
* GameState_, GameAlloc_, SystemArena_ & ZeldaArena_
* Revert "GameState_, GameAlloc_, SystemArena_ & ZeldaArena_"
This reverts commit 0d85caaf7e
.
* Like last commit but as macro
* Fix matrix not using macros
* use function not macro
* DebugArena_* functions
GameAlloc_MallocDebug
BgCheck_PosErrorCheck as macros
removed issues with ; in macro file
108 lines
4.2 KiB
C
108 lines
4.2 KiB
C
/*
|
|
* File: z_eff_ss_dt_bubble.c
|
|
* Overlay: ovl_Effect_Ss_Dt_Bubble
|
|
* Description: Bubbles (a random mix of translucent and opaque)
|
|
*/
|
|
|
|
#include "z_eff_ss_dt_bubble.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 rRandXZ regs[8]
|
|
#define rScale regs[9]
|
|
#define rLifespan regs[10]
|
|
|
|
u32 EffectSsDtBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx);
|
|
void EffectSsDtBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this);
|
|
void EffectSsDtBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this);
|
|
|
|
static Color_RGBA8 sPrimColors[] = { { 255, 255, 100, 255 }, { 150, 255, 255, 255 }, { 100, 255, 255, 255 } };
|
|
static Color_RGBA8 sEnvColors[] = { { 170, 0, 0, 255 }, { 0, 100, 0, 255 }, { 0, 0, 255, 255 } };
|
|
|
|
EffectSsInit Effect_Ss_Dt_Bubble_InitVars = {
|
|
EFFECT_SS_DT_BUBBLE,
|
|
EffectSsDtBubble_Init,
|
|
};
|
|
|
|
u32 EffectSsDtBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) {
|
|
EffectSsDtBubbleInitParams* initParams = (EffectSsDtBubbleInitParams*)initParamsx;
|
|
|
|
//! @bug Rand_ZeroOne in the macro means a random number is generated for both parts of the macro.
|
|
// In the base game this works out because both addresses are segment 4, but it may break if
|
|
// the addresses were changed to refer to different segments
|
|
this->gfx = SEGMENTED_TO_VIRTUAL(Rand_ZeroOne() < 0.5f ? gEffBubble1Tex : gEffBubble2Tex);
|
|
this->pos = initParams->pos;
|
|
this->velocity = initParams->velocity;
|
|
this->accel = initParams->accel;
|
|
this->life = initParams->life;
|
|
|
|
if (!initParams->customColor) {
|
|
this->rPrimColorR = sPrimColors[initParams->colorProfile].r;
|
|
this->rPrimColorG = sPrimColors[initParams->colorProfile].g;
|
|
this->rPrimColorB = sPrimColors[initParams->colorProfile].b;
|
|
this->rPrimColorA = sPrimColors[initParams->colorProfile].a;
|
|
this->rEnvColorR = sEnvColors[initParams->colorProfile].r;
|
|
this->rEnvColorG = sEnvColors[initParams->colorProfile].g;
|
|
this->rEnvColorB = sEnvColors[initParams->colorProfile].b;
|
|
this->rEnvColorA = sEnvColors[initParams->colorProfile].a;
|
|
} else {
|
|
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->rRandXZ = initParams->randXZ;
|
|
this->rScale = initParams->scale;
|
|
this->rLifespan = initParams->life;
|
|
this->draw = EffectSsDtBubble_Draw;
|
|
this->update = EffectSsDtBubble_Update;
|
|
|
|
return 1;
|
|
}
|
|
|
|
void EffectSsDtBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) {
|
|
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
|
|
f32 scale;
|
|
|
|
OPEN_DISPS(gfxCtx);
|
|
|
|
scale = this->rScale * 0.004f;
|
|
Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW);
|
|
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
|
|
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx),
|
|
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
|
func_80093C14(gfxCtx);
|
|
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB,
|
|
(this->rPrimColorA * this->life) / this->rLifespan);
|
|
gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB,
|
|
(this->rEnvColorA * this->life) / this->rLifespan);
|
|
gSPSegment(POLY_XLU_DISP++, 0x08, this->gfx);
|
|
gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffBubbleDL));
|
|
|
|
CLOSE_DISPS(gfxCtx);
|
|
}
|
|
|
|
void EffectSsDtBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) {
|
|
f32 rand;
|
|
|
|
if (this->rRandXZ == 1) {
|
|
rand = Rand_ZeroOne();
|
|
this->pos.x += (rand * 2.0f) - 1.0f;
|
|
|
|
rand = Rand_ZeroOne();
|
|
this->pos.z += (rand * 2.0f) - 1.0f;
|
|
}
|
|
}
|