From c84eab6efbb10651ef99b8850588df48ed1e1559 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 26 May 2023 17:28:27 -0700 Subject: [PATCH] `z_fbdemo_wipe1` OK and assorted asset cleanup (#1244) --- ...{ovl_Arrow_fire.xml => ovl_Arrow_Fire.xml} | 0 .../ovl_fbdemo_triforce.xml} | 0 assets/xml/overlays/ovl_fbdemo_wipe1.xml | 9 ++ spec | 3 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 2 +- .../ovl_fbdemo_triforce/z_fbdemo_triforce.c | 2 +- .../fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c | 127 +++++++++++++++--- .../fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h | 12 +- 8 files changed, 130 insertions(+), 25 deletions(-) rename assets/xml/overlays/{ovl_Arrow_fire.xml => ovl_Arrow_Fire.xml} (100%) rename assets/xml/{objects/object_fbdemo_triforce.xml => overlays/ovl_fbdemo_triforce.xml} (100%) create mode 100644 assets/xml/overlays/ovl_fbdemo_wipe1.xml diff --git a/assets/xml/overlays/ovl_Arrow_fire.xml b/assets/xml/overlays/ovl_Arrow_Fire.xml similarity index 100% rename from assets/xml/overlays/ovl_Arrow_fire.xml rename to assets/xml/overlays/ovl_Arrow_Fire.xml diff --git a/assets/xml/objects/object_fbdemo_triforce.xml b/assets/xml/overlays/ovl_fbdemo_triforce.xml similarity index 100% rename from assets/xml/objects/object_fbdemo_triforce.xml rename to assets/xml/overlays/ovl_fbdemo_triforce.xml diff --git a/assets/xml/overlays/ovl_fbdemo_wipe1.xml b/assets/xml/overlays/ovl_fbdemo_wipe1.xml new file mode 100644 index 0000000000..281c8ebfbd --- /dev/null +++ b/assets/xml/overlays/ovl_fbdemo_wipe1.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/spec b/spec index ef85a17641..4b8481a730 100644 --- a/spec +++ b/spec @@ -3194,8 +3194,7 @@ beginseg name "ovl_fbdemo_wipe1" compress include "build/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.o" - include "build/data/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1.data.o" - include "build/data/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1.reloc.o" + include "build/src/overlays/fbdemos/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 971b778be5..c356a5f172 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -19,7 +19,7 @@ void ArrowFire_Draw(Actor* thisx, PlayState* play); void FireArrow_ChargeAndWait(ArrowFire* this, PlayState* play); void FireArrow_Fly(ArrowFire* this, PlayState* play); -#include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c" +#include "overlays/ovl_Arrow_Fire/ovl_Arrow_Fire.c" ActorInit Arrow_Fire_InitVars = { ACTOR_ARROW_FIRE, 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 c4eb826c70..cf1000add1 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c @@ -6,7 +6,7 @@ #include "global.h" #include "z_fbdemo_triforce.h" -#include "assets/objects/object_fbdemo_triforce/ovl_fbdemo_triforce.c" +#include "assets/overlays/ovl_fbdemo_triforce/ovl_fbdemo_triforce.c" void* TransitionTriforce_Init(void* thisx); void TransitionTriforce_Destroy(void* thisx); diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c index 1ce5f0d598..94285c45bf 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c @@ -7,6 +7,8 @@ #include "global.h" #include "z_fbdemo_wipe1.h" +#define THIS ((TransitionWipe1*)thisx) + void* TransitionWipe1_Init(void* thisx); void TransitionWipe1_Destroy(void* thisx); void TransitionWipe1_Update(void* thisx, s32 updateRate); @@ -17,35 +19,120 @@ void TransitionWipe1_SetColor(void* thisx, u32 color); void TransitionWipe1_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe1_IsDone(void* thisx); -#if 0 +#include "assets/overlays/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1.c" + TransitionInit TransitionWipe1_InitVars = { - TransitionWipe1_Init, - TransitionWipe1_Destroy, - TransitionWipe1_Update, - TransitionWipe1_Draw, - TransitionWipe1_Start, - TransitionWipe1_SetType, - TransitionWipe1_SetColor, - TransitionWipe1_SetEnvColor, - TransitionWipe1_IsDone, + TransitionWipe1_Init, TransitionWipe1_Destroy, TransitionWipe1_Update, + TransitionWipe1_Draw, TransitionWipe1_Start, TransitionWipe1_SetType, + TransitionWipe1_SetColor, TransitionWipe1_SetEnvColor, TransitionWipe1_IsDone, }; -#endif +typedef enum { + /* 0 */ TRANS_WIPE1_DIR_IN, + /* 1 */ TRANS_WIPE1_DIR_OUT +} TransitionWipe1Direction; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Start.s") +void TransitionWipe1_Start(void* thisx) { + TransitionWipe1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Init.s") + this->isDone = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Destroy.s") + if (this->direction != TRANS_WIPE1_DIR_IN) { + this->texY = (s32)(83.25f * (1 << 2)); + } else { + this->texY = (s32)(153.0f * (1 << 2)); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Update.s") + 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); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Draw.s") +void* TransitionWipe1_Init(void* thisx) { + TransitionWipe1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_IsDone.s") + bzero(this, sizeof(TransitionWipe1)); + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_SetType.s") +void TransitionWipe1_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_SetColor.s") +void TransitionWipe1_Update(void* thisx, s32 updateRate) { + TransitionWipe1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_SetEnvColor.s") + if (this->direction != TRANS_WIPE1_DIR_IN) { + this->texY += (((void)0, gSaveContext.transWipeSpeed) * 3) / updateRate; + 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.25f * (1 << 2))) { + this->texY = (s32)(83.25f * (1 << 2)); + this->isDone = true; + } + } +} + +void TransitionWipe1_Draw(void* thisx, Gfx** gfxP) { + Gfx* gfx = *gfxP; + Mtx* modelView; + TransitionWipe1* this = THIS; + Gfx* texScroll; + s32 pad[4]; + + 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++); + texScroll = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0, 0); + gSPSegment(gfx++, 8, texScroll); + gDPSetPrimColor(gfx++, 0, 0x80, this->primColor.r, this->primColor.g, this->primColor.b, 255); + gSPMatrix(gfx++, &this->projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPPerspNormalize(gfx++, this->normal); + gSPMatrix(gfx++, &this->lookAt, G_MTX_MUL | 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); + gSPDisplayList(gfx++, sTransWipe1DL); + gDPPipeSync(gfx++); + *gfxP = gfx; +} + +s32 TransitionWipe1_IsDone(void* thisx) { + TransitionWipe1* this = THIS; + + return this->isDone; +} + +void TransitionWipe1_SetType(void* thisx, s32 type) { + TransitionWipe1* this = THIS; + + if (type == TRANS_INSTANCE_TYPE_FILL_OUT) { + this->direction = TRANS_WIPE1_DIR_OUT; + } else { + this->direction = TRANS_WIPE1_DIR_IN; + } + + if (this->direction != TRANS_WIPE1_DIR_IN) { + this->texY = (s32)(83.25f * (1 << 2)); + } else { + this->texY = (s32)(153.0f * (1 << 2)); + } +} + +void TransitionWipe1_SetColor(void* thisx, u32 color) { + TransitionWipe1* this = THIS; + + this->primColor.rgba = color; +} + +void TransitionWipe1_SetEnvColor(void* thisx, u32 color) { + TransitionWipe1* this = THIS; + + this->envColor.rgba = color; +} diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h index 39f881b390..4906e531c3 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h @@ -5,7 +5,17 @@ #include "color.h" typedef struct { - /* 0x000 */ char unk_0[0x218]; + /* 0x000 */ Color_RGBA8_u32 primColor; + /* 0x004 */ Color_RGBA8_u32 envColor; + /* 0x008 */ u8 direction; + /* 0x009 */ u8 frame; + /* 0x00A */ u8 isDone; + /* 0x00C */ u16 texX; + /* 0x00E */ u16 texY; + /* 0x010 */ u16 normal; + /* 0x018 */ Mtx projection; + /* 0x058 */ Mtx lookAt; + /* 0x098 */ Mtx modelView[2][3]; } TransitionWipe1; // size = 0x218 #endif