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" : "");
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

@ -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__ */

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

@ -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)

View File

@ -32,11 +32,11 @@ const u8 build = 7; // increase that with each version
#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;
@ -49,33 +49,38 @@ 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;
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;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
snprintf( libraryName, 255, "FWnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
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();
@ -84,16 +89,16 @@ EXPORT_C_(s32) FWinit()
memset(phyregs, 0, sizeof(phyregs));
// Initializing our registers.
fwregs = (s8*)calloc(0x10000,1);
if (fwregs == NULL)
{
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);
@ -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.");
@ -133,18 +140,18 @@ void PHYRead()
PHYACC |= phyregs[reg] | (reg << 8);
if(fwRu32(0x8424) & 0x40000000) //RRx interrupt mask
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;
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,30 +183,29 @@ EXPORT_C_(u32) FWread32(u32 addr)
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
if (value & 0x40000000) //Writing to PHY
{
PHYWrite();
}
else if(value & 0x80000000) //Reading from PHY
} else if (value & 0x80000000) //Reading from PHY
{
PHYRead();
}
@ -225,7 +231,7 @@ EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
fwRu32(addr) &= ~0x800000;
break;
//Control Register 2
case 0x1f808410:// fwRu32(addr) = value; break;
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*/;
@ -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

@ -23,9 +23,9 @@
#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)

View File

@ -21,46 +21,45 @@ extern HINSTANCE hInst;
void SaveConfig()
{
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
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);
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
FILE *fp;
void LoadConfig()
{
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
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)
{
CreateDirectory("inis",NULL);
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 ;
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 ;
return;
}

View File

@ -23,33 +23,37 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(GetActiveWindow(), tmp, "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) {
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:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
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,13 +62,14 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
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

@ -28,7 +28,7 @@ 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;
@ -40,7 +40,7 @@ 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,27 +56,31 @@ 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" : "");
sprintf_s(libraryName, "GSnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
#else
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];
@ -89,22 +93,25 @@ 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;
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
GSLog::Close();
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)
// returns the last tag processed (64 bits)
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

@ -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
@ -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();

View File

@ -32,54 +32,51 @@ std::string s_strLogPath("logs");
namespace GSLog
{
FILE *gsLog;
FILE* gsLog;
bool Open()
{
bool Open()
{
bool result = true;
const std::string LogFile(s_strLogPath + "/GSnull.log");
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;
}
WriteLn("GSnull plugin version %d,%d",revision,build);
WriteLn("GSnull plugin version %d,%d", revision, build);
WriteLn("GS init.");
return result;
}
}
void Close()
{
if (gsLog)
{
void Close()
{
if (gsLog) {
fclose(gsLog);
gsLog = NULL;
}
}
}
void Log(char *fmt, ...)
{
void Log(char* fmt, ...)
{
va_list list;
if (!conf.Log || gsLog == NULL) return;
if (!conf.Log || gsLog == NULL)
return;
va_start(list, fmt);
vfprintf(gsLog, fmt, list);
va_end(list);
}
}
void Message(char *fmt, ...)
{
void Message(char* fmt, ...)
{
va_list list;
char msg[512];
@ -87,11 +84,11 @@ namespace GSLog
vsprintf(msg, fmt, list);
va_end(list);
SysMessage("%s\n",msg);
}
SysMessage("%s\n", msg);
}
void Print(const char *fmt, ...)
{
void Print(const char* fmt, ...)
{
va_list list;
char msg[512];
@ -101,11 +98,11 @@ namespace GSLog
Log(msg);
fprintf(stderr, "GSnull:%s", msg);
}
}
void WriteLn(const char *fmt, ...)
{
void WriteLn(const char* fmt, ...)
{
va_list list;
char msg[512];
@ -115,5 +112,5 @@ namespace GSLog
Log("%s\n", msg);
fprintf(stderr, "GSnull:%s\n", msg);
}
}
};

View File

@ -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,87 +26,73 @@ using namespace std;
extern GSVars gs;
PCSX2_ALIGNED16( u8 g_RealGSMem[0x2000] );
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
// FUNCLOG
pathInfo *path = &gs.path[index];
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,
@ -48,20 +47,23 @@ union GIFTag
u64 REGS : 64;
};
void set(const u32 *data)
{
for (int i = 0; i <= 3; i++)
void set(const u32* data)
{
for (int i = 0; i <= 3; i++) {
ai32[i] = data[i];
}
}
GIFTag(u32 *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
@ -77,7 +79,7 @@ typedef struct
u32 adonly;
GIFTag tag;
void setTag(const u32 *data)
void setTag(const u32* data)
{
tag.set(data);
@ -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;
@ -120,10 +123,10 @@ typedef struct
} pathInfo;
extern void _GSgifPacket(pathInfo *path, const u32 *pMem);
extern void _GSgifRegList(pathInfo *path, const u32 *pMem);
template<int index>
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 <int index>
extern void _GSgifTransfer(const u32* pMem, u32 size);
extern GIFRegHandler GIFPackedRegHandlers[];
extern GIFRegHandler GIFRegHandlers[];
#endif // GIFTRANSFER_H_INCLUDED

View File

@ -41,10 +41,9 @@ 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
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

@ -19,6 +19,6 @@
void SaveConf();
void LoadConf();
extern long CFGmessage(char *msg);
extern long CFGmessage(char* msg);
extern void CFGconfigure();
extern void CFGabout();

View File

@ -16,11 +16,11 @@
#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);
@ -33,9 +33,9 @@ int GSOpenWindow(void *pDsp, const char *Title)
return 0;
}
int GSOpenWindow2(void *pDsp, u32 flags)
int GSOpenWindow2(void* pDsp, u32 flags)
{
GtkWidget *widget;
GtkWidget* widget;
if (pDsp != NULL)
win = *(GtkScrolledWindow**)pDsp;
else
@ -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;
@ -77,18 +75,16 @@ void GSProcessMessages()
}
void HandleKeyEvent(keyEvent *ev)
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:
case XK_F9:
GSKeyEvent = ev->key ;
GSKeyEvent = ev->key;
break;
case XK_Escape:
break;
@ -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

@ -20,10 +20,10 @@
#include <X11/Xlib.h>
#include <X11/keysym.h>
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

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

@ -207,7 +207,7 @@ void __gifCall GIFRegHandlerXYOFFSET(const u32* data)
}
// 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;
@ -323,7 +323,7 @@ void __gifCall GIFRegHandlerFBA(const u32* data)
gs.ctxt_regs[i].FBA._u64 = r->_u64;
}
template<u32 i>
template <u32 i>
void __gifCall GIFRegHandlerFRAME(const u32* data)
{
GIFRegFRAME* r = (GIFRegFRAME*)(data);
@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -21,49 +21,47 @@ extern HINSTANCE hInst;
void SaveConfig()
{
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
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);
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig()
{
FILE *fp;
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
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
fp = fopen("inis\\gsnull.ini", "rt"); //check if gsnull.ini really exists
if (!fp)
{
CreateDirectory("inis",NULL);
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0;//default value
SaveConfig();//save and return
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 ;
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;
@ -34,30 +33,30 @@ LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM 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,
WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"PS2EMU_GSNULL", NULL };
RegisterClassEx( &wc );
"PS2EMU_GSNULL", NULL};
RegisterClassEx(&wc);
GShwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "PS2EMU_GSNULL", 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;
}
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)
{
}

View File

@ -18,8 +18,7 @@
#include <windows.h>
#include <windowsx.h>
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);

View File

@ -24,33 +24,37 @@
HINSTANCE hInst;
extern HWND GShwnd;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox((GShwnd!=NULL) ? GShwnd : GetActiveWindow(), tmp, "GS Plugin Msg", 0);
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) {
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:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
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,13 +63,14 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
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,10 +41,9 @@ 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
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

@ -18,7 +18,7 @@
#include <gdk/gdkx.h>
#include "PadLinux.h"
Display *GSdsp;
Display* GSdsp;
int autoRepeatMode;
void _PadUpdate(int pad)
@ -27,13 +27,11 @@ 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);
key = XLookupKeysym((XKeyEvent*)&evt, 0);
// Add code to check if it's one of the keys we configured here on a real pda plugin..
@ -42,7 +40,7 @@ void _PadUpdate(int pad)
break;
case KeyRelease:
key = XLookupKeysym((XKeyEvent *) &evt, 0);
key = XLookupKeysym((XKeyEvent*)&evt, 0);
// Add code to check if it's one of the keys we configured here on a real pda plugin..
@ -61,23 +59,20 @@ void _PadUpdate(int pad)
}
}
s32 _PADOpen(void *pDsp)
s32 _PADOpen(void* pDsp)
{
GtkScrolledWindow *win;
GtkScrolledWindow* win;
win = *(GtkScrolledWindow**) 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

@ -23,7 +23,7 @@
#include <X11/Xlib.h>
void _PadUpdate(int pad);
s32 _PADOpen(void *pDsp);
s32 _PADOpen(void* pDsp);
void _PADClose();
#endif

View File

@ -29,62 +29,70 @@ const u8 build = 1; // increase that with each version
#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;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
snprintf( libraryName, 255, "Padnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
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;
if (padLog == NULL) return;
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_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,10 +108,11 @@ 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;
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
if (padLog) {
@ -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

@ -31,7 +31,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
#define PAD_LOG __Log
@ -42,10 +42,10 @@ typedef struct
} 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();

View File

@ -22,10 +22,9 @@ 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
SaveConfig(); //save and return
return;
}
conf.Log = ini.ReadInt("logging", 0);
@ -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;
@ -52,12 +52,11 @@ 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)
{
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,7 +20,7 @@
#include <windows.h>
void _PadUpdate(int pad);
s32 _PADOpen(void *pDsp);
s32 _PADOpen(void* pDsp);
void _PADClose();
#endif

View File

@ -20,16 +20,18 @@
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) {
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:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
@ -46,13 +48,14 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
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,10 +42,9 @@ 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
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;
}

File diff suppressed because it is too large Load Diff

View File

@ -24,8 +24,7 @@
#include <stdio.h>
#include <string.h>
extern "C"
{
extern "C" {
#define SPU2defs
#include "PS2Edefs.h"
}
@ -39,17 +38,17 @@ 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
{
@ -58,10 +57,10 @@ typedef struct
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 //
@ -135,18 +134,19 @@ void SysMessage(char *fmt, ...);
#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; \
#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)
@ -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;
@ -192,7 +194,7 @@ struct _SPU_VOICE
u16 Sweep1 : 1; // always one
} sweep;
u16 word;
} left, right;
} left, right;
u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc
u16 res0 : 2;
@ -234,7 +236,7 @@ struct ADSRInfoEx
#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
{
@ -275,14 +277,14 @@ struct VOICE_PROCESSED
// Sound Buffers //
///////////////////
u8* pStart; // start and end addresses
u8* pLoop, *pCurr;
u8 *pLoop, *pCurr;
_SPU_VOICE* pvoice;
};
struct ADMA
{
u16 * MemAddr;
u16* MemAddr;
s32 IntPointer;
s32 Index;
s32 AmountLeft;

View File

@ -21,46 +21,45 @@ extern HINSTANCE hInst;
void SaveConfig()
{
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
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);
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
FILE *fp;
void LoadConfig()
{
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
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)
{
CreateDirectory("inis",NULL);
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 ;
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 ;
return;
}

View File

@ -22,33 +22,37 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(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) {
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:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
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,13 +61,14 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
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

@ -18,8 +18,8 @@
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 revision = 0;
@ -43,33 +43,38 @@ 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;
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;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
snprintf( libraryName, 255, "USBnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
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)
EXPORT_C_(void)
USBwrite8(u32 addr, u8 value)
{
switch(addr)
{
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)
EXPORT_C_(void)
USBwrite16(u32 addr, u16 value)
{
switch(addr)
{
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)
EXPORT_C_(void)
USBwrite32(u32 addr, u32 value)
{
switch(addr)
{
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,39 +229,43 @@ 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;
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)
{
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;
@ -34,12 +35,12 @@ 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();

View File

@ -21,46 +21,45 @@ extern HINSTANCE hInst;
void SaveConfig()
{
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
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);
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
FILE *fp;
void LoadConfig()
{
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
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)
{
CreateDirectory("inis",NULL);
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 ;
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 ;
return;
}

View File

@ -22,33 +22,37 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(GetActiveWindow(), tmp, "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) {
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:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
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,13 +61,14 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
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,22 +54,20 @@ 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;
}
conf.Log = Ini.ReadInt("logging",0);
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
}
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

@ -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)

View File

@ -48,7 +48,7 @@ void (*DEV9irq)(int);
__aligned16 s8 dev9regs[0x10000];
string s_strIniPath = "inis";
string s_strLogPath="logs";
string s_strLogPath = "logs";
PluginLog Dev9Log;
Config conf;
@ -60,33 +60,38 @@ 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;
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;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
snprintf( libraryName, 255, "DEV9null Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
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();
@ -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)
{
// 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);
@ -134,30 +143,31 @@ 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
// 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;
// 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);
@ -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)
EXPORT_C_(void)
DEV9write16(u32 addr, u16 value)
{
switch(addr)
{
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;
@ -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();