TransitionFade OK (#1160)

* Match fade

* Some adjustments from OoT PR

* Missed 1

* iREG(50)

* Fill

* Sync

* PR review
This commit is contained in:
Derek Hensley 2023-02-24 08:20:18 -08:00 committed by GitHub
parent e75c51e841
commit 8eb54f4b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 211 additions and 61 deletions

View File

@ -1,7 +1,7 @@
<Root>
<File Name="ovl_fbdemo_triforce" BaseAddress="0x80AC5070" RangeStart="0x5C0" RangeEnd="0x690">
<DList Name="sTriforceWipeDL" Offset="0x5C0"/>
<Array Name="sTriforceWipeVtx" Count="10" Offset="0x5F0">
<DList Name="sTransTriforceDL" Offset="0x5C0"/>
<Array Name="sTransTriforceVtx" Count="10" Offset="0x5F0">
<Vtx/>
</Array>
</File>

View File

@ -2273,15 +2273,14 @@ TransitionTile* TransitionTile_Init(TransitionTile* this, s32 cols, s32 rows);
void TransitionTile_Draw(TransitionTile* this, Gfx** gfxP);
void TransitionTile_Update(TransitionTile* this);
// void TransitionFade_Start(void);
void* TransitionFade_Init(TransitionFade* arg0);
void TransitionFade_Destroy(TransitionFade* arg0);
void TransitionFade_Update(TransitionFade* thisx, s32 updateRate);
void TransitionFade_Start(void* thisx);
void* TransitionFade_Init(void* thisx);
void TransitionFade_Destroy(void* thisx);
void TransitionFade_Update(void* thisx, s32 updateRate);
void TransitionFade_Draw(void* thisx, Gfx** gfxP);
// void TransitionFade_IsDone(void);
void TransitionFade_SetColor(TransitionFade* arg0, u32 color);
void TransitionFade_SetType(TransitionFade* arg0, s32 arg1);
void TransitionFade_Start(TransitionFade* arg0);
s32 TransitionFade_IsDone(void* thisx);
void TransitionFade_SetColor(void* thisx, u32 color);
void TransitionFade_SetType(void* thisx, s32 type);
void TransitionOverlay_ClearLoadInfo(TransitionOverlay *overlayEntry);
void TransitionOverlay_SetSegment(TransitionOverlay *overlayEntry, void* vramStart, void* vramEnd, uintptr_t vromStart, uintptr_t vromEnd);
void TransitionCircle_Start(void* thisx);

View File

@ -122,6 +122,8 @@
#define R_REVERSE_FLOOR_INDEX XREG(94)
#define R_MINIMAP_DISABLED XREG(95)
#define R_TRANS_FADE_FLASH_ALPHA_STEP iREG(50) // Set to a negative number to start the flash
#define R_B_LABEL_DD WREG(0)
#define R_OW_MINIMAP_X WREG(29)
#define R_OW_MINIMAP_Y WREG(30)

View File

@ -810,7 +810,6 @@ extern KaleidoMgrOverlay* gKaleidoMgrCurOvl;
// extern UNK_TYPE4 D_801D0BB0;
// extern UNK_TYPE1 D_801D0C80;
// extern UNK_TYPE1 D_801D0CB0;
extern Gfx D_801D0D00[];
extern s32 gDbgCamEnabled;
// extern UNK_TYPE1 D_801D0D54;
// extern UNK_TYPE2 sQuakeIndex;

View File

@ -65,14 +65,20 @@ typedef struct {
/* 0x18 */ size_t size;
} TransitionOverlay;
typedef struct {
/* 0x0 */ char unk_0[0xC];
} TransitionFade; // size = 0xC
typedef enum {
/* 0 */ TRANSITION_CIRCLE_IN,
/* 1 */ TRANSITION_CIRCLE_OUT,
} TransitionCircleDirection;
/* 1 */ TRANS_INSTANCE_TYPE_FILL_OUT = 1,
/* 2 */ TRANS_INSTANCE_TYPE_FILL_IN,
} TransitionInstanceType;
#define TRANS_INSTANCE_TYPE_FADE_FLASH 3
typedef struct {
/* 0x0 */ u8 type;
/* 0x1 */ u8 isDone;
/* 0x2 */ u8 direction;
/* 0x4 */ Color_RGBA8_u32 color;
/* 0x8 */ u16 timer;
} TransitionFade; // size = 0xC
#define FBDEMO_CIRCLE_GET_MASK_TYPE(type) (type & 1)

1
spec
View File

@ -550,7 +550,6 @@ beginseg
include "build/src/code/z_fbdemo_dlftbls.o"
include "build/src/code/z_fbdemo.o"
include "build/src/code/z_fbdemo_fade.o"
include "build/data/code/z_fbdemo_fade.data.o"
include "build/src/code/z_fbdemo_circle.o"
include "build/src/code/z_overlay.o"
include "build/src/code/z_play.o"

View File

@ -1,6 +1,11 @@
#include "global.h"
Gfx D_801D0D00[] = {
typedef enum {
/* 0 */ TRANS_CIRCLE_DIR_IN,
/* 1 */ TRANS_CIRCLE_DIR_OUT,
} TransitionCircleDirection;
Gfx sTransCircleSetupDL[] = {
gsDPPipeSync(),
gsDPSetOtherMode(G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
@ -23,7 +28,7 @@ void TransitionCircle_Start(void* thisx) {
TransitionCircle* this = (TransitionCircle*)thisx;
this->stepValue = 0.1f;
if (this->direction == TRANSITION_CIRCLE_IN) {
if (this->direction == TRANS_CIRCLE_DIR_IN) {
this->targetRadius = 0.0f;
this->startingRadius = 1.0f;
} else {
@ -67,10 +72,10 @@ void TransitionCircle_SetType(void* thisx, s32 type) {
if (type & TC_SET_PARAMS) {
this->maskType = FBDEMO_CIRCLE_GET_MASK_TYPE(type);
} else if (type == 1) {
this->direction = TRANSITION_CIRCLE_OUT;
} else if (type == TRANS_INSTANCE_TYPE_FILL_OUT) {
this->direction = TRANS_CIRCLE_DIR_OUT;
} else {
this->direction = TRANSITION_CIRCLE_IN;
this->direction = TRANS_CIRCLE_DIR_IN;
}
}
@ -121,7 +126,7 @@ void TransitionCircle_Draw(void* thisx, Gfx** gfxp) {
TransitionCircle* this = (TransitionCircle*)thisx;
gDPPipeSync(gfx++);
gSPDisplayList(gfx++, &D_801D0D00);
gSPDisplayList(gfx++, sTransCircleSetupDL);
gDPSetPrimColor(gfx++, 0, this->color.a, this->color.r, this->color.g, this->color.b, 1);
if (this->maskType == 0) {
gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIM_LOD_FRAC, PRIMITIVE, 0, 0, 0, PRIMITIVE, TEXEL0, 0,

View File

@ -1,17 +1,150 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Start.s")
#define THIS ((TransitionFade*)thisx)
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Init.s")
typedef enum {
/* 0 */ TRANS_FADE_DIR_IN,
/* 1 */ TRANS_FADE_DIR_OUT
} TransitionFadeDirection;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Destroy.s")
typedef enum {
/* 0 */ TRANS_FADE_TYPE_NONE,
/* 1 */ TRANS_FADE_TYPE_ONE_WAY,
/* 2 */ TRANS_FADE_TYPE_FLASH
} TransitionFadeType;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Update.s")
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),
gsDPSetOtherMode(G_AD_NOTPATTERN | G_CD_BAYER | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_1PRIMITIVE,
G_AC_NONE | G_ZS_PIXEL | G_RM_CLD_SURF | G_RM_CLD_SURF2),
gsDPSetCombineLERP(0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE),
gsSPEndDisplayList(),
};
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Draw.s")
TransitionInit TransitionFade_InitVars = {
TransitionFade_Init, TransitionFade_Destroy, TransitionFade_Update, TransitionFade_Draw,
TransitionFade_Start, TransitionFade_SetType, TransitionFade_SetColor, NULL,
TransitionFade_IsDone,
};
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_IsDone.s")
void TransitionFade_Start(void* thisx) {
TransitionFade* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_SetColor.s")
switch (this->type) {
case TRANS_FADE_TYPE_NONE:
break;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_SetType.s")
case TRANS_FADE_TYPE_ONE_WAY:
this->timer = 0;
this->color.a = (this->direction != TRANS_FADE_DIR_IN) ? 255 : 0;
break;
case TRANS_FADE_TYPE_FLASH:
this->color.a = 0;
break;
default:
break;
}
this->isDone = false;
}
void* TransitionFade_Init(void* thisx) {
TransitionFade* this = THIS;
bzero(this, sizeof(TransitionFade));
return this;
}
void TransitionFade_Destroy(void* thisx) {
}
void TransitionFade_Update(void* thisx, s32 updateRate) {
s32 alpha;
s16 newAlpha;
TransitionFade* this = THIS;
switch (this->type) {
case TRANS_FADE_TYPE_NONE:
break;
case TRANS_FADE_TYPE_ONE_WAY:
//! FAKE:
THIS->timer += updateRate;
if (this->timer >= ((void)0, gSaveContext.transFadeDuration)) {
this->timer = ((void)0, gSaveContext.transFadeDuration);
this->isDone = true;
}
alpha = (255.0f * this->timer) / ((void)0, gSaveContext.transFadeDuration);
this->color.a = (this->direction != TRANS_FADE_DIR_IN) ? 255 - alpha : alpha;
break;
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)) {
R_TRANS_FADE_FLASH_ALPHA_STEP = 150;
}
} else {
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->color.a = newAlpha;
break;
default:
break;
}
}
void TransitionFade_Draw(void* thisx, Gfx** gfxP) {
TransitionFade* this = THIS;
Gfx* gfx;
Color_RGBA8_u32* color = &this->color;
if (color->a != 0) {
gfx = *gfxP;
gSPDisplayList(gfx++, sTransFadeSetupDL);
gDPSetPrimColor(gfx++, 0, 0, color->r, color->g, color->b, color->a);
gSPDisplayList(gfx++, D_0E000000.fillRect);
*gfxP = gfx;
}
}
s32 TransitionFade_IsDone(void* thisx) {
TransitionFade* this = THIS;
return this->isDone;
}
void TransitionFade_SetColor(void* thisx, u32 color) {
TransitionFade* this = THIS;
this->color.rgba = color;
}
void TransitionFade_SetType(void* thisx, s32 type) {
TransitionFade* this = THIS;
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->type = TRANS_FADE_TYPE_NONE;
}
}

View File

@ -668,7 +668,8 @@ void Play_UpdateTransition(PlayState* this) {
}
this->transitionCtx.setType(&this->transitionCtx.instanceData,
(this->transitionTrigger == TRANS_TRIGGER_END) ? 1 : 2);
(this->transitionTrigger == TRANS_TRIGGER_END) ? TRANS_INSTANCE_TYPE_FILL_OUT
: TRANS_INSTANCE_TYPE_FILL_IN);
this->transitionCtx.start(&this->transitionCtx.instanceData);
if (this->transitionCtx.transitionType == TRANS_TYPE_FADE_WHITE_CS_DELAYED) {

View File

@ -1,3 +1,4 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#define ANIM_INTERP 1

View File

@ -3,7 +3,7 @@
* Overlay: ovl_Dm_Char01
* Description: Woodfall scene objects (temple, water, walls, etc)
*/
#include "prevent_bss_reordering.h"
#include "z_dm_char01.h"
#include "objects/object_mtoride/object_mtoride.h"
#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h"

View File

@ -373,7 +373,7 @@ void func_8088ACE0(EnArrow* this, PlayState* play) {
}
if (this->actor.params == ENARROW_8) {
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, this->actor.speedXZ == 0.0f);
sp82 = NA_SE_IT_DEKU;

View File

@ -1261,7 +1261,8 @@ void EnWiz_UpdateDamage(EnWiz* this, PlayState* play) {
// If the player throws a Deku Nut or hits a ghost's collider (something that is impossible
// in the final game, since EnWiz_Init effectively disables them), then the below code will
// "destroy" the ghost by turning into a cloud of smoke.
if ((iREG(50) != 0) || (this->ghostColliders.elements[i + 1].info.bumperFlags & BUMP_HIT)) {
if ((R_TRANS_FADE_FLASH_ALPHA_STEP != 0) ||
(this->ghostColliders.elements[i + 1].info.bumperFlags & BUMP_HIT)) {
//! @bug: If a single ghost is destroyed, then changing the fight state here will cause
//! strange behavior; the ghosts will stand still and pretend to attack the player like
//! the real Wizrobe. Since Deku Nuts destroy all ghosts at once, and since the ghost

View File

@ -77,6 +77,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;
}
}

View File

@ -31,8 +31,11 @@ void TransitionTriforce_Start(void* thisx) {
case STATE_SPIRAL_IN_FAST:
this->transPos = 1.0f;
return;
default:
this->transPos = 0.03f;
return;
}
this->transPos = 0.03f;
}
void* TransitionTriforce_Init(void* thisx) {
@ -44,7 +47,7 @@ void* TransitionTriforce_Init(void* thisx) {
this->transPos = 1.0f;
this->state = STATE_SPIRAL_IN_FAST;
this->step = 0.015f;
this->fadeType = TYPE_TRANSPARENT_TRIFORCE;
this->type = TRANS_INSTANCE_TYPE_FILL_OUT;
return this;
}
@ -77,7 +80,7 @@ void TransitionTriforce_SetColor(void* thisx, u32 color) {
void TransitionTriforce_SetType(void* thisx, s32 type) {
TransitionTriforce* this = (TransitionTriforce*)thisx;
this->fadeType = type;
this->type = type;
}
void TransitionTriforce_SetState(void* thisx, s32 state) {
@ -99,37 +102,43 @@ 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_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
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);
gSPVertex(gfx++, &sTriforceWipeVtx, ARRAY_COUNT(sTriforceWipeVtx), 0);
gSPVertex(gfx++, &sTransTriforceVtx, ARRAY_COUNT(sTransTriforceVtx), 0);
if (!TransitionTriforce_IsDone(this)) {
switch (this->fadeType) {
case TYPE_TRANSPARENT_TRIFORCE:
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 TYPE_FILLED_TRIFORCE:
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);
gSP2Triangles(gfx++, 1, 9, 2, 0, 2, 9, 6, 0);
break;
default:
break;
}
} else {
switch (this->fadeType) {
case TYPE_TRANSPARENT_TRIFORCE:
switch (this->type) {
case TRANS_INSTANCE_TYPE_FILL_OUT:
break;
case TYPE_FILLED_TRIFORCE:
case TRANS_INSTANCE_TYPE_FILL_IN:
gSP1Quadrangle(gfx++, 6, 7, 8, 9, 0);
break;
default:
break;
}
}
gDPPipeSync(gfx++);
@ -143,6 +152,7 @@ s32 TransitionTriforce_IsDone(void* thisx) {
return this->transPos <= 0.03f;
} else if ((this->state == STATE_SPIRAL_OUT_SLOW) || (this->state == STATE_SPIRAL_OUT_FAST)) {
return (this->transPos >= 1.0f);
} else {
return false;
}
return false;
}

View File

@ -10,20 +10,14 @@ typedef enum {
/* 2 */ STATE_SPIRAL_IN_FAST,
/* 3 */ STATE_SPIRAL_OUT_SLOW,
/* 4 */ STATE_SPIRAL_OUT_FAST
} FbTriforceState;
typedef enum {
/* 0 */ TYPE_NONE,
/* 1 */ TYPE_TRANSPARENT_TRIFORCE,
/* 2 */ TYPE_FILLED_TRIFORCE
} TriforceFadeType;
} TransitionTriforceState;
typedef struct {
/* 0x000 */ Color_RGBA8_u32 color;
/* 0x004 */ f32 transPos;
/* 0x008 */ f32 step;
/* 0x00C */ s32 state;
/* 0x010 */ s32 fadeType;
/* 0x010 */ s32 type;
/* 0x018 */ Mtx projection;
/* 0x058 */ s32 frame;
/* 0x060 */ Mtx modelView[2][3];

View File

@ -127,7 +127,7 @@ void TransitionWipe5_SetType(void* thisx, s32 type) {
if (type & 0x80) {
this->unk_11 = 0;
this->unk_12 = type & 1;
} else if (type == 1) {
} else if (type == TRANS_INSTANCE_TYPE_FILL_OUT) {
this->unk_10 = 1;
} else {
this->unk_10 = 0;

View File

@ -12924,8 +12924,8 @@
0x80AC4F60:("D_80AC4F60","f32","",0x4),
0x80AC4F64:("D_80AC4F64","f32","",0x4),
0x80AC5060:("D_80AC5060","UNK_TYPE1","",0x1),
0x80AC5630:("sTriforceWipeDL","UNK_TYPE1","",0x1),
0x80AC5660:("sTriforceWipeVtx","UNK_TYPE1","",0x1),
0x80AC5630:("sTransTriforceDL","UNK_TYPE1","",0x1),
0x80AC5660:("sTransTriforceVtx","UNK_TYPE1","",0x1),
0x80AC5700:("TransitionTriforce_InitVars","UNK_PTR","",0x4),
0x80AC5730:("D_80AC5730","f32","",0x4),
0x80AC5734:("D_80AC5734","f32","",0x4),