Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
],
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion include/BaseApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 0 additions & 6 deletions include/BoundBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions include/Dolphin/GX/GXData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion include/Dolphin/OS/OSContext.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions include/Dolphin/OS/OSError.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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];

//////////////////////////////////

Expand Down
7 changes: 2 additions & 5 deletions include/Dolphin/OS/OSExi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/Dolphin/OS/OSFastCast.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BEGIN_SCOPE_EXTERN_C

/////////////// FAST CAST INLINES /////////////////////////////////////////////////////////////////

static inline void OSInitFastCast()
static inline void OSInitFastCast(void)
{
#ifdef __MWERKS__
asm {
Expand Down
7 changes: 6 additions & 1 deletion include/Dolphin/OS/OSSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
32 changes: 32 additions & 0 deletions include/Dolphin/OS/OSVersion.h
Original file line number Diff line number Diff line change
@@ -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

///////////////////////////////////////////////////////////////////////////////////////////////////
33 changes: 14 additions & 19 deletions include/Dolphin/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions include/Dolphin/dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 19 additions & 18 deletions include/Dolphin/mtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "types.h"

#include "Dolphin/OS/OSVersion.h"
#include "Dolphin/vec.h"

BEGIN_SCOPE_EXTERN_C
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions include/Dolphin/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -64,13 +68,14 @@ void OSInit();

u32 OSGetConsoleType();

//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

/////////////// Extern Things /////////////////////////////////////////////////////////////////////

// extern things.
extern BOOL __OSInIPL;
extern OSTime __OSStartTime;

//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

END_SCOPE_EXTERN_C

Expand Down
Loading
Loading