summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-08-18 01:34:01 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-08-18 01:34:01 +0000
commitc4f5208806fe4136b19cce9f63f03820fc49d0cf (patch)
treec1f42770d9fc0f88538993f0fb4cc78c364c056e /plugins
parentc4a77870fcb7793bd5a7611b9994a5b15a335a3c (diff)
downloadpcsxr-c4f5208806fe4136b19cce9f63f03820fc49d0cf.tar.gz
peopsxgl: Readded windows support.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@56180 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins')
-rw-r--r--plugins/peopsxgl/cfg.h14
-rw-r--r--plugins/peopsxgl/draw.c125
-rw-r--r--plugins/peopsxgl/draw.h5
-rw-r--r--plugins/peopsxgl/externals.h13
-rw-r--r--plugins/peopsxgl/fps.h2
-rw-r--r--plugins/peopsxgl/gl_ext.h47
-rw-r--r--plugins/peopsxgl/gpu.c291
-rw-r--r--plugins/peopsxgl/menu.c140
-rw-r--r--plugins/peopsxgl/menu.h4
-rw-r--r--plugins/peopsxgl/soft.c22
-rw-r--r--plugins/peopsxgl/stdafx.h29
-rw-r--r--plugins/peopsxgl/texture.c10
12 files changed, 668 insertions, 34 deletions
diff --git a/plugins/peopsxgl/cfg.h b/plugins/peopsxgl/cfg.h
index 634513dc..d7070bed 100644
--- a/plugins/peopsxgl/cfg.h
+++ b/plugins/peopsxgl/cfg.h
@@ -16,5 +16,17 @@
* *
***************************************************************************/
+#ifdef _WINDOWS
+
void ReadConfig(void);
-void ReadConfigFile();
+void WriteConfig(void);
+void ReadWinSizeConfig(void);
+BOOL CALLBACK CfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+#else
+
+void ReadConfig(void);
+void ReadConfigFile();
+
+#endif
diff --git a/plugins/peopsxgl/draw.c b/plugins/peopsxgl/draw.c
index 33381e59..32dcc83b 100644
--- a/plugins/peopsxgl/draw.c
+++ b/plugins/peopsxgl/draw.c
@@ -76,22 +76,27 @@
////////////////////////////////////////////////////////////////////////////////////
// draw globals; most will be initialized again later (by config or checks)
-BOOL bIsFirstFrame=TRUE;
+#ifdef _WINDOWS
+HDC dcGlobal = NULL;
+HWND hWWindow;
+#endif
+
+BOOL bIsFirstFrame = TRUE;
// resolution/ratio vars
int iResX;
int iResY;
-BOOL bKeepRatio=FALSE;
+BOOL bKeepRatio = FALSE;
RECT rRatioRect;
// psx mask related vars
-BOOL bCheckMask=FALSE;
-int iUseMask=0;
-int iSetMask=0;
-unsigned short sSetMask=0;
-uint32_t lSetMask=0;
+BOOL bCheckMask = FALSE;
+int iUseMask = 0;
+int iSetMask = 0;
+unsigned short sSetMask = 0;
+uint32_t lSetMask = 0;
// drawing/coord vars
@@ -130,6 +135,55 @@ int iZBufferDepth=0;
GLbitfield uiBufferBits=GL_COLOR_BUFFER_BIT;
////////////////////////////////////////////////////////////////////////
+// Set OGL pixel format
+////////////////////////////////////////////////////////////////////////
+
+#ifdef _WINDOWS
+BOOL bSetupPixelFormat(HDC hDC)
+{
+ int pixelformat;
+ static PIXELFORMATDESCRIPTOR pfd =
+ {
+ sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
+ 1, // version number
+ PFD_DRAW_TO_WINDOW | // support window
+ PFD_SUPPORT_OPENGL | // support OpenGL
+ PFD_DOUBLEBUFFER, // double buffered
+ PFD_TYPE_RGBA, // RGBA type
+ 16, // 16-bit color depth (adjusted later)
+ 0, 0, 0, 0, 0, 0, // color bits ignored
+ 0, // no alpha buffer
+ 0, // shift bit ignored
+ 0, // no accumulation buffer
+ 0, 0, 0, 0, // accum bits ignored
+ 0, // z-buffer
+ 0,
+ 0, // no auxiliary buffer
+ PFD_MAIN_PLANE, // main layer
+ 0, // reserved
+ 0, 0, 0 // layer masks ignored
+ };
+
+ pfd.cColorBits=iColDepth; // set user color depth
+ pfd.cDepthBits=iZBufferDepth; // set user zbuffer (by psx mask)
+
+ if((pixelformat=ChoosePixelFormat(hDC,&pfd))==0)
+ {
+ MessageBox(NULL,"ChoosePixelFormat failed","Error",MB_OK);
+ return FALSE;
+ }
+
+ if(SetPixelFormat(hDC,pixelformat, &pfd)==FALSE)
+ {
+ MessageBox(NULL,"SetPixelFormat failed","Error",MB_OK);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////
// Get extension infos (f.e. pal textures / packed pixels)
////////////////////////////////////////////////////////////////////////
@@ -170,7 +224,11 @@ void GetExtInfos(void)
{
iUsePalTextures=1; // -> wow, supported, get func pointer
+#ifdef _WINDOWS
+ glColorTableEXTEx=(PFNGLCOLORTABLEEXT)wglGetProcAddress("glColorTableEXT");
+#else
glColorTableEXTEx=(PFNGLCOLORTABLEEXT)glXGetProcAddress("glColorTableEXT");
+#endif
if(glColorTableEXTEx==NULL) iUsePalTextures=0; // -> ha, cheater... no func, no support
}
@@ -192,11 +250,27 @@ void SetExtGLFuncs(void)
//----------------------------------------------------//
+#ifdef _WINDOWS
+ if((iForceVSync>=0) && // force vsync?
+ strstr((char *)glGetString(GL_EXTENSIONS), // and extension available?
+ "WGL_EXT_swap_control"))
+ {
+ PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT=
+ (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");
+
+ if(wglSwapIntervalEXT) wglSwapIntervalEXT(iForceVSync);
+ }
+#endif
+
if(iUseExts && !(dwActFixes&1024) && // extensions wanted? and not turned off by game fix?
strstr((char *)glGetString(GL_EXTENSIONS), // and blend_subtract available?
"GL_EXT_blend_subtract"))
{ // -> get ogl blend function pointer
- glBlendEquationEXTEx=(PFNGLBLENDEQU)glXGetProcAddress("glBlendEquationEXT");
+#ifdef _WINDOWS
+ glBlendEquationEXTEx=(PFNGLBLENDEQU)wglGetProcAddress("glBlendEquationEXT");
+#else
+ glBlendEquationEXTEx=(PFNGLBLENDEQU)glXGetProcAddress("glBlendEquationEXT");
+#endif
}
else // no subtract blending?
{
@@ -446,8 +520,23 @@ void CreateScanLines(void)
// Initialize OGL
////////////////////////////////////////////////////////////////////////
+#ifdef _WINDOWS
+HGLRC GLCONTEXT=NULL;
+#endif
+
int GLinitialize()
{
+#ifdef _WINDOWS
+ HGLRC objectRC;
+ // init
+ dcGlobal = GetDC(hWWindow); // FIRST: dc/rc stuff
+ objectRC = wglCreateContext(dcGlobal);
+ GLCONTEXT=objectRC;
+ wglMakeCurrent(dcGlobal, objectRC);
+ // CheckWGLExtensions(dcGlobal);
+ if(bWindowMode) ReleaseDC(hWWindow,dcGlobal); // win mode: release dc again
+#endif
+
glViewport(rRatioRect.left, // init viewport by ratio rect
iResY-(rRatioRect.top+rRatioRect.bottom),
rRatioRect.right,
@@ -545,10 +634,13 @@ int GLinitialize()
glPixelTransferi(GL_ALPHA_SCALE, 1);
glPixelTransferi(GL_ALPHA_BIAS, 0);
- printf(glGetString(GL_VENDOR)); // linux: tell user what is getting used
- printf("\n");
- printf(glGetString(GL_RENDERER));
- printf("\n");
+#ifdef _WINDOWS
+ // detect Windows hw/sw mode (just for info)
+ if(!strcmp("Microsoft Corporation",(LPTSTR)glGetString(GL_VENDOR)) &&
+ !strcmp("GDI Generic", (LPTSTR)glGetString(GL_RENDERER)))
+ bGLSoft=TRUE;
+ else bGLSoft=FALSE;
+#endif
glFlush(); // we are done...
glFinish();
@@ -591,6 +683,13 @@ void GLcleanup()
}
CleanupTextureStore(); // bye textures
+
+#ifdef _WINDOWS
+ wglMakeCurrent(NULL, NULL); // bye context
+ if(GLCONTEXT) wglDeleteContext(GLCONTEXT);
+ if(!bWindowMode && dcGlobal)
+ ReleaseDC(hWWindow,dcGlobal);
+#endif
}
////////////////////////////////////////////////////////////////////////
@@ -1378,7 +1477,9 @@ void assignTexture4(void)
// render pos / buffers
////////////////////////////////////////////////////////////////////////
+#ifndef _WINDOWS
#define EqualRect(pr1,pr2) ((pr1)->left==(pr2)->left && (pr1)->top==(pr2)->top && (pr1)->right==(pr2)->right && (pr1)->bottom==(pr2)->bottom)
+#endif
////////////////////////////////////////////////////////////////////////
// SetDisplaySettings: "simply" calcs the new drawing area and updates
diff --git a/plugins/peopsxgl/draw.h b/plugins/peopsxgl/draw.h
index 14d2373e..82f920db 100644
--- a/plugins/peopsxgl/draw.h
+++ b/plugins/peopsxgl/draw.h
@@ -28,6 +28,11 @@
#define COLOR(x) (x & 0xffffff)
// prototypes
+
+#ifdef _WINDOWS
+BOOL bSetupPixelFormat(HDC hDC);
+#endif
+
int GLinitialize();
void GLcleanup();
BOOL offset2(void);
diff --git a/plugins/peopsxgl/externals.h b/plugins/peopsxgl/externals.h
index 8ce2b914..a2775fe9 100644
--- a/plugins/peopsxgl/externals.h
+++ b/plugins/peopsxgl/externals.h
@@ -78,6 +78,8 @@
#define KEY_STEPDOWN 256
#define KEY_TOGGLEFBREAD 512
+#ifndef _WINDOWS
+
#define FALSE 0
#define TRUE 1
#define BOOL unsigned short
@@ -96,6 +98,8 @@ typedef struct RECTTAG
int bottom;
}RECT;
+#endif
+
typedef struct VRAMLOADTAG
{
short x;
@@ -194,6 +198,12 @@ extern char *pConfigFile;
#endif
+#ifdef _WINDOWS
+
+extern HINSTANCE hInst;
+
+#endif
+
#ifndef _IN_DRAW
extern int iResX;
@@ -219,6 +229,9 @@ extern unsigned char gl_ux[8];
extern unsigned char gl_vy[8];
extern OGLVertex vertex[4];
extern short sprtY,sprtX,sprtH,sprtW;
+#ifdef _WINDOWS
+extern HWND hWWindow;
+#endif
extern BOOL bIsFirstFrame;
extern int iWinSize;
extern int iZBufferDepth;
diff --git a/plugins/peopsxgl/fps.h b/plugins/peopsxgl/fps.h
index 3b1951b8..b50e8d79 100644
--- a/plugins/peopsxgl/fps.h
+++ b/plugins/peopsxgl/fps.h
@@ -25,4 +25,6 @@ void CheckFrameRate(void);
void ReInitFrameCap(void);
void SetAutoFrameCap(void);
+#ifndef _WINDOWS
unsigned long timeGetTime();
+#endif
diff --git a/plugins/peopsxgl/gl_ext.h b/plugins/peopsxgl/gl_ext.h
index be0db439..bbdf5f3a 100644
--- a/plugins/peopsxgl/gl_ext.h
+++ b/plugins/peopsxgl/gl_ext.h
@@ -1,4 +1,4 @@
-#define COMBINE_EXT 0x8570
+#define COMBINE_EXT 0x8570
#define COMBINE_RGB_EXT 0x8571
#define COMBINE_ALPHA_EXT 0x8572
#define SOURCE0_RGB_EXT 0x8580
@@ -22,16 +22,35 @@
#define FUNC_ADD_EXT 0x8006
#define FUNC_REVERSESUBTRACT_EXT 0x800B
-
-typedef void (* PFNGLBLENDEQU) (GLenum mode);
-typedef void (* PFNGLCOLORTABLEEXT)
- (GLenum target, GLenum internalFormat, GLsizei width, GLenum format,
- GLenum type, const GLvoid *data);
-
-#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
-
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
-
-//GL_ALPHA_SCALE
+
+#ifdef _WINDOWS
+typedef void (APIENTRY * PFNGLBLENDEQU) (GLenum mode);
+typedef void (APIENTRY * PFNGLCOLORTABLEEXT)
+ (GLenum target, GLenum internalFormat, GLsizei width, GLenum format,
+ GLenum type, const GLvoid *data);
+typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int iV);
+#else
+typedef void (* PFNGLBLENDEQU) (GLenum mode);
+typedef void (* PFNGLCOLORTABLEEXT)
+ (GLenum target, GLenum internalFormat, GLsizei width, GLenum format,
+ GLenum type, const GLvoid *data);
+#endif
+
+#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
+
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+
+#ifndef GL_BGR_EXT
+#define GL_BGR_EXT 0x80E0
+#endif
+#ifndef GL_BGRA_EXT
+#define GL_BGRA_EXT 0x80E1
+#endif
+
+#ifndef GL_COLOR_INDEX8_EXT
+#define GL_COLOR_INDEX8_EXT 0x80E5
+#endif
+
+//GL_ALPHA_SCALE
diff --git a/plugins/peopsxgl/gpu.c b/plugins/peopsxgl/gpu.c
index 307a1ed9..bde3f4a4 100644
--- a/plugins/peopsxgl/gpu.c
+++ b/plugins/peopsxgl/gpu.c
@@ -20,6 +20,9 @@
//#define NOVMODE
#include "stdafx.h"
+
+#ifndef _WINDOWS
+
#include "config.h"
#ifndef NOVMODE
@@ -28,6 +31,8 @@ static XF86VidModeModeInfo **modes=0;
static int iOldMode=0;
#endif
+#endif
+
#define _IN_GPU
#include "externals.h"
@@ -40,6 +45,10 @@ static int iOldMode=0;
#include "menu.h"
#include "fps.h"
#include "key.h"
+#ifdef _WINDOWS
+#include "resource.h"
+#include "ssave.h"
+#endif
#ifdef ENABLE_NLS
#include <libintl.h>
#include <locale.h>
@@ -49,7 +58,7 @@ static int iOldMode=0;
#define _(x) (x)
#define N_(x) (x)
#endif
-
+
////////////////////////////////////////////////////////////////////////
// PPDK developer must change libraryName field and can change revision and build
////////////////////////////////////////////////////////////////////////
@@ -84,6 +93,10 @@ BOOL bNeedInterlaceUpdate=FALSE;
BOOL bNeedRGB24Update=FALSE;
BOOL bChangeWinMode=FALSE;
+#ifdef _WINDOWS
+extern HGLRC GLCONTEXT;
+#endif
+
uint32_t ulStatusControl[256];
////////////////////////////////////////////////////////////////////////
@@ -168,8 +181,15 @@ char * GPUgetLibInfos(void)
// snapshot funcs (saves screen to bitmap / text infos into file)
////////////////////////////////////////////////////////////////////////
+#ifdef _WINDOWS
+char * GetConfigInfos(HWND hW)
+#else
char * GetConfigInfos(int hW)
+#endif
{
+#ifdef _WINDOWS
+ HDC hdc;HGLRC hglrc;
+#endif
char szO[2][4]={"off","on "};
char szTxt[256];
char * pB=(char *)malloc(32767);
@@ -177,11 +197,21 @@ char * GetConfigInfos(int hW)
if(!pB) return NULL;
*pB=0;
//----------------------------------------------------//
- sprintf(szTxt,"Plugin: %s %d.%d.%d\r\n",libraryName,version,revision,build);
+ sprintf(szTxt,"Plugin: %s %d.%d.%d (mod)\r\n",libraryName,version,revision,build);
strcat(pB,szTxt);
sprintf(szTxt,"Author: %s\r\n",PluginAuthor);
strcat(pB,szTxt);
+#ifdef _WINDOWS
+ if(hW)
+ {
+ hdc = GetDC(hW);
+ bSetupPixelFormat(hdc);
+ hglrc = wglCreateContext(hdc);
+ wglMakeCurrent(hdc, hglrc);
+ }
+#endif
+
sprintf(szTxt,"Card vendor: %s\r\n",(char *)glGetString(GL_VENDOR));
strcat(pB,szTxt);
sprintf(szTxt,"GFX card: %s\r\n",(char *)glGetString(GL_RENDERER));
@@ -191,6 +221,16 @@ char * GetConfigInfos(int hW)
//strcat(pB,(char *)glGetString(GL_EXTENSIONS));
//strcat(pB,"\r\n\r\n");
+#ifdef _WINDOWS
+ if(hW)
+ {
+ wglMakeCurrent(NULL, NULL);
+ wglDeleteContext(hglrc);
+ ReleaseDC(hW,hdc);
+ }
+ //----------------------------------------------------//
+#endif
+
if(hW && bWindowMode)
sprintf(szTxt,"Resolution/Color:\r\n- %dx%d ",LOWORD(iWinSize),HIWORD(iWinSize));
else
@@ -328,7 +368,11 @@ void DoTextSnapShot(int iNum)
{
FILE *txtfile;char szTxt[256];char * pB;
+#ifdef _WINDOWS
+ sprintf(szTxt,"snap\\pcsx%04d.txt",iNum);
+#else
sprintf(szTxt,"%s/pcsx%04d.txt",getenv("HOME"),iNum);
+#endif
if((txtfile=fopen(szTxt,"wb"))==NULL)
return;
@@ -393,7 +437,11 @@ void DoSnapShot(void)
do
{
snapshotnr++;
+#ifdef _WINDOWS
+ sprintf(filename,"snap/pcsx%04d.bmp",snapshotnr);
+#else
sprintf(filename,"%s/pcsx%04d.bmp",getenv("HOME"),snapshotnr);
+#endif
bmpfile=fopen(filename,"rb");
if(bmpfile==NULL)break;
fclose(bmpfile);
@@ -421,6 +469,9 @@ void DoSnapShot(void)
free(snapshotdumpmem);
DoTextSnapShot(snapshotnr);
+#ifdef _WINDOWS
+ MessageBeep((UINT)-1);
+#endif
}
void CALLBACK GPUmakeSnapshot(void)
@@ -509,6 +560,140 @@ long CALLBACK GPUinit()
// GPU OPEN: funcs to open up the gpu display (Windows)
////////////////////////////////////////////////////////////////////////
+#ifdef _WINDOWS
+
+void ChangeDesktop() // change destop resolution
+{
+ DEVMODE dv;long lRes,iTry=0;
+
+ while(iTry<10) // keep on hammering...
+ {
+ memset(&dv,0,sizeof(DEVMODE));
+ dv.dmSize=sizeof(DEVMODE);
+ dv.dmBitsPerPel=iColDepth;
+ dv.dmPelsWidth=iResX;
+ dv.dmPelsHeight=iResY;
+
+ dv.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
+
+ lRes=ChangeDisplaySettings(&dv,0); // ...hammering the anvil
+
+ if(lRes==DISP_CHANGE_SUCCESSFUL) return;
+ iTry++;Sleep(10);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////
+// OPEN interface func: attention!
+// some emus are calling this func in their main Window thread,
+// but all other interface funcs (to draw stuff) in a different thread!
+// that's a problem, since OGL is thread safe! Therefore we cannot
+// initialize the OGL stuff right here, we simply set a "bIsFirstFrame = TRUE"
+// flag, to initialize OGL on the first real draw call.
+// btw, we also call this open func ourselfes, each time when the user
+// is changing between fullscreen/window mode (ENTER key)
+// btw part 2: in windows the plugin gets the window handle from the
+// main emu, and doesn't create it's own window (if it would do it,
+// some PAD or SPU plugins would not work anymore)
+////////////////////////////////////////////////////////////////////////
+
+HMENU hPSEMenu=NULL;
+
+long CALLBACK GPUopen(HWND hwndGPU)
+{
+ HDC hdc;RECT r;DEVMODE dv;
+
+ hWWindow = hwndGPU; // store hwnd globally
+
+ InitKeyHandler(); // init key handler (subclass window)
+
+ if(bChangeWinMode) // user wants to change fullscreen/window mode?
+ {
+ ReadWinSizeConfig(); // -> get sizes again
+ }
+ else // first real startup
+ {
+ ReadConfig(); // -> read config from registry
+
+ SetFrameRateConfig(); // -> setup frame rate stuff
+ }
+
+ if(iNoScreenSaver) EnableScreenSaver(FALSE); // at least we can try
+
+
+ memset(&dv,0,sizeof(DEVMODE));
+ dv.dmSize=sizeof(DEVMODE);
+ EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dv);
+
+ bIsFirstFrame = TRUE; // flag: we have to init OGL later in windows!
+
+ if(bWindowMode) // win mode?
+ {
+ DWORD dw=GetWindowLong(hWWindow, GWL_STYLE); // -> adjust wnd style (owndc needed by some stupid ogl drivers)
+ dw&=~WS_THICKFRAME;
+ dw|=WS_BORDER|WS_CAPTION|CS_OWNDC;
+ SetWindowLong(hWWindow, GWL_STYLE, dw);
+
+ hPSEMenu=GetMenu(hWWindow); // -> hide emu menu (if any)
+ if(hPSEMenu!=NULL) SetMenu(hWWindow,NULL);
+
+ iResX=LOWORD(iWinSize);iResY=HIWORD(iWinSize);
+ ShowWindow(hWWindow,SW_SHOWNORMAL);
+
+ MoveWindow(hWWindow, // -> center wnd
+ GetSystemMetrics(SM_CXFULLSCREEN)/2-iResX/2,
+ GetSystemMetrics(SM_CYFULLSCREEN)/2-iResY/2,
+ iResX+GetSystemMetrics(SM_CXFIXEDFRAME)+3,
+ iResY+GetSystemMetrics(SM_CYFIXEDFRAME)+GetSystemMetrics(SM_CYCAPTION)+3,
+ TRUE);
+ UpdateWindow(hWWindow); // -> let windows do some update
+
+ if(dv.dmBitsPerPel==16 || dv.dmBitsPerPel==32) // -> overwrite user color info with desktop color info
+ iColDepth=dv.dmBitsPerPel;
+ }
+ else // fullscreen mode:
+ {
+ if(dv.dmBitsPerPel!=(unsigned int)iColDepth || // -> check, if we have to change resolution
+ dv.dmPelsWidth !=(unsigned int)iResX ||
+ dv.dmPelsHeight!=(unsigned int)iResY)
+ bChangeRes=TRUE; else bChangeRes=FALSE;
+
+ if(bChangeRes) ChangeDesktop(); // -> change the res (had to do an own func because of some MS 'optimizations')
+
+ SetWindowLong(hWWindow, GWL_STYLE, CS_OWNDC); // -> adjust wnd style as well (to be sure)
+
+ hPSEMenu=GetMenu(hWWindow); // -> hide menu
+ if(hPSEMenu!=NULL) SetMenu(hWWindow,NULL);
+ ShowWindow(hWWindow,SW_SHOWMAXIMIZED); // -> max mode
+ }
+
+ rRatioRect.left = rRatioRect.top=0;
+ rRatioRect.right = iResX;
+ rRatioRect.bottom = iResY;
+
+ r.left=r.top=0;r.right=iResX;r.bottom=iResY; // hack for getting a clean black window until OGL gets initialized
+ hdc = GetDC(hWWindow);
+ FillRect(hdc,&r,(HBRUSH)GetStockObject(BLACK_BRUSH));
+ bSetupPixelFormat(hdc);
+ ReleaseDC(hWWindow,hdc);
+
+ bDisplayNotSet = TRUE;
+ bSetClip=TRUE;
+
+ SetFixes(); // setup game fixes
+
+ InitializeTextureStore(); // init texture mem
+
+// lGPUstatusRet = 0x74000000;
+
+// with some emus, we could do the OGL init right here... oh my
+// if(bIsFirstFrame) GLinitialize();
+
+ return 0;
+}
+
+#else
+
////////////////////////////////////////////////////////////////////////
// LINUX GPU OPEN: func to open up the gpu display (X stuff)
// please note: in linux we are creating our own display, and we return
@@ -844,10 +1029,36 @@ long GPUopen(unsigned long * disp,char * CapText,char * CfgFile)
return -1;
}
+#endif
+
////////////////////////////////////////////////////////////////////////
// close
////////////////////////////////////////////////////////////////////////
+#ifdef _WINDOWS
+
+long CALLBACK GPUclose() // WINDOWS CLOSE
+{
+ ExitKeyHandler();
+
+ GLcleanup(); // close OGL
+
+ if(bChangeRes) // change res back
+ ChangeDisplaySettings(NULL,0);
+
+ if(hPSEMenu) // set menu again
+ SetMenu(hWWindow,hPSEMenu);
+
+ if(pGfxCardScreen) free(pGfxCardScreen); // free helper memory
+ pGfxCardScreen=0;
+
+ if(iNoScreenSaver) EnableScreenSaver(TRUE); // enable screen saver again
+
+ return 0;
+}
+
+#else
+
long GPUclose() // LINUX CLOSE
{
GLcleanup(); // close OGL
@@ -860,6 +1071,8 @@ long GPUclose() // LINUX CLOSE
return 0;
}
+#endif
+
////////////////////////////////////////////////////////////////////////
// I shot the sheriff... last function called from emu
////////////////////////////////////////////////////////////////////////
@@ -1180,6 +1393,11 @@ void updateDisplay(void) // UPDATE DISPLAY
{
BOOL bBlur=FALSE;
+#ifdef _WINDOWS
+ HDC hdc=GetDC(hWWindow); // windows:
+ wglMakeCurrent(hdc,GLCONTEXT); // -> make context current again
+#endif
+
bFakeFrontBuffer=FALSE;
bRenderFrontBuffer=FALSE;
@@ -1267,7 +1485,11 @@ void updateDisplay(void) // UPDATE DISPLAY
if(!bSkipNextFrame)
{
if(iDrawnSomething)
+#ifdef _WINDOWS
+ SwapBuffers(wglGetCurrentDC()); // -> to skip or not to skip
+#else
glXSwapBuffers(display,window);
+#endif
}
if(dwActFixes&0x180) // -> special old frame skipping: skip max one in a row
{
@@ -1280,7 +1502,11 @@ void updateDisplay(void) // UPDATE DISPLAY
else // no skip ?
{
if(iDrawnSomething)
+#ifdef _WINDOWS
+ SwapBuffers(wglGetCurrentDC()); // -> swap
+#else
glXSwapBuffers(display,window);
+#endif
}
iDrawnSomething=0;
@@ -1364,6 +1590,10 @@ void updateDisplay(void) // UPDATE DISPLAY
rRatioRect.bottom+i4);
}
+#ifdef _WINDOWS
+ ReleaseDC(hWWindow,hdc); // ! important !
+#endif
+
if(ulKeybits&KEY_RESETTEXSTORE) ResetStuff(); // reset on gpu mode changes? do it before next frame is filled
}
@@ -1390,8 +1620,18 @@ void updateFrontDisplay(void)
if(gTexPicName) DisplayPic();
if(ulKeybits&KEY_SHOWFPS) DisplayText();
+#ifdef _WINDOWS
+ { // windows:
+ HDC hdc=GetDC(hWWindow);
+ wglMakeCurrent(hdc,GLCONTEXT); // -> make current again
+ if(iDrawnSomething)
+ SwapBuffers(wglGetCurrentDC()); // -> swap
+ ReleaseDC(hWWindow,hdc); // -> ! important !
+ }
+#else
if(iDrawnSomething) // linux:
glXSwapBuffers(display,window);
+#endif
if(iBlurBuffer) UnBlurBackBuffer();
}
@@ -1596,6 +1836,20 @@ void updateDisplayIfChanged(void)
}
////////////////////////////////////////////////////////////////////////
+// window mode <-> fullscreen mode (windows)
+////////////////////////////////////////////////////////////////////////
+
+#ifdef _WINDOWS
+void ChangeWindowMode(void)
+ {
+ GPUclose();
+ bWindowMode=!bWindowMode;
+ GPUopen(hWWindow);
+ bChangeWinMode=FALSE;
+ }
+#endif
+
+////////////////////////////////////////////////////////////////////////
// swap update check (called by psx vsync function)
////////////////////////////////////////////////////////////////////////
@@ -1706,6 +1960,10 @@ void CALLBACK GPUupdateLace(void)
{
updateDisplay();
}
+
+#ifdef _WINDOWS
+ if(bChangeWinMode) ChangeWindowMode();
+#endif
}
////////////////////////////////////////////////////////////////////////
@@ -1751,7 +2009,11 @@ uint32_t CALLBACK GPUreadStatus(void)
void CALLBACK GPUwriteStatus(uint32_t gdata)
{
uint32_t lCommand=(gdata>>24)&0xff;
-
+
+#ifdef _WINDOWS
+ if(bIsFirstFrame) GLinitialize(); // real ogl startup (needed by some emus)
+#endif
+
ulStatusControl[lCommand]=gdata;
switch(lCommand)
@@ -2641,6 +2903,8 @@ void CALLBACK GPUwriteData(uint32_t gdata)
// call config dlg
////////////////////////////////////////////////////////////////////////
+#ifndef _WINDOWS
+
void StartCfgTool(char *arg) // linux: start external cfg tool
{
char cfg[256];
@@ -2682,6 +2946,19 @@ long CALLBACK GPUconfigure(void)
return 0;
}
+#else
+
+long CALLBACK GPUconfigure(void)
+{
+ HWND hWP=GetActiveWindow();
+ DialogBox(hInst,MAKEINTRESOURCE(IDD_CFGDLG),
+ hWP,(DLGPROC)CfgDlgProc);
+
+ return 0;
+}
+
+#endif
+
////////////////////////////////////////////////////////////////////////
// sets all kind of act fixes
////////////////////////////////////////////////////////////////////////
@@ -2758,7 +3035,15 @@ long CALLBACK GPUdmaChain(uint32_t *baseAddrL, uint32_t addr)
void CALLBACK GPUabout(void)
{
+#ifdef _WINDOWS
+ HWND hWP=GetActiveWindow(); // to be sure
+ DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG_ABOUT),
+ hWP,(DLGPROC)AboutDlgProc);
+#else
+
StartCfgTool("ABOUT");
+
+#endif
}
////////////////////////////////////////////////////////////////////////
diff --git a/plugins/peopsxgl/menu.c b/plugins/peopsxgl/menu.c
index f26d5ce2..bde7eb1c 100644
--- a/plugins/peopsxgl/menu.c
+++ b/plugins/peopsxgl/menu.c
@@ -126,6 +126,9 @@ GLubyte texrasters[40][12]= {
GLuint gTexFontName=0;
GLuint gTexPicName=0;
GLuint gTexCursorName=0;
+#ifdef _WINDOWS
+HFONT hGFont=NULL;
+#endif
void MakeDisplayLists(void) // MAKE FONT
{
@@ -162,6 +165,14 @@ void MakeDisplayLists(void) // MAKE FONT
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 64, 64, 0, GL_RGB,
GL_UNSIGNED_BYTE,TexBytes);
+
+#ifdef _WINDOWS
+ hGFont=CreateFont(13,0,0,0,FW_NORMAL,FALSE, // windows: create font for hint texts
+ FALSE,FALSE,DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
+ DEFAULT_QUALITY,DEFAULT_PITCH,
+ "Arial");
+#endif
}
////////////////////////////////////////////////////////////////////////
@@ -170,6 +181,11 @@ void MakeDisplayLists(void) // MAKE FONT
void KillDisplayLists(void)
{
+#ifdef _WINDOWS
+ if(hGFont) DeleteObject(hGFont); // windows: kill info font
+ hGFont=NULL;
+#endif
+
if(gTexFontName) // del font/info textures
{glDeleteTextures(1,&gTexFontName);gTexFontName=0;}
if(gTexPicName)
@@ -555,7 +571,11 @@ void BuildDispMenu(int iInc)
iMPos+=iInc; // up or down
if(iMPos<0) iMPos=9; // wrap around
- if(iMPos>9) iMPos=0;
+ if(iMPos>9) iMPos=0;
+
+#ifdef _WINDOWS
+ if(gTexPicName) ShowTextGpuPic(); // windows: show the gpu info as well
+#endif
}
////////////////////////////////////////////////////////////////////////
@@ -573,6 +593,17 @@ void SwitchDispMenu(int iStep)
int iType=0;
bInitCap = TRUE;
+#ifdef _WINDOWS
+ if(iFrameLimit==1 && bUseFrameLimit &&
+ GetAsyncKeyState(VK_SHIFT)&32768)
+ {
+ fFrameRate+=iStep;
+ if(fFrameRate<3.0f) fFrameRate=3.0f;
+ SetAutoFrameCap();
+ break;
+ }
+#endif
+
if(bUseFrameLimit) iType=iFrameLimit;
iType+=iStep;
if(iType<0) iType=2;
@@ -1361,6 +1392,113 @@ void DisplayPic(void)
glEnable(GL_ALPHA_TEST);
glEnable(GL_SCISSOR_TEST);
}
+
+////////////////////////////////////////////////////////////////////////
+// windows only: texture with pi-tec sign and version info
+////////////////////////////////////////////////////////////////////////
+
+#ifdef _WINDOWS
+void ShowGpuPic(void)
+{
+ HRSRC hR;HGLOBAL hG;
+ unsigned long * pRMem;
+ unsigned char * pMem;
+ int x,y;unsigned long * pDMem;
+
+ if(gTexPicName) {DestroyPic();return;} // turn off any screen pic, if it does already exist
+
+ if(ulKeybits&KEY_SHOWFPS) {ShowTextGpuPic();return;}
+
+ hR=FindResource(hInst,MAKEINTRESOURCE(IDB_GPU),RT_BITMAP); // load bitmap from resource
+ hG=LoadResource(hInst,hR);
+
+ pRMem=((unsigned long *)LockResource(hG))+10; // get long ptr to bmp data
+
+ pMem=(unsigned char *)malloc(128*96*3); // change the data upside-down
+
+ for(y=0;y<96;y++)
+ {
+ pDMem=(unsigned long *)(pMem+(95-y)*128*3);
+ for(x=0;x<96;x++) *pDMem++=*pRMem++;
+ }
+
+ CreatePic(pMem); // show the pic
+
+ free(pMem); // clean up
+ DeleteObject(hG);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void ShowTextGpuPic(void) // CREATE TEXT SCREEN PIC
+{ // gets an Text and paints
+ unsigned char * pMem;BITMAPINFO bmi; // it into a rgb24 bitmap
+ HDC hdc,hdcMem;HBITMAP hBmp,hBmpMem;HFONT hFontMem; // to display it in the gpu
+ HBRUSH hBrush,hBrushMem;HPEN hPen,hPenMem;
+ char szB[256];
+ RECT r={0,0,128,96}; // size of bmp... don't change that
+ COLORREF crFrame = RGB(255,255,128); // some example color inits
+ COLORREF crBkg = RGB(0,0,0);
+ COLORREF crText = RGB(255,255,0);
+
+ if(gTexPicName) DestroyPic();
+
+ //----------------------------------------------------// creation of the dc & bitmap
+
+ hdc =GetDC(NULL); // create a dc
+ hdcMem=CreateCompatibleDC(hdc);
+ ReleaseDC(NULL,hdc);
+
+ memset(&bmi,0,sizeof(BITMAPINFO)); // create a 24bit dib
+ bmi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth=128;
+ bmi.bmiHeader.biHeight=-96;
+ bmi.bmiHeader.biPlanes=1;
+ bmi.bmiHeader.biBitCount=24;
+ bmi.bmiHeader.biCompression=BI_RGB;
+ hBmp=CreateDIBSection(hdcMem,&bmi,DIB_RGB_COLORS,
+ (void **)&pMem,NULL,0); // pMem will point to 128x96x3 bitmap data
+
+ hBmpMem = (HBITMAP)SelectObject(hdcMem,hBmp); // sel the bmp into the dc
+
+ //----------------------------------------------------// ok, the following is just a drawing example... change it...
+ // create & select an additional font... whatever you want to paint, paint it in the dc :)
+ hBrush=CreateSolidBrush(crBkg);
+ hPen=CreatePen(PS_SOLID,0,crFrame);
+
+ hBrushMem = (HBRUSH)SelectObject(hdcMem,hBrush);
+ hPenMem = (HPEN)SelectObject(hdcMem,hPen);
+ hFontMem = (HFONT)SelectObject(hdcMem,hGFont);
+
+ SetTextColor(hdcMem,crText);
+ SetBkColor(hdcMem,crBkg);
+
+ Rectangle(hdcMem,r.left,r.top,r.right,r.bottom); // our example: fill rect and paint border
+ InflateRect(&r,-3,-2); // reduce the text area
+
+ LoadString(hInst,IDS_INFO0+iMPos,szB,255);
+ DrawText(hdcMem,szB,strlen(szB),&r, // paint the text (including clipping and word break)
+ DT_LEFT|DT_WORDBREAK);
+
+ //----------------------------------------------------// ok, now store the pMem data, or just call the gpu func
+
+ CreatePic(pMem);
+
+ //----------------------------------------------------// finished, now we clean up... needed, or you will get resource leaks :)
+
+ SelectObject(hdcMem,hBmpMem); // sel old mem dc objects
+ SelectObject(hdcMem,hBrushMem);
+ SelectObject(hdcMem,hPenMem);
+ SelectObject(hdcMem,hFontMem);
+ DeleteDC(hdcMem); // delete mem dcs
+ DeleteObject(hBmp);
+ DeleteObject(hBrush); // delete created objects
+ DeleteObject(hPen);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+#endif
////////////////////////////////////////////////////////////////////////
// show gun cursor
diff --git a/plugins/peopsxgl/menu.h b/plugins/peopsxgl/menu.h
index 426eaccd..6c244952 100644
--- a/plugins/peopsxgl/menu.h
+++ b/plugins/peopsxgl/menu.h
@@ -36,6 +36,10 @@ void SwitchDispMenu(int iStep);
void CreatePic(unsigned char * pMem);
void DisplayPic(void);
void DestroyPic(void);
+#ifdef _WINDOWS
+void ShowGpuPic(void);
+void ShowTextGpuPic(void);
+#endif
void ShowGunCursor(void);
#endif // _GL_MENU_H_
diff --git a/plugins/peopsxgl/soft.c b/plugins/peopsxgl/soft.c
index bae51708..9f10a2a0 100644
--- a/plugins/peopsxgl/soft.c
+++ b/plugins/peopsxgl/soft.c
@@ -1188,6 +1188,26 @@ static int left_R, delta_left_R, right_R, delta_right_R;
static int left_G, delta_left_G, right_G, delta_right_G;
static int left_B, delta_left_B, right_B, delta_right_B;
+#ifdef _MSC_VER
+
+#pragma warning (disable : 4035)
+
+__inline int shl10idiv(int x, int y)
+{
+ __asm
+ {
+ mov eax,x
+ mov ebx,y
+ mov edx, eax
+ shl eax, 10
+ sar edx, 22
+ idiv ebx
+ // return result in eax
+ }
+}
+
+#else
+
__inline int shl10idiv(int x, int y)
{
long long int bi=x;
@@ -1195,6 +1215,8 @@ __inline int shl10idiv(int x, int y)
return bi/y;
}
+#endif
+
__inline int RightSection_F(void)
{
soft_vertex * v1 = right_array[ right_section ];
diff --git a/plugins/peopsxgl/stdafx.h b/plugins/peopsxgl/stdafx.h
index 1d845ff2..ffa66fd1 100644
--- a/plugins/peopsxgl/stdafx.h
+++ b/plugins/peopsxgl/stdafx.h
@@ -16,6 +16,28 @@
* *
***************************************************************************/
+#ifdef _WINDOWS
+
+#define _CRT_SECURE_NO_WARNINGS
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdarg.h>
+#include <windows.h>
+#include <windowsx.h>
+#include <tchar.h>
+#include <mmsystem.h>
+#include "resource.h"
+
+#pragma warning (disable:4244)
+#pragma warning (disable:4761)
+
+#include <GL/gl.h>
+
+#else
+
#define __X11_C_
#define __inline inline
@@ -32,14 +54,17 @@
#include <X11/cursorfont.h>
#define CALLBACK /* */
-#define __inline inline
+
+#endif
#include "gl_ext.h"
#define SHADETEXBIT(x) ((x>>24) & 0x1)
#define SEMITRANSBIT(x) ((x>>25) & 0x1)
-
+
+#ifndef _WINDOWS
#ifndef GL_BGRA_EXT
#define GL_BGRA_EXT GL_BGRA
#endif
#define GL_COLOR_INDEX8_EXT 0x80E5
+#endif
diff --git a/plugins/peopsxgl/texture.c b/plugins/peopsxgl/texture.c
index 01630dad..c287768f 100644
--- a/plugins/peopsxgl/texture.c
+++ b/plugins/peopsxgl/texture.c
@@ -145,7 +145,11 @@ unsigned short (*PTCF[2]) (unsigned short);
////////////////////////////////////////////////////////////////////////
// texture cache implementation
-////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+
+#ifdef _WINDOWS
+#pragma pack(1)
+#endif
// "texture window" cache entry
@@ -171,6 +175,10 @@ typedef struct textureSubCacheEntryTagS
unsigned char cTexID;
unsigned char Opaque;
} textureSubCacheEntryS;
+
+#ifdef _WINDOWS
+#pragma pack()
+#endif
//---------------------------------------------