From e33d76568c8b71f98b7a6754a8527eb82b152f55 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 2 Feb 2024 03:15:53 +1100 Subject: [PATCH] Misc Small Retail Files OK (#1687) * shrink_window, z_lib, z_lights OK * sys_cfb.c OK * cleanup --- src/code/shrink_window.c | 2 +- src/code/sys_cfb.c | 11 ++++++++ src/code/z_lib.c | 4 ++- src/code/z_lights.c | 58 +++++++++++++++++----------------------- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/code/shrink_window.c b/src/code/shrink_window.c index 71e0e14ded..d2cbf78f37 100644 --- a/src/code/shrink_window.c +++ b/src/code/shrink_window.c @@ -86,7 +86,7 @@ void Letterbox_Update(s32 updateRate) { sLetterboxState = LETTERBOX_STATE_IDLE; } - if (R_HREG_MODE == HREG_MODE_LETTERBOX) { + if (OOT_DEBUG && (R_HREG_MODE == HREG_MODE_LETTERBOX)) { if (R_LETTERBOX_INIT != HREG_MODE_LETTERBOX) { R_LETTERBOX_INIT = HREG_MODE_LETTERBOX; R_LETTERBOX_ENABLE_LOGS = 0; diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c index 2ec91e25c1..041c72659c 100644 --- a/src/code/sys_cfb.c +++ b/src/code/sys_cfb.c @@ -13,11 +13,19 @@ void SysCfb_Init(s32 n64dd) { tmpFbEnd = 0x8044BE80; if (n64dd == 1) { PRINTF("RAM 8M mode (N64DD対応)\n"); // "RAM 8M mode (N64DD compatible)" +#if OOT_DEBUG sSysCfbEnd = 0x805FB000; +#else + sSysCfbEnd = 0x80600000; +#endif } else { // "The margin for this version is %dK bytes" PRINTF("このバージョンのマージンは %dK バイトです\n", (0x4BC00 / 1024)); +#if OOT_DEBUG sSysCfbEnd = tmpFbEnd; +#else + sSysCfbEnd = 0x80400000; +#endif } } else if (osMemSize >= 0x400000) { PRINTF("RAM4M mode\n"); @@ -28,6 +36,9 @@ void SysCfb_Init(s32 n64dd) { screenSize = SCREEN_WIDTH * SCREEN_HEIGHT; sSysCfbEnd &= ~0x3F; + + if (1) {} + // "The final address used by the system is %08x" PRINTF("システムが使用する最終アドレスは %08x です\n", sSysCfbEnd); sSysCfbFbPtr[0] = sSysCfbEnd - (screenSize * 4); diff --git a/src/code/z_lib.c b/src/code/z_lib.c index cc665fd0c7..58a2911622 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -407,8 +407,10 @@ void IChain_Apply_Vec3s(u8* ptr, InitChainEntry* ichain) { * instead, with a minimum step of minStep. Returns remaining distance to target. */ f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep) { + f32 stepSize; + if (*pValue != target) { - f32 stepSize = (target - *pValue) * fraction; + stepSize = (target - *pValue) * fraction; if ((stepSize >= minStep) || (stepSize <= -minStep)) { if (stepSize > step) { diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 1b9373474f..ba197dee19 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -64,13 +64,12 @@ void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx) { gSPNumLights(POLY_OPA_DISP++, lights->numLights); gSPNumLights(POLY_XLU_DISP++, lights->numLights); - i = 0; light = &lights->l.l[0]; + i = 0; while (i < lights->numLights) { gSPLight(POLY_OPA_DISP++, light, ++i); - gSPLight(POLY_XLU_DISP++, light, i); - light++; + gSPLight(POLY_XLU_DISP++, light++, i); } // ambient light is total number of lights + 1 @@ -314,22 +313,20 @@ Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambient } void Lights_GlowCheck(PlayState* play) { - LightNode* node; - LightPoint* params; - Vec3f pos; - Vec3f multDest; - f32 cappedInvWDest; - f32 wX; - f32 wY; - s32 wZ; - s32 zBuf; - - node = play->lightCtx.listHead; + LightNode* node = play->lightCtx.listHead; while (node != NULL) { - params = &node->info->params.point; + LightPoint* params = &node->info->params.point; if (node->info->type == LIGHT_POINT_GLOW) { + Vec3f pos; + Vec3f multDest; + f32 cappedInvWDest; + f32 wX; + f32 wY; + s32 wZ; + s32 zBuf; + pos.x = params->x; pos.y = params->y; pos.z = params->z; @@ -362,9 +359,7 @@ void Lights_GlowCheck(PlayState* play) { void Lights_DrawGlow(PlayState* play) { s32 pad; - LightNode* node; - - node = play->lightCtx.listHead; + LightNode* node = play->lightCtx.listHead; OPEN_DISPS(play->state.gfxCtx, "../z_lights.c", 887); @@ -374,23 +369,20 @@ void Lights_DrawGlow(PlayState* play) { gSPDisplayList(POLY_XLU_DISP++, gGlowCircleTextureLoadDL); while (node != NULL) { - LightInfo* info; - LightPoint* params; - f32 scale; - s32 pad[4]; + if ((node->info->type == LIGHT_POINT_GLOW)) { + s32 pad[6]; + LightPoint* params = &node->info->params.point; - info = node->info; - params = &info->params.point; + if (params->drawGlow) { + f32 scale = SQ(params->radius) * 0.0000026f; - if ((info->type == LIGHT_POINT_GLOW) && (params->drawGlow)) { - scale = SQ(params->radius) * 0.0000026f; - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, params->color[0], params->color[1], params->color[2], 50); - Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW); - Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_lights.c", 918), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gGlowCircleDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, params->color[0], params->color[1], params->color[2], 50); + Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_lights.c", 918), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGlowCircleDL); + } } node = node->next;