From a8ae9f48b7c07e0188fdb720ee153d07f2fd679e Mon Sep 17 00:00:00 2001 From: petrie911 <69443847+petrie911@users.noreply.github.com> Date: Fri, 25 Dec 2020 15:19:52 -0600 Subject: z_scene_table, z_view, and z_fbdemo_fade OK (#561) * fbdemo * the view is clear * more matchings * scene table doesn't want to be nice * small thing in view * can do * accidentally a value --- src/code/z_fbdemo.c | 33 +++++++++++++++++++-------------- src/code/z_fbdemo_fade.c | 12 ++++-------- src/code/z_parameter.c | 3 ++- src/code/z_scene_table.c | 20 +++++--------------- src/code/z_view.c | 9 ++------- 5 files changed, 32 insertions(+), 45 deletions(-) (limited to 'src/code') diff --git a/src/code/z_fbdemo.c b/src/code/z_fbdemo.c index 426231bcb..743551852 100644 --- a/src/code/z_fbdemo.c +++ b/src/code/z_fbdemo.c @@ -28,8 +28,12 @@ Gfx D_8012B000[] = { #ifdef NON_EQUIVALENT // The general control flow is correct and nothing is especially out of order but there are // many small reoderings and regalloc all over so functional equivalence cannot be verified +// The first loop is down to regalloc. The second needs work. void TransitionUnk_InitGraphics(TransitionUnk* this) { - Vtx* vtx2; + s32 pad; + s32 pad2; + s32 pad3; + Vtx_t* vtx2; s32 frame; s32 rowTex; s32 row; @@ -45,20 +49,21 @@ void TransitionUnk_InitGraphics(TransitionUnk* this) { for (frame = 0; frame < 2; frame++) { this->frame = frame; vtx = (frame == 0) ? this->vtxFrame1 : this->vtxFrame2; - for (col = 0, colTex = 0; col < this->col + 1; col++, colTex += 0x20) { - for (row = 0, rowTex = 0; row < this->row + 1; row++, rowTex += 0x20) { - vtx2 = vtx; - vtx2->v.tc[0] = rowTex * 0x40; - vtx2->v.ob[0] = rowTex; - vtx2->v.ob[1] = col * 0x20; - vtx2->v.ob[2] = -5; - vtx2->v.flag = 0; - vtx2->v.tc[1] = colTex * 0x40; - vtx2->v.cn[0] = 0; - vtx2->v.cn[1] = 0; - vtx2->v.cn[2] = 120; - vtx2->v.cn[3] = 255; + for (colTex = 0, col = 0; col < this->col + 1; colTex += 0x20, col++) { + for (rowTex = 0, row = 0; row < this->row + 1; rowTex += 0x20, row++) { + vtx2 = &vtx->v; vtx++; + + vtx2->tc[0] = rowTex << 6; + vtx2->ob[0] = row * 0x20; + vtx2->ob[1] = col * 0x20; + vtx2->ob[2] = -5; + vtx2->flag = 0; + vtx2->tc[1] = colTex << 6; + vtx2->cn[0] = 0; + vtx2->cn[1] = 0; + vtx2->cn[2] = 120; + vtx2->cn[3] = 255; } } } diff --git a/src/code/z_fbdemo_fade.c b/src/code/z_fbdemo_fade.c index d0f99bed6..57c58f274 100644 --- a/src/code/z_fbdemo_fade.c +++ b/src/code/z_fbdemo_fade.c @@ -35,8 +35,6 @@ TransitionFade* TransitionFade_Init(TransitionFade* this) { void TransitionFade_Destroy(TransitionFade* this) { } -#ifdef NON_MATCHING -// Ordering differences around alpha temp void TransitionFade_Update(TransitionFade* this, s32 updateRate) { s32 alpha; s16 newAlpha; @@ -54,19 +52,20 @@ void TransitionFade_Update(TransitionFade* this, s32 updateRate) { // Divide by 0! Zero is included in ZCommonGet fade_speed osSyncPrintf(VT_COL(RED, WHITE) "0除算! ZCommonGet fade_speed に0がはいってる" VT_RST); } - alpha = (this->fadeTimer * 255.0f) / gSaveContext.fadeDuration; + + alpha = (255.0f * this->fadeTimer) / (0, gSaveContext.fadeDuration); this->fadeColor.a = (this->fadeDirection != 0) ? 255 - alpha : alpha; break; case 2: newAlpha = this->fadeColor.a; if (iREG(50) != 0) { if (iREG(50) < 0) { - if (Math_ApproxS(&newAlpha, 255, 255) != 0) { + if (Math_ApproxS(&newAlpha, 255, 255)) { iREG(50) = 150; } } else { Math_ApproxS(&iREG(50), 20, 60); - if (Math_ApproxS(&newAlpha, 0, iREG(50)) != 0) { + if (Math_ApproxS(&newAlpha, 0, iREG(50))) { iREG(50) = 0; this->isDone = 1; } @@ -76,9 +75,6 @@ void TransitionFade_Update(TransitionFade* this, s32 updateRate) { break; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Update.s") -#endif void TransitionFade_Draw(TransitionFade* this, Gfx** gfxP) { Gfx* gfx; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 1b1b0f993..fede83307 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -3047,7 +3047,8 @@ s16 D_80125B5C[] = { 91, 91 }; // unused // Due to an unknown reason, bss ordering changes within the 5 static variables in the function below. // In order to restore the correct order, we need a specific number of bss variables in the file before that point. -// For this, we introduce 3 dummy variables which end up in padding at the end of the file's bss, so they don't actually take space. +// For this, we introduce 3 dummy variables which end up in padding at the end of the file's bss, so they don't actually +// take space. s8 sBssDummy1; s8 sBssDummy2; s8 sBssDummy3; diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index f2ec63de8..8de6d86ad 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -2310,9 +2310,6 @@ void func_8009FC90(GlobalContext* globalCtx) { f32 D_8012A398 = 0.0f; -// Scene Draw Config 21 -#ifdef NON_MATCHING -// regalloc differences and single equivalent instruction difference void func_8009FE58(GlobalContext* globalCtx) { static s16 D_8012A39C = 538; static s16 D_8012A3A0 = 4272; @@ -2346,11 +2343,10 @@ void func_8009FE58(GlobalContext* globalCtx) { D_8012A3A0 += 1820; temp = 0.020000001f; - func_800AA76C(&globalCtx->view, Math_Coss(D_8012A39C) * (0.00009587531f * temp), - Math_Sins(D_8012A39C) * (0.00009587531f * temp), Math_Sins(D_8012A3A0) * (0.00009587531f * temp)); - func_800AA78C(&globalCtx->view, 1.0f + (Math_Sins(D_8012A3A0) * (0.79999995f * temp)), - 1.0f + (Math_Coss(D_8012A3A0) * (0.39999998f * temp)), - 1.0f + (Math_Coss(D_8012A39C) * (1 * temp))); + func_800AA76C(&globalCtx->view, 0.00009587531f * temp * Math_Coss(D_8012A39C), + 0.00009587531f * temp * Math_Sins(D_8012A39C), 0.00009587531f * temp * Math_Sins(D_8012A3A0)); + func_800AA78C(&globalCtx->view, 1.f + (0.79999995f * temp * Math_Sins(D_8012A3A0)), + 1.f + (0.39999998f * temp * Math_Coss(D_8012A3A0)), 1.f + (1 * temp * Math_Coss(D_8012A39C))); func_800AA7AC(&globalCtx->view, 0.95f); switch (globalCtx->unk_11D30[0]) { @@ -2377,7 +2373,7 @@ void func_8009FE58(GlobalContext* globalCtx) { } if (globalCtx->roomCtx.curRoom.num == 2) { - Matrix_Scale(1, sinf(D_8012A398) * 0.8f, 1, MTXMODE_NEW); + Matrix_Scale(1.0f, sinf(D_8012A398) * 0.8f, 1.0f, MTXMODE_NEW); } else { Matrix_Scale(1.005f, sinf(D_8012A398) * 0.8f, 1.005f, MTXMODE_NEW); } @@ -2386,12 +2382,6 @@ void func_8009FE58(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7811); } -#else -s16 D_8012A39C = 538; -s16 D_8012A3A0 = 4272; -void func_8009FE58(GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_scene_table/func_8009FE58.s") -#endif // Scene Draw Config 26 void func_800A0334(GlobalContext* globalCtx) { diff --git a/src/code/z_view.c b/src/code/z_view.c index 71913d5e6..3374eeb5e 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -194,7 +194,7 @@ void func_800AA78C(View* view, f32 x, f32 y, f32 z) { view->unk_F4.z = z; } -void func_800AA7AC(View* view, f32 arg1) { +s32 func_800AA7AC(View* view, f32 arg1) { view->unk_100 = arg1; } @@ -260,7 +260,7 @@ s32 func_800AA890(View* view, Mtx* mtx) { } void func_800AAA50(View* view, s32 arg1) { - arg1 = (view->flags & arg1) | arg1 >> 4; + arg1 = (view->flags & arg1) | (arg1 >> 4); if (arg1 & 8) { func_800AB0A8(view); @@ -522,8 +522,6 @@ s32 func_800AB944(View* view) { return 1; } -#ifdef NON_MATCHING -// regalloc differences, skips a t register at arg1's assignment s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { Gfx* gfx = *gfxp; GraphicsContext* gfxCtx = view->gfxCtx; @@ -595,9 +593,6 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) { return 1; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_view/func_800AB9EC.s") -#endif s32 func_800ABE74(f32 eyeX, f32 eyeY, f32 eyeZ) { s32 error = 0; -- cgit v1.2.3