2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-04-30 18:41:09 +00:00
|
|
|
|
|
|
|
// unused
|
2022-02-20 13:31:31 +00:00
|
|
|
Gfx sCircleEmptyDList[] = {
|
2020-04-30 18:41:09 +00:00
|
|
|
gsSPEndDisplayList(),
|
|
|
|
};
|
|
|
|
|
2021-11-09 01:51:45 +00:00
|
|
|
#include "code/fbdemo_circle/z_fbdemo_circle.c"
|
2020-04-30 18:41:09 +00:00
|
|
|
|
|
|
|
Gfx sCircleDList[] = {
|
|
|
|
gsDPPipeSync(),
|
|
|
|
gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN |
|
|
|
|
G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH),
|
|
|
|
gsSPSetGeometryMode(G_SHADE | G_SHADING_SMOOTH),
|
|
|
|
gsDPSetOtherMode(G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
|
|
|
|
G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
|
|
|
|
G_AC_NONE | G_ZS_PIXEL | G_RM_XLU_SURF | G_RM_XLU_SURF2),
|
|
|
|
gsDPSetCombineMode(G_CC_BLENDPEDECALA, G_CC_BLENDPEDECALA),
|
|
|
|
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
|
|
|
|
gsDPLoadTextureBlock(0x08000000, G_IM_FMT_I, G_IM_SIZ_8b, 16, 64, 0, G_TX_NOMIRROR | G_TX_WRAP,
|
|
|
|
G_TX_NOMIRROR | G_TX_CLAMP, 4, 6, G_TX_NOLOD, G_TX_NOLOD),
|
|
|
|
gsSPDisplayList(0x09000000),
|
2021-11-09 01:51:45 +00:00
|
|
|
gsSPVertex(sCircleWipeVtx, 32, 0),
|
2020-04-30 18:41:09 +00:00
|
|
|
gsSP2Triangles(0, 1, 2, 0, 1, 3, 4, 0),
|
|
|
|
gsSP2Triangles(3, 5, 6, 0, 5, 7, 8, 0),
|
|
|
|
gsSP2Triangles(7, 9, 10, 0, 9, 11, 12, 0),
|
|
|
|
gsSP2Triangles(11, 13, 14, 0, 13, 15, 16, 0),
|
|
|
|
gsSP2Triangles(15, 17, 18, 0, 17, 19, 20, 0),
|
|
|
|
gsSP2Triangles(19, 21, 22, 0, 21, 23, 24, 0),
|
|
|
|
gsSP2Triangles(23, 25, 26, 0, 25, 27, 28, 0),
|
|
|
|
gsSP1Triangle(27, 29, 30, 0),
|
2021-11-09 01:51:45 +00:00
|
|
|
gsSPVertex(&sCircleWipeVtx[31], 3, 0),
|
2020-04-30 18:41:09 +00:00
|
|
|
gsSP1Triangle(0, 1, 2, 0),
|
|
|
|
gsSPEndDisplayList(),
|
|
|
|
};
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void TransitionCircle_Start(void* thisx) {
|
2021-12-04 16:33:00 +00:00
|
|
|
TransitionCircle* this = (TransitionCircle*)thisx;
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2022-04-27 20:00:25 +00:00
|
|
|
this->isDone = false;
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2022-04-27 20:00:25 +00:00
|
|
|
switch (this->appearanceType) {
|
|
|
|
case TCA_WAVE:
|
|
|
|
this->texture = sTransCircleWaveTex;
|
2020-04-30 18:41:09 +00:00
|
|
|
break;
|
2022-04-27 20:00:25 +00:00
|
|
|
case TCA_RIPPLE:
|
|
|
|
this->texture = sTransCircleRippleTex;
|
2020-04-30 18:41:09 +00:00
|
|
|
break;
|
2022-04-27 20:00:25 +00:00
|
|
|
case TCA_STARBURST:
|
|
|
|
this->texture = sTransCircleStarburstTex;
|
2020-04-30 18:41:09 +00:00
|
|
|
break;
|
|
|
|
default:
|
2022-04-27 20:00:25 +00:00
|
|
|
this->texture = sTransCircleNormalTex;
|
2020-04-30 18:41:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-04-27 20:00:25 +00:00
|
|
|
if (this->speedType == TCS_FAST) {
|
|
|
|
this->speed = 20;
|
2020-04-30 18:41:09 +00:00
|
|
|
} else {
|
2022-04-27 20:00:25 +00:00
|
|
|
this->speed = 10;
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 20:00:25 +00:00
|
|
|
if (this->colorType == TCC_BLACK) {
|
2020-07-17 01:37:53 +00:00
|
|
|
this->color.rgba = RGBA8(0, 0, 0, 255);
|
2022-04-27 20:00:25 +00:00
|
|
|
} else if (this->colorType == TCC_WHITE) {
|
2020-07-17 01:37:53 +00:00
|
|
|
this->color.rgba = RGBA8(160, 160, 160, 255);
|
2022-04-27 20:00:25 +00:00
|
|
|
} else if (this->colorType == TCC_GRAY) {
|
2020-07-17 01:37:53 +00:00
|
|
|
this->color.r = 100;
|
|
|
|
this->color.g = 100;
|
|
|
|
this->color.b = 100;
|
|
|
|
this->color.a = 255;
|
2020-04-30 18:41:09 +00:00
|
|
|
} else {
|
2022-04-27 20:00:25 +00:00
|
|
|
this->speed = 40;
|
|
|
|
this->color.rgba = this->appearanceType == TCA_WAVE ? RGBA8(0, 0, 0, 255) : RGBA8(160, 160, 160, 255);
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
2022-04-27 20:00:25 +00:00
|
|
|
if (this->direction != 0) {
|
2020-04-30 18:41:09 +00:00
|
|
|
this->texY = 0;
|
2022-04-27 20:00:25 +00:00
|
|
|
if (this->colorType == TCC_SPECIAL) {
|
2020-04-30 18:41:09 +00:00
|
|
|
this->texY = 0xFA;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this->texY = 0x1F4;
|
2022-04-27 20:00:25 +00:00
|
|
|
if (this->appearanceType == TCA_RIPPLE) {
|
2022-04-23 14:55:18 +00:00
|
|
|
Audio_PlaySoundGeneral(NA_SE_OC_SECRET_WARP_OUT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
|
|
|
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
guPerspective(&this->projection, &this->normal, 60.0f, (4.0f / 3.0f), 10.0f, 12800.0f, 1.0f);
|
|
|
|
guLookAt(&this->lookAt, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void* TransitionCircle_Init(void* thisx) {
|
2021-12-04 16:33:00 +00:00
|
|
|
TransitionCircle* this = (TransitionCircle*)thisx;
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2020-04-30 18:41:09 +00:00
|
|
|
bzero(this, sizeof(*this));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void TransitionCircle_Destroy(void* thisx) {
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void TransitionCircle_Update(void* thisx, s32 updateRate) {
|
2021-12-04 16:33:00 +00:00
|
|
|
TransitionCircle* this = (TransitionCircle*)thisx;
|
2020-04-30 18:41:09 +00:00
|
|
|
s32 temp_t2;
|
|
|
|
s32 temp_t3;
|
|
|
|
|
2022-04-27 20:00:25 +00:00
|
|
|
if (this->direction != 0) {
|
2020-04-30 18:41:09 +00:00
|
|
|
if (this->texY == 0) {
|
2022-04-27 20:00:25 +00:00
|
|
|
if (this->appearanceType == TCA_RIPPLE) {
|
2022-04-23 14:55:18 +00:00
|
|
|
Audio_PlaySoundGeneral(NA_SE_OC_SECRET_WARP_IN, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
|
|
|
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-27 20:00:25 +00:00
|
|
|
this->texY += this->speed * 3 / updateRate;
|
2020-04-30 18:41:09 +00:00
|
|
|
if (this->texY >= 0x1F4) {
|
|
|
|
this->texY = 0x1F4;
|
2022-04-27 20:00:25 +00:00
|
|
|
this->isDone = true;
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-04-27 20:00:25 +00:00
|
|
|
this->texY -= this->speed * 3 / updateRate;
|
|
|
|
if (this->colorType != TCC_SPECIAL) {
|
2020-04-30 18:41:09 +00:00
|
|
|
if (this->texY <= 0) {
|
|
|
|
this->texY = 0;
|
2022-04-27 20:00:25 +00:00
|
|
|
this->isDone = true;
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this->texY < 0xFB) {
|
|
|
|
this->texY = 0xFA;
|
2022-04-27 20:00:25 +00:00
|
|
|
this->isDone = true;
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void TransitionCircle_Draw(void* thisx, Gfx** gfxP) {
|
2020-04-30 18:41:09 +00:00
|
|
|
Gfx* gfx = *gfxP;
|
2021-02-14 00:49:40 +00:00
|
|
|
Mtx* modelView;
|
2021-12-04 16:33:00 +00:00
|
|
|
TransitionCircle* this = (TransitionCircle*)thisx;
|
2020-04-30 18:41:09 +00:00
|
|
|
Gfx* texScroll;
|
|
|
|
// These variables are a best guess based on the other transition types.
|
|
|
|
f32 tPos = 0.0f;
|
|
|
|
f32 rot = 0.0f;
|
|
|
|
f32 scale = 14.8f;
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
modelView = this->modelView[this->frame];
|
|
|
|
|
2020-04-30 18:41:09 +00:00
|
|
|
this->frame ^= 1;
|
|
|
|
gDPPipeSync(gfx++);
|
|
|
|
texScroll = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0x10, 0x40);
|
|
|
|
gSPSegment(gfx++, 9, texScroll);
|
|
|
|
gSPSegment(gfx++, 8, this->texture);
|
|
|
|
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba);
|
|
|
|
gDPSetColor(gfx++, G_SETENVCOLOR, this->color.rgba);
|
|
|
|
gSPMatrix(gfx++, &this->projection, G_MTX_PROJECTION | G_MTX_LOAD);
|
|
|
|
gSPPerspNormalize(gfx++, this->normal);
|
|
|
|
gSPMatrix(gfx++, &this->lookAt, G_MTX_PROJECTION | G_MTX_NOPUSH | G_MTX_MUL);
|
|
|
|
|
|
|
|
if (scale != 1.0f) {
|
|
|
|
guScale(&modelView[0], scale, scale, 1.0f);
|
|
|
|
gSPMatrix(gfx++, &modelView[0], G_MTX_LOAD);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rot != 0.0f) {
|
|
|
|
guRotate(&modelView[1], rot, 0.0f, 0.0f, 1.0f);
|
|
|
|
gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((tPos != 0.0f) || (tPos != 0.0f)) {
|
|
|
|
guTranslate(&modelView[2], tPos, tPos, 0.0f);
|
|
|
|
gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
|
|
|
|
}
|
|
|
|
gSPDisplayList(gfx++, sCircleDList);
|
|
|
|
gDPPipeSync(gfx++);
|
|
|
|
*gfxP = gfx;
|
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
s32 TransitionCircle_IsDone(void* thisx) {
|
2021-12-04 16:33:00 +00:00
|
|
|
TransitionCircle* this = (TransitionCircle*)thisx;
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2020-04-30 18:41:09 +00:00
|
|
|
return this->isDone;
|
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void TransitionCircle_SetType(void* thisx, s32 type) {
|
2021-12-04 16:33:00 +00:00
|
|
|
TransitionCircle* this = (TransitionCircle*)thisx;
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2022-04-27 20:00:25 +00:00
|
|
|
if (type & TC_SET_PARAMS) {
|
|
|
|
// SetType is called twice for circles, the actual direction value will be set on the second call.
|
|
|
|
// The direction set here will be overwritten on that second call.
|
|
|
|
this->direction = (type >> 5) & 0x1;
|
|
|
|
|
|
|
|
this->colorType = (type >> 3) & 0x3;
|
|
|
|
this->speedType = type & 0x1;
|
|
|
|
this->appearanceType = (type >> 1) & 0x3;
|
2020-04-30 18:41:09 +00:00
|
|
|
} else if (type == 1) {
|
2022-04-27 20:00:25 +00:00
|
|
|
this->direction = 1;
|
2020-04-30 18:41:09 +00:00
|
|
|
} else {
|
2022-04-27 20:00:25 +00:00
|
|
|
this->direction = 0;
|
2020-04-30 18:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void TransitionCircle_SetColor(void* thisx, u32 color) {
|
2021-12-04 16:33:00 +00:00
|
|
|
TransitionCircle* this = (TransitionCircle*)thisx;
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2020-04-30 18:41:09 +00:00
|
|
|
this->color.rgba = color;
|
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void TransitionCircle_SetEnvColor(void* thisx, u32 envColor) {
|
2021-12-04 16:33:00 +00:00
|
|
|
TransitionCircle* this = (TransitionCircle*)thisx;
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2020-04-30 18:41:09 +00:00
|
|
|
this->envColor.rgba = envColor;
|
|
|
|
}
|