2009-10-30 22:34:27 +00:00
|
|
|
/* GSnull
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-11-01 06:47:32 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-10-30 22:34:27 +00:00
|
|
|
*
|
2009-11-01 06:47:32 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-10-30 22:34:27 +00:00
|
|
|
*
|
2009-11-01 06:47:32 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-10-30 22:34:27 +00:00
|
|
|
*/
|
|
|
|
|
2009-11-01 06:47:32 +00:00
|
|
|
|
2009-10-30 22:34:27 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "GS.h"
|
2010-08-06 09:30:36 +00:00
|
|
|
#include "GifTransfer.h"
|
2009-10-30 22:34:27 +00:00
|
|
|
#include "null/GSnull.h"
|
2012-06-18 21:16:25 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# include "svnrev.h"
|
|
|
|
#endif
|
2009-10-30 22:34:27 +00:00
|
|
|
|
|
|
|
const unsigned char version = PS2E_GS_VERSION;
|
|
|
|
const unsigned char revision = 0;
|
|
|
|
const unsigned char build = 1; // increase that with each version
|
|
|
|
|
2012-06-18 21:16:25 +00:00
|
|
|
static char libraryName[256];
|
2009-10-30 22:34:27 +00:00
|
|
|
Config conf;
|
|
|
|
u32 GSKeyEvent = 0;
|
|
|
|
bool GSShift = false, GSAlt = false;
|
|
|
|
|
2009-12-19 18:30:56 +00:00
|
|
|
string s_strIniPath="inis";
|
2011-10-30 01:39:43 +00:00
|
|
|
extern std::string s_strLogPath;
|
2009-12-19 18:30:56 +00:00
|
|
|
const char* s_iniFilename = "GSnull.ini";
|
2010-08-06 09:30:36 +00:00
|
|
|
GSVars gs;
|
2009-12-19 18:30:56 +00:00
|
|
|
|
2009-12-26 00:01:30 +00:00
|
|
|
// Because I haven't bothered to get GSOpen2 working in Windows yet in GSNull.
|
2014-08-03 18:11:22 +00:00
|
|
|
#ifdef __linux__
|
2009-12-26 00:01:30 +00:00
|
|
|
#define USE_GSOPEN2
|
|
|
|
#endif
|
|
|
|
|
2009-10-30 22:34:27 +00:00
|
|
|
void (*GSirq)();
|
2010-08-06 22:58:30 +00:00
|
|
|
extern void ResetRegs();
|
|
|
|
extern void SetMultithreaded();
|
|
|
|
extern void SetFrameSkip(bool skip);
|
|
|
|
extern void InitPath();
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(u32) PS2EgetLibType()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
return PS2E_LT_GS;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(char*) PS2EgetLibName()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2012-06-18 21:16:25 +00:00
|
|
|
#ifdef _MSC_VER
|
2014-03-23 14:44:43 +00:00
|
|
|
sprintf_s( libraryName, "GSnull Driver %lld%s",SVN_REV, SVN_MODS ? "m" : "");
|
2012-06-18 21:16:25 +00:00
|
|
|
return libraryName;
|
2012-06-20 18:00:08 +00:00
|
|
|
#else
|
2012-06-18 21:16:25 +00:00
|
|
|
return "GSnull Driver";
|
|
|
|
#endif
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
return (version<<16) | (revision<<8) | build;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSprintf(int timeout, char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
char msg[512];
|
|
|
|
|
|
|
|
va_start(list, fmt);
|
|
|
|
vsprintf(msg, fmt, list);
|
|
|
|
va_end(list);
|
|
|
|
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::Print("GSprintf:%s", msg);
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// basic funcs
|
2010-06-10 16:30:08 +00:00
|
|
|
EXPORT_C_(void) GSsetSettingsDir(const char* dir)
|
|
|
|
{
|
2011-03-25 01:09:18 +00:00
|
|
|
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
2010-06-10 16:30:08 +00:00
|
|
|
}
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-06-11 17:31:45 +00:00
|
|
|
EXPORT_C_(void) GSsetLogDir(const char* dir)
|
|
|
|
{
|
|
|
|
// Get the path to the log directory.
|
2011-03-25 01:09:18 +00:00
|
|
|
s_strLogPath = (dir==NULL) ? "logs" : dir;
|
2010-06-11 17:31:45 +00:00
|
|
|
|
|
|
|
// Reload the log file after updated the path
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::Close();
|
|
|
|
GSLog::Open();
|
2010-06-11 17:31:45 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 22:34:27 +00:00
|
|
|
EXPORT_C_(s32) GSinit()
|
|
|
|
{
|
|
|
|
LoadConfig();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::Open();
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Initializing GSnull.");
|
2009-10-30 22:34:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSshutdown()
|
|
|
|
{
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Shutting down GSnull.");
|
2009-12-19 18:30:56 +00:00
|
|
|
GSCloseWindow();
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::Close();
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2015-11-06 22:25:55 +00:00
|
|
|
EXPORT_C_(s32) GSopen(void *pDsp, const char *Title, int multithread)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
int err = 0;
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("GS open.");
|
2009-10-30 22:34:27 +00:00
|
|
|
//assert( GSirq != NULL );
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-10-30 22:34:27 +00:00
|
|
|
err = GSOpenWindow(pDsp, Title);
|
2010-08-06 22:58:30 +00:00
|
|
|
gs.MultiThreaded = multithread;
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 22:58:30 +00:00
|
|
|
ResetRegs();
|
|
|
|
SetMultithreaded();
|
|
|
|
InitPath();
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Opening GSnull.");
|
2009-10-30 22:34:27 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
#ifdef USE_GSOPEN2
|
2009-12-26 00:01:30 +00:00
|
|
|
EXPORT_C_(s32) GSopen2( void *pDsp, u32 flags )
|
|
|
|
{
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("GS open2.");
|
2009-12-26 00:01:30 +00:00
|
|
|
|
|
|
|
GSOpenWindow2(pDsp, flags);
|
|
|
|
|
2010-08-06 22:58:30 +00:00
|
|
|
gs.MultiThreaded = true;
|
|
|
|
|
|
|
|
ResetRegs();
|
|
|
|
SetMultithreaded();
|
|
|
|
InitPath();
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Opening GSnull (2).");
|
2009-12-26 00:01:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-10-30 22:34:27 +00:00
|
|
|
EXPORT_C_(void) GSclose()
|
|
|
|
{
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Closing GSnull.");
|
2009-12-19 18:30:56 +00:00
|
|
|
|
|
|
|
// 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();
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(void) GSirqCallback(void (*callback)())
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
GSirq = callback;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(s32) GSfreeze(int mode, freezeData *data)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(s32) GStest()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Testing GSnull.");
|
2009-10-30 22:34:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSvsync(int field)
|
|
|
|
{
|
|
|
|
GSProcessMessages();
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns the last tag processed (64 bits)
|
|
|
|
EXPORT_C_(void) GSgetLastTag(u64* ptag)
|
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
*(u32*)ptag = gs.nPath3Hack;
|
|
|
|
gs.nPath3Hack = 0;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSgifSoftReset(u32 mask)
|
|
|
|
{
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Doing a soft reset of the GS plugin.");
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSreadFIFO(u64 *mem)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
HandleKeyEvent(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSchangeSaveState(int, const char* filename)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSmakeSnapshot(char *path)
|
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Taking a snapshot.");
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg)
|
|
|
|
{
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Taking a snapshot to %s.", pathname);
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSsetBaseMem(void*)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSsetGameCRC(int crc, int gameoptions)
|
|
|
|
{
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Setting the crc to '%x' with 0x%x for options.", crc, gameoptions);
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done
|
|
|
|
EXPORT_C_(void) GSsetFrameSkip(int frameskip)
|
|
|
|
{
|
2010-08-06 22:58:30 +00:00
|
|
|
SetFrameSkip(frameskip != 0);
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Frameskip set to %d.", frameskip);
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
if (start)
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Pretending to record.");
|
2010-04-25 00:31:27 +00:00
|
|
|
else
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Pretending to stop recording.");
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-10-30 22:34:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSreset()
|
|
|
|
{
|
2011-10-30 01:39:43 +00:00
|
|
|
GSLog::WriteLn("Doing a reset of the GS plugin.");
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSwriteCSR(u32 value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSgetDriverInfo(GSdriverInfo *info)
|
|
|
|
{
|
|
|
|
}
|