mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-13 11:24:40 +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:
parent
1c6878b070
commit
4a9873775c
14 changed files with 186 additions and 146 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue