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
|
2016-08-24 21:17:32 +00:00
|
|
|
#include "svnrev.h"
|
2012-06-18 21:16:25 +00:00
|
|
|
#endif
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
const unsigned char version = PS2E_GS_VERSION;
|
2009-10-30 22:34:27 +00:00
|
|
|
const unsigned char revision = 0;
|
2016-10-16 19:39:56 +00:00
|
|
|
const unsigned char build = 1; // increase that with each version
|
2009-10-30 22:34:27 +00:00
|
|
|
|
|
|
|
Config conf;
|
|
|
|
u32 GSKeyEvent = 0;
|
|
|
|
bool GSShift = false, GSAlt = false;
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
string s_strIniPath = "inis";
|
2011-10-30 01:39:43 +00:00
|
|
|
extern std::string s_strLogPath;
|
2016-08-28 16:14:07 +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
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(u32)
|
|
|
|
PS2EgetLibType()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
return PS2E_LT_GS;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 09:27:43 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
static char libraryName[256];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EXPORT_C_(const char *)
|
2016-08-24 21:17:32 +00:00
|
|
|
PS2EgetLibName()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2012-06-18 21:16:25 +00:00
|
|
|
#ifdef _MSC_VER
|
2016-08-24 21:17:32 +00:00
|
|
|
sprintf_s(libraryName, "GSnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
|
|
|
return libraryName;
|
2012-06-20 18:00:08 +00:00
|
|
|
#else
|
2016-08-24 21:17:32 +00:00
|
|
|
return "GSnull Driver";
|
2012-06-18 21:16:25 +00:00
|
|
|
#endif
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(u32)
|
|
|
|
PS2EgetLibVersion2(u32 type)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
return (version << 16) | (revision << 8) | build;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// basic funcs
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSsetSettingsDir(const char *dir)
|
2010-06-10 16:30:08 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
2010-06-10 16:30:08 +00:00
|
|
|
}
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSsetLogDir(const char *dir)
|
2010-06-11 17:31:45 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
// Get the path to the log directory.
|
|
|
|
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
2010-06-11 17:31:45 +00:00
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
// Reload the log file after updated the path
|
|
|
|
GSLog::Close();
|
|
|
|
GSLog::Open();
|
2010-06-11 17:31:45 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(s32)
|
|
|
|
GSinit()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
LoadConfig();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::Open();
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("Initializing GSnull.");
|
|
|
|
return 0;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSshutdown()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("Shutting down GSnull.");
|
|
|
|
GSCloseWindow();
|
|
|
|
GSLog::Close();
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(s32)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSopen(void *pDsp, const char *Title, int multithread)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
int err = 0;
|
|
|
|
GSLog::WriteLn("GS open.");
|
|
|
|
//assert( GSirq != NULL );
|
|
|
|
|
|
|
|
err = GSOpenWindow(pDsp, Title);
|
|
|
|
gs.MultiThreaded = multithread;
|
|
|
|
|
|
|
|
ResetRegs();
|
|
|
|
SetMultithreaded();
|
|
|
|
InitPath();
|
|
|
|
GSLog::WriteLn("Opening GSnull.");
|
|
|
|
return err;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
#ifdef USE_GSOPEN2
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(s32)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSopen2(void *pDsp, u32 flags)
|
2009-12-26 00:01:30 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("GS open2.");
|
2009-12-26 00:01:30 +00:00
|
|
|
|
|
|
|
GSOpenWindow2(pDsp, flags);
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
gs.MultiThreaded = true;
|
2010-08-06 22:58:30 +00:00
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
ResetRegs();
|
|
|
|
SetMultithreaded();
|
|
|
|
InitPath();
|
|
|
|
GSLog::WriteLn("Opening GSnull (2).");
|
|
|
|
return 0;
|
2009-12-26 00:01:30 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSclose()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("Closing GSnull.");
|
2009-12-19 18:30:56 +00:00
|
|
|
|
2016-08-24 21:17:32 +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
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSirqCallback(void (*callback)())
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSirq = callback;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(s32)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSfreeze(int mode, freezeData *data)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
return 0;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(s32)
|
|
|
|
GStest()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("Testing GSnull.");
|
|
|
|
return 0;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSvsync(int field)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSProcessMessages();
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
// returns the last tag processed (64 bits)
|
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSgetLastTag(u64 *ptag)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-28 16:14:07 +00:00
|
|
|
*(u32 *)ptag = gs.nPath3Hack;
|
2016-08-24 21:17:32 +00:00
|
|
|
gs.nPath3Hack = 0;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSgifSoftReset(u32 mask)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("Doing a soft reset of the GS plugin.");
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSreadFIFO(u64 *mem)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSreadFIFO2(u64 *mem, int qwc)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// extended funcs
|
|
|
|
|
|
|
|
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSkeyEvent(keyEvent *ev)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
HandleKeyEvent(ev);
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSchangeSaveState(int, const char *filename)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSmakeSnapshot(char *path)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("Taking a snapshot.");
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSmakeSnapshot2(char *pathname, int *snapdone, int savejpg)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("Taking a snapshot to %s.", pathname);
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSsetBaseMem(void *)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSsetGameCRC(int crc, int gameoptions)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +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
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSsetFrameSkip(int frameskip)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
SetFrameSkip(frameskip != 0);
|
|
|
|
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
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(int)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSsetupRecording(int start, void *pData)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
if (start)
|
|
|
|
GSLog::WriteLn("Pretending to record.");
|
|
|
|
else
|
|
|
|
GSLog::WriteLn("Pretending to stop recording.");
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
return 1;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSreset()
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2016-08-24 21:17:32 +00:00
|
|
|
GSLog::WriteLn("Doing a reset of the GS plugin.");
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
|
|
|
GSwriteCSR(u32 value)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-24 21:17:32 +00:00
|
|
|
EXPORT_C_(void)
|
2016-08-28 16:14:07 +00:00
|
|
|
GSgetDriverInfo(GSdriverInfo *info)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
}
|