From a2ef26b36701f1c478fa9a84fe11b07e58db9083 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 9 Sep 2021 09:18:51 -0400 Subject: [PATCH] Identify many variable types and fix some compiler warnings --- .../unknown_078050/setupOSTasks.s | 16 ++-- include/PR/pfs.h | 2 +- include/PR/ultratypes.h | 2 + include/structs.h | 10 +-- include/types.h | 2 + lib/src/mips1/sc/sched.c | 67 +------------- lib/src/mips1/sc/sched.h | 89 +++++++++++++++++++ src/camera.c | 67 +++++++------- src/camera.h | 4 +- src/controller_pak.c | 5 +- src/memory.h | 2 +- src/unknown_0255E0.c | 15 ++-- src/unknown_0255E0.h | 4 +- src/unknown_0348C0.c | 14 +-- src/unknown_043920.c | 13 +-- src/unknown_043920.h | 2 +- src/unknown_06B2B0.c | 14 ++- src/unknown_06B2B0.h | 4 +- src/unknown_078050.c | 7 +- src/unknown_078050.h | 1 + src/video.c | 4 +- src/video.h | 1 + 22 files changed, 186 insertions(+), 159 deletions(-) create mode 100644 lib/src/mips1/sc/sched.h diff --git a/asm/non_matchings/unknown_078050/setupOSTasks.s b/asm/non_matchings/unknown_078050/setupOSTasks.s index 83f5b85a..7a39ce56 100644 --- a/asm/non_matchings/unknown_078050/setupOSTasks.s +++ b/asm/non_matchings/unknown_078050/setupOSTasks.s @@ -79,9 +79,9 @@ glabel setupOSTasks /* 078180 80077580 ACF8000C */ sw $t8, 0xc($a3) /* 078184 80077584 0C034628 */ jal osWritebackDCacheAll /* 078188 80077588 AFA7001C */ sw $a3, 0x1c($sp) -/* 07818C 8007758C 3C048012 */ lui $a0, %hi(D_80126100) # $a0, 0x8012 +/* 07818C 8007758C 3C048012 */ lui $a0, %hi(osScInterruptQ) # $a0, 0x8012 /* 078190 80077590 8FA5001C */ lw $a1, 0x1c($sp) -/* 078194 80077594 8C846100 */ lw $a0, %lo(D_80126100)($a0) +/* 078194 80077594 8C846100 */ lw $a0, %lo(osScInterruptQ)($a0) /* 078198 80077598 0C03238C */ jal osSendMesg /* 07819C 8007759C 24060001 */ li $a2, 1 /* 0781A0 800775A0 8FBF0014 */ lw $ra, 0x14($sp) @@ -172,9 +172,9 @@ glabel setupOSTasks .L800776EC: /* 0782EC 800776EC 0C034628 */ jal osWritebackDCacheAll /* 0782F0 800776F0 AFA70024 */ sw $a3, 0x24($sp) -/* 0782F4 800776F4 3C048012 */ lui $a0, %hi(D_80126100) # $a0, 0x8012 +/* 0782F4 800776F4 3C048012 */ lui $a0, %hi(osScInterruptQ) # $a0, 0x8012 /* 0782F8 800776F8 8FA50024 */ lw $a1, 0x24($sp) -/* 0782FC 800776FC 8C846100 */ lw $a0, %lo(D_80126100)($a0) +/* 0782FC 800776FC 8C846100 */ lw $a0, %lo(osScInterruptQ)($a0) /* 078300 80077700 0C03238C */ jal osSendMesg /* 078304 80077704 24060001 */ li $a2, 1 /* 078308 80077708 8FA80030 */ lw $t0, 0x30($sp) @@ -277,9 +277,9 @@ glabel setupOSTasks .L80077880: /* 078480 80077880 0C034628 */ jal osWritebackDCacheAll /* 078484 80077884 AFA70024 */ sw $a3, 0x24($sp) -/* 078488 80077888 3C048012 */ lui $a0, %hi(D_80126100) # $a0, 0x8012 +/* 078488 80077888 3C048012 */ lui $a0, %hi(osScInterruptQ) # $a0, 0x8012 /* 07848C 8007788C 8FA50024 */ lw $a1, 0x24($sp) -/* 078490 80077890 8C846100 */ lw $a0, %lo(D_80126100)($a0) +/* 078490 80077890 8C846100 */ lw $a0, %lo(osScInterruptQ)($a0) /* 078494 80077894 0C03238C */ jal osSendMesg /* 078498 80077898 24060001 */ li $a2, 1 /* 07849C 8007789C 8FAA0030 */ lw $t2, 0x30($sp) @@ -380,9 +380,9 @@ glabel setupOSTasks /* 078608 80077A08 ACE00068 */ sw $zero, 0x68($a3) /* 07860C 80077A0C 0C034628 */ jal osWritebackDCacheAll /* 078610 80077A10 AFA70024 */ sw $a3, 0x24($sp) -/* 078614 80077A14 3C048012 */ lui $a0, %hi(D_80126100) # $a0, 0x8012 +/* 078614 80077A14 3C048012 */ lui $a0, %hi(osScInterruptQ) # $a0, 0x8012 /* 078618 80077A18 8FA50024 */ lw $a1, 0x24($sp) -/* 07861C 80077A1C 8C846100 */ lw $a0, %lo(D_80126100)($a0) +/* 07861C 80077A1C 8C846100 */ lw $a0, %lo(osScInterruptQ)($a0) /* 078620 80077A20 0C03238C */ jal osSendMesg /* 078624 80077A24 24060001 */ li $a2, 1 /* 078628 80077A28 8FA90030 */ lw $t1, 0x30($sp) diff --git a/include/PR/pfs.h b/include/PR/pfs.h index 183be08e..d3d2928a 100644 --- a/include/PR/pfs.h +++ b/include/PR/pfs.h @@ -134,4 +134,4 @@ typedef struct { u8 map[PFS_INODE_DIST_MAP]; } __OSInodeCache; -#endif \ No newline at end of file +#endif diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index 04b872e3..5657a407 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -39,4 +39,6 @@ typedef s32 ptrdiff_t; //#include //#endif +typedef float Matrix[4][4]; + #endif diff --git a/include/structs.h b/include/structs.h index 9841772d..b42f20c5 100644 --- a/include/structs.h +++ b/include/structs.h @@ -29,10 +29,10 @@ typedef struct MenuElement { /* 0x14 */ char* asciiText; // Pointer to ascii text to be displayed on the screen. /* 0x14 */ u32* texture; // Pointer to texture to be displayed on the screen. /* 0x14 */ s32* number; // Pointer to a number to be displayed on the screen. - /* 0x14 */ u16* numberU16; // Pointer to a number to be displayed on the screen. + /* 0x14 */ u16* numberU16; // Pointer to a number to be displayed on the screen. /* 0x14 */ s32 value; // Some value for elementType == 5 /* 0x14 */ void* element; // Generic pointer - }; + } unk14_a; // Element Background Color/Transparency /* 0x18 */ s16 backgroundRed; /* 0x1A */ s16 backgroundGreen; @@ -565,7 +565,7 @@ typedef struct Object_64 { s8 unk2; s8 unk3; } unk0_b; - }; + } unk0_a; s32 unk4; u8 pad8[4]; union { @@ -661,7 +661,7 @@ typedef struct Object { union { /* 0x0034 */ f32 unk34; /* 0x0034 */ s16 unk34_s; - }; + } unk34_a; /* 0x0038 */ u8 unk38; /* 0x0039 */ u8 unk39; @@ -670,7 +670,7 @@ typedef struct Object { union { /* 0x003C */ Object_3C* unk3C; /* 0x003C */ f32 unk3C_f; - }; + } unk3C_a; /* 0x0040 */ Object_40 *descriptor_ptr; /* 0x0044 */ void *unk44; diff --git a/include/types.h b/include/types.h index a713e4a3..89ade3aa 100644 --- a/include/types.h +++ b/include/types.h @@ -39,6 +39,8 @@ typedef s32 ptrdiff_t; //#include //#endif +typedef float Matrix[4][4]; + #define stubbed_printf #endif diff --git a/lib/src/mips1/sc/sched.c b/lib/src/mips1/sc/sched.c index b48aec28..0ef65685 100644 --- a/lib/src/mips1/sc/sched.c +++ b/lib/src/mips1/sc/sched.c @@ -1,69 +1,12 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x80079350 */ +#include "sched.h" #include "types.h" #include "macros.h" #include "f3ddkr.h" #include "libultra_internal.h" -#define OS_SC_RETRACE_MSG 1 -#define OS_SC_PRE_NMI_MSG 4 -#define OS_SC_MAX_MESGS 8 - -#define OS_SC_YIELD 2 - -typedef struct { - short type; - char misc[30]; -} OSScMsg; - -typedef struct OSScTask_s { - struct OSScTask_s *next; /* note: this must be first */ - u32 state; - u32 flags; - void *framebuffer; /* used by graphics tasks */ - - OSTask list; - OSMesgQueue *msgQ; - OSMesg msg; -#ifndef _FINALROM /* all #ifdef items should */ - OSTime startTime; /* remain at the end!!, or */ - OSTime totalTime; /* possible conflict if */ -#endif /* FINALROM library used with */ -} OSScTask; /* non FINALROM code */ - - -typedef struct SCClient_s { - u8 unk0; - struct SCClient_s *next; /* next client in the list */ - OSMesgQueue *msgQ; /* where to send the frame msg */ -} OSScClient; - -typedef struct { - OSScMsg retraceMsg; - OSScMsg prenmiMsg; - OSMesgQueue interruptQ; - OSMesg intBuf[OS_SC_MAX_MESGS]; - OSMesgQueue cmdQ; - OSMesg cmdMsgBuf[OS_SC_MAX_MESGS]; - OSThread thread; - OSScClient *clientList; - OSScTask *audioListHead; - OSScTask *gfxListHead; - OSScTask *audioListTail; - OSScTask *gfxListTail; - OSScTask *curRSPTask; - OSScTask *curRDPTask; - u32 frameCount; - s32 doAudio; - s32 unk284; -} OSSched; - -typedef struct{ - u8 pad00[0x50]; -}unk800E3900; - - /************ .data ************/ // Unsure about if this is an array or struct. @@ -107,10 +50,6 @@ const char D_800E7928[] = "\toutput_buff_size\t\t= %u\n"; const char D_800E7944[] = "\tdata_ptr\t\t= %p\n"; const char D_800E7958[] = "\tdata_size\t\t= %u\n"; -/*********************************/ - -extern OSViMode osViModeTable[]; - /************ .bss ************/ s32 D_80126110; @@ -201,8 +140,8 @@ OSMesgQueue *osScGetCmdQ(OSSched *sc){ return &sc->cmdQ; } -s32 func_8007957C(s32 arg0) { - return arg0 + 0x40; +OSMesgQueue *osScGetInterruptQ(OSSched *sc) { + return &sc->interruptQ; } // Unused. diff --git a/lib/src/mips1/sc/sched.h b/lib/src/mips1/sc/sched.h new file mode 100644 index 00000000..9fa4a8a5 --- /dev/null +++ b/lib/src/mips1/sc/sched.h @@ -0,0 +1,89 @@ +#ifndef _SCHED_H_ +#define _SCHED_H_ +#include "types.h" +#include "macros.h" +#include "f3ddkr.h" +#include "libultra_internal.h" + +#define OS_SC_RETRACE_MSG 1 +#define OS_SC_PRE_NMI_MSG 4 +#define OS_SC_MAX_MESGS 8 + +#define OS_SC_YIELD 2 + +typedef struct { + short type; + char misc[30]; +} OSScMsg; + +typedef struct OSScTask_s { + struct OSScTask_s *next; /* note: this must be first */ + u32 state; + u32 flags; + void *framebuffer; /* used by graphics tasks */ + + OSTask list; + OSMesgQueue *msgQ; + OSMesg msg; +#ifndef _FINALROM /* all #ifdef items should */ + OSTime startTime; /* remain at the end!!, or */ + OSTime totalTime; /* possible conflict if */ +#endif /* FINALROM library used with */ +} OSScTask; /* non FINALROM code */ + + +typedef struct SCClient_s { + u8 unk0; + struct SCClient_s *next; /* next client in the list */ + OSMesgQueue *msgQ; /* where to send the frame msg */ +} OSScClient; + +/* 0x71C bytes */ +typedef struct { + /* 0x00 */ OSScMsg retraceMsg; + /* 0x20 */ OSScMsg prenmiMsg; + /* 0x40 */ OSMesgQueue interruptQ; + /* 0x68 */ OSMesg intBuf[OS_SC_MAX_MESGS]; //0x8 per OsMesg + /* 0xA8 */ OSMesgQueue cmdQ; + /* 0xD0 */ OSMesg cmdMsgBuf[OS_SC_MAX_MESGS]; //0x8 per OsMesg + /* 0x110 */ OSThread thread; + /* 0x2D8 */ OSScClient *clientList; + /* 0x2F0 */ OSScTask *audioListHead; + /* 0x3A0 */ OSScTask *gfxListHead; + /* 0x450 */ OSScTask *audioListTail; + /* 0x500 */ OSScTask *gfxListTail; + /* 0x5B0 */ OSScTask *curRSPTask; + /* 0x660 */ OSScTask *curRDPTask; + /* 0x710 */ u32 frameCount; + /* 0x714 */ s32 doAudio; + /* 0x718 */ s32 unk284; +} OSSched; + +typedef struct{ + u8 pad00[0x50]; +} unk800E3900; + +extern OSViMode osViModeTable[]; + +/*******************************/ + +void func_8007A080(OSSched *sc); +void __scMain(void); +void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp); +void osCreateScheduler(OSSched *sc, void *stack, OSPri priority, u8 mode, u8 numFields); +void osScAddClient(OSSched *sc, OSScClient *c, OSMesgQueue *msgQ, u8 arg3); +void osScRemoveClient(OSSched *sc, OSScClient *c); +OSMesgQueue *osScGetCmdQ(OSSched *sc); +OSMesgQueue *osScGetInterruptQ(OSSched *sc); +void func_80079584(f32 *arg0, f32 *arg1, f32 *arg2); +void func_80079760(OSSched *sc); +void __scHandleRDP(OSSched *sc); +OSScTask *__scTaskReady(OSScTask *t); +s32 __scTaskComplete(OSSched *sc, OSScTask *t); +void __scAppendList(OSSched *sc, OSScTask *t); +void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp); +void func_8007A080(OSSched *sc); +// This might need to be moved into it's own file. +void set_rsp_segment(Gfx **dlist, s32 segment, s32 base); + +#endif diff --git a/src/camera.c b/src/camera.c index eb7ff9d5..cffa4905 100644 --- a/src/camera.c +++ b/src/camera.c @@ -1,6 +1,7 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x80065EA0 */ +#include "libultra_internal.h" #include "camera.h" extern u32 osTvType; @@ -75,12 +76,11 @@ f32 D_800DD2A0[6] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f }; -// This is a matrix. -f32 D_800DD2B8[16] = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 160.0f +Matrix D_800DD2B8 = { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 160.0f }, }; u8 D_800DD2F8[8] = { @@ -135,19 +135,19 @@ s32 D_80120D1C; s32 D_80120D20[2]; s32 D_80120D28[6]; s32 D_80120D40[6]; -s32 D_80120D58[6]; +u16 *D_80120D58[6]; Mtx *D_80120D70[6]; s32 D_80120D88[6]; Mtx D_80120DA0[5]; -s32 D_80120EE0[16]; -f32 D_80120F20[16]; // Matrix -s32 D_80120F60[16]; +Matrix D_80120EE0; +Matrix D_80120F20; +Matrix D_80120F60; s32 D_80120FA0[16]; s32 D_80120FE0[16]; s32 D_80121020[16]; -s32 D_80121060[16]; +Matrix D_80121060; s32 D_801210A0[16]; -s32 D_801210E0[6]; +OSMesgQueue *D_801210E0[6]; s32 D_801210F8; s32 D_801210FC; u8 D_80121100[16]; @@ -174,9 +174,8 @@ unk80120AC0 *func_80069D20(void); void func_800014BC(f32 arg0); s8* get_misc_asset(s32 arg0); s32 func_8006A624(s8 arg0); -void guMtxXFMF(s32*, f32, f32, f32, f32*, f32*, f32*); -void guPerspectiveF(s32*, s32*, f32, f32, f32, f32, f32); -void func_8006F870(s32*, s32*); +void guMtxXFMF(Matrix, f32, f32, f32, f32*, f32*, f32*); +void func_8006F870(Matrix, s32[16]); s16 get_level_segment_index_from_position(f32, f32, f32); void func_8006A50C(void); void func_800665E8(s32 arg0); @@ -253,21 +252,21 @@ f32 get_current_camera_fov(void) { void update_camera_fov(f32 camFieldOfView) { if (CAMERA_MIN_FOV < camFieldOfView && camFieldOfView < CAMERA_MAX_FOV && camFieldOfView != gCurCamFOV) { gCurCamFOV = camFieldOfView; - guPerspectiveF(&D_80120EE0, &D_80120D58[5], camFieldOfView, + guPerspectiveF(D_80120EE0, &D_80120D58[5], camFieldOfView, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); - func_8006F870(&D_80120EE0, &D_80120FE0); + func_8006F870(D_80120EE0, D_80120FE0); } } void func_80066194(void) { - guPerspectiveF(&D_80120EE0, &D_80120D58[5], CAMERA_DEFAULT_FOV, + guPerspectiveF(D_80120EE0, &D_80120D58[5], CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); - func_8006F870(&D_80120EE0, &D_80120FE0); + func_8006F870(D_80120EE0, D_80120FE0); } /* Unused? */ s32* func_80066204(void) { - return &D_801210A0; + return D_801210A0; } s32 get_viewport_count(void) { @@ -759,12 +758,12 @@ GLOBAL_ASM("asm/non_matchings/camera/func_80067A3C.s") GLOBAL_ASM("asm/non_matchings/camera/func_80067D3C.s") void func_80067F20(f32 arg0) { - D_800DD2B8[5] = arg0; + D_800DD2B8[1][1] = arg0; } void func_80067F2C(Gfx **dlist, s32 *arg1) { u32 widthAndHeight, width, height; - s32 i; + s32 i, j; widthAndHeight = get_video_width_and_height_as_s32(); height = widthAndHeight >> 0x10; @@ -780,10 +779,14 @@ void func_80067F2C(Gfx **dlist, s32 *arg1) { *arg1 += 0x40; D_80120D1C = 0; D_80120D08 = 0; - + i = 0; - while(i < 16) { // for loop doesn't match here. - D_80120F20[i] = D_800DD2B8[i]; + while(i < 4) { // for loop doesn't match here. + j = 0; + while(j < 4) { + D_80120F20[i][j] = D_800DD2B8[i][j]; + j++; + } i++; } } @@ -793,7 +796,7 @@ void func_8006807C(Gfx **dlist, s32 *arg1) { func_8006F768(&D_80121060, &D_80120EE0, &D_80120F20); func_8006FE74(D_80120D70[0], &D_800DD2A0); func_8006F768(D_80120D70[0], &D_80120F20, &D_80121060); - func_8006F870(&D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! + func_8006F870(D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! fast3d_cmd((*dlist)++, 0x1000040, (u32)(*arg1 + 0x80000000)) *arg1 += 0x40; D_80120D1C = 0; @@ -836,7 +839,7 @@ void func_800682AC(Gfx **dlist) { void func_80068408(Gfx **dlist, s32 *arg1) { func_800705F8(D_80120D70[D_80120D1C], 0.0f, 0.0f, 0.0f); func_8006F768(D_80120D70[D_80120D1C], &D_80120F20, &D_80121060); - func_8006F870(&D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! + func_8006F870(D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! D_80120D88[D_80120D1C] = *arg1; fast3d_cmd((*dlist)++, ((((D_80120D08 << 6) & 0xFF) << 0x10) | 0x1000000) | 0x40, (u32)(*arg1 + 0x80000000)) @@ -874,22 +877,22 @@ unk80120AC0 *func_80069D7C(void) { } s32* func_80069DA4(void) { - return &D_80120FA0; + return D_80120FA0; } s32* func_80069DB0(void) { - return &D_80120FE0; + return D_80120FE0; } s32* func_80069DBC(void) { - return &D_80120F60; + return D_80120F60; } f32 func_80069DC8(f32 arg0, f32 arg1, f32 arg2) { f32 sp34; f32 sp30; f32 returnVal; - guMtxXFMF(&D_80120F60, arg0, arg1, arg2, &sp34, &sp30, &returnVal); + guMtxXFMF(D_80120F60, arg0, arg1, arg2, &sp34, &sp30, &returnVal); return returnVal; } @@ -951,7 +954,7 @@ void func_8006A03C(f32 *mtx) { func_800C9D54("\n"); } -s32* func_8006A100(void) { +OSMesgQueue* func_8006A100(void) { return &D_801210E0; } diff --git a/src/camera.h b/src/camera.h index 9f64d051..49ddb688 100644 --- a/src/camera.h +++ b/src/camera.h @@ -61,7 +61,7 @@ extern f32 D_800DD288[6]; extern f32 D_800DD2A0[6]; -extern f32 D_800DD2B8[16]; +extern Matrix D_800DD2B8; extern u8 D_800DD2F8[8]; @@ -69,4 +69,4 @@ extern s32 D_800DD300; extern s16 gButtonMask; -#endif \ No newline at end of file +#endif diff --git a/src/controller_pak.c b/src/controller_pak.c index 3280426a..3e6922c9 100644 --- a/src/controller_pak.c +++ b/src/controller_pak.c @@ -8,6 +8,7 @@ #include "types.h" #include "macros.h" +#include "structs.h" /************ .data ************/ @@ -78,7 +79,7 @@ s32 D_801241F4; /*******************************/ -u8 func_8006A4F8(arg0); +u8 func_8006A4F8(s32 arg0); u8 func_80072250(s32 arg0) { if ((arg0 == 0 || arg0 == 1) && func_8000E158()) { @@ -161,7 +162,7 @@ s32 func_80073F5C(s32 arg0, s32 arg1) { GLOBAL_ASM("asm/non_matchings/controller_pak/func_80074018.s") -s32 func_80074148(s32 arg0, s32 arg1) { +s32 func_80074148(s32 arg0, Settings *arg1) { u8 *sp2C; s32 phi_v1; s32 sp24; diff --git a/src/memory.h b/src/memory.h index f4675390..ed5cb8d2 100644 --- a/src/memory.h +++ b/src/memory.h @@ -22,4 +22,4 @@ // ??? #define COLOR_TAG_BLACK 0x000000FF -#endif \ No newline at end of file +#endif diff --git a/src/unknown_0255E0.c b/src/unknown_0255E0.c index cd4cb141..eb3dba30 100644 --- a/src/unknown_0255E0.c +++ b/src/unknown_0255E0.c @@ -255,7 +255,7 @@ s32 D_8011D4BC; /******************************/ -extern void guMtxXFMF(void*, f32, f32, f32, f32*, f32*, f32*); +extern void guMtxXFMF(Matrix, f32, f32, f32, f32*, f32*, f32*); f32 func_800BB2F4(s32, f32, f32, f32*); void func_8007B3D0(Gfx**); Object *get_object(s32); @@ -273,8 +273,7 @@ s32 func_800249E0(s32 arg0) { #if 1 GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_800249F0.s") -#else - +#else void func_800249F0(u32 arg0, u32 arg1, s32 arg2, u32 arg3, u32 arg4, u32 arg5, u32 arg6){ s32 i; s32 tmp_a2; @@ -397,7 +396,7 @@ void func_80027FC4(s32 arg0) { sp20.unk0 = arg0; D_8011B0B8 = func_8000EA54(&sp20, 2); if (D_8011B0B8 != 0) { - D_8011B0B8->unk3C = 0; + D_8011B0B8->unk3C_a.unk3C = 0; D_8011B0B8->unk4A = -1; } } @@ -1171,17 +1170,15 @@ void func_80030838(s32 arg0, s32 arg1) { } void func_8003093C(s32 arg0) { - gDPSetFogColor(D_8011B0A0++, D_8011D388[arg0].unk0 >> 0x10, D_8011D388[arg0].unk4 >> 0x10, D_8011D388[arg0].unk8 >> 0x10, 0xFF) - gSPFogPosition(D_8011B0A0++, D_8011D388[arg0].unkC >> 0x10, D_8011D388[arg0].unk10 >> 0x10) + gDPSetFogColor(D_8011B0A0++, D_8011D388[arg0].unk0 >> 0x10, D_8011D388[arg0].unk4 >> 0x10, D_8011D388[arg0].unk8 >> 0x10, 0xFF); + gSPFogPosition(D_8011B0A0++, D_8011D388[arg0].unkC >> 0x10, D_8011D388[arg0].unk10 >> 0x10); } GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80030A74.s") GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80030DE0.s") void func_80031018(void){ - struct { - u8 pad00[0x40]; - } sp_50; //same as unk80535C4_3 + Matrix sp_50; struct { s16 unk00; //sp_38 diff --git a/src/unknown_0255E0.h b/src/unknown_0255E0.h index 3d472345..3ff57731 100644 --- a/src/unknown_0255E0.h +++ b/src/unknown_0255E0.h @@ -9,7 +9,7 @@ typedef struct unknown800DC874 { union { s8 unk00; s32 dummy_force_alignment; // Not sure of a better way to do this. - }; + } unk00_a; u16 unk04; s16 unk06; } unknown800DC874; @@ -31,4 +31,4 @@ extern s32 D_800DC928; extern s8 D_800DC92C[24]; -#endif \ No newline at end of file +#endif diff --git a/src/unknown_0348C0.c b/src/unknown_0348C0.c index d6b3463f..20a5dbf1 100644 --- a/src/unknown_0348C0.c +++ b/src/unknown_0348C0.c @@ -141,7 +141,7 @@ typedef struct LevelObjectEntry80033CC0 { } LevelObjectEntry80033CC0; typedef struct Object_50_80033CC0 { - f32 unk0 + f32 unk0; } Object_50_80033CC0; void func_80033CC0(Object *arg0, LevelObjectEntry80033CC0 *arg1) { @@ -294,7 +294,7 @@ void func_8003564C(Object *arg0, s32 arg1) { Object_64_8003564C *someObj64 = someObj->unk64; someObj64->unk4 = arg0; arg0->unk78 = someObj; - someObj->unk3C = 0; + someObj->unk3C_a.unk3C = 0; } } } @@ -503,7 +503,7 @@ void func_80036194(Object *arg0, s32 arg1) { arg0->unk4C->unk12 = 0; temp = arg0->unk64; temp->unkCD.bytes.byteD = 0xFF; - temp->unk0 = 0.0f; + temp->unk0_a.unk0 = 0.0f; D_8011D4D8 = 0; } @@ -963,7 +963,7 @@ typedef struct Object_3C_80038DC4 { void func_80038DC4(Object *arg0, s32 arg1) { if (arg0->unk78 != 0) { - Object_3C_80038DC4* temp = arg0->unk3C; + Object_3C_80038DC4* temp = arg0->unk3C_a.unk3C; if(arg0->unk4C->unk13 < 0x78) { func_8006F338(temp->unk8); arg0->unk78 = 0; @@ -1085,7 +1085,7 @@ void func_800392B8(Object *arg0, s32 arg1) { arg0->unk4C->unk12 = (u8)0; temp = arg0->unk64; temp->unkCD.bytes.byteD = 0xFF; - temp->unk0 = 0.0f; + temp->unk0_a.unk0 = 0.0f; temp->unk28 = 0; temp->unk2C = 0; temp->unk34 = 0; @@ -1264,7 +1264,7 @@ void func_8003C9EC(Object *arg0, u8 *arg1) { Object_64 *temp = arg0->unk64; arg0->unk3A = arg1[8]; arg0->y_rotation = arg1[9] << 6 << 4; - temp->unk0 = arg0->y_position; + temp->unk0_a.unk0 = arg0->y_position; arg0->unk4C->unk14 = 0x21; arg0->unk4C->unk11 = 2; arg0->unk4C->unk10 = 0x14; @@ -1872,7 +1872,7 @@ void func_80042178(Object *obj, s32 arg1) { Object_3C_80042178* obj3C; unk80042178 sp20; - obj3C = obj->unk3C; + obj3C = obj->unk3C_a.unk3C; if (func_80016DE8(obj->x_position, 0, obj->z_position, (f32) obj3C->unk8, 1, &sp20) > 0) { obj->unk74 = obj3C->unkA; } else { diff --git a/src/unknown_043920.c b/src/unknown_043920.c index 48fb4298..e23a3580 100644 --- a/src/unknown_043920.c +++ b/src/unknown_043920.c @@ -651,15 +651,10 @@ typedef struct unk800535C4_2 { s16 unk1A4; } unk800535C4_2; -/* Size: 0x40 Bytes */ -typedef struct unk800535C4_3 { - u8 unk0[0x40]; -} unk800535C4_3; - -void guMtxXFMF(unk800535C4_3*, f32, f32, f32, s32*, s32*, s32*); +void guMtxXFMF(Matrix*, f32, f32, f32, s32*, s32*, s32*); void func_800535C4(unk800535C4 *arg0, unk800535C4_2 *arg1) { - unk800535C4_3 sp30; + Matrix sp30; D_8011D510.unk0 = -arg1->unk1A0; D_8011D510.unk2 = -arg0->unk2; @@ -735,7 +730,7 @@ void play_char_horn_sound(Object *arg0, Object_64 *arg1) { func_800570B8(arg0, 0x162, 8, 0x82); } else { // Play character's horn sound - func_80057048(arg0, arg1->unk0_b.unk3 + 0x156); + func_80057048(arg0, arg1->unk0_a.unk0_b.unk3 + 0x156); } } @@ -823,7 +818,7 @@ typedef struct Object_64_800575EC { } Object_64_800575EC; void func_800575EC(Object *obj, Object_64_800575EC *obj64) { - f32 sp38[4][4]; + Matrix sp38; D_8011D510.unk0 = obj->y_rotation; D_8011D510.unk2 = obj->x_rotation; diff --git a/src/unknown_043920.h b/src/unknown_043920.h index 3c84013b..cf90d10e 100644 --- a/src/unknown_043920.h +++ b/src/unknown_043920.h @@ -45,4 +45,4 @@ extern s32 D_800DCDD0; extern s16 D_800DCDD4[4]; -#endif \ No newline at end of file +#endif diff --git a/src/unknown_06B2B0.c b/src/unknown_06B2B0.c index fe31f610..e44e8761 100644 --- a/src/unknown_06B2B0.c +++ b/src/unknown_06B2B0.c @@ -4,6 +4,7 @@ #include "unknown_06B2B0.h" #include +#include #include "memory.h" #include "types.h" #include "macros.h" @@ -12,6 +13,7 @@ #include "asset_sections.h" #include "menu.h" #include "video.h" +#include "lib/src/mips1/sc/sched.h" /************ .rodata ************/ @@ -140,7 +142,7 @@ s32 *gHudTriangles[2]; s32 gCurrHudTris; s32 D_80121230[8]; s8 D_80121250[16]; -s32 D_80121260[2210]; +OSSched *D_80121260[2210]; //TODO: This almost definitely isn't an array this large. s32 D_801234E8; s32 D_801234EC; s32 D_801234F0; @@ -167,7 +169,7 @@ s32 gCurrNumHudTrisPerPlayer; s32 gCurrNumHudVertsPerPlayer; s32 D_80123538[3]; s32 D_80123544; -s32 *D_80123548; // This is actually an OSMesgQueue pointer. +OSMesgQueue *D_80123548; s32 D_8012354C; s32 D_80123550[4]; s32 D_80123560[8]; @@ -183,9 +185,7 @@ void func_8006F43C(void); void func_800014BC(f32 arg0); s8 *get_misc_asset(s32 arg0); s32 func_8006A624(s8 arg0); -void guMtxXFMF(s32*, f32, f32, f32, f32*, f32*, f32*); -void guPerspectiveF(s32*, s32*, f32, f32, f32, f32, f32); -void func_8006F870(s32*, s32*); +void func_8006F870(Matrix, s32*); s16 get_level_segment_index_from_position(f32, f32, f32); void func_8006A50C(void); void func_800665E8(s32 arg0); @@ -203,8 +203,6 @@ void func_80004A60(s32, s32); void menu_init(s32); void render(void); void func_8006C3E0(void); -void osCreateScheduler(u16*, s32*, s32, u8, s32); -void osScAddClient(u16*, u8*, s32**, s32); Settings *get_settings(void); s32 is_in_tracks_mode(void); s32 *load_asset_section_from_rom(s32); @@ -942,7 +940,7 @@ void render(void) { gCurrHudVerts = gHudVertices[D_801234E8]; gCurrHudTris = gHudTriangles[D_801234E8]; - set_rsp_segment(&gCurrDisplayList, 0, 0, &D_801234E8); + set_rsp_segment(&gCurrDisplayList, 0, 0); set_rsp_segment(&gCurrDisplayList, 1, gVideoLastFramebuffer); set_rsp_segment(&gCurrDisplayList, 2, gVideoLastDepthBuffer); set_rsp_segment(&gCurrDisplayList, 4, gVideoLastFramebuffer - 0x500); diff --git a/src/unknown_06B2B0.h b/src/unknown_06B2B0.h index 776b63fe..d746e2bc 100644 --- a/src/unknown_06B2B0.h +++ b/src/unknown_06B2B0.h @@ -36,7 +36,7 @@ enum RaceType { RACE_TYPE_CHALLENGE = 0x40, // For masking RACE_TYPE_CHALLENGE_BATTLE = 0x40, RACE_TYPE_CHALLENGE_BANANAS = 0x41, - RACE_TYPE_CHALLENGE_EGGS = 0x42, + RACE_TYPE_CHALLENGE_EGGS = 0x42 }; extern s8 *D_800DD310; @@ -86,4 +86,4 @@ extern s32 D_800DD41C[2]; extern s32 D_800DD424[2]; -#endif \ No newline at end of file +#endif diff --git a/src/unknown_078050.c b/src/unknown_078050.c index 0a914047..b9f7b6f0 100644 --- a/src/unknown_078050.c +++ b/src/unknown_078050.c @@ -2,7 +2,6 @@ /* RAM_POS: 0x80077450 */ #include "unknown_078050.h" - #include "types.h" #include "structs.h" #include "macros.h" @@ -172,7 +171,7 @@ s32 D_80125F38; s32 D_80125F3C; s32 D_80125F40[56]; s32 D_80126020[56]; -u32 D_80126100; +OSMesgQueue *osScInterruptQ; /*******************************/ @@ -282,8 +281,8 @@ void func_800780DC(Gfx** dlist){ gSPDisplayList((*dlist)++, D_800DE4E0) } -void func_80078100(void){ - D_80126100 = func_8007957C(); +void func_80078100(OSSched *sc){ + osScInterruptQ = osScGetInterruptQ(sc); osCreateMesgQueue(&D_80125EA0, &D_80125EB8,1); osCreateMesgQueue(&D_80125EC0, &D_80125EF0,8); osCreateMesgQueue(&D_80125ED8, &D_80125F10,8); diff --git a/src/unknown_078050.h b/src/unknown_078050.h index 077300ae..5f9a1a6d 100644 --- a/src/unknown_078050.h +++ b/src/unknown_078050.h @@ -3,6 +3,7 @@ #include "types.h" #include "f3ddkr.h" +#include "lib/src/mips1/sc/sched.h" extern s16 D_800DE490[16]; diff --git a/src/video.c b/src/video.c index 83a4477b..69520cf4 100644 --- a/src/video.c +++ b/src/video.c @@ -60,7 +60,7 @@ void init_framebuffer(s32); void func_8007A974(void); void swap_framebuffers(void); -void init_video(s32 arg0, s32 arg1) { +void init_video(s32 arg0, OSSched *sc) { if (osTvType == TV_TYPE_PAL) { gVideoRefreshRate = REFRESH_50HZ; gVideoAspectRatio = ASPECT_RATIO_PAL; @@ -91,7 +91,7 @@ void init_video(s32 arg0, s32 arg1) { gVideoCurrFbIndex = 1; swap_framebuffers(); osCreateMesgQueue(&D_801261A0, &D_80126180, 8); - osScAddClient(arg1, &D_80126310, &D_801261A0, 2); + osScAddClient(sc, &D_80126310, &D_801261A0, 2); init_vi_settings(); D_801262D0 = 12; osViBlack(1); diff --git a/src/video.h b/src/video.h index c7d095cf..d247d215 100644 --- a/src/video.h +++ b/src/video.h @@ -7,6 +7,7 @@ #include "PR/libultra.h" #include "PR/os_message.h" #include "PR/os_vi.h" +#include "lib/src/mips1/sc/sched.h" #define REFRESH_50HZ 50 #define REFRESH_60HZ 60