1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-25 22:26:12 +00:00

TransitionFade docs and clean up other transitions (#1459)

* TransitionFade docs

* PR suggestions

* Fix

* Fill

* Other transitions + enums

* Prefix transition assests with trans

* Fix end_title

* format

* OutNames

* nitpicks PR

* cleaner
This commit is contained in:
Derek Hensley 2022-12-23 18:46:56 -08:00 committed by GitHub
parent 1c6878b070
commit 4a9873775c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 186 additions and 146 deletions

View file

@ -1,13 +1,13 @@
<Root>
<File Name="code" OutName="z_fbdemo_circle" RangeStart="0x10ED48" RangeEnd="0x10FF68">
<Texture Name="sTransCircleNormalTex" Format="i8" Width="16" Height="64" Offset="0x10ED48"/>
<Texture Name="sTransCircleWaveTex" Format="i8" Width="16" Height="64" Offset="0x10F148"/>
<Texture Name="sTransCircleRippleTex" Format="i8" Width="16" Height="64" Offset="0x10F548"/>
<Texture Name="sTransCircleStarburstTex" Format="i8" Width="16" Height="64" Offset="0x10F948"/>
<Array Name="sCircleWipeVtx" Count="34" Offset="0x10FD48">
<Texture Name="sTransCircleNormalTex" OutName="trans_circle_normal" Format="i8" Width="16" Height="64" Offset="0x10ED48"/>
<Texture Name="sTransCircleWaveTex" OutName="trans_circle_wave" Format="i8" Width="16" Height="64" Offset="0x10F148"/>
<Texture Name="sTransCircleRippleTex" OutName="trans_circle_ripple" Format="i8" Width="16" Height="64" Offset="0x10F548"/>
<Texture Name="sTransCircleStarburstTex" OutName="trans_circle_starburst" Format="i8" Width="16" Height="64" Offset="0x10F948"/>
<Array Name="sTransCircleVtx" Count="34" Offset="0x10FD48">
<Vtx/>
</Array>
<!-- ZAPD isn't finding symbols correctly, instead finding them much later in `code`-->
<!--<DList Name="sCircleWipeDL" Offset="0x10FF68"/>-->
<!--<DList Name="sTransCircleDL" Offset="0x10FF68"/>-->
</File>
</Root>

View file

@ -1,7 +1,7 @@
<Root>
<File Name="code" OutName="z_fbdemo_triforce" RangeStart="0x10E1D0" RangeEnd="0x10E2A0">
<DList Name="sTriforceWipeDL" Offset="0x10E1D0"/>
<Array Name="sTriforceWipeVtx" Count="10" Offset="0x10E200">
<DList Name="sTransTriforceDL" Offset="0x10E1D0"/>
<Array Name="sTransTriforceVtx" Count="10" Offset="0x10E200">
<Vtx/>
</Array>
</File>

View file

@ -1,10 +1,10 @@
<Root>
<!-- ZAPD isn't finding sWipe1Vtx and sWipe1Tex properly for sWipe1DL, instead finding symbols much later in `code`-->
<File Name="code" OutName="z_fbdemo_wipe1" RangeStart="0x10E2A0" RangeEnd="0x10EC30" Segment="0">
<Array Name="sWipe1Vtx" Count="25" Offset="0x10E2A0">
<File Name="code" OutName="z_fbdemo_wipe1" RangeStart="0x10E2A0" RangeEnd="0x10EC30">
<Array Name="sTransWipeVtx" Count="25" Offset="0x10E2A0">
<Vtx/>
</Array>
<Texture Name="sWipe1Tex" Format="i4" Width="64" Height="64" Offset="0x10E430"/>
<!-- <DList Name="sWipe1DL" Offset="0x10EC30"/>-->
<Texture Name="sTransWipeTex" OutName="trans_wipe" Format="i4" Width="64" Height="64" Offset="0x10E430"/>
<!-- ZAPD isn't finding symbols correctly, instead finding them much later in `code`-->
<!-- <DList Name="sTransWipeDL" Offset="0x10EC30"/> -->
</File>
</Root>

View file

@ -1239,7 +1239,7 @@ void TransitionCircle_Draw(void* thisx, Gfx** gfxP);
s32 TransitionCircle_IsDone(void* thisx);
void TransitionCircle_SetType(void* thisx, s32 type);
void TransitionCircle_SetColor(void* thisx, u32 color);
void TransitionCircle_SetUnkColor(void* thisx, u32 unkColor);
void TransitionCircle_SetUnkColor(void* thisx, u32 color);
void TransitionFade_Start(void* thisx);
void* TransitionFade_Init(void* thisx);
void TransitionFade_Destroy(void* thisx);

View file

@ -154,6 +154,7 @@
#define R_TEXTBOX_TEXHEIGHT_TARGET XREG(77)
#define R_ENV_LIGHT1_DIR(i) cREG(3 + (i))
#define R_ENV_LIGHT2_DIR(i) cREG(6 + (i))
#define R_TRANS_FADE_FLASH_ALPHA_STEP iREG(50) // Set to a negative number to start the flash
#define R_ROOM_CULL_DEBUG_MODE iREG(86)
#define R_ROOM_CULL_NUM_ENTRIES iREG(87)
#define R_ROOM_CULL_USED_ENTRIES iREG(88)

View file

@ -1176,7 +1176,7 @@ typedef struct PlayState {
/* 0x121C8 */ TransitionContext transitionCtx;
/* 0x12418 */ char unk_12418[0x3];
/* 0x1241B */ u8 transitionMode; // "fbdemo_wipe_modem"
/* 0x1241C */ TransitionFade transitionFade;
/* 0x1241C */ TransitionFade transitionFadeFlash; // Transition fade instance which flashes screen, see R_TRANS_FADE_FLASH_ALPHA_STEP
/* 0x12428 */ char unk_12428[0x3];
/* 0x1242B */ u8 viewpoint; // toggleable camera setting by shops or player. Is also equal to the bgCamIndex + 1
/* 0x1242C */ SceneTableEntry* loadedScene;

View file

@ -23,9 +23,14 @@ typedef struct {
/* 0xDC */ u16* zBuffer;
} TransitionUnk; // size = 0xE0
typedef enum {
/* 1 */ TRANS_INSTANCE_TYPE_FILL_OUT = 1,
/* 2 */ TRANS_INSTANCE_TYPE_FILL_IN
} TransitionInstanceType;
typedef struct {
/* 0x000 */ Color_RGBA8_u32 color;
/* 0x004 */ Color_RGBA8_u32 envColor;
/* 0x004 */ Color_RGBA8_u32 unkColor;
/* 0x008 */ u8 direction;
/* 0x009 */ u8 frame;
/* 0x00A */ u8 isDone;
@ -37,12 +42,14 @@ typedef struct {
/* 0x098 */ Mtx modelView[2][3];
} TransitionWipe; // size = 0x218
#define TRANS_INSTANCE_TYPE_FADE_FLASH 3
typedef struct {
/* 0x000 */ u8 fadeType;
/* 0x000 */ u8 type;
/* 0x001 */ u8 isDone;
/* 0x002 */ u8 fadeDirection;
/* 0x004 */ Color_RGBA8_u32 fadeColor;
/* 0x008 */ u16 fadeTimer;
/* 0x002 */ u8 direction;
/* 0x004 */ Color_RGBA8_u32 color;
/* 0x008 */ u16 timer;
} TransitionFade; // size = 0xC
typedef struct {
@ -69,7 +76,7 @@ typedef struct {
/* 0x004 */ f32 transPos;
/* 0x008 */ f32 step;
/* 0x00C */ s32 state;
/* 0x010 */ s32 fadeDirection;
/* 0x010 */ s32 type;
/* 0x018 */ Mtx projection;
/* 0x058 */ s32 frame;
/* 0x060 */ Mtx modelView[2][3];

View file

@ -1,13 +1,18 @@
#include "global.h"
typedef enum {
/* 0 */ TRANS_CIRCLE_DIR_IN,
/* 1 */ TRANS_CIRCLE_DIR_OUT
} TransitionCircleDirection;
// unused
Gfx sCircleEmptyDList[] = {
Gfx sTransCircleEmptyDL[] = {
gsSPEndDisplayList(),
};
#include "assets/code/fbdemo_circle/z_fbdemo_circle.c"
Gfx sCircleDList[] = {
Gfx sTransCircleDL[] = {
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),
@ -20,7 +25,7 @@ Gfx sCircleDList[] = {
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),
gsSPVertex(sCircleWipeVtx, 32, 0),
gsSPVertex(sTransCircleVtx, 32, 0),
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),
@ -29,7 +34,7 @@ Gfx sCircleDList[] = {
gsSP2Triangles(19, 21, 22, 0, 21, 23, 24, 0),
gsSP2Triangles(23, 25, 26, 0, 25, 27, 28, 0),
gsSP1Triangle(27, 29, 30, 0),
gsSPVertex(&sCircleWipeVtx[31], 3, 0),
gsSPVertex(&sTransCircleVtx[31], 3, 0),
gsSP1Triangle(0, 1, 2, 0),
gsSPEndDisplayList(),
};
@ -43,12 +48,15 @@ void TransitionCircle_Start(void* thisx) {
case TCA_WAVE:
this->texture = sTransCircleWaveTex;
break;
case TCA_RIPPLE:
this->texture = sTransCircleRippleTex;
break;
case TCA_STARBURST:
this->texture = sTransCircleStarburstTex;
break;
default:
this->texture = sTransCircleNormalTex;
break;
@ -71,20 +79,22 @@ void TransitionCircle_Start(void* thisx) {
this->color.a = 255;
} else {
this->speed = 40;
this->color.rgba = this->appearanceType == TCA_WAVE ? RGBA8(0, 0, 0, 255) : RGBA8(160, 160, 160, 255);
this->color.rgba = (this->appearanceType == TCA_WAVE) ? RGBA8(0, 0, 0, 255) : RGBA8(160, 160, 160, 255);
}
if (this->direction != 0) {
this->texY = (s32)(0.0 * (1 << 2));
if (this->direction != TRANS_CIRCLE_DIR_IN) {
this->texY = (s32)(0.0f * (1 << 2));
if (this->colorType == TCC_SPECIAL) {
this->texY = (s32)(62.5 * (1 << 2));
this->texY = (s32)(62.5f * (1 << 2));
}
} else {
this->texY = (s32)(125.0 * (1 << 2));
this->texY = (s32)(125.0f * (1 << 2));
if (this->appearanceType == TCA_RIPPLE) {
Audio_PlaySfxGeneral(NA_SE_OC_SECRET_WARP_OUT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
}
}
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);
}
@ -92,7 +102,7 @@ void TransitionCircle_Start(void* thisx) {
void* TransitionCircle_Init(void* thisx) {
TransitionCircle* this = (TransitionCircle*)thisx;
bzero(this, sizeof(*this));
bzero(this, sizeof(TransitionCircle));
return this;
}
@ -101,10 +111,8 @@ void TransitionCircle_Destroy(void* thisx) {
void TransitionCircle_Update(void* thisx, s32 updateRate) {
TransitionCircle* this = (TransitionCircle*)thisx;
s32 temp_t2;
s32 temp_t3;
if (this->direction != 0) {
if (this->direction != TRANS_CIRCLE_DIR_IN) {
if (this->texY == 0) {
if (this->appearanceType == TCA_RIPPLE) {
Audio_PlaySfxGeneral(NA_SE_OC_SECRET_WARP_IN, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
@ -112,20 +120,20 @@ void TransitionCircle_Update(void* thisx, s32 updateRate) {
}
}
this->texY += this->speed * 3 / updateRate;
if (this->texY >= (s32)(125.0 * (1 << 2))) {
this->texY = (s32)(125.0 * (1 << 2));
if (this->texY >= (s32)(125.0f * (1 << 2))) {
this->texY = (s32)(125.0f * (1 << 2));
this->isDone = true;
}
} else {
this->texY -= this->speed * 3 / updateRate;
if (this->colorType != TCC_SPECIAL) {
if (this->texY <= (s32)(0.0 * (1 << 2))) {
this->texY = (s32)(0.0 * (1 << 2));
if (this->texY <= (s32)(0.0f * (1 << 2))) {
this->texY = (s32)(0.0f * (1 << 2));
this->isDone = true;
}
} else {
if (this->texY <= (s32)(62.5 * (1 << 2))) {
this->texY = (s32)(62.5 * (1 << 2));
if (this->texY <= (s32)(62.5f * (1 << 2))) {
this->texY = (s32)(62.5f * (1 << 2));
this->isDone = true;
}
}
@ -169,7 +177,7 @@ void TransitionCircle_Draw(void* thisx, Gfx** gfxP) {
guTranslate(&modelView[2], tPos, tPos, 0.0f);
gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
}
gSPDisplayList(gfx++, sCircleDList);
gSPDisplayList(gfx++, sTransCircleDL);
gDPPipeSync(gfx++);
*gfxP = gfx;
}
@ -186,15 +194,15 @@ void TransitionCircle_SetType(void* thisx, s32 type) {
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->direction = (type >> 5) & 1;
this->colorType = (type >> 3) & 0x3;
this->speedType = type & 0x1;
this->appearanceType = (type >> 1) & 0x3;
} else if (type == 1) {
this->direction = 1;
this->colorType = (type >> 3) & 3;
this->speedType = type & 1;
this->appearanceType = (type >> 1) & 3;
} else if (type == TRANS_INSTANCE_TYPE_FILL_OUT) {
this->direction = TRANS_CIRCLE_DIR_OUT;
} else {
this->direction = 0;
this->direction = TRANS_CIRCLE_DIR_IN;
}
}
@ -204,8 +212,8 @@ void TransitionCircle_SetColor(void* thisx, u32 color) {
this->color.rgba = color;
}
void TransitionCircle_SetUnkColor(void* thisx, u32 unkColor) {
void TransitionCircle_SetUnkColor(void* thisx, u32 color) {
TransitionCircle* this = (TransitionCircle*)thisx;
this->unkColor.rgba = unkColor;
this->unkColor.rgba = color;
}

View file

@ -1,7 +1,18 @@
#include "global.h"
#include "terminal.h"
static Gfx sRCPSetupFade[] = {
typedef enum {
/* 0 */ TRANS_FADE_DIR_IN,
/* 1 */ TRANS_FADE_DIR_OUT
} TransitionFadeDirection;
typedef enum {
/* 0 */ TRANS_FADE_TYPE_NONE,
/* 1 */ TRANS_FADE_TYPE_ONE_WAY,
/* 2 */ TRANS_FADE_TYPE_FLASH
} TransitionFadeType;
static Gfx sTransFadeSetupDL[] = {
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),
@ -15,15 +26,17 @@ static Gfx sRCPSetupFade[] = {
void TransitionFade_Start(void* thisx) {
TransitionFade* this = (TransitionFade*)thisx;
switch (this->fadeType) {
case 0:
switch (this->type) {
case TRANS_FADE_TYPE_NONE:
break;
case 1:
this->fadeTimer = 0;
this->fadeColor.a = this->fadeDirection != 0 ? 0xFF : 0;
case TRANS_FADE_TYPE_ONE_WAY:
this->timer = 0;
this->color.a = (this->direction != TRANS_FADE_DIR_IN) ? 255 : 0;
break;
case 2:
this->fadeColor.a = 0;
case TRANS_FADE_TYPE_FLASH:
this->color.a = 0;
break;
}
this->isDone = false;
@ -32,7 +45,7 @@ void TransitionFade_Start(void* thisx) {
void* TransitionFade_Init(void* thisx) {
TransitionFade* this = (TransitionFade*)thisx;
bzero(this, sizeof(*this));
bzero(this, sizeof(TransitionFade));
return this;
}
@ -44,39 +57,41 @@ void TransitionFade_Update(void* thisx, s32 updateRate) {
s16 newAlpha;
TransitionFade* this = (TransitionFade*)thisx;
switch (this->fadeType) {
case 0:
switch (this->type) {
case TRANS_FADE_TYPE_NONE:
break;
case 1:
this->fadeTimer += updateRate;
if (this->fadeTimer >= gSaveContext.transFadeDuration) {
this->fadeTimer = gSaveContext.transFadeDuration;
case TRANS_FADE_TYPE_ONE_WAY:
this->timer += updateRate;
if (this->timer >= gSaveContext.transFadeDuration) {
this->timer = gSaveContext.transFadeDuration;
this->isDone = true;
}
if (!gSaveContext.transFadeDuration) {
if ((u32)gSaveContext.transFadeDuration == 0) {
// "Divide by 0! Zero is included in ZCommonGet fade_speed"
osSyncPrintf(VT_COL(RED, WHITE) "0除算! ZCommonGet fade_speed に0がはいってる" VT_RST);
}
alpha = (255.0f * this->fadeTimer) / ((void)0, gSaveContext.transFadeDuration);
this->fadeColor.a = (this->fadeDirection != 0) ? 255 - alpha : alpha;
alpha = (255.0f * this->timer) / ((void)0, gSaveContext.transFadeDuration);
this->color.a = (this->direction != TRANS_FADE_DIR_IN) ? 255 - alpha : alpha;
break;
case 2:
newAlpha = this->fadeColor.a;
if (iREG(50) != 0) {
if (iREG(50) < 0) {
case TRANS_FADE_TYPE_FLASH:
newAlpha = this->color.a;
if (R_TRANS_FADE_FLASH_ALPHA_STEP != 0) {
if (R_TRANS_FADE_FLASH_ALPHA_STEP < 0) {
if (Math_StepToS(&newAlpha, 255, 255)) {
iREG(50) = 150;
R_TRANS_FADE_FLASH_ALPHA_STEP = 150;
}
} else {
Math_StepToS(&iREG(50), 20, 60);
if (Math_StepToS(&newAlpha, 0, iREG(50))) {
iREG(50) = 0;
Math_StepToS(&R_TRANS_FADE_FLASH_ALPHA_STEP, 20, 60);
if (Math_StepToS(&newAlpha, 0, R_TRANS_FADE_FLASH_ALPHA_STEP)) {
R_TRANS_FADE_FLASH_ALPHA_STEP = 0;
this->isDone = true;
}
}
}
this->fadeColor.a = newAlpha;
this->color.a = newAlpha;
break;
}
}
@ -84,11 +99,11 @@ void TransitionFade_Update(void* thisx, s32 updateRate) {
void TransitionFade_Draw(void* thisx, Gfx** gfxP) {
TransitionFade* this = (TransitionFade*)thisx;
Gfx* gfx;
Color_RGBA8_u32* color = &this->fadeColor;
Color_RGBA8_u32* color = &this->color;
if (color->a > 0) {
gfx = *gfxP;
gSPDisplayList(gfx++, sRCPSetupFade);
gSPDisplayList(gfx++, sTransFadeSetupDL);
gDPSetPrimColor(gfx++, 0, 0, color->r, color->g, color->b, color->a);
gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, gScreenHeight - 1);
gDPPipeSync(gfx++);
@ -105,21 +120,21 @@ s32 TransitionFade_IsDone(void* thisx) {
void TransitionFade_SetColor(void* thisx, u32 color) {
TransitionFade* this = (TransitionFade*)thisx;
this->fadeColor.rgba = color;
this->color.rgba = color;
}
void TransitionFade_SetType(void* thisx, s32 type) {
TransitionFade* this = (TransitionFade*)thisx;
if (type == 1) {
this->fadeType = 1;
this->fadeDirection = 1;
} else if (type == 2) {
this->fadeType = 1;
this->fadeDirection = 0;
} else if (type == 3) {
this->fadeType = 2;
if (type == TRANS_INSTANCE_TYPE_FILL_OUT) {
this->type = TRANS_FADE_TYPE_ONE_WAY;
this->direction = TRANS_FADE_DIR_OUT;
} else if (type == TRANS_INSTANCE_TYPE_FILL_IN) {
this->type = TRANS_FADE_TYPE_ONE_WAY;
this->direction = TRANS_FADE_DIR_IN;
} else if (type == TRANS_INSTANCE_TYPE_FADE_FLASH) {
this->type = TRANS_FADE_TYPE_FLASH;
} else {
this->fadeType = 0;
this->type = TRANS_FADE_TYPE_NONE;
}
}

View file

@ -10,19 +10,23 @@ void TransitionTriforce_Start(void* thisx) {
case 2:
this->transPos = 1.0f;
return;
default:
this->transPos = 0.03f;
return;
}
this->transPos = 0.03f;
}
void* TransitionTriforce_Init(void* thisx) {
TransitionTriforce* this = (TransitionTriforce*)thisx;
bzero(this, sizeof(*this));
bzero(this, sizeof(TransitionTriforce));
guOrtho(&this->projection, -160.0f, 160.0f, -120.0f, 120.0f, -1000.0f, 1000.0f, 1.0f);
this->transPos = 1.0f;
this->state = 2;
this->step = 0.015f;
this->fadeDirection = 1;
this->type = TRANS_INSTANCE_TYPE_FILL_OUT;
return this;
}
@ -31,7 +35,6 @@ void TransitionTriforce_Destroy(void* thisx) {
void TransitionTriforce_Update(void* thisx, s32 updateRate) {
TransitionTriforce* this = (TransitionTriforce*)thisx;
f32 temp_f0;
s32 i;
for (i = updateRate; i > 0; i--) {
@ -56,7 +59,7 @@ void TransitionTriforce_SetColor(void* thisx, u32 color) {
void TransitionTriforce_SetType(void* thisx, s32 type) {
TransitionTriforce* this = (TransitionTriforce*)thisx;
this->fadeDirection = type;
this->type = type;
}
// unused
@ -82,21 +85,23 @@ void TransitionTriforce_Draw(void* thisx, Gfx** gfxP) {
guRotate(&modelView[1], rotation, 0.0f, 0.0f, 1.0f);
guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f);
gDPPipeSync(gfx++);
gSPDisplayList(gfx++, sTriforceWipeDL);
gSPDisplayList(gfx++, sTransTriforceDL);
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba);
gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
gSPMatrix(gfx++, &this->projection, G_MTX_LOAD | G_MTX_PROJECTION);
gSPMatrix(gfx++, &modelView[0], G_MTX_LOAD);
gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MODELVIEW | G_MTX_MUL);
gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MODELVIEW | G_MTX_MUL);
gSPVertex(gfx++, sTriforceWipeVtx, 10, 0);
gSPVertex(gfx++, sTransTriforceVtx, 10, 0);
if (!TransitionTriforce_IsDone(this)) {
switch (this->fadeDirection) {
case 1:
switch (this->type) {
case TRANS_INSTANCE_TYPE_FILL_OUT:
gSP2Triangles(gfx++, 0, 4, 5, 0, 4, 1, 3, 0);
gSP1Triangle(gfx++, 5, 3, 2, 0);
break;
case 2:
case TRANS_INSTANCE_TYPE_FILL_IN:
gSP2Triangles(gfx++, 3, 4, 5, 0, 0, 2, 6, 0);
gSP2Triangles(gfx++, 0, 6, 7, 0, 1, 0, 7, 0);
gSP2Triangles(gfx++, 1, 7, 8, 0, 1, 8, 9, 0);
@ -104,10 +109,11 @@ void TransitionTriforce_Draw(void* thisx, Gfx** gfxP) {
break;
}
} else {
switch (this->fadeDirection) {
case 1:
switch (this->type) {
case TRANS_INSTANCE_TYPE_FILL_OUT:
break;
case 2:
case TRANS_INSTANCE_TYPE_FILL_IN:
gSP1Quadrangle(gfx++, 6, 7, 8, 9, 0);
break;
}
@ -119,13 +125,11 @@ void TransitionTriforce_Draw(void* thisx, Gfx** gfxP) {
s32 TransitionTriforce_IsDone(void* thisx) {
TransitionTriforce* this = (TransitionTriforce*)thisx;
s32 ret = 0;
if (this->state == 1 || this->state == 2) {
return this->transPos <= 0.03f;
} else if (this->state == 3 || this->state == 4) {
return this->transPos >= 1.0f;
} else {
return false;
}
return ret;
}

View file

@ -1,8 +1,13 @@
#include "global.h"
typedef enum {
/* 0 */ TRANS_WIPE_DIR_IN,
/* 1 */ TRANS_WIPE_DIR_OUT
} TransitionWipeDirection;
#include "assets/code/fbdemo_wipe1/z_fbdemo_wipe1.c"
Gfx sWipeDList[] = {
Gfx sTransWipeDL[] = {
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),
@ -13,14 +18,14 @@ Gfx sWipeDList[] = {
gsDPSetCombineLERP(TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, COMBINED, 0,
PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0),
gsDPSetPrimDepth(0, 0),
gsDPLoadTextureBlock_4b(sWipe1Tex, G_IM_FMT_I, 64, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 6, 6,
11, G_TX_NOLOD),
gsDPLoadMultiBlock_4b(sWipe1Tex, 0x0100, 1, G_IM_FMT_I, 64, 64, 0, G_TX_NOMIRROR | G_TX_WRAP,
gsDPLoadTextureBlock_4b(sTransWipeTex, G_IM_FMT_I, 64, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 6,
6, 11, G_TX_NOLOD),
gsDPLoadMultiBlock_4b(sTransWipeTex, 0x0100, 1, G_IM_FMT_I, 64, 64, 0, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_MIRROR | G_TX_WRAP, 6, 6, 11, 1),
gsDPSetTextureLUT(G_TT_NONE),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
gsSPDisplayList(0x08000000),
gsSPVertex(sWipe1Vtx, 25, 0),
gsSPVertex(sTransWipeVtx, 25, 0),
gsSP2Triangles(0, 1, 2, 0, 1, 3, 4, 0),
gsSP2Triangles(5, 6, 7, 0, 6, 8, 9, 0),
gsSP2Triangles(8, 10, 11, 0, 10, 12, 13, 0),
@ -31,7 +36,7 @@ Gfx sWipeDList[] = {
};
// unused.
Gfx sWipeSyncDList[] = {
Gfx sTransWipeSyncDL[] = {
gsDPPipeSync(),
gsSPEndDisplayList(),
};
@ -41,20 +46,20 @@ void TransitionWipe_Start(void* thisx) {
this->isDone = false;
if (this->direction) {
this->texY = (s32)(83.25 * (1 << 2));
if (this->direction != TRANS_WIPE_DIR_IN) {
this->texY = (s32)(83.25f * (1 << 2));
} else {
this->texY = (s32)(153.0 * (1 << 2));
this->texY = (s32)(153.0f * (1 << 2));
}
guPerspective(&this->projection, &this->normal, 60.0f, 4.0 / 3.0f, 10.0f, 12800.0f, 1.0f);
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);
}
void* TransitionWipe_Init(void* thisx) {
TransitionWipe* this = (TransitionWipe*)thisx;
bzero(this, sizeof(*this));
bzero(this, sizeof(TransitionWipe));
return this;
}
@ -64,16 +69,16 @@ void TransitionWipe_Destroy(void* thisx) {
void TransitionWipe_Update(void* thisx, s32 updateRate) {
TransitionWipe* this = (TransitionWipe*)thisx;
if (this->direction != 0) {
if (this->direction != TRANS_WIPE_DIR_IN) {
this->texY += (((void)0, gSaveContext.transWipeSpeed) * 3) / updateRate;
if (this->texY >= (s32)(153.0 * (1 << 2))) {
this->texY = (s32)(153.0 * (1 << 2));
if (this->texY >= (s32)(153.0f * (1 << 2))) {
this->texY = (s32)(153.0f * (1 << 2));
this->isDone = true;
}
} else {
this->texY -= (((void)0, gSaveContext.transWipeSpeed) * 3) / updateRate;
if (this->texY <= (s32)(83.25 * (1 << 2))) {
this->texY = (s32)(83.25 * (1 << 2));
if (this->texY <= (s32)(83.25f * (1 << 2))) {
this->texY = (s32)(83.25f * (1 << 2));
this->isDone = true;
}
}
@ -84,17 +89,17 @@ void TransitionWipe_Draw(void* thisx, Gfx** gfxP) {
Mtx* modelView;
TransitionWipe* this = (TransitionWipe*)thisx;
s32 pad[4];
Gfx* tex;
Gfx* texScroll;
modelView = this->modelView[this->frame];
this->frame ^= 1;
guScale(&modelView[0], 0.56f, 0.56f, 1.0f);
guRotate(&modelView[1], 0.0f, 0.0f, 0.0f, 1.0f);
guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f);
gDPPipeSync(gfx++);
tex = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0, 0);
gSPSegment(gfx++, 8, tex);
texScroll = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0, 0);
gSPSegment(gfx++, 8, texScroll);
gDPSetPrimColor(gfx++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255);
gSPMatrix(gfx++, &this->projection, G_MTX_LOAD | G_MTX_PROJECTION);
gSPPerspNormalize(gfx++, this->normal);
@ -102,7 +107,7 @@ void TransitionWipe_Draw(void* thisx, Gfx** gfxP) {
gSPMatrix(gfx++, &modelView[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
gSPDisplayList(gfx++, sWipeDList);
gSPDisplayList(gfx++, sTransWipeDL);
gDPPipeSync(gfx++);
*gfxP = gfx;
}
@ -116,16 +121,16 @@ s32 TransitionWipe_IsDone(void* thisx) {
void TransitionWipe_SetType(void* thisx, s32 type) {
TransitionWipe* this = (TransitionWipe*)thisx;
if (type == 1) {
this->direction = 1;
if (type == TRANS_INSTANCE_TYPE_FILL_OUT) {
this->direction = TRANS_WIPE_DIR_OUT;
} else {
this->direction = 0;
this->direction = TRANS_WIPE_DIR_IN;
}
if (this->direction != 0) {
this->texY = (s32)(83.25 * (1 << 2));
if (this->direction != TRANS_WIPE_DIR_IN) {
this->texY = (s32)(83.25f * (1 << 2));
} else {
this->texY = (s32)(153.0 * (1 << 2));
this->texY = (s32)(153.0f * (1 << 2));
}
}
@ -135,8 +140,8 @@ void TransitionWipe_SetColor(void* thisx, u32 color) {
this->color.rgba = color;
}
void TransitionWipe_SetEnvColor(void* thisx, u32 color) {
void TransitionWipe_SetUnkColor(void* thisx, u32 color) {
TransitionWipe* this = (TransitionWipe*)thisx;
this->envColor.rgba = color;
this->unkColor.rgba = color;
}

View file

@ -198,7 +198,7 @@ void Play_Destroy(GameState* thisx) {
}
Letterbox_Destroy();
TransitionFade_Destroy(&this->transitionFade);
TransitionFade_Destroy(&this->transitionFadeFlash);
VisMono_Destroy(&D_80161498);
if (gSaveContext.linkAge != this->linkAgeOnLoad) {
@ -386,10 +386,10 @@ void Play_Init(GameState* thisx) {
}
Letterbox_Init();
TransitionFade_Init(&this->transitionFade);
TransitionFade_SetType(&this->transitionFade, 3);
TransitionFade_SetColor(&this->transitionFade, RGBA8(160, 160, 160, 255));
TransitionFade_Start(&this->transitionFade);
TransitionFade_Init(&this->transitionFadeFlash);
TransitionFade_SetType(&this->transitionFadeFlash, TRANS_INSTANCE_TYPE_FADE_FLASH);
TransitionFade_SetColor(&this->transitionFadeFlash, RGBA8(160, 160, 160, 255));
TransitionFade_Start(&this->transitionFadeFlash);
VisMono_Init(&D_80161498);
D_801614B0.a = 0;
Flags_UnsetAllEnv(this);
@ -609,9 +609,9 @@ void Play_Update(PlayState* this) {
}
if (this->transitionTrigger == TRANS_TRIGGER_END) {
this->transitionCtx.setType(&this->transitionCtx.instanceData, 1);
this->transitionCtx.setType(&this->transitionCtx.instanceData, TRANS_INSTANCE_TYPE_FILL_OUT);
} else {
this->transitionCtx.setType(&this->transitionCtx.instanceData, 2);
this->transitionCtx.setType(&this->transitionCtx.instanceData, TRANS_INSTANCE_TYPE_FILL_IN);
}
this->transitionCtx.start(&this->transitionCtx.instanceData);
@ -970,7 +970,7 @@ void Play_Update(PlayState* this) {
Letterbox_Update(R_UPDATE_RATE);
PLAY_LOG(3783);
TransitionFade_Update(&this->transitionFade, R_UPDATE_RATE);
TransitionFade_Update(&this->transitionFadeFlash, R_UPDATE_RATE);
} else {
goto skip;
}
@ -1094,7 +1094,7 @@ void Play_Draw(PlayState* this) {
this->transitionCtx.draw(&this->transitionCtx.instanceData, &gfxP);
}
TransitionFade_Draw(&this->transitionFade, &gfxP);
TransitionFade_Draw(&this->transitionFadeFlash, &gfxP);
if (D_801614B0.a > 0) {
D_80161498.primColor.rgba = D_801614B0.rgba;

View file

@ -270,7 +270,7 @@ void EnArrow_Fly(EnArrow* this, PlayState* play) {
}
if (this->actor.params == ARROW_NUT) {
iREG(50) = -1;
R_TRANS_FADE_FLASH_ALPHA_STEP = -1;
Actor_Spawn(&play->actorCtx, play, ACTOR_EN_M_FIRE1, this->actor.world.pos.x, this->actor.world.pos.y,
this->actor.world.pos.z, 0, 0, 0, 0);
sfxId = NA_SE_IT_DEKU;

View file

@ -76,6 +76,6 @@ void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this) {
void EffectSsStone1_Update(PlayState* play, u32 index, EffectSs* this) {
if ((this->life == 6) && (this->rReg0 != 0)) {
iREG(50) = 0;
R_TRANS_FADE_FLASH_ALPHA_STEP = 0;
}
}