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

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,55 +25,51 @@ PluginConf Ini;
void setLoggingState()
{
if (conf.Log)
{
FWLog.WriteToConsole = true;
FWLog.WriteToFile = true;
}
else
{
FWLog.WriteToConsole = false;
FWLog.WriteToFile = false;
}
if (conf.Log) {
FWLog.WriteToConsole = true;
FWLog.WriteToFile = true;
} else {
FWLog.WriteToConsole = false;
FWLog.WriteToFile = false;
}
}
EXPORT_C_(void) FWabout()
EXPORT_C_(void)
FWabout()
{
SysMessage("FWnull: A simple null plugin.");
SysMessage("FWnull: A simple null plugin.");
}
EXPORT_C_(void) FWconfigure()
EXPORT_C_(void)
FWconfigure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
void LoadConfig()
{
string IniPath = s_strIniPath + "/FWnull.ini";
if (!Ini.Open(IniPath, READ_FILE))
{
FWLog.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
string IniPath = s_strIniPath + "/FWnull.ini";
if (!Ini.Open(IniPath, READ_FILE)) {
FWLog.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
conf.Log = Ini.ReadInt("logging", 0);
setLoggingState();
Ini.Close();
conf.Log = Ini.ReadInt("logging", 0);
setLoggingState();
Ini.Close();
}
void SaveConfig()
{
string IniPath = s_strIniPath + "/FWnull.ini";
if (!Ini.Open(IniPath, WRITE_FILE))
{
FWLog.WriteLn("Failed to open %s\n", IniPath.c_str());
return;
}
string IniPath = s_strIniPath + "/FWnull.ini";
if (!Ini.Open(IniPath, WRITE_FILE)) {
FWLog.WriteLn("Failed to open %s\n", IniPath.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

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

@ -23,20 +23,20 @@ using namespace std;
#include "FW.h"
#include "svnrev.h"
const u8 version = PS2E_FW_VERSION;
const u8 version = PS2E_FW_VERSION;
const u8 revision = 0;
const u8 build = 7; // increase that with each version
const u8 build = 7; // increase that with each version
#ifdef _MSC_VER
#define snprintf sprintf_s
#endif
static char libraryName[256];
string s_strIniPath="inis";
string s_strIniPath = "inis";
string s_strLogPath = "logs";
u8 phyregs[16];
s8 *fwregs;
s8* fwregs;
Config conf;
PluginLog FWLog;
@ -44,259 +44,268 @@ void (*FWirq)();
void LogInit()
{
const std::string LogFile(s_strLogPath + "/FWnull.log");
setLoggingState();
FWLog.Open(LogFile);
const std::string LogFile(s_strLogPath + "/FWnull.log");
setLoggingState();
FWLog.Open(LogFile);
}
EXPORT_C_(void) FWsetLogDir(const char* dir)
EXPORT_C_(void)
FWsetLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs" : dir;
// Reload the log file after updated the path
FWLog.Close();
LogInit();
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
FWLog.Close();
LogInit();
}
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_FW;
return PS2E_LT_FW;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
snprintf( libraryName, 255, "FWnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
snprintf(libraryName, 255, "FWnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version<<16) | (revision<<8) | build;
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(s32) FWinit()
EXPORT_C_(s32)
FWinit()
{
LoadConfig();
LogInit();
FWLog.WriteLn("FWnull plugin version %d,%d", revision, build);
FWLog.WriteLn("Initializing FWnull");
LoadConfig();
LogInit();
FWLog.WriteLn("FWnull plugin version %d,%d", revision, build);
FWLog.WriteLn("Initializing FWnull");
memset(phyregs, 0, sizeof(phyregs));
// Initializing our registers.
fwregs = (s8*)calloc(0x10000,1);
if (fwregs == NULL)
{
FWLog.Message("Error allocating Memory");
return -1;
}
return 0;
memset(phyregs, 0, sizeof(phyregs));
// Initializing our registers.
fwregs = (s8*)calloc(0x10000, 1);
if (fwregs == NULL) {
FWLog.Message("Error allocating Memory");
return -1;
}
return 0;
}
EXPORT_C_(void) FWshutdown()
EXPORT_C_(void)
FWshutdown()
{
// Freeing the registers.
free(fwregs);
fwregs = NULL;
// Freeing the registers.
free(fwregs);
fwregs = NULL;
FWLog.Close();
FWLog.Close();
}
EXPORT_C_(s32) FWopen(void *pDsp)
EXPORT_C_(s32)
FWopen(void* pDsp)
{
FWLog.WriteLn("Opening FWnull.");
FWLog.WriteLn("Opening FWnull.");
return 0;
return 0;
}
EXPORT_C_(void) FWclose()
EXPORT_C_(void)
FWclose()
{
// Close the plugin.
FWLog.WriteLn("Closing FWnull.");
// Close the plugin.
FWLog.WriteLn("Closing FWnull.");
}
void PHYWrite()
{
u8 reg = (PHYACC >> 8) & 0xf;
u8 data = PHYACC & 0xff;
u8 reg = (PHYACC >> 8) & 0xf;
u8 data = PHYACC & 0xff;
phyregs[reg] = data;
phyregs[reg] = data;
PHYACC &= ~0x4000ffff;
PHYACC &= ~0x4000ffff;
}
void PHYRead()
{
u8 reg = (PHYACC >> 24) & 0xf;
u8 reg = (PHYACC >> 24) & 0xf;
PHYACC &= ~0x80000000;
PHYACC &= ~0x80000000;
PHYACC |= phyregs[reg] | (reg << 8);
if(fwRu32(0x8424) & 0x40000000) //RRx interrupt mask
{
fwRu32(0x8420) |= 0x40000000;
FWirq();
}
PHYACC |= phyregs[reg] | (reg << 8);
if (fwRu32(0x8424) & 0x40000000) //RRx interrupt mask
{
fwRu32(0x8420) |= 0x40000000;
FWirq();
}
}
EXPORT_C_(u32) FWread32(u32 addr)
EXPORT_C_(u32)
FWread32(u32 addr)
{
u32 ret = 0;
u32 ret = 0;
switch (addr)
{
//Node ID Register the top part is default, bottom part i got from my ps2
case 0x1f808400:
ret = /*(0x3ff << 22) | 1;*/ 0xffc00001;
break;
// Control Register 2
case 0x1f808410:
ret = fwRu32(addr); //SCLK OK (Needs to be set when FW is "Ready"
break;
//Interrupt 0 Register
case 0x1f808420:
ret = fwRu32(addr);
break;
switch (addr) {
//Node ID Register the top part is default, bottom part i got from my ps2
case 0x1f808400:
ret = /*(0x3ff << 22) | 1;*/ 0xffc00001;
break;
// Control Register 2
case 0x1f808410:
ret = fwRu32(addr); //SCLK OK (Needs to be set when FW is "Ready"
break;
//Interrupt 0 Register
case 0x1f808420:
ret = fwRu32(addr);
break;
//Dunno what this is, but my home console always returns this value 0x10000001
//Seems to be related to the Node ID however (does some sort of compare/check)
case 0x1f80847c:
ret = 0x10000001;
break;
//Dunno what this is, but my home console always returns this value 0x10000001
//Seems to be related to the Node ID however (does some sort of compare/check)
case 0x1f80847c:
ret = 0x10000001;
break;
// Include other relevant 32 bit addresses we need to catch here.
default:
// By default, read fwregs.
ret = fwRu32(addr);
break;
}
// Include other relevant 32 bit addresses we need to catch here.
default:
// By default, read fwregs.
ret = fwRu32(addr);
break;
}
FWLog.WriteLn("FW read mem 0x%x: 0x%x", addr, ret);
FWLog.WriteLn("FW read mem 0x%x: 0x%x", addr, ret);
return ret;
return ret;
}
EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
EXPORT_C_(void)
FWwrite32(u32 addr, u32 value)
{
switch (addr)
{
// Include other memory locations we want to catch here.
// For example:
//
// case 0x1f808400:
// case 0x1f808414:
// case 0x1f808420:
// case 0x1f808428:
// case 0x1f808430:
//
switch (addr) {
// Include other memory locations we want to catch here.
// For example:
//
// case 0x1f808400:
// case 0x1f808414:
// case 0x1f808420:
// case 0x1f808428:
// case 0x1f808430:
//
//PHY access
case 0x1f808414:
//If in read mode (top bit set) we read the PHY register requested then set the RRx interrupt if it's enabled
//Im presuming we send that back to pcsx2 then. This register stores the result, plus whatever was written (minus the read/write flag
fwRu32(addr) = value; //R/W Bit cleaned in underneath function
if(value & 0x40000000) //Writing to PHY
{
PHYWrite();
}
else if(value & 0x80000000) //Reading from PHY
{
PHYRead();
}
break;
//PHY access
case 0x1f808414:
//If in read mode (top bit set) we read the PHY register requested then set the RRx interrupt if it's enabled
//Im presuming we send that back to pcsx2 then. This register stores the result, plus whatever was written (minus the read/write flag
fwRu32(addr) = value; //R/W Bit cleaned in underneath function
if (value & 0x40000000) //Writing to PHY
{
PHYWrite();
} else if (value & 0x80000000) //Reading from PHY
{
PHYRead();
}
break;
//Control Register 0
case 0x1f808408:
//This enables different functions of the link interface
//Just straight writes, should brobably struct these later.
//Default written settings (on unreal tournament) are
//Urcv M = 1
//RSP 0 = 1
//Retlim = 0xF
//Cyc Tmr En = 1
//Bus ID Rst = 1
//Rcv Self ID = 1
fwRu32(addr) = value;
// if((value & 0x800000) && (fwRu32(0x842C) & 0x2))
// {
// fwRu32(0x8428) |= 0x2;
// FWirq();
// }
fwRu32(addr) &= ~0x800000;
break;
//Control Register 2
case 0x1f808410:// fwRu32(addr) = value; break;
//Ignore writes to this for now, apart from 0x2 which is Link Power Enable
//0x8 is SCLK OK (Ready) which should be set for emulation
fwRu32(addr) = 0x8 /*| value & 0x2*/;
break;
//Interrupt 0 Register
case 0x1f808420:
//Interrupt 1 Register
case 0x1f808428:
//Interrupt 2 Register
case 0x1f808430:
//Writes of 1 clear the corresponding bits
fwRu32(addr) &= ~value;
break;
//Interrupt 0 Register Mask
case 0x1f808424:
//Interrupt 1 Register Mask
case 0x1f80842C:
//Interrupt 2 Register Mask
case 0x1f808434:
//These are direct writes (as it's a mask!)
fwRu32(addr) = value;
break;
//DMA Control and Status Register 0
case 0x1f8084B8:
fwRu32(addr) = value;
break;
//DMA Control and Status Register 1
case 0x1f808538:
fwRu32(addr) = value;
break;
default:
// By default, just write it to fwregs.
fwRu32(addr) = value;
break;
}
FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value);
//Control Register 0
case 0x1f808408:
//This enables different functions of the link interface
//Just straight writes, should brobably struct these later.
//Default written settings (on unreal tournament) are
//Urcv M = 1
//RSP 0 = 1
//Retlim = 0xF
//Cyc Tmr En = 1
//Bus ID Rst = 1
//Rcv Self ID = 1
fwRu32(addr) = value;
// if((value & 0x800000) && (fwRu32(0x842C) & 0x2))
// {
// fwRu32(0x8428) |= 0x2;
// FWirq();
// }
fwRu32(addr) &= ~0x800000;
break;
//Control Register 2
case 0x1f808410: // fwRu32(addr) = value; break;
//Ignore writes to this for now, apart from 0x2 which is Link Power Enable
//0x8 is SCLK OK (Ready) which should be set for emulation
fwRu32(addr) = 0x8 /*| value & 0x2*/;
break;
//Interrupt 0 Register
case 0x1f808420:
//Interrupt 1 Register
case 0x1f808428:
//Interrupt 2 Register
case 0x1f808430:
//Writes of 1 clear the corresponding bits
fwRu32(addr) &= ~value;
break;
//Interrupt 0 Register Mask
case 0x1f808424:
//Interrupt 1 Register Mask
case 0x1f80842C:
//Interrupt 2 Register Mask
case 0x1f808434:
//These are direct writes (as it's a mask!)
fwRu32(addr) = value;
break;
//DMA Control and Status Register 0
case 0x1f8084B8:
fwRu32(addr) = value;
break;
//DMA Control and Status Register 1
case 0x1f808538:
fwRu32(addr) = value;
break;
default:
// By default, just write it to fwregs.
fwRu32(addr) = value;
break;
}
FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value);
}
EXPORT_C_(void) FWirqCallback(void (*callback)())
EXPORT_C_(void)
FWirqCallback(void (*callback)())
{
// Register FWirq, so we can trigger an interrupt with it later.
FWirq = callback;
// Register FWirq, so we can trigger an interrupt with it later.
FWirq = callback;
}
EXPORT_C_(void) FWsetSettingsDir(const char* dir)
EXPORT_C_(void)
FWsetSettingsDir(const char* dir)
{
// Find out from pcsx2 where we are supposed to put our ini file.
// Find out from pcsx2 where we are supposed to put our ini file.
s_strIniPath = (dir == NULL) ? "inis" : dir;
}
EXPORT_C_(s32) FWfreeze(int mode, freezeData *data)
EXPORT_C_(s32)
FWfreeze(int mode, freezeData* data)
{
// This should store or retrieve any information, for if emulation
// gets suspended, or for savestates.
switch(mode)
{
case FREEZE_LOAD:
// Load previously saved data.
break;
case FREEZE_SAVE:
// Save data.
break;
case FREEZE_SIZE:
// return the size of the data.
break;
}
return 0;
// This should store or retrieve any information, for if emulation
// gets suspended, or for savestates.
switch (mode) {
case FREEZE_LOAD:
// Load previously saved data.
break;
case FREEZE_SAVE:
// Save data.
break;
case FREEZE_SIZE:
// return the size of the data.
break;
}
return 0;
}
EXPORT_C_(s32) FWtest()
EXPORT_C_(s32)
FWtest()
{
// 0 if the plugin works, non-0 if it doesn't.
return 0;
// 0 if the plugin works, non-0 if it doesn't.
return 0;
}

View File

@ -23,16 +23,16 @@
#include "PS2Eext.h"
// Our main memory storage, and defines for accessing it.
extern s8 *fwregs;
#define fwRs32(mem) (*(s32*)&fwregs[(mem) & 0xffff])
#define fwRu32(mem) (*(u32*)&fwregs[(mem) & 0xffff])
extern s8* fwregs;
#define fwRs32(mem) (*(s32*)&fwregs[(mem)&0xffff])
#define fwRu32(mem) (*(u32*)&fwregs[(mem)&0xffff])
//PHY Access Address for ease of use :P
#define PHYACC fwRu32(0x8414)
typedef struct
{
s32 Log;
s32 Log;
} Config;
extern Config conf;

View File

@ -21,46 +21,45 @@ extern HINSTANCE hInst;
void SaveConfig()
{
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
strcpy(szTemp, "\\inis\\fwnull.ini");
sprintf(szValue,"%u",Conf1->Log);
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\fwnull.ini");
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
FILE *fp;
void LoadConfig()
{
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
strcpy(szTemp, "\\inis\\fwnull.ini");
fp=fopen("inis\\fwnull.ini","rt");//check if firewirenull.ini really exists
if (!fp)
{
CreateDirectory("inis",NULL);
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\fwnull.ini");
fp = fopen("inis\\fwnull.ini", "rt"); //check if firewirenull.ini really exists
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0;//default value
SaveConfig();//save and return
return ;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return ;
conf.Log = 0; //default value
SaveConfig(); //save and return
return;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return;
}

View File

@ -23,74 +23,81 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
va_list list;
char tmp[512];
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_end(list);
MessageBox(GetActiveWindow(), tmp, "FW Plugin Msg", MB_SETFOREGROUND | MB_OK);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(GetActiveWindow(), tmp, "FW Plugin Msg", MB_SETFOREGROUND | MB_OK);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
switch (uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
return TRUE;
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
void CALLBACK FWconfigure() {
void CALLBACK FWconfigure()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
}
void CALLBACK FWabout() {
void CALLBACK FWabout()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
}
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -28,19 +28,19 @@ using namespace std;
#include "GifTransfer.h"
#include "null/GSnull.h"
#ifdef _MSC_VER
# include "svnrev.h"
#include "svnrev.h"
#endif
const unsigned char version = PS2E_GS_VERSION;
const unsigned char version = PS2E_GS_VERSION;
const unsigned char revision = 0;
const unsigned char build = 1; // increase that with each version
const unsigned char build = 1; // increase that with each version
static char libraryName[256];
Config conf;
u32 GSKeyEvent = 0;
bool GSShift = false, GSAlt = false;
string s_strIniPath="inis";
string s_strIniPath = "inis";
extern std::string s_strLogPath;
const char* s_iniFilename = "GSnull.ini";
GSVars gs;
@ -56,215 +56,245 @@ extern void SetMultithreaded();
extern void SetFrameSkip(bool skip);
extern void InitPath();
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_GS;
return PS2E_LT_GS;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
#ifdef _MSC_VER
sprintf_s( libraryName, "GSnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
sprintf_s(libraryName, "GSnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
#else
return "GSnull Driver";
return "GSnull Driver";
#endif
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version<<16) | (revision<<8) | build;
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(void) GSprintf(int timeout, char *fmt, ...)
EXPORT_C_(void)
GSprintf(int timeout, char* fmt, ...)
{
va_list list;
char msg[512];
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
GSLog::Print("GSprintf:%s", msg);
GSLog::Print("GSprintf:%s", msg);
}
// basic funcs
EXPORT_C_(void) GSsetSettingsDir(const char* dir)
EXPORT_C_(void)
GSsetSettingsDir(const char* dir)
{
s_strIniPath = (dir == NULL) ? "inis" : dir;
s_strIniPath = (dir == NULL) ? "inis" : dir;
}
EXPORT_C_(void) GSsetLogDir(const char* dir)
EXPORT_C_(void)
GSsetLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs" : dir;
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
GSLog::Close();
GSLog::Open();
// Reload the log file after updated the path
GSLog::Close();
GSLog::Open();
}
EXPORT_C_(s32) GSinit()
EXPORT_C_(s32)
GSinit()
{
LoadConfig();
LoadConfig();
GSLog::Open();
GSLog::Open();
GSLog::WriteLn("Initializing GSnull.");
return 0;
GSLog::WriteLn("Initializing GSnull.");
return 0;
}
EXPORT_C_(void) GSshutdown()
EXPORT_C_(void)
GSshutdown()
{
GSLog::WriteLn("Shutting down GSnull.");
GSCloseWindow();
GSLog::Close();
GSLog::WriteLn("Shutting down GSnull.");
GSCloseWindow();
GSLog::Close();
}
EXPORT_C_(s32) GSopen(void *pDsp, const char *Title, int multithread)
EXPORT_C_(s32)
GSopen(void* pDsp, const char* Title, int multithread)
{
int err = 0;
GSLog::WriteLn("GS open.");
//assert( GSirq != NULL );
int err = 0;
GSLog::WriteLn("GS open.");
//assert( GSirq != NULL );
err = GSOpenWindow(pDsp, Title);
gs.MultiThreaded = multithread;
err = GSOpenWindow(pDsp, Title);
gs.MultiThreaded = multithread;
ResetRegs();
SetMultithreaded();
InitPath();
GSLog::WriteLn("Opening GSnull.");
return err;
ResetRegs();
SetMultithreaded();
InitPath();
GSLog::WriteLn("Opening GSnull.");
return err;
}
#ifdef USE_GSOPEN2
EXPORT_C_(s32) GSopen2( void *pDsp, u32 flags )
EXPORT_C_(s32)
GSopen2(void* pDsp, u32 flags)
{
GSLog::WriteLn("GS open2.");
GSLog::WriteLn("GS open2.");
GSOpenWindow2(pDsp, flags);
gs.MultiThreaded = true;
gs.MultiThreaded = true;
ResetRegs();
SetMultithreaded();
InitPath();
GSLog::WriteLn("Opening GSnull (2).");
return 0;
ResetRegs();
SetMultithreaded();
InitPath();
GSLog::WriteLn("Opening GSnull (2).");
return 0;
}
#endif
EXPORT_C_(void) GSclose()
EXPORT_C_(void)
GSclose()
{
GSLog::WriteLn("Closing GSnull.");
GSLog::WriteLn("Closing GSnull.");
// Better to only close the window on Shutdown. All the other plugins
// pretty much worked that way, and all old PCSX2 versions expect it as well.
//GSCloseWindow();
// Better to only close the window on Shutdown. All the other plugins
// pretty much worked that way, and all old PCSX2 versions expect it as well.
//GSCloseWindow();
}
EXPORT_C_(void) GSirqCallback(void (*callback)())
EXPORT_C_(void)
GSirqCallback(void (*callback)())
{
GSirq = callback;
GSirq = callback;
}
EXPORT_C_(s32) GSfreeze(int mode, freezeData *data)
EXPORT_C_(s32)
GSfreeze(int mode, freezeData* data)
{
return 0;
return 0;
}
EXPORT_C_(s32) GStest()
EXPORT_C_(s32)
GStest()
{
GSLog::WriteLn("Testing GSnull.");
return 0;
GSLog::WriteLn("Testing GSnull.");
return 0;
}
EXPORT_C_(void) GSvsync(int field)
EXPORT_C_(void)
GSvsync(int field)
{
GSProcessMessages();
GSProcessMessages();
}
// returns the last tag processed (64 bits)
EXPORT_C_(void) GSgetLastTag(u64* ptag)
// returns the last tag processed (64 bits)
EXPORT_C_(void)
GSgetLastTag(u64* ptag)
{
*(u32*)ptag = gs.nPath3Hack;
gs.nPath3Hack = 0;
*(u32*)ptag = gs.nPath3Hack;
gs.nPath3Hack = 0;
}
EXPORT_C_(void) GSgifSoftReset(u32 mask)
EXPORT_C_(void)
GSgifSoftReset(u32 mask)
{
GSLog::WriteLn("Doing a soft reset of the GS plugin.");
GSLog::WriteLn("Doing a soft reset of the GS plugin.");
}
EXPORT_C_(void) GSreadFIFO(u64 *mem)
EXPORT_C_(void)
GSreadFIFO(u64* mem)
{
}
EXPORT_C_(void) GSreadFIFO2(u64 *mem, int qwc)
EXPORT_C_(void)
GSreadFIFO2(u64* mem, int qwc)
{
}
// extended funcs
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
EXPORT_C_(void) GSkeyEvent(keyEvent *ev)
EXPORT_C_(void)
GSkeyEvent(keyEvent* ev)
{
HandleKeyEvent(ev);
HandleKeyEvent(ev);
}
EXPORT_C_(void) GSchangeSaveState(int, const char* filename)
EXPORT_C_(void)
GSchangeSaveState(int, const char* filename)
{
}
EXPORT_C_(void) GSmakeSnapshot(char *path)
EXPORT_C_(void)
GSmakeSnapshot(char* path)
{
GSLog::WriteLn("Taking a snapshot.");
GSLog::WriteLn("Taking a snapshot.");
}
EXPORT_C_(void) GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg)
EXPORT_C_(void)
GSmakeSnapshot2(char* pathname, int* snapdone, int savejpg)
{
GSLog::WriteLn("Taking a snapshot to %s.", pathname);
GSLog::WriteLn("Taking a snapshot to %s.", pathname);
}
EXPORT_C_(void) GSsetBaseMem(void*)
EXPORT_C_(void)
GSsetBaseMem(void*)
{
}
EXPORT_C_(void) GSsetGameCRC(int crc, int gameoptions)
EXPORT_C_(void)
GSsetGameCRC(int crc, int gameoptions)
{
GSLog::WriteLn("Setting the crc to '%x' with 0x%x for options.", crc, gameoptions);
GSLog::WriteLn("Setting the crc to '%x' with 0x%x for options.", crc, gameoptions);
}
// controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done
EXPORT_C_(void) GSsetFrameSkip(int frameskip)
EXPORT_C_(void)
GSsetFrameSkip(int frameskip)
{
SetFrameSkip(frameskip != 0);
GSLog::WriteLn("Frameskip set to %d.", frameskip);
SetFrameSkip(frameskip != 0);
GSLog::WriteLn("Frameskip set to %d.", frameskip);
}
// if start is 1, starts recording spu2 data, else stops
// returns a non zero value if successful
// for now, pData is not used
EXPORT_C_(int) GSsetupRecording(int start, void* pData)
EXPORT_C_(int)
GSsetupRecording(int start, void* pData)
{
if (start)
GSLog::WriteLn("Pretending to record.");
else
GSLog::WriteLn("Pretending to stop recording.");
if (start)
GSLog::WriteLn("Pretending to record.");
else
GSLog::WriteLn("Pretending to stop recording.");
return 1;
return 1;
}
EXPORT_C_(void) GSreset()
EXPORT_C_(void)
GSreset()
{
GSLog::WriteLn("Doing a reset of the GS plugin.");
GSLog::WriteLn("Doing a reset of the GS plugin.");
}
EXPORT_C_(void) GSwriteCSR(u32 value)
EXPORT_C_(void)
GSwriteCSR(u32 value)
{
}
EXPORT_C_(void) GSgetDriverInfo(GSdriverInfo *info)
EXPORT_C_(void)
GSgetDriverInfo(GSdriverInfo* info)
{
}

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
@ -51,22 +51,22 @@ extern const unsigned char build;
typedef struct
{
int Log;
bool path3;
int Log;
bool path3;
} Config;
typedef struct
{
u32 CSRw;
pathInfo path[4];
bool Path3transfer;
float q;
u32 imageTransfer;
int MultiThreaded;
int nPath3Hack;
GIFReg regs;
GIFCTXTReg ctxt_regs[2];
u32 CSRw;
pathInfo path[4];
bool Path3transfer;
float q;
u32 imageTransfer;
int MultiThreaded;
int nPath3Hack;
GIFReg regs;
GIFCTXTReg ctxt_regs[2];
} GSVars;
extern GSVars gs;
@ -79,12 +79,12 @@ extern void (*GSirq)();
namespace GSLog
{
extern bool Open();
extern void Close();
extern void Log(char *fmt, ...);
extern void Message(char *fmt, ...);
extern void Print(const char *fmt, ...);
extern void WriteLn(const char *fmt, ...);
extern bool Open();
extern void Close();
extern void Log(char* fmt, ...);
extern void Message(char* fmt, ...);
extern void Print(const char* fmt, ...);
extern void WriteLn(const char* fmt, ...);
};
extern void SaveConfig();

View File

@ -32,88 +32,85 @@ std::string s_strLogPath("logs");
namespace GSLog
{
FILE *gsLog;
bool Open()
{
bool result = true;
const std::string LogFile(s_strLogPath + "/GSnull.log");
FILE* gsLog;
gsLog = fopen(LogFile.c_str(), "w");
if (gsLog != NULL)
{
setvbuf(gsLog, NULL, _IONBF, 0);
}
else
{
Message("Can't create log file %s.", LogFile.c_str());
result = false;
}
WriteLn("GSnull plugin version %d,%d",revision,build);
WriteLn("GS init.");
return result;
}
void Close()
{
if (gsLog)
{
fclose(gsLog);
gsLog = NULL;
}
}
void Log(char *fmt, ...)
{
va_list list;
bool Open()
{
bool result = true;
if (!conf.Log || gsLog == NULL) return;
const std::string LogFile(s_strLogPath + "/GSnull.log");
va_start(list, fmt);
vfprintf(gsLog, fmt, list);
va_end(list);
}
void Message(char *fmt, ...)
{
va_list list;
char msg[512];
gsLog = fopen(LogFile.c_str(), "w");
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
SysMessage("%s\n",msg);
}
void Print(const char *fmt, ...)
{
va_list list;
char msg[512];
if (gsLog != NULL) {
setvbuf(gsLog, NULL, _IONBF, 0);
} else {
Message("Can't create log file %s.", LogFile.c_str());
result = false;
}
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
WriteLn("GSnull plugin version %d,%d", revision, build);
WriteLn("GS init.");
Log(msg);
fprintf(stderr, "GSnull:%s", msg);
}
void WriteLn(const char *fmt, ...)
{
va_list list;
char msg[512];
return result;
}
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
void Close()
{
if (gsLog) {
fclose(gsLog);
gsLog = NULL;
}
}
Log("%s\n", msg);
fprintf(stderr, "GSnull:%s\n", msg);
}
void Log(char* fmt, ...)
{
va_list list;
if (!conf.Log || gsLog == NULL)
return;
va_start(list, fmt);
vfprintf(gsLog, fmt, list);
va_end(list);
}
void Message(char* fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
SysMessage("%s\n", msg);
}
void Print(const char* fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
Log(msg);
fprintf(stderr, "GSnull:%s", msg);
}
void WriteLn(const char* fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
Log("%s\n", msg);
fprintf(stderr, "GSnull:%s\n", msg);
}
};

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,174 +26,162 @@ 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];
while (size > 0)
{
//GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size);
if (path->nloop == 0)
{
path->setTag(pMem);
pMem += 4;
size--;
pathInfo* path = &gs.path[index];
// eeuser 7.2.2. GIFtag: "... when NLOOP is 0, the GIF does not output anything, and
// values other than the EOP field are disregarded."
if (path->nloop > 0)
{
gs.q = 1.0f;
while (size > 0) {
//GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size);
if (path->nloop == 0) {
path->setTag(pMem);
pMem += 4;
size--;
if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED))
{
u32 tagprim = path->tag.PRIM;
GIFRegHandlerPRIM((u32*)&tagprim);
}
}
}
else
{
switch (path->mode)
{
case GIF_FLG_PACKED:
{
// first try a shortcut for a very common case
// eeuser 7.2.2. GIFtag: "... when NLOOP is 0, the GIF does not output anything, and
// values other than the EOP field are disregarded."
if (path->nloop > 0) {
gs.q = 1.0f;
if (path->adonly && size >= path->nloop)
{
size -= path->nloop;
if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED)) {
u32 tagprim = path->tag.PRIM;
GIFRegHandlerPRIM((u32*)&tagprim);
}
}
} else {
switch (path->mode) {
case GIF_FLG_PACKED: {
// first try a shortcut for a very common case
do
{
GIFPackedRegHandlerA_D(pMem);
if (path->adonly && size >= path->nloop) {
size -= path->nloop;
pMem += 4; //sizeof(GIFPackedReg)/4;
}
while(--path->nloop > 0);
break;
}
do {
GIFPackedRegHandlerA_D(pMem);
do
{
u32 reg = path->GetReg();
GIFPackedRegHandlers[reg](pMem);
pMem += 4; //sizeof(GIFPackedReg)/4;
size--;
}
while (path->StepReg() && (size > 0));
pMem += 4; //sizeof(GIFPackedReg)/4;
} while (--path->nloop > 0);
break;
}
break;
}
do {
u32 reg = path->GetReg();
GIFPackedRegHandlers[reg](pMem);
case GIF_FLG_REGLIST:
{
//GSLog::Writeln("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
pMem += 4; //sizeof(GIFPackedReg)/4;
size--;
} while (path->StepReg() && (size > 0));
size *= 2;
break;
}
do
{
GIFRegHandlers[path->GetReg()](pMem);
case GIF_FLG_REGLIST: {
//GSLog::Writeln("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
pMem += 2;
size--;
}
while (path->StepReg() && (size > 0));
size *= 2;
if (size & 1) pMem += 2;
size /= 2;
break;
}
do {
GIFRegHandlers[path->GetReg()](pMem);
case GIF_FLG_IMAGE: // FROM_VFRAM
case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too.
{
int len = min(size, path->nloop);
//GSLog::Writeln("GIF_FLG_IMAGE(%d)=%d", gs.imageTransfer, len);
pMem += 2;
size--;
} while (path->StepReg() && (size > 0));
switch (gs.imageTransfer)
{
case 0:
//TransferHostLocal(pMem, len * 4);
break;
if (size & 1)
pMem += 2;
size /= 2;
break;
}
case 1:
// This can't happen; downloads can not be started or performed as part of
// a GIFtag operation. They're an entirely separate process that can only be
// done through the ReverseFIFO transfer (aka ReadFIFO). --air
assert(0);
break;
case GIF_FLG_IMAGE: // FROM_VFRAM
case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too.
{
int len = min(size, path->nloop);
//GSLog::Writeln("GIF_FLG_IMAGE(%d)=%d", gs.imageTransfer, len);
case 2:
// //TransferLocalLocal();
break;
switch (gs.imageTransfer) {
case 0:
//TransferHostLocal(pMem, len * 4);
break;
case 3:
//assert(0);
break;
case 1:
// This can't happen; downloads can not be started or performed as part of
// a GIFtag operation. They're an entirely separate process that can only be
// done through the ReverseFIFO transfer (aka ReadFIFO). --air
assert(0);
break;
default:
//assert(0);
break;
}
case 2:
// //TransferLocalLocal();
break;
pMem += len * 4;
case 3:
//assert(0);
break;
path->nloop -= len;
size -= len;
default:
//assert(0);
break;
}
break;
}
pMem += len * 4;
default: // GIF_IMAGE
GSLog::WriteLn("*** WARNING **** Unexpected GIFTag flag.");
assert(0);
path->nloop = 0;
break;
}
}
}
path->nloop -= len;
size -= len;
break;
}
default: // GIF_IMAGE
GSLog::WriteLn("*** WARNING **** Unexpected GIFTag flag.");
assert(0);
path->nloop = 0;
break;
}
}
}
}
#define DO_GIF_TRANSFERS
// Obsolete. Included because it's still in GSdef.
EXPORT_C_(void) GSgifTransfer1(u32 *pMem, u32 addr)
EXPORT_C_(void)
GSgifTransfer1(u32* pMem, u32 addr)
{
#ifdef DO_GIF_TRANSFERS
_GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr) / 16);
_GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr) / 16);
#endif
}
EXPORT_C_(void) GSgifTransfer(const u32 *pMem, u32 size)
EXPORT_C_(void)
GSgifTransfer(const u32* pMem, u32 size)
{
#ifdef DO_GIF_TRANSFERS
_GSgifTransfer<3>(const_cast<u32*>(pMem), size);
_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);
_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);
_GSgifTransfer<2>(const_cast<u32*>(pMem), size);
#endif
}
void InitPath()
{
gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = gs.path[3].mode = 0;
gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = gs.path[3].mode = 0;
}

View File

@ -20,110 +20,113 @@
#include <algorithm>
#include "Registers.h"
enum GIF_FLG
{
GIF_FLG_PACKED = 0,
GIF_FLG_REGLIST = 1,
GIF_FLG_IMAGE = 2,
GIF_FLG_IMAGE2 = 3
enum GIF_FLG {
GIF_FLG_PACKED = 0,
GIF_FLG_REGLIST = 1,
GIF_FLG_IMAGE = 2,
GIF_FLG_IMAGE2 = 3
};
//
// GIFTag
union GIFTag
{
u64 ai64[2];
u32 ai32[4];
u64 ai64[2];
u32 ai32[4];
struct
{
u32 NLOOP : 15;
u32 EOP : 1;
u32 _PAD1 : 16;
u32 _PAD2 : 14;
u32 PRE : 1;
u32 PRIM : 11;
u32 FLG : 2; // enum GIF_FLG
u32 NREG : 4;
u64 REGS : 64;
};
struct
{
u32 NLOOP : 15;
u32 EOP : 1;
u32 _PAD1 : 16;
u32 _PAD2 : 14;
u32 PRE : 1;
u32 PRIM : 11;
u32 FLG : 2; // enum GIF_FLG
u32 NREG : 4;
u64 REGS : 64;
};
void set(const u32 *data)
{
for (int i = 0; i <= 3; i++)
{
ai32[i] = data[i];
}
}
void set(const u32* data)
{
for (int i = 0; i <= 3; i++) {
ai32[i] = data[i];
}
}
GIFTag(u32 *data)
{
set(data);
}
GIFTag(u32* data)
{
set(data);
}
GIFTag(){ ai64[0] = 0; ai64[1] = 0; }
GIFTag()
{
ai64[0] = 0;
ai64[1] = 0;
}
};
// EE part. Data transfer packet description
typedef struct
{
u32 mode;
int reg;
u64 regs;
u32 nloop;
int eop;
int nreg;
u32 adonly;
GIFTag tag;
u32 mode;
int reg;
u64 regs;
u32 nloop;
int eop;
int nreg;
u32 adonly;
GIFTag tag;
void setTag(const u32 *data)
{
tag.set(data);
void setTag(const u32* data)
{
tag.set(data);
nloop = tag.NLOOP;
eop = tag.EOP;
mode = tag.FLG;
//adonly = false;
nloop = tag.NLOOP;
eop = tag.EOP;
mode = tag.FLG;
//adonly = false;
// Hmm....
nreg = tag.NREG << 2;
if (nreg == 0) nreg = 64;
regs = tag.REGS;
reg = 0;
//if ((nreg == 4) && (regs == GIF_REG_A_D)) adonly = true;
// Hmm....
nreg = tag.NREG << 2;
if (nreg == 0)
nreg = 64;
regs = tag.REGS;
reg = 0;
//if ((nreg == 4) && (regs == GIF_REG_A_D)) adonly = true;
// GSLog::Writeln"GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d",
// data[3], data[2], data[1], data[0],
// path->eop, path->nloop, mode, path->nreg, tag.PRE);
}
// GSLog::Writeln"GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d",
// data[3], data[2], data[1], data[0],
// path->eop, path->nloop, mode, path->nreg, tag.PRE);
}
u32 GetReg()
{
return (regs >> reg) & 0xf;
}
u32 GetReg()
{
return (regs >> reg) & 0xf;
}
bool StepReg()
{
reg += 4;
bool StepReg()
{
reg += 4;
if (reg == nreg)
{
reg = 0;
nloop--;
if (reg == nreg) {
reg = 0;
nloop--;
if (nloop == 0) return false;
}
if (nloop == 0)
return false;
}
return true;
}
return true;
}
} pathInfo;
extern void _GSgifPacket(pathInfo *path, const u32 *pMem);
extern void _GSgifRegList(pathInfo *path, const u32 *pMem);
template<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
#endif // GIFTRANSFER_H_INCLUDED

View File

@ -27,41 +27,39 @@ PluginConf Ini;
void CFGabout()
{
SysMessage("GSnull: A simple null plugin.");
SysMessage("GSnull: A simple null plugin.");
}
void CFGconfigure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/GSNull.ini");
if (!Ini.Open(iniFile, READ_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
SaveConfig();//save and return
return;
}
if (!Ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
}
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
}
void SaveConfig()
{
const std::string iniFile(s_strIniPath + "/GSNull.ini");
if (!Ini.Open(iniFile, WRITE_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
return;
}
if (!Ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

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,32 +16,32 @@
#include "GS.h"
#include "GSLinux.h"
Display *display;
Display* display;
int screen;
GtkScrolledWindow *win;
GtkScrolledWindow* win;
int GSOpenWindow(void *pDsp, const char *Title)
int GSOpenWindow(void* pDsp, const char* Title)
{
display = XOpenDisplay(0);
screen = DefaultScreen(display);
display = XOpenDisplay(0);
screen = DefaultScreen(display);
if (pDsp != NULL)
*(Display**)pDsp = display;
else
return -1;
if (pDsp != NULL)
*(Display**)pDsp = display;
else
return -1;
return 0;
return 0;
}
int GSOpenWindow2(void *pDsp, u32 flags)
int GSOpenWindow2(void* pDsp, u32 flags)
{
GtkWidget *widget;
if (pDsp != NULL)
win = *(GtkScrolledWindow**)pDsp;
else
return -1;
GtkWidget* widget;
if (pDsp != NULL)
win = *(GtkScrolledWindow**)pDsp;
else
return -1;
return 0;
return 0;
}
void GSCloseWindow()
@ -52,67 +52,62 @@ void GSCloseWindow()
void GSProcessMessages()
{
if ( GSKeyEvent )
{
int myKeyEvent = GSKeyEvent;
bool myShift = GSShift;
GSKeyEvent = 0;
if (GSKeyEvent) {
int myKeyEvent = GSKeyEvent;
bool myShift = GSShift;
GSKeyEvent = 0;
switch ( myKeyEvent )
{
case XK_F5:
OnKeyboardF5(myShift);
break;
case XK_F6:
OnKeyboardF6(myShift);
break;
case XK_F7:
OnKeyboardF7(myShift);
break;
case XK_F9:
OnKeyboardF9(myShift);
break;
}
}
switch (myKeyEvent) {
case XK_F5:
OnKeyboardF5(myShift);
break;
case XK_F6:
OnKeyboardF6(myShift);
break;
case XK_F7:
OnKeyboardF7(myShift);
break;
case XK_F9:
OnKeyboardF9(myShift);
break;
}
}
}
void HandleKeyEvent(keyEvent *ev)
void HandleKeyEvent(keyEvent* ev)
{
switch(ev->evt)
{
case KEYPRESS:
switch(ev->key)
{
case XK_F5:
case XK_F6:
case XK_F7:
case XK_F9:
GSKeyEvent = ev->key ;
break;
case XK_Escape:
break;
case XK_Shift_L:
case XK_Shift_R:
GSShift = true;
break;
case XK_Alt_L:
case XK_Alt_R:
GSAlt = true;
break;
}
break;
case KEYRELEASE:
switch(ev->key)
{
case XK_Shift_L:
case XK_Shift_R:
GSShift = false;
break;
case XK_Alt_L:
case XK_Alt_R:
GSAlt = false;
break;
}
}
switch (ev->evt) {
case KEYPRESS:
switch (ev->key) {
case XK_F5:
case XK_F6:
case XK_F7:
case XK_F9:
GSKeyEvent = ev->key;
break;
case XK_Escape:
break;
case XK_Shift_L:
case XK_Shift_R:
GSShift = true;
break;
case XK_Alt_L:
case XK_Alt_R:
GSAlt = true;
break;
}
break;
case KEYRELEASE:
switch (ev->key) {
case XK_Shift_L:
case XK_Shift_R:
GSShift = false;
break;
case XK_Alt_L:
case XK_Alt_R:
GSAlt = false;
break;
}
}
}

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();
CFGconfigure();
}
EXPORT_C_(void) GSabout()
EXPORT_C_(void)
GSabout()
{
CFGabout();
CFGabout();
}

View File

@ -15,14 +15,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "GS.h"
#include "Registers.h"
GIFRegHandler GIFPackedRegHandlers[16];
GIFRegHandler GIFRegHandlers[256];
// For now, I'm just rigging this up to store all the register information coming in, without doing
// For now, I'm just rigging this up to store all the register information coming in, without doing
// any of the normal processing.
void __gifCall GIFPackedRegHandlerNull(const u32* data)
@ -33,15 +33,15 @@ void __gifCall GIFPackedRegHandlerNull(const u32* data)
void __gifCall GIFPackedRegHandlerPRIM(const u32* data) { GIFRegHandlerPRIM(data); }
template <u32 i>
void __gifCall GIFPackedRegHandlerTEX0(const u32* data)
{
GIFRegHandlerTEX0<i>(data);
void __gifCall GIFPackedRegHandlerTEX0(const u32* data)
{
GIFRegHandlerTEX0<i>(data);
}
template <u32 i>
void __gifCall GIFPackedRegHandlerCLAMP(const u32* data)
{
GIFRegHandlerCLAMP<i>(data);
void __gifCall GIFPackedRegHandlerCLAMP(const u32* data)
{
GIFRegHandlerCLAMP<i>(data);
}
void __gifCall GIFPackedRegHandlerTEX0_1(const u32* data) { GIFRegHandlerTEX0<0>(data); }
@ -53,27 +53,27 @@ void __gifCall GIFPackedRegHandlerXYZ3(const u32* data) { GIFRegHandlerXYZ3(data
void __gifCall GIFPackedRegHandlerRGBA(const u32* data)
{
GIFPackedRGBA* r = (GIFPackedRGBA*)(data);
gs.regs.RGBAQ.R = r->R;
gs.regs.RGBAQ.G = r->G;
gs.regs.RGBAQ.B = r->B;
gs.regs.RGBAQ.A = r->A;
gs.regs.RGBAQ.Q = gs.q;
GIFPackedRGBA* r = (GIFPackedRGBA*)(data);
gs.regs.RGBAQ.R = r->R;
gs.regs.RGBAQ.G = r->G;
gs.regs.RGBAQ.B = r->B;
gs.regs.RGBAQ.A = r->A;
gs.regs.RGBAQ.Q = gs.q;
}
void __gifCall GIFPackedRegHandlerSTQ(const u32* data)
{
GIFPackedSTQ* r = (GIFPackedSTQ*)(data);
gs.regs.ST.S = r->S;
gs.regs.ST.T = r->T;
gs.q = r->Q;
GIFPackedSTQ* r = (GIFPackedSTQ*)(data);
gs.regs.ST.S = r->S;
gs.regs.ST.T = r->T;
gs.q = r->Q;
}
void __gifCall GIFPackedRegHandlerUV(const u32* data)
{
GIFPackedUV* r = (GIFPackedUV*)(data);
gs.regs.UV.U = r->U;
gs.regs.UV.V = r->V;
GIFPackedUV* r = (GIFPackedUV*)(data);
gs.regs.UV.U = r->U;
gs.regs.UV.V = r->V;
}
void __gifCall KickVertex(bool adc)
@ -82,32 +82,32 @@ void __gifCall KickVertex(bool adc)
void __gifCall GIFPackedRegHandlerXYZF2(const u32* data)
{
GIFPackedXYZF2* r = (GIFPackedXYZF2*)(data);
gs.regs.XYZ.X = r->X;
gs.regs.XYZ.Y = r->Y;
gs.regs.XYZ.Z = r->Z;
gs.regs.FOG.F = r->F;
GIFPackedXYZF2* r = (GIFPackedXYZF2*)(data);
gs.regs.XYZ.X = r->X;
gs.regs.XYZ.Y = r->Y;
gs.regs.XYZ.Z = r->Z;
gs.regs.FOG.F = r->F;
}
void __gifCall GIFPackedRegHandlerXYZ2(const u32* data)
{
GIFPackedXYZ2* r = (GIFPackedXYZ2*)(data);
gs.regs.XYZ.X = r->X;
gs.regs.XYZ.Y = r->Y;
gs.regs.XYZ.Z = r->Z;
GIFPackedXYZ2* r = (GIFPackedXYZ2*)(data);
gs.regs.XYZ.X = r->X;
gs.regs.XYZ.Y = r->Y;
gs.regs.XYZ.Z = r->Z;
}
void __gifCall GIFPackedRegHandlerFOG(const u32* data)
{
GIFPackedFOG* r = (GIFPackedFOG*)(data);
gs.regs.FOG.F = r->F;
GIFPackedFOG* r = (GIFPackedFOG*)(data);
gs.regs.FOG.F = r->F;
}
void __gifCall GIFPackedRegHandlerA_D(const u32* data)
{
GIFPackedA_D* r = (GIFPackedA_D*)(data);
GIFRegHandlers[r->ADDR](data);
GIFPackedA_D* r = (GIFPackedA_D*)(data);
GIFRegHandlers[r->ADDR](data);
}
void __gifCall GIFPackedRegHandlerNOP(const u32* data)
@ -120,64 +120,64 @@ void __gifCall GIFRegHandlerNull(const u32* data)
void __gifCall GIFRegHandlerRGBAQ(const u32* data)
{
GIFRegRGBAQ* r = (GIFRegRGBAQ*)(data);
gs.regs.RGBAQ._u64 = r->_u64;
GIFRegRGBAQ* r = (GIFRegRGBAQ*)(data);
gs.regs.RGBAQ._u64 = r->_u64;
}
void __gifCall GIFRegHandlerST(const u32* data)
{
GIFRegST* r = (GIFRegST*)(data);
gs.regs.ST._u64 = r->_u64;
GIFRegST* r = (GIFRegST*)(data);
gs.regs.ST._u64 = r->_u64;
}
void __gifCall GIFRegHandlerUV(const u32* data)
{
GIFRegUV* r = (GIFRegUV*)(data);
gs.regs.UV._u64 = r->_u64;
GIFRegUV* r = (GIFRegUV*)(data);
gs.regs.UV._u64 = r->_u64;
}
void __gifCall GIFRegHandlerXYZF2(const u32* data)
{
GIFRegXYZF* r = (GIFRegXYZF*)(data);
gs.regs.XYZF._u64 = r->_u64;
GIFRegXYZF* r = (GIFRegXYZF*)(data);
gs.regs.XYZF._u64 = r->_u64;
}
void __gifCall GIFRegHandlerXYZ2(const u32* data)
{
GIFRegXYZ* r = (GIFRegXYZ*)(data);
gs.regs.XYZ._u64 = r->_u64;
GIFRegXYZ* r = (GIFRegXYZ*)(data);
gs.regs.XYZ._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerTEX0(const u32* data)
{
GIFRegTEX0* r = (GIFRegTEX0*)(data);
gs.ctxt_regs[i].TEX0._u64 = r->_u64;
GIFRegTEX0* r = (GIFRegTEX0*)(data);
gs.ctxt_regs[i].TEX0._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerCLAMP(const u32* data)
{
GIFRegCLAMP* r = (GIFRegCLAMP*)(data);
gs.ctxt_regs[i].CLAMP._u64 = r->_u64;
GIFRegCLAMP* r = (GIFRegCLAMP*)(data);
gs.ctxt_regs[i].CLAMP._u64 = r->_u64;
}
void __gifCall GIFRegHandlerFOG(const u32* data)
{
GIFRegFOG* r = (GIFRegFOG*)(data);
gs.regs.FOG.F = r->F;
GIFRegFOG* r = (GIFRegFOG*)(data);
gs.regs.FOG.F = r->F;
}
void __gifCall GIFRegHandlerXYZF3(const u32* data)
{
GIFRegXYZF* r = (GIFRegXYZF*)(data);
gs.regs.XYZF._u64 = r->_u64;
GIFRegXYZF* r = (GIFRegXYZF*)(data);
gs.regs.XYZF._u64 = r->_u64;
}
void __gifCall GIFRegHandlerXYZ3(const u32* data)
{
GIFRegXYZ* r = (GIFRegXYZ*)(data);
gs.regs.XYZ._u64 = r->_u64;
GIFRegXYZ* r = (GIFRegXYZ*)(data);
gs.regs.XYZ._u64 = r->_u64;
}
void __gifCall GIFRegHandlerNOP(const u32* data)
@ -187,360 +187,352 @@ void __gifCall GIFRegHandlerNOP(const u32* data)
template <u32 i>
void __fastcall GIFRegHandlerTEX1(const u32* data)
{
GIFRegTEX1* r = (GIFRegTEX1*)(data);
gs.ctxt_regs[i].TEX1._u64 = r->_u64;
GIFRegTEX1* r = (GIFRegTEX1*)(data);
gs.ctxt_regs[i].TEX1._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerTEX2(const u32* data)
{
GIFRegTEX2* r = (GIFRegTEX2*)(data);
gs.ctxt_regs[i].TEX2._u64 = r->_u64;
GIFRegTEX2* r = (GIFRegTEX2*)(data);
gs.ctxt_regs[i].TEX2._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerXYOFFSET(const u32* data)
{
GIFRegXYOFFSET* r = (GIFRegXYOFFSET*)(data);
gs.ctxt_regs[i].XYOFFSET.OFX = r->OFX;
gs.ctxt_regs[i].XYOFFSET.OFY = r->OFY;
GIFRegXYOFFSET* r = (GIFRegXYOFFSET*)(data);
gs.ctxt_regs[i].XYOFFSET.OFX = r->OFX;
gs.ctxt_regs[i].XYOFFSET.OFY = r->OFY;
}
// Fill out the vertex queue(prim) and the attributes.
void __gifCall GIFRegHandlerPRIM(const u32 *data)
void __gifCall GIFRegHandlerPRIM(const u32* data)
{
GIFRegPRIM* r = (GIFRegPRIM*)(data);
gs.regs.PRIM._u64 = r->_u64;
GIFRegPRIM* r = (GIFRegPRIM*)(data);
gs.regs.PRIM._u64 = r->_u64;
}
// Fill out an alternate set of attributes.
void __gifCall GIFRegHandlerPRMODE(const u32* data)
{
GIFRegPRMODE* r = (GIFRegPRMODE*)(data);
gs.regs.PRMODE._u64 = r->_u64;
GIFRegPRMODE* r = (GIFRegPRMODE*)(data);
gs.regs.PRMODE._u64 = r->_u64;
}
// Switch between the primary set of attributes and the secondary.
void __gifCall GIFRegHandlerPRMODECONT(const u32* data)
{
GIFRegPRMODECONT* r = (GIFRegPRMODECONT*)(data);
gs.regs.PRMODECONT._u64 = r->_u64;
GIFRegPRMODECONT* r = (GIFRegPRMODECONT*)(data);
gs.regs.PRMODECONT._u64 = r->_u64;
}
void __gifCall GIFRegHandlerTEXCLUT(const u32* data)
{
GIFRegTEXCLUT* r = (GIFRegTEXCLUT*)(data);
gs.regs.TEXCLUT._u64 = r->_u64;
GIFRegTEXCLUT* r = (GIFRegTEXCLUT*)(data);
gs.regs.TEXCLUT._u64 = r->_u64;
}
void __gifCall GIFRegHandlerSCANMSK(const u32* data)
{
GIFRegSCANMSK* r = (GIFRegSCANMSK*)(data);
gs.regs.SCANMSK._u64 = r->_u64;
GIFRegSCANMSK* r = (GIFRegSCANMSK*)(data);
gs.regs.SCANMSK._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerMIPTBP1(const u32* data)
{
GIFRegMIPTBP1* r = (GIFRegMIPTBP1*)(data);
gs.ctxt_regs[i].MIPTBP1._u64 = r->_u64;
GIFRegMIPTBP1* r = (GIFRegMIPTBP1*)(data);
gs.ctxt_regs[i].MIPTBP1._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerMIPTBP2(const u32* data)
{
GIFRegMIPTBP2* r = (GIFRegMIPTBP2*)(data);
gs.ctxt_regs[i].MIPTBP2._u64 = r->_u64;
GIFRegMIPTBP2* r = (GIFRegMIPTBP2*)(data);
gs.ctxt_regs[i].MIPTBP2._u64 = r->_u64;
}
void __gifCall GIFRegHandlerTEXA(const u32* data)
{
GIFRegTEXA* r = (GIFRegTEXA*)(data);
gs.regs.TEXA._u64 = r->_u64;
GIFRegTEXA* r = (GIFRegTEXA*)(data);
gs.regs.TEXA._u64 = r->_u64;
}
void __gifCall GIFRegHandlerFOGCOL(const u32* data)
{
GIFRegFOGCOL* r = (GIFRegFOGCOL*)(data);
gs.regs.FOGCOL._u64 = r->_u64;
GIFRegFOGCOL* r = (GIFRegFOGCOL*)(data);
gs.regs.FOGCOL._u64 = r->_u64;
}
void __gifCall GIFRegHandlerTEXFLUSH(const u32* data)
{
GIFRegTEXFLUSH* r = (GIFRegTEXFLUSH*)(data);
gs.regs.TEXFLUSH._u64 = r->_u64;
GIFRegTEXFLUSH* r = (GIFRegTEXFLUSH*)(data);
gs.regs.TEXFLUSH._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerSCISSOR(const u32* data)
{
GIFRegSCISSOR* r = (GIFRegSCISSOR*)(data);
gs.ctxt_regs[i].SCISSOR._u64 = r->_u64;
GIFRegSCISSOR* r = (GIFRegSCISSOR*)(data);
gs.ctxt_regs[i].SCISSOR._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerALPHA(const u32* data)
{
GIFRegALPHA* r = (GIFRegALPHA*)(data);
gs.ctxt_regs[i].ALPHA._u64 = r->_u64;
GIFRegALPHA* r = (GIFRegALPHA*)(data);
gs.ctxt_regs[i].ALPHA._u64 = r->_u64;
}
void __gifCall GIFRegHandlerDIMX(const u32* data)
{
GIFRegDIMX* r = (GIFRegDIMX*)(data);
gs.regs.DIMX._u64 = r->_u64;
GIFRegDIMX* r = (GIFRegDIMX*)(data);
gs.regs.DIMX._u64 = r->_u64;
}
void __gifCall GIFRegHandlerDTHE(const u32* data)
{
GIFRegDTHE* r = (GIFRegDTHE*)(data);
gs.regs.DTHE._u64 = r->_u64;
GIFRegDTHE* r = (GIFRegDTHE*)(data);
gs.regs.DTHE._u64 = r->_u64;
}
void __gifCall GIFRegHandlerCOLCLAMP(const u32* data)
{
GIFRegCOLCLAMP* r = (GIFRegCOLCLAMP*)(data);
gs.regs.COLCLAMP._u64 = r->_u64;
GIFRegCOLCLAMP* r = (GIFRegCOLCLAMP*)(data);
gs.regs.COLCLAMP._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerTEST(const u32* data)
{
GIFRegTEST* r = (GIFRegTEST*)(data);
gs.ctxt_regs[i].TEST._u64 = r->_u64;
GIFRegTEST* r = (GIFRegTEST*)(data);
gs.ctxt_regs[i].TEST._u64 = r->_u64;
}
void __gifCall GIFRegHandlerPABE(const u32* data)
{
GIFRegPABE* r = (GIFRegPABE*)(data);
gs.regs.PABE._u64 = r->_u64;
GIFRegPABE* r = (GIFRegPABE*)(data);
gs.regs.PABE._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerFBA(const u32* data)
{
GIFRegFBA* r = (GIFRegFBA*)(data);
gs.ctxt_regs[i].FBA._u64 = r->_u64;
GIFRegFBA* r = (GIFRegFBA*)(data);
gs.ctxt_regs[i].FBA._u64 = r->_u64;
}
template<u32 i>
template <u32 i>
void __gifCall GIFRegHandlerFRAME(const u32* data)
{
GIFRegFRAME* r = (GIFRegFRAME*)(data);
gs.ctxt_regs[i].FRAME._u64 = r->_u64;
GIFRegFRAME* r = (GIFRegFRAME*)(data);
gs.ctxt_regs[i].FRAME._u64 = r->_u64;
}
template <u32 i>
void __gifCall GIFRegHandlerZBUF(const u32* data)
{
GIFRegZBUF* r = (GIFRegZBUF*)(data);
gs.ctxt_regs[i].ZBUF._u64 = r->_u64;
GIFRegZBUF* r = (GIFRegZBUF*)(data);
gs.ctxt_regs[i].ZBUF._u64 = r->_u64;
}
void __gifCall GIFRegHandlerBITBLTBUF(const u32* data)
{
GIFRegBITBLTBUF* r = (GIFRegBITBLTBUF*)(data);
gs.regs.BITBLTBUF._u64 = r->_u64;
GIFRegBITBLTBUF* r = (GIFRegBITBLTBUF*)(data);
gs.regs.BITBLTBUF._u64 = r->_u64;
}
void __gifCall GIFRegHandlerTRXPOS(const u32* data)
{
GIFRegTRXPOS* r = (GIFRegTRXPOS*)(data);
gs.regs.TRXPOS._u64 = r->_u64;
GIFRegTRXPOS* r = (GIFRegTRXPOS*)(data);
gs.regs.TRXPOS._u64 = r->_u64;
}
void __gifCall GIFRegHandlerTRXREG(const u32* data)
{
GIFRegTRXREG* r = (GIFRegTRXREG*)(data);
gs.regs.TRXREG._u64 = r->_u64;
GIFRegTRXREG* r = (GIFRegTRXREG*)(data);
gs.regs.TRXREG._u64 = r->_u64;
}
void __gifCall GIFRegHandlerTRXDIR(const u32* data)
{
GIFRegTRXDIR* r = (GIFRegTRXDIR*)(data);
gs.regs.TRXDIR._u64 = r->_u64;
GIFRegTRXDIR* r = (GIFRegTRXDIR*)(data);
gs.regs.TRXDIR._u64 = r->_u64;
}
void __gifCall GIFRegHandlerHWREG(const u32* data)
{
GIFRegHWREG* r = (GIFRegHWREG*)(data);
gs.regs.HWREG._u64 = r->_u64;
GIFRegHWREG* r = (GIFRegHWREG*)(data);
gs.regs.HWREG._u64 = r->_u64;
}
void __gifCall GIFRegHandlerSIGNAL(const u32* data)
{
GIFRegSIGNAL* r = (GIFRegSIGNAL*)(data);
gs.regs.SIGNAL._u64 = r->_u64;
GIFRegSIGNAL* r = (GIFRegSIGNAL*)(data);
gs.regs.SIGNAL._u64 = r->_u64;
}
void __gifCall GIFRegHandlerFINISH(const u32* data)
{
GIFRegFINISH* r = (GIFRegFINISH*)(data);
gs.regs.FINISH._u64 = r->_u64;
GIFRegFINISH* r = (GIFRegFINISH*)(data);
gs.regs.FINISH._u64 = r->_u64;
}
void __gifCall GIFRegHandlerLABEL(const u32* data)
{
GIFRegLABEL* r = (GIFRegLABEL*)(data);
gs.regs.LABEL._u64 = r->_u64;
GIFRegLABEL* r = (GIFRegLABEL*)(data);
gs.regs.LABEL._u64 = r->_u64;
}
void SetMultithreaded()
{
// Some older versions of PCSX2 didn't properly set the irq callback to NULL
// in multithreaded mode (possibly because ZeroGS itself would assert in such
// cases), and didn't bind them to a dummy callback either. PCSX2 handles all
// IRQs internally when multithreaded anyway -- so let's ignore them here:
// Some older versions of PCSX2 didn't properly set the irq callback to NULL
// in multithreaded mode (possibly because ZeroGS itself would assert in such
// cases), and didn't bind them to a dummy callback either. PCSX2 handles all
// IRQs internally when multithreaded anyway -- so let's ignore them here:
if (gs.MultiThreaded)
{
GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerNull;
GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerNull;
GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerNull;
}
else
{
GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerSIGNAL;
GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerFINISH;
GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerLABEL;
}
if (gs.MultiThreaded) {
GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerNull;
GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerNull;
GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerNull;
} else {
GIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GIFRegHandlerSIGNAL;
GIFRegHandlers[GIF_A_D_REG_FINISH] = &GIFRegHandlerFINISH;
GIFRegHandlers[GIF_A_D_REG_LABEL] = &GIFRegHandlerLABEL;
}
}
void ResetRegs()
{
for (int i = 0; i < 16; i++)
{
GIFPackedRegHandlers[i] = &GIFPackedRegHandlerNull;
}
for (int i = 0; i < 16; i++) {
GIFPackedRegHandlers[i] = &GIFPackedRegHandlerNull;
}
GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM;
GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA;
GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ;
GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV;
GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2;
GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2;
GIFPackedRegHandlers[GIF_REG_TEX0_1] = &GIFPackedRegHandlerTEX0<0>;
GIFPackedRegHandlers[GIF_REG_TEX0_2] = &GIFPackedRegHandlerTEX0<1>;
GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>;
GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>;
GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG;
GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3;
GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3;
GIFPackedRegHandlers[GIF_REG_A_D] = &GIFPackedRegHandlerA_D;
GIFPackedRegHandlers[GIF_REG_NOP] = &GIFPackedRegHandlerNOP;
for (int i = 0; i < 256; i++)
{
GIFRegHandlers[i] = &GIFRegHandlerNull;
}
GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM;
GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ;
GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST;
GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV;
GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2;
GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2;
GIFRegHandlers[GIF_A_D_REG_TEX0_1] = &GIFRegHandlerTEX0<0>;
GIFRegHandlers[GIF_A_D_REG_TEX0_2] = &GIFRegHandlerTEX0<1>;
GIFRegHandlers[GIF_A_D_REG_CLAMP_1] = &GIFRegHandlerCLAMP<0>;
GIFRegHandlers[GIF_A_D_REG_CLAMP_2] = &GIFRegHandlerCLAMP<1>;
GIFRegHandlers[GIF_A_D_REG_FOG] = &GIFRegHandlerFOG;
GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3;
GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3;
GIFRegHandlers[GIF_A_D_REG_NOP] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_TEX1_1] = &GIFRegHandlerTEX1<0>;
GIFRegHandlers[GIF_A_D_REG_TEX1_2] = &GIFRegHandlerTEX1<1>;
GIFRegHandlers[GIF_A_D_REG_TEX2_1] = &GIFRegHandlerTEX2<0>;
GIFRegHandlers[GIF_A_D_REG_TEX2_2] = &GIFRegHandlerTEX2<1>;
GIFRegHandlers[GIF_A_D_REG_XYOFFSET_1] = &GIFRegHandlerXYOFFSET<0>;
GIFRegHandlers[GIF_A_D_REG_XYOFFSET_2] = &GIFRegHandlerXYOFFSET<1>;
GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT;
GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE;
GIFRegHandlers[GIF_A_D_REG_TEXCLUT] = &GIFRegHandlerTEXCLUT;
GIFRegHandlers[GIF_A_D_REG_SCANMSK] = &GIFRegHandlerSCANMSK;
GIFRegHandlers[GIF_A_D_REG_MIPTBP1_1] = &GIFRegHandlerMIPTBP1<0>;
GIFRegHandlers[GIF_A_D_REG_MIPTBP1_2] = &GIFRegHandlerMIPTBP1<1>;
GIFRegHandlers[GIF_A_D_REG_MIPTBP2_1] = &GIFRegHandlerMIPTBP2<0>;
GIFRegHandlers[GIF_A_D_REG_MIPTBP2_2] = &GIFRegHandlerMIPTBP2<1>;
GIFRegHandlers[GIF_A_D_REG_TEXA] = &GIFRegHandlerTEXA;
GIFRegHandlers[GIF_A_D_REG_FOGCOL] = &GIFRegHandlerFOGCOL;
GIFRegHandlers[GIF_A_D_REG_TEXFLUSH] = &GIFRegHandlerTEXFLUSH;
GIFRegHandlers[GIF_A_D_REG_SCISSOR_1] = &GIFRegHandlerSCISSOR<0>;
GIFRegHandlers[GIF_A_D_REG_SCISSOR_2] = &GIFRegHandlerSCISSOR<1>;
GIFRegHandlers[GIF_A_D_REG_ALPHA_1] = &GIFRegHandlerALPHA<0>;
GIFRegHandlers[GIF_A_D_REG_ALPHA_2] = &GIFRegHandlerALPHA<1>;
GIFRegHandlers[GIF_A_D_REG_DIMX] = &GIFRegHandlerDIMX;
GIFRegHandlers[GIF_A_D_REG_DTHE] = &GIFRegHandlerDTHE;
GIFRegHandlers[GIF_A_D_REG_COLCLAMP] = &GIFRegHandlerCOLCLAMP;
GIFRegHandlers[GIF_A_D_REG_TEST_1] = &GIFRegHandlerTEST<0>;
GIFRegHandlers[GIF_A_D_REG_TEST_2] = &GIFRegHandlerTEST<1>;
GIFRegHandlers[GIF_A_D_REG_PABE] = &GIFRegHandlerPABE;
GIFRegHandlers[GIF_A_D_REG_FBA_1] = &GIFRegHandlerFBA<0>;
GIFRegHandlers[GIF_A_D_REG_FBA_2] = &GIFRegHandlerFBA<1>;
GIFRegHandlers[GIF_A_D_REG_FRAME_1] = &GIFRegHandlerFRAME<0>;
GIFRegHandlers[GIF_A_D_REG_FRAME_2] = &GIFRegHandlerFRAME<1>;
GIFRegHandlers[GIF_A_D_REG_ZBUF_1] = &GIFRegHandlerZBUF<0>;
GIFRegHandlers[GIF_A_D_REG_ZBUF_2] = &GIFRegHandlerZBUF<1>;
GIFRegHandlers[GIF_A_D_REG_BITBLTBUF] = &GIFRegHandlerBITBLTBUF;
GIFRegHandlers[GIF_A_D_REG_TRXPOS] = &GIFRegHandlerTRXPOS;
GIFRegHandlers[GIF_A_D_REG_TRXREG] = &GIFRegHandlerTRXREG;
GIFRegHandlers[GIF_A_D_REG_TRXDIR] = &GIFRegHandlerTRXDIR;
GIFRegHandlers[GIF_A_D_REG_HWREG] = &GIFRegHandlerHWREG;
SetMultithreaded();
GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM;
GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA;
GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ;
GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV;
GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2;
GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2;
GIFPackedRegHandlers[GIF_REG_TEX0_1] = &GIFPackedRegHandlerTEX0<0>;
GIFPackedRegHandlers[GIF_REG_TEX0_2] = &GIFPackedRegHandlerTEX0<1>;
GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>;
GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>;
GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG;
GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3;
GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3;
GIFPackedRegHandlers[GIF_REG_A_D] = &GIFPackedRegHandlerA_D;
GIFPackedRegHandlers[GIF_REG_NOP] = &GIFPackedRegHandlerNOP;
for (int i = 0; i < 256; i++) {
GIFRegHandlers[i] = &GIFRegHandlerNull;
}
GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM;
GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ;
GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST;
GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV;
GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2;
GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2;
GIFRegHandlers[GIF_A_D_REG_TEX0_1] = &GIFRegHandlerTEX0<0>;
GIFRegHandlers[GIF_A_D_REG_TEX0_2] = &GIFRegHandlerTEX0<1>;
GIFRegHandlers[GIF_A_D_REG_CLAMP_1] = &GIFRegHandlerCLAMP<0>;
GIFRegHandlers[GIF_A_D_REG_CLAMP_2] = &GIFRegHandlerCLAMP<1>;
GIFRegHandlers[GIF_A_D_REG_FOG] = &GIFRegHandlerFOG;
GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3;
GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3;
GIFRegHandlers[GIF_A_D_REG_NOP] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_TEX1_1] = &GIFRegHandlerTEX1<0>;
GIFRegHandlers[GIF_A_D_REG_TEX1_2] = &GIFRegHandlerTEX1<1>;
GIFRegHandlers[GIF_A_D_REG_TEX2_1] = &GIFRegHandlerTEX2<0>;
GIFRegHandlers[GIF_A_D_REG_TEX2_2] = &GIFRegHandlerTEX2<1>;
GIFRegHandlers[GIF_A_D_REG_XYOFFSET_1] = &GIFRegHandlerXYOFFSET<0>;
GIFRegHandlers[GIF_A_D_REG_XYOFFSET_2] = &GIFRegHandlerXYOFFSET<1>;
GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT;
GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE;
GIFRegHandlers[GIF_A_D_REG_TEXCLUT] = &GIFRegHandlerTEXCLUT;
GIFRegHandlers[GIF_A_D_REG_SCANMSK] = &GIFRegHandlerSCANMSK;
GIFRegHandlers[GIF_A_D_REG_MIPTBP1_1] = &GIFRegHandlerMIPTBP1<0>;
GIFRegHandlers[GIF_A_D_REG_MIPTBP1_2] = &GIFRegHandlerMIPTBP1<1>;
GIFRegHandlers[GIF_A_D_REG_MIPTBP2_1] = &GIFRegHandlerMIPTBP2<0>;
GIFRegHandlers[GIF_A_D_REG_MIPTBP2_2] = &GIFRegHandlerMIPTBP2<1>;
GIFRegHandlers[GIF_A_D_REG_TEXA] = &GIFRegHandlerTEXA;
GIFRegHandlers[GIF_A_D_REG_FOGCOL] = &GIFRegHandlerFOGCOL;
GIFRegHandlers[GIF_A_D_REG_TEXFLUSH] = &GIFRegHandlerTEXFLUSH;
GIFRegHandlers[GIF_A_D_REG_SCISSOR_1] = &GIFRegHandlerSCISSOR<0>;
GIFRegHandlers[GIF_A_D_REG_SCISSOR_2] = &GIFRegHandlerSCISSOR<1>;
GIFRegHandlers[GIF_A_D_REG_ALPHA_1] = &GIFRegHandlerALPHA<0>;
GIFRegHandlers[GIF_A_D_REG_ALPHA_2] = &GIFRegHandlerALPHA<1>;
GIFRegHandlers[GIF_A_D_REG_DIMX] = &GIFRegHandlerDIMX;
GIFRegHandlers[GIF_A_D_REG_DTHE] = &GIFRegHandlerDTHE;
GIFRegHandlers[GIF_A_D_REG_COLCLAMP] = &GIFRegHandlerCOLCLAMP;
GIFRegHandlers[GIF_A_D_REG_TEST_1] = &GIFRegHandlerTEST<0>;
GIFRegHandlers[GIF_A_D_REG_TEST_2] = &GIFRegHandlerTEST<1>;
GIFRegHandlers[GIF_A_D_REG_PABE] = &GIFRegHandlerPABE;
GIFRegHandlers[GIF_A_D_REG_FBA_1] = &GIFRegHandlerFBA<0>;
GIFRegHandlers[GIF_A_D_REG_FBA_2] = &GIFRegHandlerFBA<1>;
GIFRegHandlers[GIF_A_D_REG_FRAME_1] = &GIFRegHandlerFRAME<0>;
GIFRegHandlers[GIF_A_D_REG_FRAME_2] = &GIFRegHandlerFRAME<1>;
GIFRegHandlers[GIF_A_D_REG_ZBUF_1] = &GIFRegHandlerZBUF<0>;
GIFRegHandlers[GIF_A_D_REG_ZBUF_2] = &GIFRegHandlerZBUF<1>;
GIFRegHandlers[GIF_A_D_REG_BITBLTBUF] = &GIFRegHandlerBITBLTBUF;
GIFRegHandlers[GIF_A_D_REG_TRXPOS] = &GIFRegHandlerTRXPOS;
GIFRegHandlers[GIF_A_D_REG_TRXREG] = &GIFRegHandlerTRXREG;
GIFRegHandlers[GIF_A_D_REG_TRXDIR] = &GIFRegHandlerTRXDIR;
GIFRegHandlers[GIF_A_D_REG_HWREG] = &GIFRegHandlerHWREG;
SetMultithreaded();
}
void SetFrameSkip(bool skip)
{
if (skip)
{
GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerNOP;
if (skip) {
GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerNOP;
GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerNOP;
}
else
{
GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM;
GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA;
GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ;
GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV;
GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2;
GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2;
GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>;
GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>;
GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG;
GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3;
GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3;
GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerNOP;
GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerNOP;
} else {
GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM;
GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA;
GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ;
GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV;
GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2;
GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2;
GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>;
GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>;
GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG;
GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3;
GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3;
GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM;
GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ;
GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST;
GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV;
GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2;
GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2;
GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3;
GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3;
GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT;
GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE;
}
GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM;
GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ;
GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST;
GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV;
GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2;
GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2;
GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3;
GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3;
GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT;
GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE;
}
}

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;
char szIniFile[256], szValue[256];
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
strcpy(szTemp, "\\inis\\gsnull.ini");
sprintf(szValue,"%u",Conf1->Log);
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\gsnull.ini");
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig()
void LoadConfig()
{
FILE *fp;
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
strcpy(szTemp, "\\inis\\gsnull.ini");
fp=fopen("inis\\gsnull.ini","rt");//check if gsnull.ini really exists
if (!fp)
{
CreateDirectory("inis",NULL);
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\gsnull.ini");
fp = fopen("inis\\gsnull.ini", "rt"); //check if gsnull.ini really exists
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0;//default value
SaveConfig();//save and return
return ;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return ;
conf.Log = 0; //default value
SaveConfig(); //save and return
return;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return;
}

View File

@ -20,44 +20,43 @@ HWND GShwnd = NULL;
LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
switch (msg) {
case WM_CLOSE:
DestroyWindow(hwnd);
break;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int GSOpenWindow(void *pDsp, const char *Title)
int GSOpenWindow(void* pDsp, const char* Title)
{
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"PS2EMU_GSNULL", NULL };
RegisterClassEx( &wc );
WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"PS2EMU_GSNULL", NULL};
RegisterClassEx(&wc);
GShwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "PS2EMU_GSNULL", Title,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, wc.hInstance, NULL);
GShwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "PS2EMU_GSNULL", Title,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, wc.hInstance, NULL);
if(GShwnd == NULL)
{
GSLog::WriteLn("Failed to create window. Exiting...");
return -1;
}
if (GShwnd == NULL) {
GSLog::WriteLn("Failed to create window. Exiting...");
return -1;
}
if( pDsp != NULL ) *(uptr*)pDsp = (uptr)GShwnd;
if (pDsp != NULL)
*(uptr*)pDsp = (uptr)GShwnd;
return 0;
return 0;
}
void GSCloseWindow()
{
DestroyWindow( GShwnd );
DestroyWindow(GShwnd);
}
void GSProcessMessages()
@ -65,6 +64,6 @@ void GSProcessMessages()
}
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
void HandleKeyEvent(keyEvent *ev)
void HandleKeyEvent(keyEvent* ev)
{
}

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,74 +24,83 @@
HINSTANCE hInst;
extern HWND GShwnd;
void SysMessage(char *fmt, ...) {
va_list list;
char tmp[512];
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_end(list);
MessageBox((GShwnd!=NULL) ? GShwnd : GetActiveWindow(), tmp, "GS Plugin Msg", 0);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox((GShwnd != NULL) ? GShwnd : GetActiveWindow(), tmp, "GS Plugin Msg", 0);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
switch (uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
return TRUE;
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
EXPORT_C_(void) GSconfigure() {
EXPORT_C_(void)
GSconfigure()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
}
EXPORT_C_(void) GSabout() {
EXPORT_C_(void)
GSabout()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
}
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -17,20 +17,20 @@
void OnKeyboardF5(int myShift)
{
GSLog::WriteLn("F5 pressed!");
GSLog::WriteLn("F5 pressed!");
}
void OnKeyboardF6(int myShift)
{
GSLog::WriteLn("F6 pressed!");
GSLog::WriteLn("F6 pressed!");
}
void OnKeyboardF7(int myShift)
{
GSLog::WriteLn("F7 pressed!");
GSLog::WriteLn("F7 pressed!");
}
void OnKeyboardF9(int myShift)
{
GSLog::WriteLn("F9 pressed!");
GSLog::WriteLn("F9 pressed!");
}

View File

@ -23,43 +23,43 @@
extern std::string s_strIniPath;
PluginConf Ini;
EXPORT_C_(void) PADabout()
EXPORT_C_(void)
PADabout()
{
SysMessage("PADnull: A simple null plugin.");
SysMessage("PADnull: A simple null plugin.");
}
EXPORT_C_(void) PADconfigure()
EXPORT_C_(void)
PADconfigure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/Padnull.ini");
if (!Ini.Open(iniFile, READ_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
SaveConfig();//save and return
return;
}
if (!Ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
}
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
}
void SaveConfig()
{
const std::string iniFile(s_strIniPath + "/Padnull.ini");
if (!Ini.Open(iniFile, WRITE_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
return;
}
if (!Ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

View File

@ -18,75 +18,70 @@
#include <gdk/gdkx.h>
#include "PadLinux.h"
Display *GSdsp;
Display* GSdsp;
int autoRepeatMode;
void _PadUpdate(int pad)
{
XEvent evt;
KeySym key;
XEvent evt;
KeySym key;
// keyboard input
while (XPending(GSdsp) > 0)
{
XNextEvent(GSdsp, &evt);
switch (evt.type)
{
case KeyPress:
key = XLookupKeysym((XKeyEvent *) &evt, 0);
// keyboard input
while (XPending(GSdsp) > 0) {
XNextEvent(GSdsp, &evt);
switch (evt.type) {
case KeyPress:
key = XLookupKeysym((XKeyEvent*)&evt, 0);
// Add code to check if it's one of the keys we configured here on a real pda plugin..
// Add code to check if it's one of the keys we configured here on a real pda plugin..
event.evt = KEYPRESS;
event.key = key;
break;
event.evt = KEYPRESS;
event.key = key;
break;
case KeyRelease:
key = XLookupKeysym((XKeyEvent *) &evt, 0);
case KeyRelease:
key = XLookupKeysym((XKeyEvent*)&evt, 0);
// Add code to check if it's one of the keys we configured here on a real pda plugin..
// Add code to check if it's one of the keys we configured here on a real pda plugin..
event.evt = KEYRELEASE;
event.key = key;
break;
event.evt = KEYRELEASE;
event.key = key;
break;
case FocusIn:
XAutoRepeatOff(GSdsp);
break;
case FocusIn:
XAutoRepeatOff(GSdsp);
break;
case FocusOut:
XAutoRepeatOn(GSdsp);
break;
}
}
case FocusOut:
XAutoRepeatOn(GSdsp);
break;
}
}
}
s32 _PADOpen(void *pDsp)
s32 _PADOpen(void* pDsp)
{
GtkScrolledWindow *win;
win = *(GtkScrolledWindow**) pDsp;
GtkScrolledWindow* win;
if (GTK_IS_WIDGET(win))
{
// Since we have a GtkScrolledWindow, for now we'll grab whatever display
// comes along instead. Later, we can fiddle with this, but I'm not sure the
// best way to get a Display* out of a GtkScrolledWindow. A GtkWindow I might
// be able to manage... --arcum42
win = *(GtkScrolledWindow**)pDsp;
if (GTK_IS_WIDGET(win)) {
// Since we have a GtkScrolledWindow, for now we'll grab whatever display
// comes along instead. Later, we can fiddle with this, but I'm not sure the
// best way to get a Display* out of a GtkScrolledWindow. A GtkWindow I might
// be able to manage... --arcum42
GSdsp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
}
else
{
} else {
GSdsp = *(Display**)pDsp;
}
XAutoRepeatOff(GSdsp);
}
return 0;
XAutoRepeatOff(GSdsp);
return 0;
}
void _PADClose()
void _PADClose()
{
XAutoRepeatOn(GSdsp);
XAutoRepeatOn(GSdsp);
}

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

@ -21,149 +21,164 @@ using namespace std;
#include "svnrev.h"
#include "Pad.h"
const u8 version = PS2E_PAD_VERSION;
const u8 version = PS2E_PAD_VERSION;
const u8 revision = 0;
const u8 build = 1; // increase that with each version
const u8 build = 1; // increase that with each version
#ifdef _MSC_VER
#define snprintf sprintf_s
#endif
static char libraryName[256];
string s_strIniPath="inis";
string s_strLogPath="logs";
string s_strIniPath = "inis";
string s_strLogPath = "logs";
FILE *padLog;
FILE* padLog;
Config conf;
keyEvent event;
static keyEvent s_event;
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_PAD;
return PS2E_LT_PAD;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
snprintf( libraryName, 255, "Padnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
snprintf(libraryName, 255, "Padnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version<<16) | (revision<<8) | build;
return (version << 16) | (revision << 8) | build;
}
void __Log(const char *fmt, ...)
void __Log(const char* fmt, ...)
{
va_list list;
va_list list;
if (padLog == NULL) return;
va_start(list, fmt);
vfprintf(padLog, fmt, list);
va_end(list);
if (padLog == NULL)
return;
va_start(list, fmt);
vfprintf(padLog, fmt, list);
va_end(list);
}
void __LogToConsole(const char *fmt, ...)
void __LogToConsole(const char* fmt, ...)
{
va_list list;
va_list list;
va_start(list, fmt);
va_start(list, fmt);
if (padLog != NULL) vfprintf(padLog, fmt, list);
if (padLog != NULL)
vfprintf(padLog, fmt, list);
printf("PadNull: ");
vprintf(fmt, list);
va_end(list);
printf("PadNull: ");
vprintf(fmt, list);
va_end(list);
}
EXPORT_C_(void) PADsetSettingsDir(const char* dir)
EXPORT_C_(void)
PADsetSettingsDir(const char* dir)
{
s_strIniPath = (dir == NULL) ? "inis" : dir;
s_strIniPath = (dir == NULL) ? "inis" : dir;
}
bool OpenLog() {
bool OpenLog()
{
bool result = true;
#ifdef PAD_LOG
if(padLog) return result;
if (padLog)
return result;
const std::string LogFile(s_strLogPath + "/padnull.log");
padLog = fopen(LogFile.c_str(), "w");
if (padLog != NULL)
setvbuf(padLog, NULL, _IONBF, 0);
setvbuf(padLog, NULL, _IONBF, 0);
else {
fprintf(stderr, "Can't create log file %s\n", LogFile.c_str());
result = false;
}
PAD_LOG("PADinit\n");
PAD_LOG("PADinit\n");
#endif
return result;
}
EXPORT_C_(void) PADsetLogDir(const char* dir)
EXPORT_C_(void)
PADsetLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs" : dir;
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
if (padLog) {
// Reload the log file after updated the path
if (padLog) {
fclose(padLog);
padLog = NULL;
}
OpenLog();
}
EXPORT_C_(s32) PADinit(u32 flags)
EXPORT_C_(s32)
PADinit(u32 flags)
{
LoadConfig();
LoadConfig();
OpenLog();
return 0;
return 0;
}
EXPORT_C_(void) PADshutdown()
EXPORT_C_(void)
PADshutdown()
{
#ifdef PAD_LOG
if (padLog)
{
fclose(padLog);
padLog = NULL;
}
if (padLog) {
fclose(padLog);
padLog = NULL;
}
#endif
}
EXPORT_C_(s32) PADopen(void *pDsp)
EXPORT_C_(s32)
PADopen(void* pDsp)
{
memset(&event, 0, sizeof(event));
memset(&event, 0, sizeof(event));
return _PADOpen(pDsp);
return _PADOpen(pDsp);
}
EXPORT_C_(void) PADclose()
EXPORT_C_(void)
PADclose()
{
_PADClose();
_PADClose();
}
// PADkeyEvent is called every vsync (return NULL if no event)
EXPORT_C_(keyEvent*) PADkeyEvent()
EXPORT_C_(keyEvent*)
PADkeyEvent()
{
s_event = event;
event.evt = 0;
event.key = 0;
s_event = event;
event.evt = 0;
event.key = 0;
return &s_event;
return &s_event;
}
EXPORT_C_(u8) PADstartPoll(int pad)
EXPORT_C_(u8)
PADstartPoll(int pad)
{
return 0;
return 0;
}
EXPORT_C_(u8) PADpoll(u8 value)
EXPORT_C_(u8)
PADpoll(u8 value)
{
return 0;
return 0;
}
// call to give a hint to the PAD plugin to query for the keyboard state. A
@ -173,29 +188,34 @@ EXPORT_C_(u8) PADpoll(u8 value)
// the window (and input). Note that PADupdate can be called from a different
// thread than the other functions, so mutex or other multithreading primitives
// have to be added to maintain data integrity.
EXPORT_C_(u32) PADquery()
EXPORT_C_(u32)
PADquery()
// returns: 1 if supported pad1
// 2 if supported pad2
// 3 if both are supported
{
return 3;
return 3;
}
EXPORT_C_(void) PADupdate(int pad)
EXPORT_C_(void)
PADupdate(int pad)
{
_PadUpdate(pad);
_PadUpdate(pad);
}
EXPORT_C_(void) PADgsDriverInfo(GSdriverInfo *info)
EXPORT_C_(void)
PADgsDriverInfo(GSdriverInfo* info)
{
}
EXPORT_C_(s32) PADfreeze(int mode, freezeData *data)
EXPORT_C_(s32)
PADfreeze(int mode, freezeData* data)
{
return 0;
return 0;
}
EXPORT_C_(s32) PADtest()
EXPORT_C_(s32)
PADtest()
{
return 0;
return 0;
}

View File

@ -31,21 +31,21 @@
#ifdef _MSC_VER
#define EXPORT_C_(type) extern "C" type CALLBACK
#else
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
#endif
#define PAD_LOG __Log
typedef struct
{
s32 Log;
s32 Log;
} Config;
extern Config conf;
extern FILE *padLog;
extern FILE* padLog;
extern keyEvent event;
extern void __Log(char *fmt, ...);
extern void __Log(char* fmt, ...);
extern void SaveConfig();
extern void LoadConfig();

View File

@ -19,29 +19,27 @@ extern std::string s_strIniPath;
void SaveConfig()
{
const std::string iniFile = s_strIniPath + "/Padnull.ini";
const std::string iniFile = s_strIniPath + "/Padnull.ini";
PluginConf ini;
if (!ini.Open(iniFile, READ_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
SaveConfig();//save and return
return;
}
conf.Log = ini.ReadInt("logging", 0);
ini.Close();
PluginConf ini;
if (!ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
}
conf.Log = ini.ReadInt("logging", 0);
ini.Close();
}
void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/Padnull.ini");
const std::string iniFile(s_strIniPath + "/Padnull.ini");
PluginConf ini;
if (!ini.Open(iniFile, WRITE_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
return;
}
ini.WriteInt("logging", conf.Log);
ini.Close();
PluginConf ini;
if (!ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}
ini.WriteInt("logging", conf.Log);
ini.Close();
}

View File

@ -21,56 +21,54 @@ HWND GShwnd = NULL;
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_KEYDOWN:
if (lParam & 0x40000000)return TRUE;
switch (msg) {
case WM_KEYDOWN:
if (lParam & 0x40000000)
return TRUE;
event.evt = KEYPRESS;
event.key = wParam;
break;
event.evt = KEYPRESS;
event.key = wParam;
break;
case WM_KEYUP:
event.evt = KEYRELEASE;
event.key = wParam;
break;
case WM_KEYUP:
event.evt = KEYRELEASE;
event.key = wParam;
break;
case WM_DESTROY:
case WM_QUIT:
event.evt = KEYPRESS;
event.key = VK_ESCAPE;
return GSwndProc(hWnd, msg, wParam, lParam);
case WM_DESTROY:
case WM_QUIT:
event.evt = KEYPRESS;
event.key = VK_ESCAPE;
return GSwndProc(hWnd, msg, wParam, lParam);
default:
return GSwndProc(hWnd, msg, wParam, lParam);
};
default:
return GSwndProc(hWnd, msg, wParam, lParam);
};
return TRUE;
return TRUE;
}
void _PadUpdate(int pad)
{
}
s32 _PADOpen(void *pDsp)
s32 _PADOpen(void* pDsp)
{
GShwnd = (HWND)*(long*)pDsp;
GShwnd = (HWND) * (long*)pDsp;
if (GShwnd != NULL && GSwndProc != NULL)
{
// revert
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
}
if (GShwnd != NULL && GSwndProc != NULL) {
// revert
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
}
GSwndProc = (WNDPROC)GetWindowLongPtr(GShwnd, GWLP_WNDPROC);
GSwndProc = ((WNDPROC)SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(PADwndProc)));
return 0;
return 0;
}
void _PADClose()
void _PADClose()
{
if (GShwnd != NULL && GSwndProc != NULL)
{
if (GShwnd != NULL && GSwndProc != NULL) {
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
GSwndProc = NULL;
GShwnd = NULL;

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,65 +20,72 @@
HINSTANCE hInst;
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
switch (uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
return TRUE;
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
EXPORT_C_(void) PADconfigure() {
EXPORT_C_(void)
PADconfigure()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
}
EXPORT_C_(void) PADabout() {
EXPORT_C_(void)
PADabout()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
}
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -23,44 +23,44 @@ using namespace std;
extern string s_strIniPath;
PluginConf Ini;
EXPORT_C_(void) SPU2configure()
EXPORT_C_(void)
SPU2configure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
EXPORT_C_(void) SPU2about()
EXPORT_C_(void)
SPU2about()
{
//SysMessage("%s %d.%d", libraryName, version, build);
SysMessage("SPU2null: A simple null plugin.");
//SysMessage("%s %d.%d", libraryName, version, build);
SysMessage("SPU2null: A simple null plugin.");
}
void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/Spu2null.ini");
if (!Ini.Open(iniFile, READ_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
SaveConfig();//save and return
return;
}
if (!Ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
}
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
}
void SaveConfig()
{
const std::string iniFile(s_strIniPath + "/Spu2null.ini");
if (!Ini.Open(iniFile, WRITE_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
return;
}
if (!Ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

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,114 +38,115 @@ extern "C"
#ifdef _MSC_VER
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
#else
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
#endif
extern FILE *spu2Log;
extern FILE* spu2Log;
#define SPU2_LOG __Log //debug mode
extern const u8 version;
extern const u8 revision;
extern const u8 build;
extern const u32 minor;
extern char *libraryName;
extern char* libraryName;
typedef struct
{
s32 Log;
s32 Log;
} Config;
extern Config conf;
void __Log(char *fmt, ...);
void __Log(char* fmt, ...);
void SaveConfig();
void LoadConfig();
void SysMessage(char *fmt, ...);
void SysMessage(char* fmt, ...);
////////////////////
// SPU2 Registers //
////////////////////
#define REG_VP_VOLL 0x0000
#define REG_VP_VOLR 0x0002
#define REG_VP_PITCH 0x0004
#define REG_VP_ADSR1 0x0006
#define REG_VP_ADSR2 0x0008
#define REG_VP_ENVX 0x000A
#define REG_VP_VOLXL 0x000C
#define REG_VP_VOLXR 0x000E
#define REG_C0_FMOD1 0x0180
#define REG_C0_FMOD2 0x0182
#define REG_C1_FMOD1 0x0580
#define REG_C1_FMOD2 0x0582
#define REG_S_NON 0x0184
#define REG_S_VMIXL 0x0188
#define REG_S_VMIXEL 0x018C
#define REG_S_VMIXR 0x0190
#define REG_S_VMIXER 0x0194
#define REG_C0_MMIX 0x0198
#define REG_C1_MMIX 0x0598
#define REG_C0_CTRL 0x019A
#define REG_C0_IRQA_HI 0x019C
#define REG_C0_IRQA_LO 0x019D
#define REG_C1_IRQA_HI 0x059C
#define REG_C1_IRQA_LO 0x059D
#define REG_C0_SPUON1 0x1A0
#define REG_C0_SPUON2 0x1A2
#define REG_C1_SPUON1 0x5A0
#define REG_C1_SPUON2 0x5A2
#define REG_C0_SPUOFF1 0x1A4
#define REG_C0_SPUOFF2 0x1A6
#define REG_C1_SPUOFF1 0x5A4
#define REG_C1_SPUOFF2 0x5A6
#define REG_VP_VOLL 0x0000
#define REG_VP_VOLR 0x0002
#define REG_VP_PITCH 0x0004
#define REG_VP_ADSR1 0x0006
#define REG_VP_ADSR2 0x0008
#define REG_VP_ENVX 0x000A
#define REG_VP_VOLXL 0x000C
#define REG_VP_VOLXR 0x000E
#define REG_C0_FMOD1 0x0180
#define REG_C0_FMOD2 0x0182
#define REG_C1_FMOD1 0x0580
#define REG_C1_FMOD2 0x0582
#define REG_S_NON 0x0184
#define REG_S_VMIXL 0x0188
#define REG_S_VMIXEL 0x018C
#define REG_S_VMIXR 0x0190
#define REG_S_VMIXER 0x0194
#define REG_C0_MMIX 0x0198
#define REG_C1_MMIX 0x0598
#define REG_C0_CTRL 0x019A
#define REG_C0_IRQA_HI 0x019C
#define REG_C0_IRQA_LO 0x019D
#define REG_C1_IRQA_HI 0x059C
#define REG_C1_IRQA_LO 0x059D
#define REG_C0_SPUON1 0x1A0
#define REG_C0_SPUON2 0x1A2
#define REG_C1_SPUON1 0x5A0
#define REG_C1_SPUON2 0x5A2
#define REG_C0_SPUOFF1 0x1A4
#define REG_C0_SPUOFF2 0x1A6
#define REG_C1_SPUOFF1 0x5A4
#define REG_C1_SPUOFF2 0x5A6
#define REG_C0_SPUADDR_HI 0x01A8
#define REG_C0_SPUADDR_LO 0x01AA
#define REG_C1_SPUADDR_HI 0x05A8
#define REG_C1_SPUADDR_LO 0x05AA
#define REG_C0_SPUDATA 0x01AC
#define REG_C1_SPUDATA 0x05AC
#define REG_C0_DMACTRL 0x01AE
#define REG_C1_DMACTRL 0x05AE
#define REG_C0_ADMAS 0x01B0
#define REG_VA_SSA 0x01C0
#define REG_VA_LSAX 0x01C4
#define REG_VA_NAX 0x01C8
#define REG_A_ESA 0x02E0
#define REG_A_EEA 0x033C
#define REG_C0_END1 0x0340
#define REG_C0_END2 0x0342
#define REG_C1_END1 0x0740
#define REG_C1_END2 0x0742
#define REG_C0_SPUSTAT 0x0344 //not sure!
#define REG_C1_CTRL 0x059A
#define REG_C1_ADMAS 0x05B0
#define REG_C1_SPUSTAT 0x0744 //not sure!
#define REG_P_MVOLL 0x0760
#define REG_P_MVOLR 0x0762
#define REG_P_EVOLL 0x0764
#define REG_P_EVOLR 0x0766
#define REG_P_AVOLL 0x0768
#define REG_P_AVOLR 0x076A
#define REG_P_BVOLL 0x076C
#define REG_P_BVOLR 0x076E
#define REG_P_MVOLXL 0x0770
#define REG_P_MVOLXR 0x0772
#define SPDIF_OUT 0x07C0
#define REG_IRQINFO 0x07C2
#define SPDIF_MODE 0x07C6
#define SPDIF_MEDIA 0x07C8
#define REG_C0_SPUDATA 0x01AC
#define REG_C1_SPUDATA 0x05AC
#define REG_C0_DMACTRL 0x01AE
#define REG_C1_DMACTRL 0x05AE
#define REG_C0_ADMAS 0x01B0
#define REG_VA_SSA 0x01C0
#define REG_VA_LSAX 0x01C4
#define REG_VA_NAX 0x01C8
#define REG_A_ESA 0x02E0
#define REG_A_EEA 0x033C
#define REG_C0_END1 0x0340
#define REG_C0_END2 0x0342
#define REG_C1_END1 0x0740
#define REG_C1_END2 0x0742
#define REG_C0_SPUSTAT 0x0344 //not sure!
#define REG_C1_CTRL 0x059A
#define REG_C1_ADMAS 0x05B0
#define REG_C1_SPUSTAT 0x0744 //not sure!
#define REG_P_MVOLL 0x0760
#define REG_P_MVOLR 0x0762
#define REG_P_EVOLL 0x0764
#define REG_P_EVOLR 0x0766
#define REG_P_AVOLL 0x0768
#define REG_P_AVOLR 0x076A
#define REG_P_BVOLL 0x076C
#define REG_P_BVOLR 0x076E
#define REG_P_MVOLXL 0x0770
#define REG_P_MVOLXR 0x0772
#define SPDIF_OUT 0x07C0
#define REG_IRQINFO 0x07C2
#define SPDIF_MODE 0x07C6
#define SPDIF_MEDIA 0x07C8
#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem) & 0xffff])
#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem) & 0xffff])
#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem)&0xffff])
#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem)&0xffff])
//#define spu2Rs32(mem) (*(s32*)&spu2regs[(mem) & 0xffff])
//#define spu2Ru32(mem) (*(u32*)&spu2regs[(mem) & 0xffff])
#define IRQINFO spu2Ru16(REG_IRQINFO)
#define SPU2_GET32BIT(lo,hi) (((u32)(spu2Ru16(hi)&0x3f)<<16)|(u32)spu2Ru16(lo))
#define SPU2_SET32BIT(value, lo, hi) { \
spu2Ru16(hi) = ((value)>>16)&0x3f; \
spu2Ru16(lo) = (value)&0xffff; \
} \
#define SPU2_GET32BIT(lo, hi) (((u32)(spu2Ru16(hi) & 0x3f) << 16) | (u32)spu2Ru16(lo))
#define SPU2_SET32BIT(value, lo, hi) \
{ \
spu2Ru16(hi) = ((value) >> 16) & 0x3f; \
spu2Ru16(lo) = (value)&0xffff; \
}
#define C0_IRQA SPU2_GET32BIT(REG_C0_IRQA_LO, REG_C0_IRQA_HI)
#define C1_IRQA SPU2_GET32BIT(REG_C1_IRQA_LO, REG_C1_IRQA_HI)
@ -157,20 +157,20 @@ void SysMessage(char *fmt, ...);
#define C0_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C0_IRQA_LO, REG_C0_IRQA_HI)
#define C1_SPUADDR_SET(value) SPU2_SET32BIT(value, REG_C1_IRQA_LO, REG_C1_IRQA_HI)
#define SPU_NUMBER_VOICES 48
#define SPU_NUMBER_VOICES 48
struct SPU_CONTROL_
{
u16 spuon : 1;
u16 spuUnmute : 1;
u16 noiseFreq : 6;
u16 reverb : 1;
u16 irq : 1;
u16 dma : 2; // 1 - no dma, 2 - write, 3 - read
u16 extr : 1; // external reverb
u16 cdreverb : 1;
u16 extAudio : 1;
u16 extCd : 1;
u16 spuon : 1;
u16 spuUnmute : 1;
u16 noiseFreq : 6;
u16 reverb : 1;
u16 irq : 1;
u16 dma : 2; // 1 - no dma, 2 - write, 3 - read
u16 extr : 1; // external reverb
u16 cdreverb : 1;
u16 extAudio : 1;
u16 extCd : 1;
};
// the layout of each voice in wSpuRegs
@ -178,115 +178,117 @@ struct _SPU_VOICE
{
union
{
struct {
u16 Vol : 14;
u16 Inverted : 1;
u16 Sweep0 : 1;
struct
{
u16 Vol : 14;
u16 Inverted : 1;
u16 Sweep0 : 1;
} vol;
struct {
u16 Vol : 7;
u16 res1 : 5;
u16 Inverted : 1;
u16 Decrease : 1; // if 0, increase
u16 ExpSlope : 1; // if 0, linear slope
u16 Sweep1 : 1; // always one
} sweep;
u16 word;
} left, right;
struct
{
u16 Vol : 7;
u16 res1 : 5;
u16 Inverted : 1;
u16 Decrease : 1; // if 0, increase
u16 ExpSlope : 1; // if 0, linear slope
u16 Sweep1 : 1; // always one
} sweep;
u16 word;
} left, right;
u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc
u16 res0 : 2;
u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc
u16 res0 : 2;
u16 SustainLvl : 4;
u16 DecayRate : 4;
u16 AttackRate : 7;
u16 AttackExp : 1; // if 0, linear
u16 SustainLvl : 4;
u16 DecayRate : 4;
u16 AttackRate : 7;
u16 AttackExp : 1; // if 0, linear
u16 ReleaseRate : 5;
u16 ReleaseExp : 1; // if 0, linear
u16 SustainRate : 7;
u16 res1 : 1;
u16 SustainDec : 1; // if 0, inc
u16 SustainExp : 1; // if 0, linear
u16 ReleaseRate : 5;
u16 ReleaseExp : 1; // if 0, linear
u16 SustainRate : 7;
u16 res1 : 1;
u16 SustainDec : 1; // if 0, inc
u16 SustainExp : 1; // if 0, linear
u16 AdsrVol;
u16 Address; // add / 8
u16 RepeatAddr; // gets reset when sample starts
u16 AdsrVol;
u16 Address; // add / 8
u16 RepeatAddr; // gets reset when sample starts
};
// ADSR INFOS PER CHANNEL
struct ADSRInfoEx
{
s32 State;
s32 AttackModeExp;
s32 AttackRate;
s32 DecayRate;
s32 SustainLevel;
s32 SustainModeExp;
s32 SustainIncrease;
s32 SustainRate;
s32 ReleaseModeExp;
s32 ReleaseRate;
s32 EnvelopeVol;
s32 lVolume;
s32 State;
s32 AttackModeExp;
s32 AttackRate;
s32 DecayRate;
s32 SustainLevel;
s32 SustainModeExp;
s32 SustainIncrease;
s32 SustainRate;
s32 ReleaseModeExp;
s32 ReleaseRate;
s32 EnvelopeVol;
s32 lVolume;
};
#define NSSIZE 48 // ~ 1 ms of data
#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting
#define NSSIZE 48 // ~ 1 ms of data
#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting
#define NSPACKETS 4
#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED)-4*sizeof(void*))
#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED) - 4 * sizeof(void*))
struct VOICE_PROCESSED
{
VOICE_PROCESSED()
{
memset(this, 0, sizeof(VOICE_PROCESSED));
}
~VOICE_PROCESSED()
{
}
VOICE_PROCESSED()
{
memset(this, 0, sizeof(VOICE_PROCESSED));
}
~VOICE_PROCESSED()
{
}
void SetVolume(int right);
void StartSound();
void VoiceChangeFrequency();
void FModChangeFrequency(int ns);
void Stop();
void SetVolume(int right);
void StartSound();
void VoiceChangeFrequency();
void FModChangeFrequency(int ns);
void Stop();
SPU_CONTROL_* GetCtrl();
SPU_CONTROL_* GetCtrl();
// start save state
// start save state
s32 iSBPos; // mixing stuff
s32 spos;
s32 sinc;
s32 iSBPos; // mixing stuff
s32 spos;
s32 sinc;
s32 iActFreq; // current psx pitch
s32 iUsedFreq; // current pc pitch
s32 iActFreq; // current psx pitch
s32 iUsedFreq; // current pc pitch
s32 iStartAddr, iLoopAddr, iNextAddr;
s32 iStartAddr, iLoopAddr, iNextAddr;
ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start)
bool bIgnoreLoop, bNew, bNoise, bReverb, bOn, bStop, bVolChanged;
s32 memoffset; // if first core, 0, if second, 0x400
ADSRInfoEx ADSRX; // next ADSR settings (will be moved to active on sample start)
bool bIgnoreLoop, bNew, bNoise, bReverb, bOn, bStop, bVolChanged;
s32 memoffset; // if first core, 0, if second, 0x400
// end save state
// end save state
///////////////////
// Sound Buffers //
///////////////////
u8* pStart; // start and end addresses
u8* pLoop, *pCurr;
///////////////////
// Sound Buffers //
///////////////////
u8* pStart; // start and end addresses
u8 *pLoop, *pCurr;
_SPU_VOICE* pvoice;
_SPU_VOICE* pvoice;
};
struct ADMA
{
u16 * MemAddr;
s32 IntPointer;
s32 Index;
s32 AmountLeft;
s32 Enabled;
u16* MemAddr;
s32 IntPointer;
s32 Index;
s32 AmountLeft;
s32 Enabled;
};
#endif /* __SPU2_H__ */

View File

@ -21,46 +21,45 @@ extern HINSTANCE hInst;
void SaveConfig()
{
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
strcpy(szTemp, "\\inis\\spu2null.ini");
sprintf(szValue,"%u",Conf1->Log);
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\spu2null.ini");
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
FILE *fp;
void LoadConfig()
{
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
strcpy(szTemp, "\\inis\\spu2null.ini");
fp=fopen("inis\\usbnull.ini","rt");//check if usbnull.ini really exists
if (!fp)
{
CreateDirectory("inis",NULL);
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\spu2null.ini");
fp = fopen("inis\\usbnull.ini", "rt"); //check if usbnull.ini really exists
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0;//default value
SaveConfig();//save and return
return ;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return ;
conf.Log = 0; //default value
SaveConfig(); //save and return
return;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return;
}

View File

@ -22,75 +22,81 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
va_list list;
char tmp[512];
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_end(list);
MessageBox(0, tmp, "SPU2NULL Msg", 0);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(0, tmp, "SPU2NULL Msg", 0);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
switch (uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
return TRUE;
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
void CALLBACK SPU2configure() {
void CALLBACK SPU2configure()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
}
void CALLBACK SPU2about() {
void CALLBACK SPU2about()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
}
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -25,55 +25,51 @@ PluginConf Ini;
void setLoggingState()
{
if (conf.Log)
{
USBLog.WriteToConsole = true;
USBLog.WriteToFile = true;
}
else
{
USBLog.WriteToConsole = false;
USBLog.WriteToFile = false;
}
if (conf.Log) {
USBLog.WriteToConsole = true;
USBLog.WriteToFile = true;
} else {
USBLog.WriteToConsole = false;
USBLog.WriteToFile = false;
}
}
EXPORT_C_(void) USBabout()
EXPORT_C_(void)
USBabout()
{
SysMessage("USBnull: A simple null plugin.");
SysMessage("USBnull: A simple null plugin.");
}
EXPORT_C_(void) USBconfigure()
EXPORT_C_(void)
USBconfigure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
void LoadConfig()
{
string IniPath = s_strIniPath + "/USBnull.ini";
if (!Ini.Open(IniPath, READ_FILE))
{
USBLog.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
string IniPath = s_strIniPath + "/USBnull.ini";
if (!Ini.Open(IniPath, READ_FILE)) {
USBLog.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
conf.Log = Ini.ReadInt("logging", 0);
setLoggingState();
Ini.Close();
conf.Log = Ini.ReadInt("logging", 0);
setLoggingState();
Ini.Close();
}
void SaveConfig()
{
string IniPath = s_strIniPath + "/USBnull.ini";
if (!Ini.Open(IniPath, WRITE_FILE))
{
USBLog.WriteLn("Failed to open %s", IniPath.c_str());
return;
}
string IniPath = s_strIniPath + "/USBnull.ini";
if (!Ini.Open(IniPath, WRITE_FILE)) {
USBLog.WriteLn("Failed to open %s", IniPath.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

View File

@ -18,12 +18,12 @@
using namespace std;
#include "svnrev.h"
#include "USB.h"
string s_strIniPath="inis";
string s_strLogPath="logs";
string s_strIniPath = "inis";
string s_strLogPath = "logs";
const unsigned char version = PS2E_USB_VERSION;
const unsigned char version = PS2E_USB_VERSION;
const unsigned char revision = 0;
const unsigned char build = 7; // increase that with each version
const unsigned char build = 7; // increase that with each version
#ifdef _MSC_VER
#define snprintf sprintf_s
@ -38,233 +38,245 @@ s8 *usbregs, *ram;
void LogInit()
{
const std::string LogFile(s_strLogPath + "/USBnull.log");
setLoggingState();
USBLog.Open(LogFile);
const std::string LogFile(s_strLogPath + "/USBnull.log");
setLoggingState();
USBLog.Open(LogFile);
}
EXPORT_C_(void) USBsetLogDir(const char* dir)
EXPORT_C_(void)
USBsetLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs" : dir;
// Reload the log file after updated the path
USBLog.Close();
LogInit();
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
USBLog.Close();
LogInit();
}
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_USB;
return PS2E_LT_USB;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
snprintf( libraryName, 255, "USBnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
snprintf(libraryName, 255, "USBnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(s32) USBinit()
EXPORT_C_(s32)
USBinit()
{
LoadConfig();
LogInit();
USBLog.WriteLn("USBnull plugin version %d,%d", revision, build);
USBLog.WriteLn("Initializing USBnull");
LoadConfig();
LogInit();
USBLog.WriteLn("USBnull plugin version %d,%d", revision, build);
USBLog.WriteLn("Initializing USBnull");
// Initialize memory structures here.
usbregs = (s8*)calloc(0x10000, 1);
// Initialize memory structures here.
usbregs = (s8*)calloc(0x10000, 1);
if (usbregs == NULL)
{
USBLog.Message("Error allocating memory");
return -1;
}
if (usbregs == NULL) {
USBLog.Message("Error allocating memory");
return -1;
}
return 0;
return 0;
}
EXPORT_C_(void) USBshutdown()
EXPORT_C_(void)
USBshutdown()
{
// Yes, we close things in the Shutdown routine, and
// don't do anything in the close routine.
USBLog.Close();
free(usbregs);
usbregs = NULL;
// Yes, we close things in the Shutdown routine, and
// don't do anything in the close routine.
USBLog.Close();
free(usbregs);
usbregs = NULL;
}
EXPORT_C_(s32) USBopen(void *pDsp)
EXPORT_C_(s32)
USBopen(void* pDsp)
{
USBLog.WriteLn("Opening USBnull.");
USBLog.WriteLn("Opening USBnull.");
// Take care of anything else we need on opening, other then initialization.
return 0;
// Take care of anything else we need on opening, other then initialization.
return 0;
}
EXPORT_C_(void) USBclose()
EXPORT_C_(void)
USBclose()
{
USBLog.WriteLn("Closing USBnull.");
USBLog.WriteLn("Closing USBnull.");
}
// Note: actually uncommenting the read/write functions I provided here
// caused uLauncher.elf to hang on startup, so careful when experimenting.
EXPORT_C_(u8) USBread8(u32 addr)
EXPORT_C_(u8)
USBread8(u32 addr)
{
u8 value = 0;
u8 value = 0;
switch(addr)
{
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 8 bit read at address %lx", addr);
break;
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 8 bit read at address %lx", addr);
break;
default:
//value = usbRu8(addr);
USBLog.WriteLn("*(USBnull) 8 bit read at address %lx", addr);
break;
}
return value;
default:
//value = usbRu8(addr);
USBLog.WriteLn("*(USBnull) 8 bit read at address %lx", addr);
break;
}
return value;
}
EXPORT_C_(u16) USBread16(u32 addr)
EXPORT_C_(u16)
USBread16(u32 addr)
{
u16 value = 0;
u16 value = 0;
switch(addr)
{
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr);
break;
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr);
break;
default:
//value = usbRu16(addr);
USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr);
}
return value;
default:
//value = usbRu16(addr);
USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr);
}
return value;
}
EXPORT_C_(u32) USBread32(u32 addr)
EXPORT_C_(u32)
USBread32(u32 addr)
{
u32 value = 0;
u32 value = 0;
switch(addr)
{
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr);
break;
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr);
break;
default:
//value = usbRu32(addr);
USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr);
}
return value;
default:
//value = usbRu32(addr);
USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr);
}
return value;
}
EXPORT_C_(void) USBwrite8(u32 addr, u8 value)
EXPORT_C_(void)
USBwrite8(u32 addr, u8 value)
{
switch(addr)
{
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value);
break;
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value);
break;
default:
//usbRu8(addr) = value;
USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value);
}
default:
//usbRu8(addr) = value;
USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value);
}
}
EXPORT_C_(void) USBwrite16(u32 addr, u16 value)
EXPORT_C_(void)
USBwrite16(u32 addr, u16 value)
{
switch(addr)
{
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
break;
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
break;
default:
//usbRu16(addr) = value;
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
}
default:
//usbRu16(addr) = value;
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
}
}
EXPORT_C_(void) USBwrite32(u32 addr, u32 value)
EXPORT_C_(void)
USBwrite32(u32 addr, u32 value)
{
switch(addr)
{
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
break;
switch (addr) {
// Handle any appropriate addresses here.
case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
break;
default:
//usbRu32(addr) = value;
USBLog.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value);
}
default:
//usbRu32(addr) = value;
USBLog.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value);
}
}
EXPORT_C_(void) USBirqCallback(USBcallback callback)
EXPORT_C_(void)
USBirqCallback(USBcallback callback)
{
// Register USBirq, so we can trigger an interrupt with it later.
// It will be called as USBirq(cycles); where cycles is the number
// of cycles before the irq is triggered.
USBirq = callback;
// Register USBirq, so we can trigger an interrupt with it later.
// It will be called as USBirq(cycles); where cycles is the number
// of cycles before the irq is triggered.
USBirq = callback;
}
EXPORT_C_(int) _USBirqHandler(void)
EXPORT_C_(int)
_USBirqHandler(void)
{
// This is our USB irq handler, so if an interrupt gets triggered,
// deal with it here.
return 0;
// This is our USB irq handler, so if an interrupt gets triggered,
// deal with it here.
return 0;
}
EXPORT_C_(USBhandler) USBirqHandler(void)
EXPORT_C_(USBhandler)
USBirqHandler(void)
{
// Pass our handler to pcsx2.
return (USBhandler)_USBirqHandler;
// Pass our handler to pcsx2.
return (USBhandler)_USBirqHandler;
}
EXPORT_C_(void) USBsetRAM(void *mem)
EXPORT_C_(void)
USBsetRAM(void* mem)
{
ram = (s8*)mem;
USBLog.WriteLn("*Setting ram.");
ram = (s8*)mem;
USBLog.WriteLn("*Setting ram.");
}
EXPORT_C_(void) USBsetSettingsDir(const char* dir)
EXPORT_C_(void)
USBsetSettingsDir(const char* dir)
{
// Get the path to the ini directory.
s_strIniPath = (dir==NULL) ? "inis" : dir;
// Get the path to the ini directory.
s_strIniPath = (dir == NULL) ? "inis" : dir;
}
// extended funcs
EXPORT_C_(s32) USBfreeze(int mode, freezeData *data)
EXPORT_C_(s32)
USBfreeze(int mode, freezeData* data)
{
// This should store or retrieve any information, for if emulation
// gets suspended, or for savestates.
switch(mode)
{
case FREEZE_LOAD:
// Load previously saved data.
break;
case FREEZE_SAVE:
// Save data.
break;
case FREEZE_SIZE:
// return the size of the data.
break;
}
return 0;
// This should store or retrieve any information, for if emulation
// gets suspended, or for savestates.
switch (mode) {
case FREEZE_LOAD:
// Load previously saved data.
break;
case FREEZE_SAVE:
// Save data.
break;
case FREEZE_SIZE:
// return the size of the data.
break;
}
return 0;
}
/*EXPORT_C_(void) USBasync(u32 cycles)
@ -272,10 +284,11 @@ EXPORT_C_(s32) USBfreeze(int mode, freezeData *data)
// Optional function: Called in IopCounter.cpp.
}*/
EXPORT_C_(s32) USBtest()
EXPORT_C_(s32)
USBtest()
{
// 0 if the plugin works, non-0 if it doesn't.
return 0;
// 0 if the plugin works, non-0 if it doesn't.
return 0;
}
/* For operating systems that need an entry point for a dll/library, here it is. Defined in PS2Eext.h. */

View File

@ -22,24 +22,25 @@
#include "PS2Edefs.h"
#include "PS2Eext.h"
typedef struct {
int Log;
typedef struct
{
int Log;
} Config;
extern USBcallback USBirq;
extern Config conf;
// Previous USB plugins have needed this in ohci.
static const s64 PSXCLK = 36864000; /* 36.864 Mhz */
static const s64 PSXCLK = 36864000; /* 36.864 Mhz */
extern s8 *usbregs, *ram;
#define usbRs8(mem) usbregs[(mem) & 0xffff]
#define usbRs16(mem) (*(s16*)&usbregs[(mem) & 0xffff])
#define usbRs32(mem) (*(s32*)&usbregs[(mem) & 0xffff])
#define usbRu8(mem) (*(u8*) &usbregs[(mem) & 0xffff])
#define usbRu16(mem) (*(u16*)&usbregs[(mem) & 0xffff])
#define usbRu32(mem) (*(u32*)&usbregs[(mem) & 0xffff])
#define usbRs8(mem) usbregs[(mem)&0xffff]
#define usbRs16(mem) (*(s16*)&usbregs[(mem)&0xffff])
#define usbRs32(mem) (*(s32*)&usbregs[(mem)&0xffff])
#define usbRu8(mem) (*(u8*)&usbregs[(mem)&0xffff])
#define usbRu16(mem) (*(u16*)&usbregs[(mem)&0xffff])
#define usbRu32(mem) (*(u32*)&usbregs[(mem)&0xffff])
extern void SaveConfig();
extern void LoadConfig();

View File

@ -21,46 +21,45 @@ extern HINSTANCE hInst;
void SaveConfig()
{
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
strcpy(szTemp, "\\inis\\usbnull.ini");
sprintf(szValue,"%u",Conf1->Log);
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\usbnull.ini");
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
FILE *fp;
void LoadConfig()
{
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
strcpy(szTemp, "\\inis\\usbnull.ini");
fp=fopen("inis\\usbnull.ini","rt");//check if usbnull.ini really exists
if (!fp)
{
CreateDirectory("inis",NULL);
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\usbnull.ini");
fp = fopen("inis\\usbnull.ini", "rt"); //check if usbnull.ini really exists
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0;//default value
SaveConfig();//save and return
return ;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return ;
conf.Log = 0; //default value
SaveConfig(); //save and return
return;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return;
}

View File

@ -22,75 +22,81 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
va_list list;
char tmp[512];
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_end(list);
MessageBox(GetActiveWindow(), tmp, "USBnull Msg", MB_SETFOREGROUND | MB_OK);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(GetActiveWindow(), tmp, "USBnull Msg", MB_SETFOREGROUND | MB_OK);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
switch (uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
return TRUE;
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
void CALLBACK USBconfigure() {
void CALLBACK USBconfigure()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
}
void CALLBACK USBabout() {
void CALLBACK USBabout()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
}
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}

View File

@ -28,54 +28,50 @@ PluginConf Ini;
void setLoggingState()
{
if (conf.Log)
{
Dev9Log.WriteToConsole = true;
Dev9Log.WriteToFile = true;
}
else
{
Dev9Log.WriteToConsole = false;
Dev9Log.WriteToFile = false;
}
if (conf.Log) {
Dev9Log.WriteToConsole = true;
Dev9Log.WriteToFile = true;
} else {
Dev9Log.WriteToConsole = false;
Dev9Log.WriteToFile = false;
}
}
EXPORT_C_(void) DEV9about()
EXPORT_C_(void)
DEV9about()
{
SysMessage("Dev9null: A simple null plugin.");
SysMessage("Dev9null: A simple null plugin.");
}
EXPORT_C_(void) DEV9configure()
EXPORT_C_(void)
DEV9configure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
void LoadConfig()
{
string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, READ_FILE))
{
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, READ_FILE)) {
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
conf.Log = Ini.ReadInt("logging",0);
Ini.Close();
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
}
void SaveConfig()
{
string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, WRITE_FILE))
{
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
return;
}
string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, WRITE_FILE)) {
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

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

@ -33,9 +33,9 @@ using namespace std;
#include "DEV9.h"
#include "svnrev.h"
const unsigned char version = PS2E_DEV9_VERSION;
const unsigned char version = PS2E_DEV9_VERSION;
const unsigned char revision = 0;
const unsigned char build = 5; // increase that with each version
const unsigned char build = 5; // increase that with each version
#ifdef _MSC_VER
#define snprintf sprintf_s
@ -48,265 +48,288 @@ void (*DEV9irq)(int);
__aligned16 s8 dev9regs[0x10000];
string s_strIniPath = "inis";
string s_strLogPath="logs";
string s_strLogPath = "logs";
PluginLog Dev9Log;
Config conf;
void LogInit()
{
const std::string LogFile(s_strLogPath + "/dev9null.log");
setLoggingState();
Dev9Log.Open(LogFile);
const std::string LogFile(s_strLogPath + "/dev9null.log");
setLoggingState();
Dev9Log.Open(LogFile);
}
EXPORT_C_(void) DEV9setLogDir(const char* dir)
EXPORT_C_(void)
DEV9setLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs" : dir;
// Reload the log file after updated the path
Dev9Log.Close();
LogInit();
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
Dev9Log.Close();
LogInit();
}
EXPORT_C_(u32) PS2EgetLibType()
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_DEV9;
return PS2E_LT_DEV9;
}
EXPORT_C_(char*) PS2EgetLibName()
EXPORT_C_(char*)
PS2EgetLibName()
{
snprintf( libraryName, 255, "DEV9null Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
snprintf(libraryName, 255, "DEV9null Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version<<16) | (revision<<8) | build;
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(s32) DEV9init()
EXPORT_C_(s32)
DEV9init()
{
LoadConfig();
setLoggingState();
LogInit();
Dev9Log.WriteLn("dev9null plugin version %d,%d", revision, build);
Dev9Log.WriteLn("Initializing dev9null");
// Initialize anything that needs to be initialized.
memset(dev9regs, 0, sizeof(dev9regs));
return 0;
LoadConfig();
setLoggingState();
LogInit();
Dev9Log.WriteLn("dev9null plugin version %d,%d", revision, build);
Dev9Log.WriteLn("Initializing dev9null");
// Initialize anything that needs to be initialized.
memset(dev9regs, 0, sizeof(dev9regs));
return 0;
}
EXPORT_C_(void) DEV9shutdown()
EXPORT_C_(void)
DEV9shutdown()
{
Dev9Log.WriteLn("Shutting down Dev9null.");
Dev9Log.Close();
Dev9Log.WriteLn("Shutting down Dev9null.");
Dev9Log.Close();
}
EXPORT_C_(s32) DEV9open(void *pDsp)
EXPORT_C_(s32)
DEV9open(void* pDsp)
{
Dev9Log.WriteLn("Opening Dev9null.");
// Get anything ready we need to. Opening and creating hard
// drive files, for example.
return 0;
Dev9Log.WriteLn("Opening Dev9null.");
// Get anything ready we need to. Opening and creating hard
// drive files, for example.
return 0;
}
EXPORT_C_(void) DEV9close()
EXPORT_C_(void)
DEV9close()
{
Dev9Log.WriteLn("Closing Dev9null.");
// Close files opened.
Dev9Log.WriteLn("Closing Dev9null.");
// Close files opened.
}
EXPORT_C_(u8) DEV9read8(u32 addr)
EXPORT_C_(u8)
DEV9read8(u32 addr)
{
u8 value = 0;
switch(addr)
{
// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay)
case 0x10000038: /*value = dev9Ru8(addr);*/ break; // We need to have at least one case to avoid warnings.
switch (addr) {
// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay)
case 0x10000038: /*value = dev9Ru8(addr);*/
break; // We need to have at least one case to avoid warnings.
default:
//value = dev9Ru8(addr);
Dev9Log.WriteLn("*Unknown 8 bit read at address %lx", addr);
break;
}
return value;
return value;
}
EXPORT_C_(u16) DEV9read16(u32 addr)
EXPORT_C_(u16)
DEV9read16(u32 addr)
{
u16 value = 0;
switch(addr)
{
// Addresses you may want to catch here include:
// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay)
// case 0x10000002: // The Smart Chip revision. Should be 0x11
// case 0x10000004: // More type info: bit 0 - smap; bit 1 - hd; bit 5 - flash
// case 0x1000000E: // Similar to the last; bit 1 should be set if a hd is hooked up.
// case 0x10000028: // intr_stat
// case 0x10000038: // hard drives seem to like reading and writing the max dma size per transfer here.
// case 0x1000002A: // intr_mask
// case 0x10000040: // pio_data
// case 0x10000044: // nsector
// case 0x10000046: // sector
// case 0x10000048: // lcyl
// case 0x1000004A: // hcyl
// case 0x1000004C: // select
// case 0x1000004E: // status
// case 0x1000005C: // status
// case 0x10000064: // if_ctrl
case 0x10000038: /*value = dev9Ru16(addr);*/ break;
switch (addr) {
// Addresses you may want to catch here include:
// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay)
// case 0x10000002: // The Smart Chip revision. Should be 0x11
// case 0x10000004: // More type info: bit 0 - smap; bit 1 - hd; bit 5 - flash
// case 0x1000000E: // Similar to the last; bit 1 should be set if a hd is hooked up.
// case 0x10000028: // intr_stat
// case 0x10000038: // hard drives seem to like reading and writing the max dma size per transfer here.
// case 0x1000002A: // intr_mask
// case 0x10000040: // pio_data
// case 0x10000044: // nsector
// case 0x10000046: // sector
// case 0x10000048: // lcyl
// case 0x1000004A: // hcyl
// case 0x1000004C: // select
// case 0x1000004E: // status
// case 0x1000005C: // status
// case 0x10000064: // if_ctrl
case 0x10000038: /*value = dev9Ru16(addr);*/
break;
default:
//value = dev9Ru16(addr);
Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr);
break;
}
return value;
return value;
}
EXPORT_C_(u32 ) DEV9read32(u32 addr)
EXPORT_C_(u32)
DEV9read32(u32 addr)
{
u32 value = 0;
switch(addr)
{
case 0x10000038: /*value = dev9Ru32(addr);*/ break;
switch (addr) {
case 0x10000038: /*value = dev9Ru32(addr);*/
break;
default:
//value = dev9Ru32(addr);
Dev9Log.WriteLn("*Unknown 32 bit read at address %lx", addr);
break;
break;
}
return value;
return value;
}
EXPORT_C_(void) DEV9write8(u32 addr, u8 value)
EXPORT_C_(void)
DEV9write8(u32 addr, u8 value)
{
switch(addr)
{
case 0x10000038: /*dev9Ru8(addr) = value;*/ break;
switch (addr) {
case 0x10000038: /*dev9Ru8(addr) = value;*/
break;
default:
Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value);
//dev9Ru8(addr) = value;
break;
Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value);
//dev9Ru8(addr) = value;
break;
}
}
EXPORT_C_(void) DEV9write16(u32 addr, u16 value)
EXPORT_C_(void)
DEV9write16(u32 addr, u16 value)
{
switch(addr)
{
// Remember that list on DEV9read16? You'll want to write to a
// lot of them, too.
case 0x10000038: /*dev9Ru16(addr) = value;*/ break;
switch (addr) {
// Remember that list on DEV9read16? You'll want to write to a
// lot of them, too.
case 0x10000038: /*dev9Ru16(addr) = value;*/
break;
default:
Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value);
Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value);
//dev9Ru16(addr) = value;
break;
break;
}
}
EXPORT_C_(void) DEV9write32(u32 addr, u32 value)
EXPORT_C_(void)
DEV9write32(u32 addr, u32 value)
{
switch(addr)
{
case 0x10000038: /*dev9Ru32(addr) = value;*/ break;
switch (addr) {
case 0x10000038: /*dev9Ru32(addr) = value;*/
break;
default:
Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value);
Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value);
//dev9Ru32(addr) = value;
break;
break;
}
}
//#ifdef ENABLE_NEW_IOPDMA_DEV9
EXPORT_C_(s32) DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
EXPORT_C_(s32)
DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
{
// You'll want to put your own DMA8 reading code here.
// Time to interact with your fake (or real) hardware.
Dev9Log.WriteLn("Reading DMA8 Mem.");
*bytesProcessed = bytesLeft;
return 0;
// You'll want to put your own DMA8 reading code here.
// Time to interact with your fake (or real) hardware.
Dev9Log.WriteLn("Reading DMA8 Mem.");
*bytesProcessed = bytesLeft;
return 0;
}
EXPORT_C_(s32) DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
EXPORT_C_(s32)
DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
{
// See above.
Dev9Log.WriteLn("Writing DMA8 Mem.");
*bytesProcessed = bytesLeft;
return 0;
// See above.
Dev9Log.WriteLn("Writing DMA8 Mem.");
*bytesProcessed = bytesLeft;
return 0;
}
EXPORT_C_(void) DEV9dmaInterrupt(s32 channel)
EXPORT_C_(void)
DEV9dmaInterrupt(s32 channel)
{
// See above.
// See above.
}
//#else
EXPORT_C_(void) DEV9readDMA8Mem(u32 *pMem, int size)
EXPORT_C_(void)
DEV9readDMA8Mem(u32* pMem, int size)
{
// You'll want to put your own DMA8 reading code here.
// Time to interact with your fake (or real) hardware.
Dev9Log.WriteLn("Reading DMA8 Mem.");
// You'll want to put your own DMA8 reading code here.
// Time to interact with your fake (or real) hardware.
Dev9Log.WriteLn("Reading DMA8 Mem.");
}
EXPORT_C_(void) DEV9writeDMA8Mem(u32* pMem, int size)
EXPORT_C_(void)
DEV9writeDMA8Mem(u32* pMem, int size)
{
// See above.
Dev9Log.WriteLn("Writing DMA8 Mem.");
// See above.
Dev9Log.WriteLn("Writing DMA8 Mem.");
}
//#endif
EXPORT_C_(void) DEV9irqCallback(DEV9callback callback)
EXPORT_C_(void)
DEV9irqCallback(DEV9callback callback)
{
// Setting our callback. You will call it with DEV9irq(cycles),
// Where cycles is the number of cycles till the irq is triggered.
DEV9irq = callback;
// Setting our callback. You will call it with DEV9irq(cycles),
// Where cycles is the number of cycles till the irq is triggered.
DEV9irq = callback;
}
int _DEV9irqHandler(void)
{
// And this gets called when the irq is triggered.
return 0;
// And this gets called when the irq is triggered.
return 0;
}
EXPORT_C_(DEV9handler) DEV9irqHandler(void)
EXPORT_C_(DEV9handler)
DEV9irqHandler(void)
{
// Pass it to pcsx2.
return (DEV9handler)_DEV9irqHandler;
// Pass it to pcsx2.
return (DEV9handler)_DEV9irqHandler;
}
EXPORT_C_(void) DEV9setSettingsDir(const char* dir)
EXPORT_C_(void)
DEV9setSettingsDir(const char* dir)
{
// Grab the ini directory.
// Grab the ini directory.
s_strIniPath = (dir == NULL) ? "inis" : dir;
}
// extended funcs
EXPORT_C_(s32) DEV9test()
EXPORT_C_(s32)
DEV9test()
{
return 0;
return 0;
}
EXPORT_C_(s32) DEV9freeze(int mode, freezeData *data)
EXPORT_C_(s32)
DEV9freeze(int mode, freezeData* data)
{
// This should store or retrieve any information, for if emulation
// gets suspended, or for savestates.
switch(mode)
{
case FREEZE_LOAD:
// Load previously saved data.
break;
case FREEZE_SAVE:
// Save data.
break;
case FREEZE_SIZE:
// return the size of the data.
break;
}
return 0;
// This should store or retrieve any information, for if emulation
// gets suspended, or for savestates.
switch (mode) {
case FREEZE_LOAD:
// Load previously saved data.
break;
case FREEZE_SAVE:
// Save data.
break;
case FREEZE_SIZE:
// return the size of the data.
break;
}
return 0;
}
/* For operating systems that need an entry point for a dll/library, here it is. Defined in PS2Eext.h. */

View File

@ -25,8 +25,9 @@
#include "PS2Edefs.h"
#include "PS2Eext.h"
typedef struct {
s32 Log;
typedef struct
{
s32 Log;
} Config;
extern Config conf;
@ -42,12 +43,12 @@ void LoadConfig();
extern void (*DEV9irq)(int);
extern __aligned16 s8 dev9regs[0x10000];
#define dev9Rs8(mem) dev9regs[(mem) & 0xffff]
#define dev9Rs16(mem) (*(s16*)&dev9regs[(mem) & 0xffff])
#define dev9Rs32(mem) (*(s32*)&dev9regs[(mem) & 0xffff])
#define dev9Ru8(mem) (*(u8*) &dev9regs[(mem) & 0xffff])
#define dev9Ru16(mem) (*(u16*)&dev9regs[(mem) & 0xffff])
#define dev9Ru32(mem) (*(u32*)&dev9regs[(mem) & 0xffff])
#define dev9Rs8(mem) dev9regs[(mem)&0xffff]
#define dev9Rs16(mem) (*(s16*)&dev9regs[(mem)&0xffff])
#define dev9Rs32(mem) (*(s32*)&dev9regs[(mem)&0xffff])
#define dev9Ru8(mem) (*(u8*)&dev9regs[(mem)&0xffff])
#define dev9Ru16(mem) (*(u16*)&dev9regs[(mem)&0xffff])
#define dev9Ru32(mem) (*(u32*)&dev9regs[(mem)&0xffff])
extern void setLoggingState();