summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_fbdemo_circle.c17
-rw-r--r--src/code/z_fbdemo_fade.c149
-rw-r--r--src/code/z_play.c3
-rw-r--r--src/code/z_skelanime.c1
4 files changed, 155 insertions, 15 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