From 3249db8f9dfa113d95e4c949aa6b869e921e5b9f Mon Sep 17 00:00:00 2001 From: "SND\\edgbla_cp" Date: Fri, 1 Oct 2010 22:15:22 +0000 Subject: dfxvideo, peopsxgl: ode bit fix (Cosmowarrior Rei/iS - Internal Section). git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@57994 e17a0e51-4ae3-4d35-97c3-1a29b211df97 --- plugins/dfxvideo/externals.h | 175 ++++----- plugins/dfxvideo/gpu.c | 876 ++++++++++++++++++++++--------------------- plugins/peopsxgl/externals.h | 1 + plugins/peopsxgl/gpu.c | 58 +-- 4 files changed, 564 insertions(+), 546 deletions(-) (limited to 'plugins') diff --git a/plugins/dfxvideo/externals.h b/plugins/dfxvideo/externals.h index 9ed2b40c..5a991849 100644 --- a/plugins/dfxvideo/externals.h +++ b/plugins/dfxvideo/externals.h @@ -51,40 +51,40 @@ #define GPUIsNotReadyForCommands (lGPUstatusRet &= ~GPUSTATUS_READYFORCOMMANDS) #define GPUIsReadyForCommands (lGPUstatusRet |= GPUSTATUS_READYFORCOMMANDS) - -#ifdef _WINDOWS - -#ifndef STRICT -#define STRICT -#endif -#define D3D_OVERLOADS -#define DIRECT3D_VERSION 0x600 -#define CINTERFACE -#ifndef WINVER -#define WINVER 0x0500 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include "resource.h" - -#include "ddraw.h" -#include "d3dtypes.h" -#include "d3d.h" - -#ifdef _MSC_VER -#pragma warning (disable:864) -#pragma warning (disable:4244) -#pragma warning (disable:4996) -#endif - -#else + +#ifdef _WINDOWS + +#ifndef STRICT +#define STRICT +#endif +#define D3D_OVERLOADS +#define DIRECT3D_VERSION 0x600 +#define CINTERFACE +#ifndef WINVER +#define WINVER 0x0500 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include "resource.h" + +#include "ddraw.h" +#include "d3dtypes.h" +#include "d3d.h" + +#ifdef _MSC_VER +#pragma warning (disable:864) +#pragma warning (disable:4244) +#pragma warning (disable:4996) +#endif + +#else #define __X11_C_ //X11 render @@ -102,8 +102,8 @@ #include #include #include - -#endif + +#endif ///////////////////////////////////////////////////////////////////////////// @@ -139,21 +139,21 @@ typedef struct PSXRECTTAG short y0; short y1; } PSXRect_t; - -#ifdef _WINDOWS - -typedef struct SDXTAG -{ - LPDIRECTDRAW DD; - - LPDIRECTDRAWSURFACE DDSPrimary; - LPDIRECTDRAWSURFACE DDSRender; - LPDIRECTDRAWSURFACE DDSHelper; - LPDIRECTDRAWSURFACE DDSScreenPic; - HWND hWnd; -} sDX; - -#else + +#ifdef _WINDOWS + +typedef struct SDXTAG +{ + LPDIRECTDRAW DD; + + LPDIRECTDRAWSURFACE DDSPrimary; + LPDIRECTDRAWSURFACE DDSRender; + LPDIRECTDRAWSURFACE DDSHelper; + LPDIRECTDRAWSURFACE DDSScreenPic; + HWND hWnd; +} sDX; + +#else // linux defines for some windows stuff @@ -206,26 +206,26 @@ typedef struct PSXDISPLAYTAG } PSXDisplay_t; -#ifdef _WINDOWS -extern HINSTANCE hInst; -extern HMODULE hDDrawDLL; -#endif +#ifdef _WINDOWS +extern HINSTANCE hInst; +extern HMODULE hDDrawDLL; +#endif + +///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - // draw.c #ifndef _IN_DRAW -#ifdef _WINDOWS -extern sDX DX; -extern HWND hWGPU; -extern GUID guiDev; -extern int iRefreshRate; -extern BOOL bVsync; -extern BOOL bVsync_Key; -#else -extern char * pCaptionText; +#ifdef _WINDOWS +extern sDX DX; +extern HWND hWGPU; +extern GUID guiDev; +extern int iRefreshRate; +extern BOOL bVsync; +extern BOOL bVsync_Key; +#else +extern char * pCaptionText; #endif extern int iResX; @@ -244,9 +244,9 @@ extern short g_m1; extern short g_m2; extern short g_m3; extern short DrawSemiTrans; -extern int iUseGammaVal; -#ifdef _WINDOWS -extern int iUseScanLines; +extern int iUseGammaVal; +#ifdef _WINDOWS +extern int iUseScanLines; #endif extern int iMaintainAspect; extern int iDesktopCol; @@ -256,11 +256,11 @@ extern int iFastFwd; extern int iDebugMode; extern int iFVDisplay; extern PSXPoint_t ptCursorPoint[]; -extern unsigned short usCursorActive; +extern unsigned short usCursorActive; -#ifdef _WINDOWS -extern int iSysMemory; -#endif +#ifdef _WINDOWS +extern int iSysMemory; +#endif #endif @@ -324,6 +324,7 @@ extern BOOL bInitCap; extern DWORD dwLaceCnt; extern uint32_t lGPUInfoVals[]; extern uint32_t ulStatusControl[]; +extern uint32_t vBlank; #endif @@ -332,12 +333,12 @@ extern uint32_t ulStatusControl[]; #ifndef _IN_MENU extern uint32_t dwCoreFlags; - -#ifdef _WINDOWS -extern HFONT hGFont; -extern int iMPos; -extern BOOL bTransparent; -#endif + +#ifdef _WINDOWS +extern HFONT hGFont; +extern int iMPos; +extern BOOL bTransparent; +#endif #endif @@ -345,12 +346,12 @@ extern BOOL bTransparent; #ifndef _IN_KEY -extern unsigned long ulKeybits; +extern unsigned long ulKeybits; -#ifdef _WINDOWS -extern char szGPUKeys[]; +#ifdef _WINDOWS +extern char szGPUKeys[]; #endif - + #endif // fps.c @@ -364,10 +365,10 @@ extern int iFrameLimit; extern float fFrameRateHz; extern float fps_skip; extern float fps_cur; -#ifdef _WINDOWS -extern BOOL IsPerformanceCounter; -extern int iStopSaver; -#endif +#ifdef _WINDOWS +extern BOOL IsPerformanceCounter; +extern int iStopSaver; +#endif #endif diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c index 470a0e5b..3b68c21d 100644 --- a/plugins/dfxvideo/gpu.c +++ b/plugins/dfxvideo/gpu.c @@ -18,7 +18,7 @@ #if !defined(_MACGL) && !defined(_WINDOWS) #include "config.h" #endif - + #define _IN_GPU #include "externals.h" @@ -42,11 +42,11 @@ #define _(x) (x) #define N_(x) (x) #endif - -#ifdef _WINDOWS -#include "resource.h" -#include "record.h" -#endif + +#ifdef _WINDOWS +#include "resource.h" +#include "record.h" +#endif //////////////////////////////////////////////////////////////////////// // PPDK developer must change libraryName field and can change revision and build @@ -55,10 +55,10 @@ const unsigned char version = 1; // do not touch - library for PSEmu 1.x const unsigned char revision = 1; const unsigned char build = 17; // increase that with each version - -#if defined (_WINDOWS) + +#if defined (_WINDOWS) static char *libraryName = N_("Soft Driver"); -static char *libraryInfo = N_("P.E.Op.S. Soft Driver V1.17\nCoded by Pete Bernert and the P.E.Op.S. team\n"); +static char *libraryInfo = N_("P.E.Op.S. Soft Driver V1.17\nCoded by Pete Bernert and the P.E.Op.S. team\n"); #elif defined (_MACGL) static char *libraryName = N_("SoftGL Driver"); static char *libraryInfo = N_("P.E.Op.S. SoftGL Driver V1.17\nCoded by Pete Bernert and the P.E.Op.S. team\n"); @@ -115,65 +115,66 @@ BOOL bChangeWinMode=FALSE; BOOL bDoLazyUpdate=FALSE; uint32_t lGPUInfoVals[16]; static int iFakePrimBusy=0; - -#ifdef _WINDOWS - -//////////////////////////////////////////////////////////////////////// -// screensaver stuff: dynamically load kernel32.dll to avoid export dependeny -//////////////////////////////////////////////////////////////////////// - -int iStopSaver=0; -HINSTANCE kernel32LibHandle = NULL; - -// A stub function, that does nothing .... but it does "nothing" well :) -EXECUTION_STATE WINAPI STUB_SetThreadExecutionState(EXECUTION_STATE esFlags) -{ - return esFlags; -} - -// The dynamic version of the system call is prepended with a "D_" -EXECUTION_STATE (WINAPI *D_SetThreadExecutionState)(EXECUTION_STATE esFlags) = STUB_SetThreadExecutionState; - -BOOL LoadKernel32(void) -{ - // Get a handle to the kernel32.dll (which is actually already loaded) - kernel32LibHandle = LoadLibrary("kernel32.dll"); - - // If we've got a handle, then locate the entry point for the SetThreadExecutionState function - if (kernel32LibHandle != NULL) - { - if ((D_SetThreadExecutionState = (EXECUTION_STATE (WINAPI *)(EXECUTION_STATE))GetProcAddress (kernel32LibHandle, "SetThreadExecutionState")) == NULL) - D_SetThreadExecutionState = STUB_SetThreadExecutionState; - } - - return TRUE; -} - -BOOL FreeKernel32(void) -{ - // Release the handle to kernel32.dll - if (kernel32LibHandle != NULL) - FreeLibrary(kernel32LibHandle); - - // Set to stub function, to avoid nasty suprises if called :) - D_SetThreadExecutionState = STUB_SetThreadExecutionState; - - return TRUE; -} -#else - -// Linux: Stub the functions -BOOL LoadKernel32(void) -{ - return TRUE; -} - -BOOL FreeKernel32(void) -{ - return TRUE; -} - -#endif +uint32_t vBlank=0; + +#ifdef _WINDOWS + +//////////////////////////////////////////////////////////////////////// +// screensaver stuff: dynamically load kernel32.dll to avoid export dependeny +//////////////////////////////////////////////////////////////////////// + +int iStopSaver=0; +HINSTANCE kernel32LibHandle = NULL; + +// A stub function, that does nothing .... but it does "nothing" well :) +EXECUTION_STATE WINAPI STUB_SetThreadExecutionState(EXECUTION_STATE esFlags) +{ + return esFlags; +} + +// The dynamic version of the system call is prepended with a "D_" +EXECUTION_STATE (WINAPI *D_SetThreadExecutionState)(EXECUTION_STATE esFlags) = STUB_SetThreadExecutionState; + +BOOL LoadKernel32(void) +{ + // Get a handle to the kernel32.dll (which is actually already loaded) + kernel32LibHandle = LoadLibrary("kernel32.dll"); + + // If we've got a handle, then locate the entry point for the SetThreadExecutionState function + if (kernel32LibHandle != NULL) + { + if ((D_SetThreadExecutionState = (EXECUTION_STATE (WINAPI *)(EXECUTION_STATE))GetProcAddress (kernel32LibHandle, "SetThreadExecutionState")) == NULL) + D_SetThreadExecutionState = STUB_SetThreadExecutionState; + } + + return TRUE; +} + +BOOL FreeKernel32(void) +{ + // Release the handle to kernel32.dll + if (kernel32LibHandle != NULL) + FreeLibrary(kernel32LibHandle); + + // Set to stub function, to avoid nasty suprises if called :) + D_SetThreadExecutionState = STUB_SetThreadExecutionState; + + return TRUE; +} +#else + +// Linux: Stub the functions +BOOL LoadKernel32(void) +{ + return TRUE; +} + +BOOL FreeKernel32(void) +{ + return TRUE; +} + +#endif //////////////////////////////////////////////////////////////////////// // some misc external display funcs @@ -289,11 +290,11 @@ static 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); + +#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) @@ -351,11 +352,11 @@ void CALLBACK GPUmakeSnapshot(void) // increment snapshot value & try to get filename do { - snapshotnr++; -#ifdef _WINDOWS - sprintf(filename,"snap\\pcsx%04ld.bmp",snapshotnr); -#else - sprintf(filename, "%s/pcsx%04ld.bmp", getenv("HOME"), snapshotnr); + snapshotnr++; +#ifdef _WINDOWS + sprintf(filename,"snap\\pcsx%04ld.bmp",snapshotnr); +#else + sprintf(filename, "%s/pcsx%04ld.bmp", getenv("HOME"), snapshotnr); #endif bmpfile = fopen(filename,"rb"); @@ -458,10 +459,11 @@ long CALLBACK GPUinit() // GPU INIT lGPUstatusRet = 0x14802000; GPUIsIdle; GPUIsReadyForCommands; - bDoVSyncUpdate = TRUE; + bDoVSyncUpdate = TRUE; + vBlank = 0; - // Get a handle for kernel32.dll, and access the required export function - LoadKernel32(); + // Get a handle for kernel32.dll, and access the required export function + LoadKernel32(); return 0; } @@ -469,34 +471,34 @@ long CALLBACK GPUinit() // GPU INIT //////////////////////////////////////////////////////////////////////// // Here starts all... //////////////////////////////////////////////////////////////////////// - -#ifdef _WINDOWS -long CALLBACK GPUopen(HWND hwndGPU) // GPU OPEN -{ - hWGPU = hwndGPU; // store hwnd - - SetKeyHandler(); // sub-class window - - if(bChangeWinMode) ReadWinSizeConfig(); // alt+enter toggle? - else // or first time startup? - { - ReadConfig(); // read registry - InitFPS(); - } - - bIsFirstFrame = TRUE; // we have to init later - bDoVSyncUpdate = TRUE; - - ulInitDisplay(); // setup direct draw - - if(iStopSaver) - D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED|ES_CONTINUOUS); - - - return 0; -} - -#else + +#ifdef _WINDOWS +long CALLBACK GPUopen(HWND hwndGPU) // GPU OPEN +{ + hWGPU = hwndGPU; // store hwnd + + SetKeyHandler(); // sub-class window + + if(bChangeWinMode) ReadWinSizeConfig(); // alt+enter toggle? + else // or first time startup? + { + ReadConfig(); // read registry + InitFPS(); + } + + bIsFirstFrame = TRUE; // we have to init later + bDoVSyncUpdate = TRUE; + + ulInitDisplay(); // setup direct draw + + if(iStopSaver) + D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED|ES_CONTINUOUS); + + + return 0; +} + +#else long GPUopen(unsigned long * disp,char * CapText,char * CfgFile) { @@ -520,7 +522,7 @@ long GPUopen(unsigned long * disp,char * CapText,char * CfgFile) if(d) return 0; return -1; } - + #endif //////////////////////////////////////////////////////////////////////// @@ -529,18 +531,18 @@ long GPUopen(unsigned long * disp,char * CapText,char * CfgFile) long CALLBACK GPUclose() // GPU CLOSE { -#ifdef _WINDOWS - if(RECORD_RECORDING==TRUE) {RECORD_Stop();RECORD_RECORDING=FALSE;BuildDispMenu(0);} -#endif +#ifdef _WINDOWS + if(RECORD_RECORDING==TRUE) {RECORD_Stop();RECORD_RECORDING=FALSE;BuildDispMenu(0);} +#endif ReleaseKeyHandler(); // de-subclass window CloseDisplay(); // shutdown direct draw - -#ifdef _WINDOWS - if(iStopSaver) - D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED); -#endif + +#ifdef _WINDOWS + if(iStopSaver) + D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED); +#endif return 0; } @@ -550,9 +552,9 @@ long CALLBACK GPUclose() // GPU CLOSE //////////////////////////////////////////////////////////////////////// long CALLBACK GPUshutdown() // GPU SHUTDOWN -{ - // screensaver: release the handle for kernel32.dll - FreeKernel32(); +{ + // screensaver: release the handle for kernel32.dll + FreeKernel32(); free(psxVSecure); @@ -655,7 +657,7 @@ void ChangeDispOffsetsX(void) // X CENTER PreviousPSXDisplay.Range.x0+=2; //??? PreviousPSXDisplay.Range.x1+=(short)(lx-l); - + #ifndef _WINDOWS PreviousPSXDisplay.Range.x1-=2; // makes linux stretching easier #endif @@ -774,117 +776,117 @@ void updateDisplayIfChanged(void) // UPDATE DISPLAY IF CHAN //////////////////////////////////////////////////////////////////////// -#if defined(_WINDOWS) - -void ChangeWindowMode(void) // TOGGLE FULLSCREEN - WINDOW -{ - GPUclose(); - iWindowMode=!iWindowMode; - GPUopen(hWGPU); - bChangeWinMode=FALSE; - bDoVSyncUpdate=TRUE; -} - -#elif !defined (_MACGL) - -#include "draw.h" - -void ChangeWindowMode(void) // TOGGLE FULLSCREEN - WINDOW -{ - extern Display *display; - extern Window window; - extern int root_window_id; - Screen *screen; - XSizeHints hints; - MotifWmHints mwmhints; - Atom mwmatom; - - screen=DefaultScreenOfDisplay(display); - iWindowMode=!iWindowMode; - - if(!iWindowMode) // fullscreen - { - mwmhints.flags=MWM_HINTS_DECORATIONS; - mwmhints.functions=0; - mwmhints.decorations=0; - mwmhints.input_mode=0; - mwmatom=XInternAtom(display,"_MOTIF_WM_HINTS",0); - XChangeProperty(display,window,mwmatom,mwmatom,32, - PropModeReplace,(unsigned char *)&mwmhints,5); - - XResizeWindow(display,window,screen->width,screen->height); - - hints.min_width = hints.max_width = hints.base_width = screen->width; - hints.min_height= hints.max_height = hints.base_height = screen->height; - - XSetWMNormalHints(display,window,&hints); - - { - XEvent xev; - - memset(&xev, 0, sizeof(xev)); - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = 1; - xev.xclient.message_type = XInternAtom(display, "_NET_WM_STATE", 0); - xev.xclient.window = window; - xev.xclient.format = 32; - xev.xclient.data.l[0] = 1; - xev.xclient.data.l[1] = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", 0); - xev.xclient.data.l[2] = 0; - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; - - XSendEvent(display, root_window_id, 0, - SubstructureRedirectMask | SubstructureNotifyMask, &xev); - } - } else { - { - XEvent xev; - - memset(&xev, 0, sizeof(xev)); - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = 1; - xev.xclient.message_type = XInternAtom(display, "_NET_WM_STATE", 0); - xev.xclient.window = window; - xev.xclient.format = 32; - xev.xclient.data.l[0] = 0; - xev.xclient.data.l[1] = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", 0); - xev.xclient.data.l[2] = 0; - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; - - XSendEvent(display, root_window_id, 0, - SubstructureRedirectMask | SubstructureNotifyMask, &xev); - } - - mwmhints.flags=MWM_HINTS_DECORATIONS; - mwmhints.functions=0; - mwmhints.decorations=1; - mwmhints.input_mode=0; - mwmatom=XInternAtom(display,"_MOTIF_WM_HINTS",0); - - //This shouldn't work on 64 bit longs, but it does...in fact, it breaks when I change all the mwmhints to int. - //I don't pretend to understand it. - XChangeProperty(display,window,mwmatom,mwmatom,32, - PropModeReplace,(unsigned char *)&mwmhints,5); - - hints.flags=USPosition|USSize; - hints.base_width = iResX; - hints.base_height = iResY; - XSetWMNormalHints(display,window,&hints); - - XResizeWindow(display,window,iResX,iResY); -} - - DoClearScreenBuffer(); - - bChangeWinMode=FALSE; - bDoVSyncUpdate=TRUE; -} - -#endif +#if defined(_WINDOWS) + +void ChangeWindowMode(void) // TOGGLE FULLSCREEN - WINDOW +{ + GPUclose(); + iWindowMode=!iWindowMode; + GPUopen(hWGPU); + bChangeWinMode=FALSE; + bDoVSyncUpdate=TRUE; +} + +#elif !defined (_MACGL) + +#include "draw.h" + +void ChangeWindowMode(void) // TOGGLE FULLSCREEN - WINDOW +{ + extern Display *display; + extern Window window; + extern int root_window_id; + Screen *screen; + XSizeHints hints; + MotifWmHints mwmhints; + Atom mwmatom; + + screen=DefaultScreenOfDisplay(display); + iWindowMode=!iWindowMode; + + if(!iWindowMode) // fullscreen + { + mwmhints.flags=MWM_HINTS_DECORATIONS; + mwmhints.functions=0; + mwmhints.decorations=0; + mwmhints.input_mode=0; + mwmatom=XInternAtom(display,"_MOTIF_WM_HINTS",0); + XChangeProperty(display,window,mwmatom,mwmatom,32, + PropModeReplace,(unsigned char *)&mwmhints,5); + + XResizeWindow(display,window,screen->width,screen->height); + + hints.min_width = hints.max_width = hints.base_width = screen->width; + hints.min_height= hints.max_height = hints.base_height = screen->height; + + XSetWMNormalHints(display,window,&hints); + + { + XEvent xev; + + memset(&xev, 0, sizeof(xev)); + xev.xclient.type = ClientMessage; + xev.xclient.serial = 0; + xev.xclient.send_event = 1; + xev.xclient.message_type = XInternAtom(display, "_NET_WM_STATE", 0); + xev.xclient.window = window; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 1; + xev.xclient.data.l[1] = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", 0); + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 0; + xev.xclient.data.l[4] = 0; + + XSendEvent(display, root_window_id, 0, + SubstructureRedirectMask | SubstructureNotifyMask, &xev); + } + } else { + { + XEvent xev; + + memset(&xev, 0, sizeof(xev)); + xev.xclient.type = ClientMessage; + xev.xclient.serial = 0; + xev.xclient.send_event = 1; + xev.xclient.message_type = XInternAtom(display, "_NET_WM_STATE", 0); + xev.xclient.window = window; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 0; + xev.xclient.data.l[1] = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", 0); + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 0; + xev.xclient.data.l[4] = 0; + + XSendEvent(display, root_window_id, 0, + SubstructureRedirectMask | SubstructureNotifyMask, &xev); + } + + mwmhints.flags=MWM_HINTS_DECORATIONS; + mwmhints.functions=0; + mwmhints.decorations=1; + mwmhints.input_mode=0; + mwmatom=XInternAtom(display,"_MOTIF_WM_HINTS",0); + + //This shouldn't work on 64 bit longs, but it does...in fact, it breaks when I change all the mwmhints to int. + //I don't pretend to understand it. + XChangeProperty(display,window,mwmatom,mwmatom,32, + PropModeReplace,(unsigned char *)&mwmhints,5); + + hints.flags=USPosition|USSize; + hints.base_width = iResX; + hints.base_height = iResY; + XSetWMNormalHints(display,window,&hints); + + XResizeWindow(display,window,iResX,iResY); +} + + DoClearScreenBuffer(); + + bChangeWinMode=FALSE; + bDoVSyncUpdate=TRUE; +} + +#endif //////////////////////////////////////////////////////////////////////// // gun cursor func: player=0-7, x=0-511, y=0-255 @@ -912,14 +914,15 @@ void CALLBACK GPUcursor(int iPlayer,int x,int y) void CALLBACK GPUupdateLace(void) // VSYNC { - if(!(dwActFixes&1)) - lGPUstatusRet^=0x80000000; // odd/even bit + //if(!(dwActFixes&1)) + //lGPUstatusRet^=0x80000000; // odd/even bit if(!(dwActFixes&32)) // std fps limitation? CheckFrameRate(); if(PSXDisplay.Interlaced) // interlaced mode? { + lGPUstatusRet^=0x80000000; if(bDoVSyncUpdate && PSXDisplay.DisplayMode.x>0 && PSXDisplay.DisplayMode.y>0) { updateDisplay(); @@ -938,17 +941,17 @@ void CALLBACK GPUupdateLace(void) // VSYNC if(bDoVSyncUpdate && !UseFrameSkip) // some primitives drawn? updateDisplay(); // -> update display } - } - -#ifdef _WINDOWS - if(RECORD_RECORDING) - if(RECORD_WriteFrame()==FALSE) - {RECORD_RECORDING=FALSE;RECORD_Stop();} -#endif + } + +#ifdef _WINDOWS + if(RECORD_RECORDING) + if(RECORD_WriteFrame()==FALSE) + {RECORD_RECORDING=FALSE;RECORD_Stop();} +#endif #ifndef _MACGL if(bChangeWinMode) ChangeWindowMode(); // toggle full - window mode -#endif +#endif bDoVSyncUpdate=FALSE; // vsync done } @@ -985,7 +988,7 @@ uint32_t CALLBACK GPUreadStatus(void) // READ STATUS GPUIsReadyForCommands; } } - return lGPUstatusRet; + return lGPUstatusRet | (vBlank ? 0x80000000 : 0 ); } //////////////////////////////////////////////////////////////////////// @@ -1585,13 +1588,13 @@ long CALLBACK GPUgetMode(void) long CALLBACK GPUconfigure(void) { -#ifdef _WINDOWS - HWND hWP=GetActiveWindow(); - - DialogBox(hInst,MAKEINTRESOURCE(IDD_CFGSOFT), - hWP,(DLGPROC)SoftDlgProc); -#else - SoftDlgProc(); +#ifdef _WINDOWS + HWND hWP=GetActiveWindow(); + + DialogBox(hInst,MAKEINTRESOURCE(IDD_CFGSOFT), + hWP,(DLGPROC)SoftDlgProc); +#else + SoftDlgProc(); #endif return 0; @@ -1602,17 +1605,17 @@ long CALLBACK GPUconfigure(void) //////////////////////////////////////////////////////////////////////// void SetFixes(void) - { -#ifdef _WINDOWS - BOOL bOldPerformanceCounter=IsPerformanceCounter; // store curr timer mode - - if(dwActFixes&0x10) // check fix 0x10 - IsPerformanceCounter=FALSE; - else SetFPSHandler(); - - if(bOldPerformanceCounter!=IsPerformanceCounter) // we have change it? - InitFPS(); // -> init fps again -#endif + { +#ifdef _WINDOWS + BOOL bOldPerformanceCounter=IsPerformanceCounter; // store curr timer mode + + if(dwActFixes&0x10) // check fix 0x10 + IsPerformanceCounter=FALSE; + else SetFPSHandler(); + + if(bOldPerformanceCounter!=IsPerformanceCounter) // we have change it? + InitFPS(); // -> init fps again +#endif if(dwActFixes&0x02) sDispWidths[4]=384; else sDispWidths[4]=368; @@ -1672,33 +1675,33 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) // show about dlg //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_COMMAND: - { - switch(LOWORD(wParam)) - {case IDOK: EndDialog(hW,TRUE);return TRUE;} - } - } - return FALSE; -} -#endif - -void CALLBACK GPUabout(void) // ABOUT -{ -#ifdef _WINDOWS - HWND hWP=GetActiveWindow(); // to be sure - DialogBox(hInst,MAKEINTRESOURCE(IDD_ABOUT), - hWP,(DLGPROC)AboutDlgProc); -#else - AboutDlgProc(); -#endif - - return; -} +#ifdef _WINDOWS +BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_COMMAND: + { + switch(LOWORD(wParam)) + {case IDOK: EndDialog(hW,TRUE);return TRUE;} + } + } + return FALSE; +} +#endif + +void CALLBACK GPUabout(void) // ABOUT +{ +#ifdef _WINDOWS + HWND hWP=GetActiveWindow(); // to be sure + DialogBox(hInst,MAKEINTRESOURCE(IDD_ABOUT), + hWP,(DLGPROC)AboutDlgProc); +#else + AboutDlgProc(); +#endif + + return; +} //////////////////////////////////////////////////////////////////////// // We are ever fine ;) @@ -2031,150 +2034,150 @@ void PaintPicDot(unsigned char * p,unsigned char c) // Beware: the func can be called at any time, // so you have to use the frontbuffer to get a fully // rendered picture - -#ifdef _WINDOWS - -void CALLBACK GPUgetScreenPic(unsigned char * pMem) -{ - HRESULT ddrval;DDSURFACEDESC xddsd;unsigned char * pf; - int x,y,c,v;RECT r; - float XS,YS; - - memset(&xddsd, 0, sizeof(DDSURFACEDESC)); - xddsd.dwSize = sizeof(DDSURFACEDESC); - xddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT; - xddsd.dwWidth = iResX; - xddsd.dwHeight = iResY; - - r.left=0; r.right =iResX; - r.top=0; r.bottom=iResY; - - if(iWindowMode) - { - POINT Point={0,0}; - ClientToScreen(DX.hWnd,&Point); - r.left+=Point.x;r.right+=Point.x; - r.top+=Point.y;r.bottom+=Point.y; - } - - XS=(float)iResX/128; - YS=(float)iResY/96; - - ddrval=IDirectDrawSurface_Lock(DX.DDSPrimary,NULL, &xddsd, DDLOCK_WAIT|DDLOCK_READONLY, NULL); - - if(ddrval==DDERR_SURFACELOST) IDirectDrawSurface_Restore(DX.DDSPrimary); - - pf=pMem; - - if(ddrval==DD_OK) - { - unsigned char * ps=(unsigned char *)xddsd.lpSurface; - - if(iDesktopCol==16) - { - unsigned short sx; - for(y=0;y<96;y++) - { - for(x=0;x<128;x++) - { - sx=*((unsigned short *)((ps)+ - r.top*xddsd.lPitch+ - (((int)((float)y*YS))*xddsd.lPitch)+ - r.left*2+ - ((int)((float)x*XS))*2)); - *(pf+0)=(sx&0x1f)<<3; - *(pf+1)=(sx&0x7e0)>>3; - *(pf+2)=(sx&0xf800)>>8; - pf+=3; - } - } - } - else - if(iDesktopCol==15) - { - unsigned short sx; - for(y=0;y<96;y++) - { - for(x=0;x<128;x++) - { - sx=*((unsigned short *)((ps)+ - r.top*xddsd.lPitch+ - (((int)((float)y*YS))*xddsd.lPitch)+ - r.left*2+ - ((int)((float)x*XS))*2)); - *(pf+0)=(sx&0x1f)<<3; - *(pf+1)=(sx&0x3e0)>>2; - *(pf+2)=(sx&0x7c00)>>7; - pf+=3; - } - } - } - else - { - unsigned long sx; - for(y=0;y<96;y++) - { - for(x=0;x<128;x++) - { - sx=*((unsigned long *)((ps)+ - r.top*xddsd.lPitch+ - (((int)((float)y*YS))*xddsd.lPitch)+ - r.left*4+ - ((int)((float)x*XS))*4)); - *(pf+0)=(unsigned char)((sx&0xff)); - *(pf+1)=(unsigned char)((sx&0xff00)>>8); - *(pf+2)=(unsigned char)((sx&0xff0000)>>16); - pf+=3; - } - } - } - } - - IDirectDrawSurface_Unlock(DX.DDSPrimary,&xddsd); - - ///////////////////////////////////////////////////////////////////// - // generic number/border painter - - pf=pMem+(103*3); // offset to number rect - - for(y=0;y<20;y++) // loop the number rect pixel - { - for(x=0;x<6;x++) - { - c=cFont[lSelectedSlot][x+y*6]; // get 4 char dot infos at once (number depends on selected slot) - v=(c&0xc0)>>6; - PaintPicDot(pf,(unsigned char)v);pf+=3; // paint the dots into the rect - v=(c&0x30)>>4; - PaintPicDot(pf,(unsigned char)v);pf+=3; - v=(c&0x0c)>>2; - PaintPicDot(pf,(unsigned char)v);pf+=3; - v=c&0x03; - PaintPicDot(pf,(unsigned char)v);pf+=3; - } - pf+=104*3; // next rect y line - } - - pf=pMem; // ptr to first pos in 128x96 pic - for(x=0;x<128;x++) // loop top/bottom line - { - *(pf+(95*128*3))=0x00;*pf++=0x00; - *(pf+(95*128*3))=0x00;*pf++=0x00; // paint it red - *(pf+(95*128*3))=0xff;*pf++=0xff; - } - pf=pMem; // ptr to first pos - for(y=0;y<96;y++) // loop left/right line - { - *(pf+(127*3))=0x00;*pf++=0x00; - *(pf+(127*3))=0x00;*pf++=0x00; // paint it red - *(pf+(127*3))=0xff;*pf++=0xff; - pf+=127*3; // offset to next line - } -} - -#else - -// LINUX version: - + +#ifdef _WINDOWS + +void CALLBACK GPUgetScreenPic(unsigned char * pMem) +{ + HRESULT ddrval;DDSURFACEDESC xddsd;unsigned char * pf; + int x,y,c,v;RECT r; + float XS,YS; + + memset(&xddsd, 0, sizeof(DDSURFACEDESC)); + xddsd.dwSize = sizeof(DDSURFACEDESC); + xddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT; + xddsd.dwWidth = iResX; + xddsd.dwHeight = iResY; + + r.left=0; r.right =iResX; + r.top=0; r.bottom=iResY; + + if(iWindowMode) + { + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + r.left+=Point.x;r.right+=Point.x; + r.top+=Point.y;r.bottom+=Point.y; + } + + XS=(float)iResX/128; + YS=(float)iResY/96; + + ddrval=IDirectDrawSurface_Lock(DX.DDSPrimary,NULL, &xddsd, DDLOCK_WAIT|DDLOCK_READONLY, NULL); + + if(ddrval==DDERR_SURFACELOST) IDirectDrawSurface_Restore(DX.DDSPrimary); + + pf=pMem; + + if(ddrval==DD_OK) + { + unsigned char * ps=(unsigned char *)xddsd.lpSurface; + + if(iDesktopCol==16) + { + unsigned short sx; + for(y=0;y<96;y++) + { + for(x=0;x<128;x++) + { + sx=*((unsigned short *)((ps)+ + r.top*xddsd.lPitch+ + (((int)((float)y*YS))*xddsd.lPitch)+ + r.left*2+ + ((int)((float)x*XS))*2)); + *(pf+0)=(sx&0x1f)<<3; + *(pf+1)=(sx&0x7e0)>>3; + *(pf+2)=(sx&0xf800)>>8; + pf+=3; + } + } + } + else + if(iDesktopCol==15) + { + unsigned short sx; + for(y=0;y<96;y++) + { + for(x=0;x<128;x++) + { + sx=*((unsigned short *)((ps)+ + r.top*xddsd.lPitch+ + (((int)((float)y*YS))*xddsd.lPitch)+ + r.left*2+ + ((int)((float)x*XS))*2)); + *(pf+0)=(sx&0x1f)<<3; + *(pf+1)=(sx&0x3e0)>>2; + *(pf+2)=(sx&0x7c00)>>7; + pf+=3; + } + } + } + else + { + unsigned long sx; + for(y=0;y<96;y++) + { + for(x=0;x<128;x++) + { + sx=*((unsigned long *)((ps)+ + r.top*xddsd.lPitch+ + (((int)((float)y*YS))*xddsd.lPitch)+ + r.left*4+ + ((int)((float)x*XS))*4)); + *(pf+0)=(unsigned char)((sx&0xff)); + *(pf+1)=(unsigned char)((sx&0xff00)>>8); + *(pf+2)=(unsigned char)((sx&0xff0000)>>16); + pf+=3; + } + } + } + } + + IDirectDrawSurface_Unlock(DX.DDSPrimary,&xddsd); + + ///////////////////////////////////////////////////////////////////// + // generic number/border painter + + pf=pMem+(103*3); // offset to number rect + + for(y=0;y<20;y++) // loop the number rect pixel + { + for(x=0;x<6;x++) + { + c=cFont[lSelectedSlot][x+y*6]; // get 4 char dot infos at once (number depends on selected slot) + v=(c&0xc0)>>6; + PaintPicDot(pf,(unsigned char)v);pf+=3; // paint the dots into the rect + v=(c&0x30)>>4; + PaintPicDot(pf,(unsigned char)v);pf+=3; + v=(c&0x0c)>>2; + PaintPicDot(pf,(unsigned char)v);pf+=3; + v=c&0x03; + PaintPicDot(pf,(unsigned char)v);pf+=3; + } + pf+=104*3; // next rect y line + } + + pf=pMem; // ptr to first pos in 128x96 pic + for(x=0;x<128;x++) // loop top/bottom line + { + *(pf+(95*128*3))=0x00;*pf++=0x00; + *(pf+(95*128*3))=0x00;*pf++=0x00; // paint it red + *(pf+(95*128*3))=0xff;*pf++=0xff; + } + pf=pMem; // ptr to first pos + for(y=0;y<96;y++) // loop left/right line + { + *(pf+(127*3))=0x00;*pf++=0x00; + *(pf+(127*3))=0x00;*pf++=0x00; // paint it red + *(pf+(127*3))=0xff;*pf++=0xff; + pf+=127*3; // offset to next line + } +} + +#else + +// LINUX version: + extern char * Xpixels; void GPUgetScreenPic(unsigned char * pMem) @@ -2248,7 +2251,7 @@ void GPUgetScreenPic(unsigned char * pMem) */ } -#endif +#endif //////////////////////////////////////////////////////////////////////// // func will be called with 128x96x3 BGR data. @@ -2269,3 +2272,8 @@ void CALLBACK GPUsetfix(uint32_t dwFixBits) { dwEmuFixes=dwFixBits; } + +void CALLBACK GPUvBlank( int val ) +{ + vBlank = val; +} diff --git a/plugins/peopsxgl/externals.h b/plugins/peopsxgl/externals.h index a2775fe9..02b1fdf1 100644 --- a/plugins/peopsxgl/externals.h +++ b/plugins/peopsxgl/externals.h @@ -383,6 +383,7 @@ extern uint32_t ulGPUInfoVals[]; extern BOOL bNeedInterlaceUpdate; extern BOOL bNeedWriteUpload; extern BOOL bSkipNextFrame; +extern uint32_t vBlank; extern int bFullScreen; diff --git a/plugins/peopsxgl/gpu.c b/plugins/peopsxgl/gpu.c index bde3f4a4..91a10b2c 100644 --- a/plugins/peopsxgl/gpu.c +++ b/plugins/peopsxgl/gpu.c @@ -152,6 +152,7 @@ uint32_t ulGPUInfoVals[16]; int iFakePrimBusy = 0; int iRumbleVal = 0; int iRumbleTime = 0; +uint32_t vBlank=0; //////////////////////////////////////////////////////////////////////// // stuff to make this a true PDK module @@ -548,6 +549,7 @@ long CALLBACK GPUinit() // device initialised already ! //lGPUstatusRet = 0x74000000; + vBlank = 0; STATUSREG = 0x14802000; GPUIsIdle; @@ -972,28 +974,28 @@ void sysdep_create_display(void) // create display XResizeWindow(display,window,screen->width,screen->height); hints.min_width = hints.max_width = hints.base_width = screen->width; hints.min_height= hints.max_height = hints.base_height = screen->height; - XSetWMNormalHints(display,window,&hints); - - // set the window layer for GNOME - { - XEvent xev; - - memset(&xev, 0, sizeof(xev)); - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = 1; - xev.xclient.message_type = XInternAtom(display, "_NET_WM_STATE", 0); - xev.xclient.window = window; - xev.xclient.format = 32; - xev.xclient.data.l[0] = 1; - xev.xclient.data.l[1] = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", 0); - xev.xclient.data.l[2] = 0; - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; - - XSendEvent(display, RootWindow(display, DefaultScreen(display)), 0, - SubstructureRedirectMask | SubstructureNotifyMask, &xev); - } + XSetWMNormalHints(display,window,&hints); + + // set the window layer for GNOME + { + XEvent xev; + + memset(&xev, 0, sizeof(xev)); + xev.xclient.type = ClientMessage; + xev.xclient.serial = 0; + xev.xclient.send_event = 1; + xev.xclient.message_type = XInternAtom(display, "_NET_WM_STATE", 0); + xev.xclient.window = window; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 1; + xev.xclient.data.l[1] = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", 0); + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 0; + xev.xclient.data.l[4] = 0; + + XSendEvent(display, RootWindow(display, DefaultScreen(display)), 0, + SubstructureRedirectMask | SubstructureNotifyMask, &xev); + } } } @@ -1934,8 +1936,8 @@ static unsigned short usFirstPos=2; void CALLBACK GPUupdateLace(void) { - if(!(dwActFixes&0x1000)) - STATUSREG^=0x80000000; // interlaced bit toggle, if the CC game fix is not active (see gpuReadStatus) + //if(!(dwActFixes&0x1000)) + // STATUSREG^=0x80000000; // interlaced bit toggle, if the CC game fix is not active (see gpuReadStatus) if(!(dwActFixes&128)) // normal frame limit func CheckFrameRate(); @@ -1947,6 +1949,7 @@ void CALLBACK GPUupdateLace(void) if(PSXDisplay.Interlaced) // interlaced mode? { + STATUSREG^=0x80000000; if(PSXDisplay.DisplayMode.x>0 && PSXDisplay.DisplayMode.y>0) { updateDisplay(); // -> swap buffers (new frame) @@ -1998,7 +2001,7 @@ uint32_t CALLBACK GPUreadStatus(void) } } - return STATUSREG; + return STATUSREG | (vBlank ? 0x80000000 : 0 );; } //////////////////////////////////////////////////////////////////////// @@ -3479,3 +3482,8 @@ void CALLBACK GPUdisplayFlags(uint32_t dwFlags) { dwCoreFlags=dwFlags; } + +void CALLBACK GPUvBlank( int val ) +{ + vBlank = val; +} -- cgit v1.2.3