From d30fae23e7210cc2caa6ea369d167688dc0b860b Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 26 Dec 2024 21:41:24 -0800 Subject: [PATCH 1/8] Remove some unnecessary casts in Graph_TaskSet00 --- src/code/graph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/code/graph.c b/src/code/graph.c index 7fa6e505fe6..5145bd6c265 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -180,10 +180,10 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState) { task->ucode_data = SysUcode_GetUCodeData(); task->ucode_size = SP_UCODE_SIZE; task->ucode_data_size = SP_UCODE_DATA_SIZE; - task->dram_stack = (u64*)gGfxSPTaskStack; + task->dram_stack = gGfxSPTaskStack; task->dram_stack_size = sizeof(gGfxSPTaskStack); task->output_buff = gGfxSPTaskOutputBufferPtr; - task->output_buff_size = (void*)gGfxSPTaskOutputBufferEnd; + task->output_buff_size = gGfxSPTaskOutputBufferEnd; task->data_ptr = (u64*)gGfxMasterDL; task->data_size = 0; task->yield_data_ptr = (u64*)gGfxSPTaskYieldBuffer; From 4e71449beb6fd28e0a1e9b1adc3b0813cc7144f2 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 26 Dec 2024 21:42:52 -0800 Subject: [PATCH 2/8] gGfxSPTaskYieldBuffer as u64 --- include/buffers.h | 2 +- src/buffers/gfxbuffers.c | 2 +- src/code/graph.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/buffers.h b/include/buffers.h index fe9fa419649..34382423261 100644 --- a/include/buffers.h +++ b/include/buffers.h @@ -18,7 +18,7 @@ typedef union { extern BufferLow gLoBuffer; -extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; +extern u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)]; extern STACK(gGfxSPTaskStack, 0x400); extern GfxPool gGfxPools[2]; extern u8 gAudioHeap[0x138000]; diff --git a/src/buffers/gfxbuffers.c b/src/buffers/gfxbuffers.c index 4a20afcbe5c..66c9850b351 100644 --- a/src/buffers/gfxbuffers.c +++ b/src/buffers/gfxbuffers.c @@ -1,7 +1,7 @@ #include "prevent_bss_reordering.h" #include "buffers.h" -u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE] ALIGNED(16); +u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)] ALIGNED(16); STACK(gGfxSPTaskStack, 0x400) ALIGNED(16); diff --git a/src/code/graph.c b/src/code/graph.c index 5145bd6c265..1d3e6e0d4b1 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -186,7 +186,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState) { task->output_buff_size = gGfxSPTaskOutputBufferEnd; task->data_ptr = (u64*)gGfxMasterDL; task->data_size = 0; - task->yield_data_ptr = (u64*)gGfxSPTaskYieldBuffer; + task->yield_data_ptr = gGfxSPTaskYieldBuffer; task->yield_data_size = sizeof(gGfxSPTaskYieldBuffer); scTask->next = NULL; From b12258cd6d1ba2ac63df518c8c40f08b34370614 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 26 Dec 2024 21:45:51 -0800 Subject: [PATCH 3/8] gGfxSPTaskStack size macro --- include/buffers.h | 2 +- src/buffers/gfxbuffers.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/buffers.h b/include/buffers.h index 34382423261..28047f594e7 100644 --- a/include/buffers.h +++ b/include/buffers.h @@ -19,7 +19,7 @@ extern BufferLow gLoBuffer; extern u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)]; -extern STACK(gGfxSPTaskStack, 0x400); +extern STACK(gGfxSPTaskStack, SP_DRAM_STACK_SIZE8); extern GfxPool gGfxPools[2]; extern u8 gAudioHeap[0x138000]; diff --git a/src/buffers/gfxbuffers.c b/src/buffers/gfxbuffers.c index 66c9850b351..815f1da9289 100644 --- a/src/buffers/gfxbuffers.c +++ b/src/buffers/gfxbuffers.c @@ -3,6 +3,6 @@ u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)] ALIGNED(16); -STACK(gGfxSPTaskStack, 0x400) ALIGNED(16); +STACK(gGfxSPTaskStack, SP_DRAM_STACK_SIZE8) ALIGNED(16); GfxPool gGfxPools[2] ALIGNED(16); From e3b8a8d15fe0a816003214e378dcac9258df43c1 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 26 Dec 2024 21:46:20 -0800 Subject: [PATCH 4/8] R_THREE_DAY_CLOCK_Y_POS set to negative number --- src/code/title_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code/title_setup.c b/src/code/title_setup.c index 336d08be8b3..98da1f488c6 100644 --- a/src/code/title_setup.c +++ b/src/code/title_setup.c @@ -12,7 +12,7 @@ void Setup_InitRegs(void) { R_A_BTN_Y_OFFSET = 0; R_MAGIC_CONSUME_TIMER_GIANTS_MASK = 80; - R_THREE_DAY_CLOCK_Y_POS = 64596; + R_THREE_DAY_CLOCK_Y_POS = -940; R_THREE_DAY_CLOCK_SUN_MOON_CUTOFF = 215; R_THREE_DAY_CLOCK_HOUR_DIGIT_CUTOFF = 218; From 0a027de1e687e7dfbcc6b559eee5909265a3a3cb Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 26 Dec 2024 21:49:21 -0800 Subject: [PATCH 5/8] scope cfb in Graph_TaskSet00 --- src/code/graph.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/code/graph.c b/src/code/graph.c index 1d3e6e0d4b1..6d6791caef4 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -147,7 +147,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState) { OSScTask* scTask = &gfxCtx->task; OSTimer timer; OSMesg msg; - CfbInfo* cfb; + s32 pad; retry: osSetTimer(&timer, OS_USEC_TO_CYCLES(3 * 1000 * 1000), 0, &gfxCtx->queue, (OSMesg)666); @@ -201,27 +201,28 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState) { scTask->msgQ = &gfxCtx->queue; scTask->msg = NULL; - { s32 pad; } + { + CfbInfo* cfb = &sGraphCfbInfos[sCfbIndex]; - cfb = &sGraphCfbInfos[sCfbIndex]; - sCfbIndex = (sCfbIndex + 1) % ARRAY_COUNT(sGraphCfbInfos); + sCfbIndex = (sCfbIndex + 1) % ARRAY_COUNT(sGraphCfbInfos); - cfb->framebuffer = gfxCtx->curFrameBuffer; - cfb->swapBuffer = gfxCtx->curFrameBuffer; + cfb->framebuffer = gfxCtx->curFrameBuffer; + cfb->swapBuffer = gfxCtx->curFrameBuffer; - if (gfxCtx->updateViMode) { - gfxCtx->updateViMode = false; - cfb->viMode = gfxCtx->viMode; - cfb->viFeatures = gfxCtx->viConfigFeatures; - cfb->xScale = gfxCtx->xScale; - cfb->yScale = gfxCtx->yScale; - } else { - cfb->viMode = NULL; - } - cfb->unk_10 = 0; - cfb->updateRate = gameState->framerateDivisor; + if (gfxCtx->updateViMode) { + gfxCtx->updateViMode = false; + cfb->viMode = gfxCtx->viMode; + cfb->viFeatures = gfxCtx->viConfigFeatures; + cfb->xScale = gfxCtx->xScale; + cfb->yScale = gfxCtx->yScale; + } else { + cfb->viMode = NULL; + } + cfb->unk_10 = 0; + cfb->updateRate = gameState->framerateDivisor; - scTask->framebuffer = cfb; + scTask->framebuffer = cfb; + } while (gfxCtx->queue.validCount != 0) { osRecvMesg(&gfxCtx->queue, NULL, OS_MESG_NOBLOCK); From b2e9f7b9819e8e520051fc905f0280132941e5d4 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 27 Dec 2024 08:52:40 -0800 Subject: [PATCH 6/8] Graph_ThreadEntry types --- src/code/graph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/code/graph.c b/src/code/graph.c index 6d6791caef4..f823f995a96 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -342,11 +342,11 @@ void Graph_ThreadEntry(void* arg) { GameStateOverlay* nextOvl = &gGameStateOverlayTable[0]; GameStateOverlay* ovl; GameState* gameState; - u32 size; + size_t size; s32 pad[2]; gZBufferLoRes = malloc(sizeof(*gZBufferLoRes) + sizeof(*gWorkBufferLoRes) + 64 - 1); - gZBufferLoRes = (void*)ALIGN64((u32)gZBufferLoRes); + gZBufferLoRes = (void*)ALIGN64((uintptr_t)gZBufferLoRes); gWorkBufferLoRes = (void*)((u8*)gZBufferLoRes + sizeof(*gZBufferLoRes)); From c3bd35b418daa8af7441e003661ad1a465fa12a7 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 2 Jan 2025 21:25:33 -0800 Subject: [PATCH 7/8] func_80124618 --- src/code/z_player_lib.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 2f3e06f5952..43b98dfc83f 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1771,6 +1771,7 @@ void Player_UpdateBunnyEars(Player* player) { } void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2) { + struct_80124618* prev; s32 currentFrame = curFrame; f32 temp_f0; f32 temp_f14; @@ -1782,16 +1783,18 @@ void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2) { arg0++; } while (temp_v1 < currentFrame); - temp_f0 = arg0[-1].unk_0; + prev = arg0 - 1; + + temp_f0 = prev->unk_0; progress = (curFrame - temp_f0) / (temp_v1 - temp_f0); - temp_f14 = arg0[-1].unk_2.x; + temp_f14 = prev->unk_2.x; arg2->x = LERPIMP(temp_f14, arg0->unk_2.x, progress) * 0.01f; - temp_f14 = arg0[-1].unk_2.y; + temp_f14 = prev->unk_2.y; arg2->y = LERPIMP(temp_f14, arg0->unk_2.y, progress) * 0.01f; - temp_f14 = arg0[-1].unk_2.z; + temp_f14 = prev->unk_2.z; arg2->z = LERPIMP(temp_f14, arg0->unk_2.z, progress) * 0.01f; } From 6245167cb45338b1dbb9fb88b646418e67bd1b10 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 2 Jan 2025 21:49:28 -0800 Subject: [PATCH 8/8] SysCfb_SetHiResMode --- src/code/sys_cfb.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c index cd3d5897f46..e35aa46403a 100644 --- a/src/code/sys_cfb.c +++ b/src/code/sys_cfb.c @@ -63,27 +63,40 @@ void SysCfb_SetHiResMode(void) { gWorkBuffer = gWorkBufferHiRes; gGfxSPTaskOutputBufferPtr = *gGfxSPTaskOutputBufferHiRes; gGfxSPTaskOutputBufferEnd = gGfxSPTaskOutputBufferEndHiRes; - if (1) {} - gCfbWidth = HIRES_BUFFER_WIDTH; - gCfbHeight = HIRES_BUFFER_HEIGHT; - gCfbLeftAdjust = 30; - gCfbUpperAdjust = 10; + + if (0) { + // Remnant of debug + } else { + gCfbWidth = HIRES_BUFFER_WIDTH; + gCfbHeight = HIRES_BUFFER_HEIGHT; + gCfbLeftAdjust = 30; + gCfbUpperAdjust = 10; + } gScreenWidth = gCfbWidth; gScreenHeight = gCfbHeight; + if ((gCfbWidth == SCREEN_WIDTH_HIRES) && (gCfbHeight == SCREEN_HEIGHT_HIRES)) { gActiveViMode = &osViModeNtscHpf1; } else { + s32 leftAdjust; s32 rightAdjust; + s32 upperAdjust; s32 lowerAdjust; - //! FAKE: - l1: - rightAdjust = gCfbWidth - 610; - lowerAdjust = gCfbHeight - 470; - ViMode_Configure(&sNotebookViMode, -1, osTvType, 0, 1, 0, 1, gCfbWidth, gCfbHeight, 30, rightAdjust, 10, - lowerAdjust); + if (0) { + // Remnant of debug + } else { + leftAdjust = 30; + upperAdjust = 10; + rightAdjust = gCfbWidth - (SCREEN_WIDTH_HIRES - leftAdjust); + lowerAdjust = gCfbHeight - (SCREEN_HEIGHT_HIRES - upperAdjust); + } + + ViMode_Configure(&sNotebookViMode, -1, osTvType, false, true, false, true, gCfbWidth, gCfbHeight, leftAdjust, + rightAdjust, upperAdjust, lowerAdjust); gActiveViMode = &sNotebookViMode; } + gSysCfbHiResEnabled = true; }