zzogl-pg: Move various stuff related to GSmain around.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3368 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-07-02 12:10:40 +00:00
parent e35211addb
commit 4289d544d2
19 changed files with 252 additions and 264 deletions

View File

@ -1,5 +1,5 @@
#ifndef CRC_H_INCLUDED #ifndef CRC_H_INCLUDED
#define CRC_H_INCLUDED #define CRC_H_INCLUDED
// don't change these values! // don't change these values!
enum GAME_HACK_OPTIONS enum GAME_HACK_OPTIONS
@ -272,5 +272,6 @@ static const Game_Info crc_game_list[] =
}; };
#define GAME_INFO_INDEX (sizeof(crc_game_list)/sizeof(Game_Info)) #define GAME_INFO_INDEX (sizeof(crc_game_list)/sizeof(Game_Info))
#endif // CRC_H_INCLUDED #endif // CRC_H_INCLUDED

View File

@ -283,7 +283,6 @@ struct Vertex
}; };
extern GSconf conf; extern GSconf conf;
extern int ppf;
// PSM values // PSM values
// PSM types == Texture Storage Format // PSM types == Texture Storage Format

View File

@ -47,20 +47,21 @@ using namespace std;
#pragma warning(disable:4244) #pragma warning(disable:4244)
#endif #endif
GLWindow GLWin;
GSinternal gs; GSinternal gs;
char GStitle[256]; char GStitle[256];
extern FILE *gsLog;
GSconf conf; GSconf conf;
int ppf;
primInfo *prim; int ppf, g_GSMultiThreaded, CurrentSavestate = 0;
int g_GSMultiThreaded = 0; int g_LastCRC = 0, g_TransferredToGPU = 0, s_frameskipping = 0;
int UPDATE_FRAMES = 16, g_nFrame = 0, g_nRealFrame = 0;
float fFPS = 0;
void (*GSirq)(); void (*GSirq)();
u8* g_pBasePS2Mem = NULL; u8* g_pBasePS2Mem = NULL;
int g_TransferredToGPU = 0;
std::string s_strIniPath("inis/"); // Air's new ini path (r2361) std::string s_strIniPath("inis/"); // Air's new ini path (r2361)
std::string s_strLogPath("logs/");
int CurrentSavestate = 0; // Number of SaveSlot. Default is 0
bool SaveStateExists = true; // We could not know save slot status before first change occured bool SaveStateExists = true; // We could not know save slot status before first change occured
const char* SaveStateFile = NULL; // Name of SaveFile for access check. const char* SaveStateFile = NULL; // Name of SaveFile for access check.
@ -84,16 +85,23 @@ char *libraryName = "ZZ Ogl PG (Dev)";
char *libraryName = "ZZ Ogl PG "; char *libraryName = "ZZ Ogl PG ";
#endif #endif
extern GIFRegHandler g_GIFPackedRegHandlers[], g_GIFRegHandlers[];
GIFRegHandler g_GIFTempRegHandlers[16] = {0};
extern int g_nPixelShaderVer, g_nFrameRender, g_nFramesSkipped; extern int g_nPixelShaderVer, g_nFrameRender, g_nFramesSkipped;
int s_frameskipping = 0;
extern void ProcessMessages(); extern void ProcessMessages();
extern void WriteAA(); extern void WriteAA();
extern void WriteBilinear(); extern void WriteBilinear();
extern int VALIDATE_THRESH;
extern u32 TEXDESTROY_THRESH;
#ifdef _WIN32
HWND GShwnd = NULL;
#endif
u32 THR_KeyEvent = 0; // Value for key event processing between threads
bool THR_bShift = false;
u32 CALLBACK PS2EgetLibType() u32 CALLBACK PS2EgetLibType()
{ {
return PS2E_LT_GS; return PS2E_LT_GS;
@ -109,15 +117,6 @@ u32 CALLBACK PS2EgetLibVersion2(u32 type)
return (zgsversion << 16) | (zgsrevision << 8) | zgsbuild | (zgsminor << 24); return (zgsversion << 16) | (zgsrevision << 8) | zgsbuild | (zgsminor << 24);
} }
GLWindow GLWin;
#ifdef _WIN32
HWND GShwnd = NULL;
#endif
u32 THR_KeyEvent = 0; // Value for key event processing between threads
bool THR_bShift = false;
void CALLBACK GSsetBaseMem(void* pmem) void CALLBACK GSsetBaseMem(void* pmem)
{ {
g_pBasePS2Mem = (u8*)pmem; g_pBasePS2Mem = (u8*)pmem;
@ -130,19 +129,9 @@ void CALLBACK GSsetSettingsDir(const char* dir)
void CALLBACK GSsetLogDir(const char* dir) void CALLBACK GSsetLogDir(const char* dir)
{ {
// Get the path to the log directory. ZZLog::SetDir(dir);
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (gsLog != NULL) fclose(gsLog);
ZZLog::OpenLog();
} }
extern int VALIDATE_THRESH;
extern u32 TEXDESTROY_THRESH;
int g_LastCRC = 0;
void CALLBACK GSsetGameCRC(int crc, int options) void CALLBACK GSsetGameCRC(int crc, int options)
{ {
// TEXDESTROY_THRESH starts out at 16. // TEXDESTROY_THRESH starts out at 16.
@ -179,8 +168,6 @@ void CALLBACK GSsetGameCRC(int crc, int options)
} }
} }
//#define OLD_GS_SET_FRAMESKIP
#ifdef OLD_GS_SET_FRAMESKIP
void CALLBACK GSsetFrameSkip(int frameskip) void CALLBACK GSsetFrameSkip(int frameskip)
{ {
FUNCLOG FUNCLOG
@ -188,148 +175,34 @@ void CALLBACK GSsetFrameSkip(int frameskip)
if (frameskip && g_nFrameRender > 1) if (frameskip && g_nFrameRender > 1)
{ {
for (int i = 0; i < 16; ++i) SetFrameSkip(true);
{
g_GIFPackedRegHandlers[i] = GIFPackedRegHandlerNOP;
}
// still keep certain handlers
g_GIFPackedRegHandlers[6] = GIFRegHandlerTEX0_1;
g_GIFPackedRegHandlers[7] = GIFRegHandlerTEX0_2;
g_GIFPackedRegHandlers[14] = GIFPackedRegHandlerA_D;
g_GIFRegHandlers[0] = GIFRegHandlerNOP;
g_GIFRegHandlers[1] = GIFRegHandlerNOP;
g_GIFRegHandlers[2] = GIFRegHandlerNOP;
g_GIFRegHandlers[3] = GIFRegHandlerNOP;
g_GIFRegHandlers[4] = GIFRegHandlerNOP;
g_GIFRegHandlers[5] = GIFRegHandlerNOP;
g_GIFRegHandlers[12] = GIFRegHandlerNOP;
g_GIFRegHandlers[13] = GIFRegHandlerNOP;
g_GIFRegHandlers[26] = GIFRegHandlerNOP;
g_GIFRegHandlers[27] = GIFRegHandlerNOP;
g_nFrameRender = 0;
} }
else if (!frameskip && g_nFrameRender <= 0) else if (!frameskip && g_nFrameRender <= 0)
{ {
g_nFrameRender = 1; SetFrameSkip(false);
if (g_GIFTempRegHandlers[0] == NULL) return; // not init yet
// restore
memcpy(g_GIFPackedRegHandlers, g_GIFTempRegHandlers, sizeof(g_GIFTempRegHandlers));
g_GIFRegHandlers[0] = GIFRegHandlerPRIM;
g_GIFRegHandlers[1] = GIFRegHandlerRGBAQ;
g_GIFRegHandlers[2] = GIFRegHandlerST;
g_GIFRegHandlers[3] = GIFRegHandlerUV;
g_GIFRegHandlers[4] = GIFRegHandlerXYZF2;
g_GIFRegHandlers[5] = GIFRegHandlerXYZ2;
g_GIFRegHandlers[12] = GIFRegHandlerXYZF3;
g_GIFRegHandlers[13] = GIFRegHandlerXYZ2;
g_GIFRegHandlers[26] = GIFRegHandlerPRMODECONT;
g_GIFRegHandlers[27] = GIFRegHandlerPRMODE;
} }
} }
#else
void CALLBACK GSsetFrameSkip(int frameskip)
{
FUNCLOG
s_frameskipping |= frameskip;
if (frameskip && g_nFrameRender > 1)
{
g_GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerNOP;
}
else if (!frameskip && g_nFrameRender <= 0)
{
g_GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM;
g_GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA;
g_GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ;
g_GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV;
g_GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2;
g_GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2;
g_GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP_1;
g_GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP_2;
g_GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG;
g_GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3;
g_GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3;
g_GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM;
g_GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ;
g_GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST;
g_GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV;
g_GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2;
g_GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2;
g_GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3;
g_GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3;
g_GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT;
g_GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE;
}
}
#endif
void CALLBACK GSreset() void CALLBACK GSreset()
{ {
FUNCLOG ZeroGS::GSReset();
memset(&gs, 0, sizeof(gs));
ZeroGS::GSStateReset();
gs.prac = 1;
prim = &gs._prim[0];
gs.nTriFanVert = -1;
gs.imageTransfer = -1;
gs.q = 1;
} }
void CALLBACK GSgifSoftReset(u32 mask) void CALLBACK GSgifSoftReset(u32 mask)
{ {
FUNCLOG ZeroGS::GSSoftReset(mask);
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]));
gs.imageTransfer = -1;
gs.q = 1;
gs.nTriFanVert = -1;
} }
s32 CALLBACK GSinit() s32 CALLBACK GSinit()
{ {
FUNCLOG FUNCLOG
memcpy(g_GIFTempRegHandlers, g_GIFPackedRegHandlers, sizeof(g_GIFTempRegHandlers)); if (ZZLog::Open() == false) return -1;
if (ZZLog::OpenLog() == false)
return -1;
ZZLog::WriteLn("Calling GSinit."); ZZLog::WriteLn("Calling GSinit.");
WriteTempRegs();
GSreset(); GSreset();
ZZLog::WriteLn("GSinit finished."); ZZLog::WriteLn("GSinit finished.");
return 0; return 0;
} }
@ -345,7 +218,6 @@ extern LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
extern HINSTANCE hInst; extern HINSTANCE hInst;
#endif #endif
extern void ResetRegs();
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
{ {
@ -382,13 +254,10 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
WriteBilinear(); WriteBilinear();
WriteAA(); WriteAA();
InitProfile();
luPerfFreq = GetCPUTicks(); InitPath();
gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = 0;
ResetRegs(); ResetRegs();
ZZLog::GS_Log("GSopen finished."); ZZLog::GS_Log("GSopen finished.");
return 0; return 0;
} }
@ -396,7 +265,7 @@ void CALLBACK GSshutdown()
{ {
FUNCLOG FUNCLOG
if (gsLog != NULL) fclose(gsLog); ZZLog::Close();
} }
void CALLBACK GSclose() void CALLBACK GSclose()
@ -483,11 +352,43 @@ void CALLBACK GSmakeSnapshot(char *path)
ZeroGS::SaveSnapshot(filename); ZeroGS::SaveSnapshot(filename);
} }
int UPDATE_FRAMES = 16; // I'll probably move this somewhere else later, but it's got a ton of dependencies.
int g_nFrame = 0; static __forceinline void SetGSTitle()
int g_nRealFrame = 0; {
char strtitle[256];
float fFPS = 0; #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,
g_pInterlace[conf.interlace], g_pBilinear[conf.bilinear],
(conf.aa >= conf.negaa) ? (conf.aa ? s_aa[conf.aa - conf.negaa] : "") : (conf.negaa ? s_naa[conf.negaa - conf.aa] : ""),
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,
ZeroGS::g_MemTargs.listTargets.size(), ZeroGS::g_MemTargs.listClearedTargets.size(), g_TransferredToGPU >> 10);
//_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;
// }
if (!(conf.fullscreen())) GLWin.SetTitle(strtitle);
}
void CALLBACK GSvsync(int interlace) void CALLBACK GSvsync(int interlace)
{ {
@ -497,56 +398,28 @@ void CALLBACK GSvsync(int interlace)
static u32 dwTime = timeGetTime(); static u32 dwTime = timeGetTime();
static int nToNextUpdate = 1; static int nToNextUpdate = 1;
char strtitle[256];
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
g_nRealFrame++; g_nRealFrame++;
// !interlace? Hmmm... Fixme.
ZeroGS::RenderCRTC(!interlace); ZeroGS::RenderCRTC(!interlace);
ProcessMessages(); ProcessMessages();
if (--nToNextUpdate <= 0) if (--nToNextUpdate <= 0)
{ {
u32 d = timeGetTime(); u32 d = timeGetTime();
fFPS = UPDATE_FRAMES * 1000.0f / (float)max(d - dwTime, 1); fFPS = UPDATE_FRAMES * 1000.0f / (float)max(d - dwTime, 1);
dwTime = d; dwTime = d;
g_nFrame += UPDATE_FRAMES; g_nFrame += UPDATE_FRAMES;
SetGSTitle();
#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,
g_pInterlace[conf.interlace], g_pBilinear[conf.bilinear],
(conf.aa >= conf.negaa) ? (conf.aa ? s_aa[conf.aa - conf.negaa] : "") : (conf.negaa ? s_naa[conf.negaa - conf.aa] : ""),
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,
ZeroGS::g_MemTargs.listTargets.size(), ZeroGS::g_MemTargs.listClearedTargets.size(), g_TransferredToGPU >> 10);
//_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 ) { // if( g_nFrame > 100 && fFPS > 60.0f ) {
// ZZLog::Debug_Log("Set profile."); // ZZLog::Debug_Log("Set profile.");
// g_bWriteProfile = 1; // g_bWriteProfile = 1;
// } // }
if (!(conf.fullscreen())) GLWin.SetTitle(strtitle);
if (fFPS < 16) if (fFPS < 16)
UPDATE_FRAMES = 4; UPDATE_FRAMES = 4;
@ -557,14 +430,12 @@ void CALLBACK GSvsync(int interlace)
nToNextUpdate = UPDATE_FRAMES; nToNextUpdate = UPDATE_FRAMES;
ppf = 0;
g_TransferredToGPU = 0; g_TransferredToGPU = 0;
g_nGenVars = 0; g_nGenVars = 0;
g_nTexVars = 0; g_nTexVars = 0;
g_nAlphaVars = 0; g_nAlphaVars = 0;
g_nResolve = 0; g_nResolve = 0;
ppf = 0;
g_nFramesSkipped = 0; g_nFramesSkipped = 0;
} }
@ -603,26 +474,10 @@ int CALLBACK GSsetupRecording(int start, void* pData)
FUNCLOG FUNCLOG
if (start) if (start)
{
if (conf.captureAvi()) return 1;
ZeroGS::StartCapture(); ZeroGS::StartCapture();
conf.setCaptureAvi(true);
ZZLog::Warn_Log("Started recording zerogs.avi.");
}
else else
{
if (!(conf.captureAvi())) return 1;
conf.setCaptureAvi(false);
ZeroGS::StopCapture(); ZeroGS::StopCapture();
ZZLog::Warn_Log("Stopped recording.");
}
return 1; return 1;
} }

View File

@ -262,3 +262,8 @@ void CALLBACK GSgifTransfer3(u32 *pMem, u32 size)
_GSgifTransfer<2>(pMem, size); _GSgifTransfer<2>(pMem, size);
} }
void InitPath()
{
gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = 0;
}

View File

@ -126,5 +126,5 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size);
extern GIFRegHandler g_GIFPackedRegHandlers[]; extern GIFRegHandler g_GIFPackedRegHandlers[];
extern GIFRegHandler g_GIFRegHandlers[]; extern GIFRegHandler g_GIFRegHandlers[];
extern void InitPath();
#endif // GIFTRANSFER_H_INCLUDED #endif // GIFTRANSFER_H_INCLUDED

View File

@ -134,6 +134,9 @@
<Option compile="0" /> <Option compile="0" />
<Option link="0" /> <Option link="0" />
</Unit> </Unit>
<Unit filename="../../ZZKeyboard.cpp" />
<Unit filename="../../ZZLog.cpp" />
<Unit filename="../../ZZLog.h" />
<Unit filename="../../ZZoglCRTC.cpp" /> <Unit filename="../../ZZoglCRTC.cpp" />
<Unit filename="../../ZZoglCRTC.h" /> <Unit filename="../../ZZoglCRTC.h" />
<Unit filename="../../ZZoglCreate.cpp" /> <Unit filename="../../ZZoglCreate.cpp" />

View File

@ -257,3 +257,8 @@ void DVProfClear()
g_listProfilers.clear(); g_listProfilers.clear();
g_listAllProfilers.clear(); g_listAllProfilers.clear();
} }
void InitProfile()
{
luPerfFreq = GetCPUTicks();
}

View File

@ -142,5 +142,7 @@ class CInterfacePtr
private: private:
T* ptr; T* ptr;
}; };
extern void InitProfile();
#endif // PROFILE_H_INCLUDED #endif // PROFILE_H_INCLUDED

View File

@ -38,6 +38,7 @@ const u32 g_primsub[8] = { 1, 2, 1, 3, 1, 1, 2, 0 };
GIFRegHandler g_GIFPackedRegHandlers[16]; GIFRegHandler g_GIFPackedRegHandlers[16];
GIFRegHandler g_GIFRegHandlers[256]; GIFRegHandler g_GIFRegHandlers[256];
GIFRegHandler g_GIFTempRegHandlers[16] = {0};
// values for keeping track of changes // values for keeping track of changes
u32 s_uTex1Data[2][2] = {{0, }}; u32 s_uTex1Data[2][2] = {{0, }};
@ -1205,3 +1206,61 @@ void ResetRegs()
SetMultithreaded(); SetMultithreaded();
} }
void WriteTempRegs()
{
memcpy(g_GIFTempRegHandlers, g_GIFPackedRegHandlers, sizeof(g_GIFTempRegHandlers));
}
void SetFrameSkip(bool skip)
{
if (skip)
{
g_GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerNOP;
g_GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerNOP;
g_GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerNOP;
}
else
{
g_GIFPackedRegHandlers[GIF_REG_PRIM] = &GIFPackedRegHandlerPRIM;
g_GIFPackedRegHandlers[GIF_REG_RGBA] = &GIFPackedRegHandlerRGBA;
g_GIFPackedRegHandlers[GIF_REG_STQ] = &GIFPackedRegHandlerSTQ;
g_GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV;
g_GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2;
g_GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2;
g_GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP_1;
g_GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP_2;
g_GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG;
g_GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3;
g_GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3;
g_GIFRegHandlers[GIF_A_D_REG_PRIM] = &GIFRegHandlerPRIM;
g_GIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GIFRegHandlerRGBAQ;
g_GIFRegHandlers[GIF_A_D_REG_ST] = &GIFRegHandlerST;
g_GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV;
g_GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2;
g_GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2;
g_GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3;
g_GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3;
g_GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT;
g_GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE;
}
}

View File

@ -757,4 +757,7 @@ REG128_SET(GIFPackedReg)
GIFPackedNOP NOP; GIFPackedNOP NOP;
REG_SET_END REG_SET_END
extern void WriteTempRegs();
extern void SetFrameSkip(bool skip);
extern void ResetRegs();
#endif #endif

View File

@ -246,7 +246,7 @@ typedef struct
} }
} GSconf; } GSconf;
extern GSconf conf;
#define REG64(name) \ #define REG64(name) \
union name \ union name \
@ -301,4 +301,6 @@ extern "C" void * memcpy_amd(void *dest, const void *src, size_t n);
extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n); extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n);
#endif #endif
#endif // UTIL_H_INCLUDED #endif // UTIL_H_INCLUDED

View File

@ -24,7 +24,6 @@
#include "Profile.h" #include "Profile.h"
extern int CurrentSavestate, g_GSMultiThreaded, g_nPixelShaderVer; extern int CurrentSavestate, g_GSMultiThreaded, g_nPixelShaderVer;
extern char GStitle[256];
extern char *libraryName; extern char *libraryName;
extern const unsigned char zgsversion; extern const unsigned char zgsversion;
extern unsigned char zgsrevision, zgsbuild, zgsminor; extern unsigned char zgsrevision, zgsbuild, zgsminor;

View File

@ -20,13 +20,12 @@
#include "ZZLog.h" #include "ZZLog.h"
extern GSconf conf; extern GSconf conf;
extern std::string s_strIniPath;
extern std::string s_strLogPath;
FILE *gsLog;
namespace ZZLog namespace ZZLog
{ {
std::string s_strLogPath("logs/");
FILE *gsLog;
bool IsLogging() bool IsLogging()
{ {
// gsLog can be null if the config dialog is used prior to Pcsx2 starting an emulation session. // gsLog can be null if the config dialog is used prior to Pcsx2 starting an emulation session.
@ -34,7 +33,7 @@ bool IsLogging()
return (gsLog != NULL && conf.log); return (gsLog != NULL && conf.log);
} }
bool OpenLog() bool Open()
{ {
bool result = true; bool result = true;
const std::string LogFile(s_strLogPath + "GSzzogl.log"); const std::string LogFile(s_strLogPath + "GSzzogl.log");
@ -51,6 +50,21 @@ bool OpenLog()
return result; return result;
} }
void Close()
{
if (gsLog != NULL) fclose(gsLog);
}
void SetDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (gsLog != NULL) fclose(gsLog);
Open();
}
void WriteToScreen(const char* pstr, u32 ms) void WriteToScreen(const char* pstr, u32 ms)
{ {
ZeroGS::AddMessage(pstr, ms); ZeroGS::AddMessage(pstr, ms);

View File

@ -166,12 +166,16 @@ extern void SetAA(int mode);
extern void SetNegAA(int mode); extern void SetNegAA(int mode);
extern bool Create(int width, int height); extern bool Create(int width, int height);
extern void Destroy(bool bD3D); extern void Destroy(bool bD3D);
extern void StartCapture();
extern void StopCapture();
} }
namespace ZZLog namespace ZZLog
{ {
extern bool IsLogging(); extern bool IsLogging();
extern bool OpenLog(); void SetDir(const char* dir);
extern bool Open();
extern void Close();
extern void Message(const char *fmt, ...); extern void Message(const char *fmt, ...);
extern void Log(const char *fmt, ...); extern void Log(const char *fmt, ...);
void WriteToScreen(const char* pstr, u32 ms = 5000); void WriteToScreen(const char* pstr, u32 ms = 5000);

View File

@ -39,6 +39,7 @@ bool g_bCRTCBilinear = true, g_bDisplayFPS = false;
int g_nFrameRender = 10, g_nFramesSkipped = 0, s_nResolved = 0; // s_nResolved == number of targets resolved this frame int g_nFrameRender = 10, g_nFramesSkipped = 0, s_nResolved = 0; // s_nResolved == number of targets resolved this frame
// Helper for skip frames. // Helper for skip frames.
int TimeLastSkip = 0; int TimeLastSkip = 0;
extern bool g_bMakeSnapshot;
// Adjusts vertex shader BitBltPos vector v to preserve aspect ratio. It used to emulate 4:3 or 16:9. // Adjusts vertex shader BitBltPos vector v to preserve aspect ratio. It used to emulate 4:3 or 16:9.
void ZeroGS::AdjustTransToAspect(Vector& v) void ZeroGS::AdjustTransToAspect(Vector& v)
@ -724,7 +725,7 @@ inline void AfterRendererUnimportantJob()
if (g_bMakeSnapshot) if (g_bMakeSnapshot)
{ {
AfterRenderMadeSnapshoot(); AfterRenderMadeSnapshoot();
g_bMakeSnapshot = 0; g_bMakeSnapshot = false;
} }
if (s_avicapturing) if (s_avicapturing)

View File

@ -186,6 +186,7 @@ int g_PrevBitwiseTexX = -1, g_PrevBitwiseTexY = -1; // textures stored in SAMP_B
static alphaInfo s_alphaInfo; // ZZ static alphaInfo s_alphaInfo; // ZZ
extern u8* g_pbyGSClut; extern u8* g_pbyGSClut;
extern int ppf;
//------------------ Namespace //------------------ Namespace

View File

@ -32,6 +32,7 @@
#include "Mem.h" #include "Mem.h"
bool g_bMakeSnapshot = false;
extern "C" extern "C"
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -62,7 +63,7 @@ int s_aviinit = 0;
// Set variables need to made a snapshoot when it's possible // Set variables need to made a snapshoot when it's possible
void ZeroGS::SaveSnapshot(const char* filename) void ZeroGS::SaveSnapshot(const char* filename)
{ {
g_bMakeSnapshot = 1; g_bMakeSnapshot = true;
strSnapshot = filename; strSnapshot = filename;
} }
@ -311,6 +312,7 @@ bool ZeroGS::SaveTGA(const char* filename, int width, int height, void* pdata)
// AVI start -- set needed glabal variables // AVI start -- set needed glabal variables
void ZeroGS::StartCapture() void ZeroGS::StartCapture()
{ {
if (conf.captureAvi()) return;
if (!s_aviinit) if (!s_aviinit)
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -326,16 +328,21 @@ void ZeroGS::StartCapture()
} }
s_avicapturing = 1; s_avicapturing = 1;
conf.setCaptureAvi(true);
ZZLog::Warn_Log("Started recording zerogs.avi.");
} }
// Stop. // Stop.
void ZeroGS::StopCapture() void ZeroGS::StopCapture()
{ {
if (!conf.captureAvi()) return;
s_avicapturing = 0; s_avicapturing = 0;
conf.setCaptureAvi(false);
ZZLog::Warn_Log("Stopped recording.");
} }
// And capture frame // And capture frame does not work on linux.
// Does not work on linux
void ZeroGS::CaptureFrame() void ZeroGS::CaptureFrame()
{ {
assert(s_avicapturing && s_aviinit); assert(s_avicapturing && s_aviinit);

View File

@ -51,11 +51,11 @@ HDC hDC = NULL; // Private GDI Device Context
HGLRC hRC = NULL; // Permanent Rendering Context HGLRC hRC = NULL; // Permanent Rendering Context
#endif #endif
bool g_bIsLost = 0; // ZZ // This is always false? Fixme.
bool g_bIsLost = false;
bool g_bMakeSnapshot = 0;
string strSnapshot; string strSnapshot;
primInfo *prim;
CGprogram g_vsprog = 0, g_psprog = 0; // 2 -- ZZ CGprogram g_vsprog = 0, g_psprog = 0; // 2 -- ZZ
// AVI Capture // AVI Capture
int s_avicapturing = 0; int s_avicapturing = 0;
@ -262,7 +262,6 @@ void ZeroGS::HandleGLError()
} }
} }
void ZeroGS::GSStateReset() void ZeroGS::GSStateReset()
{ {
FUNCLOG FUNCLOG
@ -292,6 +291,62 @@ void ZeroGS::GSStateReset()
vb[1].ictx = 1; vb[1].ictx = 1;
} }
void ZeroGS::Reset()
{
FUNCLOG
s_RTs.ResolveAll();
s_DepthRTs.ResolveAll();
vb[0].nCount = 0;
vb[1].nCount = 0;
memset(s_nResolveCounts, 0, sizeof(s_nResolveCounts));
s_nLastResolveReset = 0;
icurctx = -1;
g_vsprog = g_psprog = 0;
GSStateReset();
Destroy(0);
drawfn[0] = KickDummy;
drawfn[1] = KickDummy;
drawfn[2] = KickDummy;
drawfn[3] = KickDummy;
drawfn[4] = KickDummy;
drawfn[5] = KickDummy;
drawfn[6] = KickDummy;
drawfn[7] = KickDummy;
}
void ZeroGS::GSReset()
{
FUNCLOG
memset(&gs, 0, sizeof(gs));
ZeroGS::GSStateReset();
gs.prac = 1;
prim = &gs._prim[0];
gs.nTriFanVert = -1;
gs.imageTransfer = -1;
gs.q = 1;
}
void ZeroGS::GSSoftReset(u32 mask)
{
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]));
gs.imageTransfer = -1;
gs.q = 1;
gs.nTriFanVert = -1;
}
void ZeroGS::AddMessage(const char* pstr, u32 ms) void ZeroGS::AddMessage(const char* pstr, u32 ms)
{ {
FUNCLOG FUNCLOG
@ -341,34 +396,6 @@ void ZeroGS::SetChangeDeviceSize(int nNewWidth, int nNewHeight)
} }
} }
void ZeroGS::Reset()
{
FUNCLOG
s_RTs.ResolveAll();
s_DepthRTs.ResolveAll();
vb[0].nCount = 0;
vb[1].nCount = 0;
memset(s_nResolveCounts, 0, sizeof(s_nResolveCounts));
s_nLastResolveReset = 0;
icurctx = -1;
g_vsprog = g_psprog = 0;
GSStateReset();
Destroy(0);
drawfn[0] = KickDummy;
drawfn[1] = KickDummy;
drawfn[2] = KickDummy;
drawfn[3] = KickDummy;
drawfn[4] = KickDummy;
drawfn[5] = KickDummy;
drawfn[6] = KickDummy;
drawfn[7] = KickDummy;
}
void ZeroGS::ChangeDeviceSize(int nNewWidth, int nNewHeight) void ZeroGS::ChangeDeviceSize(int nNewWidth, int nNewHeight)
{ {
FUNCLOG FUNCLOG
@ -570,7 +597,7 @@ void ZeroGS::Restore()
if (!g_bIsLost) return; if (!g_bIsLost) return;
//if( SUCCEEDED(pd3dDevice->Reset(&d3dpp)) ) { //if( SUCCEEDED(pd3dDevice->Reset(&d3dpp)) ) {
g_bIsLost = 0; g_bIsLost = false;
// handle lost states // handle lost states
ZeroGS::ChangeDeviceSize(nBackbufferWidth, nBackbufferHeight); ZeroGS::ChangeDeviceSize(nBackbufferWidth, nBackbufferHeight);

View File

@ -378,7 +378,6 @@ extern GLenum g_internalRGBAFloatFmt;
extern GLenum g_internalRGBAFloat16Fmt; extern GLenum g_internalRGBAFloat16Fmt;
extern CGprogram g_vsprog, g_psprog; extern CGprogram g_vsprog, g_psprog;
extern bool g_bMakeSnapshot;
extern string strSnapshot; extern string strSnapshot;
extern bool g_bCRTCBilinear; extern bool g_bCRTCBilinear;
@ -747,8 +746,10 @@ void Destroy(bool bD3D);
void Restore(); // call to restore device void Restore(); // call to restore device
void Reset(); // call to destroy video resources void Reset(); // call to destroy video resources
void GSStateReset(); void GSStateReset();
void GSReset();
void GSSoftReset(u32 mask);
void HandleGLError(); void HandleGLError();
// called on a primitive switch // called on a primitive switch