diff --git a/include/dolphin/dvd/dvdFatal.h b/include/dolphin/dvd/dvdFatal.h index 44f70330d..08e694b9d 100644 --- a/include/dolphin/dvd/dvdFatal.h +++ b/include/dolphin/dvd/dvdFatal.h @@ -1,5 +1,6 @@ #ifndef DVDFATAL_H #define DVDFATAL_H +void __DVDPrintFatalMessage(void); #endif /* DVDFATAL_H */ diff --git a/include/dolphin/dvd/dvdlow.h b/include/dolphin/dvd/dvdlow.h index 485c0b6a1..3672cd1f8 100644 --- a/include/dolphin/dvd/dvdlow.h +++ b/include/dolphin/dvd/dvdlow.h @@ -4,13 +4,27 @@ #include "dolphin/dvd/dvd.h" // IWYU pragma: export #include "dolphin/types.h" #include "dolphin/os/OSUtil.h" +#include "dolphin/os/OSContext.h" typedef void (*DVDLowCallback)(u32 intType); vu32 __DIRegs[16] AT_ADDRESS(0xCC006000); void __DVDInitWA(void); -void __DVDInterruptHandler(short unused, struct OSContext * context); +void __DVDInterruptHandler(short unused, OSContext * context); void __DVDLowSetWAType(u32 type, u32 location); + +BOOL DVDLowRead(void* addr, u32 length, u32 offset, DVDLowCallback callback); +BOOL DVDLowSeek(u32 offset, DVDLowCallback callback); +BOOL DVDLowWaitCoverClose(DVDLowCallback callback); +BOOL DVDLowReadDiskID(DVDDiskID* diskID, DVDLowCallback callback); +BOOL DVDLowStopMotor(DVDLowCallback callback); +BOOL DVDLowRequestError(DVDLowCallback callback); +BOOL DVDLowInquiry(DVDDriveInfo* info, DVDLowCallback callback); +BOOL DVDLowAudioStream(u32 subcmd, u32 length, u32 offset, DVDLowCallback callback); +BOOL DVDLowRequestAudioStatus(u32 subcmd, DVDLowCallback callback); +BOOL DVDLowAudioBufferConfig(BOOL enable, u32 size, DVDLowCallback callback); +void DVDLowReset(); +BOOL DVDLowBreak(); DVDLowCallback DVDLowClearCallback(void); #endif /* DVDLOW_H */ diff --git a/include/dolphin/dvd/dvdqueue.h b/include/dolphin/dvd/dvdqueue.h index 0b882bcd2..735a4efc9 100644 --- a/include/dolphin/dvd/dvdqueue.h +++ b/include/dolphin/dvd/dvdqueue.h @@ -1,11 +1,13 @@ #ifndef DVDQUEUE_H #define DVDQUEUE_H +#include "dolphin/dvd/dvd.h" + void __DVDClearWaitingQueue(); -int __DVDPushWaitingQueue(long prio, struct DVDCommandBlock * block); +int __DVDPushWaitingQueue(long prio, DVDCommandBlock * block); struct DVDCommandBlock * __DVDPopWaitingQueue(); int __DVDCheckWaitingQueue(); -int __DVDDequeueWaitingQueue(struct DVDCommandBlock * block); -int __DVDIsBlockInWaitingQueue(struct DVDCommandBlock * block); +int __DVDDequeueWaitingQueue(DVDCommandBlock * block); +int __DVDIsBlockInWaitingQueue(DVDCommandBlock * block); #endif /* DVDQUEUE_H */ diff --git a/include/dolphin/os/OS.h b/include/dolphin/os/OS.h index 9fce29771..22b061215 100644 --- a/include/dolphin/os/OS.h +++ b/include/dolphin/os/OS.h @@ -2,6 +2,7 @@ #define OS_H_ #include "stdarg.h" +#include "dolphin/base/PPCArch.h" // IWYU pragma: export #include "dolphin/dvd/dvd.h" #include "dolphin/os/OSAlarm.h" // IWYU pragma: export diff --git a/include/dolphin/os/OSCache.h b/include/dolphin/os/OSCache.h index 23885420b..dfed7a38e 100644 --- a/include/dolphin/os/OSCache.h +++ b/include/dolphin/os/OSCache.h @@ -2,6 +2,7 @@ #define OSCACHE_H #include "dolphin/types.h" +#include "dolphin/exi/EXIBios.h" #ifdef __cplusplus extern "C" { @@ -24,7 +25,7 @@ static void LCStoreBlocks(void* destAddr, void* srcAddr, u32 blockNum); u32 LCStoreData(void* destAddr, void* srcAddr, u32 nBytes); void LCQueueWait(u32 len); static void L2GlobalInvalidate(void); -static void DMAErrorHandler(u16 error, struct OSContext* context, ...); +static void DMAErrorHandler(u16 error, OSContext* context, ...); void __OSCacheInit(void); #ifdef __cplusplus diff --git a/src/d/actor/d_a_agbsw0.cpp b/src/d/actor/d_a_agbsw0.cpp index 05f3ceec1..86f483c7d 100644 --- a/src/d/actor/d_a_agbsw0.cpp +++ b/src/d/actor/d_a_agbsw0.cpp @@ -180,7 +180,7 @@ cPhs_State daAgbsw0_c::create() { } else if(type == daAgbsw0Type_B_e) { if(((paramNo == 1 || paramNo == 3) && sw0 != 0xFF && fopAcM_isSwitch(this, sw0)) || - paramNo == 2 && sw0 < 0x20 && dComIfGs_isTbox(sw0)) { + (paramNo == 2 && sw0 < 0x20 && dComIfGs_isTbox(sw0))) { return cPhs_ERROR_e; } } @@ -215,7 +215,7 @@ cPhs_State daAgbsw0_c::create() { if(type == daAgbsw0Type_B_e && getMsgNo() == 0xFFFF) { u16 msgNo = 0xE; // Debug map indicates fpcM_SetParam was used here instead of fopAcM_SetParam. - fpcM_SetParam(this, fopAcM_GetParam(this) & 0xFFFF0000 | msgNo); + fpcM_SetParam(this, (fopAcM_GetParam(this) & 0xFFFF0000) | msgNo); } if(type != daAgbsw0Type_MW_e && type != daAgbsw0Type_T_e && type != daAgbsw0Type_S_e && type != daAgbsw0Type_UNK_0xE_e && getMsgNo() == 0xFFFF) { diff --git a/src/dolphin/dvd/dvd.c b/src/dolphin/dvd/dvd.c index 61a5f2556..db5779c84 100644 --- a/src/dolphin/dvd/dvd.c +++ b/src/dolphin/dvd/dvd.c @@ -2,6 +2,8 @@ #include "dolphin/dvd/dvderror.h" #include "dolphin/dvd/dvdfs.h" #include "dolphin/dvd/dvdlow.h" +#include "dolphin/dvd/dvdqueue.h" +#include "dolphin/dvd/dvdFatal.h" #include "dolphin/os/OS.h" const char* __DVDVersion = "<< Dolphin SDK - DVD\trelease build: Sep 5 2002 05:34:06 (0x2301) >>"; diff --git a/src/dolphin/dvd/dvdfs.c b/src/dolphin/dvd/dvdfs.c index 8ccb9f22f..cc92ab049 100644 --- a/src/dolphin/dvd/dvdfs.c +++ b/src/dolphin/dvd/dvdfs.c @@ -177,6 +177,8 @@ BOOL DVDFastOpen(s32 entrynum, DVDFileInfo* fileInfo) { return TRUE; } +BOOL DVDGetCurrentDir(char* path, u32 maxlen); + BOOL DVDOpen(const char* fileName, DVDFileInfo* fileInfo) { s32 entry; char currentDir[128]; diff --git a/src/dolphin/dvd/dvdidutils.c b/src/dolphin/dvd/dvdidutils.c index 5493f537e..3aea13c94 100644 --- a/src/dolphin/dvd/dvdidutils.c +++ b/src/dolphin/dvd/dvdidutils.c @@ -1,5 +1,6 @@ #include "dolphin/dvd/dvdidutils.h" #include "dolphin/os/OS.h" +#include static u32 strnlen(const char* str, u32 maxlen) { u32 i; diff --git a/src/dolphin/os/OS.c b/src/dolphin/os/OS.c index e551627c4..b3bf6e5f5 100644 --- a/src/dolphin/os/OS.c +++ b/src/dolphin/os/OS.c @@ -7,6 +7,8 @@ #include "dolphin/db/db.h" #include "dolphin/pad/Pad.h" #include "dolphin/dvd/dvdfs.h" +#include "dolphin/si/SIBios.h" +#include // #include "TRK_MINNOW_DOLPHIN/Os/dolphin/dolphin_trk.h" #define OS_BI2_DEBUG_ADDRESS 0x800000F4 @@ -45,6 +47,7 @@ extern f64 ZeroF; f64 ZeroF; ASM void __OSFPRInit(void) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -128,6 +131,7 @@ skip_ps_init: mtfsf 0xff, f0 blr // clang-format on +#endif } static void DisableWriteGatherPipe(void) @@ -173,15 +177,15 @@ static void ClearArena(void) { if ((u32)OSGetArenaLo() < *(u32*)&__OSSavedRegionStart) { if ((u32)OSGetArenaHi() <= *(u32*)&__OSSavedRegionStart) { - memset((u32)OSGetArenaLo(), 0U, (u32)OSGetArenaHi() - (u32)OSGetArenaLo()); + memset(OSGetArenaLo(), 0U, (u32)OSGetArenaHi() - (u32)OSGetArenaLo()); return; } memset(OSGetArenaLo(), 0U, *(u32*)&__OSSavedRegionStart - (u32)OSGetArenaLo()); if ((u32)OSGetArenaHi() > *(u32*)&__OSSavedRegionEnd) { - memset(*(u32*)&__OSSavedRegionEnd, 0, - (u32)OSGetArenaHi() - *(u32*)&__OSSavedRegionEnd); + memset(__OSSavedRegionEnd, 0, + (u8*)OSGetArenaHi() - (u8*)__OSSavedRegionEnd); } } } @@ -452,6 +456,7 @@ static void OSExceptionInit(void) { } ASM void __OSDBIntegrator(void) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -477,6 +482,7 @@ entry __OSDBJUMPSTART bla 0x60 entry __OSDBJUMPEND // clang-format on +#endif } OSExceptionHandler __OSSetExceptionHandler(__OSException exception, OSExceptionHandler handler) { @@ -490,6 +496,7 @@ OSExceptionHandler __OSGetExceptionHandler(__OSException exception) { } static ASM void OSExceptionVector(void) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -571,10 +578,12 @@ recoverable: entry __OSEVEnd nop // clang-format on +#endif } static ASM void OSDefaultExceptionHandler(register __OSException exception, register OSContext* context) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -603,9 +612,11 @@ static ASM void OSDefaultExceptionHandler(register __OSException exception, stwu r1, -8(r1) b __OSUnhandledException // clang-format on +#endif } ASM void __OSPSInit(void){ +#ifdef __MWERKS__ // clang-format off nofralloc @@ -626,6 +637,7 @@ ASM void __OSPSInit(void){ mtlr r0 blr // clang-format on +#endif } vu32 __DIRegs[16] AT_ADDRESS(0xCC006000); diff --git a/src/dolphin/os/OSAlarm.c b/src/dolphin/os/OSAlarm.c index 27e1a5f1c..1988f1f75 100644 --- a/src/dolphin/os/OSAlarm.c +++ b/src/dolphin/os/OSAlarm.c @@ -179,6 +179,7 @@ static void DecrementerExceptionCallback(register __OSException exception, static ASM void DecrementerExceptionHandler(register __OSException exception, register OSContext* context) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -203,6 +204,7 @@ static ASM void DecrementerExceptionHandler(register __OSException exception, stwu r1, -8(r1) b DecrementerExceptionCallback // clang-format on +#endif } static BOOL OnReset(BOOL final) { diff --git a/src/dolphin/os/OSInterrupt.c b/src/dolphin/os/OSInterrupt.c index 4761ba92b..e3fe7ce08 100644 --- a/src/dolphin/os/OSInterrupt.c +++ b/src/dolphin/os/OSInterrupt.c @@ -2,11 +2,13 @@ #include "dolphin/dsp.h" #include "dolphin/exi/EXIBios.h" #include "dolphin/os/OS.h" +#include vu32 __PIRegs[12] AT_ADDRESS(0xCC003000); vu16 __MEMRegs[64] AT_ADDRESS(0xCC004000); ASM BOOL OSDisableInterrupts(void) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -23,9 +25,11 @@ ASM BOOL OSDisableInterrupts(void) { rlwinm r3, r3, 17, 31, 31 blr // clang-format on +#endif } ASM BOOL OSEnableInterrupts(void) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -38,9 +42,11 @@ ASM BOOL OSEnableInterrupts(void) { rlwinm r3, r3, 17, 31, 31 blr // clang-format on +#endif } ASM BOOL OSRestoreInterrupts(register BOOL status) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -62,6 +68,7 @@ set_msr: rlwinm r3, r4, 17, 31, 31 blr // clang-format on +#endif } static __OSInterruptHandler* InterruptHandlerTable; @@ -401,6 +408,7 @@ void __OSDispatchInterrupt(__OSException exception, OSContext* context) { } static ASM void ExternalInterruptHandler(register __OSInterrupt type, register OSContext* context) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -427,4 +435,5 @@ static ASM void ExternalInterruptHandler(register __OSInterrupt type, register O stwu r1, -8(r1) b __OSDispatchInterrupt // clang-format on +#endif } diff --git a/src/dolphin/os/OSReset.c b/src/dolphin/os/OSReset.c index 7ce4e7325..387865ad1 100644 --- a/src/dolphin/os/OSReset.c +++ b/src/dolphin/os/OSReset.c @@ -1,5 +1,6 @@ #include "dolphin/os/OSReset.h" #include "dolphin/os/OS.h" +#include vu16 __VIRegs[59] AT_ADDRESS(0xCC002000); OSThreadQueue __OSActiveThreadQueue AT_ADDRESS(OS_BASE_CACHED | 0x00DC); diff --git a/src/dolphin/os/__start.c b/src/dolphin/os/__start.c index f246cd2ce..b029387c3 100644 --- a/src/dolphin/os/__start.c +++ b/src/dolphin/os/__start.c @@ -1,6 +1,7 @@ #include "stdlib.h" #include "global.h" #include "dolphin/os/OS.h" +#include #include "dolphin/os/__start.h" void DBInit(); @@ -13,6 +14,7 @@ SECTION_INIT void __check_pad3(void) { } SECTION_INIT ASM void __start(void) { +#ifdef __MWERKS__ // clang-format off nofralloc @@ -113,6 +115,7 @@ lbl_8000329C: bl main b exit // clang-format on +#endif } ASM static void __init_registers(void)