pcsx2/plugins/GSnull/GS.cpp

291 lines
5.4 KiB
C++
Raw Normal View History

/* GSnull
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <string>
#include <stdio.h>
#include <assert.h>
using namespace std;
#include "GS.h"
#include "GifTransfer.h"
#include "null/GSnull.h"
#ifdef _MSC_VER
2016-08-24 21:17:32 +00:00
#include "svnrev.h"
#endif
2016-08-24 21:17:32 +00:00
const unsigned char version = PS2E_GS_VERSION;
const unsigned char revision = 0;
const unsigned char build = 1; // increase that with each version
Config conf;
u32 GSKeyEvent = 0;
bool GSShift = false, GSAlt = false;
2016-08-24 21:17:32 +00:00
string s_strIniPath = "inis";
extern std::string s_strLogPath;
const char *s_iniFilename = "GSnull.ini";
GSVars gs;
// Because I haven't bothered to get GSOpen2 working in Windows yet in GSNull.
#ifdef __linux__
#define USE_GSOPEN2
#endif
void (*GSirq)();
extern void ResetRegs();
extern void SetMultithreaded();
extern void SetFrameSkip(bool skip);
extern void InitPath();
2016-08-24 21:17:32 +00:00
EXPORT_C_(u32)
PS2EgetLibType()
{
2016-08-24 21:17:32 +00:00
return PS2E_LT_GS;
}
#ifdef _MSC_VER
static char libraryName[256];
#endif
EXPORT_C_(const char *)
2016-08-24 21:17:32 +00:00
PS2EgetLibName()
{
#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;
#else
2016-08-24 21:17:32 +00:00
return "GSnull Driver";
#endif
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
2016-08-24 21:17:32 +00:00
return (version << 16) | (revision << 8) | build;
}
// basic funcs
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSsetSettingsDir(const char *dir)
{
2016-08-24 21:17:32 +00:00
s_strIniPath = (dir == NULL) ? "inis" : dir;
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSsetLogDir(const char *dir)
{
2016-08-24 21:17:32 +00:00
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir;
2016-08-24 21:17:32 +00:00
// Reload the log file after updated the path
GSLog::Close();
GSLog::Open();
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(s32)
GSinit()
{
2016-08-24 21:17:32 +00:00
LoadConfig();
2016-08-24 21:17:32 +00:00
GSLog::Open();
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("Initializing GSnull.");
return 0;
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSshutdown()
{
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("Shutting down GSnull.");
GSCloseWindow();
GSLog::Close();
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(s32)
GSopen(void *pDsp, const char *Title, int multithread)
{
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;
}
#ifdef USE_GSOPEN2
2016-08-24 21:17:32 +00:00
EXPORT_C_(s32)
GSopen2(void *pDsp, u32 flags)
{
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("GS open2.");
GSOpenWindow2(pDsp, flags);
2016-08-24 21:17:32 +00:00
gs.MultiThreaded = true;
2016-08-24 21:17:32 +00:00
ResetRegs();
SetMultithreaded();
InitPath();
GSLog::WriteLn("Opening GSnull (2).");
return 0;
}
#endif
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSclose()
{
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("Closing GSnull.");
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();
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSirqCallback(void (*callback)())
{
2016-08-24 21:17:32 +00:00
GSirq = callback;
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(s32)
GSfreeze(int mode, freezeData *data)
{
2016-08-24 21:17:32 +00:00
return 0;
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(s32)
GStest()
{
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("Testing GSnull.");
return 0;
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSvsync(int field)
{
2016-08-24 21:17:32 +00:00
GSProcessMessages();
}
2016-08-24 21:17:32 +00:00
// returns the last tag processed (64 bits)
EXPORT_C_(void)
GSgetLastTag(u64 *ptag)
{
*(u32 *)ptag = gs.nPath3Hack;
2016-08-24 21:17:32 +00:00
gs.nPath3Hack = 0;
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSgifSoftReset(u32 mask)
{
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("Doing a soft reset of the GS plugin.");
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSreadFIFO(u64 *mem)
{
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSreadFIFO2(u64 *mem, int qwc)
{
}
// 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)
GSkeyEvent(keyEvent *ev)
{
2016-08-24 21:17:32 +00:00
HandleKeyEvent(ev);
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSchangeSaveState(int, const char *filename)
{
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSmakeSnapshot(char *path)
{
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("Taking a snapshot.");
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSmakeSnapshot2(char *pathname, int *snapdone, int savejpg)
{
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("Taking a snapshot to %s.", pathname);
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSsetBaseMem(void *)
{
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSsetGameCRC(int crc, int gameoptions)
{
2016-08-24 21:17:32 +00:00
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
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSsetFrameSkip(int frameskip)
{
2016-08-24 21:17:32 +00:00
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
2016-08-24 21:17:32 +00:00
EXPORT_C_(int)
GSsetupRecording(int start, void *pData)
{
2016-08-24 21:17:32 +00:00
if (start)
GSLog::WriteLn("Pretending to record.");
else
GSLog::WriteLn("Pretending to stop recording.");
2016-08-24 21:17:32 +00:00
return 1;
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSreset()
{
2016-08-24 21:17:32 +00:00
GSLog::WriteLn("Doing a reset of the GS plugin.");
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSwriteCSR(u32 value)
{
}
2016-08-24 21:17:32 +00:00
EXPORT_C_(void)
GSgetDriverInfo(GSdriverInfo *info)
{
}