diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2023-02-24 08:20:18 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-24 13:20:18 -0300 |
| commit | 8eb54f4b328dcdbf1d9b5517a7f958dcecc992d8 (patch) | |
| tree | 3bb879e597a0b2a30d0ee9a5857c921923196555 /src | |
| parent | e75c51e841ca97ad9f2f258c8b163acdfa4a3cf5 (diff) | |
TransitionFade OK (#1160)
* Match fade
* Some adjustments from OoT PR
* Missed 1
* iREG(50)
* Fill
* Sync
* PR review
Diffstat (limited to 'src')
| -rw-r--r-- | src/code/z_fbdemo_circle.c | 17 | ||||
| -rw-r--r-- | src/code/z_fbdemo_fade.c | 149 | ||||
| -rw-r--r-- | src/code/z_play.c | 3 | ||||
| -rw-r--r-- | src/code/z_skelanime.c | 1 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Wiz/z_en_wiz.c | 3 | ||||
| -rw-r--r-- | src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c | 2 | ||||
| -rw-r--r-- | src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c | 34 | ||||
| -rw-r--r-- | src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h | 10 | ||||
| -rw-r--r-- | src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c | 2 |
11 files changed, 185 insertions, 40 deletions
diff --git a/src/code/z_fbdemo_circle.c b/src/code/z_fbdemo_circle.c index 2a8144ea4..bc07df883 100644 --- a/src/code/z_fbdemo_circle.c +++ b/src/code/z_fbdemo_circle.c @@ -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, diff --git a/src/code/z_fbdemo_fade.c b/src/code/z_fbdemo_fade.c index a0d9f1eae..a9ab37d48 100644 --- a/src/code/z_fbdemo_fade.c +++ b/src/code/z_fbdemo_fade.c @@ -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; + } +} diff --git a/src/code/z_play.c b/src/code/z_play.c index c6c3cc273..f7e3dc521 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -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) { diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 318f49809..13ce84ec4 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define ANIM_INTERP 1 diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index 069d829c1..7e13a8e7f 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -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" diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index e203da9f0..d41da1326 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -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; diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index ee2f3d158..353fe01ab 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -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 diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index ad61166d3..c64ad38c6 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -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; } } diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c index f4f68d230..c4eb826c7 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c @@ -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; } diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h index cd7f4563e..1bcfe5c3d 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h @@ -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]; diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c index 0c20dba93..48c8bdf58 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c @@ -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; |
