ZZOgl-pg: Rework the GLX11Win.cpp code a bunch. Fix a bug leading to crashes.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3714 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-09-01 10:28:37 +00:00
parent 009d6ba5e6
commit e686d47cd7
13 changed files with 372 additions and 297 deletions

View File

@ -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 <X11/extensions/xf86vmode.h>
#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

View File

@ -19,6 +19,7 @@
#include "GS.h" #include "GS.h"
#include "zerogs.h" #include "zerogs.h"
#include "GLWin.h"
#ifdef GL_WIN32_WINDOW #ifdef GL_WIN32_WINDOW
@ -138,7 +139,7 @@ bool GLWindow::CreateWindow(void *pDisplay)
return (pDisplay != NULL); return (pDisplay != NULL);
} }
bool GLWindow::ReleaseWindow() bool GLWindow::ReleaseContext()
{ {
if (hRC) // Do We Have A Rendering Context? if (hRC) // Do We Have A Rendering Context?
{ {
@ -305,7 +306,7 @@ void GLWindow::SwapGLBuffers()
void GLWindow::SetTitle(char *strtitle) void GLWindow::SetTitle(char *strtitle)
{ {
SetWindowText(GShwnd, strtitle); if (!conf.fullscreen()) SetWindowText(GShwnd, strtitle);
} }
void GLWindow::ResizeCheck() void GLWindow::ResizeCheck()

View File

@ -17,10 +17,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "GS.h" #include "Util.h"
#include "GLWin.h"
#include "zerogs.h" #include "zerogs.h"
#ifdef GL_X11_WINDOW #ifdef GL_X11_WINDOW
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -37,9 +37,9 @@ bool GLWindow::CreateWindow(void *pDisplay)
return true; return true;
} }
bool GLWindow::ReleaseWindow() bool GLWindow::ReleaseContext()
{ {
if (context) if (context && (glDisplay != NULL))
{ {
if (!glXMakeCurrent(glDisplay, None, NULL)) if (!glXMakeCurrent(glDisplay, None, NULL))
{ {
@ -51,6 +51,15 @@ bool GLWindow::ReleaseWindow()
context = NULL; 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 */ /* switch back to original desktop resolution if we were in fullscreen */
if (glDisplay != NULL) if (glDisplay != NULL)
{ {
@ -61,15 +70,6 @@ bool GLWindow::ReleaseWindow()
} }
} }
return true;
}
void GLWindow::CloseWindow()
{
conf.x = x;
conf.y = y;
SaveConfig();
if (glDisplay != NULL) if (glDisplay != NULL)
{ {
XCloseDisplay(glDisplay); 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 // attributes for a single buffered visual in RGBA format with at least
// 8 bits per color and a 24 bit depth buffer // 8 bits per color and a 24 bit depth buffer
int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 8, int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 8,
@ -111,8 +98,6 @@ bool GLWindow::DisplayWindow(int _width, int _height)
None None
}; };
GLWin.fullScreen = (conf.fullscreen());
/* get an appropriate visual */ /* get an appropriate visual */
vi = glXChooseVisual(glDisplay, glScreen, attrListDbl); vi = glXChooseVisual(glDisplay, glScreen, attrListDbl);
@ -133,10 +118,45 @@ bool GLWindow::DisplayWindow(int _width, int _height)
ZZLog::Error_Log("Failed to get buffered Visual!"); ZZLog::Error_Log("Failed to get buffered Visual!");
return false; 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); glXQueryVersion(glDisplay, &glxMajorVersion, &glxMinorVersion);
ZZLog::Error_Log("glX-Version %d.%d", 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 */ /* create a GLX context */
context = glXCreateContext(glDisplay, vi, NULL, GL_TRUE); context = glXCreateContext(glDisplay, vi, NULL, GL_TRUE);
@ -144,21 +164,21 @@ bool GLWindow::DisplayWindow(int _width, int _height)
/* create a color map */ /* create a color map */
cmap = XCreateColormap(glDisplay, RootWindow(glDisplay, vi->screen), cmap = XCreateColormap(glDisplay, RootWindow(glDisplay, vi->screen),
vi->visual, AllocNone); vi->visual, AllocNone);
attr.colormap = cmap; attr.colormap = cmap;
attr.border_pixel = 0; attr.border_pixel = 0;
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask;
// get a connection GetGLXVersion();
XF86VidModeQueryVersion(glDisplay, &vidModeMajorVersion, &vidModeMinorVersion);
if (fullScreen) if (fullScreen)
{ {
int dpyWidth, dpyHeight;
int modeNum = 0, bestMode = 0;
XF86VidModeModeInfo **modes = NULL; XF86VidModeModeInfo **modes = NULL;
int modeNum = 0;
int bestMode = 0;
// set best mode to current GetGLXVidModeVersion();
bestMode = 0;
ZZLog::Error_Log("XF86VidModeExtension-Version %d.%d.", vidModeMajorVersion, vidModeMinorVersion);
XF86VidModeGetAllModeLines(glDisplay, glScreen, &modeNum, &modes); XF86VidModeGetAllModeLines(glDisplay, glScreen, &modeNum, &modes);
if (modeNum > 0 && modes != NULL) if (modeNum > 0 && modes != NULL)
@ -168,7 +188,7 @@ bool GLWindow::DisplayWindow(int _width, int _height)
/* look for mode with requested resolution */ /* 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)) if ((modes[i]->hdisplay == _width) && (modes[i]->vdisplay == _height))
{ {
@ -186,7 +206,6 @@ bool GLWindow::DisplayWindow(int _width, int _height)
/* create a fullscreen window */ /* create a fullscreen window */
attr.override_redirect = True; attr.override_redirect = True;
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask;
glWindow = XCreateWindow(glDisplay, RootWindow(glDisplay, vi->screen), glWindow = XCreateWindow(glDisplay, RootWindow(glDisplay, vi->screen),
0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual, 0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
@ -209,15 +228,15 @@ bool GLWindow::DisplayWindow(int _width, int _height)
if (!fullScreen) if (!fullScreen)
{ {
// create a window in window mode // create a window in window mode
attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask;
glWindow = XCreateWindow(glDisplay, RootWindow(glDisplay, vi->screen), glWindow = XCreateWindow(glDisplay, RootWindow(glDisplay, vi->screen),
0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual, 0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask, &attr); CWBorderPixel | CWColormap | CWEventMask, &attr);
// only set window title and handle wm_delete_events if in windowed mode // only set window title and handle wm_delete_events if in windowed mode
Atom wmDelete;
wmDelete = XInternAtom(glDisplay, "WM_DELETE_WINDOW", True); wmDelete = XInternAtom(glDisplay, "WM_DELETE_WINDOW", True);
XSetWMProtocols(glDisplay, glWindow, &wmDelete, 1); XSetWMProtocols(glDisplay, glWindow, &wmDelete, 1);
XSetStandardProperties(glDisplay, glWindow, "ZZOgl-PG", "ZZOgl-PG", None, NULL, 0, NULL); XSetStandardProperties(glDisplay, glWindow, "ZZOgl-PG", "ZZOgl-PG", None, NULL, 0, NULL);
XMapRaised(glDisplay, glWindow); XMapRaised(glDisplay, glWindow);
XMoveWindow(glDisplay, glWindow, x, y); XMoveWindow(glDisplay, glWindow, x, y);
@ -226,9 +245,7 @@ bool GLWindow::DisplayWindow(int _width, int _height)
// connect the glx-context to the window // connect the glx-context to the window
glXMakeCurrent(glDisplay, glWindow, context); glXMakeCurrent(glDisplay, glWindow, context);
XGetGeometry(glDisplay, glWindow, &winDummy, &x, &y, &width, &height, &borderDummy, &depth); GetWindowSize();
ZZLog::Error_Log("Depth %d", depth);
if (glXIsDirect(glDisplay, context)) if (glXIsDirect(glDisplay, context))
ZZLog::Error_Log("You have Direct Rendering!"); ZZLog::Error_Log("You have Direct Rendering!");
@ -250,6 +267,8 @@ void GLWindow::SwapGLBuffers()
void GLWindow::SetTitle(char *strtitle) void GLWindow::SetTitle(char *strtitle)
{ {
if (!conf.fullscreen())
{
XTextProperty prop; XTextProperty prop;
memset(&prop, 0, sizeof(prop)); memset(&prop, 0, sizeof(prop));
char* ptitle = strtitle; char* ptitle = strtitle;
@ -258,6 +277,7 @@ void GLWindow::SetTitle(char *strtitle)
XSetWMName(glDisplay, glWindow, &prop); XSetWMName(glDisplay, glWindow, &prop);
XFree(prop.value); XFree(prop.value);
}
} }
void GLWindow::ResizeCheck() void GLWindow::ResizeCheck()
@ -275,6 +295,8 @@ void GLWindow::ResizeCheck()
if ((event.xconfigure.x != x) || (event.xconfigure.y != y)) 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; x = event.xconfigure.x;
y = event.xconfigure.y; y = event.xconfigure.y;
} }

View File

@ -25,52 +25,16 @@
#include "Util.h" #include "Util.h"
#include "GifTransfer.h" #include "GifTransfer.h"
//#include "GLWin.h"
extern float fFPS;
using namespace std; using namespace std;
#ifdef _WIN32 extern float fFPS;
#define GL_WIN32_WINDOW
#else
#define GL_X11_WINDOW
#endif
#undef CreateWindow // Undo Windows.h global namespace pollution
#ifdef GL_X11_WINDOW
#include <X11/extensions/xf86vmode.h>
#endif
#define MEMORY_END 0x00400000 #define MEMORY_END 0x00400000
class GLWindow extern int g_LastCRC;
{ extern u8* g_pBasePS2Mem;
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 u8* g_pbyGSMemory; extern u8* g_pbyGSMemory;
@ -95,195 +59,14 @@ class GSClut
u8* get(u32 addr); u8* get(u32 addr);
u8* get_raw(u32 addr); u8* get_raw(u32 addr);
}; };
struct Vector_16F struct Vector_16F
{ {
u16 x, y, z, w; 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 // PS2 vertex
struct VertexGPU struct VertexGPU
{ {
// gained from XYZ2, XYZ3, XYZF2, XYZF3, // gained from XYZ2, XYZ3, XYZF2, XYZF3,
@ -299,7 +82,7 @@ struct VertexGPU
float s, t, q; float s, t, q;
}; };
// Almost same with previous, controlled by prim.fst flagf // Almost same as previous, controlled by prim.fst flags
struct Vertex struct Vertex
{ {
@ -508,10 +291,9 @@ union tex_0_info
u32 _u32[2]; u32 _u32[2];
u16 _u16[4]; u16 _u16[4];
u8 _u8[8]; u8 _u8[8];
tex_0_info(u64 data) { _u64 = data; } tex_0_info(u64 data) { _u64 = data; }
tex_0_info(u32 data) { _u32[0] = data; _u32[1] = 0; } tex_0_info(u32 data) { _u32[0] = data; _u32[1] = 0; }
tex_0_info(u32 data0, u32 data1) { _u32[0] = data0; _u32[1] = data1; } tex_0_info(u32 data0, u32 data1) { _u32[0] = data0; _u32[1] = data1; }
u32 tbw_mult() u32 tbw_mult()

View File

@ -32,6 +32,7 @@ using namespace std;
#include "Mem.h" #include "Mem.h"
#include "Regs.h" #include "Regs.h"
#include "Profile.h" #include "Profile.h"
#include "GLWin.h"
#include "zerogs.h" #include "zerogs.h"
#include "targets.h" #include "targets.h"
@ -318,13 +319,11 @@ void CALLBACK GSshutdown()
ZZLog::Close(); ZZLog::Close();
} }
void CALLBACK GSclose() void CALLBACK GSclose()
{ {
FUNCLOG FUNCLOG
ZeroGS::Destroy(1); ZeroGS::Destroy(1);
GLWin.CloseWindow(); GLWin.CloseWindow();
SaveStateFile = NULL; SaveStateFile = NULL;
@ -442,7 +441,7 @@ static __forceinline void SetGSTitle()
// ZZLog::Debug_Log("Set profile."); // ZZLog::Debug_Log("Set profile.");
// g_bWriteProfile = 1; // g_bWriteProfile = 1;
// } // }
if (!(conf.fullscreen())) GLWin.SetTitle(strtitle); GLWin.SetTitle(strtitle);
} }
void CALLBACK GSvsync(int interlace) void CALLBACK GSvsync(int interlace)

View File

@ -25,6 +25,7 @@
#include "GS.h" #include "GS.h"
#include "Linux.h" #include "Linux.h"
#include "zerogs.h" #include "zerogs.h"
#include "GLWin.h"
#include <map> #include <map>
@ -52,7 +53,10 @@ void CALLBACK GSkeyEvent(keyEvent *ev)
break; break;
case XK_Escape: case XK_Escape:
if (conf.fullscreen()) GSclose(); if (conf.fullscreen())
{
GSclose();
}
break; break;
case XK_Shift_L: case XK_Shift_L:
@ -205,7 +209,6 @@ void OnToggle_advopts(GtkCellRendererToggle *cell, gchar *path, gpointer user_da
void DisplayAdvancedDialog() void DisplayAdvancedDialog()
{ {
int return_value;
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *advanced_frame, *advanced_box; GtkWidget *advanced_frame, *advanced_box;

View File

@ -98,6 +98,7 @@
<Mode after="always" /> <Mode after="always" />
</ExtraCommands> </ExtraCommands>
<Unit filename="../../CRC.h" /> <Unit filename="../../CRC.h" />
<Unit filename="../../GLWin.h" />
<Unit filename="../../GLWin32.cpp" /> <Unit filename="../../GLWin32.cpp" />
<Unit filename="../../GLWinX11.cpp" /> <Unit filename="../../GLWinX11.cpp" />
<Unit filename="../../GS.h" /> <Unit filename="../../GS.h" />

View File

@ -238,7 +238,7 @@ void tex0Write(int i, const u32 *data)
} }
// check if csa is the same!! (ffx bisaid island, grass) // 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 ZeroGS::Flush(i); // flush any previous entries
} }

View File

@ -764,6 +764,185 @@ REG128_SET(GIFPackedReg)
GIFPackedNOP NOP; GIFPackedNOP NOP;
REG_SET_END 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 WriteTempRegs();
extern void SetFrameSkip(bool skip); extern void SetFrameSkip(bool skip);
extern void ResetRegs(); extern void ResetRegs();

View File

@ -23,6 +23,7 @@
#include "GS.h" #include "GS.h"
#include "ZeroGSShaders/zerogsshaders.h" #include "ZeroGSShaders/zerogsshaders.h"
#include "Profile.h" #include "Profile.h"
#include "GLWin.h"
extern int CurrentSavestate, g_GSMultiThreaded, g_nPixelShaderVer; extern int CurrentSavestate, g_GSMultiThreaded, g_nPixelShaderVer;
extern char *libraryName; extern char *libraryName;
@ -355,7 +356,7 @@ void ProcessMessages()
// check resizing // check resizing
GLWin.ResizeCheck(); 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; int my_KeyEvent = THR_KeyEvent;
bool my_bShift = THR_bShift; bool my_bShift = THR_bShift;

View File

@ -22,6 +22,7 @@
//------------------ Includes //------------------ Includes
#include "ZZoglCRTC.h" #include "ZZoglCRTC.h"
#include "GLWin.h"
using namespace ZeroGS; using namespace ZeroGS;

View File

@ -23,6 +23,7 @@
#include "GS.h" #include "GS.h"
#include "Mem.h" #include "Mem.h"
#include "zerogs.h" #include "zerogs.h"
#include "GLWin.h"
#include "ZeroGSShaders/zerogsshaders.h" #include "ZeroGSShaders/zerogsshaders.h"
#include "targets.h" #include "targets.h"
@ -922,6 +923,7 @@ bool ZeroGS::Create(int _width, int _height)
} }
} }
extern bool GSclosing;
void ZeroGS::Destroy(bool bD3D) void ZeroGS::Destroy(bool bD3D)
{ {
Delete_Avi_Capture(); Delete_Avi_Capture();
@ -949,20 +951,29 @@ void ZeroGS::Destroy(bool bD3D)
g_nCurVBOIndex = 0; g_nCurVBOIndex = 0;
if (pvs != NULL)
{
for (int i = 0; i < ARRAY_SIZE(pvs); ++i) for (int i = 0; i < ARRAY_SIZE(pvs); ++i)
{ {
SAFE_RELEASE_PROG(pvs[i]); SAFE_RELEASE_PROG(pvs[i]);
} }
}
if (ppsRegular != NULL)
{
for (int i = 0; i < ARRAY_SIZE(ppsRegular); ++i) for (int i = 0; i < ARRAY_SIZE(ppsRegular); ++i)
{ {
SAFE_RELEASE_PROG(ppsRegular[i].prog); SAFE_RELEASE_PROG(ppsRegular[i].prog);
} }
}
if (ppsTexture != NULL)
{
for (int i = 0; i < ARRAY_SIZE(ppsTexture); ++i) for (int i = 0; i < ARRAY_SIZE(ppsTexture); ++i)
{ {
SAFE_RELEASE_PROG(ppsTexture[i].prog); SAFE_RELEASE_PROG(ppsTexture[i].prog);
} }
}
SAFE_RELEASE_PROG(pvsBitBlt.prog); SAFE_RELEASE_PROG(pvsBitBlt.prog);
@ -979,8 +990,9 @@ void ZeroGS::Destroy(bool bD3D)
SAFE_DELETE(font_p); SAFE_DELETE(font_p);
GLWin.ReleaseWindow(); GLWin.ReleaseContext();
//if (GSclosing) assert(0);
mapGLExtensions.clear(); mapGLExtensions.clear();
} }

View File

@ -31,6 +31,7 @@
#include "zerogs.h" #include "zerogs.h"
#include "zpipe.h" #include "zpipe.h"
#include "targets.h" #include "targets.h"
#include "GLWin.h"
//----------------------- Defines //----------------------- Defines