summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDerek Hensley <hensley.derek58@gmail.com>2025-01-27 07:48:59 -0800
committerGitHub <noreply@github.com>2025-01-27 12:48:59 -0300
commit982ca889e2180165f7d2dd33c5fda2b6e8f998a0 (patch)
tree0850d4416d7971fe738300c200a394f1693791df /src
parentb9267f0550e4f408c93ac9d091332f51e9ea7838 (diff)
Misc Cleanup (#1782)
* Remove some unnecessary casts in Graph_TaskSet00 * gGfxSPTaskYieldBuffer as u64 * gGfxSPTaskStack size macro * R_THREE_DAY_CLOCK_Y_POS set to negative number * scope cfb in Graph_TaskSet00 * Graph_ThreadEntry types * func_80124618 * SysCfb_SetHiResMode
Diffstat (limited to 'src')
-rw-r--r--src/buffers/gfxbuffers.c4
-rw-r--r--src/code/graph.c47
-rw-r--r--src/code/sys_cfb.c35
-rw-r--r--src/code/title_setup.c2
-rw-r--r--src/code/z_player_lib.c11
5 files changed, 58 insertions, 41 deletions
diff --git a/src/buffers/gfxbuffers.c b/src/buffers/gfxbuffers.c
index 4a20afcbe..815f1da92 100644
--- a/src/buffers/gfxbuffers.c
+++ b/src/buffers/gfxbuffers.c
@@ -1,8 +1,8 @@
#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);
+STACK(gGfxSPTaskStack, SP_DRAM_STACK_SIZE8) ALIGNED(16);
GfxPool gGfxPools[2] ALIGNED(16);
diff --git a/src/code/graph.c b/src/code/graph.c
index 7fa6e505f..f823f995a 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);
@@ -180,13 +180,13 @@ retry:
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;
+ task->yield_data_ptr = gGfxSPTaskYieldBuffer;
task->yield_data_size = sizeof(gGfxSPTaskYieldBuffer);
scTask->next = NULL;
@@ -201,27 +201,28 @@ retry:
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);
@@ -341,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));
diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c
index cd3d5897f..e35aa4640 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;
}
diff --git a/src/code/title_setup.c b/src/code/title_setup.c
index 336d08be8..98da1f488 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;
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index c32f604d7..8a7a622da 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -1782,6 +1782,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;
@@ -1793,16 +1794,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;
}