General Cleanup 2 (#1538)

* Cleanup

* Cleanup variables.h

* Cleanup fault headers

* Some includes/headers cleanup

* Libultra btn wrappers

* Mark differences to original libultra headers

* Remove duplicate include in fault

* format

* Update include/PR/os_voice.h

Co-authored-by: Tom Overton <tom-overton@users.noreply.github.com>

* align

---------

Co-authored-by: Tom Overton <tom-overton@users.noreply.github.com>
This commit is contained in:
Derek Hensley
2024-01-28 16:27:50 -08:00
committed by GitHub
parent 6a15ce9521
commit db8f5f5ccc
54 changed files with 373 additions and 1785 deletions
+2 -2
View File
@@ -1263,8 +1263,8 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
gAudioCtx.curAiBufferIndex = 0;
gAudioCtx.soundMode = SOUNDMODE_STEREO;
gAudioCtx.curTask = NULL;
gAudioCtx.rspTask[0].task.t.dataSize = 0;
gAudioCtx.rspTask[1].task.t.dataSize = 0;
gAudioCtx.rspTask[0].task.t.data_size = 0;
gAudioCtx.rspTask[1].task.t.data_size = 0;
osCreateMesgQueue(&gAudioCtx.syncDmaQueue, &gAudioCtx.syncDmaMesg, 1);
osCreateMesgQueue(&gAudioCtx.curAudioFrameDmaQueue, gAudioCtx.currAudioFrameDmaMesgBuf,
+13 -13
View File
@@ -168,21 +168,21 @@ AudioTask* AudioThread_UpdateImpl(void) {
task = &gAudioCtx.curTask->task.t;
task->type = M_AUDTASK;
task->flags = 0;
task->ucodeBoot = aspMainTextStart;
task->ucodeBootSize = SP_UCODE_SIZE;
task->ucodeDataSize = ((aspMainDataEnd - aspMainDataStart) * sizeof(u64)) - 1;
task->ucode_boot = aspMainTextStart;
task->ucode_boot_size = SP_UCODE_SIZE;
task->ucode_data_size = ((aspMainDataEnd - aspMainDataStart) * sizeof(u64)) - 1;
task->ucode = aspMainTextStart;
task->ucodeData = aspMainDataStart;
task->ucodeSize = SP_UCODE_SIZE;
task->dramStack = (u64*)D_801D6200;
task->dramStackSize = 0;
task->outputBuff = NULL;
task->outputBuffSize = NULL;
task->ucode_data = aspMainDataStart;
task->ucode_size = SP_UCODE_SIZE;
task->dram_stack = (u64*)D_801D6200;
task->dram_stack_size = 0;
task->output_buff = NULL;
task->output_buff_size = NULL;
if (1) {}
task->dataPtr = (u64*)gAudioCtx.abiCmdBufs[index];
task->dataSize = numAbiCmds * sizeof(Acmd);
task->yieldDataPtr = NULL;
task->yieldDataSize = 0;
task->data_ptr = (u64*)gAudioCtx.abiCmdBufs[index];
task->data_size = numAbiCmds * sizeof(Acmd);
task->yield_data_ptr = NULL;
task->yield_data_size = 0;
if (gAudioCtx.numAbiCmdsMax < numAbiCmds) {
gAudioCtx.numAbiCmdsMax = numAbiCmds;
+4 -4
View File
@@ -280,7 +280,7 @@ s32 func_801A5808(void) {
PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue);
if (func_801A51F0(errorCode) == 0) {
switch (gVoiceHandle.status) {
switch (gVoiceHandle.cmd_status) {
case VOICE_STATUS_READY:
sVoiceContext.mode = VOICE_MODE_2;
break;
@@ -305,10 +305,10 @@ s32 func_801A5808(void) {
case VOICE_MODE_2:
if (((D_801FD5C8.warning & sVoiceContext.warning) == 0) &&
(sVoiceContext.answerNum >= D_801FD5C8.answerNum) &&
(sVoiceContext.answerNum >= D_801FD5C8.answer_num) &&
(sVoiceContext.distance >= D_801FD5C8.distance[0]) &&
(D_801FD5C8.voiceLevel >= sVoiceContext.voiceLevel) &&
(D_801FD5C8.voiceRelLevel >= sVoiceContext.voiceRelLevel)) {
(D_801FD5C8.voice_level >= sVoiceContext.voiceLevel) &&
(D_801FD5C8.voice_sn >= sVoiceContext.voiceRelLevel)) {
D_801FD5E8 = D_801FD5C8;
sVoiceContext.data = &D_801FD5E8;
}
+1
View File
@@ -1,5 +1,6 @@
#include "prevent_bss_reordering.h"
#include "CIC6105.h"
#include "build.h"
#include "fault.h"
+6 -2
View File
@@ -7,9 +7,13 @@ void MtxConv_F2L(Mtx* mtx, MtxF* mf) {
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
s32 value = (mf->mf[i][j] * 0x10000);
struct {
u16 intPart[4][4];
u16 fracPart[4][4];
}* mu = (void*)mtx;
mtx->intPart[i][j] = value >> 16;
mtx->fracPart[i][j] = value;
mu->intPart[i][j] = value >> 16;
mu->fracPart[i][j] = value;
}
}
}
+1 -2
View File
@@ -1,9 +1,8 @@
#include "prevent_bss_reordering.h"
#include "carthandle.h"
#include "CIC6105.h"
#include "idle.h"
#include "stack.h"
#include "stackcheck.h"
#include "CIC6105.h"
#include "z64thread.h"
StackEntry sBootStackInfo;
+7 -9
View File
@@ -39,19 +39,18 @@
* DPad-Up may be pressed to enable sending fault pages over osSyncPrintf as well as displaying them on-screen.
* DPad-Down disables sending fault pages over osSyncPrintf.
*/
#include "fault_internal.h"
#include "fault.h"
#include "fault_internal.h"
#include "libc64/sprintf.h"
#include "libc64/sleep.h"
#include "vt.h"
#include "libc64/sprintf.h"
#include "PR/osint.h"
#include "macros.h"
#include "main.h"
#include "vt.h"
#include "stackcheck.h"
#include "z64thread.h"
#include "main.h"
#include "macros.h"
#include "global.h"
FaultMgr* sFaultInstance;
f32 sFaultTimeTotal; // read but not set anywhere
@@ -547,7 +546,7 @@ void Fault_Wait5Seconds(void) {
do {
Fault_Sleep(1000 / 60);
} while ((osGetTime() - start) <= OS_SEC_TO_CYCLES(5));
} while ((osGetTime() - start) <= OS_USEC_TO_CYCLES(5 * 1000 * 1000));
sFaultInstance->autoScroll = true;
}
@@ -931,7 +930,6 @@ void Fault_SetOptions(void) {
uintptr_t ra;
uintptr_t sp;
// BTN_RESET is the "neutral reset". Corresponds to holding L+R and pressing S
if (CHECK_BTN_ALL(input3->press.button, BTN_RESET)) {
faultCustomOptions = !faultCustomOptions;
}
+2 -1
View File
@@ -7,7 +7,8 @@
#include "fault.h"
#include "fault_internal.h"
#include "global.h"
#include "macros.h"
#include "vt.h"
typedef struct {
+5 -3
View File
@@ -35,7 +35,9 @@
#include "irqmgr.h"
#include "libc/stdbool.h"
#include "macros.h"
#include "scheduler.h"
#include "stackcheck.h"
#include "z64thread.h"
@@ -145,7 +147,7 @@ void IrqMgr_HandlePreNMI(IrqMgr* irqMgr) {
sIrqMgrResetTime = irqMgr->resetTime = osGetTime();
// Wait .45 seconds then generate a stage 2 prenmi interrupt
osSetTimer(&irqMgr->timer, OS_MSEC_TO_CYCLES(450), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI450_MSG);
osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(450 * 1000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI450_MSG);
IrqMgr_JamMesgToClients(irqMgr, (OSMesg)&irqMgr->prenmiMsg);
}
@@ -159,14 +161,14 @@ void IrqMgr_HandlePRENMI450(IrqMgr* irqMgr) {
irqMgr->resetStatus = IRQ_RESET_STATUS_NMI;
// Wait .03 seconds then generate a stage 3 prenmi interrupt
osSetTimer(&irqMgr->timer, OS_MSEC_TO_CYCLES(30), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI480_MSG);
osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(30 * 1000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI480_MSG);
IrqMgr_SendMesgToClients(irqMgr, (OSMesg)&irqMgr->nmiMsg);
}
void IrqMgr_HandlePRENMI480(IrqMgr* irqMgr) {
// Wait .52 seconds. After this we will have waited an entire second
osSetTimer(&irqMgr->timer, OS_MSEC_TO_CYCLES(520), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI500_MSG);
osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(520 * 1000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI500_MSG);
osAfterPreNMI();
}
+5 -4
View File
@@ -5,18 +5,19 @@
* buffer copies and coverage drawing. Also contains software implementations of the Video Interface anti-aliasing and
* divot filters.
*/
#include "z64prerender.h"
#include "global.h"
#include "PR/gs2dex.h"
#include "libc/alloca.h"
#include "libc/stdbool.h"
#include "PR/gs2dex.h"
#include "global.h"
#include "color.h"
#include "macros.h"
#include "gfx.h"
#include "slowly.h"
#include "stack.h"
#include "stackcheck.h"
#include "prevent_bss_reordering.h"
/**
* Assigns the "save" values in PreRender
-1
View File
@@ -1,4 +1,3 @@
#include "global.h"
#include "libc64/sleep.h"
void func_80183070(void) {
+13 -13
View File
@@ -170,20 +170,20 @@ retry:
task->type = M_GFXTASK;
task->flags = OS_SC_DRAM_DLIST;
task->ucodeBoot = SysUcode_GetUCodeBoot();
task->ucodeBootSize = SysUcode_GetUCodeBootSize();
task->ucode_boot = SysUcode_GetUCodeBoot();
task->ucode_boot_size = SysUcode_GetUCodeBootSize();
task->ucode = SysUcode_GetUCode();
task->ucodeData = SysUcode_GetUCodeData();
task->ucodeSize = SP_UCODE_SIZE;
task->ucodeDataSize = SP_UCODE_DATA_SIZE;
task->dramStack = (u64*)gGfxSPTaskStack;
task->dramStackSize = sizeof(gGfxSPTaskStack);
task->outputBuff = gGfxSPTaskOutputBufferPtr;
task->outputBuffSize = (void*)gGfxSPTaskOutputBufferEnd;
task->dataPtr = (u64*)gGfxMasterDL;
task->dataSize = 0;
task->yieldDataPtr = (u64*)gGfxSPTaskYieldBuffer;
task->yieldDataSize = sizeof(gGfxSPTaskYieldBuffer);
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_size = sizeof(gGfxSPTaskStack);
task->output_buff = gGfxSPTaskOutputBufferPtr;
task->output_buff_size = (void*)gGfxSPTaskOutputBufferEnd;
task->data_ptr = (u64*)gGfxMasterDL;
task->data_size = 0;
task->yield_data_ptr = (u64*)gGfxSPTaskYieldBuffer;
task->yield_data_size = sizeof(gGfxSPTaskYieldBuffer);
scTask->next = NULL;
scTask->flags = OS_SC_RCP_MASK | OS_SC_SWAPBUFFER | OS_SC_LAST_TASK;
+23 -11
View File
@@ -1,11 +1,16 @@
#include "scheduler.h"
#include "libc64/sleep.h"
#include "fault.h"
#include "idle.h"
#include "libc64/sleep.h"
#include "macros.h"
#include "regs.h"
#include "stackcheck.h"
#include "viconfig.h"
#include "z64speed_meter.h"
#include "z64thread.h"
// Variables are put before most headers as a hacky way to bypass bss reordering
FaultClient sSchedFaultClient;
OSTime sRSPGFXStartTime;
@@ -16,17 +21,24 @@ OSTime sRDPStartTime;
u64* gAudioSPDataPtr;
u32 gAudioSPDataSize;
#include "functions.h"
#include "stackcheck.h"
#include "z64speed_meter.h"
#include "z64thread.h"
#define RSP_DONE_MSG 667
#define RDP_DONE_MSG 668
#define NOTIFY_MSG 670
#define RDP_AUDIO_CANCEL_MSG 671
#define RSP_GFX_CANCEL_MSG 672
#define OS_SC_DP 0x0001
#define OS_SC_SP 0x0002
#define OS_SC_YIELD 0x0010
#define OS_SC_YIELDED 0x0020
#define OS_SC_XBUS (OS_SC_SP | OS_SC_DP)
#define OS_SC_DRAM (OS_SC_SP | OS_SC_DP | OS_SC_DRAM_DLIST)
#define OS_SC_DP_XBUS (OS_SC_SP)
#define OS_SC_DP_DRAM (OS_SC_SP | OS_SC_DRAM_DLIST)
#define OS_SC_SP_XBUS (OS_SC_DP)
#define OS_SC_SP_DRAM (OS_SC_DP | OS_SC_DRAM_DLIST)
/**
* Set the current framebuffer to the swapbuffer pointed to by the provided cfb
*/
@@ -193,7 +205,7 @@ halt_rdp:
if (dpTask->type == M_GFXTASK) {
// Try to stop DP
osSyncPrintf("DP止めようとします\n");
bzero(dpTask->outputBuff, (uintptr_t)dpTask->outputBuffSize - (uintptr_t)dpTask->outputBuff);
bzero(dpTask->output_buff, (uintptr_t)dpTask->output_buff_size - (uintptr_t)dpTask->output_buff);
osSendMesg(&sched->interruptQueue, (OSMesg)RDP_DONE_MSG, OS_MESG_NOBLOCK);
}
}
@@ -376,8 +388,8 @@ void Sched_RunTask(Scheduler* sched, OSScTask* spTask, OSScTask* dpTask) {
if (spTask->list.t.type == M_AUDTASK) {
// Set global pointers to audio task data for use in audio processing
gAudioSPDataPtr = spTask->list.t.dataPtr;
gAudioSPDataSize = spTask->list.t.dataSize;
gAudioSPDataPtr = spTask->list.t.data_ptr;
gAudioSPDataSize = spTask->list.t.data_size;
}
// Begin task execution
@@ -584,7 +596,7 @@ void Sched_FaultClient(void* arg0, void* arg1) {
spTask = sched->curRSPTask;
if (spTask != NULL) {
FaultDrawer_Printf("RSPTask %08x %08x %02x %02x\n%01x %08x %08x\n", spTask, spTask->next, spTask->state,
spTask->flags, spTask->list.t.type, spTask->list.t.dataPtr, spTask->list.t.dataSize);
spTask->flags, spTask->list.t.type, spTask->list.t.data_ptr, spTask->list.t.data_size);
}
dpTask = sched->curRDPTask;
+7 -8
View File
@@ -1,16 +1,15 @@
#include "prevent_bss_reordering.h"
#include "z64speed_meter.h"
#include "libc64/malloc.h"
#include "gfx.h"
#include "main.h"
#include "regs.h"
#include "sys_cfb.h"
#include "libc64/malloc.h"
#include "z64game.h"
#include "z64malloc.h"
#include "z64view.h"
#include "variables.h"
/**
* How much time the RSP ran audio tasks for over the course of `gGraphUpdatePeriod`.
*/
@@ -78,15 +77,15 @@ typedef struct {
#define gDrawRect(gfx, color, ulx, uly, lrx, lry) \
do { \
if (gSysCfbHiResEnabled == true) { \
u32 tmp = color; \
u32 c = color; \
gDPPipeSync(gfx); \
gDPSetFillColor(gfx, ((tmp) << 16) | (tmp)); \
gDPSetFillColor(gfx, ((c) << 16) | (c)); \
gDPFillRectangle(gfx, (ulx)*2, (uly)*2, (lrx)*2, (lry)*2); \
if (1) {} \
} else { \
u32 tmp = color; \
u32 c = color; \
gDPPipeSync(gfx); \
gDPSetFillColor(gfx, ((tmp) << 16) | (tmp)); \
gDPSetFillColor(gfx, ((c) << 16) | (c)); \
gDPFillRectangle(gfx, (ulx), (uly), (lrx), (lry)); \
} \
} while (0)
+40 -35
View File
@@ -77,43 +77,46 @@
*/
void Mtx_SetTranslateScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY,
f32 translateZ) {
Mtx* m = mtx;
struct {
u16 intPart[4][4];
u16 fracPart[4][4];
}* mu = (void*)mtx;
s32 fixedPoint;
m->m[0][1] = 0; // [i02, i03] == [0, 0]
m->m[2][1] = 0; // [f02, f03] == [0, 0]
m->m[0][3] = 0; // [i12, i13] == [0, 0]
m->m[2][3] = 0; // [f22, f23] == [0, 0]
m->m[1][0] = 0; // [i20, i21] == [0, 0]
//
fixedPoint = scaleX * 0x10000; //
m->m[0][0] = fixedPoint; // [i00, i01] == [scaleX.i, scaleX.f]; i01 is now "dirty"
m->intPart[0][1] = 0; // Clean i01 by zeroing it: [i00, i01] == [scaleX.i, 0]
m->m[2][0] = (u32)fixedPoint << 16; // [f00, f01] == [scaleX.f, 0]
//
fixedPoint = scaleY * 0x10000; //
m->m[0][2] = (u32)fixedPoint >> 16; // [i10, i11] == [0, scaleY.i]
m->m[2][2] = fixedPoint & 0xFFFF; // [f10, f11] == [0, scaleY.f]
//
fixedPoint = scaleZ * 0x10000; //
m->m[1][1] = fixedPoint; // [i22, i23] == [scaleZ.i, scaleZ.f]
m->intPart[2][3] = 0; // [i22, i23] == [scaleZ.i, 0]
m->m[3][1] = (u32)fixedPoint << 16; // [f22, f23] == [scaleZ.f, 0]
//
m->m[3][0] = 0; // [f20, f21] == [0, 0]
//
fixedPoint = translateX * 0x10000; //
m->intPart[3][0] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateX.i, ?]
m->fracPart[3][0] = fixedPoint & 0xFFFF; // [f30, f31] == [translateX.f, ?]
//
fixedPoint = translateY * 0x10000; //
m->intPart[3][1] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateX.i, translateY.i]
m->fracPart[3][1] = fixedPoint & 0xFFFF; // [f30, f31] == [translateX.f, translateY.f]
//
fixedPoint = translateZ * 0x10000; //
m->intPart[3][2] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateZ.i, ?]
m->intPart[3][3] = 1; // [i32, i33] == [translateZ.i, 1]
m->m[3][3] = (u32)fixedPoint << 16; // [f32, f33] == [translateZ.f, 0]
mtx->m[0][1] = 0; // [i02, i03] == [0, 0]
mtx->m[2][1] = 0; // [f02, f03] == [0, 0]
mtx->m[0][3] = 0; // [i12, i13] == [0, 0]
mtx->m[2][3] = 0; // [f22, f23] == [0, 0]
mtx->m[1][0] = 0; // [i20, i21] == [0, 0]
//
fixedPoint = scaleX * 0x10000; //
mtx->m[0][0] = fixedPoint; // [i00, i01] == [scaleX.i, scaleX.f]; i01 is now "dirty"
mu->intPart[0][1] = 0; // Clean i01 by zeroing it: [i00, i01] == [scaleX.i, 0]
mtx->m[2][0] = (u32)fixedPoint << 16; // [f00, f01] == [scaleX.f, 0]
//
fixedPoint = scaleY * 0x10000; //
mtx->m[0][2] = (u32)fixedPoint >> 16; // [i10, i11] == [0, scaleY.i]
mtx->m[2][2] = fixedPoint & 0xFFFF; // [f10, f11] == [0, scaleY.f]
//
fixedPoint = scaleZ * 0x10000; //
mtx->m[1][1] = fixedPoint; // [i22, i23] == [scaleZ.i, scaleZ.f]
mu->intPart[2][3] = 0; // [i22, i23] == [scaleZ.i, 0]
mtx->m[3][1] = (u32)fixedPoint << 16; // [f22, f23] == [scaleZ.f, 0]
//
mtx->m[3][0] = 0; // [f20, f21] == [0, 0]
//
fixedPoint = translateX * 0x10000; //
mu->intPart[3][0] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateX.i, ?]
mu->fracPart[3][0] = fixedPoint & 0xFFFF; // [f30, f31] == [translateX.f, ?]
//
fixedPoint = translateY * 0x10000; //
mu->intPart[3][1] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateX.i, translateY.i]
mu->fracPart[3][1] = fixedPoint & 0xFFFF; // [f30, f31] == [translateX.f, translateY.f]
//
fixedPoint = translateZ * 0x10000; //
mu->intPart[3][2] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateZ.i, ?]
mu->intPart[3][3] = 1; // [i32, i33] == [translateZ.i, 1]
mtx->m[3][3] = (u32)fixedPoint << 16; // [f32, f33] == [translateZ.f, 0]
// So we end up with
// [scaleX.i, 0], [0, 0],
@@ -159,6 +162,7 @@ void Mtx_SetTranslateScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32
*
* @remark Original name: probably something like "suMtxMakeR" or "suMtxMakeRotateVector"
*/
// TODO: Find a way to match without the intPart/fracPart union (see Mtx_SetTranslateScaleMtx)
void Mtx_SetRotationMtx(Mtx* mtx, s32 angle, f32 axisX, f32 axisY, f32 axisZ) {
//! FAKE? The somewhat peculiar distribution of temps in this function seems necessary to match?
f32 tempX;
@@ -275,6 +279,7 @@ void Mtx_SetRotationMtx(Mtx* mtx, s32 angle, f32 axisX, f32 axisY, f32 axisZ) {
* @remark Original name: probably something like "suMtxMakeSRT", although Animal Forest function is a Tait-Bryan
* rotation rather than axis-angle.
*/
// TODO: Find a way to match without the intPart/fracPart union (see Mtx_SetTranslateScaleMtx)
void Mtx_SetTranslationRotationScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s32 angle, f32 axisX, f32 axisY,
f32 axisZ, f32 translateX, f32 translateY, f32 translateZ) {
f32 tempX;
+6 -5
View File
@@ -1,12 +1,13 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "sys_flashrom.h"
#include "libc64/malloc.h"
#include "PR/os_internal_flash.h"
#include "fault.h"
#include "macros.h"
#include "stack.h"
#include "stackcheck.h"
#include "libc64/malloc.h"
#include "z64thread.h"
#include "sys_flashrom.h"
#include "PR/os_internal_flash.h"
OSMesgQueue sFlashromMesgQueue;
OSMesg sFlashromMesg[1];
+5 -2
View File
@@ -38,9 +38,12 @@
* Throughout this file, `mode` indicates whether to multiply the matrix on top of the stack by the new construction
* (APPLY), or to just overwrite it (NEW).
*/
#include "sys_matrix.h"
#include "prevent_bss_reordering.h"
#include "global.h"
#include "gfx.h"
#include "macros.h"
#include "z64game.h"
#include "z64skin_matrix.h"
/* data */
+23 -23
View File
@@ -2,35 +2,20 @@
* File: z_actor.c
* Description:
*/
#include "z64actor.h"
#include "prevent_bss_reordering.h"
#include "fault.h"
#include "sys_cfb.h"
#include "loadfragment.h"
#include "z64horse.h"
#include "z64malloc.h"
#include "z64quake.h"
#include "z64rumble.h"
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
#include "overlays/actors/ovl_En_Part/z_en_part.h"
#include "overlays/actors/ovl_En_Box/z_en_box.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h"
#include "objects/object_bdoor/object_bdoor.h"
// bss
// Variables are put before most headers as a hacky way to bypass bss reordering
FaultClient sActorFaultClient; // 2 funcs
CollisionPoly* D_801ED8B0; // 1 func
s32 D_801ED8B4; // 2 funcs
struct CollisionPoly* D_801ED8B0; // 1 func
s32 D_801ED8B4; // 2 funcs
Actor* sTargetableNearestActor;
Actor* sTargetablePrioritizedActor;
Actor* D_801ED8C0;
Actor* D_801ED8C4;
struct Actor* sTargetableNearestActor;
struct Actor* sTargetablePrioritizedActor;
struct Actor* D_801ED8C0;
struct Actor* D_801ED8C4;
f32 sTargetableNearestActorDistSq;
f32 sBgmEnemyDistSq;
@@ -41,7 +26,22 @@ s16 sTargetPlayerRotY;
Mtx sActorHiliteMtx;
Actor* D_801ED920; // 2 funcs. 1 out of z_actor
struct Actor* D_801ED920; // 2 funcs. 1 out of z_actor
#include "z64actor.h"
#include "z64horse.h"
#include "z64malloc.h"
#include "z64quake.h"
#include "z64rumble.h"
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
#include "overlays/actors/ovl_En_Part/z_en_part.h"
#include "overlays/actors/ovl_En_Box/z_en_box.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h"
#include "objects/object_bdoor/object_bdoor.h"
#define ACTOR_AUDIO_FLAG_SFX_ACTOR_POS (1 << 0)
#define ACTOR_AUDIO_FLAG_SFX_CENTERED_1 (1 << 1)
-1
View File
@@ -1,4 +1,3 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "fault.h"
+6 -1
View File
@@ -1,8 +1,13 @@
#include "prevent_bss_reordering.h"
#include "fault.h"
#include "z64bgcheck.h"
#include "libc64/fixed_point.h"
#include "libc64/sprintf.h"
#include "fault.h"
#include "vt.h"
#include "z64actor.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
#define DYNA_RAYCAST_FLOORS 1
-1
View File
@@ -1,4 +1,3 @@
#include "prevent_bss_reordering.h"
#include "z64collision_check.h"
#include "z64actor.h"
+4 -4
View File
@@ -53,10 +53,10 @@ void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) {
workBuf->taskData.qTableVPtr = &workBuf->qTableV;
sJpegTask.flags = 0;
sJpegTask.ucodeBoot = SysUcode_GetUCodeBoot();
sJpegTask.ucodeBootSize = SysUcode_GetUCodeBootSize();
sJpegTask.yieldDataPtr = (u64*)&workBuf->yieldData;
sJpegTask.dataPtr = (u64*)&workBuf->taskData;
sJpegTask.ucode_boot = SysUcode_GetUCodeBoot();
sJpegTask.ucode_boot_size = SysUcode_GetUCodeBootSize();
sJpegTask.yield_data_ptr = (u64*)&workBuf->yieldData;
sJpegTask.data_ptr = (u64*)&workBuf->taskData;
jpegCtx->scTask.next = NULL;
jpegCtx->scTask.flags = OS_SC_NEEDS_RSP;
+8 -5
View File
@@ -1,12 +1,15 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "z64message.h"
#include "message_data_static.h"
#include "padmgr.h"
#include "z64actor.h"
#include "z64horse.h"
#include "z64shrink_window.h"
#include "z64view.h"
#include "message_data_static.h"
#include "interface/parameter_static/parameter_static.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
#include "interface/parameter_static/parameter_static.h"
u8 D_801C6A70 = 0;
s16 sOcarinaButtonIndexBufPos = 0;
s16 sOcarinaButtonIndexBufLen = 0;
+4 -3
View File
@@ -1,7 +1,8 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "libc/string.h"
#include "z64quake.h"
#include "libc/string.h"
#include "global.h"
#include "z64view.h"
typedef struct {
-1
View File
@@ -1,4 +1,3 @@
#include "prevent_bss_reordering.h"
#include "global.h"
s32 sMatAnimStep;
+4 -3
View File
@@ -2,11 +2,12 @@
* File: z_shrink_window.c
* Description: Draws black top/bottom/side borders on the viewing window (e.g. Z-targeting, talking to NPC)
*/
#include "prevent_bss_reordering.h"
#include "global.h"
#include "z64shrink_window.h"
#include "gfx.h"
#include "main.h"
#include "z64math.h"
typedef struct {
/* 0x0 */ s8 letterboxTarget;
/* 0x1 */ s8 letterboxSize;
+7 -2
View File
@@ -1,7 +1,12 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "z64skin.h"
#include "libc/stdbool.h"
#include "global.h"
#include "gfx.h"
#include "sys_matrix.h"
#include "z64actor.h"
// 60 is an arbitrary number which specifies the max amount of limbs per skeleton this system supports
MtxF gSkinLimbMatrices[60];
+10 -10
View File
@@ -14,12 +14,12 @@ OSTask* _VirtualToPhysicalTask(OSTask* intp) {
bcopy(intp, tp, sizeof(OSTask));
_osVirtualToPhysical(tp->t.ucode);
_osVirtualToPhysical(tp->t.ucodeData);
_osVirtualToPhysical(tp->t.dramStack);
_osVirtualToPhysical(tp->t.outputBuff);
_osVirtualToPhysical(tp->t.outputBuffSize);
_osVirtualToPhysical(tp->t.dataPtr);
_osVirtualToPhysical(tp->t.yieldDataPtr);
_osVirtualToPhysical(tp->t.ucode_data);
_osVirtualToPhysical(tp->t.dram_stack);
_osVirtualToPhysical(tp->t.output_buff);
_osVirtualToPhysical(tp->t.output_buff_size);
_osVirtualToPhysical(tp->t.data_ptr);
_osVirtualToPhysical(tp->t.yield_data_ptr);
return tp;
}
@@ -28,12 +28,12 @@ void osSpTaskLoad(OSTask* intp) {
OSTask* tp = _VirtualToPhysicalTask(intp);
if (tp->t.flags & OS_TASK_YIELDED) {
tp->t.ucodeData = tp->t.yieldDataPtr;
tp->t.ucodeDataSize = tp->t.yieldDataSize;
tp->t.ucode_data = tp->t.yield_data_ptr;
tp->t.ucode_data_size = tp->t.yield_data_size;
intp->t.flags &= ~OS_TASK_YIELDED;
if (tp->t.flags & OS_TASK_LOADABLE) {
tp->t.ucode = (void*)IO_READ((uintptr_t)intp->t.yieldDataPtr + OS_YIELD_DATA_SIZE - 4);
tp->t.ucode = (void*)IO_READ((uintptr_t)intp->t.yield_data_ptr + OS_YIELD_DATA_SIZE - 4);
}
}
@@ -46,7 +46,7 @@ void osSpTaskLoad(OSTask* intp) {
while (__osSpDeviceBusy()) {}
while (__osSpRawStartDma(1, SP_IMEM_START, tp->t.ucodeBoot, tp->t.ucodeBootSize) == -1) {}
while (__osSpRawStartDma(1, SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) {}
}
void osSpTaskStartGo(OSTask* tp) {
+3 -3
View File
@@ -7,16 +7,16 @@
#include "PR/os_voice.h"
s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) {
s32 errorCode = __osVoiceGetStatus(hd->mq, hd->channel, status);
s32 errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, status);
u8 data[2];
if (errorCode == 0) {
if (*status & 1) {
errorCode = CONT_ERR_VOICE_NO_RESPONSE;
} else {
errorCode = __osVoiceContRead2(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContRead2(hd->__mq, hd->__channel, 0, data);
if (errorCode == 0) {
hd->status = data[0] & 7;
hd->cmd_status = data[0] & 7;
if (data[0] & 0x40) {
errorCode = CONT_ERR_VOICE_NO_RESPONSE;
+2 -2
View File
@@ -19,7 +19,7 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 numWords) {
u8 status;
u8 data[4];
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -37,7 +37,7 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 numWords) {
*(u32*)data = 0x2000000;
data[2] = numWords;
errorCode = __osVoiceContWrite4(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContWrite4(hd->__mq, hd->__channel, 0, data);
if (errorCode != 0) {
return errorCode;
}
+2 -2
View File
@@ -21,7 +21,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) {
cmd = 0x98;
}
errorCode = __osVoiceSetADConverter(hd->mq, hd->channel, cmd);
errorCode = __osVoiceSetADConverter(hd->__mq, hd->__channel, cmd);
if (errorCode != 0) {
return errorCode;
}
@@ -32,7 +32,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) {
return CONT_ERR_INVALID;
}
errorCode = __osVoiceSetADConverter(hd->mq, hd->channel, cmd);
errorCode = __osVoiceSetADConverter(hd->__mq, hd->__channel, cmd);
if (errorCode != 0) {
return errorCode;
}
+22 -22
View File
@@ -15,9 +15,9 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) {
u8 status;
u8 data[36];
switch (hd->mode) {
switch (hd->__mode) {
case VOICE_HANDLE_MODE_1:
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -26,21 +26,21 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) {
return CONT_ERR_NOT_READY;
}
errorCode = __osVoiceContRead2(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContRead2(hd->__mq, hd->__channel, 0, data);
if (errorCode != 0) {
return errorCode;
}
sHandleStatus = data[0] & 7;
hd->status = sHandleStatus;
hd->cmd_status = sHandleStatus;
if ((sHandleStatus != VOICE_STATUS_READY) && (sHandleStatus != VOICE_STATUS_END)) {
return CONT_ERR_NOT_READY;
}
// fallthrough
case VOICE_HANDLE_MODE_2:
hd->mode = VOICE_HANDLE_MODE_2;
hd->__mode = VOICE_HANDLE_MODE_2;
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -50,15 +50,15 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) {
}
*(u32*)data = 0x600;
errorCode = __osVoiceContWrite4(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContWrite4(hd->__mq, hd->__channel, 0, data);
if (errorCode != 0) {
return errorCode;
}
// fallthrough
case VOICE_HANDLE_MODE_3:
hd->mode = VOICE_HANDLE_MODE_3;
hd->__mode = VOICE_HANDLE_MODE_3;
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -67,16 +67,16 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) {
return CONT_ERR_VOICE_NO_RESPONSE;
}
errorCode = __osVoiceContRead36(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContRead36(hd->__mq, hd->__channel, 0, data);
if (errorCode != 0) {
return errorCode;
}
result->warning = data[4] + (data[5] << 8);
result->answerNum = data[6];
result->voiceLevel = data[8] + (data[9] << 8);
result->voiceRelLevel = data[10] + (data[11] << 8);
result->voiceTime = data[12] + (data[13] << 8);
result->answer_num = data[6];
result->voice_level = data[8] + (data[9] << 8);
result->voice_sn = data[10] + (data[11] << 8);
result->voice_time = data[12] + (data[13] << 8);
for (i = 0; i < 5; i++) {
result->answer[i] = data[14 + (i << 2)] + (data[15 + (i << 2)] << 8);
@@ -84,18 +84,18 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) {
}
if (result->answer[0] == 0x7FFF) {
result->answerNum = 0;
result->answer_num = 0;
}
hd->status = data[34] & 7;
if ((sHandleStatus == VOICE_STATUS_READY) || (hd->status == VOICE_STATUS_READY)) {
hd->cmd_status = data[34] & 7;
if ((sHandleStatus == VOICE_STATUS_READY) || (hd->cmd_status == VOICE_STATUS_READY)) {
break;
}
// fallthrough
case VOICE_HANDLE_MODE_4:
hd->mode = VOICE_HANDLE_MODE_4;
hd->__mode = VOICE_HANDLE_MODE_4;
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -104,12 +104,12 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) {
return CONT_ERR_VOICE_NO_RESPONSE;
}
errorCode = __osVoiceContRead2(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContRead2(hd->__mq, hd->__channel, 0, data);
if (errorCode != 0) {
return errorCode;
}
hd->status = data[0] & 7;
hd->cmd_status = data[0] & 7;
if (data[0] & 7) {
return CONT_ERR_VOICE_NO_RESPONSE;
}
@@ -120,6 +120,6 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) {
return CONT_ERR_INVALID;
}
hd->mode = VOICE_HANDLE_MODE_0;
hd->__mode = VOICE_HANDLE_MODE_0;
return errorCode;
}
+3 -3
View File
@@ -20,9 +20,9 @@ s32 osVoiceInit(OSMesgQueue* mq, OSVoiceHandle* hd, int channel) {
u8 status = 0;
u8 data[4];
hd->channel = channel;
hd->mq = mq;
hd->mode = VOICE_HANDLE_MODE_0;
hd->__channel = channel;
hd->__mq = mq;
hd->__mode = VOICE_HANDLE_MODE_0;
errorCode = __osVoiceGetStatus(mq, channel, &status);
if (errorCode != 0) {
+2 -2
View File
@@ -17,7 +17,7 @@ s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, int size) {
u8 status;
u8 data[20];
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -45,7 +45,7 @@ s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, int size) {
data[ARRAY_COUNT(data) - 1] = 0;
}
errorCode = __osVoiceContWrite20(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContWrite20(hd->__mq, hd->__channel, 0, data);
if (errorCode == 0) {
errorCode = __osVoiceCheckResult(hd, &status);
if (errorCode & 0xFF00) {
+3 -3
View File
@@ -17,7 +17,7 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) {
u8 status;
u8 data[40];
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -42,13 +42,13 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) {
data[ARRAY_COUNT(data) - 1 - i - 5] = 3;
if (k >= 15) {
errorCode = __osVoiceContWrite20(hd->mq, hd->channel, 0, &data[0]);
errorCode = __osVoiceContWrite20(hd->__mq, hd->__channel, 0, &data[0]);
if (errorCode != 0) {
return errorCode;
}
}
errorCode = __osVoiceContWrite20(hd->mq, hd->channel, 0, &data[20]);
errorCode = __osVoiceContWrite20(hd->__mq, hd->__channel, 0, &data[20]);
if (errorCode != 0) {
return errorCode;
}
+4 -4
View File
@@ -13,7 +13,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) {
u8 status;
u8 data[4];
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -22,7 +22,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) {
return CONT_ERR_VOICE_NO_RESPONSE;
}
if (hd->mode != VOICE_HANDLE_MODE_0) {
if (hd->__mode != VOICE_HANDLE_MODE_0) {
return CONT_ERR_INVALID;
}
@@ -33,7 +33,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) {
* data[3] = 0
*/
*(u32*)data = 0x5000000;
errorCode = __osVoiceContWrite4(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContWrite4(hd->__mq, hd->__channel, 0, data);
if (errorCode == 0) {
errorCode = __osVoiceCheckResult(hd, &status);
@@ -41,7 +41,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) {
if (errorCode & 0xFF00) {
errorCode = CONT_ERR_INVALID;
} else {
hd->mode = VOICE_HANDLE_MODE_1;
hd->__mode = VOICE_HANDLE_MODE_1;
}
}
+5 -5
View File
@@ -14,7 +14,7 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) {
u8 status;
u8 data[4];
errorCode = __osVoiceGetStatus(hd->mq, hd->channel, &status);
errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, &status);
if (errorCode != 0) {
return errorCode;
}
@@ -23,7 +23,7 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) {
return CONT_ERR_VOICE_NO_RESPONSE;
}
if (hd->mode == VOICE_HANDLE_MODE_0) {
if (hd->__mode == VOICE_HANDLE_MODE_0) {
return CONT_ERR_INVALID;
}
@@ -34,7 +34,7 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) {
* data[3] = 0
*/
*(u32*)data = 0x700;
errorCode = __osVoiceContWrite4(hd->mq, hd->channel, 0, data);
errorCode = __osVoiceContWrite4(hd->__mq, hd->__channel, 0, data);
if (errorCode == 0) {
i = 0;
@@ -43,12 +43,12 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) {
if (errorCode & 0xFF00) {
if (((errorCode & 7) == 0) || ((errorCode & 7) == 7)) {
errorCode = 0;
hd->mode = VOICE_HANDLE_MODE_0;
hd->__mode = VOICE_HANDLE_MODE_0;
} else {
errorCode = CONT_ERR_INVALID;
}
} else {
hd->mode = VOICE_HANDLE_MODE_0;
hd->__mode = VOICE_HANDLE_MODE_0;
}
i++;
} while ((errorCode == CONT_ERR_VOICE_NO_RESPONSE) && (i < 20));
@@ -3,7 +3,6 @@
* Overlay: ovl_En_Fishing
* Description: Fishing Pond Elements (Owner, Fish, Props, Effects...)
*/
#include "prevent_bss_reordering.h"
#include "z_en_fishing.h"
#include "z64rumble.h"
#include "z64shrink_window.h"