2010-07-10 08:20:50 +00:00
|
|
|
/* ZZ Open GL graphics plugin
|
|
|
|
* Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
|
|
|
|
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
|
2010-03-19 00:31:15 +00:00
|
|
|
*
|
2010-07-10 08:20:50 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2010-03-19 00:31:15 +00:00
|
|
|
*
|
2010-07-10 08:20:50 +00:00
|
|
|
* This program 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.
|
2010-03-19 00:31:15 +00:00
|
|
|
*
|
2010-07-10 08:20:50 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2010-03-19 00:31:15 +00:00
|
|
|
*/
|
|
|
|
|
2010-11-09 12:04:07 +00:00
|
|
|
#include "Util.h"
|
2010-03-19 00:31:15 +00:00
|
|
|
#include "GS.h"
|
2010-05-02 03:09:20 +00:00
|
|
|
#include "Profile.h"
|
2010-09-01 10:28:37 +00:00
|
|
|
#include "GLWin.h"
|
2010-09-15 16:54:19 +00:00
|
|
|
#include "ZZoglFlushHack.h"
|
2012-04-19 21:22:08 +00:00
|
|
|
#include "ZZoglShaders.h"
|
2010-11-09 12:04:07 +00:00
|
|
|
|
2010-11-14 01:38:10 +00:00
|
|
|
|
2010-11-09 12:04:07 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
extern void SaveSnapshot(const char* filename);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(disable:4244)
|
|
|
|
#endif
|
|
|
|
|
2010-07-02 12:10:40 +00:00
|
|
|
GLWindow GLWin;
|
2010-03-19 00:31:15 +00:00
|
|
|
GSinternal gs;
|
|
|
|
GSconf conf;
|
2012-04-07 21:23:01 +00:00
|
|
|
GSDump g_dump;
|
2010-07-02 12:10:40 +00:00
|
|
|
|
|
|
|
int ppf, g_GSMultiThreaded, CurrentSavestate = 0;
|
|
|
|
int g_LastCRC = 0, g_TransferredToGPU = 0, s_frameskipping = 0;
|
2010-08-17 13:38:57 +00:00
|
|
|
int g_SkipFlushFrame = 0;
|
2010-08-18 16:55:45 +00:00
|
|
|
GetSkipCount GetSkipCount_Handler = 0;
|
2010-07-02 12:10:40 +00:00
|
|
|
|
|
|
|
int UPDATE_FRAMES = 16, g_nFrame = 0, g_nRealFrame = 0;
|
|
|
|
float fFPS = 0;
|
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
void (*GSirq)();
|
|
|
|
u8* g_pBasePS2Mem = NULL;
|
2011-03-25 01:09:18 +00:00
|
|
|
wxString s_strIniPath(L"inis"); // Air's new ini path (r2361)
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
bool SaveStateExists = true; // We could not know save slot status before first change occured
|
|
|
|
const char* SaveStateFile = NULL; // Name of SaveFile for access check.
|
|
|
|
|
2010-07-02 10:33:44 +00:00
|
|
|
extern const char* s_aa[5];
|
|
|
|
extern const char* pbilinear[];
|
2010-03-19 00:31:15 +00:00
|
|
|
// statistics
|
|
|
|
u32 g_nGenVars = 0, g_nTexVars = 0, g_nAlphaVars = 0, g_nResolve = 0;
|
|
|
|
|
2010-10-15 09:32:41 +00:00
|
|
|
#define VER 3
|
2010-03-19 00:31:15 +00:00
|
|
|
const unsigned char zgsversion = PS2E_GS_VERSION;
|
|
|
|
unsigned char zgsrevision = 0; // revision and build gives plugin version
|
|
|
|
unsigned char zgsbuild = VER;
|
2010-03-19 01:00:53 +00:00
|
|
|
unsigned char zgsminor = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2010-03-19 01:00:53 +00:00
|
|
|
char *libraryName = "ZZ Ogl PG (Debug) ";
|
2010-04-25 09:02:36 +00:00
|
|
|
#elif defined(ZEROGS_DEVBUILD)
|
|
|
|
char *libraryName = "ZZ Ogl PG (Dev)";
|
2010-03-19 00:31:15 +00:00
|
|
|
#else
|
2010-04-25 09:02:36 +00:00
|
|
|
char *libraryName = "ZZ Ogl PG ";
|
2010-03-19 00:31:15 +00:00
|
|
|
#endif
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-06-11 11:48:07 +00:00
|
|
|
extern int g_nPixelShaderVer, g_nFrameRender, g_nFramesSkipped;
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-07-02 10:33:44 +00:00
|
|
|
extern void WriteAA();
|
|
|
|
extern void WriteBilinear();
|
2010-10-18 11:24:40 +00:00
|
|
|
extern void ZZDestroy();
|
|
|
|
extern bool ZZCreate(int width, int height);
|
|
|
|
extern void ZZGSStateReset();
|
2010-11-14 01:38:10 +00:00
|
|
|
extern int ZZSave(s8* pbydata);
|
|
|
|
extern bool ZZLoad(s8* pbydata);
|
2010-10-18 11:24:40 +00:00
|
|
|
|
|
|
|
// switches the render target to the real target, flushes the current render targets and renders the real image
|
2012-04-19 21:22:08 +00:00
|
|
|
extern void RenderCRTC();
|
2010-07-02 10:33:44 +00:00
|
|
|
|
2010-11-14 01:38:10 +00:00
|
|
|
#if defined(_WIN32) && defined(_DEBUG)
|
|
|
|
HANDLE g_hCurrentThread = NULL;
|
|
|
|
#endif
|
|
|
|
|
2010-07-02 12:10:40 +00:00
|
|
|
extern int VALIDATE_THRESH;
|
|
|
|
extern u32 TEXDESTROY_THRESH;
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(u32) PS2EgetLibType()
|
2010-05-01 20:33:53 +00:00
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
return PS2E_LT_GS;
|
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(char*) PS2EgetLibName()
|
2010-05-01 20:33:53 +00:00
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
return libraryName;
|
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
|
2010-05-01 20:33:53 +00:00
|
|
|
{
|
|
|
|
return (zgsversion << 16) | (zgsrevision << 8) | zgsbuild | (zgsminor << 24);
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSsetBaseMem(void* pmem)
|
2010-05-01 20:33:53 +00:00
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
g_pBasePS2Mem = (u8*)pmem;
|
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSsetSettingsDir(const char* dir)
|
2010-05-01 20:33:53 +00:00
|
|
|
{
|
2011-03-25 01:09:18 +00:00
|
|
|
s_strIniPath = (dir == NULL) ? wxString(L"inis") : wxString(dir, wxConvFile);
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSsetLogDir(const char* dir)
|
2010-06-11 17:31:45 +00:00
|
|
|
{
|
2010-07-02 12:10:40 +00:00
|
|
|
ZZLog::SetDir(dir);
|
2010-06-11 17:31:45 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSsetGameCRC(int crc, int options)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
2010-08-18 13:15:43 +00:00
|
|
|
// build a list of function pointer for GetSkipCount (SkipDraw)
|
2010-08-18 12:32:24 +00:00
|
|
|
static GetSkipCount GSC_list[NUMBER_OF_TITLES];
|
2010-08-17 13:38:57 +00:00
|
|
|
static bool inited = false;
|
2010-08-18 12:32:24 +00:00
|
|
|
|
|
|
|
if (!inited)
|
2010-08-17 13:38:57 +00:00
|
|
|
{
|
|
|
|
inited = true;
|
|
|
|
|
2010-08-18 16:55:45 +00:00
|
|
|
memset(GSC_list, 0, sizeof(GSC_list));
|
2010-08-18 12:32:24 +00:00
|
|
|
|
2010-08-17 13:38:57 +00:00
|
|
|
GSC_list[Okami] = GSC_Okami;
|
|
|
|
GSC_list[MetalGearSolid3] = GSC_MetalGearSolid3;
|
|
|
|
GSC_list[DBZBT2] = GSC_DBZBT2;
|
|
|
|
GSC_list[DBZBT3] = GSC_DBZBT3;
|
|
|
|
GSC_list[SFEX3] = GSC_SFEX3;
|
|
|
|
GSC_list[Bully] = GSC_Bully;
|
|
|
|
GSC_list[BullyCC] = GSC_BullyCC;
|
|
|
|
GSC_list[SoTC] = GSC_SoTC;
|
|
|
|
GSC_list[OnePieceGrandAdventure] = GSC_OnePieceGrandAdventure;
|
|
|
|
GSC_list[OnePieceGrandBattle] = GSC_OnePieceGrandBattle;
|
|
|
|
GSC_list[ICO] = GSC_ICO;
|
|
|
|
GSC_list[GT4] = GSC_GT4;
|
2010-10-31 15:27:36 +00:00
|
|
|
GSC_list[WildArms4] = GSC_WildArms4;
|
2010-08-17 13:38:57 +00:00
|
|
|
GSC_list[WildArms5] = GSC_WildArms5;
|
|
|
|
GSC_list[Manhunt2] = GSC_Manhunt2;
|
|
|
|
GSC_list[CrashBandicootWoC] = GSC_CrashBandicootWoC;
|
|
|
|
GSC_list[ResidentEvil4] = GSC_ResidentEvil4;
|
|
|
|
GSC_list[Spartan] = GSC_Spartan;
|
|
|
|
GSC_list[AceCombat4] = GSC_AceCombat4;
|
|
|
|
GSC_list[Drakengard2] = GSC_Drakengard2;
|
|
|
|
GSC_list[Tekken5] = GSC_Tekken5;
|
|
|
|
GSC_list[IkkiTousen] = GSC_IkkiTousen;
|
|
|
|
GSC_list[GodOfWar] = GSC_GodOfWar;
|
|
|
|
GSC_list[GodOfWar2] = GSC_GodOfWar2;
|
|
|
|
GSC_list[GiTS] = GSC_GiTS;
|
|
|
|
GSC_list[Onimusha3] = GSC_Onimusha3;
|
|
|
|
GSC_list[TalesOfAbyss] = GSC_TalesOfAbyss;
|
|
|
|
GSC_list[SonicUnleashed] = GSC_SonicUnleashed;
|
|
|
|
GSC_list[Genji] = GSC_Genji;
|
|
|
|
GSC_list[StarOcean3] = GSC_StarOcean3;
|
|
|
|
GSC_list[ValkyrieProfile2] = GSC_ValkyrieProfile2;
|
|
|
|
GSC_list[RadiataStories] = GSC_RadiataStories;
|
|
|
|
}
|
|
|
|
|
2010-04-25 11:14:37 +00:00
|
|
|
// TEXDESTROY_THRESH starts out at 16.
|
2010-03-19 00:31:15 +00:00
|
|
|
VALIDATE_THRESH = 8;
|
2010-06-19 08:46:40 +00:00
|
|
|
conf.mrtdepth = (conf.settings().disable_mrt_depth != 0);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
if (!conf.mrtdepth)
|
2010-07-17 11:39:04 +00:00
|
|
|
ZZLog::WriteLn("Disabling MRT depth writing.");
|
2010-04-25 00:31:27 +00:00
|
|
|
else
|
2010-07-17 11:39:04 +00:00
|
|
|
ZZLog::WriteLn("Enabling MRT depth writing.");
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-04-25 11:14:37 +00:00
|
|
|
bool CRCValueChanged = (g_LastCRC != crc);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
g_LastCRC = crc;
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-07-17 11:39:04 +00:00
|
|
|
if (crc != 0) ZZLog::WriteLn("Current game CRC is %x.", crc);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
|
|
|
if (CRCValueChanged && (crc != 0))
|
2010-04-25 11:14:37 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < GAME_INFO_INDEX; i++)
|
|
|
|
{
|
|
|
|
if (crc_game_list[i].crc == crc)
|
|
|
|
{
|
2010-07-17 11:39:04 +00:00
|
|
|
ZZLog::WriteLn("Found CRC[%x] in crc game list.", crc);
|
2010-07-17 10:55:22 +00:00
|
|
|
|
|
|
|
if (crc_game_list[i].v_thresh > 0)
|
|
|
|
{
|
|
|
|
VALIDATE_THRESH = crc_game_list[i].v_thresh;
|
2010-07-17 11:39:04 +00:00
|
|
|
ZZLog::WriteLn("Setting VALIDATE_THRESH to %d", VALIDATE_THRESH);
|
2010-07-17 10:55:22 +00:00
|
|
|
}
|
2010-07-17 11:39:04 +00:00
|
|
|
|
2010-07-17 10:55:22 +00:00
|
|
|
if (crc_game_list[i].t_thresh > 0)
|
|
|
|
{
|
|
|
|
TEXDESTROY_THRESH = crc_game_list[i].t_thresh;
|
2010-07-17 11:39:04 +00:00
|
|
|
ZZLog::WriteLn("Setting TEXDESTROY_THRESH to %d", TEXDESTROY_THRESH);
|
2010-07-17 10:55:22 +00:00
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-08-18 13:15:43 +00:00
|
|
|
// FIXME need to check SkipDraw is positive (enabled by users)
|
2010-08-17 13:38:57 +00:00
|
|
|
GetSkipCount_Handler = GSC_list[crc_game_list[i].title];
|
|
|
|
|
2010-10-15 09:32:41 +00:00
|
|
|
if (!conf.disableHacks)
|
|
|
|
{
|
|
|
|
conf.def_hacks._u32 |= crc_game_list[i].flags;
|
|
|
|
ListHacks();
|
|
|
|
}
|
2010-04-25 11:14:37 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-17 11:39:04 +00:00
|
|
|
ListHacks();
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSsetFrameSkip(int frameskip)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
s_frameskipping |= frameskip;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
if (frameskip && g_nFrameRender > 1)
|
|
|
|
{
|
2010-07-02 12:10:40 +00:00
|
|
|
SetFrameSkip(true);
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
else if (!frameskip && g_nFrameRender <= 0)
|
|
|
|
{
|
2010-07-02 12:10:40 +00:00
|
|
|
SetFrameSkip(false);
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSreset()
|
2010-05-01 20:33:53 +00:00
|
|
|
{
|
2010-10-18 11:24:40 +00:00
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
memset(&gs, 0, sizeof(gs));
|
|
|
|
|
|
|
|
ZZGSStateReset();
|
|
|
|
|
|
|
|
gs.prac = 1;
|
|
|
|
prim = &gs._prim[0];
|
2012-04-19 21:22:08 +00:00
|
|
|
gs.transferring = false;
|
2010-10-18 11:24:40 +00:00
|
|
|
gs.q = 1;
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSgifSoftReset(u32 mask)
|
2010-04-02 02:44:14 +00:00
|
|
|
{
|
2010-10-18 11:24:40 +00:00
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
if (mask & 1) memset(&gs.path[0], 0, sizeof(gs.path[0]));
|
|
|
|
if (mask & 2) memset(&gs.path[1], 0, sizeof(gs.path[1]));
|
|
|
|
if (mask & 4) memset(&gs.path[2], 0, sizeof(gs.path[2]));
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
gs.transferring = false;
|
2010-10-18 11:24:40 +00:00
|
|
|
gs.q = 1;
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(s32) GSinit()
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
2010-09-15 16:54:19 +00:00
|
|
|
ZZLog::Open();
|
2010-06-21 12:03:14 +00:00
|
|
|
ZZLog::WriteLn("Calling GSinit.");
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-07-02 12:10:40 +00:00
|
|
|
WriteTempRegs();
|
2010-03-19 00:31:15 +00:00
|
|
|
GSreset();
|
2010-07-02 12:10:40 +00:00
|
|
|
|
2010-06-21 12:03:14 +00:00
|
|
|
ZZLog::WriteLn("GSinit finished.");
|
2010-03-19 00:31:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-10 11:15:48 +00:00
|
|
|
__forceinline void InitMisc()
|
|
|
|
{
|
|
|
|
WriteBilinear();
|
|
|
|
WriteAA();
|
|
|
|
InitProfile();
|
|
|
|
InitPath();
|
|
|
|
ResetRegs();
|
|
|
|
}
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(s32) GSopen(void *pDsp, char *Title, int multithread)
|
2010-03-19 05:24:36 +00:00
|
|
|
{
|
2010-04-30 04:40:31 +00:00
|
|
|
FUNCLOG
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
g_GSMultiThreaded = multithread;
|
|
|
|
|
2010-06-21 12:03:14 +00:00
|
|
|
ZZLog::WriteLn("Calling GSopen.");
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-11-09 12:04:07 +00:00
|
|
|
#if defined(_WIN32) && defined(_DEBUG)
|
2010-03-19 00:31:15 +00:00
|
|
|
g_hCurrentThread = GetCurrentThread();
|
2010-04-30 04:40:31 +00:00
|
|
|
#endif
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
LoadConfig();
|
2010-11-10 11:15:48 +00:00
|
|
|
strcpy(GLWin.title, Title);
|
2010-11-09 12:04:07 +00:00
|
|
|
|
|
|
|
ZZLog::GS_Log("Using %s:%d.%d.%d.", libraryName, zgsrevision, zgsbuild, zgsminor);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-06-21 12:03:14 +00:00
|
|
|
ZZLog::WriteLn("Creating ZZOgl window.");
|
2010-11-10 11:15:48 +00:00
|
|
|
if ((!GLWin.CreateWindow(pDsp)) || (!ZZCreate(conf.width, conf.height))) return -1;
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-06-21 12:03:14 +00:00
|
|
|
ZZLog::WriteLn("Initialization successful.");
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-11-10 11:15:48 +00:00
|
|
|
InitMisc();
|
2010-04-30 04:40:31 +00:00
|
|
|
ZZLog::GS_Log("GSopen finished.");
|
2010-03-19 00:31:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-12 14:48:36 +00:00
|
|
|
#ifdef USE_GSOPEN2
|
|
|
|
EXPORT_C_(s32) GSopen2( void* pDsp, u32 flags )
|
2010-11-07 04:45:10 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
g_GSMultiThreaded = true;
|
|
|
|
|
|
|
|
ZZLog::WriteLn("Calling GSopen2.");
|
|
|
|
|
|
|
|
#if defined(_WIN32) && defined(_DEBUG)
|
|
|
|
g_hCurrentThread = GetCurrentThread();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
LoadConfig();
|
|
|
|
|
|
|
|
ZZLog::GS_Log("Using %s:%d.%d.%d.", libraryName, zgsrevision, zgsbuild, zgsminor);
|
|
|
|
|
2010-11-10 11:15:48 +00:00
|
|
|
ZZLog::WriteLn("Capturing ZZOgl window.");
|
2011-06-12 14:48:36 +00:00
|
|
|
if ((!GLWin.CreateWindow(pDsp)) || (!ZZCreate(conf.width, conf.height))) return -1;
|
2010-11-07 04:45:10 +00:00
|
|
|
|
|
|
|
ZZLog::WriteLn("Initialization successful.");
|
|
|
|
|
2010-11-10 11:15:48 +00:00
|
|
|
InitMisc();
|
2010-11-07 04:45:10 +00:00
|
|
|
ZZLog::GS_Log("GSopen2 finished.");
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSshutdown()
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-07-02 12:10:40 +00:00
|
|
|
ZZLog::Close();
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSclose()
|
2010-05-01 20:33:53 +00:00
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
FUNCLOG
|
|
|
|
|
2010-10-18 11:24:40 +00:00
|
|
|
ZZDestroy();
|
2010-03-19 02:04:55 +00:00
|
|
|
GLWin.CloseWindow();
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
// Free alocated memory. We could close plugin without closing pcsx2, so we SHOULD free all allocated resources
|
|
|
|
ZZshExitCleaning();
|
2010-03-19 00:31:15 +00:00
|
|
|
SaveStateFile = NULL;
|
|
|
|
SaveStateExists = true; // default value
|
2010-09-17 19:06:52 +00:00
|
|
|
g_LastCRC = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSirqCallback(void (*callback)())
|
2010-05-01 20:33:53 +00:00
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
GSirq = callback;
|
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSwriteCSR(u32 write)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
gs.CSRw = write;
|
|
|
|
}
|
|
|
|
|
2010-07-10 12:41:49 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define access _access
|
|
|
|
#endif
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSchangeSaveState(int newstate, const char* filename)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
char str[255];
|
|
|
|
sprintf(str, "save state %d", newstate);
|
2010-10-16 11:54:46 +00:00
|
|
|
ZZAddMessage(str);
|
2010-03-19 00:31:15 +00:00
|
|
|
CurrentSavestate = newstate;
|
|
|
|
|
|
|
|
SaveStateFile = filename;
|
|
|
|
SaveStateExists = (access(SaveStateFile, 0) == 0);
|
|
|
|
}
|
|
|
|
|
2012-04-07 21:23:01 +00:00
|
|
|
static bool get_snapshot_filename(char *filename, char* path, const char* extension)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
FILE *bmpfile;
|
|
|
|
u32 snapshotnr = 0;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
// increment snapshot value & try to get filename
|
2010-05-01 20:33:53 +00:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
snapshotnr++;
|
|
|
|
|
2012-04-07 21:23:01 +00:00
|
|
|
sprintf(filename, "%s/snap%03ld.%s", path, snapshotnr, extension);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
|
|
|
bmpfile = fopen(filename, "rb");
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
if (bmpfile == NULL) break;
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
fclose(bmpfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
// try opening new snapshot file
|
2010-05-01 20:33:53 +00:00
|
|
|
if ((bmpfile = fopen(filename, "wb")) == NULL)
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
char strdir[255];
|
2010-11-14 01:38:10 +00:00
|
|
|
sprintf(strdir, "%s", path);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
#ifdef _WIN32
|
2010-12-25 04:38:44 +00:00
|
|
|
CreateDirectory(wxString::FromUTF8(strdir), NULL);
|
2010-03-19 00:31:15 +00:00
|
|
|
#else
|
2010-11-14 01:38:10 +00:00
|
|
|
mkdir(path, 0777);
|
2010-03-19 00:31:15 +00:00
|
|
|
#endif
|
|
|
|
|
2012-04-07 21:23:01 +00:00
|
|
|
if ((bmpfile = fopen(filename, "wb")) == NULL) return false;
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fclose(bmpfile);
|
|
|
|
|
2012-04-07 21:23:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSmakeSnapshot(char *path)
|
2012-04-07 21:23:01 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
char filename[256];
|
|
|
|
if (get_snapshot_filename(filename, path, (conf.zz_options.tga_snap) ? "bmp" : "jpg"))
|
|
|
|
SaveSnapshot(filename);
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2010-07-02 12:10:40 +00:00
|
|
|
// I'll probably move this somewhere else later, but it's got a ton of dependencies.
|
|
|
|
static __forceinline void SetGSTitle()
|
|
|
|
{
|
|
|
|
char strtitle[256];
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-07-02 12:10:40 +00:00
|
|
|
#if !defined(ZEROGS_DEVBUILD)
|
|
|
|
const char* g_pShaders[4] = { "full", "reduced", "accurate", "accurate-reduced" };
|
|
|
|
const char* g_pInterlace[3] = { "interlace 0 |", "interlace 1 |", "" };
|
|
|
|
const char* g_pBilinear[3] = { "", "bilinear |", "forced bilinear |" };
|
|
|
|
|
|
|
|
if (SaveStateFile != NULL && !SaveStateExists)
|
|
|
|
SaveStateExists = (access(SaveStateFile, 0) == 0);
|
|
|
|
else
|
|
|
|
SaveStateExists = true;
|
|
|
|
|
|
|
|
sprintf(strtitle, "ZZ Open GL 0.%d.%d | %.1f fps | %s%s%s savestate %d%s | shaders %s | (%.1f)", zgsbuild, zgsminor, fFPS,
|
2010-09-15 16:54:19 +00:00
|
|
|
g_pInterlace[conf.interlace], g_pBilinear[conf.bilinear], (conf.aa ? s_aa[conf.aa] : ""),
|
2010-07-02 12:10:40 +00:00
|
|
|
CurrentSavestate, (SaveStateExists ? "" : "*"),
|
|
|
|
g_pShaders[g_nPixelShaderVer], (ppf&0xfffff) / (float)UPDATE_FRAMES);
|
|
|
|
|
|
|
|
#else
|
|
|
|
sprintf(strtitle, "%d | %.1f fps (sk:%d%%) | g: %.1f, t: %.1f, a: %.1f, r: %.1f | p: %.1f | tex: %d %d (%d kbpf)", g_nFrame, fFPS,
|
|
|
|
100*g_nFramesSkipped / g_nFrame,
|
|
|
|
g_nGenVars / (float)UPDATE_FRAMES, g_nTexVars / (float)UPDATE_FRAMES, g_nAlphaVars / (float)UPDATE_FRAMES,
|
|
|
|
g_nResolve / (float)UPDATE_FRAMES, (ppf&0xfffff) / (float)UPDATE_FRAMES,
|
2010-10-16 11:54:46 +00:00
|
|
|
g_MemTargs.listTargets.size(), g_MemTargs.listClearedTargets.size(), g_TransferredToGPU >> 10);
|
2010-07-02 12:10:40 +00:00
|
|
|
|
|
|
|
//_snprintf(strtitle, 512, "%x %x", *(int*)(g_pbyGSMemory + 256 * 0x3e0c + 4), *(int*)(g_pbyGSMemory + 256 * 0x3e04 + 4));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// if( g_nFrame > 100 && fFPS > 60.0f ) {
|
|
|
|
// ZZLog::Debug_Log("Set profile.");
|
|
|
|
// g_bWriteProfile = 1;
|
|
|
|
// }
|
2010-09-01 10:28:37 +00:00
|
|
|
GLWin.SetTitle(strtitle);
|
2010-07-02 12:10:40 +00:00
|
|
|
}
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
// This isn't implemented for some reason? Adding a field for it for the moment, till I get a chance to look closer.
|
|
|
|
EXPORT_C_(void) GSsetVsync(int enabled)
|
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
ZZLog::Debug_Log("Setting VSync to 0x%x.", enabled);
|
|
|
|
gs.vsync = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSvsync(int current_interlace)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
2010-04-25 08:33:05 +00:00
|
|
|
//ZZLog::GS_Log("Calling GSvsync.");
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
static u32 dwTime = timeGetTime();
|
|
|
|
static int nToNextUpdate = 1;
|
2012-04-07 21:23:01 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
if (conf.dump & 0x1) {
|
|
|
|
freezeData fd;
|
|
|
|
fd.size = ZZSave(NULL);
|
|
|
|
s8* payload = (s8*)malloc(fd.size);
|
|
|
|
fd.data = payload;
|
|
|
|
|
|
|
|
ZZSave(fd.data);
|
|
|
|
|
|
|
|
char filename[256];
|
|
|
|
// FIXME, there is probably a better solution than /tmp ...
|
|
|
|
// A possibility will be to save the path from GSmakeSnapshot but you still need to call
|
|
|
|
// GSmakeSnapshot first.
|
|
|
|
if (get_snapshot_filename(filename, "/tmp", "gs"))
|
|
|
|
g_dump.Open(filename, g_LastCRC, fd, g_pBasePS2Mem);
|
|
|
|
conf.dump--;
|
|
|
|
}
|
|
|
|
g_dump.VSync(interlace, (conf.dump == 0), g_pBasePS2Mem);
|
|
|
|
#endif
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
GL_REPORT_ERRORD();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
g_nRealFrame++;
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
// The value passed seems to either be 0 or 0x2000, and we want 0 or 1. Perhaps !! would be better...
|
|
|
|
gs.interlace = !current_interlace;
|
|
|
|
RenderCRTC();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-11-09 12:04:07 +00:00
|
|
|
GLWin.ProcessEvents();
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
if (--nToNextUpdate <= 0)
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
u32 d = timeGetTime();
|
2010-11-07 05:51:54 +00:00
|
|
|
fFPS = UPDATE_FRAMES * 1000.0f / (float)max(d - dwTime, (u32)1);
|
2010-03-19 00:31:15 +00:00
|
|
|
dwTime = d;
|
|
|
|
g_nFrame += UPDATE_FRAMES;
|
2011-06-12 14:48:36 +00:00
|
|
|
#ifndef USE_GSOPEN2
|
|
|
|
// let PCSX2 manage the title
|
2010-07-02 12:10:40 +00:00
|
|
|
SetGSTitle();
|
2011-06-12 14:48:36 +00:00
|
|
|
#endif
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// if( g_nFrame > 100 && fFPS > 60.0f ) {
|
2010-04-25 08:33:05 +00:00
|
|
|
// ZZLog::Debug_Log("Set profile.");
|
2010-03-19 00:31:15 +00:00
|
|
|
// g_bWriteProfile = 1;
|
|
|
|
// }
|
|
|
|
|
2010-06-19 06:23:40 +00:00
|
|
|
if (fFPS < 16)
|
|
|
|
UPDATE_FRAMES = 4;
|
|
|
|
else if (fFPS < 32)
|
|
|
|
UPDATE_FRAMES = 8;
|
|
|
|
else
|
|
|
|
UPDATE_FRAMES = 16;
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
nToNextUpdate = UPDATE_FRAMES;
|
|
|
|
|
2010-07-02 12:10:40 +00:00
|
|
|
ppf = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
g_TransferredToGPU = 0;
|
|
|
|
g_nGenVars = 0;
|
|
|
|
g_nTexVars = 0;
|
|
|
|
g_nAlphaVars = 0;
|
|
|
|
g_nResolve = 0;
|
|
|
|
g_nFramesSkipped = 0;
|
2010-08-17 13:38:57 +00:00
|
|
|
g_SkipFlushFrame = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 09:02:36 +00:00
|
|
|
#if defined(ZEROGS_DEVBUILD)
|
2010-05-01 20:33:53 +00:00
|
|
|
if (g_bWriteProfile)
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
//g_bWriteProfile = 0;
|
|
|
|
DVProfWrite("prof.txt", UPDATE_FRAMES);
|
|
|
|
DVProfClear();
|
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
#endif
|
|
|
|
GL_REPORT_ERRORD();
|
2012-04-07 21:23:01 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSreadFIFO(u64 *pMem)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
2010-04-25 08:33:05 +00:00
|
|
|
//ZZLog::GS_Log("Calling GSreadFIFO.");
|
2012-04-07 21:23:01 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
g_dump.ReadFIFO(1);
|
|
|
|
#endif
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-10-16 11:54:46 +00:00
|
|
|
TransferLocalHost((u32*)pMem, 1);
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(void) GSreadFIFO2(u64 *pMem, int qwc)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
2010-04-25 08:33:05 +00:00
|
|
|
//ZZLog::GS_Log("Calling GSreadFIFO2.");
|
2012-04-07 21:23:01 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
g_dump.ReadFIFO(qwc);
|
|
|
|
#endif
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-10-16 11:54:46 +00:00
|
|
|
TransferLocalHost((u32*)pMem, qwc);
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(int) GSsetupRecording(int start, void* pData)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
if (start)
|
2010-10-16 11:54:46 +00:00
|
|
|
StartCapture();
|
2010-05-01 20:33:53 +00:00
|
|
|
else
|
2010-10-16 11:54:46 +00:00
|
|
|
StopCapture();
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-04-19 21:22:08 +00:00
|
|
|
EXPORT_C_(s32) GSfreeze(int mode, freezeData *data)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case FREEZE_LOAD:
|
2010-10-16 11:54:46 +00:00
|
|
|
if (!ZZLoad(data->data)) ZZLog::Error_Log("GS: Bad load format!");
|
2010-03-19 00:31:15 +00:00
|
|
|
g_nRealFrame += 100;
|
|
|
|
break;
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
case FREEZE_SAVE:
|
2010-10-16 11:54:46 +00:00
|
|
|
ZZSave(data->data);
|
2010-03-19 00:31:15 +00:00
|
|
|
break;
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
case FREEZE_SIZE:
|
2010-10-16 11:54:46 +00:00
|
|
|
data->size = ZZSave(NULL);
|
2010-03-19 00:31:15 +00:00
|
|
|
break;
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-04-07 21:23:01 +00:00
|
|
|
|
|
|
|
#ifdef __LINUX__
|
|
|
|
|
|
|
|
struct Packet
|
|
|
|
{
|
|
|
|
u8 type, param;
|
|
|
|
u32 size, addr;
|
|
|
|
vector<u32> buff;
|
|
|
|
};
|
|
|
|
|
|
|
|
EXPORT_C_(void) GSReplay(char* lpszCmdLine)
|
|
|
|
{
|
|
|
|
if(FILE* fp = fopen(lpszCmdLine, "rb"))
|
|
|
|
{
|
|
|
|
GSinit();
|
|
|
|
|
|
|
|
u8 regs[0x2000];
|
|
|
|
GSsetBaseMem(regs);
|
|
|
|
|
|
|
|
//s_vsync = !!theApp.GetConfig("vsync", 0);
|
|
|
|
|
|
|
|
void* hWnd = NULL;
|
|
|
|
|
|
|
|
//_GSopen((void**)&hWnd, "", renderer);
|
|
|
|
GSopen((void**)&hWnd, "", 0);
|
|
|
|
|
|
|
|
u32 crc;
|
|
|
|
fread(&crc, 4, 1, fp);
|
|
|
|
GSsetGameCRC(crc, 0);
|
|
|
|
|
|
|
|
freezeData fd;
|
|
|
|
fread(&fd.size, 4, 1, fp);
|
|
|
|
fd.data = new s8[fd.size];
|
|
|
|
fread(fd.data, fd.size, 1, fp);
|
|
|
|
GSfreeze(FREEZE_LOAD, &fd);
|
|
|
|
delete [] fd.data;
|
|
|
|
|
|
|
|
fread(regs, 0x2000, 1, fp);
|
|
|
|
|
|
|
|
long start = ftell(fp);
|
|
|
|
|
|
|
|
GSvsync(1);
|
|
|
|
|
|
|
|
list<Packet*> packets;
|
|
|
|
vector<u8> buff;
|
|
|
|
int type;
|
|
|
|
|
|
|
|
while((type = fgetc(fp)) != EOF)
|
|
|
|
{
|
|
|
|
Packet* p = new Packet();
|
|
|
|
|
|
|
|
p->type = (u8)type;
|
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
p->param = (u8)fgetc(fp);
|
|
|
|
|
|
|
|
fread(&p->size, 4, 1, fp);
|
|
|
|
|
|
|
|
switch(p->param)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
p->buff.resize(0x4000);
|
|
|
|
p->addr = 0x4000 - p->size;
|
|
|
|
fread(&p->buff[p->addr], p->size, 1, fp);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
p->buff.resize(p->size);
|
|
|
|
fread(&p->buff[0], p->size, 1, fp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
p->param = (u8)fgetc(fp);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
fread(&p->size, 4, 1, fp);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
p->buff.resize(0x2000);
|
|
|
|
|
|
|
|
fread(&p->buff[0], 0x2000, 1, fp);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
packets.push_back(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
//while(IsWindowVisible(hWnd))
|
|
|
|
//FIXME map?
|
|
|
|
int finished = 2;
|
|
|
|
while(finished > 0)
|
|
|
|
{
|
|
|
|
unsigned long start = timeGetTime();
|
|
|
|
unsigned long frame_number = 0;
|
|
|
|
for(list<Packet*>::iterator i = packets.begin(); i != packets.end(); i++)
|
|
|
|
{
|
|
|
|
Packet* p = *i;
|
|
|
|
|
|
|
|
switch(p->type)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
switch(p->param)
|
|
|
|
{
|
|
|
|
case 0: GSgifTransfer1(&p->buff[0], p->addr); break;
|
|
|
|
case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break;
|
|
|
|
case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break;
|
|
|
|
case 3: GSgifTransfer(&p->buff[0], p->size / 16); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
GSvsync(p->param);
|
|
|
|
frame_number++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
if(buff.size() < p->size) buff.resize(p->size);
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
// GSreadFIFO2(&buff[0], p->size / 16);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
memcpy(regs, &p->buff[0], 0x2000);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unsigned long end = timeGetTime();
|
|
|
|
fprintf(stderr, "The %d frames of the scene was render on %dms\n", frame_number, end - start);
|
|
|
|
fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number);
|
|
|
|
|
|
|
|
sleep(1);
|
|
|
|
finished--;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(list<Packet*>::iterator i = packets.begin(); i != packets.end(); i++)
|
|
|
|
{
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
packets.clear();
|
|
|
|
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
GSclose();
|
|
|
|
GSshutdown();
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|