Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc Cleanup #1782

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ typedef union {
extern BufferLow gLoBuffer;


extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
extern STACK(gGfxSPTaskStack, 0x400);
extern u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)];
extern STACK(gGfxSPTaskStack, SP_DRAM_STACK_SIZE8);
extern GfxPool gGfxPools[2];
extern u8 gAudioHeap[0x138000];

Expand Down
4 changes: 2 additions & 2 deletions src/buffers/gfxbuffers.c
Original file line number Diff line number Diff line change
@@ -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);
47 changes: 24 additions & 23 deletions src/code/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -180,13 +180,13 @@ 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;
task->yield_data_ptr = gGfxSPTaskYieldBuffer;
task->yield_data_size = sizeof(gGfxSPTaskYieldBuffer);

scTask->next = NULL;
Expand All @@ -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);
Expand Down Expand Up @@ -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));

Expand Down
35 changes: 24 additions & 11 deletions src/code/sys_cfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/code/title_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, that's funny

R_THREE_DAY_CLOCK_SUN_MOON_CUTOFF = 215;
R_THREE_DAY_CLOCK_HOUR_DIGIT_CUTOFF = 218;

Expand Down
11 changes: 7 additions & 4 deletions src/code/z_player_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down