diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h
index 1b27e0c3dd..97b135e683 100644
--- a/common/include/PS2Edefs.h
+++ b/common/include/PS2Edefs.h
@@ -63,68 +63,70 @@
///////////////////////////////////////////////////////////////////////
// freeze modes:
-#define FREEZE_LOAD 0
-#define FREEZE_SAVE 1
-#define FREEZE_SIZE 2
+#define FREEZE_LOAD 0
+#define FREEZE_SAVE 1
+#define FREEZE_SIZE 2
// event values:
-#define KEYPRESS 1
-#define KEYRELEASE 2
+#define KEYPRESS 1
+#define KEYRELEASE 2
-typedef struct {
- int size;
- s8 *data;
+typedef struct
+{
+ int size;
+ s8 *data;
} freezeData;
-typedef struct _keyEvent {
- u32 key;
- u32 evt;
+typedef struct _keyEvent
+{
+ u32 key;
+ u32 evt;
} keyEvent;
///////////////////////////////////////////////////////////////////////
-#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
+#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
- defined(USBdefs) || defined(FWdefs)
+ defined(USBdefs) || defined(FWdefs)
#define COMMONdefs
#endif
// PS2EgetLibType returns (may be OR'd)
-#define PS2E_LT_GS 0x01
-#define PS2E_LT_PAD 0x02 // -=[ OBSOLETE ]=-
+#define PS2E_LT_GS 0x01
+#define PS2E_LT_PAD 0x02 // -=[ OBSOLETE ]=-
#define PS2E_LT_SPU2 0x04
#define PS2E_LT_CDVD 0x08
#define PS2E_LT_DEV9 0x10
-#define PS2E_LT_USB 0x20
-#define PS2E_LT_FW 0x40
-#define PS2E_LT_SIO 0x80
+#define PS2E_LT_USB 0x20
+#define PS2E_LT_FW 0x40
+#define PS2E_LT_SIO 0x80
// PS2EgetLibVersion2 (high 16 bits)
-#define PS2E_GS_VERSION 0x0006
-#define PS2E_PAD_VERSION 0x0002 // -=[ OBSOLETE ]=-
+#define PS2E_GS_VERSION 0x0006
+#define PS2E_PAD_VERSION 0x0002 // -=[ OBSOLETE ]=-
#ifdef ENABLE_NEW_IOPDMA_SPU2
-# define PS2E_SPU2_VERSION 0x0006
+#define PS2E_SPU2_VERSION 0x0006
#else
-# define PS2E_SPU2_VERSION 0x0005
+#define PS2E_SPU2_VERSION 0x0005
#endif
#define PS2E_CDVD_VERSION 0x0005
#ifdef ENABLE_NEW_IOPDMA_DEV9
-# define PS2E_DEV9_VERSION 0x0004
+#define PS2E_DEV9_VERSION 0x0004
#else
-# define PS2E_DEV9_VERSION 0x0003
+#define PS2E_DEV9_VERSION 0x0003
#endif
-#define PS2E_USB_VERSION 0x0003
-#define PS2E_FW_VERSION 0x0002
-#define PS2E_SIO_VERSION 0x0001
+#define PS2E_USB_VERSION 0x0003
+#define PS2E_FW_VERSION 0x0002
+#define PS2E_SIO_VERSION 0x0001
#ifdef COMMONdefs
#ifdef __cplusplus
extern "C" {
#endif
-u32 CALLBACK PS2EgetLibType(void);
-u32 CALLBACK PS2EgetLibVersion2(u32 type);
-char* CALLBACK PS2EgetLibName(void);
+u32 CALLBACK PS2EgetLibType(void);
+u32 CALLBACK PS2EgetLibVersion2(u32 type);
+char *CALLBACK PS2EgetLibName(void);
#ifdef __cplusplus
}
@@ -139,85 +141,89 @@ char* CALLBACK PS2EgetLibName(void);
*/
// for 64bit compilers
-typedef char __keyEvent_Size__[(sizeof(keyEvent) == 8)?1:-1];
+typedef char __keyEvent_Size__[(sizeof(keyEvent) == 8) ? 1 : -1];
// plugin types
-#define SIO_TYPE_PAD 0x00000001
-#define SIO_TYPE_MTAP 0x00000004
-#define SIO_TYPE_RM 0x00000040
-#define SIO_TYPE_MC 0x00000100
+#define SIO_TYPE_PAD 0x00000001
+#define SIO_TYPE_MTAP 0x00000004
+#define SIO_TYPE_RM 0x00000040
+#define SIO_TYPE_MC 0x00000100
-typedef int (CALLBACK * SIOchangeSlotCB)(int slot);
+typedef int(CALLBACK *SIOchangeSlotCB)(int slot);
-typedef struct _cdvdSubQ {
- u8 ctrl:4; // control and mode bits
- u8 mode:4; // control and mode bits
- u8 trackNum; // current track number (1 to 99)
- u8 trackIndex; // current index within track (0 to 99)
- u8 trackM; // current minute location on the disc (BCD encoded)
- u8 trackS; // current sector location on the disc (BCD encoded)
- u8 trackF; // current frame location on the disc (BCD encoded)
- u8 pad; // unused
- u8 discM; // current minute offset from first track (BCD encoded)
- u8 discS; // current sector offset from first track (BCD encoded)
- u8 discF; // current frame offset from first track (BCD encoded)
+typedef struct _cdvdSubQ
+{
+ u8 ctrl : 4; // control and mode bits
+ u8 mode : 4; // control and mode bits
+ u8 trackNum; // current track number (1 to 99)
+ u8 trackIndex; // current index within track (0 to 99)
+ u8 trackM; // current minute location on the disc (BCD encoded)
+ u8 trackS; // current sector location on the disc (BCD encoded)
+ u8 trackF; // current frame location on the disc (BCD encoded)
+ u8 pad; // unused
+ u8 discM; // current minute offset from first track (BCD encoded)
+ u8 discS; // current sector offset from first track (BCD encoded)
+ u8 discF; // current frame offset from first track (BCD encoded)
} cdvdSubQ;
-typedef struct _cdvdTD { // NOT bcd coded
- u32 lsn;
- u8 type;
+typedef struct _cdvdTD
+{ // NOT bcd coded
+ u32 lsn;
+ u8 type;
} cdvdTD;
-typedef struct _cdvdTN {
- u8 strack; //number of the first track (usually 1)
- u8 etrack; //number of the last track
+typedef struct _cdvdTN
+{
+ u8 strack; //number of the first track (usually 1)
+ u8 etrack; //number of the last track
} cdvdTN;
// CDVDreadTrack mode values:
-#define CDVD_MODE_2352 0 // full 2352 bytes
-#define CDVD_MODE_2340 1 // skip sync (12) bytes
-#define CDVD_MODE_2328 2 // skip sync+head+sub (24) bytes
-#define CDVD_MODE_2048 3 // skip sync+head+sub (24) bytes
-#define CDVD_MODE_2368 4 // full 2352 bytes + 16 subq
+#define CDVD_MODE_2352 0 // full 2352 bytes
+#define CDVD_MODE_2340 1 // skip sync (12) bytes
+#define CDVD_MODE_2328 2 // skip sync+head+sub (24) bytes
+#define CDVD_MODE_2048 3 // skip sync+head+sub (24) bytes
+#define CDVD_MODE_2368 4 // full 2352 bytes + 16 subq
// CDVDgetDiskType returns:
-#define CDVD_TYPE_ILLEGAL 0xff // Illegal Disc
-#define CDVD_TYPE_DVDV 0xfe // DVD Video
-#define CDVD_TYPE_CDDA 0xfd // Audio CD
-#define CDVD_TYPE_PS2DVD 0x14 // PS2 DVD
-#define CDVD_TYPE_PS2CDDA 0x13 // PS2 CD (with audio)
-#define CDVD_TYPE_PS2CD 0x12 // PS2 CD
-#define CDVD_TYPE_PSCDDA 0x11 // PS CD (with audio)
-#define CDVD_TYPE_PSCD 0x10 // PS CD
-#define CDVD_TYPE_UNKNOWN 0x05 // Unknown
-#define CDVD_TYPE_DETCTDVDD 0x04 // Detecting Dvd Dual Sided
-#define CDVD_TYPE_DETCTDVDS 0x03 // Detecting Dvd Single Sided
-#define CDVD_TYPE_DETCTCD 0x02 // Detecting Cd
-#define CDVD_TYPE_DETCT 0x01 // Detecting
-#define CDVD_TYPE_NODISC 0x00 // No Disc
+#define CDVD_TYPE_ILLEGAL 0xff // Illegal Disc
+#define CDVD_TYPE_DVDV 0xfe // DVD Video
+#define CDVD_TYPE_CDDA 0xfd // Audio CD
+#define CDVD_TYPE_PS2DVD 0x14 // PS2 DVD
+#define CDVD_TYPE_PS2CDDA 0x13 // PS2 CD (with audio)
+#define CDVD_TYPE_PS2CD 0x12 // PS2 CD
+#define CDVD_TYPE_PSCDDA 0x11 // PS CD (with audio)
+#define CDVD_TYPE_PSCD 0x10 // PS CD
+#define CDVD_TYPE_UNKNOWN 0x05 // Unknown
+#define CDVD_TYPE_DETCTDVDD 0x04 // Detecting Dvd Dual Sided
+#define CDVD_TYPE_DETCTDVDS 0x03 // Detecting Dvd Single Sided
+#define CDVD_TYPE_DETCTCD 0x02 // Detecting Cd
+#define CDVD_TYPE_DETCT 0x01 // Detecting
+#define CDVD_TYPE_NODISC 0x00 // No Disc
// CDVDgetTrayStatus returns:
-#define CDVD_TRAY_CLOSE 0x00
-#define CDVD_TRAY_OPEN 0x01
+#define CDVD_TRAY_CLOSE 0x00
+#define CDVD_TRAY_OPEN 0x01
// cdvdTD.type (track types for cds)
-#define CDVD_AUDIO_TRACK 0x01
-#define CDVD_MODE1_TRACK 0x41
-#define CDVD_MODE2_TRACK 0x61
+#define CDVD_AUDIO_TRACK 0x01
+#define CDVD_MODE1_TRACK 0x41
+#define CDVD_MODE2_TRACK 0x61
-#define CDVD_AUDIO_MASK 0x00
-#define CDVD_DATA_MASK 0x40
+#define CDVD_AUDIO_MASK 0x00
+#define CDVD_DATA_MASK 0x40
// CDROM_DATA_TRACK 0x04 //do not enable this! (from linux kernel)
typedef void (*DEV9callback)(int cycles);
-typedef int (*DEV9handler)(void);
+typedef int (*DEV9handler)(void);
typedef void (*USBcallback)(int cycles);
-typedef int (*USBhandler)(void);
+typedef int (*USBhandler)(void);
-typedef struct _GSdriverInfo {
- char name[8];
- void *common;
+typedef struct _GSdriverInfo
+{
+ char name[8];
+ void *common;
} GSdriverInfo;
#ifdef __cplusplus
@@ -232,19 +238,19 @@ extern "C" {
// basic funcs
-s32 CALLBACK GSinit();
-s32 CALLBACK GSopen(void *pDsp, const char *Title, int multithread);
+s32 CALLBACK GSinit();
+s32 CALLBACK GSopen(void *pDsp, const char *Title, int multithread);
void CALLBACK GSclose();
void CALLBACK GSshutdown();
-void CALLBACK GSsetSettingsDir( const char* dir );
-void CALLBACK GSsetLogDir( const char* dir );
+void CALLBACK GSsetSettingsDir(const char *dir);
+void CALLBACK GSsetLogDir(const char *dir);
void CALLBACK GSvsync(int field);
void CALLBACK GSgifTransfer(const u32 *pMem, u32 addr);
void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr);
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size);
void CALLBACK GSgifTransfer3(u32 *pMem, u32 size);
-void CALLBACK GSgetLastTag(u64* ptag); // returns the last tag processed (64 bits)
+void CALLBACK GSgetLastTag(u64 *ptag); // returns the last tag processed (64 bits)
void CALLBACK GSgifSoftReset(u32 mask);
void CALLBACK GSreadFIFO(u64 *mem);
void CALLBACK GSinitReadFIFO(u64 *mem);
@@ -255,12 +261,12 @@ void CALLBACK GSinitReadFIFO2(u64 *mem, int qwc);
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
void CALLBACK GSkeyEvent(keyEvent *ev);
-void CALLBACK GSchangeSaveState(int, const char* filename);
+void CALLBACK GSchangeSaveState(int, const char *filename);
void CALLBACK GSmakeSnapshot(char *path);
-void CALLBACK GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg);
+void CALLBACK GSmakeSnapshot2(char *pathname, int *snapdone, int savejpg);
void CALLBACK GSirqCallback(void (*callback)());
void CALLBACK GSprintf(int timeout, char *fmt, ...);
-void CALLBACK GSsetBaseMem(void*);
+void CALLBACK GSsetBaseMem(void *);
void CALLBACK GSsetGameCRC(int crc, int gameoptions);
// controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done
@@ -269,17 +275,17 @@ void CALLBACK GSsetFrameSkip(int frameskip);
// if start is 1, starts recording spu2 data, else stops
// returns a non zero value if successful
// for now, pData is not used
-int CALLBACK GSsetupRecording(int start, void* pData);
+int CALLBACK GSsetupRecording(int start, void *pData);
void CALLBACK GSreset();
//deprecated: GSgetTitleInfo was used in PCSX2 but no plugin supported it prior to r4070:
//void CALLBACK GSgetTitleInfo( char dest[128] );
-void CALLBACK GSgetTitleInfo2( char* dest, size_t length );
+void CALLBACK GSgetTitleInfo2(char *dest, size_t length);
void CALLBACK GSwriteCSR(u32 value);
-s32 CALLBACK GSfreeze(int mode, freezeData *data);
+s32 CALLBACK GSfreeze(int mode, freezeData *data);
void CALLBACK GSconfigure();
void CALLBACK GSabout();
-s32 CALLBACK GStest();
+s32 CALLBACK GStest();
#endif
@@ -291,21 +297,21 @@ s32 CALLBACK GStest();
// basic funcs
-s32 CALLBACK PADinit(u32 flags);
-s32 CALLBACK PADopen(void *pDsp);
+s32 CALLBACK PADinit(u32 flags);
+s32 CALLBACK PADopen(void *pDsp);
void CALLBACK PADclose();
void CALLBACK PADshutdown();
-void CALLBACK PADsetSettingsDir( const char* dir );
-void CALLBACK PADsetLogDir( const char* dir );
+void CALLBACK PADsetSettingsDir(const char *dir);
+void CALLBACK PADsetLogDir(const char *dir);
// PADkeyEvent is called every vsync (return NULL if no event)
-keyEvent* CALLBACK PADkeyEvent();
-u8 CALLBACK PADstartPoll(int pad);
-u8 CALLBACK PADpoll(u8 value);
+keyEvent *CALLBACK PADkeyEvent();
+u8 CALLBACK PADstartPoll(int pad);
+u8 CALLBACK PADpoll(u8 value);
// returns: 1 if supported pad1
// 2 if supported pad2
// 3 if both are supported
-u32 CALLBACK PADquery();
+u32 CALLBACK PADquery();
// call to give a hint to the PAD plugin to query for the keyboard state. A
// good plugin will query the OS for keyboard state ONLY in this function.
@@ -326,7 +332,7 @@ void CALLBACK PADWriteEvent(keyEvent &evt);
void CALLBACK PADgsDriverInfo(GSdriverInfo *info);
void CALLBACK PADconfigure();
void CALLBACK PADabout();
-s32 CALLBACK PADtest();
+s32 CALLBACK PADtest();
#endif
@@ -338,20 +344,20 @@ s32 CALLBACK PADtest();
// basic funcs
-s32 CALLBACK SPU2init();
-s32 CALLBACK SPU2open(void *pDsp);
+s32 CALLBACK SPU2init();
+s32 CALLBACK SPU2open(void *pDsp);
void CALLBACK SPU2close();
void CALLBACK SPU2shutdown();
-void CALLBACK SPU2setSettingsDir( const char* dir );
-void CALLBACK SPU2setLogDir( const char* dir );
+void CALLBACK SPU2setSettingsDir(const char *dir);
+void CALLBACK SPU2setLogDir(const char *dir);
void CALLBACK SPU2reset();
void CALLBACK SPU2write(u32 mem, u16 value);
-u16 CALLBACK SPU2read(u32 mem);
+u16 CALLBACK SPU2read(u32 mem);
#ifdef ENABLE_NEW_IOPDMA_SPU2
-s32 CALLBACK SPU2dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed);
-s32 CALLBACK SPU2dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed);
+s32 CALLBACK SPU2dmaRead(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed);
+s32 CALLBACK SPU2dmaWrite(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed);
void CALLBACK SPU2dmaInterrupt(s32 channel);
// dma irq callbacks not needed anymore, they are handled by the dmac
@@ -360,7 +366,7 @@ void CALLBACK SPU2irqCallback(void (*SPU2callback)());
void CALLBACK SPU2readDMA4Mem(u16 *pMem, int size);
void CALLBACK SPU2writeDMA4Mem(u16 *pMem, int size);
void CALLBACK SPU2interruptDMA4();
-void CALLBACK SPU2readDMA7Mem(u16* pMem, int size);
+void CALLBACK SPU2readDMA7Mem(u16 *pMem, int size);
void CALLBACK SPU2writeDMA7Mem(u16 *pMem, int size);
// all addresses passed by dma will be pointers to the array starting at baseaddr
@@ -370,25 +376,25 @@ void CALLBACK SPU2setDMABaseAddr(uptr baseaddr);
void CALLBACK SPU2interruptDMA7();
u32 CALLBACK SPU2ReadMemAddr(int core);
-void CALLBACK SPU2WriteMemAddr(int core,u32 value);
+void CALLBACK SPU2WriteMemAddr(int core, u32 value);
-void CALLBACK SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
+void CALLBACK SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)());
#endif
// extended funcs
// if start is 1, starts recording spu2 data, else stops
// returns a non zero value if successful
// for now, pData is not used
-int CALLBACK SPU2setupRecording(int start, void* pData);
+int CALLBACK SPU2setupRecording(int start, void *pData);
-void CALLBACK SPU2setClockPtr(u32* ptr);
+void CALLBACK SPU2setClockPtr(u32 *ptr);
void CALLBACK SPU2setTimeStretcher(short int enable);
void CALLBACK SPU2async(u32 cycles);
-s32 CALLBACK SPU2freeze(int mode, freezeData *data);
+s32 CALLBACK SPU2freeze(int mode, freezeData *data);
void CALLBACK SPU2configure();
void CALLBACK SPU2about();
-s32 CALLBACK SPU2test();
+s32 CALLBACK SPU2test();
#endif
@@ -400,44 +406,44 @@ s32 CALLBACK SPU2test();
// basic funcs
-s32 CALLBACK CDVDinit();
-s32 CALLBACK CDVDopen(const char* pTitleFilename);
+s32 CALLBACK CDVDinit();
+s32 CALLBACK CDVDopen(const char *pTitleFilename);
void CALLBACK CDVDclose();
void CALLBACK CDVDshutdown();
-void CALLBACK CDVDsetSettingsDir( const char* dir );
-void CALLBACK CDVDsetLogDir( const char* dir );
+void CALLBACK CDVDsetSettingsDir(const char *dir);
+void CALLBACK CDVDsetLogDir(const char *dir);
-s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
+s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
// return can be NULL (for async modes)
-u8* CALLBACK CDVDgetBuffer();
+u8 *CALLBACK CDVDgetBuffer();
-s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq);//read subq from disc (only cds have subq data)
-s32 CALLBACK CDVDgetTN(cdvdTN *Buffer); //disk information
-s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
-s32 CALLBACK CDVDgetTOC(void* toc); //gets ps2 style toc from disc
-s32 CALLBACK CDVDgetDiskType(); //CDVD_TYPE_xxxx
-s32 CALLBACK CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
-s32 CALLBACK CDVDctrlTrayOpen(); //open disc tray
-s32 CALLBACK CDVDctrlTrayClose(); //close disc tray
+s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ *subq); //read subq from disc (only cds have subq data)
+s32 CALLBACK CDVDgetTN(cdvdTN *Buffer); //disk information
+s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
+s32 CALLBACK CDVDgetTOC(void *toc); //gets ps2 style toc from disc
+s32 CALLBACK CDVDgetDiskType(); //CDVD_TYPE_xxxx
+s32 CALLBACK CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
+s32 CALLBACK CDVDctrlTrayOpen(); //open disc tray
+s32 CALLBACK CDVDctrlTrayClose(); //close disc tray
// extended funcs
void CALLBACK CDVDconfigure();
void CALLBACK CDVDabout();
-s32 CALLBACK CDVDtest();
+s32 CALLBACK CDVDtest();
void CALLBACK CDVDnewDiskCB(void (*callback)());
// new funcs
// read a track directly
-s32 CALLBACK CDVDreadSector(u8* buffer, s32 lsn, int mode);
+s32 CALLBACK CDVDreadSector(u8 *buffer, s32 lsn, int mode);
// improved getBuffer
-s32 CALLBACK CDVDgetBuffer2(u8* buffer);
+s32 CALLBACK CDVDgetBuffer2(u8 *buffer);
// tool function
-s32 CALLBACK CDVDgetDualInfo(s32* dualType, u32* _layer1start);
+s32 CALLBACK CDVDgetDualInfo(s32 *dualType, u32 *_layer1start);
#endif
@@ -451,22 +457,22 @@ s32 CALLBACK CDVDgetDualInfo(s32* dualType, u32* _layer1start);
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
-s32 CALLBACK DEV9init();
-s32 CALLBACK DEV9open(void *pDsp);
+s32 CALLBACK DEV9init();
+s32 CALLBACK DEV9open(void *pDsp);
void CALLBACK DEV9close();
void CALLBACK DEV9shutdown();
-void CALLBACK DEV9setSettingsDir( const char* dir );
-void CALLBACK DEV9setLogDir( const char* dir );
+void CALLBACK DEV9setSettingsDir(const char *dir);
+void CALLBACK DEV9setLogDir(const char *dir);
-u8 CALLBACK DEV9read8(u32 addr);
-u16 CALLBACK DEV9read16(u32 addr);
-u32 CALLBACK DEV9read32(u32 addr);
-void CALLBACK DEV9write8(u32 addr, u8 value);
+u8 CALLBACK DEV9read8(u32 addr);
+u16 CALLBACK DEV9read16(u32 addr);
+u32 CALLBACK DEV9read32(u32 addr);
+void CALLBACK DEV9write8(u32 addr, u8 value);
void CALLBACK DEV9write16(u32 addr, u16 value);
void CALLBACK DEV9write32(u32 addr, u32 value);
#ifdef ENABLE_NEW_IOPDMA_DEV9
-s32 CALLBACK DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed);
-s32 CALLBACK DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed);
+s32 CALLBACK DEV9dmaRead(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed);
+s32 CALLBACK DEV9dmaWrite(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed);
void CALLBACK DEV9dmaInterrupt(s32 channel);
#else
void CALLBACK DEV9readDMA8Mem(u32 *pMem, int size);
@@ -479,10 +485,10 @@ DEV9handler CALLBACK DEV9irqHandler(void);
// extended funcs
-s32 CALLBACK DEV9freeze(int mode, freezeData *data);
+s32 CALLBACK DEV9freeze(int mode, freezeData *data);
void CALLBACK DEV9configure();
void CALLBACK DEV9about();
-s32 CALLBACK DEV9test();
+s32 CALLBACK DEV9test();
#endif
@@ -494,17 +500,17 @@ s32 CALLBACK DEV9test();
// basic funcs
-s32 CALLBACK USBinit();
-s32 CALLBACK USBopen(void *pDsp);
+s32 CALLBACK USBinit();
+s32 CALLBACK USBopen(void *pDsp);
void CALLBACK USBclose();
void CALLBACK USBshutdown();
-void CALLBACK USBsetSettingsDir( const char* dir );
-void CALLBACK USBsetLogDir( const char* dir );
+void CALLBACK USBsetSettingsDir(const char *dir);
+void CALLBACK USBsetLogDir(const char *dir);
-u8 CALLBACK USBread8(u32 addr);
-u16 CALLBACK USBread16(u32 addr);
-u32 CALLBACK USBread32(u32 addr);
-void CALLBACK USBwrite8(u32 addr, u8 value);
+u8 CALLBACK USBread8(u32 addr);
+u16 CALLBACK USBread16(u32 addr);
+u32 CALLBACK USBread32(u32 addr);
+void CALLBACK USBwrite8(u32 addr, u8 value);
void CALLBACK USBwrite16(u32 addr, u16 value);
void CALLBACK USBwrite32(u32 addr, u32 value);
void CALLBACK USBasync(u32 cycles);
@@ -517,10 +523,10 @@ void CALLBACK USBsetRAM(void *mem);
// extended funcs
-s32 CALLBACK USBfreeze(int mode, freezeData *data);
+s32 CALLBACK USBfreeze(int mode, freezeData *data);
void CALLBACK USBconfigure();
void CALLBACK USBabout();
-s32 CALLBACK USBtest();
+s32 CALLBACK USBtest();
#endif
@@ -533,324 +539,324 @@ s32 CALLBACK USBtest();
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
-s32 CALLBACK FWinit();
-s32 CALLBACK FWopen(void *pDsp);
+s32 CALLBACK FWinit();
+s32 CALLBACK FWopen(void *pDsp);
void CALLBACK FWclose();
void CALLBACK FWshutdown();
-void CALLBACK FWsetSettingsDir( const char* dir );
-void CALLBACK FWsetLogDir( const char* dir );
+void CALLBACK FWsetSettingsDir(const char *dir);
+void CALLBACK FWsetLogDir(const char *dir);
-u32 CALLBACK FWread32(u32 addr);
+u32 CALLBACK FWread32(u32 addr);
void CALLBACK FWwrite32(u32 addr, u32 value);
void CALLBACK FWirqCallback(void (*callback)());
// extended funcs
-s32 CALLBACK FWfreeze(int mode, freezeData *data);
+s32 CALLBACK FWfreeze(int mode, freezeData *data);
void CALLBACK FWconfigure();
void CALLBACK FWabout();
-s32 CALLBACK FWtest();
+s32 CALLBACK FWtest();
#endif
// might be useful for emulators
#ifdef PLUGINtypedefs
-typedef u32 (CALLBACK* _PS2EgetLibType)(void);
-typedef u32 (CALLBACK* _PS2EgetLibVersion2)(u32 type);
-typedef char*(CALLBACK* _PS2EgetLibName)(void);
+typedef u32(CALLBACK *_PS2EgetLibType)(void);
+typedef u32(CALLBACK *_PS2EgetLibVersion2)(u32 type);
+typedef char *(CALLBACK *_PS2EgetLibName)(void);
-typedef void (CALLBACK* _PS2EsetEmuVersion)(const char* emuId, u32 version); // HACK to let some plugins know it's 0.9.7 PCSX2 --air
+typedef void(CALLBACK *_PS2EsetEmuVersion)(const char *emuId, u32 version); // HACK to let some plugins know it's 0.9.7 PCSX2 --air
// GS
// NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
-typedef s32 (CALLBACK* _GSopen)(void *pDsp, const char *Title, int multithread);
-typedef s32 (CALLBACK* _GSopen2)( void *pDsp, u32 flags );
-typedef void (CALLBACK* _GSvsync)(int field);
-typedef void (CALLBACK* _GSgifTransfer)(const u32 *pMem, u32 size);
-typedef void (CALLBACK* _GSgifTransfer1)(u32 *pMem, u32 addr);
-typedef void (CALLBACK* _GSgifTransfer2)(u32 *pMem, u32 size);
-typedef void (CALLBACK* _GSgifTransfer3)(u32 *pMem, u32 size);
-typedef void (CALLBACK* _GSgifSoftReset)(u32 mask);
-typedef void (CALLBACK* _GSreadFIFO)(u64 *pMem);
-typedef void (CALLBACK* _GSreadFIFO2)(u64 *pMem, int qwc);
-typedef void (CALLBACK* _GSinitReadFIFO)(u64 *pMem);
-typedef void (CALLBACK* _GSinitReadFIFO2)(u64 *pMem, int qwc);
+typedef s32(CALLBACK *_GSopen)(void *pDsp, const char *Title, int multithread);
+typedef s32(CALLBACK *_GSopen2)(void *pDsp, u32 flags);
+typedef void(CALLBACK *_GSvsync)(int field);
+typedef void(CALLBACK *_GSgifTransfer)(const u32 *pMem, u32 size);
+typedef void(CALLBACK *_GSgifTransfer1)(u32 *pMem, u32 addr);
+typedef void(CALLBACK *_GSgifTransfer2)(u32 *pMem, u32 size);
+typedef void(CALLBACK *_GSgifTransfer3)(u32 *pMem, u32 size);
+typedef void(CALLBACK *_GSgifSoftReset)(u32 mask);
+typedef void(CALLBACK *_GSreadFIFO)(u64 *pMem);
+typedef void(CALLBACK *_GSreadFIFO2)(u64 *pMem, int qwc);
+typedef void(CALLBACK *_GSinitReadFIFO)(u64 *pMem);
+typedef void(CALLBACK *_GSinitReadFIFO2)(u64 *pMem, int qwc);
-typedef void (CALLBACK* _GSchangeSaveState)(int, const char* filename);
-typedef void (CALLBACK* _GSgetTitleInfo2)(char* dest, size_t length);
-typedef void (CALLBACK* _GSirqCallback)(void (*callback)());
-typedef void (CALLBACK* _GSprintf)(int timeout, char *fmt, ...);
-typedef void (CALLBACK* _GSsetBaseMem)(void*);
-typedef void (CALLBACK* _GSsetGameCRC)(int, int);
-typedef void (CALLBACK* _GSsetFrameSkip)(int frameskip);
-typedef void (CALLBACK* _GSsetFrameLimit)(int limit);
-typedef void (CALLBACK* _GSsetVsync)(int enabled);
-typedef void (CALLBACK* _GSsetExclusive)(int isExclusive);
-typedef int (CALLBACK* _GSsetupRecording)(int, void*);
-typedef void (CALLBACK* _GSreset)();
-typedef void (CALLBACK* _GSwriteCSR)(u32 value);
-typedef void (CALLBACK* _GSmakeSnapshot)(const char *path);
-typedef void (CALLBACK* _GSmakeSnapshot2)(const char *path, int*, int);
+typedef void(CALLBACK *_GSchangeSaveState)(int, const char *filename);
+typedef void(CALLBACK *_GSgetTitleInfo2)(char *dest, size_t length);
+typedef void(CALLBACK *_GSirqCallback)(void (*callback)());
+typedef void(CALLBACK *_GSprintf)(int timeout, char *fmt, ...);
+typedef void(CALLBACK *_GSsetBaseMem)(void *);
+typedef void(CALLBACK *_GSsetGameCRC)(int, int);
+typedef void(CALLBACK *_GSsetFrameSkip)(int frameskip);
+typedef void(CALLBACK *_GSsetFrameLimit)(int limit);
+typedef void(CALLBACK *_GSsetVsync)(int enabled);
+typedef void(CALLBACK *_GSsetExclusive)(int isExclusive);
+typedef int(CALLBACK *_GSsetupRecording)(int, void *);
+typedef void(CALLBACK *_GSreset)();
+typedef void(CALLBACK *_GSwriteCSR)(u32 value);
+typedef void(CALLBACK *_GSmakeSnapshot)(const char *path);
+typedef void(CALLBACK *_GSmakeSnapshot2)(const char *path, int *, int);
// PAD
-typedef s32 (CALLBACK* _PADinit)(u32 flags);
-typedef s32 (CALLBACK* _PADopen)(void *pDsp);
-typedef u8 (CALLBACK* _PADstartPoll)(int pad);
-typedef u8 (CALLBACK* _PADpoll)(u8 value);
-typedef u32 (CALLBACK* _PADquery)(int pad);
-typedef void (CALLBACK* _PADupdate)(int pad);
-typedef keyEvent* (CALLBACK* _PADkeyEvent)();
-typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info);
-typedef s32 (CALLBACK* _PADsetSlot)(u8 port, u8 slot);
-typedef s32 (CALLBACK* _PADqueryMtap)(u8 port);
-typedef void (CALLBACK* _PADWriteEvent)(keyEvent &evt);
+typedef s32(CALLBACK *_PADinit)(u32 flags);
+typedef s32(CALLBACK *_PADopen)(void *pDsp);
+typedef u8(CALLBACK *_PADstartPoll)(int pad);
+typedef u8(CALLBACK *_PADpoll)(u8 value);
+typedef u32(CALLBACK *_PADquery)(int pad);
+typedef void(CALLBACK *_PADupdate)(int pad);
+typedef keyEvent *(CALLBACK *_PADkeyEvent)();
+typedef void(CALLBACK *_PADgsDriverInfo)(GSdriverInfo *info);
+typedef s32(CALLBACK *_PADsetSlot)(u8 port, u8 slot);
+typedef s32(CALLBACK *_PADqueryMtap)(u8 port);
+typedef void(CALLBACK *_PADWriteEvent)(keyEvent &evt);
// SPU2
-typedef s32 (CALLBACK* _SPU2open)(void *pDsp);
-typedef void (CALLBACK* _SPU2reset)();
-typedef void (CALLBACK* _SPU2write)(u32 mem, u16 value);
-typedef u16 (CALLBACK* _SPU2read)(u32 mem);
+typedef s32(CALLBACK *_SPU2open)(void *pDsp);
+typedef void(CALLBACK *_SPU2reset)();
+typedef void(CALLBACK *_SPU2write)(u32 mem, u16 value);
+typedef u16(CALLBACK *_SPU2read)(u32 mem);
#ifdef ENABLE_NEW_IOPDMA_SPU2
-typedef s32 (CALLBACK* _SPU2dmaRead)(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed);
-typedef s32 (CALLBACK* _SPU2dmaWrite)(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed);
-typedef void (CALLBACK* _SPU2dmaInterrupt)(s32 channel);
+typedef s32(CALLBACK *_SPU2dmaRead)(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed);
+typedef s32(CALLBACK *_SPU2dmaWrite)(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed);
+typedef void(CALLBACK *_SPU2dmaInterrupt)(s32 channel);
// dma irq callbacks not needed anymore, they are handled by the dmac
-typedef void (CALLBACK* _SPU2irqCallback)(void (*SPU2callback)());
+typedef void(CALLBACK *_SPU2irqCallback)(void (*SPU2callback)());
#else
-typedef void (CALLBACK* _SPU2readDMA4Mem)(u16 *pMem, int size);
-typedef void (CALLBACK* _SPU2writeDMA4Mem)(u16 *pMem, int size);
-typedef void (CALLBACK* _SPU2interruptDMA4)();
-typedef void (CALLBACK* _SPU2readDMA7Mem)(u16 *pMem, int size);
-typedef void (CALLBACK* _SPU2writeDMA7Mem)(u16 *pMem, int size);
-typedef void (CALLBACK* _SPU2setDMABaseAddr)(uptr baseaddr);
-typedef void (CALLBACK* _SPU2interruptDMA7)();
-typedef void (CALLBACK* _SPU2irqCallback)(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
-typedef u32 (CALLBACK* _SPU2ReadMemAddr)(int core);
-typedef void (CALLBACK* _SPU2WriteMemAddr)(int core,u32 value);
+typedef void(CALLBACK *_SPU2readDMA4Mem)(u16 *pMem, int size);
+typedef void(CALLBACK *_SPU2writeDMA4Mem)(u16 *pMem, int size);
+typedef void(CALLBACK *_SPU2interruptDMA4)();
+typedef void(CALLBACK *_SPU2readDMA7Mem)(u16 *pMem, int size);
+typedef void(CALLBACK *_SPU2writeDMA7Mem)(u16 *pMem, int size);
+typedef void(CALLBACK *_SPU2setDMABaseAddr)(uptr baseaddr);
+typedef void(CALLBACK *_SPU2interruptDMA7)();
+typedef void(CALLBACK *_SPU2irqCallback)(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)());
+typedef u32(CALLBACK *_SPU2ReadMemAddr)(int core);
+typedef void(CALLBACK *_SPU2WriteMemAddr)(int core, u32 value);
#endif
-typedef int (CALLBACK* _SPU2setupRecording)(int, void*);
+typedef int(CALLBACK *_SPU2setupRecording)(int, void *);
-typedef void (CALLBACK* _SPU2setClockPtr)(u32*ptr);
-typedef void (CALLBACK* _SPU2setTimeStretcher)(short int enable);
+typedef void(CALLBACK *_SPU2setClockPtr)(u32 *ptr);
+typedef void(CALLBACK *_SPU2setTimeStretcher)(short int enable);
-typedef void (CALLBACK* _SPU2async)(u32 cycles);
+typedef void(CALLBACK *_SPU2async)(u32 cycles);
// CDVD
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
-typedef s32 (CALLBACK* _CDVDopen)(const char* pTitleFilename);
+typedef s32(CALLBACK *_CDVDopen)(const char *pTitleFilename);
// Initiates an asynchronous track read operation.
// Returns -1 on error (invalid track)
// Returns 0 on success.
-typedef s32 (CALLBACK* _CDVDreadTrack)(u32 lsn, int mode);
+typedef s32(CALLBACK *_CDVDreadTrack)(u32 lsn, int mode);
// *OBSOLETE* returns a pointer to the buffer, or NULL if data hasn't finished
// loading yet.
-typedef u8* (CALLBACK* _CDVDgetBuffer)();
+typedef u8 *(CALLBACK *_CDVDgetBuffer)();
// Copies loaded data to the target buffer.
// Returns -2 if the asynchronous read is still pending.
// Returns -1 if the asyncronous read failed.
// Returns 0 on success.
-typedef s32 (CALLBACK* _CDVDgetBuffer2)(u8* buffer);
+typedef s32(CALLBACK *_CDVDgetBuffer2)(u8 *buffer);
-typedef s32 (CALLBACK* _CDVDreadSubQ)(u32 lsn, cdvdSubQ* subq);
-typedef s32 (CALLBACK* _CDVDgetTN)(cdvdTN *Buffer);
-typedef s32 (CALLBACK* _CDVDgetTD)(u8 Track, cdvdTD *Buffer);
-typedef s32 (CALLBACK* _CDVDgetTOC)(void* toc);
-typedef s32 (CALLBACK* _CDVDgetDiskType)();
-typedef s32 (CALLBACK* _CDVDgetTrayStatus)();
-typedef s32 (CALLBACK* _CDVDctrlTrayOpen)();
-typedef s32 (CALLBACK* _CDVDctrlTrayClose)();
-typedef s32 (CALLBACK* _CDVDreadSector)(u8* buffer, u32 lsn, int mode);
-typedef s32 (CALLBACK* _CDVDgetDualInfo)(s32* dualType, u32* _layer1start);
+typedef s32(CALLBACK *_CDVDreadSubQ)(u32 lsn, cdvdSubQ *subq);
+typedef s32(CALLBACK *_CDVDgetTN)(cdvdTN *Buffer);
+typedef s32(CALLBACK *_CDVDgetTD)(u8 Track, cdvdTD *Buffer);
+typedef s32(CALLBACK *_CDVDgetTOC)(void *toc);
+typedef s32(CALLBACK *_CDVDgetDiskType)();
+typedef s32(CALLBACK *_CDVDgetTrayStatus)();
+typedef s32(CALLBACK *_CDVDctrlTrayOpen)();
+typedef s32(CALLBACK *_CDVDctrlTrayClose)();
+typedef s32(CALLBACK *_CDVDreadSector)(u8 *buffer, u32 lsn, int mode);
+typedef s32(CALLBACK *_CDVDgetDualInfo)(s32 *dualType, u32 *_layer1start);
-typedef void (CALLBACK* _CDVDnewDiskCB)(void (*callback)());
+typedef void(CALLBACK *_CDVDnewDiskCB)(void (*callback)());
// DEV9
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
-typedef s32 (CALLBACK* _DEV9open)(void *pDsp);
-typedef u8 (CALLBACK* _DEV9read8)(u32 mem);
-typedef u16 (CALLBACK* _DEV9read16)(u32 mem);
-typedef u32 (CALLBACK* _DEV9read32)(u32 mem);
-typedef void (CALLBACK* _DEV9write8)(u32 mem, u8 value);
-typedef void (CALLBACK* _DEV9write16)(u32 mem, u16 value);
-typedef void (CALLBACK* _DEV9write32)(u32 mem, u32 value);
+typedef s32(CALLBACK *_DEV9open)(void *pDsp);
+typedef u8(CALLBACK *_DEV9read8)(u32 mem);
+typedef u16(CALLBACK *_DEV9read16)(u32 mem);
+typedef u32(CALLBACK *_DEV9read32)(u32 mem);
+typedef void(CALLBACK *_DEV9write8)(u32 mem, u8 value);
+typedef void(CALLBACK *_DEV9write16)(u32 mem, u16 value);
+typedef void(CALLBACK *_DEV9write32)(u32 mem, u32 value);
#ifdef ENABLE_NEW_IOPDMA_DEV9
-typedef s32 (CALLBACK* _DEV9dmaRead)(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed);
-typedef s32 (CALLBACK* _DEV9dmaWrite)(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed);
-typedef void (CALLBACK* _DEV9dmaInterrupt)(s32 channel);
+typedef s32(CALLBACK *_DEV9dmaRead)(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed);
+typedef s32(CALLBACK *_DEV9dmaWrite)(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed);
+typedef void(CALLBACK *_DEV9dmaInterrupt)(s32 channel);
#else
-typedef void (CALLBACK* _DEV9readDMA8Mem)(u32 *pMem, int size);
-typedef void (CALLBACK* _DEV9writeDMA8Mem)(u32 *pMem, int size);
+typedef void(CALLBACK *_DEV9readDMA8Mem)(u32 *pMem, int size);
+typedef void(CALLBACK *_DEV9writeDMA8Mem)(u32 *pMem, int size);
#endif
-typedef void (CALLBACK* _DEV9irqCallback)(DEV9callback callback);
-typedef DEV9handler (CALLBACK* _DEV9irqHandler)(void);
-typedef void (CALLBACK* _DEV9async)(u32 cycles);
+typedef void(CALLBACK *_DEV9irqCallback)(DEV9callback callback);
+typedef DEV9handler(CALLBACK *_DEV9irqHandler)(void);
+typedef void(CALLBACK *_DEV9async)(u32 cycles);
// USB
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
-typedef s32 (CALLBACK* _USBopen)(void *pDsp);
-typedef u8 (CALLBACK* _USBread8)(u32 mem);
-typedef u16 (CALLBACK* _USBread16)(u32 mem);
-typedef u32 (CALLBACK* _USBread32)(u32 mem);
-typedef void (CALLBACK* _USBwrite8)(u32 mem, u8 value);
-typedef void (CALLBACK* _USBwrite16)(u32 mem, u16 value);
-typedef void (CALLBACK* _USBwrite32)(u32 mem, u32 value);
-typedef void (CALLBACK* _USBasync)(u32 cycles);
+typedef s32(CALLBACK *_USBopen)(void *pDsp);
+typedef u8(CALLBACK *_USBread8)(u32 mem);
+typedef u16(CALLBACK *_USBread16)(u32 mem);
+typedef u32(CALLBACK *_USBread32)(u32 mem);
+typedef void(CALLBACK *_USBwrite8)(u32 mem, u8 value);
+typedef void(CALLBACK *_USBwrite16)(u32 mem, u16 value);
+typedef void(CALLBACK *_USBwrite32)(u32 mem, u32 value);
+typedef void(CALLBACK *_USBasync)(u32 cycles);
-typedef void (CALLBACK* _USBirqCallback)(USBcallback callback);
-typedef USBhandler (CALLBACK* _USBirqHandler)(void);
-typedef void (CALLBACK* _USBsetRAM)(void *mem);
+typedef void(CALLBACK *_USBirqCallback)(USBcallback callback);
+typedef USBhandler(CALLBACK *_USBirqHandler)(void);
+typedef void(CALLBACK *_USBsetRAM)(void *mem);
//FW
-typedef s32 (CALLBACK* _FWopen)(void *pDsp);
-typedef u32 (CALLBACK* _FWread32)(u32 mem);
-typedef void (CALLBACK* _FWwrite32)(u32 mem, u32 value);
-typedef void (CALLBACK* _FWirqCallback)(void (*callback)());
+typedef s32(CALLBACK *_FWopen)(void *pDsp);
+typedef u32(CALLBACK *_FWread32)(u32 mem);
+typedef void(CALLBACK *_FWwrite32)(u32 mem, u32 value);
+typedef void(CALLBACK *_FWirqCallback)(void (*callback)());
#endif
#ifdef PLUGINfuncs
// GS
#ifndef BUILTIN_GS_PLUGIN
-extern _GSopen GSopen;
-extern _GSopen2 GSopen2;
-extern _GSvsync GSvsync;
-extern _GSgifTransfer GSgifTransfer;
-extern _GSgifTransfer1 GSgifTransfer1;
-extern _GSgifTransfer2 GSgifTransfer2;
-extern _GSgifTransfer3 GSgifTransfer3;
-extern _GSgifSoftReset GSgifSoftReset;
-extern _GSreadFIFO GSreadFIFO;
-extern _GSinitReadFIFO GSinitReadFIFO;
-extern _GSreadFIFO2 GSreadFIFO2;
-extern _GSinitReadFIFO2 GSinitReadFIFO2;
+extern _GSopen GSopen;
+extern _GSopen2 GSopen2;
+extern _GSvsync GSvsync;
+extern _GSgifTransfer GSgifTransfer;
+extern _GSgifTransfer1 GSgifTransfer1;
+extern _GSgifTransfer2 GSgifTransfer2;
+extern _GSgifTransfer3 GSgifTransfer3;
+extern _GSgifSoftReset GSgifSoftReset;
+extern _GSreadFIFO GSreadFIFO;
+extern _GSinitReadFIFO GSinitReadFIFO;
+extern _GSreadFIFO2 GSreadFIFO2;
+extern _GSinitReadFIFO2 GSinitReadFIFO2;
extern _GSchangeSaveState GSchangeSaveState;
-extern _GSgetTitleInfo2 GSgetTitleInfo2;
-extern _GSmakeSnapshot GSmakeSnapshot;
-extern _GSmakeSnapshot2 GSmakeSnapshot2;
-extern _GSirqCallback GSirqCallback;
-extern _GSprintf GSprintf;
-extern _GSsetBaseMem GSsetBaseMem;
-extern _GSsetGameCRC GSsetGameCRC;
-extern _GSsetFrameSkip GSsetFrameSkip;
-extern _GSsetFrameLimit GSsetFrameLimit;
-extern _GSsetVsync GSsetVsync;
-extern _GSsetupRecording GSsetupRecording;
-extern _GSreset GSreset;
-extern _GSwriteCSR GSwriteCSR;
+extern _GSgetTitleInfo2 GSgetTitleInfo2;
+extern _GSmakeSnapshot GSmakeSnapshot;
+extern _GSmakeSnapshot2 GSmakeSnapshot2;
+extern _GSirqCallback GSirqCallback;
+extern _GSprintf GSprintf;
+extern _GSsetBaseMem GSsetBaseMem;
+extern _GSsetGameCRC GSsetGameCRC;
+extern _GSsetFrameSkip GSsetFrameSkip;
+extern _GSsetFrameLimit GSsetFrameLimit;
+extern _GSsetVsync GSsetVsync;
+extern _GSsetupRecording GSsetupRecording;
+extern _GSreset GSreset;
+extern _GSwriteCSR GSwriteCSR;
#endif
// PAD
#ifndef BUILTIN_PAD_PLUGIN
-extern _PADopen PADopen;
-extern _PADstartPoll PADstartPoll;
-extern _PADpoll PADpoll;
-extern _PADquery PADquery;
-extern _PADupdate PADupdate;
-extern _PADkeyEvent PADkeyEvent;
-extern _PADgsDriverInfo PADgsDriverInfo;
-extern _PADsetSlot PADsetSlot;
-extern _PADqueryMtap PADqueryMtap;
-extern _PADWriteEvent PADWriteEvent;
+extern _PADopen PADopen;
+extern _PADstartPoll PADstartPoll;
+extern _PADpoll PADpoll;
+extern _PADquery PADquery;
+extern _PADupdate PADupdate;
+extern _PADkeyEvent PADkeyEvent;
+extern _PADgsDriverInfo PADgsDriverInfo;
+extern _PADsetSlot PADsetSlot;
+extern _PADqueryMtap PADqueryMtap;
+extern _PADWriteEvent PADWriteEvent;
#endif
// SPU2
#ifndef BUILTIN_SPU2_PLUGIN
-extern _SPU2open SPU2open;
-extern _SPU2reset SPU2reset;
-extern _SPU2write SPU2write;
-extern _SPU2read SPU2read;
+extern _SPU2open SPU2open;
+extern _SPU2reset SPU2reset;
+extern _SPU2write SPU2write;
+extern _SPU2read SPU2read;
#ifdef ENABLE_NEW_IOPDMA_SPU2
-extern _SPU2dmaRead SPU2dmaRead;
-extern _SPU2dmaWrite SPU2dmaWrite;
-extern _SPU2dmaInterrupt SPU2dmaInterrupt;
+extern _SPU2dmaRead SPU2dmaRead;
+extern _SPU2dmaWrite SPU2dmaWrite;
+extern _SPU2dmaInterrupt SPU2dmaInterrupt;
#else
-extern _SPU2readDMA4Mem SPU2readDMA4Mem;
-extern _SPU2writeDMA4Mem SPU2writeDMA4Mem;
+extern _SPU2readDMA4Mem SPU2readDMA4Mem;
+extern _SPU2writeDMA4Mem SPU2writeDMA4Mem;
extern _SPU2interruptDMA4 SPU2interruptDMA4;
-extern _SPU2readDMA7Mem SPU2readDMA7Mem;
-extern _SPU2writeDMA7Mem SPU2writeDMA7Mem;
+extern _SPU2readDMA7Mem SPU2readDMA7Mem;
+extern _SPU2writeDMA7Mem SPU2writeDMA7Mem;
extern _SPU2setDMABaseAddr SPU2setDMABaseAddr;
extern _SPU2interruptDMA7 SPU2interruptDMA7;
-extern _SPU2ReadMemAddr SPU2ReadMemAddr;
+extern _SPU2ReadMemAddr SPU2ReadMemAddr;
extern _SPU2setupRecording SPU2setupRecording;
-extern _SPU2WriteMemAddr SPU2WriteMemAddr;
-extern _SPU2irqCallback SPU2irqCallback;
+extern _SPU2WriteMemAddr SPU2WriteMemAddr;
+extern _SPU2irqCallback SPU2irqCallback;
#endif
-extern _SPU2irqCallback SPU2irqCallback;
+extern _SPU2irqCallback SPU2irqCallback;
extern _SPU2setupRecording SPU2setupRecording;
-extern _SPU2setClockPtr SPU2setClockPtr;
+extern _SPU2setClockPtr SPU2setClockPtr;
extern _SPU2setTimeStretcher SPU2setTimeStretcher;
-extern _SPU2async SPU2async;
+extern _SPU2async SPU2async;
#endif
// DEV9
#ifndef BUILTIN_DEV9_PLUGIN
-extern _DEV9open DEV9open;
-extern _DEV9read8 DEV9read8;
-extern _DEV9read16 DEV9read16;
-extern _DEV9read32 DEV9read32;
-extern _DEV9write8 DEV9write8;
-extern _DEV9write16 DEV9write16;
-extern _DEV9write32 DEV9write32;
+extern _DEV9open DEV9open;
+extern _DEV9read8 DEV9read8;
+extern _DEV9read16 DEV9read16;
+extern _DEV9read32 DEV9read32;
+extern _DEV9write8 DEV9write8;
+extern _DEV9write16 DEV9write16;
+extern _DEV9write32 DEV9write32;
#ifdef ENABLE_NEW_IOPDMA_DEV9
-extern _DEV9dmaRead DEV9dmaRead;
-extern _DEV9dmaWrite DEV9dmaWrite;
-extern _DEV9dmaInterrupt DEV9dmaInterrupt;
+extern _DEV9dmaRead DEV9dmaRead;
+extern _DEV9dmaWrite DEV9dmaWrite;
+extern _DEV9dmaInterrupt DEV9dmaInterrupt;
#else
-extern _DEV9readDMA8Mem DEV9readDMA8Mem;
-extern _DEV9writeDMA8Mem DEV9writeDMA8Mem;
+extern _DEV9readDMA8Mem DEV9readDMA8Mem;
+extern _DEV9writeDMA8Mem DEV9writeDMA8Mem;
#endif
-extern _DEV9irqCallback DEV9irqCallback;
-extern _DEV9irqHandler DEV9irqHandler;
-extern _DEV9async DEV9async;
+extern _DEV9irqCallback DEV9irqCallback;
+extern _DEV9irqHandler DEV9irqHandler;
+extern _DEV9async DEV9async;
#endif
// USB
#ifndef BUILTIN_USB_PLUGIN
-extern _USBopen USBopen;
-extern _USBread8 USBread8;
-extern _USBread16 USBread16;
-extern _USBread32 USBread32;
-extern _USBwrite8 USBwrite8;
-extern _USBwrite16 USBwrite16;
-extern _USBwrite32 USBwrite32;
-extern _USBasync USBasync;
+extern _USBopen USBopen;
+extern _USBread8 USBread8;
+extern _USBread16 USBread16;
+extern _USBread32 USBread32;
+extern _USBwrite8 USBwrite8;
+extern _USBwrite16 USBwrite16;
+extern _USBwrite32 USBwrite32;
+extern _USBasync USBasync;
-extern _USBirqCallback USBirqCallback;
-extern _USBirqHandler USBirqHandler;
-extern _USBsetRAM USBsetRAM;
+extern _USBirqCallback USBirqCallback;
+extern _USBirqHandler USBirqHandler;
+extern _USBsetRAM USBsetRAM;
#endif
// FW
#ifndef BUILTIN_FW_PLUGIN
-extern _FWopen FWopen;
-extern _FWread32 FWread32;
-extern _FWwrite32 FWwrite32;
-extern _FWirqCallback FWirqCallback;
+extern _FWopen FWopen;
+extern _FWread32 FWread32;
+extern _FWwrite32 FWwrite32;
+extern _FWirqCallback FWirqCallback;
#endif
#endif
#ifdef __cplusplus
-} // End extern "C"
+} // End extern "C"
#endif
#endif /* __PS2EDEFS_H__ */
diff --git a/common/include/PS2Eext.h b/common/include/PS2Eext.h
index 2c0412517e..ec378bf261 100644
--- a/common/include/PS2Eext.h
+++ b/common/include/PS2Eext.h
@@ -55,8 +55,7 @@ static void __forceinline PluginNullConfigure(std::wstring desc, s32 &log);
static void __forceinline PluginNullAbout(const wchar_t *aboutText);
#endif
-enum FileMode
-{
+enum FileMode {
READ_FILE = 0,
WRITE_FILE
};
@@ -70,9 +69,8 @@ struct PluginLog
{
LogFile = fopen(logname.c_str(), "w");
- if (LogFile)
- {
- setvbuf(LogFile, NULL, _IONBF, 0);
+ if (LogFile) {
+ setvbuf(LogFile, NULL, _IONBF, 0);
return true;
}
return false;
@@ -90,11 +88,14 @@ struct PluginLog
{
va_list list;
- if (LogFile == NULL) return;
+ if (LogFile == NULL)
+ return;
va_start(list, fmt);
- if (WriteToFile) vfprintf(LogFile, fmt, list);
- if (WriteToConsole) vfprintf(stdout, fmt, list);
+ if (WriteToFile)
+ vfprintf(LogFile, fmt, list);
+ if (WriteToConsole)
+ vfprintf(stdout, fmt, list);
va_end(list);
}
@@ -102,15 +103,20 @@ struct PluginLog
{
va_list list;
- if (LogFile == NULL) return;
+ if (LogFile == NULL)
+ return;
va_start(list, fmt);
- if (WriteToFile) vfprintf(LogFile, fmt, list);
- if (WriteToConsole) vfprintf(stdout, fmt, list);
+ if (WriteToFile)
+ vfprintf(LogFile, fmt, list);
+ if (WriteToConsole)
+ vfprintf(stdout, fmt, list);
va_end(list);
- if (WriteToFile) fprintf(LogFile, "\n");
- if (WriteToConsole) fprintf(stdout, "\n");
+ if (WriteToFile)
+ fprintf(LogFile, "\n");
+ if (WriteToConsole)
+ fprintf(stdout, "\n");
}
#if !defined(_MSC_VER) || !defined(UNICODE)
@@ -119,7 +125,8 @@ struct PluginLog
va_list list;
char buf[256];
- if (LogFile == NULL) return;
+ if (LogFile == NULL)
+ return;
va_start(list, fmt);
vsprintf(buf, fmt, list);
@@ -128,19 +135,20 @@ struct PluginLog
SysMessage(buf);
}
#else
- void Message(const wchar_t *fmt, ...)
- {
- va_list list;
- wchar_t buf[256];
+ void Message(const wchar_t *fmt, ...)
+ {
+ va_list list;
+ wchar_t buf[256];
- if (LogFile == NULL) return;
+ if (LogFile == NULL)
+ return;
- va_start(list, fmt);
- vswprintf(buf, 256, fmt, list);
- va_end(list);
+ va_start(list, fmt);
+ vswprintf(buf, 256, fmt, list);
+ va_end(list);
- SysMessage(buf);
- }
+ SysMessage(buf);
+ }
#endif
};
@@ -151,16 +159,14 @@ struct PluginConf
bool Open(std::string name, FileMode mode = READ_FILE)
{
- if (mode == READ_FILE)
- {
+ if (mode == READ_FILE) {
ConfFile = fopen(name.c_str(), "r");
- }
- else
- {
+ } else {
ConfFile = fopen(name.c_str(), "w");
}
- if (ConfFile == NULL) return false;
+ if (ConfFile == NULL)
+ return false;
return true;
}
@@ -173,14 +179,14 @@ struct PluginConf
}
}
- int ReadInt(const std::string& item, int defval)
+ int ReadInt(const std::string &item, int defval)
{
int value = defval;
std::string buf = item + " = %d\n";
if (ConfFile)
- if (fscanf(ConfFile, buf.c_str(), &value) < 0)
- fprintf(stderr, "Error reading %s\n", item.c_str());
+ if (fscanf(ConfFile, buf.c_str(), &value) < 0)
+ fprintf(stderr, "Error reading %s\n", item.c_str());
return value;
}
@@ -189,7 +195,8 @@ struct PluginConf
{
std::string buf = item + " = %d\n";
- if (ConfFile) fprintf(ConfFile, buf.c_str(), value);
+ if (ConfFile)
+ fprintf(ConfFile, buf.c_str(), value);
}
};
@@ -204,19 +211,20 @@ static void SysMessage(const char *fmt, ...)
vsprintf(msg, fmt, list);
va_end(list);
- if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
+ if (msg[strlen(msg) - 1] == '\n')
+ msg[strlen(msg) - 1] = 0;
GtkWidget *dialog;
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_OK,
- "%s", msg);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ "%s", msg);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
-static void __forceinline set_logging(GtkToggleButton *check, int& log)
+static void __forceinline set_logging(GtkToggleButton *check, int &log)
{
log = gtk_toggle_button_get_active(check);
}
@@ -227,7 +235,7 @@ static void __forceinline PluginNullConfigure(std::string desc, int &log)
/* Create the widgets */
dialog = gtk_dialog_new();
- label = gtk_label_new (desc.c_str());
+ label = gtk_label_new(desc.c_str());
check_box = gtk_check_button_new_with_label("Logging");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box), (log != 0));
@@ -236,14 +244,14 @@ static void __forceinline PluginNullConfigure(std::string desc, int &log)
g_signal_connect(check_box, "toggled", G_CALLBACK(set_logging), &log);
/* Add all our widgets, and show everything we've added to the dialog. */
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area(GTK_DIALOG(dialog))), check_box);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), check_box);
gtk_dialog_add_button(GTK_DIALOG(dialog), "Ok", 0);
- gtk_widget_show_all (dialog);
+ gtk_widget_show_all(dialog);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
static void __forceinline PluginNullAbout(const char *aboutText)
@@ -265,7 +273,8 @@ static void SysMessage(const char *fmt, ...)
vsprintf(msg, fmt, list);
va_end(list);
- if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
+ if (msg[strlen(msg) - 1] == '\n')
+ msg[strlen(msg) - 1] = 0;
// TODO OSX can we use WX MessageBox here or should Cocoa MessageBox used?
}
@@ -297,7 +306,7 @@ static void __forceinline PluginNullAbout(const char *aboutText)
#else
-#define usleep(x) Sleep(x / 1000)
+#define usleep(x) Sleep(x / 1000)
#ifndef UNICODE
@@ -305,15 +314,15 @@ static void __forceinline SysMessage(const char *fmt, ...)
{
va_list list;
char tmp[512];
- va_start(list,fmt);
- vsprintf(tmp,fmt,list);
+ va_start(list, fmt);
+ vsprintf(tmp, fmt, list);
va_end(list);
- MessageBox( GetActiveWindow(), tmp, "Message", MB_SETFOREGROUND | MB_OK );
+ MessageBox(GetActiveWindow(), tmp, "Message", MB_SETFOREGROUND | MB_OK);
}
static void __forceinline PluginNullConfigure(std::string desc, s32 &log)
{
- /* To do: Write a dialog box that displays a dialog box with the text in desc,
+ /* To do: Write a dialog box that displays a dialog box with the text in desc,
and a check box that says "Logging", checked if log !=0, and set log to
1 if it is checked on return, and 0 if it isn't. */
SysMessage("This space is intentionally left blank.");
@@ -327,39 +336,39 @@ static void __forceinline PluginNullAbout(const char *aboutText)
static void __forceinline SysMessage(const wchar_t *fmt, ...)
{
- va_list list;
- wchar_t tmp[512];
- va_start(list, fmt);
- vswprintf(tmp, 512, fmt, list);
- va_end(list);
- MessageBox(GetActiveWindow(), tmp, L"Message", MB_SETFOREGROUND | MB_OK);
+ va_list list;
+ wchar_t tmp[512];
+ va_start(list, fmt);
+ vswprintf(tmp, 512, fmt, list);
+ va_end(list);
+ MessageBox(GetActiveWindow(), tmp, L"Message", MB_SETFOREGROUND | MB_OK);
}
static void __forceinline PluginNullConfigure(std::string desc, s32 &log)
{
- /* To do: Write a dialog box that displays a dialog box with the text in desc,
+ /* To do: Write a dialog box that displays a dialog box with the text in desc,
and a check box that says "Logging", checked if log !=0, and set log to
1 if it is checked on return, and 0 if it isn't. */
- SysMessage(L"This space is intentionally left blank.");
+ SysMessage(L"This space is intentionally left blank.");
}
static void __forceinline PluginNullAbout(const wchar_t *aboutText)
{
- SysMessage(aboutText);
+ SysMessage(aboutText);
}
#endif
-#define ENTRY_POINT \
-HINSTANCE hInst; \
-\
-BOOL APIENTRY DllMain(HANDLE hModule, /* DLL INIT*/ \
- DWORD dwReason, \
- LPVOID lpReserved) \
-{ \
- hInst = (HINSTANCE)hModule; \
- return TRUE; /* very quick :)*/ \
-}
+#define ENTRY_POINT \
+ HINSTANCE hInst; \
+ \
+ BOOL APIENTRY DllMain(HANDLE hModule, /* DLL INIT*/ \
+ DWORD dwReason, \
+ LPVOID lpReserved) \
+ { \
+ hInst = (HINSTANCE)hModule; \
+ return TRUE; /* very quick :)*/ \
+ }
#endif
#endif // PS2EEXT_H_INCLUDED
diff --git a/common/include/PS2Etypes.h b/common/include/PS2Etypes.h
index 930596a598..cc7f2ce49b 100644
--- a/common/include/PS2Etypes.h
+++ b/common/include/PS2Etypes.h
@@ -13,7 +13,7 @@
* If not, see .
*/
- // This file is just for backwards compatibility.
+// This file is just for backwards compatibility.
#ifndef __PS2ETYPES_H__
#define __PS2ETYPES_H__
diff --git a/common/include/Pcsx2Api.h b/common/include/Pcsx2Api.h
index 06b1240d3c..0e27865f67 100644
--- a/common/include/Pcsx2Api.h
+++ b/common/include/Pcsx2Api.h
@@ -35,64 +35,71 @@
#ifdef _MSC_VER
#define EXPORT_C(type) extern "C" type CALLBACK
#else
-#define EXPORT_C(type) extern "C" __attribute__((externally_visible,visibility("default"))) type
+#define EXPORT_C(type) extern "C" __attribute__((externally_visible, visibility("default"))) type
#endif
-EXPORT_C(u32) PS2EgetLibType(void);
-EXPORT_C(u32) PS2EgetLibVersion2(u32 type);
-EXPORT_C(char*) PS2EgetLibName(void);
+EXPORT_C(u32)
+PS2EgetLibType(void);
+EXPORT_C(u32)
+PS2EgetLibVersion2(u32 type);
+EXPORT_C(char *)
+PS2EgetLibName(void);
// Extended functions.
// allows the plugin to see the whole configuration when started up.
// Intended for them to get the ini and plugin paths, but could allow for other things as well.
-EXPORT_C_(void) PS2EpassConfig(PcsxConfig Config);
+EXPORT_C_(void)
+PS2EpassConfig(PcsxConfig Config);
// Alternately, this function serves the same purpose, but would work for emulators outside
// of pcsx2.
-EXPORT_C_(void) PS2EpassIniPath(const char *path);
+EXPORT_C_(void)
+PS2EpassIniPath(const char *path);
// PS2EgetLibType returns (may be OR'd)
enum {
-PS2E_LT_GS = 0x01,
-PS2E_LT_PAD = 0x02, // -=[ OBSOLETE ]=-
-PS2E_LT_SPU2 = 0x04,
-PS2E_LT_CDVD = 0x08,
-PS2E_LT_DEV9 = 0x10,
-PS2E_LT_USB = 0x20,
-PS2E_LT_FW = 0x40,
-PS2E_LT_SIO = 0x80
+ PS2E_LT_GS = 0x01,
+ PS2E_LT_PAD = 0x02, // -=[ OBSOLETE ]=-
+ PS2E_LT_SPU2 = 0x04,
+ PS2E_LT_CDVD = 0x08,
+ PS2E_LT_DEV9 = 0x10,
+ PS2E_LT_USB = 0x20,
+ PS2E_LT_FW = 0x40,
+ PS2E_LT_SIO = 0x80
} PluginLibType;
// PS2EgetLibVersion2 (high 16 bits)
enum {
-PS2E_GS_VERSION = 0x0006,
-PS2E_PAD_VERSION = 0x0002, // -=[ OBSOLETE ]=-
-PS2E_SPU2_VERSION = 0x0005,
-PS2E_CDVD_VERSION = 0x0005,
-PS2E_DEV9_VERSION = 0x0003,
-PS2E_USB_VERSION = 0x0003,
-PS2E_FW_VERSION = 0x0002,
-PS2E_SIO_VERSION = 0x0001
+ PS2E_GS_VERSION = 0x0006,
+ PS2E_PAD_VERSION = 0x0002, // -=[ OBSOLETE ]=-
+ PS2E_SPU2_VERSION = 0x0005,
+ PS2E_CDVD_VERSION = 0x0005,
+ PS2E_DEV9_VERSION = 0x0003,
+ PS2E_USB_VERSION = 0x0003,
+ PS2E_FW_VERSION = 0x0002,
+ PS2E_SIO_VERSION = 0x0001
} PluginLibVersion;
// freeze modes:
enum {
-FREEZE_LOAD = 0,
-FREEZE_SAVE = 1,
-FREEZE_SIZE = 2
+ FREEZE_LOAD = 0,
+ FREEZE_SAVE = 1,
+ FREEZE_SIZE = 2
} FreezeModes;
-typedef struct _GSdriverInfo {
- char name[8];
- void *common;
+typedef struct _GSdriverInfo
+{
+ char name[8];
+ void *common;
} GSdriverInfo;
#ifdef _MSC_VER
-typedef struct _winInfo { // unsupported values must be set to zero
- HWND hWnd;
- HMENU hMenu;
- HWND hStatusWnd;
+typedef struct _winInfo
+{ // unsupported values must be set to zero
+ HWND hWnd;
+ HMENU hMenu;
+ HWND hStatusWnd;
} winInfo;
#endif
diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h
index 6f4bd4ec5a..dd3ea4fcfe 100644
--- a/common/include/Pcsx2Defs.h
+++ b/common/include/Pcsx2Defs.h
@@ -26,9 +26,9 @@
// make sure __POSIX__ is defined for all systems where we assume POSIX
// compliance
#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) || defined(__CYGWIN__) || defined(__LINUX__)
-# if !defined(__POSIX__)
-# define __POSIX__ 1
-# endif
+#if !defined(__POSIX__)
+#define __POSIX__ 1
+#endif
#endif
#include "Pcsx2Types.h"
@@ -39,7 +39,7 @@
// Notes: I'd have used ARRAY_SIZE instead but ran into cross-platform lib conflicts with
// that as well. >_<
#ifndef ArraySize
-# define ArraySize(x) (sizeof(x)/sizeof((x)[0]))
+#define ArraySize(x) (sizeof(x) / sizeof((x)[0]))
#endif
// --------------------------------------------------------------------------------------
@@ -51,51 +51,51 @@
// some tight loops it will likely make debug builds unusably slow.
//
#ifdef __cplusplus
-# ifdef PCSX2_DEVBUILD
- static const bool IsDevBuild = true;
-# else
- static const bool IsDevBuild = false;
-# endif
-
-# ifdef PCSX2_DEBUG
- static const bool IsDebugBuild = true;
-# else
- static const bool IsDebugBuild = false;
-# endif
-
+#ifdef PCSX2_DEVBUILD
+static const bool IsDevBuild = true;
#else
-
-# ifdef PCSX2_DEVBUILD
- static const u8 IsDevBuild = 1;
-# else
- static const u8 IsDevBuild = 0;
-# endif
-
-# ifdef PCSX2_DEBUG
- static const u8 IsDebugBuild = 1;
-# else
- static const u8 IsDebugBuild = 0;
-# endif
+static const bool IsDevBuild = false;
#endif
#ifdef PCSX2_DEBUG
-# define pxDebugCode(code) code
+static const bool IsDebugBuild = true;
#else
-# define pxDebugCode(code)
+static const bool IsDebugBuild = false;
+#endif
+
+#else
+
+#ifdef PCSX2_DEVBUILD
+static const u8 IsDevBuild = 1;
+#else
+static const u8 IsDevBuild = 0;
+#endif
+
+#ifdef PCSX2_DEBUG
+static const u8 IsDebugBuild = 1;
+#else
+static const u8 IsDebugBuild = 0;
+#endif
+#endif
+
+#ifdef PCSX2_DEBUG
+#define pxDebugCode(code) code
+#else
+#define pxDebugCode(code)
#endif
#ifdef PCSX2_DEVBUILD
-# define pxDevelCode(code) code
+#define pxDevelCode(code) code
#else
-# define pxDevelCode(code)
+#define pxDevelCode(code)
#endif
#if defined(PCSX2_DEBUG) || defined(PCSX2_DEVBUILD)
-# define pxReleaseCode(code)
-# define pxNonReleaseCode(code) code
+#define pxReleaseCode(code)
+#define pxNonReleaseCode(code) code
#else
-# define pxReleaseCode(code) code
-# define pxNonReleaseCode(code)
+#define pxReleaseCode(code) code
+#define pxNonReleaseCode(code)
#endif
// --------------------------------------------------------------------------------------
@@ -116,8 +116,8 @@
// Defines the memory page size for the target platform at compilation. All supported platforms
// (which means Intel only right now) have a 4k granularity.
-#define PCSX2_PAGESIZE 0x1000
-static const int __pagesize = PCSX2_PAGESIZE;
+#define PCSX2_PAGESIZE 0x1000
+static const int __pagesize = PCSX2_PAGESIZE;
// --------------------------------------------------------------------------------------
// Structure Packing (__packed)
@@ -154,27 +154,27 @@ static const int __pagesize = PCSX2_PAGESIZE;
// This is the 2005/earlier compatible packing define, which must be used in conjunction
// with #ifdef _MSC_VER/#pragma pack() directives (ugly).
-# define __packed
+#define __packed
-# define __aligned(alig) __declspec(align(alig))
-# define __aligned16 __declspec(align(16))
-# define __aligned32 __declspec(align(32))
-# define __pagealigned __declspec(align(PCSX2_PAGESIZE))
+#define __aligned(alig) __declspec(align(alig))
+#define __aligned16 __declspec(align(16))
+#define __aligned32 __declspec(align(32))
+#define __pagealigned __declspec(align(PCSX2_PAGESIZE))
- // Deprecated; use __align instead.
-# define PCSX2_ALIGNED(alig,x) __declspec(align(alig)) x
-# define PCSX2_ALIGNED_EXTERN(alig,x) extern __declspec(align(alig)) x
-# define PCSX2_ALIGNED16(x) __declspec(align(16)) x
-# define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x
+// Deprecated; use __align instead.
+#define PCSX2_ALIGNED(alig, x) __declspec(align(alig)) x
+#define PCSX2_ALIGNED_EXTERN(alig, x) extern __declspec(align(alig)) x
+#define PCSX2_ALIGNED16(x) __declspec(align(16)) x
+#define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x
-# define __noinline __declspec(noinline)
-# define __threadlocal __declspec(thread)
+#define __noinline __declspec(noinline)
+#define __threadlocal __declspec(thread)
// Don't know if there are Visual C++ equivalents of these.
-# define likely(x) (!!(x))
-# define unlikely(x) (!!(x))
+#define likely(x) (!!(x))
+#define unlikely(x) (!!(x))
-# define CALLBACK __stdcall
+#define CALLBACK __stdcall
#else
@@ -183,42 +183,42 @@ static const int __pagesize = PCSX2_PAGESIZE;
// --------------------------------------------------------------------------------------
#ifndef __packed
-# define __packed __attribute__((packed))
+#define __packed __attribute__((packed))
#endif
#ifndef __aligned
-# define __aligned(alig) __attribute__((aligned(alig)))
+#define __aligned(alig) __attribute__((aligned(alig)))
#endif
-# define __aligned16 __attribute__((aligned(16)))
-# define __aligned32 __attribute__((aligned(32)))
-# define __pagealigned __attribute__((aligned(PCSX2_PAGESIZE)))
- // Deprecated; use __align instead.
-# define PCSX2_ALIGNED(alig,x) x __attribute((aligned(alig)))
-# define PCSX2_ALIGNED16(x) x __attribute((aligned(16)))
-# define PCSX2_ALIGNED_EXTERN(alig,x) extern x __attribute((aligned(alig)))
-# define PCSX2_ALIGNED16_EXTERN(x) extern x __attribute((aligned(16)))
+#define __aligned16 __attribute__((aligned(16)))
+#define __aligned32 __attribute__((aligned(32)))
+#define __pagealigned __attribute__((aligned(PCSX2_PAGESIZE)))
+// Deprecated; use __align instead.
+#define PCSX2_ALIGNED(alig, x) x __attribute((aligned(alig)))
+#define PCSX2_ALIGNED16(x) x __attribute((aligned(16)))
+#define PCSX2_ALIGNED_EXTERN(alig, x) extern x __attribute((aligned(alig)))
+#define PCSX2_ALIGNED16_EXTERN(x) extern x __attribute((aligned(16)))
-# define __assume(cond) ((void)0) // GCC has no equivalent for __assume
-# define CALLBACK __attribute__((stdcall))
+#define __assume(cond) ((void)0) // GCC has no equivalent for __assume
+#define CALLBACK __attribute__((stdcall))
// Inlining note: GCC needs ((unused)) attributes defined on inlined functions to suppress
// warnings when a static inlined function isn't used in the scope of a single file (which
// happens *by design* like all the friggen time >_<)
#ifndef __fastcall
-# define __fastcall __attribute__((fastcall))
+#define __fastcall __attribute__((fastcall))
+#endif
+#define _inline __inline__ __attribute__((unused))
+#ifdef NDEBUG
+#define __forceinline __attribute__((always_inline, unused))
+#else
+#define __forceinline __attribute__((unused))
#endif
-# define _inline __inline__ __attribute__((unused))
-# ifdef NDEBUG
-# define __forceinline __attribute__((always_inline,unused))
-# else
-# define __forceinline __attribute__((unused))
-# endif
#ifndef __noinline
-# define __noinline __attribute__((noinline))
+#define __noinline __attribute__((noinline))
#endif
-# define __threadlocal __thread
-# define likely(x) __builtin_expect(!!(x), 1)
-# define unlikely(x) __builtin_expect(!!(x), 0)
+#define __threadlocal __thread
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
// --------------------------------------------------------------------------------------
@@ -233,13 +233,13 @@ static const int __pagesize = PCSX2_PAGESIZE;
// environment.
//
#ifdef PCSX2_DEVBUILD
-# define __releaseinline
+#define __releaseinline
#else
-# define __releaseinline __forceinline
+#define __releaseinline __forceinline
#endif
-#define __ri __releaseinline
-#define __fi __forceinline
-#define __fc __fastcall
+#define __ri __releaseinline
+#define __fi __forceinline
+#define __fc __fastcall
#endif
diff --git a/common/include/Pcsx2Types.h b/common/include/Pcsx2Types.h
index e6ab7c57d0..aba0f212f2 100644
--- a/common/include/Pcsx2Types.h
+++ b/common/include/Pcsx2Types.h
@@ -24,9 +24,9 @@
// depend on these types will not be usable (they will yield linker errors).
#ifdef __cplusplus
- class wxString;
- class FastFormatAscii;
- class FastFormatUnicode;
+class wxString;
+class FastFormatAscii;
+class FastFormatUnicode;
#endif
@@ -65,116 +65,116 @@ typedef unsigned int uint;
#ifdef __cplusplus
union u128
{
- struct
- {
- u64 lo;
- u64 hi;
- };
+ struct
+ {
+ u64 lo;
+ u64 hi;
+ };
- u64 _u64[2];
- u32 _u32[4];
- u16 _u16[8];
- u8 _u8[16];
+ u64 _u64[2];
+ u32 _u32[4];
+ u16 _u16[8];
+ u8 _u8[16];
- // Explicit conversion from u64. Zero-extends the source through 128 bits.
- static u128 From64( u64 src )
- {
- u128 retval;
- retval.lo = src;
- retval.hi = 0;
- return retval;
- }
+ // Explicit conversion from u64. Zero-extends the source through 128 bits.
+ static u128 From64(u64 src)
+ {
+ u128 retval;
+ retval.lo = src;
+ retval.hi = 0;
+ return retval;
+ }
- // Explicit conversion from u32. Zero-extends the source through 128 bits.
- static u128 From32( u32 src )
- {
- u128 retval;
- retval._u32[0] = src;
- retval._u32[1] = 0;
- retval.hi = 0;
- return retval;
- }
+ // Explicit conversion from u32. Zero-extends the source through 128 bits.
+ static u128 From32(u32 src)
+ {
+ u128 retval;
+ retval._u32[0] = src;
+ retval._u32[1] = 0;
+ retval.hi = 0;
+ return retval;
+ }
- operator u32() const { return _u32[0]; }
- operator u16() const { return _u16[0]; }
- operator u8() const { return _u8[0]; }
-
- bool operator==( const u128& right ) const
- {
- return (lo == right.lo) && (hi == right.hi);
- }
+ operator u32() const { return _u32[0]; }
+ operator u16() const { return _u16[0]; }
+ operator u8() const { return _u8[0]; }
- bool operator!=( const u128& right ) const
- {
- return (lo != right.lo) || (hi != right.hi);
- }
+ bool operator==(const u128 &right) const
+ {
+ return (lo == right.lo) && (hi == right.hi);
+ }
- // In order for the following ToString() and WriteTo methods to be available, you must
- // be linking to both wxWidgets and the pxWidgets extension library. If you are not
- // using them, then you will need to provide your own implementations of these methods.
- wxString ToString() const;
- wxString ToString64() const;
- wxString ToString8() const;
-
- void WriteTo( FastFormatAscii& dest ) const;
- void WriteTo8( FastFormatAscii& dest ) const;
- void WriteTo64( FastFormatAscii& dest ) const;
+ bool operator!=(const u128 &right) const
+ {
+ return (lo != right.lo) || (hi != right.hi);
+ }
+
+ // In order for the following ToString() and WriteTo methods to be available, you must
+ // be linking to both wxWidgets and the pxWidgets extension library. If you are not
+ // using them, then you will need to provide your own implementations of these methods.
+ wxString ToString() const;
+ wxString ToString64() const;
+ wxString ToString8() const;
+
+ void WriteTo(FastFormatAscii &dest) const;
+ void WriteTo8(FastFormatAscii &dest) const;
+ void WriteTo64(FastFormatAscii &dest) const;
};
struct s128
{
- s64 lo;
- s64 hi;
+ s64 lo;
+ s64 hi;
- // explicit conversion from s64, with sign extension.
- static s128 From64( s64 src )
- {
- s128 retval = { src, (src < 0) ? -1 : 0 };
- return retval;
- }
+ // explicit conversion from s64, with sign extension.
+ static s128 From64(s64 src)
+ {
+ s128 retval = {src, (src < 0) ? -1 : 0};
+ return retval;
+ }
- // explicit conversion from s32, with sign extension.
- static s128 From64( s32 src )
- {
- s128 retval = { src, (src < 0) ? -1 : 0 };
- return retval;
- }
+ // explicit conversion from s32, with sign extension.
+ static s128 From64(s32 src)
+ {
+ s128 retval = {src, (src < 0) ? -1 : 0};
+ return retval;
+ }
- operator u32() const { return (s32)lo; }
- operator u16() const { return (s16)lo; }
- operator u8() const { return (s8)lo; }
+ operator u32() const { return (s32)lo; }
+ operator u16() const { return (s16)lo; }
+ operator u8() const { return (s8)lo; }
- bool operator==( const s128& right ) const
- {
- return (lo == right.lo) && (hi == right.hi);
- }
+ bool operator==(const s128 &right) const
+ {
+ return (lo == right.lo) && (hi == right.hi);
+ }
- bool operator!=( const s128& right ) const
- {
- return (lo != right.lo) || (hi != right.hi);
- }
+ bool operator!=(const s128 &right) const
+ {
+ return (lo != right.lo) || (hi != right.hi);
+ }
};
#else
typedef union _u128_t
{
- struct
- {
- u64 lo;
- u64 hi;
- };
+ struct
+ {
+ u64 lo;
+ u64 hi;
+ };
- u64 _u64[2];
- u32 _u32[4];
- u16 _u16[8];
- u8 _u8[16];
+ u64 _u64[2];
+ u32 _u32[4];
+ u16 _u16[8];
+ u8 _u8[16];
} u128;
typedef union _s128_t
{
- u64 lo;
- s64 hi;
+ u64 lo;
+ s64 hi;
} s128;
#endif
diff --git a/common/include/PluginCallbacks.h b/common/include/PluginCallbacks.h
index db4635d927..7717001bae 100644
--- a/common/include/PluginCallbacks.h
+++ b/common/include/PluginCallbacks.h
@@ -107,7 +107,7 @@
#ifndef BOOL
- typedef int BOOL;
+typedef int BOOL;
#endif
// --------------------------------------------------------------------------------------
@@ -122,15 +122,15 @@
// on its HWND define that could be useful, and well it's probably good practice to use
// platform available defines when they exist.
//
-#if defined( _WX_DEFS_H_ )
- typedef WXWidget PS2E_HWND;
-#elif defined( _WINDEF_ )
- // For Windows let's use HWND, since it has some type strictness applied to it.
- typedef HWND PS2E_HWND;
+#if defined(_WX_DEFS_H_)
+typedef WXWidget PS2E_HWND;
+#elif defined(_WINDEF_)
+// For Windows let's use HWND, since it has some type strictness applied to it.
+typedef HWND PS2E_HWND;
#else
- // Unsupported platform... use void* as a best guess. Should work fine for almost
- // any GUI platform, and certainly works for any currently supported one.
- typedef void* PS2E_HWND;
+// Unsupported platform... use void* as a best guess. Should work fine for almost
+// any GUI platform, and certainly works for any currently supported one.
+typedef void *PS2E_HWND;
#endif
// --------------------------------------------------------------------------------------
@@ -144,20 +144,20 @@
// pointer type.
//
#ifndef PS2E_THISPTR
-# define PS2E_THISPTR struct _PS2E_ComponentAPI*
+#define PS2E_THISPTR struct _PS2E_ComponentAPI *
#else
- // Ensure the user's defined PS2E_THISPTR retains the correct signature for our
- // plugin API.
- static_assert( sizeof(PS2E_THISPTR) == sizeof(void*), "Incorrect signature for PS2E_THISPTR" );
+// Ensure the user's defined PS2E_THISPTR retains the correct signature for our
+// plugin API.
+static_assert(sizeof(PS2E_THISPTR) == sizeof(void *), "Incorrect signature for PS2E_THISPTR");
#endif
// PS2E_LIB_THISPTR - (library scope version of PS2E_THISPTR)
#ifndef PS2E_LIB_THISPTR
-# define PS2E_LIB_THISPTR void*
+#define PS2E_LIB_THISPTR void *
#else
- // Ensure the user's defined PS2E_THISPTR retains the correct signature for our
- // plugin API.
- static_assert( sizeof(PS2E_LIB_THISPTR) == sizeof(void*), "Incorrect signature for PS2E_LIB_THISPTR" );
+// Ensure the user's defined PS2E_THISPTR retains the correct signature for our
+// plugin API.
+static_assert(sizeof(PS2E_LIB_THISPTR) == sizeof(void *), "Incorrect signature for PS2E_LIB_THISPTR");
#endif
// Use fastcall by default, since under most circumstances the object-model approach of the
@@ -174,58 +174,54 @@ extern "C" {
// Plugin Type / Version Enumerations
// ------------------------------------------------------------------------------------
-enum PS2E_ComponentTypes
-{
- PS2E_TYPE_GS = 0,
- PS2E_TYPE_PAD,
- PS2E_TYPE_SPU2,
- PS2E_TYPE_CDVD,
- PS2E_TYPE_DEV9,
- PS2E_TYPE_USB,
- PS2E_TYPE_FW,
- PS2E_TYPE_SIO,
- PS2E_TYPE_Mcd,
+enum PS2E_ComponentTypes {
+ PS2E_TYPE_GS = 0,
+ PS2E_TYPE_PAD,
+ PS2E_TYPE_SPU2,
+ PS2E_TYPE_CDVD,
+ PS2E_TYPE_DEV9,
+ PS2E_TYPE_USB,
+ PS2E_TYPE_FW,
+ PS2E_TYPE_SIO,
+ PS2E_TYPE_Mcd,
};
-enum PluginLibVersion
-{
- PS2E_VER_GS = 0x1000,
- PS2E_VER_PAD = 0x1000,
- PS2E_VER_SPU2 = 0x1000,
- PS2E_VER_CDVD = 0x1000,
- PS2E_VER_DEV9 = 0x1000,
- PS2E_VER_USB = 0x1000,
- PS2E_VER_FW = 0x1000,
- PS2E_VER_SIO = 0x1000
+enum PluginLibVersion {
+ PS2E_VER_GS = 0x1000,
+ PS2E_VER_PAD = 0x1000,
+ PS2E_VER_SPU2 = 0x1000,
+ PS2E_VER_CDVD = 0x1000,
+ PS2E_VER_DEV9 = 0x1000,
+ PS2E_VER_USB = 0x1000,
+ PS2E_VER_FW = 0x1000,
+ PS2E_VER_SIO = 0x1000
};
-enum OSDIconTypes
-{
- OSD_Icon_None = 0,
- OSD_Icon_Error,
- OSD_Icon_Notice, // An exclamation point maybe?
+enum OSDIconTypes {
+ OSD_Icon_None = 0,
+ OSD_Icon_Error,
+ OSD_Icon_Notice, // An exclamation point maybe?
- // [TODO] -- dunno. What else?
+ // [TODO] -- dunno. What else?
- // Emulators implementing their own custom non-standard icon extensions should do so
- // somewhere after OSD_Icon_ReserveEnd. All values below this are reserved.
- // .
- // .
- // .
- OSD_Icon_ReserveEnd = 0x1000
+ // Emulators implementing their own custom non-standard icon extensions should do so
+ // somewhere after OSD_Icon_ReserveEnd. All values below this are reserved.
+ // .
+ // .
+ // .
+ OSD_Icon_ReserveEnd = 0x1000
};
-enum PS2E_MenuItemStyle
-{
- MenuType_Normal = 0,
- MenuType_Checked,
- MenuType_Radio,
- MenuType_Separator
+enum PS2E_MenuItemStyle {
+ MenuType_Normal = 0,
+ MenuType_Checked,
+ MenuType_Radio,
+ MenuType_Separator
};
-typedef void* PS2E_MenuHandle;
-typedef void* PS2E_MenuItemHandle;
-typedef void PS2E_CALLBACK PS2E_OnMenuItemClicked( PS2E_THISPTR* thisptr, void* userptr );
+typedef void *PS2E_MenuHandle;
+typedef void *PS2E_MenuItemHandle;
+typedef void PS2E_CALLBACK PS2E_OnMenuItemClicked(PS2E_THISPTR *thisptr, void *userptr);
// --------------------------------------------------------------------------------------
// PS2E_ConsoleWriterAPI
@@ -249,19 +245,19 @@ typedef void PS2E_CALLBACK PS2E_OnMenuItemClicked( PS2E_THISPTR* thisptr, void*
//
typedef struct _PS2E_ConsoleWriterAPI
{
- // Writes text to console; no newline is appended.
- void (PS2E_CALLBACK* Write)( const char* fmt, ... );
+ // Writes text to console; no newline is appended.
+ void(PS2E_CALLBACK *Write)(const char *fmt, ...);
- // Appends an automatic newline to the specified formatted output.
- void (PS2E_CALLBACK* WriteLn)( const char* fmt, ... );
+ // Appends an automatic newline to the specified formatted output.
+ void(PS2E_CALLBACK *WriteLn)(const char *fmt, ...);
- // This function always appends a newline.
- void (PS2E_CALLBACK* Error)( const char* fmt, ... );
+ // This function always appends a newline.
+ void(PS2E_CALLBACK *Error)(const char *fmt, ...);
- // This function always appends a newline.
- void (PS2E_CALLBACK* Warning)( const char* fmt, ... );
+ // This function always appends a newline.
+ void(PS2E_CALLBACK *Warning)(const char *fmt, ...);
- void* reserved[4];
+ void *reserved[4];
} PS2E_ConsoleWriterAPI;
@@ -278,19 +274,19 @@ typedef struct _PS2E_ConsoleWriterAPI
//
typedef struct _PS2E_ConsoleWriterWideAPI
{
- // Writes text to console; no newline is appended.
- void (PS2E_CALLBACK* Write)( const wchar_t* fmt, ... );
+ // Writes text to console; no newline is appended.
+ void(PS2E_CALLBACK *Write)(const wchar_t *fmt, ...);
- // Appends an automatic newline to the specified formatted output.
- void (PS2E_CALLBACK* WriteLn)( const wchar_t* fmt, ... );
+ // Appends an automatic newline to the specified formatted output.
+ void(PS2E_CALLBACK *WriteLn)(const wchar_t *fmt, ...);
- // This function always appends a newline.
- void (PS2E_CALLBACK* Error)( const wchar_t* fmt, ... );
+ // This function always appends a newline.
+ void(PS2E_CALLBACK *Error)(const wchar_t *fmt, ...);
- // This function always appends a newline.
- void (PS2E_CALLBACK* Warning)( const wchar_t* fmt, ... );
+ // This function always appends a newline.
+ void(PS2E_CALLBACK *Warning)(const wchar_t *fmt, ...);
- void* reserved[4];
+ void *reserved[4];
} PS2E_ConsoleWriterWideAPI;
@@ -305,9 +301,9 @@ typedef struct _PS2E_ConsoleWriterWideAPI
//
typedef struct _PS2E_Image
{
- u32 width;
- u32 height;
- u8* data; // RGBA data. top to bottom.
+ u32 width;
+ u32 height;
+ u8 *data; // RGBA data. top to bottom.
} PS2E_Image;
@@ -316,38 +312,38 @@ typedef struct _PS2E_Image
// --------------------------------------------------------------------------------------
typedef struct _PS2E_MenuItemInfo
{
- const char* LabelText;
- const char* HelpText;
+ const char *LabelText;
+ const char *HelpText;
- // Optional image displayed with the menu option. The emulator may not support
- // this option, or may choose to ignore or resize the image if the size parameters
- // are outside a valid threshold.
- const PS2E_Image* Image;
+ // Optional image displayed with the menu option. The emulator may not support
+ // this option, or may choose to ignore or resize the image if the size parameters
+ // are outside a valid threshold.
+ const PS2E_Image *Image;
- // Specifies the style of the menu, either Normal, Checked, Radio, or Separator.
- // This option is overridden if the SubMenu field is non-NULL (in such case the
- // menu assumes submenu mode).
- PS2E_MenuItemStyle Style;
+ // Specifies the style of the menu, either Normal, Checked, Radio, or Separator.
+ // This option is overridden if the SubMenu field is non-NULL (in such case the
+ // menu assumes submenu mode).
+ PS2E_MenuItemStyle Style;
- // Specifies the handle of a sub menu to bind to this menu. If NULL, the menu is
- // created normally. If non-NULL, the menu item will use sub-menu mode and will
- // ignore the Style field.
- PS2E_MenuHandle SubMenu;
+ // Specifies the handle of a sub menu to bind to this menu. If NULL, the menu is
+ // created normally. If non-NULL, the menu item will use sub-menu mode and will
+ // ignore the Style field.
+ PS2E_MenuHandle SubMenu;
- // Menu that this item is attached to. When this struct is passed into AddMenuItem,
- // the menu item will be automatically appended to the menu specified in this field
- // if the field is non-NULL (if the field is NULL, then no action is taken).
- PS2E_MenuHandle OwnerMenu;
+ // Menu that this item is attached to. When this struct is passed into AddMenuItem,
+ // the menu item will be automatically appended to the menu specified in this field
+ // if the field is non-NULL (if the field is NULL, then no action is taken).
+ PS2E_MenuHandle OwnerMenu;
- // When FALSE the menu item will appear grayed out to the user, and unselectable.
- BOOL Enabled;
+ // When FALSE the menu item will appear grayed out to the user, and unselectable.
+ BOOL Enabled;
- // Optional user data pointer (or typecast integer value)
- void* UserPtr;
+ // Optional user data pointer (or typecast integer value)
+ void *UserPtr;
- // Callback issued when the menu is clicked/activated. If NULL, the menu will be
- // disabled (grayed).
- PS2E_OnMenuItemClicked* OnClicked;
+ // Callback issued when the menu is clicked/activated. If NULL, the menu will be
+ // disabled (grayed).
+ PS2E_OnMenuItemClicked *OnClicked;
} PS2E_MenuItemInfo;
@@ -356,72 +352,75 @@ typedef struct _PS2E_MenuItemInfo
// --------------------------------------------------------------------------------------
typedef struct _PS2E_MenuItemAPI
{
- // Allocates a new MenuItem and returns its handle. The returned item can be added to any
- // menu.
- PS2E_MenuItemHandle (PS2E_CALLBACK* MenuItem_Create)( PS2E_THISPTR thisptr );
+ // Allocates a new MenuItem and returns its handle. The returned item can be added to any
+ // menu.
+ PS2E_MenuItemHandle(PS2E_CALLBACK *MenuItem_Create)(PS2E_THISPTR thisptr);
- // Deletes the menu item and frees allocated resources. The menu item will be removed from
- // whatever menu it is attached to. If the menu item has a SubMenu, the SubMenu is not
- // deleted.
- void (PS2E_CALLBACK* MenuItem_Delete)( PS2E_MenuItemHandle mitem );
+ // Deletes the menu item and frees allocated resources. The menu item will be removed from
+ // whatever menu it is attached to. If the menu item has a SubMenu, the SubMenu is not
+ // deleted.
+ void(PS2E_CALLBACK *MenuItem_Delete)(PS2E_MenuItemHandle mitem);
- // (Re-)Assigns all properties for a menu. Assignment generally takes effect immediately.
- void (PS2E_CALLBACK* MenuItem_SetEverything)( PS2E_MenuItemHandle mitem, const PS2E_MenuItemInfo* info );
+ // (Re-)Assigns all properties for a menu. Assignment generally takes effect immediately.
+ void(PS2E_CALLBACK *MenuItem_SetEverything)(PS2E_MenuItemHandle mitem, const PS2E_MenuItemInfo *info);
- // Sets the text label of a menu item.
- void (PS2E_CALLBACK* MenuItem_SetText)( PS2E_MenuItemHandle mitem, const char* text );
+ // Sets the text label of a menu item.
+ void(PS2E_CALLBACK *MenuItem_SetText)(PS2E_MenuItemHandle mitem, const char *text);
- // Assigns the help text for a menu item. This text is typically shown in a status
- // bar at the bottom of the current window. This value may be ignored if the emu
- // interface does not have a context for help text.
- void (PS2E_CALLBACK* MenuItem_SetHelpText)( PS2E_MenuItemHandle mitem, const char* helptxt );
+ // Assigns the help text for a menu item. This text is typically shown in a status
+ // bar at the bottom of the current window. This value may be ignored if the emu
+ // interface does not have a context for help text.
+ void(PS2E_CALLBACK *MenuItem_SetHelpText)(PS2E_MenuItemHandle mitem, const char *helptxt);
- // Gives the menu item an accompanying image (orientation of the image may depend
- // on the operating system platform).
- void (PS2E_CALLBACK* MenuItem_SetImage)( PS2E_MenuItemHandle mitem, const PS2E_Image* image );
+ // Gives the menu item an accompanying image (orientation of the image may depend
+ // on the operating system platform).
+ void(PS2E_CALLBACK *MenuItem_SetImage)(PS2E_MenuItemHandle mitem, const PS2E_Image *image);
- // Gives the menu item an accompanying image (orientation of the image may depend
- // on the operating system platform).
- //
- // Returns:
- // TRUE if the image was loaded successfully, or FALSE if the image was not found,
- // could not be opened, or the image data is invalid (not a PNG, or data corrupted).
- BOOL (PS2E_CALLBACK* MenuItem_SetImagePng_FromFile)( PS2E_MenuItemHandle mitem, const char* filename );
+ // Gives the menu item an accompanying image (orientation of the image may depend
+ // on the operating system platform).
+ //
+ // Returns:
+ // TRUE if the image was loaded successfully, or FALSE if the image was not found,
+ // could not be opened, or the image data is invalid (not a PNG, or data corrupted).
+ BOOL(PS2E_CALLBACK *MenuItem_SetImagePng_FromFile)
+ (PS2E_MenuItemHandle mitem, const char *filename);
- // Gives the menu item an accompanying image (orientation of the image may depend on
- // the operating system platform). Image is loaded from memory using a memory stream
- // reader. This method is useful for loading image data embedded into the dll.
- //
- // Returns:
- // TRUE if the image was loaded successfully, or FALSE if the image data is invalid
- // (not a PNG, or data corrupted).
- BOOL (PS2E_CALLBACK* MenuItem_SetImagePng_FromMemory)( PS2E_MenuItemHandle mitem, const u8* data );
+ // Gives the menu item an accompanying image (orientation of the image may depend on
+ // the operating system platform). Image is loaded from memory using a memory stream
+ // reader. This method is useful for loading image data embedded into the dll.
+ //
+ // Returns:
+ // TRUE if the image was loaded successfully, or FALSE if the image data is invalid
+ // (not a PNG, or data corrupted).
+ BOOL(PS2E_CALLBACK *MenuItem_SetImagePng_FromMemory)
+ (PS2E_MenuItemHandle mitem, const u8 *data);
- // Assigns the menu item's style.
- void (PS2E_CALLBACK* MenuItem_SetStyle)( PS2E_MenuItemHandle mitem, PS2E_MenuItemStyle style );
+ // Assigns the menu item's style.
+ void(PS2E_CALLBACK *MenuItem_SetStyle)(PS2E_MenuItemHandle mitem, PS2E_MenuItemStyle style);
- // Assigns a pointer value that the plugin can use to attach user-defined data to
- // specific menu items. The value can be any integer typecast if you don't actually
- // need more than an integers worth of data.
- void (PS2E_CALLBACK* MenuItem_SetUserData)( PS2E_MenuItemHandle mitem, void* dataptr );
+ // Assigns a pointer value that the plugin can use to attach user-defined data to
+ // specific menu items. The value can be any integer typecast if you don't actually
+ // need more than an integers worth of data.
+ void(PS2E_CALLBACK *MenuItem_SetUserData)(PS2E_MenuItemHandle mitem, void *dataptr);
- // Assigns a submenu to the menu item, causing it to open the sub menu in cascade
- // fashion. When a submenu is assigned, the Style attribute of the menu will be
- // ignored. Passing NULL into this function will clear the submenu and return the
- // menu item to whatever its current Style attribute is set to.
- void (PS2E_CALLBACK* MenuItem_SetSubMenu)( PS2E_MenuItemHandle mitem, PS2E_MenuHandle submenu );
+ // Assigns a submenu to the menu item, causing it to open the sub menu in cascade
+ // fashion. When a submenu is assigned, the Style attribute of the menu will be
+ // ignored. Passing NULL into this function will clear the submenu and return the
+ // menu item to whatever its current Style attribute is set to.
+ void(PS2E_CALLBACK *MenuItem_SetSubMenu)(PS2E_MenuItemHandle mitem, PS2E_MenuHandle submenu);
- // Assigns the callback function for this menu (important!). If passed NULL, the menu
- // item will be automatically disabled (grayed out) by the emulator.
- void (PS2E_CALLBACK* MenuItem_SetCallback)( PS2E_MenuItemHandle mitem, PS2E_OnMenuItemClicked* onClickedCallback );
+ // Assigns the callback function for this menu (important!). If passed NULL, the menu
+ // item will be automatically disabled (grayed out) by the emulator.
+ void(PS2E_CALLBACK *MenuItem_SetCallback)(PS2E_MenuItemHandle mitem, PS2E_OnMenuItemClicked *onClickedCallback);
- // Assigns the enabled status of a MenuItem. Use FALSE to gray out the menuitem option.
- void (PS2E_CALLBACK* MenuItem_Enable)( PS2E_MenuItemHandle mitem, BOOL enable );
+ // Assigns the enabled status of a MenuItem. Use FALSE to gray out the menuitem option.
+ void(PS2E_CALLBACK *MenuItem_Enable)(PS2E_MenuItemHandle mitem, BOOL enable);
- // Returns the current enable status of the specified menu item.
- BOOL (PS2E_CALLBACK* MenuItem_IsEnabled)( PS2E_MenuItemHandle mitem );
+ // Returns the current enable status of the specified menu item.
+ BOOL(PS2E_CALLBACK *MenuItem_IsEnabled)
+ (PS2E_MenuItemHandle mitem);
- void* reserved[4];
+ void *reserved[4];
} PS2E_MenuItemAPI;
@@ -434,15 +433,15 @@ typedef struct _PS2E_MenuItemAPI
//
typedef struct _PS2E_VersionInfo
{
- // Low/Mid/High versions combine to form a number in the format of: 2.3.1
- // ... where 2 is the high version, 3 mid, and 1 low.
- s16 VersionHigh;
- s16 VersionMid;
- s16 VersionLow;
+ // Low/Mid/High versions combine to form a number in the format of: 2.3.1
+ // ... where 2 is the high version, 3 mid, and 1 low.
+ s16 VersionHigh;
+ s16 VersionMid;
+ s16 VersionLow;
- // Revision typically refers a revision control system (such as SVN). When displayed
- // by the emulator it will have an 'r' prefixed before it.
- s64 Revision;
+ // Revision typically refers a revision control system (such as SVN). When displayed
+ // by the emulator it will have an 'r' prefixed before it.
+ s64 Revision;
} PS2E_VersionInfo;
@@ -454,19 +453,19 @@ typedef struct _PS2E_VersionInfo
//
typedef struct _PS2E_SessionInfo
{
- PS2E_HWND window;
+ PS2E_HWND window;
- u32* CycleEE; // current EE cycle count
- u32* CycleIOP; // current IOP cycle count
+ u32 *CycleEE; // current EE cycle count
+ u32 *CycleIOP; // current IOP cycle count
- u32 ElfCRC; // CRC of the ELF header for this app/game
+ u32 ElfCRC; // CRC of the ELF header for this app/game
- // Sony's assigned serial number, valid only for CD/CDVD games (ASCII-Z string).
- // Ex: SLUS-2932
- //
- // (if the running app is not a sony-registered game, the serial will be a zero
- // length string).
- char Serial[16];
+ // Sony's assigned serial number, valid only for CD/CDVD games (ASCII-Z string).
+ // Ex: SLUS-2932
+ //
+ // (if the running app is not a sony-registered game, the serial will be a zero
+ // length string).
+ char Serial[16];
} PS2E_SessionInfo;
@@ -490,134 +489,137 @@ typedef struct _PS2E_SessionInfo
//
typedef struct _PS2E_EmulatorInfo
{
- // Brief name of the emulator (ex: "PCSX2") [required]
- // Depending on the design of the emulator, this string may optionally include version
- // information, however that is not recommended since it can inhibit backward support.
- const char* EmuName;
+ // Brief name of the emulator (ex: "PCSX2") [required]
+ // Depending on the design of the emulator, this string may optionally include version
+ // information, however that is not recommended since it can inhibit backward support.
+ const char *EmuName;
- // Version information. All fields besides the emulator's name are optional.
- PS2E_VersionInfo EmuVersion;
+ // Version information. All fields besides the emulator's name are optional.
+ PS2E_VersionInfo EmuVersion;
- // Number of Physical Cores, as detected by the emulator.
- // This should always match the real # of cores supported by hardware.
- int PhysicalCores;
+ // Number of Physical Cores, as detected by the emulator.
+ // This should always match the real # of cores supported by hardware.
+ int PhysicalCores;
- // Number of Logical Cores, as detected and/or managed by the emulator.
- // This is not necessarily a reflection of real hardware capabilities. The emu reserves
- // the right to report this value as it deems appropriate, in management of threading
- // resources.
- int LogicalCores;
+ // Number of Logical Cores, as detected and/or managed by the emulator.
+ // This is not necessarily a reflection of real hardware capabilities. The emu reserves
+ // the right to report this value as it deems appropriate, in management of threading
+ // resources.
+ int LogicalCores;
- // Specifies the size of the wchar_t of the emulator, in bytes. Plugin authors should be
- // sure to check this against your own sizeof(wchar_t) before using any API that has
- // a wchar_t parameter (such as the ConsoleWriterWide interface). wchar_t is a loosely
- // defined type that can range from 8 bits to 32 bits (realistically, although there is
- // no actual limit on size), and can vary between compilers for the same platform.
- int Sizeof_wchar_t;
+ // Specifies the size of the wchar_t of the emulator, in bytes. Plugin authors should be
+ // sure to check this against your own sizeof(wchar_t) before using any API that has
+ // a wchar_t parameter (such as the ConsoleWriterWide interface). wchar_t is a loosely
+ // defined type that can range from 8 bits to 32 bits (realistically, although there is
+ // no actual limit on size), and can vary between compilers for the same platform.
+ int Sizeof_wchar_t;
- // Reserved area for future expansion of the structure (avoids having to upgrade the
- // plugin api for amending new extensions).
- int reserved1[6];
+ // Reserved area for future expansion of the structure (avoids having to upgrade the
+ // plugin api for amending new extensions).
+ int reserved1[6];
- // GetInt
- // Self-explanatory.
- //
- // Returns:
- // 0 - Value was retrieved successfully.
- // 1 - Unknown value. Contents of dest are unchanged.
- BOOL (PS2E_CALLBACK* GetInt)( const char* name, int* dest );
+ // GetInt
+ // Self-explanatory.
+ //
+ // Returns:
+ // 0 - Value was retrieved successfully.
+ // 1 - Unknown value. Contents of dest are unchanged.
+ BOOL(PS2E_CALLBACK *GetInt)
+ (const char *name, int *dest);
- // GetBoolean
- // Assigns *dest either 1 (true) or 0 (false). Note to Emulators: Returning any non-
- // zero value for true probably "works" but is not recommended, since C/C++ standard
- // specifically defines the result of bool->int conversions as a 0 or 1 result.
- //
- // Returns:
- // 0 - Value was retrieved successfully.
- // 1 - Unknown value. Contents of dest are unchanged.
- BOOL (PS2E_CALLBACK* GetBoolean)( const char* name, BOOL* result );
+ // GetBoolean
+ // Assigns *dest either 1 (true) or 0 (false). Note to Emulators: Returning any non-
+ // zero value for true probably "works" but is not recommended, since C/C++ standard
+ // specifically defines the result of bool->int conversions as a 0 or 1 result.
+ //
+ // Returns:
+ // 0 - Value was retrieved successfully.
+ // 1 - Unknown value. Contents of dest are unchanged.
+ BOOL(PS2E_CALLBACK *GetBoolean)
+ (const char *name, BOOL *result);
- // GetString
- // Copies an ASCII-Z string into the dest pointer, to max length allowed. The result
- // is always safely zero-terminated (none of that snprintf crap where you have to
- // zero-terminate yourself >_<).
- //
- // Returns:
- // 0 - Value was retrieved successfully.
- // 1 - Unknown value. Contents of dest are unchanged.
- BOOL (PS2E_CALLBACK* GetString)( const char* name, char* dest, int maxlen );
+ // GetString
+ // Copies an ASCII-Z string into the dest pointer, to max length allowed. The result
+ // is always safely zero-terminated (none of that snprintf crap where you have to
+ // zero-terminate yourself >_<).
+ //
+ // Returns:
+ // 0 - Value was retrieved successfully.
+ // 1 - Unknown value. Contents of dest are unchanged.
+ BOOL(PS2E_CALLBACK *GetString)
+ (const char *name, char *dest, int maxlen);
- // GetStringAlloc
- // Provides an alternative to GetString, that can retrieve strings of arbitrary length.
- // The plugin must provide a valid allocator callback, which takes a size parameter and
- // returns a pointer to an allocation large enough to hold the size.
- //
- // It is then the responsibility of the plugin to free the allocated pointer when it
- // is done with it.
- //
- char* (PS2E_CALLBACK* GetStringAlloc)( const char* name, void* (PS2E_CALLBACK *allocator)(int size) );
+ // GetStringAlloc
+ // Provides an alternative to GetString, that can retrieve strings of arbitrary length.
+ // The plugin must provide a valid allocator callback, which takes a size parameter and
+ // returns a pointer to an allocation large enough to hold the size.
+ //
+ // It is then the responsibility of the plugin to free the allocated pointer when it
+ // is done with it.
+ //
+ char *(PS2E_CALLBACK *GetStringAlloc)(const char *name, void *(PS2E_CALLBACK *allocator)(int size));
- // OSD_WriteLn
- // This function allows the plugin to post messages to the emulator's On-Screen Display.
- // The OSD message will be displayed with the specified icon (optional) for the duration
- // of a few seconds, or until other messages have scrolled it out of view.
- // Implementation of the OSD is emulator specific, and there is no guarantee that the
- // OSD will be honored at all. If the emulator does not support OSD then this function
- // call is treated as a NOP.
- //
- // Typically a plugin author should only use the OSD for infrequent notices that are
- // potentially useful to users playing games (particularly at fullscreen). Trouble-
- // shooting and debug information is best dumped to console or to disk log, or displayed
- // using a native popup window managed by the plugin.
- //
- // Parameters:
- // icon - an icon identifier, typically from the PS2E_OSDIconTypes enumeration. Specific
- // versions of emulators may provide their own icon extensions. The emulator will
- // silently ignore unrecognized icon identifiers, thus retaining cross-compat.
- //
- // msg - string message displayed to the user.
- //
- void (PS2E_CALLBACK* OSD_WriteLn)( int icon, const char* msg );
+ // OSD_WriteLn
+ // This function allows the plugin to post messages to the emulator's On-Screen Display.
+ // The OSD message will be displayed with the specified icon (optional) for the duration
+ // of a few seconds, or until other messages have scrolled it out of view.
+ // Implementation of the OSD is emulator specific, and there is no guarantee that the
+ // OSD will be honored at all. If the emulator does not support OSD then this function
+ // call is treated as a NOP.
+ //
+ // Typically a plugin author should only use the OSD for infrequent notices that are
+ // potentially useful to users playing games (particularly at fullscreen). Trouble-
+ // shooting and debug information is best dumped to console or to disk log, or displayed
+ // using a native popup window managed by the plugin.
+ //
+ // Parameters:
+ // icon - an icon identifier, typically from the PS2E_OSDIconTypes enumeration. Specific
+ // versions of emulators may provide their own icon extensions. The emulator will
+ // silently ignore unrecognized icon identifiers, thus retaining cross-compat.
+ //
+ // msg - string message displayed to the user.
+ //
+ void(PS2E_CALLBACK *OSD_WriteLn)(int icon, const char *msg);
- // ----------------------------------------------------------------------------
- // Menu / MenuItem Section
- // ----------------------------------------------------------------------------
+ // ----------------------------------------------------------------------------
+ // Menu / MenuItem Section
+ // ----------------------------------------------------------------------------
- void (PS2E_CALLBACK* AddMenuItem)( const PS2E_MenuItemInfo* item );
+ void(PS2E_CALLBACK *AddMenuItem)(const PS2E_MenuItemInfo *item);
- // Allocates a new menu handle and returns it. The returned menu can have any valid existing
- // menu items bound to it, and can be assigned as a submenu to any created MenuItem. The menu
- // can belong to multiple menu items, however menu items can only belong to a single menu.
- PS2E_MenuHandle (PS2E_CALLBACK* Menu_Create)( PS2E_THISPTR thisptr );
+ // Allocates a new menu handle and returns it. The returned menu can have any valid existing
+ // menu items bound to it, and can be assigned as a submenu to any created MenuItem. The menu
+ // can belong to multiple menu items, however menu items can only belong to a single menu.
+ PS2E_MenuHandle(PS2E_CALLBACK *Menu_Create)(PS2E_THISPTR thisptr);
- // Deletes the specified menu and frees its allocated memory resources. NULL pointers are
- // safely ignored. Any menu items also attached to this menu will be deleted. Even if you
- // do not explicitly delete your plugin's menu resources, the emulator will do automatic
- // cleanup after the plugin's instance is freed.
- void (PS2E_CALLBACK* Menu_Delete)( PS2E_MenuHandle handle );
+ // Deletes the specified menu and frees its allocated memory resources. NULL pointers are
+ // safely ignored. Any menu items also attached to this menu will be deleted. Even if you
+ // do not explicitly delete your plugin's menu resources, the emulator will do automatic
+ // cleanup after the plugin's instance is freed.
+ void(PS2E_CALLBACK *Menu_Delete)(PS2E_MenuHandle handle);
- // Adds the specified menu item to this menu. Menu items can only belong to one menu at a
- // time. If you assign an item to a created menu that already belongs to another menu, it
- // will be removed from the other menu and moved to this one. To append a menu item to
- // multiple menus, you will need to create multiple instances of the item.
- void (PS2E_CALLBACK* Menu_AddItem)( PS2E_MenuHandle menu, PS2E_MenuItemHandle mitem );
+ // Adds the specified menu item to this menu. Menu items can only belong to one menu at a
+ // time. If you assign an item to a created menu that already belongs to another menu, it
+ // will be removed from the other menu and moved to this one. To append a menu item to
+ // multiple menus, you will need to create multiple instances of the item.
+ void(PS2E_CALLBACK *Menu_AddItem)(PS2E_MenuHandle menu, PS2E_MenuItemHandle mitem);
- // Interface for creating menu items and modifying their properties.
- PS2E_MenuItemAPI MenuItem;
+ // Interface for creating menu items and modifying their properties.
+ PS2E_MenuItemAPI MenuItem;
- // Provides a set of basic console functions for writing text to the emulator's
- // console. Some emulators may not support a console, in which case these functions
- // will be NOPs. For plain and simple to-disk logging, plugins should create and use
- // their own logging facilities.
- PS2E_ConsoleWriterAPI Console;
+ // Provides a set of basic console functions for writing text to the emulator's
+ // console. Some emulators may not support a console, in which case these functions
+ // will be NOPs. For plain and simple to-disk logging, plugins should create and use
+ // their own logging facilities.
+ PS2E_ConsoleWriterAPI Console;
- // Optional wide-version of the Console API. Use with caution -- wchar_t is platform and
- // compiler dependent, and so plugin authors should be sure to check the emulator's wchar_t
- // side before using this interface. See PS2E_ConsoleWriterWideAPI comments for more info.
- PS2E_ConsoleWriterWideAPI ConsoleW;
+ // Optional wide-version of the Console API. Use with caution -- wchar_t is platform and
+ // compiler dependent, and so plugin authors should be sure to check the emulator's wchar_t
+ // side before using this interface. See PS2E_ConsoleWriterWideAPI comments for more info.
+ PS2E_ConsoleWriterWideAPI ConsoleW;
- void* reserved2[8];
+ void *reserved2[8];
} PS2E_EmulatorInfo;
@@ -629,8 +631,8 @@ typedef struct _PS2E_EmulatorInfo
//
typedef struct _PS2E_FreezeData
{
- u32 Size; // size of the data being frozen or thawed. This value is allowed to be changed by Freeze().
- void* Data; // pointer to the data target (freeze) or source (thaw)
+ u32 Size; // size of the data being frozen or thawed. This value is allowed to be changed by Freeze().
+ void *Data; // pointer to the data target (freeze) or source (thaw)
} PS2E_FreezeData;
@@ -649,115 +651,115 @@ typedef struct _PS2E_FreezeData
//
typedef struct _PS2E_ComponentAPI
{
- // EmuOpen
- // This function is called by the emulator when an emulation session is started. The
- // plugin should take this opportunity to bind itself to the given window handle, open
- // necessary audio/video/input devices, etc.
- //
- // Parameters:
- // session - provides relevant emulation session information. Provided pointer is
- // valid until after the subsequent call to EmuClose()
- //
- // Threading: EmuOpen is called from the GUI thread. All other emulation threads are
- // guaranteed to be suspended or closed at the time of this call (no locks required).
- //
- void (PS2E_CALLBACK* EmuOpen)( PS2E_THISPTR thisptr, const PS2E_SessionInfo *session );
+ // EmuOpen
+ // This function is called by the emulator when an emulation session is started. The
+ // plugin should take this opportunity to bind itself to the given window handle, open
+ // necessary audio/video/input devices, etc.
+ //
+ // Parameters:
+ // session - provides relevant emulation session information. Provided pointer is
+ // valid until after the subsequent call to EmuClose()
+ //
+ // Threading: EmuOpen is called from the GUI thread. All other emulation threads are
+ // guaranteed to be suspended or closed at the time of this call (no locks required).
+ //
+ void(PS2E_CALLBACK *EmuOpen)(PS2E_THISPTR thisptr, const PS2E_SessionInfo *session);
- // EmuClose
- // This function is called by the emulator prior to stopping emulation. The window
- // handle specified in EmuOpen is guaranteed to be valid at the time EmuClose is called,
- // and the plugin should unload/unbind all window dependencies at this time.
- //
- // Threading: EmuClose is called from the GUI thread. All other emulation threads are
- // guaranteed to be suspended or closed at the time of this call (no locks required).
- //
- void (PS2E_CALLBACK* EmuClose)( PS2E_THISPTR thisptr );
+ // EmuClose
+ // This function is called by the emulator prior to stopping emulation. The window
+ // handle specified in EmuOpen is guaranteed to be valid at the time EmuClose is called,
+ // and the plugin should unload/unbind all window dependencies at this time.
+ //
+ // Threading: EmuClose is called from the GUI thread. All other emulation threads are
+ // guaranteed to be suspended or closed at the time of this call (no locks required).
+ //
+ void(PS2E_CALLBACK *EmuClose)(PS2E_THISPTR thisptr);
- // CalcFreezeSize
- // This function should calculate and return the amount of memory needed for the plugin
- // to freeze its complete emulation state. The value can be larger than the required
- // amount of space, but cannot be smaller.
- //
- // The emulation state when this function is called is guaranteed to be the same as
- // the following call to Freeze.
- //
- // Thread Safety:
- // May be called from any thread (GUI, Emu, GS, Unknown, etc).
- // All Emulation threads are halted at a PS2 logical vsync-end event.
- // No locking is necessary.
- u32 (PS2E_CALLBACK* CalcFreezeSize)( PS2E_THISPTR thisptr );
+ // CalcFreezeSize
+ // This function should calculate and return the amount of memory needed for the plugin
+ // to freeze its complete emulation state. The value can be larger than the required
+ // amount of space, but cannot be smaller.
+ //
+ // The emulation state when this function is called is guaranteed to be the same as
+ // the following call to Freeze.
+ //
+ // Thread Safety:
+ // May be called from any thread (GUI, Emu, GS, Unknown, etc).
+ // All Emulation threads are halted at a PS2 logical vsync-end event.
+ // No locking is necessary.
+ u32(PS2E_CALLBACK *CalcFreezeSize)(PS2E_THISPTR thisptr);
- // Freeze
- // This function should make a complete copy of the plugin's emulation state into the
- // provided dest->Data pointer. The plugin is allowed to reduce the dest->Size value
- // but is not allowed to make it larger. The plugin will only receive calls to Freeze
- // and Thaw while a plugin is in an EmuOpen() state.
- //
- // Parameters:
- // dest - a pointer to the Data/Size destination buffer (never NULL).
- //
- // Thread Safety:
- // May be called from any thread (GUI, Emu, GS, Unknown, etc).
- // All Emulation threads are halted at a PS2 logical vsync-end event.
- // No locking is necessary.
- void (PS2E_CALLBACK* Freeze)( PS2E_THISPTR thisptr, PS2E_FreezeData* dest );
+ // Freeze
+ // This function should make a complete copy of the plugin's emulation state into the
+ // provided dest->Data pointer. The plugin is allowed to reduce the dest->Size value
+ // but is not allowed to make it larger. The plugin will only receive calls to Freeze
+ // and Thaw while a plugin is in an EmuOpen() state.
+ //
+ // Parameters:
+ // dest - a pointer to the Data/Size destination buffer (never NULL).
+ //
+ // Thread Safety:
+ // May be called from any thread (GUI, Emu, GS, Unknown, etc).
+ // All Emulation threads are halted at a PS2 logical vsync-end event.
+ // No locking is necessary.
+ void(PS2E_CALLBACK *Freeze)(PS2E_THISPTR thisptr, PS2E_FreezeData *dest);
- // Thaw
- // Plugin should restore a complete emulation state from the given FreezeData. The
- // plugin will only receive calls to Freeze and Thaw while a plugin is in an EmuOpen()
- // state.
- //
- // Thread Safety:
- // May be called from any thread (GUI, Emu, GS, Unknown, etc).
- // All Emulation threads are halted at a PS2 logical vsync-end event.
- // No locking is necessary.
- void (PS2E_CALLBACK* Thaw)( PS2E_THISPTR thisptr, const PS2E_FreezeData* src );
+ // Thaw
+ // Plugin should restore a complete emulation state from the given FreezeData. The
+ // plugin will only receive calls to Freeze and Thaw while a plugin is in an EmuOpen()
+ // state.
+ //
+ // Thread Safety:
+ // May be called from any thread (GUI, Emu, GS, Unknown, etc).
+ // All Emulation threads are halted at a PS2 logical vsync-end event.
+ // No locking is necessary.
+ void(PS2E_CALLBACK *Thaw)(PS2E_THISPTR thisptr, const PS2E_FreezeData *src);
- // Configure
- // The plugin should open a modal dialog box with plugin-specific settings and prop-
- // erties. This function can be NULL, in which case the user's Configure option for
- // this plugin is grayed out.
- //
- // All emulation is suspended and the plugin's state is saved to memory prior to this
- // function being called. Configure is only called outside the context of EmuOpen()
- // (after a call to EmuClose()).
- //
- // Plugin authors should ensure to re-read and re-apply all settings on EmuOpen(),
- // which will ensure that any user changes will be applied immediately. For changes
- // that can be applied without emulation suspension, see/use the GUI extensions for
- // menu and toolbar shortcuts.
- //
- // Thread Safety:
- // Always called from the GUI thread, with emulation in a halted state (no locks
- // needed).
- void (PS2E_CALLBACK* Configure)( PS2E_THISPTR thisptr );
+ // Configure
+ // The plugin should open a modal dialog box with plugin-specific settings and prop-
+ // erties. This function can be NULL, in which case the user's Configure option for
+ // this plugin is grayed out.
+ //
+ // All emulation is suspended and the plugin's state is saved to memory prior to this
+ // function being called. Configure is only called outside the context of EmuOpen()
+ // (after a call to EmuClose()).
+ //
+ // Plugin authors should ensure to re-read and re-apply all settings on EmuOpen(),
+ // which will ensure that any user changes will be applied immediately. For changes
+ // that can be applied without emulation suspension, see/use the GUI extensions for
+ // menu and toolbar shortcuts.
+ //
+ // Thread Safety:
+ // Always called from the GUI thread, with emulation in a halted state (no locks
+ // needed).
+ void(PS2E_CALLBACK *Configure)(PS2E_THISPTR thisptr);
- // GetLastError
- // This is an optional method with allows the emulator to retrieve extended formatted
- // error information about a recent failed plugin call. If implemented by the plugin,
- // it should store message information in it's PS2E_THISPTR allocation, and free the
- // string buffers when the plugin's instance is deleted.
- //
- // The plugin is allowed to return NULL for either msg_diag or msg_user (or both).
- // Returned pointers should be static global arrays, and must be NULL terminated. If
- // only one message is provided, it will be used for both console log and popup.
- //
- // Parameters:
- // msg_diag - diagnostic message, which is english only and typically intended for
- // console or disk logging.
- //
- // msg_user - optional translated user message, which is displayed as a popup to explain
- // to the user why the plugin failed to initialize.
- //
- // Thread safety:
- // * Thread Affinity: none. May be called from any thread.
- // * Interlocking: Instance. All calls from the emu are fully interlocked against
- // the plugin instance.
- //
- void (PS2E_CALLBACK* GetLastError)( PS2E_THISPTR thisptr, char* const* msg_diag, wchar_t* const* msg_user );
+ // GetLastError
+ // This is an optional method with allows the emulator to retrieve extended formatted
+ // error information about a recent failed plugin call. If implemented by the plugin,
+ // it should store message information in it's PS2E_THISPTR allocation, and free the
+ // string buffers when the plugin's instance is deleted.
+ //
+ // The plugin is allowed to return NULL for either msg_diag or msg_user (or both).
+ // Returned pointers should be static global arrays, and must be NULL terminated. If
+ // only one message is provided, it will be used for both console log and popup.
+ //
+ // Parameters:
+ // msg_diag - diagnostic message, which is english only and typically intended for
+ // console or disk logging.
+ //
+ // msg_user - optional translated user message, which is displayed as a popup to explain
+ // to the user why the plugin failed to initialize.
+ //
+ // Thread safety:
+ // * Thread Affinity: none. May be called from any thread.
+ // * Interlocking: Instance. All calls from the emu are fully interlocked against
+ // the plugin instance.
+ //
+ void(PS2E_CALLBACK *GetLastError)(PS2E_THISPTR thisptr, char *const *msg_diag, wchar_t *const *msg_user);
- // Reserved area at the end of the structure, for future API expansion.
- void* reserved[8];
+ // Reserved area at the end of the structure, for future API expansion.
+ void *reserved[8];
} PS2E_ComponentAPI;
@@ -780,111 +782,113 @@ typedef struct _PS2E_ComponentAPI
//
typedef struct _PS2E_LibraryAPI
{
- // GetName
- // Returns an ASCII-Z (zero-terminated) string name of the plugin. The name should
- // *not* include version or build information. That info is returned separately
- // via GetVersion. The return value cannot be NULL (if it is NULL, the emulator
- // will assume the DLL is invalid and ignore it).
- //
- // The pointer should reference a static/global scope char array, or an allocated
- // heap pointer (not recommended).
- //
- // This function may be called multiple times by the emulator, so it should accommodate
- // for such if it performs heap allocations or other initialization procedures.
- const char* (PS2E_CALLBACK* GetName)();
+ // GetName
+ // Returns an ASCII-Z (zero-terminated) string name of the plugin. The name should
+ // *not* include version or build information. That info is returned separately
+ // via GetVersion. The return value cannot be NULL (if it is NULL, the emulator
+ // will assume the DLL is invalid and ignore it).
+ //
+ // The pointer should reference a static/global scope char array, or an allocated
+ // heap pointer (not recommended).
+ //
+ // This function may be called multiple times by the emulator, so it should accommodate
+ // for such if it performs heap allocations or other initialization procedures.
+ const char *(PS2E_CALLBACK *GetName)();
- // GetVersion
- // This function returns name and version information for the requested PS2 component.
- // If the plugin does not support the requested component, it should return NULL.
- // The returned pointer, if non-NULL, must be either a static value [recommended] or a
- // heap-allocated value, and valid for the lifetime of the plugin.
- //
- // This function may be called multiple times by the emulator, so it should accommodate
- // for such if it performs heap allocations or other initialization procedures.
- //
- // Typically a plugin will return the same version for all supported components. The
- // component parameter is mostly provided to allow this function to serve a dual purpose
- // of both component versioning and as a component enumerator.
- //
- // See PS2E_VersionInfo for more details.
- //
- // Parameters:
- // component - indicates the ps2 component plugin to be versioned. If the plugin
- // does not support the requested component, the function should return NULL.
- //
- const PS2E_VersionInfo* (PS2E_CALLBACK* GetVersion)( u32 component );
+ // GetVersion
+ // This function returns name and version information for the requested PS2 component.
+ // If the plugin does not support the requested component, it should return NULL.
+ // The returned pointer, if non-NULL, must be either a static value [recommended] or a
+ // heap-allocated value, and valid for the lifetime of the plugin.
+ //
+ // This function may be called multiple times by the emulator, so it should accommodate
+ // for such if it performs heap allocations or other initialization procedures.
+ //
+ // Typically a plugin will return the same version for all supported components. The
+ // component parameter is mostly provided to allow this function to serve a dual purpose
+ // of both component versioning and as a component enumerator.
+ //
+ // See PS2E_VersionInfo for more details.
+ //
+ // Parameters:
+ // component - indicates the ps2 component plugin to be versioned. If the plugin
+ // does not support the requested component, the function should return NULL.
+ //
+ const PS2E_VersionInfo *(PS2E_CALLBACK *GetVersion)(u32 component);
- // Test
- // Called by the plugin enumerator to check the hardware availability of the specified
- // component. The function should return 1 if the plugin appears to be supported, or
- // 0 if the test failed.
- //
- // While a plugin is welcome to use its own CPU capabilities information, it is recommended
- // that you use the emulator provided CPU capabilities structure instead. The emulator may
- // have provisions in its interface to allow for the forced disabling of extended CPU cap-
- // abilities, for testing purposes.
- //
- BOOL (PS2E_CALLBACK* Test)( u32 component, const PS2E_EmulatorInfo* xinfo );
+ // Test
+ // Called by the plugin enumerator to check the hardware availability of the specified
+ // component. The function should return 1 if the plugin appears to be supported, or
+ // 0 if the test failed.
+ //
+ // While a plugin is welcome to use its own CPU capabilities information, it is recommended
+ // that you use the emulator provided CPU capabilities structure instead. The emulator may
+ // have provisions in its interface to allow for the forced disabling of extended CPU cap-
+ // abilities, for testing purposes.
+ //
+ BOOL(PS2E_CALLBACK *Test)
+ (u32 component, const PS2E_EmulatorInfo *xinfo);
- // NewComponentInstance
- // The emulator calls this function to fetch the API for the requested component.
- // The plugin is expected to perform an "availability test" (the same test as performed
- // by Test()) and return NULL if the plugin does not support the host machine's hardware
- // or software installations.
- //
- // This function is only called for components which the plugin returned a non-NULL
- // version information struct for in GetVersion().
- //
- // Plugin Allocation Strategy:
- // The Component API has been designed with function invocation efficiency in mind.
- // To allocate your plugin's component instance you should create a structure that
- // contains PS2E_ComponentAPI_* as the first member (where * refers to the PS2
- // component type), and plugin-specific instance data is stored as any number of
- // subsequent members in the struct.
- //
- // Parameters:
- // component - indicates the ps2 component API to return.
- // dest - structure to fill with plugin function implementations. Dest should
- // be manually typecast by the plugin to match the requested component.
- //
- // OnError:
- // Plugins may optionally prepare more detailed information on why the plugin failed
- // it's availability test which the emu can request via GetLastError.
- //
- PS2E_THISPTR (PS2E_CALLBACK* NewComponentInstance)( u32 component );
+ // NewComponentInstance
+ // The emulator calls this function to fetch the API for the requested component.
+ // The plugin is expected to perform an "availability test" (the same test as performed
+ // by Test()) and return NULL if the plugin does not support the host machine's hardware
+ // or software installations.
+ //
+ // This function is only called for components which the plugin returned a non-NULL
+ // version information struct for in GetVersion().
+ //
+ // Plugin Allocation Strategy:
+ // The Component API has been designed with function invocation efficiency in mind.
+ // To allocate your plugin's component instance you should create a structure that
+ // contains PS2E_ComponentAPI_* as the first member (where * refers to the PS2
+ // component type), and plugin-specific instance data is stored as any number of
+ // subsequent members in the struct.
+ //
+ // Parameters:
+ // component - indicates the ps2 component API to return.
+ // dest - structure to fill with plugin function implementations. Dest should
+ // be manually typecast by the plugin to match the requested component.
+ //
+ // OnError:
+ // Plugins may optionally prepare more detailed information on why the plugin failed
+ // it's availability test which the emu can request via GetLastError.
+ //
+ PS2E_THISPTR(PS2E_CALLBACK *NewComponentInstance)
+ (u32 component);
- // DeleteComponentInstance
- // Called by the emulator when the plugin component is to be shutdown. The component API
- // instance pointer can be safely deleted here.
- void (PS2E_CALLBACK* DeleteComponentInstance)( PS2E_THISPTR instance );
+ // DeleteComponentInstance
+ // Called by the emulator when the plugin component is to be shutdown. The component API
+ // instance pointer can be safely deleted here.
+ void(PS2E_CALLBACK *DeleteComponentInstance)(PS2E_THISPTR instance);
- // SetSettingsFolder
- // Callback is passed an ASCII-Z string representing the folder where the emulator's
- // settings files are stored (may either be under the user's documents folder, or a
- // location relative to the CWD of the emu application).
- //
- // Typically this callback is only issued once per plugin session, aand prior to the
- // opening of any PS2 components. It is the responsibility of the emu to save the
- // emulation state, shutdown plugins, and restart everything anew from the new settings
- // in such an event as a dynamic change of the settings folder.
- //
- void (PS2E_CALLBACK* SetSettingsFolder)( const char* folder );
+ // SetSettingsFolder
+ // Callback is passed an ASCII-Z string representing the folder where the emulator's
+ // settings files are stored (may either be under the user's documents folder, or a
+ // location relative to the CWD of the emu application).
+ //
+ // Typically this callback is only issued once per plugin session, aand prior to the
+ // opening of any PS2 components. It is the responsibility of the emu to save the
+ // emulation state, shutdown plugins, and restart everything anew from the new settings
+ // in such an event as a dynamic change of the settings folder.
+ //
+ void(PS2E_CALLBACK *SetSettingsFolder)(const char *folder);
- // SetLogFolder
- // This callback may be issued at any time. It is the responsibility of the plugin
- // to do the necessary actions to close existing disk logging facilities and re-open
- // new facilities.
- //
- // Thread Safety:
- // This function is always called from the GUI thread. All emulation threads are
- // suspended during the call, so no locking is required.
- //
- void (PS2E_CALLBACK* SetLogFolder)( const char* folder );
+ // SetLogFolder
+ // This callback may be issued at any time. It is the responsibility of the plugin
+ // to do the necessary actions to close existing disk logging facilities and re-open
+ // new facilities.
+ //
+ // Thread Safety:
+ // This function is always called from the GUI thread. All emulation threads are
+ // suspended during the call, so no locking is required.
+ //
+ void(PS2E_CALLBACK *SetLogFolder)(const char *folder);
- // Reserved area at the end of the structure, for future API expansion. This area
- // should always be zeroed out, so that future versions of emulators that may have
- // defined functions here will recognize the functions as not supported by the plugin.
- void* reserved[12];
+ // Reserved area at the end of the structure, for future API expansion. This area
+ // should always be zeroed out, so that future versions of emulators that may have
+ // defined functions here will recognize the functions as not supported by the plugin.
+ void *reserved[12];
} PS2E_LibraryAPI;
@@ -899,117 +903,119 @@ typedef struct _PS2E_LibraryAPI
//
typedef struct _PS2E_ComponentAPI_GS
{
- // Base Component API (inherited structure)
- struct _PS2E_ComponentAPI Base;
+ // Base Component API (inherited structure)
+ struct _PS2E_ComponentAPI Base;
- // SetSnapshotsFolder
- // Callback is passed an ASCII-Z string representing the folder where the emulator's
- // snapshots are to be saved (typically located under user documents, but may be CWD
- // or any user-specified location).
- //
- // Thread Safety:
- // This function may be called from either GUI thread or GS thread. Emulators calling
- // it from non-GS threads must ensure mutex locking with TakeSnapshot (meaning the
- // plugin should be free to disregard threading concerns).
- void (PS2E_CALLBACK* GsSetSnapshotsFolder)( PS2E_THISPTR thisptr, const char* folder );
+ // SetSnapshotsFolder
+ // Callback is passed an ASCII-Z string representing the folder where the emulator's
+ // snapshots are to be saved (typically located under user documents, but may be CWD
+ // or any user-specified location).
+ //
+ // Thread Safety:
+ // This function may be called from either GUI thread or GS thread. Emulators calling
+ // it from non-GS threads must ensure mutex locking with TakeSnapshot (meaning the
+ // plugin should be free to disregard threading concerns).
+ void(PS2E_CALLBACK *GsSetSnapshotsFolder)(PS2E_THISPTR thisptr, const char *folder);
- // TakeSnapshot
- // The GS plugin is to save the current frame into the given target image. This
- // function is always called immediately after a GSvsync(), ensuring that the current
- // framebuffer is safely intact for capture.
- //
- // Returns TRUE if the snapshot succeeded, or FALSE if it failed (contents of dest
- // are considered indeterminate and will be ignored by the emu).
- BOOL (PS2E_CALLBACK* GsTakeSnapshot)( PS2E_THISPTR thisptr, PS2E_Image* dest );
+ // TakeSnapshot
+ // The GS plugin is to save the current frame into the given target image. This
+ // function is always called immediately after a GSvsync(), ensuring that the current
+ // framebuffer is safely intact for capture.
+ //
+ // Returns TRUE if the snapshot succeeded, or FALSE if it failed (contents of dest
+ // are considered indeterminate and will be ignored by the emu).
+ BOOL(PS2E_CALLBACK *GsTakeSnapshot)
+ (PS2E_THISPTR thisptr, PS2E_Image *dest);
- // OSD_QueueMessage
- // Queues a message to the GS for display to the user. The GS can print the message
- // where-ever it pleases, though it's suggested that the messages be printed either
- // near the top or the bottom of the window (and in the black/empty area if the
- // game's display is letterboxed).
- //
- // Parameters:
- // message - text to queue (UTF8 format); will always be a single line (emulator
- // is responsible for pre-processing linebreaks into multiple messages). The pointer
- // will become invalid after this call retunrs, so be sure to make a local copy of the
- // text.
- //
- // timeout - Suggested timeout period, in milliseconds. This is a hint and need
- // not be strictly adhered to by the GS.
- //
- void (PS2E_CALLBACK* OSD_QueueMessage)( PS2E_THISPTR thisptr, const char* msg, int timeout );
+ // OSD_QueueMessage
+ // Queues a message to the GS for display to the user. The GS can print the message
+ // where-ever it pleases, though it's suggested that the messages be printed either
+ // near the top or the bottom of the window (and in the black/empty area if the
+ // game's display is letterboxed).
+ //
+ // Parameters:
+ // message - text to queue (UTF8 format); will always be a single line (emulator
+ // is responsible for pre-processing linebreaks into multiple messages). The pointer
+ // will become invalid after this call retunrs, so be sure to make a local copy of the
+ // text.
+ //
+ // timeout - Suggested timeout period, in milliseconds. This is a hint and need
+ // not be strictly adhered to by the GS.
+ //
+ void(PS2E_CALLBACK *OSD_QueueMessage)(PS2E_THISPTR thisptr, const char *msg, int timeout);
- // OSD_IconStatus
- // Sets the visibility status of an icon. Icon placement can be determined by the GS,
- // although it's recommended that the icon be displayed near a corner of the screen, and
- // be displayed in the empty/black areas if present (letterboxing).
- //
- // Parameters:
- // iconId - Icon status to change
- // alpha - 0.0 is hdden, 1.0 is visible. Other alpha values may be used as either
- // transparency or as a scrolling factor (ie, to scroll the icon in and out of view, in
- // any way the GS plugin sees fit).
- void (PS2E_CALLBACK* OSD_IconStatus)( PS2E_THISPTR thisptr, OSDIconTypes iconId, float alpha );
+ // OSD_IconStatus
+ // Sets the visibility status of an icon. Icon placement can be determined by the GS,
+ // although it's recommended that the icon be displayed near a corner of the screen, and
+ // be displayed in the empty/black areas if present (letterboxing).
+ //
+ // Parameters:
+ // iconId - Icon status to change
+ // alpha - 0.0 is hdden, 1.0 is visible. Other alpha values may be used as either
+ // transparency or as a scrolling factor (ie, to scroll the icon in and out of view, in
+ // any way the GS plugin sees fit).
+ void(PS2E_CALLBACK *OSD_IconStatus)(PS2E_THISPTR thisptr, OSDIconTypes iconId, float alpha);
- // GSvsync
- //
- // Returns FALSE if the plugin encountered a critical error while updating the display;
- // indicating a device or emulation failure that should terminate the current emulation.
- // (if any critical errors accumulated during GStransferTags or GStransferImage, they
- // should also be handled here by returning FALSE)
- //
- BOOL (PS2E_CALLBACK* GsVsync)(int field);
+ // GSvsync
+ //
+ // Returns FALSE if the plugin encountered a critical error while updating the display;
+ // indicating a device or emulation failure that should terminate the current emulation.
+ // (if any critical errors accumulated during GStransferTags or GStransferImage, they
+ // should also be handled here by returning FALSE)
+ //
+ BOOL(PS2E_CALLBACK *GsVsync)
+ (int field);
- // GSwriteRegs
- // Sends a GIFtag and associated register data. This is the main transfer method for all
- // GIF register data. REGLIST mode is unpacked into the forat described below.
- //
- // Note that SIGNAL, FINISH, and LABEL tags are handled internally by the emulator in a
- // thread-safe manner -- the GS plugin should ignore those tags when processing.
- //
- // Returns FALSE if the plugin encountered a critical error while setting texture;
- // indicating a device failure.
- //
- // Parameters:
- // pMem - pointer to source memory for the register descriptors and register data.
- // The first 128 bits (1 qwc) is the descriptors unrolled into 16x8 format. The
- // following data is (regcnt x tagcnt) QWCs in length.
- //
- // regcnt - number of registers per loop packet (register descriptors are filled
- // low->high). Valid range is 1->16, and will never be zero.
- //
- // nloop - number of loops of register data. Valid range is 1->32767 (upper 17
- // bits are always zero). This value will never be zero.
- void (PS2E_CALLBACK* GsWriteRegs)(const u128 *pMem, int regcnt, int nloop);
+ // GSwriteRegs
+ // Sends a GIFtag and associated register data. This is the main transfer method for all
+ // GIF register data. REGLIST mode is unpacked into the forat described below.
+ //
+ // Note that SIGNAL, FINISH, and LABEL tags are handled internally by the emulator in a
+ // thread-safe manner -- the GS plugin should ignore those tags when processing.
+ //
+ // Returns FALSE if the plugin encountered a critical error while setting texture;
+ // indicating a device failure.
+ //
+ // Parameters:
+ // pMem - pointer to source memory for the register descriptors and register data.
+ // The first 128 bits (1 qwc) is the descriptors unrolled into 16x8 format. The
+ // following data is (regcnt x tagcnt) QWCs in length.
+ //
+ // regcnt - number of registers per loop packet (register descriptors are filled
+ // low->high). Valid range is 1->16, and will never be zero.
+ //
+ // nloop - number of loops of register data. Valid range is 1->32767 (upper 17
+ // bits are always zero). This value will never be zero.
+ void(PS2E_CALLBACK *GsWriteRegs)(const u128 *pMem, int regcnt, int nloop);
- // GSwritePrim
- // Starts a new prim by sending the specified value to the PRIM register. The emulator
- // only posts this data to the GS s per the rules of GIFpath processing (note however
- // that packed register data can also contain PRIM writes).
- //
- // Parameters:
- // primData - value to write to the PRIM register. Only the bottom 10 bits are
- // valid. Upper bits are always zero.
- void (PS2E_CALLBACK* GsWritePrim)(int primData);
+ // GSwritePrim
+ // Starts a new prim by sending the specified value to the PRIM register. The emulator
+ // only posts this data to the GS s per the rules of GIFpath processing (note however
+ // that packed register data can also contain PRIM writes).
+ //
+ // Parameters:
+ // primData - value to write to the PRIM register. Only the bottom 10 bits are
+ // valid. Upper bits are always zero.
+ void(PS2E_CALLBACK *GsWritePrim)(int primData);
- // GSwriteImage
- // Uploads new image data. Data uploaded may be in any number of partial chunks, for
- // which the GS is responsible for managing the state machine for writes to GS memory.
- //
- // Plugin authors: Note that it is valid for games to only modify a small portion of a
- // larger texture buffer, or for games to modify several portions of a single large
- // buffer, by using mid-transfer writes to TRXPOS and TRXDIR (TRXPOS writes only become
- // effective once TRXDIR has been written).
- void (PS2E_CALLBACK* GsWriteImage)(const u128 *pMem, int qwc_cnt);
+ // GSwriteImage
+ // Uploads new image data. Data uploaded may be in any number of partial chunks, for
+ // which the GS is responsible for managing the state machine for writes to GS memory.
+ //
+ // Plugin authors: Note that it is valid for games to only modify a small portion of a
+ // larger texture buffer, or for games to modify several portions of a single large
+ // buffer, by using mid-transfer writes to TRXPOS and TRXDIR (TRXPOS writes only become
+ // effective once TRXDIR has been written).
+ void(PS2E_CALLBACK *GsWriteImage)(const u128 *pMem, int qwc_cnt);
- // GSreadImage
- // This special callback is for implementing the Read mode direction of the GIFpath.
- // The GS plugin writes the texture data as requested by it's internally managed state
- // values for TRXPOS/TRXREG to the buffer provided by pMem. The buffer size is qwc_cnt
- // and the GS must not write more than that.
- void (PS2E_CALLBACK* GsReadImage)(u128 *pMem, int qwc_cnt);
+ // GSreadImage
+ // This special callback is for implementing the Read mode direction of the GIFpath.
+ // The GS plugin writes the texture data as requested by it's internally managed state
+ // values for TRXPOS/TRXREG to the buffer provided by pMem. The buffer size is qwc_cnt
+ // and the GS must not write more than that.
+ void(PS2E_CALLBACK *GsReadImage)(u128 *pMem, int qwc_cnt);
- void* reserved[8];
+ void *reserved[8];
} PS2E_ComponentAPI_GS;
@@ -1019,10 +1025,10 @@ typedef struct _PS2E_ComponentAPI_GS
// --------------------------------------------------------------------------------------
struct PS2E_McdSizeInfo
{
- u16 SectorSize; // Size of each sector, in bytes. (only 512 and 1024 are valid)
- u16 EraseBlockSizeInSectors; // Size of the erase block, in sectors (max is 16)
- u32 McdSizeInSectors; // Total size of the card, in sectors (no upper limit)
- u8 Xor; // Checksum of previous data
+ u16 SectorSize; // Size of each sector, in bytes. (only 512 and 1024 are valid)
+ u16 EraseBlockSizeInSectors; // Size of the erase block, in sectors (max is 16)
+ u32 McdSizeInSectors; // Total size of the card, in sectors (no upper limit)
+ u8 Xor; // Checksum of previous data
};
// --------------------------------------------------------------------------------------
@@ -1036,82 +1042,86 @@ struct PS2E_McdSizeInfo
//
typedef struct _PS2E_ComponentAPI_Mcd
{
- // Base Component API (inherited structure)
- struct _PS2E_ComponentAPI Base;
+ // Base Component API (inherited structure)
+ struct _PS2E_ComponentAPI Base;
- // McdIsPresent
- // Called by the emulator to detect the availability of a memory card. This function
- // will be called frequently -- essentially whenever the SIO port for the memory card
- // has its status polled - so its overhead should be minimal when possible.
- //
- // Returns:
- // False if the card is not available, or True if it is available.
- //
- BOOL (PS2E_CALLBACK* McdIsPresent)( PS2E_THISPTR thisptr, uint port, uint slot );
+ // McdIsPresent
+ // Called by the emulator to detect the availability of a memory card. This function
+ // will be called frequently -- essentially whenever the SIO port for the memory card
+ // has its status polled - so its overhead should be minimal when possible.
+ //
+ // Returns:
+ // False if the card is not available, or True if it is available.
+ //
+ BOOL(PS2E_CALLBACK *McdIsPresent)
+ (PS2E_THISPTR thisptr, uint port, uint slot);
- // McdGetSectorSize (can be NULL)
- // Requests memorycard formatting information from the Mcd provider. See the description of
- // PS2E_McdSizeInfo for details on each field. If the Mcd provider supports only standard 8MB
- // carts, then this function can be NULL.
- //
- // Returns:
- // Assigned values for memorycard sector size and sector count in 'outways.'
- //
- void (PS2E_CALLBACK* McdGetSizeInfo)( PS2E_THISPTR thisptr, uint port, uint slot, PS2E_McdSizeInfo* outways );
+ // McdGetSectorSize (can be NULL)
+ // Requests memorycard formatting information from the Mcd provider. See the description of
+ // PS2E_McdSizeInfo for details on each field. If the Mcd provider supports only standard 8MB
+ // carts, then this function can be NULL.
+ //
+ // Returns:
+ // Assigned values for memorycard sector size and sector count in 'outways.'
+ //
+ void(PS2E_CALLBACK *McdGetSizeInfo)(PS2E_THISPTR thisptr, uint port, uint slot, PS2E_McdSizeInfo *outways);
- // McdIsPSX
- // Checks if the memorycard is a PSX one from the Mcd provider.
- //
- // Returns:
- // False: PS2, True: PSX
- //
- bool (PS2E_CALLBACK* McdIsPSX)( PS2E_THISPTR thisptr, uint port, uint slot );
+ // McdIsPSX
+ // Checks if the memorycard is a PSX one from the Mcd provider.
+ //
+ // Returns:
+ // False: PS2, True: PSX
+ //
+ bool(PS2E_CALLBACK *McdIsPSX)(PS2E_THISPTR thisptr, uint port, uint slot);
- // McdRead
- // Requests that a block of data be loaded from the memorycard into the specified dest
- // buffer (which is allocated by the caller). Bytes read should match the requested
- // size. Reads *must* be performed synchronously (function cannot return until the
- // read op has finished).
- //
- // Returns:
- // False on failure, and True on success. Emulator may use GetLastError to retrieve additional
- // information for logging or displaying to the user.
- //
- BOOL (PS2E_CALLBACK* McdRead)( PS2E_THISPTR thisptr, uint port, uint slot, u8 *dest, u32 adr, int size );
+ // McdRead
+ // Requests that a block of data be loaded from the memorycard into the specified dest
+ // buffer (which is allocated by the caller). Bytes read should match the requested
+ // size. Reads *must* be performed synchronously (function cannot return until the
+ // read op has finished).
+ //
+ // Returns:
+ // False on failure, and True on success. Emulator may use GetLastError to retrieve additional
+ // information for logging or displaying to the user.
+ //
+ BOOL(PS2E_CALLBACK *McdRead)
+ (PS2E_THISPTR thisptr, uint port, uint slot, u8 *dest, u32 adr, int size);
- // McdSave
- // Saves the provided block of data to the memorycard at the specified seek address.
- // Writes *must* be performed synchronously (function cannot return until the write op
- // has finished). Write cache flushing is optional.
- //
- // Returns:
- // False on failure, and True on success. Emulator may use GetLastError to retrieve additional
- // information for logging or displaying to the user.
- //
- BOOL (PS2E_CALLBACK* McdSave)( PS2E_THISPTR thisptr, uint port, uint slot, const u8 *src, u32 adr, int size );
+ // McdSave
+ // Saves the provided block of data to the memorycard at the specified seek address.
+ // Writes *must* be performed synchronously (function cannot return until the write op
+ // has finished). Write cache flushing is optional.
+ //
+ // Returns:
+ // False on failure, and True on success. Emulator may use GetLastError to retrieve additional
+ // information for logging or displaying to the user.
+ //
+ BOOL(PS2E_CALLBACK *McdSave)
+ (PS2E_THISPTR thisptr, uint port, uint slot, const u8 *src, u32 adr, int size);
- // McdEraseBlock
- // Saves "cleared" data to the memorycard at the specified seek address. Cleared data
- // is a series of 0xff values (all bits set to 1).
- // Writes *must* be performed synchronously (function cannot return until the write op
- // has finished). Write cache flushing is optional.
- //
- // Returns:
- // False on failure, and True on success. Emulator may use GetLastError to retrieve additional
- // information for logging or displaying to the user.
- //
- BOOL (PS2E_CALLBACK* McdEraseBlock)( PS2E_THISPTR thisptr, uint port, uint slot, u32 adr );
+ // McdEraseBlock
+ // Saves "cleared" data to the memorycard at the specified seek address. Cleared data
+ // is a series of 0xff values (all bits set to 1).
+ // Writes *must* be performed synchronously (function cannot return until the write op
+ // has finished). Write cache flushing is optional.
+ //
+ // Returns:
+ // False on failure, and True on success. Emulator may use GetLastError to retrieve additional
+ // information for logging or displaying to the user.
+ //
+ BOOL(PS2E_CALLBACK *McdEraseBlock)
+ (PS2E_THISPTR thisptr, uint port, uint slot, u32 adr);
- u64 (PS2E_CALLBACK* McdGetCRC)( PS2E_THISPTR thisptr, uint port, uint slot );
+ u64(PS2E_CALLBACK *McdGetCRC)(PS2E_THISPTR thisptr, uint port, uint slot);
- // McdNextFrame
- // Inform the memory card that a frame of emulation time has passed.
- // Used by the FolderMemoryCard to find a good time to flush written data to the host file system.
- void (PS2E_CALLBACK* McdNextFrame)( PS2E_THISPTR thisptr, uint port, uint slot );
+ // McdNextFrame
+ // Inform the memory card that a frame of emulation time has passed.
+ // Used by the FolderMemoryCard to find a good time to flush written data to the host file system.
+ void(PS2E_CALLBACK *McdNextFrame)(PS2E_THISPTR thisptr, uint port, uint slot);
- bool (PS2E_CALLBACK* McdReIndex)( PS2E_THISPTR thisptr, uint port, uint slot, const wxString& filter );
+ bool(PS2E_CALLBACK *McdReIndex)(PS2E_THISPTR thisptr, uint port, uint slot, const wxString &filter);
- void* reserved[6];
+ void *reserved[6];
} PS2E_ComponentAPI_Mcd;
@@ -1120,17 +1130,15 @@ typedef struct _PS2E_ComponentAPI_Mcd
// KeyEvent type enumerations
// ------------------------------------------------------------------------------------
-enum PS2E_KeyEventTypes
-{
- PS2E_KEY_UP = 0,
- PS2E_KEY_DOWN
+enum PS2E_KeyEventTypes {
+ PS2E_KEY_UP = 0,
+ PS2E_KEY_DOWN
};
-enum PS2E_KeyModifiers
-{
- PS2E_SHIFT = 1,
- PS2E_CONTROL = 2,
- PS2E_ALT = 4
+enum PS2E_KeyModifiers {
+ PS2E_SHIFT = 1,
+ PS2E_CONTROL = 2,
+ PS2E_ALT = 4
};
// --------------------------------------------------------------------------------------
@@ -1140,14 +1148,14 @@ enum PS2E_KeyModifiers
//
typedef struct _PS2E_KeyEvent
{
- PS2E_KeyEventTypes event;
+ PS2E_KeyEventTypes event;
- // Value of the key being pressed or released
- uint value;
+ // Value of the key being pressed or released
+ uint value;
- // Combination of PS2E_SHIFT, PS2E_CONTROL, and/or PS2E_ALT, indicating which
- // modifier keys were also down when the key was pressed.
- uint flags;
+ // Combination of PS2E_SHIFT, PS2E_CONTROL, and/or PS2E_ALT, indicating which
+ // modifier keys were also down when the key was pressed.
+ uint flags;
} PS2E_KeyEvent;
@@ -1163,71 +1171,72 @@ typedef struct _PS2E_KeyEvent
//
typedef struct _PS2E_ComponentAPI_Pad
{
- // Base Component API (inherited structure)
- struct _PS2E_ComponentAPI Base;
+ // Base Component API (inherited structure)
+ struct _PS2E_ComponentAPI Base;
- // PadIsPresent
- // Called by the emulator to detect the availability of a pad. This function will
- // be called frequently -- essentially whenever the SIO port for the pad has its
- // status polled - so its overhead should be minimal when possible.
- //
- // A plugin should behave reasonably when a pad that's not plugged in is polled.
- //
- // Returns:
- // False if the card/pad is not available, or True if it is available.
- //
- BOOL (PS2E_CALLBACK* PadIsPresent)( PS2E_THISPTR thisptr, uint port, uint slot );
+ // PadIsPresent
+ // Called by the emulator to detect the availability of a pad. This function will
+ // be called frequently -- essentially whenever the SIO port for the pad has its
+ // status polled - so its overhead should be minimal when possible.
+ //
+ // A plugin should behave reasonably when a pad that's not plugged in is polled.
+ //
+ // Returns:
+ // False if the card/pad is not available, or True if it is available.
+ //
+ BOOL(PS2E_CALLBACK *PadIsPresent)
+ (PS2E_THISPTR thisptr, uint port, uint slot);
- // PadStartPoll
- // Called by the emulator to start polling the specified pad.
- //
- // Returns:
- // First byte in response to the poll (Typically 0xff).
- //
- // Threading:
- // Called from the EEcore thread. The emulator performs no locking of its own, so
- // calls to this may occur concurrently with calls to PadUpdate.
- //
- u8 (PS2E_CALLBACK* PadStartPoll)( PS2E_THISPTR thisptr, uint port, uint slot );
+ // PadStartPoll
+ // Called by the emulator to start polling the specified pad.
+ //
+ // Returns:
+ // First byte in response to the poll (Typically 0xff).
+ //
+ // Threading:
+ // Called from the EEcore thread. The emulator performs no locking of its own, so
+ // calls to this may occur concurrently with calls to PadUpdate.
+ //
+ u8(PS2E_CALLBACK *PadStartPoll)(PS2E_THISPTR thisptr, uint port, uint slot);
- // PadPoll
- // Continues polling the specified pad, sending the given value.
- //
- // Returns:
- // Next byte in response to the poll.
- //
- // Threading:
- // Called from the EEcore thread. The emulator performs no locking of its own, so
- // calls to this may occur concurrently with calls to PadUpdate.
- //
- u8 (PS2E_CALLBACK* PadPoll)( PS2E_THISPTR thisptr, u8 value );
+ // PadPoll
+ // Continues polling the specified pad, sending the given value.
+ //
+ // Returns:
+ // Next byte in response to the poll.
+ //
+ // Threading:
+ // Called from the EEcore thread. The emulator performs no locking of its own, so
+ // calls to this may occur concurrently with calls to PadUpdate.
+ //
+ u8(PS2E_CALLBACK *PadPoll)(PS2E_THISPTR thisptr, u8 value);
- // PadKeyEvent
- // Called by the emulator in the gui thread to check for keys being pressed or released.
- //
- // Returns:
- // PS2E_KeyEvent: Key being pressed or released. Should stay valid until next call to
- // PadKeyEvent or plugin is closed with EmuClose.
- //
- // Threading:
- // May be called from any thread. The emulator performs no locking of its own, so
- // calls to this may occur concurrently with calls to PadUpdate.
- //
- PS2E_KeyEvent* (PS2E_CALLBACK* PadGetKeyEvent)( PS2E_THISPTR thisptr );
+ // PadKeyEvent
+ // Called by the emulator in the gui thread to check for keys being pressed or released.
+ //
+ // Returns:
+ // PS2E_KeyEvent: Key being pressed or released. Should stay valid until next call to
+ // PadKeyEvent or plugin is closed with EmuClose.
+ //
+ // Threading:
+ // May be called from any thread. The emulator performs no locking of its own, so
+ // calls to this may occur concurrently with calls to PadUpdate.
+ //
+ PS2E_KeyEvent *(PS2E_CALLBACK *PadGetKeyEvent)(PS2E_THISPTR thisptr);
- // PadUpdate
- // This callback is issued from the thread that owns the GSwindow, at roughly 50/60hz,
- // allowing the Pad plugin to use it for update logic that expects thread affinity with
- // the GSwindow.
- //
- // Threading:
- // Called from the same thread that owns the GSwindow (typically either a GUI thread
- // or an MTGS thread). The emulator performs no locking of its own, so calls to this
- // may occur concurrently with calls to PadKeyEvent and PadPoll.
- //
- void (PS2E_CALLBACK* PadUpdate)( PS2E_THISPTR thisptr );
+ // PadUpdate
+ // This callback is issued from the thread that owns the GSwindow, at roughly 50/60hz,
+ // allowing the Pad plugin to use it for update logic that expects thread affinity with
+ // the GSwindow.
+ //
+ // Threading:
+ // Called from the same thread that owns the GSwindow (typically either a GUI thread
+ // or an MTGS thread). The emulator performs no locking of its own, so calls to this
+ // may occur concurrently with calls to PadKeyEvent and PadPoll.
+ //
+ void(PS2E_CALLBACK *PadUpdate)(PS2E_THISPTR thisptr);
- void* reserved[8];
+ void *reserved[8];
} PS2E_ComponentAPI_Pad;
@@ -1260,7 +1269,7 @@ typedef struct _PS2E_ComponentAPI_Pad
// * Affinity: Called only from the Main/GUI thread.
// * Interlocking: Full interlocking garaunteed.
//
-typedef const PS2E_LibraryAPI* (PS2E_CALLBACK* _PS2E_InitAPI)( const PS2E_EmulatorInfo* emuinfo );
+typedef const PS2E_LibraryAPI *(PS2E_CALLBACK *_PS2E_InitAPI)(const PS2E_EmulatorInfo *emuinfo);
// --------------------------------------------------------------------------------------
// PS2E_GetLastError
@@ -1277,7 +1286,7 @@ typedef const PS2E_LibraryAPI* (PS2E_CALLBACK* _PS2E_InitAPI)( const PS2E_Emulat
// msg_user - optional translated user message, which is displayed as a popup to explain
// to the user why the plugin failed to initialize.
//
-typedef void (PS2E_CALLBACK* _PS2E_GetLastError)( char* const* msg_diag, wchar_t* const* msg_user );
+typedef void(PS2E_CALLBACK *_PS2E_GetLastError)(char *const *msg_diag, wchar_t *const *msg_user);
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/common/include/Utilities/AppTrait.h b/common/include/Utilities/AppTrait.h
index 6ddce2658e..3816a9258a 100644
--- a/common/include/Utilities/AppTrait.h
+++ b/common/include/Utilities/AppTrait.h
@@ -27,14 +27,13 @@
//
class Pcsx2AppTraits : public wxGUIAppTraits
{
- typedef wxGUIAppTraits _parent;
+ typedef wxGUIAppTraits _parent;
public:
- virtual ~Pcsx2AppTraits() {}
- wxMessageOutput* CreateMessageOutput();
+ virtual ~Pcsx2AppTraits() {}
+ wxMessageOutput *CreateMessageOutput();
#ifdef wxUSE_STDPATHS
- wxStandardPaths& GetStandardPaths();
+ wxStandardPaths &GetStandardPaths();
#endif
};
-
diff --git a/common/include/Utilities/Assertions.h b/common/include/Utilities/Assertions.h
index 3bdefb7165..c35759c578 100644
--- a/common/include/Utilities/Assertions.h
+++ b/common/include/Utilities/Assertions.h
@@ -17,14 +17,14 @@
#ifndef __pxFUNCTION__
#if defined(__GNUG__)
-# define __pxFUNCTION__ __PRETTY_FUNCTION__
+#define __pxFUNCTION__ __PRETTY_FUNCTION__
#else
-# define __pxFUNCTION__ __FUNCTION__
+#define __pxFUNCTION__ __FUNCTION__
#endif
#endif
#ifndef wxNullChar
-# define wxNullChar ((wxChar*)NULL)
+#define wxNullChar ((wxChar *)NULL)
#endif
// FnChar_t - function name char type; typedef'd in case it ever changes between compilers
@@ -36,29 +36,29 @@ typedef char FnChar_t;
// --------------------------------------------------------------------------------------
struct DiagnosticOrigin
{
- const wxChar* srcfile;
- const FnChar_t* function;
- const wxChar* condition;
- int line;
+ const wxChar *srcfile;
+ const FnChar_t *function;
+ const wxChar *condition;
+ int line;
- DiagnosticOrigin( const wxChar *_file, int _line, const FnChar_t *_func, const wxChar* _cond = NULL )
- : srcfile( _file )
- , function( _func )
- , condition( _cond )
- , line( _line )
- {
- }
+ DiagnosticOrigin(const wxChar *_file, int _line, const FnChar_t *_func, const wxChar *_cond = NULL)
+ : srcfile(_file)
+ , function(_func)
+ , condition(_cond)
+ , line(_line)
+ {
+ }
- wxString ToString( const wxChar* msg=NULL ) const;
+ wxString ToString(const wxChar *msg = NULL) const;
};
// Returns ture if the assertion is to trap into the debugger, or false if execution
// of the program should continue unimpeded.
-typedef bool pxDoAssertFnType(const DiagnosticOrigin& origin, const wxChar *msg);
+typedef bool pxDoAssertFnType(const DiagnosticOrigin &origin, const wxChar *msg);
extern pxDoAssertFnType pxAssertImpl_LogIt;
-extern pxDoAssertFnType* pxDoAssert;
+extern pxDoAssertFnType *pxDoAssert;
// ----------------------------------------------------------------------------------------
// pxAssert / pxAssertDev
@@ -97,95 +97,99 @@ extern pxDoAssertFnType* pxDoAssert;
// it can lead to the compiler optimizing out code and leading to crashes in dev/release
// builds. To have code optimized, explicitly use pxAssume(false) or pxAssumeDev(false,msg);
-#define pxDiagSpot DiagnosticOrigin( __TFILE__, __LINE__, __pxFUNCTION__ )
-#define pxAssertSpot(cond) DiagnosticOrigin( __TFILE__, __LINE__, __pxFUNCTION__, _T(#cond) )
+#define pxDiagSpot DiagnosticOrigin(__TFILE__, __LINE__, __pxFUNCTION__)
+#define pxAssertSpot(cond) DiagnosticOrigin(__TFILE__, __LINE__, __pxFUNCTION__, _T(#cond))
// pxAssertRel ->
// Special release-mode assertion. Limited use since stack traces in release mode builds
// (especially with LTCG) are highly suspect. But when troubleshooting crashes that only
// rear ugly heads in optimized builds, this is one of the few tools we have.
-#define pxAssertRel(cond, msg) ( (likely(cond)) || (pxOnAssert(pxAssertSpot(cond), msg), false) )
-#define pxAssumeRel(cond, msg) ((void) ( (!likely(cond)) && (pxOnAssert(pxAssertSpot(cond), msg), false) ))
-#define pxFailRel(msg) pxAssertRel(false, msg)
+#define pxAssertRel(cond, msg) ((likely(cond)) || (pxOnAssert(pxAssertSpot(cond), msg), false))
+#define pxAssumeRel(cond, msg) ((void)((!likely(cond)) && (pxOnAssert(pxAssertSpot(cond), msg), false)))
+#define pxFailRel(msg) pxAssertRel(false, msg)
#if defined(PCSX2_DEBUG)
-# define pxAssertMsg(cond, msg) pxAssertRel(cond, msg)
-# define pxAssertDev(cond, msg) pxAssertMsg(cond, msg)
+#define pxAssertMsg(cond, msg) pxAssertRel(cond, msg)
+#define pxAssertDev(cond, msg) pxAssertMsg(cond, msg)
-# define pxAssumeMsg(cond, msg) pxAssumeRel(cond, msg)
-# define pxAssumeDev(cond, msg) pxAssumeRel(cond, msg)
+#define pxAssumeMsg(cond, msg) pxAssumeRel(cond, msg)
+#define pxAssumeDev(cond, msg) pxAssumeRel(cond, msg)
-# define pxFail(msg) pxAssertMsg(false, msg)
-# define pxFailDev(msg) pxAssertDev(false, msg)
+#define pxFail(msg) pxAssertMsg(false, msg)
+#define pxFailDev(msg) pxAssertDev(false, msg)
#elif defined(PCSX2_DEVBUILD)
- // Devel builds now will give you a release-mode assertion dialog window if any of the
- // following macro's 'cond' field is false.
- // Note: Only use pxAssume/Msg/Dev if you know what you're doing, __assume is supposed
- // to be used as an optimization hint, yet many devs have been using psAssume
- // thinking its the same as an assertion.
- // __assume(0) is also very dangerous because it is a special case of __assume() which
- // tells the compiler that the code path is not reachable, and it can cause unpredictable
- // results if the code path can be reached.
- // i.e. if (1) { __assume(0); something(); }
- // In the above example, something() may never be called.
- // __assume(0)'s real use is in optimizing stuff such as "default:" cases on a switch
- // statement. See jNO_DEFAULT
+// Devel builds now will give you a release-mode assertion dialog window if any of the
+// following macro's 'cond' field is false.
+// Note: Only use pxAssume/Msg/Dev if you know what you're doing, __assume is supposed
+// to be used as an optimization hint, yet many devs have been using psAssume
+// thinking its the same as an assertion.
+// __assume(0) is also very dangerous because it is a special case of __assume() which
+// tells the compiler that the code path is not reachable, and it can cause unpredictable
+// results if the code path can be reached.
+// i.e. if (1) { __assume(0); something(); }
+// In the above example, something() may never be called.
+// __assume(0)'s real use is in optimizing stuff such as "default:" cases on a switch
+// statement. See jNO_DEFAULT
-# define pxAssertMsg(cond, msg) pxAssertRel(cond, msg)
-# define pxAssertDev(cond, msg) pxAssertRel(cond, msg)
+#define pxAssertMsg(cond, msg) pxAssertRel(cond, msg)
+#define pxAssertDev(cond, msg) pxAssertRel(cond, msg)
-# define pxAssumeMsg(cond, msg) pxAssumeRel(cond, msg) //(__assume(cond))
-# define pxAssumeDev(cond, msg) pxAssumeRel(cond, msg)
+#define pxAssumeMsg(cond, msg) pxAssumeRel(cond, msg) //(__assume(cond))
+#define pxAssumeDev(cond, msg) pxAssumeRel(cond, msg)
-# define pxFail(msg) pxAssertDev(false, msg)
-# define pxFailDev(msg) pxAssertDev(false, msg)
+#define pxFail(msg) pxAssertDev(false, msg)
+#define pxFailDev(msg) pxAssertDev(false, msg)
#else
- // Release Builds just use __assume as an optimization, and return the conditional
- // as a result (which is optimized to nil if unused).
+// Release Builds just use __assume as an optimization, and return the conditional
+// as a result (which is optimized to nil if unused).
-# define pxAssertMsg(cond, msg) (likely(cond))
-# define pxAssertDev(cond, msg) (likely(cond))
+#define pxAssertMsg(cond, msg) (likely(cond))
+#define pxAssertDev(cond, msg) (likely(cond))
-# define pxAssumeMsg(cond, msg) (__assume(cond))
-# define pxAssumeDev(cond, msg) (__assume(cond))
+#define pxAssumeMsg(cond, msg) (__assume(cond))
+#define pxAssumeDev(cond, msg) (__assume(cond))
-# define pxFail(msg) do{} while(0)
-# define pxFailDev(msg) do{} while(0)
+#define pxFail(msg) \
+ do { \
+ } while (0)
+#define pxFailDev(msg) \
+ do { \
+ } while (0)
#endif
-#define pxAssert(cond) pxAssertMsg(cond, wxNullChar)
-#define pxAssume(cond) pxAssumeMsg(cond, wxNullChar)
+#define pxAssert(cond) pxAssertMsg(cond, wxNullChar)
+#define pxAssume(cond) pxAssumeMsg(cond, wxNullChar)
-#define pxAssertRelease( cond, msg )
+#define pxAssertRelease(cond, msg)
// Performs an unsigned index bounds check, and generates a debug assertion if the check fails.
// For stricter checking in Devel builds as well as debug builds (but possibly slower), use
// IndexBoundsCheckDev.
-#define IndexBoundsCheck( objname, idx, sze ) pxAssertMsg( (uint)(idx) < (uint)(sze), \
- pxsFmt( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) )
+#define IndexBoundsCheck(objname, idx, sze) pxAssertMsg((uint)(idx) < (uint)(sze), \
+ pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze)))
-#define IndexBoundsCheckDev( objname, idx, sze ) pxAssertDev( (uint)(idx) < (uint)(sze), \
- pxsFmt( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) )
+#define IndexBoundsCheckDev(objname, idx, sze) pxAssertDev((uint)(idx) < (uint)(sze), \
+ pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze)))
-#define IndexBoundsAssume( objname, idx, sze ) pxAssumeMsg( (uint)(idx) < (uint)(sze), \
- pxsFmt( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) )
+#define IndexBoundsAssume(objname, idx, sze) pxAssumeMsg((uint)(idx) < (uint)(sze), \
+ pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze)))
-#define IndexBoundsAssumeDev( objname, idx, sze ) pxAssumeDev( (uint)(idx) < (uint)(sze), \
- pxsFmt( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) )
+#define IndexBoundsAssumeDev(objname, idx, sze) pxAssumeDev((uint)(idx) < (uint)(sze), \
+ pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze)))
-extern void pxOnAssert( const DiagnosticOrigin& origin, const wxChar* msg=NULL );
-extern void pxOnAssert( const DiagnosticOrigin& origin, const char* msg );
-extern void pxOnAssert( const DiagnosticOrigin& origin, const wxString& msg);
-extern void pxOnAssert( const DiagnosticOrigin& origin, const FastFormatUnicode& msg);
+extern void pxOnAssert(const DiagnosticOrigin &origin, const wxChar *msg = NULL);
+extern void pxOnAssert(const DiagnosticOrigin &origin, const char *msg);
+extern void pxOnAssert(const DiagnosticOrigin &origin, const wxString &msg);
+extern void pxOnAssert(const DiagnosticOrigin &origin, const FastFormatUnicode &msg);
// --------------------------------------------------------------------------------------
// jNO_DEFAULT -- disables the default case in a switch, which improves switch optimization
@@ -198,10 +202,9 @@ extern void pxOnAssert( const DiagnosticOrigin& origin, const FastFormatUnicode&
// * In debug/devel builds the default case will cause an assertion.
//
#ifndef jNO_DEFAULT
-# define jNO_DEFAULT \
- default: \
- { \
- pxAssumeDev( 0, "Incorrect usage of jNO_DEFAULT detected (default case is not unreachable!)" ); \
- break; \
- }
+#define jNO_DEFAULT \
+ default: { \
+ pxAssumeDev(0, "Incorrect usage of jNO_DEFAULT detected (default case is not unreachable!)"); \
+ break; \
+ }
#endif
diff --git a/common/include/Utilities/CheckedStaticBox.h b/common/include/Utilities/CheckedStaticBox.h
index df846ec4c3..1ae9c453ad 100644
--- a/common/include/Utilities/CheckedStaticBox.h
+++ b/common/include/Utilities/CheckedStaticBox.h
@@ -19,19 +19,19 @@
class CheckedStaticBox : public wxPanelWithHelpers
{
- typedef wxPanelWithHelpers _parent;
+ typedef wxPanelWithHelpers _parent;
public:
- wxBoxSizer& ThisSizer; // Boxsizer which holds all child items.
- wxCheckBox& ThisToggle; // toggle which can enable/disable all child controls
+ wxBoxSizer &ThisSizer; // Boxsizer which holds all child items.
+ wxCheckBox &ThisToggle; // toggle which can enable/disable all child controls
public:
- CheckedStaticBox( wxWindow* parent, int orientation, const wxString& title=wxEmptyString );
+ CheckedStaticBox(wxWindow *parent, int orientation, const wxString &title = wxEmptyString);
+
+ void SetValue(bool val);
+ bool GetValue() const;
+ bool Enable(bool enable = true);
- void SetValue( bool val );
- bool GetValue() const;
- bool Enable( bool enable = true );
-
public:
- virtual void MainToggle_Click( wxCommandEvent& evt );
+ virtual void MainToggle_Click(wxCommandEvent &evt);
};
diff --git a/common/include/Utilities/Console.h b/common/include/Utilities/Console.h
index ca4b71b1fb..a87f825266 100644
--- a/common/include/Utilities/Console.h
+++ b/common/include/Utilities/Console.h
@@ -17,46 +17,45 @@
#include "StringHelpers.h"
-enum ConsoleColors
-{
- Color_Current = -1,
+enum ConsoleColors {
+ Color_Current = -1,
- Color_Default = 0,
+ Color_Default = 0,
- Color_Black,
- Color_Green,
- Color_Red,
- Color_Blue,
- Color_Magenta,
- Color_Orange,
- Color_Gray,
+ Color_Black,
+ Color_Green,
+ Color_Red,
+ Color_Blue,
+ Color_Magenta,
+ Color_Orange,
+ Color_Gray,
- Color_Cyan, // faint visibility, intended for logging PS2/IOP output
- Color_Yellow, // faint visibility, intended for logging PS2/IOP output
- Color_White, // faint visibility, intended for logging PS2/IOP output
+ Color_Cyan, // faint visibility, intended for logging PS2/IOP output
+ Color_Yellow, // faint visibility, intended for logging PS2/IOP output
+ Color_White, // faint visibility, intended for logging PS2/IOP output
- // Strong text *may* result in mis-aligned text in the console, depending on the
- // font and the platform, so use these with caution.
- Color_StrongBlack,
- Color_StrongRed, // intended for errors
- Color_StrongGreen, // intended for infrequent state information
- Color_StrongBlue, // intended for block headings
- Color_StrongMagenta,
- Color_StrongOrange, // intended for warnings
- Color_StrongGray,
+ // Strong text *may* result in mis-aligned text in the console, depending on the
+ // font and the platform, so use these with caution.
+ Color_StrongBlack,
+ Color_StrongRed, // intended for errors
+ Color_StrongGreen, // intended for infrequent state information
+ Color_StrongBlue, // intended for block headings
+ Color_StrongMagenta,
+ Color_StrongOrange, // intended for warnings
+ Color_StrongGray,
- Color_StrongCyan,
- Color_StrongYellow,
- Color_StrongWhite,
+ Color_StrongCyan,
+ Color_StrongYellow,
+ Color_StrongWhite,
- ConsoleColors_Count
+ ConsoleColors_Count
};
static const ConsoleColors DefaultConsoleColor = Color_Default;
// Use fastcall for the console; should be helpful in most cases
-#define __concall __fastcall
+#define __concall __fastcall
// ----------------------------------------------------------------------------------------
// IConsoleWriter -- For printing messages to the console.
@@ -71,60 +70,60 @@ static const ConsoleColors DefaultConsoleColor = Color_Default;
//
struct IConsoleWriter
{
- // A direct console write, without tabbing or newlines. Useful to devs who want to do quick
- // logging of various junk; but should *not* be used in production code due.
- void (__concall *WriteRaw)( const wxString& fmt );
+ // A direct console write, without tabbing or newlines. Useful to devs who want to do quick
+ // logging of various junk; but should *not* be used in production code due.
+ void(__concall *WriteRaw)(const wxString &fmt);
- // WriteLn implementation for internal use only. Bypasses tabbing, prefixing, and other
- // formatting.
- void (__concall *DoWriteLn)( const wxString& fmt );
+ // WriteLn implementation for internal use only. Bypasses tabbing, prefixing, and other
+ // formatting.
+ void(__concall *DoWriteLn)(const wxString &fmt);
- // SetColor implementation for internal use only.
- void (__concall *DoSetColor)( ConsoleColors color );
+ // SetColor implementation for internal use only.
+ void(__concall *DoSetColor)(ConsoleColors color);
- // Special implementation of DoWrite that's pretty much for MSVC use only.
- // All implementations should map to DoWrite, except Stdio which should map to Null.
- // (This avoids circular/recursive stdio output)
- void (__concall *DoWriteFromStdout)( const wxString& fmt );
+ // Special implementation of DoWrite that's pretty much for MSVC use only.
+ // All implementations should map to DoWrite, except Stdio which should map to Null.
+ // (This avoids circular/recursive stdio output)
+ void(__concall *DoWriteFromStdout)(const wxString &fmt);
- void (__concall *Newline)();
- void (__concall *SetTitle)( const wxString& title );
+ void(__concall *Newline)();
+ void(__concall *SetTitle)(const wxString &title);
- // internal value for indentation of individual lines. Use the Indent() member to invoke.
- int _imm_indentation;
+ // internal value for indentation of individual lines. Use the Indent() member to invoke.
+ int _imm_indentation;
- // For internal use only.
- wxString _addIndentation( const wxString& src, int glob_indent ) const;
+ // For internal use only.
+ wxString _addIndentation(const wxString &src, int glob_indent) const;
- // ----------------------------------------------------------------------------
- // Public members; call these to print stuff to console!
- //
- // All functions always return false. Return value is provided only so that we can easily
- // disable logs at compile time using the "0&&action" macro trick.
+ // ----------------------------------------------------------------------------
+ // Public members; call these to print stuff to console!
+ //
+ // All functions always return false. Return value is provided only so that we can easily
+ // disable logs at compile time using the "0&&action" macro trick.
- ConsoleColors GetColor() const;
- const IConsoleWriter& SetColor( ConsoleColors color ) const;
- const IConsoleWriter& ClearColor() const;
- const IConsoleWriter& SetIndent( int tabcount=1 ) const;
+ ConsoleColors GetColor() const;
+ const IConsoleWriter &SetColor(ConsoleColors color) const;
+ const IConsoleWriter &ClearColor() const;
+ const IConsoleWriter &SetIndent(int tabcount = 1) const;
- IConsoleWriter Indent( int tabcount=1 ) const;
+ IConsoleWriter Indent(int tabcount = 1) const;
- bool FormatV( const char* fmt, va_list args ) const;
- bool WriteLn( ConsoleColors color, const char* fmt, ... ) const;
- bool WriteLn( const char* fmt, ... ) const;
- bool Error( const char* fmt, ... ) const;
- bool Warning( const char* fmt, ... ) const;
+ bool FormatV(const char *fmt, va_list args) const;
+ bool WriteLn(ConsoleColors color, const char *fmt, ...) const;
+ bool WriteLn(const char *fmt, ...) const;
+ bool Error(const char *fmt, ...) const;
+ bool Warning(const char *fmt, ...) const;
- bool FormatV( const wxChar* fmt, va_list args ) const;
- bool WriteLn( ConsoleColors color, const wxChar* fmt, ... ) const;
- bool WriteLn( const wxChar* fmt, ... ) const;
- bool Error( const wxChar* fmt, ... ) const;
- bool Warning( const wxChar* fmt, ... ) const;
+ bool FormatV(const wxChar *fmt, va_list args) const;
+ bool WriteLn(ConsoleColors color, const wxChar *fmt, ...) const;
+ bool WriteLn(const wxChar *fmt, ...) const;
+ bool Error(const wxChar *fmt, ...) const;
+ bool Warning(const wxChar *fmt, ...) const;
- bool WriteLn( ConsoleColors color, const wxString fmt, ... ) const;
- bool WriteLn( const wxString fmt, ... ) const;
- bool Error( const wxString fmt, ... ) const;
- bool Warning( const wxString fmt, ... ) const;
+ bool WriteLn(ConsoleColors color, const wxString fmt, ...) const;
+ bool WriteLn(const wxString fmt, ...) const;
+ bool Error(const wxString fmt, ...) const;
+ bool Warning(const wxString fmt, ...) const;
};
// --------------------------------------------------------------------------------------
@@ -134,37 +133,37 @@ struct IConsoleWriter
//
struct NullConsoleWriter
{
- void WriteRaw( const wxString& fmt ) {}
- void DoWriteLn( const wxString& fmt ) {}
- void DoSetColor( ConsoleColors color ) {}
- void DoWriteFromStdout( const wxString& fmt ) {}
- void Newline() {}
- void SetTitle( const wxString& title ) {}
+ void WriteRaw(const wxString &fmt) {}
+ void DoWriteLn(const wxString &fmt) {}
+ void DoSetColor(ConsoleColors color) {}
+ void DoWriteFromStdout(const wxString &fmt) {}
+ void Newline() {}
+ void SetTitle(const wxString &title) {}
- ConsoleColors GetColor() const { return Color_Current; }
- const NullConsoleWriter& SetColor( ConsoleColors color ) const { return *this; }
- const NullConsoleWriter& ClearColor() const { return *this; }
- const NullConsoleWriter& SetIndent( int tabcount=1 ) const { return *this; }
+ ConsoleColors GetColor() const { return Color_Current; }
+ const NullConsoleWriter &SetColor(ConsoleColors color) const { return *this; }
+ const NullConsoleWriter &ClearColor() const { return *this; }
+ const NullConsoleWriter &SetIndent(int tabcount = 1) const { return *this; }
- NullConsoleWriter Indent( int tabcount=1 ) const { return NullConsoleWriter(); }
+ NullConsoleWriter Indent(int tabcount = 1) const { return NullConsoleWriter(); }
- bool FormatV( const char* fmt, va_list args ) const { return false; }
- bool WriteLn( ConsoleColors color, const char* fmt, ... ) const { return false; }
- bool WriteLn( const char* fmt, ... ) const { return false; }
- bool Error( const char* fmt, ... ) const { return false; }
- bool Warning( const char* fmt, ... ) const { return false; }
+ bool FormatV(const char *fmt, va_list args) const { return false; }
+ bool WriteLn(ConsoleColors color, const char *fmt, ...) const { return false; }
+ bool WriteLn(const char *fmt, ...) const { return false; }
+ bool Error(const char *fmt, ...) const { return false; }
+ bool Warning(const char *fmt, ...) const { return false; }
- bool FormatV( const wxChar* fmt, va_list args ) const { return false; }
- bool WriteLn( ConsoleColors color, const wxChar* fmt, ... ) const { return false; }
- bool WriteLn( const wxChar* fmt, ... ) const { return false; }
- bool Error( const wxChar* fmt, ... ) const { return false; }
- bool Warning( const wxChar* fmt, ... ) const { return false; }
+ bool FormatV(const wxChar *fmt, va_list args) const { return false; }
+ bool WriteLn(ConsoleColors color, const wxChar *fmt, ...) const { return false; }
+ bool WriteLn(const wxChar *fmt, ...) const { return false; }
+ bool Error(const wxChar *fmt, ...) const { return false; }
+ bool Warning(const wxChar *fmt, ...) const { return false; }
- bool WriteLn( ConsoleColors color, const wxString fmt, ... ) const { return false; }
- bool WriteLn( const wxString fmt, ... ) const { return false; }
- bool Error( const wxString fmt, ... ) const { return false; }
- bool Warning( const wxString fmt, ... ) const { return false; }
+ bool WriteLn(ConsoleColors color, const wxString fmt, ...) const { return false; }
+ bool WriteLn(const wxString fmt, ...) const { return false; }
+ bool Error(const wxString fmt, ...) const { return false; }
+ bool Warning(const wxString fmt, ...) const { return false; }
};
// --------------------------------------------------------------------------------------
@@ -180,19 +179,19 @@ struct NullConsoleWriter
//
class ConsoleIndentScope
{
- DeclareNoncopyableObject( ConsoleIndentScope );
+ DeclareNoncopyableObject(ConsoleIndentScope);
protected:
- int m_amount;
- bool m_IsScoped;
+ int m_amount;
+ bool m_IsScoped;
public:
- // Constructor: The specified number of tabs will be appended to the current indentation
- // setting. The tabs will be unrolled when the object leaves scope or is destroyed.
- ConsoleIndentScope( int tabs=1 );
- virtual ~ConsoleIndentScope() throw();
- void EnterScope();
- void LeaveScope();
+ // Constructor: The specified number of tabs will be appended to the current indentation
+ // setting. The tabs will be unrolled when the object leaves scope or is destroyed.
+ ConsoleIndentScope(int tabs = 1);
+ virtual ~ConsoleIndentScope() throw();
+ void EnterScope();
+ void LeaveScope();
};
// --------------------------------------------------------------------------------------
@@ -200,18 +199,18 @@ public:
// --------------------------------------------------------------------------------------
class ConsoleColorScope
{
- DeclareNoncopyableObject( ConsoleColorScope );
+ DeclareNoncopyableObject(ConsoleColorScope);
protected:
- ConsoleColors m_newcolor;
- ConsoleColors m_old_color;
- bool m_IsScoped;
+ ConsoleColors m_newcolor;
+ ConsoleColors m_old_color;
+ bool m_IsScoped;
public:
- ConsoleColorScope( ConsoleColors newcolor );
- virtual ~ConsoleColorScope() throw();
- void EnterScope();
- void LeaveScope();
+ ConsoleColorScope(ConsoleColors newcolor);
+ virtual ~ConsoleColorScope() throw();
+ void EnterScope();
+ void LeaveScope();
};
// --------------------------------------------------------------------------------------
@@ -221,42 +220,42 @@ public:
//
class ConsoleAttrScope
{
- DeclareNoncopyableObject( ConsoleAttrScope );
+ DeclareNoncopyableObject(ConsoleAttrScope);
protected:
- ConsoleColors m_old_color;
- int m_tabsize;
+ ConsoleColors m_old_color;
+ int m_tabsize;
public:
- ConsoleAttrScope( ConsoleColors newcolor, int indent=0 );
- virtual ~ConsoleAttrScope() throw();
+ ConsoleAttrScope(ConsoleColors newcolor, int indent = 0);
+ virtual ~ConsoleAttrScope() throw();
};
-extern IConsoleWriter Console;
+extern IConsoleWriter Console;
#if defined(__unix__)
extern void Console_SetStdout(FILE *fp);
#endif
-extern void Console_SetActiveHandler( const IConsoleWriter& writer, FILE* flushfp=NULL );
+extern void Console_SetActiveHandler(const IConsoleWriter &writer, FILE *flushfp = NULL);
-extern const IConsoleWriter ConsoleWriter_Null;
-extern const IConsoleWriter ConsoleWriter_Stdout;
-extern const IConsoleWriter ConsoleWriter_Assert;
+extern const IConsoleWriter ConsoleWriter_Null;
+extern const IConsoleWriter ConsoleWriter_Stdout;
+extern const IConsoleWriter ConsoleWriter_Assert;
-extern NullConsoleWriter NullCon;
+extern NullConsoleWriter NullCon;
-extern IConsoleWriter DevConWriter;
-extern bool DevConWriterEnabled;
+extern IConsoleWriter DevConWriter;
+extern bool DevConWriterEnabled;
#ifdef PCSX2_DEVBUILD
-# define DevCon DevConWriter
+#define DevCon DevConWriter
#else
-# define DevCon DevConWriterEnabled && DevConWriter
+#define DevCon DevConWriterEnabled &&DevConWriter
#endif
#ifdef PCSX2_DEBUG
-extern IConsoleWriter DbgConWriter;
-# define DbgCon DbgConWriter
+extern IConsoleWriter DbgConWriter;
+#define DbgCon DbgConWriter
#else
-# define DbgCon 0&&NullCon
+#define DbgCon 0 && NullCon
#endif
diff --git a/common/include/Utilities/Dependencies.h b/common/include/Utilities/Dependencies.h
index 2ef212067c..714a7f8c0d 100644
--- a/common/include/Utilities/Dependencies.h
+++ b/common/include/Utilities/Dependencies.h
@@ -24,19 +24,19 @@
#define wxsFormat wxString::Format
#ifdef PCSX2_DEBUG
-# define tryDEBUG try
-# define catchDEBUG(clause) catch(clause)
+#define tryDEBUG try
+#define catchDEBUG(clause) catch (clause)
#else
-# define tryDEBUG if(true)
-# define catchDEBUG(clause) if(false)
+#define tryDEBUG if (true)
+#define catchDEBUG(clause) if (false)
#endif
#if defined(PCSX2_DEVBUILD) || defined(PCSX2_DEBUG)
-# define tryDEVEL try
-# define catchDEVEL catch(clause)
+#define tryDEVEL try
+#define catchDEVEL catch (clause)
#else
-# define tryDEBUG if(true)
-# define catchDEBUG(clause) if(false)
+#define tryDEBUG if (true)
+#define catchDEBUG(clause) if (false)
#endif
// --------------------------------------------------------------------------------------
@@ -61,24 +61,48 @@
// method is not implemented! You must implement it yourself if you want to use it:
// EnumToString(value);
//
-#define ImplementEnumOperators( enumName ) \
- static __fi enumName& operator++ ( enumName& src ) { src = (enumName)((int)src+1); return src; } \
- static __fi enumName& operator-- ( enumName& src ) { src = (enumName)((int)src-1); return src; } \
- static __fi enumName operator++ ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src+1); return orig; } \
- static __fi enumName operator-- ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src-1); return orig; } \
- \
- static __fi bool operator< ( const enumName& left, const pxEnumEnd_t& ) { return (int)left < enumName##_COUNT; } \
- static __fi bool operator!=( const enumName& left, const pxEnumEnd_t& ) { return (int)left != enumName##_COUNT; } \
- static __fi bool operator==( const enumName& left, const pxEnumEnd_t& ) { return (int)left == enumName##_COUNT; } \
- \
- static __fi bool EnumIsValid( enumName id ) { \
- return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); } \
- static __fi void EnumAssert( enumName id ) { \
- pxAssert( EnumIsValid(id) ); } \
- \
- extern const wxChar* EnumToString( enumName id )
+#define ImplementEnumOperators(enumName) \
+ static __fi enumName &operator++(enumName &src) \
+ { \
+ src = (enumName)((int)src + 1); \
+ return src; \
+ } \
+ static __fi enumName &operator--(enumName &src) \
+ { \
+ src = (enumName)((int)src - 1); \
+ return src; \
+ } \
+ static __fi enumName operator++(enumName &src, int) \
+ { \
+ enumName orig = src; \
+ src = (enumName)((int)src + 1); \
+ return orig; \
+ } \
+ static __fi enumName operator--(enumName &src, int) \
+ { \
+ enumName orig = src; \
+ src = (enumName)((int)src - 1); \
+ return orig; \
+ } \
+ \
+ static __fi bool operator<(const enumName &left, const pxEnumEnd_t &) { return (int)left < enumName##_COUNT; } \
+ static __fi bool operator!=(const enumName &left, const pxEnumEnd_t &) { return (int)left != enumName##_COUNT; } \
+ static __fi bool operator==(const enumName &left, const pxEnumEnd_t &) { return (int)left == enumName##_COUNT; } \
+ \
+ static __fi bool EnumIsValid(enumName id) \
+ { \
+ return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); \
+ } \
+ static __fi void EnumAssert(enumName id) \
+ { \
+ pxAssert(EnumIsValid(id)); \
+ } \
+ \
+ extern const wxChar *EnumToString(enumName id)
-class pxEnumEnd_t { };
+class pxEnumEnd_t
+{
+};
static const pxEnumEnd_t pxEnumEnd = {};
// --------------------------------------------------------------------------------------
@@ -105,10 +129,10 @@ static const pxEnumEnd_t pxEnumEnd = {};
// of wx dependencies though, and has a nicer typeset. :)
//
#ifndef DeclareNoncopyableObject
-# define DeclareNoncopyableObject(classname) \
- private: \
- explicit classname(const classname&); \
- classname& operator=(const classname&)
+#define DeclareNoncopyableObject(classname) \
+private: \
+ explicit classname(const classname &); \
+ classname &operator=(const classname &)
#endif
@@ -120,19 +144,19 @@ static const pxEnumEnd_t pxEnumEnd = {};
class ScopedBool
{
protected:
- bool* m_boolme;
+ bool *m_boolme;
public:
- ScopedBool(bool& boolme)
- {
- boolme = true;
- m_boolme = &boolme;
- }
+ ScopedBool(bool &boolme)
+ {
+ boolme = true;
+ m_boolme = &boolme;
+ }
- ~ScopedBool() throw()
- {
- *m_boolme = false;
- }
+ ~ScopedBool() throw()
+ {
+ *m_boolme = false;
+ }
};
// --------------------------------------------------------------------------------------
@@ -149,15 +173,15 @@ public:
#define WXINTL_NO_GETTEXT_MACRO
#ifndef _
-# define _(s) pxGetTranslation(_T(s))
+#define _(s) pxGetTranslation(_T(s))
#endif
#ifndef _t
-# define _t(s) pxGetTranslation(_T(s))
+#define _t(s) pxGetTranslation(_T(s))
#endif
#ifndef _d
-# define _d(s) pxGetTranslation(_T(s))
+#define _d(s) pxGetTranslation(_T(s))
#endif
// pxL / pxLt / pxDt -- macros provided for tagging translation strings, without actually running
@@ -167,15 +191,15 @@ public:
// debug/devel specific translations.
//
#ifndef pxL
-# define pxL(a) wxT(a)
+#define pxL(a) wxT(a)
#endif
#ifndef pxLt
-# define pxLt(a) wxT(a)
+#define pxLt(a) wxT(a)
#endif
#ifndef pxDt
-# define pxDt(a) wxT(a)
+#define pxDt(a) wxT(a)
#endif
@@ -193,8 +217,8 @@ public:
#endif
#include
-#include // string.h under c++
-#include // stdio.h under c++
+#include // string.h under c++
+#include // stdio.h under c++
#include
#include
#include
@@ -207,42 +231,42 @@ public:
// --------------------------------------------------------------------------------------
// Handy Human-readable constants for common immediate values (_16kb -> _4gb)
-static const sptr _1kb = 1024 * 1;
-static const sptr _4kb = _1kb * 4;
-static const sptr _16kb = _1kb * 16;
-static const sptr _32kb = _1kb * 32;
-static const sptr _64kb = _1kb * 64;
-static const sptr _128kb = _1kb * 128;
-static const sptr _256kb = _1kb * 256;
+static const sptr _1kb = 1024 * 1;
+static const sptr _4kb = _1kb * 4;
+static const sptr _16kb = _1kb * 16;
+static const sptr _32kb = _1kb * 32;
+static const sptr _64kb = _1kb * 64;
+static const sptr _128kb = _1kb * 128;
+static const sptr _256kb = _1kb * 256;
-static const s64 _1mb = 1024 * 1024;
-static const s64 _8mb = _1mb * 8;
-static const s64 _16mb = _1mb * 16;
-static const s64 _32mb = _1mb * 32;
-static const s64 _64mb = _1mb * 64;
-static const s64 _256mb = _1mb * 256;
-static const s64 _1gb = _1mb * 1024;
-static const s64 _4gb = _1gb * 4;
+static const s64 _1mb = 1024 * 1024;
+static const s64 _8mb = _1mb * 8;
+static const s64 _16mb = _1mb * 16;
+static const s64 _32mb = _1mb * 32;
+static const s64 _64mb = _1mb * 64;
+static const s64 _256mb = _1mb * 256;
+static const s64 _1gb = _1mb * 1024;
+static const s64 _4gb = _1gb * 4;
// --------------------------------------------------------------------------------------
// pxE(msg) and pxEt(msg) [macros] => now same as _/_t/_d
// --------------------------------------------------------------------------------------
-#define pxE(english) pxExpandMsg( (english) )
+#define pxE(english) pxExpandMsg((english))
// For use with tertiary translations (low priority).
-#define pxEt(english) pxExpandMsg( (english) )
+#define pxEt(english) pxExpandMsg((english))
// For use with Dev/debug build translations (low priority).
-#define pxE_dev(english) pxExpandMsg( (english) )
+#define pxE_dev(english) pxExpandMsg((english))
-extern const wxChar* __fastcall pxExpandMsg( const wxChar* englishContent );
-extern const wxChar* __fastcall pxGetTranslation( const wxChar* message );
-extern bool pxIsEnglish( int id );
+extern const wxChar *__fastcall pxExpandMsg(const wxChar *englishContent);
+extern const wxChar *__fastcall pxGetTranslation(const wxChar *message);
+extern bool pxIsEnglish(int id);
-extern wxString fromUTF8( const char* src );
-extern wxString fromAscii( const char* src );
+extern wxString fromUTF8(const char *src);
+extern wxString fromAscii(const char *src);
#include "Utilities/Assertions.h"
diff --git a/common/include/Utilities/EmbeddedImage.h b/common/include/Utilities/EmbeddedImage.h
index 91051ecd08..488efa6a9c 100644
--- a/common/include/Utilities/EmbeddedImage.h
+++ b/common/include/Utilities/EmbeddedImage.h
@@ -25,8 +25,8 @@
class IEmbeddedImage
{
public:
- virtual const wxImage& Get()=0;
- virtual wxImage Scale( int width, int height )=0;
+ virtual const wxImage &Get() = 0;
+ virtual wxImage Scale(int width, int height) = 0;
};
//////////////////////////////////////////////////////////////////////////////////////////
@@ -38,85 +38,83 @@ public:
// Note: Get() only loads the image once. All subsequent calls to Get will use the
// previously loaded image data.
//
-template< typename ImageType >
+template
class EmbeddedImage : public IEmbeddedImage
{
protected:
- wxImage m_Image;
- const wxSize m_ResampleTo;
+ wxImage m_Image;
+ const wxSize m_ResampleTo;
protected:
- // ------------------------------------------------------------------------
- // Internal function used to ensure the image is loaded before returning the image
- // handle (called from all methods that return an image handle).
- //
- void _loadImage()
- {
- if( !m_Image.Ok() )
- {
- wxMemoryInputStream joe( ImageType::Data, ImageType::Length );
- m_Image.LoadFile( joe, ImageType::GetFormat() );
+ // ------------------------------------------------------------------------
+ // Internal function used to ensure the image is loaded before returning the image
+ // handle (called from all methods that return an image handle).
+ //
+ void _loadImage()
+ {
+ if (!m_Image.Ok()) {
+ wxMemoryInputStream joe(ImageType::Data, ImageType::Length);
+ m_Image.LoadFile(joe, ImageType::GetFormat());
- if( m_ResampleTo.IsFullySpecified() && ( m_ResampleTo.GetWidth() != m_Image.GetWidth() || m_ResampleTo.GetHeight() != m_Image.GetHeight() ) )
- m_Image.Rescale( m_ResampleTo.GetWidth(), m_ResampleTo.GetHeight(), wxIMAGE_QUALITY_HIGH );
- }
- }
+ if (m_ResampleTo.IsFullySpecified() && (m_ResampleTo.GetWidth() != m_Image.GetWidth() || m_ResampleTo.GetHeight() != m_Image.GetHeight()))
+ m_Image.Rescale(m_ResampleTo.GetWidth(), m_ResampleTo.GetHeight(), wxIMAGE_QUALITY_HIGH);
+ }
+ }
public:
- EmbeddedImage() :
- m_Image()
- , m_ResampleTo( wxDefaultSize )
- {
- }
+ EmbeddedImage()
+ : m_Image()
+ , m_ResampleTo(wxDefaultSize)
+ {
+ }
- // ------------------------------------------------------------------------
- // Constructor for creating an embedded image that gets resampled to the specified size when
- // loaded.
- //
- // Implementation Note: This function uses wxWidgets ResamplBox method to resize the image.
- // wxWidgets ResampleBicubic appears to be buggy and produces fairly poor results when down-
- // sampling images (basically resembles a pixel resize). ResampleBox produces much cleaner
- // results.
- //
- EmbeddedImage( int newWidth, int newHeight ) :
- m_Image()
- , m_ResampleTo( newWidth, newHeight )
- {
- }
+ // ------------------------------------------------------------------------
+ // Constructor for creating an embedded image that gets resampled to the specified size when
+ // loaded.
+ //
+ // Implementation Note: This function uses wxWidgets ResamplBox method to resize the image.
+ // wxWidgets ResampleBicubic appears to be buggy and produces fairly poor results when down-
+ // sampling images (basically resembles a pixel resize). ResampleBox produces much cleaner
+ // results.
+ //
+ EmbeddedImage(int newWidth, int newHeight)
+ : m_Image()
+ , m_ResampleTo(newWidth, newHeight)
+ {
+ }
- // ------------------------------------------------------------------------
- // Loads and retrieves the embedded image. The embedded image is only loaded from its em-
- // bedded format once. Any subsequent calls to Get(), Rescale(), or Resample() will use
- // the pre-loaded copy. Translation: the png/jpeg decoding overhead happens only once,
- // and only happens when the image is actually fetched. Simply creating an instance
- // of an EmbeddedImage object uses no excess memory nor cpu overhead. :)
- //
- const wxImage& Get()
- {
- _loadImage();
- return m_Image;
- }
+ // ------------------------------------------------------------------------
+ // Loads and retrieves the embedded image. The embedded image is only loaded from its em-
+ // bedded format once. Any subsequent calls to Get(), Rescale(), or Resample() will use
+ // the pre-loaded copy. Translation: the png/jpeg decoding overhead happens only once,
+ // and only happens when the image is actually fetched. Simply creating an instance
+ // of an EmbeddedImage object uses no excess memory nor cpu overhead. :)
+ //
+ const wxImage &Get()
+ {
+ _loadImage();
+ return m_Image;
+ }
- wxIcon GetIcon()
- {
- wxIcon retval;
- retval.CopyFromBitmap( Get() );
- return retval;
- }
+ wxIcon GetIcon()
+ {
+ wxIcon retval;
+ retval.CopyFromBitmap(Get());
+ return retval;
+ }
- // ------------------------------------------------------------------------
- // Performs a pixel resize of the loaded image and returns a new image handle (EmbeddedImage
- // is left unmodified).
- //
+ // ------------------------------------------------------------------------
+ // Performs a pixel resize of the loaded image and returns a new image handle (EmbeddedImage
+ // is left unmodified).
+ //
- wxImage Scale( int width, int height )
- {
- _loadImage();
- // Not strictly necessary - wxWidgets does the dimensions check anyway.
- if( width != m_Image.GetWidth() || height != m_Image.GetHeight() )
- return m_Image.Scale( width, height, wxIMAGE_QUALITY_HIGH );
- else
- return m_Image;
- }
+ wxImage Scale(int width, int height)
+ {
+ _loadImage();
+ // Not strictly necessary - wxWidgets does the dimensions check anyway.
+ if (width != m_Image.GetWidth() || height != m_Image.GetHeight())
+ return m_Image.Scale(width, height, wxIMAGE_QUALITY_HIGH);
+ else
+ return m_Image;
+ }
};
-
diff --git a/common/include/Utilities/EventSource.h b/common/include/Utilities/EventSource.h
index a61ceeb702..98b1d02797 100644
--- a/common/include/Utilities/EventSource.h
+++ b/common/include/Utilities/EventSource.h
@@ -22,56 +22,58 @@
// EventSource< template EvtType >
// --------------------------------------------------------------------------------------
-template< typename ListenerType >
+template
class EventSource
{
public:
- typedef typename ListenerType::EvtParams EvtParams;
- typedef typename std::list< ListenerType* > ListenerList;
- typedef typename ListenerList::iterator ListenerIterator;
+ typedef typename ListenerType::EvtParams EvtParams;
+ typedef typename std::list ListenerList;
+ typedef typename ListenerList::iterator ListenerIterator;
protected:
- typedef typename ListenerList::const_iterator ConstIterator;
+ typedef typename ListenerList::const_iterator ConstIterator;
- ListenerList m_listeners;
+ ListenerList m_listeners;
- // This is a cached copy of the listener list used to handle standard dispatching, which
- // allows for self-modification of the EventSource's listener list by the listeners.
- // Translation: The dispatcher uses this copy instead, to avoid iterator invalidation.
- ListenerList m_cache_copy;
- bool m_cache_valid;
+ // This is a cached copy of the listener list used to handle standard dispatching, which
+ // allows for self-modification of the EventSource's listener list by the listeners.
+ // Translation: The dispatcher uses this copy instead, to avoid iterator invalidation.
+ ListenerList m_cache_copy;
+ bool m_cache_valid;
- Threading::Mutex m_listeners_lock;
+ Threading::Mutex m_listeners_lock;
public:
- EventSource()
- {
- m_cache_valid = false;
- }
+ EventSource()
+ {
+ m_cache_valid = false;
+ }
- virtual ~EventSource() throw() {}
+ virtual ~EventSource() throw() {}
- virtual ListenerIterator Add( ListenerType& listener );
- virtual void Remove( ListenerType& listener );
- virtual void Remove( const ListenerIterator& listenerHandle );
+ virtual ListenerIterator Add(ListenerType &listener);
+ virtual void Remove(ListenerType &listener);
+ virtual void Remove(const ListenerIterator &listenerHandle);
- void Add( ListenerType* listener )
- {
- if( listener == NULL ) return;
- Add( *listener );
- }
+ void Add(ListenerType *listener)
+ {
+ if (listener == NULL)
+ return;
+ Add(*listener);
+ }
- void Remove( ListenerType* listener )
- {
- if( listener == NULL ) return;
- Remove( *listener );
- }
+ void Remove(ListenerType *listener)
+ {
+ if (listener == NULL)
+ return;
+ Remove(*listener);
+ }
- void Dispatch( const EvtParams& params );
+ void Dispatch(const EvtParams ¶ms);
protected:
- virtual ListenerIterator _AddFast_without_lock( ListenerType& listener );
- virtual void _DispatchRaw( ListenerIterator iter, const ListenerIterator& iend, const EvtParams& params );
+ virtual ListenerIterator _AddFast_without_lock(ListenerType &listener);
+ virtual void _DispatchRaw(ListenerIterator iter, const ListenerIterator &iend, const EvtParams ¶ms);
};
// --------------------------------------------------------------------------------------
@@ -80,13 +82,13 @@ protected:
// This class is used as a base interface for EventListeners. It allows the listeners to do
// customized dispatching of several event types into "user friendly" function overrides.
//
-template< typename EvtParams >
+template
class IEventDispatcher
{
protected:
- IEventDispatcher() {}
+ IEventDispatcher() {}
public:
- virtual ~IEventDispatcher() throw() {}
- virtual void DispatchEvent( const EvtParams& params )=0;
+ virtual ~IEventDispatcher() throw() {}
+ virtual void DispatchEvent(const EvtParams ¶ms) = 0;
};
diff --git a/common/include/Utilities/EventSource.inl b/common/include/Utilities/EventSource.inl
index 7cee20b57a..80636684cc 100644
--- a/common/include/Utilities/EventSource.inl
+++ b/common/include/Utilities/EventSource.inl
@@ -19,88 +19,80 @@
using Threading::ScopedLock;
-template< typename ListenerType >
-typename EventSource::ListenerIterator EventSource::Add( ListenerType& listener )
+template
+typename EventSource::ListenerIterator EventSource::Add(ListenerType &listener)
{
- ScopedLock locker( m_listeners_lock );
+ ScopedLock locker(m_listeners_lock);
- // Check for duplicates before adding the event.
- if( IsDebugBuild )
- {
- ListenerIterator iter = m_listeners.begin();
- while( iter != m_listeners.end() )
- {
- if( (*iter) == &listener ) return iter;
- ++iter;
- }
- }
- return _AddFast_without_lock( listener );
+ // Check for duplicates before adding the event.
+ if (IsDebugBuild) {
+ ListenerIterator iter = m_listeners.begin();
+ while (iter != m_listeners.end()) {
+ if ((*iter) == &listener)
+ return iter;
+ ++iter;
+ }
+ }
+ return _AddFast_without_lock(listener);
}
-template< typename ListenerType >
-void EventSource::Remove( ListenerType& listener )
+template
+void EventSource::Remove(ListenerType &listener)
{
- ScopedLock locker( m_listeners_lock );
- m_cache_valid = false;
- m_listeners.remove( &listener );
+ ScopedLock locker(m_listeners_lock);
+ m_cache_valid = false;
+ m_listeners.remove(&listener);
}
-template< typename ListenerType >
-void EventSource::Remove( const ListenerIterator& listenerHandle )
+template
+void EventSource::Remove(const ListenerIterator &listenerHandle)
{
- ScopedLock locker( m_listeners_lock );
- m_cache_valid = false;
- m_listeners.erase( listenerHandle );
+ ScopedLock locker(m_listeners_lock);
+ m_cache_valid = false;
+ m_listeners.erase(listenerHandle);
}
-template< typename ListenerType >
-typename EventSource::ListenerIterator EventSource::_AddFast_without_lock( ListenerType& listener )
+template
+typename EventSource::ListenerIterator EventSource::_AddFast_without_lock(ListenerType &listener)
{
- m_cache_valid = false;
- m_listeners.push_front( &listener );
- return m_listeners.begin();
+ m_cache_valid = false;
+ m_listeners.push_front(&listener);
+ return m_listeners.begin();
}
-template< typename ListenerType >
-__fi void EventSource::_DispatchRaw( ListenerIterator iter, const ListenerIterator& iend, const EvtParams& evtparams )
+template
+__fi void EventSource::_DispatchRaw(ListenerIterator iter, const ListenerIterator &iend, const EvtParams &evtparams)
{
- while( iter != iend )
- {
- try {
- (*iter)->DispatchEvent( evtparams );
- }
- catch( Exception::RuntimeError& ex )
- {
- if( IsDevBuild ) {
- pxFailDev( L"Ignoring runtime error thrown from event listener (event listeners should not throw exceptions!): " + ex.FormatDiagnosticMessage() );
- }
- else {
- Console.Error( L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage() );
- }
- }
- catch( BaseException& ex )
- {
- if( IsDevBuild )
- {
- ex.DiagMsg() = L"Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg();
- throw;
- }
- Console.Error( L"Ignoring non-runtime BaseException thrown from event listener: " + ex.FormatDiagnosticMessage() );
- }
- ++iter;
- }
+ while (iter != iend) {
+ try {
+ (*iter)->DispatchEvent(evtparams);
+ } catch (Exception::RuntimeError &ex) {
+ if (IsDevBuild) {
+ pxFailDev(L"Ignoring runtime error thrown from event listener (event listeners should not throw exceptions!): " + ex.FormatDiagnosticMessage());
+ } else {
+ Console.Error(L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage());
+ }
+ } catch (BaseException &ex) {
+ if (IsDevBuild) {
+ ex.DiagMsg() = L"Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg();
+ throw;
+ }
+ Console.Error(L"Ignoring non-runtime BaseException thrown from event listener: " + ex.FormatDiagnosticMessage());
+ }
+ ++iter;
+ }
}
-template< typename ListenerType >
-void EventSource::Dispatch( const EvtParams& evtparams )
+template
+void EventSource::Dispatch(const EvtParams &evtparams)
{
- if( !m_cache_valid )
- {
- m_cache_copy = m_listeners;
- m_cache_valid = true;
- }
+ if (!m_cache_valid) {
+ m_cache_copy = m_listeners;
+ m_cache_valid = true;
+ }
- if( m_cache_copy.empty() ) return;
- _DispatchRaw( m_cache_copy.begin(), m_cache_copy.end(), evtparams );
+ if (m_cache_copy.empty())
+ return;
+ _DispatchRaw(m_cache_copy.begin(), m_cache_copy.end(), evtparams);
}
diff --git a/common/include/Utilities/Exceptions.h b/common/include/Utilities/Exceptions.h
index 9eb3b83a1a..05476615e0 100644
--- a/common/include/Utilities/Exceptions.h
+++ b/common/include/Utilities/Exceptions.h
@@ -30,112 +30,113 @@ void pxTrap();
// friendly error log in their wake.
//
// Note: Console can also fire an Exception::OutOfMemory
-#define __DESTRUCTOR_CATCHALL( funcname ) \
- catch( BaseException& ex ) \
- { \
- try { \
- Console.Error( "Unhandled BaseException in %s (ignored!):", funcname ); \
- Console.Error( ex.FormatDiagnosticMessage() ); \
- } catch (...) { \
- fprintf(stderr, "ERROR: (out of memory?)\n"); \
- } \
- } \
- catch( std::exception& ex ) \
- { \
- try { \
- Console.Error( "Unhandled std::exception in %s (ignored!):", funcname ); \
- Console.Error( ex.what() ); \
- } catch (...) { \
- fprintf(stderr, "ERROR: (out of memory?)\n"); \
- } \
- } \
- catch(...) { \
- /* Unreachable code */ \
- }
+#define __DESTRUCTOR_CATCHALL(funcname) \
+ catch (BaseException & ex) \
+ { \
+ try { \
+ Console.Error("Unhandled BaseException in %s (ignored!):", funcname); \
+ Console.Error(ex.FormatDiagnosticMessage()); \
+ } catch (...) { \
+ fprintf(stderr, "ERROR: (out of memory?)\n"); \
+ } \
+ } \
+ catch (std::exception & ex) \
+ { \
+ try { \
+ Console.Error("Unhandled std::exception in %s (ignored!):", funcname); \
+ Console.Error(ex.what()); \
+ } catch (...) { \
+ fprintf(stderr, "ERROR: (out of memory?)\n"); \
+ } \
+ } \
+ catch (...) \
+ { \
+ /* Unreachable code */ \
+ }
-#define DESTRUCTOR_CATCHALL __DESTRUCTOR_CATCHALL( __pxFUNCTION__ )
+#define DESTRUCTOR_CATCHALL __DESTRUCTOR_CATCHALL(__pxFUNCTION__)
namespace Exception
{
- int MakeNewType();
- BaseException* FromErrno( const wxString& streamname, int errcode );
+int MakeNewType();
+BaseException *FromErrno(const wxString &streamname, int errcode);
- // --------------------------------------------------------------------------------------
- // BaseException
- // --------------------------------------------------------------------------------------
- // std::exception sucks, and isn't entirely cross-platform reliable in its implementation,
- // so I made a replacement. The internal messages are non-const, which means that a
- // catch clause can optionally modify them and then re-throw to a top-level handler.
- //
- // Note, this class is "abstract" which means you shouldn't use it directly like, ever.
- // Use Exception::RuntimeError instead for generic exceptions.
- //
- // Because exceptions are the (only!) really useful example of multiple inheritance,
- // this class has only a trivial constructor, and must be manually initialized using
- // InitBaseEx() or by individual member assignments. This is because C++ multiple inheritence
- // is, by design, a lot of fail, especially when class initializers are mixed in.
- //
- // [TODO] : Add an InnerException component, and Clone() facility.
- //
- class BaseException
- {
- protected:
- wxString m_message_diag; // (untranslated) a "detailed" message of what disastrous thing has occurred!
- wxString m_message_user; // (translated) a "detailed" message of what disastrous thing has occurred!
+// --------------------------------------------------------------------------------------
+// BaseException
+// --------------------------------------------------------------------------------------
+// std::exception sucks, and isn't entirely cross-platform reliable in its implementation,
+// so I made a replacement. The internal messages are non-const, which means that a
+// catch clause can optionally modify them and then re-throw to a top-level handler.
+//
+// Note, this class is "abstract" which means you shouldn't use it directly like, ever.
+// Use Exception::RuntimeError instead for generic exceptions.
+//
+// Because exceptions are the (only!) really useful example of multiple inheritance,
+// this class has only a trivial constructor, and must be manually initialized using
+// InitBaseEx() or by individual member assignments. This is because C++ multiple inheritence
+// is, by design, a lot of fail, especially when class initializers are mixed in.
+//
+// [TODO] : Add an InnerException component, and Clone() facility.
+//
+class BaseException
+{
+protected:
+ wxString m_message_diag; // (untranslated) a "detailed" message of what disastrous thing has occurred!
+ wxString m_message_user; // (translated) a "detailed" message of what disastrous thing has occurred!
- public:
- virtual ~BaseException() throw()=0; // the =0; syntax forces this class into "abstract" mode.
+public:
+ virtual ~BaseException() throw() = 0; // the =0; syntax forces this class into "abstract" mode.
- const wxString& DiagMsg() const { return m_message_diag; }
- const wxString& UserMsg() const { return m_message_user; }
+ const wxString &DiagMsg() const { return m_message_diag; }
+ const wxString &UserMsg() const { return m_message_user; }
- wxString& DiagMsg() { return m_message_diag; }
- wxString& UserMsg() { return m_message_user; }
+ wxString &DiagMsg() { return m_message_diag; }
+ wxString &UserMsg() { return m_message_user; }
- BaseException& SetBothMsgs( const wxChar* msg_diag );
- BaseException& SetDiagMsg( const wxString& msg_diag );
- BaseException& SetUserMsg( const wxString& msg_user );
+ BaseException &SetBothMsgs(const wxChar *msg_diag);
+ BaseException &SetDiagMsg(const wxString &msg_diag);
+ BaseException &SetUserMsg(const wxString &msg_user);
- // Returns a message suitable for diagnostic / logging purposes.
- // This message is always in English, and includes a full stack trace.
- virtual wxString FormatDiagnosticMessage() const;
+ // Returns a message suitable for diagnostic / logging purposes.
+ // This message is always in English, and includes a full stack trace.
+ virtual wxString FormatDiagnosticMessage() const;
- // Returns a message suitable for end-user display.
- // This message is usually meant for display in a user popup or such.
- virtual wxString FormatDisplayMessage() const;
+ // Returns a message suitable for end-user display.
+ // This message is usually meant for display in a user popup or such.
+ virtual wxString FormatDisplayMessage() const;
- virtual void Rethrow() const=0;
- virtual BaseException* Clone() const=0;
- };
+ virtual void Rethrow() const = 0;
+ virtual BaseException *Clone() const = 0;
+};
- typedef std::unique_ptr ScopedExcept;
+typedef std::unique_ptr ScopedExcept;
- // --------------------------------------------------------------------------------------
- // Ps2Generic Exception
- // --------------------------------------------------------------------------------------
- // This class is used as a base exception for things tossed by PS2 cpus (EE, IOP, etc).
- //
- // Implementation note: does not derive from BaseException, so that we can use different
- // catch block hierarchies to handle them (if needed).
- //
- // Translation Note: Currently these exceptions are never translated. English/diagnostic
- // format only. :)
- //
- class Ps2Generic
- {
- protected:
- wxString m_message; // a "detailed" message of what disastrous thing has occurred!
+// --------------------------------------------------------------------------------------
+// Ps2Generic Exception
+// --------------------------------------------------------------------------------------
+// This class is used as a base exception for things tossed by PS2 cpus (EE, IOP, etc).
+//
+// Implementation note: does not derive from BaseException, so that we can use different
+// catch block hierarchies to handle them (if needed).
+//
+// Translation Note: Currently these exceptions are never translated. English/diagnostic
+// format only. :)
+//
+class Ps2Generic
+{
+protected:
+ wxString m_message; // a "detailed" message of what disastrous thing has occurred!
- public:
- virtual ~Ps2Generic() throw() {}
+public:
+ virtual ~Ps2Generic() throw() {}
- virtual u32 GetPc() const=0;
- virtual bool IsDelaySlot() const=0;
- virtual wxString& Message() { return m_message; }
+ virtual u32 GetPc() const = 0;
+ virtual bool IsDelaySlot() const = 0;
+ virtual wxString &Message() { return m_message; }
- virtual void Rethrow() const=0;
- virtual Ps2Generic* Clone() const=0;
- };
+ virtual void Rethrow() const = 0;
+ virtual Ps2Generic *Clone() const = 0;
+};
// Some helper macros for defining the standard constructors of internationalized constructors
// Parameters:
@@ -151,217 +152,239 @@ namespace Exception
//
// (update: web searches indicate it's MSVC specific -- happens in 2008, not sure about 2010).
//
-#define DEFINE_EXCEPTION_COPYTORS( classname, parent ) \
-private: \
- typedef parent _parent; \
-public: \
- virtual ~classname() throw() {} \
- virtual void Rethrow() const { throw *this; } \
- virtual classname* Clone() const { return new classname( *this ); }
+#define DEFINE_EXCEPTION_COPYTORS(classname, parent) \
+private: \
+ typedef parent _parent; \
+ \
+public: \
+ virtual ~classname() throw() {} \
+ virtual void Rethrow() const { throw * this; } \
+ virtual classname *Clone() const { return new classname(*this); }
-#define DEFINE_EXCEPTION_MESSAGES( classname ) \
-public: \
- classname& SetBothMsgs( const wxChar* msg_diag ) { BaseException::SetBothMsgs(msg_diag); return *this; } \
- classname& SetDiagMsg( const wxString& msg_diag ) { m_message_diag = msg_diag; return *this; } \
- classname& SetUserMsg( const wxString& msg_user ) { m_message_user = msg_user; return *this; }
+#define DEFINE_EXCEPTION_MESSAGES(classname) \
+public: \
+ classname &SetBothMsgs(const wxChar *msg_diag) \
+ { \
+ BaseException::SetBothMsgs(msg_diag); \
+ return *this; \
+ } \
+ classname &SetDiagMsg(const wxString &msg_diag) \
+ { \
+ m_message_diag = msg_diag; \
+ return *this; \
+ } \
+ classname &SetUserMsg(const wxString &msg_user) \
+ { \
+ m_message_user = msg_user; \
+ return *this; \
+ }
-#define DEFINE_RUNTIME_EXCEPTION( classname, parent, message ) \
- DEFINE_EXCEPTION_COPYTORS( classname, parent ) \
- classname() { SetDiagMsg(message); } \
- DEFINE_EXCEPTION_MESSAGES( classname )
-
-
- // ---------------------------------------------------------------------------------------
- // RuntimeError - Generalized Exceptions with Recoverable Traits!
- // ---------------------------------------------------------------------------------------
+#define DEFINE_RUNTIME_EXCEPTION(classname, parent, message) \
+ DEFINE_EXCEPTION_COPYTORS(classname, parent) \
+ classname() { SetDiagMsg(message); } \
+ DEFINE_EXCEPTION_MESSAGES(classname)
- class RuntimeError : public BaseException
- {
- DEFINE_EXCEPTION_COPYTORS( RuntimeError, BaseException )
- DEFINE_EXCEPTION_MESSAGES( RuntimeError )
- public:
- bool IsSilent;
+// ---------------------------------------------------------------------------------------
+// RuntimeError - Generalized Exceptions with Recoverable Traits!
+// ---------------------------------------------------------------------------------------
- RuntimeError() { IsSilent = false; }
- RuntimeError( const std::runtime_error& ex, const wxString& prefix=wxEmptyString );
- RuntimeError( const std::exception& ex, const wxString& prefix=wxEmptyString );
- };
+class RuntimeError : public BaseException
+{
+ DEFINE_EXCEPTION_COPYTORS(RuntimeError, BaseException)
+ DEFINE_EXCEPTION_MESSAGES(RuntimeError)
- // --------------------------------------------------------------------------------------
- // CancelAppEvent - Exception for canceling an event in a non-verbose fashion
- // --------------------------------------------------------------------------------------
- // Typically the PCSX2 interface issues popup dialogs for runtime errors. This exception
- // instead issues a "silent" cancelation that is handled by the app gracefully (generates
- // log, and resumes messages queue processing).
- //
- // I chose to have this exception derive from RuntimeError, since if one is thrown from outside
- // an App message loop we'll still want it to be handled in a reasonably graceful manner.
- class CancelEvent : public RuntimeError
- {
- DEFINE_RUNTIME_EXCEPTION( CancelEvent, RuntimeError, pxLt("No reason given.") )
+public:
+ bool IsSilent;
- public:
- explicit CancelEvent( const wxString& logmsg )
- {
- m_message_diag = logmsg;
- // overridden message formatters only use the diagnostic version...
- }
+ RuntimeError() { IsSilent = false; }
+ RuntimeError(const std::runtime_error &ex, const wxString &prefix = wxEmptyString);
+ RuntimeError(const std::exception &ex, const wxString &prefix = wxEmptyString);
+};
- virtual wxString FormatDisplayMessage() const;
- virtual wxString FormatDiagnosticMessage() const;
- };
+// --------------------------------------------------------------------------------------
+// CancelAppEvent - Exception for canceling an event in a non-verbose fashion
+// --------------------------------------------------------------------------------------
+// Typically the PCSX2 interface issues popup dialogs for runtime errors. This exception
+// instead issues a "silent" cancelation that is handled by the app gracefully (generates
+// log, and resumes messages queue processing).
+//
+// I chose to have this exception derive from RuntimeError, since if one is thrown from outside
+// an App message loop we'll still want it to be handled in a reasonably graceful manner.
+class CancelEvent : public RuntimeError
+{
+ DEFINE_RUNTIME_EXCEPTION(CancelEvent, RuntimeError, pxLt("No reason given."))
- // ---------------------------------------------------------------------------------------
- // OutOfMemory
- // ---------------------------------------------------------------------------------------
- // This exception has a custom-formatted Diagnostic string. The parameter give when constructing
- // the exception is a block/alloc name, which is used as a formatting parameter in the diagnostic
- // output. The default diagnostic message is "Out of memory exception, while allocating the %s."
- // where %s is filled in with the block name.
- //
- // The user string is not custom-formatted, and should contain *NO* %s tags.
- //
- class OutOfMemory : public RuntimeError
- {
- DEFINE_RUNTIME_EXCEPTION( OutOfMemory, RuntimeError, wxEmptyString )
+public:
+ explicit CancelEvent(const wxString &logmsg)
+ {
+ m_message_diag = logmsg;
+ // overridden message formatters only use the diagnostic version...
+ }
- public:
- wxString AllocDescription;
+ virtual wxString FormatDisplayMessage() const;
+ virtual wxString FormatDiagnosticMessage() const;
+};
- public:
- OutOfMemory( const wxString& allocdesc );
+// ---------------------------------------------------------------------------------------
+// OutOfMemory
+// ---------------------------------------------------------------------------------------
+// This exception has a custom-formatted Diagnostic string. The parameter give when constructing
+// the exception is a block/alloc name, which is used as a formatting parameter in the diagnostic
+// output. The default diagnostic message is "Out of memory exception, while allocating the %s."
+// where %s is filled in with the block name.
+//
+// The user string is not custom-formatted, and should contain *NO* %s tags.
+//
+class OutOfMemory : public RuntimeError
+{
+ DEFINE_RUNTIME_EXCEPTION(OutOfMemory, RuntimeError, wxEmptyString)
- virtual wxString FormatDisplayMessage() const;
- virtual wxString FormatDiagnosticMessage() const;
- };
+public:
+ wxString AllocDescription;
- class ParseError : public RuntimeError
- {
- DEFINE_RUNTIME_EXCEPTION( ParseError, RuntimeError, pxL("Parse error") );
- };
+public:
+ OutOfMemory(const wxString &allocdesc);
- // ---------------------------------------------------------------------------------------
- // Hardware/OS Exceptions:
- // HardwareDeficiency / VirtualMemoryMapConflict
- // ---------------------------------------------------------------------------------------
+ virtual wxString FormatDisplayMessage() const;
+ virtual wxString FormatDiagnosticMessage() const;
+};
- // This exception is a specific type of OutOfMemory error that isn't "really" an out of
- // memory error. More likely it's caused by a plugin or driver reserving a range of memory
- // we'd really like to have access to.
- class VirtualMemoryMapConflict : public OutOfMemory
- {
- DEFINE_RUNTIME_EXCEPTION( VirtualMemoryMapConflict, OutOfMemory, wxEmptyString )
+class ParseError : public RuntimeError
+{
+ DEFINE_RUNTIME_EXCEPTION(ParseError, RuntimeError, pxL("Parse error"));
+};
- VirtualMemoryMapConflict( const wxString& allocdesc );
+// ---------------------------------------------------------------------------------------
+// Hardware/OS Exceptions:
+// HardwareDeficiency / VirtualMemoryMapConflict
+// ---------------------------------------------------------------------------------------
- virtual wxString FormatDisplayMessage() const;
- virtual wxString FormatDiagnosticMessage() const;
- };
+// This exception is a specific type of OutOfMemory error that isn't "really" an out of
+// memory error. More likely it's caused by a plugin or driver reserving a range of memory
+// we'd really like to have access to.
+class VirtualMemoryMapConflict : public OutOfMemory
+{
+ DEFINE_RUNTIME_EXCEPTION(VirtualMemoryMapConflict, OutOfMemory, wxEmptyString)
- class HardwareDeficiency : public RuntimeError
- {
- public:
- DEFINE_RUNTIME_EXCEPTION( HardwareDeficiency, RuntimeError, pxL("Your machine's hardware is incapable of running PCSX2. Sorry dood.") );
- };
+ VirtualMemoryMapConflict(const wxString &allocdesc);
- // ---------------------------------------------------------------------------------------
- // Streaming (file) Exceptions:
- // Stream / BadStream / CannotCreateStream / FileNotFound / AccessDenied / EndOfStream
- // ---------------------------------------------------------------------------------------
+ virtual wxString FormatDisplayMessage() const;
+ virtual wxString FormatDiagnosticMessage() const;
+};
- #define DEFINE_STREAM_EXCEPTION_ACCESSORS( classname ) \
- virtual classname& SetStreamName( const wxString& name ) { StreamName = name; return *this; } \
- virtual classname& SetStreamName( const char* name ) { StreamName = fromUTF8(name); return *this; }
+class HardwareDeficiency : public RuntimeError
+{
+public:
+ DEFINE_RUNTIME_EXCEPTION(HardwareDeficiency, RuntimeError, pxL("Your machine's hardware is incapable of running PCSX2. Sorry dood."));
+};
- #define DEFINE_STREAM_EXCEPTION( classname, parent ) \
- DEFINE_RUNTIME_EXCEPTION( classname, parent, wxEmptyString ) \
- classname( const wxString& filename ) { \
- StreamName = filename; \
- } \
- DEFINE_STREAM_EXCEPTION_ACCESSORS( classname )
-
- // A generic base error class for bad streams -- corrupted data, sudden closures, loss of
- // connection, or anything else that would indicate a failure to open a stream or read the
- // data after the stream was successfully opened.
- //
- class BadStream : public RuntimeError
- {
- DEFINE_STREAM_EXCEPTION( BadStream, RuntimeError )
+// ---------------------------------------------------------------------------------------
+// Streaming (file) Exceptions:
+// Stream / BadStream / CannotCreateStream / FileNotFound / AccessDenied / EndOfStream
+// ---------------------------------------------------------------------------------------
- public:
- wxString StreamName; // name of the stream (if applicable)
+#define DEFINE_STREAM_EXCEPTION_ACCESSORS(classname) \
+ virtual classname &SetStreamName(const wxString &name) \
+ { \
+ StreamName = name; \
+ return *this; \
+ } \
+ virtual classname &SetStreamName(const char *name) \
+ { \
+ StreamName = fromUTF8(name); \
+ return *this; \
+ }
- virtual wxString FormatDiagnosticMessage() const;
- virtual wxString FormatDisplayMessage() const;
+#define DEFINE_STREAM_EXCEPTION(classname, parent) \
+ DEFINE_RUNTIME_EXCEPTION(classname, parent, wxEmptyString) \
+ classname(const wxString &filename) \
+ { \
+ StreamName = filename; \
+ } \
+ DEFINE_STREAM_EXCEPTION_ACCESSORS(classname)
- protected:
- void _formatDiagMsg( FastFormatUnicode& dest ) const;
- void _formatUserMsg( FastFormatUnicode& dest ) const;
- };
+// A generic base error class for bad streams -- corrupted data, sudden closures, loss of
+// connection, or anything else that would indicate a failure to open a stream or read the
+// data after the stream was successfully opened.
+//
+class BadStream : public RuntimeError
+{
+ DEFINE_STREAM_EXCEPTION(BadStream, RuntimeError)
- // A generic exception for odd-ball stream creation errors.
- //
- class CannotCreateStream : public BadStream
- {
- DEFINE_STREAM_EXCEPTION( CannotCreateStream, BadStream )
+public:
+ wxString StreamName; // name of the stream (if applicable)
- virtual wxString FormatDiagnosticMessage() const;
- virtual wxString FormatDisplayMessage() const;
- };
+ virtual wxString FormatDiagnosticMessage() const;
+ virtual wxString FormatDisplayMessage() const;
- // Exception thrown when an attempt to open a non-existent file is made.
- // (this exception can also mean file permissions are invalid)
- //
- class FileNotFound : public CannotCreateStream
- {
- public:
- DEFINE_STREAM_EXCEPTION( FileNotFound, CannotCreateStream )
+protected:
+ void _formatDiagMsg(FastFormatUnicode &dest) const;
+ void _formatUserMsg(FastFormatUnicode &dest) const;
+};
- virtual wxString FormatDiagnosticMessage() const;
- virtual wxString FormatDisplayMessage() const;
- };
+// A generic exception for odd-ball stream creation errors.
+//
+class CannotCreateStream : public BadStream
+{
+ DEFINE_STREAM_EXCEPTION(CannotCreateStream, BadStream)
- class AccessDenied : public CannotCreateStream
- {
- public:
- DEFINE_STREAM_EXCEPTION( AccessDenied, CannotCreateStream )
+ virtual wxString FormatDiagnosticMessage() const;
+ virtual wxString FormatDisplayMessage() const;
+};
- virtual wxString FormatDiagnosticMessage() const;
- virtual wxString FormatDisplayMessage() const;
- };
+// Exception thrown when an attempt to open a non-existent file is made.
+// (this exception can also mean file permissions are invalid)
+//
+class FileNotFound : public CannotCreateStream
+{
+public:
+ DEFINE_STREAM_EXCEPTION(FileNotFound, CannotCreateStream)
- // EndOfStream can be used either as an error, or used just as a shortcut for manual
- // feof checks.
- //
- class EndOfStream : public BadStream
- {
- public:
- DEFINE_STREAM_EXCEPTION( EndOfStream, BadStream )
+ virtual wxString FormatDiagnosticMessage() const;
+ virtual wxString FormatDisplayMessage() const;
+};
- virtual wxString FormatDiagnosticMessage() const;
- virtual wxString FormatDisplayMessage() const;
- };
+class AccessDenied : public CannotCreateStream
+{
+public:
+ DEFINE_STREAM_EXCEPTION(AccessDenied, CannotCreateStream)
+
+ virtual wxString FormatDiagnosticMessage() const;
+ virtual wxString FormatDisplayMessage() const;
+};
+
+// EndOfStream can be used either as an error, or used just as a shortcut for manual
+// feof checks.
+//
+class EndOfStream : public BadStream
+{
+public:
+ DEFINE_STREAM_EXCEPTION(EndOfStream, BadStream)
+
+ virtual wxString FormatDiagnosticMessage() const;
+ virtual wxString FormatDisplayMessage() const;
+};
#ifdef __WXMSW__
- // --------------------------------------------------------------------------------------
- // Exception::WinApiError
- // --------------------------------------------------------------------------------------
- class WinApiError : public RuntimeError
- {
- DEFINE_EXCEPTION_COPYTORS( WinApiError, RuntimeError )
- DEFINE_EXCEPTION_MESSAGES( WinApiError )
+// --------------------------------------------------------------------------------------
+// Exception::WinApiError
+// --------------------------------------------------------------------------------------
+class WinApiError : public RuntimeError
+{
+ DEFINE_EXCEPTION_COPYTORS(WinApiError, RuntimeError)
+ DEFINE_EXCEPTION_MESSAGES(WinApiError)
- public:
- int ErrorId;
+public:
+ int ErrorId;
- public:
- WinApiError();
+public:
+ WinApiError();
- wxString GetMsgFromWindows() const;
- virtual wxString FormatDisplayMessage() const;
- virtual wxString FormatDiagnosticMessage() const;
- };
+ wxString GetMsgFromWindows() const;
+ virtual wxString FormatDisplayMessage() const;
+ virtual wxString FormatDiagnosticMessage() const;
+};
#endif
}
diff --git a/common/include/Utilities/FixedPointTypes.h b/common/include/Utilities/FixedPointTypes.h
index 58f2eb6e1b..01de348ec3 100644
--- a/common/include/Utilities/FixedPointTypes.h
+++ b/common/include/Utilities/FixedPointTypes.h
@@ -17,59 +17,59 @@
#include "Dependencies.h"
-template< int Precision >
+template
struct FixedInt
{
- s32 Raw;
+ s32 Raw;
- FixedInt();
- FixedInt( int signedval );
- FixedInt( double doubval );
- FixedInt( float floval );
+ FixedInt();
+ FixedInt(int signedval);
+ FixedInt(double doubval);
+ FixedInt(float floval);
- bool operator ==( const FixedInt& right ) const { return Raw == right.Raw; }
- bool operator !=( const FixedInt& right ) const { return Raw != right.Raw; }
+ bool operator==(const FixedInt &right) const { return Raw == right.Raw; }
+ bool operator!=(const FixedInt &right) const { return Raw != right.Raw; }
- bool operator>( const FixedInt& right ) const { return Raw > right.Raw; };
- bool operator>=( const FixedInt& right ) const { return Raw >= right.Raw; };
- bool operator<( const FixedInt& right ) const { return Raw < right.Raw; };
- bool operator<=( const FixedInt& right ) const { return Raw <= right.Raw; };
+ bool operator>(const FixedInt &right) const { return Raw > right.Raw; };
+ bool operator>=(const FixedInt &right) const { return Raw >= right.Raw; };
+ bool operator<(const FixedInt &right) const { return Raw < right.Raw; };
+ bool operator<=(const FixedInt &right) const { return Raw <= right.Raw; };
- FixedInt operator+( const FixedInt& right ) const;
- FixedInt operator-( const FixedInt& right ) const;
- FixedInt& operator+=( const FixedInt& right );
- FixedInt& operator-=( const FixedInt& right );
+ FixedInt operator+(const FixedInt &right) const;
+ FixedInt operator-(const FixedInt &right) const;
+ FixedInt &operator+=(const FixedInt &right);
+ FixedInt &operator-=(const FixedInt &right);
- FixedInt& ConfineTo( const FixedInt& low, const FixedInt& high );
+ FixedInt &ConfineTo(const FixedInt &low, const FixedInt &high);
- FixedInt operator*( const FixedInt& right ) const;
- FixedInt operator/( const FixedInt& right ) const;
- FixedInt& operator*=( const FixedInt& right );
- FixedInt& operator/=( const FixedInt& right );
+ FixedInt operator*(const FixedInt &right) const;
+ FixedInt operator/(const FixedInt &right) const;
+ FixedInt &operator*=(const FixedInt &right);
+ FixedInt &operator/=(const FixedInt &right);
- static bool OverflowCheck( int signedval );
- static bool OverflowCheck( double signedval );
+ static bool OverflowCheck(int signedval);
+ static bool OverflowCheck(double signedval);
- int GetWhole() const;
- int GetFraction() const;
+ int GetWhole() const;
+ int GetFraction() const;
- FixedInt& SetRaw( s32 rawsrc );
- FixedInt& Round();
- FixedInt& SetWhole( s32 wholepart );
- FixedInt& SetFraction( u32 fracpart );
+ FixedInt &SetRaw(s32 rawsrc);
+ FixedInt &Round();
+ FixedInt &SetWhole(s32 wholepart);
+ FixedInt &SetFraction(u32 fracpart);
- wxString ToString() const;
- wxString ToString( int fracDigits ) const;
+ wxString ToString() const;
+ wxString ToString(int fracDigits) const;
- double ToDouble() const;
- float ToFloat() const;
- int ToIntTruncated() const;
- int ToIntRounded() const;
+ double ToDouble() const;
+ float ToFloat() const;
+ int ToIntTruncated() const;
+ int ToIntRounded() const;
- static bool TryFromString( FixedInt& dest, const wxString& parseFrom );
- static FixedInt FromString( const wxString& parseFrom, const FixedInt& defval );
- static FixedInt FromString( const wxString parseFrom );
+ static bool TryFromString(FixedInt &dest, const wxString &parseFrom);
+ static FixedInt FromString(const wxString &parseFrom, const FixedInt &defval);
+ static FixedInt FromString(const wxString parseFrom);
};
-typedef FixedInt<256> Fixed256;
-typedef FixedInt<100> Fixed100;
+typedef FixedInt<256> Fixed256;
+typedef FixedInt<100> Fixed100;
diff --git a/common/include/Utilities/FixedPointTypes.inl b/common/include/Utilities/FixedPointTypes.inl
index 2d071f1269..79c2be0d57 100644
--- a/common/include/Utilities/FixedPointTypes.inl
+++ b/common/include/Utilities/FixedPointTypes.inl
@@ -16,226 +16,237 @@
#pragma once
#include "FixedPointTypes.h"
-#include // for pow!
+#include // for pow!
-template< int Precision >
+template
FixedInt::FixedInt()
{
- Raw = 0;
+ Raw = 0;
}
-template< int Precision >
-FixedInt::FixedInt( int signedval )
+template
+FixedInt::FixedInt(int signedval)
{
- Raw = signedval * Precision;
+ Raw = signedval * Precision;
}
-template< int Precision >
-FixedInt::FixedInt( double doubval )
+template
+FixedInt::FixedInt(double doubval)
{
- Raw = lround(doubval * (double)Precision);
+ Raw = lround(doubval * (double)Precision);
}
-template< int Precision >
-FixedInt::FixedInt( float floval )
+template
+FixedInt::FixedInt(float floval)
{
- Raw = lroundf(floval * (float)Precision);
+ Raw = lroundf(floval * (float)Precision);
}
-template< int Precision >
-FixedInt FixedInt::operator+( const FixedInt& right ) const
+template
+FixedInt FixedInt::operator+(const FixedInt &right) const
{
- return FixedInt().SetRaw( Raw + right.Raw );
+ return FixedInt().SetRaw(Raw + right.Raw);
}
-template< int Precision >
-FixedInt FixedInt::operator-( const FixedInt& right ) const
+template
+FixedInt FixedInt::operator-(const FixedInt &right) const
{
- return FixedInt().SetRaw( Raw + right.Raw );
+ return FixedInt().SetRaw(Raw + right.Raw);
}
-template< int Precision >
-FixedInt& FixedInt::operator+=( const FixedInt& right )
+template
+FixedInt &FixedInt::operator+=(const FixedInt &right)
{
- return SetRaw( Raw + right.Raw );
+ return SetRaw(Raw + right.Raw);
}
-template< int Precision >
-FixedInt& FixedInt::operator-=( const FixedInt& right )
+template
+FixedInt &FixedInt::operator-=(const FixedInt &right)
{
- return SetRaw( Raw + right.Raw );
+ return SetRaw(Raw + right.Raw);
}
-template< int Precision >
-FixedInt& FixedInt::ConfineTo( const FixedInt& low, const FixedInt& high )
+template
+FixedInt &FixedInt::ConfineTo(const FixedInt &low, const FixedInt &high)
{
- return SetRaw( std::min( std::max( Raw, low.Raw ), high.Raw ) );
+ return SetRaw(std::min(std::max(Raw, low.Raw), high.Raw));
}
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
// you'll need to use the Raw values directly.
-template< int Precision >
-FixedInt FixedInt::operator*( const FixedInt& right ) const
+template
+FixedInt FixedInt::operator*(const FixedInt &right) const
{
- s64 mulres = (s64)Raw * right.Raw;
- return FixedInt().SetRaw( (s32)(mulres / Precision) );
+ s64 mulres = (s64)Raw * right.Raw;
+ return FixedInt().SetRaw((s32)(mulres / Precision));
}
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
// you'll need to use the Raw values directly.
-template< int Precision >
-FixedInt FixedInt::operator/( const FixedInt& right ) const
+template
+FixedInt FixedInt::operator/(const FixedInt &right) const
{
- s64 divres = Raw * Precision;
- return FixedInt().SetRaw( (s32)(divres / right.Raw) );
+ s64 divres = Raw * Precision;
+ return FixedInt().SetRaw((s32)(divres / right.Raw));
}
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
// you'll need to use the Raw values directly.
-template< int Precision >
-FixedInt& FixedInt::operator*=( const FixedInt& right )
+template
+FixedInt &FixedInt::operator*=(const FixedInt &right)
{
- s64 mulres = (s64)Raw * right.Raw;
- return SetRaw( (s32)(mulres / Precision) );
+ s64 mulres = (s64)Raw * right.Raw;
+ return SetRaw((s32)(mulres / Precision));
}
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
// you'll need to use the Raw values directly.
-template< int Precision >
-FixedInt& FixedInt::operator/=( const FixedInt& right )
+template
+FixedInt &FixedInt::operator/=(const FixedInt &right)
{
- s64 divres = Raw * Precision;
- return SetRaw( (s32)(divres / right.Raw) );
+ s64 divres = Raw * Precision;
+ return SetRaw((s32)(divres / right.Raw));
}
// returns TRUE if the value overflows the legal integer range of this container.
-template< int Precision >
-bool FixedInt::OverflowCheck( int signedval )
+template
+bool FixedInt::OverflowCheck(int signedval)
{
- return ( signedval >= (INT_MAX / Precision) );
+ return (signedval >= (INT_MAX / Precision));
}
// returns TRUE if the value overflows the legal integer range of this container.
-template< int Precision >
-bool FixedInt::OverflowCheck( double signedval )
+template
+bool FixedInt::OverflowCheck(double signedval)
{
- return ( signedval >= (INT_MAX / Precision) );
+ return (signedval >= (INT_MAX / Precision));
}
-template< int Precision > int FixedInt::GetWhole() const { return Raw / Precision; }
-template< int Precision > int FixedInt::GetFraction() const { return Raw % Precision; }
-
-template< int Precision >
-FixedInt& FixedInt::SetRaw( s32 rawsrc )
+template
+int FixedInt::GetWhole() const
{
- Raw = rawsrc;
- return *this;
+ return Raw / Precision;
+}
+template
+int FixedInt::GetFraction() const
+{
+ return Raw % Precision;
}
-template< int Precision >
-FixedInt& FixedInt::Round()
+template
+FixedInt &FixedInt::SetRaw(s32 rawsrc)
{
- Raw = ToIntRounded();
- return *this;
+ Raw = rawsrc;
+ return *this;
}
-template< int Precision >
-FixedInt& FixedInt::SetWhole( s32 wholepart )
+template
+FixedInt &FixedInt::Round()
{
- pxAssert( wholepart < (INT_MAX / Precision) );
- Raw = GetFraction() + (wholepart * Precision);
- return *this;
+ Raw = ToIntRounded();
+ return *this;
}
-template< int Precision >
-FixedInt& FixedInt::SetFraction( u32 fracpart )
+template
+FixedInt &FixedInt::SetWhole(s32 wholepart)
{
- Raw = (GetWhole() * Precision) + fracpart;
- return *this;
+ pxAssert(wholepart < (INT_MAX / Precision));
+ Raw = GetFraction() + (wholepart * Precision);
+ return *this;
}
-template< int Precision >
+template
+FixedInt &FixedInt::SetFraction(u32 fracpart)
+{
+ Raw = (GetWhole() * Precision) + fracpart;
+ return *this;
+}
+
+template
wxString FixedInt::ToString() const
{
- return wxsFormat( L"%d.%02d", GetWhole(), (GetFraction() * 100) / Precision );
+ return wxsFormat(L"%d.%02d", GetWhole(), (GetFraction() * 100) / Precision);
}
-template< int Precision >
-wxString FixedInt::ToString( int fracDigits ) const
+template
+wxString FixedInt::ToString(int fracDigits) const
{
- if( fracDigits == 0 ) return wxsFormat( L"%d", GetWhole() );
+ if (fracDigits == 0)
+ return wxsFormat(L"%d", GetWhole());
- pxAssert( fracDigits <= 7 ); // higher numbers would just cause overflows and bad mojo.
- int mulby = (int)pow( 10.0, fracDigits );
- wxString fmt=wxsFormat(L"%%d.%%0%dd", fracDigits);
- return wxsFormat( fmt, GetWhole(), (GetFraction() * mulby) / Precision );
+ pxAssert(fracDigits <= 7); // higher numbers would just cause overflows and bad mojo.
+ int mulby = (int)pow(10.0, fracDigits);
+ wxString fmt = wxsFormat(L"%%d.%%0%dd", fracDigits);
+ return wxsFormat(fmt, GetWhole(), (GetFraction() * mulby) / Precision);
}
-template< int Precision >
+template
double FixedInt::ToDouble() const
{
- return ((double)Raw / (double)Precision);
+ return ((double)Raw / (double)Precision);
}
-template< int Precision >
+template
float FixedInt::ToFloat() const
{
- return ((float)Raw / (float)Precision);
+ return ((float)Raw / (float)Precision);
}
-template< int Precision >
+template
int FixedInt::ToIntTruncated() const
{
- return Raw / Precision;
+ return Raw / Precision;
}
-template< int Precision >
+template
int FixedInt::ToIntRounded() const
{
- return (Raw + (Precision/2)) / Precision;
+ return (Raw + (Precision / 2)) / Precision;
}
-template< int Precision >
-bool FixedInt::TryFromString( FixedInt& dest, const wxString& parseFrom )
+template
+bool FixedInt::TryFromString(FixedInt &dest, const wxString &parseFrom)
{
- long whole=0, frac=0;
- const wxString beforeFirst( parseFrom.BeforeFirst( L'.' ) );
- const wxString afterFirst( parseFrom.AfterFirst( L'.' ).Mid(0, 5) );
- bool success = true;
+ long whole = 0, frac = 0;
+ const wxString beforeFirst(parseFrom.BeforeFirst(L'.'));
+ const wxString afterFirst(parseFrom.AfterFirst(L'.').Mid(0, 5));
+ bool success = true;
- if( !beforeFirst.IsEmpty() )
- success = success && beforeFirst.ToLong( &whole );
+ if (!beforeFirst.IsEmpty())
+ success = success && beforeFirst.ToLong(&whole);
- if( !afterFirst.IsEmpty() )
- success = success && afterFirst.ToLong( &frac );
+ if (!afterFirst.IsEmpty())
+ success = success && afterFirst.ToLong(&frac);
- if( !success ) return false;
+ if (!success)
+ return false;
- dest.SetWhole( whole );
+ dest.SetWhole(whole);
- if( afterFirst.Length() != 0 && frac != 0 )
- {
- int fracPower = (int)pow( 10.0, (int)afterFirst.Length() );
- dest.SetFraction( (frac * Precision) / fracPower );
- }
- return true;
+ if (afterFirst.Length() != 0 && frac != 0) {
+ int fracPower = (int)pow(10.0, (int)afterFirst.Length());
+ dest.SetFraction((frac * Precision) / fracPower);
+ }
+ return true;
}
-template< int Precision >
-FixedInt FixedInt::FromString( const wxString& parseFrom, const FixedInt& defval )
+template
+FixedInt FixedInt::FromString(const wxString &parseFrom, const FixedInt &defval)
{
- FixedInt dest;
- if( !TryFromString( dest, parseFrom ) ) return defval;
- return dest;
+ FixedInt dest;
+ if (!TryFromString(dest, parseFrom))
+ return defval;
+ return dest;
}
// This version of FromString throws a ParseError exception if the conversion fails.
-template< int Precision >
-FixedInt FixedInt::FromString( const wxString parseFrom )
+template
+FixedInt FixedInt::FromString(const wxString parseFrom)
{
- FixedInt dest;
- if( !TryFromString( dest, parseFrom ) ) throw Exception::ParseError()
- .SetDiagMsg(wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision));
+ FixedInt