diff --git a/configure.py b/configure.py index d77f1210..10d31c54 100644 --- a/configure.py +++ b/configure.py @@ -880,7 +880,7 @@ def MatchingFor(*versions): Object(Matching, "os/OSSync.c"), Object(Matching, "os/OSThread.c"), Object(Matching, "os/OSTime.c"), - Object(Matching, "os/OSUartExi.c"), + Object(Matching, "os/OSUartExi.c", extra_cflags=["-char signed" if version_num in (0, 3, 6, 7) else "-char unsigned"]), Object(Matching, "os/__start.c"), Object(Matching, "os/__ppc_eabi_init.cpp"), ], @@ -909,11 +909,11 @@ def MatchingFor(*versions): "dvd", [ Object(Matching, "dvd/dvdlow.c"), - Object(Matching, "dvd/dvdfs.c"), + Object(Matching, "dvd/dvdfs.c", extra_cflags=["-char signed" if version_num in (0, 3, 6, 7) else "-char unsigned"]), Object(Matching, "dvd/dvd.c"), Object(Matching, "dvd/dvdqueue.c"), Object(Matching, "dvd/dvderror.c"), - Object(Matching, "dvd/fstload.c"), + Object(Matching, "dvd/fstload.c", extra_cflags=["-char signed" if version_num in (0, 3, 6, 7) else "-char unsigned"]), ], ), DolphinLib( @@ -926,7 +926,7 @@ def MatchingFor(*versions): "pad", [ Object(Matching, "pad/Padclamp.c"), - Object(not MatchingFor("DPIJ01_PIKIDEMO", "G98E01_PIKIDEMO", "G98P01_PIKIDEMO"), "pad/Pad.c"), + Object(Matching, "pad/Pad.c"), ], ), DolphinLib( diff --git a/include/BaseApp.h b/include/BaseApp.h index 0693ac17..ecf64034 100644 --- a/include/BaseApp.h +++ b/include/BaseApp.h @@ -33,7 +33,7 @@ struct BaseApp : public Node { * @brief Gets a random float between 0 and 1. Unused in DOL. * @return Random value between 0 and 1. */ - f32 rnd() { return rand() / 32767.0f; } + f32 rnd() { return rand() / f32(RAND_MAX); } void startAgeServer(); void stopAgeServer(); diff --git a/include/BoundBox.h b/include/BoundBox.h index 62990166..49aaabb2 100644 --- a/include/BoundBox.h +++ b/include/BoundBox.h @@ -75,12 +75,6 @@ struct BoundBox { return false; } - // void resetBound() - // { - // mMax.set(32768.0f, 32768.0f, 32768.0f); - // mMin.set(-32768.0f, -32768.0f, -32768.0f); - // } - // void setBoundZero() // { // mMax.set(0.0f, 0.0f, 0.0f); diff --git a/include/Dolphin/GX/GXData.h b/include/Dolphin/GX/GXData.h index 35d43528..7b4c2ff4 100644 --- a/include/Dolphin/GX/GXData.h +++ b/include/Dolphin/GX/GXData.h @@ -40,7 +40,7 @@ typedef enum _CPClear { // size: 0x5B0 struct __GXData_struct { // total size: 0x4F4 -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) // +#if OS_BUILD_VERSION >= 20011002L // u8 _00[2]; // _00 unsigned short bpSent; // offset 0x2, size 0x2 unsigned short vNum; // offset 0x4, size 0x2 @@ -115,7 +115,7 @@ struct __GXData_struct { unsigned long tMode0[8]; // offset 0x47C, size 0x20 unsigned long texmapId[16]; // offset 0x49C, size 0x40 unsigned long tcsManEnab; // offset 0x4DC, size 0x4 -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) // +#if OS_BUILD_VERSION >= 20011217L // unsigned long tevTcEnab; // #endif // GXPerf0 perf0; // offset 0x4E0, size 0x4 diff --git a/include/Dolphin/OS/OSContext.h b/include/Dolphin/OS/OSContext.h index b807c93c..18f25bcf 100644 --- a/include/Dolphin/OS/OSContext.h +++ b/include/Dolphin/OS/OSContext.h @@ -1,6 +1,7 @@ #ifndef _DOLPHIN_OS_OSCONTEXT_H #define _DOLPHIN_OS_OSCONTEXT_H +#include "Dolphin/OS/OSVersion.h" #include "types.h" BEGIN_SCOPE_EXTERN_C @@ -21,7 +22,7 @@ typedef struct OSContext { u16 mode; // _1A0, context mode. u16 state; // _1A2, |'d OS_CONTEXT_STATE_* u32 gqr[8]; // _1A4, Gekko additional registers. -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L u32 psf_pad; #endif f64 psf[32]; // _1C8, Gekko additional registers. diff --git a/include/Dolphin/OS/OSError.h b/include/Dolphin/OS/OSError.h index 809bd358..74389be5 100644 --- a/include/Dolphin/OS/OSError.h +++ b/include/Dolphin/OS/OSError.h @@ -21,8 +21,8 @@ OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler); void OSReport(const char* message, ...); void OSPanic(const char* file, int line, const char* message, ...); -#define OSError(...) OSPanic(__FILE__, __LINE__, __VA_ARGS__) #define OSErrorLine(line, ...) OSPanic(__FILE__, line, __VA_ARGS__) +#define OSError(...) OSErrorLine(__LINE__, __VA_ARGS__) #ifdef DEBUG // Currently necessary for dsp_cardunlock.c #define OSAssertMsgLine(line, cond, ...) ((void)((cond) || (OSErrorLine(line, __VA_ARGS__), 0))) @@ -54,7 +54,7 @@ void OSPanic(const char* file, int line, const char* message, ...); #define OS_ERROR_MAX (OS_ERROR_PROTECTION + 1) // Error table. -extern OSErrorHandler __OSErrorTable[16]; +extern OSErrorHandler __OSErrorTable[OS_ERROR_MAX]; ////////////////////////////////// diff --git a/include/Dolphin/OS/OSExi.h b/include/Dolphin/OS/OSExi.h index a2c77d86..c88c73dc 100644 --- a/include/Dolphin/OS/OSExi.h +++ b/include/Dolphin/OS/OSExi.h @@ -3,6 +3,7 @@ #include "Dolphin/OS/OSExpansion.h" #include "Dolphin/OS/OSInterrupt.h" +#include "Dolphin/OS/OSVersion.h" #include "Dolphin/hw_regs.h" #include "types.h" @@ -38,7 +39,7 @@ typedef struct EXIControl { int immLen; // _10 u8* immBuf; // _14 u32 dev; // _18 -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L u32 id; s32 idTime; #endif @@ -58,11 +59,7 @@ BOOL EXIImm(s32 channel, void* buffer, s32 length, u32 type, EXICallback callbac BOOL EXIImmEx(s32 channel, void* buffer, s32 length, u32 type); BOOL EXIDma(s32 channel, void* buffer, s32 length, u32 type, EXICallback callback); BOOL EXISync(s32 channel); -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) u32 EXIClearInterrupts(s32 channel, BOOL clearExiBit, BOOL clearTcBit, BOOL clearExtBit); -#else -BOOL EXIClearInterrupts(s32 channel, BOOL clearExiBit, BOOL clearTcBit, BOOL clearExtBit); -#endif EXICallback EXISetExiCallback(s32 channel, EXICallback callback); BOOL EXIAttach(s32 channel, EXICallback callback); BOOL EXIDetach(s32 channel); diff --git a/include/Dolphin/OS/OSFastCast.h b/include/Dolphin/OS/OSFastCast.h index e9b30497..43af12d4 100644 --- a/include/Dolphin/OS/OSFastCast.h +++ b/include/Dolphin/OS/OSFastCast.h @@ -29,7 +29,7 @@ BEGIN_SCOPE_EXTERN_C /////////////// FAST CAST INLINES ///////////////////////////////////////////////////////////////// -static inline void OSInitFastCast() +static inline void OSInitFastCast(void) { #ifdef __MWERKS__ asm { diff --git a/include/Dolphin/OS/OSSerial.h b/include/Dolphin/OS/OSSerial.h index e06ec93d..38510304 100644 --- a/include/Dolphin/OS/OSSerial.h +++ b/include/Dolphin/OS/OSSerial.h @@ -2,6 +2,7 @@ #define _DOLPHIN_OS_OSSERIAL_H #include "Dolphin/OS/OSContext.h" +#include "Dolphin/OS/OSVersion.h" #include "types.h" BEGIN_SCOPE_EXTERN_C @@ -63,13 +64,17 @@ BOOL SIRegisterPollingHandler(__OSInterruptHandler handler); BOOL SIUnregisterPollingHandler(__OSInterruptHandler handler); void SIInit(void); +#if OS_BUILD_VERSION >= 20011002L && OS_BUILD_VERSION < 20011112L +u32 SIGetStatus(void); // WHAT? +#else u32 SIGetStatus(s32 chan); +#endif void SISetCommand(s32 chan, u32 command); void SITransferCommands(void); u32 SISetXY(u32 x, u32 y); u32 SIEnablePolling(u32 poll); u32 SIDisablePolling(u32 poll); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L BOOL SIGetResponse(s32 chan, void* data); #else void SIGetResponse(s32 chan, void* data); diff --git a/include/Dolphin/OS/OSVersion.h b/include/Dolphin/OS/OSVersion.h new file mode 100644 index 00000000..59ba6d9e --- /dev/null +++ b/include/Dolphin/OS/OSVersion.h @@ -0,0 +1,32 @@ +#include "types.h" + +// This is a fabricated header with fabricated macros in order to support multiple revisions of the SDK. +// `OS_BUILD_REVISION` is not granular enough because there are differences between the Oct. and Nov. +// versions of Dolphin SDK Revision 47, so prefer `OS_BUILD_VERSION` for conditionally compiled code. +// TODO: There are revisional differences in vi.c that cannot be explained by the build date and time. + +/////////////// OS BUILD INFO ///////////////////////////////////////////////////////////////////// + +#if defined(VERSION_GPIJ01) || defined(VERSION_GPIE01) +#define OS_BUILD_REVISION 37 +#define OS_BUILD_DATE "Jul 19 2001" +#define OS_BUILD_TIME "05:43:42" +#define OS_BUILD_VERSION 20010719L +#elif defined(VERSION_DPIJ01_PIKIDEMO) +#define OS_BUILD_REVISION 47 +#define OS_BUILD_DATE "Oct 2 2001" +#define OS_BUILD_TIME "11:02:22" +#define OS_BUILD_VERSION 20011002L +#elif defined(VERSION_G98E01_PIKIDEMO) +#define OS_BUILD_REVISION 47 +#define OS_BUILD_DATE "Nov 12 2001" +#define OS_BUILD_TIME "01:46:17" +#define OS_BUILD_VERSION 20011112L +#else // VERSION_G98P01_PIKIDEMO, VERSION_GPIP01 +#define OS_BUILD_REVISION 49 +#define OS_BUILD_DATE "Dec 17 2001" +#define OS_BUILD_TIME "18:46:45" +#define OS_BUILD_VERSION 20011217L +#endif + +/////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/Dolphin/card.h b/include/Dolphin/card.h index 6fd3049f..9fbc92dc 100644 --- a/include/Dolphin/card.h +++ b/include/Dolphin/card.h @@ -102,23 +102,18 @@ struct CARDDirCheck { // Struct for CARD information (size 0x110). struct CARDControl { - BOOL attached; // _00 - s32 result; // _04 - u16 size; // _08, size in Mbits. - u16 pageSize; // _0A, program size in bytes. - s32 sectorSize; // _0C, erase size in bytes. - u16 cBlock; // _10, # blocks. - u16 vendorID; // _12, 0xC243 for MX, 0xECE6 for Samsung - s32 latency; // _14, read latency in bytes. - u8 id[0xC]; // _18 - int mountStep; // _24 -#if defined(VERSION_GPIP01_00) // somethings fishy with this... - u32 scramble; // _28, for __CARDUnlock(). - int formatStep; // _2C -#else - int formatStep; // _28 - u32 scramble; // _2C, for __CARDUnlock(). -#endif + BOOL attached; // _00 + s32 result; // _04 + u16 size; // _08, size in Mbits. + u16 pageSize; // _0A, program size in bytes. + s32 sectorSize; // _0C, erase size in bytes. + u16 cBlock; // _10, # blocks. + u16 vendorID; // _12, 0xC243 for MX, 0xECE6 for Samsung + s32 latency; // _14, read latency in bytes. + u8 id[0xC]; // _18 + int mountStep; // _24 + u32 scramble; // _28, for __CARDUnlock(). + int formatStep; // _2C DSPTaskInfo task; // _30 CARDMemoryCard* workArea; // _80, void* in docs. CARDDirectoryBlock* currentDir; // _84, CARDDir* in docs. @@ -143,7 +138,7 @@ struct CARDControl { CARDCallback eraseCallback; // _D8 CARDCallback unlockCallback; // _DC OSAlarm alarm; // _E0, for timeout. -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L u32 cid; // _108 const DVDDiskID* diskID; // _10C #endif @@ -308,7 +303,7 @@ s32 __CARDSync(s32 channel); void __CARDCheckSum(void* data, int length, u16* checksum, u16* checksumInv); s32 __CARDVerify(CARDControl* card); BOOL __CARDCompareFileName(CARDDir* entry, const char* fileName); -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L s32 __CARDAccess(CARDControl* card, CARDDir* ent); #else s32 __CARDAccess(CARDDir* entry); diff --git a/include/Dolphin/dsp.h b/include/Dolphin/dsp.h index 9661cfd2..fa025c85 100644 --- a/include/Dolphin/dsp.h +++ b/include/Dolphin/dsp.h @@ -82,21 +82,18 @@ void DSPHalt(); void DSPReset(); //////////////////////////////////////////// -#if defined(VERSION_GPIP01_00) DSPTaskInfo* DSPAddTask(DSPTaskInfo*); -#endif END_SCOPE_EXTERN_C typedef void (*CommandTask)(u16); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) void Dsp_Running_Start(); -u64 DSP_CreateMap(); u32 DSPSendCommands2(u32*, u32, CommandTask); static void DspInitWork(); void DSPAddPriorTask(DSPTaskInfo*); -int Dsp_Running_Check(); +BOOL Dsp_Running_Check(); int DspStartWork(u32, CommandTask); extern DSPTaskInfo* DSP_prior_task; diff --git a/include/Dolphin/mtx.h b/include/Dolphin/mtx.h index 541c2859..894f14cd 100644 --- a/include/Dolphin/mtx.h +++ b/include/Dolphin/mtx.h @@ -3,6 +3,7 @@ #include "types.h" +#include "Dolphin/OS/OSVersion.h" #include "Dolphin/vec.h" BEGIN_SCOPE_EXTERN_C @@ -82,24 +83,7 @@ typedef struct Quaternion { // to juggle these version differences while still producing a useable codebase: for matching Japanese and American retail versions, // certain `C_`-prefixed function implementations are renamed via macros, and the paired-singles implementations and C functions // from the future Dolphin OS revisions that shouldn't be accessible are not given function alias macros. -#if defined(BUILD_MATCHING) && (defined(VERSION_GPIJ01) || defined(VERSION_GPIE01)) -#define C_MTXRotRad MTXRotRad -#define C_MTXRotTrig MTXRotTrig -#define C_MTXRotAxisRad MTXRotAxisRad -#define C_MTXTrans MTXTrans -#define C_MTXTransApply MTXTransApply -#define C_MTXScale MTXScale -#define C_MTXScaleApply MTXScaleApply -#define C_MTXQuat MTXQuat -#define C_MTXReflect MTXReflect -#define C_MTXLookAt MTXLookAt -#define C_MTXLightFrustum MTXLightFrustum -#define C_MTXLightPerspective MTXLightPerspective -#define C_MTXLightOrtho MTXLightOrtho -#define C_MTXFrustum MTXFrustum -#define C_MTXPerspective MTXPerspective -#define C_MTXOrtho MTXOrtho -#else // VERSION_PIKIDEMO, VERSION_GPIP01, Non-Matching builds +#if OS_BUILD_VERSION >= 20011002L #define MTXRotRad PSMTXRotRad #define MTXRotTrig PSMTXRotTrig #define MTXRotAxisRad PSMTXRotAxisRad @@ -128,6 +112,23 @@ typedef struct Quaternion { #define MTX44RotRad PSMTX44RotRad #define MTX44RotTrig PSMTX44RotTrig #define MTX44RotAxisRad PSMTX44RotAxisRad +#else +#define C_MTXRotRad MTXRotRad +#define C_MTXRotTrig MTXRotTrig +#define C_MTXRotAxisRad MTXRotAxisRad +#define C_MTXTrans MTXTrans +#define C_MTXTransApply MTXTransApply +#define C_MTXScale MTXScale +#define C_MTXScaleApply MTXScaleApply +#define C_MTXQuat MTXQuat +#define C_MTXReflect MTXReflect +#define C_MTXLookAt MTXLookAt +#define C_MTXLightFrustum MTXLightFrustum +#define C_MTXLightPerspective MTXLightPerspective +#define C_MTXLightOrtho MTXLightOrtho +#define C_MTXFrustum MTXFrustum +#define C_MTXPerspective MTXPerspective +#define C_MTXOrtho MTXOrtho #endif #endif diff --git a/include/Dolphin/os.h b/include/Dolphin/os.h index 35e6d8d5..e553b9ca 100644 --- a/include/Dolphin/os.h +++ b/include/Dolphin/os.h @@ -26,11 +26,14 @@ #include "Dolphin/OS/OSThread.h" #include "Dolphin/OS/OSTime.h" #include "Dolphin/OS/OSUtil.h" +#include "Dolphin/OS/OSVersion.h" BEGIN_SCOPE_EXTERN_C -///////// OS FUNCTIONS /////////// +/////////////// OS FUNCTIONS ////////////////////////////////////////////////////////////////////// + // Initialisers. + extern void __OSPSInit(); extern void __OSFPRInit(); extern void __OSCacheInit(); @@ -45,6 +48,7 @@ extern void __OSInitMemoryProtection(); void OSInit(); // Other OS functions. + #define OS_CONSOLE_RETAIL4 0x00000004 #define OS_CONSOLE_RETAIL3 0x00000003 #define OS_CONSOLE_RETAIL2 0x00000002 @@ -64,13 +68,14 @@ void OSInit(); u32 OSGetConsoleType(); -////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/////////////// Extern Things ///////////////////////////////////////////////////////////////////// -// extern things. extern BOOL __OSInIPL; extern OSTime __OSStartTime; -////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////////////// END_SCOPE_EXTERN_C diff --git a/include/Dolphin/pad.h b/include/Dolphin/pad.h index 219d61ea..a8299a85 100644 --- a/include/Dolphin/pad.h +++ b/include/Dolphin/pad.h @@ -90,20 +90,27 @@ BOOL PADInit(void); BOOL PADReset(u32 mask); u32 PADRead(PADStatus* status); void PADSetSamplingRate(u32 msec); +#if OS_BUILD_VERSION >= 20011002L && OS_BUILD_VERSION < 20011217L +void __PADRefreshSamplingRate(void); +#endif void PADClamp(PADStatus* status); void PADClampCircle(PADStatus* status); -void PADControlAllMotors(const u32* command); +void PADControlAllMotors(const u32* commandArray); void PADControlMotor(s32 chan, u32 command); BOOL PADRecalibrate(u32 mask); BOOL PADSync(void); void PADSetAnalogMode(u32 mode); void PADSetSpec(u32 spec); +u32 PADGetSpec(void); +int PADGetType(s32 chan, u32* type); typedef void (*PADSamplingCallback)(void); +#if OS_BUILD_VERSION >= 20011112L PADSamplingCallback PADSetSamplingCallback(PADSamplingCallback callback); - -extern u32 __PADFixBits; +#else +void PADSetSamplingCallback(PADSamplingCallback callback); +#endif END_SCOPE_EXTERN_C diff --git a/include/Dolphin/vec.h b/include/Dolphin/vec.h index 9c0d8a27..9fbb7736 100644 --- a/include/Dolphin/vec.h +++ b/include/Dolphin/vec.h @@ -3,6 +3,8 @@ #include "types.h" +#include "Dolphin/OS/OSVersion.h" + BEGIN_SCOPE_EXTERN_C /////////////// TYPE DEFINES ////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -49,16 +51,16 @@ typedef struct SVec { #define VECCrossProduct PSVECCrossProduct #define VECSquareDistance PSVECSquareDistance // Handling Dolphin OS revision 37 vs 47, see longer comment in "mtx.h" for an explanation to what's going on. -#if defined(BUILD_MATCHING) && (defined(VERSION_GPIJ01) || defined(VERSION_GPIE01)) -#define C_VECMag VECMag -#define C_VECHalfAngle VECHalfAngle -#define C_VECReflect VECReflect -#define C_VECDistance VECDistance -#else +#if OS_BUILD_VERSION >= 20011002L #define VECMag PSVECMag #define VECHalfAngle C_VECHalfAngle // No paired-singles implementation #define VECReflect C_VECReflect // No paired-singles implementation #define VECDistance PSVECDistance +#else +#define C_VECMag VECMag +#define C_VECHalfAngle VECHalfAngle +#define C_VECReflect VECReflect +#define C_VECDistance VECDistanc #endif #endif diff --git a/include/FlowController.h b/include/FlowController.h index 6bd3ce73..4783e7d4 100644 --- a/include/FlowController.h +++ b/include/FlowController.h @@ -62,7 +62,7 @@ struct FlowController { char mDoorStageFilePath[0x80]; ///< _1B0, likely stage unused "door" item would've led to - same as above + unused in reality. BOOL mIsVersusMode; ///< _230, indicator of an (unimplemented) VS mode - never TRUE because we never spawn a second navi. int mGameEndFlag; ///< _234, type of situation forcing the day/gameplay to end - see `GameEndFlag` enum. -#if defined(VERSION_GPIP01_00) /// +#if defined(VERSION_GPIP01) /// BOOL mIsDayEndSkippable; ///< _238, day ends from extinction and navi down aren't skippable. BOOL mIsDayEndSkipped; ///< _23C, has day end cutscene been skipped? #endif /// diff --git a/include/Generator.h b/include/Generator.h index 2b5f6986..01156103 100644 --- a/include/Generator.h +++ b/include/Generator.h @@ -567,10 +567,7 @@ struct GenObjectMapParts : public GenObject { * @brief TODO */ struct GenObjectNavi : public GenObject { - GenObjectNavi() - : GenObject('navi', "プレイヤー2を生む") // 'generate player 2' - { - } + GenObjectNavi(); // unused/inlined virtual void doRead(RandomAccessStream&); // _14 virtual Creature* birth(BirthInfo&); // _34 diff --git a/include/PlayerState.h b/include/PlayerState.h index 1896afed..9b89b624 100644 --- a/include/PlayerState.h +++ b/include/PlayerState.h @@ -177,7 +177,8 @@ struct PlayerState { bool hasContainer(int color) { return mContainerFlag & (1 << color); } void setBootContainer(int color) { mContainerFlag |= 1 << color + 3; } - bool bootContainer(int color) { return mContainerFlag & (1 << color + 3); } + // This member function is named `bootContainer` according to the ILK, but that's inconsistent. + bool hasBootContainer(int color) { return mContainerFlag & (1 << color + 3); } int getLastPikmins() { return mLivingPikiNum; } diff --git a/include/Shape.h b/include/Shape.h index c83b7490..6d349c00 100644 --- a/include/Shape.h +++ b/include/Shape.h @@ -299,7 +299,7 @@ struct BaseShape : public CoreNode { // _00 = VTBL // _00-_14 = CoreNode - u32 mSystemFlags; // _14, see BaseShapeFlags enum + u32 mShapeFlags; // _14, see ShapeFlags enum AnimContext* mCurrentAnimation; // _18 AnimContext** mAnimOverrides; // _1C AnimContext** mBackupAnimOverrides; // _20 diff --git a/include/Texture.h b/include/Texture.h index 335a84bc..bbfe2f09 100644 --- a/include/Texture.h +++ b/include/Texture.h @@ -133,7 +133,7 @@ struct TexImg : public CoreNode { TexImg() : CoreNode("texImg") { - mDataPtrOffset = 1; + mImageCount = 1; mPixelData = nullptr; } @@ -157,7 +157,7 @@ struct TexImg : public CoreNode { TexImgFormat mFormat; // _18 int mWidth; // _1C int mHeight; // _20 - int mDataPtrOffset; // _24 + int mImageCount; // _24, 1 + number of mipmaps int mDataSize; // _28 void* mTextureData; // _2C void* mPixelData; // _30 @@ -173,14 +173,9 @@ struct Texture : public GfxObject { * @brief TODO */ enum TexFlags { - TEX_CLAMP_S = 1 << 0, // 0x1 + TEX_CLAMP_S = 1 << 0, // 0x1 TEX_MIRROR_S = 1 << 1, // 0x2 TEX_Unk2 = 1 << 2, // 0x4 - TEX_Unk3 = 1 << 3, // 0x8 - TEX_Unk4 = 1 << 4, // 0x10 - TEX_Unk5 = 1 << 5, // 0x20 - TEX_Unk6 = 1 << 6, // 0x40 - TEX_Unk7 = 1 << 7, // 0x80 TEX_CLAMP_T = 1 << 8, // 0x100 TEX_MIRROR_T = 1 << 9, // 0x200 }; @@ -203,13 +198,13 @@ struct Texture : public GfxObject { // _00 = VTBL u16 mTexFormat; // _04, see TexImgFormat enum - u16 mTexFlags; // _06 + u16 mTexFlags; // _06, see TexFlags enum u16 mWidth; // _08 u16 mHeight; // _0A u32 mTileSizeX; // _0C u32 mTileSizeY; // _10 void* mPixelData; // _14 - u32* mTextureData; // _18 + u32 mLODCount; // _18 f32 mLODBias; // _1C u32 _20; // _20, -1 if detached, 0 if attached GXTexObj* mTexObj; // _24 diff --git a/include/bigFont.h b/include/bigFont.h index 6a084bc7..ef474f1a 100644 --- a/include/bigFont.h +++ b/include/bigFont.h @@ -1,7 +1,7 @@ // This file is WAY too big to justify having multiple versions of the font in one header, so we do a little decision-making here. #if defined(VERSION_GPIJ01) || defined(VERSION_DPIJ01_PIKIDEMO) #include "bigFont_JPN.h" -#elif defined(VERSION_GPIP01_00) +#elif defined(VERSION_GPIP01) #include "bigFont_PAL.h" #else #include "bigFont_USA.h" diff --git a/include/gameflow.h b/include/gameflow.h index 16bfe574..90e02f52 100644 --- a/include/gameflow.h +++ b/include/gameflow.h @@ -479,7 +479,7 @@ struct GamePrefs : public CoreNode { virtual void read(RandomAccessStream& input); // _0C virtual void write(RandomAccessStream& output); // _10 -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) void Initialise(); #else @@ -504,7 +504,7 @@ struct GamePrefs : public CoreNode { void setSfxVol(u8 vol); void setStereoMode(bool set); void setVibeMode(bool set); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) void setChildMode(int lang); #else void setChildMode(bool set); @@ -542,7 +542,7 @@ struct GamePrefs : public CoreNode { /// Checks if sound is in stereo mode. bool getStereoMode() { return (mFlags & GAMEPREF_Stereo) != 0; } -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) int getChildMode(); #else diff --git a/include/jaudio/dspboot.h b/include/jaudio/dspboot.h index aae34e3c..71958b53 100644 --- a/include/jaudio/dspboot.h +++ b/include/jaudio/dspboot.h @@ -34,7 +34,7 @@ END_SCOPE_EXTERN_C // Global functions. s32 __DSPCheckMXICBoot2(DSPTaskInfo2* task); void DSPInit2(DSPTaskInfo2* task); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) void DspBoot(DSPCallback); #else void DspBoot(); diff --git a/include/jaudio/dspinterface.h b/include/jaudio/dspinterface.h index f038aef3..1b1248a0 100644 --- a/include/jaudio/dspinterface.h +++ b/include/jaudio/dspinterface.h @@ -40,6 +40,9 @@ void DSP_FlushBuffer(); void DSP_FlushChannel(u8 idx); void DSP_InvalChannelAll(); void DSP_ClearBuffer(); +#if defined(VERSION_GPIP01) +u64 DSP_CreateMap(); +#endif void DSP_SetupBuffer(); void DSP_InitBuffer(); diff --git a/include/jaudio/dspproc.h b/include/jaudio/dspproc.h index 571c81bb..9941cf03 100644 --- a/include/jaudio/dspproc.h +++ b/include/jaudio/dspproc.h @@ -15,7 +15,7 @@ void DwaitFrame(); void DiplSec(u32 cmd); void DagbSec(u32 cmd); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) void DsyncFrame2(u32 subframes, u32 dspbufStart, u32 dspbufEnd); #endif diff --git a/include/jaudio/dsptask.h b/include/jaudio/dsptask.h index 7db4dc1c..58a7c605 100644 --- a/include/jaudio/dsptask.h +++ b/include/jaudio/dsptask.h @@ -1,5 +1,5 @@ -#ifndef _JAUDIO_DSKTASK_H -#define _JAUDIO_DSKTASK_H +#ifndef _JAUDIO_DSPTASK_H +#define _JAUDIO_DSPTASK_H #include "types.h" diff --git a/include/system.h b/include/system.h index fae127a4..74f95d5d 100644 --- a/include/system.h +++ b/include/system.h @@ -67,7 +67,7 @@ enum TimerState { */ enum LanguageID { LANG_FORCE_CHANGE = -1, ///< -1, index to set if language requires re-loading. -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) LANG_English = 0, ///< 0, PAL English. NB: for PAL, Dutch OS language also maps to this. LANG_French = 1, ///< 1, PAL French. LANG_German = 2, ///< 2, PAL Italian. @@ -197,10 +197,10 @@ struct StdSystem { // Static functions static char* stringDup(immut char*); - static f32 getHalfRand(f32 max) { return max * (f32(rand()) / 32767.0f - 0.5f); } + static f32 getHalfRand(f32 max) { return max * (rand() / f32(RAND_MAX) - 0.5f); } // Inline functions - f32 getRand(f32 max) { return max * (f32(rand()) / 32767.0f); } + f32 getRand(f32 max) { return max * (rand() / f32(RAND_MAX)); } inline f32 getFade() { return mCurrentFade; } inline void setFade(f32 target, f32 rate = 3.0f) { @@ -249,7 +249,7 @@ struct StdSystem { int mActiveHeapIdx; // _194 BOOL mForcePrint; // _198 MemInfo* mCurrMemInfo; // _19C -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) LanguageID mLanguageID; // _1A0, language ID for PAL. #endif diff --git a/include/types.h b/include/types.h index 656db6ee..be251a21 100644 --- a/include/types.h +++ b/include/types.h @@ -82,6 +82,10 @@ typedef u32 HWND; // For when you have to pass something as a macro argument that contains commas. #define MACRO_ARG(...) __VA_ARGS__ +// Your tyical stringification macros +#define TO_STRING(x) STRINGIFY(x) +#define STRINGIFY(x) #x + // Workaround to introduce scoped enums (A feature of C++11 and onward). #define BEGIN_ENUM_TYPE(name) \ struct name { \ diff --git a/include/zen/ogTitle.h b/include/zen/ogTitle.h index 66e18001..9f4fe294 100644 --- a/include/zen/ogTitle.h +++ b/include/zen/ogTitle.h @@ -82,7 +82,7 @@ struct ogScrTitleMgr { s16 mBgmVol; // _9E s16 mSfxVol; // _A0 bool mVibeMode; // _A2 -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) int mChildMode; // _A4 #else bool mChildMode; // _A3 diff --git a/src/ar/ar.c b/src/ar/ar.c index 92701112..2b8fd465 100644 --- a/src/ar/ar.c +++ b/src/ar/ar.c @@ -6,7 +6,7 @@ static ARCallback __AR_Callback; static u32 __AR_Size; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L static u32 __AR_InternalSize; static u32 __AR_ExpansionSize; #endif @@ -100,7 +100,7 @@ void ARCheckInit(void) u32 ARInit(u32* stack_index_addr, u32 num_entries) { BOOL old; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L #else u16 refresh; #endif @@ -120,7 +120,7 @@ u32 ARInit(u32* stack_index_addr, u32 num_entries) __AR_FreeBlocks = num_entries; __AR_BlockLength = stack_index_addr; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L // WHY? __DSPRegs[DSP_ARAM_REFRESH] = __DSPRegs[DSP_ARAM_REFRESH] & 0xff | __DSPRegs[DSP_ARAM_REFRESH] & ~0xff; #else @@ -230,7 +230,7 @@ void __ARWriteDMA(u32 mmem_addr, u32 aram_addr, u32 length) do { } while ((__DSPRegs[DSP_CONTROL_STATUS] & 0x200)); -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L __DSPRegs[DSP_CONTROL_STATUS] = __DSPRegs[DSP_CONTROL_STATUS] & ~0x88 | 0x20; #endif } @@ -260,11 +260,20 @@ void __ARReadDMA(u32 mmem_addr, u32 aram_addr, u32 length) do { } while ((__DSPRegs[DSP_CONTROL_STATUS] & 0x200)); -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L __DSPRegs[DSP_CONTROL_STATUS] = __DSPRegs[DSP_CONTROL_STATUS] & ~0x88 | 0x20; #endif } +// Really repetitive changes to the following function that are better represented by macros. +#if OS_BUILD_VERSION >= 20011217L +#define __ARWaitForDMAToFinish(buffer, size) PPCSync() +#define __ARSetExpansionSize(value) (__AR_ExpansionSize = (value)) +#else +#define __ARWaitForDMAToFinish(buffer, size) DCInvalidateRange(buffer, size) +#define __ARSetExpansionSize(value) ((void)0) +#endif + /** * @TODO: Documentation */ @@ -280,7 +289,7 @@ void __ARChecksize(void) u32 ARAM_size; u32 i; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L do { } while (!(__DSPRegs[DSP_ARAM_MODE] & 1)); @@ -288,22 +297,10 @@ void __ARChecksize(void) ARAM_size = __AR_InternalSize = 0x1000000; __DSPRegs[DSP_ARAM_SIZE] = ((__DSPRegs[DSP_ARAM_SIZE] & 0xFFFFFFC0) | ARAM_mode) | 0x20; - - test_data = (void*)ALIGN_NEXT((u32)test_data_pad, 0x20); - dummy_data = (void*)ALIGN_NEXT((u32)dummy_data_pad, 0x20); - buffer = (void*)ALIGN_NEXT((u32)buffer_pad, 0x20); - for (i = 0; i < 8; i++) { - test_data[i] = 0xDEADBEEF; - dummy_data[i] = 0xBAD0BAD0; - } - - DCFlushRange(test_data, 0x20); - DCFlushRange(dummy_data, 0x20); - - __AR_ExpansionSize = 0; #else ARAM_mode = 0; ARAM_size = 0; +#endif test_data = (u32*)(OSRoundUp32B((u32)(test_data_pad))); dummy_data = (u32*)(OSRoundUp32B((u32)(dummy_data_pad))); @@ -316,67 +313,14 @@ void __ARChecksize(void) DCFlushRange(test_data, 0x20); DCFlushRange(dummy_data, 0x20); + +#if OS_BUILD_VERSION >= 20011217L +#else do { } while (!(__DSPRegs[DSP_ARAM_MODE] & 1)); __DSPRegs[DSP_ARAM_SIZE] = ((__DSPRegs[DSP_ARAM_SIZE] & 0xFFFFFFC0) | 4) | 0x20; -#endif - -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) - __ARWriteDMA((u32)dummy_data, ARAM_size + 0x0, 0x20U); - __ARWriteDMA((u32)dummy_data, ARAM_size + 0x200000, 0x20U); - __ARWriteDMA((u32)dummy_data, ARAM_size + 0x1000000, 0x20U); - __ARWriteDMA((u32)dummy_data, ARAM_size + 0x200, 0x20U); - __ARWriteDMA((u32)dummy_data, ARAM_size + 0x400000, 0x20U); - - memset(buffer, 0, 0x20); - DCFlushRange(buffer, 0x20); - - __ARWriteDMA((u32)test_data, ARAM_size, 0x20U); - DCInvalidateRange(buffer, 0x20); - - __ARReadDMA((u32)buffer, ARAM_size, 0x20U); - PPCSync(); - - if (*buffer == *test_data) { - memset(buffer, 0, 0x20); - DCFlushRange(buffer, 0x20); - - __ARReadDMA((u32)buffer, ARAM_size + 0x200000, 0x20U); - PPCSync(); - - if (*buffer == *test_data) { - ARAM_size += 0x200000; - __AR_ExpansionSize = 0x200000; - } else { - memset(buffer, 0, 0x20); - DCFlushRange(buffer, 0x20); - - __ARReadDMA((u32)buffer, ARAM_size + 0x01000000, 0x20U); - PPCSync(); - - if (*buffer == *test_data) { - ARAM_mode |= 8; - ARAM_size += 0x400000; - __AR_ExpansionSize = 0x400000; - } else { - memset(buffer, 0, 0x20); - DCFlushRange(buffer, 0x20); - - __ARReadDMA((u32)buffer, ARAM_size + 0x200, 0x20U); - PPCSync(); - - if (*buffer == *test_data) { - ARAM_mode |= 0x10; - ARAM_size += 0x800000; - __AR_ExpansionSize = 0x800000; - } else { - memset(buffer, 0, 0x20); - DCFlushRange(buffer, 0x20); - __ARReadDMA((u32)buffer, ARAM_size + 0x400000, 0x20U); - PPCSync(); -#else __ARWriteDMA((u32)dummy_data, ARAM_size + 0x0, 0x20U); __ARWriteDMA((u32)dummy_data, ARAM_size + 0x200000, 0x20U); __ARWriteDMA((u32)dummy_data, ARAM_size + 0x200, 0x20U); @@ -437,6 +381,10 @@ void __ARChecksize(void) } __DSPRegs[DSP_ARAM_SIZE] = (u16)((__DSPRegs[DSP_ARAM_SIZE] & 0xFFFFFFC0) | 0x20) | ARAM_mode; +#endif + + __ARSetExpansionSize(0); + __ARWriteDMA((u32)dummy_data, ARAM_size, 0x20U); __ARWriteDMA((u32)dummy_data, ARAM_size + 0x200000, 0x20U); __ARWriteDMA((u32)dummy_data, ARAM_size + 0x01000000, 0x20U); @@ -446,57 +394,55 @@ void __ARChecksize(void) memset(buffer, 0, 0x20); DCFlushRange(buffer, 0x20); __ARWriteDMA((u32)test_data, ARAM_size, 0x20U); +#if OS_BUILD_VERSION >= 20011217L + DCInvalidateRange(buffer, 0x20U); // Probably related to the revisional difference in `__ARWaitForDMAToFinish`. +#endif __ARReadDMA((u32)buffer, ARAM_size, 0x20U); - DCInvalidateRange(buffer, 0x20); + __ARWaitForDMAToFinish(buffer, 0x20); if (*buffer == *test_data) { memset(buffer, 0, 0x20); DCFlushRange(buffer, 0x20); __ARReadDMA((u32)buffer, ARAM_size + 0x200000, 0x20U); - DCInvalidateRange(buffer, 0x20); + __ARWaitForDMAToFinish(buffer, 0x20); if (*buffer == *test_data) { ARAM_size += 0x200000; - + __ARSetExpansionSize(0x200000); } else { memset(buffer, 0, 0x20); DCFlushRange(buffer, 0x20); __ARReadDMA((u32)buffer, ARAM_size + 0x01000000, 0x20U); - DCInvalidateRange(buffer, 0x20); + __ARWaitForDMAToFinish(buffer, 0x20); if (*buffer == *test_data) { ARAM_mode |= 8; ARAM_size += 0x400000; - + __ARSetExpansionSize(0x400000); } else { memset(buffer, 0, 0x20); DCFlushRange(buffer, 0x20); __ARReadDMA((u32)buffer, ARAM_size + 0x200, 0x20U); - DCInvalidateRange(buffer, 0x20); + __ARWaitForDMAToFinish(buffer, 0x20); if (*buffer == *test_data) { ARAM_mode |= 0x10; ARAM_size += 0x800000; - + __ARSetExpansionSize(0x800000); } else { memset(buffer, 0, 0x20); DCFlushRange(buffer, 0x20); __ARReadDMA((u32)buffer, ARAM_size + 0x400000, 0x20U); - DCInvalidateRange(buffer, 0x20); -#endif + __ARWaitForDMAToFinish(buffer, 0x20); + if (*buffer == *test_data) { ARAM_mode |= 0x18; ARAM_size += 0x01000000; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) - __AR_ExpansionSize = 0x1000000; -#endif - + __ARSetExpansionSize(0x1000000); } else { ARAM_mode |= 0x20; ARAM_size += 0x02000000; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) - __AR_ExpansionSize = 0x2000000; -#endif + __ARSetExpansionSize(0x2000000); } } } @@ -506,3 +452,6 @@ void __ARChecksize(void) *(u32*)OSPhysicalToUncached(0xD0) = ARAM_size; __AR_Size = ARAM_size; } + +#undef __ARWaitForDMAToFinish +#undef __ARSetExpansionSize diff --git a/src/card/CARDBios.c b/src/card/CARDBios.c index 2426a384..7b10aed9 100644 --- a/src/card/CARDBios.c +++ b/src/card/CARDBios.c @@ -1,7 +1,7 @@ #include "Dolphin/card.h" #include -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L #else DVDDiskID* __CARDDiskID; #endif @@ -46,7 +46,7 @@ void __CARDExtHandler(s32 channel, OSContext* context) card = &__CARDBlock[channel]; if (card->attached) { card->attached = FALSE; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L #else card->result = CARD_RESULT_NOCARD; #endif @@ -59,7 +59,7 @@ void __CARDExtHandler(s32 channel, OSContext* context) callback(channel, CARD_RESULT_NOCARD); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (card->result != CARD_RESULT_BUSY) { card->result = CARD_RESULT_NOCARD; } @@ -104,7 +104,7 @@ void __CARDExiHandler(s32 channel, OSContext* context) if ((result = (status & 0x18) ? CARD_RESULT_IOERROR : CARD_RESULT_READY) == CARD_RESULT_IOERROR && --card->retry > 0) { result = Retry(channel); - if (result >= 0) { + if (result >= CARD_RESULT_READY) { return; } goto fatal; @@ -372,7 +372,7 @@ static void UnlockedCallback(s32 channel, s32 result) CARDControl* card; card = &__CARDBlock[channel]; - if (result >= 0) { + if (result >= CARD_RESULT_READY) { card->unlockCallback = UnlockedCallback; if (!EXILock(channel, 0, __CARDUnlockedHandler)) { result = CARD_RESULT_READY; @@ -382,7 +382,7 @@ static void UnlockedCallback(s32 channel, s32 result) } } - if (result < 0) { + if (result < CARD_RESULT_READY) { switch (card->cmd[0]) { case 0x52: { @@ -413,13 +413,13 @@ static void UnlockedCallback(s32 channel, s32 result) */ static s32 __CARDStart(s32 channel, CARDCallback txCallback, CARDCallback exiCallback) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L BOOL enabled; #endif CARDControl* card; s32 result; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L enabled = OSDisableInterrupts(); #endif @@ -450,7 +450,7 @@ static s32 __CARDStart(s32 channel, CARDCallback txCallback, CARDCallback exiCal } } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSRestoreInterrupts(enabled); #endif @@ -480,8 +480,8 @@ s32 __CARDReadSegment(s32 channel, CARDCallback callback) return CARD_RESULT_READY; } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (result >= 0) { +#if OS_BUILD_VERSION >= 20011002L + if (result >= CARD_RESULT_READY) { if (!EXIImmEx(channel, card->cmd, card->cmdlen, 1) || !EXIImmEx(channel, card->workArea->header.buffer, card->latency, 1) @@ -497,7 +497,7 @@ s32 __CARDReadSegment(s32 channel, CARDCallback callback) } return result; #else - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -534,10 +534,10 @@ s32 __CARDWritePage(s32 channel, CARDCallback callback) card->retry = 3; result = __CARDStart(channel, NULL, callback); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (result == CARD_RESULT_BUSY) { result = CARD_RESULT_READY; - } else if (result >= 0) { + } else if (result >= CARD_RESULT_READY) { if (!EXIImmEx(channel, card->cmd, card->cmdlen, 1) || !EXIDma(channel, card->buffer, 128, card->mode, __CARDTxHandler)) { card->exiCallback = 0; EXIDeselect(channel); @@ -551,7 +551,7 @@ s32 __CARDWritePage(s32 channel, CARDCallback callback) if (result == CARD_RESULT_BUSY) { return CARD_RESULT_READY; } - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } if (!EXIImmEx(channel, card->cmd, card->cmdlen, 1) || !EXIDma(channel, card->buffer, 128, card->mode, __CARDTxHandler)) { @@ -591,10 +591,10 @@ s32 __CARDEraseSector(s32 channel, u32 addr, CARDCallback callback) result = __CARDStart(channel, NULL, callback); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (result == CARD_RESULT_BUSY) { result = CARD_RESULT_READY; - } else if (result >= 0) { + } else if (result >= CARD_RESULT_READY) { result = CARD_RESULT_READY; if (!EXIImmEx(channel, card->cmd, card->cmdlen, 1)) { result = CARD_RESULT_NOCARD; @@ -611,7 +611,7 @@ s32 __CARDEraseSector(s32 channel, u32 addr, CARDCallback callback) return CARD_RESULT_READY; } - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -633,11 +633,12 @@ void CARDInit(void) { s32 channel; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (__CARDBlock[0].diskID && __CARDBlock[1].diskID) { +#if OS_BUILD_VERSION >= 20011112L + if (__CARDBlock[0].diskID && __CARDBlock[1].diskID) #else - if (__CARDDiskID) { + if (__CARDDiskID) #endif + { return; } @@ -662,7 +663,7 @@ void CARDInit(void) */ void __CARDSetDiskID(DVDDiskID* diskID) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L __CARDBlock[0].diskID = diskID ? diskID : &__CARDDiskNone; __CARDBlock[1].diskID = diskID ? diskID : &__CARDDiskNone; #else @@ -678,7 +679,7 @@ s32 __CARDGetControlBlock(s32 channel, CARDControl** card) BOOL enabled; s32 result; CARDControl* reqCard; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L reqCard = &__CARDBlock[channel]; if (channel < 0 || channel >= 2 || reqCard->diskID == NULL) { return CARD_RESULT_FATAL_ERROR; @@ -715,7 +716,7 @@ s32 __CARDPutControlBlock(CARDControl* card, s32 result) BOOL enabled; enabled = OSDisableInterrupts(); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (card->attached) { card->result = result; } else if (card->result == CARD_RESULT_BUSY) { @@ -760,7 +761,7 @@ s32 CARDFreeBlocks(s32 channel, s32* byteNotUsed, s32* filesNotUsed) u16 fileNo; result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -814,7 +815,7 @@ s32 CARDGetSectorSize(s32 channel, u32* size) s32 result; result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } *size = card->sectorSize; diff --git a/src/card/CARDBlock.c b/src/card/CARDBlock.c index e19a27f8..beaec563 100644 --- a/src/card/CARDBlock.c +++ b/src/card/CARDBlock.c @@ -25,7 +25,7 @@ static void WriteCallback(s32 channel, s32 result) card = &__CARDBlock[channel]; - if (result >= 0) { + if (result >= CARD_RESULT_READY) { fat = &card->workArea->blockAllocMap; fatBack = &card->workArea->blockAllocMapBackup; @@ -56,19 +56,19 @@ static void EraseCallback(s32 channel, s32 result) { CARDControl* card; CARDCallback callback; - u32 temp[2]; /* this compiler sucks */ CARDFatBlock* fat; u32 addr; + STACK_PAD_VAR(2); /* this compiler sucks */ card = &__CARDBlock[channel]; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } fat = __CARDGetFatBlock(card); addr = ((u32)fat - (u32)card->workArea) / CARD_SYSTEM_BLOCK_SIZE * card->sectorSize; result = __CARDWrite(channel, addr, CARD_SYSTEM_BLOCK_SIZE, fat, WriteCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } diff --git a/src/card/CARDCheck.c b/src/card/CARDCheck.c index 6156929a..df26dd87 100644 --- a/src/card/CARDCheck.c +++ b/src/card/CARDCheck.c @@ -182,7 +182,7 @@ s32 __CARDVerify(CARDControl* card) int errors; result = VerifyID(card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -230,12 +230,12 @@ s32 CARDCheckExAsync(s32 channel, s32* xferBytes, CARDCallback callback) } result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } result = VerifyID(card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return __CARDPutControlBlock(card, result); } @@ -369,7 +369,7 @@ s32 CARDCheck(s32 channel) result = CARDCheckExAsync(channel, &xferBytes, __CARDSyncCallback); - if (result < 0 || &xferBytes == NULL) { + if (result < CARD_RESULT_READY || &xferBytes == NULL) { return result; } diff --git a/src/card/CARDCreate.c b/src/card/CARDCreate.c index 04a922ff..3da5392d 100644 --- a/src/card/CARDCreate.c +++ b/src/card/CARDCreate.c @@ -15,13 +15,13 @@ static void CreateCallbackFat(s32 channel, s32 result) card = &__CARDBlock[channel]; callback = card->apiCallback; card->apiCallback = NULL; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } dir = __CARDGetDirBlock(card); ent = &dir->entries[card->freeNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L memcpy(ent->gameName, card->diskID->gameName, sizeof(ent->gameName)); memcpy(ent->company, card->diskID->company, sizeof(ent->company)); #else @@ -45,7 +45,7 @@ static void CreateCallbackFat(s32 channel, s32 result) ent->time = (u32)OSTicksToSeconds(OSGetTime()); result = __CARDUpdateDir(channel, callback); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } return; @@ -75,7 +75,7 @@ s32 CARDCreateAsync(s32 channel, const char* fileName, u32 size, CARDFileInfo* f } result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -91,13 +91,15 @@ s32 CARDCreateAsync(s32 channel, const char* fileName, u32 size, CARDFileInfo* f if (freeNo == (u16)-1) { freeNo = fileNo; } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - } else if (memcmp(ent->gameName, card->diskID->gameName, sizeof(ent->gameName)) == 0 - && memcmp(ent->company, card->diskID->company, sizeof(ent->company)) == 0 && __CARDCompareFileName(ent, fileName)) { + } +#if OS_BUILD_VERSION >= 20011112L + else if (memcmp(ent->gameName, card->diskID->gameName, sizeof(ent->gameName)) == 0 + && memcmp(ent->company, card->diskID->company, sizeof(ent->company)) == 0 && __CARDCompareFileName(ent, fileName)) #else - } else if (memcmp(ent->gameName, __CARDDiskID->gameName, sizeof(ent->gameName)) == 0 - && memcmp(ent->company, __CARDDiskID->company, sizeof(ent->company)) == 0 && __CARDCompareFileName(ent, fileName)) { + else if (memcmp(ent->gameName, __CARDDiskID->gameName, sizeof(ent->gameName)) == 0 + && memcmp(ent->company, __CARDDiskID->company, sizeof(ent->company)) == 0 && __CARDCompareFileName(ent, fileName)) #endif + { return __CARDPutControlBlock(card, CARD_RESULT_EXIST); } } @@ -121,7 +123,7 @@ s32 CARDCreateAsync(s32 channel, const char* fileName, u32 size, CARDFileInfo* f fileInfo->fileNo = freeNo; result = __CARDAllocBlock(channel, size / card->sectorSize, CreateCallbackFat); - if (result < 0) { + if (result < CARD_RESULT_READY) { return __CARDPutControlBlock(card, result); } return result; @@ -133,7 +135,7 @@ s32 CARDCreateAsync(s32 channel, const char* fileName, u32 size, CARDFileInfo* f s32 CARDCreate(s32 channel, const char* fileName, u32 size, CARDFileInfo* fileInfo) { s32 result = CARDCreateAsync(channel, fileName, size, fileInfo, __CARDSyncCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } return __CARDSync(channel); diff --git a/src/card/CARDDelete.c b/src/card/CARDDelete.c index 98a22354..2671aded 100644 --- a/src/card/CARDDelete.c +++ b/src/card/CARDDelete.c @@ -14,12 +14,12 @@ static void DeleteCallback(s32 channel, s32 result) callback = card->apiCallback; card->apiCallback = NULL; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } result = __CARDFreeBlock(channel, card->startBlock, callback); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } return; @@ -46,18 +46,18 @@ s32 CARDFastDeleteAsync(s32 channel, s32 fileNo, CARDCallback callback) } result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } dir = __CARDGetDirBlock(card); ent = &dir->entries[fileNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L result = __CARDAccess(card, ent); #else result = __CARDAccess(ent); #endif - if (result < 0) { + if (result < CARD_RESULT_READY) { return __CARDPutControlBlock(card, result); } @@ -70,7 +70,7 @@ s32 CARDFastDeleteAsync(s32 channel, s32 fileNo, CARDCallback callback) card->apiCallback = callback ? callback : __CARDDefaultApiCallback; result = __CARDUpdateDir(channel, DeleteCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { __CARDPutControlBlock(card, result); } return result; @@ -83,7 +83,7 @@ s32 CARDFastDelete(s32 channel, s32 fileNo) { s32 result = CARDFastDeleteAsync(channel, fileNo, __CARDSyncCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } return __CARDSync(channel); diff --git a/src/card/CARDDir.c b/src/card/CARDDir.c index 50ef958f..6b2d8985 100644 --- a/src/card/CARDDir.c +++ b/src/card/CARDDir.c @@ -51,18 +51,18 @@ static void EraseCallback(s32 channel, s32 result) CARDControl* card; CARDCallback callback; CARDDirectoryBlock* dir; - u32 tmp[2]; u32 addr; + STACK_PAD_VAR(2); card = &__CARDBlock[channel]; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } dir = __CARDGetDirBlock(card); addr = ((u32)dir - (u32)card->workArea) / CARD_SYSTEM_BLOCK_SIZE * card->sectorSize; result = __CARDWrite(channel, addr, CARD_SYSTEM_BLOCK_SIZE, dir, WriteCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -86,9 +86,9 @@ s32 __CARDUpdateDir(s32 channel, CARDCallback callback) { CARDControl* card; CARDDirCheck* check; - u32 tmp[2]; u32 addr; CARDDirectoryBlock* dir; + STACK_PAD_VAR(2); card = &__CARDBlock[channel]; if (!card->attached) { diff --git a/src/card/CARDFormat.c b/src/card/CARDFormat.c index e424de16..0cc89afa 100644 --- a/src/card/CARDFormat.c +++ b/src/card/CARDFormat.c @@ -11,7 +11,7 @@ static void FormatCallback(s32 channel, s32 result) CARDCallback callback; card = &__CARDBlock[channel]; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -25,7 +25,7 @@ static void FormatCallback(s32 channel, s32 result) int step = card->mountStep - CARD_NUM_SYSTEM_BLOCK; result = __CARDWrite(channel, (u32)card->sectorSize * step, CARD_SYSTEM_BLOCK_SIZE, (u8*)card->workArea + (CARD_SYSTEM_BLOCK_SIZE * step), FormatCallback); - if (result >= 0) { + if (result >= CARD_RESULT_READY) { return; } } else { @@ -60,7 +60,7 @@ s32 __CARDFormatRegionAsync(s32 chan, u16 encode, CARDCallback callback) OSAssertLine(0x9A, 0 <= chan && chan < 2); result = __CARDGetControlBlock(chan, &card); - if (result < 0) + if (result < CARD_RESULT_READY) return result; id = (CARDID*)card->workArea; @@ -115,7 +115,7 @@ s32 __CARDFormatRegionAsync(s32 chan, u16 encode, CARDCallback callback) // melee uses formatStep here, is this wrong? I dont know anymore, its what matches card->mountStep = 0; result = __CARDEraseSector(chan, (u32)card->sectorSize * card->mountStep, FormatCallback); - if (result < 0) + if (result < CARD_RESULT_READY) __CARDPutControlBlock(card, result); return result; } @@ -125,7 +125,7 @@ s32 __CARDFormatRegionAsync(s32 chan, u16 encode, CARDCallback callback) */ s32 CARDFormatAsync(s32 channel, CARDCallback callback) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L return __CARDFormatRegionAsync(channel, OSGetFontEncode(), callback); #else CARDControl* card; @@ -141,7 +141,7 @@ s32 CARDFormatAsync(s32 channel, CARDCallback callback) OSTime rand; result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -196,7 +196,7 @@ s32 CARDFormatAsync(s32 channel, CARDCallback callback) card->mountStep = 0; result = __CARDEraseSector(channel, (u32)card->sectorSize * card->mountStep, FormatCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { __CARDPutControlBlock(card, result); } return result; @@ -209,7 +209,7 @@ s32 CARDFormatAsync(s32 channel, CARDCallback callback) s32 CARDFormat(s32 channel) { s32 result = CARDFormatAsync(channel, __CARDSyncCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } return __CARDSync(channel); diff --git a/src/card/CARDMount.c b/src/card/CARDMount.c index 3cc716af..f22e9ea3 100644 --- a/src/card/CARDMount.c +++ b/src/card/CARDMount.c @@ -18,7 +18,7 @@ static void DoUnmount(s32 channel, s32 result); */ BOOL CARDProbe(s32 channel) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (GameChoice & 0x80) { return 0; } @@ -27,9 +27,12 @@ BOOL CARDProbe(s32 channel) return EXIProbe(channel); } +/** + * This inline is not used anywhere, but we have a revisional difference for it? Okay... + */ static inline BOOL IsCard(u32 id) { -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L if ((id == 0x80000004 && __CARDVendorID != 0xFFFF) || !(id & 0xFFFF0000) && !(id & 3)) { return TRUE; } @@ -150,7 +153,7 @@ static s32 DoMount(s32 channel) if (card->mountStep == 0) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L if (EXIGetID(channel, 0, &id) == 0) { result = CARD_RESULT_NOCARD; } else if ((id == 0x80000004 && __CARDVendorID != 0xFFFF) || (!(id & 0xFFFF0000) && !(id & 3))) { @@ -161,18 +164,18 @@ static s32 DoMount(s32 channel) #else result = __CARDReadNintendoID(channel, &id); #endif - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L card->cid = id; #endif card->size = (u16)(id & 0xFC); card->sectorSize = SectorSizeTable[(id & 0x00003800) >> 11]; card->cBlock = (u16)((card->size * 1024 * 1024 / 8) / card->sectorSize); card->latency = LatencyTable[(id & 0x00000700) >> 8]; -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011217L #else if (card->sectorSize == 0 || card->cBlock < 8) { result = CARD_RESULT_WRONGDEVICE; @@ -180,11 +183,11 @@ static s32 DoMount(s32 channel) } #endif result = __CARDClearStatus(channel); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } result = __CARDReadStatus(channel, &status); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -195,7 +198,7 @@ static s32 DoMount(s32 channel) if (!(status & 0x40)) { result = __CARDUnlock(channel, card->id); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -226,7 +229,7 @@ static s32 DoMount(s32 channel) } if (card->mountStep == 1) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L if (card->cid == 0x80000004) { u16 vendorID; @@ -244,7 +247,7 @@ static s32 DoMount(s32 channel) card->mountStep = 2; result = __CARDEnableInterrupt(channel, TRUE); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -256,7 +259,7 @@ static s32 DoMount(s32 channel) step = card->mountStep - 2; result = __CARDRead(channel, (u32)card->sectorSize * step, CARD_SYSTEM_BLOCK_SIZE, (u8*)card->workArea + (CARD_SYSTEM_BLOCK_SIZE * step), __CARDMountCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { __CARDPutControlBlock(card, result); } return result; @@ -323,7 +326,7 @@ s32 CARDMountAsync(s32 channel, CARDMemoryCard* workArea, CARDCallback detachCal if (channel < 0 || 2 <= channel) { return CARD_RESULT_FATAL_ERROR; } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (GameChoice & 0x80) return CARD_RESULT_NOCARD; #endif @@ -378,7 +381,7 @@ s32 CARDMountAsync(s32 channel, CARDMemoryCard* workArea, CARDCallback detachCal s32 CARDMount(s32 channel, CARDMemoryCard* workArea, CARDCallback detachCallback) { s32 result = CARDMountAsync(channel, workArea, detachCallback, __CARDSyncCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -415,7 +418,7 @@ s32 CARDUnmount(s32 channel) s32 result; result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } DoUnmount(channel, CARD_RESULT_NOCARD); diff --git a/src/card/CARDOpen.c b/src/card/CARDOpen.c index d166cb43..228d9b57 100644 --- a/src/card/CARDOpen.c +++ b/src/card/CARDOpen.c @@ -32,7 +32,7 @@ BOOL __CARDCompareFileName(CARDDir* entry, const char* fileName) /** * @TODO: Documentation */ -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L s32 __CARDAccess(CARDControl* card, CARDDir* entry) #else s32 __CARDAccess(CARDDir* entry) @@ -42,7 +42,7 @@ s32 __CARDAccess(CARDDir* entry) return CARD_RESULT_NOFILE; } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L if (card->diskID == &__CARDDiskNone || (memcmp(entry->gameName, card->diskID->gameName, sizeof(entry->gameName)) == 0 && memcmp(entry->company, card->diskID->company, sizeof(entry->company)) == 0)) { @@ -89,12 +89,12 @@ s32 __CARDGetFileNo(CARDControl* card, const char* fileName, s32* outFileNo) dir = __CARDGetDirBlock(card); for (fileNo = 0; fileNo < CARD_MAX_FILE; fileNo++) { entry = &dir->entries[fileNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L result = __CARDAccess(card, entry); #else result = __CARDAccess(entry); #endif - if (result < 0) { + if (result < CARD_RESULT_READY) { continue; } if (__CARDCompareFileName(entry, fileName)) { @@ -123,13 +123,13 @@ s32 CARDFastOpen(s32 channel, s32 fileNo, CARDFileInfo* fileInfo) fileInfo->chan = -1; result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } dir = __CARDGetDirBlock(card); ent = &dir->entries[fileNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L result = __CARDAccess(card, ent); #else result = __CARDAccess(ent); @@ -137,7 +137,7 @@ s32 CARDFastOpen(s32 channel, s32 fileNo, CARDFileInfo* fileInfo) if (result == CARD_RESULT_NOPERM) { result = __CARDIsPublic(ent); } - if (result >= 0) { + if (result >= CARD_RESULT_READY) { if (!CARDIsValidBlockNo(card, ent->startBlock)) { result = CARD_RESULT_BROKEN; } else { @@ -163,7 +163,7 @@ s32 CARDOpen(s32 chan, const char* fileName, CARDFileInfo* fileInfo) fileInfo->chan = -1; result = __CARDGetControlBlock(chan, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } result = __CARDGetFileNo(card, fileName, &fileNo); @@ -191,7 +191,7 @@ s32 CARDClose(CARDFileInfo* fileInfo) s32 result; result = __CARDGetControlBlock(fileInfo->chan, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } diff --git a/src/card/CARDRdwr.c b/src/card/CARDRdwr.c index db60ef40..47c60a81 100644 --- a/src/card/CARDRdwr.c +++ b/src/card/CARDRdwr.c @@ -10,7 +10,7 @@ static void BlockReadCallback(s32 channel, s32 result) CARDCallback callback; card = &__CARDBlock[channel]; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -23,7 +23,7 @@ static void BlockReadCallback(s32 channel, s32 result) } result = __CARDReadSegment(channel, BlockReadCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } return; @@ -67,7 +67,7 @@ static void BlockWriteCallback(s32 channel, s32 result) CARDCallback callback; card = &__CARDBlock[channel]; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -80,7 +80,7 @@ static void BlockWriteCallback(s32 channel, s32 result) } result = __CARDWritePage(channel, BlockWriteCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } return; diff --git a/src/card/CARDRead.c b/src/card/CARDRead.c index d7b0d95d..174c29d7 100644 --- a/src/card/CARDRead.c +++ b/src/card/CARDRead.c @@ -13,7 +13,7 @@ s32 __CARDSeek(CARDFileInfo* fileInfo, s32 length, s32 offset, CARDControl** out CARDFatBlock* fat; result = __CARDGetControlBlock(fileInfo->chan, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -63,7 +63,7 @@ static void ReadCallback(s32 channel, s32 result) s32 length; card = &__CARDBlock[channel]; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -89,7 +89,7 @@ static void ReadCallback(s32 channel, s32 result) result = __CARDRead(channel, card->sectorSize * (u32)fileInfo->iBlock, (fileInfo->length < card->sectorSize) ? fileInfo->length : card->sectorSize, card->buffer, ReadCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -116,13 +116,13 @@ s32 CARDReadAsync(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset, return CARD_RESULT_FATAL_ERROR; } result = __CARDSeek(fileInfo, length, offset, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } dir = __CARDGetDirBlock(card); ent = &dir->entries[fileInfo->fileNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L result = __CARDAccess(card, ent); #else result = __CARDAccess(ent); @@ -131,7 +131,7 @@ s32 CARDReadAsync(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset, result = __CARDIsPublic(ent); } - if (result < 0) { + if (result < CARD_RESULT_READY) { return __CARDPutControlBlock(card, result); } @@ -141,7 +141,7 @@ s32 CARDReadAsync(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset, offset = (s32)OFFSET(fileInfo->offset, card->sectorSize); length = (length < card->sectorSize - offset) ? length : card->sectorSize - offset; result = __CARDRead(fileInfo->chan, card->sectorSize * (u32)fileInfo->iBlock + offset, length, buffer, ReadCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { __CARDPutControlBlock(card, result); } return result; @@ -154,7 +154,7 @@ s32 CARDRead(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset) { s32 result = CARDReadAsync(fileInfo, buffer, length, offset, __CARDSyncCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } diff --git a/src/card/CARDRename.c b/src/card/CARDRename.c index eb51f242..922f074e 100644 --- a/src/card/CARDRename.c +++ b/src/card/CARDRename.c @@ -21,7 +21,7 @@ s32 CARDRenameAsync(s32 channel, const char* oldName, const char* newName, CARDC return CARD_RESULT_NAMETOOLONG; } result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } newNo = oldNo = -1; @@ -32,13 +32,14 @@ s32 CARDRenameAsync(s32 channel, const char* oldName, const char* newName, CARDC continue; } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L if (memcmp(ent->gameName, card->diskID->gameName, sizeof(ent->gameName)) != 0 - || memcmp(ent->company, card->diskID->company, sizeof(ent->company)) != 0) { + || memcmp(ent->company, card->diskID->company, sizeof(ent->company)) != 0) #else if (memcmp(ent->gameName, __CARDDiskID->gameName, sizeof(ent->gameName)) != 0 - || memcmp(ent->company, __CARDDiskID->company, sizeof(ent->company)) != 0) { + || memcmp(ent->company, __CARDDiskID->company, sizeof(ent->company)) != 0) #endif + { continue; } @@ -58,12 +59,12 @@ s32 CARDRenameAsync(s32 channel, const char* oldName, const char* newName, CARDC } ent = &dir->entries[oldNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L result = __CARDAccess(card, ent); #else result = __CARDAccess(ent); #endif - if (result < 0) { + if (result < CARD_RESULT_READY) { return __CARDPutControlBlock(card, result); } @@ -71,7 +72,7 @@ s32 CARDRenameAsync(s32 channel, const char* oldName, const char* newName, CARDC ent->time = (u32)OSTicksToSeconds(OSGetTime()); result = __CARDUpdateDir(channel, callback); - if (result < 0) { + if (result < CARD_RESULT_READY) { __CARDPutControlBlock(card, result); } @@ -85,7 +86,7 @@ s32 CARDRename(s32 channel, const char* oldName, const char* newName) { s32 result = CARDRenameAsync(channel, oldName, newName, __CARDSyncCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } return __CARDSync(channel); diff --git a/src/card/CARDStat.c b/src/card/CARDStat.c index d81bb72c..3e8278a2 100644 --- a/src/card/CARDStat.c +++ b/src/card/CARDStat.c @@ -87,13 +87,13 @@ s32 CARDGetStatus(s32 channel, s32 fileNo, CARDStat* state) return CARD_RESULT_FATAL_ERROR; } result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } dir = __CARDGetDirBlock(card); ent = &dir->entries[fileNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L result = __CARDAccess(card, ent); #else result = __CARDAccess(ent); @@ -102,7 +102,7 @@ s32 CARDGetStatus(s32 channel, s32 fileNo, CARDStat* state) result = __CARDIsPublic(ent); } - if (result >= 0) { + if (result >= CARD_RESULT_READY) { memcpy(state->gameName, ent->gameName, sizeof(state->gameName)); memcpy(state->company, ent->company, sizeof(state->company)); state->length = (u32)ent->length * card->sectorSize; @@ -135,18 +135,18 @@ s32 CARDSetStatusAsync(s32 channel, s32 fileNo, CARDStat* state, CARDCallback ca return CARD_RESULT_FATAL_ERROR; } result = __CARDGetControlBlock(channel, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } dir = __CARDGetDirBlock(card); ent = &dir->entries[fileNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L result = __CARDAccess(card, ent); #else result = __CARDAccess(ent); #endif - if (result < 0) { + if (result < CARD_RESULT_READY) { return __CARDPutControlBlock(card, result); } @@ -163,7 +163,7 @@ s32 CARDSetStatusAsync(s32 channel, s32 fileNo, CARDStat* state, CARDCallback ca ent->time = (u32)OSTicksToSeconds(OSGetTime()); result = __CARDUpdateDir(channel, callback); - if (result < 0) { + if (result < CARD_RESULT_READY) { __CARDPutControlBlock(card, result); } return result; @@ -175,7 +175,7 @@ s32 CARDSetStatusAsync(s32 channel, s32 fileNo, CARDStat* state, CARDCallback ca s32 CARDSetStatus(s32 channel, s32 fileNo, CARDStat* state) { s32 result = CARDSetStatusAsync(channel, fileNo, state, __CARDSyncCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } diff --git a/src/card/CARDWrite.c b/src/card/CARDWrite.c index 5a1222a6..8d8ec431 100644 --- a/src/card/CARDWrite.c +++ b/src/card/CARDWrite.c @@ -16,7 +16,7 @@ static void WriteCallback(s32 channel, s32 result) CARDFileInfo* fileInfo; card = &__CARDBlock[channel]; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } @@ -46,7 +46,7 @@ static void WriteCallback(s32 channel, s32 result) result = __CARDEraseSector(channel, card->sectorSize * (u32)fileInfo->iBlock, EraseCallback); } - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } return; @@ -68,13 +68,13 @@ void EraseCallback(s32 channel, s32 result) CARDFileInfo* fileInfo; card = &__CARDBlock[channel]; - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } fileInfo = card->fileInfo; result = __CARDWrite(channel, card->sectorSize * (u32)fileInfo->iBlock, card->sectorSize, card->buffer, WriteCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { goto error; } return; @@ -97,7 +97,7 @@ s32 CARDWriteAsync(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset, CARDDir* ent; result = __CARDSeek(fileInfo, length, offset, &card); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } @@ -107,12 +107,12 @@ s32 CARDWriteAsync(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset, dir = __CARDGetDirBlock(card); ent = &dir->entries[fileInfo->fileNo]; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L result = __CARDAccess(card, ent); #else result = __CARDAccess(ent); #endif - if (result < 0) { + if (result < CARD_RESULT_READY) { return __CARDPutControlBlock(card, result); } @@ -120,7 +120,7 @@ s32 CARDWriteAsync(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset, card->apiCallback = callback ? callback : __CARDDefaultApiCallback; card->buffer = buffer; result = __CARDEraseSector(fileInfo->chan, card->sectorSize * (u32)fileInfo->iBlock, EraseCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { __CARDPutControlBlock(card, result); } return result; @@ -132,7 +132,7 @@ s32 CARDWriteAsync(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset, s32 CARDWrite(CARDFileInfo* fileInfo, void* buffer, s32 length, s32 offset) { s32 result = CARDWriteAsync(fileInfo, buffer, length, offset, __CARDSyncCallback); - if (result < 0) { + if (result < CARD_RESULT_READY) { return result; } diff --git a/src/dsp/dsp.c b/src/dsp/dsp.c index ae645cee..313c7091 100644 --- a/src/dsp/dsp.c +++ b/src/dsp/dsp.c @@ -121,7 +121,11 @@ void DSPAssertTask(void) // UNUSED FUNCTION } -#if defined(VERSION_GPIP01_00) +// TODO: The presence of this function (but not necessarily its contents) is not a revisional +// difference, but is instead an instance of an UNREFERENCED DUPLICATE func,global. This only +// happens when linking static libraries rather than individual objects, but I don't know how +// to / if it's possible to do that within Decomp Toolkit yet. +#if defined(VERSION_GPIP01) static int __DSP_init_flag; diff --git a/src/dvd/dvderror.c b/src/dvd/dvderror.c index 60789940..6edb4f16 100644 --- a/src/dvd/dvderror.c +++ b/src/dvd/dvderror.c @@ -1,7 +1,7 @@ #include "Dolphin/dvd.h" #include "Dolphin/os.h" -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L u32 ErrorTable[18] = { 0x00000000, 0x00023A00, 0x00062800, 0x00030200, 0x00031100, 0x00052000, 0x00052001, 0x00052100, 0x00052400, 0x00052401, 0x00052402, 0x000B5A01, 0x00056300, 0x00020401, 0x00020400, 0x00040800, 0x00100007, 0x00000000 }; #else @@ -21,7 +21,7 @@ u8 ErrorCode2Num(u32 errorCode) } } -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L if ((errorCode >= 0x00100000) && (errorCode <= 0x00100008)) { return 17; } diff --git a/src/dvd/dvdfs.c b/src/dvd/dvdfs.c index 2e5272b7..176bea5a 100644 --- a/src/dvd/dvdfs.c +++ b/src/dvd/dvdfs.c @@ -54,7 +54,6 @@ void __DVDFSInit() */ static BOOL isSame(const char* path, const char* string) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) while (*string != '\0') { if (tolower(*path++) != tolower(*string++)) { return FALSE; @@ -64,17 +63,6 @@ static BOOL isSame(const char* path, const char* string) if ((*path == '/') || (*path == '\0')) { return TRUE; } -#else - while ((u8)*string != '\0') { - if (tolower((u8)*path++) != tolower((u8)*string++)) { - return FALSE; - } - } - - if (((u8)*path == '/') || ((u8)*path == '\0')) { - return TRUE; - } -#endif return FALSE; // UNUSED FUNCTION } @@ -97,7 +85,6 @@ s32 DVDConvertPathToEntrynum(const char* pathPtr) dirLookAt = currentDirectory; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) while (1) { if (*pathPtr == '\0') { return (s32)dirLookAt; @@ -145,100 +132,24 @@ s32 DVDConvertPathToEntrynum(const char* pathPtr) } if (illegal) { +#if OS_BUILD_VERSION >= 20011002L OSErrorLine(376, "DVDConvertEntrynumToPath(possibly DVDOpen or DVDChangeDir or DVDOpenDir): specified directory or file " "(%s) doesn't match standard 8.3 format. This is a temporary restriction and will be removed soon\n", origPathPtr); - } - } else { - for (ptr = pathPtr; (*ptr != '\0') && (*ptr != '/'); ptr++) - ; - } - - isDir = (*ptr == '\0') ? FALSE : TRUE; - length = (u32)(ptr - pathPtr); - - ptr = pathPtr; - - for (i = dirLookAt + 1; i < nextDir(dirLookAt); i = entryIsDir(i) ? nextDir(i) : (i + 1)) { - if ((entryIsDir(i) == FALSE) && (isDir == TRUE)) { - continue; - } - - stringPtr = FstStringStart + stringOff(i); - - if (isSame(ptr, stringPtr) == TRUE) { - goto next_hier; - } - } - - return -1; - - next_hier: - if (!isDir) { - return (s32)i; - } - - dirLookAt = i; - pathPtr += length + 1; - } #else - while (1) { - if ((u8)*pathPtr == '\0') { - return (s32)dirLookAt; - } else if ((u8)*pathPtr == '/') { - dirLookAt = 0; - pathPtr++; - continue; - } else if ((u8)*pathPtr == '.') { - if ((u8) * (pathPtr + 1) == '.') { - if ((u8) * (pathPtr + 2) == '/') { - dirLookAt = parentDir(dirLookAt); - pathPtr += 3; - continue; - } else if ((u8) * (pathPtr + 2) == '\0') { - return (s32)parentDir(dirLookAt); - } - } else if ((u8) * (pathPtr + 1) == '/') { - pathPtr += 2; - continue; - } else if ((u8) * (pathPtr + 1) == '\0') { - return (s32)dirLookAt; - } - } - - if (__DVDLongFileNameFlag == 0) { - extention = FALSE; - illegal = FALSE; - - for (ptr = pathPtr; ((u8)*ptr != '\0') && ((u8)*ptr != '/'); ptr++) { - if ((u8)*ptr == '.') { - if ((ptr - pathPtr > 8) || (extention == TRUE)) { - illegal = TRUE; - break; - } - extention = TRUE; - extentionStart = ptr + 1; - - } else if ((u8)*ptr == ' ') - illegal = TRUE; - } - - if ((extention == TRUE) && (ptr - extentionStart > 3)) - illegal = TRUE; - - if (illegal) OSErrorLine(373, - "DVDConvertEntrynumToPath(possibly DVDOpen or DVDChangeDir or DVDOpenDir): " - "specified directory or file (%s) doesn't match standard 8.3 format. This is a " - "temporary restriction and will be removed soon\n", + "DVDConvertEntrynumToPath(possibly DVDOpen or DVDChangeDir or DVDOpenDir): specified directory or file " + "(%s) doesn't match standard 8.3 format. This is a temporary restriction and will be removed soon\n", origPathPtr); +#endif + } } else { - for (ptr = pathPtr; ((u8)*ptr != '\0') && ((u8)*ptr != '/'); ptr++) + for (ptr = pathPtr; (*ptr != '\0') && (*ptr != '/'); ptr++) ; } - isDir = ((u8)*ptr == '\0') ? FALSE : TRUE; + isDir = (*ptr == '\0') ? FALSE : TRUE; length = (u32)(ptr - pathPtr); ptr = pathPtr; @@ -265,7 +176,6 @@ s32 DVDConvertPathToEntrynum(const char* pathPtr) dirLookAt = i; pathPtr += length + 1; } -#endif } /** @@ -330,11 +240,7 @@ static u32 myStrncpy(char* dest, const char* src, u32 maxlen) { u32 i = maxlen; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) while ((i > 0) && (*src != 0)) { -#else - while ((i > 0) && ((u8)*src != 0)) { -#endif *dest++ = *src++; i--; } @@ -428,7 +334,7 @@ BOOL DVDChangeDir(const char* dirName) BOOL DVDReadAsyncPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, DVDCallback callback, s32 prio) { if (!((0 <= offset) && (offset < fileInfo->length))) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSErrorLine(739, "DVDReadAsync(): specified area is out of the file "); #else OSErrorLine(735, "DVDReadAsync(): specified area is out of the file "); @@ -436,7 +342,7 @@ BOOL DVDReadAsyncPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, } if (!((0 <= offset + length) && (offset + length < fileInfo->length + DVD_MIN_TRANSFER_SIZE))) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSErrorLine(745, "DVDReadAsync(): specified area is out of the file "); #else OSErrorLine(741, "DVDReadAsync(): specified area is out of the file "); @@ -474,7 +380,7 @@ s32 DVDReadPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, s32 p s32 retVal; if (!((0 <= offset) && (offset < fileInfo->length))) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSErrorLine(809, "DVDRead(): specified area is out of the file "); #else OSErrorLine(805, "DVDRead(): specified area is out of the file "); @@ -482,7 +388,7 @@ s32 DVDReadPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, s32 p } if (!((0 <= offset + length) && (offset + length < fileInfo->length + DVD_MIN_TRANSFER_SIZE))) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSErrorLine(815, "DVDRead(): specified area is out of the file "); #else OSErrorLine(811, "DVDRead(): specified area is out of the file "); @@ -583,29 +489,33 @@ s32 DVDGetFileInfoStatus(DVDFileInfo* fileInfo) /** * @TODO: Documentation - * @note UNUSED Size: 000084 + * @note UNUSED Size: 000084 (OS_BUILD_VERSION < 20011002L) (Matching by size) + * @note UNUSED Size: 0000c0 (OS_BUILD_VERSION >= 20011002L) (Matching by size) */ BOOL DVDOpenDir(const char* dirName, DVDDir* dir) { - // something is making this function in particular compile this warning string in demo, this probably isnt right but it gets the job - // done -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) - - long entry; + s32 entry; char currentDir[128]; entry = DVDConvertPathToEntrynum(dirName); - if (entry <= 0) - OSErrorLine(0x409, "Warning: DVDOpenDir(): file '%s' was not found under %s.\n", dirName, - (DVDGetCurrentDir(currentDir, 128), currentDir)); +#if OS_BUILD_VERSION >= 20011002L + if (entry < 0) { + DVDGetCurrentDir(currentDir, sizeof(currentDir)); + OSReport("Warning: DVDOpenDir(): file '%s' was not found under %s.\n", dirName, currentDir); + return FALSE; + } + if (!entryIsDir(entry)) { + return FALSE; + } +#else if (entry < 0 || !entryIsDir(entry)) { - return 0; + return FALSE; } +#endif dir->entryNum = entry; dir->location = entry + 1; dir->next = nextDir(entry); - return 1; -#endif + return TRUE; // UNUSED FUNCTION } @@ -649,7 +559,7 @@ BOOL DVDPrepareStreamAsync(DVDFileInfo* fileInfo, u32 length, u32 offset, DVDCal start = fileInfo->startAddr + offset; if (!Is32KBAligned(start)) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSErrorLine(1186, "DVDPrepareStreamAsync(): Specified start address (filestart(0x%x) + offset(0x%x)) is " "not 32KB aligned", @@ -666,7 +576,7 @@ BOOL DVDPrepareStreamAsync(DVDFileInfo* fileInfo, u32 length, u32 offset, DVDCal length = fileInfo->length - offset; if (!Is32KBAligned(length)) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSErrorLine(1196, "DVDPrepareStreamAsync(): Specified length (0x%x) is not a multiple of 32768(32*1024)", length); #else OSErrorLine(1160, "DVDPrepareStreamAsync(): Specified length (0x%x) is not a multiple of 32768(32*1024)", length); @@ -675,7 +585,7 @@ BOOL DVDPrepareStreamAsync(DVDFileInfo* fileInfo, u32 length, u32 offset, DVDCal if (!((offset < fileInfo->length) && (offset + length <= fileInfo->length))) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSErrorLine(1204, "DVDPrepareStreamAsync(): The area specified (offset(0x%x), length(0x%x)) is out of " "the file", diff --git a/src/dvd/fstload.c b/src/dvd/fstload.c index 6535808f..942ff6a8 100644 --- a/src/dvd/fstload.c +++ b/src/dvd/fstload.c @@ -16,8 +16,8 @@ static DVDDiskID* idTmp; // also pointer static u8 bb2Buf[0x3F]; struct blah { - s8 Gamecode[4]; - s8 Company[2]; + char Gamecode[4]; + char Company[2]; u8 DiskID; u8 Version; u8 Streaming; @@ -80,13 +80,8 @@ void __fstLoad(void) di->FSTMaxLength = bb2->maxLength; memcpy(di, idTmp, sizeof(DVDDiskID)); OSReport("\n"); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) OSReport(" Game Name ... %c%c%c%c\n", di->Gamecode[0], di->Gamecode[1], di->Gamecode[2], di->Gamecode[3]); OSReport(" Company ..... %c%c\n", di->Company[0], di->Company[1]); -#else - OSReport(" Game Name ... %c%c%c%c\n", (u8)di->Gamecode[0], (u8)di->Gamecode[1], (u8)di->Gamecode[2], (u8)di->Gamecode[3]); - OSReport(" Company ..... %c%c\n", (u8)di->Company[0], (u8)di->Company[1]); -#endif OSReport(" Disk # ...... %d\n", di->DiskID); OSReport(" Game ver .... %d\n", di->Version); if (di->Streaming == 0) { diff --git a/src/exi/EXIBios.c b/src/exi/EXIBios.c index 90945822..df06bfb9 100644 --- a/src/exi/EXIBios.c +++ b/src/exi/EXIBios.c @@ -3,7 +3,7 @@ #include // exi was added in PAL version -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L #define MAX_DEV 3 #define MAX_CHAN 3 diff --git a/src/gx/GXAttr.c b/src/gx/GXAttr.c index d716153b..289739b9 100644 --- a/src/gx/GXAttr.c +++ b/src/gx/GXAttr.c @@ -41,7 +41,7 @@ static void __GXXfVtxSpecs(void) nTex += GET_REG_FIELD(gx->vcdHi, 2, 14) ? 1 : 0; reg = (nCols) | (nNrm << 2) | (nTex << 4); GX_WRITE_XF_REG(8, reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = 1; #else gx->bpSent = 0; @@ -101,8 +101,9 @@ static inline void SETVCDATTR(GXAttr Attr, GXAttrType Type) SET_REG_FIELD(0xB1, gx->vcdLo, 2, 9, Type); break; } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) case GX_VA_NRM: + { +#if OS_BUILD_VERSION >= 20011002L if (Type != GX_NONE) { gx->hasNrms = 1; gx->hasBiNrms = 0; @@ -110,8 +111,17 @@ static inline void SETVCDATTR(GXAttr Attr, GXAttrType Type) } else { gx->hasNrms = 0; } +#else + gx->hasNrms = (Type != 0); + if (Type != GX_NONE) { + gx->nrmType = Type; + } +#endif break; + } case GX_VA_NBT: + { +#if OS_BUILD_VERSION >= 20011002L if (Type != GX_NONE) { gx->hasBiNrms = 1; gx->hasNrms = 0; @@ -119,25 +129,14 @@ static inline void SETVCDATTR(GXAttr Attr, GXAttrType Type) } else { gx->hasBiNrms = 0; } - break; #else - case GX_VA_NRM: - { - gx->hasNrms = (Type != 0); - if (Type != GX_NONE) { - gx->nrmType = Type; - } - break; - } - case GX_VA_NBT: - { gx->hasBiNrms = (Type != 0); if (Type != GX_NONE) { gx->nrmType = Type; } +#endif break; } -#endif case GX_VA_CLR0: { SET_REG_FIELD(0xBA, gx->vcdLo, 2, 13, Type); diff --git a/src/gx/GXBump.c b/src/gx/GXBump.c index c61c9454..eda49371 100644 --- a/src/gx/GXBump.c +++ b/src/gx/GXBump.c @@ -37,7 +37,7 @@ void GXSetTevIndirect(GXTevStageID tev_stage, GXIndTexStageID ind_stage, GXIndTe SET_REG_FIELD(0x89, reg, 1, 20, add_prev); SET_REG_FIELD(0x8A, reg, 8, 24, tev_stage + 16); GX_WRITE_SOME_REG5(0x61, reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -113,7 +113,7 @@ void GXSetIndTexMtx(GXIndTexMtxID mtx_id, const f32 offset[2][3], s8 scale_exp) SET_REG_FIELD(0xD2, reg, 8, 24, id * 3 + 8); GX_WRITE_SOME_REG5(0x61, reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -166,7 +166,7 @@ void GXSetIndTexCoordScale(GXIndTexStageID ind_state, GXIndTexScale scale_s, GXI break; } } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -217,7 +217,7 @@ void GXSetIndTexOrder(GXIndTexStageID ind_stage, GXTexCoordID tex_coord, GXTexMa } GX_WRITE_SOME_REG5(0x61, gx->iref); gx->dirtyState |= 3; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -460,7 +460,7 @@ void __GXUpdateBPMask(void) if ((u8)gx->bpMask != new_imask) { SET_REG_FIELD(0x26E, gx->bpMask, 8, 0, new_imask); GX_WRITE_SOME_REG5(0x61, gx->bpMask); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -475,7 +475,7 @@ void __GXFlushTextureState(void) { GX_WRITE_SOME_REG5(0x61, gx->bpMask); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; diff --git a/src/gx/GXDisplayList.c b/src/gx/GXDisplayList.c index cf1d3b74..c88d4b54 100644 --- a/src/gx/GXDisplayList.c +++ b/src/gx/GXDisplayList.c @@ -88,7 +88,7 @@ void GXCallDisplayList(void* list, u32 nbytes) __GXShadowDispList(list, nbytes); #endif -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (*(u32*)&gx->_00 == 0) { #else if (*(u32*)&gx->vNum != 0) { // checks both vNum and bpSent diff --git a/src/gx/GXFifo.c b/src/gx/GXFifo.c index 413a2ce9..f8a03c0e 100644 --- a/src/gx/GXFifo.c +++ b/src/gx/GXFifo.c @@ -3,7 +3,7 @@ #include "Dolphin/os.h" #include -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L static struct __GXFifoObj* CPUFifo; static struct __GXFifoObj* GPFifo; #endif @@ -17,7 +17,7 @@ static u32 __GXOverflowCount; static int IsWGPipeRedirected; #endif -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L #else static struct __GXFifoObj* GPFifo; static struct __GXFifoObj* CPUFifo; @@ -486,7 +486,7 @@ void __GXFifoInit(void) __OSUnmaskInterrupts(0x4000); __GXCurrentThread = OSGetCurrentThread(); GXOverflowSuspendInProgress = FALSE; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L CPUFifo = NULL; GPFifo = NULL; #endif diff --git a/src/gx/GXFrameBuf.c b/src/gx/GXFrameBuf.c index 3fadd37f..0f621f9f 100644 --- a/src/gx/GXFrameBuf.c +++ b/src/gx/GXFrameBuf.c @@ -1,341 +1,405 @@ #include "Dolphin/gx.h" -GXRenderModeObj GXNtsc240Ds = { 1, - 640, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; - -GXRenderModeObj GXNtsc240DsAa = { 1, - 640, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 0, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 0, 0, 21, 22, 21, 0, 0 } }; - -GXRenderModeObj GXNtsc240Int = { 0, - 640, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 1, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; - -GXRenderModeObj GXNtsc240IntAa = { 0, - 640, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 1, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 0, 0, 21, 22, 21, 0, 0 } }; - -GXRenderModeObj GXNtsc480IntDf = { 0, - 640, - 480, - 480, - 40, - 0, - 640, - 480, - 1, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 8, 8, 10, 12, 10, 8, 8 } }; - -GXRenderModeObj GXNtsc480Int = { 0, - 640, - 480, - 480, - 40, - 0, - 640, - 480, - 1, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; - -GXRenderModeObj GXNtsc480IntAa = { 0, - 640, - 242, - 480, - 40, - 0, - 640, - 480, - 1, - 0, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 4, 8, 12, 16, 12, 8, 4 } }; - -GXRenderModeObj GXNtsc480Prog = { 2, - 640, - 480, - 480, - 40, - 0, - 640, - 480, - 0, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; - -GXRenderModeObj GXNtsc480ProgAa = { 2, - 640, - 242, - 480, - 40, - 0, - 640, - 480, - 0, - 0, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 4, 8, 12, 16, 12, 8, 4 } }; - -GXRenderModeObj GXMpal240Ds = { 9, - 640, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXMpal240DsAa = { 9, - 640, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 0, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXMpal240Int = { 8, - 640, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 1, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXMpal240IntAa = { 8, - 640, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 1, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXMpal480IntDf = { 8, - 640, - 480, - 480, - 40, - 0, - 640, - 480, - 1, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 8, 8, 10, 12, 10, 8, 8 } }; -GXRenderModeObj GXMpal480Int = { 8, - 640, - 480, - 480, - 40, - 0, - 640, - 480, - 1, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXMpal480IntAa = { 8, - 640, - 242, - 480, - 40, - 0, - 640, - 480, - 1, - 0, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 4, 8, 12, 16, 12, 8, 4 } }; -GXRenderModeObj GXPal264Ds = { 5, - 640, - 264, - 264, - 40, - 23, - 640, - 528, - 0, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXPal264DsAa = { 5, - 640, - 264, - 264, - 40, - 23, - 640, - 528, - 0, - 0, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXPal264Int = { 4, - 640, - 264, - 264, - 40, - 23, - 640, - 528, - 0, - 1, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXPal264IntAa = { 4, - 640, - 264, - 264, - 40, - 23, - 640, - 528, - 0, - 1, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXPal528IntDf = { 4, - 640, - 528, - 528, - 40, - 23, - 640, - 528, - 1, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 8, 8, 10, 12, 10, 8, 8 } }; -GXRenderModeObj GXPal528Int = { 4, - 640, - 528, - 528, - 40, - 23, - 640, - 528, - 1, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; -GXRenderModeObj GXPal524IntAa = { 4, - 640, - 264, - 524, - 40, - 23, - 640, - 524, - 1, - 0, - 1, - { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, - { 4, 8, 12, 16, 12, 8, 4 } }; -GXRenderModeObj GXRmHW = { 1, - 320, - 240, - 240, - 40, - 0, - 640, - 480, - 0, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 21, 22, 21, 0, 0 } }; - -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) -GXRenderModeObj GXEurgb60Hz480IntDf = { 20, - 640, - 480, - 480, - 40, - 0, - 640, - 480, - 1, - 0, - 0, - { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, - { 8, 8, 10, 12, 10, 8, 8 } }; +GXRenderModeObj GXNtsc240Ds = { + 1, + 640, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXNtsc240DsAa = { + 1, + 640, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 0, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXNtsc240Int = { + 0, + 640, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 1, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXNtsc240IntAa = { + 0, + 640, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 1, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXNtsc480IntDf = { + 0, + 640, + 480, + 480, + 40, + 0, + 640, + 480, + 1, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 8, 8, 10, 12, 10, 8, 8 }, +}; + +GXRenderModeObj GXNtsc480Int = { + 0, + 640, + 480, + 480, + 40, + 0, + 640, + 480, + 1, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXNtsc480IntAa = { + 0, + 640, + 242, + 480, + 40, + 0, + 640, + 480, + 1, + 0, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 4, 8, 12, 16, 12, 8, 4 }, +}; + +GXRenderModeObj GXNtsc480Prog = { + 2, + 640, + 480, + 480, + 40, + 0, + 640, + 480, + 0, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXNtsc480ProgAa = { + 2, + 640, + 242, + 480, + 40, + 0, + 640, + 480, + 0, + 0, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 4, 8, 12, 16, 12, 8, 4 }, +}; + +GXRenderModeObj GXMpal240Ds = { + 9, + 640, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXMpal240DsAa = { + 9, + 640, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 0, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXMpal240Int = { + 8, + 640, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 1, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXMpal240IntAa = { + 8, + 640, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 1, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXMpal480IntDf = { + 8, + 640, + 480, + 480, + 40, + 0, + 640, + 480, + 1, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 8, 8, 10, 12, 10, 8, 8 }, +}; + +GXRenderModeObj GXMpal480Int = { + 8, + 640, + 480, + 480, + 40, + 0, + 640, + 480, + 1, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXMpal480IntAa = { + 8, + 640, + 242, + 480, + 40, + 0, + 640, + 480, + 1, + 0, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 4, 8, 12, 16, 12, 8, 4 }, +}; + +GXRenderModeObj GXPal264Ds = { + 5, + 640, + 264, + 264, + 40, + 23, + 640, + 528, + 0, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXPal264DsAa = { + 5, + 640, + 264, + 264, + 40, + 23, + 640, + 528, + 0, + 0, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXPal264Int = { + 4, + 640, + 264, + 264, + 40, + 23, + 640, + 528, + 0, + 1, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXPal264IntAa = { + 4, + 640, + 264, + 264, + 40, + 23, + 640, + 528, + 0, + 1, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXPal528IntDf = { + 4, + 640, + 528, + 528, + 40, + 23, + 640, + 528, + 1, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 8, 8, 10, 12, 10, 8, 8 }, +}; + +GXRenderModeObj GXPal528Int = { + 4, + 640, + 528, + 528, + 40, + 23, + 640, + 528, + 1, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +GXRenderModeObj GXPal524IntAa = { + 4, + 640, + 264, + 524, + 40, + 23, + 640, + 524, + 1, + 0, + 1, + { 3, 2, 9, 6, 3, 10, 3, 2, 9, 6, 3, 10, 9, 2, 3, 6, 9, 10, 9, 2, 3, 6, 9, 10 }, + { 4, 8, 12, 16, 12, 8, 4 }, +}; + +GXRenderModeObj GXRmHW = { + 1, + 320, + 240, + 240, + 40, + 0, + 640, + 480, + 0, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 0, 0, 21, 22, 21, 0, 0 }, +}; + +#if OS_BUILD_VERSION >= 20011217L +GXRenderModeObj GXEurgb60Hz480IntDf = { + 20, + 640, + 480, + 480, + 40, + 0, + 640, + 480, + 1, + 0, + 0, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 8, 8, 10, 12, 10, 8, 8 }, +}; #endif /** @@ -543,7 +607,7 @@ u32 GXSetDispCopyYScale(f32 vscale) OSAssertMsgLine(0x49D, vscale >= 1.0f, "GXSetDispCopyYScale: Vertical scale must be >= 1.0"); iScale = (u32)(256.0f / vscale) & 0x1FF; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L #else fScale = 256.0f / (f32)iScale; #endif @@ -553,7 +617,7 @@ u32 GXSetDispCopyYScale(f32 vscale) SET_REG_FIELD(0x4A6, reg, 9, 0, iScale); SET_REG_FIELD(0x4A7, reg, 8, 24, 0x4E); GX_WRITE_RAS_REG(reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -561,7 +625,7 @@ u32 GXSetDispCopyYScale(f32 vscale) SET_REG_FIELD(0x4AB, gx->cpDisp, 1, 10, enable); ht = (u32)GET_REG_FIELD(gx->cpDispSize, 10, 10) + 1; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L return __GXGetNumXfbLines(ht, iScale); #else return ht * fScale; @@ -594,7 +658,7 @@ void GXSetCopyClear(GXColor clear_clr, u32 clear_z) SET_REG_FIELD(0x4D5, reg, 24, 0, clear_z); SET_REG_FIELD(0x4D6, reg, 8, 24, 0x51); GX_WRITE_RAS_REG(reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -682,7 +746,7 @@ void GXSetCopyFilter(GXBool aa, const u8 sample_pattern[12][2], GXBool vf, const } GX_WRITE_RAS_REG(coeff0); GX_WRITE_RAS_REG(coeff1); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -791,7 +855,7 @@ void GXCopyDisp(void* dest, GXBool clear) if (changePeCtrl) { GX_WRITE_RAS_REG(gx->peCtrl); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -859,7 +923,7 @@ void GXCopyTex(void* dest, GXBool clear) if (changePeCtrl) { GX_WRITE_RAS_REG(gx->peCtrl); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -878,7 +942,7 @@ void GXClearBoundingBox(void) GX_WRITE_RAS_REG(reg); reg = 0x560003FF; GX_WRITE_RAS_REG(reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; diff --git a/src/gx/GXGeometry.c b/src/gx/GXGeometry.c index 650ebe71..c42a3614 100644 --- a/src/gx/GXGeometry.c +++ b/src/gx/GXGeometry.c @@ -41,7 +41,7 @@ void GXBegin(GXPrimitive type, GXVtxFmt vtxfmt, u16 nverts) } __GXinBegin = TRUE; #endif -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (*(u32*)&gx->_00 == 0) // checks both _00 and bpSent #else if (*(u32*)&gx->vNum != 0) // checks both vNum and bpSent @@ -66,7 +66,7 @@ void __GXSendFlushPrim(void) for (i = 0; i < numD; i += 4) { GX_WRITE_U32(0); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; @@ -82,7 +82,7 @@ void GXSetLineWidth(u8 width, GXTexOffset texOffsets) SET_REG_FIELD(0x1A9, gx->lpSize, 8, 0, width); SET_REG_FIELD(0x1AA, gx->lpSize, 3, 16, texOffsets); GX_WRITE_RAS_REG(gx->lpSize); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -110,7 +110,7 @@ void GXSetPointSize(u8 pointSize, GXTexOffset texOffsets) SET_REG_FIELD(0x1D5, gx->lpSize, 8, 8, pointSize); SET_REG_FIELD(0x1D6, gx->lpSize, 3, 19, texOffsets); GX_WRITE_RAS_REG(gx->lpSize); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -141,7 +141,7 @@ void GXEnableTexOffsets(GXTexCoordID coord, u8 line_enable, u8 point_enable) SET_REG_FIELD(0x205, gx->suTs0[coord], 1, 18, line_enable); SET_REG_FIELD(0x206, gx->suTs0[coord], 1, 19, point_enable); GX_WRITE_RAS_REG(gx->suTs0[coord]); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -225,7 +225,7 @@ void GXSetCoPlanar(GXBool enable) void __GXSetGenMode(void) { GX_WRITE_RAS_REG(gx->genMode); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; diff --git a/src/gx/GXInit.c b/src/gx/GXInit.c index 718b2c3a..91b1ee21 100644 --- a/src/gx/GXInit.c +++ b/src/gx/GXInit.c @@ -82,7 +82,7 @@ GXFifoObj FifoObj; */ GXFifoObj* GXInit(void* base, u32 size) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L #else GXRenderModeObj* rmode; Mtx identity_mtx; @@ -100,7 +100,7 @@ GXFifoObj* GXInit(void* base, u32 size) __GXinBegin = FALSE; #endif gx->tcsManEnab = FALSE; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L gx->tevTcEnab = GX_FALSE; #endif gx->vNum = 0; @@ -204,7 +204,7 @@ GXFifoObj* GXInit(void* base, u32 size) SET_REG_FIELD(0, reg, 8, 24, 0x58); GX_WRITE_RAS_REG(reg); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L for (i = 0; i < 8; i++) GXInitTexCacheRegion(&gx->TexRegions[i], 0, i * 0x8000, 0, 0x80000 + i * 0x8000, 0); for (i = 0; i < 4; i++) @@ -394,7 +394,7 @@ GXFifoObj* GXInit(void* base, u32 size) return &FifoObj; } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L void __GXInitGX() { GXRenderModeObj* rmode; @@ -415,7 +415,7 @@ void __GXInitGX() rmode = &GXPal528IntDf; break; } -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L case VI_EURGB60: { rmode = &GXEurgb60Hz480IntDf; @@ -447,7 +447,7 @@ void __GXInitGX() GXClearVtxDesc(); GXInvalidateVtxCache(); -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L for (i = GX_VA_POS; i <= GX_LIGHT_ARRAY; i++) { GXSetArray(i, gx, 0); } diff --git a/src/gx/GXLight.c b/src/gx/GXLight.c index 9a20b5b0..6763d612 100644 --- a/src/gx/GXLight.c +++ b/src/gx/GXLight.c @@ -474,7 +474,7 @@ void GXLoadLightObjImm(GXLightObj* lt_obj, GXLightID light) WRITE_SOME_LIGHT_REG2(obj->ldir[1], addr + 14); WRITE_SOME_LIGHT_REG2(obj->ldir[2], addr + 15); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; @@ -553,7 +553,7 @@ void GXLoadLightObjIndx(u32 lt_obj_indx, GXLightID light) __GXShadowIndexState(7, reg); #endif -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -633,7 +633,7 @@ void GXSetChanAmbColor(GXChannelID chan, GXColor amb_color) GX_WRITE_XF_REG(colIdx + 10, reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; @@ -713,7 +713,7 @@ void GXSetChanMatColor(GXChannelID chan, GXColor mat_color) } GX_WRITE_XF_REG(colIdx + 12, reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; @@ -771,7 +771,7 @@ void GXSetChanCtrl(GXChannelID chan, GXBool enable, GXColorSrc amb_src, GXColorS SET_REG_FIELD(0x310, reg, 1, 10, (attn_fn != 0)); GX_WRITE_XF_REG(idx + 14, reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; diff --git a/src/gx/GXMisc.c b/src/gx/GXMisc.c index 3e52fed4..2df7ac46 100644 --- a/src/gx/GXMisc.c +++ b/src/gx/GXMisc.c @@ -56,7 +56,7 @@ void GXFlush(void) if (gx->dirtyState) { __GXSetDirtyState(); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L for (i = 8; i > 0; i--) { GX_WRITE_U32(0); } @@ -191,7 +191,7 @@ void GXPixModeSync(void) { CHECK_GXBEGIN(550, "GXPixModeSync"); GX_WRITE_RAS_REG(gx->peCtrl); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; diff --git a/src/gx/GXPixel.c b/src/gx/GXPixel.c index 18155814..e5e5bd74 100644 --- a/src/gx/GXPixel.c +++ b/src/gx/GXPixel.c @@ -91,7 +91,7 @@ void GXSetFog(GXFogType type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor GX_WRITE_RAS_REG(fog2); GX_WRITE_RAS_REG(fog3); GX_WRITE_RAS_REG(fogclr); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -155,7 +155,7 @@ void GXSetFogRangeAdj(GXBool enable, u16 center, GXFogAdjTable* table) } } range_c = 0; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L SET_REG_FIELD(0x115, range_c, 10, 0, center + 342); #else SET_REG_FIELD(0x115, range_c, 10, 0, center + 340); @@ -163,7 +163,7 @@ void GXSetFogRangeAdj(GXBool enable, u16 center, GXFogAdjTable* table) SET_REG_FIELD(0x116, range_c, 1, 10, enable); SET_REG_FIELD(0x117, range_c, 8, 24, 0xE8); GX_WRITE_RAS_REG(range_c); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -185,7 +185,7 @@ void GXSetBlendMode(GXBlendMode type, GXBlendFactor src_factor, GXBlendFactor ds SET_REG_FIELD(0x13B, gx->cmode0, 3, 5, dst_factor); SET_REG_FIELD(0x13C, gx->cmode0, 8, 24, 0x41); GX_WRITE_RAS_REG(gx->cmode0); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -200,7 +200,7 @@ void GXSetColorUpdate(GXBool update_enable) CHECK_GXBEGIN(0x14F, "GXSetColorUpdate"); SET_REG_FIELD(0x150, gx->cmode0, 1, 3, update_enable); GX_WRITE_RAS_REG(gx->cmode0); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -215,7 +215,7 @@ void GXSetAlphaUpdate(GXBool update_enable) CHECK_GXBEGIN(0x158, "GXSetAlphaUpdate"); SET_REG_FIELD(0x159, gx->cmode0, 1, 4, update_enable); GX_WRITE_RAS_REG(gx->cmode0); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -232,7 +232,7 @@ void GXSetZMode(GXBool compare_enable, GXCompare func, GXBool update_enable) SET_REG_FIELD(0x172, gx->zmode, 3, 1, func); SET_REG_FIELD(0x173, gx->zmode, 1, 4, update_enable); GX_WRITE_RAS_REG(gx->zmode); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -247,7 +247,7 @@ void GXSetZCompLoc(GXBool before_tex) CHECK_GXBEGIN(0x17C, "GXSetZCompLoc"); SET_REG_FIELD(0x17D, gx->peCtrl, 1, 6, before_tex); GX_WRITE_RAS_REG(gx->peCtrl); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -282,7 +282,7 @@ void GXSetPixelFmt(GXPixelFmt pix_fmt, GXZFmt16 z_fmt) SET_REG_FIELD(0x1B9, gx->cmode1, 8, 24, 0x42); GX_WRITE_RAS_REG(gx->cmode1); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -297,7 +297,7 @@ void GXSetDither(GXBool dither) CHECK_GXBEGIN(0x1CD, "GXSetDither"); SET_REG_FIELD(0x1CE, gx->cmode0, 1, 2, dither); GX_WRITE_RAS_REG(gx->cmode0); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -313,7 +313,7 @@ void GXSetDstAlpha(GXBool enable, u8 alpha) SET_REG_FIELD(0x1E2, gx->cmode1, 8, 0, alpha); SET_REG_FIELD(0x1E3, gx->cmode1, 1, 8, enable); GX_WRITE_RAS_REG(gx->cmode1); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -333,7 +333,7 @@ void GXSetFieldMask(GXBool odd_mask, GXBool even_mask) SET_REG_FIELD(0x1FC, reg, 1, 1, odd_mask); SET_REG_FIELD(0x1FD, reg, 8, 24, 0x44); GX_WRITE_RAS_REG(reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; diff --git a/src/gx/GXTev.c b/src/gx/GXTev.c index be6a2b6b..88732b02 100644 --- a/src/gx/GXTev.c +++ b/src/gx/GXTev.c @@ -76,7 +76,7 @@ void GXSetTevColorIn(GXTevStageID stage, GXTevColorArg a, GXTevColorArg b, GXTev SET_REG_FIELD(0xF0, *pTevReg, 4, 0, d); GX_WRITE_RAS_REG(*pTevReg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -104,7 +104,7 @@ void GXSetTevAlphaIn(GXTevStageID stage, GXTevAlphaArg a, GXTevAlphaArg b, GXTev SET_REG_FIELD(0x113, *pTevReg, 3, 4, d); GX_WRITE_RAS_REG(*pTevReg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -134,7 +134,7 @@ void GXSetTevColorOp(GXTevStageID stage, GXTevOp op, GXTevBias bias, GXTevScale SET_REG_FIELD(0x141, *pTevReg, 2, 22, out_reg); GX_WRITE_RAS_REG(*pTevReg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -164,7 +164,7 @@ void GXSetTevAlphaOp(GXTevStageID stage, GXTevOp op, GXTevBias bias, GXTevScale SET_REG_FIELD(0x16D, *pTevReg, 2, 22, out_reg); GX_WRITE_RAS_REG(*pTevReg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -195,7 +195,7 @@ void GXSetTevColor(GXTevRegID id, GXColor color) GX_WRITE_RAS_REG(regBG); GX_WRITE_RAS_REG(regBG); GX_WRITE_RAS_REG(regBG); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -231,7 +231,7 @@ void GXSetTevColorS10(GXTevRegID id, GXColorS10 color) GX_WRITE_RAS_REG(regBG); GX_WRITE_RAS_REG(regBG); GX_WRITE_RAS_REG(regBG); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -262,7 +262,7 @@ void GXSetTevKColor(GXTevKColorID id, GXColor color) GX_WRITE_RAS_REG(regRA); GX_WRITE_RAS_REG(regBG); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -287,7 +287,7 @@ void GXSetTevKColorSel(GXTevStageID stage, GXTevKColorSel sel) } GX_WRITE_RAS_REG(*Kreg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -312,7 +312,7 @@ void GXSetTevKAlphaSel(GXTevStageID stage, GXTevKAlphaSel sel) } GX_WRITE_RAS_REG(*Kreg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -334,7 +334,7 @@ void GXSetTevSwapMode(GXTevStageID stage, GXTevSwapSel ras_sel, GXTevSwapSel tex SET_REG_FIELD(0x24F, *pTevReg, 2, 2, tex_sel); GX_WRITE_RAS_REG(*pTevReg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -370,7 +370,7 @@ void GXSetTevSwapModeTable(GXTevSwapSel table, GXTevColorChan red, GXTevColorCha SET_REG_FIELD(0x278, *Kreg, 2, 2, alpha); GX_WRITE_RAS_REG(*Kreg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -403,7 +403,7 @@ void GXSetAlphaCompare(GXCompare comp0, u8 ref0, GXAlphaOp op, GXCompare comp1, SET_REG_FIELD(0x2B9, reg, 8, 24, 0xF3); GX_WRITE_RAS_REG(reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -455,7 +455,7 @@ void GXSetZTexture(GXZTexOp op, GXTexFmt fmt, u32 bias) GX_WRITE_RAS_REG(zenv0); GX_WRITE_RAS_REG(zenv1); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -481,7 +481,7 @@ void GXSetTevOrder(GXTevStageID stage, GXTexCoordID coord, GXTexMapID map, GXCha tmap = map & ~0x100; tmap = (tmap >= GX_MAX_TEXMAP) ? GX_TEXMAP0 : tmap; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011217L if (coord >= GX_MAX_TEXCOORD) { tcoord = GX_TEXCOORD0; gx->tevTcEnab = gx->tevTcEnab & ~(1 << stage); @@ -506,7 +506,7 @@ void GXSetTevOrder(GXTevStageID stage, GXTexCoordID coord, GXTexMapID map, GXCha } GX_WRITE_RAS_REG(*ptref); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; diff --git a/src/gx/GXTexture.c b/src/gx/GXTexture.c index 61b8709a..3e37f06d 100644 --- a/src/gx/GXTexture.c +++ b/src/gx/GXTexture.c @@ -173,7 +173,7 @@ void GXInitTexObj(GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFm if (mipmap != 0) { u8 lmax; t->flags |= 1; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (format - 8 <= 2U) { t->mode0 = (t->mode0 & 0xFFFFFF1F) | 0xA0; } else { @@ -664,7 +664,7 @@ void GXLoadTexObjPreLoaded(GXTexObj* obj, GXTexRegion* region, GXTexMapID id) gx->tImage0[id] = t->image0; gx->tMode0[id] = t->mode0; gx->dirtyState |= 1; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -1318,7 +1318,7 @@ static void __SetSURegs(u32 tmap, u32 tcoord) SET_REG_FIELD(0x73D, gx->suTs1[tcoord], 1, 16, t_bias); GX_WRITE_RAS_REG(gx->suTs0[tcoord]); GX_WRITE_RAS_REG(gx->suTs1[tcoord]); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -1382,11 +1382,12 @@ void __GXSetSUTexRegs(void) } else { coord = GET_REG_FIELD(*ptref, 3, 3); } -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) - if ((tmap != 0xFF) && !(gx->tcsManEnab & (1 << coord)) && (gx->tevTcEnab & (1 << i))) { +#if OS_BUILD_VERSION >= 20011217L + if ((tmap != 0xFF) && !(gx->tcsManEnab & (1 << coord)) && (gx->tevTcEnab & (1 << i))) #else - if ((tmap != 0xFF) && !(gx->tcsManEnab & (1 << coord))) { + if ((tmap != 0xFF) && !(gx->tcsManEnab & (1 << coord))) #endif + { __SetSURegs(tmap, coord); } } @@ -1403,7 +1404,7 @@ void __GXGetSUTexSize(GXTexCoordID coord, u16* width, u16* height) *height = (u16)gx->suTs1[coord] + 1; } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L void __GXSetTmemConfig(u32 arg0) { switch (arg0) { diff --git a/src/gx/GXTransform.c b/src/gx/GXTransform.c index 8519d845..4d23d0b5 100644 --- a/src/gx/GXTransform.c +++ b/src/gx/GXTransform.c @@ -65,7 +65,7 @@ void GXSetProjection(const Mtx44 mtx, GXProjectionType type) GX_WRITE_XF_REG_F(36, gx->projMtx[4]); GX_WRITE_XF_REG_F(37, gx->projMtx[5]); GX_WRITE_XF_REG_2(38, gx->projType); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; @@ -456,7 +456,7 @@ void GXSetViewportJitter(f32 left, f32 top, f32 wd, f32 ht, f32 nearz, f32 farz, } sx = wd / 2.0f; sy = -ht / 2.0f; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L ox = 342.0f + (left + (wd / 2.0f)); oy = 342.0f + (top + (ht / 2.0f)); #else @@ -485,7 +485,7 @@ void GXSetViewportJitter(f32 left, f32 top, f32 wd, f32 ht, f32 nearz, f32 farz, GX_WRITE_F32(ox); GX_WRITE_F32(oy); GX_WRITE_F32(oz); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; @@ -533,7 +533,7 @@ void GXSetScissor(u32 left, u32 top, u32 wd, u32 ht) OSAssertMsgLine(0x3B7, left + wd < 1708, "GXSetScissor: right edge > 1708"); OSAssertMsgLine(0x3B8, top + ht < 1708, "GXSetScissor: bottom edge > 1708"); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L tp = top + 342; lf = left + 342; #else @@ -550,7 +550,7 @@ void GXSetScissor(u32 left, u32 top, u32 wd, u32 ht) GX_WRITE_RAS_REG(gx->suScis0); GX_WRITE_RAS_REG(gx->suScis1); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -595,7 +595,7 @@ void GXSetScissorBoxOffset(s32 x_off, s32 y_off) OSAssertMsgLine(0x3FE, (u32)(x_off + 340) < 2048, "GXSetScissorBoxOffset: x offset > 2048"); OSAssertMsgLine(0x400, (u32)(y_off + 340) < 2048, "GXSetScissorBoxOffset: y offset > 2048"); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L hx = (u32)(x_off + 342) >> 1; hy = (u32)(y_off + 342) >> 1; #else @@ -607,7 +607,7 @@ void GXSetScissorBoxOffset(s32 x_off, s32 y_off) SET_REG_FIELD(0x406, reg, 10, 10, hy); SET_REG_FIELD(0x407, reg, 8, 24, 0x59); GX_WRITE_RAS_REG(reg); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_FALSE; #else gx->bpSent = GX_TRUE; @@ -621,7 +621,7 @@ void GXSetClipMode(GXClipMode mode) { CHECK_GXBEGIN(0x41B, "GXSetClipMode"); GX_WRITE_XF_REG(5, mode); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; @@ -640,7 +640,7 @@ void __GXSetMatrixIndex(GXAttr matIdxAttr) GX_WRITE_SOME_REG4(8, 0x40, gx->matIdxB, -12); GX_WRITE_XF_REG(25, gx->matIdxB); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L gx->bpSent = GX_TRUE; #else gx->bpSent = GX_FALSE; diff --git a/src/hio/hio.c b/src/hio/hio.c index c7fb5bca..c8bea1bb 100644 --- a/src/hio/hio.c +++ b/src/hio/hio.c @@ -4,7 +4,7 @@ #include static s32 Chan = -1; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L static u32 Dev; #endif static HIOCallback ExiCallback; @@ -17,7 +17,7 @@ static HIOCallback RxCallback; static void ExtHandler(s32 chan, OSContext* context) { Chan = -1; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L Dev = 0; if ((chan < 2)) { EXISetExiCallback(chan, NULL); @@ -41,13 +41,13 @@ static void ExiHandler(s32 chan, OSContext* context) */ static void DbgHandler(__OSInterrupt interrupt, OSContext* context) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L OSContext exceptionContext; #endif __PIRegs[0] = 0x1000; if (ExiCallback) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L OSClearContext(&exceptionContext); OSSetCurrentContext(&exceptionContext); ExiCallback(); @@ -82,7 +82,7 @@ static void RxHandler(s32 chan, OSContext* context) */ BOOL HIOEnumDevices(HIOEnumCallback callback) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L s32 chan; u32 id; @@ -161,7 +161,7 @@ BOOL HIOInit(s32 chan, HIOCallback callback) if (__OSGetDIConfig() == 0xFF) { Chan = -1; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L Dev = 0; #endif return FALSE; @@ -175,41 +175,44 @@ BOOL HIOInit(s32 chan, HIOCallback callback) ExiCallback = callback; TxCallback = NULL; RxCallback = NULL; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (chan < 2 && Dev == 0) { +#if OS_BUILD_VERSION >= 20011112L + if (chan < 2 && Dev == 0) #else - if (chan < 2) { + if (chan < 2) #endif + { while (EXIProbeEx(Chan) == 0) { } if (EXIAttach(Chan, ExtHandler) == FALSE) { Chan = -1; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L Dev = 0; #endif return FALSE; } } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (EXILock(Chan, Dev, NULL) == FALSE) { +#if OS_BUILD_VERSION >= 20011112L + if (EXILock(Chan, Dev, NULL) == FALSE) #else - if (EXILock(Chan, 0, NULL) == FALSE) { + if (EXILock(Chan, 0, NULL) == FALSE) #endif + { EXIDetach(Chan); Chan = -1; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L Dev = 0; #endif return FALSE; } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (EXISelect(Chan, Dev, 0) == FALSE) { +#if OS_BUILD_VERSION >= 20011112L + if (EXISelect(Chan, Dev, 0) == FALSE) #else - if (EXISelect(Chan, 0, 0) == FALSE) { + if (EXISelect(Chan, 0, 0) == FALSE) #endif + { EXIUnlock(Chan); EXIDetach(Chan); Chan = -1; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L Dev = 0; #endif return FALSE; @@ -223,23 +226,24 @@ BOOL HIOInit(s32 chan, HIOCallback callback) err |= !EXIDeselect(Chan); EXIUnlock(Chan); if (err != 0 || id != 0x1010000) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (chan < 2 && Dev == 0) { +#if OS_BUILD_VERSION >= 20011112L + if (chan < 2 && Dev == 0) #else - if (chan < 2) { + if (chan < 2) #endif + { EXIDetach(Chan); } EXIUnlock(Chan); Chan = -1; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L Dev = 0; #endif return FALSE; } if (ExiCallback) { if (chan < 2) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L if (Dev == 0) { EXISetExiCallback(Chan, ExiHandler); } else { @@ -269,17 +273,21 @@ BOOL HIOReadMailbox(u32* word) return FALSE; } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (EXILock(Chan, Dev, NULL) == FALSE) { - return FALSE; - } - if (EXISelect(Chan, Dev, 4) == FALSE) { +#if OS_BUILD_VERSION >= 20011112L + if (EXILock(Chan, Dev, NULL) == FALSE) #else - if (EXILock(Chan, 0, NULL) == FALSE) { + if (EXILock(Chan, 0, NULL) == FALSE) +#endif + { return FALSE; } - if (EXISelect(Chan, 0, 4) == FALSE) { + +#if OS_BUILD_VERSION >= 20011112L + if (EXISelect(Chan, Dev, 4) == FALSE) +#else + if (EXISelect(Chan, 0, 4) == FALSE) #endif + { EXIUnlock(Chan); return FALSE; } @@ -306,17 +314,22 @@ BOOL HIOWriteMailbox(u32 word) if (Chan == -1 || __OSGetDIConfig() == 0xFF) { return FALSE; } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (EXILock(Chan, Dev, NULL) == FALSE) { - return FALSE; - } - if (EXISelect(Chan, Dev, 4) == FALSE) { + +#if OS_BUILD_VERSION >= 20011112L + if (EXILock(Chan, Dev, NULL) == FALSE) #else - if (EXILock(Chan, 0, NULL) == FALSE) { + if (EXILock(Chan, 0, NULL) == FALSE) +#endif + { return FALSE; } - if (EXISelect(Chan, 0, 4) == FALSE) { + +#if OS_BUILD_VERSION >= 20011112L + if (EXISelect(Chan, Dev, 4) == FALSE) +#else + if (EXISelect(Chan, 0, 4) == FALSE) #endif + { EXIUnlock(Chan); return FALSE; } @@ -350,20 +363,25 @@ BOOL HIOWrite(u32 addr, void* buffer, s32 size) return FALSE; } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (EXILock(Chan, Dev, NULL) == FALSE) { - return FALSE; - } - if (EXISelect(Chan, Dev, 4) == FALSE) { +#if OS_BUILD_VERSION >= 20011112L + if (EXILock(Chan, Dev, NULL) == FALSE) #else - if (EXILock(Chan, 0, NULL) == FALSE) { + if (EXILock(Chan, 0, NULL) == FALSE) +#endif + { return FALSE; } - if (EXISelect(Chan, 0, 4) == FALSE) { + +#if OS_BUILD_VERSION >= 20011112L + if (EXISelect(Chan, Dev, 4) == FALSE) +#else + if (EXISelect(Chan, 0, 4) == FALSE) #endif + { EXIUnlock(Chan); return FALSE; } + cmd = ((addr << 8) & 0x01FFFC00) | 0xA0000000; err = 0; err |= !EXIImm(Chan, &cmd, 4, 1, NULL); diff --git a/src/hvqm4dec/hvqm4dec.c b/src/hvqm4dec/hvqm4dec.c index 0358090d..76930dd5 100644 --- a/src/hvqm4dec/hvqm4dec.c +++ b/src/hvqm4dec/hvqm4dec.c @@ -174,10 +174,10 @@ static inline s16 getByte(BitBuffer* str) */ static s16 _readTree(Tree* const dst, BitBuffer* const str) { - int _FAKE[2]; // Doesn't exist, but used to match stack alignment int node; s16 no; s16 val; + STACK_PAD_VAR(2); // Doesn't exist, but used to match stack alignment if (getBit(str)) { // Branch node (0/1) diff --git a/src/jaudio/audiothread.c b/src/jaudio/audiothread.c index ab5a8a1b..edb60d06 100644 --- a/src/jaudio/audiothread.c +++ b/src/jaudio/audiothread.c @@ -75,7 +75,7 @@ static void DspSync() } } -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) /** * @TODO: Documentation */ @@ -175,7 +175,7 @@ static void* audioproc(void*) OSInitFastCast(); OSInitMessageQueue(&audioproc_mq, msgbuf, AUDIOPROC_MQ_BUF_COUNT); audioproc_mq_init = TRUE; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) ResetPlayerCallback(); Jac_Init(); Jac_InitSinTable(); @@ -186,7 +186,7 @@ static void* audioproc(void*) #endif DspbufProcess(DSPBUF_EVENT_INIT); CpubufProcess(DSPBUF_EVENT_INIT); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) DspBoot(DspSync2); DSP_InitBuffer(); #else diff --git a/src/jaudio/dsp_cardunlock.c b/src/jaudio/dsp_cardunlock.c index dfcac13c..8829a38e 100644 --- a/src/jaudio/dsp_cardunlock.c +++ b/src/jaudio/dsp_cardunlock.c @@ -154,16 +154,13 @@ int __CARDUnlock(int chan, u8 flashID[12]) if (ReadArrayUnlock(chan, data, rbuf, rlen, FALSE) < CARD_RESULT_READY) return CARD_RESULT_NOCARD; - // TODO: Pikmin uses `card->formatStep`, but every other - // decomp uses `card->scramble`. What's up with that? - u32 shift; u32 wk; shift = dummy * 8 + 1; wk = exnor_1st(data, shift); - card->formatStep = wk | (DATA_SCRAMBLE_R(wk) << 31 & 0x80000000); - card->formatStep = bitrev(card->formatStep); + card->scramble = wk | (DATA_SCRAMBLE_R(wk) << 31 & 0x80000000); + card->scramble = bitrev(card->scramble); data = 0; dummy = DummyLen(); @@ -176,35 +173,35 @@ int __CARDUnlock(int chan, u8 flashID[12]) Ans1 = *(u32*)(rbuf + 8); u32 para2A = *(u32*)(rbuf + 12); u32 para2B = *(u32*)(rbuf + 16); - para1A ^= card->formatStep; + para1A ^= card->scramble; shift = 32; - wk = exnor(card->formatStep, shift); - card->formatStep = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); - para1B ^= card->formatStep; + wk = exnor(card->scramble, shift); + card->scramble = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); + para1B ^= card->scramble; shift = 32; - wk = exnor(card->formatStep, shift); - card->formatStep = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); - Ans1 ^= card->formatStep; + wk = exnor(card->scramble, shift); + card->scramble = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); + Ans1 ^= card->scramble; shift = 32; - wk = exnor(card->formatStep, shift); - card->formatStep = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); - para2A ^= card->formatStep; + wk = exnor(card->scramble, shift); + card->scramble = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); + para2A ^= card->scramble; shift = 32; - wk = exnor(card->formatStep, shift); - card->formatStep = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); - para2B ^= card->formatStep; + wk = exnor(card->scramble, shift); + card->scramble = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); + para2B ^= card->scramble; shift = dummy * 8; - wk = exnor(card->formatStep, shift); - card->formatStep = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); + wk = exnor(card->scramble, shift); + card->scramble = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); shift = 32 + 1; - wk = exnor(card->formatStep, shift); - card->formatStep = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); + wk = exnor(card->scramble, shift); + card->scramble = wk | (DATA_SCRAMBLE_L(wk) >> 31 & 0x00000001); *(u32*)(input + 0) = para2A; *(u32*)(input + 4) = para2B; @@ -263,16 +260,13 @@ static void DoneCallback(void* dspTask) u8* output = input + 32; Ans2 = *(u32*)output; - // TODO: Pikmin uses `card->formatStep`, but every other - // decomp uses `card->scramble`. What's up with that? - s32 dummy; s32 rlen; u32 data; dummy = DummyLen(); rlen = dummy; - data = (Ans2 ^ card->formatStep) & 0xffff0000; + data = (Ans2 ^ card->scramble) & 0xffff0000; if (ReadArrayUnlock(chan, data, rbuf, rlen, TRUE) < CARD_RESULT_READY) { EXIUnlock(chan); __CARDMountCallback(chan, CARD_RESULT_NOCARD); @@ -283,12 +277,12 @@ static void DoneCallback(void* dspTask) u32 wk, wk1; shift = (rlen + 4 + card->latency) * 8 + 1; - wk = exnor(card->formatStep, shift); - card->formatStep = wk | ((DATA_SCRAMBLE_L(wk) >> 31) & 0x00000001); + wk = exnor(card->scramble, shift); + card->scramble = wk | ((DATA_SCRAMBLE_L(wk) >> 31) & 0x00000001); dummy = DummyLen(); rlen = dummy; - data = ((Ans2 << 16) ^ card->formatStep) & 0xffff0000; + data = ((Ans2 << 16) ^ card->scramble) & 0xffff0000; if (ReadArrayUnlock(chan, data, rbuf, rlen, TRUE) < CARD_RESULT_READY) { EXIUnlock(chan); __CARDMountCallback(chan, CARD_RESULT_NOCARD); diff --git a/src/jaudio/dspboot.c b/src/jaudio/dspboot.c index 314a9d4d..2e64a18f 100644 --- a/src/jaudio/dspboot.c +++ b/src/jaudio/dspboot.c @@ -7,7 +7,7 @@ // Fun Fact: Prior to Dolphin Emulator 5.0-16483, USA Demo's early DSP microcode required DSP LLE to run. // This wasn't because it was difficult to support or anything, it was just so obscure that nobody thought to add it yet. // https://dolphin-emu.org/download/dev/8b3517a9f943b7379805a5a6a5a4d77c60d366f9/ -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) // for PAL, this data is contained in dsptask.c #else u16 jdsp[] ATTRIBUTE_ALIGN(32) = { diff --git a/src/jaudio/dspbuf.c b/src/jaudio/dspbuf.c index edc32fe8..afd9f6ad 100644 --- a/src/jaudio/dspbuf.c +++ b/src/jaudio/dspbuf.c @@ -53,7 +53,7 @@ s16* DspbufProcess(DSPBUF_EVENTS event) } case DSPBUF_EVENT_FRAME_END: { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) #else DspExtraTaskCheck(); #endif @@ -69,7 +69,7 @@ s16* DspbufProcess(DSPBUF_EVENTS event) write_buffer = write; DspSyncCountClear(JAC_SUBFRAMES); Probe_Start(7, "DSP-MAIN"); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) DsyncFrame2(JAC_SUBFRAMES, (u32)dsp_buf[write_buffer], (u32)&dsp_buf[write_buffer][JAC_FRAMESAMPLES]); #else DsyncFrame(JAC_SUBFRAMES, (u32)dsp_buf[write_buffer], (u32)&dsp_buf[write_buffer][JAC_FRAMESAMPLES]); diff --git a/src/jaudio/dspinterface.c b/src/jaudio/dspinterface.c index 624b924d..061ff20b 100644 --- a/src/jaudio/dspinterface.c +++ b/src/jaudio/dspinterface.c @@ -369,13 +369,12 @@ void DSP_ClearBuffer() } } -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) /** * @TODO: Documentation */ -void DSP_CreateMap() +u64 DSP_CreateMap() { - // This is accomplishing nothing... u64 map = 0; for (u32 i = 0; i < 64; i++) { map <<= 1; @@ -383,7 +382,7 @@ void DSP_CreateMap() map |= 1; } } - // UNUSED FUNCTION + return map; } #endif diff --git a/src/jaudio/dspproc.c b/src/jaudio/dspproc.c index 279f6edc..718e47bb 100644 --- a/src/jaudio/dspproc.c +++ b/src/jaudio/dspproc.c @@ -1,10 +1,11 @@ #include "jaudio/dspproc.h" #include "Dolphin/dsp.h" #include "Dolphin/os.h" +#include "jaudio/dspinterface.h" #include static u16 DSP_MIXERLEVEL = 0x4000; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) volatile static int flag; #endif @@ -46,7 +47,7 @@ s32 DSPSendCommands(u32* commands, u32 count) */ u32 DSPReleaseHalt() { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) u32 bit[4]; u64 map = DSP_CreateMap(); bit[0] = map >> 32; @@ -64,7 +65,7 @@ u32 DSPReleaseHalt() #endif } -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) static void setup_callback(u16 a) { flag = 0; @@ -249,7 +250,7 @@ void DsetupTable(u32 cmd1, u32 cmd2, u32 cmd3, u32 cmd4, u32 cmd5) commands[3] = cmd4; commands[4] = cmd5; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) flag = 1; DSPSendCommands2(commands, ARRAY_SIZE(commands), setup_callback); while (flag != 0) { } @@ -280,8 +281,8 @@ void DsyncFrame(u32 subframes, u32 dspbufStart, u32 dspbufEnd) commands[1] = dspbufStart; commands[2] = dspbufEnd; -#if defined(VERSION_GPIP01_00) - u32 stack; +#if defined(VERSION_GPIP01) + STACK_PAD_VAR(1); DSPSendCommands2(commands, ARRAY_SIZE(commands), NULL); #else DSPSendCommands(commands, ARRAY_SIZE(commands)); diff --git a/src/jaudio/dsptask.c b/src/jaudio/dsptask.c index de809b07..540ce689 100644 --- a/src/jaudio/dsptask.c +++ b/src/jaudio/dsptask.c @@ -4,7 +4,7 @@ #include "jaudio/dspboot.h" #include -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) static DSPTaskInfo audio_task; static u32 AUDIO_YIELD_BUFFER[0x800] ATTRIBUTE_ALIGN(32); diff --git a/src/jaudio/dvdthread.c b/src/jaudio/dvdthread.c index ea1558a1..fdc4bef9 100644 --- a/src/jaudio/dvdthread.c +++ b/src/jaudio/dvdthread.c @@ -212,21 +212,16 @@ s32 DVDT_LoadtoDRAM_Main(void* dvdCall) s32 readStatus = 0; DVDCall* call = (DVDCall*)dvdCall; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) static DVDFileInfo finfo; - if (Jac_DVDOpen(call->fileName, &finfo) == FALSE) { #else - DVDFileInfo info; - if (Jac_DVDOpen(call->fileName, &info) == FALSE) { + DVDFileInfo finfo; #endif + if (Jac_DVDOpen(call->fileName, &finfo) == FALSE) { __DoError(call, 0); return -1; } -#if defined(VERSION_GPIP01_00) u32 infoLength = finfo.length; -#else - u32 infoLength = info.length; -#endif if (infoLength == 0) { __DoError(call, 1); return -1; @@ -241,13 +236,8 @@ s32 DVDT_LoadtoDRAM_Main(void* dvdCall) } DCInvalidateRange((void*)call->dst, call->length); -#if defined(VERSION_GPIP01_00) readStatus |= DVDReadMutex(&finfo, (void*)call->dst, call->length, call->src, call->fileName); DVDClose(&finfo); -#else - readStatus |= DVDReadMutex(&info, (void*)call->dst, call->length, call->src, call->fileName); - DVDClose(&info); -#endif __DoFinish(call, readStatus); return 0; } diff --git a/src/jaudio/osdsp.c b/src/jaudio/osdsp.c index 71ec64c1..89e5ded0 100644 --- a/src/jaudio/osdsp.c +++ b/src/jaudio/osdsp.c @@ -2,7 +2,7 @@ #include "Dolphin/os.h" #include -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) DSPTaskInfo* __DSP_tmp_task; diff --git a/src/jaudio/osdsp_task.c b/src/jaudio/osdsp_task.c index 70bb0dad..74174441 100644 --- a/src/jaudio/osdsp_task.c +++ b/src/jaudio/osdsp_task.c @@ -1,8 +1,9 @@ #include "Dolphin/dsp.h" #include "Dolphin/os.h" #include "jaudio/dspproc.h" +#include "jaudio/dummyprobe.h" -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) static vu8 DSP_prior_yield; static int AUDIO_UPDATE_REQUEST; @@ -10,10 +11,7 @@ static u32 sync_stack[3]; static void Dsp_Update_Request(); -#ifdef __cplusplus -extern "C" { -void Console_printf(char*, ...); -#endif // ifdef __cplusplus +BEGIN_SCOPE_EXTERN_C /** * @TODO: Documentation @@ -21,7 +19,7 @@ void Console_printf(char*, ...); void __DSPHandler(__OSInterrupt interrupt, OSContext* context) { OSContext funcContext; - int stack[3]; + STACK_PAD_VAR(3); __DSPRegs[5] = ((u16)(__DSPRegs[5]) & ~0x28) | 0x80; diff --git a/src/jaudio/piki_bgm.c b/src/jaudio/piki_bgm.c index 1051f4e3..9b26b51c 100644 --- a/src/jaudio/piki_bgm.c +++ b/src/jaudio/piki_bgm.c @@ -272,14 +272,14 @@ void Jac_PlayBgm(u32 trackNo, u32 bgmID) bgm[trackNo].songId = bgmID - 2; bgm[trackNo].trackHandle = trackNo + 3; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) call_counter = 6000; #endif Jac_SetBgmModeFlag(trackNo, 2, 0); Jac_SetBgmModeFlag(trackNo, 1, 0); Jac_SetBgmModeFlag(trackNo, 4, 0); Jac_SetBgmModeFlag(trackNo, 8, 0); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) call_counter = 0; #endif Jaf_ReadySeq(trackNo + 3, bgmID); @@ -335,8 +335,8 @@ BOOL Jac_ChangeBgmMode(u32 trackNo, u8 mode) */ void Jac_SetBgmModeFlag(u32 trackNo, u8 flag, u8 doSet) { -#if defined(VERSION_GPIP01_00) - int stack[2]; +#if defined(VERSION_GPIP01) + STACK_PAD_VAR(2); if (call_counter < 6000 && Jac_GetCurrentScene() == SCENE_Course && flag != 8 && flag != 4) { return; } diff --git a/src/jaudio/piki_scene.c b/src/jaudio/piki_scene.c index 21e2c8dd..c5726f5c 100644 --- a/src/jaudio/piki_scene.c +++ b/src/jaudio/piki_scene.c @@ -250,7 +250,7 @@ void Jac_SceneSetup(u32 sceneID, u32 stage) case BGM_SysEvent: { bgm2 = tbl_stage_to_bgm[stage]; - if (stage) { + if (stage != STAGE_Practice) { closeScene = TRUE; } Jam_PauseTrack(Jam_GetTrackHandle(0x20000), 1); diff --git a/src/jaudio/pikiseq.c b/src/jaudio/pikiseq.c index 435a5ff4..7028e9ef 100644 --- a/src/jaudio/pikiseq.c +++ b/src/jaudio/pikiseq.c @@ -59,7 +59,7 @@ u8 HEAD_pikiseq[] ATTRIBUTE_ALIGN(32) = { 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xD9, 0x80, 0x00, 0x00, 0x23, 0x00, 0x6D, 0x61, 0x70, 0x2E, 0x6A, 0x61, 0x6D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFC, 0x80, 0x00, 0x00, 0x30, 0x20, 0x64, 0x65, 0x6D, 0x6F, 0x62, 0x67, 0x6D, 0x2E, 0x6A, 0x61, 0x6D, 0x00, 0x00, 0x00, -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x2C, 0xA0, 0x00, 0x00, 0x77, 0xC0, 0x64, 0x75, 0x6D, 0x6D, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x75, 0x6D, 0x6D, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/src/mtx/mtx.c b/src/mtx/mtx.c index 62006fb0..f33b96fb 100644 --- a/src/mtx/mtx.c +++ b/src/mtx/mtx.c @@ -366,13 +366,13 @@ ASM u32 PSMTXInverse(register const Mtx src, register Mtx inv) { blr _regular: -#if defined(BUILD_MATCHING) && (defined(VERSION_GPIJ01) || defined(VERSION_GPIE01)) +#if OS_BUILD_VERSION >= 20011002L + fres fp0, fp7 +#else ps_res fp0, fp7 ps_add fp6, fp0, fp0 ps_mul fp5, fp0, fp0 ps_nmsub fp0, fp7, fp5, fp6 -#else // VERSION_PIKIDEMO, VERSION_GPIP01, Non-Matching builds - fres fp0, fp7 #endif ps_add fp6, fp0, fp0 ps_mul fp5, fp0, fp0 @@ -497,9 +497,9 @@ ASM u32 PSMTXInvXpose(register const Mtx src, register Mtx inv) blr _regular: -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01) +#if OS_BUILD_VERSION >= 20011002L fres fp0, fp7 -#else// VERSION_PIKIDEMO, VERSION_GPIP01, Non-Matching builds +#else ps_res f0, f7 ps_add f6, f0, f0 ps_mul f5, f0, f0 diff --git a/src/os/OS.c b/src/os/OS.c index b3d217a8..ea42c852 100644 --- a/src/os/OS.c +++ b/src/os/OS.c @@ -134,7 +134,7 @@ u32 OSGetConsoleType(void) return BootInfo->consoleType; } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L extern void* BOOT_REGION_START AT_ADDRESS(0x812FDFF0); //(*(void *)0x812fdff0) extern void* BOOT_REGION_END AT_ADDRESS(0x812FDFEC); //(*(void *)0x812fdfec) @@ -186,7 +186,7 @@ void OSInit(void) AreWeInitialized = TRUE; // flag to make sure we don't have to do this again // SYSTEM // -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L __OSStartTime = __OSGetSystemTime(); #endif @@ -203,7 +203,7 @@ void OSInit(void) // the address for where the BI2 debug info is, is stored at OS_BI2_DEBUG_ADDRESS DebugInfo = (BI2Debug*)*((u32*)OS_BI2_DEBUG_ADDRESS); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L // if the debug info address exists, grab some debug info if (DebugInfo != NULL) { BI2DebugFlag = &DebugInfo->debugFlag; // debug flag from DVD BI2 @@ -245,7 +245,7 @@ void OSInit(void) // initialise a whole bunch of OS stuff OSExceptionInit(); __OSInitSystemCall(); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSInitAlarm(); #endif __OSModuleInit(); @@ -258,7 +258,7 @@ void OSInit(void) __OSInitSram(); __OSThreadInit(); __OSInitAudioSystem(); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L PPCMthid2(PPCMfhid2() & 0xBFFFFFFF); #endif if ((BootInfo->consoleType & OS_CONSOLE_DEVELOPMENT) != 0) { @@ -267,27 +267,15 @@ void OSInit(void) BootInfo->consoleType = OS_CONSOLE_RETAIL1; } BootInfo->consoleType += (__PIRegs[11] & 0xF0000000) >> 28; -#if defined(VERSION_GPIP01_00) || defined(VERSION_G98P01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L +#if OS_BUILD_VERSION >= 20011217L if (__OSInIPL == FALSE) +#endif __OSInitMemoryProtection(); - // begin OS reporting - OSReport("\nDolphin OS $Revision: 49 $.\n"); - OSReport("Kernel built : %s %s\n", "Dec 17 2001", "18:46:45"); -#elif defined(VERSION_DPIJ01_PIKIDEMO) - __OSInitMemoryProtection(); - // begin OS reporting - OSReport("\nDolphin OS $Revision: 47 $.\n"); - OSReport("Kernel built : %s %s\n", "Oct 2 2001", "11:02:22"); -#elif defined(VERSION_G98E01_PIKIDEMO) - __OSInitMemoryProtection(); - // begin OS reporting - OSReport("\nDolphin OS $Revision: 47 $.\n"); - OSReport("Kernel built : %s %s\n", "Nov 12 2001", "01:46:17"); -#else - // begin OS reporting - OSReport("\nDolphin OS $Revision: 37 $.\n"); - OSReport("Kernel built : %s %s\n", "Jul 19 2001", "05:43:42"); #endif + // begin OS reporting + OSReport("\nDolphin OS $Revision: " TO_STRING(OS_BUILD_REVISION) " $.\n"); + OSReport("Kernel built : %s %s\n", OS_BUILD_DATE, OS_BUILD_TIME); OSReport("Console Type : "); if (BootInfo == NULL || (inputConsoleType = BootInfo->consoleType) == 0) { inputConsoleType = OS_CONSOLE_ARTHUR; // default console type @@ -343,7 +331,7 @@ void OSInit(void) } // free up memory and re-enable things -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L ClearArena(); #endif OSEnableInterrupts(); diff --git a/src/os/OSAlarm.c b/src/os/OSAlarm.c index 24fbc6a6..d54562ab 100644 --- a/src/os/OSAlarm.c +++ b/src/os/OSAlarm.c @@ -24,7 +24,7 @@ static void SetTimer(OSAlarm* alarm) { OSTime delta; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L delta = alarm->fire - __OSGetSystemTime(); #else delta = alarm->fire - OSGetTime(); @@ -68,7 +68,7 @@ static void InsertAlarm(OSAlarm* alarm, OSTime fire, OSAlarmHandler handler) OSAlarm* prev; if (alarm->period > 0) { -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSTime time = __OSGetSystemTime(); #else OSTime time = OSGetTime(); @@ -120,7 +120,7 @@ void OSSetAlarm(OSAlarm* alarm, OSTime tick, OSAlarmHandler handler) BOOL enabled; enabled = OSDisableInterrupts(); alarm->period = 0; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L InsertAlarm(alarm, __OSGetSystemTime() + tick, handler); #else InsertAlarm(alarm, OSGetTime() + tick, handler); @@ -194,7 +194,7 @@ static void DecrementerExceptionCallback(__OSException exception, OSContext* con OSAlarmHandler handler; OSTime time; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSContext exceptionContext; time = __OSGetSystemTime(); #else @@ -229,12 +229,12 @@ static void DecrementerExceptionCallback(__OSException exception, OSContext* con } OSDisableScheduler(); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSClearContext(&exceptionContext); OSSetCurrentContext(&exceptionContext); #endif handler(alarm, context); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L OSClearContext(&exceptionContext); OSSetCurrentContext(context); #endif diff --git a/src/os/OSAudioSystem.c b/src/os/OSAudioSystem.c index 065bc212..072eb8d7 100644 --- a/src/os/OSAudioSystem.c +++ b/src/os/OSAudioSystem.c @@ -2,7 +2,7 @@ #include "types.h" #include -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L static u8 DSPInitCode[] = { 0x02, 0x9F, 0x00, 0x10, 0x02, 0x9F, 0x00, 0x33, 0x02, 0x9F, 0x00, 0x34, 0x02, 0x9F, 0x00, 0x35, 0x02, 0x9F, 0x00, 0x36, 0x02, 0x9F, 0x00, 0x37, 0x02, 0x9F, 0x00, 0x38, 0x02, 0x9F, 0x00, 0x39, 0x12, 0x06, 0x12, 0x03, 0x12, 0x04, 0x12, 0x05, 0x00, 0x80, 0x80, 0x00, @@ -31,9 +31,9 @@ void __OSInitAudioSystem(void) { u32 r28; u16 r3; + STACK_PAD_VAR(1); - u32 padding; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L memcpy((void*)((u8*)OSGetArenaHi() - 128), __DSPWorkBuffer, 128); #endif memcpy(__DSPWorkBuffer, (void*)DSPInitCode, 128); @@ -88,7 +88,7 @@ void __OSInitAudioSystem(void) __DSPRegs[5] |= 1; while (__DSPRegs[5] & 1) ; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L memcpy(__DSPWorkBuffer, (void*)((u8*)OSGetArenaHi() - 128), 128); #endif } diff --git a/src/os/OSError.c b/src/os/OSError.c index 24a6a349..9fb1be89 100644 --- a/src/os/OSError.c +++ b/src/os/OSError.c @@ -2,6 +2,7 @@ #include "Dolphin/OS/OSException.h" #include "Dolphin/OS/OSInterrupt.h" +#include "Dolphin/OS/OSVersion.h" #include "Dolphin/PPCArch.h" #include "Dolphin/hw_regs.h" @@ -9,8 +10,10 @@ #include #include -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L OSErrorHandler __OSErrorTable[OS_ERROR_MAX]; +// For ease of implementing revisional differences. +#define OSErrorTable __OSErrorTable #else static OSErrorHandler OSErrorTable[OS_ERROR_MAX]; #endif @@ -58,15 +61,9 @@ void OSPanic(const char* file, int line, const char* msg, ...) */ OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - OSErrorHandler prevHandler = __OSErrorTable[error]; - - __OSErrorTable[error] = handler; -#else OSErrorHandler prevHandler = OSErrorTable[error]; OSErrorTable[error] = handler; -#endif return prevHandler; } @@ -75,15 +72,18 @@ OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler) */ void __OSUnhandledException(__OSException exception, OSContext* context, u32 dsisr, u32 dar) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) if (!(context->srr1 & MSR_RI)) { OSReport("Non-recoverable Exception %d", exception); } else { - if (__OSErrorTable[exception]) { + if (OSErrorTable[exception] != NULL) { +#if OS_BUILD_VERSION >= 20011112L OSDisableScheduler(); - __OSErrorTable[exception](exception, context, dsisr, dar); +#endif + OSErrorTable[exception](exception, context, dsisr, dar); +#if OS_BUILD_VERSION >= 20011112L OSEnableScheduler(); __OSReschedule(); +#endif OSLoadContext(context); } @@ -96,30 +96,35 @@ void __OSUnhandledException(__OSException exception, OSContext* context, u32 dsi OSReport("\n"); OSDumpContext(context); +#if OS_BUILD_VERSION >= 20011112L OSReport("\nDSISR = 0x%08x DAR = 0x%08x\n", dsisr, dar); OSReport("TB = 0x%016llx\n", OSGetTime()); +#else + OSReport("\nDSISR= 0x%08x DAR = 0x%08x\n", dsisr, dar); +#endif switch (exception) { - case __OS_EXCEPTION_DSI: + case OS_ERROR_DSI: { OSReport("\nInstruction at 0x%x (read from SRR0) attempted to access invalid address 0x%x (read from DAR)\n", context->srr0, dar); break; } - case __OS_EXCEPTION_ISI: + case OS_ERROR_ISI: { OSReport("\nAttempted to fetch instruction from invalid address 0x%x (read from SRR0)\n", context->srr0); break; } - case __OS_EXCEPTION_ALIGNMENT: + case OS_ERROR_ALIGNMENT: { OSReport("\nInstruction at 0x%x (read from SRR0) attempted to access unaligned address 0x%x (read from DAR)\n", context->srr0, dar); break; } - case __OS_EXCEPTION_PROGRAM: + case OS_ERROR_PROGRAM: { OSReport("\nProgram exception : Possible illegal instruction/operation at or around 0x%x (read from SRR0)\n", context->srr0, dar); break; } +#if OS_BUILD_VERSION >= 20011112L case OS_ERROR_PROTECTION: { OSReport("\n"); @@ -128,47 +133,12 @@ void __OSUnhandledException(__OSException exception, OSContext* context, u32 dsi OSReport("DI DMA Address = 0x%08x\n", __DIRegs[0x00000005]); break; } +#endif } +#if OS_BUILD_VERSION >= 20011112L OSReport("\nLast interrupt (%d): SRR0 = 0x%08x TB = 0x%016llx\n", __OSLastInterrupt, __OSLastInterruptSrr0, __OSLastInterruptTime); -#else - if (!(context->srr1 & (1 << 1))) - OSReport("Non-recoverable Exception %d", exception); - else { - if (OSErrorTable[exception] != NULL) { - OSErrorTable[exception](exception, context, dsisr, dar); - OSLoadContext(context); - } - if (exception == OS_ERROR_DECREMENTER) - OSLoadContext(context); - OSReport("Unhandled Exception %d", exception); - } - - OSReport("\n"); - OSDumpContext(context); - OSReport("\nDSISR= 0x%08x DAR = 0x%08x\n", dsisr, dar); - switch (exception) { - case OS_ERROR_DSI: - { - OSReport("\nInstruction at 0x%x (read from SRR0) attempted to access invalid address 0x%x (read from DAR)\n", context->srr0, dar); - break; - } - case OS_ERROR_ISI: - { - OSReport("\nAttempted to fetch instruction from invalid address 0x%x (read from SRR0)\n", context->srr0); - break; - } - case OS_ERROR_ALIGNMENT: - { - OSReport("\nInstruction at 0x%x (read from SRR0) attempted to access unaligned address 0x%x (read from DAR)\n", context->srr0, dar); - break; - } - case OS_ERROR_PROGRAM: - { - OSReport("\nProgram exception : Possible illegal instruction/operation at or around 0x%x (read from SRR0)\n", context->srr0, dar); - break; - } - } #endif + PPCHalt(); } diff --git a/src/os/OSExi.c b/src/os/OSExi.c index 7c15a659..e7c03218 100644 --- a/src/os/OSExi.c +++ b/src/os/OSExi.c @@ -2,716 +2,21 @@ #include #include -// This OS file in particular is really fussy, so I'm just seperating the whole thing for v37 (USA) and v47 (USA Demo) -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) -typedef void (*EXICallback)(s32, OSContext*); +// These formerly public interface functions got renamed when they became private implementation details. +// This preprocessor block handles two issues stemming from that. If `OS_BUILD_VERSION >= 20011112L`, it +// makes the functions static. If not, then it silently renames the functions for matching using macros. +#if OS_BUILD_VERSION >= 20011112L +static BOOL __EXIProbe(s32 chan); +static BOOL __EXIAttach(s32 chan, EXICallback extCallback); +#else +#define __EXIProbe EXIProbe +#define __EXIAttach EXIAttach +#endif #define EXI_0LENGTH_EXILENGTH_MASK 0x03FFFFE0 static EXIControl Ecb[EXI_MAX_CHAN]; -static void SetExiInterruptMask(s32 chan, struct EXIControl* exi); -static void CompleteTransfer(s32 chan); -int EXIImm(s32 chan, void* buf, s32 len, u32 type, EXICallback callback); -int EXIImmEx(s32 chan, void* buf, s32 len, u32 mode); -int EXIDma(s32 chan, void* buf, s32 len, u32 type, EXICallback callback); -int EXISync(s32 chan); -EXICallback EXISetExiCallback(s32 chan, EXICallback exiCallback); -void EXIProbeReset(); -static int __EXIProbe(s32 chan); -int EXIProbe(s32 chan); -int EXIAttach(s32 chan, EXICallback extCallback); -int EXIDetach(s32 chan); -int EXISelect(s32 chan, u32 dev, u32 freq); -int EXIDeselect(s32 chan); -static void EXIIntrruptHandler(signed short interrupt, struct OSContext* context); -static void TCIntrruptHandler(signed short interrupt, struct OSContext* context); -static void EXTIntrruptHandler(signed short interrupt, struct OSContext* context); -void EXIInit(); -int EXILock(s32 chan, u32 dev, void (*unlockedCallback)(s32, struct OSContext*)); -int EXIUnlock(s32 chan); -u32 EXIGetState(s32 chan); - -static void SetExiInterruptMask(s32 chan, struct EXIControl* exi) -{ - struct EXIControl* exi2 = &Ecb[2]; - - switch (chan) { - case 0: - { - if ((exi->exiCallback == 0 && exi2->exiCallback == 0) || exi->state & 0x10) { - __OSMaskInterrupts(0x410000U); - return; - } - __OSUnmaskInterrupts(0x410000U); - return; - } - case 1: - { - if (exi->exiCallback == 0 || exi->state & 0x10) { - __OSMaskInterrupts(0x80000U); - return; - } - __OSUnmaskInterrupts(0x80000U); - return; - } - case 2: - { - if ((__OSGetInterruptHandler(0x19) == 0U) || (exi->state & 0x10)) { - __OSMaskInterrupts(0x40U); - return; - } - __OSUnmaskInterrupts(0x40U); - return; - } - } -} - -static void CompleteTransfer(s32 chan) -{ - struct EXIControl* exi; - unsigned char* buf; - u32 data; - int i; - int len; - - exi = &Ecb[chan]; - OSAssertLine(0x115, 0 <= chan && chan < EXI_MAX_CHAN); - - if (exi->state & 3) { - if (exi->state & 2) { - if ((len = exi->immLen) != 0) { - buf = exi->immBuf; - data = __EXIRegs[(chan * 5) + 4]; - for (i = 0; i < len; i++) { - *buf++ = data >> ((3 - i) * 8); - } - } - } - exi->state &= ~3; - } -} - -int EXIImm(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) -{ - struct EXIControl* exi; - int enabled; - u32 data; - int i; - - exi = &Ecb[chan]; - OSAssertLine(0x13B, exi->state & EXI_STATE_SELECTED); - OSAssertLine(0x13C, 0 <= chan && chan < EXI_MAX_CHAN); - OSAssertLine(0x13D, 0 < len && len <= MAX_IMM); - OSAssertLine(0x13E, type < MAX_TYPE); - enabled = OSDisableInterrupts(); - if ((exi->state & 3) || !(exi->state & 4)) { - OSRestoreInterrupts(enabled); - return 0; - } - exi->tcCallback = callback; - if (exi->tcCallback) { - EXIClearInterrupts(chan, 0, 1, 0); - __OSUnmaskInterrupts(0x200000U >> (chan * 3)); - } - exi->state |= 2; - if (type != 0) { - data = 0; - for (i = 0; i < len; i++) { - data |= ((u8*)buf)[i] << ((3 - i) * 8); - } - __EXIRegs[(chan * 5) + 4] = data; - } - exi->immBuf = buf; - exi->immLen = (type != 1) ? len : 0; - __EXIRegs[(chan * 5) + 3] = (type << 2) | 1 | ((len - 1) << 4); - OSRestoreInterrupts(enabled); - return 1; -} - -int EXIImmEx(s32 chan, void* buf, s32 len, u32 mode) -{ - s32 xLen; - - while (len) { - xLen = (len < 4) ? len : 4; - if (EXIImm(chan, buf, xLen, mode, 0) == 0) { - return 0; - } - if (EXISync(chan) == 0) { - return 0; - } - ((u8*)buf) += xLen; - len -= xLen; - } - return 1; -} - -int EXIDma(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) -{ - struct EXIControl* exi; - int enabled; - - exi = &Ecb[chan]; - - OSAssertLine(0x1A4, exi->state & EXI_STATE_SELECTED); - OSAssertLine(0x1A5, OFFSET(buf, 32) == 0); - OSAssertLine(0x1A6, 0 < len && OFFSET(len, 32) == 0); - OSAssertLine(0x1A8, ((u32)len & ~EXI_0LENGTH_EXILENGTH_MASK) == 0); - OSAssertLine(0x1AA, type == EXI_READ || type == EXI_WRITE); - - enabled = OSDisableInterrupts(); - if ((exi->state & 3) || !(exi->state & 4)) { - OSRestoreInterrupts(enabled); - return 0; - } - exi->tcCallback = callback; - if ((u32)exi->tcCallback) { - EXIClearInterrupts(chan, 0, 1, 0); - __OSUnmaskInterrupts(0x200000U >> (chan * 3)); - } - exi->state |= 1; - __EXIRegs[(chan * 5) + 1] = (u32)buf & 0x03FFFFE0; - __EXIRegs[(chan * 5) + 2] = len; - __EXIRegs[(chan * 5) + 3] = (type * 4) | 3; - OSRestoreInterrupts(enabled); - return 1; -} - -#define EXI_REG_MAX 5 -#define EXI_USB_ADAPTER 0x01010000 -#define EXI_FREQ_1M 0 -#define EXIREG(chan, idx) (__EXIRegs[((chan) * EXI_REG_MAX) + (idx)]) - -int EXISync(s32 chan) -{ - struct EXIControl* exi; - int rc; - int enabled; - - exi = &Ecb[chan]; - rc = 0; - OSAssertLine(0x1D7, 0 <= chan && chan < EXI_MAX_CHAN); - while ((exi->state & 4)) { - if (!(__EXIRegs[(chan * 5) + 3] & 1)) { - enabled = OSDisableInterrupts(); - if (exi->state & 4) { - CompleteTransfer(chan); - if (__OSGetDIConfig() != 0xff || exi->immLen != 4 || (EXIREG(chan, 0) & 0x00000070) != (EXI_FREQ_1M << 4) - || (EXIREG(chan, 4) != EXI_USB_ADAPTER)) { - rc = TRUE; - } - } - OSRestoreInterrupts(enabled); - break; - } - } - OSAssertLine(0x1E9, !(exi->state & EXI_STATE_BUSY)); - return rc; -} - -BOOL EXIClearInterrupts(s32 chan, int exi, int tc, int ext) -{ - u32 cpr; - u32 prev; - - OSAssertLine(0x1FE, 0 <= chan && chan < EXI_MAX_CHAN); - cpr = prev = __EXIRegs[(chan * 5)]; - prev &= 0x7F5; - if (exi != 0) { - prev |= 2; - } - if (tc != 0) { - prev |= 8; - } - if (ext != 0) { - prev |= 0x800; - } - __EXIRegs[(chan * 5)] = prev; - return cpr; -} - -EXICallback EXISetExiCallback(s32 chan, EXICallback exiCallback) -{ - struct EXIControl* exi; - EXICallback prev; - int enabled; - - exi = &Ecb[chan]; - OSAssertLine(0x220, 0 <= chan && chan < EXI_MAX_CHAN); - enabled = OSDisableInterrupts(); - prev = exi->exiCallback; - exi->exiCallback = exiCallback; - if (chan != 2) { - SetExiInterruptMask(chan, exi); - } else { - SetExiInterruptMask(0, &Ecb[0]); - } - OSRestoreInterrupts(enabled); - return prev; -} - -void EXIProbeReset() -{ - __EXIProbeStartTime[0] = __EXIProbeStartTime[1] = 0; - Ecb[0].idTime = Ecb[1].idTime = 0; - __EXIProbe(0); - __EXIProbe(1); -} - -static int __EXIProbe(s32 chan) -{ - struct EXIControl* exi; - int enabled; - int rc; - u32 cpr; - s32 t; - - exi = &Ecb[chan]; - OSAssertLine(0x256, 0 <= chan && chan < EXI_MAX_CHAN); - if (chan == 2) { - return 1; - } - rc = 1; - enabled = OSDisableInterrupts(); - cpr = __EXIRegs[(chan * 5)]; - if (!(exi->state & 8)) { - if (cpr & 0x800) { - EXIClearInterrupts(chan, 0, 0, 1); - exi->idTime = 0; - __EXIProbeStartTime[chan] = 0; - } - if (cpr & 0x1000) { - t = ((s32)(OSTicksToMilliseconds(OSGetTime()) / 100) + 1); - - if (__EXIProbeStartTime[chan] == 0) { - __EXIProbeStartTime[chan] = t; - } - if (t - (s32)__EXIProbeStartTime[chan] < 3) { - rc = 0; - } - } else { - exi->idTime = 0; - __EXIProbeStartTime[chan] = 0; - rc = 0; - } - } else if (!(cpr & 0x1000) || (cpr & 0x800)) { - exi->idTime = 0; - __EXIProbeStartTime[chan] = 0; - rc = 0; - } - OSRestoreInterrupts(enabled); - return rc; -} - -int EXIProbe(s32 chan) -{ - int var_r3; - struct EXIControl* exi = &Ecb[chan]; - - if ((var_r3 = __EXIProbe(chan))) { - u32 id; - if (exi->idTime == 0) { - if (EXIGetID(chan, 0, &id) != 0) { - var_r3 = 1; - } else { - var_r3 = 0; - } - } - } - return var_r3; -} - -s32 EXIProbeEx(s32 chan) -{ - if (EXIProbe(chan)) { - return 1; - } - if (__EXIProbeStartTime[chan]) { - return 0; - } - return -1; -} - -static int __EXIAttach(s32 chan, EXICallback extCallback) -{ - struct EXIControl* exi = &Ecb[chan]; - int enabled = OSDisableInterrupts(); - int result; - - if (exi->state & 8 || __EXIProbe(chan) == 0) { - OSRestoreInterrupts(enabled); - result = 0; - } else { - u32 intr; - EXIClearInterrupts(chan, 1, 0, 0); - exi->extCallback = extCallback; - __OSUnmaskInterrupts(0x100000U >> (chan * 3)); - exi->state |= 8; - OSRestoreInterrupts(enabled); - result = 1; - } - return result; -} - -int EXIAttach(s32 chan, EXICallback extCallback) -{ - struct EXIControl* exi; - int enabled; - int result; - - exi = &Ecb[chan]; - OSAssertLine(0x2AE, 0 <= chan && chan < 2); - - EXIProbe(chan); - - enabled = OSDisableInterrupts(); - if (exi->idTime == 0) { - OSRestoreInterrupts(enabled); - return 0; - } - result = __EXIAttach(chan, extCallback); - - OSRestoreInterrupts(enabled); - return result; -} - -int EXIDetach(s32 chan) -{ - struct EXIControl* exi; - int enabled; - - exi = &Ecb[chan]; - OSAssertLine(0x2D7, 0 <= chan && chan < 2); - enabled = OSDisableInterrupts(); - if (!(exi->state & 8)) { - OSRestoreInterrupts(enabled); - return 1; - } - if ((exi->state & 0x10) && (exi->dev == 0)) { - OSRestoreInterrupts(enabled); - return 0; - } - exi->state &= ~8; - __OSMaskInterrupts(0x700000U >> (chan * 3)); - OSRestoreInterrupts(enabled); - return 1; -} - -int EXISelect(s32 chan, u32 dev, u32 freq) -{ - struct EXIControl* exi; - u32 cpr; - int enabled; - - exi = &Ecb[chan]; - - OSAssertLine(0x2FF, 0 <= chan && chan < EXI_MAX_CHAN); - OSAssertLine(0x300, chan == 0 && dev < EXI_MAX_DEV || dev == 0); - OSAssertLine(0x301, freq < EXI_MAX_FREQ); - OSAssertLine(0x302, !(exi->state & EXI_STATE_SELECTED)); - - enabled = OSDisableInterrupts(); - if ((exi->state & 4) - || ((chan != 2) && (((dev == 0) && !(exi->state & 8) && (__EXIProbe(chan) == 0)) || !(exi->state & 0x10) || (exi->dev != dev)))) { - OSRestoreInterrupts(enabled); - return 0; - } - exi->state |= 4; - cpr = __EXIRegs[(chan * 5)]; - cpr &= 0x405; - cpr |= (((1 << dev) << 7) | (freq * 0x10)); - __EXIRegs[(chan * 5)] = cpr; - if (exi->state & 8) { - switch (chan) { - case 0: - { - __OSMaskInterrupts(0x100000U); - break; - } - case 1: - { - __OSMaskInterrupts(0x20000U); - break; - } - } - } - OSRestoreInterrupts(enabled); - return 1; -} - -int EXIDeselect(s32 chan) -{ - struct EXIControl* exi; - u32 cpr; - int enabled; - - exi = &Ecb[chan]; - OSAssertLine(0x335, 0 <= chan && chan < EXI_MAX_CHAN); - enabled = OSDisableInterrupts(); - if (!(exi->state & 4)) { - OSRestoreInterrupts(enabled); - return 0; - } - exi->state &= ~4; - cpr = __EXIRegs[(chan * 5)]; - __EXIRegs[(chan * 5)] = cpr & 0x405; - if (exi->state & 8) { - switch (chan) { - case 0: - { - __OSUnmaskInterrupts(0x100000U); - break; - } - case 1: - { - __OSUnmaskInterrupts(0x20000U); - break; - } - } - } - OSRestoreInterrupts(enabled); - if ((chan != 2) && (cpr & 0x80)) { - if (__EXIProbe(chan) != 0) { - return 1; - } - return 0; - } - return 1; -} - -static void EXIIntrruptHandler(signed short interrupt, struct OSContext* context) -{ - s32 chan; - struct EXIControl* exi; - EXICallback callback; - OSContext old; - int stack, stack2; - - chan = (interrupt - 9) / 3; - - OSAssertLine(0x368, 0 <= chan && chan < EXI_MAX_CHAN); - exi = &Ecb[chan]; - EXIClearInterrupts(chan, 1, 0, 0); - callback = exi->exiCallback; - if (callback) { - OSClearContext(&old); - OSSetCurrentContext(&old); - callback(chan, context); - OSClearContext(&old); - OSSetCurrentContext(context); - } -} - -static void TCIntrruptHandler(signed short interrupt, struct OSContext* context) -{ - s32 chan; - struct EXIControl* exi; - EXICallback callback; - OSContext old; - int stack, stack2; - - chan = (interrupt - 10) / 3; - - OSAssertLine(0x383, 0 <= chan && chan < EXI_MAX_CHAN); - exi = &Ecb[chan]; - __OSMaskInterrupts(0x80000000U >> interrupt); - EXIClearInterrupts(chan, 0, 1, 0); - callback = exi->tcCallback; - if (callback) { - exi->tcCallback = NULL; - CompleteTransfer(chan); - OSClearContext(&old); - OSSetCurrentContext(&old); - callback(chan, context); - OSClearContext(&old); - OSSetCurrentContext(context); - } -} - -static void EXTIntrruptHandler(signed short interrupt, struct OSContext* context) -{ - s32 chan; - struct EXIControl* exi; - EXICallback callback; - OSContext old; - - chan = (interrupt - 11) / 3; - - OSAssertLine(0x3A2, 0 <= chan && chan < 2); - __OSMaskInterrupts(0x700000U >> (chan * 3)); - __EXIRegs[(chan * 5)] = 0; - exi = &Ecb[chan]; - callback = exi->extCallback; - exi->state &= 0xFFFFFFF7; - if (callback) { - OSClearContext(&old); - OSSetCurrentContext(&old); - exi->extCallback = 0; - callback(chan, context); - OSClearContext(&old); - OSSetCurrentContext(context); - } -} - -void EXIInit() -{ - __OSMaskInterrupts(0x7F8000U); - __EXIRegs[0] = 0; - __EXIRegs[5] = 0; - __EXIRegs[10] = 0; - __EXIRegs[0] = 0x2000; - __OSSetInterruptHandler(9, EXIIntrruptHandler); - __OSSetInterruptHandler(10, TCIntrruptHandler); - __OSSetInterruptHandler(11, EXTIntrruptHandler); - __OSSetInterruptHandler(12, EXIIntrruptHandler); - __OSSetInterruptHandler(13, TCIntrruptHandler); - __OSSetInterruptHandler(14, EXTIntrruptHandler); - __OSSetInterruptHandler(15, EXIIntrruptHandler); - __OSSetInterruptHandler(16, TCIntrruptHandler); - - if (OSGetConsoleType() & 0x10000000) { - EXIProbeReset(); - } -} - -int EXILock(s32 chan, u32 dev, void (*unlockedCallback)(s32, struct OSContext*)) -{ - struct EXIControl* exi; - int enabled; - int i; - - exi = &Ecb[chan]; - OSAssertLine(0x3F2, 0 <= chan && chan < EXI_MAX_CHAN); - OSAssertLine(0x3F3, chan == 0 && dev < EXI_MAX_DEV || dev == 0); - enabled = OSDisableInterrupts(); - - if (exi->state & 0x10) { - if (unlockedCallback) { - OSAssertLine(0x3F9, chan == 0 && exi->items < (EXI_MAX_DEV - 1) || exi->items == 0); - for (i = 0; i < exi->items; i++) { - if (exi->queue[i].dev == dev) { - OSRestoreInterrupts(enabled); - return 0; - } - } - exi->queue[exi->items].callback = unlockedCallback; - exi->queue[exi->items].dev = dev; - exi->items++; - } - OSRestoreInterrupts(enabled); - return 0; - } - OSAssertLine(0x409, exi->items == 0); - exi->state |= 0x10; - exi->dev = dev; - SetExiInterruptMask(chan, exi); - OSRestoreInterrupts(enabled); - return 1; -} - -int EXIUnlock(s32 chan) -{ - struct EXIControl* exi; - int enabled; - EXICallback unlockedCallback; - - exi = &Ecb[chan]; - OSAssertLine(0x421, 0 <= chan && chan < EXI_MAX_CHAN); - enabled = OSDisableInterrupts(); - if (!(exi->state & 0x10)) { - OSRestoreInterrupts(enabled); - return 0; - } - exi->state &= 0xFFFFFFEF; - SetExiInterruptMask(chan, exi); - if (exi->items > 0) { - unlockedCallback = exi->queue[0].callback; - if (--exi->items > 0) { - memmove(&exi->queue[0], &exi->queue[1], exi->items * 8); - } - unlockedCallback(chan, 0); - } - OSRestoreInterrupts(enabled); - return 1; -} - -u32 EXIGetState(s32 chan) -{ - struct EXIControl* exi; - - exi = &Ecb[chan]; - OSAssertLine(0x446, 0 <= chan && chan < EXI_MAX_CHAN); - return exi->state; -} - -static void UnlockedHandler(s32 chan, OSContext* context) -{ - u32 id; - EXIGetID(chan, 0, &id); -} - -s32 EXIGetID(s32 chan, u32 dev, u32* id) -{ - int err; - u32 cmd; - struct EXIControl* exi = &Ecb[chan]; - s32 startTime; - - OSAssertLine(0x45A, 0 <= chan && chan < EXI_MAX_CHAN); - - if (chan < 2 && dev == 0) { - if (!__EXIProbe(chan)) { - return 0; - } - - if (exi->idTime == __EXIProbeStartTime[chan]) { - *id = exi->id; - return exi->idTime; - } - - if (!__EXIAttach(chan, NULL)) { - return 0; - } - startTime = __EXIProbeStartTime[chan]; - } - - err = !EXILock(chan, dev, (chan < 2 && dev == 0) ? UnlockedHandler : NULL); - if (err == 0) { - err = !EXISelect(chan, dev, 0); - if (err == 0) { - cmd = 0; - err |= !EXIImm(chan, &cmd, 2, 1, 0); - err |= !EXISync(chan); - err |= !EXIImm(chan, id, 4, 0, 0); - err |= !EXISync(chan); - err |= !EXIDeselect(chan); - } - EXIUnlock(chan); - } - if ((chan < 2) && (dev == 0)) { - int enabled; - EXIDetach(chan); - enabled = OSDisableInterrupts(); - err |= (startTime != __EXIProbeStartTime[chan]); - - if (err == 0) { - exi->id = *id; - exi->idTime = startTime; - } - - OSRestoreInterrupts(enabled); - return err ? 0 : exi->idTime; - } - if (err) { - return 0; - } - return 1; -} -#else - -static EXIControl Ecb[EXI_MAX_CHAN]; - /** * @TODO: Documentation */ @@ -757,18 +62,21 @@ static void SetExiInterruptMask(s32 chan, EXIControl* exi) */ static void CompleteTransfer(s32 chan) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; u8* buf; u32 data; int i; int len; - if (exi->state & EXI_STATE_BUSY) { - if ((exi->state & EXI_STATE_IMM) && (len = exi->immLen)) { + exi = &Ecb[chan]; + OSAssertLine(0x115, 0 <= chan && chan < EXI_MAX_CHAN); + + if ((exi->state & EXI_STATE_BUSY)) { + if ((exi->state & EXI_STATE_IMM) && (len = exi->immLen) != 0) { buf = exi->immBuf; data = EXIREG(chan, 4); for (i = 0; i < len; i++) { - *buf++ = (u8)((data >> ((3 - i) * 8)) & 0xff); + *buf++ = data >> ((3 - i) * 8); } } exi->state &= ~EXI_STATE_BUSY; @@ -781,10 +89,16 @@ static void CompleteTransfer(s32 chan) */ BOOL EXIImm(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; BOOL enabled; + exi = &Ecb[chan]; + OSAssertLine(0x13B, exi->state & EXI_STATE_SELECTED); + OSAssertLine(0x13C, 0 <= chan && chan < EXI_MAX_CHAN); + OSAssertLine(0x13D, 0 < len && len <= MAX_IMM); + OSAssertLine(0x13E, type < MAX_TYPE); enabled = OSDisableInterrupts(); + if ((exi->state & EXI_STATE_BUSY) || !(exi->state & EXI_STATE_SELECTED)) { OSRestoreInterrupts(enabled); return FALSE; @@ -793,7 +107,7 @@ BOOL EXIImm(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) exi->tcCallback = callback; if (exi->tcCallback) { EXIClearInterrupts(chan, FALSE, TRUE, FALSE); - __OSUnmaskInterrupts(OS_INTERRUPTMASK_EXI_0_TC >> (3 * chan)); + __OSUnmaskInterrupts(OS_INTERRUPTMASK_EXI_0_TC >> (chan * 3)); } exi->state |= EXI_STATE_IMM; @@ -801,7 +115,6 @@ BOOL EXIImm(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) if (type != EXI_READ) { u32 data; int i; - data = 0; for (i = 0; i < len; i++) { data |= ((u8*)buf)[i] << ((3 - i) * 8); @@ -822,7 +135,7 @@ BOOL EXIImm(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) /** * @TODO: Documentation */ -BOOL EXIImmEx(s32 chan, void* buf, s32 len, u32 mode) +int EXIImmEx(s32 chan, void* buf, s32 len, u32 mode) { s32 xLen; @@ -845,12 +158,19 @@ BOOL EXIImmEx(s32 chan, void* buf, s32 len, u32 mode) /** * @TODO: Documentation */ -BOOL EXIDma(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) +int EXIDma(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; BOOL enabled; + exi = &Ecb[chan]; + OSAssertLine(0x1A4, exi->state & EXI_STATE_SELECTED); + OSAssertLine(0x1A5, OFFSET(buf, 32) == 0); + OSAssertLine(0x1A6, 0 < len && OFFSET(len, 32) == 0); + OSAssertLine(0x1A8, ((u32)len & ~EXI_0LENGTH_EXILENGTH_MASK) == 0); + OSAssertLine(0x1AA, type == EXI_READ || type == EXI_WRITE); enabled = OSDisableInterrupts(); + if ((exi->state & EXI_STATE_BUSY) || !(exi->state & EXI_STATE_SELECTED)) { OSRestoreInterrupts(enabled); return FALSE; @@ -859,7 +179,7 @@ BOOL EXIDma(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) exi->tcCallback = callback; if (exi->tcCallback) { EXIClearInterrupts(chan, FALSE, TRUE, FALSE); - __OSUnmaskInterrupts(OS_INTERRUPTMASK_EXI_0_TC >> (3 * chan)); + __OSUnmaskInterrupts(OS_INTERRUPTMASK_EXI_0_TC >> (chan * 3)); } exi->state |= EXI_STATE_DMA; @@ -878,12 +198,16 @@ BOOL EXIDma(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) */ BOOL EXISync(s32 chan) { - EXIControl* exi = &Ecb[chan]; - BOOL rc = FALSE; + EXIControl* exi; + BOOL rc; BOOL enabled; + exi = &Ecb[chan]; + rc = FALSE; + OSAssertLine(0x1D7, 0 <= chan && chan < EXI_MAX_CHAN); + while (exi->state & EXI_STATE_SELECTED) { - if (((EXIREG(chan, 3) & 1) >> 0) == 0) { + if (!(EXIREG(chan, 3) & 1)) { enabled = OSDisableInterrupts(); if (exi->state & EXI_STATE_SELECTED) { CompleteTransfer(chan); @@ -896,17 +220,19 @@ BOOL EXISync(s32 chan) break; } } + OSAssertLine(0x1E9, !(exi->state & EXI_STATE_BUSY)); return rc; } /** * @TODO: Documentation */ -BOOL EXIClearInterrupts(s32 chan, BOOL exi, BOOL tc, BOOL ext) +u32 EXIClearInterrupts(s32 chan, BOOL exi, BOOL tc, BOOL ext) { u32 cpr; u32 prev; + OSAssertLine(0x1FE, 0 <= chan && chan < EXI_MAX_CHAN); prev = cpr = EXIREG(chan, 0); cpr &= 0x7f5; if (exi) @@ -924,10 +250,12 @@ BOOL EXIClearInterrupts(s32 chan, BOOL exi, BOOL tc, BOOL ext) */ EXICallback EXISetExiCallback(s32 chan, EXICallback exiCallback) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; EXICallback prev; BOOL enabled; + exi = &Ecb[chan]; + OSAssertLine(0x220, 0 <= chan && chan < EXI_MAX_CHAN); enabled = OSDisableInterrupts(); prev = exi->exiCallback; exi->exiCallback = exiCallback; @@ -946,9 +274,12 @@ EXICallback EXISetExiCallback(s32 chan, EXICallback exiCallback) * @TODO: Documentation * @note UNUSED Size: 00003C */ -void EXIProbeReset(void) +void EXIProbeReset() { __EXIProbeStartTime[0] = __EXIProbeStartTime[1] = 0; +#if OS_BUILD_VERSION >= 20011112L + Ecb[0].idTime = Ecb[1].idTime = 0; +#endif __EXIProbe(0); __EXIProbe(1); // UNUSED FUNCTION @@ -956,15 +287,18 @@ void EXIProbeReset(void) /** * @TODO: Documentation + * @note If `!(OS_BUILD_REVISION >= 20011112L)`, then this function is named `EXIProbe`. */ -BOOL EXIProbe(s32 chan) +BOOL __EXIProbe(s32 chan) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; BOOL enabled; BOOL rc; u32 cpr; s32 t; + exi = &Ecb[chan]; + OSAssertLine(0x256, 0 <= chan && chan < EXI_MAX_CHAN); if (chan == 2) { return TRUE; } @@ -972,32 +306,73 @@ BOOL EXIProbe(s32 chan) rc = TRUE; enabled = OSDisableInterrupts(); cpr = EXIREG(chan, 0); + if (!(exi->state & EXI_STATE_ATTACHED)) { - if (cpr & 0x00000800) { + if (cpr & 0x800) { EXIClearInterrupts(chan, FALSE, FALSE, TRUE); +#if OS_BUILD_VERSION >= 20011112L + exi->idTime = 0; +#endif __EXIProbeStartTime[chan] = 0; } - if (cpr & 0x00001000) { + if (cpr & 0x1000) { t = (s32)(OSTicksToMilliseconds(OSGetTime()) / 100) + 1; - if ((u32)__EXIProbeStartTime[chan] == 0) { +#if OS_BUILD_VERSION >= 20011112L + if (__EXIProbeStartTime[chan] == 0) +#else + if ((u32)__EXIProbeStartTime[chan] == 0) +#endif + { __EXIProbeStartTime[chan] = t; } if (t - __EXIProbeStartTime[chan] < 300 / 100) { rc = FALSE; } } else { +#if OS_BUILD_VERSION >= 20011112L + exi->idTime = 0; +#endif __EXIProbeStartTime[chan] = 0; - rc = FALSE; + rc = 0; } - } else if (!(cpr & 0x00001000) || (cpr & 0x00000800)) { + } else if (!(cpr & 0x1000) || (cpr & 0x800)) { +#if OS_BUILD_VERSION >= 20011112L + exi->idTime = 0; +#endif __EXIProbeStartTime[chan] = 0; - rc = FALSE; + rc = 0; } OSRestoreInterrupts(enabled); return rc; } +#if OS_BUILD_VERSION >= 20011112L + +/** + * @TODO: Documentation + */ +BOOL EXIProbe(s32 chan) +{ + BOOL rc; + EXIControl* exi; + + exi = &Ecb[chan]; + if ((rc = __EXIProbe(chan))) { + u32 id; + if (exi->idTime == 0) { + if (EXIGetID(chan, 0, &id) != 0) { + rc = TRUE; + } else { + rc = FALSE; + } + } + } + return rc; +} + +#endif + /** * @TODO: Documentation */ @@ -1005,7 +380,13 @@ s32 EXIProbeEx(s32 chan) { if (EXIProbe(chan)) { return 1; - } else if ((u32)__EXIProbeStartTime[chan] != 0) { + } +#if OS_BUILD_VERSION >= 20011112L + if (__EXIProbeStartTime[chan] != 0) +#else + if ((u32)__EXIProbeStartTime[chan] != 0) +#endif + { return 0; } return -1; @@ -1013,55 +394,96 @@ s32 EXIProbeEx(s32 chan) /** * @TODO: Documentation + * @note If `!(OS_BUILD_REVISION >= 20011112L)`, then this function is named `EXIAttach`. */ -BOOL EXIAttach(s32 chan, EXICallback extCallback) +BOOL __EXIAttach(s32 chan, EXICallback extCallback) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; BOOL enabled; - u32 stack1; // unused, just stack filling - u32 stack2; // unused, just stack filling + BOOL result; + exi = &Ecb[chan]; enabled = OSDisableInterrupts(); - if ((exi->state & EXI_STATE_ATTACHED)) { + +#if OS_BUILD_VERSION >= 20011112L + if ((exi->state & EXI_STATE_ATTACHED) || __EXIProbe(chan) == 0) +#else + if ((exi->state & EXI_STATE_ATTACHED)) +#endif + { OSRestoreInterrupts(enabled); - return FALSE; + result = FALSE; } +#if OS_BUILD_VERSION >= 20011112L +#else + else if (__EXIProbe(chan) == FALSE) { + OSRestoreInterrupts(enabled); + result = FALSE; + } +#endif + else { + EXIClearInterrupts(chan, TRUE, FALSE, FALSE); + exi->extCallback = extCallback; + __OSUnmaskInterrupts(OS_INTERRUPTMASK_EXI_0_EXT >> (chan * 3)); + exi->state |= EXI_STATE_ATTACHED; + OSRestoreInterrupts(enabled); + result = TRUE; + } + return result; +} + +#if OS_BUILD_VERSION >= 20011112L + +/** + * @TODO: Documentation + */ +BOOL EXIAttach(s32 chan, EXICallback extCallback) +{ + EXIControl* exi; + BOOL enabled; + BOOL result; + + exi = &Ecb[chan]; + OSAssertLine(0x2AE, 0 <= chan && chan < 2); + + EXIProbe(chan); - if (EXIProbe(chan) == FALSE) { + enabled = OSDisableInterrupts(); + if (exi->idTime == 0) { OSRestoreInterrupts(enabled); return FALSE; } + result = __EXIAttach(chan, extCallback); - EXIClearInterrupts(chan, TRUE, FALSE, FALSE); - - exi->extCallback = extCallback; - __OSUnmaskInterrupts(OS_INTERRUPTMASK_EXI_0_EXT >> (3 * chan)); - exi->state |= EXI_STATE_ATTACHED; OSRestoreInterrupts(enabled); - - return TRUE; + return result; } +#endif + /** * @TODO: Documentation */ BOOL EXIDetach(s32 chan) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; BOOL enabled; + exi = &Ecb[chan]; + OSAssertLine(0x2D7, 0 <= chan && chan < 2); enabled = OSDisableInterrupts(); + if (!(exi->state & EXI_STATE_ATTACHED)) { OSRestoreInterrupts(enabled); return TRUE; } - if ((exi->state & EXI_STATE_LOCKED) && exi->dev == 0) { + if ((exi->state & EXI_STATE_LOCKED) && (exi->dev == 0)) { OSRestoreInterrupts(enabled); return FALSE; } - exi->state &= ~EXI_STATE_ATTACHED; - __OSMaskInterrupts((OS_INTERRUPTMASK_EXI_0_EXT | OS_INTERRUPTMASK_EXI_0_EXI | OS_INTERRUPTMASK_EXI_0_TC) >> (3 * chan)); + __OSMaskInterrupts((OS_INTERRUPTMASK_EXI_0_EXT | OS_INTERRUPTMASK_EXI_0_EXI | OS_INTERRUPTMASK_EXI_0_TC) >> (chan * 3)); + OSRestoreInterrupts(enabled); return TRUE; } @@ -1071,15 +493,20 @@ BOOL EXIDetach(s32 chan) */ BOOL EXISelect(s32 chan, u32 dev, u32 freq) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; u32 cpr; BOOL enabled; + exi = &Ecb[chan]; + OSAssertLine(0x2FF, 0 <= chan && chan < EXI_MAX_CHAN); + OSAssertLine(0x300, chan == 0 && dev < EXI_MAX_DEV || dev == 0); + OSAssertLine(0x301, freq < EXI_MAX_FREQ); + OSAssertLine(0x302, !(exi->state & EXI_STATE_SELECTED)); enabled = OSDisableInterrupts(); if ((exi->state & EXI_STATE_SELECTED) || chan != 2 - && (dev == 0 && !(exi->state & EXI_STATE_ATTACHED) && !EXIProbe(chan) || !(exi->state & EXI_STATE_LOCKED) + && (dev == 0 && !(exi->state & EXI_STATE_ATTACHED) && !__EXIProbe(chan) || !(exi->state & EXI_STATE_LOCKED) || (exi->dev != dev))) { OSRestoreInterrupts(enabled); return FALSE; @@ -1115,15 +542,19 @@ BOOL EXISelect(s32 chan, u32 dev, u32 freq) */ BOOL EXIDeselect(s32 chan) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; u32 cpr; BOOL enabled; + exi = &Ecb[chan]; + OSAssertLine(0x335, 0 <= chan && chan < EXI_MAX_CHAN); enabled = OSDisableInterrupts(); + if (!(exi->state & EXI_STATE_SELECTED)) { OSRestoreInterrupts(enabled); return FALSE; } + exi->state &= ~EXI_STATE_SELECTED; cpr = EXIREG(chan, 0); EXIREG(chan, 0) = cpr & 0x405; @@ -1144,11 +575,9 @@ BOOL EXIDeselect(s32 chan) } OSRestoreInterrupts(enabled); - if (chan != 2 && (cpr & EXI_CPR_CS(0))) { - return EXIProbe(chan) ? TRUE : FALSE; + return __EXIProbe(chan) ? TRUE : FALSE; } - return TRUE; } @@ -1160,13 +589,26 @@ static void EXIIntrruptHandler(__OSInterrupt interrupt, OSContext* context) s32 chan; EXIControl* exi; EXICallback callback; +#if OS_BUILD_VERSION >= 20011112L + OSContext old; +#endif chan = (interrupt - __OS_INTERRUPT_EXI_0_EXI) / 3; - exi = &Ecb[chan]; + OSAssertLine(0x368, 0 <= chan && chan < EXI_MAX_CHAN); + exi = &Ecb[chan]; + EXIClearInterrupts(chan, TRUE, FALSE, FALSE); callback = exi->exiCallback; if (callback) { +#if OS_BUILD_VERSION >= 20011112L + OSClearContext(&old); + OSSetCurrentContext(&old); +#endif callback(chan, context); +#if OS_BUILD_VERSION >= 20011112L + OSClearContext(&old); + OSSetCurrentContext(context); +#endif } } @@ -1178,17 +620,29 @@ static void TCIntrruptHandler(__OSInterrupt interrupt, OSContext* context) s32 chan; EXIControl* exi; EXICallback callback; - int pad, pad2; +#if OS_BUILD_VERSION >= 20011112L + OSContext old; +#endif chan = (interrupt - __OS_INTERRUPT_EXI_0_TC) / 3; - exi = &Ecb[chan]; + OSAssertLine(0x383, 0 <= chan && chan < EXI_MAX_CHAN); + exi = &Ecb[chan]; + __OSMaskInterrupts(OS_INTERRUPTMASK(interrupt)); EXIClearInterrupts(chan, FALSE, TRUE, FALSE); callback = exi->tcCallback; if (callback) { - exi->tcCallback = 0; + exi->tcCallback = NULL; CompleteTransfer(chan); +#if OS_BUILD_VERSION >= 20011112L + OSClearContext(&old); + OSSetCurrentContext(&old); +#endif callback(chan, context); +#if OS_BUILD_VERSION >= 20011112L + OSClearContext(&old); + OSSetCurrentContext(context); +#endif } } @@ -1200,17 +654,29 @@ static void EXTIntrruptHandler(__OSInterrupt interrupt, OSContext* context) s32 chan; EXIControl* exi; EXICallback callback; +#if OS_BUILD_VERSION >= 20011112L + OSContext old; +#endif chan = (interrupt - __OS_INTERRUPT_EXI_0_EXT) / 3; - __OSMaskInterrupts((OS_INTERRUPTMASK_EXI_0_EXT | OS_INTERRUPTMASK_EXI_0_EXI | OS_INTERRUPTMASK_EXI_0_TC) >> (3 * chan)); - __EXIRegs[(chan * 5)] = 0; + OSAssertLine(0x3A2, 0 <= chan && chan < 2); - exi = &Ecb[chan]; - callback = exi->extCallback; + __OSMaskInterrupts((OS_INTERRUPTMASK_EXI_0_EXT | OS_INTERRUPTMASK_EXI_0_EXI | OS_INTERRUPTMASK_EXI_0_TC) >> (3 * chan)); + EXIREG(chan, 0) = 0; + exi = &Ecb[chan]; + callback = exi->extCallback; exi->state &= ~EXI_STATE_ATTACHED; if (callback) { - exi->extCallback = 0; +#if OS_BUILD_VERSION >= 20011112L + OSClearContext(&old); + OSSetCurrentContext(&old); +#endif + exi->extCallback = NULL; callback(chan, context); +#if OS_BUILD_VERSION >= 20011112L + OSClearContext(&old); + OSSetCurrentContext(context); +#endif } } @@ -1238,9 +704,13 @@ void EXIInit(void) __OSSetInterruptHandler(__OS_INTERRUPT_EXI_2_TC, TCIntrruptHandler); if (OSGetConsoleType() & 0x10000000) { +#if OS_BUILD_VERSION >= 20011112L + EXIProbeReset(); +#else __EXIProbeStartTime[0] = __EXIProbeStartTime[1] = 0; - EXIProbe(0); - EXIProbe(1); + __EXIProbe(0); + __EXIProbe(1); +#endif } } @@ -1249,13 +719,18 @@ void EXIInit(void) */ BOOL EXILock(s32 chan, u32 dev, EXICallback unlockedCallback) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; BOOL enabled; int i; + exi = &Ecb[chan]; + OSAssertLine(0x3F2, 0 <= chan && chan < EXI_MAX_CHAN); + OSAssertLine(0x3F3, chan == 0 && dev < EXI_MAX_DEV || dev == 0); enabled = OSDisableInterrupts(); + if (exi->state & EXI_STATE_LOCKED) { if (unlockedCallback) { + OSAssertLine(0x3F9, chan == 0 && exi->items < (EXI_MAX_DEV - 1) || exi->items == 0); for (i = 0; i < exi->items; i++) { if (exi->queue[i].dev == dev) { OSRestoreInterrupts(enabled); @@ -1270,6 +745,7 @@ BOOL EXILock(s32 chan, u32 dev, EXICallback unlockedCallback) return FALSE; } + OSAssertLine(0x409, exi->items == 0); exi->state |= EXI_STATE_LOCKED; exi->dev = dev; SetExiInterruptMask(chan, exi); @@ -1283,11 +759,14 @@ BOOL EXILock(s32 chan, u32 dev, EXICallback unlockedCallback) */ BOOL EXIUnlock(s32 chan) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; BOOL enabled; EXICallback unlockedCallback; + exi = &Ecb[chan]; + OSAssertLine(0x421, 0 <= chan && chan < EXI_MAX_CHAN); enabled = OSDisableInterrupts(); + if (!(exi->state & EXI_STATE_LOCKED)) { OSRestoreInterrupts(enabled); return FALSE; @@ -1295,10 +774,10 @@ BOOL EXIUnlock(s32 chan) exi->state &= ~EXI_STATE_LOCKED; SetExiInterruptMask(chan, exi); - if (0 < exi->items) { + if (exi->items > 0) { unlockedCallback = exi->queue[0].callback; - if (0 < --exi->items) { - memmove(&exi->queue[0], &exi->queue[1], sizeof(exi->queue[0]) * exi->items); + if (--exi->items > 0) { + memmove(&exi->queue[0], &exi->queue[1], exi->items * sizeof(exi->queue[0])); } unlockedCallback(chan, 0); } @@ -1312,15 +791,16 @@ BOOL EXIUnlock(s32 chan) */ u32 EXIGetState(s32 chan) { - EXIControl* exi = &Ecb[chan]; + EXIControl* exi; - return (u32)exi->state; + exi = &Ecb[chan]; + OSAssertLine(0x446, 0 <= chan && chan < EXI_MAX_CHAN); + return exi->state; } static void UnlockedHandler(s32 chan, OSContext* context) { u32 id; - EXIGetID(chan, 0, &id); } @@ -1331,5 +811,60 @@ static void UnlockedHandler(s32 chan, OSContext* context) s32 EXIGetID(s32 chan, u32 dev, u32* id) { // UNUSED FUNCTION -} +#if OS_BUILD_VERSION >= 20011112L + BOOL err; + u32 cmd; + EXIControl* exi = &Ecb[chan]; + s32 startTime; + + OSAssertLine(0x45A, 0 <= chan && chan < EXI_MAX_CHAN); + + if (chan < 2 && dev == 0) { + if (!__EXIProbe(chan)) { + return 0; + } + + if (exi->idTime == __EXIProbeStartTime[chan]) { + *id = exi->id; + return exi->idTime; + } + + if (!__EXIAttach(chan, NULL)) { + return 0; + } + startTime = __EXIProbeStartTime[chan]; + } + + err = !EXILock(chan, dev, (chan < 2 && dev == 0) ? UnlockedHandler : NULL); + if (err == 0) { + err = !EXISelect(chan, dev, 0); + if (err == 0) { + cmd = 0; + err |= !EXIImm(chan, &cmd, 2, 1, 0); + err |= !EXISync(chan); + err |= !EXIImm(chan, id, 4, 0, 0); + err |= !EXISync(chan); + err |= !EXIDeselect(chan); + } + EXIUnlock(chan); + } + if ((chan < 2) && (dev == 0)) { + BOOL enabled; + EXIDetach(chan); + enabled = OSDisableInterrupts(); + err |= (startTime != __EXIProbeStartTime[chan]); + + if (err == 0) { + exi->id = *id; + exi->idTime = startTime; + } + + OSRestoreInterrupts(enabled); + return err ? 0 : exi->idTime; + } + if (err) { + return 0; + } + return 1; #endif +} diff --git a/src/os/OSInterrupt.c b/src/os/OSInterrupt.c index 03ed6cbe..288b7583 100644 --- a/src/os/OSInterrupt.c +++ b/src/os/OSInterrupt.c @@ -124,7 +124,7 @@ static u32 SetInterruptMask(OSInterruptMask mask, OSInterruptMask current) case __OS_INTERRUPT_MEM_1: case __OS_INTERRUPT_MEM_2: case __OS_INTERRUPT_MEM_3: -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L case __OS_INTERRUPT_MEM_ADDRESS: #endif { @@ -353,7 +353,7 @@ OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask global) return prev; } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L volatile OSTime __OSLastInterruptTime; volatile __OSInterrupt __OSLastInterrupt; volatile u32 __OSLastInterruptSrr0; @@ -466,7 +466,7 @@ void __OSDispatchInterrupt(__OSException exception, OSContext* context) handler = __OSGetInterruptHandler(interrupt); if (handler) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L if (__OS_INTERRUPT_MEM_ADDRESS < interrupt) { __OSLastInterrupt = interrupt; __OSLastInterruptTime = OSGetTime(); diff --git a/src/os/OSMemory.c b/src/os/OSMemory.c index fa9d0fcd..4ad44c2e 100644 --- a/src/os/OSMemory.c +++ b/src/os/OSMemory.c @@ -40,8 +40,7 @@ static void MEMIntrruptHandler(__OSInterrupt interrupt, OSContext* context) addr = (((u32)__MEMRegs[0x12] & 0x3ff) << 16) | __MEMRegs[0x11]; __MEMRegs[0x10] = 0; -#if defined(VERSION_DPIJ01_PIKIDEMO) -#else +#if OS_BUILD_VERSION >= 20011112L if (__OSErrorTable[OS_ERROR_PROTECTION]) { __OSErrorTable[OS_ERROR_PROTECTION](OS_ERROR_PROTECTION, context, cause, addr); return; @@ -201,23 +200,20 @@ static ASM void RealMode(register u32 addr) void __OSInitMemoryProtection() { -#if defined(VERSION_DPIJ01_PIKIDEMO) - u32 padding[4]; -#else - u32 padding[8]; +#if OS_BUILD_VERSION >= 20011112L u32 simulatedSize; BOOL enabled; - simulatedSize = OSGetConsoleSimulatedMemSize(); -#endif + STACK_PAD_VAR(8); -#if defined(VERSION_DPIJ01_PIKIDEMO) -#else - enabled = OSDisableInterrupts(); + simulatedSize = OSGetConsoleSimulatedMemSize(); + enabled = OSDisableInterrupts(); if (simulatedSize <= 0x1800000) { RealMode((u32)&Config24MB); } else if (simulatedSize <= 0x3000000) { RealMode((u32)&Config48MB); } +#else + STACK_PAD_VAR(4); #endif __MEMRegs[16] = 0; @@ -237,8 +233,7 @@ void __OSInitMemoryProtection() __OSUnmaskInterrupts(OS_INTERRUPTMASK_MEM_ADDRESS); -#if defined(VERSION_DPIJ01_PIKIDEMO) -#else +#if OS_BUILD_VERSION >= 20011112L OSRestoreInterrupts(enabled); #endif } diff --git a/src/os/OSReboot.c b/src/os/OSReboot.c index 04e467b8..131afba1 100644 --- a/src/os/OSReboot.c +++ b/src/os/OSReboot.c @@ -2,7 +2,7 @@ #include "Dolphin/os.h" #include -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L static void* SaveStart = NULL; static void* SaveEnd = NULL; #endif @@ -113,14 +113,14 @@ void __OSReboot(u32 resetCode, u32 bootDol) OS_HOT_RESET_CODE = resetCode; OS_UNK_CODE = 0; OS_REBOOT_BOOL = TRUE; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L BOOT_REGION_START = SaveStart; BOOT_REGION_END = SaveEnd; #endif OSClearContext(&exceptionContext); OSSetCurrentContext(&exceptionContext); DVDInit(); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L DVDSetAutoInvalidation(TRUE); #endif diff --git a/src/os/OSReset.c b/src/os/OSReset.c index b9addd7c..000d1704 100644 --- a/src/os/OSReset.c +++ b/src/os/OSReset.c @@ -168,13 +168,13 @@ void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu) BOOL rc; BOOL disableRecalibration; BOOL enabled; -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) - int stack, stack2; +#if OS_BUILD_VERSION >= 20011002L + STACK_PAD_VAR(2); #endif OSDisableScheduler(); __OSStopAudioSystem(); -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L if (reset == OS_RESET_SHUTDOWN) { disableRecalibration = __PADDisableRecalibration(TRUE); } @@ -184,11 +184,12 @@ void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu) ; } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) - if (reset == OS_RESET_HOTRESET && forceMenu) { +#if OS_BUILD_VERSION >= 20011002L + if (reset == OS_RESET_HOTRESET && forceMenu) #else - if (reset && forceMenu) { + if (reset && forceMenu) #endif + { OSSram* sram; sram = __OSLockSram(); @@ -200,28 +201,30 @@ void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu) } } -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011112L OSDisableInterrupts(); #else enabled = OSDisableInterrupts(); #endif CallResetFunctions(TRUE); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L LCDisable(); #endif if (reset == OS_RESET_HOTRESET) { __OSDoHotReset(resetCode); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) - } else if (reset == OS_RESET_RESTART) { + } +#if OS_BUILD_VERSION >= 20011002L + else if (reset == OS_RESET_RESTART) #else - } else { + else #endif + { KillThreads(); OSEnableScheduler(); __OSReboot(resetCode, forceMenu); } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L KillThreads(); memset(OSPhysicalToCached(0x40), 0, 0xcc - 0x40); memset(OSPhysicalToCached(0xd4), 0, 0xe8 - 0xd4); @@ -230,8 +233,7 @@ void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu) memset(OSPhysicalToCached(0x30c8), 0, 0xd4 - 0xc8); // memset(OSPhysicalToCached(0x30e2), 0, 1); -#if defined(VERSION_DPIJ01_PIKIDEMO) -#else +#if OS_BUILD_VERSION >= 20011112L __PADDisableRecalibration(disableRecalibration); #endif @@ -241,7 +243,6 @@ void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu) #endif } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) extern volatile u8 DAT_800030e2 AT_ADDRESS(0x800030e2); typedef struct Unk { u8 pad[0x24]; @@ -261,4 +262,3 @@ u32 OSGetResetCode(void) return ((DAT_cc003000.resetCode & ~7) >> 3); // UNUSED FUNCTION } -#endif diff --git a/src/os/OSResetSW.c b/src/os/OSResetSW.c index 746b908e..43403c40 100644 --- a/src/os/OSResetSW.c +++ b/src/os/OSResetSW.c @@ -42,6 +42,11 @@ OSResetCallback OSSetResetCallback(OSResetCallback) // UNUSED FUNCTION } +#if OS_BUILD_VERSION >= 20011002L + +/** + * @TODO: Documentation + */ BOOL OSGetResetButtonState(void) { BOOL enabled; @@ -78,27 +83,28 @@ BOOL OSGetResetButtonState(void) } LastState = state; -#if defined(VERSION_DPIJ01_PIKIDEMO) - if (LastState == FALSE && GameChoice & 0x3f) { +#if OS_BUILD_VERSION >= 20011112L + if (GameChoice & 0x3f) #else - if (GameChoice & 0x3f) { + if (LastState == FALSE && GameChoice & 0x3f) #endif + { OSTime fire = (GameChoice & 0x3f) * 60; fire = __OSStartTime + OSSecondsToTicks(fire); if (fire < now) { now -= fire; now = OSTicksToSeconds(now) / 2; -#if defined(VERSION_DPIJ01_PIKIDEMO) - if ((now & 1) == 0 || Down) { - state = TRUE; - } -#else +#if OS_BUILD_VERSION >= 20011112L if ((now & 1) == 0) { state = TRUE; } else { state = FALSE; } +#else + if ((now & 1) == 0 || Down) { + state = TRUE; + } #endif } } @@ -107,19 +113,20 @@ BOOL OSGetResetButtonState(void) return state; } +#endif + /** * @TODO: Documentation */ BOOL OSGetResetSwitchState(void) { +#if OS_BUILD_VERSION >= 20011112L + return OSGetResetButtonState(); +#else BOOL enabled; BOOL state; u32 reg; -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_GPIP01_00) - return OSGetResetButtonState(); -#endif - enabled = OSDisableInterrupts(); reg = __PIRegs[PI_INTRPT_SRC]; @@ -148,4 +155,5 @@ BOOL OSGetResetSwitchState(void) OSRestoreInterrupts(enabled); return state; +#endif } diff --git a/src/os/OSRtc.c b/src/os/OSRtc.c index 4a02c065..7052ddb6 100644 --- a/src/os/OSRtc.c +++ b/src/os/OSRtc.c @@ -259,7 +259,7 @@ u32 OSGetSoundMode(void) { OSSram* sram; u32 mode; - u32 tmp; // dumbass compiler + STACK_PAD_VAR(1); // dumbass compiler sram = LockSram(0); mode = (sram->flags & 0x4) ? OS_SOUND_MODE_STEREO : OS_SOUND_MODE_MONO; @@ -273,7 +273,7 @@ u32 OSGetSoundMode(void) void OSSetSoundMode(u32 mode) { OSSram* sram; - u32 tmp; // dumbass compiler + STACK_PAD_VAR(1); // dumbass compiler mode <<= 2; mode &= 4; @@ -299,20 +299,14 @@ static inline OSSram* __OSLockSramHACK() */ u32 OSGetProgressiveMode(void) { -#if defined(VERSION_G98E01_PIKIDEMO) || defined(VERSION_G98P01_PIKIDEMO) OSSram* sram; u32 mode; +#if OS_BUILD_VERSION >= 20011112L sram = __OSLockSramHACK(); mode = (sram->flags & 0x80) >> 7; - __OSUnlockSram(FALSE); - return mode; #else - - OSSram* sram; - u32 mode; - u32 tmp; // dumbass compiler - u32 tmp2; // dumbass compiler + STACK_PAD_VAR(2); // dumbass compiler sram = LockSram(0); if (sram->flags & 0x80) { @@ -320,9 +314,9 @@ u32 OSGetProgressiveMode(void) } else { mode = 0; } +#endif __OSUnlockSram(FALSE); return mode; -#endif } /** @@ -331,7 +325,7 @@ u32 OSGetProgressiveMode(void) void OSSetProgressiveMode(u32 mode) { OSSram* sram; - u32 tmp; // dumbass compiler + STACK_PAD_VAR(1); // dumbass compiler mode <<= 7; mode &= 0x80; @@ -406,7 +400,12 @@ void __OSSetBootMode(void) { // UNUSED FUNCTION } -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01_00) + +#if OS_BUILD_VERSION >= 20011002L + +/** + * This was moved from Pad.c + */ u16 OSGetWirelessID(s32 channel) { OSSramEx* sram; @@ -418,6 +417,9 @@ u16 OSGetWirelessID(s32 channel) return id; } +/** + * This was moved from Pad.c + */ void OSSetWirelessID(s32 channel, u16 id) { OSSramEx* sram; @@ -431,4 +433,5 @@ void OSSetWirelessID(s32 channel, u16 id) __OSUnlockSramEx(FALSE); } + #endif diff --git a/src/os/OSSerial.c b/src/os/OSSerial.c index 57275e39..350a5f56 100644 --- a/src/os/OSSerial.c +++ b/src/os/OSSerial.c @@ -14,7 +14,8 @@ static BOOL __SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u static BOOL SIGetResponseRaw(s32 chan); static void GetTypeCallback(s32 chan, u32 error, OSContext* context); -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L + static u32 Type[SI_MAX_CHAN] = { SI_ERROR_NO_RESPONSE, SI_ERROR_NO_RESPONSE, @@ -43,7 +44,7 @@ BOOL SIBusy(void) return Si.chan != -1 ? TRUE : FALSE; } -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L BOOL SIIsChanBusy(s32 chan) { return (Packet[chan].chan != -1 || Si.chan == chan); @@ -53,10 +54,10 @@ static void SIClearTCInterrupt() { u32 reg; - reg = __SIRegs[13]; + reg = __SIRegs[SI_CC_STAT]; reg |= 0x80000000; reg &= ~0x00000001; - __SIRegs[13] = reg; + __SIRegs[SI_CC_STAT] = reg; } #endif @@ -65,36 +66,42 @@ static void SIClearTCInterrupt() */ static u32 CompleteTransfer(void) { -#if defined(VERSION_PIKIDEMO) - u32 sr; u32 i; u32 rLen; u8* input; + u32 temp; - sr = __SIRegs[14]; + sr = __SIRegs[SI_STAT]; + +#if OS_BUILD_VERSION >= 20011002L SIClearTCInterrupt(); +#else + __SIRegs[SI_CC_STAT] = 1 << 31; +#endif if (Si.chan != -1) { +#if OS_BUILD_VERSION >= 20011002L XferTime[Si.chan] = __OSGetSystemTime(); +#endif input = Si.input; - - rLen = Si.inputBytes / 4; + rLen = Si.inputBytes / 4; for (i = 0; i < rLen; i++) { - *(u32*)input = __SIRegs[32 + i]; + *(u32*)input = __SIRegs[SI_IO_BUFFER + i]; input += 4; } rLen = Si.inputBytes & 3; - if (rLen) { - u32 temp = __SIRegs[32 + i]; + if (rLen != 0) { + temp = __SIRegs[SI_IO_BUFFER + i]; for (i = 0; i < rLen; i++) { - *input++ = (u8)((temp >> ((3 - i) * 8)) & 0xff); + *(input++) = temp >> ((3 - i) * 8); } } - if (__SIRegs[13] & 0x20000000) { +#if OS_BUILD_VERSION >= 20011002L + if (__SIRegs[SI_CC_STAT] & 0x20000000) { sr >>= 8 * (3 - Si.chan); sr &= 0xf; @@ -108,42 +115,13 @@ static u32 CompleteTransfer(void) TypeTime[Si.chan] = __OSGetSystemTime(); sr = 0; } - - Si.chan = -1; - } - return sr; - #else - u32 sr; - u32 i; - u32 rLen; - u8* input; - u32 temp; - - sr = __SIRegs[SI_STAT]; - __SIRegs[SI_CC_STAT] = 1 << 31; - - if (Si.chan != -1) { - input = Si.input; - rLen = (Si.inputBytes / 4); - for (i = 0; i < rLen; i++) { - *((u32*)input)++ = __SIRegs[i + 0x20]; - } - - rLen = Si.inputBytes & 3; - if (rLen != 0) { - temp = __SIRegs[i + 32]; - for (i = 0; i < rLen; i++) { - *(input++) = temp >> ((3 - i) * 8); - } - } - sr >>= ((3 - Si.chan) * 8); + sr >>= 8 * (3 - Si.chan); sr &= 0xF; +#endif Si.chan = -1; } - return sr; -#endif } /** @@ -159,11 +137,12 @@ void SITransferNext(s32 chan) ++chan; chan %= SI_MAX_CHAN; packet = &Packet[chan]; -#if defined(VERSION_PIKIDEMO) - if (packet->chan != -1 && packet->fire <= __OSGetSystemTime()) { +#if OS_BUILD_VERSION >= 20011002L + if (packet->chan != -1 && packet->fire <= __OSGetSystemTime()) #else - if (packet->chan != -1 && packet->fire <= OSGetTime()) { + if (packet->chan != -1 && packet->fire <= OSGetTime()) #endif + { if (__SITransfer(packet->chan, packet->output, packet->outputBytes, packet->input, packet->inputBytes, packet->callback)) { OSCancelAlarm(&Alarm[chan]); packet->chan = -1; @@ -173,12 +152,12 @@ void SITransferNext(s32 chan) } } -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L static void SIInterruptHandler(__OSInterrupt interrupt, OSContext* context) { u32 reg; - reg = __SIRegs[13]; + reg = __SIRegs[SI_CC_STAT]; if ((reg & 0xc0000000) == 0xc0000000) { s32 chan; @@ -196,9 +175,9 @@ static void SIInterruptHandler(__OSInterrupt interrupt, OSContext* context) callback(chan, sr, context); } - sr = __SIRegs[14]; + sr = __SIRegs[SI_STAT]; sr &= 0xf000000 >> (8 * chan); - __SIRegs[14] = sr; + __SIRegs[SI_STAT] = sr; if (Type[chan] == SI_ERROR_BUSY && !SIIsChanBusy(chan)) { static u32 cmdTypeAndStatus = 0 << 24; @@ -250,7 +229,7 @@ static BOOL SIEnablePollingInterrupt(BOOL enable) int i; enabled = OSDisableInterrupts(); - reg = __SIRegs[13]; + reg = __SIRegs[SI_CC_STAT]; rc = (reg & 0x08000000) ? TRUE : FALSE; if (enable) { reg |= 0x08000000; @@ -261,7 +240,7 @@ static BOOL SIEnablePollingInterrupt(BOOL enable) reg &= ~0x08000000; } reg &= ~0x80000001; - __SIRegs[13] = reg; + __SIRegs[SI_CC_STAT] = reg; OSRestoreInterrupts(enabled); return rc; } @@ -353,14 +332,14 @@ void SIInit(void) __SIRegs[SI_CC_STAT] = 0x80000000; -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L __OSSetInterruptHandler(__OS_INTERRUPT_PI_SI, SIInterruptHandler); #else __OSSetInterruptHandler(__OS_INTERRUPT_PI_SI, SIIntrruptHandler); #endif __OSUnmaskInterrupts(OS_INTERRUPTMASK_PI_SI); -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L SIGetType(0); SIGetType(1); SIGetType(2); @@ -399,8 +378,8 @@ static BOOL __SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u __SIRegs[SI_IO_BUFFER + i] = ((u32*)output)[i]; } -#if defined(VERSION_PIKIDEMO) - comcsr.val = __SIRegs[13]; +#if OS_BUILD_VERSION >= 20011002L + comcsr.val = __SIRegs[SI_CC_STAT]; #else comcsr.val = 0; #endif @@ -429,15 +408,20 @@ void SISync(void) /** * @TODO: Documentation */ +#if OS_BUILD_VERSION >= 20011002L && OS_BUILD_VERSION < 20011112L +u32 SIGetStatus(void) +#else u32 SIGetStatus(s32 chan) +#endif { -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L +#if OS_BUILD_VERSION >= 20011112L BOOL enabled; u32 sr; int chanShift; enabled = OSDisableInterrupts(); - sr = __SIRegs[14]; + sr = __SIRegs[SI_STAT]; chanShift = 8 * (SI_MAX_CHAN - 1 - chan); sr >>= chanShift; if (sr & SI_ERROR_NO_RESPONSE) { @@ -447,6 +431,9 @@ u32 SIGetStatus(s32 chan) } OSRestoreInterrupts(enabled); return sr; +#else + // Something else +#endif #else return __SIRegs[SI_STAT]; #endif @@ -559,12 +546,19 @@ u32 SIDisablePolling(u32 poll) return poll; } -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L +/** + * @TODO: Documentation + */ static BOOL SIGetResponseRaw(s32 chan) { u32 sr; +#if OS_BUILD_VERSION >= 20011002L && OS_BUILD_VERSION < 20011112L + sr = SIGetStatus(); +#else sr = SIGetStatus(chan); +#endif if (sr & SI_ERROR_RDST) { InputBuffer[chan][0] = __SIRegs[3 * chan + 1]; InputBuffer[chan][1] = __SIRegs[3 * chan + 2]; @@ -578,9 +572,13 @@ static BOOL SIGetResponseRaw(s32 chan) /** * @TODO: Documentation */ -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L BOOL SIGetResponse(s32 chan, void* data) +#else +void SIGetResponse(s32 chan, void* data) +#endif { +#if OS_BUILD_VERSION >= 20011002L BOOL rc; BOOL enabled; @@ -595,8 +593,6 @@ BOOL SIGetResponse(s32 chan, void* data) OSRestoreInterrupts(enabled); return rc; #else -void SIGetResponse(s32 chan, void* data) -{ ((u32*)data)[0] = __SIRegs[chan * 3 + 1]; ((u32*)data)[1] = __SIRegs[chan * 3 + 2]; #endif @@ -625,53 +621,39 @@ static void AlarmHandler(OSAlarm* alarm, OSContext* context) */ BOOL SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u32 inputBytes, SICallback callback, OSTime delay) { -#if defined(VERSION_PIKIDEMO) BOOL enabled; - SIPacket* packet = &Packet[chan]; + SIPacket* packet; OSTime now; +#if OS_BUILD_VERSION >= 20011002L OSTime fire; +#endif + packet = &Packet[chan]; enabled = OSDisableInterrupts(); - if (packet->chan != -1 || Si.chan == chan) { + +#if OS_BUILD_VERSION >= 20011002L + if (packet->chan != -1 || Si.chan == chan) +#else + if (packet->chan != -1) +#endif + { OSRestoreInterrupts(enabled); return FALSE; } +#if OS_BUILD_VERSION >= 20011002L now = __OSGetSystemTime(); if (delay == 0) { fire = now; } else { fire = XferTime[chan] + delay; } + if (now < fire) { delay = fire - now; OSSetAlarm(&Alarm[chan], delay, AlarmHandler); - } else if (__SITransfer(chan, output, outputBytes, input, inputBytes, callback)) { - OSRestoreInterrupts(enabled); - return TRUE; } - - packet->chan = chan; - packet->output = output; - packet->outputBytes = outputBytes; - packet->input = input; - packet->inputBytes = inputBytes; - packet->callback = callback; - packet->fire = fire; - - OSRestoreInterrupts(enabled); - return TRUE; #else - BOOL enabled; - SIPacket* packet = &Packet[chan]; - OSTime now; - - enabled = OSDisableInterrupts(); - if (packet->chan != -1) { - OSRestoreInterrupts(enabled); - return FALSE; - } - now = OSGetTime(); if (delay == 0) { delay = now; @@ -679,7 +661,9 @@ BOOL SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u32 inputB if (now < delay) { OSSetAbsAlarm(&Alarm[chan], delay, AlarmHandler); - } else if (__SITransfer(chan, output, outputBytes, input, inputBytes, callback)) { + } +#endif + else if (__SITransfer(chan, output, outputBytes, input, inputBytes, callback)) { OSRestoreInterrupts(enabled); return TRUE; } @@ -690,14 +674,17 @@ BOOL SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u32 inputB packet->input = input; packet->inputBytes = inputBytes; packet->callback = callback; - packet->fire = delay; +#if OS_BUILD_VERSION >= 20011002L + packet->fire = fire; +#else + packet->fire = delay; +#endif OSRestoreInterrupts(enabled); return TRUE; -#endif } -#if defined(VERSION_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011002L static void CallTypeAndStatusCallback(s32 chan, u32 type) { @@ -881,10 +868,12 @@ char* SIGetTypeString(u32 type) { return "Keyboard"; } - // case SI_GC_STEERING: - // { - // return "Steering"; - // } +#if 0 + case SI_GC_STEERING: + { + return "Steering"; + } +#endif } } diff --git a/src/os/OSUartExi.c b/src/os/OSUartExi.c index 6a5f24b8..b2209696 100644 --- a/src/os/OSUartExi.c +++ b/src/os/OSUartExi.c @@ -56,11 +56,7 @@ u32 WriteUARTN(const void* buf, u32 len) u32 cmd; int qLen; s32 xLen; -#if defined(VERSION_PIKIDEMO) char* ptr; -#else - u8* ptr; -#endif BOOL locked; u32 error; @@ -72,11 +68,7 @@ u32 WriteUARTN(const void* buf, u32 len) return 0; } -#if defined(VERSION_PIKIDEMO) for (ptr = (char*)buf; ptr - (char*)buf < len; ptr++) { -#else - for (ptr = (u8*)buf; ptr - (u8*)buf < len; ptr++) { -#endif if (*ptr == '\n') *ptr = '\r'; } @@ -106,7 +98,7 @@ u32 WriteUARTN(const void* buf, u32 len) break; xLen = (len < 4) ? (s32)len : 4; EXIImm(0, (void*)buf, xLen, EXI_WRITE, NULL); - (u8*)buf += xLen; + (char*)buf += xLen; len -= xLen; qLen -= xLen; EXISync(0); diff --git a/src/os/__start.c b/src/os/__start.c index 09ccae16..b5f5edcc 100644 --- a/src/os/__start.c +++ b/src/os/__start.c @@ -23,7 +23,7 @@ static void __init_data(void); extern u16 Pad3Button AT_ADDRESS(PAD3_BUTTON_ADDR); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01) +#if OS_BUILD_VERSION >= 20011002L static void __check_pad3(void) { if ((Pad3Button & 0x0eef) == 0x0eef) { @@ -106,7 +106,7 @@ WEAKFUNC ASM void __start(void) _end_of_parseargs: bl DBInit bl OSInit -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIP01) +#if OS_BUILD_VERSION >= 20011002L lis r4, 0x8000 addi r4, r4, 0x30e6 lhz r3, 0x0(r4) diff --git a/src/pad/Pad.c b/src/pad/Pad.c index 90867087..8b91516b 100644 --- a/src/pad/Pad.c +++ b/src/pad/Pad.c @@ -4,96 +4,78 @@ #include #include -#define LATENCY 8 - -#define PAD_ALL \ - (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP | PAD_TRIGGER_Z | PAD_TRIGGER_R | PAD_TRIGGER_L | PAD_BUTTON_A \ - | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_MENU | 0x2000 | 0x0080) - -#define RES_WIRELESS_LITE 0x40000 - -extern u16 __OSWirelessPadFixMode AT_ADDRESS(OS_BASE_CACHED | 0x30E0); - -static int Initialized; // size: 0x4, address: 0x0 -static u32 EnabledBits; // size: 0x4, address: 0x4 -static u32 ResettingBits; // size: 0x4, address: 0x8 -#if defined(VERSION_GPIP01_00) +// For ease of implementing multiple revisions, static variables that were renamed go by their final +// names everywhere in this file and are silently renamed for older revisions via the below macros. +#if OS_BUILD_VERSION >= 20011002L #else -static u32 ProbingBits; // size: 0x4, address: 0xC +#define CmdTypeAndStatus cmdTypeAndStatus // This one was renamed only to go unused, lol. +#define CmdReadOrigin cmdReadOrigin +#define CmdCalibrate cmdCalibrate +#define CmdProbeDevice cmdProbeDevice +#define CmdFixDevice cmdFixDevice // This one wasn't renamed, but now it's the odd one out. #endif -static u32 RecalibrateBits; // size: 0x4, address: 0x10 -static u32 WaitingBits; // size: 0x4, address: 0x14 -static u32 CheckingBits; // size: 0x4, address: 0x18 -#if defined(VERSION_GPIP01_00) -static u32 PendingBits; -#else -static u32 cmdTypeAndStatus; -#endif +#define RES_WIRELESS_LITE 0x40000 -#if defined(VERSION_GPIP01_00) -#else -static u32 PADType[PAD_MAX_CONTROLLERS]; // size: 0x10, address: 0x0 -#endif -static u32 Type[PAD_MAX_CONTROLLERS]; // size: 0x10, address: 0x0 -static struct PADStatus Origin[PAD_MAX_CONTROLLERS]; // size: 0x30, address: 0x10 -#if defined(VERSION_GPIP01_00) -static u32 CmdProbeDevice[PAD_MAX_CONTROLLERS]; -static void (*SamplingCallback)(); -#else -static u32 cmdProbeDevice[PAD_MAX_CONTROLLERS]; -static u32 cmdFixDevice[PAD_MAX_CONTROLLERS]; -#endif - -// functions -static u16 GetWirelessID(s32 chan); -static void SetWirelessID(s32 chan, u16 id); -static int DoReset(); -static void PADEnable(s32 chan); -static void ProbeWireless(s32 chan); -static void PADProbeCallback(s32 chan, u32 error, OSContext* context); -static void PADDisable(s32 chan); -static void UpdateOrigin(s32 chan); -static void PADOriginCallback(s32 chan, u32 error, OSContext* context); -static void PADFixCallback(s32 unused, u32 error, struct OSContext* context); -static void PADResetCallback(s32 unused, u32 error, struct OSContext* context); -int PADReset(u32 mask); -BOOL PADRecalibrate(u32 mask); -BOOL PADInit(); +typedef void (*MakeStatusCallback)(s32, PADStatus*, u32*); + +static void PADResetCallback(s32 unused, u32 error, OSContext* context); static void PADTypeAndStatusCallback(s32 chan, u32 type); -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L static void PADReceiveCheckCallback(s32 chan, u32 type); #else static void PADReceiveCheckCallback(s32 chan, u32 error, OSContext* arg2); #endif -u32 PADRead(struct PADStatus* status); -void PADSetSamplingRate(u32 msec); -void __PADTestSamplingRate(u32 tvmode); -void PADControlAllMotors(const u32* commandArray); -void PADControlMotor(s32 chan, u32 command); -void PADSetSpec(u32 spec); -u32 PADGetSpec(); static void SPEC0_MakeStatus(s32 chan, PADStatus* status, u32 data[2]); static void SPEC1_MakeStatus(s32 chan, PADStatus* status, u32 data[2]); -static s8 ClampS8(s8 var, s8 org); -static u8 ClampU8(u8 var, u8 org); static void SPEC2_MakeStatus(s32 chan, PADStatus* status, u32 data[2]); -int PADGetType(s32 chan, u32* type); -BOOL PADSync(void); -void PADSetAnalogMode(u32 mode); static BOOL OnReset(BOOL f); -static s32 ResettingChan = 0x00000020; // size: 0x4, address: 0x0 -static u32 XPatchBits = PAD_CHAN0_BIT | PAD_CHAN1_BIT | PAD_CHAN2_BIT | PAD_CHAN3_BIT; -static u32 AnalogMode = 0x00000300; // size: 0x4, address: 0x4 -static u32 Spec = 0x00000005; // size: 0x4, address: 0x8 -static void (*MakeStatus)(s32, struct PADStatus*, u32*) = SPEC2_MakeStatus; // size: 0x4, address: 0xC -#if defined(VERSION_GPIP01_00) -static u32 CmdReadOrigin = 0x41000000; -static u32 CmdCalibrate = 0x42000000; +extern u16 __OSWirelessPadFixMode AT_ADDRESS(OS_BASE_CACHED | 0x30E0); +extern u8 GameChoice AT_ADDRESS(OS_BASE_CACHED | 0x30E3); +extern u16 DAT_CC00206C AT_ADDRESS(0xCC00206C); // Which hardware register? + +static BOOL Initialized = FALSE; + +static u32 EnabledBits = 0x00000000; +static u32 ResettingBits = 0x00000000; +#if OS_BUILD_VERSION >= 20011002L #else -static u32 cmdReadOrigin = 0x41000000; -static u32 cmdCalibrate = 0x42000000; +static u32 ProbingBits = 0x00000000; +#endif +static u32 RecalibrateBits = 0x00000000; +static u32 WaitingBits = 0x00000000; +static u32 CheckingBits = 0x00000000; +#if OS_BUILD_VERSION >= 20011002L +static u32 PendingBits = 0x00000000; +#endif + +#if OS_BUILD_VERSION >= 20011002L +#else +static u32 PADType[PAD_MAX_CONTROLLERS]; +#endif +static u32 Type[PAD_MAX_CONTROLLERS]; +static PADStatus Origin[PAD_MAX_CONTROLLERS]; + +static s32 ResettingChan = 0x00000020; +static u32 XPatchBits = PAD_CHAN0_BIT | PAD_CHAN1_BIT | PAD_CHAN2_BIT | PAD_CHAN3_BIT; +static u32 AnalogMode = 0x00000300; +static u32 Spec = 0x00000005; +static MakeStatusCallback MakeStatus = SPEC2_MakeStatus; +#if OS_BUILD_VERSION >= 20011002L && OS_BUILD_VERSION < 20011217L +static u32 SamplingRate = 0; // This was moved to SISamplingRate.c +#endif +#if OS_BUILD_VERSION >= 20011002L +static PADSamplingCallback SamplingCallback = NULL; +#endif + +static u32 CmdReadOrigin = 0x41000000; +static u32 CmdCalibrate = 0x42000000; +static u32 CmdTypeAndStatus = 0x00000000; +static u32 CmdProbeDevice[PAD_MAX_CONTROLLERS]; +#if OS_BUILD_VERSION >= 20011002L +#else +static u32 CmdFixDevice[PAD_MAX_CONTROLLERS]; #endif static OSResetFunctionInfo ResetFunctionInfo = { @@ -103,68 +85,117 @@ static OSResetFunctionInfo ResetFunctionInfo = { NULL, }; +#if OS_BUILD_VERSION >= 20011002L +extern u32 __PADFixBits; // This was moved to SIBios.c +#else +u32 __PADFixBits; +#endif +u32 __PADSpec; + +// TODO: This struct changed / moved a lot. +typedef struct XY { +#if OS_BUILD_VERSION >= 20011002L + u16 line; +#else + u8 line; +#endif + u8 count; +} XY; + +#if OS_BUILD_VERSION >= 20011217L +extern XY XYNTSC[12]; // This was moved to SISamplingRate.c +extern XY XYPAL[12]; // This was moved to SISamplingRate.c +#else +static XY XYNTSC[12] = { +#if OS_BUILD_VERSION >= 20011002L + { 0xF6, 0x02 }, { 0x0E, 0x13 }, { 0x1E, 0x09 }, +#else + { 0xF7, 0x02 }, { 0x0E, 0x13 }, { 0x1D, 0x09 }, +#endif + { 0x25, 0x07 }, { 0x34, 0x05 }, { 0x41, 0x04 }, { 0x57, 0x03 }, { 0x57, 0x03 }, + { 0x57, 0x03 }, { 0x83, 0x02 }, { 0x83, 0x02 }, { 0x83, 0x02 }, +}; +static XY XYPAL[12] = { +#if OS_BUILD_VERSION >= 20011002L + { 0x128, 0x02 }, +#else + { 0x94, 0x03 }, +#endif + { 0x0D, 0x18 }, { 0x1A, 0x0C }, { 0x27, 0x08 }, { 0x34, 0x06 }, { 0x3E, 0x05 }, { 0x4E, 0x04 }, + { 0x68, 0x03 }, { 0x68, 0x03 }, { 0x68, 0x03 }, { 0x68, 0x03 }, { 0x9C, 0x02 }, +}; +#endif + +#if OS_BUILD_VERSION >= 20011002L +#else + /** - * @TODO: Documentation + * This was moved to OSRtc.c * @note UNUSED Size: 000044 */ static u16 GetWirelessID(s32 chan) { - struct OSSramEx* sram; + OSSramEx* sram; u16 id; sram = __OSLockSramEx(); id = sram->wirelessPadID[chan]; - __OSUnlockSramEx(0); + __OSUnlockSramEx(FALSE); return id; } /** - * @TODO: Documentation + * This was moved to OSRtc.c * @note UNUSED Size: 000068 */ static void SetWirelessID(s32 chan, u16 id) { - struct OSSramEx* sram = __OSLockSramEx(); + OSSramEx* sram = __OSLockSramEx(); if (sram->wirelessPadID[chan] != id) { sram->wirelessPadID[chan] = id; - __OSUnlockSramEx(1); + __OSUnlockSramEx(TRUE); return; } - __OSUnlockSramEx(0); + __OSUnlockSramEx(FALSE); } +#endif + /** * @TODO: Documentation */ -static int DoReset(void) +#if OS_BUILD_VERSION >= 20011002L +static void DoReset(void) +#else +static BOOL DoReset(void) +#endif { -#if defined(VERSION_GPIP01_00) u32 chanBit; +#if OS_BUILD_VERSION >= 20011002L #else - int rc; - u32 chanBit; - rc = 1; + BOOL rc; + rc = TRUE; #endif ResettingChan = __mwerks_cntlzw(ResettingBits); -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (ResettingChan != 0x20) { chanBit = PAD_CHAN0_BIT >> ResettingChan; ResettingBits &= ~chanBit; - memset(&Origin[ResettingChan], 0, 0xc); + memset(&Origin[ResettingChan], 0, sizeof(PADStatus)); SIGetTypeAsync(ResettingChan, PADTypeAndStatusCallback); } #else if ((ResettingChan >= 0) && (ResettingChan < 4)) { - memset(&Origin[ResettingChan], 0, 0xC); + memset(&Origin[ResettingChan], 0, sizeof(PADStatus)); Type[ResettingChan] = 0; PADType[ResettingChan] = 0; - rc = SITransfer(ResettingChan, &cmdTypeAndStatus, 1, &Type[ResettingChan], 3, PADResetCallback, 0); - chanBit = (0x80000000 >> ResettingChan); + rc = SITransfer(ResettingChan, &CmdTypeAndStatus, 1, &Type[ResettingChan], 3, PADResetCallback, 0); + chanBit = PAD_CHAN0_BIT >> ResettingChan; ResettingBits &= ~chanBit; - if (rc == 0) { + if (!rc) { ResettingChan = 0x20; ResettingBits = 0; } @@ -175,7 +206,7 @@ static int DoReset(void) /** * @TODO: Documentation - * @note UNUSED Size: 000060 + * @note UNUSED Size: 000060 (Matching by size) */ static void PADEnable(s32 chan) { @@ -183,7 +214,7 @@ static void PADEnable(s32 chan) u32 chanBit; u32 data[2]; - chanBit = 0x80000000 >> chan; + chanBit = PAD_CHAN0_BIT >> chan; EnabledBits |= chanBit; SIGetResponse(chan, &data); OSAssertLine(0x1C4, !(Type[chan] & RES_WIRELESS_LITE)); @@ -192,8 +223,9 @@ static void PADEnable(s32 chan) SIEnablePolling(EnabledBits); } -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L #else + /** * @TODO: Documentation * @note UNUSED Size: 0000C0 @@ -205,7 +237,7 @@ static void ProbeWireless(s32 chan) u32 type; u32 data[2]; - chanBit = 0x80000000 >> chan; + chanBit = PAD_CHAN0_BIT >> chan; EnabledBits |= chanBit; ProbingBits |= chanBit; SIGetResponse(chan, &data); @@ -220,12 +252,9 @@ static void ProbeWireless(s32 chan) SISetCommand(chan, cmd); SIEnablePolling(EnabledBits); } -#endif -#if defined(VERSION_GPIP01_00) -#else /** - * @TODO: Documentation + * This was moved to later in this file. */ static void PADProbeCallback(s32 chan, u32 error, OSContext* context) { @@ -233,8 +262,7 @@ static void PADProbeCallback(s32 chan, u32 error, OSContext* context) OSAssertLine(0x1F6, chan == ResettingChan); if (!(error & (SI_ERROR_UNDER_RUN | SI_ERROR_OVER_RUN | SI_ERROR_NO_RESPONSE | SI_ERROR_COLLISION))) { - u32 type; - type = Type[chan]; + u32 type = Type[chan]; if (!(type & 0x80000) && !(type & 0x40000)) { PADEnable(ResettingChan); WaitingBits |= PAD_CHAN0_BIT >> ResettingChan; @@ -244,6 +272,7 @@ static void PADProbeCallback(s32 chan, u32 error, OSContext* context) } DoReset(); } + #endif /** @@ -261,7 +290,7 @@ static void PADDisable(s32 chan) EnabledBits &= ~chanBit; WaitingBits &= ~chanBit; CheckingBits &= ~chanBit; -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L PendingBits &= ~chanBit; OSSetWirelessID(chan, 0); #else @@ -280,7 +309,7 @@ static void UpdateOrigin(s32 chan) PADStatus* origin; u32 chanBit; - chanBit = 0x80000000 >> chan; + chanBit = PAD_CHAN0_BIT >> chan; origin = &Origin[chan]; switch (AnalogMode & 0x00000700u) { case 0x00000000u: @@ -325,11 +354,12 @@ static void UpdateOrigin(s32 chan) origin->substickX -= 128; origin->substickY -= 128; -#if defined(VERSION_GPIP01_00) - if ((XPatchBits & chanBit) != 0 && origin->stickX > 64 && (SIGetType(chan) & 0xFFFF0000) == SI_GC_CONTROLLER) { +#if OS_BUILD_VERSION >= 20011002L + if ((XPatchBits & chanBit) != 0 && origin->stickX > 64 && (SIGetType(chan) & 0xFFFF0000) == SI_GC_CONTROLLER) #else - if ((XPatchBits & chanBit) != 0 && origin->stickX > 64 && (Type[chan] & 0xFFFF0000) == SI_GC_CONTROLLER) { + if ((XPatchBits & chanBit) != 0 && origin->stickX > 64 && (Type[chan] & 0xFFFF0000) == SI_GC_CONTROLLER) #endif + { origin->stickX = 0; } } @@ -358,16 +388,16 @@ static void PADOriginUpdateCallback(s32 chan, u32 error, OSContext* context) return; if (!(error & (SI_ERROR_UNDER_RUN | SI_ERROR_OVER_RUN | SI_ERROR_NO_RESPONSE | SI_ERROR_COLLISION))) UpdateOrigin(chan); - -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if ((error & SI_ERROR_NO_RESPONSE)) PADDisable(chan); #endif } -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L + /** - * @TODO: Documentation + * This was moved from earlier in this file. */ static void PADProbeCallback(s32 chan, u32 error, OSContext* context) { @@ -380,14 +410,15 @@ static void PADProbeCallback(s32 chan, u32 error, OSContext* context) } DoReset(); } -#endif -#if defined(VERSION_GPIP01_00) +/** + * @TODO: Documentation + */ static void PADTypeAndStatusCallback(s32 chan, u32 type) { u32 chanBit; u32 recalibrate; - int rc; + BOOL rc; u32 error; rc = TRUE; @@ -428,14 +459,14 @@ static void PADTypeAndStatusCallback(s32 chan, u32 type) } } - if (rc == 0) { + if (!rc) { PendingBits |= chanBit; DoReset(); } } /** - * @TODO: Documentation + * This was moved from later in this file */ static void PADReceiveCheckCallback(s32 chan, u32 type) { @@ -461,12 +492,13 @@ static void PADReceiveCheckCallback(s32 chan, u32 type) PADDisable(chan); } } -#endif + +#else /** * @TODO: Documentation */ -static void PADFixCallback(s32 unused, u32 error, struct OSContext* context) +static void PADFixCallback(s32 unused, u32 error, OSContext* context) { u32 type; u32 id; @@ -482,32 +514,20 @@ static void PADFixCallback(s32 unused, u32 error, struct OSContext* context) return; } if ((type & 0x40000000) && !(type & 0x80000) && !(type & 0x40000)) { -#if defined(VERSION_GPIP01_00) SITransfer(ResettingChan, &CmdReadOrigin, 1, &Origin[ResettingChan], 0xA, PADOriginCallback, 0); -#else - SITransfer(ResettingChan, &cmdReadOrigin, 1, &Origin[ResettingChan], 0xA, PADOriginCallback, 0); -#endif return; } frame = (ResettingChan << 0x16) | 0x4D000000 | (__OSWirelessPadFixMode << 8) & 0x3FFF00u; -#if defined(VERSION_GPIP01_00) SITransfer(ResettingChan, &CmdProbeDevice[ResettingChan], 3, &Origin[ResettingChan], 8, PADProbeCallback, 0); -#else - SITransfer(ResettingChan, &cmdProbeDevice[ResettingChan], 3, &Origin[ResettingChan], 8, PADProbeCallback, 0); -#endif return; } DoReset(); } -#if defined(VERSION_GPIP01_00) -#else -u32 __PADFixBits; // size: 0x4, address: 0x24 - /** * @TODO: Documentation */ -static void PADResetCallback(s32 unused, u32 error, struct OSContext* context) +static void PADResetCallback(s32 unused, u32 error, OSContext* context) { u32 type; u32 id; @@ -522,7 +542,7 @@ static void PADResetCallback(s32 unused, u32 error, struct OSContext* context) } PADType[ResettingChan] = type = Type[ResettingChan]; - chanBit = 0x80000000 >> ResettingChan; + chanBit = PAD_CHAN0_BIT >> ResettingChan; recalibrate = RecalibrateBits & chanBit; RecalibrateBits &= ~chanBit; fix = __PADFixBits & chanBit; @@ -544,16 +564,16 @@ static void PADResetCallback(s32 unused, u32 error, struct OSContext* context) return; } if (recalibrate != 0) { - SITransfer(ResettingChan, &cmdCalibrate, 3, &Origin[ResettingChan], 0xA, PADOriginCallback, 0); + SITransfer(ResettingChan, &CmdCalibrate, 3, &Origin[ResettingChan], 0xA, PADOriginCallback, 0); return; } - SITransfer(ResettingChan, &cmdReadOrigin, 1, &Origin[ResettingChan], 0xA, PADOriginCallback, 0); + SITransfer(ResettingChan, &CmdReadOrigin, 1, &Origin[ResettingChan], 0xA, PADOriginCallback, 0); return; } id = (GetWirelessID(ResettingChan) << 8); if ((fix != 0) && (id & 0x100000)) { - cmdFixDevice[ResettingChan] = (id & 0xCFFF00) | 0x4E000000 | 0x100000; - SITransfer(ResettingChan, &cmdFixDevice[ResettingChan], 3, &Type[ResettingChan], 3, PADFixCallback, 0); + CmdFixDevice[ResettingChan] = (id & 0xCFFF00) | 0x4E000000 | 0x100000; + SITransfer(ResettingChan, &CmdFixDevice[ResettingChan], 3, &Type[ResettingChan], 3, PADFixCallback, 0); return; } if (type & 0x100000) { @@ -563,204 +583,221 @@ static void PADResetCallback(s32 unused, u32 error, struct OSContext* context) id |= 0x100000; SetWirelessID(ResettingChan, (u16)(id >> 8) & 0xFFFFFF); } - cmdFixDevice[ResettingChan] = id | 0x4E000000; - SITransfer(ResettingChan, &cmdFixDevice[ResettingChan], 3, &Type[ResettingChan], 3, PADFixCallback, 0); + CmdFixDevice[ResettingChan] = id | 0x4E000000; + SITransfer(ResettingChan, &CmdFixDevice[ResettingChan], 3, &Type[ResettingChan], 3, PADFixCallback, 0); return; } if ((type & 0x40000000) && !(type & 0x80000) && !(type & 0x40000)) { - SITransfer(ResettingChan, &cmdReadOrigin, 1, &Origin[ResettingChan], 0xA, PADOriginCallback, 0); + SITransfer(ResettingChan, &CmdReadOrigin, 1, &Origin[ResettingChan], 0xA, PADOriginCallback, 0); return; } - SITransfer(ResettingChan, &cmdProbeDevice[ResettingChan], 3, &Origin[ResettingChan], 8, PADProbeCallback, 0); + SITransfer(ResettingChan, &CmdProbeDevice[ResettingChan], 3, &Origin[ResettingChan], 8, PADProbeCallback, 0); return; } if (type & 0x40000000) { u32 id = (type & 0xCFFF00); id |= 0x100000; SetWirelessID(ResettingChan, (u16)(id >> 8) & 0xFFFFFF); - cmdFixDevice[ResettingChan] = id | 0x4E000000; - SITransfer(ResettingChan, &cmdFixDevice[ResettingChan], 3, &Type[ResettingChan], 3, PADFixCallback, 0); + CmdFixDevice[ResettingChan] = id | 0x4E000000; + SITransfer(ResettingChan, &CmdFixDevice[ResettingChan], 3, &Type[ResettingChan], 3, PADFixCallback, 0); return; } SetWirelessID(ResettingChan, 0); ProbeWireless(ResettingChan); DoReset(); } + #endif /** * @TODO: Documentation */ -int PADReset(u32 mask) +BOOL PADReset(u32 mask) { -#if defined(VERSION_GPIP01_00) BOOL enabled; +#if OS_BUILD_VERSION >= 20011002L +#if OS_BUILD_VERSION >= 20011112L u32 disabledBits; +#endif +#else + BOOL rc = FALSE; +#endif + OSAssertMsgLine(0x392, !(mask & 0x0FFFFFFF), "PADReset(): invalid mask"); enabled = OSDisableInterrupts(); +#if OS_BUILD_VERSION >= 20011002L mask |= PendingBits; PendingBits = 0; mask &= ~(WaitingBits | CheckingBits); ResettingBits |= mask; +#if OS_BUILD_VERSION >= 20011112L disabledBits = ResettingBits & EnabledBits; +#endif EnabledBits &= ~mask; - - if (Spec == PAD_SPEC_4) - RecalibrateBits |= mask; - - SIDisablePolling(disabledBits); - if (ResettingChan == 0x20) - DoReset(); - - OSRestoreInterrupts(enabled); - - return TRUE; #else - int enabled; - int rc; - - rc = 0; - OSAssertMsgLine(0x392, !(mask & 0x0FFFFFFF), "PADReset(): invalid mask"); - - enabled = OSDisableInterrupts(); - mask = mask & ~(CheckingBits | (ProbingBits | WaitingBits)); ResettingBits |= mask; EnabledBits &= ~mask; WaitingBits &= ~mask; +#endif + if (Spec == PAD_SPEC_4) { RecalibrateBits |= mask; } + +#if OS_BUILD_VERSION >= 20011112L + SIDisablePolling(disabledBits); + if (ResettingChan == 0x20) { + DoReset(); + } +#else SIDisablePolling(ResettingBits); if (ResettingChan == 0x20) { +#if OS_BUILD_VERSION >= 20011002L + DoReset(); +#else rc = DoReset(); +#endif } +#endif OSRestoreInterrupts(enabled); + +#if OS_BUILD_VERSION >= 20011002L + return TRUE; +#else return rc; #endif } -u8 GameChoice AT_ADDRESS(OS_BASE_CACHED | 0x30E3); - /** * @TODO: Documentation */ BOOL PADRecalibrate(u32 mask) { - BOOL intrEnabled; - BOOL ret; - - ret = FALSE; - -#if defined(VERSION_GPIP01_00) + BOOL enabled; +#if OS_BUILD_VERSION >= 20011002L +#if OS_BUILD_VERSION >= 20011112L + u32 disabledBits; +#endif #else - OSAssertMsgLine(0x3BD, !(mask & 0x0FFFFFFF), "PADReset(): invalid mask"); + BOOL rc = FALSE; #endif - intrEnabled = OSDisableInterrupts(); -#if defined(VERSION_GPIP01_00) + OSAssertMsgLine(0x3BD, !(mask & 0x0FFFFFFF), "PADRecalibrate(): invalid mask"); + enabled = OSDisableInterrupts(); + +#if OS_BUILD_VERSION >= 20011002L mask |= PendingBits; PendingBits = 0; mask &= ~(WaitingBits | CheckingBits); ResettingBits |= mask; - ret = ResettingBits & EnabledBits; +#if OS_BUILD_VERSION >= 20011112L + disabledBits = ResettingBits & EnabledBits; +#endif #else mask &= ~(CheckingBits | (ProbingBits | WaitingBits)); ResettingBits |= mask; #endif - EnabledBits &= ~mask; -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (!(GameChoice & 0x40)) { RecalibrateBits |= mask; } - SIDisablePolling(ret); +#if OS_BUILD_VERSION >= 20011112L + SIDisablePolling(disabledBits); +#else + SIDisablePolling(ResettingBits); +#endif #else RecalibrateBits |= mask; SIDisablePolling(ResettingBits); #endif -#if defined(VERSION_GPIP01_00) - if ((s32)ResettingChan == 32) + if (ResettingChan == 32) { +#if OS_BUILD_VERSION >= 20011002L DoReset(); - OSRestoreInterrupts(intrEnabled); +#else + rc = DoReset(); +#endif + } + + OSRestoreInterrupts(enabled); + +#if OS_BUILD_VERSION >= 20011002L return TRUE; #else - if ((s32)ResettingChan == 32) - ret = DoReset(); - OSRestoreInterrupts(intrEnabled); - return ret; + return rc; #endif } -u32 __PADSpec; // size: 0x4, address: 0x20 - /** * @TODO: Documentation */ -BOOL PADInit() +BOOL PADInit(void) { s32 chan; + OSTime time; -#if defined(VERSION_GPIP01_00) - if (Initialized) +#if OS_BUILD_VERSION >= 20011002L + if (Initialized) { return TRUE; - - if (__PADSpec) - PADSetSpec(__PADSpec); - - Initialized = TRUE; - - if (__PADFixBits != 0) { - OSTime time = OSGetTime(); - __OSWirelessPadFixMode - = (u16)((((time) & 0xffff) + ((time >> 16) & 0xffff) + ((time >> 32) & 0xffff) + ((time >> 48) & 0xffff)) & 0x3fffu); - RecalibrateBits = PAD_CHAN0_BIT | PAD_CHAN1_BIT | PAD_CHAN2_BIT | PAD_CHAN3_BIT; - } - - for (chan = 0; chan < SI_MAX_CHAN; ++chan) - CmdProbeDevice[chan] = (0x4d << 24) | (chan << 22) | ((__OSWirelessPadFixMode & 0x3fff) << 8); - - SIRefreshSamplingRate(); - OSRegisterResetFunction(&ResetFunctionInfo); + } else #else - OSTime time; - - if (!Initialized) { + if (!Initialized) +#endif + { if (__PADSpec) { PADSetSpec(__PADSpec); } - if (__PADFixBits == -1) { +#if OS_BUILD_VERSION >= 20011217L + Initialized = TRUE; +#endif + +#if OS_BUILD_VERSION >= 20011002L + if (__PADFixBits != 0) +#else + if (__PADFixBits == -1) +#endif + { time = OSGetTime(); __OSWirelessPadFixMode = (u16)((((time) & 0xffff) + ((time >> 16) & 0xffff) + ((time >> 32) & 0xffff) + ((time >> 48) & 0xffff)) & 0x3fffu); +#if OS_BUILD_VERSION >= 20011002L + RecalibrateBits = PAD_CHAN0_BIT | PAD_CHAN1_BIT | PAD_CHAN2_BIT | PAD_CHAN3_BIT; +#endif } - for (chan = 0; chan < SI_MAX_CHAN; chan++) { - cmdProbeDevice[chan] = 0x4D000000 | (chan << 22) | (__OSWirelessPadFixMode & 0x3FFF) << 8; + for (chan = 0; chan < SI_MAX_CHAN; ++chan) { + CmdProbeDevice[chan] = (0x4d << 24) | (chan << 22) | ((__OSWirelessPadFixMode & 0x3fff) << 8); } +#if OS_BUILD_VERSION >= 20011217L + SIRefreshSamplingRate(); +#else Initialized = TRUE; PADSetSamplingRate(0); +#endif OSRegisterResetFunction(&ResetFunctionInfo); } -#endif return PADReset(PAD_CHAN0_BIT | PAD_CHAN1_BIT | PAD_CHAN2_BIT | PAD_CHAN3_BIT); } -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L #else -static void PADReceiveCheckCallback(s32 chan, u32 error, OSContext* arg2) + +/** + * This was moved to earlier in this file + */ +static void PADReceiveCheckCallback(s32 chan, u32 error, OSContext*) { u32 type; u32 chanBit; - type = Type[chan]; - + type = Type[chan]; chanBit = PAD_CHAN0_BIT >> chan; WaitingBits &= ~chanBit; @@ -768,12 +805,13 @@ static void PADReceiveCheckCallback(s32 chan, u32 error, OSContext* arg2) if (EnabledBits & chanBit) { if (!(error & 0xF) && (type & 0x80000000) && (type & 0x02000000) && (type & 0x40000000) && !(type & 0x04000000)) { - SITransfer(chan, &cmdReadOrigin, 1, &Origin[chan], 0xA, PADOriginUpdateCallback, 0); + SITransfer(chan, &CmdReadOrigin, 1, &Origin[chan], 0xA, PADOriginUpdateCallback, 0); return; } PADDisable(chan); } } + #endif /** @@ -781,7 +819,6 @@ static void PADReceiveCheckCallback(s32 chan, u32 error, OSContext* arg2) */ u32 PADRead(PADStatus* status) { -#if defined(VERSION_GPIP01_00) BOOL enabled; s32 chan; u32 data[2]; @@ -790,7 +827,9 @@ u32 PADRead(PADStatus* status) int chanShift; u32 motor; +#if OS_BUILD_VERSION >= 20011002L enabled = OSDisableInterrupts(); +#endif motor = 0; @@ -798,12 +837,14 @@ u32 PADRead(PADStatus* status) chanBit = PAD_CHAN0_BIT >> chan; chanShift = 8 * (SI_MAX_CHAN - 1 - chan); +#if OS_BUILD_VERSION >= 20011002L if (PendingBits & chanBit) { PADReset(0); status->err = PAD_ERR_NOT_READY; memset(status, 0, offsetof(PADStatus, err)); continue; } +#endif if ((ResettingBits & chanBit) || ResettingChan == chan) { status->err = PAD_ERR_NOT_READY; @@ -812,48 +853,81 @@ u32 PADRead(PADStatus* status) } if (!(EnabledBits & chanBit)) { - status->err = (s8)PAD_ERR_NO_CONTROLLER; + status->err = PAD_ERR_NO_CONTROLLER; memset(status, 0, offsetof(PADStatus, err)); continue; } +#if OS_BUILD_VERSION >= 20011002L if (SIIsChanBusy(chan)) { status->err = PAD_ERR_TRANSFER; memset(status, 0, offsetof(PADStatus, err)); continue; } +#endif +#if OS_BUILD_VERSION >= 20011112L sr = SIGetStatus(chan); - if (sr & SI_ERROR_NO_RESPONSE) { + if (sr & SI_ERROR_NO_RESPONSE) +#elif OS_BUILD_VERSION >= 20011002L + sr = SIGetStatus(); + if (sr & (SI_ERROR_NO_RESPONSE << chanShift)) +#else + sr = SIGetStatus(SI_MAX_CHAN - 1 - chan); + if (sr & (SI_ERROR_NO_RESPONSE << chanShift)) +#endif + { +#if OS_BUILD_VERSION >= 20011002L SIGetResponse(chan, data); +#endif if (WaitingBits & chanBit) { - status->err = (s8)PAD_ERR_NONE; + status->err = PAD_ERR_NONE; memset(status, 0, offsetof(PADStatus, err)); if (!(CheckingBits & chanBit)) { +#if OS_BUILD_VERSION >= 20011002L // TODO CheckingBits |= chanBit; SIGetTypeAsync(chan, PADReceiveCheckCallback); +#else + enabled = OSDisableInterrupts(); + if (SITransfer(chan, &CmdTypeAndStatus, 1, &Type[chan], 3, PADReceiveCheckCallback, 0) != 0) { + CheckingBits |= chanBit; + } + OSRestoreInterrupts(enabled); +#endif } - continue; + } else { + PADDisable(chan); + status->err = PAD_ERR_NO_CONTROLLER; + memset(status, 0, offsetof(PADStatus, err)); } - - PADDisable(chan); - - status->err = (s8)PAD_ERR_NO_CONTROLLER; - memset(status, 0, offsetof(PADStatus, err)); continue; } - if (!(SIGetType(chan) & SI_GC_NOMOTOR)) { +#if OS_BUILD_VERSION >= 20011002L + if (!(SIGetType(chan) & SI_GC_NOMOTOR)) +#else + if (!(ProbingBits & chanBit) && !(Type[chan] & SI_GC_NOMOTOR)) +#endif + { motor |= chanBit; } - if (!SIGetResponse(chan, data)) { +#if OS_BUILD_VERSION >= 20011002L + if (!SIGetResponse(chan, data)) +#else + if (!(sr & (0x20 << chanShift))) +#endif + { status->err = PAD_ERR_TRANSFER; memset(status, 0, offsetof(PADStatus, err)); continue; } +#if OS_BUILD_VERSION >= 20011002L +#else + SIGetResponse(chan, &data); +#endif if (data[0] & 0x80000000) { status->err = PAD_ERR_TRANSFER; @@ -861,6 +935,15 @@ u32 PADRead(PADStatus* status) continue; } +#if OS_BUILD_VERSION >= 20011002L +#else + if (ProbingBits & chanBit) { + status->err = PAD_ERR_NO_CONTROLLER; + memset(status, 0, offsetof(PADStatus, err)); + continue; + } +#endif + MakeStatus(chan, status, data); // Check and clear PAD_ORIGIN bit @@ -881,107 +964,38 @@ u32 PADRead(PADStatus* status) status->button &= ~0x0080; } +#if OS_BUILD_VERSION >= 20011002L OSRestoreInterrupts(enabled); - - return motor; -#else - s32 chan; - u32 data[2]; - u32 chanBit; - u32 sr; - int chanShift; - int enabled; - u32 motor; - - motor = 0; - - for (chan = 0; chan < 4; chan++, status++) { - chanBit = 0x80000000 >> chan; - chanShift = (3 - chan) * 8; - if ((ResettingBits & chanBit) || (ResettingChan == chan)) { - status->err = -2; - memset(status, 0, 0xA); - } else if (!(EnabledBits & chanBit)) { - status->err = -1; - memset(status, 0, 0xA); - } else { - sr = SIGetStatus(3 - chan); - if (sr & (8 << chanShift)) { - if (WaitingBits & chanBit) { - status->err = 0; - memset(status, 0, 0xA); - if (!(CheckingBits & chanBit)) { - enabled = OSDisableInterrupts(); - if (SITransfer(chan, &cmdTypeAndStatus, 1, &Type[chan], 3, PADReceiveCheckCallback, 0) != 0) { - CheckingBits |= chanBit; - } - OSRestoreInterrupts(enabled); - } - } else { - PADDisable(chan); - status->err = -1; - memset(status, 0, 0xA); - } - } else { - if (!(ProbingBits & chanBit) && !(Type[chan] & SI_GC_NOMOTOR)) { - motor |= chanBit; - } - if (!(sr & (0x20 << chanShift))) { - status->err = -3; - memset(status, 0, 0xA); - } else { - SIGetResponse(chan, &data); - if (data[0] & 0x80000000) { - status->err = -3; - memset(status, 0, 0xA); - } else if (ProbingBits & chanBit) { - status->err = -1; - memset(status, 0, 0xA); - } else { - MakeStatus(chan, status, data); - if (status->button & 0x2000) { - status->err = -3; - memset(status, 0, 0xA); - SITransfer(chan, &cmdReadOrigin, 1, &Origin[chan], 0xA, PADOriginUpdateCallback, 0); - } else { - status->err = 0; - status->button &= 0xFFFFFF7F; - } - } - } - } - } - } - return motor; #endif + return motor; } -#if defined(VERSION_GPIP01_00) -#else - -typedef struct XY { - /* 0x00 */ u8 line; - /* 0x01 */ u8 count; -} XY; - -static XY XYNTSC[12] = { { 0xF7, 0x02 }, { 0x0E, 0x13 }, { 0x1D, 0x09 }, { 0x25, 0x07 }, { 0x34, 0x05 }, { 0x41, 0x04 }, - { 0x57, 0x03 }, { 0x57, 0x03 }, { 0x57, 0x03 }, { 0x83, 0x02 }, { 0x83, 0x02 }, { 0x83, 0x02 } }; - -static XY XYPAL[12] = { { 0x94, 0x03 }, { 0x0D, 0x18 }, { 0x1A, 0x0C }, { 0x27, 0x08 }, { 0x34, 0x06 }, { 0x3E, 0x05 }, - { 0x4E, 0x04 }, { 0x68, 0x03 }, { 0x68, 0x03 }, { 0x68, 0x03 }, { 0x68, 0x03 }, { 0x9C, 0x02 } }; - /** - * @TODO: Documentation + * This implementation was moved to SISetSamplingRate.c (`SISetSamplingRate`) + * @note UNUSED Size: 000020 (`OS_BUILD_VERSION >= 20011217L`) (Matching by size) */ void PADSetSamplingRate(u32 msec) { +#if OS_BUILD_VERSION >= 20011217L + // It's unclear how this function was stubbed, but you're not supposed to use it anymore. + PPCHalt(); +#else u32 tv; XY* xy; +#if OS_BUILD_VERSION >= 20011002L + BOOL enabled; + int test; +#endif - OSAssertMsgLine(0x4CE, (msec <= 0xB), "PADSetSamplingRate(): out of rage (0 <= msec <= 11)"); - if (msec > 0xB) { - msec = 0xB; + OSAssertMsgLine(0x4CE, (msec <= 11), "PADSetSamplingRate(): out of rage (0 <= msec <= 11)"); + if (msec > 11) { + msec = 11; } +#if OS_BUILD_VERSION >= 20011002L + enabled = OSDisableInterrupts(); + SamplingRate = msec; +#endif + tv = VIGetTvFormat(); switch (tv) { case VI_NTSC: @@ -997,22 +1011,48 @@ void PADSetSamplingRate(u32 msec) } default: { +#if OS_BUILD_VERSION >= 20011112L + OSErrorLine(1174, "PADSetSamplingRate: unknown TV format"); +#elif OS_BUILD_VERSION >= 20011002L + OSErrorLine(1153, "PADSetSamplingRate: unknown TV format"); +#else OSErrorLine(1296, "PADSetSamplingRate: unknown TV format"); +#endif + break; } } +#if OS_BUILD_VERSION >= 20011002L + SISetXY(((DAT_CC00206C & 1) ? 2 : 1) * xy[msec].line, xy[msec].count); +#else SISetXY(xy[msec].line, xy[msec].count); +#endif SIEnablePolling(EnabledBits); + +#if OS_BUILD_VERSION >= 20011002L + OSRestoreInterrupts(enabled); +#endif +#endif +} + +#if OS_BUILD_VERSION >= 20011002L && OS_BUILD_VERSION < 20011217L +/** + * @TODO: Documentation + */ +void __PADRefreshSamplingRate(void) +{ + PADSetSamplingRate(SamplingRate); } #endif -#if defined(VERSION_GPIP01_00) -#else /** * @TODO: Documentation - * @note UNUSED Size: 0000CC + * @note UNUSED Size: 0000CC (OS_BUILD_VERSION < 20011002L) (Matching by size) + * @note UNUSED Size: 0000B8 (OS_BUILD_VERSION >= 20011002L) (Matching by size) */ void PADControlAllMotors(const u32* commandArray) { + // UNUSED FUNCTION + BOOL enabled; int chan; u32 command; @@ -1024,7 +1064,12 @@ void PADControlAllMotors(const u32* commandArray) for (chan = 0; chan < SI_MAX_CHAN; chan++, commandArray++) { chanBit = PAD_CHAN0_BIT >> chan; - if ((EnabledBits & chanBit) && !(ProbingBits & chanBit) && !(Type[chan] & 0x20000000)) { +#if OS_BUILD_VERSION >= 20011002L + if ((EnabledBits & chanBit) && !(SIGetType(chan) & SI_GC_NOMOTOR)) +#else + if ((EnabledBits & chanBit) && !(ProbingBits & chanBit) && !(Type[chan] & SI_GC_NOMOTOR)) +#endif + { command = *commandArray; OSAssertMsgLine(0x545, !(command & 0xFFFFFFFC), "PADControlAllMotors(): invalid command"); if (Spec < PAD_SPEC_2 && command == PAD_MOTOR_STOP_HARD) @@ -1036,9 +1081,7 @@ void PADControlAllMotors(const u32* commandArray) if (commit) SITransferCommands(); OSRestoreInterrupts(enabled); - // UNUSED FUNCTION } -#endif /** * @TODO: Documentation @@ -1052,11 +1095,12 @@ void PADControlMotor(s32 chan, u32 command) enabled = OSDisableInterrupts(); chanBit = PAD_CHAN0_BIT >> chan; -#if defined(VERSION_GPIP01_00) - if ((EnabledBits & chanBit) && !(SIGetType(chan) & SI_GC_NOMOTOR)) { +#if OS_BUILD_VERSION >= 20011002L + if ((EnabledBits & chanBit) && !(SIGetType(chan) & SI_GC_NOMOTOR)) #else - if ((EnabledBits & chanBit) && !(ProbingBits & chanBit) && !(Type[chan] & 0x20000000)) { + if ((EnabledBits & chanBit) && !(ProbingBits & chanBit) && !(Type[chan] & SI_GC_NOMOTOR)) #endif + { if (Spec < PAD_SPEC_2 && command == PAD_MOTOR_STOP_HARD) command = PAD_MOTOR_STOP; SISetCommand(chan, (0x40 << 16) | AnalogMode | (command & (0x00000001 | 0x00000002))); @@ -1097,7 +1141,7 @@ void PADSetSpec(u32 spec) /** * @TODO: Documentation - * @note UNUSED Size: 000008 + * @note UNUSED Size: 000008 (Matching by size) */ u32 PADGetSpec(void) { @@ -1288,7 +1332,7 @@ int PADGetType(s32 chan, u32* type) u32 chanBit; *type = Type[chan]; - chanBit = 0x80000000 >> chan; + chanBit = PAD_CHAN0_BIT >> chan; if (ResettingBits & chanBit || ResettingChan == chan || !(EnabledBits & chanBit)) { return 0; } @@ -1306,11 +1350,10 @@ BOOL PADSync(void) // UNUSED FUNCTION } -#if defined(VERSION_GPIP01_00) -#else /** * @TODO: Documentation - * @note UNUSED Size: 000078 + * @note UNUSED Size: 000078 (OS_BUILD_VERSION < 20011002L) (Matching by size) + * @note UNUSED Size: 000074 (OS_BUILD_VERSION >= 20011002L) (Matching by size) */ void PADSetAnalogMode(u32 mode) { @@ -1321,7 +1364,11 @@ void PADSetAnalogMode(u32 mode) enabled = OSDisableInterrupts(); AnalogMode = mode << 8; - mask = EnabledBits & ~ProbingBits; +#if OS_BUILD_VERSION >= 20011002L + mask = EnabledBits; // This is a guess +#else + mask = EnabledBits & ~ProbingBits; +#endif EnabledBits &= ~mask; WaitingBits &= ~mask; @@ -1331,7 +1378,6 @@ void PADSetAnalogMode(u32 mode) OSRestoreInterrupts(enabled); // UNUSED FUNCTION } -#endif /** * @TODO: Documentation @@ -1341,7 +1387,7 @@ static BOOL OnReset(BOOL f) BOOL sync; static BOOL recalibrated = FALSE; -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L if (SamplingCallback) PADSetSamplingCallback(NULL); #endif @@ -1368,7 +1414,8 @@ void __PADDisableXPatch(void) XPatchBits = 0; } -#if defined(VERSION_GPIP01_00) +#if OS_BUILD_VERSION >= 20011002L + static void SamplingHandler(__OSInterrupt interrupt, OSContext* context) { OSContext exceptionContext; @@ -1382,18 +1429,26 @@ static void SamplingHandler(__OSInterrupt interrupt, OSContext* context) } } +#if OS_BUILD_VERSION >= 20011112L PADSamplingCallback PADSetSamplingCallback(PADSamplingCallback callback) +#else +void PADSetSamplingCallback(PADSamplingCallback callback) +#endif { +#if OS_BUILD_VERSION >= 20011112L PADSamplingCallback prev; + prev = SamplingCallback; +#endif - prev = SamplingCallback; SamplingCallback = callback; if (callback) SIRegisterPollingHandler(SamplingHandler); else SIUnregisterPollingHandler(SamplingHandler); +#if OS_BUILD_VERSION >= 20011112L return prev; +#endif } BOOL __PADDisableRecalibration(BOOL disable) @@ -1410,4 +1465,5 @@ BOOL __PADDisableRecalibration(BOOL disable) OSRestoreInterrupts(enabled); return prev; } + #endif diff --git a/src/plugPikiColin/cinePlayer.cpp b/src/plugPikiColin/cinePlayer.cpp index 3a095dba..2d5eeff2 100644 --- a/src/plugPikiColin/cinePlayer.cpp +++ b/src/plugPikiColin/cinePlayer.cpp @@ -1181,12 +1181,12 @@ void ActorInstance::refresh(immut Matrix4f& mtx, Graphics& gfx, f32* p3) naviMgr->getNavi()->demoDraw(gfx, nullptr); } } else { - u32 flags = mActiveActor->mModel->mSystemFlags; + u32 flags = mActiveActor->mModel->mShapeFlags; if (mFlags & CAF_NoXluSort) { - mActiveActor->mModel->mSystemFlags |= ShapeFlags::AlwaysRedraw; + mActiveActor->mModel->mShapeFlags |= ShapeFlags::AlwaysRedraw; } mActiveActor->mModel->drawshape(gfx, *gfx.mCamera, &mAnimatedMaterials); - mActiveActor->mModel->mSystemFlags = flags; + mActiveActor->mModel->mShapeFlags = flags; } if (modelType == 1) { diff --git a/src/plugPikiColin/game.cpp b/src/plugPikiColin/game.cpp index 7d1a1c39..399cff51 100644 --- a/src/plugPikiColin/game.cpp +++ b/src/plugPikiColin/game.cpp @@ -207,7 +207,7 @@ void FlowController::readMapList(immut char* fileName) /// Load banner textures for each map (as well as one for entering from title). static immut char* levNames[] = { "intro/map0.bti", "intro/ot_map.bti", "intro/map2.bti", "intro/map3.bti", "intro/map4.bti", "intro/loading.bti" }; -#elif defined(VERSION_GPIP01_00) +#elif defined(VERSION_GPIP01) /// Load banner textures for each map. static immut char* levNames[STAGE_COUNT] = { "map0.bti", "map1.bti", "map2.bti", "map3.bti", "map4.bti", @@ -251,32 +251,24 @@ void OnePlayerSection::init() // the demo has a single loading banner for the setup section gameflow.mLevelBannerTex = gameflow.setLoadBanner(levNames[5]); gameflow.mLevelBannerFadeValue = 0.0f; - -#elif defined(VERSION_GPIP01_00) +#else // only show a loading banner during setup for the E3 demos if (gameflow.mNextOnePlayerSectionOnDayEnd >= ONEPLAYER_E3_MIN && gameflow.mNextOnePlayerSectionOnDayEnd <= ONEPLAYER_E3_MAX) { PRINT("setting banner!\n"); +#if defined(VERSION_GPIP01) char bannerTex[128]; sprintf(bannerTex, "%s/%s", dirNames[gameflow.mGamePrefs.getChildMode()], levNames[gameflow.mNextOnePlayerSectionOnDayEnd - ONEPLAYER_E3_STAGE_OFFSET]); - - gameflow.mLevelBannerTex = gameflow.setLoadBanner(bannerTex); - gameflow.mLevelBannerFadeValue = 0.0f; - } else { - gameflow.mLevelBannerTex = nullptr; - } + gameflow.mLevelBannerTex = gameflow.setLoadBanner(bannerTex); #else - // only show a loading banner during setup for the E3 demos - if (gameflow.mNextOnePlayerSectionOnDayEnd >= ONEPLAYER_E3_MIN && gameflow.mNextOnePlayerSectionOnDayEnd <= ONEPLAYER_E3_MAX) { - PRINT("setting banner!\n"); gameflow.mLevelBannerTex = gameflow.setLoadBanner(levNames[gameflow.mNextOnePlayerSectionOnDayEnd - ONEPLAYER_E3_STAGE_OFFSET]); +#endif gameflow.mLevelBannerFadeValue = 0.0f; } else { gameflow.mLevelBannerTex = nullptr; } #endif - currentSection = new GameSetupSection(); gsys->endLoading(); break; @@ -302,7 +294,7 @@ void OnePlayerSection::init() // tutorial level! (impact site for E3 demo) if (!gameflow.mLevelBannerTex) { PRINT("setting banner!\n"); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) char bannerTex[128]; sprintf(bannerTex, "%s/%s", dirNames[gameflow.mGamePrefs.getChildMode()], levNames[nextSectionType - ONEPLAYER_E3_STAGE_OFFSET]); @@ -330,7 +322,7 @@ void OnePlayerSection::init() // forest level 1! (forest of hope day 1 for E3 demo) if (!gameflow.mLevelBannerTex) { PRINT("setting banner!\n"); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) char bannerTex[128]; sprintf(bannerTex, "%s/%s", dirNames[gameflow.mGamePrefs.getChildMode()], levNames[nextSectionType - 2]); gameflow.mLevelBannerTex = gameflow.setLoadBanner(bannerTex); @@ -338,6 +330,7 @@ void OnePlayerSection::init() gameflow.mLevelBannerTex = gameflow.setLoadBanner(levNames[nextSectionType - 2]); #endif } + gsys->startLoading(&gameflow.mGameLoadIdler, true, 60); flowCont.setStage("stages/stage1.ini"); @@ -356,7 +349,7 @@ void OnePlayerSection::init() // forest level 2! (forest of hope day 2 for E3 demo) if (!gameflow.mLevelBannerTex) { PRINT("setting banner!\n"); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) char bannerTex[128]; sprintf(bannerTex, "%s/%s", dirNames[gameflow.mGamePrefs.getChildMode()], levNames[nextSectionType - 2]); gameflow.mLevelBannerTex = gameflow.setLoadBanner(bannerTex); @@ -408,7 +401,7 @@ void OnePlayerSection::init() // if we're loading into a "valid" story or challenge mode stage, show the area title banner if (stageID <= STAGE_COUNT - 1) { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) char bannerTex[128]; sprintf(bannerTex, "%s/%s", dirNames[gameflow.mGamePrefs.getChildMode()], levNames[stageID]); gameflow.mLevelBannerTex = tex = gameflow.setLoadBanner(bannerTex); diff --git a/src/plugPikiColin/gamePrefs.cpp b/src/plugPikiColin/gamePrefs.cpp index d4703e25..898ab09c 100644 --- a/src/plugPikiColin/gamePrefs.cpp +++ b/src/plugPikiColin/gamePrefs.cpp @@ -41,7 +41,7 @@ void PlayState::openStage(int storyStageID) } // This is a weak inline in US but a full function in PAL -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) /** * @brief Initialises game preferences with basic default values. */ @@ -141,7 +141,7 @@ void GamePrefs::setVibeMode(bool set) rumbleMgr->rumbleOption(set); } -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) /** * @brief Gets language preference - PAL exclusive version. * @@ -388,7 +388,7 @@ void GamePrefs::read(RandomAccessStream& input) STACK_PAD_VAR(1); #endif -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) STACK_PAD_VAR(2); LanguageID lang = (LanguageID)(UNPACK_LANG_FLAG(mFlags)); if (lang < LANG_English || lang > LANG_Italian) { diff --git a/src/plugPikiColin/gameSetup.cpp b/src/plugPikiColin/gameSetup.cpp index 3a0c3672..6dbe9c54 100644 --- a/src/plugPikiColin/gameSetup.cpp +++ b/src/plugPikiColin/gameSetup.cpp @@ -82,7 +82,7 @@ static immut char* arambundleList[][2] = { { "archives/bosses.dir", "dataDir/archives/bosses.arc" }, { "archives/tekipara.dir", "dataDir/archives/tekipara.arc" }, { "archives/tekikey.dir", "dataDir/archives/tekikey.arc" }, -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) #else { "archives/plants.dir", "dataDir/archives/plants.arc" }, #endif diff --git a/src/plugPikiColin/gameflow.cpp b/src/plugPikiColin/gameflow.cpp index bb79b11c..9a470766 100644 --- a/src/plugPikiColin/gameflow.cpp +++ b/src/plugPikiColin/gameflow.cpp @@ -525,7 +525,7 @@ void GameFlow::hardReset(BaseApp* baseApp) "screen/kodomo_blo/", "screen/kodomo_tex/"); gsys->set2DRoot("screen/sys_blo/", "screen/otona_tex/"); -#elif defined(VERSION_GPIE01_00) || defined(VERSION_GPIE01_01) +#elif defined(VERSION_GPIE01) // in the US retail releases, there's no difference between these two settings - just a holdover from demo/jp mLanguageIndex = LANG_Adult; mLangModes[LANG_Adult].set("archives/blo_eng.dir", "dataDir/archives/blo_eng.arc", "screen/eng_tex/screen.bun", "screen/eng_blo/", @@ -534,7 +534,7 @@ void GameFlow::hardReset(BaseApp* baseApp) "screen/eng_tex/"); gsys->set2DRoot("screen/sys_blo/", "screen/otona_tex/"); -#elif defined(VERSION_GPIP01_00) +#elif defined(VERSION_GPIP01) mLanguageIndex = LANG_English; mLangModes[LANG_English].set("archives/blo__eng.dir", "dataDir/archives/blo__eng.arc", "screen/eng_tex/screen.bun", "screen/eng_blo/", "screen/eng_tex/"); @@ -655,7 +655,7 @@ void GameFlow::softReset() } case SECTION_PaniTest: { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) mGameSection = new GameCourseClearSection(); #else mGameSection = new PaniTestSection(); @@ -723,7 +723,7 @@ void GameFlow::softReset() // always print load time reporting gsys->mTogglePrint = TRUE; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) int size = (u32)gsys->getHeap(SYSHEAP_App)->getFree(); int size2 = size - 0x1800000; if (size2 < 0) { diff --git a/src/plugPikiColin/introGame.cpp b/src/plugPikiColin/introGame.cpp index 568b4102..1ab56d55 100644 --- a/src/plugPikiColin/introGame.cpp +++ b/src/plugPikiColin/introGame.cpp @@ -169,7 +169,7 @@ struct IntroGameSetupSection : public BaseGameSection { gameflow.mIsDayEndActive = FALSE; _44 = 0; // unused -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) mDrawCounter = 0; #endif @@ -244,7 +244,7 @@ struct IntroGameSetupSection : public BaseGameSection { { Matrix4f orthoMtx; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) // this does nothing but loop. never referenced. mDrawCounter++; if (mDrawCounter == 5) { @@ -330,7 +330,7 @@ struct IntroGameSetupSection : public BaseGameSection { Colour _3A0; ///< _3A0, unused/unknown. bool mIsInitialSetup; ///< _3A4, are we still in the initial setup phase? Cannot do certain actions til we're done. -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) int mDrawCounter; ///< _3A8, looping 5-frame draw counter - tracked but never referenced. #endif }; diff --git a/src/plugPikiColin/mapMgr.cpp b/src/plugPikiColin/mapMgr.cpp index 8e2def6c..325734bc 100644 --- a/src/plugPikiColin/mapMgr.cpp +++ b/src/plugPikiColin/mapMgr.cpp @@ -1180,7 +1180,7 @@ void MapMgr::initShape() // set up model mMapModel = gameflow.loadShape(flowCont.mMapModelFilePath, true); - mMapModel->mSystemFlags |= ShapeFlags::AlwaysRedraw; + mMapModel->mShapeFlags |= ShapeFlags::AlwaysRedraw; // set up instances for every animated material used by the map model mMapModel->makeInstance(mAnimatedMaterials, 0); @@ -1857,7 +1857,7 @@ CollGroup* MapMgr::getCollGroupList(f32 x, f32 z, bool includePlatColl) FOREACH_NODE(DynCollShape, mCollShapeList->mChild, coll) { if (x >= coll->mBoundingBox.mMin.x && x < coll->mBoundingBox.mMax.x && z >= coll->mBoundingBox.mMin.z - && z < coll->mBoundingBox.mMax.z && coll->mCollisionModel->mSystemFlags & ShapeFlags::IsPlatform) { + && z < coll->mBoundingBox.mMax.z && coll->mCollisionModel->mShapeFlags & ShapeFlags::IsPlatform) { for (int i = 0; i < coll->mCollGroupCount; i++) { if (coll->mJointVisibility[coll->mCollGroupList[i]->mJointIndex]) { coll->mCollGroupList[i]->mNextCollGroup = collList; diff --git a/src/plugPikiColin/memoryCard.cpp b/src/plugPikiColin/memoryCard.cpp index 82bbaa80..d78e1647 100644 --- a/src/plugPikiColin/memoryCard.cpp +++ b/src/plugPikiColin/memoryCard.cpp @@ -667,7 +667,7 @@ bool MemoryCard::getCardStatus(int channel) */ void MemoryCard::checkUseFile() { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) DVDDiskID* disk = DVDGetCurrentDiskID(); #endif for (int i = 0; i < 127; i++) { @@ -681,11 +681,12 @@ void MemoryCard::checkUseFile() (void)((u32)i / 100); -#if defined(VERSION_GPIP01_00) - if (!strncmp(stat.fileName, basecardname, 15) && memcmp(&stat, disk, 4) == 0 && memcmp(&stat + 4, (void*)((int)disk + 4), 2) == 0) { +#if defined(VERSION_GPIP01) + if (!strncmp(stat.fileName, basecardname, 15) && memcmp(&stat, disk, 4) == 0 && memcmp(&stat + 4, (void*)((int)disk + 4), 2) == 0) #else - if (!strncmp(stat.fileName, basecardname, 15)) { + if (!strncmp(stat.fileName, basecardname, 15)) #endif + { strcpy(mFilePath, stat.fileName); mSaveFileIndex = i; break; @@ -884,21 +885,18 @@ void MemoryCard::saveCurrentGame() */ void MemoryCard::writeCurrentGame(RandomAccessStream* output, PlayState& playState) { -#if defined(VERSION_PIKIDEMO) if (playerState) { +#if defined(VERSION_PIKIDEMO) playState.mRedPikiCount = playerState->hasContainer(Red) ? playerState->getCardPikiCount(Red) : -1; playState.mYellowPikiCount = playerState->hasContainer(Yellow) ? playerState->getCardPikiCount(Yellow) : -1; playState.mBluePikiCount = playerState->hasContainer(Blue) ? playerState->getCardPikiCount(Blue) : -1; - playState.mShipPartsCount = playerState->getCardUfoPartsCount(); - } #else - if (playerState) { playState.mRedPikiCount = playerState->hasContainer(Red) ? pikiInfMgr.getColorTotal(Red) : -1; playState.mYellowPikiCount = playerState->hasContainer(Yellow) ? pikiInfMgr.getColorTotal(Yellow) : -1; playState.mBluePikiCount = playerState->hasContainer(Blue) ? pikiInfMgr.getColorTotal(Blue) : -1; +#endif playState.mShipPartsCount = playerState->getCardUfoPartsCount(); } -#endif playState.write(*output); if (playState.mSaveStatus == PlayState::ReadyToSave && playerState) { diff --git a/src/plugPikiColin/newPikiGame.cpp b/src/plugPikiColin/newPikiGame.cpp index eb3e90dc..52d371d5 100644 --- a/src/plugPikiColin/newPikiGame.cpp +++ b/src/plugPikiColin/newPikiGame.cpp @@ -483,7 +483,7 @@ struct DayOverModeState : public ModeState { gamecore->mDrawGameInfo->lowerFrameOut(0.5f, true); if (startState == STATE_PhaseZero) { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) OSReport("!!!!!!!!!!!!!! CLEANUPDAYEND!!!!\n"); OSReport("!!!!!!!!!!!!!! CLEANUPDAYEND!!!!\n"); OSReport("!!!!!!!!!!!!!! CLEANUPDAYEND!!!!\n"); @@ -937,7 +937,7 @@ ModeState* RunningModeState::update(u32& result) if (flowCont.mGameEndFlag != GAMEEND_None) { if (flowCont.mGameEndFlag == GAMEEND_NaviDown) { // you killed your captain! -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) // can't skip the end of day cutscene in PAL if you kill your captain - shame! shame! shame! flowCont.mIsDayEndSkippable = FALSE; #endif @@ -948,7 +948,7 @@ ModeState* RunningModeState::update(u32& result) if (flowCont.mGameEndFlag == GAMEEND_PikminExtinction) { // you killed all your pikmin! -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) // can't skip the end of day cutscene in PAL if you kill all your pikmin - shame! shame! shame! flowCont.mIsDayEndSkippable = FALSE; #endif @@ -1202,7 +1202,7 @@ ModeState* DayOverModeState::update(u32& result) // handle any text windows we might have open, such as during endings handleTutorialWindow(result, mParentSection->mController); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) // PAL-exclusive day end cutscene skipping code! bool skipped = false; @@ -1232,7 +1232,7 @@ ModeState* DayOverModeState::update(u32& result) switch (mState) { case STATE_PhaseZero: { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) OSReport("!!!!!!!!!!!!!! INITIALISE PHASE ONE!!!!\n"); OSReport("!!!!!!!!!!!!!! INITIALISE PHASE ONE!!!!\n"); #endif @@ -1241,7 +1241,7 @@ ModeState* DayOverModeState::update(u32& result) } case STATE_PhaseOne: { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) OSReport("!!!!!!!!!!!!!! INITIALISE PHASE TWO!!!!\n"); OSReport("!!!!!!!!!!!!!! INITIALISE PHASE TWO!!!!\n"); #endif @@ -1250,7 +1250,7 @@ ModeState* DayOverModeState::update(u32& result) } case STATE_PhaseTwo: { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) OSReport("!!!!!!!!!!!!!! INITIALISE PHASE THREE!!!!\n"); OSReport("!!!!!!!!!!!!!! INITIALISE PHASE THREE!!!!\n"); #endif @@ -1260,7 +1260,7 @@ ModeState* DayOverModeState::update(u32& result) } case STATE_PhaseThree: { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) OSReport("!!!!!!!!!!!!!! INITIALISE PHASE FOUR!!!!\n"); OSReport("!!!!!!!!!!!!!! INITIALISE PHASE FOUR!!!!\n"); #endif @@ -2559,7 +2559,7 @@ void GameMovieInterface::parse(GameMovieInterface::SimpleMessage& msg) int cmd = msg.mCommand; int data = msg.mData; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) OSReport("!!!!!!!!!!! Got message %d : %d\n", cmd, data); #endif @@ -2822,7 +2822,7 @@ NewPikiGameSection::NewPikiGameSection() } flowCont.mGameEndFlag = GAMEEND_None; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) // in PAL, day end is skippable unless it's a special day end flowCont.mIsDayEndSkippable = TRUE; flowCont.mIsDayEndSkipped = FALSE; diff --git a/src/plugPikiColin/ninLogo.cpp b/src/plugPikiColin/ninLogo.cpp index 0a0e0b26..56e79104 100644 --- a/src/plugPikiColin/ninLogo.cpp +++ b/src/plugPikiColin/ninLogo.cpp @@ -43,7 +43,7 @@ struct NinLogoSetupSection : public Node { mController = new Controller(1); progresWindow = nullptr; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) // no progressive mode for PAL #else if ((VIGetDTVStatus() && OSGetProgressiveMode()) || (VIGetDTVStatus() && gsys->mControllerMgr.keyDown(KBBTN_DPAD_RIGHT))) { diff --git a/src/plugPikiColin/titles.cpp b/src/plugPikiColin/titles.cpp index 39083c00..f29004f3 100644 --- a/src/plugPikiColin/titles.cpp +++ b/src/plugPikiColin/titles.cpp @@ -457,7 +457,7 @@ struct TitleSetupSection : public Node { titleWindowOn = false; } #else -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) int lang = gameflow.mGamePrefs.getChildMode(); STACK_PAD_VAR(1); PRINT("got language index %d\n", lang); @@ -467,7 +467,7 @@ struct TitleSetupSection : public Node { if (gameflow.mGamePrefs.mChangesPending) { bool vibe = gameflow.mGamePrefs.getVibeMode(); bool stereo = gameflow.mGamePrefs.getStereoMode(); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) int lang = gameflow.mGamePrefs.getChildMode(); #else bool lang = gameflow.mGamePrefs.getChildMode(); @@ -818,7 +818,7 @@ void TitlesSection::init() // check if we need to reload the language, in case the preference has changed since last load int beforeLang = gameflow.mLanguageIndex; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) gameflow.mLanguageIndex = gameflow.mGamePrefs.getChildMode(); if (gameflow.mLanguageIndex < LANG_MIN || gameflow.mLanguageIndex > LANG_MAX) { PRINT("trying to load language %d\n", gameflow.mLanguageIndex); diff --git a/src/plugPikiKando/aiAttack.cpp b/src/plugPikiKando/aiAttack.cpp index 034d2dcf..178321ad 100644 --- a/src/plugPikiKando/aiAttack.cpp +++ b/src/plugPikiKando/aiAttack.cpp @@ -153,27 +153,31 @@ bool ActAttack::resumable() } /** - * @todo: Documentation + * @brief This is a stubbed function, closely related to the unused `ActAttack::decideTarget`. + * @return `nullptr` */ Creature* ActAttack::findTarget() { - // yep. - if (false) { - Iterator iter(tekiMgr); - CI_LOOP(iter) - { - Creature* teki = *iter; - if (roughCull(teki, mPiki, 30.0f)) { - continue; - } - // i'm bad at reading the DLL assembly, but it's genuinely something like this - // (IDA and ghidra both don't try it bc it's inaccessible) - if (qdist2(teki, mPiki) < 50.0f && teki->isAlive() && teki->isVisible() && !teki->isBuried() && !teki->isFlying()) { - return teki; - } + return nullptr; // yep. + + f32 minDist = 12800.0f; // The DLL says this was uninitialized, but that can't be right... + Creature* target; + // In the DLL, this iterator is also somehow uninitialized? Gonna assume it's a quirk of + // unreachable code, but that means we don't actually know what was being iterated over. + Iterator iter(_20); + CI_LOOP(iter) + { + Creature* creature = *iter; + if (roughCull(mPiki, creature, minDist)) { + continue; + } + f32 dist = qdist2(creature, mPiki); + if (creature->isAlive() && creature->isVisible() && !creature->isFlying() && dist < minDist) { + target = creature; + minDist = dist; } } - return nullptr; + return target; } /** diff --git a/src/plugPikiKando/aiPut.cpp b/src/plugPikiKando/aiPut.cpp index f2cc86e5..00069859 100644 --- a/src/plugPikiKando/aiPut.cpp +++ b/src/plugPikiKando/aiPut.cpp @@ -58,9 +58,9 @@ void ActPutBomb::findTeki() #if defined(VERSION_GPIJ01_01) || defined(VERSION_G98P01_PIKIDEMO) || defined(VERSION_DPIJ01_PIKIDEMO) // surely the tekiMgr is fine... #else -#if defined(VERSION_GPIE01_00) || defined(VERSION_GPIE01_01) || defined(VERSION_GPIP01_00) || defined(VERSION_GPIJ01_02) +#if defined(VERSION_GPIE01) || defined(VERSION_GPIP01) || defined(VERSION_GPIJ01_02) if (!tekiMgr) -#else +#else // VERSION_G98E01_PIKIDEMO if (!tekiMgr || !bossMgr) #endif { diff --git a/src/plugPikiKando/demoEvent.cpp b/src/plugPikiKando/demoEvent.cpp index f7ce0371..8201db2f 100644 --- a/src/plugPikiKando/demoEvent.cpp +++ b/src/plugPikiKando/demoEvent.cpp @@ -181,7 +181,7 @@ void DemoEventMgr::act(int cmd, int type) } case 4: { - if (playerState->hasContainer(goalID + 3)) { + if (playerState->hasBootContainer(goalID)) { goal->startConeEmit(); } break; @@ -204,7 +204,7 @@ void DemoEventMgr::act(int cmd, int type) { PRINT("boot onion\n"); goal->startBoot(); - playerState->setContainer(goalID + 3); + playerState->setBootContainer(goalID); if (playerState->isTutorial() && playerState->mShipEffectPartFlag & 8) { Navi* navi = naviMgr->getNavi(); playerState->mShipEffectPartFlag &= ~8; diff --git a/src/plugPikiKando/dynCreature.cpp b/src/plugPikiKando/dynCreature.cpp index 64bbc875..b1605aae 100644 --- a/src/plugPikiKando/dynCreature.cpp +++ b/src/plugPikiKando/dynCreature.cpp @@ -176,7 +176,7 @@ void DynCreature::addParticle(f32 mass, immut Vector3f& position) mMass += mass; mParticleCount++; } else { -#if defined(VERSION_GPIE01_00) || defined(VERSION_GPIE01_01) || defined(VERSION_GPIP01_00) || defined(VERSION_GPIJ01_02) +#if defined(VERSION_GPIE01) || defined(VERSION_GPIP01) || defined(VERSION_GPIJ01_02) #else PRINT("PARTICLE ADD FAILED ! (%s)\n", ObjType::getName(mObjType)); ERROR("ZANNEN !\n"); diff --git a/src/plugPikiKando/gameDemo.cpp b/src/plugPikiKando/gameDemo.cpp index 74aec472..ec440d3f 100644 --- a/src/plugPikiKando/gameDemo.cpp +++ b/src/plugPikiKando/gameDemo.cpp @@ -264,7 +264,6 @@ void DemoFlags::setFlag(int index, Creature* obj) Vector3f rotation(0.0f, yRotation, 0.0f); gameflow.mGameInterface->movie(getDemoFlag(index)->mMovieIndex, 0, obj, obj ? &obj->mSRT.t : nullptr, &rotation, CAF_AllVisibleMask, true); - } else { if (obj && obj->mObjType != OBJTYPE_Goal) { Vector3f objPosition = obj->mSRT.t; diff --git a/src/plugPikiKando/genNavi.cpp b/src/plugPikiKando/genNavi.cpp index 860ae639..5f3c173f 100644 --- a/src/plugPikiKando/genNavi.cpp +++ b/src/plugPikiKando/genNavi.cpp @@ -20,10 +20,10 @@ DEFINE_PRINT("genNavi"); * @todo: Documentation * @note UNUSED Size: 000060 */ -// GenObjectNavi::GenObjectNavi() -// : GenObject('navi', "プレイヤー2を生む") -// { -// } +GenObjectNavi::GenObjectNavi() + : GenObject('navi', "プレイヤー2を生む") // 'generate player 2' +{ +} /** * @todo: Documentation diff --git a/src/plugPikiKando/generator.cpp b/src/plugPikiKando/generator.cpp index f9d77f87..f786b0ba 100644 --- a/src/plugPikiKando/generator.cpp +++ b/src/plugPikiKando/generator.cpp @@ -570,7 +570,6 @@ void Generator::init() if (!ramMode) { mAliveCount = 0; - } else if (!(mCarryOverFlags & GENCARRY_SaveSpawnCount)) { // do nothing. mAliveCount = 0; diff --git a/src/plugPikiKando/goalItem.cpp b/src/plugPikiKando/goalItem.cpp index ee9baadb..6d0df5d7 100644 --- a/src/plugPikiKando/goalItem.cpp +++ b/src/plugPikiKando/goalItem.cpp @@ -647,7 +647,7 @@ void GoalItem::startAI(int) } WayPoint* wp = routeMgr->getWayPoint('test', mWaypointIdx); - if (!playerState->bootContainer(mOnionColour) || playerState->isTutorial()) { + if (!playerState->hasBootContainer(mOnionColour) || playerState->isTutorial()) { setMotionSpeed(0.0f); C_SAI(this)->start(this, GoalAI::GOAL_BootInit); startConeShrink(); diff --git a/src/plugPikiKando/soundMgr.cpp b/src/plugPikiKando/soundMgr.cpp index 164da301..b66eb0b5 100644 --- a/src/plugPikiKando/soundMgr.cpp +++ b/src/plugPikiKando/soundMgr.cpp @@ -891,8 +891,7 @@ void SeSystem::update(Graphics& gfx, immut Vector3f& listenerPos) return; } -#if defined(VERSION_GPIE01_00) || defined(VERSION_GPIE01_01) || defined(VERSION_GPIP01_00) || defined(VERSION_GPIJ01) -#else +#if defined(VERSION_PIKIDEMO) ++mClock; if (mClock >= 30 * 60 * 60) { mClock = 0; // Reset the clock every hour (30 Hz * 60 seconds * 60 minutes) @@ -968,10 +967,11 @@ void SeSystem::calcCameraPos(immut Vector3f& objectPos, Vector3f& normalisedCamD int SeSystem::getJacID(int soundID) { #if defined(VERSION_GPIJ01) || defined(VERSION_DPIJ01_PIKIDEMO) - if (soundID < 0 || soundID >= mMaxSoundID) { + if (soundID < 0 || soundID >= mMaxSoundID) #else - if (soundID < 0 || soundID > mMaxSoundID) { + if (soundID < 0 || soundID > mMaxSoundID) #endif + { PRINT("soundID = %d\n", soundID); ERROR("go to HELL!\n"); // rude. } diff --git a/src/plugPikiKando/ufoItem.cpp b/src/plugPikiKando/ufoItem.cpp index 9ab2d913..a99aa80b 100644 --- a/src/plugPikiKando/ufoItem.cpp +++ b/src/plugPikiKando/ufoItem.cpp @@ -137,7 +137,7 @@ void UfoItem::setSpotActive(bool set) mIsLightActive = set; Vector3f goal = Vector3f(getGoalPos()); - f32 padding[2]; // needed for stack to work + STACK_PAD_VAR(2); // needed for stack to work CollPart* part = mCollInfo->getSphere('gol1'); if (mIsLightActive) { diff --git a/src/plugPikiKando/workObject.cpp b/src/plugPikiKando/workObject.cpp index 6ca44224..a1b68db6 100644 --- a/src/plugPikiKando/workObject.cpp +++ b/src/plugPikiKando/workObject.cpp @@ -482,7 +482,7 @@ Creature* GenObjectWorkObject::birth(BirthInfo& info) HinderRock::HinderRock(Shape* shape) { mBoxShape = shape; - mBoxShape->mSystemFlags |= ShapeFlags::IsPlatform; + mBoxShape->mShapeFlags |= ShapeFlags::IsPlatform; mBuildShape = new DynBuildShape(shape); mBuildShape->mCreature = this; mCollInfo = new CollInfo(20); @@ -970,8 +970,8 @@ Bridge::Bridge(Shape* shape, bool a3) mDoUseJointSegments = a3; mBridgeShape = shape; - mBridgeShape->mSystemFlags |= ShapeFlags::IsPlatform; - mBridgeShape->mSystemFlags |= ShapeFlags::AlwaysRedraw; + mBridgeShape->mShapeFlags |= ShapeFlags::IsPlatform; + mBridgeShape->mShapeFlags |= ShapeFlags::AlwaysRedraw; mBuildShape = new DynBuildShape(shape); mBuildShape->mCreature = this; diff --git a/src/plugPikiOgawa/ogFileSelect.cpp b/src/plugPikiOgawa/ogFileSelect.cpp index aa3c5069..dbf4187e 100644 --- a/src/plugPikiOgawa/ogFileSelect.cpp +++ b/src/plugPikiOgawa/ogFileSelect.cpp @@ -45,7 +45,7 @@ bool zen::ogScrFileSelectMgr::getCardFileInfos() #else bool vibe = gameflow.mGamePrefs.getVibeMode(); bool stereo = gameflow.mGamePrefs.getStereoMode(); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) int child = gameflow.mGamePrefs.getChildMode(); #else bool child = gameflow.mGamePrefs.getChildMode(); @@ -153,7 +153,7 @@ void zen::ogScrFileSelectMgr::UpDateYesNoWindow() if (mDataAnimationTimer < 0.25f) { mDataAnimationTimer += gsys->getFrameTime(); f32 t = mDataAnimationTimer / 0.25f; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) if (t >= 1.0f) { t = 1.0f; } @@ -734,7 +734,7 @@ void zen::ogScrFileSelectMgr::init() zen::ogScrFileSelectMgr::ogScrFileSelectMgr() { init(); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) mFxMgr = new EffectMgr2D(16, 0x800, 0x800); #else mFxMgr = new EffectMgr2D(16, 0x400, 0x400); diff --git a/src/plugPikiOgawa/ogMakeDefault.cpp b/src/plugPikiOgawa/ogMakeDefault.cpp index 8e192eea..1cd0ddd7 100644 --- a/src/plugPikiOgawa/ogMakeDefault.cpp +++ b/src/plugPikiOgawa/ogMakeDefault.cpp @@ -138,7 +138,7 @@ zen::ogScrMakeDefaultMgr::MakeDefaultStatus zen::ogScrMakeDefaultMgr::update(Con switch (mStatus) { case Processing: { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) if (mStateTimer > 6.0f && gameflow.mMemoryCard.hasCardFinished()) #else if (mStateTimer > 2.0f && gameflow.mMemoryCard.hasCardFinished()) diff --git a/src/plugPikiOgawa/ogMessage.cpp b/src/plugPikiOgawa/ogMessage.cpp index 29424354..30a7da09 100644 --- a/src/plugPikiOgawa/ogMessage.cpp +++ b/src/plugPikiOgawa/ogMessage.cpp @@ -55,7 +55,7 @@ static s16 sjis_convert_table[0x258] ATTRIBUTE_ALIGN(32) = { // doesn't want to match when copy-pasted from anywhere in the actual code (there seems to be dozens // of "・"s in the shift-jis table and its using the wrong one if you dont manually specify it) static char kanji_convert_table[] ATTRIBUTE_ALIGN(32) = { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) "日目時私未知星大地\x85\x20名前宇宙旅途中流墜落愛機号多失無残姿動一重迎教気猛毒酸素含生命維持装置限度修復考船探検奇妙物体待立上何械観察" "芽光放" #else @@ -356,7 +356,7 @@ void zen::ogScrMessageMgr::cnvButtonIcon(char* str) tmp2[1] = 0; char buf1[PATH_MAX]; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) sprintf(buf1, "%sCC[%s]%s%sCC[%s]", tmp2, mButtonMarkupColours[offset], tmp1, tmp2, mDefaultButtonMarkupColour); #else sprintf(buf1, "%sFX[32]%sFY[28]%sCC[%s]%s%sCC[%s]%sFX[24]%sFY[24]", tmp2, tmp2, tmp2, mButtonMarkupColours[offset], tmp1, tmp2, diff --git a/src/plugPikiOgawa/ogRader.cpp b/src/plugPikiOgawa/ogRader.cpp index a0426354..2eed96c5 100644 --- a/src/plugPikiOgawa/ogRader.cpp +++ b/src/plugPikiOgawa/ogRader.cpp @@ -571,7 +571,7 @@ void zen::ogRaderMgr::AreaScroll(f32* p1, f32* p2, f32 p3, f32 p4) */ void zen::ogRaderMgr::updateMenu(Controller* input) { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) if (mStatus == -1) { return; } diff --git a/src/plugPikiOgawa/ogTest.cpp b/src/plugPikiOgawa/ogTest.cpp index fac4bb05..2e62e13c 100644 --- a/src/plugPikiOgawa/ogTest.cpp +++ b/src/plugPikiOgawa/ogTest.cpp @@ -470,7 +470,7 @@ void OgTestScreen::draw(Graphics& gfx) gfx.setAuxColour(Colour(255, 255, 0, 255)); char scrnSelectorText[PATH_MAX]; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) sprintf(scrnSelectorText, "2D Screen checker"); // '2D screen selector' #else sprintf(scrnSelectorText, "2Dスクリーン・セレクター"); // '2D screen selector' @@ -482,7 +482,7 @@ void OgTestScreen::draw(Graphics& gfx) char optionsTexts[11][PATH_MAX]; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) sprintf(optionsTexts[0], "title (%d)", mTitleMode); // 'Title (%d)' sprintf(optionsTexts[1], "tutorial (%d)", mTutorialMode); // 'Tutorial (%d)' sprintf(optionsTexts[2], "save select (%d)", mSaveMode); // 'Save Select (%d)' @@ -528,7 +528,7 @@ void OgTestScreen::draw(Graphics& gfx) ogScrMessageMgr* msgMgr = mTutorialMgr->getScrMsgMgr(); char tutorialText[PATH_MAX]; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) sprintf(tutorialText, "<<< tutorial >>> tx(%d)", msgMgr->getTxtLineMax()); // '<<< Tutorial >>> Number of tx?? (%d)' #else sprintf(tutorialText, "<<< チュ−トリアル >>> tx??の数(%d個)", msgMgr->getTxtLineMax()); // '<<< Tutorial >>> Number of tx?? (%d)' diff --git a/src/plugPikiOgawa/ogTitle.cpp b/src/plugPikiOgawa/ogTitle.cpp index d4c1b7aa..7938a1ac 100644 --- a/src/plugPikiOgawa/ogTitle.cpp +++ b/src/plugPikiOgawa/ogTitle.cpp @@ -80,8 +80,8 @@ zen::ogScrTitleMgr::ogScrTitleMgr() mAlphaMgr = new setTenmetuAlpha(mStereoButton, 0.5f, 0.0f, 0, 255); -#if defined(VERSION_GPIP01_00) - char path[4]; +#if !defined(BUGFIX) && defined(VERSION_GPIP01) + char path[4]; // You made it undefined behavior?! #else char path[12]; #endif @@ -109,7 +109,7 @@ zen::ogScrTitleMgr::ogScrTitleMgr() mLanguageMenu->setCancelSE(ogEnumFix(SYSSE_DECIDE1, JACSYS_Decide1)); mRumbleMenu->setCancelSE(ogEnumFix(SYSSE_DECIDE1, JACSYS_Decide1)); mSoundMenu->setCancelSE(ogEnumFix(SYSSE_DECIDE1, JACSYS_Decide1)); -#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIJ01) || defined(VERSION_GPIP01_00) +#if defined(VERSION_PIKIDEMO) || defined(VERSION_GPIJ01) || defined(VERSION_GPIP01) #else mOptionsMenu->setMenuItemActiveSw(1, false); #endif @@ -234,7 +234,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) if (mCurrentSelection == 1) { // Language mCurrentMenuID = MENU_Language; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) mLanguageMenu->start(mChildMode); #else if (mChildMode) { @@ -268,7 +268,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) #else bool vibe = gameflow.mGamePrefs.getVibeMode(); bool stereo = gameflow.mGamePrefs.getStereoMode(); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) int child = gameflow.mGamePrefs.getChildMode(); #else bool child = gameflow.mGamePrefs.getChildMode(); @@ -309,7 +309,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) // For every time this sound is played here, it worked correctly in USA demo, then broken in final USA (Jac_PlaySystemSe // is meant to use its own sound ids for system sounds), then fixed AGAIN in a different way for PAL -#if defined(BUGFIX) || defined(VERSION_GPIP01_00) +#if defined(BUGFIX) || defined(VERSION_GPIP01) seSystem->playSysSe(Sound_Config); #elif defined(VERSION_PIKIDEMO) || defined(VERSION_GPIJ01) Jac_PlaySystemSe(JACSYS_SoundConfig); @@ -325,7 +325,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) if (mBgmVol > 0) { mBgmVol--; setGamePrefs(); -#if defined(BUGFIX) || defined(VERSION_GPIP01_00) +#if defined(BUGFIX) || defined(VERSION_GPIP01) seSystem->playSysSe(Sound_Config); #elif defined(VERSION_PIKIDEMO) || defined(VERSION_GPIJ01) Jac_PlaySystemSe(JACSYS_SoundConfig); @@ -341,7 +341,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) if (mSfxVol > 0) { mSfxVol--; setGamePrefs(); -#if defined(BUGFIX) || defined(VERSION_GPIP01_00) +#if defined(BUGFIX) || defined(VERSION_GPIP01) seSystem->playSysSe(Sound_Config); #elif defined(VERSION_PIKIDEMO) || defined(VERSION_GPIJ01) Jac_PlaySystemSe(JACSYS_SoundConfig); @@ -361,7 +361,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) if (mStereoMode) { mStereoMode = false; setGamePrefs(); -#if defined(BUGFIX) || defined(VERSION_GPIP01_00) +#if defined(BUGFIX) || defined(VERSION_GPIP01) seSystem->playSysSe(Sound_Config); #elif defined(VERSION_PIKIDEMO) || defined(VERSION_GPIJ01) Jac_PlaySystemSe(JACSYS_SoundConfig); @@ -377,7 +377,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) if (mBgmVol < 10) { mBgmVol++; setGamePrefs(); -#if defined(BUGFIX) || defined(VERSION_GPIP01_00) +#if defined(BUGFIX) || defined(VERSION_GPIP01) seSystem->playSysSe(Sound_Config); #elif defined(VERSION_PIKIDEMO) || defined(VERSION_GPIJ01) Jac_PlaySystemSe(JACSYS_SoundConfig); @@ -393,7 +393,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) if (mSfxVol < 10) { mSfxVol++; setGamePrefs(); -#if defined(BUGFIX) || defined(VERSION_GPIP01_00) +#if defined(BUGFIX) || defined(VERSION_GPIP01) seSystem->playSysSe(Sound_Config); #elif defined(VERSION_PIKIDEMO) || defined(VERSION_GPIJ01) Jac_PlaySystemSe(JACSYS_SoundConfig); @@ -466,7 +466,7 @@ zen::ogScrTitleMgr::TitleStatus zen::ogScrTitleMgr::update(Controller* input) mLanguageMenu->update(input); int flag4 = mLanguageMenu->getStatusFlag(); mCurrentSelection = mLanguageMenu->getSelectMenu(); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) if (mCurrentSelection >= 0) { mChildMode = mCurrentSelection; } diff --git a/src/plugPikiYamashita/P2DPrint.cpp b/src/plugPikiYamashita/P2DPrint.cpp index 6777a4e0..3fbdf2fd 100644 --- a/src/plugPikiYamashita/P2DPrint.cpp +++ b/src/plugPikiYamashita/P2DPrint.cpp @@ -223,7 +223,7 @@ f32 P2DPrint::parse(const u8* textBuffer, int textLen, int maxWidth, u16* outXPo } else { continue; } -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) } else if (mFont->getFontType() == OS_FONT_ENCODE_UNK2 && (currChar < 0xa0 && currChar >= 0x80) && *textBuffer != 0) { #else } else if (mFont->getFontType() == OS_FONT_ENCODE_UNK2 && currChar >= ASCII_PRINTABLE_MAX && *textBuffer != 0) { diff --git a/src/plugPikiYamashita/drawContainer.cpp b/src/plugPikiYamashita/drawContainer.cpp index 8f6840bf..61d2c852 100644 --- a/src/plugPikiYamashita/drawContainer.cpp +++ b/src/plugPikiYamashita/drawContainer.cpp @@ -51,7 +51,7 @@ zen::DrawContainer::DrawContainer() mZenController.setContPtr(mController); mPerspGraph = new P2DPerspGraph(0, 0, 640, 480, 30.0f, 1.0f, 5000.0f); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) mScreen.set("screen/blo/conmix.blo", true); #else mScreen.set("screen/blo/con01.blo", true); diff --git a/src/plugPikiYamashita/effectMgr.cpp b/src/plugPikiYamashita/effectMgr.cpp index ec3425f2..b8e2fda5 100644 --- a/src/plugPikiYamashita/effectMgr.cpp +++ b/src/plugPikiYamashita/effectMgr.cpp @@ -531,7 +531,7 @@ EffectParticleRegistration::EffectParticleRegistration(immut char* pcrFile, immu void EffectShape::initShape(immut char* modelFile) { mModel = gameflow.loadShape(modelFile, true); - mModel->mSystemFlags |= ShapeFlags::AlwaysRedraw; + mModel->mShapeFlags |= ShapeFlags::AlwaysRedraw; mModel->makeInstance(mAnimatedMaterials, 0); } diff --git a/src/si/SIBios.c b/src/si/SIBios.c index 49008f3c..e71c4cbc 100644 --- a/src/si/SIBios.c +++ b/src/si/SIBios.c @@ -1,32 +1,10 @@ #include "Dolphin/os.h" #include "Dolphin/vi.h" -extern OSTime __OSGetSystemTime(); - static SIControl Si = { -1, 0, 0, NULL, NULL, }; -typedef struct SIComm_s { - u32 tcint : 1; - u32 tcintmsk : 1; - u32 comerr : 1; - u32 rdstint : 1; - u32 rdstintmsk : 1; - u32 pad0 : 4; - u32 outlngth : 7; - u32 pad1 : 1; - u32 inlngth : 7; - u32 pad2 : 5; - u32 channel : 2; - u32 tstart : 1; -} SIComm_s; - -typedef union SIComm_u { - u32 val; - SIComm_s f; -} SIComm_u; - static SIPacket Packet[SI_MAX_CHAN]; static OSAlarm Alarm[SI_MAX_CHAN]; static u32 Type[SI_MAX_CHAN] = { @@ -313,7 +291,7 @@ static BOOL __SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u u32 rLen; u32 i; u32 sr; - SIComm_u comcsr; + SIComm comcsr; enabled = OSDisableInterrupts(); if (Si.chan != -1) { @@ -336,12 +314,12 @@ static BOOL __SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u } comcsr.val = __SIRegs[13]; - comcsr.f.tcint = 1; - comcsr.f.tcintmsk = callback ? 1 : 0; - comcsr.f.outlngth = (outputBytes == SI_MAX_COMCSR_OUTLNGTH) ? 0 : outputBytes; - comcsr.f.inlngth = (inputBytes == SI_MAX_COMCSR_INLNGTH) ? 0 : inputBytes; - comcsr.f.channel = chan; - comcsr.f.tstart = 1; + comcsr.flags.tcint = 1; + comcsr.flags.tcintmsk = callback ? 1 : 0; + comcsr.flags.outlngth = (outputBytes == SI_MAX_COMCSR_OUTLNGTH) ? 0 : outputBytes; + comcsr.flags.inlngth = (inputBytes == SI_MAX_COMCSR_INLNGTH) ? 0 : inputBytes; + comcsr.flags.channel = chan; + comcsr.flags.tstart = 1; __SIRegs[13] = comcsr.val; OSRestoreInterrupts(enabled); diff --git a/src/si/SISamplingRate.c b/src/si/SISamplingRate.c index 444428c5..4b46d072 100644 --- a/src/si/SISamplingRate.c +++ b/src/si/SISamplingRate.c @@ -18,6 +18,9 @@ static XY XYPAL[12] = { { 78, 4 }, { 104, 3 }, { 104, 3 }, { 104, 3 }, { 104, 3 }, { 156, 2 }, }; +/** + * This implementation was moved from Pad.c (`PADSetSamplingRate`) + */ void SISetSamplingRate(u32 msec) { XY* xy; @@ -51,4 +54,10 @@ void SISetSamplingRate(u32 msec) OSRestoreInterrupts(enabled); } -void SIRefreshSamplingRate() { SISetSamplingRate(SamplingRate); } +/** + * This implementation was moved from Pad.c (`__PADRefreshSamplingRate`) + */ +void SIRefreshSamplingRate() +{ + SISetSamplingRate(SamplingRate); +} diff --git a/src/sysCommon/graphics.cpp b/src/sysCommon/graphics.cpp index d0b8206a..ff9cb2ac 100644 --- a/src/sysCommon/graphics.cpp +++ b/src/sysCommon/graphics.cpp @@ -682,7 +682,7 @@ static u16 sjis_convert_table[0x258] = { }; static char kanji_convert_table[] ATTRIBUTE_ALIGN(32) = { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) "日目時私未知星大地\x85\x20名前宇宙旅途中流墜落愛機号多失無残姿動一重迎教気猛毒酸素含生命維持装置限度修復考船探検奇妙物体待立上何械観察" "芽光放" #else @@ -749,15 +749,16 @@ int Font::stringWidth(immut char* str) int width = 0; while (*str) { int idx; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) STACK_PAD_VAR(4); if (*str >= 0xa0) { idx = *str - 0x20; str++; - } else if (*str & 0x80) { + } else if (*str & 0x80) #else - if (*str & 0x80) { + if (*str & 0x80) #endif + { u16 c = (str[0] << 8) | (str[1] & 0xFF); idx = charToIndex(c); str += 2; @@ -1048,7 +1049,7 @@ void TexImg::read(RandomAccessStream& stream) mWidth = stream.readShort(); mHeight = stream.readShort(); mFormat = static_cast(stream.readInt()); - mDataPtrOffset = stream.readInt(); + mImageCount = stream.readInt(); s32 _ = stream.readInt(); _ = stream.readInt(); @@ -1181,7 +1182,7 @@ void TexImg::importBti(Texture* tex, RandomAccessStream& input, u8* data) ERROR("Bti file has imageData at offset %d!!!\n", bti.mImageDataOffset); } - tex->mTexFlags = (!bti.mWrapS ? 0x1 : 0) | (!bti.mWrapT ? 0x100 : 0); + tex->mTexFlags = (!bti.mWrapS ? Texture::TEX_CLAMP_S : 0) | (!bti.mWrapT ? Texture::TEX_CLAMP_T : 0); readTexData(tex, input, data); } @@ -1221,10 +1222,10 @@ void TexAttr::initImage() TexImg::getTileSize(mImage->mFormat, mTexture->mTileSizeX, mTexture->mTileSizeY); if (mUseOffsetImgData) { - mTexture->mTextureData = (u32*)(mImage->mDataPtrOffset - 1); + mTexture->mLODCount = mImage->mImageCount - 1; mTexture->mLODBias = mLODBias; } else { - mTexture->mTextureData = nullptr; + mTexture->mLODCount = 0; mTexture->mLODBias = 0.0f; } diff --git a/src/sysCommon/shapeBase.cpp b/src/sysCommon/shapeBase.cpp index bd6837d8..e6db4d91 100644 --- a/src/sysCommon/shapeBase.cpp +++ b/src/sysCommon/shapeBase.cpp @@ -1741,7 +1741,7 @@ BaseShape::BaseShape() mName = "noname"; mAnimMatrices = nullptr; mAnimMtxCount = 0; - mSystemFlags = 0; + mShapeFlags = ShapeFlags::None; mVertexCacheFlags = VertexCacheFlags::None; _2AC = 1; mVtxMatrixCount = 0; @@ -2008,13 +2008,13 @@ void BaseShape::drawshape(Graphics& gfx, Camera& cam, ShapeDynMaterials* dynMats gsys->mTimer->start("drawShape", true); u32 prevRender = gfx.mMatRenderMask; if (mMeshCount) { - if (!(mSystemFlags & ShapeFlags::AlwaysRedraw) && (mSystemFlags & ShapeFlags::AllowCaching) + if (!(mShapeFlags & ShapeFlags::AlwaysRedraw) && (mShapeFlags & ShapeFlags::AllowCaching) && (gfx.mMatRenderMask & MATFLAG_AlphaBlend)) { gfx.cacheShape(this, dynMats); gfx.mMatRenderMask &= ~MATFLAG_AlphaBlend; } - if ((mSystemFlags & ShapeFlags::AlwaysRedraw) + if ((mShapeFlags & ShapeFlags::AlwaysRedraw) || (gfx.mMatRenderMask & (MATFLAG_Opaque | MATFLAG_AlphaTest | MATFLAG_InverseColorBlend))) { if (dynMats) { for (ShapeDynMaterials* iMat = dynMats; iMat; iMat = iMat->mNext) { @@ -2146,7 +2146,7 @@ void BaseShape::read(RandomAccessStream& stream) { stream.skipPadding(0x20); int unused = stream.readInt(); - mSystemFlags = stream.readInt(); + mShapeFlags = stream.readInt(); stream.skipPadding(0x20); break; } @@ -2608,7 +2608,7 @@ void BaseShape::initIni(bool usePlatforms) coll->mPlatShape->createCollisions(32); } if (coll->mFlags) { - coll->mPlatShape->mSystemFlags |= ShapeFlags::IsPlatform; + coll->mPlatShape->mShapeFlags |= ShapeFlags::IsPlatform; } } @@ -2619,7 +2619,7 @@ void BaseShape::initIni(bool usePlatforms) childColl->mPlatShape->createCollisions(32); } if (childColl->mFlags) { - childColl->mPlatShape->mSystemFlags |= ShapeFlags::IsPlatform; + childColl->mPlatShape->mShapeFlags |= ShapeFlags::IsPlatform; } } } @@ -2628,7 +2628,7 @@ void BaseShape::initIni(bool usePlatforms) for (RouteGroup* route = (RouteGroup*)mRouteGroup.Child(); route; route = (RouteGroup*)route->mNext) { #ifdef WIN32 route->mDebugWaypointTexture = gsys->loadTexture("rootRing.txe", true); - route->mDebugWaypointTexture->mTexFlags = (0x100 | 0x1); + route->mDebugWaypointTexture->mTexFlags = Texture::TEX_CLAMP_S | Texture::TEX_CLAMP_T; #else route->mDebugWaypointTexture = nullptr; #endif diff --git a/src/sysCommon/stdSystem.cpp b/src/sysCommon/stdSystem.cpp index 0295d03a..12a924bd 100644 --- a/src/sysCommon/stdSystem.cpp +++ b/src/sysCommon/stdSystem.cpp @@ -38,7 +38,7 @@ StdSystem::StdSystem() , mAramRoot("CoreNode") { mConsFont = nullptr; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) mLanguageID = LANG_English; #endif mCurrentFade = 0.0f; diff --git a/src/sysDolphin/dgxGraphics.cpp b/src/sysDolphin/dgxGraphics.cpp index 95f66a64..394427cc 100644 --- a/src/sysDolphin/dgxGraphics.cpp +++ b/src/sysDolphin/dgxGraphics.cpp @@ -24,7 +24,7 @@ GXRenderModeObj progressiveRenderMode = { 480, // efbHeight 480, // xfbHeight 40, // viXOrigin -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) 47, // viYOrigin #else 0, // viYOrigin @@ -50,7 +50,7 @@ GXRenderModeObj progressiveRenderMode = { }, { 0, 0, 21, 22, 21, 0, 0 }, // vfilter }; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) GXRenderModeObj localGXPal528IntDf = { VI_TVMODE_PAL_INT, // viTVmode 640, // fbWidth @@ -178,7 +178,7 @@ DGXGraphics::DGXGraphics(bool flag) } mScreenWidth = sScreenMode[mRenderMode]->fbWidth; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) mScreenHeight = 480; GXSetDispCopySrc(0, 0, sScreenMode[mRenderMode]->fbWidth, mScreenHeight); @@ -201,7 +201,7 @@ DGXGraphics::DGXGraphics(bool flag) VIInit(); videoReset(); -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) sFrameSize = (sScreenMode[mRenderMode]->fbWidth + 0xf & 0xfff0) * (sScreenMode[mRenderMode]->xfbHeight + 2) * 2; #else sFrameSize = (sScreenMode[mRenderMode]->fbWidth + 0xf & 0xfff0) * sScreenMode[mRenderMode]->xfbHeight * 2; @@ -1449,7 +1449,7 @@ void DGXGraphics::setFog(bool set) if (mCamera->mNear < mCamera->mFar) { GXSetFog(GX_FOG_LINEAR, mFogStart, mFogEnd, mCamera->mNear, mCamera->mFar, *(GXColor*)&mFogColour); } else { -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) OSReport("%s:%d Warning: cam->vNear >= cam->vFar\n", __FILE__, 1732); #else OSReport("%s:%d Warning: cam->vNear >= cam->vFar\n", __FILE__, 1683); @@ -2056,7 +2056,7 @@ void DGXGraphics::texturePrintf(Font* font, int x, int y, immut char* format, .. while (*bufPtr) { int idx; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) if (*bufPtr >= 0xa0) { STACK_PAD_VAR(1); idx = font->charToIndex(*bufPtr); diff --git a/src/sysDolphin/system.cpp b/src/sysDolphin/system.cpp index 4b43b1ad..d2323efd 100644 --- a/src/sysDolphin/system.cpp +++ b/src/sysDolphin/system.cpp @@ -619,7 +619,7 @@ void initBigFont() img->mFormat = TEX_FMT_IA4; img->mWidth = 504; img->mHeight = 1008; - tex->mTexFlags = 0x101; + tex->mTexFlags = Texture::TEX_CLAMP_S | Texture::TEX_CLAMP_T; img->mDataSize = img->calcDataSize(img->mFormat, img->mWidth, img->mHeight); img->mTextureData = bigFont_data; img->getTileSize(img->mFormat, tex->mTileSizeX, tex->mTileSizeY); @@ -629,7 +629,7 @@ void initBigFont() tex->attach(); } -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) static immut char* e_errorMessages[] = { "Reading Game Disc...", nullptr, @@ -869,7 +869,7 @@ void System::showDvdError(Graphics& gfx) if (mDvdErrorCode) { // DvdError::ReadingDisc or higher int y = 160; -#if defined(VERSION_GPIP01_00) +#if defined(VERSION_GPIP01) immut char** errors = errorList[mDvdErrorCode + mLanguageID * 6]; #else immut char** errors = errorList[mDvdErrorCode]; diff --git a/src/sysDolphin/texture.cpp b/src/sysDolphin/texture.cpp index acb87c16..3272a5f2 100644 --- a/src/sysDolphin/texture.cpp +++ b/src/sysDolphin/texture.cpp @@ -36,7 +36,7 @@ Texture::Texture() _30 = 0; _34 = 0; _20 = -1; - mTextureData = nullptr; + mLODCount = 0; mLODBias = 0.0f; mTexObj = new GXTexObj(); } @@ -215,7 +215,7 @@ void Texture::attach() GXTexFmt texFmt = gxTexFmts[mTexFormat]; GXBool useMIPmap; - if (mTextureData) { + if (mLODCount != 0) { useMIPmap = GX_TRUE; } else { useMIPmap = GX_FALSE; @@ -223,8 +223,8 @@ void Texture::attach() GXInitTexObj(mTexObj, mPixelData, mWidth, mHeight, texFmt, sWrap, tWrap, useMIPmap); - if (mTextureData) { - GXInitTexObjLOD(mTexObj, GX_LIN_MIP_LIN, GX_LINEAR, 0.0f, (u32)mTextureData, mLODBias, GX_FALSE, GX_FALSE, GX_ANISO_1); + if (mLODCount != 0) { + GXInitTexObjLOD(mTexObj, GX_LIN_MIP_LIN, GX_LINEAR, 0.0f, mLODCount, mLODBias, GX_FALSE, GX_FALSE, GX_ANISO_1); } } diff --git a/src/vi/vi.c b/src/vi/vi.c index 921c8f8c..0f57916a 100644 --- a/src/vi/vi.c +++ b/src/vi/vi.c @@ -42,7 +42,7 @@ static vu16 shdwRegs[59]; static VIPositionInfo HorVer; -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L static VITimingInfo* CurrTiming; static s32 CurrTvMode; #endif @@ -134,7 +134,7 @@ static BOOL VISetRegs(void) shdwChangeMode = 0; #endif -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L CurrTiming = HorVer.timing; CurrTvMode = HorVer.tv; #endif @@ -194,7 +194,7 @@ static void __VIRetraceHandler(__OSInterrupt interrupt, OSContext* context) if (VISetRegs()) { flushFlag = 0; -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L __PADRefreshSamplingRate(); #endif } @@ -262,7 +262,7 @@ static VITimingInfo* getTiming(VITVMode mode) return &timing[3]; } -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L case VI_TVMODE_EURGB60_INT: { return &timing[0]; @@ -287,7 +287,7 @@ static VITimingInfo* getTiming(VITVMode mode) return &timing[6]; } -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L case VI_TVMODE_NTSC_3D: { return &timing[7]; @@ -364,7 +364,7 @@ void __VIInit(VITVMode mode) __VIRegs[VI_DISP_INT_0U] = hct << 0; __VIRegs[VI_DISP_INT_0] = vct; -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L if (mode != VI_TVMODE_NTSC_PROG && mode != VI_TVMODE_NTSC_3D) #else if (mode != VI_TVMODE_NTSC_PROG) @@ -770,7 +770,7 @@ void VIConfigure(const GXRenderModeObj* obj) u32 regDspCfg; BOOL enabled; u32 newNonInter, tvInBootrom, tvInGame; -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L static u32 message = FALSE; #endif @@ -806,7 +806,7 @@ void VIConfigure(const GXRenderModeObj* obj) } #endif -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L if (tvInGame == VI_DEBUG_PAL && message == FALSE) { message = TRUE; OSReport("***************************************\n"); @@ -903,7 +903,7 @@ void VIFlush(void) { BOOL enabled; s32 regIndex; - u32 val; // for stack. + STACK_PAD_VAR(1); // for stack. enabled = OSDisableInterrupts(); #if defined(VERSION_GPIE01_00) || defined(VERSION_GPIJ01_01) @@ -983,32 +983,26 @@ u32 VIGetRetraceCount(void) */ static u32 getCurrentHalfLine(void) { -#if defined(VERSION_G98E01_PIKIDEMO) - u32 hcount; u32 vcount0; u32 vcount; - vcount = __VIRegs[22] & 0x7FF; - do { - vcount0 = vcount; - hcount = __VIRegs[23] & 0x7FF; - vcount = __VIRegs[22] & 0x7FF; - } while (vcount0 != vcount); - return ((vcount - 1) * 2) + ((hcount - 1) / CurrTiming->hlw); +#if OS_BUILD_VERSION >= 20011112L #else - u32 hcount; - u32 vcount0; - u32 vcount; VITimingInfo* tm; + tm = HorVer.timing; +#endif - tm = HorVer.timing; vcount = __VIRegs[22] & 0x7FF; do { vcount0 = vcount; hcount = __VIRegs[23] & 0x7FF; vcount = __VIRegs[22] & 0x7FF; } while (vcount0 != vcount); + +#if OS_BUILD_VERSION >= 20011112L + return ((vcount - 1) * 2) + ((hcount - 1) / CurrTiming->hlw); +#else return ((vcount - 1) * 2) + ((hcount - 1) / tm->hlw); #endif } @@ -1018,7 +1012,6 @@ static u32 getCurrentHalfLine(void) */ static u32 getCurrentFieldEvenOdd() { -#if defined(VERSION_G98E01_PIKIDEMO) u16 value; u32 nin; u32 fmt; @@ -1026,19 +1019,11 @@ static u32 getCurrentFieldEvenOdd() u32 nhlines; VITimingInfo* tm; +#if OS_BUILD_VERSION >= 20011112L if (getCurrentHalfLine() < CurrTiming->numHalfLines) { - return 1U; + return 1; } - return 0U; #else - - u16 value; - u32 nin; - u32 fmt; - VITVMode tvMode; - u32 nhlines; - VITimingInfo* tm; - if (__VIRegs[54] & 1) { tm = getTiming(VI_TVMODE_NTSC_PROG); } else { @@ -1052,8 +1037,8 @@ static u32 getCurrentFieldEvenOdd() if (getCurrentHalfLine() < nhlines) { return 1; } - return 0; #endif + return 0; } /** @@ -1078,7 +1063,7 @@ u32 VIGetNextField(void) */ u32 VIGetCurrentLine(void) { -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L u32 halfLine; VITimingInfo* tm; BOOL enabled; @@ -1100,7 +1085,7 @@ u32 VIGetCurrentLine(void) */ u32 VIGetTvFormat(void) { -#if defined(VERSION_G98E01_PIKIDEMO) +#if OS_BUILD_VERSION >= 20011112L s32 enabled; s32 format;