diff --git a/plugins/CDVDnull/CDVD.cpp b/plugins/CDVDnull/CDVD.cpp index 27f41d4713..db4acfe7e3 100644 --- a/plugins/CDVDnull/CDVD.cpp +++ b/plugins/CDVDnull/CDVD.cpp @@ -27,102 +27,122 @@ const unsigned char version = PS2E_CDVD_VERSION; const unsigned char revision = 0; const unsigned char build = 6; -EXPORT_C_(char*) PS2EgetLibName() +EXPORT_C_(char*) +PS2EgetLibName() { - snprintf( libraryName, 255, "CDVDnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : ""); - return libraryName; + snprintf(libraryName, 255, "CDVDnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : ""); + return libraryName; } -EXPORT_C_(u32) PS2EgetLibType() +EXPORT_C_(u32) +PS2EgetLibType() { - return PS2E_LT_CDVD; + return PS2E_LT_CDVD; } -EXPORT_C_(u32) CALLBACK PS2EgetLibVersion2(u32 type) +EXPORT_C_(u32) +CALLBACK PS2EgetLibVersion2(u32 type) { - return (version << 16) | (revision << 8) | build; + return (version << 16) | (revision << 8) | build; } -EXPORT_C_(s32) CDVDinit() +EXPORT_C_(s32) +CDVDinit() { - return 0; + return 0; } -EXPORT_C_(s32) CDVDopen(const char* pTitle) +EXPORT_C_(s32) +CDVDopen(const char* pTitle) { - return 0; + return 0; } -EXPORT_C_(void) CDVDclose() +EXPORT_C_(void) +CDVDclose() { } -EXPORT_C_(void) CDVDshutdown() +EXPORT_C_(void) +CDVDshutdown() { } -EXPORT_C_(s32) CDVDreadTrack(u32 lsn, int mode) +EXPORT_C_(s32) +CDVDreadTrack(u32 lsn, int mode) { - return -1; + return -1; } // return can be NULL (for async modes) -EXPORT_C_(u8*) CDVDgetBuffer() +EXPORT_C_(u8*) +CDVDgetBuffer() { - return NULL; + return NULL; } -EXPORT_C_(s32) CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) +EXPORT_C_(s32) +CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) { - return -1; + return -1; } -EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer) +EXPORT_C_(s32) +CDVDgetTN(cdvdTN* Buffer) { - return -1; + return -1; } -EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer) +EXPORT_C_(s32) +CDVDgetTD(u8 Track, cdvdTD* Buffer) { - return -1; + return -1; } -EXPORT_C_(s32) CDVDgetTOC(void* toc) +EXPORT_C_(s32) +CDVDgetTOC(void* toc) { - return -1; + return -1; } -EXPORT_C_(s32) CDVDgetDiskType() +EXPORT_C_(s32) +CDVDgetDiskType() { - return CDVD_TYPE_NODISC; + return CDVD_TYPE_NODISC; } -EXPORT_C_(s32) CDVDgetTrayStatus() +EXPORT_C_(s32) +CDVDgetTrayStatus() { - return CDVD_TRAY_CLOSE; + return CDVD_TRAY_CLOSE; } -EXPORT_C_(s32) CDVDctrlTrayOpen() +EXPORT_C_(s32) +CDVDctrlTrayOpen() { - return 0; + return 0; } -EXPORT_C_(s32) CDVDctrlTrayClose() +EXPORT_C_(s32) +CDVDctrlTrayClose() { - return 0; + return 0; } -EXPORT_C_(void) CDVDconfigure() +EXPORT_C_(void) +CDVDconfigure() { - SysMessage("Nothing to Configure"); + SysMessage("Nothing to Configure"); } -EXPORT_C_(void) CDVDabout() +EXPORT_C_(void) +CDVDabout() { - SysMessage("%s %d.%d", "CDVDnull Driver", revision, build); + SysMessage("%s %d.%d", "CDVDnull Driver", revision, build); } -EXPORT_C_(s32) CDVDtest() +EXPORT_C_(s32) +CDVDtest() { - return 0; + return 0; } diff --git a/plugins/CDVDnull/CDVD.h b/plugins/CDVDnull/CDVD.h index 264a9a5b74..56496eaf46 100644 --- a/plugins/CDVDnull/CDVD.h +++ b/plugins/CDVDnull/CDVD.h @@ -14,7 +14,7 @@ */ - #ifndef __CDVD_H__ +#ifndef __CDVD_H__ #define __CDVD_H__ #define CDVDdefs @@ -30,7 +30,7 @@ #ifdef _MSC_VER #define EXPORT_C_(type) extern "C" type CALLBACK #else -#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type +#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type #endif extern const unsigned char version; @@ -38,5 +38,5 @@ extern const unsigned char revision; extern const unsigned char build; extern const unsigned int minor; -extern void SysMessage(const char *fmt, ...); +extern void SysMessage(const char* fmt, ...); #endif /* __CDVD_H__ */ diff --git a/plugins/FWnull/Config.cpp b/plugins/FWnull/Config.cpp index 9afc393431..76ed50bd31 100644 --- a/plugins/FWnull/Config.cpp +++ b/plugins/FWnull/Config.cpp @@ -25,55 +25,51 @@ PluginConf Ini; void setLoggingState() { - if (conf.Log) - { - FWLog.WriteToConsole = true; - FWLog.WriteToFile = true; - } - else - { - FWLog.WriteToConsole = false; - FWLog.WriteToFile = false; - } + if (conf.Log) { + FWLog.WriteToConsole = true; + FWLog.WriteToFile = true; + } else { + FWLog.WriteToConsole = false; + FWLog.WriteToFile = false; + } } -EXPORT_C_(void) FWabout() +EXPORT_C_(void) +FWabout() { - SysMessage("FWnull: A simple null plugin."); + SysMessage("FWnull: A simple null plugin."); } -EXPORT_C_(void) FWconfigure() +EXPORT_C_(void) +FWconfigure() { - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); + LoadConfig(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } void LoadConfig() { - string IniPath = s_strIniPath + "/FWnull.ini"; - if (!Ini.Open(IniPath, READ_FILE)) - { - FWLog.WriteLn("Failed to open %s", IniPath.c_str()); - SaveConfig(); - return; - } + string IniPath = s_strIniPath + "/FWnull.ini"; + if (!Ini.Open(IniPath, READ_FILE)) { + FWLog.WriteLn("Failed to open %s", IniPath.c_str()); + SaveConfig(); + return; + } - conf.Log = Ini.ReadInt("logging", 0); - setLoggingState(); - Ini.Close(); + conf.Log = Ini.ReadInt("logging", 0); + setLoggingState(); + Ini.Close(); } void SaveConfig() { - string IniPath = s_strIniPath + "/FWnull.ini"; - if (!Ini.Open(IniPath, WRITE_FILE)) - { - FWLog.WriteLn("Failed to open %s\n", IniPath.c_str()); - return; - } + string IniPath = s_strIniPath + "/FWnull.ini"; + if (!Ini.Open(IniPath, WRITE_FILE)) { + FWLog.WriteLn("Failed to open %s\n", IniPath.c_str()); + return; + } - Ini.WriteInt("logging", conf.Log); - Ini.Close(); + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } - diff --git a/plugins/FWnull/Config.h b/plugins/FWnull/Config.h index e91f9b8f4a..5621eebb74 100644 --- a/plugins/FWnull/Config.h +++ b/plugins/FWnull/Config.h @@ -15,7 +15,7 @@ void SaveConf(); void LoadConf(); -void SysMessage(const char *fmt, ...); +void SysMessage(const char* fmt, ...); #define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)))) -#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state) +#define set_checked(main_widget, widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state) diff --git a/plugins/FWnull/FW.cpp b/plugins/FWnull/FW.cpp index 2e9eccaf5f..62fd537a0b 100644 --- a/plugins/FWnull/FW.cpp +++ b/plugins/FWnull/FW.cpp @@ -23,20 +23,20 @@ using namespace std; #include "FW.h" #include "svnrev.h" -const u8 version = PS2E_FW_VERSION; +const u8 version = PS2E_FW_VERSION; const u8 revision = 0; -const u8 build = 7; // increase that with each version +const u8 build = 7; // increase that with each version #ifdef _MSC_VER #define snprintf sprintf_s #endif static char libraryName[256]; -string s_strIniPath="inis"; +string s_strIniPath = "inis"; string s_strLogPath = "logs"; u8 phyregs[16]; -s8 *fwregs; +s8* fwregs; Config conf; PluginLog FWLog; @@ -44,259 +44,268 @@ void (*FWirq)(); void LogInit() { - const std::string LogFile(s_strLogPath + "/FWnull.log"); - setLoggingState(); - FWLog.Open(LogFile); + const std::string LogFile(s_strLogPath + "/FWnull.log"); + setLoggingState(); + FWLog.Open(LogFile); } -EXPORT_C_(void) FWsetLogDir(const char* dir) +EXPORT_C_(void) +FWsetLogDir(const char* dir) { - // Get the path to the log directory. - s_strLogPath = (dir==NULL) ? "logs" : dir; - - // Reload the log file after updated the path - FWLog.Close(); - LogInit(); + // Get the path to the log directory. + s_strLogPath = (dir == NULL) ? "logs" : dir; + + // Reload the log file after updated the path + FWLog.Close(); + LogInit(); } -EXPORT_C_(u32) PS2EgetLibType() +EXPORT_C_(u32) +PS2EgetLibType() { - return PS2E_LT_FW; + return PS2E_LT_FW; } -EXPORT_C_(char*) PS2EgetLibName() +EXPORT_C_(char*) +PS2EgetLibName() { - snprintf( libraryName, 255, "FWnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : ""); - return libraryName; + snprintf(libraryName, 255, "FWnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : ""); + return libraryName; } -EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +EXPORT_C_(u32) +PS2EgetLibVersion2(u32 type) { - return (version<<16) | (revision<<8) | build; + return (version << 16) | (revision << 8) | build; } -EXPORT_C_(s32) FWinit() +EXPORT_C_(s32) +FWinit() { - LoadConfig(); - LogInit(); - FWLog.WriteLn("FWnull plugin version %d,%d", revision, build); - FWLog.WriteLn("Initializing FWnull"); + LoadConfig(); + LogInit(); + FWLog.WriteLn("FWnull plugin version %d,%d", revision, build); + FWLog.WriteLn("Initializing FWnull"); - memset(phyregs, 0, sizeof(phyregs)); - // Initializing our registers. - fwregs = (s8*)calloc(0x10000,1); - if (fwregs == NULL) - { - FWLog.Message("Error allocating Memory"); - return -1; - } - return 0; + memset(phyregs, 0, sizeof(phyregs)); + // Initializing our registers. + fwregs = (s8*)calloc(0x10000, 1); + if (fwregs == NULL) { + FWLog.Message("Error allocating Memory"); + return -1; + } + return 0; } -EXPORT_C_(void) FWshutdown() +EXPORT_C_(void) +FWshutdown() { - // Freeing the registers. - free(fwregs); - fwregs = NULL; + // Freeing the registers. + free(fwregs); + fwregs = NULL; - FWLog.Close(); + FWLog.Close(); } -EXPORT_C_(s32) FWopen(void *pDsp) +EXPORT_C_(s32) +FWopen(void* pDsp) { - FWLog.WriteLn("Opening FWnull."); + FWLog.WriteLn("Opening FWnull."); - return 0; + return 0; } -EXPORT_C_(void) FWclose() +EXPORT_C_(void) +FWclose() { - // Close the plugin. - FWLog.WriteLn("Closing FWnull."); + // Close the plugin. + FWLog.WriteLn("Closing FWnull."); } void PHYWrite() { - u8 reg = (PHYACC >> 8) & 0xf; - u8 data = PHYACC & 0xff; + u8 reg = (PHYACC >> 8) & 0xf; + u8 data = PHYACC & 0xff; - phyregs[reg] = data; + phyregs[reg] = data; - PHYACC &= ~0x4000ffff; + PHYACC &= ~0x4000ffff; } void PHYRead() { - u8 reg = (PHYACC >> 24) & 0xf; + u8 reg = (PHYACC >> 24) & 0xf; - PHYACC &= ~0x80000000; + PHYACC &= ~0x80000000; - PHYACC |= phyregs[reg] | (reg << 8); - - if(fwRu32(0x8424) & 0x40000000) //RRx interrupt mask - { - fwRu32(0x8420) |= 0x40000000; - FWirq(); - } + PHYACC |= phyregs[reg] | (reg << 8); + + if (fwRu32(0x8424) & 0x40000000) //RRx interrupt mask + { + fwRu32(0x8420) |= 0x40000000; + FWirq(); + } } -EXPORT_C_(u32) FWread32(u32 addr) +EXPORT_C_(u32) +FWread32(u32 addr) { - u32 ret = 0; + u32 ret = 0; - switch (addr) - { - //Node ID Register the top part is default, bottom part i got from my ps2 - case 0x1f808400: - ret = /*(0x3ff << 22) | 1;*/ 0xffc00001; - break; - // Control Register 2 - case 0x1f808410: - ret = fwRu32(addr); //SCLK OK (Needs to be set when FW is "Ready" - break; - //Interrupt 0 Register - case 0x1f808420: - ret = fwRu32(addr); - break; + switch (addr) { + //Node ID Register the top part is default, bottom part i got from my ps2 + case 0x1f808400: + ret = /*(0x3ff << 22) | 1;*/ 0xffc00001; + break; + // Control Register 2 + case 0x1f808410: + ret = fwRu32(addr); //SCLK OK (Needs to be set when FW is "Ready" + break; + //Interrupt 0 Register + case 0x1f808420: + ret = fwRu32(addr); + break; - //Dunno what this is, but my home console always returns this value 0x10000001 - //Seems to be related to the Node ID however (does some sort of compare/check) - case 0x1f80847c: - ret = 0x10000001; - break; + //Dunno what this is, but my home console always returns this value 0x10000001 + //Seems to be related to the Node ID however (does some sort of compare/check) + case 0x1f80847c: + ret = 0x10000001; + break; - // Include other relevant 32 bit addresses we need to catch here. - default: - // By default, read fwregs. - ret = fwRu32(addr); - break; - } + // Include other relevant 32 bit addresses we need to catch here. + default: + // By default, read fwregs. + ret = fwRu32(addr); + break; + } - FWLog.WriteLn("FW read mem 0x%x: 0x%x", addr, ret); + FWLog.WriteLn("FW read mem 0x%x: 0x%x", addr, ret); - return ret; + return ret; } -EXPORT_C_(void) FWwrite32(u32 addr, u32 value) +EXPORT_C_(void) +FWwrite32(u32 addr, u32 value) { - switch (addr) - { -// Include other memory locations we want to catch here. -// For example: -// -// case 0x1f808400: -// case 0x1f808414: -// case 0x1f808420: -// case 0x1f808428: -// case 0x1f808430: -// + switch (addr) { + // Include other memory locations we want to catch here. + // For example: + // + // case 0x1f808400: + // case 0x1f808414: + // case 0x1f808420: + // case 0x1f808428: + // case 0x1f808430: + // - //PHY access - case 0x1f808414: - //If in read mode (top bit set) we read the PHY register requested then set the RRx interrupt if it's enabled - //Im presuming we send that back to pcsx2 then. This register stores the result, plus whatever was written (minus the read/write flag - fwRu32(addr) = value; //R/W Bit cleaned in underneath function - if(value & 0x40000000) //Writing to PHY - { - PHYWrite(); - } - else if(value & 0x80000000) //Reading from PHY - { - PHYRead(); - } - break; + //PHY access + case 0x1f808414: + //If in read mode (top bit set) we read the PHY register requested then set the RRx interrupt if it's enabled + //Im presuming we send that back to pcsx2 then. This register stores the result, plus whatever was written (minus the read/write flag + fwRu32(addr) = value; //R/W Bit cleaned in underneath function + if (value & 0x40000000) //Writing to PHY + { + PHYWrite(); + } else if (value & 0x80000000) //Reading from PHY + { + PHYRead(); + } + break; - //Control Register 0 - case 0x1f808408: - //This enables different functions of the link interface - //Just straight writes, should brobably struct these later. - //Default written settings (on unreal tournament) are - //Urcv M = 1 - //RSP 0 = 1 - //Retlim = 0xF - //Cyc Tmr En = 1 - //Bus ID Rst = 1 - //Rcv Self ID = 1 - fwRu32(addr) = value; - // if((value & 0x800000) && (fwRu32(0x842C) & 0x2)) - // { - // fwRu32(0x8428) |= 0x2; - // FWirq(); - // } - fwRu32(addr) &= ~0x800000; - break; - //Control Register 2 - case 0x1f808410:// fwRu32(addr) = value; break; - //Ignore writes to this for now, apart from 0x2 which is Link Power Enable - //0x8 is SCLK OK (Ready) which should be set for emulation - fwRu32(addr) = 0x8 /*| value & 0x2*/; - break; - //Interrupt 0 Register - case 0x1f808420: - //Interrupt 1 Register - case 0x1f808428: - //Interrupt 2 Register - case 0x1f808430: - //Writes of 1 clear the corresponding bits - fwRu32(addr) &= ~value; - break; - //Interrupt 0 Register Mask - case 0x1f808424: - //Interrupt 1 Register Mask - case 0x1f80842C: - //Interrupt 2 Register Mask - case 0x1f808434: - //These are direct writes (as it's a mask!) - fwRu32(addr) = value; - break; - //DMA Control and Status Register 0 - case 0x1f8084B8: - fwRu32(addr) = value; - break; - //DMA Control and Status Register 1 - case 0x1f808538: - fwRu32(addr) = value; - break; - default: - // By default, just write it to fwregs. - fwRu32(addr) = value; - break; - } - FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value); + //Control Register 0 + case 0x1f808408: + //This enables different functions of the link interface + //Just straight writes, should brobably struct these later. + //Default written settings (on unreal tournament) are + //Urcv M = 1 + //RSP 0 = 1 + //Retlim = 0xF + //Cyc Tmr En = 1 + //Bus ID Rst = 1 + //Rcv Self ID = 1 + fwRu32(addr) = value; + // if((value & 0x800000) && (fwRu32(0x842C) & 0x2)) + // { + // fwRu32(0x8428) |= 0x2; + // FWirq(); + // } + fwRu32(addr) &= ~0x800000; + break; + //Control Register 2 + case 0x1f808410: // fwRu32(addr) = value; break; + //Ignore writes to this for now, apart from 0x2 which is Link Power Enable + //0x8 is SCLK OK (Ready) which should be set for emulation + fwRu32(addr) = 0x8 /*| value & 0x2*/; + break; + //Interrupt 0 Register + case 0x1f808420: + //Interrupt 1 Register + case 0x1f808428: + //Interrupt 2 Register + case 0x1f808430: + //Writes of 1 clear the corresponding bits + fwRu32(addr) &= ~value; + break; + //Interrupt 0 Register Mask + case 0x1f808424: + //Interrupt 1 Register Mask + case 0x1f80842C: + //Interrupt 2 Register Mask + case 0x1f808434: + //These are direct writes (as it's a mask!) + fwRu32(addr) = value; + break; + //DMA Control and Status Register 0 + case 0x1f8084B8: + fwRu32(addr) = value; + break; + //DMA Control and Status Register 1 + case 0x1f808538: + fwRu32(addr) = value; + break; + default: + // By default, just write it to fwregs. + fwRu32(addr) = value; + break; + } + FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value); } -EXPORT_C_(void) FWirqCallback(void (*callback)()) +EXPORT_C_(void) +FWirqCallback(void (*callback)()) { - // Register FWirq, so we can trigger an interrupt with it later. - FWirq = callback; + // Register FWirq, so we can trigger an interrupt with it later. + FWirq = callback; } -EXPORT_C_(void) FWsetSettingsDir(const char* dir) +EXPORT_C_(void) +FWsetSettingsDir(const char* dir) { - // Find out from pcsx2 where we are supposed to put our ini file. + // Find out from pcsx2 where we are supposed to put our ini file. s_strIniPath = (dir == NULL) ? "inis" : dir; } -EXPORT_C_(s32) FWfreeze(int mode, freezeData *data) +EXPORT_C_(s32) +FWfreeze(int mode, freezeData* data) { - // This should store or retrieve any information, for if emulation - // gets suspended, or for savestates. - switch(mode) - { - case FREEZE_LOAD: - // Load previously saved data. - break; - case FREEZE_SAVE: - // Save data. - break; - case FREEZE_SIZE: - // return the size of the data. - break; - } - return 0; + // This should store or retrieve any information, for if emulation + // gets suspended, or for savestates. + switch (mode) { + case FREEZE_LOAD: + // Load previously saved data. + break; + case FREEZE_SAVE: + // Save data. + break; + case FREEZE_SIZE: + // return the size of the data. + break; + } + return 0; } -EXPORT_C_(s32) FWtest() +EXPORT_C_(s32) +FWtest() { - // 0 if the plugin works, non-0 if it doesn't. - return 0; + // 0 if the plugin works, non-0 if it doesn't. + return 0; } diff --git a/plugins/FWnull/FW.h b/plugins/FWnull/FW.h index b9e238a358..c80a79043a 100644 --- a/plugins/FWnull/FW.h +++ b/plugins/FWnull/FW.h @@ -23,16 +23,16 @@ #include "PS2Eext.h" // Our main memory storage, and defines for accessing it. -extern s8 *fwregs; -#define fwRs32(mem) (*(s32*)&fwregs[(mem) & 0xffff]) -#define fwRu32(mem) (*(u32*)&fwregs[(mem) & 0xffff]) +extern s8* fwregs; +#define fwRs32(mem) (*(s32*)&fwregs[(mem)&0xffff]) +#define fwRu32(mem) (*(u32*)&fwregs[(mem)&0xffff]) //PHY Access Address for ease of use :P #define PHYACC fwRu32(0x8414) typedef struct { - s32 Log; + s32 Log; } Config; extern Config conf; diff --git a/plugins/FWnull/Windows/Config.cpp b/plugins/FWnull/Windows/Config.cpp index 9831e03604..41bbaa88ed 100644 --- a/plugins/FWnull/Windows/Config.cpp +++ b/plugins/FWnull/Windows/Config.cpp @@ -21,46 +21,45 @@ extern HINSTANCE hInst; void SaveConfig() { - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; + Config* Conf1 = &conf; + char* szTemp; + char szIniFile[256], szValue[256]; - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); - - if(!szTemp) return; - strcpy(szTemp, "\\inis\\fwnull.ini"); - sprintf(szValue,"%u",Conf1->Log); - WritePrivateProfileString("Interface", "Logging",szValue,szIniFile); + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); + if (!szTemp) + return; + strcpy(szTemp, "\\inis\\fwnull.ini"); + sprintf(szValue, "%u", Conf1->Log); + WritePrivateProfileString("Interface", "Logging", szValue, szIniFile); } -void LoadConfig() { - FILE *fp; +void LoadConfig() +{ + FILE* fp; - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; + Config* Conf1 = &conf; + char* szTemp; + char szIniFile[256], szValue[256]; - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); - if(!szTemp) return ; - strcpy(szTemp, "\\inis\\fwnull.ini"); - fp=fopen("inis\\fwnull.ini","rt");//check if firewirenull.ini really exists - if (!fp) - { - CreateDirectory("inis",NULL); + if (!szTemp) + return; + strcpy(szTemp, "\\inis\\fwnull.ini"); + fp = fopen("inis\\fwnull.ini", "rt"); //check if firewirenull.ini really exists + if (!fp) { + CreateDirectory("inis", NULL); memset(&conf, 0, sizeof(conf)); - conf.Log = 0;//default value - SaveConfig();//save and return - return ; - } - fclose(fp); - GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); - Conf1->Log = strtoul(szValue, NULL, 10); - return ; - + conf.Log = 0; //default value + SaveConfig(); //save and return + return; + } + fclose(fp); + GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); + Conf1->Log = strtoul(szValue, NULL, 10); + return; } - diff --git a/plugins/FWnull/Windows/Win32.cpp b/plugins/FWnull/Windows/Win32.cpp index 951b1b20a2..6acc010e07 100644 --- a/plugins/FWnull/Windows/Win32.cpp +++ b/plugins/FWnull/Windows/Win32.cpp @@ -23,74 +23,81 @@ HINSTANCE hInst; -void SysMessage(char *fmt, ...) { - va_list list; - char tmp[512]; +void SysMessage(char* fmt, ...) +{ + va_list list; + char tmp[512]; - va_start(list,fmt); - vsprintf(tmp,fmt,list); - va_end(list); - MessageBox(GetActiveWindow(), tmp, "FW Plugin Msg", MB_SETFOREGROUND | MB_OK); + va_start(list, fmt); + vsprintf(tmp, fmt, list); + va_end(list); + MessageBox(GetActiveWindow(), tmp, "FW Plugin Msg", MB_SETFOREGROUND | MB_OK); } -BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { +BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ - switch(uMsg) { - case WM_INITDIALOG: - LoadConfig(); - if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); - return TRUE; + switch (uMsg) { + case WM_INITDIALOG: + LoadConfig(); + if (conf.Log) + CheckDlgButton(hW, IDC_LOGGING, TRUE); + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - EndDialog(hW, TRUE); - return TRUE; - case IDOK: - if (IsDlgButtonChecked(hW, IDC_LOGGING)) - conf.Log = 1; - else conf.Log = 0; - SaveConfig(); - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hW, TRUE); + return TRUE; + case IDOK: + if (IsDlgButtonChecked(hW, IDC_LOGGING)) + conf.Log = 1; + else + conf.Log = 0; + SaveConfig(); + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { - case WM_INITDIALOG: - return TRUE; +BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case WM_INITDIALOG: + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -void CALLBACK FWconfigure() { +void CALLBACK FWconfigure() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), GetActiveWindow(), (DLGPROC)ConfigureDlgProc); } -void CALLBACK FWabout() { +void CALLBACK FWabout() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), (DLGPROC)AboutDlgProc); } -BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT - DWORD dwReason, - LPVOID lpReserved) { - hInst = (HINSTANCE)hModule; - return TRUE; // very quick :) +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) +{ + hInst = (HINSTANCE)hModule; + return TRUE; // very quick :) } - diff --git a/plugins/GSnull/GS.cpp b/plugins/GSnull/GS.cpp index 2054d2ddae..1fd78d5ee8 100644 --- a/plugins/GSnull/GS.cpp +++ b/plugins/GSnull/GS.cpp @@ -28,19 +28,19 @@ using namespace std; #include "GifTransfer.h" #include "null/GSnull.h" #ifdef _MSC_VER -# include "svnrev.h" +#include "svnrev.h" #endif -const unsigned char version = PS2E_GS_VERSION; +const unsigned char version = PS2E_GS_VERSION; const unsigned char revision = 0; -const unsigned char build = 1; // increase that with each version +const unsigned char build = 1; // increase that with each version static char libraryName[256]; Config conf; u32 GSKeyEvent = 0; bool GSShift = false, GSAlt = false; -string s_strIniPath="inis"; +string s_strIniPath = "inis"; extern std::string s_strLogPath; const char* s_iniFilename = "GSnull.ini"; GSVars gs; @@ -56,215 +56,245 @@ extern void SetMultithreaded(); extern void SetFrameSkip(bool skip); extern void InitPath(); -EXPORT_C_(u32) PS2EgetLibType() +EXPORT_C_(u32) +PS2EgetLibType() { - return PS2E_LT_GS; + return PS2E_LT_GS; } -EXPORT_C_(char*) PS2EgetLibName() +EXPORT_C_(char*) +PS2EgetLibName() { #ifdef _MSC_VER - sprintf_s( libraryName, "GSnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : ""); - return libraryName; + sprintf_s(libraryName, "GSnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : ""); + return libraryName; #else - return "GSnull Driver"; + return "GSnull Driver"; #endif } -EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +EXPORT_C_(u32) +PS2EgetLibVersion2(u32 type) { - return (version<<16) | (revision<<8) | build; + return (version << 16) | (revision << 8) | build; } -EXPORT_C_(void) GSprintf(int timeout, char *fmt, ...) +EXPORT_C_(void) +GSprintf(int timeout, char* fmt, ...) { - va_list list; - char msg[512]; + va_list list; + char msg[512]; - va_start(list, fmt); - vsprintf(msg, fmt, list); - va_end(list); + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); - GSLog::Print("GSprintf:%s", msg); + GSLog::Print("GSprintf:%s", msg); } // basic funcs -EXPORT_C_(void) GSsetSettingsDir(const char* dir) +EXPORT_C_(void) +GSsetSettingsDir(const char* dir) { - s_strIniPath = (dir == NULL) ? "inis" : dir; + s_strIniPath = (dir == NULL) ? "inis" : dir; } -EXPORT_C_(void) GSsetLogDir(const char* dir) +EXPORT_C_(void) +GSsetLogDir(const char* dir) { - // Get the path to the log directory. - s_strLogPath = (dir==NULL) ? "logs" : dir; + // Get the path to the log directory. + s_strLogPath = (dir == NULL) ? "logs" : dir; - // Reload the log file after updated the path - GSLog::Close(); - GSLog::Open(); + // Reload the log file after updated the path + GSLog::Close(); + GSLog::Open(); } -EXPORT_C_(s32) GSinit() +EXPORT_C_(s32) +GSinit() { - LoadConfig(); + LoadConfig(); - GSLog::Open(); + GSLog::Open(); - GSLog::WriteLn("Initializing GSnull."); - return 0; + GSLog::WriteLn("Initializing GSnull."); + return 0; } -EXPORT_C_(void) GSshutdown() +EXPORT_C_(void) +GSshutdown() { - GSLog::WriteLn("Shutting down GSnull."); - GSCloseWindow(); - GSLog::Close(); + GSLog::WriteLn("Shutting down GSnull."); + GSCloseWindow(); + GSLog::Close(); } -EXPORT_C_(s32) GSopen(void *pDsp, const char *Title, int multithread) +EXPORT_C_(s32) +GSopen(void* pDsp, const char* Title, int multithread) { - int err = 0; - GSLog::WriteLn("GS open."); - //assert( GSirq != NULL ); + int err = 0; + GSLog::WriteLn("GS open."); + //assert( GSirq != NULL ); - err = GSOpenWindow(pDsp, Title); - gs.MultiThreaded = multithread; + err = GSOpenWindow(pDsp, Title); + gs.MultiThreaded = multithread; - ResetRegs(); - SetMultithreaded(); - InitPath(); - GSLog::WriteLn("Opening GSnull."); - return err; + ResetRegs(); + SetMultithreaded(); + InitPath(); + GSLog::WriteLn("Opening GSnull."); + return err; } #ifdef USE_GSOPEN2 -EXPORT_C_(s32) GSopen2( void *pDsp, u32 flags ) +EXPORT_C_(s32) +GSopen2(void* pDsp, u32 flags) { - GSLog::WriteLn("GS open2."); + GSLog::WriteLn("GS open2."); GSOpenWindow2(pDsp, flags); - gs.MultiThreaded = true; + gs.MultiThreaded = true; - ResetRegs(); - SetMultithreaded(); - InitPath(); - GSLog::WriteLn("Opening GSnull (2)."); - return 0; + ResetRegs(); + SetMultithreaded(); + InitPath(); + GSLog::WriteLn("Opening GSnull (2)."); + return 0; } #endif -EXPORT_C_(void) GSclose() +EXPORT_C_(void) +GSclose() { - GSLog::WriteLn("Closing GSnull."); + GSLog::WriteLn("Closing GSnull."); - // Better to only close the window on Shutdown. All the other plugins - // pretty much worked that way, and all old PCSX2 versions expect it as well. - //GSCloseWindow(); + // Better to only close the window on Shutdown. All the other plugins + // pretty much worked that way, and all old PCSX2 versions expect it as well. + //GSCloseWindow(); } -EXPORT_C_(void) GSirqCallback(void (*callback)()) +EXPORT_C_(void) +GSirqCallback(void (*callback)()) { - GSirq = callback; + GSirq = callback; } -EXPORT_C_(s32) GSfreeze(int mode, freezeData *data) +EXPORT_C_(s32) +GSfreeze(int mode, freezeData* data) { - return 0; + return 0; } -EXPORT_C_(s32) GStest() +EXPORT_C_(s32) +GStest() { - GSLog::WriteLn("Testing GSnull."); - return 0; + GSLog::WriteLn("Testing GSnull."); + return 0; } -EXPORT_C_(void) GSvsync(int field) +EXPORT_C_(void) +GSvsync(int field) { - GSProcessMessages(); + GSProcessMessages(); } - // returns the last tag processed (64 bits) -EXPORT_C_(void) GSgetLastTag(u64* ptag) +// returns the last tag processed (64 bits) +EXPORT_C_(void) +GSgetLastTag(u64* ptag) { - *(u32*)ptag = gs.nPath3Hack; - gs.nPath3Hack = 0; + *(u32*)ptag = gs.nPath3Hack; + gs.nPath3Hack = 0; } -EXPORT_C_(void) GSgifSoftReset(u32 mask) +EXPORT_C_(void) +GSgifSoftReset(u32 mask) { - GSLog::WriteLn("Doing a soft reset of the GS plugin."); + GSLog::WriteLn("Doing a soft reset of the GS plugin."); } -EXPORT_C_(void) GSreadFIFO(u64 *mem) +EXPORT_C_(void) +GSreadFIFO(u64* mem) { } -EXPORT_C_(void) GSreadFIFO2(u64 *mem, int qwc) +EXPORT_C_(void) +GSreadFIFO2(u64* mem, int qwc) { } // extended funcs // GSkeyEvent gets called when there is a keyEvent from the PAD plugin -EXPORT_C_(void) GSkeyEvent(keyEvent *ev) +EXPORT_C_(void) +GSkeyEvent(keyEvent* ev) { - HandleKeyEvent(ev); + HandleKeyEvent(ev); } -EXPORT_C_(void) GSchangeSaveState(int, const char* filename) +EXPORT_C_(void) +GSchangeSaveState(int, const char* filename) { } -EXPORT_C_(void) GSmakeSnapshot(char *path) +EXPORT_C_(void) +GSmakeSnapshot(char* path) { - GSLog::WriteLn("Taking a snapshot."); + GSLog::WriteLn("Taking a snapshot."); } -EXPORT_C_(void) GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg) +EXPORT_C_(void) +GSmakeSnapshot2(char* pathname, int* snapdone, int savejpg) { - GSLog::WriteLn("Taking a snapshot to %s.", pathname); + GSLog::WriteLn("Taking a snapshot to %s.", pathname); } -EXPORT_C_(void) GSsetBaseMem(void*) +EXPORT_C_(void) +GSsetBaseMem(void*) { } -EXPORT_C_(void) GSsetGameCRC(int crc, int gameoptions) +EXPORT_C_(void) +GSsetGameCRC(int crc, int gameoptions) { - GSLog::WriteLn("Setting the crc to '%x' with 0x%x for options.", crc, gameoptions); + GSLog::WriteLn("Setting the crc to '%x' with 0x%x for options.", crc, gameoptions); } // controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done -EXPORT_C_(void) GSsetFrameSkip(int frameskip) +EXPORT_C_(void) +GSsetFrameSkip(int frameskip) { - SetFrameSkip(frameskip != 0); - GSLog::WriteLn("Frameskip set to %d.", frameskip); + SetFrameSkip(frameskip != 0); + GSLog::WriteLn("Frameskip set to %d.", frameskip); } // if start is 1, starts recording spu2 data, else stops // returns a non zero value if successful // for now, pData is not used -EXPORT_C_(int) GSsetupRecording(int start, void* pData) +EXPORT_C_(int) +GSsetupRecording(int start, void* pData) { - if (start) - GSLog::WriteLn("Pretending to record."); - else - GSLog::WriteLn("Pretending to stop recording."); + if (start) + GSLog::WriteLn("Pretending to record."); + else + GSLog::WriteLn("Pretending to stop recording."); - return 1; + return 1; } -EXPORT_C_(void) GSreset() +EXPORT_C_(void) +GSreset() { - GSLog::WriteLn("Doing a reset of the GS plugin."); + GSLog::WriteLn("Doing a reset of the GS plugin."); } -EXPORT_C_(void) GSwriteCSR(u32 value) +EXPORT_C_(void) +GSwriteCSR(u32 value) { } -EXPORT_C_(void) GSgetDriverInfo(GSdriverInfo *info) +EXPORT_C_(void) +GSgetDriverInfo(GSdriverInfo* info) { } diff --git a/plugins/GSnull/GS.h b/plugins/GSnull/GS.h index 125cc554cd..2b803dc0cd 100644 --- a/plugins/GSnull/GS.h +++ b/plugins/GSnull/GS.h @@ -23,11 +23,11 @@ typedef struct _keyEvent keyEvent; #include "Pcsx2Defs.h" #ifdef _WIN32 -# include "Windows/GSwin.h" +#include "Windows/GSwin.h" #endif #ifdef __linux__ -# include "Linux/GSLinux.h" +#include "Linux/GSLinux.h" #endif #define GSdefs @@ -40,7 +40,7 @@ typedef struct _keyEvent keyEvent; #ifdef _MSC_VER #define EXPORT_C_(type) extern "C" type CALLBACK #else -#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type +#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type #endif //#define GS_LOG GSLog::Log @@ -51,22 +51,22 @@ extern const unsigned char build; typedef struct { - int Log; - bool path3; + int Log; + bool path3; } Config; typedef struct { - u32 CSRw; - pathInfo path[4]; - bool Path3transfer; - float q; - u32 imageTransfer; - int MultiThreaded; - int nPath3Hack; - - GIFReg regs; - GIFCTXTReg ctxt_regs[2]; + u32 CSRw; + pathInfo path[4]; + bool Path3transfer; + float q; + u32 imageTransfer; + int MultiThreaded; + int nPath3Hack; + + GIFReg regs; + GIFCTXTReg ctxt_regs[2]; } GSVars; extern GSVars gs; @@ -79,12 +79,12 @@ extern void (*GSirq)(); namespace GSLog { - extern bool Open(); - extern void Close(); - extern void Log(char *fmt, ...); - extern void Message(char *fmt, ...); - extern void Print(const char *fmt, ...); - extern void WriteLn(const char *fmt, ...); +extern bool Open(); +extern void Close(); +extern void Log(char* fmt, ...); +extern void Message(char* fmt, ...); +extern void Print(const char* fmt, ...); +extern void WriteLn(const char* fmt, ...); }; extern void SaveConfig(); diff --git a/plugins/GSnull/GSLog.cpp b/plugins/GSnull/GSLog.cpp index ba9cc9d588..7683865e2c 100644 --- a/plugins/GSnull/GSLog.cpp +++ b/plugins/GSnull/GSLog.cpp @@ -32,88 +32,85 @@ std::string s_strLogPath("logs"); namespace GSLog { - FILE *gsLog; - - bool Open() - { - bool result = true; - - const std::string LogFile(s_strLogPath + "/GSnull.log"); +FILE* gsLog; - gsLog = fopen(LogFile.c_str(), "w"); - - if (gsLog != NULL) - { - setvbuf(gsLog, NULL, _IONBF, 0); - } - else - { - Message("Can't create log file %s.", LogFile.c_str()); - result = false; - } - - WriteLn("GSnull plugin version %d,%d",revision,build); - WriteLn("GS init."); - - return result; - } - - void Close() - { - if (gsLog) - { - fclose(gsLog); - gsLog = NULL; - } - } - - void Log(char *fmt, ...) - { - va_list list; +bool Open() +{ + bool result = true; - if (!conf.Log || gsLog == NULL) return; + const std::string LogFile(s_strLogPath + "/GSnull.log"); - va_start(list, fmt); - vfprintf(gsLog, fmt, list); - va_end(list); - } - - void Message(char *fmt, ...) - { - va_list list; - char msg[512]; + gsLog = fopen(LogFile.c_str(), "w"); - va_start(list, fmt); - vsprintf(msg, fmt, list); - va_end(list); - - SysMessage("%s\n",msg); - } - - void Print(const char *fmt, ...) - { - va_list list; - char msg[512]; + if (gsLog != NULL) { + setvbuf(gsLog, NULL, _IONBF, 0); + } else { + Message("Can't create log file %s.", LogFile.c_str()); + result = false; + } - va_start(list, fmt); - vsprintf(msg, fmt, list); - va_end(list); + WriteLn("GSnull plugin version %d,%d", revision, build); + WriteLn("GS init."); - Log(msg); - fprintf(stderr, "GSnull:%s", msg); - } - - - void WriteLn(const char *fmt, ...) - { - va_list list; - char msg[512]; + return result; +} - va_start(list, fmt); - vsprintf(msg, fmt, list); - va_end(list); +void Close() +{ + if (gsLog) { + fclose(gsLog); + gsLog = NULL; + } +} - Log("%s\n", msg); - fprintf(stderr, "GSnull:%s\n", msg); - } +void Log(char* fmt, ...) +{ + va_list list; + + if (!conf.Log || gsLog == NULL) + return; + + va_start(list, fmt); + vfprintf(gsLog, fmt, list); + va_end(list); +} + +void Message(char* fmt, ...) +{ + va_list list; + char msg[512]; + + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); + + SysMessage("%s\n", msg); +} + +void Print(const char* fmt, ...) +{ + va_list list; + char msg[512]; + + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); + + Log(msg); + fprintf(stderr, "GSnull:%s", msg); +} + + +void WriteLn(const char* fmt, ...) +{ + va_list list; + char msg[512]; + + va_start(list, fmt); + vsprintf(msg, fmt, list); + va_end(list); + + Log("%s\n", msg); + fprintf(stderr, "GSnull:%s\n", msg); +} }; diff --git a/plugins/GSnull/GifTransfer.cpp b/plugins/GSnull/GifTransfer.cpp index 45a79d2ec5..150538ff7e 100644 --- a/plugins/GSnull/GifTransfer.cpp +++ b/plugins/GSnull/GifTransfer.cpp @@ -14,7 +14,7 @@ */ - // Processes a GIFtag & packet, and throws out some gsIRQs as needed. +// Processes a GIFtag & packet, and throws out some gsIRQs as needed. // Used to keep interrupts in sync with the EE, while the GS itself // runs potentially several frames behind. // size - size of the packet in simd128's @@ -26,174 +26,162 @@ using namespace std; extern GSVars gs; -PCSX2_ALIGNED16( u8 g_RealGSMem[0x2000] ); +PCSX2_ALIGNED16(u8 g_RealGSMem[0x2000]); -template void _GSgifTransfer(const u32 *pMem, u32 size) +template +void _GSgifTransfer(const u32* pMem, u32 size) { -// FUNCLOG + // FUNCLOG - pathInfo *path = &gs.path[index]; - - while (size > 0) - { - //GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size); - if (path->nloop == 0) - { - path->setTag(pMem); - pMem += 4; - size--; + pathInfo* path = &gs.path[index]; - // eeuser 7.2.2. GIFtag: "... when NLOOP is 0, the GIF does not output anything, and - // values other than the EOP field are disregarded." - if (path->nloop > 0) - { - gs.q = 1.0f; + while (size > 0) { + //GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size); + if (path->nloop == 0) { + path->setTag(pMem); + pMem += 4; + size--; - if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED)) - { - u32 tagprim = path->tag.PRIM; - GIFRegHandlerPRIM((u32*)&tagprim); - } - } - } - else - { - switch (path->mode) - { - case GIF_FLG_PACKED: - { - // first try a shortcut for a very common case + // eeuser 7.2.2. GIFtag: "... when NLOOP is 0, the GIF does not output anything, and + // values other than the EOP field are disregarded." + if (path->nloop > 0) { + gs.q = 1.0f; - if (path->adonly && size >= path->nloop) - { - size -= path->nloop; + if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED)) { + u32 tagprim = path->tag.PRIM; + GIFRegHandlerPRIM((u32*)&tagprim); + } + } + } else { + switch (path->mode) { + case GIF_FLG_PACKED: { + // first try a shortcut for a very common case - do - { - GIFPackedRegHandlerA_D(pMem); + if (path->adonly && size >= path->nloop) { + size -= path->nloop; - pMem += 4; //sizeof(GIFPackedReg)/4; - } - while(--path->nloop > 0); - break; - } + do { + GIFPackedRegHandlerA_D(pMem); - do - { - u32 reg = path->GetReg(); - GIFPackedRegHandlers[reg](pMem); - - pMem += 4; //sizeof(GIFPackedReg)/4; - size--; - } - while (path->StepReg() && (size > 0)); + pMem += 4; //sizeof(GIFPackedReg)/4; + } while (--path->nloop > 0); + break; + } - break; - } + do { + u32 reg = path->GetReg(); + GIFPackedRegHandlers[reg](pMem); - case GIF_FLG_REGLIST: - { - //GSLog::Writeln("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4); + pMem += 4; //sizeof(GIFPackedReg)/4; + size--; + } while (path->StepReg() && (size > 0)); - size *= 2; + break; + } - do - { - GIFRegHandlers[path->GetReg()](pMem); + case GIF_FLG_REGLIST: { + //GSLog::Writeln("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4); - pMem += 2; - size--; - } - while (path->StepReg() && (size > 0)); + size *= 2; - if (size & 1) pMem += 2; - size /= 2; - break; - } + do { + GIFRegHandlers[path->GetReg()](pMem); - case GIF_FLG_IMAGE: // FROM_VFRAM - case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too. - { - int len = min(size, path->nloop); - //GSLog::Writeln("GIF_FLG_IMAGE(%d)=%d", gs.imageTransfer, len); + pMem += 2; + size--; + } while (path->StepReg() && (size > 0)); - switch (gs.imageTransfer) - { - case 0: - //TransferHostLocal(pMem, len * 4); - break; + if (size & 1) + pMem += 2; + size /= 2; + break; + } - case 1: - // This can't happen; downloads can not be started or performed as part of - // a GIFtag operation. They're an entirely separate process that can only be - // done through the ReverseFIFO transfer (aka ReadFIFO). --air - assert(0); - break; + case GIF_FLG_IMAGE: // FROM_VFRAM + case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too. + { + int len = min(size, path->nloop); + //GSLog::Writeln("GIF_FLG_IMAGE(%d)=%d", gs.imageTransfer, len); - case 2: - // //TransferLocalLocal(); - break; + switch (gs.imageTransfer) { + case 0: + //TransferHostLocal(pMem, len * 4); + break; - case 3: - //assert(0); - break; + case 1: + // This can't happen; downloads can not be started or performed as part of + // a GIFtag operation. They're an entirely separate process that can only be + // done through the ReverseFIFO transfer (aka ReadFIFO). --air + assert(0); + break; - default: - //assert(0); - break; - } + case 2: + // //TransferLocalLocal(); + break; - pMem += len * 4; + case 3: + //assert(0); + break; - path->nloop -= len; - size -= len; + default: + //assert(0); + break; + } - break; - } + pMem += len * 4; - default: // GIF_IMAGE - GSLog::WriteLn("*** WARNING **** Unexpected GIFTag flag."); - assert(0); - path->nloop = 0; - break; - } - } - } + path->nloop -= len; + size -= len; + + break; + } + + default: // GIF_IMAGE + GSLog::WriteLn("*** WARNING **** Unexpected GIFTag flag."); + assert(0); + path->nloop = 0; + break; + } + } + } } #define DO_GIF_TRANSFERS // Obsolete. Included because it's still in GSdef. -EXPORT_C_(void) GSgifTransfer1(u32 *pMem, u32 addr) +EXPORT_C_(void) +GSgifTransfer1(u32* pMem, u32 addr) { #ifdef DO_GIF_TRANSFERS - _GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr) / 16); + _GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr) / 16); #endif } -EXPORT_C_(void) GSgifTransfer(const u32 *pMem, u32 size) +EXPORT_C_(void) +GSgifTransfer(const u32* pMem, u32 size) { #ifdef DO_GIF_TRANSFERS - _GSgifTransfer<3>(const_cast(pMem), size); + _GSgifTransfer<3>(const_cast(pMem), size); #endif } -EXPORT_C_(void) GSgifTransfer2(u32 *pMem, u32 size) +EXPORT_C_(void) +GSgifTransfer2(u32* pMem, u32 size) { #ifdef DO_GIF_TRANSFERS - _GSgifTransfer<1>(const_cast(pMem), size); + _GSgifTransfer<1>(const_cast(pMem), size); #endif } -EXPORT_C_(void) GSgifTransfer3(u32 *pMem, u32 size) +EXPORT_C_(void) +GSgifTransfer3(u32* pMem, u32 size) { #ifdef DO_GIF_TRANSFERS - _GSgifTransfer<2>(const_cast(pMem), size); + _GSgifTransfer<2>(const_cast(pMem), size); #endif } void InitPath() { - gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = gs.path[3].mode = 0; + gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = gs.path[3].mode = 0; } - diff --git a/plugins/GSnull/GifTransfer.h b/plugins/GSnull/GifTransfer.h index 583efc78d7..f1535b3245 100644 --- a/plugins/GSnull/GifTransfer.h +++ b/plugins/GSnull/GifTransfer.h @@ -20,110 +20,113 @@ #include #include "Registers.h" -enum GIF_FLG -{ - GIF_FLG_PACKED = 0, - GIF_FLG_REGLIST = 1, - GIF_FLG_IMAGE = 2, - GIF_FLG_IMAGE2 = 3 +enum GIF_FLG { + GIF_FLG_PACKED = 0, + GIF_FLG_REGLIST = 1, + GIF_FLG_IMAGE = 2, + GIF_FLG_IMAGE2 = 3 }; // // GIFTag union GIFTag { - u64 ai64[2]; - u32 ai32[4]; + u64 ai64[2]; + u32 ai32[4]; - struct - { - u32 NLOOP : 15; - u32 EOP : 1; - u32 _PAD1 : 16; - u32 _PAD2 : 14; - u32 PRE : 1; - u32 PRIM : 11; - u32 FLG : 2; // enum GIF_FLG - u32 NREG : 4; - u64 REGS : 64; - }; + struct + { + u32 NLOOP : 15; + u32 EOP : 1; + u32 _PAD1 : 16; + u32 _PAD2 : 14; + u32 PRE : 1; + u32 PRIM : 11; + u32 FLG : 2; // enum GIF_FLG + u32 NREG : 4; + u64 REGS : 64; + }; - void set(const u32 *data) - { - for (int i = 0; i <= 3; i++) - { - ai32[i] = data[i]; - } - } + void set(const u32* data) + { + for (int i = 0; i <= 3; i++) { + ai32[i] = data[i]; + } + } - GIFTag(u32 *data) - { - set(data); - } + GIFTag(u32* data) + { + set(data); + } - GIFTag(){ ai64[0] = 0; ai64[1] = 0; } + GIFTag() + { + ai64[0] = 0; + ai64[1] = 0; + } }; // EE part. Data transfer packet description typedef struct { - u32 mode; - int reg; - u64 regs; - u32 nloop; - int eop; - int nreg; - u32 adonly; - GIFTag tag; + u32 mode; + int reg; + u64 regs; + u32 nloop; + int eop; + int nreg; + u32 adonly; + GIFTag tag; - void setTag(const u32 *data) - { - tag.set(data); + void setTag(const u32* data) + { + tag.set(data); - nloop = tag.NLOOP; - eop = tag.EOP; - mode = tag.FLG; - //adonly = false; + nloop = tag.NLOOP; + eop = tag.EOP; + mode = tag.FLG; + //adonly = false; - // Hmm.... - nreg = tag.NREG << 2; - if (nreg == 0) nreg = 64; - regs = tag.REGS; - reg = 0; - //if ((nreg == 4) && (regs == GIF_REG_A_D)) adonly = true; + // Hmm.... + nreg = tag.NREG << 2; + if (nreg == 0) + nreg = 64; + regs = tag.REGS; + reg = 0; + //if ((nreg == 4) && (regs == GIF_REG_A_D)) adonly = true; - // GSLog::Writeln"GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d", - // data[3], data[2], data[1], data[0], - // path->eop, path->nloop, mode, path->nreg, tag.PRE); - } + // GSLog::Writeln"GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d", + // data[3], data[2], data[1], data[0], + // path->eop, path->nloop, mode, path->nreg, tag.PRE); + } - u32 GetReg() - { - return (regs >> reg) & 0xf; - } + u32 GetReg() + { + return (regs >> reg) & 0xf; + } - bool StepReg() - { - reg += 4; + bool StepReg() + { + reg += 4; - if (reg == nreg) - { - reg = 0; - nloop--; + if (reg == nreg) { + reg = 0; + nloop--; - if (nloop == 0) return false; - } + if (nloop == 0) + return false; + } - return true; - } + return true; + } } pathInfo; -extern void _GSgifPacket(pathInfo *path, const u32 *pMem); -extern void _GSgifRegList(pathInfo *path, const u32 *pMem); -template -extern void _GSgifTransfer(const u32 *pMem, u32 size); +extern void _GSgifPacket(pathInfo* path, const u32* pMem); +extern void _GSgifRegList(pathInfo* path, const u32* pMem); +template +extern void _GSgifTransfer(const u32* pMem, u32 size); extern GIFRegHandler GIFPackedRegHandlers[]; extern GIFRegHandler GIFRegHandlers[]; -#endif // GIFTRANSFER_H_INCLUDED +#endif // GIFTRANSFER_H_INCLUDED diff --git a/plugins/GSnull/Linux/Config.cpp b/plugins/GSnull/Linux/Config.cpp index 20b3797a57..3bfd4ba201 100644 --- a/plugins/GSnull/Linux/Config.cpp +++ b/plugins/GSnull/Linux/Config.cpp @@ -27,41 +27,39 @@ PluginConf Ini; void CFGabout() { - SysMessage("GSnull: A simple null plugin."); + SysMessage("GSnull: A simple null plugin."); } void CFGconfigure() { - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); + LoadConfig(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } void LoadConfig() { const std::string iniFile(s_strIniPath + "/GSNull.ini"); - if (!Ini.Open(iniFile, READ_FILE)) - { - printf("failed to open %s\n", iniFile.c_str()); - SaveConfig();//save and return - return; - } + if (!Ini.Open(iniFile, READ_FILE)) { + printf("failed to open %s\n", iniFile.c_str()); + SaveConfig(); //save and return + return; + } - conf.Log = Ini.ReadInt("logging", 0); - Ini.Close(); + conf.Log = Ini.ReadInt("logging", 0); + Ini.Close(); } void SaveConfig() { const std::string iniFile(s_strIniPath + "/GSNull.ini"); - if (!Ini.Open(iniFile, WRITE_FILE)) - { - printf("failed to open %s\n", iniFile.c_str()); - return; - } + if (!Ini.Open(iniFile, WRITE_FILE)) { + printf("failed to open %s\n", iniFile.c_str()); + return; + } - Ini.WriteInt("logging", conf.Log); - Ini.Close(); + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } diff --git a/plugins/GSnull/Linux/Config.h b/plugins/GSnull/Linux/Config.h index 5b691e066f..0cb5f0767e 100644 --- a/plugins/GSnull/Linux/Config.h +++ b/plugins/GSnull/Linux/Config.h @@ -19,6 +19,6 @@ void SaveConf(); void LoadConf(); -extern long CFGmessage(char *msg); +extern long CFGmessage(char* msg); extern void CFGconfigure(); extern void CFGabout(); diff --git a/plugins/GSnull/Linux/GSLinux.cpp b/plugins/GSnull/Linux/GSLinux.cpp index 9f8349a200..c583be1a88 100644 --- a/plugins/GSnull/Linux/GSLinux.cpp +++ b/plugins/GSnull/Linux/GSLinux.cpp @@ -16,32 +16,32 @@ #include "GS.h" #include "GSLinux.h" -Display *display; +Display* display; int screen; -GtkScrolledWindow *win; +GtkScrolledWindow* win; -int GSOpenWindow(void *pDsp, const char *Title) +int GSOpenWindow(void* pDsp, const char* Title) { - display = XOpenDisplay(0); - screen = DefaultScreen(display); + display = XOpenDisplay(0); + screen = DefaultScreen(display); - if (pDsp != NULL) - *(Display**)pDsp = display; - else - return -1; + if (pDsp != NULL) + *(Display**)pDsp = display; + else + return -1; - return 0; + return 0; } -int GSOpenWindow2(void *pDsp, u32 flags) +int GSOpenWindow2(void* pDsp, u32 flags) { - GtkWidget *widget; - if (pDsp != NULL) - win = *(GtkScrolledWindow**)pDsp; - else - return -1; + GtkWidget* widget; + if (pDsp != NULL) + win = *(GtkScrolledWindow**)pDsp; + else + return -1; - return 0; + return 0; } void GSCloseWindow() @@ -52,67 +52,62 @@ void GSCloseWindow() void GSProcessMessages() { - if ( GSKeyEvent ) - { - int myKeyEvent = GSKeyEvent; - bool myShift = GSShift; - GSKeyEvent = 0; + if (GSKeyEvent) { + int myKeyEvent = GSKeyEvent; + bool myShift = GSShift; + GSKeyEvent = 0; - switch ( myKeyEvent ) - { - case XK_F5: - OnKeyboardF5(myShift); - break; - case XK_F6: - OnKeyboardF6(myShift); - break; - case XK_F7: - OnKeyboardF7(myShift); - break; - case XK_F9: - OnKeyboardF9(myShift); - break; - } - } + switch (myKeyEvent) { + case XK_F5: + OnKeyboardF5(myShift); + break; + case XK_F6: + OnKeyboardF6(myShift); + break; + case XK_F7: + OnKeyboardF7(myShift); + break; + case XK_F9: + OnKeyboardF9(myShift); + break; + } + } } -void HandleKeyEvent(keyEvent *ev) +void HandleKeyEvent(keyEvent* ev) { - switch(ev->evt) - { - case KEYPRESS: - switch(ev->key) - { - case XK_F5: - case XK_F6: - case XK_F7: - case XK_F9: - GSKeyEvent = ev->key ; - break; - case XK_Escape: - break; - case XK_Shift_L: - case XK_Shift_R: - GSShift = true; - break; - case XK_Alt_L: - case XK_Alt_R: - GSAlt = true; - break; - } - break; - case KEYRELEASE: - switch(ev->key) - { - case XK_Shift_L: - case XK_Shift_R: - GSShift = false; - break; - case XK_Alt_L: - case XK_Alt_R: - GSAlt = false; - break; - } - } + switch (ev->evt) { + case KEYPRESS: + switch (ev->key) { + case XK_F5: + case XK_F6: + case XK_F7: + case XK_F9: + GSKeyEvent = ev->key; + break; + case XK_Escape: + break; + case XK_Shift_L: + case XK_Shift_R: + GSShift = true; + break; + case XK_Alt_L: + case XK_Alt_R: + GSAlt = true; + break; + } + break; + case KEYRELEASE: + switch (ev->key) { + case XK_Shift_L: + case XK_Shift_R: + GSShift = false; + break; + case XK_Alt_L: + case XK_Alt_R: + GSAlt = false; + break; + } + } } diff --git a/plugins/GSnull/Linux/GSLinux.h b/plugins/GSnull/Linux/GSLinux.h index 5b872ef223..c775b46088 100644 --- a/plugins/GSnull/Linux/GSLinux.h +++ b/plugins/GSnull/Linux/GSLinux.h @@ -20,10 +20,10 @@ #include #include -extern int GSOpenWindow(void *pDsp, const char *Title); -extern int GSOpenWindow2(void *pDsp, u32 flags); +extern int GSOpenWindow(void* pDsp, const char* Title); +extern int GSOpenWindow2(void* pDsp, u32 flags); extern void GSCloseWindow(); extern void GSProcessMessages(); -extern void HandleKeyEvent(keyEvent *ev); +extern void HandleKeyEvent(keyEvent* ev); #endif diff --git a/plugins/GSnull/Linux/Linux.cpp b/plugins/GSnull/Linux/Linux.cpp index 2d317a4702..23c9cd431a 100644 --- a/plugins/GSnull/Linux/Linux.cpp +++ b/plugins/GSnull/Linux/Linux.cpp @@ -19,13 +19,14 @@ #include "GS.h" #include "Config.h" -EXPORT_C_(void) GSconfigure() +EXPORT_C_(void) +GSconfigure() { - CFGconfigure(); + CFGconfigure(); } -EXPORT_C_(void) GSabout() +EXPORT_C_(void) +GSabout() { - CFGabout(); + CFGabout(); } - diff --git a/plugins/GSnull/Registers.cpp b/plugins/GSnull/Registers.cpp index dbc892ef23..650f630fbd 100644 --- a/plugins/GSnull/Registers.cpp +++ b/plugins/GSnull/Registers.cpp @@ -15,14 +15,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - + #include "GS.h" #include "Registers.h" GIFRegHandler GIFPackedRegHandlers[16]; GIFRegHandler GIFRegHandlers[256]; -// For now, I'm just rigging this up to store all the register information coming in, without doing +// For now, I'm just rigging this up to store all the register information coming in, without doing // any of the normal processing. void __gifCall GIFPackedRegHandlerNull(const u32* data) @@ -33,15 +33,15 @@ void __gifCall GIFPackedRegHandlerNull(const u32* data) void __gifCall GIFPackedRegHandlerPRIM(const u32* data) { GIFRegHandlerPRIM(data); } template -void __gifCall GIFPackedRegHandlerTEX0(const u32* data) -{ - GIFRegHandlerTEX0(data); +void __gifCall GIFPackedRegHandlerTEX0(const u32* data) +{ + GIFRegHandlerTEX0(data); } template -void __gifCall GIFPackedRegHandlerCLAMP(const u32* data) -{ - GIFRegHandlerCLAMP(data); +void __gifCall GIFPackedRegHandlerCLAMP(const u32* data) +{ + GIFRegHandlerCLAMP(data); } void __gifCall GIFPackedRegHandlerTEX0_1(const u32* data) { GIFRegHandlerTEX0<0>(data); } @@ -53,27 +53,27 @@ void __gifCall GIFPackedRegHandlerXYZ3(const u32* data) { GIFRegHandlerXYZ3(data void __gifCall GIFPackedRegHandlerRGBA(const u32* data) { - GIFPackedRGBA* r = (GIFPackedRGBA*)(data); - gs.regs.RGBAQ.R = r->R; - gs.regs.RGBAQ.G = r->G; - gs.regs.RGBAQ.B = r->B; - gs.regs.RGBAQ.A = r->A; - gs.regs.RGBAQ.Q = gs.q; + GIFPackedRGBA* r = (GIFPackedRGBA*)(data); + gs.regs.RGBAQ.R = r->R; + gs.regs.RGBAQ.G = r->G; + gs.regs.RGBAQ.B = r->B; + gs.regs.RGBAQ.A = r->A; + gs.regs.RGBAQ.Q = gs.q; } void __gifCall GIFPackedRegHandlerSTQ(const u32* data) { - GIFPackedSTQ* r = (GIFPackedSTQ*)(data); - gs.regs.ST.S = r->S; - gs.regs.ST.T = r->T; - gs.q = r->Q; + GIFPackedSTQ* r = (GIFPackedSTQ*)(data); + gs.regs.ST.S = r->S; + gs.regs.ST.T = r->T; + gs.q = r->Q; } void __gifCall GIFPackedRegHandlerUV(const u32* data) { - GIFPackedUV* r = (GIFPackedUV*)(data); - gs.regs.UV.U = r->U; - gs.regs.UV.V = r->V; + GIFPackedUV* r = (GIFPackedUV*)(data); + gs.regs.UV.U = r->U; + gs.regs.UV.V = r->V; } void __gifCall KickVertex(bool adc) @@ -82,32 +82,32 @@ void __gifCall KickVertex(bool adc) void __gifCall GIFPackedRegHandlerXYZF2(const u32* data) { - GIFPackedXYZF2* r = (GIFPackedXYZF2*)(data); - gs.regs.XYZ.X = r->X; - gs.regs.XYZ.Y = r->Y; - gs.regs.XYZ.Z = r->Z; - gs.regs.FOG.F = r->F; + GIFPackedXYZF2* r = (GIFPackedXYZF2*)(data); + gs.regs.XYZ.X = r->X; + gs.regs.XYZ.Y = r->Y; + gs.regs.XYZ.Z = r->Z; + gs.regs.FOG.F = r->F; } void __gifCall GIFPackedRegHandlerXYZ2(const u32* data) { - GIFPackedXYZ2* r = (GIFPackedXYZ2*)(data); - gs.regs.XYZ.X = r->X; - gs.regs.XYZ.Y = r->Y; - gs.regs.XYZ.Z = r->Z; + GIFPackedXYZ2* r = (GIFPackedXYZ2*)(data); + gs.regs.XYZ.X = r->X; + gs.regs.XYZ.Y = r->Y; + gs.regs.XYZ.Z = r->Z; } void __gifCall GIFPackedRegHandlerFOG(const u32* data) { - GIFPackedFOG* r = (GIFPackedFOG*)(data); - gs.regs.FOG.F = r->F; + GIFPackedFOG* r = (GIFPackedFOG*)(data); + gs.regs.FOG.F = r->F; } void __gifCall GIFPackedRegHandlerA_D(const u32* data) { - GIFPackedA_D* r = (GIFPackedA_D*)(data); - - GIFRegHandlers[r->ADDR](data); + GIFPackedA_D* r = (GIFPackedA_D*)(data); + + GIFRegHandlers[r->ADDR](data); } void __gifCall GIFPackedRegHandlerNOP(const u32* data) @@ -120,64 +120,64 @@ void __gifCall GIFRegHandlerNull(const u32* data) void __gifCall GIFRegHandlerRGBAQ(const u32* data) { - GIFRegRGBAQ* r = (GIFRegRGBAQ*)(data); - gs.regs.RGBAQ._u64 = r->_u64; + GIFRegRGBAQ* r = (GIFRegRGBAQ*)(data); + gs.regs.RGBAQ._u64 = r->_u64; } void __gifCall GIFRegHandlerST(const u32* data) { - GIFRegST* r = (GIFRegST*)(data); - gs.regs.ST._u64 = r->_u64; + GIFRegST* r = (GIFRegST*)(data); + gs.regs.ST._u64 = r->_u64; } void __gifCall GIFRegHandlerUV(const u32* data) { - GIFRegUV* r = (GIFRegUV*)(data); - gs.regs.UV._u64 = r->_u64; + GIFRegUV* r = (GIFRegUV*)(data); + gs.regs.UV._u64 = r->_u64; } void __gifCall GIFRegHandlerXYZF2(const u32* data) { - GIFRegXYZF* r = (GIFRegXYZF*)(data); - gs.regs.XYZF._u64 = r->_u64; + GIFRegXYZF* r = (GIFRegXYZF*)(data); + gs.regs.XYZF._u64 = r->_u64; } void __gifCall GIFRegHandlerXYZ2(const u32* data) { - GIFRegXYZ* r = (GIFRegXYZ*)(data); - gs.regs.XYZ._u64 = r->_u64; + GIFRegXYZ* r = (GIFRegXYZ*)(data); + gs.regs.XYZ._u64 = r->_u64; } template void __gifCall GIFRegHandlerTEX0(const u32* data) { - GIFRegTEX0* r = (GIFRegTEX0*)(data); - gs.ctxt_regs[i].TEX0._u64 = r->_u64; + GIFRegTEX0* r = (GIFRegTEX0*)(data); + gs.ctxt_regs[i].TEX0._u64 = r->_u64; } template void __gifCall GIFRegHandlerCLAMP(const u32* data) { - GIFRegCLAMP* r = (GIFRegCLAMP*)(data); - gs.ctxt_regs[i].CLAMP._u64 = r->_u64; + GIFRegCLAMP* r = (GIFRegCLAMP*)(data); + gs.ctxt_regs[i].CLAMP._u64 = r->_u64; } void __gifCall GIFRegHandlerFOG(const u32* data) { - GIFRegFOG* r = (GIFRegFOG*)(data); - gs.regs.FOG.F = r->F; + GIFRegFOG* r = (GIFRegFOG*)(data); + gs.regs.FOG.F = r->F; } void __gifCall GIFRegHandlerXYZF3(const u32* data) { - GIFRegXYZF* r = (GIFRegXYZF*)(data); - gs.regs.XYZF._u64 = r->_u64; + GIFRegXYZF* r = (GIFRegXYZF*)(data); + gs.regs.XYZF._u64 = r->_u64; } void __gifCall GIFRegHandlerXYZ3(const u32* data) { - GIFRegXYZ* r = (GIFRegXYZ*)(data); - gs.regs.XYZ._u64 = r->_u64; + GIFRegXYZ* r = (GIFRegXYZ*)(data); + gs.regs.XYZ._u64 = r->_u64; } void __gifCall GIFRegHandlerNOP(const u32* data) @@ -187,360 +187,352 @@ void __gifCall GIFRegHandlerNOP(const u32* data) template void __fastcall GIFRegHandlerTEX1(const u32* data) { - GIFRegTEX1* r = (GIFRegTEX1*)(data); - gs.ctxt_regs[i].TEX1._u64 = r->_u64; + GIFRegTEX1* r = (GIFRegTEX1*)(data); + gs.ctxt_regs[i].TEX1._u64 = r->_u64; } template void __gifCall GIFRegHandlerTEX2(const u32* data) { - GIFRegTEX2* r = (GIFRegTEX2*)(data); - gs.ctxt_regs[i].TEX2._u64 = r->_u64; + GIFRegTEX2* r = (GIFRegTEX2*)(data); + gs.ctxt_regs[i].TEX2._u64 = r->_u64; } template void __gifCall GIFRegHandlerXYOFFSET(const u32* data) { - GIFRegXYOFFSET* r = (GIFRegXYOFFSET*)(data); - gs.ctxt_regs[i].XYOFFSET.OFX = r->OFX; - gs.ctxt_regs[i].XYOFFSET.OFY = r->OFY; + GIFRegXYOFFSET* r = (GIFRegXYOFFSET*)(data); + gs.ctxt_regs[i].XYOFFSET.OFX = r->OFX; + gs.ctxt_regs[i].XYOFFSET.OFY = r->OFY; } // Fill out the vertex queue(prim) and the attributes. -void __gifCall GIFRegHandlerPRIM(const u32 *data) +void __gifCall GIFRegHandlerPRIM(const u32* data) { - GIFRegPRIM* r = (GIFRegPRIM*)(data); - gs.regs.PRIM._u64 = r->_u64; + GIFRegPRIM* r = (GIFRegPRIM*)(data); + gs.regs.PRIM._u64 = r->_u64; } // Fill out an alternate set of attributes. void __gifCall GIFRegHandlerPRMODE(const u32* data) { - GIFRegPRMODE* r = (GIFRegPRMODE*)(data); - gs.regs.PRMODE._u64 = r->_u64; + GIFRegPRMODE* r = (GIFRegPRMODE*)(data); + gs.regs.PRMODE._u64 = r->_u64; } // Switch between the primary set of attributes and the secondary. void __gifCall GIFRegHandlerPRMODECONT(const u32* data) { - GIFRegPRMODECONT* r = (GIFRegPRMODECONT*)(data); - gs.regs.PRMODECONT._u64 = r->_u64; + GIFRegPRMODECONT* r = (GIFRegPRMODECONT*)(data); + gs.regs.PRMODECONT._u64 = r->_u64; } void __gifCall GIFRegHandlerTEXCLUT(const u32* data) { - GIFRegTEXCLUT* r = (GIFRegTEXCLUT*)(data); - gs.regs.TEXCLUT._u64 = r->_u64; + GIFRegTEXCLUT* r = (GIFRegTEXCLUT*)(data); + gs.regs.TEXCLUT._u64 = r->_u64; } void __gifCall GIFRegHandlerSCANMSK(const u32* data) { - GIFRegSCANMSK* r = (GIFRegSCANMSK*)(data); - gs.regs.SCANMSK._u64 = r->_u64; + GIFRegSCANMSK* r = (GIFRegSCANMSK*)(data); + gs.regs.SCANMSK._u64 = r->_u64; } template void __gifCall GIFRegHandlerMIPTBP1(const u32* data) { - GIFRegMIPTBP1* r = (GIFRegMIPTBP1*)(data); - gs.ctxt_regs[i].MIPTBP1._u64 = r->_u64; + GIFRegMIPTBP1* r = (GIFRegMIPTBP1*)(data); + gs.ctxt_regs[i].MIPTBP1._u64 = r->_u64; } template void __gifCall GIFRegHandlerMIPTBP2(const u32* data) { - GIFRegMIPTBP2* r = (GIFRegMIPTBP2*)(data); - gs.ctxt_regs[i].MIPTBP2._u64 = r->_u64; + GIFRegMIPTBP2* r = (GIFRegMIPTBP2*)(data); + gs.ctxt_regs[i].MIPTBP2._u64 = r->_u64; } void __gifCall GIFRegHandlerTEXA(const u32* data) { - GIFRegTEXA* r = (GIFRegTEXA*)(data); - gs.regs.TEXA._u64 = r->_u64; + GIFRegTEXA* r = (GIFRegTEXA*)(data); + gs.regs.TEXA._u64 = r->_u64; } void __gifCall GIFRegHandlerFOGCOL(const u32* data) { - GIFRegFOGCOL* r = (GIFRegFOGCOL*)(data); - gs.regs.FOGCOL._u64 = r->_u64; + GIFRegFOGCOL* r = (GIFRegFOGCOL*)(data); + gs.regs.FOGCOL._u64 = r->_u64; } void __gifCall GIFRegHandlerTEXFLUSH(const u32* data) { - GIFRegTEXFLUSH* r = (GIFRegTEXFLUSH*)(data); - gs.regs.TEXFLUSH._u64 = r->_u64; + GIFRegTEXFLUSH* r = (GIFRegTEXFLUSH*)(data); + gs.regs.TEXFLUSH._u64 = r->_u64; } template void __gifCall GIFRegHandlerSCISSOR(const u32* data) { - GIFRegSCISSOR* r = (GIFRegSCISSOR*)(data); - gs.ctxt_regs[i].SCISSOR._u64 = r->_u64; + GIFRegSCISSOR* r = (GIFRegSCISSOR*)(data); + gs.ctxt_regs[i].SCISSOR._u64 = r->_u64; } template void __gifCall GIFRegHandlerALPHA(const u32* data) { - GIFRegALPHA* r = (GIFRegALPHA*)(data); - gs.ctxt_regs[i].ALPHA._u64 = r->_u64; + GIFRegALPHA* r = (GIFRegALPHA*)(data); + gs.ctxt_regs[i].ALPHA._u64 = r->_u64; } void __gifCall GIFRegHandlerDIMX(const u32* data) { - GIFRegDIMX* r = (GIFRegDIMX*)(data); - gs.regs.DIMX._u64 = r->_u64; + GIFRegDIMX* r = (GIFRegDIMX*)(data); + gs.regs.DIMX._u64 = r->_u64; } void __gifCall GIFRegHandlerDTHE(const u32* data) { - GIFRegDTHE* r = (GIFRegDTHE*)(data); - gs.regs.DTHE._u64 = r->_u64; + GIFRegDTHE* r = (GIFRegDTHE*)(data); + gs.regs.DTHE._u64 = r->_u64; } void __gifCall GIFRegHandlerCOLCLAMP(const u32* data) { - GIFRegCOLCLAMP* r = (GIFRegCOLCLAMP*)(data); - gs.regs.COLCLAMP._u64 = r->_u64; + GIFRegCOLCLAMP* r = (GIFRegCOLCLAMP*)(data); + gs.regs.COLCLAMP._u64 = r->_u64; } template void __gifCall GIFRegHandlerTEST(const u32* data) { - GIFRegTEST* r = (GIFRegTEST*)(data); - gs.ctxt_regs[i].TEST._u64 = r->_u64; + GIFRegTEST* r = (GIFRegTEST*)(data); + gs.ctxt_regs[i].TEST._u64 = r->_u64; } void __gifCall GIFRegHandlerPABE(const u32* data) { - GIFRegPABE* r = (GIFRegPABE*)(data); - gs.regs.PABE._u64 = r->_u64; + GIFRegPABE* r = (GIFRegPABE*)(data); + gs.regs.PABE._u64 = r->_u64; } template void __gifCall GIFRegHandlerFBA(const u32* data) { - GIFRegFBA* r = (GIFRegFBA*)(data); - gs.ctxt_regs[i].FBA._u64 = r->_u64; + GIFRegFBA* r = (GIFRegFBA*)(data); + gs.ctxt_regs[i].FBA._u64 = r->_u64; } -template +template void __gifCall GIFRegHandlerFRAME(const u32* data) { - GIFRegFRAME* r = (GIFRegFRAME*)(data); - gs.ctxt_regs[i].FRAME._u64 = r->_u64; + GIFRegFRAME* r = (GIFRegFRAME*)(data); + gs.ctxt_regs[i].FRAME._u64 = r->_u64; } template void __gifCall GIFRegHandlerZBUF(const u32* data) { - GIFRegZBUF* r = (GIFRegZBUF*)(data); - gs.ctxt_regs[i].ZBUF._u64 = r->_u64; + GIFRegZBUF* r = (GIFRegZBUF*)(data); + gs.ctxt_regs[i].ZBUF._u64 = r->_u64; } void __gifCall GIFRegHandlerBITBLTBUF(const u32* data) { - GIFRegBITBLTBUF* r = (GIFRegBITBLTBUF*)(data); - gs.regs.BITBLTBUF._u64 = r->_u64; + GIFRegBITBLTBUF* r = (GIFRegBITBLTBUF*)(data); + gs.regs.BITBLTBUF._u64 = r->_u64; } void __gifCall GIFRegHandlerTRXPOS(const u32* data) { - GIFRegTRXPOS* r = (GIFRegTRXPOS*)(data); - gs.regs.TRXPOS._u64 = r->_u64; + GIFRegTRXPOS* r = (GIFRegTRXPOS*)(data); + gs.regs.TRXPOS._u64 = r->_u64; } void __gifCall GIFRegHandlerTRXREG(const u32* data) { - GIFRegTRXREG* r = (GIFRegTRXREG*)(data); - gs.regs.TRXREG._u64 = r->_u64; + GIFRegTRXREG* r = (GIFRegTRXREG*)(data); + gs.regs.TRXREG._u64 = r->_u64; } void __gifCall GIFRegHandlerTRXDIR(const u32* data) { - GIFRegTRXDIR* r = (GIFRegTRXDIR*)(data); - gs.regs.TRXDIR._u64 = r->_u64; + GIFRegTRXDIR* r = (GIFRegTRXDIR*)(data); + gs.regs.TRXDIR._u64 = r->_u64; } void __gifCall GIFRegHandlerHWREG(const u32* data) { - GIFRegHWREG* r = (GIFRegHWREG*)(data); - gs.regs.HWREG._u64 = r->_u64; + GIFRegHWREG* r = (GIFRegHWREG*)(data); + gs.regs.HWREG._u64 = r->_u64; } void __gifCall GIFRegHandlerSIGNAL(const u32* data) { - GIFRegSIGNAL* r = (GIFRegSIGNAL*)(data); - gs.regs.SIGNAL._u64 = r->_u64; + GIFRegSIGNAL* r = (GIFRegSIGNAL*)(data); + gs.regs.SIGNAL._u64 = r->_u64; } void __gifCall GIFRegHandlerFINISH(const u32* data) { - GIFRegFINISH* r = (GIFRegFINISH*)(data); - gs.regs.FINISH._u64 = r->_u64; + GIFRegFINISH* r = (GIFRegFINISH*)(data); + gs.regs.FINISH._u64 = r->_u64; } void __gifCall GIFRegHandlerLABEL(const u32* data) { - GIFRegLABEL* r = (GIFRegLABEL*)(data); - gs.regs.LABEL._u64 = r->_u64; + GIFRegLABEL* r = (GIFRegLABEL*)(data); + gs.regs.LABEL._u64 = r->_u64; } void SetMultithreaded() { - // Some older versions of PCSX2 didn't properly set the irq callback to NULL - // in multithreaded mode (possibly because ZeroGS itself would assert in such - // cases), and didn't bind them to a dummy callback either. PCSX2 handles all - // IRQs internally when multithreaded anyway -- so let's ignore them here: + // Some older versions of PCSX2 didn't properly set the irq callback to NULL + // in multithreaded mode (possibly because ZeroGS itself would assert in such + // cases), and didn't bind them to a dummy callback either. PCSX2 handles all + // IRQs internally when multithreaded anyway -- so let's ignore them here: - if (gs.MultiThreaded) - { - GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerNull; - GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerNull; - GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerNull; - } - else - { - GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerSIGNAL; - GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerFINISH; - GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerLABEL; - } + if (gs.MultiThreaded) { + GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerNull; + GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerNull; + GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerNull; + } else { + GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerSIGNAL; + GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerFINISH; + GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerLABEL; + } } void ResetRegs() { - for (int i = 0; i < 16; i++) - { - GIFPackedRegHandlers[i] = &GIFPackedRegHandlerNull; - } + for (int i = 0; i < 16; i++) { + GIFPackedRegHandlers[i] = &GIFPackedRegHandlerNull; + } - GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM; - GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA; - GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ; - GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV; - GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2; - GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2; - GIFPackedRegHandlers[GIF_REG_TEX0_1] = &GIFPackedRegHandlerTEX0<0>; - GIFPackedRegHandlers[GIF_REG_TEX0_2] = &GIFPackedRegHandlerTEX0<1>; - GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>; - GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>; - GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG; - GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3; - GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3; - GIFPackedRegHandlers[GIF_REG_A_D] = &GIFPackedRegHandlerA_D; - GIFPackedRegHandlers[GIF_REG_NOP] = &GIFPackedRegHandlerNOP; - - for (int i = 0; i < 256; i++) - { - GIFRegHandlers[i] = &GIFRegHandlerNull; - } - - GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM; - GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ; - GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST; - GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV; - GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2; - GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2; - GIFRegHandlers[GIF_A_D_REG_TEX0_1] = &GIFRegHandlerTEX0<0>; - GIFRegHandlers[GIF_A_D_REG_TEX0_2] = &GIFRegHandlerTEX0<1>; - GIFRegHandlers[GIF_A_D_REG_CLAMP_1] = &GIFRegHandlerCLAMP<0>; - GIFRegHandlers[GIF_A_D_REG_CLAMP_2] = &GIFRegHandlerCLAMP<1>; - GIFRegHandlers[GIF_A_D_REG_FOG] = &GIFRegHandlerFOG; - GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3; - GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3; - GIFRegHandlers[GIF_A_D_REG_NOP] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_TEX1_1] = &GIFRegHandlerTEX1<0>; - GIFRegHandlers[GIF_A_D_REG_TEX1_2] = &GIFRegHandlerTEX1<1>; - GIFRegHandlers[GIF_A_D_REG_TEX2_1] = &GIFRegHandlerTEX2<0>; - GIFRegHandlers[GIF_A_D_REG_TEX2_2] = &GIFRegHandlerTEX2<1>; - GIFRegHandlers[GIF_A_D_REG_XYOFFSET_1] = &GIFRegHandlerXYOFFSET<0>; - GIFRegHandlers[GIF_A_D_REG_XYOFFSET_2] = &GIFRegHandlerXYOFFSET<1>; - GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT; - GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE; - GIFRegHandlers[GIF_A_D_REG_TEXCLUT] = &GIFRegHandlerTEXCLUT; - GIFRegHandlers[GIF_A_D_REG_SCANMSK] = &GIFRegHandlerSCANMSK; - GIFRegHandlers[GIF_A_D_REG_MIPTBP1_1] = &GIFRegHandlerMIPTBP1<0>; - GIFRegHandlers[GIF_A_D_REG_MIPTBP1_2] = &GIFRegHandlerMIPTBP1<1>; - GIFRegHandlers[GIF_A_D_REG_MIPTBP2_1] = &GIFRegHandlerMIPTBP2<0>; - GIFRegHandlers[GIF_A_D_REG_MIPTBP2_2] = &GIFRegHandlerMIPTBP2<1>; - GIFRegHandlers[GIF_A_D_REG_TEXA] = &GIFRegHandlerTEXA; - GIFRegHandlers[GIF_A_D_REG_FOGCOL] = &GIFRegHandlerFOGCOL; - GIFRegHandlers[GIF_A_D_REG_TEXFLUSH] = &GIFRegHandlerTEXFLUSH; - GIFRegHandlers[GIF_A_D_REG_SCISSOR_1] = &GIFRegHandlerSCISSOR<0>; - GIFRegHandlers[GIF_A_D_REG_SCISSOR_2] = &GIFRegHandlerSCISSOR<1>; - GIFRegHandlers[GIF_A_D_REG_ALPHA_1] = &GIFRegHandlerALPHA<0>; - GIFRegHandlers[GIF_A_D_REG_ALPHA_2] = &GIFRegHandlerALPHA<1>; - GIFRegHandlers[GIF_A_D_REG_DIMX] = &GIFRegHandlerDIMX; - GIFRegHandlers[GIF_A_D_REG_DTHE] = &GIFRegHandlerDTHE; - GIFRegHandlers[GIF_A_D_REG_COLCLAMP] = &GIFRegHandlerCOLCLAMP; - GIFRegHandlers[GIF_A_D_REG_TEST_1] = &GIFRegHandlerTEST<0>; - GIFRegHandlers[GIF_A_D_REG_TEST_2] = &GIFRegHandlerTEST<1>; - GIFRegHandlers[GIF_A_D_REG_PABE] = &GIFRegHandlerPABE; - GIFRegHandlers[GIF_A_D_REG_FBA_1] = &GIFRegHandlerFBA<0>; - GIFRegHandlers[GIF_A_D_REG_FBA_2] = &GIFRegHandlerFBA<1>; - GIFRegHandlers[GIF_A_D_REG_FRAME_1] = &GIFRegHandlerFRAME<0>; - GIFRegHandlers[GIF_A_D_REG_FRAME_2] = &GIFRegHandlerFRAME<1>; - GIFRegHandlers[GIF_A_D_REG_ZBUF_1] = &GIFRegHandlerZBUF<0>; - GIFRegHandlers[GIF_A_D_REG_ZBUF_2] = &GIFRegHandlerZBUF<1>; - GIFRegHandlers[GIF_A_D_REG_BITBLTBUF] = &GIFRegHandlerBITBLTBUF; - GIFRegHandlers[GIF_A_D_REG_TRXPOS] = &GIFRegHandlerTRXPOS; - GIFRegHandlers[GIF_A_D_REG_TRXREG] = &GIFRegHandlerTRXREG; - GIFRegHandlers[GIF_A_D_REG_TRXDIR] = &GIFRegHandlerTRXDIR; - GIFRegHandlers[GIF_A_D_REG_HWREG] = &GIFRegHandlerHWREG; - SetMultithreaded(); + GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM; + GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA; + GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ; + GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV; + GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2; + GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2; + GIFPackedRegHandlers[GIF_REG_TEX0_1] = &GIFPackedRegHandlerTEX0<0>; + GIFPackedRegHandlers[GIF_REG_TEX0_2] = &GIFPackedRegHandlerTEX0<1>; + GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>; + GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>; + GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG; + GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3; + GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3; + GIFPackedRegHandlers[GIF_REG_A_D] = &GIFPackedRegHandlerA_D; + GIFPackedRegHandlers[GIF_REG_NOP] = &GIFPackedRegHandlerNOP; + + for (int i = 0; i < 256; i++) { + GIFRegHandlers[i] = &GIFRegHandlerNull; + } + + GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM; + GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ; + GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST; + GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV; + GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2; + GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2; + GIFRegHandlers[GIF_A_D_REG_TEX0_1] = &GIFRegHandlerTEX0<0>; + GIFRegHandlers[GIF_A_D_REG_TEX0_2] = &GIFRegHandlerTEX0<1>; + GIFRegHandlers[GIF_A_D_REG_CLAMP_1] = &GIFRegHandlerCLAMP<0>; + GIFRegHandlers[GIF_A_D_REG_CLAMP_2] = &GIFRegHandlerCLAMP<1>; + GIFRegHandlers[GIF_A_D_REG_FOG] = &GIFRegHandlerFOG; + GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3; + GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3; + GIFRegHandlers[GIF_A_D_REG_NOP] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_TEX1_1] = &GIFRegHandlerTEX1<0>; + GIFRegHandlers[GIF_A_D_REG_TEX1_2] = &GIFRegHandlerTEX1<1>; + GIFRegHandlers[GIF_A_D_REG_TEX2_1] = &GIFRegHandlerTEX2<0>; + GIFRegHandlers[GIF_A_D_REG_TEX2_2] = &GIFRegHandlerTEX2<1>; + GIFRegHandlers[GIF_A_D_REG_XYOFFSET_1] = &GIFRegHandlerXYOFFSET<0>; + GIFRegHandlers[GIF_A_D_REG_XYOFFSET_2] = &GIFRegHandlerXYOFFSET<1>; + GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT; + GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE; + GIFRegHandlers[GIF_A_D_REG_TEXCLUT] = &GIFRegHandlerTEXCLUT; + GIFRegHandlers[GIF_A_D_REG_SCANMSK] = &GIFRegHandlerSCANMSK; + GIFRegHandlers[GIF_A_D_REG_MIPTBP1_1] = &GIFRegHandlerMIPTBP1<0>; + GIFRegHandlers[GIF_A_D_REG_MIPTBP1_2] = &GIFRegHandlerMIPTBP1<1>; + GIFRegHandlers[GIF_A_D_REG_MIPTBP2_1] = &GIFRegHandlerMIPTBP2<0>; + GIFRegHandlers[GIF_A_D_REG_MIPTBP2_2] = &GIFRegHandlerMIPTBP2<1>; + GIFRegHandlers[GIF_A_D_REG_TEXA] = &GIFRegHandlerTEXA; + GIFRegHandlers[GIF_A_D_REG_FOGCOL] = &GIFRegHandlerFOGCOL; + GIFRegHandlers[GIF_A_D_REG_TEXFLUSH] = &GIFRegHandlerTEXFLUSH; + GIFRegHandlers[GIF_A_D_REG_SCISSOR_1] = &GIFRegHandlerSCISSOR<0>; + GIFRegHandlers[GIF_A_D_REG_SCISSOR_2] = &GIFRegHandlerSCISSOR<1>; + GIFRegHandlers[GIF_A_D_REG_ALPHA_1] = &GIFRegHandlerALPHA<0>; + GIFRegHandlers[GIF_A_D_REG_ALPHA_2] = &GIFRegHandlerALPHA<1>; + GIFRegHandlers[GIF_A_D_REG_DIMX] = &GIFRegHandlerDIMX; + GIFRegHandlers[GIF_A_D_REG_DTHE] = &GIFRegHandlerDTHE; + GIFRegHandlers[GIF_A_D_REG_COLCLAMP] = &GIFRegHandlerCOLCLAMP; + GIFRegHandlers[GIF_A_D_REG_TEST_1] = &GIFRegHandlerTEST<0>; + GIFRegHandlers[GIF_A_D_REG_TEST_2] = &GIFRegHandlerTEST<1>; + GIFRegHandlers[GIF_A_D_REG_PABE] = &GIFRegHandlerPABE; + GIFRegHandlers[GIF_A_D_REG_FBA_1] = &GIFRegHandlerFBA<0>; + GIFRegHandlers[GIF_A_D_REG_FBA_2] = &GIFRegHandlerFBA<1>; + GIFRegHandlers[GIF_A_D_REG_FRAME_1] = &GIFRegHandlerFRAME<0>; + GIFRegHandlers[GIF_A_D_REG_FRAME_2] = &GIFRegHandlerFRAME<1>; + GIFRegHandlers[GIF_A_D_REG_ZBUF_1] = &GIFRegHandlerZBUF<0>; + GIFRegHandlers[GIF_A_D_REG_ZBUF_2] = &GIFRegHandlerZBUF<1>; + GIFRegHandlers[GIF_A_D_REG_BITBLTBUF] = &GIFRegHandlerBITBLTBUF; + GIFRegHandlers[GIF_A_D_REG_TRXPOS] = &GIFRegHandlerTRXPOS; + GIFRegHandlers[GIF_A_D_REG_TRXREG] = &GIFRegHandlerTRXREG; + GIFRegHandlers[GIF_A_D_REG_TRXDIR] = &GIFRegHandlerTRXDIR; + GIFRegHandlers[GIF_A_D_REG_HWREG] = &GIFRegHandlerHWREG; + SetMultithreaded(); } void SetFrameSkip(bool skip) { - if (skip) - { - GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerNOP; - GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerNOP; + if (skip) { + GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerNOP; + GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerNOP; - GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerNOP; - } - else - { - GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM; - GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA; - GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ; - GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV; - GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2; - GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2; - GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>; - GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>; - GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG; - GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3; - GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3; + GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerNOP; + GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerNOP; + } else { + GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM; + GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA; + GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ; + GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV; + GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2; + GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2; + GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>; + GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>; + GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG; + GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3; + GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3; - GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM; - GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ; - GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST; - GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV; - GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2; - GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2; - GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3; - GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3; - GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT; - GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE; - } + GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM; + GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ; + GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST; + GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV; + GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2; + GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2; + GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3; + GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3; + GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT; + GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE; + } } diff --git a/plugins/GSnull/Registers.h b/plugins/GSnull/Registers.h index ca9fbd590b..62a8a6c261 100644 --- a/plugins/GSnull/Registers.h +++ b/plugins/GSnull/Registers.h @@ -21,8 +21,7 @@ #define __REGISTERS_H__ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #define GSdefs #include "PS2Edefs.h" @@ -36,82 +35,80 @@ extern "C" #pragma pack(push, 1) -enum GIF_REG -{ - GIF_REG_PRIM = 0x00, - GIF_REG_RGBA = 0x01, - GIF_REG_STQ = 0x02, - GIF_REG_UV = 0x03, - GIF_REG_XYZF2 = 0x04, - GIF_REG_XYZ2 = 0x05, - GIF_REG_TEX0_1 = 0x06, - GIF_REG_TEX0_2 = 0x07, - GIF_REG_CLAMP_1 = 0x08, - GIF_REG_CLAMP_2 = 0x09, - GIF_REG_FOG = 0x0a, - GIF_REG_XYZF3 = 0x0c, - GIF_REG_XYZ3 = 0x0d, - GIF_REG_A_D = 0x0e, - GIF_REG_NOP = 0x0f, +enum GIF_REG { + GIF_REG_PRIM = 0x00, + GIF_REG_RGBA = 0x01, + GIF_REG_STQ = 0x02, + GIF_REG_UV = 0x03, + GIF_REG_XYZF2 = 0x04, + GIF_REG_XYZ2 = 0x05, + GIF_REG_TEX0_1 = 0x06, + GIF_REG_TEX0_2 = 0x07, + GIF_REG_CLAMP_1 = 0x08, + GIF_REG_CLAMP_2 = 0x09, + GIF_REG_FOG = 0x0a, + GIF_REG_XYZF3 = 0x0c, + GIF_REG_XYZ3 = 0x0d, + GIF_REG_A_D = 0x0e, + GIF_REG_NOP = 0x0f, }; -enum GIF_A_D_REG -{ - GIF_A_D_REG_PRIM = 0x00, - GIF_A_D_REG_RGBAQ = 0x01, - GIF_A_D_REG_ST = 0x02, - GIF_A_D_REG_UV = 0x03, - GIF_A_D_REG_XYZF2 = 0x04, - GIF_A_D_REG_XYZ2 = 0x05, - GIF_A_D_REG_TEX0_1 = 0x06, - GIF_A_D_REG_TEX0_2 = 0x07, - GIF_A_D_REG_CLAMP_1 = 0x08, - GIF_A_D_REG_CLAMP_2 = 0x09, - GIF_A_D_REG_FOG = 0x0a, - GIF_A_D_REG_XYZF3 = 0x0c, - GIF_A_D_REG_XYZ3 = 0x0d, - GIF_A_D_REG_NOP = 0x0f, - GIF_A_D_REG_TEX1_1 = 0x14, - GIF_A_D_REG_TEX1_2 = 0x15, - GIF_A_D_REG_TEX2_1 = 0x16, - GIF_A_D_REG_TEX2_2 = 0x17, - GIF_A_D_REG_XYOFFSET_1 = 0x18, - GIF_A_D_REG_XYOFFSET_2 = 0x19, - GIF_A_D_REG_PRMODECONT = 0x1a, - GIF_A_D_REG_PRMODE = 0x1b, - GIF_A_D_REG_TEXCLUT = 0x1c, - GIF_A_D_REG_SCANMSK = 0x22, - GIF_A_D_REG_MIPTBP1_1 = 0x34, - GIF_A_D_REG_MIPTBP1_2 = 0x35, - GIF_A_D_REG_MIPTBP2_1 = 0x36, - GIF_A_D_REG_MIPTBP2_2 = 0x37, - GIF_A_D_REG_TEXA = 0x3b, - GIF_A_D_REG_FOGCOL = 0x3d, - GIF_A_D_REG_TEXFLUSH = 0x3f, - GIF_A_D_REG_SCISSOR_1 = 0x40, - GIF_A_D_REG_SCISSOR_2 = 0x41, - GIF_A_D_REG_ALPHA_1 = 0x42, - GIF_A_D_REG_ALPHA_2 = 0x43, - GIF_A_D_REG_DIMX = 0x44, - GIF_A_D_REG_DTHE = 0x45, - GIF_A_D_REG_COLCLAMP = 0x46, - GIF_A_D_REG_TEST_1 = 0x47, - GIF_A_D_REG_TEST_2 = 0x48, - GIF_A_D_REG_PABE = 0x49, - GIF_A_D_REG_FBA_1 = 0x4a, - GIF_A_D_REG_FBA_2 = 0x4b, - GIF_A_D_REG_FRAME_1 = 0x4c, - GIF_A_D_REG_FRAME_2 = 0x4d, - GIF_A_D_REG_ZBUF_1 = 0x4e, - GIF_A_D_REG_ZBUF_2 = 0x4f, - GIF_A_D_REG_BITBLTBUF = 0x50, - GIF_A_D_REG_TRXPOS = 0x51, - GIF_A_D_REG_TRXREG = 0x52, - GIF_A_D_REG_TRXDIR = 0x53, - GIF_A_D_REG_HWREG = 0x54, - GIF_A_D_REG_SIGNAL = 0x60, - GIF_A_D_REG_FINISH = 0x61, - GIF_A_D_REG_LABEL = 0x62, +enum GIF_A_D_REG { + GIF_A_D_REG_PRIM = 0x00, + GIF_A_D_REG_RGBAQ = 0x01, + GIF_A_D_REG_ST = 0x02, + GIF_A_D_REG_UV = 0x03, + GIF_A_D_REG_XYZF2 = 0x04, + GIF_A_D_REG_XYZ2 = 0x05, + GIF_A_D_REG_TEX0_1 = 0x06, + GIF_A_D_REG_TEX0_2 = 0x07, + GIF_A_D_REG_CLAMP_1 = 0x08, + GIF_A_D_REG_CLAMP_2 = 0x09, + GIF_A_D_REG_FOG = 0x0a, + GIF_A_D_REG_XYZF3 = 0x0c, + GIF_A_D_REG_XYZ3 = 0x0d, + GIF_A_D_REG_NOP = 0x0f, + GIF_A_D_REG_TEX1_1 = 0x14, + GIF_A_D_REG_TEX1_2 = 0x15, + GIF_A_D_REG_TEX2_1 = 0x16, + GIF_A_D_REG_TEX2_2 = 0x17, + GIF_A_D_REG_XYOFFSET_1 = 0x18, + GIF_A_D_REG_XYOFFSET_2 = 0x19, + GIF_A_D_REG_PRMODECONT = 0x1a, + GIF_A_D_REG_PRMODE = 0x1b, + GIF_A_D_REG_TEXCLUT = 0x1c, + GIF_A_D_REG_SCANMSK = 0x22, + GIF_A_D_REG_MIPTBP1_1 = 0x34, + GIF_A_D_REG_MIPTBP1_2 = 0x35, + GIF_A_D_REG_MIPTBP2_1 = 0x36, + GIF_A_D_REG_MIPTBP2_2 = 0x37, + GIF_A_D_REG_TEXA = 0x3b, + GIF_A_D_REG_FOGCOL = 0x3d, + GIF_A_D_REG_TEXFLUSH = 0x3f, + GIF_A_D_REG_SCISSOR_1 = 0x40, + GIF_A_D_REG_SCISSOR_2 = 0x41, + GIF_A_D_REG_ALPHA_1 = 0x42, + GIF_A_D_REG_ALPHA_2 = 0x43, + GIF_A_D_REG_DIMX = 0x44, + GIF_A_D_REG_DTHE = 0x45, + GIF_A_D_REG_COLCLAMP = 0x46, + GIF_A_D_REG_TEST_1 = 0x47, + GIF_A_D_REG_TEST_2 = 0x48, + GIF_A_D_REG_PABE = 0x49, + GIF_A_D_REG_FBA_1 = 0x4a, + GIF_A_D_REG_FBA_2 = 0x4b, + GIF_A_D_REG_FRAME_1 = 0x4c, + GIF_A_D_REG_FRAME_2 = 0x4d, + GIF_A_D_REG_ZBUF_1 = 0x4e, + GIF_A_D_REG_ZBUF_2 = 0x4f, + GIF_A_D_REG_BITBLTBUF = 0x50, + GIF_A_D_REG_TRXPOS = 0x51, + GIF_A_D_REG_TRXREG = 0x52, + GIF_A_D_REG_TRXDIR = 0x53, + GIF_A_D_REG_HWREG = 0x54, + GIF_A_D_REG_SIGNAL = 0x60, + GIF_A_D_REG_FINISH = 0x61, + GIF_A_D_REG_LABEL = 0x62, }; // In case we want to change to/from __fastcall for GIF register handlers: @@ -133,10 +130,10 @@ extern FnType_GIFRegHandler GIFPackedRegHandlerNOP; // These are unimplemented, and fall back on the non-packed versions. extern FnType_GIFRegHandler GIFPackedRegHandlerPRIM; -template +template extern FnType_GIFRegHandler GIFPackedRegHandlerTEX0; -template +template extern FnType_GIFRegHandler GIFPackedRegHandlerCLAMP; extern FnType_GIFRegHandler GIFPackedRegHandlerXYZF3; @@ -150,10 +147,10 @@ extern FnType_GIFRegHandler GIFRegHandlerUV; extern FnType_GIFRegHandler GIFRegHandlerXYZF2; extern FnType_GIFRegHandler GIFRegHandlerXYZ2; -template +template extern FnType_GIFRegHandler GIFRegHandlerTEX0; -template +template extern FnType_GIFRegHandler GIFRegHandlerCLAMP; extern FnType_GIFRegHandler GIFRegHandlerFOG; @@ -208,300 +205,303 @@ extern FnType_GIFRegHandler GIFRegHandlerSIGNAL; extern FnType_GIFRegHandler GIFRegHandlerFINISH; extern FnType_GIFRegHandler GIFRegHandlerLABEL; -enum GS_PRIM -{ - GS_POINTLIST = 0, - GS_LINELIST = 1, - GS_LINESTRIP = 2, - GS_TRIANGLELIST = 3, - GS_TRIANGLESTRIP = 4, - GS_TRIANGLEFAN = 5, - GS_SPRITE = 6, - GS_INVALID = 7, +enum GS_PRIM { + GS_POINTLIST = 0, + GS_LINELIST = 1, + GS_LINESTRIP = 2, + GS_TRIANGLELIST = 3, + GS_TRIANGLESTRIP = 4, + GS_TRIANGLEFAN = 5, + GS_SPRITE = 6, + GS_INVALID = 7, }; -enum GS_PRIM_CLASS -{ - GS_POINT_CLASS = 0, - GS_LINE_CLASS = 1, - GS_TRIANGLE_CLASS = 2, - GS_SPRITE_CLASS = 3, - GS_INVALID_CLASS = 7, +enum GS_PRIM_CLASS { + GS_POINT_CLASS = 0, + GS_LINE_CLASS = 1, + GS_TRIANGLE_CLASS = 2, + GS_SPRITE_CLASS = 3, + GS_INVALID_CLASS = 7, }; -enum GS_PSM -{ - PSM_PSMCT32 = 0, // 0000-0000 - PSM_PSMCT24 = 1, // 0000-0001 - PSM_PSMCT16 = 2, // 0000-0010 - PSM_PSMCT16S = 10, // 0000-1010 - PSM_PSMT8 = 19, // 0001-0011 - PSM_PSMT4 = 20, // 0001-0100 - PSM_PSMT8H = 27, // 0001-1011 - PSM_PSMT4HL = 36, // 0010-0100 - PSM_PSMT4HH = 44, // 0010-1100 - PSM_PSMZ32 = 48, // 0011-0000 - PSM_PSMZ24 = 49, // 0011-0001 - PSM_PSMZ16 = 50, // 0011-0010 - PSM_PSMZ16S = 58, // 0011-1010 +enum GS_PSM { + PSM_PSMCT32 = 0, // 0000-0000 + PSM_PSMCT24 = 1, // 0000-0001 + PSM_PSMCT16 = 2, // 0000-0010 + PSM_PSMCT16S = 10, // 0000-1010 + PSM_PSMT8 = 19, // 0001-0011 + PSM_PSMT4 = 20, // 0001-0100 + PSM_PSMT8H = 27, // 0001-1011 + PSM_PSMT4HL = 36, // 0010-0100 + PSM_PSMT4HH = 44, // 0010-1100 + PSM_PSMZ32 = 48, // 0011-0000 + PSM_PSMZ24 = 49, // 0011-0001 + PSM_PSMZ16 = 50, // 0011-0010 + PSM_PSMZ16S = 58, // 0011-1010 }; -enum GS_TFX -{ - TFX_MODULATE = 0, - TFX_DECAL = 1, - TFX_HIGHLIGHT = 2, - TFX_HIGHLIGHT2 = 3, - TFX_NONE = 4, +enum GS_TFX { + TFX_MODULATE = 0, + TFX_DECAL = 1, + TFX_HIGHLIGHT = 2, + TFX_HIGHLIGHT2 = 3, + TFX_NONE = 4, }; -enum GS_CLAMP -{ - CLAMP_REPEAT = 0, - CLAMP_CLAMP = 1, - CLAMP_REGION_CLAMP = 2, - CLAMP_REGION_REPEAT = 3, +enum GS_CLAMP { + CLAMP_REPEAT = 0, + CLAMP_CLAMP = 1, + CLAMP_REGION_CLAMP = 2, + CLAMP_REGION_REPEAT = 3, }; -enum GS_ZTST -{ - ZTST_NEVER = 0, - ZTST_ALWAYS = 1, - ZTST_GEQUAL = 2, - ZTST_GREATER = 3, +enum GS_ZTST { + ZTST_NEVER = 0, + ZTST_ALWAYS = 1, + ZTST_GEQUAL = 2, + ZTST_GREATER = 3, }; -enum GS_ATST -{ - ATST_NEVER = 0, - ATST_ALWAYS = 1, - ATST_LESS = 2, - ATST_LEQUAL = 3, - ATST_EQUAL = 4, - ATST_GEQUAL = 5, - ATST_GREATER = 6, - ATST_NOTEQUAL = 7, +enum GS_ATST { + ATST_NEVER = 0, + ATST_ALWAYS = 1, + ATST_LESS = 2, + ATST_LEQUAL = 3, + ATST_EQUAL = 4, + ATST_GEQUAL = 5, + ATST_GREATER = 6, + ATST_NOTEQUAL = 7, }; -enum GS_AFAIL -{ - AFAIL_KEEP = 0, - AFAIL_FB_ONLY = 1, - AFAIL_ZB_ONLY = 2, - AFAIL_RGB_ONLY = 3, +enum GS_AFAIL { + AFAIL_KEEP = 0, + AFAIL_FB_ONLY = 1, + AFAIL_ZB_ONLY = 2, + AFAIL_RGB_ONLY = 3, }; #define REG32(name) \ -union name \ -{ \ - u32 _u32; \ - struct { \ + union name \ + { \ + u32 _u32; \ + struct \ + { -#define REG64(name) \ -union name \ -{ \ - u64 _u64; \ - u32 _u32[2]; \ - /*void operator = (const GSVector4i& v) {GSVector4i::storel(this, v);} \ - bool operator == (const union name& r) const {return ((GSVector4i)r).eq(*this);} \ - bool operator != (const union name& r) const {return !((GSVector4i)r).eq(*this);} \ - operator GSVector4i() const {return GSVector4i::loadl(this);}*/ \ - struct { \ +#define REG64(name) \ + union name \ + { \ + u64 _u64; \ + u32 _u32[2]; \ + /*void operator = (const GSVector4i& v) {GSVector4i::storel(this, v);} \ + bool operator == (const union name& r) const {return ((GSVector4i)r).eq(*this);} \ + bool operator != (const union name& r) const {return !((GSVector4i)r).eq(*this);} \ + operator GSVector4i() const {return GSVector4i::loadl(this);}*/ \ + struct \ + { -#define REG128(name)\ -union name \ -{ \ - u64 _u64[2]; \ - u32 _u32[4]; \ - struct { \ +#define REG128(name) \ + union name \ + { \ + u64 _u64[2]; \ + u32 _u32[4]; \ + struct \ + { #define REG32_(prefix, name) REG32(prefix##name) #define REG64_(prefix, name) REG64(prefix##name) #define REG128_(prefix, name) REG128(prefix##name) -#define REG_END }; }; -#define REG_END2 }; +#define REG_END \ + } \ + ; \ + } \ + ; +#define REG_END2 \ + } \ + ; #define REG32_SET(name) \ -struct name \ -{ \ + struct name \ + { #define REG64_SET(name) \ -struct name \ -{ \ + struct name \ + { -#define REG128_SET(name)\ -struct name \ -{ \ +#define REG128_SET(name) \ + struct name \ + { -#define REG_SET_END }; +#define REG_SET_END \ + } \ + ; REG64_(GSReg, BGCOLOR) - u32 R:8; - u32 G:8; - u32 B:8; - u32 _PAD1:8; - u32 _PAD2:32; +u32 R : 8; +u32 G : 8; +u32 B : 8; +u32 _PAD1 : 8; +u32 _PAD2 : 32; REG_END REG64_(GSReg, BUSDIR) - u32 DIR:1; - u32 _PAD1:31; - u32 _PAD2:32; +u32 DIR : 1; +u32 _PAD1 : 31; +u32 _PAD2 : 32; REG_END REG64_(GSReg, CSR) - u32 rSIGNAL:1; - u32 rFINISH:1; - u32 rHSINT:1; - u32 rVSINT:1; - u32 rEDWINT:1; - u32 rZERO1:1; - u32 rZERO2:1; - u32 r_PAD1:1; - u32 rFLUSH:1; - u32 rRESET:1; - u32 r_PAD2:2; - u32 rNFIELD:1; - u32 rFIELD:1; - u32 rFIFO:2; - u32 rREV:8; - u32 rID:8; - u32 wSIGNAL:1; - u32 wFINISH:1; - u32 wHSINT:1; - u32 wVSINT:1; - u32 wEDWINT:1; - u32 wZERO1:1; - u32 wZERO2:1; - u32 w_PAD1:1; - u32 wFLUSH:1; - u32 wRESET:1; - u32 w_PAD2:2; - u32 wNFIELD:1; - u32 wFIELD:1; - u32 wFIFO:2; - u32 wREV:8; - u32 wID:8; +u32 rSIGNAL : 1; +u32 rFINISH : 1; +u32 rHSINT : 1; +u32 rVSINT : 1; +u32 rEDWINT : 1; +u32 rZERO1 : 1; +u32 rZERO2 : 1; +u32 r_PAD1 : 1; +u32 rFLUSH : 1; +u32 rRESET : 1; +u32 r_PAD2 : 2; +u32 rNFIELD : 1; +u32 rFIELD : 1; +u32 rFIFO : 2; +u32 rREV : 8; +u32 rID : 8; +u32 wSIGNAL : 1; +u32 wFINISH : 1; +u32 wHSINT : 1; +u32 wVSINT : 1; +u32 wEDWINT : 1; +u32 wZERO1 : 1; +u32 wZERO2 : 1; +u32 w_PAD1 : 1; +u32 wFLUSH : 1; +u32 wRESET : 1; +u32 w_PAD2 : 2; +u32 wNFIELD : 1; +u32 wFIELD : 1; +u32 wFIFO : 2; +u32 wREV : 8; +u32 wID : 8; REG_END -REG64_(GSReg, DISPFB) // (-1/2) - u32 FBP:9; - u32 FBW:6; - u32 PSM:5; - u32 _PAD:12; - u32 DBX:11; - u32 DBY:11; - u32 _PAD2:10; +REG64_(GSReg, DISPFB) // (-1/2) +u32 FBP : 9; +u32 FBW : 6; +u32 PSM : 5; +u32 _PAD : 12; +u32 DBX : 11; +u32 DBY : 11; +u32 _PAD2 : 10; REG_END2 - u32 Block() const {return FBP << 5;} +u32 Block() const { return FBP << 5; } REG_END2 -REG64_(GSReg, DISPLAY) // (-1/2) - u32 DX:12; - u32 DY:11; - u32 MAGH:4; - u32 MAGV:2; - u32 _PAD:3; - u32 DW:12; - u32 DH:11; - u32 _PAD2:9; +REG64_(GSReg, DISPLAY) // (-1/2) +u32 DX : 12; +u32 DY : 11; +u32 MAGH : 4; +u32 MAGV : 2; +u32 _PAD : 3; +u32 DW : 12; +u32 DH : 11; +u32 _PAD2 : 9; REG_END REG64_(GSReg, EXTBUF) - u32 EXBP:14; - u32 EXBW:6; - u32 FBIN:2; - u32 WFFMD:1; - u32 EMODA:2; - u32 EMODC:2; - u32 _PAD1:5; - u32 WDX:11; - u32 WDY:11; - u32 _PAD2:10; +u32 EXBP : 14; +u32 EXBW : 6; +u32 FBIN : 2; +u32 WFFMD : 1; +u32 EMODA : 2; +u32 EMODC : 2; +u32 _PAD1 : 5; +u32 WDX : 11; +u32 WDY : 11; +u32 _PAD2 : 10; REG_END REG64_(GSReg, EXTDATA) - u32 SX:12; - u32 SY:11; - u32 SMPH:4; - u32 SMPV:2; - u32 _PAD1:3; - u32 WW:12; - u32 WH:11; - u32 _PAD2:9; +u32 SX : 12; +u32 SY : 11; +u32 SMPH : 4; +u32 SMPV : 2; +u32 _PAD1 : 3; +u32 WW : 12; +u32 WH : 11; +u32 _PAD2 : 9; REG_END REG64_(GSReg, EXTWRITE) - u32 WRITE:1; - u32 _PAD1:31; - u32 _PAD2:32; +u32 WRITE : 1; +u32 _PAD1 : 31; +u32 _PAD2 : 32; REG_END REG64_(GSReg, IMR) - u32 _PAD1:8; - u32 SIGMSK:1; - u32 FINISHMSK:1; - u32 HSMSK:1; - u32 VSMSK:1; - u32 EDWMSK:1; - u32 _PAD2:19; - u32 _PAD3:32; +u32 _PAD1 : 8; +u32 SIGMSK : 1; +u32 FINISHMSK : 1; +u32 HSMSK : 1; +u32 VSMSK : 1; +u32 EDWMSK : 1; +u32 _PAD2 : 19; +u32 _PAD3 : 32; REG_END REG64_(GSReg, PMODE) union { - struct - { - u32 EN1:1; - u32 EN2:1; - u32 CRTMD:3; - u32 MMOD:1; - u32 AMOD:1; - u32 SLBG:1; - u32 ALP:8; - u32 _PAD:16; - u32 _PAD1:32; - }; + struct + { + u32 EN1 : 1; + u32 EN2 : 1; + u32 CRTMD : 3; + u32 MMOD : 1; + u32 AMOD : 1; + u32 SLBG : 1; + u32 ALP : 8; + u32 _PAD : 16; + u32 _PAD1 : 32; + }; - struct - { - u32 EN:2; - u32 _PAD2:30; - u32 _PAD3:32; - }; + struct + { + u32 EN : 2; + u32 _PAD2 : 30; + u32 _PAD3 : 32; + }; }; REG_END REG64_(GSReg, SIGLBLID) - u32 SIGID:32; - u32 LBLID:32; +u32 SIGID : 32; +u32 LBLID : 32; REG_END REG64_(GSReg, SMODE1) - u32 RC:3; - u32 LC:7; - u32 T1248:2; - u32 SLCK:1; - u32 CMOD:2; - u32 EX:1; - u32 PRST:1; - u32 SINT:1; - u32 XPCK:1; - u32 PCK2:2; - u32 SPML:4; - u32 GCONT:1; // YCrCb - u32 PHS:1; - u32 PVS:1; - u32 PEHS:1; - u32 PEVS:1; - u32 CLKSEL:2; - u32 NVCK:1; - u32 SLCK2:1; - u32 VCKSEL:2; - u32 VHP:1; - u32 _PAD1:27; +u32 RC : 3; +u32 LC : 7; +u32 T1248 : 2; +u32 SLCK : 1; +u32 CMOD : 2; +u32 EX : 1; +u32 PRST : 1; +u32 SINT : 1; +u32 XPCK : 1; +u32 PCK2 : 2; +u32 SPML : 4; +u32 GCONT : 1; // YCrCb +u32 PHS : 1; +u32 PVS : 1; +u32 PEHS : 1; +u32 PEVS : 1; +u32 CLKSEL : 2; +u32 NVCK : 1; +u32 SLCK2 : 1; +u32 VCKSEL : 2; +u32 VHP : 1; +u32 _PAD1 : 27; REG_END /* @@ -521,47 +521,47 @@ CLKSEL=1 CMOD=0 EX=0 GCONT=0 LC=32 NVCK=1 PCK2=0 PEHS=0 PEVS=0 PHS=0 PRST=1 PVS= */ REG64_(GSReg, SMODE2) - u32 INT:1; - u32 FFMD:1; - u32 DPMS:2; - u32 _PAD2:28; - u32 _PAD3:32; +u32 INT : 1; +u32 FFMD : 1; +u32 DPMS : 2; +u32 _PAD2 : 28; +u32 _PAD3 : 32; REG_END REG64_(GSReg, SRFSH) - u32 _DUMMY; - // TODO +u32 _DUMMY; +// TODO REG_END REG64_(GSReg, SYNCH1) - u32 _DUMMY; - // TODO +u32 _DUMMY; +// TODO REG_END REG64_(GSReg, SYNCH2) - u32 _DUMMY; - // TODO +u32 _DUMMY; +// TODO REG_END REG64_(GSReg, SYNCV) - u64 _DUMMY; - // TODO +u64 _DUMMY; +// TODO REG_END REG64_SET(GSReg) - GSRegBGCOLOR BGCOLOR; - GSRegBUSDIR BUSDIR; - GSRegCSR CSR; - GSRegDISPFB DISPFB; - GSRegDISPLAY DISPLAY; - GSRegEXTBUF EXTBUF; - GSRegEXTDATA EXTDATA; - GSRegEXTWRITE EXTWRITE; - GSRegIMR IMR; - GSRegPMODE PMODE; - GSRegSIGLBLID SIGLBLID; - GSRegSMODE1 SMODE1; - GSRegSMODE2 SMODE2; +GSRegBGCOLOR BGCOLOR; +GSRegBUSDIR BUSDIR; +GSRegCSR CSR; +GSRegDISPFB DISPFB; +GSRegDISPLAY DISPLAY; +GSRegEXTBUF EXTBUF; +GSRegEXTDATA EXTDATA; +GSRegEXTWRITE EXTWRITE; +GSRegIMR IMR; +GSRegPMODE PMODE; +GSRegSIGLBLID SIGLBLID; +GSRegSMODE1 SMODE1; +GSRegSMODE2 SMODE2; REG_SET_END // @@ -582,637 +582,637 @@ REG_END*/ // GIFReg REG64_(GIFReg, ALPHA) - u32 A:2; - u32 B:2; - u32 C:2; - u32 D:2; - u32 _PAD1:24; - u32 FIX:8; - u32 _PAD2:24; +u32 A : 2; +u32 B : 2; +u32 C : 2; +u32 D : 2; +u32 _PAD1 : 24; +u32 FIX : 8; +u32 _PAD2 : 24; REG_END2 - // opaque => output will be Cs/As - //__forceinline bool IsOpaque() const {return (A == B || C == 2 && FIX == 0) && D == 0 || (A == 0 && B == D && C == 2 && FIX == 0x80);} - //__forceinline bool IsOpaque(int amin, int amax) const {return (A == B || amax == 0) && D == 0 || A == 0 && B == D && amin == 0x80 && amax == 0x80;} +// opaque => output will be Cs/As +//__forceinline bool IsOpaque() const {return (A == B || C == 2 && FIX == 0) && D == 0 || (A == 0 && B == D && C == 2 && FIX == 0x80);} +//__forceinline bool IsOpaque(int amin, int amax) const {return (A == B || amax == 0) && D == 0 || A == 0 && B == D && amin == 0x80 && amax == 0x80;} REG_END2 REG64_(GIFReg, BITBLTBUF) - u32 SBP:14; - u32 _PAD1:2; - u32 SBW:6; - u32 _PAD2:2; - u32 SPSM:6; - u32 _PAD3:2; - u32 DBP:14; - u32 _PAD4:2; - u32 DBW:6; - u32 _PAD5:2; - u32 DPSM:6; - u32 _PAD6:2; +u32 SBP : 14; +u32 _PAD1 : 2; +u32 SBW : 6; +u32 _PAD2 : 2; +u32 SPSM : 6; +u32 _PAD3 : 2; +u32 DBP : 14; +u32 _PAD4 : 2; +u32 DBW : 6; +u32 _PAD5 : 2; +u32 DPSM : 6; +u32 _PAD6 : 2; REG_END REG64_(GIFReg, CLAMP) union { - struct - { - u32 WMS:2; - u32 WMT:2; - u32 MINU:10; - u32 MAXU:10; - u32 _PAD1:8; - u32 _PAD2:2; - u32 MAXV:10; - u32 _PAD3:20; - }; + struct + { + u32 WMS : 2; + u32 WMT : 2; + u32 MINU : 10; + u32 MAXU : 10; + u32 _PAD1 : 8; + u32 _PAD2 : 2; + u32 MAXV : 10; + u32 _PAD3 : 20; + }; - struct - { - u64 _PAD4:24; - u64 MINV:10; - u64 _PAD5:30; - }; + struct + { + u64 _PAD4 : 24; + u64 MINV : 10; + u64 _PAD5 : 30; + }; }; REG_END REG64_(GIFReg, COLCLAMP) - u32 CLAMP:1; - u32 _PAD1:31; - u32 _PAD2:32; +u32 CLAMP : 1; +u32 _PAD1 : 31; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, DIMX) - s32 DM00:3; - s32 _PAD00:1; - s32 DM01:3; - s32 _PAD01:1; - s32 DM02:3; - s32 _PAD02:1; - s32 DM03:3; - s32 _PAD03:1; - s32 DM10:3; - s32 _PAD10:1; - s32 DM11:3; - s32 _PAD11:1; - s32 DM12:3; - s32 _PAD12:1; - s32 DM13:3; - s32 _PAD13:1; - s32 DM20:3; - s32 _PAD20:1; - s32 DM21:3; - s32 _PAD21:1; - s32 DM22:3; - s32 _PAD22:1; - s32 DM23:3; - s32 _PAD23:1; - s32 DM30:3; - s32 _PAD30:1; - s32 DM31:3; - s32 _PAD31:1; - s32 DM32:3; - s32 _PAD32:1; - s32 DM33:3; - s32 _PAD33:1; +s32 DM00 : 3; +s32 _PAD00 : 1; +s32 DM01 : 3; +s32 _PAD01 : 1; +s32 DM02 : 3; +s32 _PAD02 : 1; +s32 DM03 : 3; +s32 _PAD03 : 1; +s32 DM10 : 3; +s32 _PAD10 : 1; +s32 DM11 : 3; +s32 _PAD11 : 1; +s32 DM12 : 3; +s32 _PAD12 : 1; +s32 DM13 : 3; +s32 _PAD13 : 1; +s32 DM20 : 3; +s32 _PAD20 : 1; +s32 DM21 : 3; +s32 _PAD21 : 1; +s32 DM22 : 3; +s32 _PAD22 : 1; +s32 DM23 : 3; +s32 _PAD23 : 1; +s32 DM30 : 3; +s32 _PAD30 : 1; +s32 DM31 : 3; +s32 _PAD31 : 1; +s32 DM32 : 3; +s32 _PAD32 : 1; +s32 DM33 : 3; +s32 _PAD33 : 1; REG_END REG64_(GIFReg, DTHE) - u32 DTHE:1; - u32 _PAD1:31; - u32 _PAD2:32; +u32 DTHE : 1; +u32 _PAD1 : 31; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, FBA) - u32 FBA:1; - u32 _PAD1:31; - u32 _PAD2:32; +u32 FBA : 1; +u32 _PAD1 : 31; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, FINISH) - u32 _PAD1:32; - u32 _PAD2:32; +u32 _PAD1 : 32; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, FOG) - u32 _PAD1:32; - u32 _PAD2:24; - u32 F:8; +u32 _PAD1 : 32; +u32 _PAD2 : 24; +u32 F : 8; REG_END REG64_(GIFReg, FOGCOL) - u32 FCR:8; - u32 FCG:8; - u32 FCB:8; - u32 _PAD1:8; - u32 _PAD2:32; +u32 FCR : 8; +u32 FCG : 8; +u32 FCB : 8; +u32 _PAD1 : 8; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, FRAME) - u32 FBP:9; - u32 _PAD1:7; - u32 FBW:6; - u32 _PAD2:2; - u32 PSM:6; - u32 _PAD3:2; - u32 FBMSK:32; +u32 FBP : 9; +u32 _PAD1 : 7; +u32 FBW : 6; +u32 _PAD2 : 2; +u32 PSM : 6; +u32 _PAD3 : 2; +u32 FBMSK : 32; REG_END2 - u32 Block() const {return FBP << 5;} +u32 Block() const { return FBP << 5; } REG_END2 REG64_(GIFReg, HWREG) - u32 DATA_LOWER:32; - u32 DATA_UPPER:32; +u32 DATA_LOWER : 32; +u32 DATA_UPPER : 32; REG_END REG64_(GIFReg, LABEL) - u32 ID:32; - u32 IDMSK:32; +u32 ID : 32; +u32 IDMSK : 32; REG_END REG64_(GIFReg, MIPTBP1) - u64 TBP1:14; - u64 TBW1:6; - u64 TBP2:14; - u64 TBW2:6; - u64 TBP3:14; - u64 TBW3:6; - u64 _PAD:4; +u64 TBP1 : 14; +u64 TBW1 : 6; +u64 TBP2 : 14; +u64 TBW2 : 6; +u64 TBP3 : 14; +u64 TBW3 : 6; +u64 _PAD : 4; REG_END REG64_(GIFReg, MIPTBP2) - u64 TBP4:14; - u64 TBW4:6; - u64 TBP5:14; - u64 TBW5:6; - u64 TBP6:14; - u64 TBW6:6; - u64 _PAD:4; +u64 TBP4 : 14; +u64 TBW4 : 6; +u64 TBP5 : 14; +u64 TBW5 : 6; +u64 TBP6 : 14; +u64 TBW6 : 6; +u64 _PAD : 4; REG_END REG64_(GIFReg, NOP) - u32 _PAD1:32; - u32 _PAD2:32; +u32 _PAD1 : 32; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, PABE) - u32 PABE:1; - u32 _PAD1:31; - u32 _PAD2:32; +u32 PABE : 1; +u32 _PAD1 : 31; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, PRIM) - u32 PRIM:3; - u32 IIP:1; - u32 TME:1; - u32 FGE:1; - u32 ABE:1; - u32 AA1:1; - u32 FST:1; - u32 CTXT:1; - u32 FIX:1; - u32 _PAD1:21; - u32 _PAD2:32; +u32 PRIM : 3; +u32 IIP : 1; +u32 TME : 1; +u32 FGE : 1; +u32 ABE : 1; +u32 AA1 : 1; +u32 FST : 1; +u32 CTXT : 1; +u32 FIX : 1; +u32 _PAD1 : 21; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, PRMODE) - u32 _PRIM:3; - u32 IIP:1; - u32 TME:1; - u32 FGE:1; - u32 ABE:1; - u32 AA1:1; - u32 FST:1; - u32 CTXT:1; - u32 FIX:1; - u32 _PAD2:21; - u32 _PAD3:32; +u32 _PRIM : 3; +u32 IIP : 1; +u32 TME : 1; +u32 FGE : 1; +u32 ABE : 1; +u32 AA1 : 1; +u32 FST : 1; +u32 CTXT : 1; +u32 FIX : 1; +u32 _PAD2 : 21; +u32 _PAD3 : 32; REG_END REG64_(GIFReg, PRMODECONT) - u32 AC:1; - u32 _PAD1:31; - u32 _PAD2:32; +u32 AC : 1; +u32 _PAD1 : 31; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, RGBAQ) - u32 R:8; - u32 G:8; - u32 B:8; - u32 A:8; - float Q; +u32 R : 8; +u32 G : 8; +u32 B : 8; +u32 A : 8; +float Q; REG_END REG64_(GIFReg, SCANMSK) - u32 MSK:2; - u32 _PAD1:30; - u32 _PAD2:32; +u32 MSK : 2; +u32 _PAD1 : 30; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, SCISSOR) - u32 SCAX0:11; - u32 _PAD1:5; - u32 SCAX1:11; - u32 _PAD2:5; - u32 SCAY0:11; - u32 _PAD3:5; - u32 SCAY1:11; - u32 _PAD4:5; +u32 SCAX0 : 11; +u32 _PAD1 : 5; +u32 SCAX1 : 11; +u32 _PAD2 : 5; +u32 SCAY0 : 11; +u32 _PAD3 : 5; +u32 SCAY1 : 11; +u32 _PAD4 : 5; REG_END REG64_(GIFReg, SIGNAL) - u32 ID:32; - u32 IDMSK:32; +u32 ID : 32; +u32 IDMSK : 32; REG_END REG64_(GIFReg, ST) - float S; - float T; +float S; +float T; REG_END REG64_(GIFReg, TEST) - u32 ATE:1; - u32 ATST:3; - u32 AREF:8; - u32 AFAIL:2; - u32 DATE:1; - u32 DATM:1; - u32 ZTE:1; - u32 ZTST:2; - u32 _PAD1:13; - u32 _PAD2:32; +u32 ATE : 1; +u32 ATST : 3; +u32 AREF : 8; +u32 AFAIL : 2; +u32 DATE : 1; +u32 DATM : 1; +u32 ZTE : 1; +u32 ZTST : 2; +u32 _PAD1 : 13; +u32 _PAD2 : 32; REG_END2 - __forceinline bool DoFirstPass() {return !ATE || ATST != ATST_NEVER;} // not all pixels fail automatically - __forceinline bool DoSecondPass() {return ATE && ATST != ATST_ALWAYS && AFAIL != AFAIL_KEEP;} // pixels may fail, write fb/z - __forceinline bool NoSecondPass() {return ATE && ATST != ATST_ALWAYS && AFAIL == AFAIL_KEEP;} // pixels may fail, no output +__forceinline bool DoFirstPass() { return !ATE || ATST != ATST_NEVER; } // not all pixels fail automatically +__forceinline bool DoSecondPass() { return ATE && ATST != ATST_ALWAYS && AFAIL != AFAIL_KEEP; } // pixels may fail, write fb/z +__forceinline bool NoSecondPass() { return ATE && ATST != ATST_ALWAYS && AFAIL == AFAIL_KEEP; } // pixels may fail, no output REG_END2 REG64_(GIFReg, TEX0) union { - struct - { - u32 TBP0:14; - u32 TBW:6; - u32 PSM:6; - u32 TW:4; - u32 _PAD1:2; - u32 _PAD2:2; - u32 TCC:1; - u32 TFX:2; - u32 CBP:14; - u32 CPSM:4; - u32 CSM:1; - u32 CSA:5; - u32 CLD:3; - }; + struct + { + u32 TBP0 : 14; + u32 TBW : 6; + u32 PSM : 6; + u32 TW : 4; + u32 _PAD1 : 2; + u32 _PAD2 : 2; + u32 TCC : 1; + u32 TFX : 2; + u32 CBP : 14; + u32 CPSM : 4; + u32 CSM : 1; + u32 CSA : 5; + u32 CLD : 3; + }; - struct - { - u64 _PAD3:30; - u64 TH:4; - u64 _PAD4:30; - }; + struct + { + u64 _PAD3 : 30; + u64 TH : 4; + u64 _PAD4 : 30; + }; }; REG_END2 - //__forceinline bool IsRepeating() {return ((u32)1 << TW) > (TBW << 6);} +//__forceinline bool IsRepeating() {return ((u32)1 << TW) > (TBW << 6);} REG_END2 REG64_(GIFReg, TEX1) - u32 LCM:1; - u32 _PAD1:1; - u32 MXL:3; - u32 MMAG:1; - u32 MMIN:3; - u32 MTBA:1; - u32 _PAD2:9; - u32 L:2; - u32 _PAD3:11; - s32 K:12; // 1:7:4 - u32 _PAD4:20; +u32 LCM : 1; +u32 _PAD1 : 1; +u32 MXL : 3; +u32 MMAG : 1; +u32 MMIN : 3; +u32 MTBA : 1; +u32 _PAD2 : 9; +u32 L : 2; +u32 _PAD3 : 11; +s32 K : 12; // 1:7:4 +u32 _PAD4 : 20; REG_END2 - bool IsMinLinear() const {return (MMIN == 1) || (MMIN & 4);} - bool IsMagLinear() const {return MMAG;} +bool IsMinLinear() const { return (MMIN == 1) || (MMIN & 4); } +bool IsMagLinear() const { return MMAG; } REG_END2 REG64_(GIFReg, TEX2) - u32 _PAD1:20; - u32 PSM:6; - u32 _PAD2:6; - u32 _PAD3:5; - u32 CBP:14; - u32 CPSM:4; - u32 CSM:1; - u32 CSA:5; - u32 CLD:3; +u32 _PAD1 : 20; +u32 PSM : 6; +u32 _PAD2 : 6; +u32 _PAD3 : 5; +u32 CBP : 14; +u32 CPSM : 4; +u32 CSM : 1; +u32 CSA : 5; +u32 CLD : 3; REG_END REG64_(GIFReg, TEXA) - u32 TA0:8; - u32 _PAD1:7; - u32 AEM:1; - u32 _PAD2:16; - u32 TA1:8; - u32 _PAD3:24; +u32 TA0 : 8; +u32 _PAD1 : 7; +u32 AEM : 1; +u32 _PAD2 : 16; +u32 TA1 : 8; +u32 _PAD3 : 24; REG_END REG64_(GIFReg, TEXCLUT) - u32 CBW:6; - u32 COU:6; - u32 COV:10; - u32 _PAD1:10; - u32 _PAD2:32; +u32 CBW : 6; +u32 COU : 6; +u32 COV : 10; +u32 _PAD1 : 10; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, TEXFLUSH) - u32 _PAD1:32; - u32 _PAD2:32; +u32 _PAD1 : 32; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, TRXDIR) - u32 XDIR:2; - u32 _PAD1:30; - u32 _PAD2:32; +u32 XDIR : 2; +u32 _PAD1 : 30; +u32 _PAD2 : 32; REG_END REG64_(GIFReg, TRXPOS) - u32 SSAX:11; - u32 _PAD1:5; - u32 SSAY:11; - u32 _PAD2:5; - u32 DSAX:11; - u32 _PAD3:5; - u32 DSAY:11; - u32 DIRY:1; - u32 DIRX:1; - u32 _PAD4:3; +u32 SSAX : 11; +u32 _PAD1 : 5; +u32 SSAY : 11; +u32 _PAD2 : 5; +u32 DSAX : 11; +u32 _PAD3 : 5; +u32 DSAY : 11; +u32 DIRY : 1; +u32 DIRX : 1; +u32 _PAD4 : 3; REG_END REG64_(GIFReg, TRXREG) - u32 RRW:12; - u32 _PAD1:20; - u32 RRH:12; - u32 _PAD2:20; +u32 RRW : 12; +u32 _PAD1 : 20; +u32 RRH : 12; +u32 _PAD2 : 20; REG_END // GSState::GIFPackedRegHandlerUV and GSState::GIFRegHandlerUV will make sure that the _PAD1/2 bits are set to zero REG64_(GIFReg, UV) - u32 U:16; +u32 U : 16; // u32 _PAD1:2; - u32 V:16; +u32 V : 16; // u32 _PAD2:2; - u32 _PAD3:32; +u32 _PAD3 : 32; REG_END // GSState::GIFRegHandlerXYOFFSET will make sure that the _PAD1/2 bits are set to zero REG64_(GIFReg, XYOFFSET) - u32 OFX; // :16; u32 _PAD1:16; - u32 OFY; // :16; u32 _PAD2:16; +u32 OFX; // :16; u32 _PAD1:16; +u32 OFY; // :16; u32 _PAD2:16; REG_END REG64_(GIFReg, XYZ) - u32 X:16; - u32 Y:16; - u32 Z:32; +u32 X : 16; +u32 Y : 16; +u32 Z : 32; REG_END REG64_(GIFReg, XYZF) - u32 X:16; - u32 Y:16; - u32 Z:24; - u32 F:8; +u32 X : 16; +u32 Y : 16; +u32 Z : 24; +u32 F : 8; REG_END REG64_(GIFReg, ZBUF) - u32 ZBP:9; - u32 _PAD1:15; - // u32 PSM:4; - // u32 _PAD2:4; - u32 PSM:6; - u32 _PAD2:2; - u32 ZMSK:1; - u32 _PAD3:31; +u32 ZBP : 9; +u32 _PAD1 : 15; +// u32 PSM:4; +// u32 _PAD2:4; +u32 PSM : 6; +u32 _PAD2 : 2; +u32 ZMSK : 1; +u32 _PAD3 : 31; REG_END2 - u32 Block() const {return ZBP << 5;} +u32 Block() const { return ZBP << 5; } REG_END2 REG64_SET(GIFReg) - GIFRegALPHA ALPHA; - GIFRegBITBLTBUF BITBLTBUF; - GIFRegCLAMP CLAMP; - GIFRegCOLCLAMP COLCLAMP; - GIFRegDIMX DIMX; - GIFRegDTHE DTHE; - GIFRegFBA FBA; - GIFRegFINISH FINISH; - GIFRegFOG FOG; - GIFRegFOGCOL FOGCOL; - GIFRegFRAME FRAME; - GIFRegHWREG HWREG; - GIFRegLABEL LABEL; - GIFRegMIPTBP1 MIPTBP1; - GIFRegMIPTBP2 MIPTBP2; - GIFRegNOP NOP; - GIFRegPABE PABE; - GIFRegPRIM PRIM; - GIFRegPRMODE PRMODE; - GIFRegPRMODECONT PRMODECONT; - GIFRegRGBAQ RGBAQ; - GIFRegSCANMSK SCANMSK; - GIFRegSCISSOR SCISSOR; - GIFRegSIGNAL SIGNAL; - GIFRegST ST; - GIFRegTEST TEST; - GIFRegTEX0 TEX0; - GIFRegTEX1 TEX1; - GIFRegTEX2 TEX2; - GIFRegTEXA TEXA; - GIFRegTEXCLUT TEXCLUT; - GIFRegTEXFLUSH TEXFLUSH; - GIFRegTRXDIR TRXDIR; - GIFRegTRXPOS TRXPOS; - GIFRegTRXREG TRXREG; - GIFRegUV UV; - GIFRegXYOFFSET XYOFFSET; - GIFRegXYZ XYZ; - GIFRegXYZF XYZF; - GIFRegZBUF ZBUF; +GIFRegALPHA ALPHA; +GIFRegBITBLTBUF BITBLTBUF; +GIFRegCLAMP CLAMP; +GIFRegCOLCLAMP COLCLAMP; +GIFRegDIMX DIMX; +GIFRegDTHE DTHE; +GIFRegFBA FBA; +GIFRegFINISH FINISH; +GIFRegFOG FOG; +GIFRegFOGCOL FOGCOL; +GIFRegFRAME FRAME; +GIFRegHWREG HWREG; +GIFRegLABEL LABEL; +GIFRegMIPTBP1 MIPTBP1; +GIFRegMIPTBP2 MIPTBP2; +GIFRegNOP NOP; +GIFRegPABE PABE; +GIFRegPRIM PRIM; +GIFRegPRMODE PRMODE; +GIFRegPRMODECONT PRMODECONT; +GIFRegRGBAQ RGBAQ; +GIFRegSCANMSK SCANMSK; +GIFRegSCISSOR SCISSOR; +GIFRegSIGNAL SIGNAL; +GIFRegST ST; +GIFRegTEST TEST; +GIFRegTEX0 TEX0; +GIFRegTEX1 TEX1; +GIFRegTEX2 TEX2; +GIFRegTEXA TEXA; +GIFRegTEXCLUT TEXCLUT; +GIFRegTEXFLUSH TEXFLUSH; +GIFRegTRXDIR TRXDIR; +GIFRegTRXPOS TRXPOS; +GIFRegTRXREG TRXREG; +GIFRegUV UV; +GIFRegXYOFFSET XYOFFSET; +GIFRegXYZ XYZ; +GIFRegXYZF XYZF; +GIFRegZBUF ZBUF; REG_SET_END REG64_SET(GIFCTXTReg) - GIFRegTEX0 TEX0; - GIFRegCLAMP CLAMP; - GIFRegTEX1 TEX1; - GIFRegTEX2 TEX2; - GIFRegXYOFFSET XYOFFSET; - GIFRegMIPTBP1 MIPTBP1; - GIFRegMIPTBP2 MIPTBP2; - GIFRegSCISSOR SCISSOR; - GIFRegALPHA ALPHA; - GIFRegTEST TEST; - GIFRegFBA FBA; - GIFRegFRAME FRAME; - GIFRegZBUF ZBUF; +GIFRegTEX0 TEX0; +GIFRegCLAMP CLAMP; +GIFRegTEX1 TEX1; +GIFRegTEX2 TEX2; +GIFRegXYOFFSET XYOFFSET; +GIFRegMIPTBP1 MIPTBP1; +GIFRegMIPTBP2 MIPTBP2; +GIFRegSCISSOR SCISSOR; +GIFRegALPHA ALPHA; +GIFRegTEST TEST; +GIFRegFBA FBA; +GIFRegFRAME FRAME; +GIFRegZBUF ZBUF; REG_SET_END // GIFPacked REG128_(GIFPacked, PRIM) - u32 PRIM:11; - u32 _PAD1:21; - u32 _PAD2:32; - u32 _PAD3:32; - u32 _PAD4:32; +u32 PRIM : 11; +u32 _PAD1 : 21; +u32 _PAD2 : 32; +u32 _PAD3 : 32; +u32 _PAD4 : 32; REG_END REG128_(GIFPacked, RGBA) - u32 R:8; - u32 _PAD1:24; - u32 G:8; - u32 _PAD2:24; - u32 B:8; - u32 _PAD3:24; - u32 A:8; - u32 _PAD4:24; +u32 R : 8; +u32 _PAD1 : 24; +u32 G : 8; +u32 _PAD2 : 24; +u32 B : 8; +u32 _PAD3 : 24; +u32 A : 8; +u32 _PAD4 : 24; REG_END REG128_(GIFPacked, STQ) - float S; - float T; - float Q; - u32 _PAD1:32; +float S; +float T; +float Q; +u32 _PAD1 : 32; REG_END REG128_(GIFPacked, UV) - u32 U:14; - u32 _PAD1:18; - u32 V:14; - u32 _PAD2:18; - u32 _PAD3:32; - u32 _PAD4:32; +u32 U : 14; +u32 _PAD1 : 18; +u32 V : 14; +u32 _PAD2 : 18; +u32 _PAD3 : 32; +u32 _PAD4 : 32; REG_END REG128_(GIFPacked, XYZF2) - u32 X:16; - u32 _PAD1:16; - u32 Y:16; - u32 _PAD2:16; - u32 _PAD3:4; - u32 Z:24; - u32 _PAD4:4; - u32 _PAD5:4; - u32 F:8; - u32 _PAD6:3; - u32 ADC:1; - u32 _PAD7:16; +u32 X : 16; +u32 _PAD1 : 16; +u32 Y : 16; +u32 _PAD2 : 16; +u32 _PAD3 : 4; +u32 Z : 24; +u32 _PAD4 : 4; +u32 _PAD5 : 4; +u32 F : 8; +u32 _PAD6 : 3; +u32 ADC : 1; +u32 _PAD7 : 16; REG_END REG128_(GIFPacked, XYZ2) - u32 X:16; - u32 _PAD1:16; - u32 Y:16; - u32 _PAD2:16; - u32 Z:32; - u32 _PAD3:15; - u32 ADC:1; - u32 _PAD4:16; +u32 X : 16; +u32 _PAD1 : 16; +u32 Y : 16; +u32 _PAD2 : 16; +u32 Z : 32; +u32 _PAD3 : 15; +u32 ADC : 1; +u32 _PAD4 : 16; REG_END REG128_(GIFPacked, FOG) - u32 _PAD1:32; - u32 _PAD2:32; - u32 _PAD3:32; - u32 _PAD4:4; - u32 F:8; - u32 _PAD5:20; +u32 _PAD1 : 32; +u32 _PAD2 : 32; +u32 _PAD3 : 32; +u32 _PAD4 : 4; +u32 F : 8; +u32 _PAD5 : 20; REG_END REG128_(GIFPacked, A_D) - u64 DATA:64; - u32 ADDR:8; // enum GIF_A_D_REG - u32 _PAD1:24; - u32 _PAD2:32; +u64 DATA : 64; +u32 ADDR : 8; // enum GIF_A_D_REG +u32 _PAD1 : 24; +u32 _PAD2 : 32; REG_END REG128_(GIFPacked, NOP) - u32 _PAD1:32; - u32 _PAD2:32; - u32 _PAD3:32; - u32 _PAD4:32; +u32 _PAD1 : 32; +u32 _PAD2 : 32; +u32 _PAD3 : 32; +u32 _PAD4 : 32; REG_END REG128_SET(GIFPackedReg) - GIFReg r; - GIFPackedPRIM PRIM; - GIFPackedRGBA RGBA; - GIFPackedSTQ STQ; - GIFPackedUV UV; - GIFPackedXYZF2 XYZF2; - GIFPackedXYZ2 XYZ2; - GIFPackedFOG FOG; - GIFPackedA_D A_D; - GIFPackedNOP NOP; +GIFReg r; +GIFPackedPRIM PRIM; +GIFPackedRGBA RGBA; +GIFPackedSTQ STQ; +GIFPackedUV UV; +GIFPackedXYZF2 XYZF2; +GIFPackedXYZ2 XYZ2; +GIFPackedFOG FOG; +GIFPackedA_D A_D; +GIFPackedNOP NOP; REG_SET_END struct GSPrivRegSet { - union - { - struct - { - GSRegPMODE PMODE; - u64 _pad1; - GSRegSMODE1 SMODE1; - u64 _pad2; - GSRegSMODE2 SMODE2; - u64 _pad3; - GSRegSRFSH SRFSH; - u64 _pad4; - GSRegSYNCH1 SYNCH1; - u64 _pad5; - GSRegSYNCH2 SYNCH2; - u64 _pad6; - GSRegSYNCV SYNCV; - u64 _pad7; - struct { - GSRegDISPFB DISPFB; - u64 _pad1; - GSRegDISPLAY DISPLAY; - u64 _pad2; - } DISP[2]; - GSRegEXTBUF EXTBUF; - u64 _pad8; - GSRegEXTDATA EXTDATA; - u64 _pad9; - GSRegEXTWRITE EXTWRITE; - u64 _pad10; - GSRegBGCOLOR BGCOLOR; - u64 _pad11; - }; + union + { + struct + { + GSRegPMODE PMODE; + u64 _pad1; + GSRegSMODE1 SMODE1; + u64 _pad2; + GSRegSMODE2 SMODE2; + u64 _pad3; + GSRegSRFSH SRFSH; + u64 _pad4; + GSRegSYNCH1 SYNCH1; + u64 _pad5; + GSRegSYNCH2 SYNCH2; + u64 _pad6; + GSRegSYNCV SYNCV; + u64 _pad7; + struct + { + GSRegDISPFB DISPFB; + u64 _pad1; + GSRegDISPLAY DISPLAY; + u64 _pad2; + } DISP[2]; + GSRegEXTBUF EXTBUF; + u64 _pad8; + GSRegEXTDATA EXTDATA; + u64 _pad9; + GSRegEXTWRITE EXTWRITE; + u64 _pad10; + GSRegBGCOLOR BGCOLOR; + u64 _pad11; + }; - u8 _pad12[0x1000]; - }; + u8 _pad12[0x1000]; + }; - union - { - struct - { - GSRegCSR CSR; - u64 _pad13; - GSRegIMR IMR; - u64 _pad14; - u64 _unk1[4]; - GSRegBUSDIR BUSDIR; - u64 _pad15; - u64 _unk2[6]; - GSRegSIGLBLID SIGLBLID; - u64 _pad16; - }; + union + { + struct + { + GSRegCSR CSR; + u64 _pad13; + GSRegIMR IMR; + u64 _pad14; + u64 _unk1[4]; + GSRegBUSDIR BUSDIR; + u64 _pad15; + u64 _unk2[6]; + GSRegSIGLBLID SIGLBLID; + u64 _pad16; + }; - u8 _pad17[0x1000]; - }; + u8 _pad17[0x1000]; + }; }; #pragma pack(pop) #endif - diff --git a/plugins/GSnull/Windows/Config.cpp b/plugins/GSnull/Windows/Config.cpp index 110e23e485..c021c4c1f3 100644 --- a/plugins/GSnull/Windows/Config.cpp +++ b/plugins/GSnull/Windows/Config.cpp @@ -21,49 +21,47 @@ extern HINSTANCE hInst; void SaveConfig() { - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; + Config* Conf1 = &conf; + char* szTemp; + char szIniFile[256], szValue[256]; - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); - - if(!szTemp) return; - strcpy(szTemp, "\\inis\\gsnull.ini"); - sprintf(szValue,"%u",Conf1->Log); - WritePrivateProfileString("Interface", "Logging",szValue,szIniFile); + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); + if (!szTemp) + return; + strcpy(szTemp, "\\inis\\gsnull.ini"); + sprintf(szValue, "%u", Conf1->Log); + WritePrivateProfileString("Interface", "Logging", szValue, szIniFile); } -void LoadConfig() +void LoadConfig() { - FILE *fp; + FILE* fp; - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; + Config* Conf1 = &conf; + char* szTemp; + char szIniFile[256], szValue[256]; - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); - if(!szTemp) return ; - strcpy(szTemp, "\\inis\\gsnull.ini"); - fp=fopen("inis\\gsnull.ini","rt");//check if gsnull.ini really exists - - if (!fp) - { - CreateDirectory("inis",NULL); + if (!szTemp) + return; + strcpy(szTemp, "\\inis\\gsnull.ini"); + fp = fopen("inis\\gsnull.ini", "rt"); //check if gsnull.ini really exists + + if (!fp) { + CreateDirectory("inis", NULL); memset(&conf, 0, sizeof(conf)); - conf.Log = 0;//default value - SaveConfig();//save and return - return ; - } - - fclose(fp); - GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); - Conf1->Log = strtoul(szValue, NULL, 10); - return ; + conf.Log = 0; //default value + SaveConfig(); //save and return + return; + } + fclose(fp); + GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); + Conf1->Log = strtoul(szValue, NULL, 10); + return; } - diff --git a/plugins/GSnull/Windows/GSwin.cpp b/plugins/GSnull/Windows/GSwin.cpp index 508ba40347..ccf2eebd44 100644 --- a/plugins/GSnull/Windows/GSwin.cpp +++ b/plugins/GSnull/Windows/GSwin.cpp @@ -20,44 +20,43 @@ HWND GShwnd = NULL; LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) - { + switch (msg) { case WM_CLOSE: DestroyWindow(hwnd); - break; + break; case WM_DESTROY: PostQuitMessage(0); - break; + break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } -int GSOpenWindow(void *pDsp, const char *Title) +int GSOpenWindow(void* pDsp, const char* Title) { - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, - GetModuleHandle(NULL), NULL, NULL, NULL, NULL, - "PS2EMU_GSNULL", NULL }; - RegisterClassEx( &wc ); + WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, + GetModuleHandle(NULL), NULL, NULL, NULL, NULL, + "PS2EMU_GSNULL", NULL}; + RegisterClassEx(&wc); - GShwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "PS2EMU_GSNULL", Title, - WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, wc.hInstance, NULL); + GShwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "PS2EMU_GSNULL", Title, + WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, wc.hInstance, NULL); - if(GShwnd == NULL) - { - GSLog::WriteLn("Failed to create window. Exiting..."); - return -1; - } + if (GShwnd == NULL) { + GSLog::WriteLn("Failed to create window. Exiting..."); + return -1; + } - if( pDsp != NULL ) *(uptr*)pDsp = (uptr)GShwnd; + if (pDsp != NULL) + *(uptr*)pDsp = (uptr)GShwnd; - return 0; + return 0; } void GSCloseWindow() { - DestroyWindow( GShwnd ); + DestroyWindow(GShwnd); } void GSProcessMessages() @@ -65,6 +64,6 @@ void GSProcessMessages() } // GSkeyEvent gets called when there is a keyEvent from the PAD plugin -void HandleKeyEvent(keyEvent *ev) +void HandleKeyEvent(keyEvent* ev) { } diff --git a/plugins/GSnull/Windows/GSwin.h b/plugins/GSnull/Windows/GSwin.h index 723867158a..d39d86113f 100644 --- a/plugins/GSnull/Windows/GSwin.h +++ b/plugins/GSnull/Windows/GSwin.h @@ -18,8 +18,7 @@ #include #include -extern int GSOpenWindow(void *pDsp, const char *Title); +extern int GSOpenWindow(void* pDsp, const char* Title); extern void GSCloseWindow(); extern void GSProcessMessages(); -extern void HandleKeyEvent(keyEvent *ev); - +extern void HandleKeyEvent(keyEvent* ev); diff --git a/plugins/GSnull/Windows/Win32.cpp b/plugins/GSnull/Windows/Win32.cpp index 6ebdda304a..32d61bb9ed 100644 --- a/plugins/GSnull/Windows/Win32.cpp +++ b/plugins/GSnull/Windows/Win32.cpp @@ -24,74 +24,83 @@ HINSTANCE hInst; extern HWND GShwnd; -void SysMessage(char *fmt, ...) { - va_list list; - char tmp[512]; +void SysMessage(char* fmt, ...) +{ + va_list list; + char tmp[512]; - va_start(list,fmt); - vsprintf(tmp,fmt,list); - va_end(list); - MessageBox((GShwnd!=NULL) ? GShwnd : GetActiveWindow(), tmp, "GS Plugin Msg", 0); + va_start(list, fmt); + vsprintf(tmp, fmt, list); + va_end(list); + MessageBox((GShwnd != NULL) ? GShwnd : GetActiveWindow(), tmp, "GS Plugin Msg", 0); } -BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { +BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ - switch(uMsg) { - case WM_INITDIALOG: - LoadConfig(); - if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); - return TRUE; + switch (uMsg) { + case WM_INITDIALOG: + LoadConfig(); + if (conf.Log) + CheckDlgButton(hW, IDC_LOGGING, TRUE); + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - EndDialog(hW, TRUE); - return TRUE; - case IDOK: - if (IsDlgButtonChecked(hW, IDC_LOGGING)) - conf.Log = 1; - else conf.Log = 0; - SaveConfig(); - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hW, TRUE); + return TRUE; + case IDOK: + if (IsDlgButtonChecked(hW, IDC_LOGGING)) + conf.Log = 1; + else + conf.Log = 0; + SaveConfig(); + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { - case WM_INITDIALOG: - return TRUE; +BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case WM_INITDIALOG: + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -EXPORT_C_(void) GSconfigure() { +EXPORT_C_(void) +GSconfigure() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), GetActiveWindow(), (DLGPROC)ConfigureDlgProc); } -EXPORT_C_(void) GSabout() { +EXPORT_C_(void) +GSabout() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), (DLGPROC)AboutDlgProc); } -BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT - DWORD dwReason, - LPVOID lpReserved) { - hInst = (HINSTANCE)hModule; - return TRUE; // very quick :) +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) +{ + hInst = (HINSTANCE)hModule; + return TRUE; // very quick :) } - diff --git a/plugins/GSnull/null/GSnull.cpp b/plugins/GSnull/null/GSnull.cpp index bb7649a681..8c62bbcabe 100644 --- a/plugins/GSnull/null/GSnull.cpp +++ b/plugins/GSnull/null/GSnull.cpp @@ -17,20 +17,20 @@ void OnKeyboardF5(int myShift) { - GSLog::WriteLn("F5 pressed!"); + GSLog::WriteLn("F5 pressed!"); } void OnKeyboardF6(int myShift) { - GSLog::WriteLn("F6 pressed!"); + GSLog::WriteLn("F6 pressed!"); } void OnKeyboardF7(int myShift) { - GSLog::WriteLn("F7 pressed!"); + GSLog::WriteLn("F7 pressed!"); } void OnKeyboardF9(int myShift) { - GSLog::WriteLn("F9 pressed!"); + GSLog::WriteLn("F9 pressed!"); } diff --git a/plugins/PadNull/Linux/Config.cpp b/plugins/PadNull/Linux/Config.cpp index 7ec96e4e65..471a21061b 100644 --- a/plugins/PadNull/Linux/Config.cpp +++ b/plugins/PadNull/Linux/Config.cpp @@ -23,43 +23,43 @@ extern std::string s_strIniPath; PluginConf Ini; -EXPORT_C_(void) PADabout() +EXPORT_C_(void) +PADabout() { - SysMessage("PADnull: A simple null plugin."); + SysMessage("PADnull: A simple null plugin."); } -EXPORT_C_(void) PADconfigure() +EXPORT_C_(void) +PADconfigure() { - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); + LoadConfig(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } void LoadConfig() { const std::string iniFile(s_strIniPath + "/Padnull.ini"); - if (!Ini.Open(iniFile, READ_FILE)) - { - printf("failed to open %s\n", iniFile.c_str()); - SaveConfig();//save and return - return; - } + if (!Ini.Open(iniFile, READ_FILE)) { + printf("failed to open %s\n", iniFile.c_str()); + SaveConfig(); //save and return + return; + } - conf.Log = Ini.ReadInt("logging", 0); - Ini.Close(); + conf.Log = Ini.ReadInt("logging", 0); + Ini.Close(); } void SaveConfig() { const std::string iniFile(s_strIniPath + "/Padnull.ini"); - if (!Ini.Open(iniFile, WRITE_FILE)) - { - printf("failed to open %s\n", iniFile.c_str()); - return; - } + if (!Ini.Open(iniFile, WRITE_FILE)) { + printf("failed to open %s\n", iniFile.c_str()); + return; + } - Ini.WriteInt("logging", conf.Log); - Ini.Close(); + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } diff --git a/plugins/PadNull/Linux/PadLinux.cpp b/plugins/PadNull/Linux/PadLinux.cpp index c36f49ee48..884cc233b2 100644 --- a/plugins/PadNull/Linux/PadLinux.cpp +++ b/plugins/PadNull/Linux/PadLinux.cpp @@ -18,75 +18,70 @@ #include #include "PadLinux.h" -Display *GSdsp; +Display* GSdsp; int autoRepeatMode; void _PadUpdate(int pad) { - XEvent evt; - KeySym key; + XEvent evt; + KeySym key; - // keyboard input - while (XPending(GSdsp) > 0) - { - XNextEvent(GSdsp, &evt); - switch (evt.type) - { - case KeyPress: - key = XLookupKeysym((XKeyEvent *) &evt, 0); + // keyboard input + while (XPending(GSdsp) > 0) { + XNextEvent(GSdsp, &evt); + switch (evt.type) { + case KeyPress: + key = XLookupKeysym((XKeyEvent*)&evt, 0); - // Add code to check if it's one of the keys we configured here on a real pda plugin.. + // Add code to check if it's one of the keys we configured here on a real pda plugin.. - event.evt = KEYPRESS; - event.key = key; - break; + event.evt = KEYPRESS; + event.key = key; + break; - case KeyRelease: - key = XLookupKeysym((XKeyEvent *) &evt, 0); + case KeyRelease: + key = XLookupKeysym((XKeyEvent*)&evt, 0); - // Add code to check if it's one of the keys we configured here on a real pda plugin.. + // Add code to check if it's one of the keys we configured here on a real pda plugin.. - event.evt = KEYRELEASE; - event.key = key; - break; + event.evt = KEYRELEASE; + event.key = key; + break; - case FocusIn: - XAutoRepeatOff(GSdsp); - break; + case FocusIn: + XAutoRepeatOff(GSdsp); + break; - case FocusOut: - XAutoRepeatOn(GSdsp); - break; - } - } + case FocusOut: + XAutoRepeatOn(GSdsp); + break; + } + } } -s32 _PADOpen(void *pDsp) +s32 _PADOpen(void* pDsp) { - - GtkScrolledWindow *win; - win = *(GtkScrolledWindow**) pDsp; + GtkScrolledWindow* win; - if (GTK_IS_WIDGET(win)) - { - // Since we have a GtkScrolledWindow, for now we'll grab whatever display - // comes along instead. Later, we can fiddle with this, but I'm not sure the - // best way to get a Display* out of a GtkScrolledWindow. A GtkWindow I might - // be able to manage... --arcum42 + win = *(GtkScrolledWindow**)pDsp; + + if (GTK_IS_WIDGET(win)) { + // Since we have a GtkScrolledWindow, for now we'll grab whatever display + // comes along instead. Later, we can fiddle with this, but I'm not sure the + // best way to get a Display* out of a GtkScrolledWindow. A GtkWindow I might + // be able to manage... --arcum42 GSdsp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); - } - else - { + } else { GSdsp = *(Display**)pDsp; - } - - XAutoRepeatOff(GSdsp); + } - return 0; + XAutoRepeatOff(GSdsp); + + return 0; } -void _PADClose() +void _PADClose() { - XAutoRepeatOn(GSdsp); + XAutoRepeatOn(GSdsp); } diff --git a/plugins/PadNull/Linux/PadLinux.h b/plugins/PadNull/Linux/PadLinux.h index 3aebb4bf0a..2e816a8bf7 100644 --- a/plugins/PadNull/Linux/PadLinux.h +++ b/plugins/PadNull/Linux/PadLinux.h @@ -23,7 +23,7 @@ #include void _PadUpdate(int pad); -s32 _PADOpen(void *pDsp); +s32 _PADOpen(void* pDsp); void _PADClose(); #endif diff --git a/plugins/PadNull/Pad.cpp b/plugins/PadNull/Pad.cpp index d3ad35220e..3b12f9259e 100644 --- a/plugins/PadNull/Pad.cpp +++ b/plugins/PadNull/Pad.cpp @@ -21,149 +21,164 @@ using namespace std; #include "svnrev.h" #include "Pad.h" -const u8 version = PS2E_PAD_VERSION; +const u8 version = PS2E_PAD_VERSION; const u8 revision = 0; -const u8 build = 1; // increase that with each version +const u8 build = 1; // increase that with each version #ifdef _MSC_VER #define snprintf sprintf_s #endif static char libraryName[256]; -string s_strIniPath="inis"; -string s_strLogPath="logs"; +string s_strIniPath = "inis"; +string s_strLogPath = "logs"; -FILE *padLog; +FILE* padLog; Config conf; keyEvent event; static keyEvent s_event; -EXPORT_C_(u32) PS2EgetLibType() +EXPORT_C_(u32) +PS2EgetLibType() { - return PS2E_LT_PAD; + return PS2E_LT_PAD; } -EXPORT_C_(char*) PS2EgetLibName() +EXPORT_C_(char*) +PS2EgetLibName() { - snprintf( libraryName, 255, "Padnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : ""); - return libraryName; + snprintf(libraryName, 255, "Padnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : ""); + return libraryName; } -EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +EXPORT_C_(u32) +PS2EgetLibVersion2(u32 type) { - return (version<<16) | (revision<<8) | build; + return (version << 16) | (revision << 8) | build; } -void __Log(const char *fmt, ...) +void __Log(const char* fmt, ...) { - va_list list; + va_list list; - if (padLog == NULL) return; - va_start(list, fmt); - vfprintf(padLog, fmt, list); - va_end(list); + if (padLog == NULL) + return; + va_start(list, fmt); + vfprintf(padLog, fmt, list); + va_end(list); } -void __LogToConsole(const char *fmt, ...) +void __LogToConsole(const char* fmt, ...) { - va_list list; + va_list list; - va_start(list, fmt); + va_start(list, fmt); - if (padLog != NULL) vfprintf(padLog, fmt, list); + if (padLog != NULL) + vfprintf(padLog, fmt, list); - printf("PadNull: "); - vprintf(fmt, list); - va_end(list); + printf("PadNull: "); + vprintf(fmt, list); + va_end(list); } -EXPORT_C_(void) PADsetSettingsDir(const char* dir) +EXPORT_C_(void) +PADsetSettingsDir(const char* dir) { - s_strIniPath = (dir == NULL) ? "inis" : dir; + s_strIniPath = (dir == NULL) ? "inis" : dir; } -bool OpenLog() { +bool OpenLog() +{ bool result = true; #ifdef PAD_LOG - if(padLog) return result; + if (padLog) + return result; const std::string LogFile(s_strLogPath + "/padnull.log"); padLog = fopen(LogFile.c_str(), "w"); if (padLog != NULL) - setvbuf(padLog, NULL, _IONBF, 0); + setvbuf(padLog, NULL, _IONBF, 0); else { fprintf(stderr, "Can't create log file %s\n", LogFile.c_str()); result = false; } - PAD_LOG("PADinit\n"); + PAD_LOG("PADinit\n"); #endif return result; } -EXPORT_C_(void) PADsetLogDir(const char* dir) +EXPORT_C_(void) +PADsetLogDir(const char* dir) { - // Get the path to the log directory. - s_strLogPath = (dir==NULL) ? "logs" : dir; + // Get the path to the log directory. + s_strLogPath = (dir == NULL) ? "logs" : dir; - // Reload the log file after updated the path - if (padLog) { + // Reload the log file after updated the path + if (padLog) { fclose(padLog); padLog = NULL; } OpenLog(); } -EXPORT_C_(s32) PADinit(u32 flags) +EXPORT_C_(s32) +PADinit(u32 flags) { - LoadConfig(); + LoadConfig(); OpenLog(); - return 0; + return 0; } -EXPORT_C_(void) PADshutdown() +EXPORT_C_(void) +PADshutdown() { #ifdef PAD_LOG - if (padLog) - { - fclose(padLog); - padLog = NULL; - } + if (padLog) { + fclose(padLog); + padLog = NULL; + } #endif } -EXPORT_C_(s32) PADopen(void *pDsp) +EXPORT_C_(s32) +PADopen(void* pDsp) { - memset(&event, 0, sizeof(event)); + memset(&event, 0, sizeof(event)); - return _PADOpen(pDsp); + return _PADOpen(pDsp); } -EXPORT_C_(void) PADclose() +EXPORT_C_(void) +PADclose() { - _PADClose(); + _PADClose(); } // PADkeyEvent is called every vsync (return NULL if no event) -EXPORT_C_(keyEvent*) PADkeyEvent() +EXPORT_C_(keyEvent*) +PADkeyEvent() { - s_event = event; - event.evt = 0; - event.key = 0; + s_event = event; + event.evt = 0; + event.key = 0; - return &s_event; + return &s_event; } -EXPORT_C_(u8) PADstartPoll(int pad) +EXPORT_C_(u8) +PADstartPoll(int pad) { - return 0; + return 0; } -EXPORT_C_(u8) PADpoll(u8 value) +EXPORT_C_(u8) +PADpoll(u8 value) { - return 0; + return 0; } // call to give a hint to the PAD plugin to query for the keyboard state. A @@ -173,29 +188,34 @@ EXPORT_C_(u8) PADpoll(u8 value) // the window (and input). Note that PADupdate can be called from a different // thread than the other functions, so mutex or other multithreading primitives // have to be added to maintain data integrity. -EXPORT_C_(u32) PADquery() +EXPORT_C_(u32) +PADquery() // returns: 1 if supported pad1 // 2 if supported pad2 // 3 if both are supported { - return 3; + return 3; } -EXPORT_C_(void) PADupdate(int pad) +EXPORT_C_(void) +PADupdate(int pad) { - _PadUpdate(pad); + _PadUpdate(pad); } -EXPORT_C_(void) PADgsDriverInfo(GSdriverInfo *info) +EXPORT_C_(void) +PADgsDriverInfo(GSdriverInfo* info) { } -EXPORT_C_(s32) PADfreeze(int mode, freezeData *data) +EXPORT_C_(s32) +PADfreeze(int mode, freezeData* data) { - return 0; + return 0; } -EXPORT_C_(s32) PADtest() +EXPORT_C_(s32) +PADtest() { - return 0; + return 0; } diff --git a/plugins/PadNull/Pad.h b/plugins/PadNull/Pad.h index d502f8188c..99d5b5882a 100644 --- a/plugins/PadNull/Pad.h +++ b/plugins/PadNull/Pad.h @@ -31,21 +31,21 @@ #ifdef _MSC_VER #define EXPORT_C_(type) extern "C" type CALLBACK #else -#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type +#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type #endif #define PAD_LOG __Log typedef struct { - s32 Log; + s32 Log; } Config; extern Config conf; -extern FILE *padLog; +extern FILE* padLog; extern keyEvent event; -extern void __Log(char *fmt, ...); +extern void __Log(char* fmt, ...); extern void SaveConfig(); extern void LoadConfig(); diff --git a/plugins/PadNull/Windows/Config.cpp b/plugins/PadNull/Windows/Config.cpp index 745e2b7778..506864e1ed 100644 --- a/plugins/PadNull/Windows/Config.cpp +++ b/plugins/PadNull/Windows/Config.cpp @@ -19,29 +19,27 @@ extern std::string s_strIniPath; void SaveConfig() { - const std::string iniFile = s_strIniPath + "/Padnull.ini"; + const std::string iniFile = s_strIniPath + "/Padnull.ini"; - PluginConf ini; - if (!ini.Open(iniFile, READ_FILE)) - { - printf("failed to open %s\n", iniFile.c_str()); - SaveConfig();//save and return - return; - } - conf.Log = ini.ReadInt("logging", 0); - ini.Close(); + PluginConf ini; + if (!ini.Open(iniFile, READ_FILE)) { + printf("failed to open %s\n", iniFile.c_str()); + SaveConfig(); //save and return + return; + } + conf.Log = ini.ReadInt("logging", 0); + ini.Close(); } void LoadConfig() { - const std::string iniFile(s_strIniPath + "/Padnull.ini"); + const std::string iniFile(s_strIniPath + "/Padnull.ini"); - PluginConf ini; - if (!ini.Open(iniFile, WRITE_FILE)) - { - printf("failed to open %s\n", iniFile.c_str()); - return; - } - ini.WriteInt("logging", conf.Log); - ini.Close(); + PluginConf ini; + if (!ini.Open(iniFile, WRITE_FILE)) { + printf("failed to open %s\n", iniFile.c_str()); + return; + } + ini.WriteInt("logging", conf.Log); + ini.Close(); } diff --git a/plugins/PadNull/Windows/PadWin.cpp b/plugins/PadNull/Windows/PadWin.cpp index c01b0db333..1db206be17 100644 --- a/plugins/PadNull/Windows/PadWin.cpp +++ b/plugins/PadNull/Windows/PadWin.cpp @@ -21,56 +21,54 @@ HWND GShwnd = NULL; LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { - case WM_KEYDOWN: - if (lParam & 0x40000000)return TRUE; + switch (msg) { + case WM_KEYDOWN: + if (lParam & 0x40000000) + return TRUE; - event.evt = KEYPRESS; - event.key = wParam; - break; + event.evt = KEYPRESS; + event.key = wParam; + break; - case WM_KEYUP: - event.evt = KEYRELEASE; - event.key = wParam; - break; + case WM_KEYUP: + event.evt = KEYRELEASE; + event.key = wParam; + break; - case WM_DESTROY: - case WM_QUIT: - event.evt = KEYPRESS; - event.key = VK_ESCAPE; - return GSwndProc(hWnd, msg, wParam, lParam); + case WM_DESTROY: + case WM_QUIT: + event.evt = KEYPRESS; + event.key = VK_ESCAPE; + return GSwndProc(hWnd, msg, wParam, lParam); - default: - return GSwndProc(hWnd, msg, wParam, lParam); - }; + default: + return GSwndProc(hWnd, msg, wParam, lParam); + }; - return TRUE; + return TRUE; } void _PadUpdate(int pad) { } -s32 _PADOpen(void *pDsp) +s32 _PADOpen(void* pDsp) { - GShwnd = (HWND)*(long*)pDsp; + GShwnd = (HWND) * (long*)pDsp; - if (GShwnd != NULL && GSwndProc != NULL) - { - // revert - SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc)); - } + if (GShwnd != NULL && GSwndProc != NULL) { + // revert + SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc)); + } GSwndProc = (WNDPROC)GetWindowLongPtr(GShwnd, GWLP_WNDPROC); GSwndProc = ((WNDPROC)SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(PADwndProc))); - return 0; + return 0; } -void _PADClose() +void _PADClose() { - if (GShwnd != NULL && GSwndProc != NULL) - { + if (GShwnd != NULL && GSwndProc != NULL) { SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc)); GSwndProc = NULL; GShwnd = NULL; diff --git a/plugins/PadNull/Windows/PadWin.h b/plugins/PadNull/Windows/PadWin.h index ddc698f382..ba81be0599 100644 --- a/plugins/PadNull/Windows/PadWin.h +++ b/plugins/PadNull/Windows/PadWin.h @@ -20,7 +20,7 @@ #include void _PadUpdate(int pad); -s32 _PADOpen(void *pDsp); +s32 _PADOpen(void* pDsp); void _PADClose(); #endif diff --git a/plugins/PadNull/Windows/Win32.cpp b/plugins/PadNull/Windows/Win32.cpp index 7803d64b73..2c8e526922 100644 --- a/plugins/PadNull/Windows/Win32.cpp +++ b/plugins/PadNull/Windows/Win32.cpp @@ -20,65 +20,72 @@ HINSTANCE hInst; -BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { +BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ - switch(uMsg) { - case WM_INITDIALOG: - LoadConfig(); - if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); - return TRUE; + switch (uMsg) { + case WM_INITDIALOG: + LoadConfig(); + if (conf.Log) + CheckDlgButton(hW, IDC_LOGGING, TRUE); + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - EndDialog(hW, TRUE); - return TRUE; - case IDOK: - if (IsDlgButtonChecked(hW, IDC_LOGGING)) - conf.Log = 1; - else - conf.Log = 0; - SaveConfig(); - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hW, TRUE); + return TRUE; + case IDOK: + if (IsDlgButtonChecked(hW, IDC_LOGGING)) + conf.Log = 1; + else + conf.Log = 0; + SaveConfig(); + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { - case WM_INITDIALOG: - return TRUE; +BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case WM_INITDIALOG: + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -EXPORT_C_(void) PADconfigure() { +EXPORT_C_(void) +PADconfigure() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), GetActiveWindow(), (DLGPROC)ConfigureDlgProc); } -EXPORT_C_(void) PADabout() { +EXPORT_C_(void) +PADabout() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), (DLGPROC)AboutDlgProc); } -BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT - DWORD dwReason, - LPVOID lpReserved) { - hInst = (HINSTANCE)hModule; - return TRUE; // very quick :) +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) +{ + hInst = (HINSTANCE)hModule; + return TRUE; // very quick :) } - diff --git a/plugins/SPU2null/Linux/Config.cpp b/plugins/SPU2null/Linux/Config.cpp index 8b7921c0c5..1bcdfde0d7 100644 --- a/plugins/SPU2null/Linux/Config.cpp +++ b/plugins/SPU2null/Linux/Config.cpp @@ -23,44 +23,44 @@ using namespace std; extern string s_strIniPath; PluginConf Ini; -EXPORT_C_(void) SPU2configure() +EXPORT_C_(void) +SPU2configure() { - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); + LoadConfig(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } -EXPORT_C_(void) SPU2about() +EXPORT_C_(void) +SPU2about() { - //SysMessage("%s %d.%d", libraryName, version, build); - SysMessage("SPU2null: A simple null plugin."); + //SysMessage("%s %d.%d", libraryName, version, build); + SysMessage("SPU2null: A simple null plugin."); } void LoadConfig() { const std::string iniFile(s_strIniPath + "/Spu2null.ini"); - if (!Ini.Open(iniFile, READ_FILE)) - { - printf("failed to open %s\n", iniFile.c_str()); - SaveConfig();//save and return - return; - } + if (!Ini.Open(iniFile, READ_FILE)) { + printf("failed to open %s\n", iniFile.c_str()); + SaveConfig(); //save and return + return; + } - conf.Log = Ini.ReadInt("logging", 0); - Ini.Close(); + conf.Log = Ini.ReadInt("logging", 0); + Ini.Close(); } void SaveConfig() { const std::string iniFile(s_strIniPath + "/Spu2null.ini"); - if (!Ini.Open(iniFile, WRITE_FILE)) - { - printf("failed to open %s\n", iniFile.c_str()); - return; - } + if (!Ini.Open(iniFile, WRITE_FILE)) { + printf("failed to open %s\n", iniFile.c_str()); + return; + } - Ini.WriteInt("logging", conf.Log); - Ini.Close(); + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } diff --git a/plugins/SPU2null/SPU2.cpp b/plugins/SPU2null/SPU2.cpp index 73cda72ef0..6f845f68f6 100644 --- a/plugins/SPU2null/SPU2.cpp +++ b/plugins/SPU2null/SPU2.cpp @@ -23,27 +23,27 @@ #include using namespace std; -const u8 version = PS2E_SPU2_VERSION; +const u8 version = PS2E_SPU2_VERSION; const u8 revision = 0; -const u8 build = 8; // increase that with each version -const u32 minor = 0; // increase that with each version +const u8 build = 8; // increase that with each version +const u32 minor = 0; // increase that with each version // ADSR constants -#define ATTACK_MS 494L -#define DECAYHALF_MS 286L -#define DECAY_MS 572L -#define SUSTAIN_MS 441L -#define RELEASE_MS 437L +#define ATTACK_MS 494L +#define DECAYHALF_MS 286L +#define DECAY_MS 572L +#define SUSTAIN_MS 441L +#define RELEASE_MS 437L #ifdef PCSX2_DEBUG -char *libraryName = "SPU2null (Debug)"; +char* libraryName = "SPU2null (Debug)"; #else -char *libraryName = "SPU2null "; +char* libraryName = "SPU2null "; #endif -string s_strIniPath="inis/"; -string s_strLogPath="logs/"; +string s_strIniPath = "inis/"; +string s_strLogPath = "logs/"; -FILE *spu2Log; +FILE* spu2Log; Config conf; ADMA Adma4; @@ -52,11 +52,11 @@ ADMA Adma7; u32 MemAddr[2]; u32 g_nSpuInit = 0; u16 interrupt = 0; -s8 *spu2regs = NULL; +s8* spu2regs = NULL; u16* spu2mem = NULL; u16* pSpuIrq[2] = {NULL}; -u32 dwEndChannel2[2] = {0}; // keeps track of what channels have ended -u32 dwNoiseVal = 1; // global noise generator +u32 dwEndChannel2[2] = {0}; // keeps track of what channels have ended +u32 dwNoiseVal = 1; // global noise generator s32 SPUCycles = 0, SPUWorkerCycles = 0; s32 SPUStartCycle[2]; @@ -67,152 +67,160 @@ int ADMAS7Write(); void InitADSR(); -void (*irqCallbackSPU2)(); // func of main emu, called on spu irq -void (*irqCallbackDMA4)() = 0; // func of main emu, called on spu irq -void (*irqCallbackDMA7)() = 0; // func of main emu, called on spu irq +void (*irqCallbackSPU2)(); // func of main emu, called on spu irq +void (*irqCallbackDMA4)() = 0; // func of main emu, called on spu irq +void (*irqCallbackDMA7)() = 0; // func of main emu, called on spu irq const s32 f[5][2] = { - { 0, 0 }, - { 60, 0 }, - { 115, -52 }, - { 98, -55 }, - { 122, -60 } -}; + {0, 0}, + {60, 0}, + {115, -52}, + {98, -55}, + {122, -60}}; u32 RateTable[160]; // channels and voices -VOICE_PROCESSED voices[SPU_NUMBER_VOICES+1]; // +1 for modulation +VOICE_PROCESSED voices[SPU_NUMBER_VOICES + 1]; // +1 for modulation -EXPORT_C_(u32) PS2EgetLibType() +EXPORT_C_(u32) +PS2EgetLibType() { - return PS2E_LT_SPU2; + return PS2E_LT_SPU2; } -EXPORT_C_(char*) PS2EgetLibName() +EXPORT_C_(char*) +PS2EgetLibName() { - return libraryName; + return libraryName; } -EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +EXPORT_C_(u32) +PS2EgetLibVersion2(u32 type) { - return (version << 16) | (revision << 8) | build | (minor << 24); + return (version << 16) | (revision << 8) | build | (minor << 24); } -void __Log(char *fmt, ...) +void __Log(char* fmt, ...) { - va_list list; + va_list list; - if (!conf.Log || spu2Log == NULL) return; + if (!conf.Log || spu2Log == NULL) + return; - va_start(list, fmt); - vfprintf(spu2Log, fmt, list); - va_end(list); + va_start(list, fmt); + vfprintf(spu2Log, fmt, list); + va_end(list); } -EXPORT_C_(void) SPU2setSettingsDir(const char* dir) +EXPORT_C_(void) +SPU2setSettingsDir(const char* dir) { - s_strIniPath = (dir == NULL) ? "inis/" : dir; + s_strIniPath = (dir == NULL) ? "inis/" : dir; } -bool OpenLog() { +bool OpenLog() +{ bool result = true; #ifdef SPU2_LOG - if(spu2Log) return result; + if (spu2Log) + return result; const std::string LogFile(s_strLogPath + "/spu2null.log"); spu2Log = fopen(LogFile.c_str(), "w"); if (spu2Log != NULL) - setvbuf(spu2Log, NULL, _IONBF, 0); + setvbuf(spu2Log, NULL, _IONBF, 0); else { SysMessage("Can't create log file %s\n", LogFile.c_str()); result = false; } - SPU2_LOG("Spu2 null version %d,%d\n", revision, build); - SPU2_LOG("SPU2init\n"); + SPU2_LOG("Spu2 null version %d,%d\n", revision, build); + SPU2_LOG("SPU2init\n"); #endif return result; } -EXPORT_C_(void) SPU2setLogDir(const char* dir) +EXPORT_C_(void) +SPU2setLogDir(const char* dir) { - // Get the path to the log directory. - s_strLogPath = (dir==NULL) ? "logs/" : dir; + // Get the path to the log directory. + s_strLogPath = (dir == NULL) ? "logs/" : dir; - // Reload the log file after updated the path - if(spu2Log) { + // Reload the log file after updated the path + if (spu2Log) { fclose(spu2Log); spu2Log = NULL; } OpenLog(); } -EXPORT_C_(s32) SPU2init() +EXPORT_C_(s32) +SPU2init() { OpenLog(); - spu2regs = (s8*)malloc(0x10000); - if (spu2regs == NULL) - { - SysMessage("Error allocating Memory\n"); - return -1; - } - memset(spu2regs, 0, 0x10000); + spu2regs = (s8*)malloc(0x10000); + if (spu2regs == NULL) { + SysMessage("Error allocating Memory\n"); + return -1; + } + memset(spu2regs, 0, 0x10000); - spu2mem = (u16*)malloc(0x200000); // 2Mb - if (spu2mem == NULL) - { - SysMessage("Error allocating Memory\n"); - return -1; - } - memset(spu2mem, 0, 0x200000); - memset(dwEndChannel2, 0, sizeof(dwEndChannel2)); + spu2mem = (u16*)malloc(0x200000); // 2Mb + if (spu2mem == NULL) { + SysMessage("Error allocating Memory\n"); + return -1; + } + memset(spu2mem, 0, 0x200000); + memset(dwEndChannel2, 0, sizeof(dwEndChannel2)); - InitADSR(); + InitADSR(); - memset(voices, 0, sizeof(voices)); - // last 24 channels have higher mem offset - for (int i = 0; i < 24; ++i) - voices[i+24].memoffset = 0x400; + memset(voices, 0, sizeof(voices)); + // last 24 channels have higher mem offset + for (int i = 0; i < 24; ++i) + voices[i + 24].memoffset = 0x400; - // init each channel - for (u32 i = 0; i < ArraySize(voices); ++i) - { + // init each channel + for (u32 i = 0; i < ArraySize(voices); ++i) { - voices[i].pLoop = voices[i].pStart = voices[i].pCurr = (u8*)spu2mem; + voices[i].pLoop = voices[i].pStart = voices[i].pCurr = (u8*)spu2mem; - voices[i].pvoice = (_SPU_VOICE*)((u8*)spu2regs + voices[i].memoffset) + (i % 24); - voices[i].ADSRX.SustainLevel = 1024; // -> init sustain - } + voices[i].pvoice = (_SPU_VOICE*)((u8*)spu2regs + voices[i].memoffset) + (i % 24); + voices[i].ADSRX.SustainLevel = 1024; // -> init sustain + } - return 0; + return 0; } -EXPORT_C_(s32) SPU2open(void *pDsp) +EXPORT_C_(s32) +SPU2open(void* pDsp) { - LoadConfig(); - SPUCycles = SPUWorkerCycles = 0; - interrupt = 0; - SPUStartCycle[0] = SPUStartCycle[1] = 0; - SPUTargetCycle[0] = SPUTargetCycle[1] = 0; - g_nSpuInit = 1; - return 0; + LoadConfig(); + SPUCycles = SPUWorkerCycles = 0; + interrupt = 0; + SPUStartCycle[0] = SPUStartCycle[1] = 0; + SPUTargetCycle[0] = SPUTargetCycle[1] = 0; + g_nSpuInit = 1; + return 0; } -EXPORT_C_(void) SPU2close() +EXPORT_C_(void) +SPU2close() { - g_nSpuInit = 0; + g_nSpuInit = 0; } -EXPORT_C_(void) SPU2shutdown() +EXPORT_C_(void) +SPU2shutdown() { - free(spu2regs); - spu2regs = NULL; - free(spu2mem); - spu2mem = NULL; + free(spu2regs); + spu2regs = NULL; + free(spu2mem); + spu2mem = NULL; #ifdef SPU2_LOG - if(spu2Log) { + if (spu2Log) { fclose(spu2Log); spu2Log = NULL; } @@ -222,482 +230,432 @@ EXPORT_C_(void) SPU2shutdown() // simulate SPU2 for 1ms void SPU2Worker(); -#define CYCLES_PER_MS (36864000/1000) +#define CYCLES_PER_MS (36864000 / 1000) -EXPORT_C_(void) SPU2async(u32 cycle) +EXPORT_C_(void) +SPU2async(u32 cycle) { - SPUCycles += cycle; - if (interrupt & (1 << 2)) - { - if (SPUCycles - SPUStartCycle[1] >= SPUTargetCycle[1]) - { - interrupt &= ~(1 << 2); - irqCallbackDMA7(); - } + SPUCycles += cycle; + if (interrupt & (1 << 2)) { + if (SPUCycles - SPUStartCycle[1] >= SPUTargetCycle[1]) { + interrupt &= ~(1 << 2); + irqCallbackDMA7(); + } + } - } + if (interrupt & (1 << 1)) { + if (SPUCycles - SPUStartCycle[0] >= SPUTargetCycle[0]) { + interrupt &= ~(1 << 1); + irqCallbackDMA4(); + } + } - if (interrupt & (1 << 1)) - { - if (SPUCycles - SPUStartCycle[0] >= SPUTargetCycle[0]) - { - interrupt &= ~(1 << 1); - irqCallbackDMA4(); - } - } + if (g_nSpuInit) { - if (g_nSpuInit) - { - - while (SPUCycles - SPUWorkerCycles > 0 && CYCLES_PER_MS < SPUCycles - SPUWorkerCycles) - { - SPU2Worker(); - SPUWorkerCycles += CYCLES_PER_MS; - } - } + while (SPUCycles - SPUWorkerCycles > 0 && CYCLES_PER_MS < SPUCycles - SPUWorkerCycles) { + SPU2Worker(); + SPUWorkerCycles += CYCLES_PER_MS; + } + } } -void InitADSR() // INIT ADSR +void InitADSR() // INIT ADSR { - u32 r, rs, rd; - s32 i; - memset(RateTable, 0, sizeof(u32)*160); // build the rate table according to Neill's rules (see at bottom of file) + u32 r, rs, rd; + s32 i; + memset(RateTable, 0, sizeof(u32) * 160); // build the rate table according to Neill's rules (see at bottom of file) - r = 3; - rs = 1; - rd = 0; + r = 3; + rs = 1; + rd = 0; - for (i = 32;i < 160;i++) // we start at pos 32 with the real values... everything before is 0 - { - if (r < 0x3FFFFFFF) - { - r += rs; - rd++; - if (rd == 5) - { - rd = 1; - rs *= 2; - } - } - if (r > 0x3FFFFFFF) r = 0x3FFFFFFF; + for (i = 32; i < 160; i++) // we start at pos 32 with the real values... everything before is 0 + { + if (r < 0x3FFFFFFF) { + r += rs; + rd++; + if (rd == 5) { + rd = 1; + rs *= 2; + } + } + if (r > 0x3FFFFFFF) + r = 0x3FFFFFFF; - RateTable[i] = r; - } + RateTable[i] = r; + } } -int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR +int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR { - if (pvoice->bStop) // should be stopped: - { - if (pvoice->bIgnoreLoop == 0) - { - pvoice->ADSRX.EnvelopeVol = 0; - pvoice->bOn = false; - pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); - pvoice->pLoop = (u8*)(spu2mem + pvoice->iStartAddr); - pvoice->pCurr = (u8*)(spu2mem + pvoice->iStartAddr); - pvoice->bStop = true; - pvoice->bIgnoreLoop = false; - return 0; - } - if (pvoice->ADSRX.ReleaseModeExp)// do release - { - switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7) - { - case 0: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +0 + 32]; - break; - case 1: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +4 + 32]; - break; - case 2: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +6 + 32]; - break; - case 3: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +8 + 32]; - break; - case 4: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +9 + 32]; - break; - case 5: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +10+ 32]; - break; - case 6: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +11+ 32]; - break; - case 7: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x18 +12+ 32]; - break; - } - } - else - { - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.ReleaseRate^0x1F))-0x0C + 32]; - } + if (pvoice->bStop) // should be stopped: + { + if (pvoice->bIgnoreLoop == 0) { + pvoice->ADSRX.EnvelopeVol = 0; + pvoice->bOn = false; + pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->pLoop = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->pCurr = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->bStop = true; + pvoice->bIgnoreLoop = false; + return 0; + } + if (pvoice->ADSRX.ReleaseModeExp) // do release + { + switch ((pvoice->ADSRX.EnvelopeVol >> 28) & 0x7) { + case 0: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 0 + 32]; + break; + case 1: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 4 + 32]; + break; + case 2: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 6 + 32]; + break; + case 3: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 8 + 32]; + break; + case 4: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 9 + 32]; + break; + case 5: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 10 + 32]; + break; + case 6: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 11 + 32]; + break; + case 7: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 12 + 32]; + break; + } + } else { + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x0C + 32]; + } - if (pvoice->ADSRX.EnvelopeVol < 0) - { - pvoice->ADSRX.EnvelopeVol = 0; - pvoice->bOn = false; - pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); - pvoice->pLoop = (u8*)(spu2mem + pvoice->iStartAddr); - pvoice->pCurr = (u8*)(spu2mem + pvoice->iStartAddr); - pvoice->bStop = true; - pvoice->bIgnoreLoop = false; - //pvoice->bReverb=0; - //pvoice->bNoise=0; - } + if (pvoice->ADSRX.EnvelopeVol < 0) { + pvoice->ADSRX.EnvelopeVol = 0; + pvoice->bOn = false; + pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->pLoop = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->pCurr = (u8*)(spu2mem + pvoice->iStartAddr); + pvoice->bStop = true; + pvoice->bIgnoreLoop = false; + //pvoice->bReverb=0; + //pvoice->bNoise=0; + } - pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; - pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; - return pvoice->ADSRX.lVolume; - } - else // not stopped yet? - { - if (pvoice->ADSRX.State == 0) // -> attack - { - if (pvoice->ADSRX.AttackModeExp) - { - if (pvoice->ADSRX.EnvelopeVol < 0x60000000) - pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x10 + 32]; - else - pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x18 + 32]; - } - else - { - pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate^0x7F)-0x10 + 32]; - } + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + return pvoice->ADSRX.lVolume; + } else // not stopped yet? + { + if (pvoice->ADSRX.State == 0) // -> attack + { + if (pvoice->ADSRX.AttackModeExp) { + if (pvoice->ADSRX.EnvelopeVol < 0x60000000) + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate ^ 0x7F) - 0x10 + 32]; + else + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate ^ 0x7F) - 0x18 + 32]; + } else { + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate ^ 0x7F) - 0x10 + 32]; + } - if (pvoice->ADSRX.EnvelopeVol < 0) - { - pvoice->ADSRX.EnvelopeVol = 0x7FFFFFFF; - pvoice->ADSRX.State = 1; - } + if (pvoice->ADSRX.EnvelopeVol < 0) { + pvoice->ADSRX.EnvelopeVol = 0x7FFFFFFF; + pvoice->ADSRX.State = 1; + } - pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; - return pvoice->ADSRX.lVolume; - } - //--------------------------------------------------// - if (pvoice->ADSRX.State == 1) // -> decay - { - switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7) - { - case 0: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+0 + 32]; - break; - case 1: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+4 + 32]; - break; - case 2: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+6 + 32]; - break; - case 3: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+8 + 32]; - break; - case 4: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+9 + 32]; - break; - case 5: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+10+ 32]; - break; - case 6: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+11+ 32]; - break; - case 7: - pvoice->ADSRX.EnvelopeVol -= RateTable[(4*(pvoice->ADSRX.DecayRate^0x1F))-0x18+12+ 32]; - break; - } + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + return pvoice->ADSRX.lVolume; + } + //--------------------------------------------------// + if (pvoice->ADSRX.State == 1) // -> decay + { + switch ((pvoice->ADSRX.EnvelopeVol >> 28) & 0x7) { + case 0: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 0 + 32]; + break; + case 1: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 4 + 32]; + break; + case 2: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 6 + 32]; + break; + case 3: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 8 + 32]; + break; + case 4: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 9 + 32]; + break; + case 5: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 10 + 32]; + break; + case 6: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 11 + 32]; + break; + case 7: + pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 12 + 32]; + break; + } - if (pvoice->ADSRX.EnvelopeVol < 0) pvoice->ADSRX.EnvelopeVol = 0; - if (((pvoice->ADSRX.EnvelopeVol >> 27)&0xF) <= pvoice->ADSRX.SustainLevel) - { - pvoice->ADSRX.State = 2; - } + if (pvoice->ADSRX.EnvelopeVol < 0) + pvoice->ADSRX.EnvelopeVol = 0; + if (((pvoice->ADSRX.EnvelopeVol >> 27) & 0xF) <= pvoice->ADSRX.SustainLevel) { + pvoice->ADSRX.State = 2; + } - pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; - return pvoice->ADSRX.lVolume; - } - //--------------------------------------------------// - if (pvoice->ADSRX.State == 2) // -> sustain - { - if (pvoice->ADSRX.SustainIncrease) - { - if (pvoice->ADSRX.SustainModeExp) - { - if (pvoice->ADSRX.EnvelopeVol < 0x60000000) - pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x10 + 32]; - else - pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x18 + 32]; - } - else - { - pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate^0x7F)-0x10 + 32]; - } + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + return pvoice->ADSRX.lVolume; + } + //--------------------------------------------------// + if (pvoice->ADSRX.State == 2) // -> sustain + { + if (pvoice->ADSRX.SustainIncrease) { + if (pvoice->ADSRX.SustainModeExp) { + if (pvoice->ADSRX.EnvelopeVol < 0x60000000) + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate ^ 0x7F) - 0x10 + 32]; + else + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate ^ 0x7F) - 0x18 + 32]; + } else { + pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate ^ 0x7F) - 0x10 + 32]; + } - if (pvoice->ADSRX.EnvelopeVol < 0) - { - pvoice->ADSRX.EnvelopeVol = 0x7FFFFFFF; - } - } - else - { - if (pvoice->ADSRX.SustainModeExp) - { - switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7) - { - case 0: - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +0 + 32]; - break; - case 1: - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +4 + 32]; - break; - case 2: - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +6 + 32]; - break; - case 3: - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +8 + 32]; - break; - case 4: - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +9 + 32]; - break; - case 5: - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +10+ 32]; - break; - case 6: - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +11+ 32]; - break; - case 7: - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x1B +12+ 32]; - break; - } - } - else - { - pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate^0x7F))-0x0F + 32]; - } + if (pvoice->ADSRX.EnvelopeVol < 0) { + pvoice->ADSRX.EnvelopeVol = 0x7FFFFFFF; + } + } else { + if (pvoice->ADSRX.SustainModeExp) { + switch ((pvoice->ADSRX.EnvelopeVol >> 28) & 0x7) { + case 0: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 0 + 32]; + break; + case 1: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 4 + 32]; + break; + case 2: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 6 + 32]; + break; + case 3: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 8 + 32]; + break; + case 4: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 9 + 32]; + break; + case 5: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 10 + 32]; + break; + case 6: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 11 + 32]; + break; + case 7: + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 12 + 32]; + break; + } + } else { + pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x0F + 32]; + } - if (pvoice->ADSRX.EnvelopeVol < 0) - { - pvoice->ADSRX.EnvelopeVol = 0; - } - } - pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; - return pvoice->ADSRX.lVolume; - } - } - return 0; + if (pvoice->ADSRX.EnvelopeVol < 0) { + pvoice->ADSRX.EnvelopeVol = 0; + } + } + pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21; + return pvoice->ADSRX.lVolume; + } + } + return 0; } // simulate SPU2 for 1ms void SPU2Worker() { - u8* start; - int ch, flags; + u8* start; + int ch, flags; - VOICE_PROCESSED* pChannel = voices; - for (ch = 0;ch < SPU_NUMBER_VOICES;ch++, pChannel++) // loop em all... we will collect 1 ms of sound of each playing channel - { - if (pChannel->bNew) - { - pChannel->StartSound(); // start new sound - dwEndChannel2[ch/24] &= ~(1 << (ch % 24)); // clear end channel bit - } + VOICE_PROCESSED* pChannel = voices; + for (ch = 0; ch < SPU_NUMBER_VOICES; ch++, pChannel++) // loop em all... we will collect 1 ms of sound of each playing channel + { + if (pChannel->bNew) { + pChannel->StartSound(); // start new sound + dwEndChannel2[ch / 24] &= ~(1 << (ch % 24)); // clear end channel bit + } - if (!pChannel->bOn) - { - // fill buffer with empty data - continue; - } + if (!pChannel->bOn) { + // fill buffer with empty data + continue; + } - if (pChannel->iActFreq != pChannel->iUsedFreq) // new psx frequency? - pChannel->VoiceChangeFrequency(); + if (pChannel->iActFreq != pChannel->iUsedFreq) // new psx frequency? + pChannel->VoiceChangeFrequency(); - // loop until 1 ms of data is reached - int ns = 0; - while (ns < NSSIZE) - { - while (pChannel->spos >= 0x10000) - { - if (pChannel->iSBPos == 28) // 28 reached? - { - start = pChannel->pCurr; // set up the current pos + // loop until 1 ms of data is reached + int ns = 0; + while (ns < NSSIZE) { + while (pChannel->spos >= 0x10000) { + if (pChannel->iSBPos == 28) // 28 reached? + { + start = pChannel->pCurr; // set up the current pos - // special "stop" sign - if (start == (u8*) - 1) //!pChannel->bOn - { - pChannel->bOn = false; // -> turn everything off - pChannel->ADSRX.lVolume = 0; - pChannel->ADSRX.EnvelopeVol = 0; - goto ENDX; // -> and done for this channel - } + // special "stop" sign + if (start == (u8*)-1) //!pChannel->bOn + { + pChannel->bOn = false; // -> turn everything off + pChannel->ADSRX.lVolume = 0; + pChannel->ADSRX.EnvelopeVol = 0; + goto ENDX; // -> and done for this channel + } - pChannel->iSBPos = 0; + pChannel->iSBPos = 0; - // decode the 16 byte packet + // decode the 16 byte packet - flags = (int)start[1]; - start += 16; + flags = (int)start[1]; + start += 16; - // some callback and irq active? - if (pChannel->GetCtrl()->irq) - { - // if irq address reached or irq on looping addr, when stop/loop flag is set - u8* pirq = (u8*)pSpuIrq[ch>=24]; - if ((pirq > start - 16 && pirq <= start) - || ((flags&1) && (pirq > pChannel->pLoop - 16 && pirq <= pChannel->pLoop))) - { - IRQINFO |= 4 << (int)(ch >= 24); - irqCallbackSPU2(); - } - } + // some callback and irq active? + if (pChannel->GetCtrl()->irq) { + // if irq address reached or irq on looping addr, when stop/loop flag is set + u8* pirq = (u8*)pSpuIrq[ch >= 24]; + if ((pirq > start - 16 && pirq <= start) || ((flags & 1) && (pirq > pChannel->pLoop - 16 && pirq <= pChannel->pLoop))) { + IRQINFO |= 4 << (int)(ch >= 24); + irqCallbackSPU2(); + } + } - // flag handler - if ((flags&4) && (!pChannel->bIgnoreLoop)) - pChannel->pLoop = start - 16; // loop adress + // flag handler + if ((flags & 4) && (!pChannel->bIgnoreLoop)) + pChannel->pLoop = start - 16; // loop adress - if (flags&1) // 1: stop/loop - { - // We play this block out first... - dwEndChannel2[ch/24] |= (1 << (ch % 24)); - //if(!(flags&2)) // 1+2: do loop... otherwise: stop - if (flags != 3 || pChannel->pLoop == NULL) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example) - { // and checking if pLoop is set avoids crashes, yeah - start = (u8*) - 1; - pChannel->bStop = true; - pChannel->bIgnoreLoop = false; - } - else - { - start = pChannel->pLoop; - } - } + if (flags & 1) // 1: stop/loop + { + // We play this block out first... + dwEndChannel2[ch / 24] |= (1 << (ch % 24)); + //if(!(flags&2)) // 1+2: do loop... otherwise: stop + if (flags != 3 || pChannel->pLoop == NULL) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example) + { // and checking if pLoop is set avoids crashes, yeah + start = (u8*)-1; + pChannel->bStop = true; + pChannel->bIgnoreLoop = false; + } else { + start = pChannel->pLoop; + } + } - pChannel->pCurr = start; // store values for next cycle - } + pChannel->pCurr = start; // store values for next cycle + } - pChannel->iSBPos++; // get sample data - pChannel->spos -= 0x10000; - } + pChannel->iSBPos++; // get sample data + pChannel->spos -= 0x10000; + } - MixADSR(pChannel); + MixADSR(pChannel); - // go to the next packet - ns++; - pChannel->spos += pChannel->sinc; - } -ENDX: - ; - } + // go to the next packet + ns++; + pChannel->spos += pChannel->sinc; + } + ENDX:; + } - // mix all channels - if ((spu2Ru16(REG_C0_MMIX) & 0xC0) && (spu2Ru16(REG_C0_ADMAS) & 0x1) && !(spu2Ru16(REG_C0_CTRL) & 0x30)) - { - for (int ns = 0;ns < NSSIZE;ns++) - { - Adma4.Index += 1; + // mix all channels + if ((spu2Ru16(REG_C0_MMIX) & 0xC0) && (spu2Ru16(REG_C0_ADMAS) & 0x1) && !(spu2Ru16(REG_C0_CTRL) & 0x30)) { + for (int ns = 0; ns < NSSIZE; ns++) { + Adma4.Index += 1; - if (Adma4.Index == 128 || Adma4.Index == 384) - { - if (ADMAS4Write()) - { - spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; - irqCallbackDMA4(); - } - else MemAddr[0] += 1024; - } + if (Adma4.Index == 128 || Adma4.Index == 384) { + if (ADMAS4Write()) { + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; + irqCallbackDMA4(); + } else + MemAddr[0] += 1024; + } - if (Adma4.Index == 512) - { - Adma4.Index = 0; - } - } - } + if (Adma4.Index == 512) { + Adma4.Index = 0; + } + } + } - if ((spu2Ru16(REG_C1_MMIX) & 0xC0) && (spu2Ru16(REG_C1_ADMAS) & 0x2) && !(spu2Ru16(REG_C1_CTRL) & 0x30)) - { - for (int ns = 0;ns < NSSIZE;ns++) - { - Adma7.Index += 1; + if ((spu2Ru16(REG_C1_MMIX) & 0xC0) && (spu2Ru16(REG_C1_ADMAS) & 0x2) && !(spu2Ru16(REG_C1_CTRL) & 0x30)) { + for (int ns = 0; ns < NSSIZE; ns++) { + Adma7.Index += 1; - if (Adma7.Index == 128 || Adma7.Index == 384) - { - if (ADMAS7Write()) - { - spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; - irqCallbackDMA7(); - } - else MemAddr[1] += 1024; - } + if (Adma7.Index == 128 || Adma7.Index == 384) { + if (ADMAS7Write()) { + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; + irqCallbackDMA7(); + } else + MemAddr[1] += 1024; + } - if (Adma7.Index == 512) Adma7.Index = 0; - } - } + if (Adma7.Index == 512) + Adma7.Index = 0; + } + } } -EXPORT_C_(void) SPU2readDMA4Mem(u16 *pMem, int size) +EXPORT_C_(void) +SPU2readDMA4Mem(u16* pMem, int size) { - u32 spuaddr = C0_SPUADDR; - int i; + u32 spuaddr = C0_SPUADDR; + int i; - SPU2_LOG("SPU2 readDMA4Mem size %x, addr: %x\n", size, pMem); + SPU2_LOG("SPU2 readDMA4Mem size %x, addr: %x\n", size, pMem); - for (i = 0;i < size;i++) - { - *pMem++ = *(u16*)(spu2mem + spuaddr); - if ((spu2Rs16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr) - { - spu2Ru16(SPDIF_OUT) |= 0x4; - C0_SPUADDR_SET(spuaddr); - IRQINFO |= 4; - irqCallbackSPU2(); - } + for (i = 0; i < size; i++) { + *pMem++ = *(u16*)(spu2mem + spuaddr); + if ((spu2Rs16(REG_C0_CTRL) & 0x40) && C0_IRQA == spuaddr) { + spu2Ru16(SPDIF_OUT) |= 0x4; + C0_SPUADDR_SET(spuaddr); + IRQINFO |= 4; + irqCallbackSPU2(); + } - spuaddr++; // inc spu addr - if (spuaddr > 0x0fffff) // wrap at 2Mb - spuaddr = 0; // wrap - } + spuaddr++; // inc spu addr + if (spuaddr > 0x0fffff) // wrap at 2Mb + spuaddr = 0; // wrap + } - spuaddr += 19; //Transfer Local To Host TSAH/L + Data Size + 20 (already +1'd) - C0_SPUADDR_SET(spuaddr); + spuaddr += 19; //Transfer Local To Host TSAH/L + Data Size + 20 (already +1'd) + C0_SPUADDR_SET(spuaddr); - // got from J.F. and Kanodin... is it needed? - spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; // DMA complete - SPUStartCycle[0] = SPUCycles; - SPUTargetCycle[0] = size; - interrupt |= (1 << 1); + // got from J.F. and Kanodin... is it needed? + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; // DMA complete + SPUStartCycle[0] = SPUCycles; + SPUTargetCycle[0] = size; + interrupt |= (1 << 1); } -EXPORT_C_(void) SPU2readDMA7Mem(u16* pMem, int size) +EXPORT_C_(void) +SPU2readDMA7Mem(u16* pMem, int size) { - u32 spuaddr = C1_SPUADDR; - int i; + u32 spuaddr = C1_SPUADDR; + int i; - SPU2_LOG("SPU2 readDMA7Mem size %x, addr: %x\n", size, pMem); + SPU2_LOG("SPU2 readDMA7Mem size %x, addr: %x\n", size, pMem); - for (i = 0;i < size;i++) - { - *pMem++ = *(u16*)(spu2mem + spuaddr); - if ((spu2Rs16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr) - { - spu2Ru16(SPDIF_OUT) |= 0x8; - C1_SPUADDR_SET(spuaddr); - IRQINFO |= 8; - irqCallbackSPU2(); - } - spuaddr++; // inc spu addr - if (spuaddr > 0x0fffff) // wrap at 2Mb - spuaddr = 0; // wrap - } + for (i = 0; i < size; i++) { + *pMem++ = *(u16*)(spu2mem + spuaddr); + if ((spu2Rs16(REG_C1_CTRL) & 0x40) && C1_IRQA == spuaddr) { + spu2Ru16(SPDIF_OUT) |= 0x8; + C1_SPUADDR_SET(spuaddr); + IRQINFO |= 8; + irqCallbackSPU2(); + } + spuaddr++; // inc spu addr + if (spuaddr > 0x0fffff) // wrap at 2Mb + spuaddr = 0; // wrap + } - spuaddr += 19; //Transfer Local To Host TSAH/L + Data Size + 20 (already +1'd) - C1_SPUADDR_SET(spuaddr); + spuaddr += 19; //Transfer Local To Host TSAH/L + Data Size + 20 (already +1'd) + C1_SPUADDR_SET(spuaddr); - // got from J.F. and Kanodin... is it needed? - spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; // DMA complete - SPUStartCycle[1] = SPUCycles; - SPUTargetCycle[1] = size; - interrupt |= (1 << 2); + // got from J.F. and Kanodin... is it needed? + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; // DMA complete + SPUStartCycle[1] = SPUCycles; + SPUTargetCycle[1] = size; + interrupt |= (1 << 2); } // WRITE @@ -710,580 +668,578 @@ EXPORT_C_(void) SPU2readDMA7Mem(u16* pMem, int size) // the end of the transfer. int ADMAS4Write() { - u32 spuaddr; - if (interrupt & 0x2) return 0; - if (Adma4.AmountLeft <= 0) return 1; + u32 spuaddr; + if (interrupt & 0x2) + return 0; + if (Adma4.AmountLeft <= 0) + return 1; - spuaddr = C0_SPUADDR; - // SPU2 Deinterleaves the Left and Right Channels - memcpy((s16*)(spu2mem + spuaddr + 0x2000), (s16*)Adma4.MemAddr, 512); - Adma4.MemAddr += 256; - memcpy((s16*)(spu2mem + spuaddr + 0x2200), (s16*)Adma4.MemAddr, 512); - Adma4.MemAddr += 256; - spuaddr = (spuaddr + 256) & 511; - C0_SPUADDR_SET(spuaddr); + spuaddr = C0_SPUADDR; + // SPU2 Deinterleaves the Left and Right Channels + memcpy((s16*)(spu2mem + spuaddr + 0x2000), (s16*)Adma4.MemAddr, 512); + Adma4.MemAddr += 256; + memcpy((s16*)(spu2mem + spuaddr + 0x2200), (s16*)Adma4.MemAddr, 512); + Adma4.MemAddr += 256; + spuaddr = (spuaddr + 256) & 511; + C0_SPUADDR_SET(spuaddr); - Adma4.AmountLeft -= 512; - if (Adma4.AmountLeft == 0) - { - SPUStartCycle[0] = SPUCycles; - SPUTargetCycle[0] = 1;//512*48000; - spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; - interrupt |= (1 << 1); - } - return 0; + Adma4.AmountLeft -= 512; + if (Adma4.AmountLeft == 0) { + SPUStartCycle[0] = SPUCycles; + SPUTargetCycle[0] = 1; //512*48000; + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; + interrupt |= (1 << 1); + } + return 0; } int ADMAS7Write() { - u32 spuaddr; - if (interrupt & 0x4) return 0; - if (Adma7.AmountLeft <= 0) return 1; + u32 spuaddr; + if (interrupt & 0x4) + return 0; + if (Adma7.AmountLeft <= 0) + return 1; - spuaddr = C1_SPUADDR; - // SPU2 Deinterleaves the Left and Right Channels - memcpy((s16*)(spu2mem + spuaddr + 0x2400), (s16*)Adma7.MemAddr, 512); - Adma7.MemAddr += 256; - memcpy((s16*)(spu2mem + spuaddr + 0x2600), (s16*)Adma7.MemAddr, 512); - Adma7.MemAddr += 256; - spuaddr = (spuaddr + 256) & 511; - C1_SPUADDR_SET(spuaddr); + spuaddr = C1_SPUADDR; + // SPU2 Deinterleaves the Left and Right Channels + memcpy((s16*)(spu2mem + spuaddr + 0x2400), (s16*)Adma7.MemAddr, 512); + Adma7.MemAddr += 256; + memcpy((s16*)(spu2mem + spuaddr + 0x2600), (s16*)Adma7.MemAddr, 512); + Adma7.MemAddr += 256; + spuaddr = (spuaddr + 256) & 511; + C1_SPUADDR_SET(spuaddr); - Adma7.AmountLeft -= 512; - if (Adma7.AmountLeft == 0) - { - SPUStartCycle[1] = SPUCycles; - SPUTargetCycle[1] = 1;//512*48000; - spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; - interrupt |= (1 << 2); - } - return 0; + Adma7.AmountLeft -= 512; + if (Adma7.AmountLeft == 0) { + SPUStartCycle[1] = SPUCycles; + SPUTargetCycle[1] = 1; //512*48000; + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; + interrupt |= (1 << 2); + } + return 0; } -EXPORT_C_(void) SPU2writeDMA4Mem(u16* pMem, int size) +EXPORT_C_(void) +SPU2writeDMA4Mem(u16* pMem, int size) { - u32 spuaddr; + u32 spuaddr; - SPU2_LOG("SPU2 writeDMA4Mem size %x, addr: %x\n", size, pMem); + SPU2_LOG("SPU2 writeDMA4Mem size %x, addr: %x\n", size, pMem); - if ((spu2Ru16(REG_C0_ADMAS) & 0x1) && (spu2Ru16(REG_C0_CTRL) & 0x30) == 0 && size) - { - //fwrite(pMem,iSize<<1,1,LogFile); - memset(&Adma4, 0, sizeof(ADMA)); - C0_SPUADDR_SET(0); - Adma4.MemAddr = pMem; - Adma4.AmountLeft = size; - ADMAS4Write(); - return; - } + if ((spu2Ru16(REG_C0_ADMAS) & 0x1) && (spu2Ru16(REG_C0_CTRL) & 0x30) == 0 && size) { + //fwrite(pMem,iSize<<1,1,LogFile); + memset(&Adma4, 0, sizeof(ADMA)); + C0_SPUADDR_SET(0); + Adma4.MemAddr = pMem; + Adma4.AmountLeft = size; + ADMAS4Write(); + return; + } - spuaddr = C0_SPUADDR; - memcpy((u8*)(spu2mem + spuaddr), (u8*)pMem, size << 1); - spuaddr += size; - C0_SPUADDR_SET(spuaddr); + spuaddr = C0_SPUADDR; + memcpy((u8*)(spu2mem + spuaddr), (u8*)pMem, size << 1); + spuaddr += size; + C0_SPUADDR_SET(spuaddr); - if ((spu2Ru16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr) - { - spu2Ru16(SPDIF_OUT) |= 0x4; - IRQINFO |= 4; - irqCallbackSPU2(); - } - if (spuaddr > 0xFFFFE) - spuaddr = 0x2800; - C0_SPUADDR_SET(spuaddr); + if ((spu2Ru16(REG_C0_CTRL) & 0x40) && C0_IRQA == spuaddr) { + spu2Ru16(SPDIF_OUT) |= 0x4; + IRQINFO |= 4; + irqCallbackSPU2(); + } + if (spuaddr > 0xFFFFE) + spuaddr = 0x2800; + C0_SPUADDR_SET(spuaddr); - MemAddr[0] += size << 1; - spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; - SPUStartCycle[0] = SPUCycles; - SPUTargetCycle[0] = 1;//iSize; - interrupt |= (1 << 1); + MemAddr[0] += size << 1; + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; + SPUStartCycle[0] = SPUCycles; + SPUTargetCycle[0] = 1; //iSize; + interrupt |= (1 << 1); } -EXPORT_C_(void) SPU2writeDMA7Mem(u16* pMem, int size) +EXPORT_C_(void) +SPU2writeDMA7Mem(u16* pMem, int size) { - u32 spuaddr; + u32 spuaddr; - SPU2_LOG("SPU2 writeDMA7Mem size %x, addr: %x\n", size, pMem); + SPU2_LOG("SPU2 writeDMA7Mem size %x, addr: %x\n", size, pMem); - if ((spu2Ru16(REG_C1_ADMAS) & 0x2) && (spu2Ru16(REG_C1_CTRL) & 0x30) == 0 && size) - { - //fwrite(pMem,iSize<<1,1,LogFile); - memset(&Adma7, 0, sizeof(ADMA)); - C1_SPUADDR_SET(0); - Adma7.MemAddr = pMem; - Adma7.AmountLeft = size; - ADMAS7Write(); - return; - } + if ((spu2Ru16(REG_C1_ADMAS) & 0x2) && (spu2Ru16(REG_C1_CTRL) & 0x30) == 0 && size) { + //fwrite(pMem,iSize<<1,1,LogFile); + memset(&Adma7, 0, sizeof(ADMA)); + C1_SPUADDR_SET(0); + Adma7.MemAddr = pMem; + Adma7.AmountLeft = size; + ADMAS7Write(); + return; + } - spuaddr = C1_SPUADDR; - memcpy((u8*)(spu2mem + spuaddr), (u8*)pMem, size << 1); - spuaddr += size; - C1_SPUADDR_SET(spuaddr); + spuaddr = C1_SPUADDR; + memcpy((u8*)(spu2mem + spuaddr), (u8*)pMem, size << 1); + spuaddr += size; + C1_SPUADDR_SET(spuaddr); - if ((spu2Ru16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr) - { - spu2Ru16(SPDIF_OUT) |= 0x8; - IRQINFO |= 8; - irqCallbackSPU2(); - } - if (spuaddr > 0xFFFFE) - spuaddr = 0x2800; - C1_SPUADDR_SET(spuaddr); + if ((spu2Ru16(REG_C1_CTRL) & 0x40) && C1_IRQA == spuaddr) { + spu2Ru16(SPDIF_OUT) |= 0x8; + IRQINFO |= 8; + irqCallbackSPU2(); + } + if (spuaddr > 0xFFFFE) + spuaddr = 0x2800; + C1_SPUADDR_SET(spuaddr); - MemAddr[1] += size << 1; - spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; - SPUStartCycle[1] = SPUCycles; - SPUTargetCycle[1] = 1;//iSize; - interrupt |= (1 << 2); + MemAddr[1] += size << 1; + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; + SPUStartCycle[1] = SPUCycles; + SPUTargetCycle[1] = 1; //iSize; + interrupt |= (1 << 2); } -EXPORT_C_(void) SPU2interruptDMA4() +EXPORT_C_(void) +SPU2interruptDMA4() { - SPU2_LOG("SPU2 interruptDMA4\n"); + SPU2_LOG("SPU2 interruptDMA4\n"); - spu2Rs16(REG_C0_CTRL) &= ~0x30; - spu2Ru16(REG_C0_SPUSTAT) |= 0x80; + spu2Rs16(REG_C0_CTRL) &= ~0x30; + spu2Ru16(REG_C0_SPUSTAT) |= 0x80; } -EXPORT_C_(void) SPU2interruptDMA7() +EXPORT_C_(void) +SPU2interruptDMA7() { - SPU2_LOG("SPU2 interruptDMA7\n"); + SPU2_LOG("SPU2 interruptDMA7\n"); -// spu2Rs16(REG_C1_CTRL)&= ~0x30; -// //spu2Rs16(REG__5B0) = 0; -// spu2Rs16(SPU2_STATX_DREQ)|= 0x80; - spu2Rs16(REG_C1_CTRL) &= ~0x30; - spu2Ru16(REG_C1_SPUSTAT) |= 0x80; + // spu2Rs16(REG_C1_CTRL)&= ~0x30; + // //spu2Rs16(REG__5B0) = 0; + // spu2Rs16(SPU2_STATX_DREQ)|= 0x80; + spu2Rs16(REG_C1_CTRL) &= ~0x30; + spu2Ru16(REG_C1_SPUSTAT) |= 0x80; } // turn channels on -void SoundOn(s32 start, s32 end, u16 val) // SOUND ON PSX COMAND +void SoundOn(s32 start, s32 end, u16 val) // SOUND ON PSX COMAND { - for (s32 ch = start;ch < end;ch++, val >>= 1) // loop channels - { - if ((val&1) && voices[ch].pStart) // mmm... start has to be set before key on !?! - { - voices[ch].bNew = true; - voices[ch].bIgnoreLoop = false; - } - } + for (s32 ch = start; ch < end; ch++, val >>= 1) // loop channels + { + if ((val & 1) && voices[ch].pStart) // mmm... start has to be set before key on !?! + { + voices[ch].bNew = true; + voices[ch].bIgnoreLoop = false; + } + } } // turn channels off void SoundOff(s32 start, s32 end, u16 val) // SOUND OFF PSX COMMAND { - for (s32 ch = start;ch < end;ch++, val >>= 1) // loop channels - { - if (val&1) // && s_chan[i].bOn) mmm... - voices[ch].bStop = true; - } + for (s32 ch = start; ch < end; ch++, val >>= 1) // loop channels + { + if (val & 1) // && s_chan[i].bOn) mmm... + voices[ch].bStop = true; + } } -void FModOn(s32 start, s32 end, u16 val) // FMOD ON PSX COMMAND +void FModOn(s32 start, s32 end, u16 val) // FMOD ON PSX COMMAND { - int ch; + int ch; - for (ch = start;ch < end;ch++, val >>= 1) // loop channels - { - if (val&1) // -> fmod on/off - { - if (ch > 0) - { - } - } - else - { - // turn fmod off - } - } + for (ch = start; ch < end; ch++, val >>= 1) // loop channels + { + if (val & 1) // -> fmod on/off + { + if (ch > 0) { + } + } else { + // turn fmod off + } + } } -EXPORT_C_(void) SPU2write(u32 mem, u16 value) +EXPORT_C_(void) +SPU2write(u32 mem, u16 value) { - u32 spuaddr; + u32 spuaddr; - SPU2_LOG("SPU2 write mem %x value %x\n", mem, value); + SPU2_LOG("SPU2 write mem %x value %x\n", mem, value); - assert(C0_SPUADDR < 0x100000); - assert(C1_SPUADDR < 0x100000); + assert(C0_SPUADDR < 0x100000); + assert(C1_SPUADDR < 0x100000); - spu2Ru16(mem) = value; - u32 r = mem & 0xffff; + spu2Ru16(mem) = value; + u32 r = mem & 0xffff; - // channel info - if ((r >= 0x0000 && r < 0x0180) || (r >= 0x0400 && r < 0x0580)) // some channel info? - { - int ch = 0; - if (r >= 0x400) ch = ((r - 0x400) >> 4) + 24; - else ch = (r >> 4); + // channel info + if ((r >= 0x0000 && r < 0x0180) || (r >= 0x0400 && r < 0x0580)) // some channel info? + { + int ch = 0; + if (r >= 0x400) + ch = ((r - 0x400) >> 4) + 24; + else + ch = (r >> 4); - VOICE_PROCESSED* pvoice = &voices[ch]; + VOICE_PROCESSED* pvoice = &voices[ch]; - switch (r&0x0f) - { - case 0: - case 2: - pvoice->SetVolume(mem&0x2); - break; - case 4: - { - int NP; - if (value > 0x3fff) - NP = 0x3fff; // get pitch val - else - NP = value; + switch (r & 0x0f) { + case 0: + case 2: + pvoice->SetVolume(mem & 0x2); + break; + case 4: { + int NP; + if (value > 0x3fff) + NP = 0x3fff; // get pitch val + else + NP = value; - pvoice->pvoice->pitch = NP; + pvoice->pvoice->pitch = NP; - NP = (44100L * NP) / 4096L; // calc frequency - if (NP < 1) NP = 1; // some security - pvoice->iActFreq = NP; // store frequency - break; - } - case 6: - { - pvoice->ADSRX.AttackModeExp = (value & 0x8000) ? 1 : 0; - pvoice->ADSRX.AttackRate = ((value >> 8) & 0x007f); - pvoice->ADSRX.DecayRate = (((value >> 4) & 0x000f)); - pvoice->ADSRX.SustainLevel = (value & 0x000f); - break; - } - case 8: - pvoice->ADSRX.SustainModeExp = (value & 0x8000) ? 1 : 0; - pvoice->ADSRX.SustainIncrease = (value & 0x4000) ? 0 : 1; - pvoice->ADSRX.SustainRate = ((value >> 6) & 0x007f); - pvoice->ADSRX.ReleaseModeExp = (value & 0x0020) ? 1 : 0; - pvoice->ADSRX.ReleaseRate = ((value & 0x001f)); - break; - } + NP = (44100L * NP) / 4096L; // calc frequency + if (NP < 1) + NP = 1; // some security + pvoice->iActFreq = NP; // store frequency + break; + } + case 6: { + pvoice->ADSRX.AttackModeExp = (value & 0x8000) ? 1 : 0; + pvoice->ADSRX.AttackRate = ((value >> 8) & 0x007f); + pvoice->ADSRX.DecayRate = (((value >> 4) & 0x000f)); + pvoice->ADSRX.SustainLevel = (value & 0x000f); + break; + } + case 8: + pvoice->ADSRX.SustainModeExp = (value & 0x8000) ? 1 : 0; + pvoice->ADSRX.SustainIncrease = (value & 0x4000) ? 0 : 1; + pvoice->ADSRX.SustainRate = ((value >> 6) & 0x007f); + pvoice->ADSRX.ReleaseModeExp = (value & 0x0020) ? 1 : 0; + pvoice->ADSRX.ReleaseRate = ((value & 0x001f)); + break; + } - return; - } + return; + } - // more channel info - if ((r >= 0x01c0 && r <= 0x02E0) || (r >= 0x05c0 && r <= 0x06E0)) - { - s32 ch = 0; - u32 rx = r; - if (rx >= 0x400) - { - ch = 24; - rx -= 0x400; - } + // more channel info + if ((r >= 0x01c0 && r <= 0x02E0) || (r >= 0x05c0 && r <= 0x06E0)) { + s32 ch = 0; + u32 rx = r; + if (rx >= 0x400) { + ch = 24; + rx -= 0x400; + } - ch += ((rx - 0x1c0) / 12); - rx -= (ch % 24) * 12; - VOICE_PROCESSED* pvoice = &voices[ch]; + ch += ((rx - 0x1c0) / 12); + rx -= (ch % 24) * 12; + VOICE_PROCESSED* pvoice = &voices[ch]; - switch (rx) - { - case 0x1C0: - pvoice->iStartAddr = (((u32)value & 0x3f) << 16) | (pvoice->iStartAddr & 0xFFFF); - pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); - break; - case 0x1C2: - pvoice->iStartAddr = (pvoice->iStartAddr & 0x3f0000) | (value & 0xFFFF); - pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); - break; - case 0x1C4: - pvoice->iLoopAddr = (((u32)value & 0x3f) << 16) | (pvoice->iLoopAddr & 0xFFFF); - pvoice->pLoop = (u8*)(spu2mem + pvoice->iLoopAddr); - pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0; - break; - case 0x1C6: - pvoice->iLoopAddr = (pvoice->iLoopAddr & 0x3f0000) | (value & 0xFFFF); - pvoice->pLoop = (u8*)(spu2mem + pvoice->iLoopAddr); - pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0; - break; - case 0x1C8: - // unused... check if it gets written as well - pvoice->iNextAddr = (((u32)value & 0x3f) << 16) | (pvoice->iNextAddr & 0xFFFF); - break; - case 0x1CA: - // unused... check if it gets written as well - pvoice->iNextAddr = (pvoice->iNextAddr & 0x3f0000) | (value & 0xFFFF); - break; - } + switch (rx) { + case 0x1C0: + pvoice->iStartAddr = (((u32)value & 0x3f) << 16) | (pvoice->iStartAddr & 0xFFFF); + pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); + break; + case 0x1C2: + pvoice->iStartAddr = (pvoice->iStartAddr & 0x3f0000) | (value & 0xFFFF); + pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr); + break; + case 0x1C4: + pvoice->iLoopAddr = (((u32)value & 0x3f) << 16) | (pvoice->iLoopAddr & 0xFFFF); + pvoice->pLoop = (u8*)(spu2mem + pvoice->iLoopAddr); + pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0; + break; + case 0x1C6: + pvoice->iLoopAddr = (pvoice->iLoopAddr & 0x3f0000) | (value & 0xFFFF); + pvoice->pLoop = (u8*)(spu2mem + pvoice->iLoopAddr); + pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0; + break; + case 0x1C8: + // unused... check if it gets written as well + pvoice->iNextAddr = (((u32)value & 0x3f) << 16) | (pvoice->iNextAddr & 0xFFFF); + break; + case 0x1CA: + // unused... check if it gets written as well + pvoice->iNextAddr = (pvoice->iNextAddr & 0x3f0000) | (value & 0xFFFF); + break; + } - return; - } + return; + } - // process non-channel data - switch (mem&0xffff) - { - case REG_C0_SPUDATA: - spuaddr = C0_SPUADDR; - spu2mem[spuaddr] = value; - spuaddr++; - if ((spu2Ru16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr) - { - spu2Ru16(SPDIF_OUT) |= 0x4; - IRQINFO |= 4; - irqCallbackSPU2(); - } - if (spuaddr > 0xFFFFE) spuaddr = 0x2800; + // process non-channel data + switch (mem & 0xffff) { + case REG_C0_SPUDATA: + spuaddr = C0_SPUADDR; + spu2mem[spuaddr] = value; + spuaddr++; + if ((spu2Ru16(REG_C0_CTRL) & 0x40) && C0_IRQA == spuaddr) { + spu2Ru16(SPDIF_OUT) |= 0x4; + IRQINFO |= 4; + irqCallbackSPU2(); + } + if (spuaddr > 0xFFFFE) + spuaddr = 0x2800; - C0_SPUADDR_SET(spuaddr); - spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; - spu2Ru16(REG_C0_CTRL) &= ~0x30; - break; - case REG_C1_SPUDATA: - spuaddr = C1_SPUADDR; - spu2mem[spuaddr] = value; - spuaddr++; - if ((spu2Ru16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr) - { - spu2Ru16(SPDIF_OUT) |= 0x8; - IRQINFO |= 8; - irqCallbackSPU2(); - } - if (spuaddr > 0xFFFFE) spuaddr = 0x2800; + C0_SPUADDR_SET(spuaddr); + spu2Ru16(REG_C0_SPUSTAT) &= ~0x80; + spu2Ru16(REG_C0_CTRL) &= ~0x30; + break; + case REG_C1_SPUDATA: + spuaddr = C1_SPUADDR; + spu2mem[spuaddr] = value; + spuaddr++; + if ((spu2Ru16(REG_C1_CTRL) & 0x40) && C1_IRQA == spuaddr) { + spu2Ru16(SPDIF_OUT) |= 0x8; + IRQINFO |= 8; + irqCallbackSPU2(); + } + if (spuaddr > 0xFFFFE) + spuaddr = 0x2800; - C1_SPUADDR_SET(spuaddr); - spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; - spu2Ru16(REG_C1_CTRL) &= ~0x30; - break; - case REG_C0_IRQA_HI: - case REG_C0_IRQA_LO: - pSpuIrq[0] = spu2mem + (C0_IRQA << 1); - break; - case REG_C1_IRQA_HI: - case REG_C1_IRQA_LO: - pSpuIrq[1] = spu2mem + (C1_IRQA << 1); - break; + C1_SPUADDR_SET(spuaddr); + spu2Ru16(REG_C1_SPUSTAT) &= ~0x80; + spu2Ru16(REG_C1_CTRL) &= ~0x30; + break; + case REG_C0_IRQA_HI: + case REG_C0_IRQA_LO: + pSpuIrq[0] = spu2mem + (C0_IRQA << 1); + break; + case REG_C1_IRQA_HI: + case REG_C1_IRQA_LO: + pSpuIrq[1] = spu2mem + (C1_IRQA << 1); + break; - case REG_C0_SPUADDR_HI: - case REG_C1_SPUADDR_HI: - spu2Ru16(mem) = value & 0xf; - break; + case REG_C0_SPUADDR_HI: + case REG_C1_SPUADDR_HI: + spu2Ru16(mem) = value & 0xf; + break; - case REG_C0_SPUON1: - SoundOn(0, 16, value); - break; - case REG_C0_SPUON2: - SoundOn(16, 24, value); - break; - case REG_C1_SPUON1: - SoundOn(24, 40, value); - break; - case REG_C1_SPUON2: - SoundOn(40, 48, value); - break; - case REG_C0_SPUOFF1: - SoundOff(0, 16, value); - break; - case REG_C0_SPUOFF2: - SoundOff(16, 24, value); - break; - case REG_C1_SPUOFF1: - SoundOff(24, 40, value); - break; - case REG_C1_SPUOFF2: - SoundOff(40, 48, value); - break; + case REG_C0_SPUON1: + SoundOn(0, 16, value); + break; + case REG_C0_SPUON2: + SoundOn(16, 24, value); + break; + case REG_C1_SPUON1: + SoundOn(24, 40, value); + break; + case REG_C1_SPUON2: + SoundOn(40, 48, value); + break; + case REG_C0_SPUOFF1: + SoundOff(0, 16, value); + break; + case REG_C0_SPUOFF2: + SoundOff(16, 24, value); + break; + case REG_C1_SPUOFF1: + SoundOff(24, 40, value); + break; + case REG_C1_SPUOFF2: + SoundOff(40, 48, value); + break; - // According to manual all bits are cleared by writing an arbitary value - case REG_C0_END1: - dwEndChannel2[0] = 0; - break; - case REG_C0_END2: - dwEndChannel2[0] = 0; - break; - case REG_C1_END1: - dwEndChannel2[1] = 0; - break; - case REG_C1_END2: - dwEndChannel2[1] = 0; - break; - case REG_C0_FMOD1: - FModOn(0, 16, value); - break; - case REG_C0_FMOD2: - FModOn(16, 24, value); - break; - case REG_C1_FMOD1: - FModOn(24, 40, value); - break; - case REG_C1_FMOD2: - FModOn(40, 48, value); - break; - } + // According to manual all bits are cleared by writing an arbitary value + case REG_C0_END1: + dwEndChannel2[0] = 0; + break; + case REG_C0_END2: + dwEndChannel2[0] = 0; + break; + case REG_C1_END1: + dwEndChannel2[1] = 0; + break; + case REG_C1_END2: + dwEndChannel2[1] = 0; + break; + case REG_C0_FMOD1: + FModOn(0, 16, value); + break; + case REG_C0_FMOD2: + FModOn(16, 24, value); + break; + case REG_C1_FMOD1: + FModOn(24, 40, value); + break; + case REG_C1_FMOD2: + FModOn(40, 48, value); + break; + } - assert(C0_SPUADDR < 0x100000); - assert(C1_SPUADDR < 0x100000); + assert(C0_SPUADDR < 0x100000); + assert(C1_SPUADDR < 0x100000); } -EXPORT_C_(u16) SPU2read(u32 mem) +EXPORT_C_(u16) +SPU2read(u32 mem) { - u32 spuaddr; - u16 ret; - u32 r = mem & 0xffff; + u32 spuaddr; + u16 ret; + u32 r = mem & 0xffff; - if ((r >= 0x0000 && r <= 0x0180) || (r >= 0x0400 && r <= 0x0580)) // some channel info? - { - s32 ch = 0; + if ((r >= 0x0000 && r <= 0x0180) || (r >= 0x0400 && r <= 0x0580)) // some channel info? + { + s32 ch = 0; - if (r >= 0x400) - ch = ((r - 0x400) >> 4) + 24; - else - ch = (r >> 4); + if (r >= 0x400) + ch = ((r - 0x400) >> 4) + 24; + else + ch = (r >> 4); - VOICE_PROCESSED* pvoice = &voices[ch]; + VOICE_PROCESSED* pvoice = &voices[ch]; - switch (r&0x0f) - { - case 10: - return (u16)(pvoice->ADSRX.EnvelopeVol >> 16); - } - } + switch (r & 0x0f) { + case 10: + return (u16)(pvoice->ADSRX.EnvelopeVol >> 16); + } + } - if ((r > 0x01c0 && r <= 0x02E0) || (r > 0x05c0 && r <= 0x06E0)) // some channel info? - { - s32 ch = 0; - u32 rx = r; + if ((r > 0x01c0 && r <= 0x02E0) || (r > 0x05c0 && r <= 0x06E0)) // some channel info? + { + s32 ch = 0; + u32 rx = r; - if (rx >= 0x400) - { - ch = 24; - rx -= 0x400; - } + if (rx >= 0x400) { + ch = 24; + rx -= 0x400; + } - ch += ((rx - 0x1c0) / 12); - rx -= (ch % 24) * 12; - VOICE_PROCESSED* pvoice = &voices[ch]; + ch += ((rx - 0x1c0) / 12); + rx -= (ch % 24) * 12; + VOICE_PROCESSED* pvoice = &voices[ch]; - switch (rx) - { - case 0x1C0: - return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 17)&0x3F); - case 0x1C2: - return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 1)&0xFFFF); - case 0x1C4: - return (u16)(((pvoice->pLoop - (u8*)spu2mem) >> 17)&0x3F); - case 0x1C6: - return (u16)(((pvoice->pLoop - (u8*)spu2mem) >> 1)&0xFFFF); - case 0x1C8: - return (u16)(((pvoice->pCurr - (u8*)spu2mem) >> 17)&0x3F); - case 0x1CA: - return (u16)(((pvoice->pCurr - (u8*)spu2mem) >> 1)&0xFFFF); - } - } + switch (rx) { + case 0x1C0: + return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 17) & 0x3F); + case 0x1C2: + return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 1) & 0xFFFF); + case 0x1C4: + return (u16)(((pvoice->pLoop - (u8*)spu2mem) >> 17) & 0x3F); + case 0x1C6: + return (u16)(((pvoice->pLoop - (u8*)spu2mem) >> 1) & 0xFFFF); + case 0x1C8: + return (u16)(((pvoice->pCurr - (u8*)spu2mem) >> 17) & 0x3F); + case 0x1CA: + return (u16)(((pvoice->pCurr - (u8*)spu2mem) >> 1) & 0xFFFF); + } + } - switch (mem&0xffff) - { - case REG_C0_SPUDATA: - spuaddr = C0_SPUADDR; - ret = spu2mem[spuaddr]; - spuaddr++; - if (spuaddr > 0xfffff) spuaddr = 0; - C0_SPUADDR_SET(spuaddr); - break; + switch (mem & 0xffff) { + case REG_C0_SPUDATA: + spuaddr = C0_SPUADDR; + ret = spu2mem[spuaddr]; + spuaddr++; + if (spuaddr > 0xfffff) + spuaddr = 0; + C0_SPUADDR_SET(spuaddr); + break; - case REG_C1_SPUDATA: - spuaddr = C1_SPUADDR; - ret = spu2mem[spuaddr]; - spuaddr++; - if (spuaddr > 0xfffff) spuaddr = 0; - C1_SPUADDR_SET(spuaddr); - break; + case REG_C1_SPUDATA: + spuaddr = C1_SPUADDR; + ret = spu2mem[spuaddr]; + spuaddr++; + if (spuaddr > 0xfffff) + spuaddr = 0; + C1_SPUADDR_SET(spuaddr); + break; - case REG_C0_END1: - return (dwEndChannel2[0]&0xffff); - case REG_C0_END2: - return (dwEndChannel2[0] >> 16); - case REG_C1_END1: - return (dwEndChannel2[1]&0xffff); - case REG_C1_END2: - return (dwEndChannel2[1] >> 16); + case REG_C0_END1: + return (dwEndChannel2[0] & 0xffff); + case REG_C0_END2: + return (dwEndChannel2[0] >> 16); + case REG_C1_END1: + return (dwEndChannel2[1] & 0xffff); + case REG_C1_END2: + return (dwEndChannel2[1] >> 16); - case REG_IRQINFO: - ret = IRQINFO; - IRQINFO = 0; - break; - default: - ret = spu2Ru16(mem); - } + case REG_IRQINFO: + ret = IRQINFO; + IRQINFO = 0; + break; + default: + ret = spu2Ru16(mem); + } - SPU2_LOG("SPU2 read mem %x: %x\n", mem, ret); + SPU2_LOG("SPU2 read mem %x: %x\n", mem, ret); - return ret; + return ret; } -EXPORT_C_(void) SPU2WriteMemAddr(int core, u32 value) +EXPORT_C_(void) +SPU2WriteMemAddr(int core, u32 value) { - MemAddr[core] = value; + MemAddr[core] = value; } -EXPORT_C_(u32) SPU2ReadMemAddr(int core) +EXPORT_C_(u32) +SPU2ReadMemAddr(int core) { - return MemAddr[core]; + return MemAddr[core]; } -EXPORT_C_(void) SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)()) +EXPORT_C_(void) +SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)()) { - irqCallbackSPU2 = SPU2callback; - irqCallbackDMA4 = DMA4callback; - irqCallbackDMA7 = DMA7callback; + irqCallbackSPU2 = SPU2callback; + irqCallbackDMA4 = DMA4callback; + irqCallbackDMA7 = DMA7callback; } // VOICE_PROCESSED definitions SPU_CONTROL_* VOICE_PROCESSED::GetCtrl() { - return ((SPU_CONTROL_*)(spu2regs + memoffset + REG_C0_CTRL)); + return ((SPU_CONTROL_*)(spu2regs + memoffset + REG_C0_CTRL)); } void VOICE_PROCESSED::SetVolume(int iProcessRight) { - u16 vol = iProcessRight ? pvoice->right.word : pvoice->left.word; + u16 vol = iProcessRight ? pvoice->right.word : pvoice->left.word; - if (vol&0x8000) // sweep not working - { - s16 sInc = 1; // -> sweep up? - if (vol&0x2000) sInc = -1; // -> or down? - if (vol&0x1000) vol ^= 0xffff; // -> mmm... phase inverted? have to investigate this - vol = ((vol & 0x7f) + 1) / 2; // -> sweep: 0..127 -> 0..64 - vol += vol / (2 * sInc); // -> HACK: we don't sweep right now, so we just raise/lower the volume by the half! - vol *= 128; - } - else // no sweep: - { - if (vol&0x4000) // -> mmm... phase inverted? have to investigate this - vol = 0x3fff - (vol & 0x3fff); - } + if (vol & 0x8000) // sweep not working + { + s16 sInc = 1; // -> sweep up? + if (vol & 0x2000) + sInc = -1; // -> or down? + if (vol & 0x1000) + vol ^= 0xffff; // -> mmm... phase inverted? have to investigate this + vol = ((vol & 0x7f) + 1) / 2; // -> sweep: 0..127 -> 0..64 + vol += vol / (2 * sInc); // -> HACK: we don't sweep right now, so we just raise/lower the volume by the half! + vol *= 128; + } else // no sweep: + { + if (vol & 0x4000) // -> mmm... phase inverted? have to investigate this + vol = 0x3fff - (vol & 0x3fff); + } - vol &= 0x3fff; - // set volume - //if( iProcessRight ) right = vol; - //else left = vol; + vol &= 0x3fff; + // set volume + //if( iProcessRight ) right = vol; + //else left = vol; } void VOICE_PROCESSED::StartSound() { - ADSRX.lVolume = 1; // and init some adsr vars - ADSRX.State = 0; - ADSRX.EnvelopeVol = 0; + ADSRX.lVolume = 1; // and init some adsr vars + ADSRX.State = 0; + ADSRX.EnvelopeVol = 0; - if (bReverb && GetCtrl()->reverb) - { - // setup the reverb effects - } + if (bReverb && GetCtrl()->reverb) { + // setup the reverb effects + } - pCurr = pStart; // set sample start - iSBPos = 28; + pCurr = pStart; // set sample start + iSBPos = 28; - bNew = false; // init channel flags - bStop = false; - bOn = true; - spos = 0x10000L; + bNew = false; // init channel flags + bStop = false; + bOn = true; + spos = 0x10000L; } void VOICE_PROCESSED::VoiceChangeFrequency() { - iUsedFreq = iActFreq; // -> take it and calc steps - sinc = (u32)pvoice->pitch << 4; - if (!sinc) - sinc = 1; + iUsedFreq = iActFreq; // -> take it and calc steps + sinc = (u32)pvoice->pitch << 4; + if (!sinc) + sinc = 1; } void VOICE_PROCESSED::Stop() @@ -1291,46 +1247,37 @@ void VOICE_PROCESSED::Stop() } // GUI Routines -EXPORT_C_(s32) SPU2test() +EXPORT_C_(s32) +SPU2test() { - return 0; + return 0; } typedef struct { - u32 version; - u8 spu2regs[0x10000]; + u32 version; + u8 spu2regs[0x10000]; } SPU2freezeData; -EXPORT_C_(s32) SPU2freeze(int mode, freezeData *data) +EXPORT_C_(s32) +SPU2freeze(int mode, freezeData* data) { - SPU2freezeData *spud; + SPU2freezeData* spud; - if (mode == FREEZE_LOAD) - { - spud = (SPU2freezeData*)data->data; - if (spud->version == 0x11223344) - { - memcpy(spu2regs, spud->spu2regs, 0x10000); - } - else - { - printf("SPU2null wrong format\n"); - } - } - else - if (mode == FREEZE_SAVE) - { - spud = (SPU2freezeData*)data->data; - spud->version = 0x11223344; - memcpy(spud->spu2regs, spu2regs, 0x10000); - } - else - if (mode == FREEZE_SIZE) - { - data->size = sizeof(SPU2freezeData); - } + if (mode == FREEZE_LOAD) { + spud = (SPU2freezeData*)data->data; + if (spud->version == 0x11223344) { + memcpy(spu2regs, spud->spu2regs, 0x10000); + } else { + printf("SPU2null wrong format\n"); + } + } else if (mode == FREEZE_SAVE) { + spud = (SPU2freezeData*)data->data; + spud->version = 0x11223344; + memcpy(spud->spu2regs, spu2regs, 0x10000); + } else if (mode == FREEZE_SIZE) { + data->size = sizeof(SPU2freezeData); + } - return 0; + return 0; } - diff --git a/plugins/SPU2null/SPU2.h b/plugins/SPU2null/SPU2.h index a3438ab07f..e5f0db7e54 100644 --- a/plugins/SPU2null/SPU2.h +++ b/plugins/SPU2null/SPU2.h @@ -24,8 +24,7 @@ #include #include -extern "C" -{ +extern "C" { #define SPU2defs #include "PS2Edefs.h" } @@ -39,114 +38,115 @@ extern "C" #ifdef _MSC_VER #define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK #else -#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type +#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type #endif -extern FILE *spu2Log; +extern FILE* spu2Log; #define SPU2_LOG __Log //debug mode extern const u8 version; extern const u8 revision; extern const u8 build; extern const u32 minor; -extern char *libraryName; +extern char* libraryName; typedef struct { - s32 Log; + s32 Log; } Config; extern Config conf; -void __Log(char *fmt, ...); +void __Log(char* fmt, ...); void SaveConfig(); void LoadConfig(); -void SysMessage(char *fmt, ...); +void SysMessage(char* fmt, ...); //////////////////// // SPU2 Registers // //////////////////// -#define REG_VP_VOLL 0x0000 -#define REG_VP_VOLR 0x0002 -#define REG_VP_PITCH 0x0004 -#define REG_VP_ADSR1 0x0006 -#define REG_VP_ADSR2 0x0008 -#define REG_VP_ENVX 0x000A -#define REG_VP_VOLXL 0x000C -#define REG_VP_VOLXR 0x000E -#define REG_C0_FMOD1 0x0180 -#define REG_C0_FMOD2 0x0182 -#define REG_C1_FMOD1 0x0580 -#define REG_C1_FMOD2 0x0582 -#define REG_S_NON 0x0184 -#define REG_S_VMIXL 0x0188 -#define REG_S_VMIXEL 0x018C -#define REG_S_VMIXR 0x0190 -#define REG_S_VMIXER 0x0194 -#define REG_C0_MMIX 0x0198 -#define REG_C1_MMIX 0x0598 -#define REG_C0_CTRL 0x019A -#define REG_C0_IRQA_HI 0x019C -#define REG_C0_IRQA_LO 0x019D -#define REG_C1_IRQA_HI 0x059C -#define REG_C1_IRQA_LO 0x059D -#define REG_C0_SPUON1 0x1A0 -#define REG_C0_SPUON2 0x1A2 -#define REG_C1_SPUON1 0x5A0 -#define REG_C1_SPUON2 0x5A2 -#define REG_C0_SPUOFF1 0x1A4 -#define REG_C0_SPUOFF2 0x1A6 -#define REG_C1_SPUOFF1 0x5A4 -#define REG_C1_SPUOFF2 0x5A6 +#define REG_VP_VOLL 0x0000 +#define REG_VP_VOLR 0x0002 +#define REG_VP_PITCH 0x0004 +#define REG_VP_ADSR1 0x0006 +#define REG_VP_ADSR2 0x0008 +#define REG_VP_ENVX 0x000A +#define REG_VP_VOLXL 0x000C +#define REG_VP_VOLXR 0x000E +#define REG_C0_FMOD1 0x0180 +#define REG_C0_FMOD2 0x0182 +#define REG_C1_FMOD1 0x0580 +#define REG_C1_FMOD2 0x0582 +#define REG_S_NON 0x0184 +#define REG_S_VMIXL 0x0188 +#define REG_S_VMIXEL 0x018C +#define REG_S_VMIXR 0x0190 +#define REG_S_VMIXER 0x0194 +#define REG_C0_MMIX 0x0198 +#define REG_C1_MMIX 0x0598 +#define REG_C0_CTRL 0x019A +#define REG_C0_IRQA_HI 0x019C +#define REG_C0_IRQA_LO 0x019D +#define REG_C1_IRQA_HI 0x059C +#define REG_C1_IRQA_LO 0x059D +#define REG_C0_SPUON1 0x1A0 +#define REG_C0_SPUON2 0x1A2 +#define REG_C1_SPUON1 0x5A0 +#define REG_C1_SPUON2 0x5A2 +#define REG_C0_SPUOFF1 0x1A4 +#define REG_C0_SPUOFF2 0x1A6 +#define REG_C1_SPUOFF1 0x5A4 +#define REG_C1_SPUOFF2 0x5A6 #define REG_C0_SPUADDR_HI 0x01A8 #define REG_C0_SPUADDR_LO 0x01AA #define REG_C1_SPUADDR_HI 0x05A8 #define REG_C1_SPUADDR_LO 0x05AA -#define REG_C0_SPUDATA 0x01AC -#define REG_C1_SPUDATA 0x05AC -#define REG_C0_DMACTRL 0x01AE -#define REG_C1_DMACTRL 0x05AE -#define REG_C0_ADMAS 0x01B0 -#define REG_VA_SSA 0x01C0 -#define REG_VA_LSAX 0x01C4 -#define REG_VA_NAX 0x01C8 -#define REG_A_ESA 0x02E0 -#define REG_A_EEA 0x033C -#define REG_C0_END1 0x0340 -#define REG_C0_END2 0x0342 -#define REG_C1_END1 0x0740 -#define REG_C1_END2 0x0742 -#define REG_C0_SPUSTAT 0x0344 //not sure! -#define REG_C1_CTRL 0x059A -#define REG_C1_ADMAS 0x05B0 -#define REG_C1_SPUSTAT 0x0744 //not sure! -#define REG_P_MVOLL 0x0760 -#define REG_P_MVOLR 0x0762 -#define REG_P_EVOLL 0x0764 -#define REG_P_EVOLR 0x0766 -#define REG_P_AVOLL 0x0768 -#define REG_P_AVOLR 0x076A -#define REG_P_BVOLL 0x076C -#define REG_P_BVOLR 0x076E -#define REG_P_MVOLXL 0x0770 -#define REG_P_MVOLXR 0x0772 -#define SPDIF_OUT 0x07C0 -#define REG_IRQINFO 0x07C2 -#define SPDIF_MODE 0x07C6 -#define SPDIF_MEDIA 0x07C8 +#define REG_C0_SPUDATA 0x01AC +#define REG_C1_SPUDATA 0x05AC +#define REG_C0_DMACTRL 0x01AE +#define REG_C1_DMACTRL 0x05AE +#define REG_C0_ADMAS 0x01B0 +#define REG_VA_SSA 0x01C0 +#define REG_VA_LSAX 0x01C4 +#define REG_VA_NAX 0x01C8 +#define REG_A_ESA 0x02E0 +#define REG_A_EEA 0x033C +#define REG_C0_END1 0x0340 +#define REG_C0_END2 0x0342 +#define REG_C1_END1 0x0740 +#define REG_C1_END2 0x0742 +#define REG_C0_SPUSTAT 0x0344 //not sure! +#define REG_C1_CTRL 0x059A +#define REG_C1_ADMAS 0x05B0 +#define REG_C1_SPUSTAT 0x0744 //not sure! +#define REG_P_MVOLL 0x0760 +#define REG_P_MVOLR 0x0762 +#define REG_P_EVOLL 0x0764 +#define REG_P_EVOLR 0x0766 +#define REG_P_AVOLL 0x0768 +#define REG_P_AVOLR 0x076A +#define REG_P_BVOLL 0x076C +#define REG_P_BVOLR 0x076E +#define REG_P_MVOLXL 0x0770 +#define REG_P_MVOLXR 0x0772 +#define SPDIF_OUT 0x07C0 +#define REG_IRQINFO 0x07C2 +#define SPDIF_MODE 0x07C6 +#define SPDIF_MEDIA 0x07C8 -#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem) & 0xffff]) -#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem) & 0xffff]) +#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem)&0xffff]) +#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem)&0xffff]) //#define spu2Rs32(mem) (*(s32*)&spu2regs[(mem) & 0xffff]) //#define spu2Ru32(mem) (*(u32*)&spu2regs[(mem) & 0xffff]) #define IRQINFO spu2Ru16(REG_IRQINFO) -#define SPU2_GET32BIT(lo,hi) (((u32)(spu2Ru16(hi)&0x3f)<<16)|(u32)spu2Ru16(lo)) -#define SPU2_SET32BIT(value, lo, hi) { \ - spu2Ru16(hi) = ((value)>>16)&0x3f; \ - spu2Ru16(lo) = (value)&0xffff; \ - } \ +#define SPU2_GET32BIT(lo, hi) (((u32)(spu2Ru16(hi) & 0x3f) << 16) | (u32)spu2Ru16(lo)) +#define SPU2_SET32BIT(value, lo, hi) \ + { \ + spu2Ru16(hi) = ((value) >> 16) & 0x3f; \ + spu2Ru16(lo) = (value)&0xffff; \ + } #define C0_IRQA SPU2_GET32BIT(REG_C0_IRQA_LO, REG_C0_IRQA_HI) #define C1_IRQA SPU2_GET32BIT(REG_C1_IRQA_LO, REG_C1_IRQA_HI) @@ -157,20 +157,20 @@ void SysMessage(char *fmt, ...); #define C0_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C0_IRQA_LO, REG_C0_IRQA_HI) #define C1_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C1_IRQA_LO, REG_C1_IRQA_HI) -#define SPU_NUMBER_VOICES 48 +#define SPU_NUMBER_VOICES 48 struct SPU_CONTROL_ { - u16 spuon : 1; - u16 spuUnmute : 1; - u16 noiseFreq : 6; - u16 reverb : 1; - u16 irq : 1; - u16 dma : 2; // 1 - no dma, 2 - write, 3 - read - u16 extr : 1; // external reverb - u16 cdreverb : 1; - u16 extAudio : 1; - u16 extCd : 1; + u16 spuon : 1; + u16 spuUnmute : 1; + u16 noiseFreq : 6; + u16 reverb : 1; + u16 irq : 1; + u16 dma : 2; // 1 - no dma, 2 - write, 3 - read + u16 extr : 1; // external reverb + u16 cdreverb : 1; + u16 extAudio : 1; + u16 extCd : 1; }; // the layout of each voice in wSpuRegs @@ -178,115 +178,117 @@ struct _SPU_VOICE { union { - struct { - u16 Vol : 14; - u16 Inverted : 1; - u16 Sweep0 : 1; + struct + { + u16 Vol : 14; + u16 Inverted : 1; + u16 Sweep0 : 1; } vol; - struct { - u16 Vol : 7; - u16 res1 : 5; - u16 Inverted : 1; - u16 Decrease : 1; // if 0, increase - u16 ExpSlope : 1; // if 0, linear slope - u16 Sweep1 : 1; // always one - } sweep; - u16 word; -} left, right; + struct + { + u16 Vol : 7; + u16 res1 : 5; + u16 Inverted : 1; + u16 Decrease : 1; // if 0, increase + u16 ExpSlope : 1; // if 0, linear slope + u16 Sweep1 : 1; // always one + } sweep; + u16 word; + } left, right; - u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc - u16 res0 : 2; + u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc + u16 res0 : 2; - u16 SustainLvl : 4; - u16 DecayRate : 4; - u16 AttackRate : 7; - u16 AttackExp : 1; // if 0, linear + u16 SustainLvl : 4; + u16 DecayRate : 4; + u16 AttackRate : 7; + u16 AttackExp : 1; // if 0, linear - u16 ReleaseRate : 5; - u16 ReleaseExp : 1; // if 0, linear - u16 SustainRate : 7; - u16 res1 : 1; - u16 SustainDec : 1; // if 0, inc - u16 SustainExp : 1; // if 0, linear + u16 ReleaseRate : 5; + u16 ReleaseExp : 1; // if 0, linear + u16 SustainRate : 7; + u16 res1 : 1; + u16 SustainDec : 1; // if 0, inc + u16 SustainExp : 1; // if 0, linear - u16 AdsrVol; - u16 Address; // add / 8 - u16 RepeatAddr; // gets reset when sample starts + u16 AdsrVol; + u16 Address; // add / 8 + u16 RepeatAddr; // gets reset when sample starts }; // ADSR INFOS PER CHANNEL struct ADSRInfoEx { - s32 State; - s32 AttackModeExp; - s32 AttackRate; - s32 DecayRate; - s32 SustainLevel; - s32 SustainModeExp; - s32 SustainIncrease; - s32 SustainRate; - s32 ReleaseModeExp; - s32 ReleaseRate; - s32 EnvelopeVol; - s32 lVolume; + s32 State; + s32 AttackModeExp; + s32 AttackRate; + s32 DecayRate; + s32 SustainLevel; + s32 SustainModeExp; + s32 SustainIncrease; + s32 SustainRate; + s32 ReleaseModeExp; + s32 ReleaseRate; + s32 EnvelopeVol; + s32 lVolume; }; -#define NSSIZE 48 // ~ 1 ms of data -#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting +#define NSSIZE 48 // ~ 1 ms of data +#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting #define NSPACKETS 4 -#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED)-4*sizeof(void*)) +#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED) - 4 * sizeof(void*)) struct VOICE_PROCESSED { - VOICE_PROCESSED() - { - memset(this, 0, sizeof(VOICE_PROCESSED)); - } - ~VOICE_PROCESSED() - { - } + VOICE_PROCESSED() + { + memset(this, 0, sizeof(VOICE_PROCESSED)); + } + ~VOICE_PROCESSED() + { + } - void SetVolume(int right); - void StartSound(); - void VoiceChangeFrequency(); - void FModChangeFrequency(int ns); - void Stop(); + void SetVolume(int right); + void StartSound(); + void VoiceChangeFrequency(); + void FModChangeFrequency(int ns); + void Stop(); - SPU_CONTROL_* GetCtrl(); + SPU_CONTROL_* GetCtrl(); - // start save state + // start save state - s32 iSBPos; // mixing stuff - s32 spos; - s32 sinc; + s32 iSBPos; // mixing stuff + s32 spos; + s32 sinc; - s32 iActFreq; // current psx pitch - s32 iUsedFreq; // current pc pitch + s32 iActFreq; // current psx pitch + s32 iUsedFreq; // current pc pitch - s32 iStartAddr, iLoopAddr, iNextAddr; + s32 iStartAddr, iLoopAddr, iNextAddr; - ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start) - bool bIgnoreLoop, bNew, bNoise, bReverb, bOn, bStop, bVolChanged; - s32 memoffset; // if first core, 0, if second, 0x400 + ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start) + bool bIgnoreLoop, bNew, bNoise, bReverb, bOn, bStop, bVolChanged; + s32 memoffset; // if first core, 0, if second, 0x400 - // end save state + // end save state - /////////////////// - // Sound Buffers // - /////////////////// - u8* pStart; // start and end addresses - u8* pLoop, *pCurr; + /////////////////// + // Sound Buffers // + /////////////////// + u8* pStart; // start and end addresses + u8 *pLoop, *pCurr; - _SPU_VOICE* pvoice; + _SPU_VOICE* pvoice; }; struct ADMA { - u16 * MemAddr; - s32 IntPointer; - s32 Index; - s32 AmountLeft; - s32 Enabled; + u16* MemAddr; + s32 IntPointer; + s32 Index; + s32 AmountLeft; + s32 Enabled; }; #endif /* __SPU2_H__ */ diff --git a/plugins/SPU2null/Windows/Config.cpp b/plugins/SPU2null/Windows/Config.cpp index 5b8b56eedd..906ac62c00 100644 --- a/plugins/SPU2null/Windows/Config.cpp +++ b/plugins/SPU2null/Windows/Config.cpp @@ -21,46 +21,45 @@ extern HINSTANCE hInst; void SaveConfig() { - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; + Config* Conf1 = &conf; + char* szTemp; + char szIniFile[256], szValue[256]; - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); - - if(!szTemp) return; - strcpy(szTemp, "\\inis\\spu2null.ini"); - sprintf(szValue,"%u",Conf1->Log); - WritePrivateProfileString("Interface", "Logging",szValue,szIniFile); + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); + if (!szTemp) + return; + strcpy(szTemp, "\\inis\\spu2null.ini"); + sprintf(szValue, "%u", Conf1->Log); + WritePrivateProfileString("Interface", "Logging", szValue, szIniFile); } -void LoadConfig() { - FILE *fp; +void LoadConfig() +{ + FILE* fp; - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; + Config* Conf1 = &conf; + char* szTemp; + char szIniFile[256], szValue[256]; - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); - if(!szTemp) return ; - strcpy(szTemp, "\\inis\\spu2null.ini"); - fp=fopen("inis\\usbnull.ini","rt");//check if usbnull.ini really exists - if (!fp) - { - CreateDirectory("inis",NULL); + if (!szTemp) + return; + strcpy(szTemp, "\\inis\\spu2null.ini"); + fp = fopen("inis\\usbnull.ini", "rt"); //check if usbnull.ini really exists + if (!fp) { + CreateDirectory("inis", NULL); memset(&conf, 0, sizeof(conf)); - conf.Log = 0;//default value - SaveConfig();//save and return - return ; - } - fclose(fp); - GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); - Conf1->Log = strtoul(szValue, NULL, 10); - return ; - + conf.Log = 0; //default value + SaveConfig(); //save and return + return; + } + fclose(fp); + GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); + Conf1->Log = strtoul(szValue, NULL, 10); + return; } - diff --git a/plugins/SPU2null/Windows/Win32.cpp b/plugins/SPU2null/Windows/Win32.cpp index cc3c2672c8..a29fe8b6a4 100644 --- a/plugins/SPU2null/Windows/Win32.cpp +++ b/plugins/SPU2null/Windows/Win32.cpp @@ -22,75 +22,81 @@ HINSTANCE hInst; -void SysMessage(char *fmt, ...) { - va_list list; - char tmp[512]; +void SysMessage(char* fmt, ...) +{ + va_list list; + char tmp[512]; - va_start(list,fmt); - vsprintf(tmp,fmt,list); - va_end(list); - MessageBox(0, tmp, "SPU2NULL Msg", 0); + va_start(list, fmt); + vsprintf(tmp, fmt, list); + va_end(list); + MessageBox(0, tmp, "SPU2NULL Msg", 0); } -BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { +BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ - switch(uMsg) { - case WM_INITDIALOG: - LoadConfig(); - if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); - return TRUE; + switch (uMsg) { + case WM_INITDIALOG: + LoadConfig(); + if (conf.Log) + CheckDlgButton(hW, IDC_LOGGING, TRUE); + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - EndDialog(hW, TRUE); - return TRUE; - case IDOK: - if (IsDlgButtonChecked(hW, IDC_LOGGING)) - conf.Log = 1; - else conf.Log = 0; - SaveConfig(); - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hW, TRUE); + return TRUE; + case IDOK: + if (IsDlgButtonChecked(hW, IDC_LOGGING)) + conf.Log = 1; + else + conf.Log = 0; + SaveConfig(); + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { - case WM_INITDIALOG: - return TRUE; +BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case WM_INITDIALOG: + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -void CALLBACK SPU2configure() { +void CALLBACK SPU2configure() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), GetActiveWindow(), (DLGPROC)ConfigureDlgProc); - } -void CALLBACK SPU2about() { +void CALLBACK SPU2about() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), (DLGPROC)AboutDlgProc); } -BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT - DWORD dwReason, - LPVOID lpReserved) { - hInst = (HINSTANCE)hModule; - return TRUE; // very quick :) +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) +{ + hInst = (HINSTANCE)hModule; + return TRUE; // very quick :) } - diff --git a/plugins/USBnull/Config.cpp b/plugins/USBnull/Config.cpp index 8858d6da14..cccc1a839f 100644 --- a/plugins/USBnull/Config.cpp +++ b/plugins/USBnull/Config.cpp @@ -25,55 +25,51 @@ PluginConf Ini; void setLoggingState() { - if (conf.Log) - { - USBLog.WriteToConsole = true; - USBLog.WriteToFile = true; - } - else - { - USBLog.WriteToConsole = false; - USBLog.WriteToFile = false; - } + if (conf.Log) { + USBLog.WriteToConsole = true; + USBLog.WriteToFile = true; + } else { + USBLog.WriteToConsole = false; + USBLog.WriteToFile = false; + } } -EXPORT_C_(void) USBabout() +EXPORT_C_(void) +USBabout() { - SysMessage("USBnull: A simple null plugin."); + SysMessage("USBnull: A simple null plugin."); } -EXPORT_C_(void) USBconfigure() +EXPORT_C_(void) +USBconfigure() { - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); + LoadConfig(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } void LoadConfig() { - string IniPath = s_strIniPath + "/USBnull.ini"; - if (!Ini.Open(IniPath, READ_FILE)) - { - USBLog.WriteLn("Failed to open %s", IniPath.c_str()); - SaveConfig(); - return; - } + string IniPath = s_strIniPath + "/USBnull.ini"; + if (!Ini.Open(IniPath, READ_FILE)) { + USBLog.WriteLn("Failed to open %s", IniPath.c_str()); + SaveConfig(); + return; + } - conf.Log = Ini.ReadInt("logging", 0); - setLoggingState(); - Ini.Close(); + conf.Log = Ini.ReadInt("logging", 0); + setLoggingState(); + Ini.Close(); } void SaveConfig() { - string IniPath = s_strIniPath + "/USBnull.ini"; - if (!Ini.Open(IniPath, WRITE_FILE)) - { - USBLog.WriteLn("Failed to open %s", IniPath.c_str()); - return; - } + string IniPath = s_strIniPath + "/USBnull.ini"; + if (!Ini.Open(IniPath, WRITE_FILE)) { + USBLog.WriteLn("Failed to open %s", IniPath.c_str()); + return; + } - Ini.WriteInt("logging", conf.Log); - Ini.Close(); + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } - diff --git a/plugins/USBnull/USB.cpp b/plugins/USBnull/USB.cpp index 58ea4d6960..590a642be0 100644 --- a/plugins/USBnull/USB.cpp +++ b/plugins/USBnull/USB.cpp @@ -18,12 +18,12 @@ using namespace std; #include "svnrev.h" #include "USB.h" -string s_strIniPath="inis"; -string s_strLogPath="logs"; +string s_strIniPath = "inis"; +string s_strLogPath = "logs"; -const unsigned char version = PS2E_USB_VERSION; +const unsigned char version = PS2E_USB_VERSION; const unsigned char revision = 0; -const unsigned char build = 7; // increase that with each version +const unsigned char build = 7; // increase that with each version #ifdef _MSC_VER #define snprintf sprintf_s @@ -38,233 +38,245 @@ s8 *usbregs, *ram; void LogInit() { - const std::string LogFile(s_strLogPath + "/USBnull.log"); - setLoggingState(); - USBLog.Open(LogFile); + const std::string LogFile(s_strLogPath + "/USBnull.log"); + setLoggingState(); + USBLog.Open(LogFile); } -EXPORT_C_(void) USBsetLogDir(const char* dir) +EXPORT_C_(void) +USBsetLogDir(const char* dir) { - // Get the path to the log directory. - s_strLogPath = (dir==NULL) ? "logs" : dir; - - // Reload the log file after updated the path - USBLog.Close(); - LogInit(); + // Get the path to the log directory. + s_strLogPath = (dir == NULL) ? "logs" : dir; + + // Reload the log file after updated the path + USBLog.Close(); + LogInit(); } -EXPORT_C_(u32) PS2EgetLibType() +EXPORT_C_(u32) +PS2EgetLibType() { - return PS2E_LT_USB; + return PS2E_LT_USB; } -EXPORT_C_(char*) PS2EgetLibName() +EXPORT_C_(char*) +PS2EgetLibName() { - snprintf( libraryName, 255, "USBnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : ""); - return libraryName; + snprintf(libraryName, 255, "USBnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : ""); + return libraryName; } -EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +EXPORT_C_(u32) +PS2EgetLibVersion2(u32 type) { - return (version << 16) | (revision << 8) | build; + return (version << 16) | (revision << 8) | build; } -EXPORT_C_(s32) USBinit() +EXPORT_C_(s32) +USBinit() { - LoadConfig(); - LogInit(); - USBLog.WriteLn("USBnull plugin version %d,%d", revision, build); - USBLog.WriteLn("Initializing USBnull"); + LoadConfig(); + LogInit(); + USBLog.WriteLn("USBnull plugin version %d,%d", revision, build); + USBLog.WriteLn("Initializing USBnull"); - // Initialize memory structures here. - usbregs = (s8*)calloc(0x10000, 1); + // Initialize memory structures here. + usbregs = (s8*)calloc(0x10000, 1); - if (usbregs == NULL) - { - USBLog.Message("Error allocating memory"); - return -1; - } + if (usbregs == NULL) { + USBLog.Message("Error allocating memory"); + return -1; + } - return 0; + return 0; } -EXPORT_C_(void) USBshutdown() +EXPORT_C_(void) +USBshutdown() { - // Yes, we close things in the Shutdown routine, and - // don't do anything in the close routine. - USBLog.Close(); - - free(usbregs); - usbregs = NULL; + // Yes, we close things in the Shutdown routine, and + // don't do anything in the close routine. + USBLog.Close(); + + free(usbregs); + usbregs = NULL; } -EXPORT_C_(s32) USBopen(void *pDsp) +EXPORT_C_(s32) +USBopen(void* pDsp) { - USBLog.WriteLn("Opening USBnull."); + USBLog.WriteLn("Opening USBnull."); - // Take care of anything else we need on opening, other then initialization. - return 0; + // Take care of anything else we need on opening, other then initialization. + return 0; } -EXPORT_C_(void) USBclose() +EXPORT_C_(void) +USBclose() { - USBLog.WriteLn("Closing USBnull."); + USBLog.WriteLn("Closing USBnull."); } // Note: actually uncommenting the read/write functions I provided here // caused uLauncher.elf to hang on startup, so careful when experimenting. -EXPORT_C_(u8) USBread8(u32 addr) +EXPORT_C_(u8) +USBread8(u32 addr) { - u8 value = 0; + u8 value = 0; - switch(addr) - { - // Handle any appropriate addresses here. - case 0x1f801600: - USBLog.WriteLn("(USBnull) 8 bit read at address %lx", addr); - break; + switch (addr) { + // Handle any appropriate addresses here. + case 0x1f801600: + USBLog.WriteLn("(USBnull) 8 bit read at address %lx", addr); + break; - default: - //value = usbRu8(addr); - USBLog.WriteLn("*(USBnull) 8 bit read at address %lx", addr); - break; - } - return value; + default: + //value = usbRu8(addr); + USBLog.WriteLn("*(USBnull) 8 bit read at address %lx", addr); + break; + } + return value; } -EXPORT_C_(u16) USBread16(u32 addr) +EXPORT_C_(u16) +USBread16(u32 addr) { - u16 value = 0; + u16 value = 0; - switch(addr) - { - // Handle any appropriate addresses here. - case 0x1f801600: - USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); - break; + switch (addr) { + // Handle any appropriate addresses here. + case 0x1f801600: + USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); + break; - default: - //value = usbRu16(addr); - USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); - } - return value; + default: + //value = usbRu16(addr); + USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); + } + return value; } -EXPORT_C_(u32) USBread32(u32 addr) +EXPORT_C_(u32) +USBread32(u32 addr) { - u32 value = 0; + u32 value = 0; - switch(addr) - { - // Handle any appropriate addresses here. - case 0x1f801600: - USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); - break; + switch (addr) { + // Handle any appropriate addresses here. + case 0x1f801600: + USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); + break; - default: - //value = usbRu32(addr); - USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); - } - return value; + default: + //value = usbRu32(addr); + USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); + } + return value; } -EXPORT_C_(void) USBwrite8(u32 addr, u8 value) +EXPORT_C_(void) +USBwrite8(u32 addr, u8 value) { - switch(addr) - { - // Handle any appropriate addresses here. - case 0x1f801600: - USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); - break; + switch (addr) { + // Handle any appropriate addresses here. + case 0x1f801600: + USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); + break; - default: - //usbRu8(addr) = value; - USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); - } + default: + //usbRu8(addr) = value; + USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); + } } -EXPORT_C_(void) USBwrite16(u32 addr, u16 value) +EXPORT_C_(void) +USBwrite16(u32 addr, u16 value) { - switch(addr) - { - // Handle any appropriate addresses here. - case 0x1f801600: - USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); - break; + switch (addr) { + // Handle any appropriate addresses here. + case 0x1f801600: + USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); + break; - default: - //usbRu16(addr) = value; - USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); - } + default: + //usbRu16(addr) = value; + USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); + } } -EXPORT_C_(void) USBwrite32(u32 addr, u32 value) +EXPORT_C_(void) +USBwrite32(u32 addr, u32 value) { - switch(addr) - { - // Handle any appropriate addresses here. - case 0x1f801600: - USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); - break; + switch (addr) { + // Handle any appropriate addresses here. + case 0x1f801600: + USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); + break; - default: - //usbRu32(addr) = value; - USBLog.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value); - } + default: + //usbRu32(addr) = value; + USBLog.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value); + } } -EXPORT_C_(void) USBirqCallback(USBcallback callback) +EXPORT_C_(void) +USBirqCallback(USBcallback callback) { - // Register USBirq, so we can trigger an interrupt with it later. - // It will be called as USBirq(cycles); where cycles is the number - // of cycles before the irq is triggered. - USBirq = callback; + // Register USBirq, so we can trigger an interrupt with it later. + // It will be called as USBirq(cycles); where cycles is the number + // of cycles before the irq is triggered. + USBirq = callback; } -EXPORT_C_(int) _USBirqHandler(void) +EXPORT_C_(int) +_USBirqHandler(void) { - // This is our USB irq handler, so if an interrupt gets triggered, - // deal with it here. - return 0; + // This is our USB irq handler, so if an interrupt gets triggered, + // deal with it here. + return 0; } -EXPORT_C_(USBhandler) USBirqHandler(void) +EXPORT_C_(USBhandler) +USBirqHandler(void) { - // Pass our handler to pcsx2. - return (USBhandler)_USBirqHandler; + // Pass our handler to pcsx2. + return (USBhandler)_USBirqHandler; } -EXPORT_C_(void) USBsetRAM(void *mem) +EXPORT_C_(void) +USBsetRAM(void* mem) { - ram = (s8*)mem; - USBLog.WriteLn("*Setting ram."); + ram = (s8*)mem; + USBLog.WriteLn("*Setting ram."); } -EXPORT_C_(void) USBsetSettingsDir(const char* dir) +EXPORT_C_(void) +USBsetSettingsDir(const char* dir) { - // Get the path to the ini directory. - s_strIniPath = (dir==NULL) ? "inis" : dir; + // Get the path to the ini directory. + s_strIniPath = (dir == NULL) ? "inis" : dir; } // extended funcs -EXPORT_C_(s32) USBfreeze(int mode, freezeData *data) +EXPORT_C_(s32) +USBfreeze(int mode, freezeData* data) { - // This should store or retrieve any information, for if emulation - // gets suspended, or for savestates. - switch(mode) - { - case FREEZE_LOAD: - // Load previously saved data. - break; - case FREEZE_SAVE: - // Save data. - break; - case FREEZE_SIZE: - // return the size of the data. - break; - } - return 0; + // This should store or retrieve any information, for if emulation + // gets suspended, or for savestates. + switch (mode) { + case FREEZE_LOAD: + // Load previously saved data. + break; + case FREEZE_SAVE: + // Save data. + break; + case FREEZE_SIZE: + // return the size of the data. + break; + } + return 0; } /*EXPORT_C_(void) USBasync(u32 cycles) @@ -272,10 +284,11 @@ EXPORT_C_(s32) USBfreeze(int mode, freezeData *data) // Optional function: Called in IopCounter.cpp. }*/ -EXPORT_C_(s32) USBtest() +EXPORT_C_(s32) +USBtest() { - // 0 if the plugin works, non-0 if it doesn't. - return 0; + // 0 if the plugin works, non-0 if it doesn't. + return 0; } /* For operating systems that need an entry point for a dll/library, here it is. Defined in PS2Eext.h. */ diff --git a/plugins/USBnull/USB.h b/plugins/USBnull/USB.h index cd260734ca..4bd6d633b2 100644 --- a/plugins/USBnull/USB.h +++ b/plugins/USBnull/USB.h @@ -22,24 +22,25 @@ #include "PS2Edefs.h" #include "PS2Eext.h" -typedef struct { - int Log; +typedef struct +{ + int Log; } Config; extern USBcallback USBirq; extern Config conf; // Previous USB plugins have needed this in ohci. -static const s64 PSXCLK = 36864000; /* 36.864 Mhz */ +static const s64 PSXCLK = 36864000; /* 36.864 Mhz */ extern s8 *usbregs, *ram; -#define usbRs8(mem) usbregs[(mem) & 0xffff] -#define usbRs16(mem) (*(s16*)&usbregs[(mem) & 0xffff]) -#define usbRs32(mem) (*(s32*)&usbregs[(mem) & 0xffff]) -#define usbRu8(mem) (*(u8*) &usbregs[(mem) & 0xffff]) -#define usbRu16(mem) (*(u16*)&usbregs[(mem) & 0xffff]) -#define usbRu32(mem) (*(u32*)&usbregs[(mem) & 0xffff]) +#define usbRs8(mem) usbregs[(mem)&0xffff] +#define usbRs16(mem) (*(s16*)&usbregs[(mem)&0xffff]) +#define usbRs32(mem) (*(s32*)&usbregs[(mem)&0xffff]) +#define usbRu8(mem) (*(u8*)&usbregs[(mem)&0xffff]) +#define usbRu16(mem) (*(u16*)&usbregs[(mem)&0xffff]) +#define usbRu32(mem) (*(u32*)&usbregs[(mem)&0xffff]) extern void SaveConfig(); extern void LoadConfig(); diff --git a/plugins/USBnull/Windows/Config.cpp b/plugins/USBnull/Windows/Config.cpp index 6c210ec2c9..437b233f71 100644 --- a/plugins/USBnull/Windows/Config.cpp +++ b/plugins/USBnull/Windows/Config.cpp @@ -21,46 +21,45 @@ extern HINSTANCE hInst; void SaveConfig() { - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; + Config* Conf1 = &conf; + char* szTemp; + char szIniFile[256], szValue[256]; - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); - - if(!szTemp) return; - strcpy(szTemp, "\\inis\\usbnull.ini"); - sprintf(szValue,"%u",Conf1->Log); - WritePrivateProfileString("Interface", "Logging",szValue,szIniFile); + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); + if (!szTemp) + return; + strcpy(szTemp, "\\inis\\usbnull.ini"); + sprintf(szValue, "%u", Conf1->Log); + WritePrivateProfileString("Interface", "Logging", szValue, szIniFile); } -void LoadConfig() { - FILE *fp; +void LoadConfig() +{ + FILE* fp; - Config *Conf1 = &conf; - char *szTemp; - char szIniFile[256], szValue[256]; + Config* Conf1 = &conf; + char* szTemp; + char szIniFile[256], szValue[256]; - GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); - szTemp = strrchr(szIniFile, '\\'); + GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256); + szTemp = strrchr(szIniFile, '\\'); - if(!szTemp) return ; - strcpy(szTemp, "\\inis\\usbnull.ini"); - fp=fopen("inis\\usbnull.ini","rt");//check if usbnull.ini really exists - if (!fp) - { - CreateDirectory("inis",NULL); + if (!szTemp) + return; + strcpy(szTemp, "\\inis\\usbnull.ini"); + fp = fopen("inis\\usbnull.ini", "rt"); //check if usbnull.ini really exists + if (!fp) { + CreateDirectory("inis", NULL); memset(&conf, 0, sizeof(conf)); - conf.Log = 0;//default value - SaveConfig();//save and return - return ; - } - fclose(fp); - GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); - Conf1->Log = strtoul(szValue, NULL, 10); - return ; - + conf.Log = 0; //default value + SaveConfig(); //save and return + return; + } + fclose(fp); + GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile); + Conf1->Log = strtoul(szValue, NULL, 10); + return; } - diff --git a/plugins/USBnull/Windows/Win32.cpp b/plugins/USBnull/Windows/Win32.cpp index 5d4c54be31..806126587d 100644 --- a/plugins/USBnull/Windows/Win32.cpp +++ b/plugins/USBnull/Windows/Win32.cpp @@ -22,75 +22,81 @@ HINSTANCE hInst; -void SysMessage(char *fmt, ...) { - va_list list; - char tmp[512]; +void SysMessage(char* fmt, ...) +{ + va_list list; + char tmp[512]; - va_start(list,fmt); - vsprintf(tmp,fmt,list); - va_end(list); - MessageBox(GetActiveWindow(), tmp, "USBnull Msg", MB_SETFOREGROUND | MB_OK); + va_start(list, fmt); + vsprintf(tmp, fmt, list); + va_end(list); + MessageBox(GetActiveWindow(), tmp, "USBnull Msg", MB_SETFOREGROUND | MB_OK); } -BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { +BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ - switch(uMsg) { - case WM_INITDIALOG: - LoadConfig(); - if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE); - return TRUE; + switch (uMsg) { + case WM_INITDIALOG: + LoadConfig(); + if (conf.Log) + CheckDlgButton(hW, IDC_LOGGING, TRUE); + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - EndDialog(hW, TRUE); - return TRUE; - case IDOK: - if (IsDlgButtonChecked(hW, IDC_LOGGING)) - conf.Log = 1; - else conf.Log = 0; - SaveConfig(); - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hW, TRUE); + return TRUE; + case IDOK: + if (IsDlgButtonChecked(hW, IDC_LOGGING)) + conf.Log = 1; + else + conf.Log = 0; + SaveConfig(); + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { - case WM_INITDIALOG: - return TRUE; +BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case WM_INITDIALOG: + return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - EndDialog(hW, FALSE); - return TRUE; - } - } - return FALSE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + EndDialog(hW, FALSE); + return TRUE; + } + } + return FALSE; } -void CALLBACK USBconfigure() { +void CALLBACK USBconfigure() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), GetActiveWindow(), (DLGPROC)ConfigureDlgProc); - } -void CALLBACK USBabout() { +void CALLBACK USBabout() +{ DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), (DLGPROC)AboutDlgProc); } -BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT - DWORD dwReason, - LPVOID lpReserved) { - hInst = (HINSTANCE)hModule; - return TRUE; // very quick :) +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) +{ + hInst = (HINSTANCE)hModule; + return TRUE; // very quick :) } - diff --git a/plugins/dev9null/Config.cpp b/plugins/dev9null/Config.cpp index 17113c3465..6242ac370d 100644 --- a/plugins/dev9null/Config.cpp +++ b/plugins/dev9null/Config.cpp @@ -28,54 +28,50 @@ PluginConf Ini; void setLoggingState() { - if (conf.Log) - { - Dev9Log.WriteToConsole = true; - Dev9Log.WriteToFile = true; - } - else - { - Dev9Log.WriteToConsole = false; - Dev9Log.WriteToFile = false; - } + if (conf.Log) { + Dev9Log.WriteToConsole = true; + Dev9Log.WriteToFile = true; + } else { + Dev9Log.WriteToConsole = false; + Dev9Log.WriteToFile = false; + } } -EXPORT_C_(void) DEV9about() +EXPORT_C_(void) +DEV9about() { - SysMessage("Dev9null: A simple null plugin."); + SysMessage("Dev9null: A simple null plugin."); } -EXPORT_C_(void) DEV9configure() +EXPORT_C_(void) +DEV9configure() { - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); + LoadConfig(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } void LoadConfig() { - string IniPath = s_strIniPath + "/Dev9null.ini"; - if (!Ini.Open(IniPath, READ_FILE)) - { - Dev9Log.WriteLn("Failed to open %s", IniPath.c_str()); - SaveConfig(); - return; - } + string IniPath = s_strIniPath + "/Dev9null.ini"; + if (!Ini.Open(IniPath, READ_FILE)) { + Dev9Log.WriteLn("Failed to open %s", IniPath.c_str()); + SaveConfig(); + return; + } - conf.Log = Ini.ReadInt("logging",0); - Ini.Close(); + conf.Log = Ini.ReadInt("logging", 0); + Ini.Close(); } void SaveConfig() { - string IniPath = s_strIniPath + "/Dev9null.ini"; - if (!Ini.Open(IniPath, WRITE_FILE)) - { - Dev9Log.WriteLn("Failed to open %s", IniPath.c_str()); - return; - } + string IniPath = s_strIniPath + "/Dev9null.ini"; + if (!Ini.Open(IniPath, WRITE_FILE)) { + Dev9Log.WriteLn("Failed to open %s", IniPath.c_str()); + return; + } - Ini.WriteInt("logging", conf.Log); - Ini.Close(); + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } - diff --git a/plugins/dev9null/Config.h b/plugins/dev9null/Config.h index 1013380a2c..67b1e38a5e 100644 --- a/plugins/dev9null/Config.h +++ b/plugins/dev9null/Config.h @@ -18,7 +18,7 @@ void SaveConfig(); void LoadConfig(); -void SysMessage(char *fmt, ...); +void SysMessage(char* fmt, ...); //#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)))) //#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state) diff --git a/plugins/dev9null/DEV9.cpp b/plugins/dev9null/DEV9.cpp index c4865e5b40..a9783af800 100644 --- a/plugins/dev9null/DEV9.cpp +++ b/plugins/dev9null/DEV9.cpp @@ -33,9 +33,9 @@ using namespace std; #include "DEV9.h" #include "svnrev.h" -const unsigned char version = PS2E_DEV9_VERSION; +const unsigned char version = PS2E_DEV9_VERSION; const unsigned char revision = 0; -const unsigned char build = 5; // increase that with each version +const unsigned char build = 5; // increase that with each version #ifdef _MSC_VER #define snprintf sprintf_s @@ -48,265 +48,288 @@ void (*DEV9irq)(int); __aligned16 s8 dev9regs[0x10000]; string s_strIniPath = "inis"; -string s_strLogPath="logs"; +string s_strLogPath = "logs"; PluginLog Dev9Log; Config conf; void LogInit() { - const std::string LogFile(s_strLogPath + "/dev9null.log"); - setLoggingState(); - Dev9Log.Open(LogFile); + const std::string LogFile(s_strLogPath + "/dev9null.log"); + setLoggingState(); + Dev9Log.Open(LogFile); } -EXPORT_C_(void) DEV9setLogDir(const char* dir) +EXPORT_C_(void) +DEV9setLogDir(const char* dir) { - // Get the path to the log directory. - s_strLogPath = (dir==NULL) ? "logs" : dir; - - // Reload the log file after updated the path - Dev9Log.Close(); - LogInit(); + // Get the path to the log directory. + s_strLogPath = (dir == NULL) ? "logs" : dir; + + // Reload the log file after updated the path + Dev9Log.Close(); + LogInit(); } -EXPORT_C_(u32) PS2EgetLibType() +EXPORT_C_(u32) +PS2EgetLibType() { - return PS2E_LT_DEV9; + return PS2E_LT_DEV9; } -EXPORT_C_(char*) PS2EgetLibName() +EXPORT_C_(char*) +PS2EgetLibName() { - snprintf( libraryName, 255, "DEV9null Driver %lld%s",SVN_REV, SVN_MODS ? "m" : ""); - return libraryName; + snprintf(libraryName, 255, "DEV9null Driver %lld%s", SVN_REV, SVN_MODS ? "m" : ""); + return libraryName; } -EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) +EXPORT_C_(u32) +PS2EgetLibVersion2(u32 type) { - return (version<<16) | (revision<<8) | build; + return (version << 16) | (revision << 8) | build; } -EXPORT_C_(s32) DEV9init() +EXPORT_C_(s32) +DEV9init() { - LoadConfig(); - setLoggingState(); - LogInit(); - Dev9Log.WriteLn("dev9null plugin version %d,%d", revision, build); - Dev9Log.WriteLn("Initializing dev9null"); - // Initialize anything that needs to be initialized. - memset(dev9regs, 0, sizeof(dev9regs)); - return 0; + LoadConfig(); + setLoggingState(); + LogInit(); + Dev9Log.WriteLn("dev9null plugin version %d,%d", revision, build); + Dev9Log.WriteLn("Initializing dev9null"); + // Initialize anything that needs to be initialized. + memset(dev9regs, 0, sizeof(dev9regs)); + return 0; } -EXPORT_C_(void) DEV9shutdown() +EXPORT_C_(void) +DEV9shutdown() { - Dev9Log.WriteLn("Shutting down Dev9null."); - Dev9Log.Close(); + Dev9Log.WriteLn("Shutting down Dev9null."); + Dev9Log.Close(); } -EXPORT_C_(s32) DEV9open(void *pDsp) +EXPORT_C_(s32) +DEV9open(void* pDsp) { - Dev9Log.WriteLn("Opening Dev9null."); - // Get anything ready we need to. Opening and creating hard - // drive files, for example. - return 0; + Dev9Log.WriteLn("Opening Dev9null."); + // Get anything ready we need to. Opening and creating hard + // drive files, for example. + return 0; } -EXPORT_C_(void) DEV9close() +EXPORT_C_(void) +DEV9close() { - Dev9Log.WriteLn("Closing Dev9null."); - // Close files opened. + Dev9Log.WriteLn("Closing Dev9null."); + // Close files opened. } -EXPORT_C_(u8) DEV9read8(u32 addr) +EXPORT_C_(u8) +DEV9read8(u32 addr) { u8 value = 0; - switch(addr) - { -// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay) - case 0x10000038: /*value = dev9Ru8(addr);*/ break; // We need to have at least one case to avoid warnings. + switch (addr) { + // case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay) + case 0x10000038: /*value = dev9Ru8(addr);*/ + break; // We need to have at least one case to avoid warnings. default: //value = dev9Ru8(addr); Dev9Log.WriteLn("*Unknown 8 bit read at address %lx", addr); break; } - return value; + return value; } -EXPORT_C_(u16) DEV9read16(u32 addr) +EXPORT_C_(u16) +DEV9read16(u32 addr) { u16 value = 0; - switch(addr) - { - // Addresses you may want to catch here include: -// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay) -// case 0x10000002: // The Smart Chip revision. Should be 0x11 -// case 0x10000004: // More type info: bit 0 - smap; bit 1 - hd; bit 5 - flash -// case 0x1000000E: // Similar to the last; bit 1 should be set if a hd is hooked up. -// case 0x10000028: // intr_stat -// case 0x10000038: // hard drives seem to like reading and writing the max dma size per transfer here. -// case 0x1000002A: // intr_mask -// case 0x10000040: // pio_data -// case 0x10000044: // nsector -// case 0x10000046: // sector -// case 0x10000048: // lcyl -// case 0x1000004A: // hcyl -// case 0x1000004C: // select -// case 0x1000004E: // status -// case 0x1000005C: // status -// case 0x10000064: // if_ctrl - case 0x10000038: /*value = dev9Ru16(addr);*/ break; + switch (addr) { + // Addresses you may want to catch here include: + // case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay) + // case 0x10000002: // The Smart Chip revision. Should be 0x11 + // case 0x10000004: // More type info: bit 0 - smap; bit 1 - hd; bit 5 - flash + // case 0x1000000E: // Similar to the last; bit 1 should be set if a hd is hooked up. + // case 0x10000028: // intr_stat + // case 0x10000038: // hard drives seem to like reading and writing the max dma size per transfer here. + // case 0x1000002A: // intr_mask + // case 0x10000040: // pio_data + // case 0x10000044: // nsector + // case 0x10000046: // sector + // case 0x10000048: // lcyl + // case 0x1000004A: // hcyl + // case 0x1000004C: // select + // case 0x1000004E: // status + // case 0x1000005C: // status + // case 0x10000064: // if_ctrl + case 0x10000038: /*value = dev9Ru16(addr);*/ + break; default: //value = dev9Ru16(addr); Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr); break; } - return value; + return value; } -EXPORT_C_(u32 ) DEV9read32(u32 addr) +EXPORT_C_(u32) +DEV9read32(u32 addr) { u32 value = 0; - switch(addr) - { - case 0x10000038: /*value = dev9Ru32(addr);*/ break; + switch (addr) { + case 0x10000038: /*value = dev9Ru32(addr);*/ + break; default: //value = dev9Ru32(addr); Dev9Log.WriteLn("*Unknown 32 bit read at address %lx", addr); - break; + break; } - return value; + return value; } -EXPORT_C_(void) DEV9write8(u32 addr, u8 value) +EXPORT_C_(void) +DEV9write8(u32 addr, u8 value) { - switch(addr) - { - case 0x10000038: /*dev9Ru8(addr) = value;*/ break; + switch (addr) { + case 0x10000038: /*dev9Ru8(addr) = value;*/ + break; default: - Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value); - //dev9Ru8(addr) = value; - break; + Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value); + //dev9Ru8(addr) = value; + break; } } -EXPORT_C_(void) DEV9write16(u32 addr, u16 value) +EXPORT_C_(void) +DEV9write16(u32 addr, u16 value) { - switch(addr) - { - // Remember that list on DEV9read16? You'll want to write to a - // lot of them, too. - case 0x10000038: /*dev9Ru16(addr) = value;*/ break; + switch (addr) { + // Remember that list on DEV9read16? You'll want to write to a + // lot of them, too. + case 0x10000038: /*dev9Ru16(addr) = value;*/ + break; default: - Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value); + Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value); //dev9Ru16(addr) = value; - break; + break; } } -EXPORT_C_(void) DEV9write32(u32 addr, u32 value) +EXPORT_C_(void) +DEV9write32(u32 addr, u32 value) { - switch(addr) - { - case 0x10000038: /*dev9Ru32(addr) = value;*/ break; + switch (addr) { + case 0x10000038: /*dev9Ru32(addr) = value;*/ + break; default: - Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value); + Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value); //dev9Ru32(addr) = value; - break; + break; } } //#ifdef ENABLE_NEW_IOPDMA_DEV9 -EXPORT_C_(s32) DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) +EXPORT_C_(s32) +DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) { - // You'll want to put your own DMA8 reading code here. - // Time to interact with your fake (or real) hardware. - Dev9Log.WriteLn("Reading DMA8 Mem."); - *bytesProcessed = bytesLeft; - return 0; + // You'll want to put your own DMA8 reading code here. + // Time to interact with your fake (or real) hardware. + Dev9Log.WriteLn("Reading DMA8 Mem."); + *bytesProcessed = bytesLeft; + return 0; } -EXPORT_C_(s32) DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) +EXPORT_C_(s32) +DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) { - // See above. - Dev9Log.WriteLn("Writing DMA8 Mem."); - *bytesProcessed = bytesLeft; - return 0; + // See above. + Dev9Log.WriteLn("Writing DMA8 Mem."); + *bytesProcessed = bytesLeft; + return 0; } -EXPORT_C_(void) DEV9dmaInterrupt(s32 channel) +EXPORT_C_(void) +DEV9dmaInterrupt(s32 channel) { - // See above. + // See above. } //#else -EXPORT_C_(void) DEV9readDMA8Mem(u32 *pMem, int size) +EXPORT_C_(void) +DEV9readDMA8Mem(u32* pMem, int size) { - // You'll want to put your own DMA8 reading code here. - // Time to interact with your fake (or real) hardware. - Dev9Log.WriteLn("Reading DMA8 Mem."); + // You'll want to put your own DMA8 reading code here. + // Time to interact with your fake (or real) hardware. + Dev9Log.WriteLn("Reading DMA8 Mem."); } -EXPORT_C_(void) DEV9writeDMA8Mem(u32* pMem, int size) +EXPORT_C_(void) +DEV9writeDMA8Mem(u32* pMem, int size) { - // See above. - Dev9Log.WriteLn("Writing DMA8 Mem."); + // See above. + Dev9Log.WriteLn("Writing DMA8 Mem."); } //#endif -EXPORT_C_(void) DEV9irqCallback(DEV9callback callback) +EXPORT_C_(void) +DEV9irqCallback(DEV9callback callback) { - // Setting our callback. You will call it with DEV9irq(cycles), - // Where cycles is the number of cycles till the irq is triggered. - DEV9irq = callback; + // Setting our callback. You will call it with DEV9irq(cycles), + // Where cycles is the number of cycles till the irq is triggered. + DEV9irq = callback; } int _DEV9irqHandler(void) { - // And this gets called when the irq is triggered. - return 0; + // And this gets called when the irq is triggered. + return 0; } -EXPORT_C_(DEV9handler) DEV9irqHandler(void) +EXPORT_C_(DEV9handler) +DEV9irqHandler(void) { - // Pass it to pcsx2. - return (DEV9handler)_DEV9irqHandler; + // Pass it to pcsx2. + return (DEV9handler)_DEV9irqHandler; } -EXPORT_C_(void) DEV9setSettingsDir(const char* dir) +EXPORT_C_(void) +DEV9setSettingsDir(const char* dir) { - // Grab the ini directory. + // Grab the ini directory. s_strIniPath = (dir == NULL) ? "inis" : dir; } // extended funcs -EXPORT_C_(s32) DEV9test() +EXPORT_C_(s32) +DEV9test() { - return 0; + return 0; } -EXPORT_C_(s32) DEV9freeze(int mode, freezeData *data) +EXPORT_C_(s32) +DEV9freeze(int mode, freezeData* data) { - // This should store or retrieve any information, for if emulation - // gets suspended, or for savestates. - switch(mode) - { - case FREEZE_LOAD: - // Load previously saved data. - break; - case FREEZE_SAVE: - // Save data. - break; - case FREEZE_SIZE: - // return the size of the data. - break; - } - return 0; + // This should store or retrieve any information, for if emulation + // gets suspended, or for savestates. + switch (mode) { + case FREEZE_LOAD: + // Load previously saved data. + break; + case FREEZE_SAVE: + // Save data. + break; + case FREEZE_SIZE: + // return the size of the data. + break; + } + return 0; } /* For operating systems that need an entry point for a dll/library, here it is. Defined in PS2Eext.h. */ diff --git a/plugins/dev9null/DEV9.h b/plugins/dev9null/DEV9.h index 8b7ec12b43..cddb28c339 100644 --- a/plugins/dev9null/DEV9.h +++ b/plugins/dev9null/DEV9.h @@ -25,8 +25,9 @@ #include "PS2Edefs.h" #include "PS2Eext.h" -typedef struct { - s32 Log; +typedef struct +{ + s32 Log; } Config; extern Config conf; @@ -42,12 +43,12 @@ void LoadConfig(); extern void (*DEV9irq)(int); extern __aligned16 s8 dev9regs[0x10000]; -#define dev9Rs8(mem) dev9regs[(mem) & 0xffff] -#define dev9Rs16(mem) (*(s16*)&dev9regs[(mem) & 0xffff]) -#define dev9Rs32(mem) (*(s32*)&dev9regs[(mem) & 0xffff]) -#define dev9Ru8(mem) (*(u8*) &dev9regs[(mem) & 0xffff]) -#define dev9Ru16(mem) (*(u16*)&dev9regs[(mem) & 0xffff]) -#define dev9Ru32(mem) (*(u32*)&dev9regs[(mem) & 0xffff]) +#define dev9Rs8(mem) dev9regs[(mem)&0xffff] +#define dev9Rs16(mem) (*(s16*)&dev9regs[(mem)&0xffff]) +#define dev9Rs32(mem) (*(s32*)&dev9regs[(mem)&0xffff]) +#define dev9Ru8(mem) (*(u8*)&dev9regs[(mem)&0xffff]) +#define dev9Ru16(mem) (*(u16*)&dev9regs[(mem)&0xffff]) +#define dev9Ru32(mem) (*(u32*)&dev9regs[(mem)&0xffff]) extern void setLoggingState();