Merge pull request #1530 from PCSX2/clang-format-plugin-v1

Clang format plugin v1
This commit is contained in:
Gregory Hainaut 2016-08-26 10:04:52 +02:00 committed by GitHub
commit 601c828562
48 changed files with 4028 additions and 3981 deletions

View File

@ -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;
}
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_CDVD;
}
EXPORT_C_(u32) CALLBACK PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
CALLBACK PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(s32) CDVDinit()
EXPORT_C_(s32)
CDVDinit()
{
return 0;
}
EXPORT_C_(s32) CDVDopen(const char* pTitle)
EXPORT_C_(s32)
CDVDopen(const char* pTitle)
{
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 can be NULL (for async modes)
EXPORT_C_(u8*) CDVDgetBuffer()
EXPORT_C_(u8*)
CDVDgetBuffer()
{
return NULL;
}
EXPORT_C_(s32) CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
EXPORT_C_(s32)
CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
{
return -1;
}
EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer)
EXPORT_C_(s32)
CDVDgetTN(cdvdTN* Buffer)
{
return -1;
}
EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer)
EXPORT_C_(s32)
CDVDgetTD(u8 Track, cdvdTD* Buffer)
{
return -1;
}
EXPORT_C_(s32) CDVDgetTOC(void* toc)
EXPORT_C_(s32)
CDVDgetTOC(void* toc)
{
return -1;
}
EXPORT_C_(s32) CDVDgetDiskType()
EXPORT_C_(s32)
CDVDgetDiskType()
{
return CDVD_TYPE_NODISC;
}
EXPORT_C_(s32) CDVDgetTrayStatus()
EXPORT_C_(s32)
CDVDgetTrayStatus()
{
return CDVD_TRAY_CLOSE;
}
EXPORT_C_(s32) CDVDctrlTrayOpen()
EXPORT_C_(s32)
CDVDctrlTrayOpen()
{
return 0;
}
EXPORT_C_(s32) CDVDctrlTrayClose()
EXPORT_C_(s32)
CDVDctrlTrayClose()
{
return 0;
}
EXPORT_C_(void) CDVDconfigure()
EXPORT_C_(void)
CDVDconfigure()
{
SysMessage("Nothing to Configure");
}
EXPORT_C_(void) CDVDabout()
EXPORT_C_(void)
CDVDabout()
{
SysMessage("%s %d.%d", "CDVDnull Driver", revision, build);
}
EXPORT_C_(s32) CDVDtest()
EXPORT_C_(s32)
CDVDtest()
{
return 0;
}

View File

@ -25,24 +25,23 @@ PluginConf Ini;
void setLoggingState()
{
if (conf.Log)
{
if (conf.Log) {
FWLog.WriteToConsole = true;
FWLog.WriteToFile = true;
}
else
{
} else {
FWLog.WriteToConsole = false;
FWLog.WriteToFile = false;
}
}
EXPORT_C_(void) FWabout()
EXPORT_C_(void)
FWabout()
{
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);
@ -52,8 +51,7 @@ EXPORT_C_(void) FWconfigure()
void LoadConfig()
{
string IniPath = s_strIniPath + "/FWnull.ini";
if (!Ini.Open(IniPath, READ_FILE))
{
if (!Ini.Open(IniPath, READ_FILE)) {
FWLog.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
@ -67,8 +65,7 @@ void LoadConfig()
void SaveConfig()
{
string IniPath = s_strIniPath + "/FWnull.ini";
if (!Ini.Open(IniPath, WRITE_FILE))
{
if (!Ini.Open(IniPath, WRITE_FILE)) {
FWLog.WriteLn("Failed to open %s\n", IniPath.c_str());
return;
}
@ -76,4 +73,3 @@ void SaveConfig()
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

View File

@ -49,7 +49,8 @@ void LogInit()
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;
@ -59,23 +60,27 @@ EXPORT_C_(void) FWsetLogDir(const char* dir)
LogInit();
}
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
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;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(s32) FWinit()
EXPORT_C_(s32)
FWinit()
{
LoadConfig();
LogInit();
@ -85,15 +90,15 @@ EXPORT_C_(s32) FWinit()
memset(phyregs, 0, sizeof(phyregs));
// Initializing our registers.
fwregs = (s8*)calloc(0x10000, 1);
if (fwregs == NULL)
{
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);
@ -102,14 +107,16 @@ EXPORT_C_(void) FWshutdown()
FWLog.Close();
}
EXPORT_C_(s32) FWopen(void *pDsp)
EXPORT_C_(s32)
FWopen(void* pDsp)
{
FWLog.WriteLn("Opening FWnull.");
return 0;
}
EXPORT_C_(void) FWclose()
EXPORT_C_(void)
FWclose()
{
// Close the plugin.
FWLog.WriteLn("Closing FWnull.");
@ -139,12 +146,12 @@ void PHYRead()
FWirq();
}
}
EXPORT_C_(u32) FWread32(u32 addr)
EXPORT_C_(u32)
FWread32(u32 addr)
{
u32 ret = 0;
switch (addr)
{
switch (addr) {
//Node ID Register the top part is default, bottom part i got from my ps2
case 0x1f808400:
ret = /*(0x3ff << 22) | 1;*/ 0xffc00001;
@ -176,10 +183,10 @@ EXPORT_C_(u32) FWread32(u32 addr)
return ret;
}
EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
{
switch (addr)
EXPORT_C_(void)
FWwrite32(u32 addr, u32 value)
{
switch (addr) {
// Include other memory locations we want to catch here.
// For example:
//
@ -198,8 +205,7 @@ EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
if (value & 0x40000000) //Writing to PHY
{
PHYWrite();
}
else if(value & 0x80000000) //Reading from PHY
} else if (value & 0x80000000) //Reading from PHY
{
PHYRead();
}
@ -264,24 +270,26 @@ EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
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;
}
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.
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)
{
switch (mode) {
case FREEZE_LOAD:
// Load previously saved data.
break;
@ -295,7 +303,8 @@ EXPORT_C_(s32) FWfreeze(int mode, freezeData *data)
return 0;
}
EXPORT_C_(s32) FWtest()
EXPORT_C_(s32)
FWtest()
{
// 0 if the plugin works, non-0 if it doesn't.
return 0;

View File

@ -28,14 +28,15 @@ void SaveConfig()
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\fwnull.ini");
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
void LoadConfig()
{
FILE* fp;
@ -46,11 +47,11 @@ void LoadConfig() {
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\fwnull.ini");
fp = fopen("inis\\fwnull.ini", "rt"); //check if firewirenull.ini really exists
if (!fp)
{
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0; //default value
@ -61,6 +62,4 @@ void LoadConfig() {
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return;
}

View File

@ -23,7 +23,8 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
@ -33,12 +34,14 @@ void SysMessage(char *fmt, ...) {
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);
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
@ -49,7 +52,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
@ -58,7 +62,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
@ -73,14 +78,16 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
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(),
@ -89,8 +96,8 @@ void CALLBACK FWabout() {
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -56,12 +56,14 @@ extern void SetMultithreaded();
extern void SetFrameSkip(bool skip);
extern void InitPath();
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
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" : "");
@ -71,12 +73,14 @@ EXPORT_C_(char*) PS2EgetLibName()
#endif
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
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];
@ -89,12 +93,14 @@ EXPORT_C_(void) GSprintf(int timeout, char *fmt, ...)
}
// basic funcs
EXPORT_C_(void) GSsetSettingsDir(const char* dir)
EXPORT_C_(void)
GSsetSettingsDir(const char* 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;
@ -104,7 +110,8 @@ EXPORT_C_(void) GSsetLogDir(const char* dir)
GSLog::Open();
}
EXPORT_C_(s32) GSinit()
EXPORT_C_(s32)
GSinit()
{
LoadConfig();
@ -114,14 +121,16 @@ EXPORT_C_(s32) GSinit()
return 0;
}
EXPORT_C_(void) GSshutdown()
EXPORT_C_(void)
GSshutdown()
{
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.");
@ -138,7 +147,8 @@ EXPORT_C_(s32) GSopen(void *pDsp, const char *Title, int multithread)
}
#ifdef USE_GSOPEN2
EXPORT_C_(s32) GSopen2( void *pDsp, u32 flags )
EXPORT_C_(s32)
GSopen2(void* pDsp, u32 flags)
{
GSLog::WriteLn("GS open2.");
@ -154,7 +164,8 @@ EXPORT_C_(s32) GSopen2( void *pDsp, u32 flags )
}
#endif
EXPORT_C_(void) GSclose()
EXPORT_C_(void)
GSclose()
{
GSLog::WriteLn("Closing GSnull.");
@ -163,81 +174,96 @@ EXPORT_C_(void) GSclose()
//GSCloseWindow();
}
EXPORT_C_(void) GSirqCallback(void (*callback)())
EXPORT_C_(void)
GSirqCallback(void (*callback)())
{
GSirq = callback;
}
EXPORT_C_(s32) GSfreeze(int mode, freezeData *data)
EXPORT_C_(s32)
GSfreeze(int mode, freezeData* data)
{
return 0;
}
EXPORT_C_(s32) GStest()
EXPORT_C_(s32)
GStest()
{
GSLog::WriteLn("Testing GSnull.");
return 0;
}
EXPORT_C_(void) GSvsync(int field)
EXPORT_C_(void)
GSvsync(int field)
{
GSProcessMessages();
}
// returns the last tag processed (64 bits)
EXPORT_C_(void) GSgetLastTag(u64* ptag)
EXPORT_C_(void)
GSgetLastTag(u64* ptag)
{
*(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.");
}
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);
}
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.");
}
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);
}
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);
}
// 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);
@ -246,7 +272,8 @@ EXPORT_C_(void) GSsetFrameSkip(int frameskip)
// if start is 1, starts recording spu2 data, else stops
// returns a non zero value if successful
// for now, pData is not used
EXPORT_C_(int) GSsetupRecording(int start, void* pData)
EXPORT_C_(int)
GSsetupRecording(int start, void* pData)
{
if (start)
GSLog::WriteLn("Pretending to record.");
@ -256,15 +283,18 @@ EXPORT_C_(int) GSsetupRecording(int start, void* pData)
return 1;
}
EXPORT_C_(void) GSreset()
EXPORT_C_(void)
GSreset()
{
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)
{
}

View File

@ -42,12 +42,9 @@ namespace GSLog
gsLog = fopen(LogFile.c_str(), "w");
if (gsLog != NULL)
{
if (gsLog != NULL) {
setvbuf(gsLog, NULL, _IONBF, 0);
}
else
{
} else {
Message("Can't create log file %s.", LogFile.c_str());
result = false;
}
@ -60,8 +57,7 @@ namespace GSLog
void Close()
{
if (gsLog)
{
if (gsLog) {
fclose(gsLog);
gsLog = NULL;
}
@ -71,7 +67,8 @@ namespace GSLog
{
va_list list;
if (!conf.Log || gsLog == NULL) return;
if (!conf.Log || gsLog == NULL)
return;
va_start(list, fmt);
vfprintf(gsLog, fmt, list);

View File

@ -28,85 +28,71 @@ extern GSVars gs;
PCSX2_ALIGNED16(u8 g_RealGSMem[0x2000]);
template<int index> void _GSgifTransfer(const u32 *pMem, u32 size)
template <int index>
void _GSgifTransfer(const u32* pMem, u32 size)
{
// FUNCLOG
pathInfo* path = &gs.path[index];
while (size > 0)
{
while (size > 0) {
//GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size);
if (path->nloop == 0)
{
if (path->nloop == 0) {
path->setTag(pMem);
pMem += 4;
size--;
// 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)
{
if (path->nloop > 0) {
gs.q = 1.0f;
if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED))
{
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:
{
} else {
switch (path->mode) {
case GIF_FLG_PACKED: {
// first try a shortcut for a very common case
if (path->adonly && size >= path->nloop)
{
if (path->adonly && size >= path->nloop) {
size -= path->nloop;
do
{
do {
GIFPackedRegHandlerA_D(pMem);
pMem += 4; //sizeof(GIFPackedReg)/4;
}
while(--path->nloop > 0);
} while (--path->nloop > 0);
break;
}
do
{
do {
u32 reg = path->GetReg();
GIFPackedRegHandlers[reg](pMem);
pMem += 4; //sizeof(GIFPackedReg)/4;
size--;
}
while (path->StepReg() && (size > 0));
} while (path->StepReg() && (size > 0));
break;
}
case GIF_FLG_REGLIST:
{
case GIF_FLG_REGLIST: {
//GSLog::Writeln("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
size *= 2;
do
{
do {
GIFRegHandlers[path->GetReg()](pMem);
pMem += 2;
size--;
}
while (path->StepReg() && (size > 0));
} while (path->StepReg() && (size > 0));
if (size & 1) pMem += 2;
if (size & 1)
pMem += 2;
size /= 2;
break;
}
@ -117,8 +103,7 @@ template<int index> void _GSgifTransfer(const u32 *pMem, u32 size)
int len = min(size, path->nloop);
//GSLog::Writeln("GIF_FLG_IMAGE(%d)=%d", gs.imageTransfer, len);
switch (gs.imageTransfer)
{
switch (gs.imageTransfer) {
case 0:
//TransferHostLocal(pMem, len * 4);
break;
@ -164,28 +149,32 @@ template<int index> void _GSgifTransfer(const u32 *pMem, u32 size)
#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);
#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<u32*>(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<u32*>(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<u32*>(pMem), size);
@ -196,4 +185,3 @@ void InitPath()
{
gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = gs.path[3].mode = 0;
}

View File

@ -20,8 +20,7 @@
#include <algorithm>
#include "Registers.h"
enum GIF_FLG
{
enum GIF_FLG {
GIF_FLG_PACKED = 0,
GIF_FLG_REGLIST = 1,
GIF_FLG_IMAGE = 2,
@ -50,8 +49,7 @@ union GIFTag
void set(const u32* data)
{
for (int i = 0; i <= 3; i++)
{
for (int i = 0; i <= 3; i++) {
ai32[i] = data[i];
}
}
@ -61,7 +59,11 @@ union GIFTag
set(data);
}
GIFTag(){ ai64[0] = 0; ai64[1] = 0; }
GIFTag()
{
ai64[0] = 0;
ai64[1] = 0;
}
};
// EE part. Data transfer packet description
@ -88,7 +90,8 @@ typedef struct
// Hmm....
nreg = tag.NREG << 2;
if (nreg == 0) nreg = 64;
if (nreg == 0)
nreg = 64;
regs = tag.REGS;
reg = 0;
//if ((nreg == 4) && (regs == GIF_REG_A_D)) adonly = true;
@ -107,12 +110,12 @@ typedef struct
{
reg += 4;
if (reg == nreg)
{
if (reg == nreg) {
reg = 0;
nloop--;
if (nloop == 0) return false;
if (nloop == 0)
return false;
}
return true;

View File

@ -41,8 +41,7 @@ void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/GSNull.ini");
if (!Ini.Open(iniFile, READ_FILE))
{
if (!Ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
@ -56,8 +55,7 @@ void SaveConfig()
{
const std::string iniFile(s_strIniPath + "/GSNull.ini");
if (!Ini.Open(iniFile, WRITE_FILE))
{
if (!Ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}

View File

@ -52,14 +52,12 @@ void GSCloseWindow()
void GSProcessMessages()
{
if ( GSKeyEvent )
{
if (GSKeyEvent) {
int myKeyEvent = GSKeyEvent;
bool myShift = GSShift;
GSKeyEvent = 0;
switch ( myKeyEvent )
{
switch (myKeyEvent) {
case XK_F5:
OnKeyboardF5(myShift);
break;
@ -79,11 +77,9 @@ void GSProcessMessages()
void HandleKeyEvent(keyEvent* ev)
{
switch(ev->evt)
{
switch (ev->evt) {
case KEYPRESS:
switch(ev->key)
{
switch (ev->key) {
case XK_F5:
case XK_F6:
case XK_F7:
@ -103,8 +99,7 @@ void HandleKeyEvent(keyEvent *ev)
}
break;
case KEYRELEASE:
switch(ev->key)
{
switch (ev->key) {
case XK_Shift_L:
case XK_Shift_R:
GSShift = false;

View File

@ -19,13 +19,14 @@
#include "GS.h"
#include "Config.h"
EXPORT_C_(void) GSconfigure()
EXPORT_C_(void)
GSconfigure()
{
CFGconfigure();
}
EXPORT_C_(void) GSabout()
EXPORT_C_(void)
GSabout()
{
CFGabout();
}

View File

@ -394,14 +394,11 @@ void SetMultithreaded()
// 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)
{
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
{
} else {
GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerSIGNAL;
GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerFINISH;
GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerLABEL;
@ -410,8 +407,7 @@ void SetMultithreaded()
void ResetRegs()
{
for (int i = 0; i < 16; i++)
{
for (int i = 0; i < 16; i++) {
GIFPackedRegHandlers[i] = &GIFPackedRegHandlerNull;
}
@ -431,8 +427,7 @@ void ResetRegs()
GIFPackedRegHandlers[GIF_REG_A_D] = &GIFPackedRegHandlerA_D;
GIFPackedRegHandlers[GIF_REG_NOP] = &GIFPackedRegHandlerNOP;
for (int i = 0; i < 256; i++)
{
for (int i = 0; i < 256; i++) {
GIFRegHandlers[i] = &GIFRegHandlerNull;
}
@ -493,8 +488,7 @@ void ResetRegs()
void SetFrameSkip(bool skip)
{
if (skip)
{
if (skip) {
GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerNOP;
@ -517,9 +511,7 @@ void SetFrameSkip(bool skip)
GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerNOP;
}
else
{
} else {
GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM;
GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA;
GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ;

View File

@ -21,8 +21,7 @@
#define __REGISTERS_H__
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#define GSdefs
#include "PS2Edefs.h"
@ -36,8 +35,7 @@ extern "C"
#pragma pack(push, 1)
enum GIF_REG
{
enum GIF_REG {
GIF_REG_PRIM = 0x00,
GIF_REG_RGBA = 0x01,
GIF_REG_STQ = 0x02,
@ -55,8 +53,7 @@ enum GIF_REG
GIF_REG_NOP = 0x0f,
};
enum GIF_A_D_REG
{
enum GIF_A_D_REG {
GIF_A_D_REG_PRIM = 0x00,
GIF_A_D_REG_RGBAQ = 0x01,
GIF_A_D_REG_ST = 0x02,
@ -208,8 +205,7 @@ extern FnType_GIFRegHandler GIFRegHandlerSIGNAL;
extern FnType_GIFRegHandler GIFRegHandlerFINISH;
extern FnType_GIFRegHandler GIFRegHandlerLABEL;
enum GS_PRIM
{
enum GS_PRIM {
GS_POINTLIST = 0,
GS_LINELIST = 1,
GS_LINESTRIP = 2,
@ -220,8 +216,7 @@ enum GS_PRIM
GS_INVALID = 7,
};
enum GS_PRIM_CLASS
{
enum GS_PRIM_CLASS {
GS_POINT_CLASS = 0,
GS_LINE_CLASS = 1,
GS_TRIANGLE_CLASS = 2,
@ -229,8 +224,7 @@ enum GS_PRIM_CLASS
GS_INVALID_CLASS = 7,
};
enum GS_PSM
{
enum GS_PSM {
PSM_PSMCT32 = 0, // 0000-0000
PSM_PSMCT24 = 1, // 0000-0001
PSM_PSMCT16 = 2, // 0000-0010
@ -246,8 +240,7 @@ enum GS_PSM
PSM_PSMZ16S = 58, // 0011-1010
};
enum GS_TFX
{
enum GS_TFX {
TFX_MODULATE = 0,
TFX_DECAL = 1,
TFX_HIGHLIGHT = 2,
@ -255,24 +248,21 @@ enum GS_TFX
TFX_NONE = 4,
};
enum GS_CLAMP
{
enum GS_CLAMP {
CLAMP_REPEAT = 0,
CLAMP_CLAMP = 1,
CLAMP_REGION_CLAMP = 2,
CLAMP_REGION_REPEAT = 3,
};
enum GS_ZTST
{
enum GS_ZTST {
ZTST_NEVER = 0,
ZTST_ALWAYS = 1,
ZTST_GEQUAL = 2,
ZTST_GREATER = 3,
};
enum GS_ATST
{
enum GS_ATST {
ATST_NEVER = 0,
ATST_ALWAYS = 1,
ATST_LESS = 2,
@ -283,8 +273,7 @@ enum GS_ATST
ATST_NOTEQUAL = 7,
};
enum GS_AFAIL
{
enum GS_AFAIL {
AFAIL_KEEP = 0,
AFAIL_FB_ONLY = 1,
AFAIL_ZB_ONLY = 2,
@ -295,7 +284,8 @@ enum GS_AFAIL
union name \
{ \
u32 _u32; \
struct { \
struct \
{
#define REG64(name) \
union name \
@ -306,35 +296,45 @@ union name \
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 { \
struct \
{
#define REG128(name) \
union name \
{ \
u64 _u64[2]; \
u32 _u32[4]; \
struct { \
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 \
{ \
{
#define REG64_SET(name) \
struct name \
{ \
{
#define REG128_SET(name) \
struct name \
{ \
{
#define REG_SET_END };
#define REG_SET_END \
} \
;
REG64_(GSReg, BGCOLOR)
u32 R : 8;
@ -1174,7 +1174,8 @@ struct GSPrivRegSet
u64 _pad6;
GSRegSYNCV SYNCV;
u64 _pad7;
struct {
struct
{
GSRegDISPFB DISPFB;
u64 _pad1;
GSRegDISPLAY DISPLAY;
@ -1215,4 +1216,3 @@ struct GSPrivRegSet
#pragma pack(pop)
#endif

View File

@ -28,11 +28,11 @@ void SaveConfig()
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\gsnull.ini");
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig()
@ -47,12 +47,12 @@ void LoadConfig()
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\gsnull.ini");
fp = fopen("inis\\gsnull.ini", "rt"); //check if gsnull.ini really exists
if (!fp)
{
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0; //default value
@ -64,6 +64,4 @@ void LoadConfig()
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return;
}

View File

@ -20,8 +20,7 @@ HWND GShwnd = NULL;
LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
switch (msg) {
case WM_CLOSE:
DestroyWindow(hwnd);
break;
@ -44,13 +43,13 @@ int GSOpenWindow(void *pDsp, const char *Title)
GShwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "PS2EMU_GSNULL", Title,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, wc.hInstance, NULL);
if(GShwnd == NULL)
{
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;
}

View File

@ -22,4 +22,3 @@ extern int GSOpenWindow(void *pDsp, const char *Title);
extern void GSCloseWindow();
extern void GSProcessMessages();
extern void HandleKeyEvent(keyEvent* ev);

View File

@ -24,7 +24,8 @@
HINSTANCE hInst;
extern HWND GShwnd;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
@ -34,12 +35,14 @@ void SysMessage(char *fmt, ...) {
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);
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
@ -50,7 +53,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
@ -59,7 +63,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
@ -74,14 +79,18 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
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(),
@ -90,8 +99,8 @@ EXPORT_C_(void) GSabout() {
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -23,12 +23,14 @@
extern std::string s_strIniPath;
PluginConf Ini;
EXPORT_C_(void) PADabout()
EXPORT_C_(void)
PADabout()
{
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);
@ -39,8 +41,7 @@ void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/Padnull.ini");
if (!Ini.Open(iniFile, READ_FILE))
{
if (!Ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
@ -54,8 +55,7 @@ void SaveConfig()
{
const std::string iniFile(s_strIniPath + "/Padnull.ini");
if (!Ini.Open(iniFile, WRITE_FILE))
{
if (!Ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}

View File

@ -27,11 +27,9 @@ void _PadUpdate(int pad)
KeySym key;
// keyboard input
while (XPending(GSdsp) > 0)
{
while (XPending(GSdsp) > 0) {
XNextEvent(GSdsp, &evt);
switch (evt.type)
{
switch (evt.type) {
case KeyPress:
key = XLookupKeysym((XKeyEvent*)&evt, 0);
@ -68,16 +66,13 @@ s32 _PADOpen(void *pDsp)
win = *(GtkScrolledWindow**)pDsp;
if (GTK_IS_WIDGET(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
GSdsp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
}
else
{
} else {
GSdsp = *(Display**)pDsp;
}

View File

@ -37,18 +37,21 @@ Config conf;
keyEvent event;
static keyEvent s_event;
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
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;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
@ -57,7 +60,8 @@ void __Log(const char *fmt, ...)
{
va_list list;
if (padLog == NULL) return;
if (padLog == NULL)
return;
va_start(list, fmt);
vfprintf(padLog, fmt, list);
va_end(list);
@ -69,22 +73,26 @@ void __LogToConsole(const char *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);
}
EXPORT_C_(void) PADsetSettingsDir(const char* dir)
EXPORT_C_(void)
PADsetSettingsDir(const char* 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");
@ -100,7 +108,8 @@ bool OpenLog() {
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;
@ -113,7 +122,8 @@ EXPORT_C_(void) PADsetLogDir(const char* dir)
OpenLog();
}
EXPORT_C_(s32) PADinit(u32 flags)
EXPORT_C_(s32)
PADinit(u32 flags)
{
LoadConfig();
@ -122,31 +132,34 @@ EXPORT_C_(s32) PADinit(u32 flags)
return 0;
}
EXPORT_C_(void) PADshutdown()
EXPORT_C_(void)
PADshutdown()
{
#ifdef PAD_LOG
if (padLog)
{
if (padLog) {
fclose(padLog);
padLog = NULL;
}
#endif
}
EXPORT_C_(s32) PADopen(void *pDsp)
EXPORT_C_(s32)
PADopen(void* pDsp)
{
memset(&event, 0, sizeof(event));
return _PADOpen(pDsp);
}
EXPORT_C_(void) PADclose()
EXPORT_C_(void)
PADclose()
{
_PADClose();
}
// PADkeyEvent is called every vsync (return NULL if no event)
EXPORT_C_(keyEvent*) PADkeyEvent()
EXPORT_C_(keyEvent*)
PADkeyEvent()
{
s_event = event;
@ -156,12 +169,14 @@ EXPORT_C_(keyEvent*) PADkeyEvent()
return &s_event;
}
EXPORT_C_(u8) PADstartPoll(int pad)
EXPORT_C_(u8)
PADstartPoll(int pad)
{
return 0;
}
EXPORT_C_(u8) PADpoll(u8 value)
EXPORT_C_(u8)
PADpoll(u8 value)
{
return 0;
}
@ -173,7 +188,8 @@ 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
@ -181,21 +197,25 @@ EXPORT_C_(u32) PADquery()
return 3;
}
EXPORT_C_(void) PADupdate(int pad)
EXPORT_C_(void)
PADupdate(int 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;
}
EXPORT_C_(s32) PADtest()
EXPORT_C_(s32)
PADtest()
{
return 0;
}

View File

@ -22,8 +22,7 @@ void SaveConfig()
const std::string iniFile = s_strIniPath + "/Padnull.ini";
PluginConf ini;
if (!ini.Open(iniFile, READ_FILE))
{
if (!ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
@ -37,8 +36,7 @@ void LoadConfig()
const std::string iniFile(s_strIniPath + "/Padnull.ini");
PluginConf ini;
if (!ini.Open(iniFile, WRITE_FILE))
{
if (!ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}

View File

@ -21,10 +21,10 @@ HWND GShwnd = NULL;
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
switch (msg) {
case WM_KEYDOWN:
if (lParam & 0x40000000)return TRUE;
if (lParam & 0x40000000)
return TRUE;
event.evt = KEYPRESS;
event.key = wParam;
@ -56,8 +56,7 @@ s32 _PADOpen(void *pDsp)
{
GShwnd = (HWND) * (long*)pDsp;
if (GShwnd != NULL && GSwndProc != NULL)
{
if (GShwnd != NULL && GSwndProc != NULL) {
// revert
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
}
@ -69,8 +68,7 @@ s32 _PADOpen(void *pDsp)
void _PADClose()
{
if (GShwnd != NULL && GSwndProc != NULL)
{
if (GShwnd != NULL && GSwndProc != NULL) {
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
GSwndProc = NULL;
GShwnd = NULL;

View File

@ -20,12 +20,14 @@
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);
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
@ -46,7 +48,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
@ -61,14 +64,18 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
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(),
@ -77,8 +84,8 @@ EXPORT_C_(void) PADabout() {
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -23,14 +23,16 @@ 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();
}
EXPORT_C_(void) SPU2about()
EXPORT_C_(void)
SPU2about()
{
//SysMessage("%s %d.%d", libraryName, version, build);
SysMessage("SPU2null: A simple null plugin.");
@ -40,8 +42,7 @@ void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/Spu2null.ini");
if (!Ini.Open(iniFile, READ_FILE))
{
if (!Ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
@ -55,8 +56,7 @@ void SaveConfig()
{
const std::string iniFile(s_strIniPath + "/Spu2null.ini");
if (!Ini.Open(iniFile, WRITE_FILE))
{
if (!Ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}

View File

@ -76,25 +76,27 @@ const s32 f[5][2] = {
{60, 0},
{115, -52},
{98, -55},
{ 122, -60 }
};
{122, -60}};
u32 RateTable[160];
// channels and voices
VOICE_PROCESSED voices[SPU_NUMBER_VOICES + 1]; // +1 for modulation
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_SPU2;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
return libraryName;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build | (minor << 24);
}
@ -103,22 +105,26 @@ void __Log(char *fmt, ...)
{
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);
}
EXPORT_C_(void) SPU2setSettingsDir(const char* dir)
EXPORT_C_(void)
SPU2setSettingsDir(const char* 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");
@ -135,7 +141,8 @@ bool OpenLog() {
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;
@ -148,21 +155,20 @@ EXPORT_C_(void) SPU2setLogDir(const char* dir)
OpenLog();
}
EXPORT_C_(s32) SPU2init()
EXPORT_C_(s32)
SPU2init()
{
OpenLog();
spu2regs = (s8*)malloc(0x10000);
if (spu2regs == NULL)
{
if (spu2regs == NULL) {
SysMessage("Error allocating Memory\n");
return -1;
}
memset(spu2regs, 0, 0x10000);
spu2mem = (u16*)malloc(0x200000); // 2Mb
if (spu2mem == NULL)
{
if (spu2mem == NULL) {
SysMessage("Error allocating Memory\n");
return -1;
}
@ -177,8 +183,7 @@ EXPORT_C_(s32) SPU2init()
voices[i + 24].memoffset = 0x400;
// init each channel
for (u32 i = 0; i < ArraySize(voices); ++i)
{
for (u32 i = 0; i < ArraySize(voices); ++i) {
voices[i].pLoop = voices[i].pStart = voices[i].pCurr = (u8*)spu2mem;
@ -189,7 +194,8 @@ EXPORT_C_(s32) SPU2init()
return 0;
}
EXPORT_C_(s32) SPU2open(void *pDsp)
EXPORT_C_(s32)
SPU2open(void* pDsp)
{
LoadConfig();
SPUCycles = SPUWorkerCycles = 0;
@ -200,12 +206,14 @@ EXPORT_C_(s32) SPU2open(void *pDsp)
return 0;
}
EXPORT_C_(void) SPU2close()
EXPORT_C_(void)
SPU2close()
{
g_nSpuInit = 0;
}
EXPORT_C_(void) SPU2shutdown()
EXPORT_C_(void)
SPU2shutdown()
{
free(spu2regs);
spu2regs = NULL;
@ -224,33 +232,27 @@ void SPU2Worker();
#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])
{
if (interrupt & (1 << 2)) {
if (SPUCycles - SPUStartCycle[1] >= SPUTargetCycle[1]) {
interrupt &= ~(1 << 2);
irqCallbackDMA7();
}
}
if (interrupt & (1 << 1))
{
if (SPUCycles - SPUStartCycle[0] >= SPUTargetCycle[0])
{
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)
{
while (SPUCycles - SPUWorkerCycles > 0 && CYCLES_PER_MS < SPUCycles - SPUWorkerCycles) {
SPU2Worker();
SPUWorkerCycles += CYCLES_PER_MS;
}
@ -269,17 +271,16 @@ void InitADSR() // INIT ADSR
for (i = 32; i < 160; i++) // we start at pos 32 with the real values... everything before is 0
{
if (r < 0x3FFFFFFF)
{
if (r < 0x3FFFFFFF) {
r += rs;
rd++;
if (rd == 5)
{
if (rd == 5) {
rd = 1;
rs *= 2;
}
}
if (r > 0x3FFFFFFF) r = 0x3FFFFFFF;
if (r > 0x3FFFFFFF)
r = 0x3FFFFFFF;
RateTable[i] = r;
}
@ -289,8 +290,7 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
{
if (pvoice->bStop) // should be stopped:
{
if (pvoice->bIgnoreLoop == 0)
{
if (pvoice->bIgnoreLoop == 0) {
pvoice->ADSRX.EnvelopeVol = 0;
pvoice->bOn = false;
pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr);
@ -302,8 +302,7 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
}
if (pvoice->ADSRX.ReleaseModeExp) // do release
{
switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7)
{
switch ((pvoice->ADSRX.EnvelopeVol >> 28) & 0x7) {
case 0:
pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 0 + 32];
break;
@ -329,14 +328,11 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x18 + 12 + 32];
break;
}
}
else
{
} else {
pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.ReleaseRate ^ 0x1F)) - 0x0C + 32];
}
if (pvoice->ADSRX.EnvelopeVol < 0)
{
if (pvoice->ADSRX.EnvelopeVol < 0) {
pvoice->ADSRX.EnvelopeVol = 0;
pvoice->bOn = false;
pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr);
@ -351,25 +347,20 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21;
pvoice->ADSRX.lVolume = pvoice->ADSRX.EnvelopeVol >> 21;
return pvoice->ADSRX.lVolume;
}
else // not stopped yet?
} else // not stopped yet?
{
if (pvoice->ADSRX.State == 0) // -> attack
{
if (pvoice->ADSRX.AttackModeExp)
{
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
{
} else {
pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.AttackRate ^ 0x7F) - 0x10 + 32];
}
if (pvoice->ADSRX.EnvelopeVol < 0)
{
if (pvoice->ADSRX.EnvelopeVol < 0) {
pvoice->ADSRX.EnvelopeVol = 0x7FFFFFFF;
pvoice->ADSRX.State = 1;
}
@ -380,8 +371,7 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
//--------------------------------------------------//
if (pvoice->ADSRX.State == 1) // -> decay
{
switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7)
{
switch ((pvoice->ADSRX.EnvelopeVol >> 28) & 0x7) {
case 0:
pvoice->ADSRX.EnvelopeVol -= RateTable[(4 * (pvoice->ADSRX.DecayRate ^ 0x1F)) - 0x18 + 0 + 32];
break;
@ -408,9 +398,9 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
break;
}
if (pvoice->ADSRX.EnvelopeVol < 0) pvoice->ADSRX.EnvelopeVol = 0;
if (((pvoice->ADSRX.EnvelopeVol >> 27)&0xF) <= pvoice->ADSRX.SustainLevel)
{
if (pvoice->ADSRX.EnvelopeVol < 0)
pvoice->ADSRX.EnvelopeVol = 0;
if (((pvoice->ADSRX.EnvelopeVol >> 27) & 0xF) <= pvoice->ADSRX.SustainLevel) {
pvoice->ADSRX.State = 2;
}
@ -420,31 +410,22 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
//--------------------------------------------------//
if (pvoice->ADSRX.State == 2) // -> sustain
{
if (pvoice->ADSRX.SustainIncrease)
{
if (pvoice->ADSRX.SustainModeExp)
{
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
{
} else {
pvoice->ADSRX.EnvelopeVol += RateTable[(pvoice->ADSRX.SustainRate ^ 0x7F) - 0x10 + 32];
}
if (pvoice->ADSRX.EnvelopeVol < 0)
{
if (pvoice->ADSRX.EnvelopeVol < 0) {
pvoice->ADSRX.EnvelopeVol = 0x7FFFFFFF;
}
}
else
{
if (pvoice->ADSRX.SustainModeExp)
{
switch ((pvoice->ADSRX.EnvelopeVol >> 28)&0x7)
{
} 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;
@ -470,14 +451,11 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x1B + 12 + 32];
break;
}
}
else
{
} else {
pvoice->ADSRX.EnvelopeVol -= RateTable[((pvoice->ADSRX.SustainRate ^ 0x7F)) - 0x0F + 32];
}
if (pvoice->ADSRX.EnvelopeVol < 0)
{
if (pvoice->ADSRX.EnvelopeVol < 0) {
pvoice->ADSRX.EnvelopeVol = 0;
}
}
@ -497,14 +475,12 @@ void SPU2Worker()
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)
{
if (pChannel->bNew) {
pChannel->StartSound(); // start new sound
dwEndChannel2[ch / 24] &= ~(1 << (ch % 24)); // clear end channel bit
}
if (!pChannel->bOn)
{
if (!pChannel->bOn) {
// fill buffer with empty data
continue;
}
@ -514,10 +490,8 @@ void SPU2Worker()
// loop until 1 ms of data is reached
int ns = 0;
while (ns < NSSIZE)
{
while (pChannel->spos >= 0x10000)
{
while (ns < NSSIZE) {
while (pChannel->spos >= 0x10000) {
if (pChannel->iSBPos == 28) // 28 reached?
{
start = pChannel->pCurr; // set up the current pos
@ -539,13 +513,10 @@ void SPU2Worker()
start += 16;
// some callback and irq active?
if (pChannel->GetCtrl()->irq)
{
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)))
{
if ((pirq > start - 16 && pirq <= start) || ((flags & 1) && (pirq > pChannel->pLoop - 16 && pirq <= pChannel->pLoop))) {
IRQINFO |= 4 << (int)(ch >= 24);
irqCallbackSPU2();
}
@ -565,9 +536,7 @@ void SPU2Worker()
start = (u8*)-1;
pChannel->bStop = true;
pChannel->bIgnoreLoop = false;
}
else
{
} else {
start = pChannel->pLoop;
}
}
@ -585,68 +554,58 @@ void SPU2Worker()
ns++;
pChannel->spos += pChannel->sinc;
}
ENDX:
;
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++)
{
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())
{
if (Adma4.Index == 128 || Adma4.Index == 384) {
if (ADMAS4Write()) {
spu2Ru16(REG_C0_SPUSTAT) &= ~0x80;
irqCallbackDMA4();
}
else MemAddr[0] += 1024;
} else
MemAddr[0] += 1024;
}
if (Adma4.Index == 512)
{
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++)
{
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())
{
if (Adma7.Index == 128 || Adma7.Index == 384) {
if (ADMAS7Write()) {
spu2Ru16(REG_C1_SPUSTAT) &= ~0x80;
irqCallbackDMA7();
}
else MemAddr[1] += 1024;
} 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;
SPU2_LOG("SPU2 readDMA4Mem size %x, addr: %x\n", size, pMem);
for (i = 0;i < size;i++)
{
for (i = 0; i < size; i++) {
*pMem++ = *(u16*)(spu2mem + spuaddr);
if ((spu2Rs16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr)
{
if ((spu2Rs16(REG_C0_CTRL) & 0x40) && C0_IRQA == spuaddr) {
spu2Ru16(SPDIF_OUT) |= 0x4;
C0_SPUADDR_SET(spuaddr);
IRQINFO |= 4;
@ -668,18 +627,17 @@ EXPORT_C_(void) SPU2readDMA4Mem(u16 *pMem, int 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;
SPU2_LOG("SPU2 readDMA7Mem size %x, addr: %x\n", size, pMem);
for (i = 0;i < size;i++)
{
for (i = 0; i < size; i++) {
*pMem++ = *(u16*)(spu2mem + spuaddr);
if ((spu2Rs16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr)
{
if ((spu2Rs16(REG_C1_CTRL) & 0x40) && C1_IRQA == spuaddr) {
spu2Ru16(SPDIF_OUT) |= 0x8;
C1_SPUADDR_SET(spuaddr);
IRQINFO |= 8;
@ -711,8 +669,10 @@ EXPORT_C_(void) SPU2readDMA7Mem(u16* pMem, int size)
int ADMAS4Write()
{
u32 spuaddr;
if (interrupt & 0x2) return 0;
if (Adma4.AmountLeft <= 0) return 1;
if (interrupt & 0x2)
return 0;
if (Adma4.AmountLeft <= 0)
return 1;
spuaddr = C0_SPUADDR;
// SPU2 Deinterleaves the Left and Right Channels
@ -724,8 +684,7 @@ int ADMAS4Write()
C0_SPUADDR_SET(spuaddr);
Adma4.AmountLeft -= 512;
if (Adma4.AmountLeft == 0)
{
if (Adma4.AmountLeft == 0) {
SPUStartCycle[0] = SPUCycles;
SPUTargetCycle[0] = 1; //512*48000;
spu2Ru16(REG_C0_SPUSTAT) &= ~0x80;
@ -737,8 +696,10 @@ int ADMAS4Write()
int ADMAS7Write()
{
u32 spuaddr;
if (interrupt & 0x4) return 0;
if (Adma7.AmountLeft <= 0) return 1;
if (interrupt & 0x4)
return 0;
if (Adma7.AmountLeft <= 0)
return 1;
spuaddr = C1_SPUADDR;
// SPU2 Deinterleaves the Left and Right Channels
@ -750,8 +711,7 @@ int ADMAS7Write()
C1_SPUADDR_SET(spuaddr);
Adma7.AmountLeft -= 512;
if (Adma7.AmountLeft == 0)
{
if (Adma7.AmountLeft == 0) {
SPUStartCycle[1] = SPUCycles;
SPUTargetCycle[1] = 1; //512*48000;
spu2Ru16(REG_C1_SPUSTAT) &= ~0x80;
@ -760,14 +720,14 @@ int ADMAS7Write()
return 0;
}
EXPORT_C_(void) SPU2writeDMA4Mem(u16* pMem, int size)
EXPORT_C_(void)
SPU2writeDMA4Mem(u16* pMem, int size)
{
u32 spuaddr;
SPU2_LOG("SPU2 writeDMA4Mem size %x, addr: %x\n", size, pMem);
if ((spu2Ru16(REG_C0_ADMAS) & 0x1) && (spu2Ru16(REG_C0_CTRL) & 0x30) == 0 && size)
{
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);
@ -782,8 +742,7 @@ EXPORT_C_(void) SPU2writeDMA4Mem(u16* pMem, int size)
spuaddr += size;
C0_SPUADDR_SET(spuaddr);
if ((spu2Ru16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr)
{
if ((spu2Ru16(REG_C0_CTRL) & 0x40) && C0_IRQA == spuaddr) {
spu2Ru16(SPDIF_OUT) |= 0x4;
IRQINFO |= 4;
irqCallbackSPU2();
@ -799,14 +758,14 @@ EXPORT_C_(void) SPU2writeDMA4Mem(u16* pMem, int size)
interrupt |= (1 << 1);
}
EXPORT_C_(void) SPU2writeDMA7Mem(u16* pMem, int size)
EXPORT_C_(void)
SPU2writeDMA7Mem(u16* pMem, int size)
{
u32 spuaddr;
SPU2_LOG("SPU2 writeDMA7Mem size %x, addr: %x\n", size, pMem);
if ((spu2Ru16(REG_C1_ADMAS) & 0x2) && (spu2Ru16(REG_C1_CTRL) & 0x30) == 0 && size)
{
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);
@ -821,8 +780,7 @@ EXPORT_C_(void) SPU2writeDMA7Mem(u16* pMem, int size)
spuaddr += size;
C1_SPUADDR_SET(spuaddr);
if ((spu2Ru16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr)
{
if ((spu2Ru16(REG_C1_CTRL) & 0x40) && C1_IRQA == spuaddr) {
spu2Ru16(SPDIF_OUT) |= 0x8;
IRQINFO |= 8;
irqCallbackSPU2();
@ -838,7 +796,8 @@ EXPORT_C_(void) SPU2writeDMA7Mem(u16* pMem, int size)
interrupt |= (1 << 2);
}
EXPORT_C_(void) SPU2interruptDMA4()
EXPORT_C_(void)
SPU2interruptDMA4()
{
SPU2_LOG("SPU2 interruptDMA4\n");
@ -846,7 +805,8 @@ EXPORT_C_(void) SPU2interruptDMA4()
spu2Ru16(REG_C0_SPUSTAT) |= 0x80;
}
EXPORT_C_(void) SPU2interruptDMA7()
EXPORT_C_(void)
SPU2interruptDMA7()
{
SPU2_LOG("SPU2 interruptDMA7\n");
@ -888,18 +848,16 @@ void FModOn(s32 start, s32 end, u16 val) // FMOD ON PSX COMMAND
{
if (val & 1) // -> fmod on/off
{
if (ch > 0)
{
if (ch > 0) {
}
}
else
{
} else {
// turn fmod off
}
}
}
EXPORT_C_(void) SPU2write(u32 mem, u16 value)
EXPORT_C_(void)
SPU2write(u32 mem, u16 value)
{
u32 spuaddr;
@ -915,19 +873,19 @@ EXPORT_C_(void) SPU2write(u32 mem, u16 value)
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);
if (r >= 0x400)
ch = ((r - 0x400) >> 4) + 24;
else
ch = (r >> 4);
VOICE_PROCESSED* pvoice = &voices[ch];
switch (r&0x0f)
{
switch (r & 0x0f) {
case 0:
case 2:
pvoice->SetVolume(mem & 0x2);
break;
case 4:
{
case 4: {
int NP;
if (value > 0x3fff)
NP = 0x3fff; // get pitch val
@ -937,12 +895,12 @@ EXPORT_C_(void) SPU2write(u32 mem, u16 value)
pvoice->pvoice->pitch = NP;
NP = (44100L * NP) / 4096L; // calc frequency
if (NP < 1) NP = 1; // some security
if (NP < 1)
NP = 1; // some security
pvoice->iActFreq = NP; // store frequency
break;
}
case 6:
{
case 6: {
pvoice->ADSRX.AttackModeExp = (value & 0x8000) ? 1 : 0;
pvoice->ADSRX.AttackRate = ((value >> 8) & 0x007f);
pvoice->ADSRX.DecayRate = (((value >> 4) & 0x000f));
@ -962,12 +920,10 @@ EXPORT_C_(void) SPU2write(u32 mem, u16 value)
}
// more channel info
if ((r >= 0x01c0 && r <= 0x02E0) || (r >= 0x05c0 && r <= 0x06E0))
{
if ((r >= 0x01c0 && r <= 0x02E0) || (r >= 0x05c0 && r <= 0x06E0)) {
s32 ch = 0;
u32 rx = r;
if (rx >= 0x400)
{
if (rx >= 0x400) {
ch = 24;
rx -= 0x400;
}
@ -976,8 +932,7 @@ EXPORT_C_(void) SPU2write(u32 mem, u16 value)
rx -= (ch % 24) * 12;
VOICE_PROCESSED* pvoice = &voices[ch];
switch (rx)
{
switch (rx) {
case 0x1C0:
pvoice->iStartAddr = (((u32)value & 0x3f) << 16) | (pvoice->iStartAddr & 0xFFFF);
pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr);
@ -1010,19 +965,18 @@ EXPORT_C_(void) SPU2write(u32 mem, u16 value)
}
// process non-channel data
switch (mem&0xffff)
{
switch (mem & 0xffff) {
case REG_C0_SPUDATA:
spuaddr = C0_SPUADDR;
spu2mem[spuaddr] = value;
spuaddr++;
if ((spu2Ru16(REG_C0_CTRL)&0x40) && C0_IRQA == spuaddr)
{
if ((spu2Ru16(REG_C0_CTRL) & 0x40) && C0_IRQA == spuaddr) {
spu2Ru16(SPDIF_OUT) |= 0x4;
IRQINFO |= 4;
irqCallbackSPU2();
}
if (spuaddr > 0xFFFFE) spuaddr = 0x2800;
if (spuaddr > 0xFFFFE)
spuaddr = 0x2800;
C0_SPUADDR_SET(spuaddr);
spu2Ru16(REG_C0_SPUSTAT) &= ~0x80;
@ -1032,13 +986,13 @@ EXPORT_C_(void) SPU2write(u32 mem, u16 value)
spuaddr = C1_SPUADDR;
spu2mem[spuaddr] = value;
spuaddr++;
if ((spu2Ru16(REG_C1_CTRL)&0x40) && C1_IRQA == spuaddr)
{
if ((spu2Ru16(REG_C1_CTRL) & 0x40) && C1_IRQA == spuaddr) {
spu2Ru16(SPDIF_OUT) |= 0x8;
IRQINFO |= 8;
irqCallbackSPU2();
}
if (spuaddr > 0xFFFFE) spuaddr = 0x2800;
if (spuaddr > 0xFFFFE)
spuaddr = 0x2800;
C1_SPUADDR_SET(spuaddr);
spu2Ru16(REG_C1_SPUSTAT) &= ~0x80;
@ -1114,7 +1068,8 @@ EXPORT_C_(void) SPU2write(u32 mem, u16 value)
assert(C1_SPUADDR < 0x100000);
}
EXPORT_C_(u16) SPU2read(u32 mem)
EXPORT_C_(u16)
SPU2read(u32 mem)
{
u32 spuaddr;
u16 ret;
@ -1131,8 +1086,7 @@ EXPORT_C_(u16) SPU2read(u32 mem)
VOICE_PROCESSED* pvoice = &voices[ch];
switch (r&0x0f)
{
switch (r & 0x0f) {
case 10:
return (u16)(pvoice->ADSRX.EnvelopeVol >> 16);
}
@ -1143,8 +1097,7 @@ EXPORT_C_(u16) SPU2read(u32 mem)
s32 ch = 0;
u32 rx = r;
if (rx >= 0x400)
{
if (rx >= 0x400) {
ch = 24;
rx -= 0x400;
}
@ -1153,8 +1106,7 @@ EXPORT_C_(u16) SPU2read(u32 mem)
rx -= (ch % 24) * 12;
VOICE_PROCESSED* pvoice = &voices[ch];
switch (rx)
{
switch (rx) {
case 0x1C0:
return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 17) & 0x3F);
case 0x1C2:
@ -1170,13 +1122,13 @@ EXPORT_C_(u16) SPU2read(u32 mem)
}
}
switch (mem&0xffff)
{
switch (mem & 0xffff) {
case REG_C0_SPUDATA:
spuaddr = C0_SPUADDR;
ret = spu2mem[spuaddr];
spuaddr++;
if (spuaddr > 0xfffff) spuaddr = 0;
if (spuaddr > 0xfffff)
spuaddr = 0;
C0_SPUADDR_SET(spuaddr);
break;
@ -1184,7 +1136,8 @@ EXPORT_C_(u16) SPU2read(u32 mem)
spuaddr = C1_SPUADDR;
ret = spu2mem[spuaddr];
spuaddr++;
if (spuaddr > 0xfffff) spuaddr = 0;
if (spuaddr > 0xfffff)
spuaddr = 0;
C1_SPUADDR_SET(spuaddr);
break;
@ -1210,17 +1163,20 @@ EXPORT_C_(u16) SPU2read(u32 mem)
return ret;
}
EXPORT_C_(void) SPU2WriteMemAddr(int core, u32 value)
EXPORT_C_(void)
SPU2WriteMemAddr(int core, u32 value)
{
MemAddr[core] = value;
}
EXPORT_C_(u32) SPU2ReadMemAddr(int core)
EXPORT_C_(u32)
SPU2ReadMemAddr(int 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;
@ -1240,13 +1196,14 @@ void VOICE_PROCESSED::SetVolume(int iProcessRight)
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
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:
} else // no sweep:
{
if (vol & 0x4000) // -> mmm... phase inverted? have to investigate this
vol = 0x3fff - (vol & 0x3fff);
@ -1264,8 +1221,7 @@ void VOICE_PROCESSED::StartSound()
ADSRX.State = 0;
ADSRX.EnvelopeVol = 0;
if (bReverb && GetCtrl()->reverb)
{
if (bReverb && GetCtrl()->reverb) {
// setup the reverb effects
}
@ -1291,7 +1247,8 @@ void VOICE_PROCESSED::Stop()
}
// GUI Routines
EXPORT_C_(s32) SPU2test()
EXPORT_C_(s32)
SPU2test()
{
return 0;
}
@ -1302,35 +1259,25 @@ typedef struct
u8 spu2regs[0x10000];
} SPU2freezeData;
EXPORT_C_(s32) SPU2freeze(int mode, freezeData *data)
EXPORT_C_(s32)
SPU2freeze(int mode, freezeData* data)
{
SPU2freezeData* spud;
if (mode == FREEZE_LOAD)
{
if (mode == FREEZE_LOAD) {
spud = (SPU2freezeData*)data->data;
if (spud->version == 0x11223344)
{
if (spud->version == 0x11223344) {
memcpy(spu2regs, spud->spu2regs, 0x10000);
}
else
{
} else {
printf("SPU2null wrong format\n");
}
}
else
if (mode == FREEZE_SAVE)
{
} else if (mode == FREEZE_SAVE) {
spud = (SPU2freezeData*)data->data;
spud->version = 0x11223344;
memcpy(spud->spu2regs, spu2regs, 0x10000);
}
else
if (mode == FREEZE_SIZE)
{
} else if (mode == FREEZE_SIZE) {
data->size = sizeof(SPU2freezeData);
}
return 0;
}

View File

@ -24,8 +24,7 @@
#include <stdio.h>
#include <string.h>
extern "C"
{
extern "C" {
#define SPU2defs
#include "PS2Edefs.h"
}
@ -143,10 +142,11 @@ void SysMessage(char *fmt, ...);
#define IRQINFO spu2Ru16(REG_IRQINFO)
#define SPU2_GET32BIT(lo, hi) (((u32)(spu2Ru16(hi) & 0x3f) << 16) | (u32)spu2Ru16(lo))
#define SPU2_SET32BIT(value, lo, hi) { \
#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)
@ -178,12 +178,14 @@ struct _SPU_VOICE
{
union
{
struct {
struct
{
u16 Vol : 14;
u16 Inverted : 1;
u16 Sweep0 : 1;
} vol;
struct {
struct
{
u16 Vol : 7;
u16 res1 : 5;
u16 Inverted : 1;

View File

@ -28,14 +28,15 @@ void SaveConfig()
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\spu2null.ini");
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
void LoadConfig()
{
FILE* fp;
@ -46,11 +47,11 @@ void LoadConfig() {
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\spu2null.ini");
fp = fopen("inis\\usbnull.ini", "rt"); //check if usbnull.ini really exists
if (!fp)
{
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0; //default value
@ -61,6 +62,4 @@ void LoadConfig() {
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return;
}

View File

@ -22,7 +22,8 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
@ -32,12 +33,14 @@ void SysMessage(char *fmt, ...) {
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);
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
@ -48,7 +51,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
@ -57,7 +61,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
@ -72,15 +77,16 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
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(),
@ -89,8 +95,8 @@ void CALLBACK SPU2about() {
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -25,24 +25,23 @@ PluginConf Ini;
void setLoggingState()
{
if (conf.Log)
{
if (conf.Log) {
USBLog.WriteToConsole = true;
USBLog.WriteToFile = true;
}
else
{
} else {
USBLog.WriteToConsole = false;
USBLog.WriteToFile = false;
}
}
EXPORT_C_(void) USBabout()
EXPORT_C_(void)
USBabout()
{
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);
@ -52,8 +51,7 @@ EXPORT_C_(void) USBconfigure()
void LoadConfig()
{
string IniPath = s_strIniPath + "/USBnull.ini";
if (!Ini.Open(IniPath, READ_FILE))
{
if (!Ini.Open(IniPath, READ_FILE)) {
USBLog.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
@ -67,8 +65,7 @@ void LoadConfig()
void SaveConfig()
{
string IniPath = s_strIniPath + "/USBnull.ini";
if (!Ini.Open(IniPath, WRITE_FILE))
{
if (!Ini.Open(IniPath, WRITE_FILE)) {
USBLog.WriteLn("Failed to open %s", IniPath.c_str());
return;
}
@ -76,4 +73,3 @@ void SaveConfig()
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

View File

@ -43,7 +43,8 @@ void LogInit()
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;
@ -53,23 +54,27 @@ EXPORT_C_(void) USBsetLogDir(const char* dir)
LogInit();
}
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
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;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(s32) USBinit()
EXPORT_C_(s32)
USBinit()
{
LoadConfig();
LogInit();
@ -79,8 +84,7 @@ EXPORT_C_(s32) USBinit()
// Initialize memory structures here.
usbregs = (s8*)calloc(0x10000, 1);
if (usbregs == NULL)
{
if (usbregs == NULL) {
USBLog.Message("Error allocating memory");
return -1;
}
@ -88,7 +92,8 @@ EXPORT_C_(s32) USBinit()
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.
@ -98,7 +103,8 @@ EXPORT_C_(void) USBshutdown()
usbregs = NULL;
}
EXPORT_C_(s32) USBopen(void *pDsp)
EXPORT_C_(s32)
USBopen(void* pDsp)
{
USBLog.WriteLn("Opening USBnull.");
@ -106,19 +112,20 @@ EXPORT_C_(s32) USBopen(void *pDsp)
return 0;
}
EXPORT_C_(void) USBclose()
EXPORT_C_(void)
USBclose()
{
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;
switch(addr)
{
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 8 bit read at address %lx", addr);
@ -132,12 +139,12 @@ EXPORT_C_(u8) USBread8(u32 addr)
return value;
}
EXPORT_C_(u16) USBread16(u32 addr)
EXPORT_C_(u16)
USBread16(u32 addr)
{
u16 value = 0;
switch(addr)
{
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr);
@ -150,12 +157,12 @@ EXPORT_C_(u16) USBread16(u32 addr)
return value;
}
EXPORT_C_(u32) USBread32(u32 addr)
EXPORT_C_(u32)
USBread32(u32 addr)
{
u32 value = 0;
switch(addr)
{
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr);
@ -168,10 +175,10 @@ EXPORT_C_(u32) USBread32(u32 addr)
return value;
}
EXPORT_C_(void) USBwrite8(u32 addr, u8 value)
{
switch(addr)
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);
@ -183,10 +190,10 @@ EXPORT_C_(void) USBwrite8(u32 addr, u8 value)
}
}
EXPORT_C_(void) USBwrite16(u32 addr, u16 value)
{
switch(addr)
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);
@ -198,10 +205,10 @@ EXPORT_C_(void) USBwrite16(u32 addr, u16 value)
}
}
EXPORT_C_(void) USBwrite32(u32 addr, u32 value)
{
switch(addr)
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);
@ -213,7 +220,8 @@ EXPORT_C_(void) USBwrite32(u32 addr, u32 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
@ -221,26 +229,30 @@ EXPORT_C_(void) USBirqCallback(USBcallback callback)
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;
}
EXPORT_C_(USBhandler) USBirqHandler(void)
EXPORT_C_(USBhandler)
USBirqHandler(void)
{
// 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.");
}
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;
@ -248,12 +260,12 @@ EXPORT_C_(void) USBsetSettingsDir(const char* 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)
{
switch (mode) {
case FREEZE_LOAD:
// Load previously saved data.
break;
@ -272,7 +284,8 @@ 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;

View File

@ -22,7 +22,8 @@
#include "PS2Edefs.h"
#include "PS2Eext.h"
typedef struct {
typedef struct
{
int Log;
} Config;

View File

@ -28,14 +28,15 @@ void SaveConfig()
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\usbnull.ini");
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
void LoadConfig()
{
FILE* fp;
@ -46,11 +47,11 @@ void LoadConfig() {
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\usbnull.ini");
fp = fopen("inis\\usbnull.ini", "rt"); //check if usbnull.ini really exists
if (!fp)
{
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0; //default value
@ -61,6 +62,4 @@ void LoadConfig() {
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return;
}

View File

@ -22,7 +22,8 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
@ -32,12 +33,14 @@ void SysMessage(char *fmt, ...) {
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);
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
@ -48,7 +51,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
@ -57,7 +61,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
@ -72,15 +77,16 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
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(),
@ -89,8 +95,8 @@ void CALLBACK USBabout() {
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -28,24 +28,23 @@ PluginConf Ini;
void setLoggingState()
{
if (conf.Log)
{
if (conf.Log) {
Dev9Log.WriteToConsole = true;
Dev9Log.WriteToFile = true;
}
else
{
} else {
Dev9Log.WriteToConsole = false;
Dev9Log.WriteToFile = false;
}
}
EXPORT_C_(void) DEV9about()
EXPORT_C_(void)
DEV9about()
{
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);
@ -55,8 +54,7 @@ EXPORT_C_(void) DEV9configure()
void LoadConfig()
{
string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, READ_FILE))
{
if (!Ini.Open(IniPath, READ_FILE)) {
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
@ -69,8 +67,7 @@ void LoadConfig()
void SaveConfig()
{
string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, WRITE_FILE))
{
if (!Ini.Open(IniPath, WRITE_FILE)) {
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
return;
}
@ -78,4 +75,3 @@ void SaveConfig()
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

View File

@ -60,7 +60,8 @@ void LogInit()
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;
@ -70,23 +71,27 @@ EXPORT_C_(void) DEV9setLogDir(const char* dir)
LogInit();
}
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
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;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(s32) DEV9init()
EXPORT_C_(s32)
DEV9init()
{
LoadConfig();
setLoggingState();
@ -98,13 +103,15 @@ EXPORT_C_(s32) DEV9init()
return 0;
}
EXPORT_C_(void) DEV9shutdown()
EXPORT_C_(void)
DEV9shutdown()
{
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
@ -112,20 +119,22 @@ EXPORT_C_(s32) DEV9open(void *pDsp)
return 0;
}
EXPORT_C_(void) DEV9close()
EXPORT_C_(void)
DEV9close()
{
Dev9Log.WriteLn("Closing Dev9null.");
// Close files opened.
}
EXPORT_C_(u8) DEV9read8(u32 addr)
EXPORT_C_(u8)
DEV9read8(u32 addr)
{
u8 value = 0;
switch(addr)
{
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.
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);
@ -134,12 +143,12 @@ EXPORT_C_(u8) DEV9read8(u32 addr)
return value;
}
EXPORT_C_(u16) DEV9read16(u32 addr)
EXPORT_C_(u16)
DEV9read16(u32 addr)
{
u16 value = 0;
switch(addr)
{
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
@ -157,7 +166,8 @@ EXPORT_C_(u16) DEV9read16(u32 addr)
// case 0x1000004E: // status
// case 0x1000005C: // status
// case 0x10000064: // if_ctrl
case 0x10000038: /*value = dev9Ru16(addr);*/ break;
case 0x10000038: /*value = dev9Ru16(addr);*/
break;
default:
//value = dev9Ru16(addr);
Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr);
@ -167,13 +177,14 @@ EXPORT_C_(u16) DEV9read16(u32 addr)
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);
@ -183,11 +194,12 @@ EXPORT_C_(u32 ) DEV9read32(u32 addr)
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;
@ -195,13 +207,14 @@ EXPORT_C_(void) DEV9write8(u32 addr, u8 value)
}
}
EXPORT_C_(void) DEV9write16(u32 addr, u16 value)
{
switch(addr)
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;
case 0x10000038: /*dev9Ru16(addr) = value;*/
break;
default:
Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value);
//dev9Ru16(addr) = value;
@ -209,11 +222,12 @@ EXPORT_C_(void) DEV9write16(u32 addr, u16 value)
}
}
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);
//dev9Ru32(addr) = value;
@ -222,7 +236,8 @@ EXPORT_C_(void) DEV9write32(u32 addr, u32 value)
}
//#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.
@ -231,7 +246,8 @@ EXPORT_C_(s32) DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProc
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.");
@ -239,26 +255,30 @@ EXPORT_C_(s32) DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesPro
return 0;
}
EXPORT_C_(void) DEV9dmaInterrupt(s32 channel)
EXPORT_C_(void)
DEV9dmaInterrupt(s32 channel)
{
// 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.");
}
EXPORT_C_(void) DEV9writeDMA8Mem(u32* pMem, int size)
EXPORT_C_(void)
DEV9writeDMA8Mem(u32* pMem, int size)
{
// 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.
@ -271,13 +291,15 @@ int _DEV9irqHandler(void)
return 0;
}
EXPORT_C_(DEV9handler) DEV9irqHandler(void)
EXPORT_C_(DEV9handler)
DEV9irqHandler(void)
{
// 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.
s_strIniPath = (dir == NULL) ? "inis" : dir;
@ -285,17 +307,18 @@ EXPORT_C_(void) DEV9setSettingsDir(const char* dir)
// extended funcs
EXPORT_C_(s32) DEV9test()
EXPORT_C_(s32)
DEV9test()
{
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)
{
switch (mode) {
case FREEZE_LOAD:
// Load previously saved data.
break;

View File

@ -25,7 +25,8 @@
#include "PS2Edefs.h"
#include "PS2Eext.h"
typedef struct {
typedef struct
{
s32 Log;
} Config;