diff --git a/plugins/zerogs/opengl/GS.h b/plugins/zerogs/opengl/GS.h index 5e643ca651..86b350619b 100644 --- a/plugins/zerogs/opengl/GS.h +++ b/plugins/zerogs/opengl/GS.h @@ -855,4 +855,5 @@ public: #endif + #endif diff --git a/plugins/zzogl-pg/opengl/GLWin.h b/plugins/zzogl-pg/opengl/GLWin.h index ff3cdfa598..6410086d99 100644 --- a/plugins/zzogl-pg/opengl/GLWin.h +++ b/plugins/zzogl-pg/opengl/GLWin.h @@ -67,5 +67,6 @@ class GLWindow extern GLWindow GLWin; +extern void ChangeWindowSize(int nNewWidth, int nNewHeight); #endif // GLWIN_H_INCLUDED diff --git a/plugins/zzogl-pg/opengl/GLWin32.cpp b/plugins/zzogl-pg/opengl/GLWin32.cpp index d72f5498d2..2c4fe1938f 100644 --- a/plugins/zzogl-pg/opengl/GLWin32.cpp +++ b/plugins/zzogl-pg/opengl/GLWin32.cpp @@ -18,7 +18,6 @@ */ #include "GS.h" -#include "zerogs.h" #include "GLWin.h" #ifdef GL_WIN32_WINDOW diff --git a/plugins/zzogl-pg/opengl/GLWinX11.cpp b/plugins/zzogl-pg/opengl/GLWinX11.cpp index 070b0eb5e3..d707441134 100644 --- a/plugins/zzogl-pg/opengl/GLWinX11.cpp +++ b/plugins/zzogl-pg/opengl/GLWinX11.cpp @@ -19,7 +19,6 @@ #include "Util.h" #include "GLWin.h" -#include "zerogs.h" #ifdef GL_X11_WINDOW diff --git a/plugins/zzogl-pg/opengl/GS.h b/plugins/zzogl-pg/opengl/GS.h index d562eb31db..7460745660 100644 --- a/plugins/zzogl-pg/opengl/GS.h +++ b/plugins/zzogl-pg/opengl/GS.h @@ -362,6 +362,8 @@ union tex_0_info #define TEX_HIGHLIGHT2 3 bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height); +extern void SaveTex(tex0Info* ptex, int usevid); +extern char* NamedSaveTex(tex0Info* ptex, int usevid); typedef struct { diff --git a/plugins/zzogl-pg/opengl/GSmain.cpp b/plugins/zzogl-pg/opengl/GSmain.cpp index 9da51abac4..17e279e799 100644 --- a/plugins/zzogl-pg/opengl/GSmain.cpp +++ b/plugins/zzogl-pg/opengl/GSmain.cpp @@ -34,7 +34,6 @@ using namespace std; #include "Profile.h" #include "GLWin.h" -#include "zerogs.h" #include "targets.h" #include "ZZoglShaders.h" #include "ZZoglFlushHack.h" @@ -88,6 +87,12 @@ extern int g_nPixelShaderVer, g_nFrameRender, g_nFramesSkipped; extern void ProcessEvents(); extern void WriteAA(); extern void WriteBilinear(); +extern void ZZDestroy(); +extern bool ZZCreate(int width, int height); +extern void ZZGSStateReset(); + +// switches the render target to the real target, flushes the current render targets and renders the real image +void RenderCRTC(int interlace); extern int VALIDATE_THRESH; extern u32 TEXDESTROY_THRESH; @@ -296,12 +301,30 @@ void CALLBACK GSsetFrameSkip(int frameskip) void CALLBACK GSreset() { - ZZGSReset(); + FUNCLOG + + memset(&gs, 0, sizeof(gs)); + + ZZGSStateReset(); + + gs.prac = 1; + prim = &gs._prim[0]; + gs.nTriFanVert = -1; + gs.imageTransfer = -1; + gs.q = 1; } void CALLBACK GSgifSoftReset(u32 mask) { - ZZGSSoftReset(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; } s32 CALLBACK GSinit() @@ -382,7 +405,7 @@ void CALLBACK GSclose() { FUNCLOG - ZZDestroy(1); + ZZDestroy(); GLWin.CloseWindow(); SaveStateFile = NULL; diff --git a/plugins/zzogl-pg/opengl/GifTransfer.cpp b/plugins/zzogl-pg/opengl/GifTransfer.cpp index 81025ea428..c5c6461a2b 100644 --- a/plugins/zzogl-pg/opengl/GifTransfer.cpp +++ b/plugins/zzogl-pg/opengl/GifTransfer.cpp @@ -19,7 +19,6 @@ #include "GS.h" #include "Mem.h" -#include "zerogs.h" #include "GifTransfer.h" #ifdef _DEBUG diff --git a/plugins/zzogl-pg/opengl/HostMemory.cpp b/plugins/zzogl-pg/opengl/HostMemory.cpp index f82b458190..ca79739f7d 100644 --- a/plugins/zzogl-pg/opengl/HostMemory.cpp +++ b/plugins/zzogl-pg/opengl/HostMemory.cpp @@ -24,9 +24,11 @@ #include #include "Mem.h" #include "x86.h" -#include "zerogs.h" #include "targets.h" +// flush current vertices, call before setting new registers (the main render method) +extern void Flush(int context); + u8* g_pbyGSMemory = NULL; // 4Mb GS system mem void GSMemory::init() diff --git a/plugins/zzogl-pg/opengl/Linux/Linux.cpp b/plugins/zzogl-pg/opengl/Linux/Linux.cpp index 42ba896b07..df1e87f63c 100644 --- a/plugins/zzogl-pg/opengl/Linux/Linux.cpp +++ b/plugins/zzogl-pg/opengl/Linux/Linux.cpp @@ -24,7 +24,6 @@ #include "GS.h" #include "Linux.h" -#include "zerogs.h" #include "GLWin.h" #include diff --git a/plugins/zzogl-pg/opengl/Mem.cpp b/plugins/zzogl-pg/opengl/Mem.cpp index b5493e350b..c6eb6f1601 100644 --- a/plugins/zzogl-pg/opengl/Mem.cpp +++ b/plugins/zzogl-pg/opengl/Mem.cpp @@ -19,7 +19,6 @@ #include "GS.h" #include "Mem.h" -#include "zerogs.h" #include "targets.h" #include "x86.h" diff --git a/plugins/zzogl-pg/opengl/NewRegs.cpp b/plugins/zzogl-pg/opengl/NewRegs.cpp index 18aef6aa32..4ddbb7884d 100644 --- a/plugins/zzogl-pg/opengl/NewRegs.cpp +++ b/plugins/zzogl-pg/opengl/NewRegs.cpp @@ -22,7 +22,6 @@ #include "NewRegs.h" #include "PS2Etypes.h" -#include "zerogs.h" #include "targets.h" #ifdef USE_OLD_REGS diff --git a/plugins/zzogl-pg/opengl/NewRegs.h b/plugins/zzogl-pg/opengl/NewRegs.h index d87bdcacd6..a2a3091ecd 100644 --- a/plugins/zzogl-pg/opengl/NewRegs.h +++ b/plugins/zzogl-pg/opengl/NewRegs.h @@ -23,8 +23,6 @@ #ifdef USE_OLD_REGS #include "Regs.h" #else - -bool CheckChangeInClut(u32 highdword, u32 psm); // returns true if clut will change after this tex0 op enum GIF_REG { @@ -778,7 +776,20 @@ REG_SET_END extern void WriteTempRegs(); extern void SetFrameSkip(bool skip); -extern void ResetRegs(); +extern void ResetRegs(); + +extern void SetTexFlush(); +extern void SetFogColor(u32 fog); +extern void SetFogColor(GIFRegFOGCOL* fog); +extern bool CheckChangeInClut(u32 highdword, u32 psm); // returns true if clut will change after this tex0 op + +// flush current vertices, call before setting new registers (the main render method) +void Flush(int context); +void FlushBoth(); + +// called on a primitive switch +void Prim(); + #endif #endif // NEWREGS_H_INCLUDED diff --git a/plugins/zzogl-pg/opengl/Profile.cpp b/plugins/zzogl-pg/opengl/Profile.cpp index 2b68c0dfcc..20c9c3712f 100644 --- a/plugins/zzogl-pg/opengl/Profile.cpp +++ b/plugins/zzogl-pg/opengl/Profile.cpp @@ -25,6 +25,7 @@ #include #include #include "Profile.h" +#include "Util.h" using namespace std; diff --git a/plugins/zzogl-pg/opengl/Profile.h b/plugins/zzogl-pg/opengl/Profile.h index d81bb44ff8..d8c4a0a3c2 100644 --- a/plugins/zzogl-pg/opengl/Profile.h +++ b/plugins/zzogl-pg/opengl/Profile.h @@ -20,7 +20,7 @@ #ifndef PROFILE_H_INCLUDED #define PROFILE_H_INCLUDED -#include "zerogs.h" +#include "Util.h" #if !defined(ZEROGS_DEVBUILD) #define g_bWriteProfile 0 diff --git a/plugins/zzogl-pg/opengl/Regs.cpp b/plugins/zzogl-pg/opengl/Regs.cpp index 06088f5f54..5241352991 100644 --- a/plugins/zzogl-pg/opengl/Regs.cpp +++ b/plugins/zzogl-pg/opengl/Regs.cpp @@ -22,7 +22,6 @@ #include "Regs.h" #include "PS2Etypes.h" -#include "zerogs.h" #include "targets.h" #include "ZZKick.h" diff --git a/plugins/zzogl-pg/opengl/Regs.h b/plugins/zzogl-pg/opengl/Regs.h index fa1d53855d..c0bf4f6fd7 100644 --- a/plugins/zzogl-pg/opengl/Regs.h +++ b/plugins/zzogl-pg/opengl/Regs.h @@ -23,8 +23,6 @@ #ifdef USE_OLD_REGS -bool CheckChangeInClut(u32 highdword, u32 psm); // returns true if clut will change after this tex0 op - enum GIF_REG { GIF_REG_PRIM = 0x00, @@ -948,6 +946,19 @@ REG_END extern void WriteTempRegs(); extern void SetFrameSkip(bool skip); extern void ResetRegs(); + +extern void SetTexFlush(); +extern void SetFogColor(u32 fog); +extern void SetFogColor(GIFRegFOGCOL* fog); +extern bool CheckChangeInClut(u32 highdword, u32 psm); // returns true if clut will change after this tex0 op + +// flush current vertices, call before setting new registers (the main render method) +void Flush(int context); +void FlushBoth(); + +// called on a primitive switch +void Prim(); + #else #include "NewRegs.h" #endif diff --git a/plugins/zzogl-pg/opengl/Util.h b/plugins/zzogl-pg/opengl/Util.h index 705bdde7df..da2e9bb002 100644 --- a/plugins/zzogl-pg/opengl/Util.h +++ b/plugins/zzogl-pg/opengl/Util.h @@ -366,6 +366,13 @@ extern char *SysLibError(); // Gets previous error loading sysbols extern void SysCloseLibrary(void *lib); // Closes Library extern void SysMessage(const char *fmt, ...); +#ifdef ZEROGS_DEVBUILD +extern char* EFFECT_NAME; +extern char* EFFECT_DIR; +extern u32 g_nGenVars, g_nTexVars, g_nAlphaVars, g_nResolve; +extern bool g_bSaveTrans, g_bUpdateEffect, g_bSaveTex, g_bSaveResolved; +#endif + #ifdef __LINUX__ #include "Utilities/MemcpyFast.h" #define memcpy_amd memcpy_fast diff --git a/plugins/zzogl-pg/opengl/ZZKeyboard.cpp b/plugins/zzogl-pg/opengl/ZZKeyboard.cpp index 390cb9b7d5..2571848a71 100644 --- a/plugins/zzogl-pg/opengl/ZZKeyboard.cpp +++ b/plugins/zzogl-pg/opengl/ZZKeyboard.cpp @@ -36,6 +36,7 @@ extern bool THR_bShift, SaveStateExists; const char* s_aa[5] = { "AA none |", "AA 2x |", "AA 4x |", "AA 8x |", "AA 16x |" }; const char* pbilinear[] = { "off", "normal", "forced" }; +extern void SetAA(int mode); void ProcessBilinear() { @@ -255,6 +256,9 @@ void WriteBilinear() } #ifdef _WIN32 + +extern void ChangeDeviceSize(int nNewWidth, int nNewHeight); + void ProcessEvents() { MSG msg; diff --git a/plugins/zzogl-pg/opengl/ZZKick.cpp b/plugins/zzogl-pg/opengl/ZZKick.cpp index ef585d460e..90daf63ef5 100644 --- a/plugins/zzogl-pg/opengl/ZZKick.cpp +++ b/plugins/zzogl-pg/opengl/ZZKick.cpp @@ -18,11 +18,13 @@ */ #include "ZZKick.h" -#include "zerogs.h" +#include "targets.h" const u32 g_primmult[8] = { 1, 2, 2, 3, 3, 3, 2, 0xff }; const u32 g_primsub[8] = { 1, 2, 1, 3, 1, 1, 2, 0 }; +extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height + DrawFn drawfn[8] = { KickDummy, KickDummy, KickDummy, KickDummy, KickDummy, KickDummy, KickDummy, KickDummy }; diff --git a/plugins/zzogl-pg/opengl/ZZLog.h b/plugins/zzogl-pg/opengl/ZZLog.h index 81fa0fe465..bbcc785f7a 100644 --- a/plugins/zzogl-pg/opengl/ZZLog.h +++ b/plugins/zzogl-pg/opengl/ZZLog.h @@ -23,6 +23,8 @@ #include "Util.h" #include +extern void HandleGLError(); + //Logging for errors that are called often should have a time counter. #ifdef __LINUX__ static u32 __attribute__((unused)) lasttime = 0; @@ -168,9 +170,6 @@ extern void DrawText(const char* pstr, int left, int top, u32 color); extern void __LogToConsole(const char *fmt, ...); extern void ZZAddMessage(const char* pstr, u32 ms = 5000); -extern void SetAA(int mode); -extern bool ZZCreate(int width, int height); -extern void ZZDestroy(bool bD3D); extern void StartCapture(); extern void StopCapture(); diff --git a/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp b/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp index db46e958ee..6c1060944d 100644 --- a/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp @@ -25,7 +25,9 @@ #include "GLWin.h" #include "ZZoglShaders.h" #include "ZZoglShoots.h" +#include "ZZKick.h" #include "rasterfont.h" // simple font +#include //------------------ Defines #if !defined(ZEROGS_DEVBUILD) @@ -49,6 +51,11 @@ vector s_vecTempTextures; // temporary textures, released at the end of extern bool g_bMakeSnapshot; extern string strSnapshot; +extern void ExtWrite(); +extern void ZZDestroy(); +extern void ChangeDeviceSize(int nNewWidth, int nNewHeight); + +extern GLuint vboRect; // Adjusts vertex shader BitBltPos vector v to preserve aspect ratio. It used to emulate 4:3 or 16:9. void AdjustTransToAspect(float4& v) { @@ -175,6 +182,8 @@ inline void FrameObtainDispinfo(u32 bInterlace, tex0Info* dispinfo) } } +extern bool s_bWriteDepth; + // Something should be done before Renderering the picture. inline void RenderStartHelper(u32 bInterlace) { @@ -677,6 +686,27 @@ inline void AfterRenderMadeSnapshoot() g_bMakeSnapshot = false; } +// call to destroy video resources +void ZZReset() +{ + 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; + + ZZGSStateReset(); + ZZDestroy(); + clear_drawfn(); +} + // If needed reset inline void AfterRendererResizeWindow() { diff --git a/plugins/zzogl-pg/opengl/ZZoglCRTC.h b/plugins/zzogl-pg/opengl/ZZoglCRTC.h index 6f5982eda2..6a3f9dfa80 100644 --- a/plugins/zzogl-pg/opengl/ZZoglCRTC.h +++ b/plugins/zzogl-pg/opengl/ZZoglCRTC.h @@ -22,7 +22,6 @@ #include -#include "zerogs.h" #include "targets.h" #define INTERLACE_COUNT (bInterlace && interlace == (conf.interlace)) @@ -62,6 +61,9 @@ extern void FlushTransferRanges(const tex0Info* ptex); extern void ProcessMessages(); void AdjustTransToAspect(float4& v); +void ZZGSStateReset(); +extern int nBackbufferWidth, nBackbufferHeight; + // Interlace texture is lazy 1*(height) array of 1 and 0. // If its height (named s_nInterlaceTexWidth here) is hanging we must redo // the texture. diff --git a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp index e5c216bfc8..32a4d341ab 100644 --- a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp @@ -22,7 +22,6 @@ //------------------ Includes #include "GS.h" #include "Mem.h" -#include "zerogs.h" #include "GLWin.h" #include "ZZoglShaders.h" @@ -88,6 +87,9 @@ inline bool CreateImportantCheck(); inline void CreateOtherCheck(); inline bool CreateOpenShadersFile(); +void ZZGSStateReset(); +extern int nBackbufferWidth, nBackbufferHeight; + //------------------ Dummies #ifdef _WIN32 void __stdcall glBlendFuncSeparateDummy(GLenum e1, GLenum e2, GLenum e3, GLenum e4) @@ -158,9 +160,12 @@ u32 ptexConv32to16 = 0; int g_nDepthBias = 0; extern void Delete_Avi_Capture(); +extern void ZZDestroy(); +extern void SetAA(int mode); //------------------ Code +///< returns true if the the opengl extension is supported bool IsGLExt(const char* szTargetExtension) { return mapGLExtensions.find(string(szTargetExtension)) != mapGLExtensions.end(); @@ -444,7 +449,7 @@ bool ZZCreate(int _width, int _height) bool bSuccess = true; int i; - ZZDestroy(1); + ZZDestroy(); ZZGSStateReset(); if (!Create_Window(_width, _height)) return false; @@ -777,7 +782,7 @@ bool ZZCreate(int _width, int _height) } } -void ZZDestroy(bool bD3D) +void ZZDestroy() { Delete_Avi_Capture(); diff --git a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp index c2a01abf84..1207697a65 100644 --- a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp @@ -23,10 +23,10 @@ #include "GS.h" #include "Mem.h" -#include "zerogs.h" #include "targets.h" #include "ZZoglFlushHack.h" #include "ZZoglShaders.h" +#include //------------------ Defines #ifndef ZEROGS_DEVBUILD @@ -144,6 +144,7 @@ static u32 s_ptexNextSet[2] = {0}; // ZZ extern vector s_vecTempTextures; // temporary textures, released at the end of every frame extern bool s_bTexFlush; +extern int g_nCurVBOIndex; bool s_bWriteDepth = false; bool s_bDestAlphaTest = false; int s_ClutResolve = 0; // ZZ @@ -192,6 +193,7 @@ int s_nWireframeCount = 0; VB vb[2]; float fiTexWidth[2], fiTexHeight[2]; // current tex width and height +extern vector g_vboBuffers; // VBOs for all drawing commands //u8 s_AAx = 0, s_AAy = 0; // if AAy is set, then AAx has to be set Point AA = {0,0}; @@ -217,6 +219,11 @@ inline void ProcessFBA(const VB& curvb, ZZshParameter sOneColor); // zz void SetContextTarget(int context); +void SetWriteDepth(); +bool IsWriteDepth(); +void SetDestAlphaTest(); +void ResetRenderTarget(int index); + //------------------ Code inline float AlphaReferedValue(int aref) diff --git a/plugins/zzogl-pg/opengl/ZZoglFlushHack.h b/plugins/zzogl-pg/opengl/ZZoglFlushHack.h index 999f399db6..2e05604baa 100644 --- a/plugins/zzogl-pg/opengl/ZZoglFlushHack.h +++ b/plugins/zzogl-pg/opengl/ZZoglFlushHack.h @@ -27,7 +27,6 @@ #define ZZOGL_FLUSH_HACK_H_INCLUDED #include "GS.h" -#include "zerogs.h" #include "targets.h" extern int g_SkipFlushFrame; diff --git a/plugins/zzogl-pg/opengl/ZZoglMath.h b/plugins/zzogl-pg/opengl/ZZoglMath.h index 1754a9ae8c..2a3fbca45d 100644 --- a/plugins/zzogl-pg/opengl/ZZoglMath.h +++ b/plugins/zzogl-pg/opengl/ZZoglMath.h @@ -26,6 +26,7 @@ #endif #include +#include "Pcsx2Defs.h" //#define ZZ_MMATH diff --git a/plugins/zzogl-pg/opengl/ZZoglSave.cpp b/plugins/zzogl-pg/opengl/ZZoglSave.cpp index 5087162b4c..32d2a5d7e0 100644 --- a/plugins/zzogl-pg/opengl/ZZoglSave.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglSave.cpp @@ -20,9 +20,9 @@ // Save and Load. //------------------ Includes -#include "zerogs.h" #include "targets.h" +extern void ZZGSStateReset(); //----------------------- Defines #define VBSAVELIMIT ((u32)((u8*)&vb[0].nNextFrameHeight-(u8*)&vb[0])) @@ -44,6 +44,9 @@ char *libraryNameX = "ZeroGS Playground OpenGL "; extern char *libraryName; extern u32 s_uTex1Data[2][2], s_uClampData[2]; +void SetFogColor(u32 fog); +void SetFogColor(GIFRegFOGCOL* fog); + int ZZSave(s8* pbydata) { if (pbydata == NULL) @@ -86,6 +89,7 @@ int ZZSave(s8* pbydata) } extern u32 s_uFramebuffer; +extern int g_nCurVBOIndex; bool ZZLoad(s8* pbydata) { diff --git a/plugins/zzogl-pg/opengl/ZZoglShaders.cpp b/plugins/zzogl-pg/opengl/ZZoglShaders.cpp index a52277f052..545245865b 100644 --- a/plugins/zzogl-pg/opengl/ZZoglShaders.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglShaders.cpp @@ -21,10 +21,10 @@ // ZZogl Shader manipulation functions. //------------------- Includes -#include "zerogs.h" #include "ZZoglShaders.h" #include "zpipe.h" - +#include +#include #ifdef _WIN32 # include "Win32.h" @@ -101,6 +101,7 @@ extern u32 ptexBilinearBlocks; extern u32 ptexConv32to16; inline bool LoadEffects(); +extern bool s_bWriteDepth; struct SHADERHEADER { diff --git a/plugins/zzogl-pg/opengl/ZZoglShaders.h b/plugins/zzogl-pg/opengl/ZZoglShaders.h index 5814032e1f..ecf1c582db 100644 --- a/plugins/zzogl-pg/opengl/ZZoglShaders.h +++ b/plugins/zzogl-pg/opengl/ZZoglShaders.h @@ -29,6 +29,10 @@ // Just bitmask for different type of shaders #define SHADER_REDUCED 1 // equivalent to ps2.0 #define SHADER_ACCURATE 2 // for older cards with less accurate math (ps2.x+) + +#include "ZZoglMath.h" +#include "GS.h" + // For output const static char* g_pShaders[] = { "full", "reduced", "accurate", "accurate-reduced" }; diff --git a/plugins/zzogl-pg/opengl/ZZoglShoots.cpp b/plugins/zzogl-pg/opengl/ZZoglShoots.cpp index 42be08ec99..09eef0ca9e 100644 --- a/plugins/zzogl-pg/opengl/ZZoglShoots.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglShoots.cpp @@ -27,7 +27,6 @@ #endif #include -#include "zerogs.h" #include "targets.h" #include "Mem.h" #include "ZZoglShoots.h" @@ -44,9 +43,12 @@ extern "C" #define HAVE_BOOLEAN #endif -#include "jpeglib.h" // This library want to be after zerogs.h +#include "jpeglib.h" } + +extern int nBackbufferWidth, nBackbufferHeight; + //------------------ Defines #define TGA_FILE_NAME_MAX_LENGTH 20 #define MAX_NUMBER_SAVED_TGA 200 diff --git a/plugins/zzogl-pg/opengl/ZZoglVB.cpp b/plugins/zzogl-pg/opengl/ZZoglVB.cpp index 7206329227..4621de7666 100644 --- a/plugins/zzogl-pg/opengl/ZZoglVB.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglVB.cpp @@ -21,10 +21,10 @@ // VB stands for Visual Buffer, as I think //------------------- Includes -#include "zerogs.h" #include "targets.h" #include "GS.h" #include "Mem.h" +extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height // ----------------- Defines #define MINMAX_SHIFT 3 diff --git a/plugins/zzogl-pg/opengl/targets.cpp b/plugins/zzogl-pg/opengl/targets.cpp index 10d8a435a3..621e94bc2c 100644 --- a/plugins/zzogl-pg/opengl/targets.cpp +++ b/plugins/zzogl-pg/opengl/targets.cpp @@ -23,10 +23,10 @@ #include "Mem.h" #include "x86.h" -#include "zerogs.h" #include "targets.h" #include "ZZoglShaders.h" #include "Clut.h" +#include #ifdef ZEROGS_SSE2 #include @@ -60,6 +60,10 @@ int VALIDATE_THRESH = 8; u32 TEXDESTROY_THRESH = 16; void _Resolve(const void* psrc, int fbp, int fbw, int fbh, int psm, u32 fbm, bool mode); +void SetWriteDepth(); +bool IsWriteDepth(); +bool IsWriteDestAlphaTest(); +void ResetRenderTarget(int index); // ------------------------- Useful inlines ------------------------------------ diff --git a/plugins/zzogl-pg/opengl/targets.h b/plugins/zzogl-pg/opengl/targets.h index 399096a2ac..9a77161a03 100644 --- a/plugins/zzogl-pg/opengl/targets.h +++ b/plugins/zzogl-pg/opengl/targets.h @@ -22,6 +22,10 @@ #define TARGET_VIRTUAL_KEY 0x80000000 #include "PS2Edefs.h" +#include +#include +#include "GS.h" +#include "ZZGl.h" #ifndef GL_TEXTURE_RECTANGLE #define GL_TEXTURE_RECTANGLE GL_TEXTURE_RECTANGLE_NV diff --git a/plugins/zzogl-pg/opengl/zerogs.cpp b/plugins/zzogl-pg/opengl/zerogs.cpp index e874eb880a..2e485ad085 100644 --- a/plugins/zzogl-pg/opengl/zerogs.cpp +++ b/plugins/zzogl-pg/opengl/zerogs.cpp @@ -95,11 +95,12 @@ int nBackbufferWidth, nBackbufferHeight; // ZZ extern CRangeManager s_RangeMngr; // manages overwritten memory int s_nNewWidth = -1, s_nNewHeight = -1; -void ChangeDeviceSize(int nNewWidth, int nNewHeight); void ProcessMessages(); void RenderCustom(float fAlpha); // intro anim +bool ZZCreate(int width, int height); + /////////////////////// // Method Prototypes // /////////////////////// @@ -107,6 +108,7 @@ void RenderCustom(float fAlpha); // intro anim void ResolveInRange(int start, int end); void ExtWrite(); +extern GLuint vboRect; void ResetRenderTarget(int index) { @@ -237,54 +239,6 @@ void ZZGSStateReset() vb[1].ictx = 1; } -void ZZReset() -{ - 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; - - ZZGSStateReset(); - ZZDestroy(0); - clear_drawfn(); -} - -void ZZGSReset() -{ - FUNCLOG - - memset(&gs, 0, sizeof(gs)); - - ZZGSStateReset(); - - gs.prac = 1; - prim = &gs._prim[0]; - gs.nTriFanVert = -1; - gs.imageTransfer = -1; - gs.q = 1; -} - -void ZZGSSoftReset(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 ChangeWindowSize(int nNewWidth, int nNewHeight) { FUNCLOG diff --git a/plugins/zzogl-pg/opengl/zerogs.h b/plugins/zzogl-pg/opengl/zerogs.h index a816e6c54d..bf7d9a41e7 100644 --- a/plugins/zzogl-pg/opengl/zerogs.h +++ b/plugins/zzogl-pg/opengl/zerogs.h @@ -25,17 +25,16 @@ #endif // ----------------------------- Includes -#include -#include -#include -#include -#include - -#include "ZZGl.h" -#include "GS.h" -#include "CRC.h" -#include "targets.h" +//#include +//#include +//#include +//#include +//#include +//#include "ZZGl.h" +//#include "CRC.h" +//#include "targets.h" +#include "PS2Edefs.h" // ------------------------ Variables ------------------------- ////////////////////////// @@ -48,60 +47,22 @@ extern u32 g_nGenVars, g_nTexVars, g_nAlphaVars, g_nResolve; extern bool g_bSaveTrans, g_bUpdateEffect, g_bSaveTex, g_bSaveResolved; #endif -extern int g_nPixelShaderVer; - extern bool s_bWriteDepth; extern int nBackbufferWidth, nBackbufferHeight; extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height -extern vector g_vboBuffers; // VBOs for all drawing commands -extern GLuint vboRect; -extern int g_nCurVBOIndex; - -void ChangeWindowSize(int nNewWidth, int nNewHeight); -void SetChangeDeviceSize(int nNewWidth, int nNewHeight); -void ChangeDeviceSize(int nNewWidth, int nNewHeight); -void SetAA(int mode); -void SetCRC(int crc); - -void ReloadEffects(); // Methods // -bool IsGLExt(const char* szTargetExtension); ///< returns true if the the opengl extension is supported -inline bool Create_Window(int _width, int _height); -bool ZZCreate(int width, int height); -void ZZDestroy(bool bD3D); -void ZZReset(); // call to destroy video resources void ZZGSStateReset(); -void ZZGSReset(); -void ZZGSSoftReset(u32 mask); -void HandleGLError(); + +// flush current vertices, call before setting new registers (the main render method) +void Flush(int context); +void FlushBoth(); // called on a primitive switch void Prim(); -void SetTexFlush(); -// flush current vertices, call before setting new registers (the main render method) -void Flush(int context); -void FlushBoth(); -void ExtWrite(); - -void SetWriteDepth(); -bool IsWriteDepth(); - -void SetDestAlphaTest(); -bool IsWriteDestAlphaTest(); - -void SetFogColor(u32 fog); -void SetFogColor(GIFRegFOGCOL* fog); -void SaveTex(tex0Info* ptex, int usevid); -char* NamedSaveTex(tex0Info* ptex, int usevid); - -// switches the render target to the real target, flushes the current render targets and renders the real image -void RenderCRTC(int interlace); -void ResetRenderTarget(int index); - #endif