GSnull reformat

This commit is contained in:
Clang Format 2016-08-24 23:17:32 +02:00 committed by Gregory Hainaut
parent e61d14168a
commit 25b0b63216
17 changed files with 1656 additions and 1647 deletions

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;
u32 CSRw;
pathInfo path[4];
bool Path3transfer;
float q;
u32 imageTransfer;
int MultiThreaded;
int nPath3Hack;
GIFReg regs;
GIFCTXTReg ctxt_regs[2];
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;
FILE* gsLog;
bool Open()
{
bool result = true;
bool Open()
{
bool result = true;
const std::string LogFile(s_strLogPath + "/GSnull.log");
const std::string LogFile(s_strLogPath + "/GSnull.log");
gsLog = fopen(LogFile.c_str(), "w");
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;
}
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.");
WriteLn("GSnull plugin version %d,%d", revision, build);
WriteLn("GS init.");
return result;
}
return result;
}
void Close()
{
if (gsLog)
{
fclose(gsLog);
gsLog = NULL;
}
}
void Close()
{
if (gsLog) {
fclose(gsLog);
gsLog = NULL;
}
}
void Log(char *fmt, ...)
{
va_list list;
void Log(char* fmt, ...)
{
va_list list;
if (!conf.Log || gsLog == NULL) return;
if (!conf.Log || gsLog == NULL)
return;
va_start(list, fmt);
vfprintf(gsLog, fmt, list);
va_end(list);
}
va_start(list, fmt);
vfprintf(gsLog, fmt, list);
va_end(list);
}
void Message(char *fmt, ...)
{
va_list list;
char msg[512];
void Message(char* fmt, ...)
{
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);
SysMessage("%s\n",msg);
}
SysMessage("%s\n", msg);
}
void Print(const char *fmt, ...)
{
va_list list;
char msg[512];
void Print(const char* fmt, ...)
{
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);
Log(msg);
fprintf(stderr, "GSnull:%s", msg);
}
Log(msg);
fprintf(stderr, "GSnull:%s", msg);
}
void WriteLn(const char *fmt, ...)
{
va_list list;
char msg[512];
void WriteLn(const char* fmt, ...)
{
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);
Log("%s\n", msg);
fprintf(stderr, "GSnull:%s\n", msg);
}
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];
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--;
while (size > 0) {
//GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size);
if (path->nloop == 0) {
path->setTag(pMem);
pMem += 4;
size--;
// eeuser 7.2.2. GIFtag: "... when NLOOP is 0, the GIF does not output anything, and
// values other than the EOP field are disregarded."
if (path->nloop > 0)
{
gs.q = 1.0f;
// 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->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
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
if (path->adonly && size >= path->nloop)
{
size -= path->nloop;
if (path->adonly && size >= path->nloop) {
size -= path->nloop;
do
{
GIFPackedRegHandlerA_D(pMem);
do {
GIFPackedRegHandlerA_D(pMem);
pMem += 4; //sizeof(GIFPackedReg)/4;
}
while(--path->nloop > 0);
break;
}
pMem += 4; //sizeof(GIFPackedReg)/4;
} while (--path->nloop > 0);
break;
}
do
{
u32 reg = path->GetReg();
GIFPackedRegHandlers[reg](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;
size--;
} while (path->StepReg() && (size > 0));
break;
}
break;
}
case GIF_FLG_REGLIST:
{
//GSLog::Writeln("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
case GIF_FLG_REGLIST: {
//GSLog::Writeln("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
size *= 2;
size *= 2;
do
{
GIFRegHandlers[path->GetReg()](pMem);
do {
GIFRegHandlers[path->GetReg()](pMem);
pMem += 2;
size--;
}
while (path->StepReg() && (size > 0));
pMem += 2;
size--;
} while (path->StepReg() && (size > 0));
if (size & 1) pMem += 2;
size /= 2;
break;
}
if (size & 1)
pMem += 2;
size /= 2;
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 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);
switch (gs.imageTransfer)
{
case 0:
//TransferHostLocal(pMem, len * 4);
break;
switch (gs.imageTransfer) {
case 0:
//TransferHostLocal(pMem, len * 4);
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 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 2:
// //TransferLocalLocal();
break;
case 2:
// //TransferLocalLocal();
break;
case 3:
//assert(0);
break;
case 3:
//assert(0);
break;
default:
//assert(0);
break;
}
default:
//assert(0);
break;
}
pMem += len * 4;
pMem += len * 4;
path->nloop -= len;
size -= len;
path->nloop -= len;
size -= len;
break;
}
break;
}
default: // GIF_IMAGE
GSLog::WriteLn("*** WARNING **** Unexpected GIFTag flag.");
assert(0);
path->nloop = 0;
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

@ -35,13 +35,13 @@ void __gifCall GIFPackedRegHandlerPRIM(const u32* data) { GIFRegHandlerPRIM(data
template <u32 i>
void __gifCall GIFPackedRegHandlerTEX0(const u32* data)
{
GIFRegHandlerTEX0<i>(data);
GIFRegHandlerTEX0<i>(data);
}
template <u32 i>
void __gifCall GIFPackedRegHandlerCLAMP(const u32* data)
{
GIFRegHandlerCLAMP<i>(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);
GIFPackedA_D* r = (GIFPackedA_D*)(data);
GIFRegHandlers[r->ADDR](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;
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;
}
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();
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()
{
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 (!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 (!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!");
}