diff --git a/plugins/zzogl-pg/opengl/GLWin.h b/plugins/zzogl-pg/opengl/GLWin.h new file mode 100644 index 0000000000..bca595fe1b --- /dev/null +++ b/plugins/zzogl-pg/opengl/GLWin.h @@ -0,0 +1,73 @@ +/* ZZ Open GL graphics plugin + * Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com + * Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008 + * + * 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. + * + * 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. + * + * 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 + */ + +#ifndef GLWIN_H_INCLUDED +#define GLWIN_H_INCLUDED + + +#ifdef _WIN32 +#define GL_WIN32_WINDOW +#else +#define GL_X11_WINDOW +#endif + +#undef CreateWindow // Undo Windows.h global namespace pollution + +#ifdef GL_X11_WINDOW +#include +#endif + +class GLWindow +{ + private: +#ifdef GL_X11_WINDOW + Display *glDisplay; + int glScreen; + GLXContext context; + XVisualInfo *vi; + + Window glWindow; + XSetWindowAttributes attr; + + // Original desktop video mode + XF86VidModeModeInfo deskMode; + + bool CreateVisual(); + void GetGLXVersion(); + void GetGLXVidModeVersion(); + void GetWindowSize(); +#endif + bool fullScreen, doubleBuffered; + s32 x, y; + u32 width, height, depth; + + public: + void SwapGLBuffers(); + bool ReleaseContext(); + + bool CreateWindow(void *pDisplay); + void CloseWindow(); + bool DisplayWindow(int _width, int _height); + void SetTitle(char *strtitle); + void ResizeCheck(); +}; + +extern GLWindow GLWin; + +#endif // GLWIN_H_INCLUDED diff --git a/plugins/zzogl-pg/opengl/GLWin32.cpp b/plugins/zzogl-pg/opengl/GLWin32.cpp index 849c8d1db0..e154de0b3d 100644 --- a/plugins/zzogl-pg/opengl/GLWin32.cpp +++ b/plugins/zzogl-pg/opengl/GLWin32.cpp @@ -19,6 +19,7 @@ #include "GS.h" #include "zerogs.h" +#include "GLWin.h" #ifdef GL_WIN32_WINDOW @@ -138,7 +139,7 @@ bool GLWindow::CreateWindow(void *pDisplay) return (pDisplay != NULL); } -bool GLWindow::ReleaseWindow() +bool GLWindow::ReleaseContext() { if (hRC) // Do We Have A Rendering Context? { @@ -305,7 +306,7 @@ void GLWindow::SwapGLBuffers() void GLWindow::SetTitle(char *strtitle) { - SetWindowText(GShwnd, strtitle); + if (!conf.fullscreen()) SetWindowText(GShwnd, strtitle); } void GLWindow::ResizeCheck() diff --git a/plugins/zzogl-pg/opengl/GLWinX11.cpp b/plugins/zzogl-pg/opengl/GLWinX11.cpp index a296d1940c..70b15c6ad6 100644 --- a/plugins/zzogl-pg/opengl/GLWinX11.cpp +++ b/plugins/zzogl-pg/opengl/GLWinX11.cpp @@ -17,10 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "GS.h" +#include "Util.h" +#include "GLWin.h" #include "zerogs.h" - #ifdef GL_X11_WINDOW #include @@ -37,19 +37,28 @@ bool GLWindow::CreateWindow(void *pDisplay) return true; } -bool GLWindow::ReleaseWindow() +bool GLWindow::ReleaseContext() { - if (context) + if (context && (glDisplay != NULL)) { if (!glXMakeCurrent(glDisplay, None, NULL)) { ZZLog::Error_Log("Could not release drawing context."); } - + glXDestroyContext(glDisplay, context); context = NULL; } + + return true; +} + +void GLWindow::CloseWindow() +{ + conf.x = x; + conf.y = y; + SaveConfig(); /* switch back to original desktop resolution if we were in fullscreen */ if (glDisplay != NULL) @@ -60,16 +69,7 @@ bool GLWindow::ReleaseWindow() XF86VidModeSetViewPort(glDisplay, glScreen, 0, 0); } } - - return true; -} - -void GLWindow::CloseWindow() -{ - conf.x = x; - conf.y = y; - SaveConfig(); - + if (glDisplay != NULL) { XCloseDisplay(glDisplay); @@ -77,21 +77,8 @@ void GLWindow::CloseWindow() } } -bool GLWindow::DisplayWindow(int _width, int _height) +bool GLWindow::CreateVisual() { - int i; - XVisualInfo *vi; - Colormap cmap; - int dpyWidth, dpyHeight; - int glxMajorVersion, glxMinorVersion; - int vidModeMajorVersion, vidModeMinorVersion; - Atom wmDelete; - Window winDummy; - unsigned int borderDummy; - - x = conf.x; - y = conf.y; - // attributes for a single buffered visual in RGBA format with at least // 8 bits per color and a 24 bit depth buffer int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 8, @@ -111,8 +98,6 @@ bool GLWindow::DisplayWindow(int _width, int _height) None }; - GLWin.fullScreen = (conf.fullscreen()); - /* get an appropriate visual */ vi = glXChooseVisual(glDisplay, glScreen, attrListDbl); @@ -133,32 +118,67 @@ bool GLWindow::DisplayWindow(int _width, int _height) ZZLog::Error_Log("Failed to get buffered Visual!"); return false; } + return true; +} +void GLWindow::GetWindowSize() +{ + unsigned int borderDummy; + Window winDummy; + + XGetGeometry(glDisplay, glWindow, &winDummy, &x, &y, &width, &height, &borderDummy, &depth); + ZZLog::Error_Log("Depth %d", depth); +} + +void GLWindow::GetGLXVersion() +{ + int glxMajorVersion, glxMinorVersion; + glXQueryVersion(glDisplay, &glxMajorVersion, &glxMinorVersion); ZZLog::Error_Log("glX-Version %d.%d", glxMajorVersion, glxMinorVersion); +} +void GLWindow::GetGLXVidModeVersion() +{ + int vidModeMajorVersion, vidModeMinorVersion; + + XF86VidModeQueryVersion(glDisplay, &vidModeMajorVersion, &vidModeMinorVersion); + + ZZLog::Error_Log("XF86VidModeExtension-Version %d.%d.", vidModeMajorVersion, vidModeMinorVersion); +} + +bool GLWindow::DisplayWindow(int _width, int _height) +{ + Colormap cmap; + + x = conf.x; + y = conf.y; + fullScreen = (conf.fullscreen()); + + if (!CreateVisual()) return false; + /* create a GLX context */ context = glXCreateContext(glDisplay, vi, NULL, GL_TRUE); - + /* create a color map */ cmap = XCreateColormap(glDisplay, RootWindow(glDisplay, vi->screen), vi->visual, AllocNone); + attr.colormap = cmap; attr.border_pixel = 0; + attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask; - // get a connection - XF86VidModeQueryVersion(glDisplay, &vidModeMajorVersion, &vidModeMinorVersion); - + GetGLXVersion(); + if (fullScreen) { + int dpyWidth, dpyHeight; + int modeNum = 0, bestMode = 0; XF86VidModeModeInfo **modes = NULL; - int modeNum = 0; - int bestMode = 0; - - // set best mode to current - bestMode = 0; - ZZLog::Error_Log("XF86VidModeExtension-Version %d.%d.", vidModeMajorVersion, vidModeMinorVersion); + + GetGLXVidModeVersion(); + XF86VidModeGetAllModeLines(glDisplay, glScreen, &modeNum, &modes); if (modeNum > 0 && modes != NULL) @@ -168,7 +188,7 @@ bool GLWindow::DisplayWindow(int _width, int _height) /* look for mode with requested resolution */ - for (i = 0; i < modeNum; i++) + for (int i = 0; i < modeNum; i++) { if ((modes[i]->hdisplay == _width) && (modes[i]->vdisplay == _height)) { @@ -186,7 +206,6 @@ bool GLWindow::DisplayWindow(int _width, int _height) /* create a fullscreen window */ attr.override_redirect = True; - attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask; glWindow = XCreateWindow(glDisplay, RootWindow(glDisplay, vi->screen), 0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, @@ -209,15 +228,15 @@ bool GLWindow::DisplayWindow(int _width, int _height) if (!fullScreen) { // create a window in window mode - attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask; glWindow = XCreateWindow(glDisplay, RootWindow(glDisplay, vi->screen), 0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &attr); // only set window title and handle wm_delete_events if in windowed mode + Atom wmDelete; wmDelete = XInternAtom(glDisplay, "WM_DELETE_WINDOW", True); - XSetWMProtocols(glDisplay, glWindow, &wmDelete, 1); + XSetStandardProperties(glDisplay, glWindow, "ZZOgl-PG", "ZZOgl-PG", None, NULL, 0, NULL); XMapRaised(glDisplay, glWindow); XMoveWindow(glDisplay, glWindow, x, y); @@ -225,10 +244,8 @@ bool GLWindow::DisplayWindow(int _width, int _height) // connect the glx-context to the window glXMakeCurrent(glDisplay, glWindow, context); - - XGetGeometry(glDisplay, glWindow, &winDummy, &x, &y, &width, &height, &borderDummy, &depth); - - ZZLog::Error_Log("Depth %d", depth); + + GetWindowSize(); if (glXIsDirect(glDisplay, context)) ZZLog::Error_Log("You have Direct Rendering!"); @@ -250,14 +267,17 @@ void GLWindow::SwapGLBuffers() void GLWindow::SetTitle(char *strtitle) { - XTextProperty prop; - memset(&prop, 0, sizeof(prop)); - char* ptitle = strtitle; + if (!conf.fullscreen()) + { + XTextProperty prop; + memset(&prop, 0, sizeof(prop)); + char* ptitle = strtitle; - if (XStringListToTextProperty(&ptitle, 1, &prop)) - XSetWMName(glDisplay, glWindow, &prop); + if (XStringListToTextProperty(&ptitle, 1, &prop)) + XSetWMName(glDisplay, glWindow, &prop); - XFree(prop.value); + XFree(prop.value); + } } void GLWindow::ResizeCheck() @@ -275,6 +295,8 @@ void GLWindow::ResizeCheck() if ((event.xconfigure.x != x) || (event.xconfigure.y != y)) { + // Fixme; x&y occassionally gives values near the top left corner rather then the real values, + // causing the window to change positions when adjusting ZZOgl's settings. x = event.xconfigure.x; y = event.xconfigure.y; } diff --git a/plugins/zzogl-pg/opengl/GS.h b/plugins/zzogl-pg/opengl/GS.h index 3c593ad5ac..7a5c4925d8 100644 --- a/plugins/zzogl-pg/opengl/GS.h +++ b/plugins/zzogl-pg/opengl/GS.h @@ -25,52 +25,16 @@ #include "Util.h" #include "GifTransfer.h" - -extern float fFPS; +//#include "GLWin.h" using namespace std; -#ifdef _WIN32 -#define GL_WIN32_WINDOW -#else -#define GL_X11_WINDOW -#endif - -#undef CreateWindow // Undo Windows.h global namespace pollution - -#ifdef GL_X11_WINDOW -#include -#endif +extern float fFPS; #define MEMORY_END 0x00400000 -class GLWindow -{ - - private: -#ifdef GL_X11_WINDOW - Display *glDisplay; - Window glWindow; - int glScreen; - GLXContext context; - XSetWindowAttributes attr; - XF86VidModeModeInfo deskMode; -#endif - bool fullScreen, doubleBuffered; - s32 x, y; - u32 width, height, depth; - - public: - void SwapGLBuffers(); - void SetTitle(char *strtitle); - bool CreateWindow(void *pDisplay); - bool ReleaseWindow(); - void CloseWindow(); - bool DisplayWindow(int _width, int _height); - void ResizeCheck(); -}; - -extern GLWindow GLWin; +extern int g_LastCRC; +extern u8* g_pBasePS2Mem; extern u8* g_pbyGSMemory; @@ -95,195 +59,14 @@ class GSClut u8* get(u32 addr); u8* get_raw(u32 addr); }; + struct Vector_16F { u16 x, y, z, w; }; -REG64_(GSReg, BGCOLOR) - u32 R:8; - u32 G:8; - u32 B:8; - u32 _PAD1:8; - u32 _PAD2:32; -REG_END - -REG64_(GSReg, BUSDIR) - u32 DIR:1; - u32 _PAD1:31; - u32 _PAD2:32; -REG_END - -REG64_(GSReg, CSR) - u32 SIGNAL:1; - u32 FINISH:1; - u32 HSINT:1; - u32 VSINT:1; - u32 EDWINT:1; - u32 ZERO1:1; - u32 ZERO2:1; - u32 _PAD1:1; - u32 FLUSH:1; - u32 RESET:1; - u32 _PAD2:2; - u32 NFIELD:1; - u32 FIELD:1; - u32 FIFO:2; - u32 REV:8; - u32 ID:8; - u32 _PAD3:32; -REG_END - -REG64_(GSReg, DISPFB) // (-1/2) - u32 FBP:9; - u32 FBW:6; - u32 PSM:5; - u32 _PAD:12; - u32 DBX:11; - u32 DBY:11; - u32 _PAD2:10; -REG_END - -REG64_(GSReg, DISPLAY) // (-1/2) - u32 DX:12; - u32 DY:11; - u32 MAGH:4; - u32 MAGV:2; - u32 _PAD:3; - u32 DW:12; - u32 DH:11; - u32 _PAD2:9; -REG_END - -REG64_(GSReg, EXTBUF) - u32 EXBP:14; - u32 EXBW:6; - u32 FBIN:2; - u32 WFFMD:1; - u32 EMODA:2; - u32 EMODC:2; - u32 _PAD1:5; - u32 WDX:11; - u32 WDY:11; - u32 _PAD2:10; -REG_END - -REG64_(GSReg, EXTDATA) - u32 SX:12; - u32 SY:11; - u32 SMPH:4; - u32 SMPV:2; - u32 _PAD1:3; - u32 WW:12; - u32 WH:11; - u32 _PAD2:9; -REG_END - -REG64_(GSReg, EXTWRITE) - u32 WRITE; - u32 _PAD2:32; -REG_END - -REG64_(GSReg, IMR) - u32 _PAD1:8; - u32 SIGMSK:1; - u32 FINISHMSK:1; - u32 HSMSK:1; - u32 VSMSK:1; - u32 EDWMSK:1; - u32 _PAD2:19; - u32 _PAD3:32; -REG_END - -REG64_(GSReg, PMODE) - u32 EN1:1; - u32 EN2:1; - u32 CRTMD:3; - u32 MMOD:1; - u32 AMOD:1; - u32 SLBG:1; - u32 ALP:8; - u32 _PAD:16; - u32 _PAD1:32; -REG_END - -REG64_(GSReg, SIGLBLID) - u32 SIGID:32; - u32 LBLID:32; -REG_END - -REG64_(GSReg, SMODE1) - u32 RC:3; - u32 LC:7; - u32 T1248:2; - u32 SLCK:1; - u32 CMOD:2; - u32 EX:1; - u32 PRST:1; - u32 SINT:1; - u32 XPCK:1; - u32 PCK2:2; - u32 SPML:4; - u32 GCONT:1; - u32 PHS:1; - u32 PVS:1; - u32 PEHS:1; - u32 PEVS:1; - u32 CLKSEL:2; - u32 NVCK:1; - u32 SLCK2:1; - u32 VCKSEL:2; - u32 VHP:1; - u32 _PAD1:27; -REG_END - -REG64_(GSReg, SMODE2) - u32 INT:1; - u32 FFMD:1; - u32 DPMS:2; - u32 _PAD2:28; - u32 _PAD3:32; -REG_END - -REG64_(GSReg, SIGBLID) - u32 SIGID; - u32 LBLID; -REG_END - -extern int g_LastCRC; -extern u8* g_pBasePS2Mem; - -#define PMODE ((GSRegPMODE*)(g_pBasePS2Mem+0x0000)) -#define SMODE1 ((GSRegSMODE1*)(g_pBasePS2Mem+0x0010)) -#define SMODE2 ((GSRegSMODE2*)(g_pBasePS2Mem+0x0020)) -// SRFSH -#define SYNCH1 ((GSRegSYNCH1*)(g_pBasePS2Mem+0x0040)) -#define SYNCH2 ((GSRegSYNCH2*)(g_pBasePS2Mem+0x0050)) -#define SYNCV ((GSRegSYNCV*)(g_pBasePS2Mem+0x0060)) -#define DISPFB1 ((GSRegDISPFB*)(g_pBasePS2Mem+0x0070)) -#define DISPLAY1 ((GSRegDISPLAY*)(g_pBasePS2Mem+0x0080)) -#define DISPFB2 ((GSRegDISPFB*)(g_pBasePS2Mem+0x0090)) -#define DISPLAY2 ((GSRegDISPLAY*)(g_pBasePS2Mem+0x00a0)) -#define EXTBUF ((GSRegEXTBUF*)(g_pBasePS2Mem+0x00b0)) -#define EXTDATA ((GSRegEXTDATA*)(g_pBasePS2Mem+0x00c0)) -#define EXTWRITE ((GSRegEXTWRITE*)(g_pBasePS2Mem+0x00d0)) -#define BGCOLOR ((GSRegBGCOLOR*)(g_pBasePS2Mem+0x00e0)) -#define CSR ((GSRegCSR*)(g_pBasePS2Mem+0x1000)) -#define IMR ((GSRegIMR*)(g_pBasePS2Mem+0x1010)) -#define BUSDIR ((GSRegBUSDIR*)(g_pBasePS2Mem+0x1040)) -#define SIGLBLID ((GSRegSIGBLID*)(g_pBasePS2Mem+0x1080)) - -#define GET_GSFPS (((SMODE1->CMOD&1) ? 50 : 60) / (SMODE2->INT ? 1 : 2)) - -// -// sps2tags.h -// -#define GET_GIF_REG(tag, reg) \ - (((tag).ai32[2 + ((reg) >> 3)] >> (((reg) & 7) << 2)) & 0xf) - // PS2 vertex - struct VertexGPU { // gained from XYZ2, XYZ3, XYZF2, XYZF3, @@ -299,7 +82,7 @@ struct VertexGPU float s, t, q; }; -// Almost same with previous, controlled by prim.fst flagf +// Almost same as previous, controlled by prim.fst flags struct Vertex { @@ -508,10 +291,9 @@ union tex_0_info u32 _u32[2]; u16 _u16[4]; u8 _u8[8]; + tex_0_info(u64 data) { _u64 = data; } - tex_0_info(u32 data) { _u32[0] = data; _u32[1] = 0; } - tex_0_info(u32 data0, u32 data1) { _u32[0] = data0; _u32[1] = data1; } u32 tbw_mult() diff --git a/plugins/zzogl-pg/opengl/GSmain.cpp b/plugins/zzogl-pg/opengl/GSmain.cpp index dd46a08ee3..075a9736c8 100644 --- a/plugins/zzogl-pg/opengl/GSmain.cpp +++ b/plugins/zzogl-pg/opengl/GSmain.cpp @@ -32,6 +32,7 @@ using namespace std; #include "Mem.h" #include "Regs.h" #include "Profile.h" +#include "GLWin.h" #include "zerogs.h" #include "targets.h" @@ -318,13 +319,11 @@ void CALLBACK GSshutdown() ZZLog::Close(); } - void CALLBACK GSclose() { FUNCLOG ZeroGS::Destroy(1); - GLWin.CloseWindow(); SaveStateFile = NULL; @@ -442,7 +441,7 @@ static __forceinline void SetGSTitle() // ZZLog::Debug_Log("Set profile."); // g_bWriteProfile = 1; // } - if (!(conf.fullscreen())) GLWin.SetTitle(strtitle); + GLWin.SetTitle(strtitle); } void CALLBACK GSvsync(int interlace) diff --git a/plugins/zzogl-pg/opengl/Linux/Linux.cpp b/plugins/zzogl-pg/opengl/Linux/Linux.cpp index 004a3655c5..9097905479 100644 --- a/plugins/zzogl-pg/opengl/Linux/Linux.cpp +++ b/plugins/zzogl-pg/opengl/Linux/Linux.cpp @@ -25,6 +25,7 @@ #include "GS.h" #include "Linux.h" #include "zerogs.h" +#include "GLWin.h" #include @@ -52,7 +53,10 @@ void CALLBACK GSkeyEvent(keyEvent *ev) break; case XK_Escape: - if (conf.fullscreen()) GSclose(); + if (conf.fullscreen()) + { + GSclose(); + } break; case XK_Shift_L: @@ -205,7 +209,6 @@ void OnToggle_advopts(GtkCellRendererToggle *cell, gchar *path, gpointer user_da void DisplayAdvancedDialog() { - int return_value; GtkWidget *dialog; GtkWidget *advanced_frame, *advanced_box; diff --git a/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp b/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp index 4bc932da33..47ecca0316 100644 --- a/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp +++ b/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp @@ -98,6 +98,7 @@ + diff --git a/plugins/zzogl-pg/opengl/Regs.cpp b/plugins/zzogl-pg/opengl/Regs.cpp index b096d47a7a..ed470969b4 100644 --- a/plugins/zzogl-pg/opengl/Regs.cpp +++ b/plugins/zzogl-pg/opengl/Regs.cpp @@ -238,7 +238,7 @@ void tex0Write(int i, const u32 *data) } // check if csa is the same!! (ffx bisaid island, grass) - else if ((data[1] & 0x1f780000) != (ZeroGS::vb[i].uCurTex0Data[1] & 0x1f780000)) + else if ((data[1] & CPSM_CSA_BITMASK) != (ZeroGS::vb[i].uCurTex0Data[1] & CPSM_CSA_BITMASK)) { ZeroGS::Flush(i); // flush any previous entries } diff --git a/plugins/zzogl-pg/opengl/Regs.h b/plugins/zzogl-pg/opengl/Regs.h index 4c881e8b02..a3578b635d 100644 --- a/plugins/zzogl-pg/opengl/Regs.h +++ b/plugins/zzogl-pg/opengl/Regs.h @@ -764,6 +764,185 @@ REG128_SET(GIFPackedReg) GIFPackedNOP NOP; REG_SET_END + +REG64_(GSReg, BGCOLOR) + u32 R:8; + u32 G:8; + u32 B:8; + u32 _PAD1:8; + u32 _PAD2:32; +REG_END + +REG64_(GSReg, BUSDIR) + u32 DIR:1; + u32 _PAD1:31; + u32 _PAD2:32; +REG_END + +REG64_(GSReg, CSR) + u32 SIGNAL:1; + u32 FINISH:1; + u32 HSINT:1; + u32 VSINT:1; + u32 EDWINT:1; + u32 ZERO1:1; + u32 ZERO2:1; + u32 _PAD1:1; + u32 FLUSH:1; + u32 RESET:1; + u32 _PAD2:2; + u32 NFIELD:1; + u32 FIELD:1; + u32 FIFO:2; + u32 REV:8; + u32 ID:8; + u32 _PAD3:32; +REG_END + +REG64_(GSReg, DISPFB) // (-1/2) + u32 FBP:9; + u32 FBW:6; + u32 PSM:5; + u32 _PAD:12; + u32 DBX:11; + u32 DBY:11; + u32 _PAD2:10; +REG_END + +REG64_(GSReg, DISPLAY) // (-1/2) + u32 DX:12; + u32 DY:11; + u32 MAGH:4; + u32 MAGV:2; + u32 _PAD:3; + u32 DW:12; + u32 DH:11; + u32 _PAD2:9; +REG_END + +REG64_(GSReg, EXTBUF) + u32 EXBP:14; + u32 EXBW:6; + u32 FBIN:2; + u32 WFFMD:1; + u32 EMODA:2; + u32 EMODC:2; + u32 _PAD1:5; + u32 WDX:11; + u32 WDY:11; + u32 _PAD2:10; +REG_END + +REG64_(GSReg, EXTDATA) + u32 SX:12; + u32 SY:11; + u32 SMPH:4; + u32 SMPV:2; + u32 _PAD1:3; + u32 WW:12; + u32 WH:11; + u32 _PAD2:9; +REG_END + +REG64_(GSReg, EXTWRITE) + u32 WRITE; + u32 _PAD2:32; +REG_END + +REG64_(GSReg, IMR) + u32 _PAD1:8; + u32 SIGMSK:1; + u32 FINISHMSK:1; + u32 HSMSK:1; + u32 VSMSK:1; + u32 EDWMSK:1; + u32 _PAD2:19; + u32 _PAD3:32; +REG_END + +REG64_(GSReg, PMODE) + u32 EN1:1; + u32 EN2:1; + u32 CRTMD:3; + u32 MMOD:1; + u32 AMOD:1; + u32 SLBG:1; + u32 ALP:8; + u32 _PAD:16; + u32 _PAD1:32; +REG_END + +REG64_(GSReg, SIGLBLID) + u32 SIGID:32; + u32 LBLID:32; +REG_END + +REG64_(GSReg, SMODE1) + u32 RC:3; + u32 LC:7; + u32 T1248:2; + u32 SLCK:1; + u32 CMOD:2; + u32 EX:1; + u32 PRST:1; + u32 SINT:1; + u32 XPCK:1; + u32 PCK2:2; + u32 SPML:4; + u32 GCONT:1; + u32 PHS:1; + u32 PVS:1; + u32 PEHS:1; + u32 PEVS:1; + u32 CLKSEL:2; + u32 NVCK:1; + u32 SLCK2:1; + u32 VCKSEL:2; + u32 VHP:1; + u32 _PAD1:27; +REG_END + +REG64_(GSReg, SMODE2) + u32 INT:1; + u32 FFMD:1; + u32 DPMS:2; + u32 _PAD2:28; + u32 _PAD3:32; +REG_END + +REG64_(GSReg, SIGBLID) + u32 SIGID; + u32 LBLID; +REG_END + +#define PMODE ((GSRegPMODE*)(g_pBasePS2Mem+0x0000)) +#define SMODE1 ((GSRegSMODE1*)(g_pBasePS2Mem+0x0010)) +#define SMODE2 ((GSRegSMODE2*)(g_pBasePS2Mem+0x0020)) +// SRFSH +#define SYNCH1 ((GSRegSYNCH1*)(g_pBasePS2Mem+0x0040)) +#define SYNCH2 ((GSRegSYNCH2*)(g_pBasePS2Mem+0x0050)) +#define SYNCV ((GSRegSYNCV*)(g_pBasePS2Mem+0x0060)) +#define DISPFB1 ((GSRegDISPFB*)(g_pBasePS2Mem+0x0070)) +#define DISPLAY1 ((GSRegDISPLAY*)(g_pBasePS2Mem+0x0080)) +#define DISPFB2 ((GSRegDISPFB*)(g_pBasePS2Mem+0x0090)) +#define DISPLAY2 ((GSRegDISPLAY*)(g_pBasePS2Mem+0x00a0)) +#define EXTBUF ((GSRegEXTBUF*)(g_pBasePS2Mem+0x00b0)) +#define EXTDATA ((GSRegEXTDATA*)(g_pBasePS2Mem+0x00c0)) +#define EXTWRITE ((GSRegEXTWRITE*)(g_pBasePS2Mem+0x00d0)) +#define BGCOLOR ((GSRegBGCOLOR*)(g_pBasePS2Mem+0x00e0)) +#define CSR ((GSRegCSR*)(g_pBasePS2Mem+0x1000)) +#define IMR ((GSRegIMR*)(g_pBasePS2Mem+0x1010)) +#define BUSDIR ((GSRegBUSDIR*)(g_pBasePS2Mem+0x1040)) +#define SIGLBLID ((GSRegSIGBLID*)(g_pBasePS2Mem+0x1080)) + +// +// sps2tags.h +// +#define GET_GIF_REG(tag, reg) \ + (((tag).ai32[2 + ((reg) >> 3)] >> (((reg) & 7) << 2)) & 0xf) + +#define GET_GSFPS (((SMODE1->CMOD&1) ? 50 : 60) / (SMODE2->INT ? 1 : 2)) + extern void WriteTempRegs(); extern void SetFrameSkip(bool skip); extern void ResetRegs(); diff --git a/plugins/zzogl-pg/opengl/ZZKeyboard.cpp b/plugins/zzogl-pg/opengl/ZZKeyboard.cpp index 1066fcc998..b858e75954 100644 --- a/plugins/zzogl-pg/opengl/ZZKeyboard.cpp +++ b/plugins/zzogl-pg/opengl/ZZKeyboard.cpp @@ -23,6 +23,7 @@ #include "GS.h" #include "ZeroGSShaders/zerogsshaders.h" #include "Profile.h" +#include "GLWin.h" extern int CurrentSavestate, g_GSMultiThreaded, g_nPixelShaderVer; extern char *libraryName; @@ -355,7 +356,7 @@ void ProcessMessages() // check resizing GLWin.ResizeCheck(); - if (THR_KeyEvent) // This values was passed from GSKeyEvents which could be in another thread + if (THR_KeyEvent) // This value was passed from GSKeyEvents which could be in another thread { int my_KeyEvent = THR_KeyEvent; bool my_bShift = THR_bShift; diff --git a/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp b/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp index 9ff971c9ca..aa3c966340 100644 --- a/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp @@ -22,6 +22,7 @@ //------------------ Includes #include "ZZoglCRTC.h" +#include "GLWin.h" using namespace ZeroGS; diff --git a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp index 571fdd442b..c7d72eee12 100644 --- a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp @@ -23,6 +23,7 @@ #include "GS.h" #include "Mem.h" #include "zerogs.h" +#include "GLWin.h" #include "ZeroGSShaders/zerogsshaders.h" #include "targets.h" @@ -922,6 +923,7 @@ bool ZeroGS::Create(int _width, int _height) } } +extern bool GSclosing; void ZeroGS::Destroy(bool bD3D) { Delete_Avi_Capture(); @@ -948,20 +950,29 @@ void ZeroGS::Destroy(bool bD3D) } g_nCurVBOIndex = 0; - - for (int i = 0; i < ARRAY_SIZE(pvs); ++i) + + if (pvs != NULL) { - SAFE_RELEASE_PROG(pvs[i]); + for (int i = 0; i < ARRAY_SIZE(pvs); ++i) + { + SAFE_RELEASE_PROG(pvs[i]); + } } - for (int i = 0; i < ARRAY_SIZE(ppsRegular); ++i) + if (ppsRegular != NULL) { - SAFE_RELEASE_PROG(ppsRegular[i].prog); + for (int i = 0; i < ARRAY_SIZE(ppsRegular); ++i) + { + SAFE_RELEASE_PROG(ppsRegular[i].prog); + } } - for (int i = 0; i < ARRAY_SIZE(ppsTexture); ++i) + if (ppsTexture != NULL) { - SAFE_RELEASE_PROG(ppsTexture[i].prog); + for (int i = 0; i < ARRAY_SIZE(ppsTexture); ++i) + { + SAFE_RELEASE_PROG(ppsTexture[i].prog); + } } SAFE_RELEASE_PROG(pvsBitBlt.prog); @@ -979,8 +990,9 @@ void ZeroGS::Destroy(bool bD3D) SAFE_DELETE(font_p); - GLWin.ReleaseWindow(); + GLWin.ReleaseContext(); + //if (GSclosing) assert(0); mapGLExtensions.clear(); } diff --git a/plugins/zzogl-pg/opengl/zerogs.cpp b/plugins/zzogl-pg/opengl/zerogs.cpp index 27831a58df..a14fbf101e 100644 --- a/plugins/zzogl-pg/opengl/zerogs.cpp +++ b/plugins/zzogl-pg/opengl/zerogs.cpp @@ -31,6 +31,7 @@ #include "zerogs.h" #include "zpipe.h" #include "targets.h" +#include "GLWin.h" //----------------------- Defines