summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorParker Burnett <jpburnett@gwu.edu>2022-10-04 05:55:20 -0700
committerGitHub <noreply@github.com>2022-10-04 13:55:20 +0100
commit6c414889c9561837c5103c7d27c868f2b90cd142 (patch)
tree5a6b6b52e8e27a8fd2b2e258c5f440b2925be7b0 /src/code
parent4833c08364014ac93727c907f0f149d5426fad30 (diff)
Fbdemo_circle OK (#1024)
* some progress, nasty draw func only thing to do * pushing for engineer * matching with no warnings * fixes * minor names * PR feedback * fixes for PR * docs * PR comments * fixing format and found bit shift
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c3
-rw-r--r--src/code/z_fbdemo_circle.c143
2 files changed, 136 insertions, 10 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 389f7a051..88ec6c07b 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -2609,7 +2609,8 @@ s32 Actor_RecordUndrawnActor(PlayState* play, Actor* actor) {
}
void Actor_DrawLensOverlay(Gfx** gfxP, s32 lensMaskSize) {
- func_80164C14(gfxP, &gCircleTex, 4, 0, 6, 6, ((LENS_MASK_ACTIVE_SIZE - lensMaskSize) * 0.003f) + 1.0f);
+ TransitionCircle_LoadAndSetTexture(gfxP, gCircleTex, 4, 0, 6, 6,
+ ((LENS_MASK_ACTIVE_SIZE - lensMaskSize) * 0.003f) + 1.0f);
}
#ifdef NON_EQUIVALENT
diff --git a/src/code/z_fbdemo_circle.c b/src/code/z_fbdemo_circle.c
index a822262ee..9cbc308be 100644
--- a/src/code/z_fbdemo_circle.c
+++ b/src/code/z_fbdemo_circle.c
@@ -1,19 +1,144 @@
#include "global.h"
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Start.s")
+Gfx D_801D0D00[] = {
+ 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,
+ G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | FORCE_BL |
+ GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) |
+ GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)),
+ gsDPSetPrimColor(0, 255, 0, 0, 0, 1),
+ gsDPSetBlendColor(0, 0, 0, 1),
+ gsSPEndDisplayList(),
+};
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Init.s")
+//! @bug: TransitionCircle_Update should take an additional argument `s32 updateRate`
+const TransitionInit TransitionCircle_InitVars = {
+ TransitionCircle_Init, TransitionCircle_Destroy, (void*)TransitionCircle_Update, TransitionCircle_Draw,
+ TransitionCircle_Start, TransitionCircle_SetType, TransitionCircle_SetColor, NULL,
+ TransitionCircle_IsDone,
+};
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Destroy.s")
+void TransitionCircle_Start(void* thisx) {
+ TransitionCircle* this = (TransitionCircle*)thisx;
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Update.s")
+ this->stepValue = 0.1f;
+ if (this->direction == TRANSITION_CIRCLE_IN) {
+ this->targetRadius = 0.0f;
+ this->startingRadius = 1.0f;
+ } else {
+ this->startingRadius = 0.0f;
+ this->targetRadius = 1.0f;
+ }
+ this->referenceRadius = this->startingRadius;
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_SetColor.s")
+void* TransitionCircle_Init(void* thisx) {
+ TransitionCircle* this = (TransitionCircle*)thisx;
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_SetType.s")
+ bzero(this, sizeof(TransitionCircle));
+ this->maskType = 1;
+ this->texture = gCircleTex;
+ this->masks = 6;
+ this->maskt = 6;
+ this->unk_1E = 4;
+ this->unk_1F = 0;
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/func_80164C14.s")
+ return this;
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Draw.s")
+void TransitionCircle_Destroy(void* thisx) {
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_IsDone.s")
+void TransitionCircle_Update(void* thisx) {
+ TransitionCircle* this = (TransitionCircle*)thisx;
+
+ this->isDone = Math_StepToF(&this->referenceRadius, this->targetRadius, this->stepValue);
+}
+
+void TransitionCircle_SetColor(void* thisx, u32 color) {
+ TransitionCircle* this = (TransitionCircle*)thisx;
+
+ this->color.rgba = color;
+}
+
+void TransitionCircle_SetType(void* thisx, s32 type) {
+ TransitionCircle* this = (TransitionCircle*)thisx;
+
+ if (type & TC_SET_PARAMS) {
+ this->maskType = FBDEMO_CIRCLE_GET_MASK_TYPE(type);
+ } else if (type == 1) {
+ this->direction = TRANSITION_CIRCLE_OUT;
+ } else {
+ this->direction = TRANSITION_CIRCLE_IN;
+ }
+}
+
+void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, s32 arg3, s32 masks, s32 maskt,
+ f32 arg6) {
+ Gfx* gfx = *gfxp;
+ s32 xh = D_801FBBCC;
+ s32 yh = D_801FBBCE;
+ s32 width = 1 << masks;
+ s32 height = 1 << maskt;
+ f32 s;
+ f32 t;
+ s32 dtdy;
+ s32 dsdx;
+
+ gDPLoadTextureBlock_4b(gfx++, texture, fmt, width, height, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP,
+ masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
+ gDPSetTileSize(gfx++, G_TX_RENDERTILE, ((SCREEN_WIDTH / 2) - width) << 2, ((SCREEN_HEIGHT / 2) - height) << 2,
+ ((SCREEN_WIDTH / 2) + (width - 1)) << 2, ((SCREEN_HEIGHT / 2) + (height - 1)) << 2);
+
+ s = ((1.0f - (1.0f / arg6)) * (SCREEN_WIDTH / 2)) + 70.0f;
+ t = ((1.0f - (1.0f / arg6)) * (SCREEN_HEIGHT / 2)) + 50.0f;
+
+ if (s < -1023.0f) {
+ s = -1023.0f;
+ }
+ if (t < -1023.0f) {
+ t = -1023.0f;
+ }
+
+ if ((s <= -1023.0f) || (t <= -1023.0f)) {
+ dsdx = 0;
+ dtdy = 0;
+ } else {
+ dsdx = ((SCREEN_WIDTH - (2.0f * s)) / gScreenWidth) * (1 << 10);
+ dtdy = ((SCREEN_HEIGHT - (2.0f * t)) / gScreenHeight) * (1 << 10);
+ }
+
+ gSPTextureRectangle(gfx++, 0, 0, xh << 2, yh << 2, G_TX_RENDERTILE, (s32)(s * (1 << 5)), (s32)(t * (1 << 5)), dsdx,
+ dtdy);
+ gDPPipeSync(gfx++);
+
+ *gfxp = gfx;
+}
+
+void TransitionCircle_Draw(void* thisx, Gfx** gfxp) {
+ Gfx* gfx = *gfxp;
+ TransitionCircle* this = (TransitionCircle*)thisx;
+
+ gDPPipeSync(gfx++);
+ gSPDisplayList(gfx++, &D_801D0D00);
+ 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,
+ PRIM_LOD_FRAC, PRIMITIVE);
+ } else {
+ gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, 1, TEXEL0, PRIM_LOD_FRAC, PRIMITIVE, 0, 0, 0, PRIMITIVE, 1, TEXEL0,
+ PRIM_LOD_FRAC, PRIMITIVE);
+ }
+ TransitionCircle_LoadAndSetTexture(&gfx, this->texture, G_IM_FMT_I, 0, this->masks, this->maskt,
+ this->referenceRadius);
+ gDPPipeSync(gfx++);
+
+ *gfxp = gfx;
+}
+
+s32 TransitionCircle_IsDone(void* thisx) {
+ TransitionCircle* this = (TransitionCircle*)thisx;
+
+ return this->isDone;
+}