diff --git a/.vscode/settings.json b/.vscode/settings.json index 3546560a..e04d9ce5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,6 +32,8 @@ "os_version.h": "c", "stdbool.h": "c", "variables.h": "c", + "functions.h": "c", + "macros.h": "c", "random": "c" }, } \ No newline at end of file diff --git a/include/functions.h b/include/functions.h index 638d1c33..f8905f32 100644 --- a/include/functions.h +++ b/include/functions.h @@ -9,6 +9,10 @@ void func_80002AF4(void); void func_80002BE8(void); void func_80002C50(void); void func_80002CB8(void); +void func_8000316C(Gfx** dList); +void func_800032B4(Gfx** dList); +void func_800033E0(void* var_s2, void* var_s1, s32 var_s0); +void func_800034E8(u8 arg0); f32 Math_ModF(f32 value, f32 mod); void Rand_Init(void); @@ -21,32 +25,55 @@ f32 Math_Atan2F_XYAlt(f32 x, f32 y); f32 Math_PowF(f32 base, s32 exp); void Math_MinMax(s32* min, s32* max, s32 val1, s32 val2, s32 val3); -void func_80005680(Matrix*, Matrix*); -void func_80005708(Matrix** mtx); -void func_80005740(Matrix** mtx); -void func_80005B00(Matrix*, f32, f32, f32, u8); -void func_80005C34(Matrix*, f32, f32, f32, s32); -void func_80005E90(Matrix*, float, char); -void func_80006A20(Matrix*, Vec3f*, Vec3f*); -void func_80006EB8(Gfx**); -void func_80006F20(void); +void Matrix_Copy(Matrix*, Matrix*); +void Matrix_Push(Matrix** mtxStack); +void Matrix_Pop(Matrix** mtxStack); +void Matrix_Mult(Matrix*, Matrix*, u8); +void Matrix_Translate(Matrix*, f32, f32, f32, u8); +void Matrix_Scale(Matrix*, f32, f32, f32, u8); +void Matrix_RotateX(Matrix*, f32, u8); +void Matrix_RotateY(Matrix*, f32, u8); +void Matrix_RotateZ(Matrix*, f32, u8); +void Matrix_RotateAxis(Matrix*, f32, f32, f32, f32, u8); +void Matrix_ToMtx(Mtx *dest); +void Matrix_FromMtx(Mtx *src, Matrix *dest); +void Matrix_MultVec3f(Matrix*, Vec3f*, Vec3f*); +void Matrix_MultVec3fNoTranslate(Matrix*, Vec3f*, Vec3f*); +void Matrix_GetYRPAngles(Matrix*, Vec3f*); +void Matrix_GetXYZAngles(Matrix*, Vec3f*); +void Matrix_LookAt(Matrix*, f32, f32, f32, f32, f32, f32, f32, f32, f32, u8); +void Matrix_SetGfxMtx(Gfx**); +s32 func_80006FD8(u64 arg0, void* arg2, s32 arg3, s32 arg4); + +void func_80006F20(void); +void* func_80006F38(s32); + +void func_80007068(s32* arg0, s32 arg1); +void func_8000707C(s32* arg0, s32 arg1); +void func_80007088(UnkStruct_func_80007088*); void func_800070C8(u64); -s32 func_800071FC(UnkStruct_7D30*); -s32 func_800072E0(UnkStruct_7D30*); +s32 func_800071FC(SaveFile*); +s32 func_800072E0(SaveFile*); void Fault_ThreadEntry(void*); void func_80007FE4(FrameBuffer*, u16, u16); -void func_80008018(void); +void Fault_Init(void); +void func_80016A50(void); void func_800182F4(s32); void func_80019218(u32, f32*, u8, f32*, f32*, s8*); void func_8001A838(u32 arg0); +void func_8001ACDC(s32); +void func_8001AE58(void); void func_8001AF40(s32 arg0); +void func_8001D400(s32); +void func_8001DBD0(s32); void func_8001DC6C(s32, s32); void func_8000FFCC(void); +void func_8001D8A8(u8, u8); void func_8001DCE0(void); void func_8001DECC(void); SPTask* func_8001DF50(void); @@ -99,7 +126,17 @@ s64 __ull_div(s64, s64); s64 __ll_mul(s64, s64); s64 __ll_rshift(s64, s64); +void func_8002E548(void); +void func_8003DAF0(void); +void func_80040CDC(void); + +u8 func_80058F14(u8 arg0, u8 arg1); +void func_80059498(void); +void func_80057D00(void); + void func_80060FBC(u8*, f32*); +void func_800612B8(UnkStruct_90A00_1C*, u16); +void func_800613C4(UnkStruct_func_80090A00*); void func_8006EEFC(s32, f32, f32, f32, f32, f32, f32, f32, f32, f32); void func_8007C120(f32, f32, f32, f32, f32, f32, f32, s32); @@ -110,6 +147,7 @@ void func_800857DC(f32, f32, f32, f32); void func_80085890(f32, f32, f32, f32); void func_80086664(f32, f32); void func_80087530(f32, f32, s32); +void func_8008865C(void); void func_8008B5B0(f32 x, f32 y); s32 func_8008B774(void); void func_8008BD00(u8*, s32, s32, u8); @@ -117,13 +155,18 @@ void func_8008C390(f32, f32, f32, s32); void func_8008C5C8(f32, f32, f32, s32); void func_8008C6F4(s32, s32); s32 func_8008BCBC(s32 arg0); +void func_8008CA44(void); +s32 func_8008CB8C(void); void func_8008D0DC(f32, f32, f32, f32, f32); +void func_8008DE68(void); void func_8008E9EC(f32 arg0, f32 arg1); void func_8008EA14(f32, f32); +void func_8008FA84(void); void func_8008FFF0(UnkStruct_D_8016F110* arg0, s32); s32 func_8009092C(UnkStruct_func_80090A00*); s32 func_800915FC(UnkStruct_func_80090A00*); void func_80094D20(f32, f32); +void func_8009F574(Gfx **, s32, s32, s32, s32, u8, u8, u8, u8); f32 func_8009BC2C(f32*, f32, f32, f32, f32); f32 func_8009BD38(f32*, f32, f32, f32, f32); void func_8009D418(Gfx**, void*, u32, u32, f32, f32, f32, f32); @@ -134,22 +177,45 @@ f32 func_8009F768(f32); void func_8009FEA0(s32, s32, s32); void func_800A1200(s32, s32, f32, f32, char*); void func_800A18B0(void); +void func_800A1980(void); +s32 func_800A1B6C(void); +void func_800A1C14(Gfx **); +void func_800A1E68(Gfx **); +void func_800A1F44(void); +void func_800A1FB0(Gfx **, u8 , u8); +void func_800A24DC(s32); void func_800A26C0(void); +void func_800A25DC(void); +UnkStruct_func_80090A00 *func_800A3608(s32 arg0); +void func_800A3CA0(void); s32 func_800A3F50(s32); +void func_800A5844(void); void func_800A5D6C(void); +void func_800A6148(void); +void func_800B86CC(void); void func_800B8DD0(Gfx**, s16); void func_800BA490(void); void func_800BA4F0(void); -s32 func_800BA7BC(s32, s32); +s32 func_800BA7BC(u16*, s32); void func_800BA808(u16*, s32); void func_800BB5D0(void); void func_800BC4B0(void); void func_800B6F50(f32, f32, f32, f32, f32, f32); void func_800B9358(void); +void func_800C1ED4(void); +void func_800C20B0(void); +void func_800C2190(void); s32 func_800C2890(u16*); -s32 func_800C2F30(s32, s32); +s32 func_800C2F30(u16*, s32); +s32 func_800C3084(void); +s32 func_800C3194(void); +void func_80187520_EFFA40(s32, void*); +void func_8018A96C(void); +void func_8018AAC4(void); void func_801988E0(void); +void func_8019E8D0(void); + void func_801877F0_EBFEB0(void); s32 func_80187ABC_EC017C(void); diff --git a/include/global.h b/include/global.h index 2792c67e..f67271a6 100644 --- a/include/global.h +++ b/include/global.h @@ -17,9 +17,32 @@ #include "macros.h" #include "sf64math.h" +typedef enum { + SI_MESG_10 = 10, + SI_MESG_11, + SI_MESG_12, + SI_MESG_13, + SI_MESG_14, + SI_MESG_15, + SI_MESG_16, +} SerialMesg; + #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 +#define MSG_QUEUE_EMPTY -1 + +#define FAULT_MESG_BREAK 1 +#define FAULT_MESG_FAULT 2 + +#define TASK_MESG_1 1 +#define TASK_MESG_2 2 + +#define EVENT_MESG_SP 1 +#define EVENT_MESG_DP 2 +#define EVENT_MESG_VI 3 +#define EVENT_MESG_PRENMI 4 + typedef enum { THREAD_ID_SYSTEM, THREAD_ID_IDLE, @@ -29,7 +52,7 @@ typedef enum { THREAD_ID_AUDIO, THREAD_ID_GRAPHICS, THREAD_ID_7, - THREAD_ID_8, + THREAD_ID_SERIAL, } ThreadID; #endif // GLOBAL_H diff --git a/include/hud.h b/include/hud.h index 4229c359..6267ff50 100644 --- a/include/hud.h +++ b/include/hud.h @@ -11,8 +11,6 @@ typedef struct UnkStruct_func_80095350 { /* 0xB6 */ s16 unkB6; } UnkStruct_func_80095350; -void func_800612B8(void*, s32); -void func_800613C4(UnkStruct_func_80090A00*); void func_80084E78(Gfx**, void*, void*, s32, s32, f32, f32, f32, f32, f32, f32); void func_80085944(void); void func_80086CC8(void); diff --git a/include/libc/math.h b/include/libc/math.h index 84a943fa..1ce362b1 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -5,6 +5,7 @@ #define M_PI 3.14159265358979323846f #define M_DTOR (M_PI / 180.0f) +#define M_RTOD (180.0f / M_PI) #define M_SQRT2 1.41421356237309504880f #define M_SQRT1_2 0.70710678118654752440f /* 1/sqrt(2) */ #define FLT_MAX 340282346638528859811704183484516925440.0f @@ -25,17 +26,6 @@ typedef union { f32 f; } fu; -typedef union { - float m[4][4]; - struct { - float xx, yx, zx, wx, - xy, yy, zy, wy, - xz, yz, zz, wz, - xw, yw, zw, ww; - }; - // u64 force_struct_alignment; -} Matrix; - extern f32 __libm_qnan_f; float fabsf(float f); diff --git a/include/sf64math.h b/include/sf64math.h index 154b7cd1..3700968d 100644 --- a/include/sf64math.h +++ b/include/sf64math.h @@ -9,4 +9,15 @@ typedef struct { /* 0x8 */ f32 z; } Vec3f; // size = 0xC +typedef union { + float m[4][4]; + struct { + float xx, yx, zx, wx, + xy, yy, zy, wy, + xz, yz, zz, wz, + xw, yw, zw, ww; + }; + // u64 force_struct_alignment; +} Matrix; // size = 0x40 + #endif diff --git a/include/structs.h b/include/structs.h index 2147424b..9132c4bb 100644 --- a/include/structs.h +++ b/include/structs.h @@ -4,23 +4,58 @@ #include "global.h" #include "sf64math.h" +typedef struct { + /* 0x0 */ void* start; + /* 0x4 */ void* end; +} SegmentOffset; // size = 0x8 + +typedef struct { + /* 0x00 */ SegmentOffset unk_0; + /* 0x08 */ SegmentOffset unk_8; + /* 0x10 */ SegmentOffset unk_10; + /* 0x18 */ SegmentOffset unk_18; + /* 0x20 */ SegmentOffset unk_20[15]; +} OverlayInit; // size = 0x98 + +typedef struct { + /* 0x0 */ void* vRomAddress; + /* 0x8 */ SegmentOffset pRom; + /* 0xC */ s32 compFlag; +} DmaEntry; // size = 0x10; + +typedef void (*unkFunc_80007088)(s32, s32); + +typedef struct { + /* 0x00 */ u8 unk0; + /* 0x08 */ OSTimer unk8; + /* 0x28 */ unkFunc_80007088 unk28; + /* 0x2C */ s32 unk2C; + /* 0x30 */ s32 unk30; +} UnkStruct_func_80007088; // size = 0x38, 0x8 aligned + typedef struct { u16 data[240 * 320]; -} FrameBuffer; +} FrameBuffer; // size = 0x25800 typedef struct { - u8 data[0x40][8]; -} UnkStruct_7D30; + /* 0x00 */ char unk_0[0xFE]; + /* 0xFE */ u16 unk_FE; +} Save; // size = 0x100 + +typedef union { + Save save[2]; + u8 raw[EEPROM_BLOCK_SIZE*EEPROM_MAXBLOCKS]; +} SaveFile; // size = 0x200 typedef struct { - OSThread thread; - char stack[0x800]; - OSMesgQueue msgQueue; - OSMesg msg; - FrameBuffer* fb; - u16 width; - u16 height; -} FaultMgr; + /* 0x000 */ OSThread thread; + /* 0x1B0 */ char stack[0x800]; + /* 0x9B0 */ OSMesgQueue msgQueue; + /* 0x9C8 */ OSMesg msg; + /* 0x9CC */ FrameBuffer* fb; + /* 0x9D0 */ u16 width; + /* 0x9D2 */ u16 height; +} FaultMgr; // size = 0x9D8, 0x8 aligned typedef enum { SPTASK_STATE_NOT_STARTED, @@ -31,21 +66,21 @@ typedef enum { } SpTaskState; typedef struct { - OSTask task; - OSMesgQueue* msgQueue; - OSMesg msg; - SpTaskState state; -} SPTask; + /* 0x00 */ OSTask task; + /* 0x40 */ OSMesgQueue* msgQueue; + /* 0x44 */ OSMesg msg; + /* 0x48 */ SpTaskState state; +} SPTask; // size = 0x50, 0x8 aligned typedef struct { - SPTask task; - Vp viewports[0x10]; - Mtx mtx[0x480]; - Gfx unkDL1[0x180]; - Gfx masterDL[0x1380]; - Gfx unkDL2[0xD80]; - Lightsn lights[0x100]; -} GfxPool; + /* 0x00000 */ SPTask task; + /* 0x00050 */ Vp viewports[0x10]; + /* 0x00150 */ Mtx mtx[0x480]; + /* 0x12150 */ Gfx unkDL1[0x180]; + /* 0x12D50 */ Gfx masterDL[0x1380]; + /* 0x1C950 */ Gfx unkDL2[0xD80]; + /* 0x23550 */ Lightsn lights[0x100]; +} GfxPool; // size = 0x2AD50 typedef struct UnkStruct_D_801B8350 { /* 0x00 */ Vec3f unk0; @@ -104,6 +139,10 @@ typedef struct UnkStruct_D_80178280 { /* 0x2C0 */ char pad_2C0[0x220]; } UnkStruct_D_80178280; // size = 0x4E0 +typedef struct { + char unk0[0x24]; +} UnkStruct_90A00_1C; + typedef struct { /* 0x000 */ ElementType1 unk_000; /* 0x01C */ char pad_01C[0x32]; @@ -115,8 +154,7 @@ typedef struct { typedef struct { /* 0x000 */ ElementType1 unk_000; - /* 0x01C */ s32 unk_01C; - /* 0x020 */ char pad_020[0x20]; + /* 0x01C */ UnkStruct_90A00_1C unk_01C; /* 0x040 */ s32 unk_040; /* 0x044 */ char pad_044[0xC]; /* 0x050 */ s32 unk_050[25]; diff --git a/include/variables.h b/include/variables.h index febbf951..50dfeb74 100644 --- a/include/variables.h +++ b/include/variables.h @@ -27,8 +27,8 @@ extern Vec3f D_800C46DC; extern u8 sFaultCharIndex[]; extern s32 sFaultCharPixelFlags[]; -extern char* D_800C4870[]; -extern char* D_800C48B8[]; +extern const char* D_800C4870[]; +extern const char* D_800C48B8[]; extern f32 D_800C5D34; extern s8 D_800C5D3C; @@ -41,6 +41,38 @@ extern OSMesgQueue* D_800C7C64; extern char D_800C7C80[]; +extern u8 D_800CA3B0; + +extern OverlayInit D_800CA3B4[]; +extern OverlayInit D_800CA44C[]; +extern OverlayInit D_800CA7DC[]; +extern OverlayInit D_800CA874[]; +extern OverlayInit D_800CA90C[]; +extern OverlayInit D_800CA9A4[]; +extern OverlayInit D_800CAA3C[]; +extern OverlayInit D_800CAAD4[]; +extern OverlayInit D_800CAC04[]; +extern OverlayInit D_800CAF94[]; +extern OverlayInit D_800CB0C4[]; +extern OverlayInit D_800CB15C[]; +extern OverlayInit D_800CB1F4[]; +extern OverlayInit D_800CB28C[]; +extern OverlayInit D_800CB3BC[]; +extern OverlayInit D_800CB454[]; +extern OverlayInit D_800CB4EC[]; +extern OverlayInit D_800CB584[]; +extern OverlayInit D_800CB61C[]; +extern OverlayInit D_800CB6B4[]; +extern OverlayInit D_800CB74C[]; +extern OverlayInit D_800CB87C[]; +extern OverlayInit D_800CB914[]; +extern OverlayInit D_800CB9AC[]; +extern OverlayInit D_800CBA44[]; +extern OverlayInit D_800CBB74[]; +extern OverlayInit D_800CBC0C[]; + +extern UnkStruct_90A00_1C D_800CC124[400]; + extern Gfx D_800D31F8[]; extern Gfx D_800D3240[]; extern Gfx D_800D3288[]; @@ -66,8 +98,9 @@ extern OSThread gGraphicsThread; // 800DEAA0 extern u8 gGraphicsThreadStack[0x1000]; // 800DEC50 extern OSThread gUnkThread3; // 800DFC50 extern u8 gUnkThread3Stack[0x1000]; // 800DFE00 -extern OSThread gUnkThread4; // 800E0E00 -extern u8 gUnkThread4Stack[0x1000]; // 800E0FB0 +extern OSThread gSerialThread; // 800E0E00 +extern u8 gSerialThreadStack[0x1000]; // 800E0FB0 +extern u8 gUnusedStack[0x1000]; extern SPTask* gCurrentTask; extern SPTask* D_800E1FB4[1]; @@ -81,11 +114,11 @@ extern OSMesg sPiMgrCmdBuff[50]; // 800E2028 extern OSMesgQueue D_800E20F0; extern void *D_800E2108[1]; extern OSIoMesg D_800E2110; -extern OSMesgQueue D_800E2128; +extern OSMesgQueue gSerialEventQueue; extern void *D_800E2140[1]; -extern OSMesgQueue D_800E2148; +extern OSMesgQueue gMainThreadMsgQueue; extern void *D_800E2160[32]; -extern OSMesgQueue D_800E21E0; +extern OSMesgQueue gTaskMsgQueue; extern void *D_800E21F8[16]; extern OSMesgQueue D_800E2238; extern void *D_800E2250[1]; @@ -95,13 +128,13 @@ extern OSMesgQueue D_800E2278; extern void *D_800E2290[4]; extern OSMesgQueue D_800E22A0; extern void *D_800E22B8[2]; -extern OSMesgQueue D_800E22C0; +extern OSMesgQueue gSerialThreadMsgQueue; extern void *D_800E22D8[8]; extern OSMesgQueue D_800E22F8; extern void *D_800E2310[1]; extern OSMesgQueue D_800E2318; extern void *D_800E2330[1]; -extern OSMesgQueue D_800E2338; +extern OSMesgQueue gThread7msgQueue; extern void *D_800E2350[16]; extern OSMesgQueue D_800E2390; extern void *D_800E23A8[1]; @@ -126,6 +159,8 @@ extern u8 D_80137E84[4]; extern u16 D_80137E88; extern u16 D_80137E8A; +extern DmaEntry gDmaTable[]; + extern s32 D_80178580; extern s32 *D_80178710; extern s32 D_80178728; @@ -139,13 +174,15 @@ extern s32 D_80387800; extern u16 D_8038F080[]; extern u16 D_8038F300[]; +extern FrameBuffer D_80282000; // z buffer extern FrameBuffer gFrameBuffers[3]; // 8038F800 +extern Gfx D_Gfx_800DBAA0[]; extern GfxPool gGfxPools[2]; // 800E23B0 extern Matrix* D_8013B3C0; extern Matrix D_8013B3C8[0x20]; extern Matrix* D_8013BBC8; -extern Matrix D_8013BBD0[]; +extern Matrix D_8013BBD0[0x20]; extern OSThread sIdleThread; // 80138E90 extern u8 sIdleThreadStack[0x1000]; // 801390A0 @@ -153,14 +190,14 @@ extern OSThread gMainThread; // 8013A040 extern u8 sMainThreadStack[0x1000]; // 8013A1F0 extern OSThread gAudioThread; //8013B1F0 -extern UnkStruct_7D30 D_80144F60; -extern UnkStruct_7D30 D_80145160; +extern SaveFile D_80144F60; +extern SaveFile D_80145160; extern FaultMgr gFaultMgr; -extern OSMesg D_80156600; -extern OSMesg D_80156608; -extern OSMesg D_80156618; -extern OSMesg D_8015661C; +extern OSMesg D_80156600[1]; +extern OSMesg D_80156608[4]; +extern OSMesg D_80156618[1]; +extern OSMesg D_8015661C[1]; extern s32 D_8015F928; @@ -177,6 +214,11 @@ extern s32 D_800D2190[]; extern f32 D_800D21A0; extern f32 D_800D21A4; extern s32 D_800D2870; +extern s32 D_800D28B4[]; +extern u8 D_800D2908; +extern u8 D_800D290C; +extern u8 D_800D2910; +extern u8 D_800D2914; extern u16 D_Tex_800D99F8[]; extern OSContPad D_800DD880[4]; @@ -190,8 +232,7 @@ extern u8 D_800DD8BC[4]; // Fake symbol. Only exists as loop terminator for D_80 // extern OSContStatus D_800DD8F0[4]; // extern OSPfs D_800DD900[4]; - - +extern s32 D_8015F924; extern s32 D_80161690; extern f32 D_801616BC; extern f32 D_801616C0; @@ -214,23 +255,36 @@ extern s32 D_801617B0; extern s32 D_801617B4; extern s32 D_801617B8; extern s32 D_80161810[]; +extern f32 D_80161A10; +extern f32 D_80161A14; +extern u16 D_80161A2E; +extern u16 D_80161A30; +extern u16 D_80161A32; extern s16 D_80161A34; -extern s16 D_80161A36; +extern u16 D_80161A36; +extern u8 D_80161A38; +extern s8 D_80161A39; extern f32 D_80161A3C; extern f32 D_80161A40; extern f32 D_80161A44; extern u8 D_80161A90[]; extern s16 D_80161AA0[]; +extern UnkStruct_func_80090A00 D_80163FE0[60]; extern UnkStruct_D_8016F110 D_8016F110[]; extern UnkStruct_D_80175A10 D_80175A10[]; extern UnkStruct_D_80178280* D_80178280; + +extern s32 D_801774F8; +extern s32 D_80177820; +extern s32 D_8017782C; extern u8 D_80177830; extern s32 D_80177834; extern s32 D_80177838; extern s32 D_8017783C; extern s32 D_80177848; extern s32 D_80177854; +extern s32 D_80177868; extern s32 D_80177898; extern s32 D_801778A0; extern s32 D_801778A8; @@ -248,6 +302,7 @@ extern f32 D_801779C0; extern s32 D_801779F8; extern s32 D_80177AE0; extern s32 D_80177AF8; +extern s32 D_80177B40; extern u8 D_80177C98; extern f32 D_80177D08; extern f32 D_80177D20; @@ -256,6 +311,7 @@ extern f32 D_80177D68; extern s32 D_80177DA0[]; extern s32 D_80177DB0; extern s32 D_80178234; +extern s32 D_8017827C; extern s32 D_8017829C; extern s32 D_801782A4; extern s32 D_801782D8; @@ -269,9 +325,11 @@ extern s32 D_80178340; extern s32 D_80178348; extern s32 D_80178350; extern s32 D_80178354; +extern s32 D_80178380; extern s32 D_80178410; extern f32 D_80178420; extern f32 D_80178424; +extern f32 D_80178428; extern f32 D_8017842C; extern s32 D_80178548; extern s32 D_8017854C; diff --git a/linker_scripts/us/symbol_addrs.txt b/linker_scripts/us/symbol_addrs.txt index 43f8849f..7be4f4d5 100644 --- a/linker_scripts/us/symbol_addrs.txt +++ b/linker_scripts/us/symbol_addrs.txt @@ -15,12 +15,68 @@ Math_FactorialF = 0x800053C8; Math_Factorial = 0x800054C8; Math_PowF = 0x800055DC; Math_MinMax = 0x80005604; + +Matrix_Copy = 0x80005680; +Matrix_Push = 0x80005708; +Matrix_Pop = 0x80005740; +Matrix_Mult = 0x80005754; +Matrix_Translate = 0x80005B00; +Matrix_Scale = 0x80005C34; +Matrix_RotateX = 0x80005D44; +Matrix_RotateY = 0x80005E90; +Matrix_RotateZ = 0x80005FE0; +Matrix_RotateAxis = 0x8000612C; +Matrix_ToMtx = 0x80006500; +Matrix_FromMtx = 0x8000671C; +Matrix_MultVec3f = 0x80006970; +Matrix_MultVec3fNoTranslate = 0x80006A20; +Matrix_GetYRPAngles = 0x80006AB8; +Matrix_GetXYZAngles = 0x80006C7C; +Matrix_LookAt = 0x80006E3C; +Matrix_SetGfxMtx = 0x80006EB8; + D_800C45E0 = 0x800C45E0; D_800C57EC = 0x800C57EC; D_800C7380 = 0x800C7380; D_800C5FF4 = 0x800C5FF4; //type:u16 size:5000 +D_80163FE0 = 0x80163FE0; //size:0xB130 + +gDmaTable = 0x80178A70; + +D_800DD880 = 0x800DD880; // size:0x18 +D_800DD898 = 0x800DD898; // size:0x18 +D_800DD8B0 = 0x800DD8B0; // size:0x4 +D_800DD8B4 = 0x800DD8B4; // size:0x4 +D_800DD8B8 = 0x800DD8B8; // size:0x4 +D_800DD8BC = 0x800DD8BC; // ignore:true +D_800DD8C0 = 0x800DD8C0; // size:0x18 +D_800DD8D8 = 0x800DD8D8; // size:0x18 +D_800DD8F0 = 0x800DD8F0; // size:0x10 +D_800DD900 = 0x800DD900; // size:0x1A0 + +D_800CBDD4 = 0x800CBDD4; //size:0x98 + +D_80178870 = 0x80178870; //size:0x200 + +D_800E20F0 = 0x800E20F0; +gTaskMsgQueue = 0x800E21E0; +D_800E2238 = 0x800E2238; +D_800E2258 = 0x800E2258; +D_800E2278 = 0x800E2278; +D_800E22A0 = 0x800E22A0; +gSerialEventQueue = 0x800E2128; +gMainThreadMsgQueue = 0x800E2148; +gThread7msgQueue = 0x800E2338; +D_800E2390 = 0x800E2390; +gSerialThreadMsgQueue = 0x800E22C0; +D_800E22F8 = 0x800E22F8; +D_800E2318 = 0x800E2318; + +Thread7_ThreadEntry = 0x800040D4; +SerialInterface_ThreadEntry = 0x80003FEC; + gIdentityMtx = 0x800C4620; gIdentityMatrix = 0x800C4660; @@ -32,6 +88,9 @@ Math_FAtan2F = 0x8001FD0C; Math_FAsinF = 0x8001FE00; Math_FAcosF = 0x8001FE30; +Fault_Init = 0x80008018; +func_80003C50 = 0x80003C50; + Idle_ThreadEntry = 0x80004D00; Main_ThreadEntry = 0x80004ABC; Audio_ThreadEntry = 0x80003B48; @@ -47,8 +106,8 @@ gGraphicsThread = 0x800DEAA0; gGraphicsThreadStack = 0x800DEC50; gUnkThread3 = 0x800DFC50; gUnkThread3Stack = 0x800DFE00; -gUnkThread4 = 0x800E0E00; -gUnkThread4Stack = 0x800E0FB0; +gSerialThread = 0x800E0E00; +gSerialThreadStack = 0x800E0FB0; gCurrentTask = 0x800E1FB0; D_800E1FB4 = 0x800E1FB4; diff --git a/linker_scripts/us/symbol_addrs_assets.txt b/linker_scripts/us/symbol_addrs_assets.txt index 29204c8b..433b365a 100644 --- a/linker_scripts/us/symbol_addrs_assets.txt +++ b/linker_scripts/us/symbol_addrs_assets.txt @@ -31,4 +31,4 @@ D_Vtx_800DAC80 = 0x800DAC80; D_Unk_800DACB8 = 0x800DACB8; D_Unk_800DB4B8 = 0x800DB4B8; -D_Unk_800D96E4 = 0x800D96E4; // type:s16 +D_Unk_800D96E8 = 0x800D96E8; // type:s16 diff --git a/src/libultra/io/aisetnextbuf.c b/src/libultra/io/aisetnextbuf.c index cb19d276..8f4fb277 100644 --- a/src/libultra/io/aisetnextbuf.c +++ b/src/libultra/io/aisetnextbuf.c @@ -1,6 +1,6 @@ #include "global.h" -#ifdef NON_MATCHING // needs data import +#ifdef DATA_IMPORT_PENDING s32 osAiSetNextBuffer(void* bufPtr, u32 size) { static u8 hdwrBugFlag = FALSE; char* bptr; diff --git a/src/libultra/io/pimgr.c b/src/libultra/io/pimgr.c index ebc9ae29..52d5d47a 100644 --- a/src/libultra/io/pimgr.c +++ b/src/libultra/io/pimgr.c @@ -10,7 +10,7 @@ extern char piThreadStack[]; extern OSThread ramromThread; extern char ramromThreadStack[]; -#ifdef NON_MATCHING +#ifdef DATA_IMPORT_PENDING OSDevMgr __osPiDevMgr = { 0 }; void osCreatePiMgr(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) { diff --git a/src/main/1EB50.c b/src/main/1EB50.c index 7e7a7f86..c2d7abd6 100644 --- a/src/main/1EB50.c +++ b/src/main/1EB50.c @@ -11,10 +11,10 @@ void func_8001E7C8(void) { D_800C7C50 = 0; D_800C7C54 = 0; - osCreateMesgQueue(D_800C7C58, &D_80156600, 1); - osCreateMesgQueue(D_800C7C5C, &D_80156608, 4); - osCreateMesgQueue(D_800C7C60, &D_80156618, 1); - osCreateMesgQueue(D_800C7C64, &D_8015661C, 1); + osCreateMesgQueue(D_800C7C58, D_80156600, 1); + osCreateMesgQueue(D_800C7C5C, D_80156608, 4); + osCreateMesgQueue(D_800C7C60, D_80156618, 1); + osCreateMesgQueue(D_800C7C64, D_8015661C, 1); } #pragma GLOBAL_ASM("asm/us/nonmatchings/main/1EB50/func_8001E850.s") diff --git a/src/main/3440.c b/src/main/3440.c index 720b5d66..d34c6b0f 100644 --- a/src/main/3440.c +++ b/src/main/3440.c @@ -1,9 +1,21 @@ #include "global.h" -extern OSContPad D_800DD8C0[4]; -extern OSContPad D_800DD8D8[4]; -extern OSContStatus D_800DD8F0[4]; -extern OSPfs D_800DD900[4]; +#ifdef DATA_IMPORT_PENDING +OSContPad D_800DD880[4]; +OSContPad D_800DD898[4]; +u8 D_800DD8B0[4]; +s32 D_800DD8B4; +u8 D_800DD8B8[4]; +OSContPad D_800DD8C0[4]; // +OSContPad D_800DD8D8[4]; // +OSContStatus D_800DD8F0[4]; // +OSPfs D_800DD900[4]; // +#else +extern OSContPad D_800DD8C0[4]; // +extern OSContPad D_800DD8D8[4]; // +extern OSContStatus D_800DD8F0[4]; // +extern OSPfs D_800DD900[4]; // +#endif void func_80002840(s32 contrNum) { s32 temp_v0 = D_800DD880[contrNum].stick_x; @@ -47,7 +59,7 @@ void func_8000291C(void) { u8 sp1F; s32 i; - osContInit(&D_800E2128, &sp1F, D_800DD8F0); + osContInit(&gSerialEventQueue, &sp1F, D_800DD8F0); for (i = 0; i < 4; i++) { D_800DD8B0[i] = (sp1F >> i) & 1; D_800DD8B8[i] = 0; @@ -70,7 +82,7 @@ void func_800029A8(void) { } } -#ifdef NON_MATCHING // requires data import on D_800DD8C0 +#ifdef DATA_IMPORT_PENDING // requires data import on D_800DD8C0 void func_80002AF4(void) { s32 i; @@ -80,11 +92,11 @@ void func_80002AF4(void) { D_800DD8C0[i].button = D_800DD8C0[i].stick_x = D_800DD8C0[i].stick_y = D_800DD8C0[i].errno = 0; } } else { - osContStartReadData(&D_800E2128); - osRecvMesg(&D_800E2128, NULL, 1); + osContStartReadData(&gSerialEventQueue); + osRecvMesg(&gSerialEventQueue, NULL, OS_MESG_BLOCK); osContGetReadData(D_800DD8C0); } - osSendMesg(&D_800E22F8, (OSMesg) 16, 0); + osSendMesg(&D_800E22F8, (OSMesg) SI_MESG_16, OS_MESG_PRI_NORMAL); } #else #pragma GLOBAL_ASM("asm/us/nonmatchings/main/3440/func_80002AF4.s") @@ -92,32 +104,32 @@ void func_80002AF4(void) { void func_80002BE8(void) { if ((D_80137E80 == 0) && (func_800072E0(&D_80144F60) == 0)) { - osSendMesg(&D_800E2318, (OSMesg) 15, 0); + osSendMesg(&D_800E2318, (OSMesg) SI_MESG_15, OS_MESG_PRI_NORMAL); return; } - osSendMesg(&D_800E2318, (OSMesg) 14, 0); + osSendMesg(&D_800E2318, (OSMesg) SI_MESG_14, OS_MESG_PRI_NORMAL); } void func_80002C50(void) { if ((D_80137E80 == 0) && (func_800071FC(&D_80144F60) == 0)) { - osSendMesg(&D_800E2318, (OSMesg) 15, 0); + osSendMesg(&D_800E2318, (OSMesg) SI_MESG_15, OS_MESG_PRI_NORMAL); return; } - osSendMesg(&D_800E2318, (OSMesg) 14, 0); + osSendMesg(&D_800E2318, (OSMesg) SI_MESG_14, OS_MESG_PRI_NORMAL); } void func_80002CB8(void) { s32 i; - osContStartQuery(&D_800E2128); - osRecvMesg(&D_800E2128, NULL, 1); + osContStartQuery(&gSerialEventQueue); + osRecvMesg(&gSerialEventQueue, NULL, OS_MESG_BLOCK); osContGetQuery(D_800DD8F0); for (i = 0; i < 4; i++) { if ((D_800DD8B0[i] != 0) && (D_800DD8F0[i].errno == 0)) { if (D_800DD8F0[i].status & 1) { if (D_800DD8B8[i] == 0) { - if (osMotorInit(&D_800E2128, &D_800DD900[i], i)) { + if (osMotorInit(&gSerialEventQueue, &D_800DD900[i], i)) { D_800DD8B8[i] = 0; } else { D_800DD8B8[i] = 1; diff --git a/src/main/3A80.c b/src/main/3A80.c index 111d45f1..e3a5042d 100644 --- a/src/main/3A80.c +++ b/src/main/3A80.c @@ -91,57 +91,13 @@ void func_8000316C(Gfx** dList) { gSPMatrix((*dList)++, gGfxMtx++, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); guLookAt(gGfxMtx, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -12800.0f, 0.0f, 1.0f, 0.0f); gSPMatrix((*dList)++, gGfxMtx++, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); - func_80005680(D_8013B3C0, &gIdentityMatrix); + Matrix_Copy(D_8013B3C0, &gIdentityMatrix); } void func_800032B4(Gfx** dList) { - void* temp_t0; - void* temp_t0_2; - guOrtho(gGfxMtx, -160.0f, 160.0f, -120.0f, 120.0f, D_80161A40, D_80161A44, 1.0f); gSPMatrix((*dList)++, gGfxMtx++, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); guLookAt(gGfxMtx, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -12800.0f, 0.0f, 1.0f, 0.0f); gSPMatrix((*dList)++, gGfxMtx++, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); - func_80005680(D_8013B3C0, &gIdentityMatrix); -} - -void func_800033E0(u32 var_s2, u8* var_s1, s32 var_s0) { - osInvalICache(var_s1, var_s0); - osInvalDCache(var_s1, var_s0); - while (var_s0 > 0x100) { - osPiStartDma(&D_800E2110, 0, 0, var_s2, var_s1, 0x100, &D_800E20F0); - var_s0 -= 0x100; - var_s2 += 0x100; - var_s1 += 0x100; - osRecvMesg(&D_800E20F0, NULL, 1); - } - if (var_s0 != 0) { - osPiStartDma(&D_800E2110, 0, 0, var_s2, var_s1, var_s0, &D_800E20F0); - osRecvMesg(&D_800E20F0, NULL, 1); - } -} - -void func_800034E8(u8 arg0) { - s32 i; - - D_80137E88 |= 1; - if (arg0 == 1) { - if (D_80137E8A == 0) { - if (D_80137E88 == 1) { - osViBlack(1); - } else { - for (i = 0; i < 0x3C0; i++) { - D_8038F080[i] = D_80137E88; - } - osWritebackDCacheAll(); - osViSwapBuffer(&D_8038F300); - osViRepeatLine(1); - } - D_80137E8A = 1; - } - } else if (D_80137E8A == 1) { - osViRepeatLine(0); - osViBlack(0); - D_80137E8A = 0; - } + Matrix_Copy(D_8013B3C0, &gIdentityMatrix); } diff --git a/src/main/3FE0.c b/src/main/3FE0.c new file mode 100644 index 00000000..cffee105 --- /dev/null +++ b/src/main/3FE0.c @@ -0,0 +1,42 @@ +#include "global.h" + +void func_800033E0(void* var_s2, void* var_s1, ptrdiff_t var_s0) { + osInvalICache(var_s1, var_s0); + osInvalDCache(var_s1, var_s0); + while (var_s0 > 0x100) { + osPiStartDma(&D_800E2110, 0, 0, (uintptr_t) var_s2, var_s1, 0x100, &D_800E20F0); + var_s0 -= 0x100; + var_s2 = (void*) ((uintptr_t) var_s2 + 0x100); + var_s1 = (void*) ((uintptr_t) var_s1 + 0x100); + osRecvMesg(&D_800E20F0, NULL, OS_MESG_BLOCK); + } + if (var_s0 != 0) { + osPiStartDma(&D_800E2110, 0, 0, (uintptr_t) var_s2, var_s1, var_s0, &D_800E20F0); + osRecvMesg(&D_800E20F0, NULL, OS_MESG_BLOCK); + } +} + +void func_800034E8(u8 arg0) { + s32 i; + + D_80137E88 |= 1; + if (arg0 == 1) { + if (D_80137E8A == 0) { + if (D_80137E88 == 1) { + osViBlack(1); + } else { + for (i = 0; i < 0x3C0; i++) { + D_8038F080[i] = D_80137E88; + } + osWritebackDCacheAll(); + osViSwapBuffer(&D_8038F300); + osViRepeatLine(1); + } + D_80137E8A = 1; + } + } else if (D_80137E8A == 1) { + osViRepeatLine(0); + osViBlack(0); + D_80137E8A = 0; + } +} diff --git a/src/main/4650.c b/src/main/4650.c index 420c0969..7e006830 100644 --- a/src/main/4650.c +++ b/src/main/4650.c @@ -1,21 +1,82 @@ #include "global.h" -void func_800034E8(s32); -void Audio_ThreadEntry(void* /*arg0*/); -void func_80003EE0(void); -void func_80003FEC(void* /*arg0*/); -void func_800040D4(void* /*arg0*/); -void Graphics_ThreadEntry(void* /*arg0*/); - -void func_80004560(void); -void func_80004714(void); -void func_80004798(void); -void func_80004824(void); -void func_800049D4(void); -void func_80007088(void*); - s32 D_800C45D0 = 1; +#ifdef IMPORT_DATA_PENDING +u8 gAudioThreadStack[0x1000]; // 800DDAA0 +OSThread gGraphicsThread; // 800DEAA0 +u8 gGraphicsThreadStack[0x1000]; // 800DEC50 +OSThread gUnkThread3; // 800DFC50 +u8 gUnkThread3Stack[0x1000]; // 800DFE00 +OSThread gSerialThread; // 800E0E00 +u8 gSerialThreadStack[0x1000]; // 800E0FB0 + +SPTask* gCurrentTask; +SPTask* D_800E1FB4[1]; +SPTask* D_800E1FB8[2]; +SPTask* D_800E1FC0[2]; +SPTask* D_800E1FC8[2]; +u32 gSegments[16]; // 800E1FD0 +OSMesgQueue gPiMgrCmdQueue; // 800E2010 +OSMesg sPiMgrCmdBuff[50]; // 800E2028 + +OSMesgQueue D_800E20F0; +void* D_800E2108[1]; +OSIoMesg D_800E2110; +OSMesgQueue gSerialEventQueue; +void* D_800E2140[1]; +OSMesgQueue gMainThreadMsgQueue; +void* D_800E2160[32]; +OSMesgQueue gTaskMsgQueue; +void* D_800E21F8[16]; +OSMesgQueue D_800E2238; +void* D_800E2250[1]; +OSMesgQueue D_800E2258; +void* D_800E2270[1]; +OSMesgQueue D_800E2278; +void* D_800E2290[4]; +OSMesgQueue D_800E22A0; +void* D_800E22B8[2]; +OSMesgQueue gSerialThreadMsgQueue; +void* D_800E22D8[8]; +OSMesgQueue D_800E22F8; +void* D_800E2310[1]; +OSMesgQueue D_800E2318; +void* D_800E2330[1]; +OSMesgQueue gThread7msgQueue; +void* D_800E2350[16]; +OSMesgQueue D_800E2390; +void* D_800E23A8[1]; + +GfxPool gGfxPools[2]; + +GfxPool* gGfxPool; +SPTask* gGfxTask; +Vp* gViewport; +Mtx* gGfxMtx; +Gfx* gUnkDisp1; +Gfx* gMasterDisp; +Gfx* gUnkDisp2; +Lightsn* gLight; +FrameBuffer* gFrameBuffer; +s32* D_80137E74; + +u8 D_80137E78; +u32 D_80137E7C; +u8 D_80137E80; +u8 D_80137E81; +u8 D_80137E84[4]; +u16 D_80137E88; +u16 D_80137E8A; + +u8 gUnusedStack[0x1000]; +OSThread sIdleThread; // 80138E90 +u8 sIdleThreadStack[0x1000]; // 801390A0 +OSThread gMainThread; // 8013A040 +u8 sMainThreadStack[0x1000]; // 8013A1F0 +OSThread gAudioThread; // 8013B1F0 +#endif + void func_80003A50(void) { u8 i; @@ -42,35 +103,35 @@ void func_80003A50(void) { } void Audio_ThreadEntry(void* arg0) { - SPTask* temp_v0; + SPTask* task; func_8000FFCC(); func_8001DCE0(); - temp_v0 = func_8001DF50(); - if (temp_v0 != NULL) { - temp_v0->msgQueue = &D_800E2258; - temp_v0->msg = (OSMesg) 1; + task = func_8001DF50(); + if (task != NULL) { + task->msgQueue = &D_800E2258; + task->msg = (OSMesg) TASK_MESG_1; osWritebackDCacheAll(); - osSendMesg(&D_800E21E0, temp_v0, 0); + osSendMesg(&gTaskMsgQueue, task, OS_MESG_PRI_NORMAL); } while (1) { - temp_v0 = func_8001DF50(); - if (temp_v0 != NULL) { - temp_v0->msgQueue = &D_800E2258; - temp_v0->msg = (OSMesg) 1; + task = func_8001DF50(); + if (task != NULL) { + task->msgQueue = &D_800E2258; + task->msg = (OSMesg) TASK_MESG_1; osWritebackDCacheAll(); } - osRecvMesg(&D_800E2258, NULL, 0); - if (temp_v0 != NULL) { - osSendMesg(&D_800E21E0, temp_v0, 0); + osRecvMesg(&D_800E2258, NULL, OS_MESG_NOBLOCK); + if (task != NULL) { + osSendMesg(&gTaskMsgQueue, task, OS_MESG_PRI_NORMAL); } - osRecvMesg(&D_800E2238, NULL, 1); + osRecvMesg(&D_800E2238, NULL, OS_MESG_BLOCK); } } void func_80003C50(void) { gGfxTask->msgQueue = &D_800E22A0; - gGfxTask->msg = (OSMesg) 2; + gGfxTask->msg = (OSMesg) TASK_MESG_2; gGfxTask->task.t.type = M_GFXTASK; gGfxTask->task.t.flags = 0; gGfxTask->task.t.ucode_boot = __rspboot_start; @@ -88,7 +149,7 @@ void func_80003C50(void) { gGfxTask->task.t.yield_data_ptr = (u64*) &D_80281400; gGfxTask->task.t.yield_data_size = OS_YIELD_DATA_SIZE; osWritebackDCacheAll(); - osSendMesg(&D_800E21E0, gGfxTask, 0); + osSendMesg(&gTaskMsgQueue, gGfxTask, OS_MESG_PRI_NORMAL); } void func_80003DC0(u32 arg0) { @@ -135,34 +196,35 @@ void func_80003EE0(void) { } } -void func_80003FEC(void* arg0) { - s32 sp34; +void SerialInterface_ThreadEntry(void* arg0) { + OSMesg sp34; func_8000291C(); while (1) { - osRecvMesg(&D_800E22C0, (OSMesg) &sp34, 1); - switch (sp34) { - case 0xA: + osRecvMesg(&gSerialThreadMsgQueue, &sp34, OS_MESG_BLOCK); + + switch ((s32) sp34) { + case SI_MESG_10: func_80002AF4(); break; - case 0xB: + case SI_MESG_11: func_80002BE8(); break; - case 0xC: + case SI_MESG_12: func_80002C50(); break; - case 0xD: + case SI_MESG_13: func_80002CB8(); break; } } } -void func_800040D4(void* arg0) { +void Thread7_ThreadEntry(void* arg0) { void* sp24; while (1) { - osRecvMesg(&D_800E2338, &sp24, 1); + osRecvMesg(&gThread7msgQueue, &sp24, OS_MESG_BLOCK); func_80007088(sp24); } } @@ -173,7 +235,7 @@ void Graphics_ThreadEntry(void* arg0) { u8 var_v2; func_800A18B0(); - osSendMesg(&D_800E22C0, (OSMesg) 10, 0); + osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_MESG_10, OS_MESG_PRI_NORMAL); func_80003DC0(D_80137E7C); { gSPSegment(gUnkDisp1++, 0, 0); @@ -189,11 +251,11 @@ void Graphics_ThreadEntry(void* arg0) { while (1) { D_80137E7C++; func_80003DC0(D_80137E7C); - osRecvMesg(&D_800E22F8, NULL, 1); - osSendMesg(&D_800E22C0, (OSMesg) 13, 0); + osRecvMesg(&D_800E22F8, NULL, OS_MESG_BLOCK); + osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_MESG_13, OS_MESG_PRI_NORMAL); func_800029A8(); - osSendMesg(&D_800E22C0, (OSMesg) 10, 0); - if (D_800DD8AA & 0x800) { + osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_MESG_10, OS_MESG_PRI_NORMAL); + if (D_800DD898[3].button & 0x800) { func_80003EE0(); } { @@ -209,7 +271,7 @@ void Graphics_ThreadEntry(void* arg0) { gDPFullSync(gMasterDisp++); gSPEndDisplayList(gMasterDisp++); } - osRecvMesg(&D_800E22A0, NULL, 1); + osRecvMesg(&D_800E22A0, NULL, OS_MESG_BLOCK); func_80003C50(); if (D_80137E8A == 0) { osViSwapBuffer(&gFrameBuffers[(D_80137E7C - 1) % 3]); @@ -219,30 +281,30 @@ void Graphics_ThreadEntry(void* arg0) { var_v1 = MIN(D_80137E78, 4); var_v2 = MAX(var_v1, D_800E2278.validCount + 1); for (i = 0; i < var_v2; i += 1) { // Can't be ++ - osRecvMesg(&D_800E2278, NULL, 1); + osRecvMesg(&D_800E2278, NULL, OS_MESG_BLOCK); } func_8001DECC(); } } -void func_80004560(void) { +void Main_InitMesgQueues(void) { osCreateMesgQueue(&D_800E20F0, D_800E2108, ARRAY_COUNT(D_800E2108)); - osCreateMesgQueue(&D_800E21E0, D_800E21F8, ARRAY_COUNT(D_800E21F8)); + osCreateMesgQueue(&gTaskMsgQueue, D_800E21F8, ARRAY_COUNT(D_800E21F8)); osCreateMesgQueue(&D_800E2238, D_800E2250, ARRAY_COUNT(D_800E2250)); osCreateMesgQueue(&D_800E2258, D_800E2270, ARRAY_COUNT(D_800E2270)); osCreateMesgQueue(&D_800E2278, D_800E2290, ARRAY_COUNT(D_800E2290)); osCreateMesgQueue(&D_800E22A0, D_800E22B8, ARRAY_COUNT(D_800E22B8)); - osCreateMesgQueue(&D_800E2128, D_800E2140, ARRAY_COUNT(D_800E2140)); - osSetEventMesg(OS_EVENT_SI, &D_800E2128, (OSMesg) 0); - osCreateMesgQueue(&D_800E2148, D_800E2160, ARRAY_COUNT(D_800E2160)); - osViSetEvent(&D_800E2148, (OSMesg) 3, 1); - osSetEventMesg(OS_EVENT_SP, &D_800E2148, (OSMesg) 1); - osSetEventMesg(OS_EVENT_DP, &D_800E2148, (OSMesg) 2); - osSetEventMesg(OS_EVENT_PRENMI, &D_800E2148, (OSMesg) 4); - osCreateMesgQueue(&D_800E2338, D_800E2350, ARRAY_COUNT(D_800E2350)); + osCreateMesgQueue(&gSerialEventQueue, D_800E2140, ARRAY_COUNT(D_800E2140)); + osSetEventMesg(OS_EVENT_SI, &gSerialEventQueue, NULL); + osCreateMesgQueue(&gMainThreadMsgQueue, D_800E2160, ARRAY_COUNT(D_800E2160)); + osViSetEvent(&gMainThreadMsgQueue, (OSMesg) EVENT_MESG_VI, 1); + osSetEventMesg(OS_EVENT_SP, &gMainThreadMsgQueue, (OSMesg) EVENT_MESG_SP); + osSetEventMesg(OS_EVENT_DP, &gMainThreadMsgQueue, (OSMesg) EVENT_MESG_DP); + osSetEventMesg(OS_EVENT_PRENMI, &gMainThreadMsgQueue, (OSMesg) EVENT_MESG_PRENMI); + osCreateMesgQueue(&gThread7msgQueue, D_800E2350, ARRAY_COUNT(D_800E2350)); osCreateMesgQueue(&D_800E2390, D_800E23A8, ARRAY_COUNT(D_800E23A8)); - osCreateMesgQueue(&D_800E22C0, D_800E22D8, ARRAY_COUNT(D_800E22D8)); + osCreateMesgQueue(&gSerialThreadMsgQueue, D_800E22D8, ARRAY_COUNT(D_800E22D8)); osCreateMesgQueue(&D_800E22F8, D_800E2310, ARRAY_COUNT(D_800E2310)); osCreateMesgQueue(&D_800E2318, D_800E2330, ARRAY_COUNT(D_800E2330)); } @@ -252,7 +314,7 @@ void func_80004714(void) { u8 i; if ((*var_v1)->msgQueue != NULL) { - osSendMesg((*var_v1)->msgQueue, (*var_v1)->msg, 0); + osSendMesg((*var_v1)->msgQueue, (*var_v1)->msg, OS_MESG_PRI_NORMAL); } (*var_v1)->state = SPTASK_STATE_FINISHED_DP; for (i = 0; i < 1; i += 1, var_v1++) { @@ -273,7 +335,7 @@ void func_80004798(void) { task->state = SPTASK_STATE_FINISHED; if (task->task.t.type == M_AUDTASK) { if (task->msgQueue != NULL) { - osSendMesg(task->msgQueue, task->msg, 0); + osSendMesg(task->msgQueue, task->msg, OS_MESG_PRI_NORMAL); } D_800E1FB4[0] = NULL; } @@ -286,7 +348,7 @@ void func_80004824(void) { SPTask** var_a1; SPTask** var_s0_2; SPTask** var_s1_2; - void* sp40; + OSMesg sp40; SPTask* sp3C; var_s0_2 = D_800E1FC0; @@ -300,15 +362,15 @@ void func_80004824(void) { var_s0_2 = D_800E1FC0; var_s1_2 = D_800E1FC8; - while (osRecvMesg(&D_800E21E0, &sp40, 0) != -1) { + while (osRecvMesg(&gTaskMsgQueue, &sp40, OS_MESG_NOBLOCK) != MSG_QUEUE_EMPTY) { sp3C = (SPTask*) sp40; sp3C->state = SPTASK_STATE_NOT_STARTED; switch (sp3C->task.t.type) { - case 2: + case M_AUDTASK: *(var_s0_2++) = sp3C; break; - case 1: + case M_GFXTASK: *(var_s1_2++) = sp3C; break; } @@ -359,7 +421,8 @@ void func_800049D4(void) { } void Main_ThreadEntry(void* arg0) { - s32 sp54; + OSMesg sp54; + u8 mesg; osCreateThread(&gAudioThread, THREAD_ID_AUDIO, Audio_ThreadEntry, arg0, gAudioThreadStack + sizeof(gAudioThreadStack), 80); @@ -367,28 +430,32 @@ void Main_ThreadEntry(void* arg0) { osCreateThread(&gGraphicsThread, THREAD_ID_GRAPHICS, Graphics_ThreadEntry, arg0, gGraphicsThreadStack + sizeof(gGraphicsThreadStack), 40); osStartThread(&gGraphicsThread); - osCreateThread(&gUnkThread3, THREAD_ID_7, func_800040D4, arg0, gUnkThread3Stack + sizeof(gUnkThread3Stack), 60); + osCreateThread(&gUnkThread3, THREAD_ID_7, Thread7_ThreadEntry, arg0, gUnkThread3Stack + sizeof(gUnkThread3Stack), + 60); osStartThread(&gUnkThread3); - osCreateThread(&gUnkThread4, THREAD_ID_8, func_80003FEC, arg0, gUnkThread4Stack + sizeof(gUnkThread4Stack), 20); - osStartThread(&gUnkThread4); + osCreateThread(&gSerialThread, THREAD_ID_SERIAL, SerialInterface_ThreadEntry, arg0, + gSerialThreadStack + sizeof(gSerialThreadStack), 20); + osStartThread(&gSerialThread); - func_80004560(); + Main_InitMesgQueues(); while (true) { - osRecvMesg(&D_800E2148, (OSMesg) &sp54, 1); - switch ((u8) sp54) { - case 3: - osSendMesg(&D_800E2238, (OSMesg) 3, 0); - osSendMesg(&D_800E2278, (OSMesg) 3, 0); + osRecvMesg(&gMainThreadMsgQueue, &sp54, OS_MESG_BLOCK); + mesg = (u32) sp54; + + switch (mesg) { + case EVENT_MESG_VI: + osSendMesg(&D_800E2238, (OSMesg) EVENT_MESG_VI, OS_MESG_PRI_NORMAL); + osSendMesg(&D_800E2278, (OSMesg) EVENT_MESG_VI, OS_MESG_PRI_NORMAL); func_80004824(); break; - case 1: + case EVENT_MESG_SP: func_80004798(); break; - case 2: + case EVENT_MESG_DP: func_80004714(); break; - case 4: + case EVENT_MESG_PRENMI: D_80137E80 = 1; break; } @@ -406,7 +473,7 @@ void Idle_ThreadEntry(void* arg0) { osCreateThread(&gMainThread, THREAD_ID_MAIN, &Main_ThreadEntry, arg0, sMainThreadStack + sizeof(sMainThreadStack), 100); osStartThread(&gMainThread); - func_80008018(); + Fault_Init(); osSetThreadPri(NULL, OS_PRIORITY_IDLE); loop_1: goto loop_1; diff --git a/src/main/6280.c b/src/main/6280.c deleted file mode 100644 index 3a0f264b..00000000 --- a/src/main/6280.c +++ /dev/null @@ -1,97 +0,0 @@ -#include "global.h" - -Mtx gIdentityMtx = { { - { 0x00010000, 0, 1, 0 }, - { 0, 0x00010000, 0, 1 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, -} }; - -Matrix gIdentityMatrix = { { - { 1.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 1.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 1.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f, 1.0f }, -} }; - -Vec3f D_800C46A0 = { 0.0f, 0.0f, 0.0f }; -Vec3f D_800C46AC = { 0.0f, 0.0f, 1.0f }; -Vec3f D_800C46B8 = { 1.0f, 0.0f, 0.0f }; -Vec3f D_800C46C4 = { 0.0f, 0.0f, 0.0f }; -Vec3f D_800C46D0 = { 1.0f, 0.0f, 0.0f }; -Vec3f D_800C46DC = { 0.0f, 1.0f, 0.0f }; - -void func_80005680(Matrix* dst, Matrix* src) { - dst->m[0][0] = src->m[0][0]; - dst->m[0][1] = src->m[0][1]; - dst->m[0][2] = src->m[0][2]; - dst->m[0][3] = src->m[0][3]; - dst->m[1][0] = src->m[1][0]; - dst->m[1][1] = src->m[1][1]; - dst->m[1][2] = src->m[1][2]; - dst->m[1][3] = src->m[1][3]; - dst->m[2][0] = src->m[2][0]; - dst->m[2][1] = src->m[2][1]; - dst->m[2][2] = src->m[2][2]; - dst->m[2][3] = src->m[2][3]; - dst->m[3][0] = src->m[3][0]; - dst->m[3][1] = src->m[3][1]; - dst->m[3][2] = src->m[3][2]; - dst->m[3][3] = src->m[3][3]; - // dst->xx = src->xx; - // dst->yx = src->yx; - // dst->zx = src->zx; - // dst->wx = src->wx; - // dst->xy = src->xy; - // dst->yy = src->yy; - // dst->zy = src->zy; - // dst->wy = src->wy; - // dst->xz = src->xz; - // dst->yz = src->yz; - // dst->zz = src->zz; - // dst->wz = src->wz; - // dst->xw = src->xw; - // dst->yw = src->yw; - // dst->zw = src->zw; - // dst->ww = src->ww; -} - -void func_80005708(Matrix** mtx) { - func_80005680(*mtx + 1, *mtx); - *mtx += 1; -} - -void func_80005740(Matrix** mtx) { - *mtx -= 1; -} - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80005754.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80005B00.s") - -// https://decomp.me/scratch/v4KEJ 91% -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80005C34.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80005D44.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80005E90.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80005FE0.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_8000612C.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80006500.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_8000671C.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80006970.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80006A20.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80006AB8.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80006C7C.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80006E3C.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/6280/func_80006EB8.s") diff --git a/src/main/7B20.c b/src/main/7B20.c index 2ed4f717..cab1ba38 100644 --- a/src/main/7B20.c +++ b/src/main/7B20.c @@ -1,74 +1,15 @@ #include "global.h" -typedef void (*unkFunc_80007088)(s32, s32); - -typedef struct { - u8 unk0; - OSTimer unk8; - unkFunc_80007088 unk28; - s32 unk2C; - s32 unk30; -} UnkStruct_func_80007088; - -extern s32 D_8013C3D0; -extern s32 D_80144BD0; -extern UnkStruct_func_80007088 D_80144BE0[]; +extern s32 D_8013C3D0[0x2200]; +extern s32* D_80144BD0; void func_80006F20(void) { - D_80144BD0 = (s32) &D_8013C3D0; + D_80144BD0 = D_8013C3D0; } -s32 func_80006F38(s32 arg0) { - s32 tmp = D_80144BD0; +void* func_80006F38(s32 arg0) { + void* tmp = D_80144BD0; - D_80144BD0 = ((arg0 + 0xF) & ~0xF) + D_80144BD0; + D_80144BD0 = (void*) (((arg0 + 0xF) & ~0xF) + (uintptr_t) D_80144BD0); return tmp; } - -UnkStruct_func_80007088* func_80006F60(void) { - s32 i; - - for (i = 0; i < 0x10; i++) { - if (D_80144BE0[i].unk0 == 0) { - return &D_80144BE0[i]; - } - } - return NULL; -} - -s32 func_80006FD8(u64 arg0, void* arg2, s32 arg3, s32 arg4) { - UnkStruct_func_80007088* temp_v0; - - temp_v0 = func_80006F60(); - if (temp_v0 == NULL) { - return -1; - } - temp_v0->unk0 = 1; - temp_v0->unk28 = arg2; - temp_v0->unk2C = arg3; - temp_v0->unk30 = arg4; - return osSetTimer(&temp_v0->unk8, arg0, 0, &D_800E2338, temp_v0); -} - -void func_80007068(s32* arg0, s32 arg1) { - *arg0 += arg1; -} - -void func_8000707C(s32* arg0, s32 arg1) { - *arg0 = arg1; -} - -void func_80007088(UnkStruct_func_80007088* arg0) { - if (arg0->unk28 != NULL) { - arg0->unk28(arg0->unk2C, arg0->unk30); - } - arg0->unk0 = 0; -} - -void func_800070C8(u64 arg0) { - OSTimer sp30; - void* sp2C; - - osSetTimer(&sp30, arg0, 0, &D_800E2390, NULL); - osRecvMesg(&D_800E2390, &sp2C, 1); -} diff --git a/src/main/7B60.c b/src/main/7B60.c new file mode 100644 index 00000000..cf2ad3e4 --- /dev/null +++ b/src/main/7B60.c @@ -0,0 +1,51 @@ +#include "global.h" + +extern UnkStruct_func_80007088 D_80144BE0[0x10]; + +UnkStruct_func_80007088* func_80006F60(void) { + s32 i; + + for (i = 0; i < 0x10; i++) { + if (D_80144BE0[i].unk0 == 0) { + return &D_80144BE0[i]; + } + } + return NULL; +} + +s32 func_80006FD8(u64 arg0, void* arg2, s32 arg3, s32 arg4) { + UnkStruct_func_80007088* temp_v0; + + temp_v0 = func_80006F60(); + if (temp_v0 == NULL) { + return -1; + } + temp_v0->unk0 = 1; + temp_v0->unk28 = arg2; + temp_v0->unk2C = arg3; + temp_v0->unk30 = arg4; + return osSetTimer(&temp_v0->unk8, arg0, 0, &gThread7msgQueue, temp_v0); +} + +void func_80007068(s32* arg0, s32 arg1) { + *arg0 += arg1; +} + +void func_8000707C(s32* arg0, s32 arg1) { + *arg0 = arg1; +} + +void func_80007088(UnkStruct_func_80007088* arg0) { + if (arg0->unk28 != NULL) { + arg0->unk28(arg0->unk2C, arg0->unk30); + } + arg0->unk0 = 0; +} + +void func_800070C8(u64 arg0) { + OSTimer sp30; + OSMesg sp2C; + + osSetTimer(&sp30, arg0, 0, &D_800E2390, NULL); + osRecvMesg(&D_800E2390, &sp2C, OS_MESG_BLOCK); +} diff --git a/src/main/7D30.c b/src/main/7D30.c index 2b133af2..af8e5f9d 100644 --- a/src/main/7D30.c +++ b/src/main/7D30.c @@ -2,8 +2,13 @@ #include "global.h" +#ifdef DATA_IMPORT_PENDING +SaveFile D_80144F60; +SaveFile D_80145160; +#endif + s32 func_80007130(s32 arg0, u8* arg1) { - if (osEepromRead(&D_800E2128, arg0, arg1)) { + if (osEepromRead(&gSerialEventQueue, arg0, arg1)) { (void) "EEPROM インターフェース回路反応なし (READ)\n"; return -1; } @@ -12,7 +17,7 @@ s32 func_80007130(s32 arg0, u8* arg1) { } s32 func_8000716C(s32 arg0, u8* arg1) { - if (osEepromWrite(&D_800E2128, arg0, arg1)) { + if (osEepromWrite(&gSerialEventQueue, arg0, arg1)) { (void) "EEPROM インターフェース回路反応なし (WRITE)\n"; return -1; } @@ -21,44 +26,39 @@ s32 func_8000716C(s32 arg0, u8* arg1) { return 0; } -#ifdef NON_MATCHING -s32 func_800071FC(UnkStruct_7D30* arg0) { +s32 func_800071FC(SaveFile* arg0) { s32 var_a2; s32 i; s32 j; - if (osEepromProbe(&D_800E2128) != 1) { + if (osEepromProbe(&gSerialEventQueue) != 1) { + (void) "EEPROM が ありません\n"; return -1; } - for (i = 0; i < 0x40; i++) { + for (i = 0; i < EEPROM_MAXBLOCKS; i++) { var_a2 = 0; - for (j = 0; j < 8; j++) { - if (arg0->data[i][j] != D_80145160.data[i][j]) { - arg0->data[i][j] = D_80145160.data[i][j]; + for (j = 0; j < EEPROM_BLOCK_SIZE; j++) { + if (D_80145160.raw[EEPROM_BLOCK_SIZE * i + j] != arg0->raw[EEPROM_BLOCK_SIZE * i + j]) { + D_80145160.raw[EEPROM_BLOCK_SIZE * i + j] = arg0->raw[EEPROM_BLOCK_SIZE * i + j]; var_a2 = 1; } } - if ((var_a2 == 1) && func_8000716C(i, arg0->data[i])) { + if ((var_a2 == 1) && func_8000716C(i, &arg0->raw[EEPROM_BLOCK_SIZE * i])) { return -1; } } return 0; } -#else -s32 func_800071FC(UnkStruct_7D30* arg0); -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D30/func_800071FC.s") -#endif -s32 func_800072E0(UnkStruct_7D30* arg0) { +s32 func_800072E0(SaveFile* arg0) { s32 i; - if (osEepromProbe(&D_800E2128) != 1) { - (void) "EEPROM が ありません\n"; // actually goes in above function + if (osEepromProbe(&gSerialEventQueue) != 1) { (void) "EEPROM が ありません\n"; return -1; } - for (i = 0; i < 0x40; i++) { - if (func_80007130(i, arg0->data[i]) != 0) { + for (i = 0; i < EEPROM_MAXBLOCKS; i++) { + if (func_80007130(i, &arg0->raw[EEPROM_BLOCK_SIZE * i]) != 0) { return -1; } } diff --git a/src/main/7FC0.c b/src/main/7FC0.c index 5dff5909..4cfccbbd 100644 --- a/src/main/7FC0.c +++ b/src/main/7FC0.c @@ -1,5 +1,13 @@ #include "global.h" +#ifdef DATA_IMPORT_PENDING +FaultMgr gFaultMgr; +s32 sFaultCharPixelFlags[0x40]; +u8 sFaultCharIndex[0x80]; +const char* D_800C4870[18]; +const char* D_800C48B8[6]; +#endif + void func_800073C0(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { u16* var_v0; s32 i; @@ -44,12 +52,11 @@ void* func_80007604(void* arg0, const char* arg1, size_t arg2) { return (char*) memcpy(arg0, arg1, arg2) + arg2; } -#ifdef NON_MATCHING void func_8000762C(s32 arg0, s32 arg1, const char* fmt, ...) { u8* var_s0; s32 i; u8 sp40[0x100]; - u32 temp_a2; + s32 temp_a2; va_list args; va_start(args, fmt); @@ -57,20 +64,20 @@ void func_8000762C(s32 arg0, s32 arg1, const char* fmt, ...) { sp40[i] = 0; } - if (_Printf(func_80007604, sp40, fmt, args) > 0) { - for (var_s0 = sp40; *var_s0 != 0; arg0 += 6, var_s0++) { - temp_a2 = sFaultCharIndex[*var_s0 & 0x7F]; - if (temp_a2 != 0xFF) { - func_800074AC(arg0, arg1, temp_a2); - } + if (_Printf(func_80007604, sp40, fmt, args) <= 0) { + return; + } + for (var_s0 = sp40; *var_s0 != 0; var_s0++) { + temp_a2 = sFaultCharIndex[*var_s0 & 0x7F]; + + if (temp_a2 != 0xFF) { + func_800074AC(arg0, arg1, temp_a2); } + arg0 += 6; + label:; // fake, probably } va_end(args); } -#else -void func_8000762C(s32 arg0, s32 arg1, const char* fmt, ...); -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7FC0/func_8000762C.s") -#endif void func_8000770C(s32 arg0) { u64 temp_ret_4 = MSEC_TO_CYCLES(arg0); @@ -153,49 +160,51 @@ void func_80007880(u32 arg0) { } } +#define CAUSE_INDEX(cause) ((cause >> CAUSE_EXCSHIFT) & (CAUSE_EXCMASK >> CAUSE_EXCSHIFT)) + void func_80007910(OSThread* thread) { __OSThreadContext* context = &thread->context; - s16 var_s0 = (thread->context.cause >> 2) & 0x1F; + s16 var_s0 = CAUSE_INDEX(context->cause); - if (var_s0 == 0x17) { - var_s0 = 0x10; + if (var_s0 == CAUSE_INDEX(EXC_WATCH)) { + var_s0 = 16; } - if (var_s0 == 0x1F) { - var_s0 = 0x11; + if (var_s0 == CAUSE_INDEX(EXC_VCED)) { + var_s0 = 17; } - func_8000770C(0xBB8); - func_800073C0(0xF, 0xF, 0x122, 0xD2); - func_8000762C(0x1E, 0x28, "THREAD:%d (%s)", thread->id, D_800C4870[var_s0]); - func_8000762C(0x1E, 0x32, "PC:%08XH SR:%08XH\tVA:%08XH", context->pc, context->sr, context->badvaddr); + func_8000770C(3000); + func_800073C0(15, 15, 290, 210); + func_8000762C(30, 40, "THREAD:%d (%s)", thread->id, D_800C4870[var_s0]); + func_8000762C(30, 50, "PC:%08XH SR:%08XH\tVA:%08XH", context->pc, context->sr, context->badvaddr); osWritebackDCacheAll(); - func_8000762C(0x1E, 0x3C, "AT:%08XH V0:%08XH\tV1:%08XH", (s32) context->at, (s32) context->v0, (s32) context->v1); - func_8000762C(0x1E, 0x46, "A0:%08XH A1:%08XH\tA2:%08XH", (s32) context->a0, (s32) context->a1, (s32) context->a2); - func_8000762C(0x1E, 0x50, "A3:%08XH T0:%08XH\tT1:%08XH", (s32) context->a3, (s32) context->t0, (s32) context->t1); - func_8000762C(0x1E, 0x5A, "T2:%08XH T3:%08XH\tT4:%08XH", (s32) context->t2, (s32) context->t3, (s32) context->t4); - func_8000762C(0x1E, 0x64, "T5:%08XH T6:%08XH\tT7:%08XH", (s32) context->t5, (s32) context->t6, (s32) context->t7); - func_8000762C(0x1E, 0x6E, "S0:%08XH S1:%08XH\tS2:%08XH", (s32) context->s0, (s32) context->s1, (s32) context->s2); - func_8000762C(0x1E, 0x78, "S3:%08XH S4:%08XH\tS5:%08XH", (s32) context->s3, (s32) context->s4, (s32) context->s5); - func_8000762C(0x1E, 0x82, "S6:%08XH S7:%08XH\tT8:%08XH", (s32) context->s6, (s32) context->s7, (s32) context->t8); - func_8000762C(0x1E, 0x8C, "T9:%08XH GP:%08XH\tSP:%08XH", (s32) context->t9, (s32) context->gp, (s32) context->sp); - func_8000762C(0x1E, 0x96, "S8:%08XH RA:%08XH", (s32) context->s8, (s32) context->ra); + func_8000762C(30, 60, "AT:%08XH V0:%08XH\tV1:%08XH", (s32) context->at, (s32) context->v0, (s32) context->v1); + func_8000762C(30, 70, "A0:%08XH A1:%08XH\tA2:%08XH", (s32) context->a0, (s32) context->a1, (s32) context->a2); + func_8000762C(30, 80, "A3:%08XH T0:%08XH\tT1:%08XH", (s32) context->a3, (s32) context->t0, (s32) context->t1); + func_8000762C(30, 90, "T2:%08XH T3:%08XH\tT4:%08XH", (s32) context->t2, (s32) context->t3, (s32) context->t4); + func_8000762C(30, 100, "T5:%08XH T6:%08XH\tT7:%08XH", (s32) context->t5, (s32) context->t6, (s32) context->t7); + func_8000762C(30, 110, "S0:%08XH S1:%08XH\tS2:%08XH", (s32) context->s0, (s32) context->s1, (s32) context->s2); + func_8000762C(30, 120, "S3:%08XH S4:%08XH\tS5:%08XH", (s32) context->s3, (s32) context->s4, (s32) context->s5); + func_8000762C(30, 130, "S6:%08XH S7:%08XH\tT8:%08XH", (s32) context->s6, (s32) context->s7, (s32) context->t8); + func_8000762C(30, 140, "T9:%08XH GP:%08XH\tSP:%08XH", (s32) context->t9, (s32) context->gp, (s32) context->sp); + func_8000762C(30, 150, "S8:%08XH RA:%08XH", (s32) context->s8, (s32) context->ra); func_80007880(context->fpcsr); osWritebackDCacheAll(); - func_800077F8(0x1E, 0xAA, 0, &context->fp0.f.f_even); - func_800077F8(0x78, 0xAA, 2, &context->fp2.f.f_even); - func_800077F8(0xD2, 0xAA, 4, &context->fp4.f.f_even); - func_800077F8(0x1E, 0xB4, 6, &context->fp6.f.f_even); - func_800077F8(0x78, 0xB4, 8, &context->fp8.f.f_even); - func_800077F8(0xD2, 0xB4, 0xA, &context->fp10.f.f_even); - func_800077F8(0x1E, 0xBE, 0xC, &context->fp12.f.f_even); - func_800077F8(0x78, 0xBE, 0xE, &context->fp14.f.f_even); - func_800077F8(0xD2, 0xBE, 0x10, &context->fp16.f.f_even); - func_800077F8(0x1E, 0xC8, 0x12, &context->fp18.f.f_even); - func_800077F8(0x78, 0xC8, 0x14, &context->fp20.f.f_even); - func_800077F8(0xD2, 0xC8, 0x16, &context->fp22.f.f_even); - func_800077F8(0x1E, 0xD2, 0x18, &context->fp24.f.f_even); - func_800077F8(0x78, 0xD2, 0x1A, &context->fp26.f.f_even); - func_800077F8(0xD2, 0xD2, 0x1C, &context->fp28.f.f_even); - func_800077F8(0x1E, 0xDC, 0x1E, &context->fp30.f.f_even); + func_800077F8(30, 170, 0, &context->fp0.f.f_even); + func_800077F8(120, 170, 2, &context->fp2.f.f_even); + func_800077F8(210, 170, 4, &context->fp4.f.f_even); + func_800077F8(30, 180, 6, &context->fp6.f.f_even); + func_800077F8(120, 180, 8, &context->fp8.f.f_even); + func_800077F8(210, 180, 10, &context->fp10.f.f_even); + func_800077F8(30, 190, 12, &context->fp12.f.f_even); + func_800077F8(120, 190, 14, &context->fp14.f.f_even); + func_800077F8(210, 190, 16, &context->fp16.f.f_even); + func_800077F8(30, 200, 18, &context->fp18.f.f_even); + func_800077F8(120, 200, 20, &context->fp20.f.f_even); + func_800077F8(210, 200, 22, &context->fp22.f.f_even); + func_800077F8(30, 210, 24, &context->fp24.f.f_even); + func_800077F8(120, 210, 26, &context->fp26.f.f_even); + func_800077F8(210, 210, 28, &context->fp28.f.f_even); + func_800077F8(30, 220, 30, &context->fp30.f.f_even); osWritebackDCacheAll(); osViBlack(0); osViRepeatLine(0); @@ -217,7 +226,7 @@ OSThread* func_80007CEC(void) { } void Fault_ThreadEntry(void* arg0) { - void* sp44; + OSMesg sp44; OSThread* sp40; s32 var_s2; s32 var_s5; @@ -228,26 +237,26 @@ void Fault_ThreadEntry(void* arg0) { var_s0 = 0; var_s2 = 0; - osSetEventMesg(OS_EVENT_CPU_BREAK, &gFaultMgr.msgQueue, (OSMesg) 1); - osSetEventMesg(OS_EVENT_FAULT, &gFaultMgr.msgQueue, (OSMesg) 2); + osSetEventMesg(OS_EVENT_CPU_BREAK, &gFaultMgr.msgQueue, (OSMesg) FAULT_MESG_BREAK); + osSetEventMesg(OS_EVENT_FAULT, &gFaultMgr.msgQueue, (OSMesg) FAULT_MESG_FAULT); sp40 = NULL; while (sp40 == NULL) { - osRecvMesg(&gFaultMgr.msgQueue, &sp44, 1); + osRecvMesg(&gFaultMgr.msgQueue, &sp44, OS_MESG_BLOCK); sp40 = func_80007CEC(); } func_8000762C(300, 10, "-"); D_800DD8B0[0] = 1; while (var_s5 == 0) { - osSendMesg(&D_800E22C0, (OSMesg) 10, 0); - osRecvMesg(&D_800E22F8, NULL, 1); + osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_MESG_10, OS_MESG_PRI_NORMAL); + osRecvMesg(&D_800E22F8, NULL, OS_MESG_BLOCK); func_800029A8(); switch (var_s0) { case 0: if (D_800DD880[0].button == 0x16) { var_s0++; - var_s2 = 0xFA0; + var_s2 = 4000; } break; case 1: @@ -256,7 +265,7 @@ void Fault_ThreadEntry(void* arg0) { if (D_800DD880[0].button & 0x10) { if (D_800DD898[0].button == 0x8000) { var_s0++; - var_s2 = 0xBB8; + var_s2 = 3000; } else if (D_800DD898[0].button != 0) { var_s0 = 0; } @@ -268,7 +277,7 @@ void Fault_ThreadEntry(void* arg0) { if (D_800DD880[0].button & 0x10) { if (D_800DD898[0].button == 0x4000) { var_s0++; - var_s2 = 0xBB8; + var_s2 = 3000; } else if (D_800DD898[0].button != 0) { var_s0 = 0; } @@ -284,7 +293,7 @@ void Fault_ThreadEntry(void* arg0) { if (D_800DD880[0].button & 0x10) { if (D_800DD898[0].button == 2) { var_s0++; - var_s2 = 0xBB8; + var_s2 = 3000; } else if (D_800DD898[0].button != 0) { var_s0 = 0; } @@ -294,7 +303,7 @@ void Fault_ThreadEntry(void* arg0) { if (D_800DD880[0].button & 0x10) { if (D_800DD898[0].button == 0x1000) { var_s0++; - var_s2 = 0xBB8; + var_s2 = 3000; } else if (D_800DD898[0].button != 0) { var_s0 = 0; } @@ -322,7 +331,7 @@ void func_80007FE4(FrameBuffer* arg0, u16 arg1, u16 arg2) { gFaultMgr.height = arg2; } -void func_80008018(void) { +void Fault_Init(void) { gFaultMgr.fb = (FrameBuffer*) (PHYS_TO_K0(osMemSize) - sizeof(FrameBuffer)); gFaultMgr.width = SCREEN_WIDTH; gFaultMgr.height = SCREEN_HEIGHT; diff --git a/src/main/F0A0.c b/src/main/F0A0.c index f127d3fb..e9a87a85 100644 --- a/src/main/F0A0.c +++ b/src/main/F0A0.c @@ -1,4 +1,4 @@ -#include "common.h" +#include "global.h" #pragma GLOBAL_ASM("asm/us/nonmatchings/main/F0A0/func_8000E4A0.s") diff --git a/src/main/5A20.c b/src/main/math.c similarity index 100% rename from src/main/5A20.c rename to src/main/math.c diff --git a/src/main/matrix.c b/src/main/matrix.c new file mode 100644 index 00000000..93330396 --- /dev/null +++ b/src/main/matrix.c @@ -0,0 +1,579 @@ +#include "global.h" + +Mtx gIdentityMtx = { { + { 0x00010000, 0, 1, 0 }, + { 0, 0x00010000, 0, 1 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, +} }; + +Matrix gIdentityMatrix = { { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +} }; + +#ifdef DATA_IMPORT_PENDING +Matrix* D_8013B3C0; +Matrix D_8013B3C8[0x20]; +Matrix* D_8013BBC8; +Matrix D_8013BBD0[0x20]; +#endif + +// Matrix_Copy +void Matrix_Copy(Matrix* dst, Matrix* src) { + dst->m[0][0] = src->m[0][0]; + dst->m[0][1] = src->m[0][1]; + dst->m[0][2] = src->m[0][2]; + dst->m[0][3] = src->m[0][3]; + dst->m[1][0] = src->m[1][0]; + dst->m[1][1] = src->m[1][1]; + dst->m[1][2] = src->m[1][2]; + dst->m[1][3] = src->m[1][3]; + dst->m[2][0] = src->m[2][0]; + dst->m[2][1] = src->m[2][1]; + dst->m[2][2] = src->m[2][2]; + dst->m[2][3] = src->m[2][3]; + dst->m[3][0] = src->m[3][0]; + dst->m[3][1] = src->m[3][1]; + dst->m[3][2] = src->m[3][2]; + dst->m[3][3] = src->m[3][3]; + // dst->xx = src->xx; + // dst->yx = src->yx; + // dst->zx = src->zx; + // dst->wx = src->wx; + // dst->xy = src->xy; + // dst->yy = src->yy; + // dst->zy = src->zy; + // dst->wy = src->wy; + // dst->xz = src->xz; + // dst->yz = src->yz; + // dst->zz = src->zz; + // dst->wz = src->wz; + // dst->xw = src->xw; + // dst->yw = src->yw; + // dst->zw = src->zw; + // dst->ww = src->ww; +} + +// Matrix_Push +void Matrix_Push(Matrix** mtxStack) { + Matrix_Copy(*mtxStack + 1, *mtxStack); + *mtxStack += 1; +} + +// Matrix_Pop +void Matrix_Pop(Matrix** mtxStack) { + *mtxStack -= 1; +} + +// Matrix_Mult +void Matrix_Mult(Matrix* mtx, Matrix* tf, u8 mode) { + f32 rx; + f32 ry; + f32 rz; + f32 rw; + + if (mode == 1) { + rx = mtx->m[0][0]; + ry = mtx->m[1][0]; + rz = mtx->m[2][0]; + rw = mtx->m[3][0]; + + mtx->m[0][0] = (rx * tf->m[0][0]) + (ry * tf->m[0][1]) + (rz * tf->m[0][2]) + (rw * tf->m[0][3]); + mtx->m[1][0] = (rx * tf->m[1][0]) + (ry * tf->m[1][1]) + (rz * tf->m[1][2]) + (rw * tf->m[1][3]); + mtx->m[2][0] = (rx * tf->m[2][0]) + (ry * tf->m[2][1]) + (rz * tf->m[2][2]) + (rw * tf->m[2][3]); + mtx->m[3][0] = (rx * tf->m[3][0]) + (ry * tf->m[3][1]) + (rz * tf->m[3][2]) + (rw * tf->m[3][3]); + + rx = mtx->m[0][1]; + ry = mtx->m[1][1]; + rz = mtx->m[2][1]; + rw = mtx->m[3][1]; + + mtx->m[0][1] = (rx * tf->m[0][0]) + (ry * tf->m[0][1]) + (rz * tf->m[0][2]) + (rw * tf->m[0][3]); + mtx->m[1][1] = (rx * tf->m[1][0]) + (ry * tf->m[1][1]) + (rz * tf->m[1][2]) + (rw * tf->m[1][3]); + mtx->m[2][1] = (rx * tf->m[2][0]) + (ry * tf->m[2][1]) + (rz * tf->m[2][2]) + (rw * tf->m[2][3]); + mtx->m[3][1] = (rx * tf->m[3][0]) + (ry * tf->m[3][1]) + (rz * tf->m[3][2]) + (rw * tf->m[3][3]); + + rx = mtx->m[0][2]; + ry = mtx->m[1][2]; + rz = mtx->m[2][2]; + rw = mtx->m[3][2]; + + mtx->m[0][2] = (rx * tf->m[0][0]) + (ry * tf->m[0][1]) + (rz * tf->m[0][2]) + (rw * tf->m[0][3]); + mtx->m[1][2] = (rx * tf->m[1][0]) + (ry * tf->m[1][1]) + (rz * tf->m[1][2]) + (rw * tf->m[1][3]); + mtx->m[2][2] = (rx * tf->m[2][0]) + (ry * tf->m[2][1]) + (rz * tf->m[2][2]) + (rw * tf->m[2][3]); + mtx->m[3][2] = (rx * tf->m[3][0]) + (ry * tf->m[3][1]) + (rz * tf->m[3][2]) + (rw * tf->m[3][3]); + + rx = mtx->m[0][3]; + ry = mtx->m[1][3]; + rz = mtx->m[2][3]; + rw = mtx->m[3][3]; + + mtx->m[0][3] = (rx * tf->m[0][0]) + (ry * tf->m[0][1]) + (rz * tf->m[0][2]) + (rw * tf->m[0][3]); + mtx->m[1][3] = (rx * tf->m[1][0]) + (ry * tf->m[1][1]) + (rz * tf->m[1][2]) + (rw * tf->m[1][3]); + mtx->m[2][3] = (rx * tf->m[2][0]) + (ry * tf->m[2][1]) + (rz * tf->m[2][2]) + (rw * tf->m[2][3]); + mtx->m[3][3] = (rx * tf->m[3][0]) + (ry * tf->m[3][1]) + (rz * tf->m[3][2]) + (rw * tf->m[3][3]); + } else { + Matrix_Copy(mtx, tf); + } +} + +// Matrix_Translate +void Matrix_Translate(Matrix* mtx, f32 x, f32 y, f32 z, u8 mode) { + f32 rx; + f32 ry; + + if (mode == 1) { + rx = mtx->m[0][0]; + ry = mtx->m[1][0]; + + mtx->m[3][0] += (rx * x) + (ry * y) + (mtx->m[2][0] * z); + + rx = mtx->m[0][1]; + ry = mtx->m[1][1]; + + mtx->m[3][1] += (rx * x) + (ry * y) + (mtx->m[2][1] * z); + + rx = mtx->m[0][2]; + ry = mtx->m[1][2]; + + mtx->m[3][2] += (rx * x) + (ry * y) + (mtx->m[2][2] * z); + + rx = mtx->m[0][3]; + ry = mtx->m[1][3]; + + mtx->m[3][3] += (rx * x) + (ry * y) + (mtx->m[2][3] * z); + } else { + mtx->m[3][0] = x; + mtx->m[3][1] = y; + mtx->m[3][2] = z; + mtx->m[0][1] = mtx->m[0][2] = mtx->m[0][3] = mtx->m[1][0] = mtx->m[1][2] = mtx->m[1][3] = mtx->m[2][0] = + mtx->m[2][1] = mtx->m[2][3] = 0.0f; + mtx->m[0][0] = mtx->m[1][1] = mtx->m[2][2] = mtx->m[3][3] = 1.0f; + } +} + +// Matrix_Scale +#ifdef NON_MATCHING +void Matrix_Scale(Matrix* mtx, f32 xScale, f32 yScale, f32 zScale, u8 mode) { + if (mode == 1) { + mtx->m[0][0] *= xScale; + mtx->m[1][0] *= yScale; + mtx->m[2][0] *= zScale; + mtx->m[0][1] *= xScale; + mtx->m[1][1] *= yScale; + mtx->m[2][1] *= zScale; + mtx->m[0][2] *= xScale; + mtx->m[1][2] *= yScale; + mtx->m[2][2] *= zScale; + mtx->m[0][3] *= xScale; + mtx->m[1][3] *= yScale; + mtx->m[2][3] *= zScale; + } else { + mtx->m[0][0] = xScale; + mtx->m[1][1] = yScale; + mtx->m[2][2] = zScale; + mtx->m[0][1] = mtx->m[0][2] = mtx->m[0][3] = mtx->m[1][0] = mtx->m[1][2] = mtx->m[1][3] = mtx->m[2][0] = + mtx->m[2][1] = mtx->m[2][3] = mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f; + mtx->m[3][3] = 1.0f; + } +} +#else +// https://decomp.me/scratch/v4KEJ 91% +void Matrix_Scale(Matrix* mtx, f32 xScale, f32 yScale, f32 zScale, u8 mode); +#pragma GLOBAL_ASM("asm/us/nonmatchings/main/matrix/Matrix_Scale.s") +#endif + +// Matrix_RotateX +void Matrix_RotateX(Matrix* mtx, f32 angle, u8 mode) { + f32 cs; + f32 sn; + f32 ry; + f32 rz; + + sn = __sinf(angle); + cs = __cosf(angle); + if (mode == 1) { + ry = mtx->m[1][0]; + rz = mtx->m[2][0]; + mtx->m[1][0] = (ry * cs) + (rz * sn); + mtx->m[2][0] = (rz * cs) - (ry * sn); + + ry = mtx->m[1][1]; + rz = mtx->m[2][1]; + mtx->m[1][1] = (ry * cs) + (rz * sn); + mtx->m[2][1] = (rz * cs) - (ry * sn); + + ry = mtx->m[1][2]; + rz = mtx->m[2][2]; + mtx->m[1][2] = (ry * cs) + (rz * sn); + mtx->m[2][2] = (rz * cs) - (ry * sn); + + ry = mtx->m[1][3]; + rz = mtx->m[2][3]; + mtx->m[1][3] = (ry * cs) + (rz * sn); + mtx->m[2][3] = (rz * cs) - (ry * sn); + } else { + mtx->m[1][1] = mtx->m[2][2] = cs; + mtx->m[1][2] = sn; + mtx->m[2][1] = -sn; + mtx->m[0][0] = mtx->m[3][3] = 1.0f; + mtx->m[0][1] = mtx->m[0][2] = mtx->m[0][3] = mtx->m[1][0] = mtx->m[1][3] = mtx->m[2][0] = mtx->m[2][3] = + mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f; + } +} + +// Matrix_RotateY +void Matrix_RotateY(Matrix* mtx, f32 angle, u8 mode) { + f32 cs; + f32 sn; + f32 rx; + f32 rz; + + sn = __sinf(angle); + cs = __cosf(angle); + if (mode == 1) { + rx = mtx->m[0][0]; + rz = mtx->m[2][0]; + mtx->m[0][0] = (rx * cs) - (rz * sn); + mtx->m[2][0] = (rx * sn) + (rz * cs); + + rx = mtx->m[0][1]; + rz = mtx->m[2][1]; + mtx->m[0][1] = (rx * cs) - (rz * sn); + mtx->m[2][1] = (rx * sn) + (rz * cs); + + rx = mtx->m[0][2]; + rz = mtx->m[2][2]; + mtx->m[0][2] = (rx * cs) - (rz * sn); + mtx->m[2][2] = (rx * sn) + (rz * cs); + + rx = mtx->m[0][3]; + rz = mtx->m[2][3]; + mtx->m[0][3] = (rx * cs) - (rz * sn); + mtx->m[2][3] = (rx * sn) + (rz * cs); + } else { + mtx->m[0][0] = mtx->m[2][2] = cs; + mtx->m[0][2] = -sn; + mtx->m[2][0] = sn; + mtx->m[1][1] = mtx->m[3][3] = 1.0f; + mtx->m[0][1] = mtx->m[0][3] = mtx->m[1][0] = mtx->m[1][2] = mtx->m[1][3] = mtx->m[2][1] = mtx->m[2][3] = + mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f; + } +} + +// Matrix_RotateZ +void Matrix_RotateZ(Matrix* mtx, f32 angle, u8 mode) { + f32 cs; + f32 sn; + f32 rx; + f32 ry; + + sn = __sinf(angle); + cs = __cosf(angle); + if (mode == 1) { + rx = mtx->m[0][0]; + ry = mtx->m[1][0]; + mtx->m[0][0] = (rx * cs) + (ry * sn); + mtx->m[1][0] = (ry * cs) - (rx * sn); + + rx = mtx->m[0][1]; + ry = mtx->m[1][1]; + mtx->m[0][1] = (rx * cs) + (ry * sn); + mtx->m[1][1] = (ry * cs) - (rx * sn); + + rx = mtx->m[0][2]; + ry = mtx->m[1][2]; + mtx->m[0][2] = (rx * cs) + (ry * sn); + mtx->m[1][2] = (ry * cs) - (rx * sn); + + rx = mtx->m[0][3]; + ry = mtx->m[1][3]; + mtx->m[0][3] = (rx * cs) + (ry * sn); + mtx->m[1][3] = (ry * cs) - (rx * sn); + } else { + mtx->m[0][0] = mtx->m[1][1] = cs; + mtx->m[0][1] = sn; + mtx->m[1][0] = -sn; + mtx->m[2][2] = mtx->m[3][3] = 1.0f; + mtx->m[0][2] = mtx->m[0][3] = mtx->m[1][2] = mtx->m[1][3] = mtx->m[2][0] = mtx->m[2][1] = mtx->m[2][3] = + mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f; + } +} + +// Matrix_RotateAxis +void Matrix_RotateAxis(Matrix* mtx, f32 angle, f32 axisX, f32 axisY, f32 axisZ, u8 mode) { + f32 rx; + f32 ry; + f32 rz; + f32 norm; + f32 cxx; + f32 cyx; + f32 czx; + f32 cxy; + f32 cyy; + f32 czy; + f32 cxz; + f32 cyz; + f32 czz; + f32 xx; + f32 yy; + f32 zz; + f32 xy; + f32 yz; + f32 xz; + f32 sinA; + f32 cosA; + + norm = sqrtf((axisX * axisX) + (axisY * axisY) + (axisZ * axisZ)); + if (norm != 0.0) { + axisX /= norm; + axisY /= norm; + axisZ /= norm; + sinA = __sinf(angle); + cosA = __cosf(angle); + xx = axisX * axisX; + yy = axisY * axisY; + zz = axisZ * axisZ; + xy = axisX * axisY; + yz = axisY * axisZ; + xz = axisX * axisZ; + + if (mode == 1) { + cxx = (1.0f - xx) * cosA + xx; + cyx = (1.0f - cosA) * xy + axisZ * sinA; + czx = (1.0f - cosA) * xz - axisY * sinA; + + cxy = (1.0f - cosA) * xy - axisZ * sinA; + cyy = (1.0f - yy) * cosA + yy; + czy = (1.0f - cosA) * yz + axisX * sinA; + + cxz = (1.0f - cosA) * xz + axisY * sinA; + cyz = (1.0f - cosA) * yz - axisX * sinA; + czz = (1.0f - zz) * cosA + zz; + + rx = mtx->m[0][0]; + ry = mtx->m[0][1]; + rz = mtx->m[0][2]; + mtx->m[0][0] = (rx * cxx) + (ry * cxy) + (rz * cxz); + mtx->m[0][1] = (rx * cyx) + (ry * cyy) + (rz * cyz); + mtx->m[0][2] = (rx * czx) + (ry * czy) + (rz * czz); + + rx = mtx->m[1][0]; + ry = mtx->m[1][1]; + rz = mtx->m[1][2]; + mtx->m[1][0] = (rx * cxx) + (ry * cxy) + (rz * cxz); + mtx->m[1][1] = (rx * cyx) + (ry * cyy) + (rz * cyz); + mtx->m[1][2] = (rx * czx) + (ry * czy) + (rz * czz); + + rx = mtx->m[2][0]; + ry = mtx->m[2][1]; + rz = mtx->m[2][2]; + mtx->m[2][0] = (rx * cxx) + (ry * cxy) + (rz * cxz); + mtx->m[2][1] = (rx * cyx) + (ry * cyy) + (rz * cyz); + mtx->m[2][2] = (rx * czx) + (ry * czy) + (rz * czz); + } else { + mtx->m[0][0] = (1.0f - xx) * cosA + xx; + mtx->m[0][1] = (1.0f - cosA) * xy + axisZ * sinA; + mtx->m[0][2] = (1.0f - cosA) * xz - axisY * sinA; + mtx->m[0][3] = 0.0f; + + mtx->m[1][0] = (1.0f - cosA) * xy - axisZ * sinA; + mtx->m[1][1] = (1.0f - yy) * cosA + yy; + mtx->m[1][2] = (1.0f - cosA) * yz + axisX * sinA; + mtx->m[1][3] = 0.0f; + + mtx->m[2][0] = (1.0f - cosA) * xz + axisY * sinA; + mtx->m[2][1] = (1.0f - cosA) * yz - axisX * sinA; + mtx->m[2][2] = (1.0f - zz) * cosA + zz; + mtx->m[2][3] = 0.0f; + + mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f; + mtx->m[3][3] = 1.0f; + } + } +} + +// Matrix_ToMtx +void Matrix_ToMtx(Mtx* dest) { + s32 temp; + u16* m1 = (u16*) &dest->m[0][0]; + u16* m2 = (u16*) &dest->m[2][0]; + Matrix* src = D_8013B3C0; + + temp = src->xx * 0x10000; + m1[0] = (temp >> 0x10); + m2[0] = temp & 0xFFFF; + + temp = src->yx * 0x10000; + m1[1] = (temp >> 0x10); + m2[1] = temp & 0xFFFF; + + temp = src->zx * 0x10000; + m1[2] = (temp >> 0x10); + m2[2] = temp & 0xFFFF; + + temp = src->wx * 0x10000; + m1[3] = (temp >> 0x10); + m2[3] = temp & 0xFFFF; + + temp = src->xy * 0x10000; + m1[4] = (temp >> 0x10); + m2[4] = temp & 0xFFFF; + + temp = src->yy * 0x10000; + m1[5] = (temp >> 0x10); + m2[5] = temp & 0xFFFF; + + temp = src->zy * 0x10000; + m1[6] = (temp >> 0x10); + m2[6] = temp & 0xFFFF; + + temp = src->wy * 0x10000; + m1[7] = (temp >> 0x10); + m2[7] = temp & 0xFFFF; + + temp = src->xz * 0x10000; + m1[8] = (temp >> 0x10); + m2[8] = temp & 0xFFFF; + + temp = src->yz * 0x10000; + m1[9] = (temp >> 0x10); + m2[9] = temp & 0xFFFF; + + temp = src->zz * 0x10000; + m1[10] = (temp >> 0x10); + m2[10] = temp & 0xFFFF; + + temp = src->wz * 0x10000; + m1[11] = (temp >> 0x10); + m2[11] = temp & 0xFFFF; + + temp = src->xw * 0x10000; + m1[12] = (temp >> 0x10); + m2[12] = temp & 0xFFFF; + + temp = src->yw * 0x10000; + m1[13] = (temp >> 0x10); + m2[13] = temp & 0xFFFF; + + temp = src->zw * 0x10000; + m1[14] = (temp >> 0x10); + m2[14] = temp & 0xFFFF; + + temp = src->ww * 0x10000; + m1[15] = (temp >> 0x10); + m2[15] = temp & 0xFFFF; +} + +// Matrix_FromMtx +void Matrix_FromMtx(Mtx* src, Matrix* dest) { + u16* m1 = (u16*) &src->m[0][0]; + u16* m2 = (u16*) &src->m[2][0]; + + dest->xx = ((m1[0] << 0x10) | m2[0]) * (1 / 65536.0f); + dest->yx = ((m1[1] << 0x10) | m2[1]) * (1 / 65536.0f); + dest->zx = ((m1[2] << 0x10) | m2[2]) * (1 / 65536.0f); + dest->wx = ((m1[3] << 0x10) | m2[3]) * (1 / 65536.0f); + dest->xy = ((m1[4] << 0x10) | m2[4]) * (1 / 65536.0f); + dest->yy = ((m1[5] << 0x10) | m2[5]) * (1 / 65536.0f); + dest->zy = ((m1[6] << 0x10) | m2[6]) * (1 / 65536.0f); + dest->wy = ((m1[7] << 0x10) | m2[7]) * (1 / 65536.0f); + dest->xz = ((m1[8] << 0x10) | m2[8]) * (1 / 65536.0f); + dest->yz = ((m1[9] << 0x10) | m2[9]) * (1 / 65536.0f); + dest->zz = ((m1[10] << 0x10) | m2[10]) * (1 / 65536.0f); + dest->wz = ((m1[11] << 0x10) | m2[11]) * (1 / 65536.0f); + dest->xw = ((m1[12] << 0x10) | m2[12]) * (1 / 65536.0f); + dest->yw = ((m1[13] << 0x10) | m2[13]) * (1 / 65536.0f); + dest->zw = ((m1[14] << 0x10) | m2[14]) * (1 / 65536.0f); + dest->ww = ((m1[15] << 0x10) | m2[15]) * (1 / 65536.0f); +} + +// Matrix_MultVec3f +void Matrix_MultVec3f(Matrix* mtx, Vec3f* src, Vec3f* dest) { + dest->x = (mtx->m[0][0] * src->x) + (mtx->m[1][0] * src->y) + (mtx->m[2][0] * src->z) + mtx->m[3][0]; + dest->y = (mtx->m[0][1] * src->x) + (mtx->m[1][1] * src->y) + (mtx->m[2][1] * src->z) + mtx->m[3][1]; + dest->z = (mtx->m[0][2] * src->x) + (mtx->m[1][2] * src->y) + (mtx->m[2][2] * src->z) + mtx->m[3][2]; +} + +// Matrix_MultVec3fLinear ? +void Matrix_MultVec3fNoTranslate(Matrix* mtx, Vec3f* src, Vec3f* dest) { + dest->x = (mtx->m[0][0] * src->x) + (mtx->m[1][0] * src->y) + (mtx->m[2][0] * src->z); + dest->y = (mtx->m[0][1] * src->x) + (mtx->m[1][1] * src->y) + (mtx->m[2][1] * src->z); + dest->z = (mtx->m[0][2] * src->x) + (mtx->m[1][2] * src->y) + (mtx->m[2][2] * src->z); +} + +// Matrix_GetYPRAngles +void Matrix_GetYRPAngles(Matrix* mtx, Vec3f* rot) { + Matrix invYP; + Vec3f origin = { 0.0f, 0.0f, 0.0f }; + Vec3f originP; + Vec3f zHat = { 0.0f, 0.0f, 1.0f }; + Vec3f zHatP; + Vec3f xHat = { 1.0f, 0.0f, 0.0f }; + Vec3f xHatP; + + Matrix_MultVec3fNoTranslate(mtx, &origin, &originP); + Matrix_MultVec3fNoTranslate(mtx, &zHat, &zHatP); + Matrix_MultVec3fNoTranslate(mtx, &xHat, &xHatP); + zHatP.x -= originP.x; + zHatP.y -= originP.y; + zHatP.z -= originP.z; + xHatP.x -= originP.x; + xHatP.y -= originP.y; + xHatP.z -= originP.z; + rot->y = Math_Atan2F(zHatP.x, zHatP.z); + rot->x = -Math_Atan2F(zHatP.y, sqrtf((zHatP.x * zHatP.x) + (zHatP.z * zHatP.z))); + Matrix_RotateX(&invYP, -rot->x, 0); + Matrix_RotateY(&invYP, -rot->y, 1); + Matrix_MultVec3fNoTranslate(&invYP, &xHatP, &xHat); + rot->x *= 57.295776f; + rot->y *= 57.295776f; + rot->z = Math_Atan2F(xHat.y, xHat.x) * 57.295776f; +} + +// Matrix_GetXYZAngles +void Matrix_GetXYZAngles(Matrix* mtx, Vec3f* rot) { + Matrix invYZ; + Vec3f origin = { 0.0f, 0.0f, 0.0f }; + Vec3f originP; + Vec3f xHat = { 1.0f, 0.0f, 0.0f }; + Vec3f xHatP; + Vec3f yHat = { 0.0f, 1.0f, 0.0f }; + Vec3f yHatP; + + Matrix_MultVec3fNoTranslate(mtx, &origin, &originP); + Matrix_MultVec3fNoTranslate(mtx, &xHat, &xHatP); + Matrix_MultVec3fNoTranslate(mtx, &yHat, &yHatP); + xHatP.x -= originP.x; + xHatP.y -= originP.y; + xHatP.z -= originP.z; + yHatP.x -= originP.x; + yHatP.y -= originP.y; + yHatP.z -= originP.z; + rot->z = Math_Atan2F(xHatP.y, xHatP.x); + rot->y = -Math_Atan2F(xHatP.z, sqrtf((xHatP.x * xHatP.x) + (xHatP.y * xHatP.y))); + Matrix_RotateY(&invYZ, -rot->y, 0); + Matrix_RotateZ(&invYZ, -rot->z, 1); + Matrix_MultVec3fNoTranslate(&invYZ, &yHatP, &yHat); + rot->x = Math_Atan2F(yHat.z, yHat.y) * M_RTOD; + rot->y *= M_RTOD; + rot->z *= M_RTOD; +} + +// Matrix_LookAt +void Matrix_LookAt(Matrix* mtx, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, + u8 mode) { + Matrix lookAt; + + guLookAtF(lookAt.m, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp); + Matrix_Mult(mtx, &lookAt, mode); +} + +// Matrix_SetMtx ? +void Matrix_SetGfxMtx(Gfx** gfx) { + Matrix_ToMtx(gGfxMtx); + gSPMatrix((*gfx)++, gGfxMtx++, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); +} diff --git a/src/main/sf_59780.c b/src/main/sf_59780.c index 99f9b7f2..11c6b390 100644 --- a/src/main/sf_59780.c +++ b/src/main/sf_59780.c @@ -1,17 +1,186 @@ -#include "common.h" +#include "global.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_59780/func_80058B80.s") +#define SEGMENT_SIZE(segment) ((ptrdiff_t) ((uintptr_t) (segment).end - (uintptr_t) (segment).start)) +#define PHYS_ADDR(ptr) ((uintptr_t) (ptr) &0x1FFFFFFF) -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_59780/func_80058C48.s") +extern u8 func_80187520[]; +extern OverlayInit D_800CBDD4; -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_59780/func_80058F14.s") +void func_80058B80(void* arg0, void* arg1, ptrdiff_t arg2) { + s32 i; -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_59780/func_80059498.s") + for (i = 0; gDmaTable[i].pRom.end != NULL; i++) { + if (gDmaTable[i].vRomAddress == arg0) { + if (gDmaTable[i].compFlag == 0) { + func_800033E0(gDmaTable[i].pRom.start, arg1, arg2); + } else { + func_800034E8(1); + D_800CA3B0 = 3; + D_80161A39 = 1; + func_800033E0(gDmaTable[i].pRom.start, gFrameBuffers, SEGMENT_SIZE(gDmaTable[i].pRom)); + Mio0_Decompress(gFrameBuffers, arg1); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_59780/func_800594F0.s") +u8 func_80058C48(OverlayInit* segment) { + u8* var_s2 = func_80187520; + u8 var_s1; + u8 sp42 = 0; -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_59780/func_800595D0.s") + if (segment->unk_0.start == (0, D_800CBDD4.unk_0.start)) { // fake because D_800CBDD4 is probably 2D array + var_s2 = var_s2 + SEGMENT_SIZE(segment->unk_0); + var_s2 = var_s2 + SEGMENT_SIZE(segment->unk_8); + } else { + D_800CBDD4.unk_0.start = segment->unk_0.start; + D_800CBDD4.unk_0.end = var_s2; + if (segment->unk_0.start != 0) { + sp42 = 1; + func_80058B80(segment->unk_0.start, var_s2, SEGMENT_SIZE(segment->unk_0)); + var_s2 = var_s2 + SEGMENT_SIZE(segment->unk_0); + bzero(segment->unk_8.start, SEGMENT_SIZE(segment->unk_8)); + var_s2 = var_s2 + SEGMENT_SIZE(segment->unk_8); + } + } + var_s1 = 0; + while ((var_s1 < 15) && (segment->unk_20[var_s1].start == D_800CBDD4.unk_20[var_s1].start) && (sp42 == 0)) { + if (segment->unk_20[var_s1].start != 0) { + gSegments[var_s1 + 1] = PHYS_ADDR(var_s2); + gSPSegment(gUnkDisp1++, var_s1 + 1, PHYS_ADDR(var_s2)); + var_s2 = var_s2 + SEGMENT_SIZE(segment->unk_20[var_s1]); + } + var_s1 += 1; + } + for (var_s1; var_s1 < 15; var_s1 += 1) { + D_800CBDD4.unk_20[var_s1].start = segment->unk_20[var_s1].start; + D_800CBDD4.unk_20[var_s1].end = var_s2; + if (segment->unk_20[var_s1].start != 0) { + gSegments[var_s1 + 1] = PHYS_ADDR(var_s2); + gSPSegment(gUnkDisp1++, var_s1 + 1, PHYS_ADDR(var_s2)); + func_80058B80(segment->unk_20[var_s1].start, var_s2, SEGMENT_SIZE(segment->unk_20[var_s1])); + var_s2 = var_s2 + SEGMENT_SIZE(segment->unk_20[var_s1]); + } + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_59780/func_800596B0.s") + if (D_800CA3B0 != 0) { + D_800CA3B0--; + } else if (D_80137E80 == 0) { + func_800034E8(0); + } + return sp42; +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_59780/D_800D5FA0.s") +u8 func_80058F14(u8 arg0, u8 arg1) { + u8 var_v1; + + switch (arg0) { + case 0x0: + var_v1 = func_80058C48(&D_800CA7DC[arg1]); + if (var_v1 == 1) { + func_8001DC6C(0, 0x16); + } + break; + case 0x1: + var_v1 = func_80058C48(&D_800CA874[arg1]); + break; + case 0x2: + var_v1 = func_80058C48(&D_800CA90C[arg1]); + break; + case 0x3: + var_v1 = func_80058C48(&D_800CA9A4[arg1]); + break; + case 0x5: + var_v1 = func_80058C48(&D_800CAA3C[arg1]); + break; + case 0x6: + var_v1 = func_80058C48(&D_800CAAD4[arg1]); + break; + case 0x7: + var_v1 = func_80058C48(&D_800CAC04[arg1]); + break; + case 0x8: + var_v1 = func_80058C48(&D_800CAF94[arg1]); + break; + case 0x17: + var_v1 = func_80058C48(&D_800CB0C4[arg1]); + break; + case 0x9: + var_v1 = func_80058C48(&D_800CB15C[arg1]); + break; + case 0xA: + var_v1 = func_80058C48(&D_800CB1F4[arg1]); + break; + case 0xB: + var_v1 = func_80058C48(&D_800CB28C[arg1]); + break; + case 0xC: + var_v1 = func_80058C48(&D_800CB3BC[arg1]); + break; + case 0xD: + var_v1 = func_80058C48(&D_800CB454[arg1]); + break; + case 0xE: + var_v1 = func_80058C48(&D_800CB4EC[arg1]); + break; + case 0xF: + var_v1 = func_80058C48(&D_800CB584[arg1]); + break; + case 0x10: + var_v1 = func_80058C48(&D_800CB6B4[arg1]); + break; + case 0x11: + var_v1 = func_80058C48(&D_800CBB74[arg1]); + break; + case 0x12: + var_v1 = func_80058C48(&D_800CB61C[arg1]); + break; + case 0x18: + var_v1 = func_80058C48(&D_800CB74C[arg1]); + break; + case 0x14: + var_v1 = func_80058C48(&D_800CB87C[arg1]); + break; + case 0x16: + var_v1 = func_80058C48(&D_800CB914[arg1]); + break; + case 0x13: + var_v1 = func_80058C48(&D_800CB9AC[arg1]); + break; + case 0x15: + var_v1 = func_80058C48(&D_800CBA44[arg1]); + break; + case 0x32: + var_v1 = func_80058C48(&D_800CBC0C[arg1]); + if (var_v1 == 1) { + func_8001DC6C(3, 0x310); + } + break; + case 0x63: + var_v1 = func_80058C48(&D_800CA3B4[arg1]); + if (var_v1 == 1) { + func_8001DC6C(0, 0xE); + } + break; + case 0x4: + var_v1 = func_80058C48(&D_800CA44C[arg1]); + break; + default: + (void) "DMA MODE ERROR %d\n"; + var_v1 = 0; + break; + } + return var_v1; +} + +extern DmaEntry D_80179010[]; +extern u8 D_DE480[]; +extern u8 D_DE5D50[]; +extern u8 D_DEA20[]; +extern u8 D_DF4260[]; + +void func_80059498(void) { + func_800033E0(D_DE480, gDmaTable, D_DEA20 - D_DE480); + func_80058B80(D_DE5D50, D_80179010, D_DF4260 - D_DE5D50); +} diff --git a/src/main/sf_5A0F0.c b/src/main/sf_5A0F0.c new file mode 100644 index 00000000..dfe33209 --- /dev/null +++ b/src/main/sf_5A0F0.c @@ -0,0 +1,7 @@ +#include "common.h" + +#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_5A0F0/func_800594F0.s") + +#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_5A0F0/func_800595D0.s") + +#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_5A0F0/func_800596B0.s") diff --git a/src/main/sf_A24B0.c b/src/main/sf_A24B0.c index dbf2083b..4b7eff0a 100644 --- a/src/main/sf_A24B0.c +++ b/src/main/sf_A24B0.c @@ -1,23 +1,295 @@ -#include "common.h" +#include "global.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A18B0.s") +extern void func_80187520(s32, void*); -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A1980.s") +void func_800A18B0(void) { + func_80006F20(); + Rand_Init(); + Rand_SetSeed(1, 29000, 9876); + D_80177834 = 0x64; + D_8017783C = 0; + D_80161A36 = 0; + D_80161A38 = 0xFF; + D_80161A3C = 45.0f; + D_80161A40 = 10.0f; + D_80161A44 = 12800.0f; + D_80161A10 = D_80161A14 = 0.0f; + D_801774F8 = 0x63; + D_80177820 = 0; + func_80059498(); + D_80161A39 = 1; +} + +void func_800A1980(void) { + u16 temp; + D_80161A14 = D_80161A10; + temp = D_80161A32; + + switch (temp) { + case 7: + D_80178234 = D_80161A30; + func_800A5844(); + D_80177854 = 0; + D_8017827C = D_80161A2E; + D_80161A2E = 0; + if ((D_8017827C != 0) && (D_80178234 != 9)) { + D_8017782C = 0; + } + break; + case 4: + D_80177B40 = 0; + break; + case 5: + D_80177868 = 0; + break; + case 0: + return; + } + func_80006F20(); + func_800A6148(); + D_80177834 = D_80161A32; + D_8017783C = 3; + D_8015F924 = 0; + D_80161A32 = 0; + D_80177820 = 0; + D_80137E88 = D_80161A36 = 0; + D_80177D20 = 0.0f; + if ((D_80178234 == 0x13) && (D_8017827C == 2)) { + D_80137E88 = D_80161A36 = 0xFFFF; + D_80178348 = D_80178350 = D_80178354 = 0xFF; + } else { + D_80178348 = D_80178350 = D_80178354 = 0; + func_8001DBD0(1); + } + D_80178340 = 0xFF; + D_80178380 = 0; + D_8017829C = 0; + D_80178428 = 0.0f; + D_80161A38 = 0xFF; + D_80177898 = 0; + func_8001AE58(); + func_8001D400(0); +} + +#ifdef DATA_IMPORT_PENDING +s32 func_800A1B6C(void) { + static u8 D_800D2908 = 5; + static u8 D_800D290C = 5; + static u8 D_800D2910 = 5; + static u8 D_800D2914 = 5; + + if (D_801774F8 != D_800D2910) { + D_800D2908 = 2; + D_800D2910 = D_801774F8; + } + if (D_800D2908 == 0) { + D_800D290C = D_800D2910; + D_800D2914 = D_80177820; + } + func_80058F14(D_800D290C, D_800D2914); + + if (D_800D2908) { + D_800D2908--; + return 1; + } + return 0; +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A1B6C.s") +#endif -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A1C14.s") +void func_800A1C14(Gfx** arg0) { + s32 temp_t9; -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A1E68.s") + gSPDisplayList((*arg0)++, D_Gfx_800DBAA0); + gDPSetScissor((*arg0)++, G_SC_NON_INTERLACE, 8, 8, 312, 232); + gDPSetDepthImage((*arg0)++, &D_80282000); + gDPSetColorImage((*arg0)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, &D_80282000); + gDPSetFillColor((*arg0)++, 0xFFFCFFFC); + gDPFillRectangle((*arg0)++, 8, 8, 311, 231); + gDPSetColorImage((*arg0)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, gFrameBuffer); -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A1F44.s") + if (D_80161A38 < 0xFF) { + gDPPipeSync((*arg0)++); + gDPSetCycleType((*arg0)++, G_CYC_1CYCLE); + gDPSetCombineMode((*arg0)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetRenderMode((*arg0)++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetPrimColor((*arg0)++, 0x00, 0x00, (u8) (D_80161A36 >> 0xB) * 8, (u8) (D_80161A36 >> 6) * 8, + (u8) (D_80161A36 >> 1) * 8, D_80161A38); + } else { + gDPSetFillColor((*arg0)++, (((D_80161A36 | 1) << 0x10) | (D_80161A36 | 1))); + } + gDPFillRectangle((*arg0)++, 8, 8, 311, 232); + gDPPipeSync((*arg0)++); + gDPSetColorDither((*arg0)++, G_CD_MAGICSQ); +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A1FB0.s") +void func_800A1E68(Gfx** arg0) { + gSPDisplayList((*arg0)++, D_Gfx_800DBAA0); + gDPSetScissor((*arg0)++, G_SC_NON_INTERLACE, 0, 0, 320, 720); + gDPSetFillColor((*arg0)++, 0x00010001); + gDPSetColorImage((*arg0)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, gFrameBuffers); + gDPFillRectangle((*arg0)++, 0, 0, 319, 719); + gDPPipeSync((*arg0)++); + gDPSetColorDither((*arg0)++, G_CD_MAGICSQ); +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A24DC.s") +void func_800A1F44(void) { + gViewport->vp.vscale[0] = gViewport->vp.vtrans[0] = 0x280; + gViewport->vp.vscale[1] = gViewport->vp.vtrans[1] = 0x1E0; + gViewport->vp.vscale[2] = gViewport->vp.vtrans[2] = 0x1FF; + gViewport->vp.vscale[3] = gViewport->vp.vtrans[3] = 0; +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A25DC.s") +void func_800A1FB0(Gfx** arg0, u8 arg1, u8 arg2) { + if ((arg1 != 1) && (arg1 == 4)) { + switch (arg2) { + case 0: + gViewport->vp.vscale[0] = 320 * (D_80161A14 - 1.0f) * 2; + gViewport->vp.vscale[1] = 240 * (D_80161A14 - 1.0f) * 2; + gViewport->vp.vscale[2] = 0x1FF; + gViewport->vp.vscale[3] = 0; + gViewport->vp.vtrans[0] = 320 * (2.0f - D_80161A14) * 2; + gViewport->vp.vtrans[1] = 240 * (2.0f - D_80161A14) * 2; + gViewport->vp.vtrans[2] = 0x1FF; + gViewport->vp.vtrans[3] = 0; + gDPSetScissor((*arg0)++, G_SC_NON_INTERLACE, 8, 8, 160, 120); + break; + case 1: + gViewport->vp.vscale[0] = 320 * (D_80161A14 - 1.0f) * 2; + gViewport->vp.vscale[1] = 240 * (D_80161A14 - 1.0f) * 2; + gViewport->vp.vscale[2] = 0x1FF; + gViewport->vp.vscale[3] = 0; + gViewport->vp.vtrans[0] = 320 * D_80161A14 * 2; + gViewport->vp.vtrans[1] = (2.0f - D_80161A14) * 240 * 2; + gViewport->vp.vtrans[2] = 0x1FF; + gViewport->vp.vtrans[3] = 0; + gDPSetScissor((*arg0)++, G_SC_NON_INTERLACE, 160, 8, 312, 120); + break; + case 2: + gViewport->vp.vscale[0] = 320 * (D_80161A14 - 1.0f) * 2; + gViewport->vp.vscale[1] = 240 * (D_80161A14 - 1.0f) * 2; + gViewport->vp.vscale[2] = 0x1FF; + gViewport->vp.vscale[3] = 0; + gViewport->vp.vtrans[0] = 320 * (2.0f - D_80161A14) * 2; + gViewport->vp.vtrans[1] = 240 * D_80161A14 * 2; + gViewport->vp.vtrans[2] = 0x1FF; + gViewport->vp.vtrans[3] = 0; + gDPSetScissor((*arg0)++, G_SC_NON_INTERLACE, 8, 120, 160, 232); + break; + case 3: + gViewport->vp.vscale[0] = 320 * (D_80161A14 - 1.0f) * 2; + gViewport->vp.vscale[1] = 240 * (D_80161A14 - 1.0f) * 2; + gViewport->vp.vscale[2] = 0x1FF; + gViewport->vp.vscale[3] = 0; + gViewport->vp.vtrans[0] = 320 * D_80161A14 * 2; + gViewport->vp.vtrans[1] = 240 * D_80161A14 * 2; + gViewport->vp.vtrans[2] = 0x1FF; + gViewport->vp.vtrans[3] = 0; + gDPSetScissor((*arg0)++, G_SC_NON_INTERLACE, 160, 120, 312, 232); + break; + default: + func_800A1F44(); + break; + } + } else { + func_800A1F44(); + if (1) {} + } + gSPViewport((*arg0)++, gViewport++); +} + +void func_800A24DC(s32 arg0) { + switch (D_80177898) { + case 0: + break; + case 1: + func_8003DAF0(); + func_80187520(0x68, NULL); + break; + case 2: + func_8003DAF0(); + func_80187520(0x6C, NULL); + break; + case 3: + func_8003DAF0(); + func_80187520(0x6A, NULL); + break; + case 4: + D_801778A0 = arg0; + func_80057D00(); + break; + case 5: + func_8003DAF0(); + func_80187520(0x6E, NULL); + break; + case 6: + func_800C2190(); + break; + case 7: + D_801778A0 = arg0; + func_800A3CA0(); + break; + case 8: + func_8003DAF0(); + D_801778A0 = arg0; + func_8018AAC4(); + break; + } +} + +void func_800A25DC(void) { + switch (D_80177834) { + case 1: + D_801774F8 = 0; + D_80177820 = 0; + break; + case 2: + D_801774F8 = 0; + D_80177820 = 0; + break; + case 3: + D_801774F8 = 1; + D_80177820 = 0; + break; + case 4: + D_801774F8 = 2; + D_80177820 = 0; + return; + case 6: + D_801774F8 = 0x32; + break; + case 7: + D_801774F8 = D_800D28B4[D_80178234]; + break; + case 5: + D_801774F8 = 3; + D_80177820 = 0; + break; + case 8: + D_801774F8 = 4; + break; + } +} #pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A26C0.s") -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_A24B0/func_800A3608.s") +UnkStruct_func_80090A00* func_800A3608(s32 arg0) { + UnkStruct_func_80090A00* var_a2 = D_80163FE0; + s32 i; + + for (i = 0; i < 60; i++, var_a2++) { + if (var_a2->unk_000.unk_00 == 0) { + func_800613C4(var_a2); + var_a2->unk_000.unk_00 = 1; + var_a2->unk_000.unk_02 = arg0; + func_800612B8(&var_a2->unk_01C, var_a2->unk_000.unk_02); + break; + } + } + if (i == 60) { + var_a2 = NULL; + } + return var_a2; +} diff --git a/src/main/sf_BB360.c b/src/main/sf_BB360.c index 014fa7fc..ef174029 100644 --- a/src/main/sf_BB360.c +++ b/src/main/sf_BB360.c @@ -7,7 +7,7 @@ void func_800BA760(void) { } } -s32 func_800BA7BC(s32 arg0, s32 arg1) { +s32 func_800BA7BC(u16* arg0, s32 arg1) { s32 var_v0 = D_800D4A70; if (arg1 == var_v0) { diff --git a/src/main/sf_C3BB0.c b/src/main/sf_C3BB0.c index ee235593..ce607c7f 100644 --- a/src/main/sf_C3BB0.c +++ b/src/main/sf_C3BB0.c @@ -1,9 +1,72 @@ -#include "common.h" +#include "global.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_C3BB0/func_800C2FB0.s") +#ifdef DATA_IMPORT_PENDING +SaveFile D_80178870; +#else +extern SaveFile D_80178870; +#endif -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_C3BB0/func_800C3084.s") +u16 func_800C2FB0(Save* arg0) { + u16 var_v1; + s32 i; + + for (i = 0, var_v1 = 0; i < 0xFE; i++) { + var_v1 ^= arg0->unk_0[i]; + var_v1 <<= 1; + var_v1 = (var_v1 & 0xFE) | ((var_v1 >> 8) & 1); + } + + var_v1 = (var_v1 & 0xFF) | 0x9500; + + return var_v1; +} + +s32 func_800C3084(void) { + void* sp1C; + + D_80178870.save[0].unk_FE = func_800C2FB0(&D_80178870.save[0]); + D_80178870.save[1] = D_80178870.save[0]; + D_80144F60 = D_80178870; + osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_MESG_12, OS_MESG_PRI_NORMAL); + osRecvMesg(&D_800E2318, &sp1C, OS_MESG_BLOCK); + if (sp1C != (OSMesg) SI_MESG_15) { + return -1; + } + return 0; +} + +#ifdef DATA_IMPORT_PENDING +s32 func_800C3194(void) { + void* sp24; + s32 i; + + osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_MESG_11, OS_MESG_PRI_NORMAL); + osRecvMesg(&D_800E2318, &sp24, OS_MESG_BLOCK); + if ((s32) sp24 != SI_MESG_15) { + return -1; + } + + D_80178870 = D_80144F60; + + if (D_80178870.save[0].unk_FE == func_800C2FB0(&D_80178870.save[0])) { + (void) "EEPROM ROM[0] 正常\n"; + return 0; + } + + for (i = 0; i < 0xFF; i++) { + D_80178870.save[0].unk_0[i] = D_80178870.save[1].unk_0[i]; + } + D_80178870.save[0].unk_FE = D_80178870.save[1].unk_FE; + + if (D_80178870.save[0].unk_FE == func_800C2FB0(&D_80178870.save[0])) { + (void) "EEPROM ROM[1] 正常\n"; + return 0; + } + (void) "EEPROM ROM[0] & ROM[1] 異常\n"; + return -1; +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_C3BB0/func_800C3194.s") - #pragma GLOBAL_ASM("asm/us/nonmatchings/main/sf_C3BB0/D_800D9430.s") +#endif diff --git a/src/main/sf_hud.c b/src/main/sf_hud.c index eb0f673a..8e234359 100644 --- a/src/main/sf_hud.c +++ b/src/main/sf_hud.c @@ -288,10 +288,10 @@ void func_80088784(s32 arg0) { arg0--; func_800B8DD0(&gMasterDisp, 0x24); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, D_800D1DC8[arg0]); - func_80005708(&D_8013B3C0); - func_80005B00(D_8013B3C0, 3.9f, -3.3f, -100.0f, 0); - func_80005C34(D_8013B3C0, 0.37f, 0.37f, 0.37f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Push(&D_8013B3C0); + Matrix_Translate(D_8013B3C0, 3.9f, -3.3f, -100.0f, 0); + Matrix_Scale(D_8013B3C0, 0.37f, 0.37f, 0.37f, 1); + Matrix_SetGfxMtx(&gMasterDisp); if (D_80177C98 == 0) { gSPDisplayList(gMasterDisp++, D_800D1D4C[arg0]); @@ -299,7 +299,7 @@ void func_80088784(s32 arg0) { gSPDisplayList(gMasterDisp++, D_800D1D94[arg0]); } - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); } } #else @@ -311,40 +311,40 @@ void func_80088784(s32 arg0) { void func_80089670(void) { func_800B8DD0(&gMasterDisp, 0x3E); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); - func_80005C34(D_8013B3C0, 18.64f, 21.04f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, 18.64f, 21.04f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_1024AC0); } void func_80089710(void) { func_800B8DD0(&gMasterDisp, 0x3E); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); - func_80005C34(D_8013B3C0, 11.0f, 11.0f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, 11.0f, 11.0f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_1024AC0); } void func_800897B0(void) { func_800B8DD0(&gMasterDisp, 0x3E); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); - func_80005C34(D_8013B3C0, 130.0f, 130.0f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, 130.0f, 130.0f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_1024830); } void func_80089850(void) { func_800B8DD0(&gMasterDisp, 0x3E); gDPSetPrimColor(gMasterDisp++, 0, 0, 0, 0, 0, 255); - func_80005C34(D_8013B3C0, 125.0f, 125.0f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, 125.0f, 125.0f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_102A8A0); } void func_800898F0(void) { func_800B8DD0(&gMasterDisp, 1); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 208, 80, 255); - func_80005C34(D_8013B3C0, 30.0f, 30.0f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, 30.0f, 30.0f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_6004570); } @@ -368,8 +368,8 @@ void func_80089994(s32 arg0) { func_800B8DD0(&gMasterDisp, 0x3E); gDPSetPrimColor(gMasterDisp++, 0, 0, D_800D1E14[arg0][0], D_800D1E14[arg0][1], D_800D1E14[arg0][2], D_800D1E14[arg0][3]); - func_80005C34(D_8013B3C0, var_fv1, var_fv2, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, var_fv1, var_fv2, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_1015510); } #else @@ -379,16 +379,16 @@ void func_80089994(s32 arg0) { void func_80089AF4(void) { func_800B8DD0(&gMasterDisp, 0x3E); gDPSetPrimColor(gMasterDisp++, 0, 0, 0, 0, 0, 255); - func_80005C34(D_8013B3C0, 54.0f, 54.0f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, 54.0f, 54.0f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_F014180); } void func_80089B94(void) { func_800B8DD0(&gMasterDisp, 0x3E); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 92, 92, 255); - func_80005C34(D_8013B3C0, 54.0f, 54.0f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, 54.0f, 54.0f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_D0098B0); } @@ -405,8 +405,8 @@ void func_80089C38(void) { alpha *= 255.0f / 10.0f; gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, alpha); - func_80005C34(D_8013B3C0, 15.0f, 15.0f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Scale(D_8013B3C0, 15.0f, 15.0f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_1024230); } @@ -431,9 +431,9 @@ void func_80089D28(void) { } gDPSetPrimColor(gMasterDisp++, 0, 0, 255, gb, gb, 255); - func_80005B00(D_8013B3C0, 0.0f, -185.92001f, 0, 1); - func_80005C34(D_8013B3C0, 3.55f, 0.13f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Translate(D_8013B3C0, 0.0f, -185.92001f, 0, 1); + Matrix_Scale(D_8013B3C0, 3.55f, 0.13f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_1024230); } @@ -771,12 +771,12 @@ void func_8008BAE4(void) { if ((D_80161788 != 0) || (D_8016178C != 0)) { func_800B8DD0(&gMasterDisp, 0xC); gDPSetPrimColor(gMasterDisp++, 0, 0, r, g, b, alpha); - func_80005708(&D_8013B3C0); - func_80005B00(D_8013B3C0, -53.9f, -38.5f, -139.4f, 1); - func_80005C34(D_8013B3C0, 1.0f, 1.0f, 1.0f, 1); - func_80006EB8(&gMasterDisp); + Matrix_Push(&D_8013B3C0); + Matrix_Translate(D_8013B3C0, -53.9f, -38.5f, -139.4f, 1); + Matrix_Scale(D_8013B3C0, 1.0f, 1.0f, 1.0f, 1); + Matrix_SetGfxMtx(&gMasterDisp); gSPDisplayList(gMasterDisp++, D_800D1A40); - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); } } @@ -1845,7 +1845,7 @@ s32 func_80091DF4(UnkStruct_func_80090A00* arg0) { sp44.x = 0.0f; sp44.y = 0.0f; sp44.z = 100.0f; - func_80006A20(D_8013BBC8, &sp44, &sp38); + Matrix_MultVec3fNoTranslate(D_8013BBC8, &sp44, &sp38); func_8006EEFC(arg0->unk_0E4, arg0->unk_000.pos.x + (sp38.x * 1.5), arg0->unk_000.pos.y + (sp38.y * 1.5), arg0->unk_000.pos.z + (sp38.z * 1.5), sp38.x, sp38.y, sp38.z, arg0->unk_000.unk_10.x, arg0->unk_000.unk_10.y, arg0->unk_000.unk_10.z); @@ -1872,7 +1872,7 @@ s32 func_80091F00(UnkStruct_func_80090A00* arg0) { func_80019218(0x2903300E, arg0->unk_100, 4, &D_800C5D34, &D_800C5D34, &D_800C5D3C); func_8007D10C(arg0->unk_000.pos.x, arg0->unk_000.pos.y, arg0->unk_000.pos.z, 1.5f); - func_80005E90(D_8013BBC8, arg0->unk_0F8 * (M_PI / 180), 0); + Matrix_RotateY(D_8013BBC8, arg0->unk_0F8 * (M_PI / 180), 0); if (Rand_ZeroOne() < 0.5f) { sp40.x = -20.0f; @@ -1883,7 +1883,7 @@ s32 func_80091F00(UnkStruct_func_80090A00* arg0) { sp40.y = (Rand_ZeroOne() - 0.5f) * 20.0f; sp40.z = 0.0f; - func_80006A20(D_8013BBC8, &sp40, &sp34); + Matrix_MultVec3fNoTranslate(D_8013BBC8, &sp40, &sp34); arg0->unk_114[13] = sp34.x; arg0->unk_114[14] = sp34.y; diff --git a/src/overlays/segment_EBFBE0/EBFCA0.c b/src/overlays/segment_EBFBE0/EBFCA0.c index 81da8051..8d244d6a 100644 --- a/src/overlays/segment_EBFBE0/EBFCA0.c +++ b/src/overlays/segment_EBFBE0/EBFCA0.c @@ -121,21 +121,21 @@ void func_801878D8_EBFF98(void) { case 0: func_801918FC_EC9FBC(); func_80189208_EC18C8(); - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); func_8018F680_EC7D40(); func_8018F85C_EC7F1C(); func_8018FC14_EC82D4(); func_8018F8E4_EC7FA4(); func_801918FC_EC9FBC(); func_8018F77C_EC7E3C(); - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); break; case 1: if (D_801B8348 != 0) { func_801918FC_EC9FBC(); func_8018A2F8_EC29B8(); - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); func_800BB5D0(); func_80190C9C_EC935C(); } @@ -146,7 +146,7 @@ void func_801878D8_EBFF98(void) { case 2: func_801918FC_EC9FBC(); func_8018A990_EC3050(); - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); if (D_801B8344 != 0) { func_8018FD08_EC83C8(); } @@ -155,20 +155,20 @@ void func_801878D8_EBFF98(void) { case 3: func_801918FC_EC9FBC(); func_8018B038_EC36F8(); - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); break; case 4: func_801918FC_EC9FBC(); func_8018C114_EC47D4(); - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); func_80190C9C_EC935C(); break; case 5: func_801918FC_EC9FBC(); func_8018CB90_EC5250(); - func_80005740(&D_8013B3C0); + Matrix_Pop(&D_8013B3C0); break; } diff --git a/yamls/us/main.yaml b/yamls/us/main.yaml index 15537f6c..82c58047 100644 --- a/yamls/us/main.yaml +++ b/yamls/us/main.yaml @@ -13,11 +13,13 @@ # Nintendo libraries - [0x03440, c, 3440] - [0x03A80, c, 3A80] + - [0x03FE0, c, 3FE0] - [0x041D0, c, 41D0] - [0x04650, c, 4650] - - [0x05A20, c, 5A20] - - [0x06280, c, 6280] + - [0x05A20, c, math] + - [0x06280, c, matrix] - [0x07B20, c, 7B20] + - [0x07B60, c, 7B60] - [0x07D30, c, 7D30] - [0x07FC0, c, 7FC0] # Audio block @@ -169,6 +171,7 @@ - [0x496C0, c, sf_496C0] - [0x52730, c, sf_52730] - [0x59780, c, sf_59780] + - [0x5A0F0, c, sf_5A0F0] - [0x5A2C0, c, sf_5A2C0] - [0x61B30, c, sf_61B30] - [0x6B3B0, c, sf_6B3B0] @@ -194,9 +197,9 @@ # DATA - Nintendo Libraries - [0xC51D0, .data, 4650] - - [0xC51E0, .data, 5A20] - - [0xC5220, .data, 6280] - - [0xC52F0, data, 7B20] + - [0xC51E0, .data, math] + - [0xC5220, .data, matrix] + - [0xC52F0, data, 7FC0] - [0xC54D0, data, audio] - [0xC8880, data, sprintf] @@ -221,8 +224,8 @@ - [0xC8CB0, data, ../libultra/rmon/rmonmain] # RODATA - Nintendo Libraries - - [0xC8CC0, .rodata, 5A20] - - [0xC8D10, .rodata, 6280] + - [0xC8CC0, .rodata, math] + - [0xC8D10, .rodata, matrix] - [0xC8D20, .rodata, 7D30] - [0xC8E40, .rodata, 7FC0] - [0xC9220, .rodata, 8CC0] @@ -305,7 +308,16 @@ - [0xDC710, data, audiodata] # Nintendo Library bss - - { start: 0xDE480, type: bss, vram: 0x800DD880, name: nlib } + - { start: 0xDE480, type: bss, vram: 0x800DD880, name: 3440 } + - { start: 0xDE480, type: bss, vram: 0x800DDAA0, name: 4650 } + - { start: 0xDE480, type: bss, vram: 0x8013B3A0, name: math } + - { start: 0xDE480, type: bss, vram: 0x8013B3C0, name: matrix } + - { start: 0xDE480, type: bss, vram: 0x8013C3D0, name: 7B20 } + - { start: 0xDE480, type: bss, vram: 0x80144BE0, name: 7B60 } + - { start: 0xDE480, type: bss, vram: 0x80144F60, name: 7D30 } + - { start: 0xDE480, type: bss, vram: 0x80145360, name: 7FC0 } + - { start: 0xDE480, type: bss, vram: 0x80145D40, name: audio } + # Libultra bss - { start: 0xDE480, type: bss, vram: 0x80156620, name: ../libultra/io/controller } diff --git a/yamls/us/overlays.yaml b/yamls/us/overlays.yaml index f90decab..f42b28db 100644 --- a/yamls/us/overlays.yaml +++ b/yamls/us/overlays.yaml @@ -49,7 +49,7 @@ - [0xE1F680, c, E1F680] - [0xE2DF20, c, E2DF20] - [0xE38560, c, E38560] - - [0xE4E3E0, data, E16C50] + - [0xE4E3D0, data, E16C50] - [0xE4EC90, data, E1F680] - [0xE4F010, data, E2DF20] - [0xE4F290, data, E38560]