diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-08-13 01:32:56 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-08-13 01:32:56 +0000 |
| commit | c6191a4474b4cab60cc9886860c8b6de7c4e146b (patch) | |
| tree | 7b450e4d69ec922805cf2448af9cc53286f17d73 | |
| parent | 7d0cd28dd85965b4f94c8eeb5aa2c70297122485 (diff) | |
| download | pcsxr-c6191a4474b4cab60cc9886860c8b6de7c4e146b.tar.gz | |
dfxvideo: Readded windows support.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@56047 e17a0e51-4ae3-4d35-97c3-1a29b211df97
25 files changed, 8773 insertions, 195 deletions
@@ -1,3 +1,20 @@ +August 13, 2010 Wei Mingzhi <whistler_wmz@users.sf.net>
+
+ * plugins/dfxvideo/cfg.h: Readded Windows support.
+ * plugins/dfxvideo/externals.h: Likewise.
+ * plugins/dfxvideo/gpu.c: Likewise.
+ * plugins/dfxvideo/interp.h: Likewise.
+ * plugins/dfxvideo/menu.c: Likewise.
+ * plugins/dfxvideo/prim.c: Likewise.
+ * plugins/dfxvideo/soft.c: Likewise.
+ * plugins/dfxvideo/zn.c: Likewise.
+ * win32/plugins/dfxvideo: Added.
+ * win32/gui/plugin.c: Disable the menu item of savestate slots
+ which cannot be loaded from.
+ * win32/gui/Win32.h: Likewise.
+ * win32/gui/WndMain.c: Likewise.
+ * win32/plugins/dfsound/winsrc/cfg.c: Changed registry entry.
+
August 12, 2010 Wei Mingzhi <whistler_wmz@users.sf.net>
* plugins/dfsound/cfg.h: Readded Windows support.
diff --git a/plugins/dfxvideo/cfg.h b/plugins/dfxvideo/cfg.h index fa259f30..a58a3de2 100644 --- a/plugins/dfxvideo/cfg.h +++ b/plugins/dfxvideo/cfg.h @@ -22,7 +22,11 @@ void ReadConfig(void); void WriteConfig(void); void ReadWinSizeConfig(void); -void SoftDlgProc(void); -void AboutDlgProc(void); +#ifdef _WINDOWS
+BOOL CALLBACK SoftDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
+#else
+void SoftDlgProc(void);
+void AboutDlgProc(void);
+#endif -#endif // _GPU_CFG_H_ +#endif diff --git a/plugins/dfxvideo/externals.h b/plugins/dfxvideo/externals.h index 2c29faf2..35fe0eff 100644 --- a/plugins/dfxvideo/externals.h +++ b/plugins/dfxvideo/externals.h @@ -51,6 +51,33 @@ #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
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <windows.h>
+#include <windowsx.h>
+#include <tchar.h>
+#include "resource.h"
+
+#include "ddraw.h"
+#include "d3dtypes.h"
+#include "d3d.h"
+
+#pragma warning (disable:864)
+
+#else
#define __X11_C_ //X11 render @@ -68,6 +95,8 @@ #include <math.h> #include <X11/cursorfont.h> #include <stdint.h> +
+#endif
///////////////////////////////////////////////////////////////////////////// @@ -103,6 +132,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
// linux defines for some windows stuff @@ -122,9 +166,9 @@ typedef struct RECTTAG int top; int right; int bottom; -}RECT; - +} RECT; +#endif ///////////////////////////////////////////////////////////////////////////// @@ -155,13 +199,26 @@ typedef struct PSXDISPLAYTAG } PSXDisplay_t; -///////////////////////////////////////////////////////////////////////////// +#ifdef _WINDOWS
+extern HINSTANCE hInst;
+#endif
+/////////////////////////////////////////////////////////////////////////////
+
// draw.c #ifndef _IN_DRAW -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; extern int iResY; @@ -179,7 +236,10 @@ extern short g_m1; extern short g_m2; extern short g_m3; extern short DrawSemiTrans; -extern int iUseGammaVal; +extern int iUseGammaVal;
+#ifdef _WINDOWS
+extern int iUseScanLines;
+#endif extern int iMaintainAspect; extern int iDesktopCol; extern int iUseNoStretchBlt; @@ -188,8 +248,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
#endif @@ -261,6 +324,12 @@ extern uint32_t ulStatusControl[]; #ifndef _IN_MENU extern uint32_t dwCoreFlags; +
+#ifdef _WINDOWS
+extern HFONT hGFont;
+extern int iMPos;
+extern BOOL bTransparent;
+#endif
#endif @@ -268,8 +337,12 @@ extern uint32_t dwCoreFlags; #ifndef _IN_KEY -extern unsigned long ulKeybits; +extern unsigned long ulKeybits;
+#ifdef _WINDOWS
+extern char szGPUKeys[];
+#endif +
#endif // fps.c @@ -283,6 +356,10 @@ extern int iFrameLimit; extern float fFrameRateHz; extern float fps_skip; extern float fps_cur; +#ifdef _WINDOWS
+extern BOOL IsPerformanceCounter;
+extern int iStopSaver;
+#endif
#endif @@ -311,5 +388,3 @@ extern int GlobalTextIL; extern int iTileCheat; #endif - - diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c index 7dd359ff..1bb2ad63 100644 --- a/plugins/dfxvideo/gpu.c +++ b/plugins/dfxvideo/gpu.c @@ -18,7 +18,7 @@ #ifndef _MACGL #include "config.h" #endif - +
#define _IN_GPU #include "externals.h" @@ -42,6 +42,11 @@ #define _(x) (x) #define N_(x) (x) #endif +
+#ifdef _WINDOWS
+#include "resource.h"
+#include "record.h"
+#endif
//////////////////////////////////////////////////////////////////////// // PPDK developer must change libraryName field and can change revision and build @@ -50,8 +55,11 @@ 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 - -#ifdef _MACGL +
+#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");
+#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"); #else @@ -107,6 +115,65 @@ 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
//////////////////////////////////////////////////////////////////////// // some misc external display funcs @@ -159,7 +226,7 @@ char * GPUgetLibInfos(void) // Snapshot func //////////////////////////////////////////////////////////////////////// -static char * pGetConfigInfos(int iCfg) +char * pGetConfigInfos(int iCfg) { char szO[2][4]={"off","on "}; char szTxt[256]; @@ -203,7 +270,7 @@ static char * pGetConfigInfos(int iCfg) else sprintf(szTxt,"- FPS limit: %.1f\r\n\r\n",fFrameRate); strcat(pB,szTxt); //----------------------------------------------------// -#ifndef _MACGL +#if !defined (_MACGL) && !defined (_WINDOWS) strcpy(szTxt,"Misc:\r\n- MaintainAspect: "); if(iMaintainAspect == 0) strcat(szTxt,"disabled"); else @@ -222,8 +289,12 @@ static void DoTextSnapShot(int iNum) FILE *txtfile; char szTxt[256]; char *pB; - - 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) return; @@ -280,8 +351,12 @@ void CALLBACK GPUmakeSnapshot(void) // increment snapshot value & try to get filename do { - snapshotnr++; - 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"); if (bmpfile == NULL) @@ -383,7 +458,10 @@ long CALLBACK GPUinit() // GPU INIT lGPUstatusRet = 0x14802000; GPUIsIdle; GPUIsReadyForCommands; - bDoVSyncUpdate = TRUE; + bDoVSyncUpdate = TRUE;
+ + // Get a handle for kernel32.dll, and access the required export function
+ LoadKernel32();
return 0; } @@ -391,7 +469,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
long GPUopen(unsigned long * disp,char * CapText,char * CfgFile) { @@ -415,7 +520,8 @@ long GPUopen(unsigned long * disp,char * CapText,char * CfgFile) if(d) return 0; return -1; } - +
+#endif //////////////////////////////////////////////////////////////////////// // time to leave... @@ -423,10 +529,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
ReleaseKeyHandler(); // de-subclass window CloseDisplay(); // shutdown direct draw +
+#ifdef _WINDOWS
+ if(iStopSaver)
+ D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED);
+#endif
return 0; } @@ -436,7 +550,10 @@ long CALLBACK GPUclose() // GPU CLOSE //////////////////////////////////////////////////////////////////////// long CALLBACK GPUshutdown() // GPU SHUTDOWN -{ +{
+ // screensaver: release the handle for kernel32.dll
+ FreeKernel32();
+ free(psxVSecure); return 0; // nothinh to do @@ -538,18 +655,19 @@ 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 } - +#ifndef _WINDOWS // some linux alignment security PreviousPSXDisplay.Range.x0=PreviousPSXDisplay.Range.x0>>1; PreviousPSXDisplay.Range.x0=PreviousPSXDisplay.Range.x0<<1; PreviousPSXDisplay.Range.x1=PreviousPSXDisplay.Range.x1>>1; PreviousPSXDisplay.Range.x1=PreviousPSXDisplay.Range.x1<<1; - +#endif DoClearScreenBuffer(); } @@ -656,106 +774,117 @@ void updateDisplayIfChanged(void) // UPDATE DISPLAY IF CHAN //////////////////////////////////////////////////////////////////////// -#ifndef _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;
+}
+
+#else !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 @@ -809,10 +938,18 @@ 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
+ #ifndef _MACGL if(bChangeWinMode) ChangeWindowMode(); // toggle full - window mode -#endif +#endif
+ bDoVSyncUpdate=FALSE; // vsync done } @@ -1403,7 +1540,8 @@ ENDVRAM: gpuDataC=gpuDataP=0; primFunc[gpuCommand]((unsigned char *)gpuDataM); if(dwEmuFixes&0x0001 || dwActFixes&0x0400) // hack for emulating "gpu busy" in some games - iFakePrimBusy=4;
} + iFakePrimBusy=4; + } } } @@ -1447,7 +1585,14 @@ long CALLBACK GPUgetMode(void) long CALLBACK GPUconfigure(void) { - SoftDlgProc(); +#ifdef _WINDOWS
+ HWND hWP=GetActiveWindow();
+
+ DialogBox(hInst,MAKEINTRESOURCE(IDD_CFGSOFT),
+ hWP,(DLGPROC)SoftDlgProc);
+#else
+ SoftDlgProc();
+#endif return 0; } @@ -1457,7 +1602,18 @@ 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
+ if(dwActFixes&0x02) sDispWidths[4]=384; else sDispWidths[4]=368; } @@ -1516,12 +1672,33 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) // show about dlg //////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUabout(void) // ABOUT -{ - AboutDlgProc(); - 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 ;) @@ -1854,9 +2031,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 - -// 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) @@ -1930,6 +2248,7 @@ void GPUgetScreenPic(unsigned char * pMem) */ } +#endif
//////////////////////////////////////////////////////////////////////// // func will be called with 128x96x3 BGR data. diff --git a/plugins/dfxvideo/interp.h b/plugins/dfxvideo/interp.h index 30432371..e4ae0e36 100644 --- a/plugins/dfxvideo/interp.h +++ b/plugins/dfxvideo/interp.h @@ -209,7 +209,7 @@ static __inline unsigned int interp_32_97(unsigned int p1, unsigned int p2) #define INTERP_U_LIMIT (0x07*4) #define INTERP_V_LIMIT (0x06*8) -inline static int interp_16_diff(unsigned short p1, unsigned short p2) +__inline static int interp_16_diff(unsigned short p1, unsigned short p2) { int r, g, b; int y, u, v; @@ -243,7 +243,7 @@ inline static int interp_16_diff(unsigned short p1, unsigned short p2) return 0; } -inline static int interp_32_diff(unsigned int p1, unsigned int p2) +__inline static int interp_32_diff(unsigned int p1, unsigned int p2) { int r, g, b; int y, u, v; @@ -271,8 +271,6 @@ inline static int interp_32_diff(unsigned int p1, unsigned int p2) return 0; } -#if 0 - static void interp_set(unsigned bits_per_pixel) { interp_bits_per_pixel = bits_per_pixel; @@ -294,5 +292,3 @@ static void interp_set(unsigned bits_per_pixel) } #endif - -#endif diff --git a/plugins/dfxvideo/menu.c b/plugins/dfxvideo/menu.c index 33d111d9..57ff2201 100644 --- a/plugins/dfxvideo/menu.c +++ b/plugins/dfxvideo/menu.c @@ -20,19 +20,43 @@ #include "externals.h" #include "draw.h" #include "menu.h" -#include "gpu.h" +#include "gpu.h"
+ +#ifdef _WINDOWS
+
+#include "record.h"
+
+HFONT hGFont=NULL;
+BOOL bTransparent=FALSE;
+
+#endif
unsigned long dwCoreFlags = 0; // create lists/stuff for fonts (actually there are no more lists, but I am too lazy to change the func names ;) void InitMenu(void) -{ +{
+#ifdef _WINDOWS
+ hGFont=CreateFont(//-8,
+ 13,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,
+ ANSI_CHARSET,OUT_DEFAULT_PRECIS,
+ CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
+ DEFAULT_PITCH,
+ //"Courier New");
+ //"MS Sans Serif");
+ "Arial");
+#endif } // kill existing lists/fonts void CloseMenu(void) { - DestroyPic(); +#ifdef _WINDOWS
+ if(hGFont) DeleteObject(hGFont);
+ hGFont=NULL;
+#else
+ DestroyPic();
+#endif } // DISPLAY FPS/MENU TEXT @@ -43,7 +67,33 @@ extern time_t tStart; int iMPos=0; // menu arrow pos void DisplayText(void) // DISPLAY TEXT -{ +{
+#ifdef _WINDOWS
+ HDC hdc;HFONT hFO;
+
+ IDirectDrawSurface_GetDC(DX.DDSRender,&hdc);
+ hFO=(HFONT)SelectObject(hdc,hGFont);
+
+ SetTextColor(hdc,RGB(0,255,0));
+ if(bTransparent)
+ SetBkMode(hdc,TRANSPARENT);
+ else SetBkColor(hdc,RGB(0,0,0));
+
+ if(szDebugText[0] && ((time(NULL) - tStart) < 2)) // special debug text? show it
+ {
+ RECT r={0,0,1024,1024};
+ DrawText(hdc,szDebugText,lstrlen(szDebugText),&r,DT_LEFT|DT_NOCLIP);
+ }
+ else // else standard gpu menu
+ {
+ szDebugText[0]=0;
+ lstrcat(szDispBuf,szMenuBuf);
+ ExtTextOut(hdc,0,0,0,NULL,szDispBuf,lstrlen(szDispBuf),NULL);
+ }
+
+ SelectObject(hdc,hFO);
+ IDirectDrawSurface_ReleaseDC(DX.DDSRender,hdc);
+#endif } // Build Menu buffer (== Dispbuffer without FPS)... @@ -94,11 +144,28 @@ void BuildDispMenu(int iInc) szMenuBuf[24]='0'+(char)((dwCoreFlags&0xf000)>>12); // number } +#ifdef _WINDOWS
+ if(bVsync_Key) szMenuBuf[25] = 'V';
+#endif
if(lSelectedSlot) szMenuBuf[26] = '0'+(char)lSelectedSlot; - szMenuBuf[(iMPos+1)*5]='<'; // set arrow - + szMenuBuf[(iMPos+1)*5]='<'; // set arrow
+ +#ifdef _WINDOWS
+ if(RECORD_RECORDING)
+ {
+ szMenuBuf[27] = ' ';
+ szMenuBuf[28] = ' ';
+ szMenuBuf[29] = ' ';
+ szMenuBuf[30] = 'R';
+ szMenuBuf[31] = 'e';
+ szMenuBuf[32] = 'c';
+ szMenuBuf[33] = 0;
+ }
+
+ if(DX.DDSScreenPic) ShowTextGpuPic();
+#endif } // Some menu action... @@ -111,7 +178,18 @@ void SwitchDispMenu(int iStep) // SWITCH DISP MENU case 0: // frame limit { int iType=0; - bInitCap = TRUE; + bInitCap = TRUE;
+ +#ifdef _WINDOWS
+ if(iFrameLimit==1 && UseFrameLimit &&
+ GetAsyncKeyState(VK_SHIFT)&32768)
+ {
+ fFrameRate+=iStep;
+ if(fFrameRate<3.0f) fFrameRate=3.0f;
+ SetAutoFrameCap();
+ break;
+ }
+#endif
if(UseFrameLimit) iType=iFrameLimit; iType+=iStep; diff --git a/plugins/dfxvideo/prim.c b/plugins/dfxvideo/prim.c index 097f202e..563980ae 100644 --- a/plugins/dfxvideo/prim.c +++ b/plugins/dfxvideo/prim.c @@ -387,9 +387,9 @@ void cmdTexturePage(unsigned char * baseAddr) lGPUstatusRet&=~0x000007ff; lGPUstatusRet|=(gdata & 0x07ff); - - usMirror=gdata&0x3000; - + + usMirror=(unsigned short)(gdata&0x3000); + UpdateGlobalTP((unsigned short)gdata); GlobalTextREST = (gdata&0x00ffffff)>>9; } diff --git a/plugins/dfxvideo/soft.c b/plugins/dfxvideo/soft.c index 21625664..4fdb3ae8 100644 --- a/plugins/dfxvideo/soft.c +++ b/plugins/dfxvideo/soft.c @@ -25,6 +25,11 @@ #include "prim.h" #include "menu.h" #include "swap.h" +
+#ifdef _WINDOWS
+#pragma warning (disable:4244)
+#pragma warning (disable:4761)
+#endif
//////////////////////////////////////////////////////////////////////////////////// // "NO EDGE BUFFER" POLY VERSION... FUNCS BASED ON FATMAP.TXT FROM MRI / Doomsday diff --git a/plugins/dfxvideo/zn.c b/plugins/dfxvideo/zn.c index ea8537b6..534e9674 100644 --- a/plugins/dfxvideo/zn.c +++ b/plugins/dfxvideo/zn.c @@ -23,8 +23,11 @@ // - psx gpu plugin interface prototypes-------------- // // --------------------------------------------------- // -long GPUopen(unsigned long *disp, const char *CapText, const char *CfgFile); - +#ifdef _WINDOWS
+long CALLBACK GPUopen(HWND hwndGPU);
+#else
+long GPUopen(unsigned long * disp,const char * CapText,const char * CfgFile);
+#endif void CALLBACK GPUdisplayText(char * pText); void CALLBACK GPUdisplayFlags(uint32_t dwFlags); void CALLBACK GPUmakeSnapshot(void); @@ -48,9 +51,9 @@ long CALLBACK GPUtest(void); long CALLBACK GPUfreeze(uint32_t ulGetFreezeData,void * pF); void CALLBACK GPUgetScreenPic(unsigned char * pMem); void CALLBACK GPUshowScreenPic(unsigned char * pMem); - -void CALLBACK GPUkeypressed(int keycode); - +#ifndef _WINDOWS
+void CALLBACK GPUkeypressed(int keycode);
+#endif // --------------------------------------------------- // // - zn gpu interface -------------------------------- // @@ -110,10 +113,13 @@ long CALLBACK ZN_GPUopen(void * vcfg) long lret; if(!cfg) return -1; - if(cfg->Version!=1) return -1; + if(cfg->Version!=1) return -1;
+#ifdef _WINDOWS
+ lret=GPUopen((HWND)cfg->hWnd);
+#else lret = GPUopen(&cfg->hWnd, cfg->GameName, cfg->CfgFile); - +#endif /* if(!lstrcmp(cfg->GameName,"kikaioh") || @@ -248,8 +254,11 @@ void CALLBACK ZN_GPUshowScreenPic(unsigned char * pMem) // --------------------------------------------------- // -void CALLBACK ZN_GPUkeypressed(int keycode) -{ - GPUkeypressed(keycode); -} - +#ifndef _WINDOWS
+
+void CALLBACK ZN_GPUkeypressed(int keycode)
+{
+ GPUkeypressed(keycode);
+}
+
+#endif
diff --git a/win32/gui/Win32.h b/win32/gui/Win32.h index 39aa59f3..bfe51543 100644 --- a/win32/gui/Win32.h +++ b/win32/gui/Win32.h @@ -58,7 +58,6 @@ void PADhandleKey(int key); int LoadConfig();
void SaveConfig();
-void UpdateMenuSlots();
void ResetMenuSlots();
void InitLanguages();
diff --git a/win32/gui/WndMain.c b/win32/gui/WndMain.c index 2e1ae141..cee6a11f 100644 --- a/win32/gui/WndMain.c +++ b/win32/gui/WndMain.c @@ -210,26 +210,16 @@ void RestoreWindow() { ShowCursor(TRUE);
}
-int Slots[5] = { -1, -1, -1, -1, -1 };
-
-void ResetMenuSlots() {
- int i;
-
- for (i = 0; i < 5; i++) {
- if (Slots[i] == -1)
- EnableMenuItem(GetSubMenu(gApp.hMenu, 0), ID_FILE_STATES_LOAD_SLOT1+i, MF_GRAYED);
- else
- EnableMenuItem(GetSubMenu(gApp.hMenu, 0), ID_FILE_STATES_LOAD_SLOT1+i, MF_ENABLED);
- }
-}
-
-void UpdateMenuSlots() {
+void ResetMenuSlots() { char str[256];
int i;
- for (i = 0; i < 5; i++) {
- GetStateFilename(str, i);
- Slots[i] = CheckState(str);
+ for (i = 0; i < 9; i++) { + GetStateFilename(str, i); + if (CheckState(str) == -1)
+ EnableMenuItem(gApp.hMenu, ID_FILE_STATES_LOAD_SLOT1+i, MF_GRAYED);
+ else
+ EnableMenuItem(gApp.hMenu, ID_FILE_STATES_LOAD_SLOT1+i, MF_ENABLED);
}
}
@@ -1603,7 +1593,9 @@ void CreateMainMenu() { EnableMenuItem(gApp.hMenu, ID_CONFIGURATION, MF_BYCOMMAND | MF_GRAYED);
if (!UsingIso()) {
EnableMenuItem(gApp.hMenu, ID_EMULATOR_SWITCH_ISO, MF_BYCOMMAND | MF_GRAYED);
- }
+ } + + ResetMenuSlots();
} else {
EnableMenuItem(gApp.hMenu, ID_EMULATOR_RESET, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(gApp.hMenu, ID_EMULATOR_RUN, MF_BYCOMMAND | MF_GRAYED);
@@ -1662,7 +1654,6 @@ void CreateMainWindow(int nCmdShow) { NULL);
gApp.hWnd = hWnd;
- ResetMenuSlots();
CreateMainMenu();
SetMenu(gApp.hWnd, gApp.hMenu);
diff --git a/win32/gui/plugin.c b/win32/gui/plugin.c index 57171a34..b3939028 100644 --- a/win32/gui/plugin.c +++ b/win32/gui/plugin.c @@ -308,8 +308,6 @@ void ClosePlugins() { PAD1_close();
PAD2_close();
- UpdateMenuSlots();
-
ret = CDR_close();
if (ret < 0) { SysMessage (_("Error Closing CDR Plugin")); return; }
ret = GPU_close();
diff --git a/win32/plugins/dfsound/winsrc/cfg.c b/win32/plugins/dfsound/winsrc/cfg.c index 4ac6ee94..1282417a 100644 --- a/win32/plugins/dfsound/winsrc/cfg.c +++ b/win32/plugins/dfsound/winsrc/cfg.c @@ -66,7 +66,7 @@ void ReadConfig(void) iUseInterpolation=2; iDisStereo=0;
- if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SPU\\PeopsSound",0,KEY_ALL_ACCESS,&myKey)==ERROR_SUCCESS) + if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SPU\\DFSound",0,KEY_ALL_ACCESS,&myKey)==ERROR_SUCCESS) { size = 4; if(RegQueryValueEx(myKey,"Volume",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) @@ -114,7 +114,7 @@ void WriteConfig(void) DWORD myDisp; DWORD temp; - RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SPU\\PeopsSound",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&myKey,&myDisp); + RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SPU\\DFSound",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&myKey,&myDisp); temp=iVolume; RegSetValueEx(myKey,"Volume",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iXAPitch; diff --git a/win32/plugins/dfxvideo/DFXVideo.dsp b/win32/plugins/dfxvideo/DFXVideo.dsp new file mode 100644 index 00000000..9289bffb --- /dev/null +++ b/win32/plugins/dfxvideo/DFXVideo.dsp @@ -0,0 +1,219 @@ +# Microsoft Developer Studio Project File - Name="DFXVideo" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=DFXVideo - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "DFXVideo.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "DFXVideo.mak" CFG="DFXVideo - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "DFXVideo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "DFXVideo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "DFXVideo - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /G5 /MD /W3 /GX /O2 /I ".\winsrc" /I "..\.." /I "..\..\glue" /I "..\..\..\libpcsxcore" /I "..\..\..\plugins\dfxvideo" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "__i386__" /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 user32.lib gdi32.lib ddraw.lib dxguid.lib winmm.lib advapi32.lib vfw32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=rem copy release\DFXVideo.dll d:\emus\epsxe\plugins rem copy release\DFXVideo.dll d:\emus\zinc\renderer.znc
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "DFXVideo - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I ".\winsrc" /I "..\..\glue" /I "..\..\..\libpcsxcore" /I "..\..\..\plugins\dfxvideo" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 user32.lib gdi32.lib ddraw.lib dxguid.lib winmm.lib advapi32.lib vfw32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "DFXVideo - Win32 Release"
+# Name "DFXVideo - Win32 Debug"
+# Begin Group "winsrc"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\winsrc\cfg.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\DFXVideo.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\DFXVideo.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\draw.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\fps.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\gpu.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\key.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\record.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\record.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\winsrc\winmain.c
+# End Source File
+# End Group
+# Begin Group "dfxvideo"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\cfg.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\draw.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\externals.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\fps.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\gpu.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\gpu.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\hq2x.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\hq3x.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\interp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\key.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\menu.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\menu.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\prim.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\prim.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\soft.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\soft.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\swap.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\plugins\dfxvideo\zn.c
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/win32/plugins/dfxvideo/winsrc/DFXVideo.def b/win32/plugins/dfxvideo/winsrc/DFXVideo.def new file mode 100644 index 00000000..f5f19c24 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/DFXVideo.def @@ -0,0 +1,57 @@ +; gpuPeopsSoft.def : Declares the module parameters for the DLL. + +LIBRARY "DFXVideo" +DESCRIPTION 'DFXVideo GPU' +EXPORTS + ; Explicit exports can go here + PSEgetLibType @2 + PSEgetLibName @3 + PSEgetLibVersion @4 + GPUinit @5 + GPUshutdown @6 + GPUopen @7 + GPUclose @8 + GPUconfigure @9 + GPUabout @10 + GPUtest @11 + GPUwriteData @12 + GPUwriteStatus @13 + GPUreadData @14 + GPUreadStatus @15 + GPUdmaChain @16 + GPUgetMode @17 + GPUsetMode @18 + GPUupdateLace @19 + GPUmakeSnapshot @20 + GPUwriteDataMem @21 + GPUreadDataMem @22 + GPUdisplayText @23 + GPUdisplayFlags @24 + GPUfreeze @25 + GPUshowScreenPic @26 + GPUgetScreenPic @27 + + GPUcursor @41
+
+ ZN_GPUdisplayFlags @42
+ ZN_GPUmakeSnapshot @43
+ ZN_GPUinit @44
+ ZN_GPUopen @45
+ ZN_GPUclose @46
+ ZN_GPUshutdown @47
+ ZN_GPUupdateLace @48
+ ZN_GPUreadStatus @49
+ ZN_GPUwriteStatus @50
+ ZN_GPUdmaSliceOut @51
+ ZN_GPUreadData @52
+ ZN_GPUsetMode @53
+ ZN_GPUgetMode @54
+ ZN_GPUdmaSliceIn @55
+ ZN_GPUwriteData @56
+ ZN_GPUdmaChain @57
+ ZN_GPUtest @58
+ ZN_GPUfreeze @59
+ ZN_GPUgetScreenPic @61
+ ZN_GPUshowScreenPic @62
+
+ ;GPUdebugSetPC @62
diff --git a/win32/plugins/dfxvideo/winsrc/DFXVideo.rc b/win32/plugins/dfxvideo/winsrc/DFXVideo.rc new file mode 100644 index 00000000..79551832 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/DFXVideo.rc @@ -0,0 +1,556 @@ +//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_GPU BITMAP DISCARDABLE "gpu.bmp"
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+ "#define _AFX_NO_OLE_RESOURCES\r\n"
+ "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+ "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+ "\r\n"
+ "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+ "#ifdef _WIN32\r\n"
+ "LANGUAGE 9, 1\r\n"
+ "#pragma code_page(1252)\r\n"
+ "#endif\r\n"
+ "#endif\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,17,0,0
+ PRODUCTVERSION 1,17,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "\0"
+ VALUE "CompanyName", "\0"
+ VALUE "FileDescription", "Based on P.E.Op.S. gpu soft plugin\0"
+ VALUE "FileVersion", "1, 17, 0, 0\0"
+ VALUE "InternalName", "DFXVideo\0"
+ VALUE "LegalCopyright", "GPL\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "DFXVideo.DLL\0"
+ VALUE "PrivateBuild", "\0"
+ VALUE "ProductName", "DFXVideo\0"
+ VALUE "ProductVersion", "1, 17, 0, 0\0"
+ VALUE "SpecialBuild", "\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_CFGSOFT DIALOGEX 0, 0, 291, 292
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Configure the DirectDraw Renderer..."
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ PUSHBUTTON "Select device...",IDC_SELDEV,7,3,60,12
+ CONTROL "Fullscreen mode",IDC_DISPMODE1,"Button",
+ BS_AUTORADIOBUTTON,10,28,67,10
+ CONTROL "Window mode",IDC_DISPMODE2,"Button",BS_AUTORADIOBUTTON,
+ 10,43,63,10
+ COMBOBOX IDC_RESOLUTION,78,27,102,64,CBS_DROPDOWNLIST | CBS_SORT |
+ WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_COLDEPTH,225,27,52,64,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ EDITTEXT IDC_WINX,103,43,36,12,ES_AUTOHSCROLL
+ EDITTEXT IDC_WINY,151,43,36,12,ES_AUTOHSCROLL
+ COMBOBOX IDC_NOSTRETCH,78,61,199,100,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_DITHER,78,77,199,100,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ CONTROL "Transparent FPS display",IDC_TRANSPARENT,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,107,93,10
+ CONTROL "Show FPS display on startup",IDC_SHOWFPS,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,118,104,10
+ PUSHBUTTON "...",IDC_KEYCONFIG,216,111,11,10,0,WS_EX_STATICEDGE
+ CONTROL "Use FPS limit",IDC_USELIMIT,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,24,130,61,10
+ CONTROL "Use Frame skipping",IDC_USESKIPPING,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,24,141,81,10
+ CONTROL "Auto-detect FPS/Frame skipping limit",IDC_FRAMEAUTO,
+ "Button",BS_AUTORADIOBUTTON | WS_GROUP,143,129,135,11
+ CONTROL "FPS limit (10-200) :",IDC_FRAMEMANUELL,"Button",
+ BS_AUTORADIOBUTTON,143,140,72,11
+ EDITTEXT IDC_FRAMELIM,218,140,28,12,ES_AUTOHSCROLL
+ COMBOBOX IDC_SCANLINES,78,167,199,64,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "Use system memory - slower with most cards, disables auto-screen-filtering",
+ IDC_SYSMEMORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,
+ 184,260,10
+ CONTROL "Wait for VSYNC - synchronize screen update with monitor refresh rate",
+ IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,195,
+ 256,10
+ CONTROL "Stop screen saver - disables screen savers/power-saving (n.a. in W95/NT4!)",
+ IDC_STOPSAVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,
+ 206,263,10
+ CONTROL "Debug mode - enables some debugging features (n.a. with all cards)",
+ IDC_DEBUGMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,
+ 217,263,10
+ CONTROL "Activate special game fixes",IDC_GAMEFIX,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,228,101,10
+ PUSHBUTTON "...",IDC_SELFIX,121,228,11,10,0,WS_EX_STATICEDGE
+ PUSHBUTTON "...",IDC_RECORDING,121,241,11,10,0,WS_EX_STATICEDGE
+ PUSHBUTTON "Fast",IDC_DEF1,10,267,35,14
+ PUSHBUTTON "Nice",IDC_DEF2,49,267,35,14
+ DEFPUSHBUTTON "OK",IDOK,97,267,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,153,267,50,14
+ PUSHBUTTON "Copy settings\n to clipboard",IDC_CLIPBOARD,210,261,77,
+ 26,BS_MULTILINE,WS_EX_STATICEDGE
+ LTEXT "Primary",IDC_DEVICETXT,72,5,211,10
+ GROUPBOX "Resolution && Colors",IDC_STATIC,4,17,283,78
+ RTEXT "Color depth:",IDC_STATIC,182,28,39,10,SS_CENTERIMAGE
+ RTEXT "Size:",IDC_STATIC,74,44,26,9
+ RTEXT "Stretching:",IDC_STATIC,26,63,48,9
+ RTEXT "Scanline mode:",IDC_STATIC,9,169,61,8
+ RTEXT "Recording options:",IDC_STATIC,55,241,61,10,
+ SS_CENTERIMAGE
+ CTEXT "x",IDC_STATIC,141,44,8,9
+ GROUPBOX "Framerate",IDC_STATIC,4,96,283,60
+ LTEXT "FPS",IDC_STATIC,250,142,20,9
+ GROUPBOX "Options",IDC_STATIC,4,157,283,99
+ GROUPBOX "Default settings",IDC_STATIC,4,257,87,30
+ RTEXT "Key configuration:",IDC_STATIC,152,111,59,10,
+ SS_CENTERIMAGE
+ EDITTEXT IDC_CLPEDIT,204,278,6,8,ES_MULTILINE | ES_AUTOVSCROLL |
+ ES_AUTOHSCROLL | NOT WS_VISIBLE
+ RTEXT "Dithering:",IDC_STATIC,26,79,48,9
+END
+
+IDD_DEVICE DIALOG DISCARDABLE 0, 0, 186, 82
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "Select device..."
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,24,63,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,112,63,50,14
+ COMBOBOX IDC_DEVICE,7,7,167,64,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ CONTROL "Adjust gamma (fullscreen modes only)",IDC_USEGAMMA,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,28,156,9
+ SCROLLBAR IDC_GAMMA,55,42,68,10
+ RTEXT "Dark",IDC_STATIC,30,43,21,8
+ LTEXT "Bright",IDC_STATIC,127,43,28,8
+END
+
+IDD_ABOUT DIALOG DISCARDABLE 0, 0, 258, 194
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "About the P.E.Op.S. PSX DirectDraw Soft Renderer..."
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,103,176,50,14
+ RTEXT "Version:",IDC_STATIC,17,6,49,10
+ RTEXT "Coded by:",IDC_STATIC,17,29,49,10
+ RTEXT "Pete's EMail:",IDC_STATIC,17,41,49,10
+ LTEXT "1.17",IDC_STATIC,69,6,159,10
+ LTEXT "Pete Bernert and the P.E.Op.S. team",IDC_STATIC,69,29,
+ 159,10
+ LTEXT "BlackDove@addcom.de",IDC_STATIC,69,41,159,10
+ LTEXT "http://www.pbernert.com",IDC_STATIC,82,95,142,10
+ RTEXT "Release date:",IDC_STATIC,17,17,49,10
+ LTEXT "12.06.2005",IDC_STATIC,69,17,159,10
+ LTEXT "The P.E.Op.S. SoftGPU team:",IDC_STATIC,9,82,103,10
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME | SS_SUNKEN,4,76,
+ 249,94
+ RTEXT "P.E.Op.S. page:",IDC_STATIC,9,56,57,10
+ LTEXT "https://sourceforge.net/projects/peops",IDC_STATIC,69,
+ 56,159,10
+ LTEXT "- Pete Bernert",IDC_STATIC,13,95,69,10
+ LTEXT "- Lewpy",IDC_STATIC,13,106,69,10
+ LTEXT "- lu_zero",IDC_STATIC,13,117,69,10
+ LTEXT "- linuzappz",IDC_STATIC,13,128,69,10
+ LTEXT "- Darko Matesic",IDC_STATIC,13,139,69,10
+ LTEXT "http://mrdario.tripod.com",IDC_STATIC,82,139,142,10
+ LTEXT "http://www.pcsx.net",IDC_STATIC,82,128,142,10
+ LTEXT "http://lewpy.psxemu.com/",IDC_STATIC,82,106,142,10
+ LTEXT "http://brsk.virtualave.net/lu_zero/",IDC_STATIC,82,117,
+ 142,10
+ LTEXT "- syo",IDC_STATIC,13,150,69,10
+ LTEXT "http://www.geocities.co.jp/SiliconValley-Bay/2072/",
+ IDC_STATIC,82,150,167,10
+END
+
+IDD_FIXES DIALOG DISCARDABLE 0, 0, 285, 207
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "Special game fixes..."
+FONT 8, "MS Sans Serif"
+BEGIN
+ CONTROL "Odd/even bit hack",IDC_FIX1,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,34,30,100,10
+ CONTROL "Expand screen width",IDC_FIX2,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,34,45,91,10
+ CONTROL "Ignore black brightness color",IDC_FIX3,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,34,60,106,10
+ CONTROL "Disable coord check",IDC_FIX4,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,34,75,85,10
+ CONTROL "Use low-res fps timer",IDC_FIX5,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,34,90,101,10
+ CONTROL "Use PC fps calculation",IDC_FIX6,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,34,105,91,10
+ CONTROL "Lazy screen updates",IDC_FIX7,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,34,120,91,10
+ CONTROL "Use old frame skipping",IDC_FIX8,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,34,135,91,10
+ CONTROL "Repeated flat tex triangles",IDC_FIX9,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,34,150,97,10
+ CONTROL "Draw tex-quads as triangles",IDC_FIX10,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,34,165,100,10
+ DEFPUSHBUTTON "OK",IDOK,66,187,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,169,187,50,14
+ LTEXT "Activate the following options only if you want to play one of the listed games (or if your game is showing similar glitches)!",
+ IDC_STATIC,8,4,245,22
+ LTEXT "Needed with epsxe 1.5.2 and older",IDC_STATIC,145,30,
+ 135,9,SS_CENTERIMAGE
+ LTEXT "Shows the full area in Capcom 2D fighters",IDC_STATIC,
+ 145,45,136,9,SS_CENTERIMAGE
+ LTEXT "Fixes black screens in Lunar",IDC_STATIC,145,60,134,9,
+ SS_CENTERIMAGE
+ LTEXT "Old compatibility mode",IDC_STATIC,145,75,135,9,
+ SS_CENTERIMAGE
+ LTEXT "For buggy motherboard chipsets",IDC_STATIC,145,90,133,9,
+ SS_CENTERIMAGE
+ LTEXT "Better fps limitation with some games",IDC_STATIC,145,
+ 105,129,9,SS_CENTERIMAGE
+ LTEXT "Maybe faster, needed for Pandemonium2",IDC_STATIC,145,
+ 120,139,9,SS_CENTERIMAGE
+ RTEXT "0x0001:",IDC_STATIC,1,30,28,9,SS_CENTERIMAGE
+ RTEXT "0x0002:",IDC_STATIC,1,45,28,9,SS_CENTERIMAGE
+ RTEXT "0x0004:",IDC_STATIC,1,60,28,9,SS_CENTERIMAGE
+ RTEXT "0x0008:",IDC_STATIC,1,75,28,9,SS_CENTERIMAGE
+ RTEXT "0x0010:",IDC_STATIC,1,90,28,9,SS_CENTERIMAGE
+ RTEXT "0x0020:",IDC_STATIC,1,105,28,9,SS_CENTERIMAGE
+ RTEXT "0x0040:",IDC_STATIC,1,120,28,9,SS_CENTERIMAGE
+ LTEXT "Skips only every second frame",IDC_STATIC,145,135,139,9,
+ SS_CENTERIMAGE
+ RTEXT "0x0080:",IDC_STATIC,1,135,28,9,SS_CENTERIMAGE
+ LTEXT "Needed by Dark Forces",IDC_STATIC,145,150,139,9,
+ SS_CENTERIMAGE
+ RTEXT "0x0100:",IDC_STATIC,1,150,28,9,SS_CENTERIMAGE
+ LTEXT "Slightly distorted textures can happen",IDC_STATIC,145,
+ 165,139,9,SS_CENTERIMAGE
+ RTEXT "0x0200:",IDC_STATIC,1,165,28,9,SS_CENTERIMAGE
+END
+
+IDD_KEYS DIALOG DISCARDABLE 0, 0, 186, 220
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "GPU key configuration"
+FONT 8, "MS Sans Serif"
+BEGIN
+ PUSHBUTTON "Default keys",IDC_DEFAULT,107,6,61,13
+ COMBOBOX IDC_KEY1,108,25,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY2,108,41,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY3,108,57,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY4,108,73,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY5,108,89,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY6,108,105,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY7,108,121,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY8,108,137,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY9,108,153,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ COMBOBOX IDC_KEY10,108,169,61,62,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ DEFPUSHBUTTON "OK",IDOK,20,197,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,115,197,50,14
+ RTEXT "Show/hide gpu menu:",IDC_STATIC,4,26,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Show/hide gpu infos:",IDC_STATIC,4,42,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Toggle selected option up:",IDC_STATIC,4,58,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Toggle selected option down:",IDC_STATIC,4,74,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Select previous option:",IDC_STATIC,4,90,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Select next option:",IDC_STATIC,4,106,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Start/stop recording:",IDC_STATIC,4,122,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Toggle wait VSYNC:",IDC_STATIC,4,138,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Fast forward frame skipping:",IDC_STATIC,4,154,100,9,
+ SS_CENTERIMAGE
+ RTEXT "Debug mode: toggle vram view:",IDC_STATIC,4,170,100,9,
+ SS_CENTERIMAGE
+END
+
+IDD_RECORDING DIALOG DISCARDABLE 0, 0, 215, 158
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Recording Options"
+FONT 8, "MS Sans Serif"
+BEGIN
+ CONTROL "Standard Video Size",IDC_REC_MODE1,"Button",
+ BS_AUTORADIOBUTTON | WS_GROUP,25,36,80,12
+ COMBOBOX IDC_VIDEO_SIZE,115,37,65,60,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "Custom Video Size",IDC_REC_MODE2,"Button",
+ BS_AUTORADIOBUTTON,25,51,80,12
+ EDITTEXT IDC_REC_WIDTH,115,51,25,12,ES_AUTOHSCROLL
+ CTEXT "x",IDC_STATIC,141,51,12,12,SS_CENTERIMAGE
+ EDITTEXT IDC_REC_HEIGHT,155,51,25,12,ES_AUTOHSCROLL
+ RTEXT "Frame Rate Scale:",IDC_STATIC,45,69,60,12,
+ SS_CENTERIMAGE | NOT WS_GROUP
+ COMBOBOX IDC_FRAME_RATE,115,69,30,60,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "16 bit Compression:",IDC_COMPRESSION1,"Button",
+ BS_AUTORADIOBUTTON | WS_GROUP,21,86,165,12
+ CONTROL "24 bit Compression:",IDC_COMPRESSION2,"Button",
+ BS_AUTORADIOBUTTON,21,101,165,12
+ PUSHBUTTON "Configure",IDC_RECCFG,77,116,50,12
+ DEFPUSHBUTTON "OK",IDOK,24,137,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,133,137,50,14
+ LTEXT "You can start/stop the video recording using the 'recording' key (see key configuration)!\nThe video will be stored in the 'Demo' sub-directory.",
+ IDC_STATIC,5,3,203,27
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_CFGSOFT, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 284
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 280
+ END
+
+ IDD_DEVICE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 75
+ END
+
+ IDD_ABOUT, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 189
+ END
+
+ IDD_FIXES, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 278
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 200
+ END
+
+ IDD_KEYS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 190
+ END
+
+ IDD_RECORDING, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 208
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 151
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_CFGSOFT DLGINIT
+BEGIN
+ IDC_RESOLUTION, 0x403, 1, 0
+"\000"
+ IDC_NOSTRETCH, 0x403, 10, 0
+0x3436, 0x2030, 0x2078, 0x3834, 0x0030,
+ IDC_NOSTRETCH, 0x403, 10, 0
+0x3038, 0x2030, 0x2078, 0x3036, 0x0030,
+ IDC_NOSTRETCH, 0x403, 11, 0
+0x3031, 0x3432, 0x7820, 0x3720, 0x3836, "\000"
+ IDC_NOSTRETCH, 0x403, 11, 0
+0x3131, 0x3235, 0x7820, 0x3820, 0x3436, "\000"
+ IDC_NOSTRETCH, 0x403, 12, 0
+0x3231, 0x3038, 0x7820, 0x3120, 0x3230, 0x0034,
+ IDC_NOSTRETCH, 0x403, 12, 0
+0x3631, 0x3030, 0x7820, 0x3120, 0x3032, 0x0030,
+ IDC_DITHER, 0x403, 10, 0
+0x3436, 0x2030, 0x2078, 0x3834, 0x0030,
+ IDC_DITHER, 0x403, 10, 0
+0x3038, 0x2030, 0x2078, 0x3036, 0x0030,
+ IDC_DITHER, 0x403, 11, 0
+0x3031, 0x3432, 0x7820, 0x3720, 0x3836, "\000"
+ IDC_DITHER, 0x403, 11, 0
+0x3131, 0x3235, 0x7820, 0x3820, 0x3436, "\000"
+ IDC_DITHER, 0x403, 12, 0
+0x3231, 0x3038, 0x7820, 0x3120, 0x3230, 0x0034,
+ IDC_DITHER, 0x403, 12, 0
+0x3631, 0x3030, 0x7820, 0x3120, 0x3032, 0x0030,
+ IDC_SCANLINES, 0x403, 10, 0
+0x3436, 0x2030, 0x2078, 0x3834, 0x0030,
+ IDC_SCANLINES, 0x403, 10, 0
+0x3038, 0x2030, 0x2078, 0x3036, 0x0030,
+ IDC_SCANLINES, 0x403, 11, 0
+0x3031, 0x3432, 0x7820, 0x3720, 0x3836, "\000"
+ IDC_SCANLINES, 0x403, 11, 0
+0x3131, 0x3235, 0x7820, 0x3820, 0x3436, "\000"
+ IDC_SCANLINES, 0x403, 12, 0
+0x3231, 0x3038, 0x7820, 0x3120, 0x3230, 0x0034,
+ IDC_SCANLINES, 0x403, 12, 0
+0x3631, 0x3030, 0x7820, 0x3120, 0x3032, 0x0030,
+ 0
+END
+
+IDD_DEVICE DLGINIT
+BEGIN
+ IDC_DEVICE, 0x403, 11, 0
+0x6f64, 0x276e, 0x2074, 0x6163, 0x6572, "\000"
+ IDC_DEVICE, 0x403, 12, 0
+0x3452, 0x4720, 0x2034, 0x3442, 0x4120, 0x0034,
+ IDC_DEVICE, 0x403, 12, 0
+0x3552, 0x4720, 0x2035, 0x3542, 0x4120, 0x0031,
+ IDC_DEVICE, 0x403, 12, 0
+0x3852, 0x4720, 0x2038, 0x3842, 0x4120, 0x0038,
+ 0
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_INFO0 "FL - Frame limitation:\n[Off] - Speed as fast as possible\n[On-1] - Limits speed to manual value\n[On-2] - Limits speed to auto-detected value."
+ IDS_INFO1 "FS - Frame skipping:\n[Off] - No frames get skipped\n[On] - Tries to speed up the game by skipping frames. Can cause glitches!"
+ IDS_INFO2 "GF - Special game fixes:\n[Off] - Turn off all fixes\n[On] - Turn on all activated fixes. You have to select the fixes you want to use in the gpu config."
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif
+#endif
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/win32/plugins/dfxvideo/winsrc/cfg.c b/win32/plugins/dfxvideo/winsrc/cfg.c new file mode 100644 index 00000000..d311aa72 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/cfg.c @@ -0,0 +1,1294 @@ +/*************************************************************************** + cfg.c - description + ------------------- + begin : Sun Oct 28 2001 + copyright : (C) 2001 by Pete Bernert + email : BlackDove@addcom.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ + +#define _IN_CFG + +#include "externals.h" +#include "cfg.h" +#include "gpu.h" +#include "record.h"
+
+///////////////////////////////////////////////////////////////////////////// +// globals + +char szKeyDefaults[11]={VK_DELETE,VK_INSERT,VK_HOME,VK_END,VK_PRIOR,VK_NEXT,VK_MULTIPLY,VK_SUBTRACT,VK_ADD,VK_F12,0x00}; +char szDevName[128]; + +//////////////////////////////////////////////////////////////////////// +// prototypes + +BOOL OnInitCfgDialog(HWND hW); +void OnCfgOK(HWND hW); +BOOL OnInitSoftDialog(HWND hW); +void OnSoftOK(HWND hW); +void OnCfgCancel(HWND hW); +void OnCfgDef1(HWND hW); +void OnCfgDef2(HWND hW); +void OnBugFixes(HWND hW); + +void OnRecording(HWND hW); + +void SelectDev(HWND hW); +BOOL bTestModes(void); +void OnKeyConfig(HWND hW); +void GetSettings(HWND hW); +void OnClipboard(HWND hW); +void DoDevEnum(HWND hW); +char * pGetConfigInfos(int iCfg); + +//////////////////////////////////////////////////////////////////////// +// funcs + +BOOL CALLBACK SoftDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + return OnInitSoftDialog(hW); + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDC_DISPMODE1: + { + CheckDlgButton(hW,IDC_DISPMODE2,FALSE); + return TRUE; + } + case IDC_DISPMODE2: + { + CheckDlgButton(hW,IDC_DISPMODE1,FALSE); + return TRUE; + } + case IDC_DEF1: OnCfgDef1(hW); return TRUE; + case IDC_DEF2: OnCfgDef2(hW); return TRUE; + case IDC_SELFIX: OnBugFixes(hW); return TRUE; + case IDC_KEYCONFIG: OnKeyConfig(hW); return TRUE; + case IDC_SELDEV: SelectDev(hW); return TRUE; + case IDCANCEL: OnCfgCancel(hW); return TRUE; + case IDOK: OnSoftOK(hW); return TRUE; + case IDC_CLIPBOARD: OnClipboard(hW); return TRUE; + + case IDC_RECORDING: OnRecording(hW); return TRUE; + } + } + } + return FALSE; +} + +//////////////////////////////////////////////////////////////////////// +// init dlg +//////////////////////////////////////////////////////////////////////// + +void ComboBoxAddRes(HWND hWC,char * cs) +{ + int i=ComboBox_FindString(hWC,-1,cs); + if(i!=CB_ERR) return; + ComboBox_AddString(hWC,cs); +} + +BOOL OnInitSoftDialog(HWND hW) +{ + HWND hWC;char cs[256];int i;DEVMODE dv; + + ReadConfig(); // read registry stuff + + if(szDevName[0]) + SetDlgItemText(hW,IDC_DEVICETXT,szDevName); + + hWC=GetDlgItem(hW,IDC_RESOLUTION); + + memset(&dv,0,sizeof(DEVMODE)); + dv.dmSize=sizeof(DEVMODE); + i=0; + + while(EnumDisplaySettings(NULL,i,&dv)) + { + wsprintf(cs,"%4d x %4d - default",dv.dmPelsWidth,dv.dmPelsHeight); + ComboBoxAddRes(hWC,cs); + if(dv.dmDisplayFrequency > 40 && dv.dmDisplayFrequency < 200 ) + { + wsprintf(cs,"%4d x %4d , %4d Hz",dv.dmPelsWidth,dv.dmPelsHeight,dv.dmDisplayFrequency); + ComboBoxAddRes(hWC,cs); + } + i++; + } + + ComboBoxAddRes(hWC," 320 x 200 - default"); + ComboBoxAddRes(hWC," 320 x 240 - default"); + ComboBoxAddRes(hWC," 400 x 300 - default"); + ComboBoxAddRes(hWC," 512 x 384 - default"); + ComboBoxAddRes(hWC," 640 x 480 - default"); + ComboBoxAddRes(hWC," 800 x 600 - default"); + ComboBoxAddRes(hWC,"1024 x 768 - default"); + ComboBoxAddRes(hWC,"1152 x 864 - default"); + ComboBoxAddRes(hWC,"1280 x 1024 - default"); + ComboBoxAddRes(hWC,"1600 x 1200 - default"); + + if(iRefreshRate) + wsprintf(cs,"%4d x %4d , %4d Hz",iResX,iResY,iRefreshRate); + else wsprintf(cs,"%4d x %4d - default",iResX,iResY); + + i=ComboBox_FindString(hWC,-1,cs); + if(i==CB_ERR) i=0; + ComboBox_SetCurSel(hWC,i); + + hWC=GetDlgItem(hW,IDC_COLDEPTH); + ComboBox_AddString(hWC,"16 Bit"); + ComboBox_AddString(hWC,"32 Bit"); + wsprintf(cs,"%d Bit",iColDepth); // resolution + i=ComboBox_FindString(hWC,-1,cs); + if(i==CB_ERR) i=0; + ComboBox_SetCurSel(hWC,i); + + hWC=GetDlgItem(hW,IDC_SCANLINES); + ComboBox_AddString(hWC,"Scanlines disabled"); + ComboBox_AddString(hWC,"Scanlines enabled (standard)"); + ComboBox_AddString(hWC,"Scanlines enabled (double blitting - nVidia fix)"); + ComboBox_SetCurSel(hWC,iUseScanLines); + + SetDlgItemInt(hW,IDC_WINX,LOWORD(iWinSize),FALSE); // window size + SetDlgItemInt(hW,IDC_WINY,HIWORD(iWinSize),FALSE); + + if(UseFrameLimit) CheckDlgButton(hW,IDC_USELIMIT,TRUE); + if(UseFrameSkip) CheckDlgButton(hW,IDC_USESKIPPING,TRUE); + if(iWindowMode) CheckRadioButton(hW,IDC_DISPMODE1,IDC_DISPMODE2,IDC_DISPMODE2); + else CheckRadioButton(hW,IDC_DISPMODE1,IDC_DISPMODE2,IDC_DISPMODE1); + if(iSysMemory) CheckDlgButton(hW,IDC_SYSMEMORY,TRUE); + if(iStopSaver) CheckDlgButton(hW,IDC_STOPSAVER,TRUE); + if(iUseFixes) CheckDlgButton(hW,IDC_GAMEFIX,TRUE); + if(iShowFPS) CheckDlgButton(hW,IDC_SHOWFPS,TRUE); + if(bVsync) CheckDlgButton(hW,IDC_VSYNC,TRUE); + if(bTransparent) CheckDlgButton(hW,IDC_TRANSPARENT,TRUE); + if(iDebugMode) CheckDlgButton(hW,IDC_DEBUGMODE,TRUE); + + hWC=GetDlgItem(hW,IDC_NOSTRETCH); // streching + ComboBox_AddString(hWC,"Stretch to full window size"); + ComboBox_AddString(hWC,"1:1 (faster with some cards)"); + ComboBox_AddString(hWC,"Scale to window size, keep aspect ratio"); + ComboBox_AddString(hWC,"2xSaI stretching (needs a fast cpu)"); + ComboBox_AddString(hWC,"2xSaI unstretched (needs a fast cpu)"); + ComboBox_AddString(hWC,"Super2xSaI stretching (needs a very fast cpu)"); + ComboBox_AddString(hWC,"Super2xSaI unstretched (needs a very fast cpu)"); + ComboBox_AddString(hWC,"SuperEagle stretching (needs a fast cpu)"); + ComboBox_AddString(hWC,"SuperEagle unstretched (needs a fast cpu)"); + ComboBox_AddString(hWC,"Scale2x stretching (needs a fast cpu)"); + ComboBox_AddString(hWC,"Scale2x unstretched (needs a fast cpu)"); + ComboBox_AddString(hWC,"HQ2X unstretched (needs a fast cpu)"); + ComboBox_AddString(hWC,"HQ2X streched (needs a fast cpu)"); + ComboBox_AddString(hWC,"Scale3x stretching (needs a fast cpu)"); + ComboBox_AddString(hWC,"Scale3x unstretched (needs a fast cpu)"); + ComboBox_AddString(hWC,"HQ3X unstretched (needs a fast cpu)"); + ComboBox_SetCurSel(hWC,iUseNoStretchBlt); + + hWC=GetDlgItem(hW,IDC_DITHER); // dithering + ComboBox_AddString(hWC,"No dithering (fastest)"); + ComboBox_AddString(hWC,"Game dependend dithering (slow)"); + ComboBox_AddString(hWC,"Always dither g-shaded polygons (slowest)"); + ComboBox_SetCurSel(hWC,iUseDither); + + if(iFrameLimit==2) // frame limit wrapper + CheckDlgButton(hW,IDC_FRAMEAUTO,TRUE); + else CheckDlgButton(hW,IDC_FRAMEMANUELL,TRUE); + + sprintf(cs,"%.1f",fFrameRate); + SetDlgItemText(hW,IDC_FRAMELIM,cs); // set frame rate + + return TRUE; +} + +//////////////////////////////////////////////////////////////////////// +// on ok: take vals +//////////////////////////////////////////////////////////////////////// + +void GetSettings(HWND hW) +{ + HWND hWC;char cs[256];int i,j;char * p; + + hWC=GetDlgItem(hW,IDC_RESOLUTION); // get resolution + i=ComboBox_GetCurSel(hWC); + ComboBox_GetLBText(hWC,i,cs); + iResX=atol(cs); + p=strchr(cs,'x'); + iResY=atol(p+1); + p=strchr(cs,','); // added by syo + if(p) iRefreshRate=atol(p+1); // get refreshrate + else iRefreshRate=0; + + hWC=GetDlgItem(hW,IDC_COLDEPTH); // get color depth + i=ComboBox_GetCurSel(hWC); + ComboBox_GetLBText(hWC,i,cs); + iColDepth=atol(cs); + + hWC=GetDlgItem(hW,IDC_SCANLINES); // scanlines + iUseScanLines=ComboBox_GetCurSel(hWC); + + i=GetDlgItemInt(hW,IDC_WINX,NULL,FALSE); // get win size + if(i<50) i=50; if(i>20000) i=20000; + j=GetDlgItemInt(hW,IDC_WINY,NULL,FALSE); + if(j<50) j=50; if(j>20000) j=20000; + iWinSize=MAKELONG(i,j); + + if(IsDlgButtonChecked(hW,IDC_DISPMODE2)) // win mode + iWindowMode=1; else iWindowMode=0; + + if(IsDlgButtonChecked(hW,IDC_USELIMIT)) // fps limit + UseFrameLimit=1; else UseFrameLimit=0; + + if(IsDlgButtonChecked(hW,IDC_USESKIPPING)) // fps skip + UseFrameSkip=1; else UseFrameSkip=0; + + if(IsDlgButtonChecked(hW,IDC_GAMEFIX)) // game fix + iUseFixes=1; else iUseFixes=0; + + if(IsDlgButtonChecked(hW,IDC_SYSMEMORY)) // use system memory + iSysMemory=1; else iSysMemory=0; + + if(IsDlgButtonChecked(hW,IDC_STOPSAVER)) // stop screen saver + iStopSaver=1; else iStopSaver=0; + + if(IsDlgButtonChecked(hW,IDC_VSYNC)) // wait VSYNC + bVsync=bVsync_Key=TRUE; else bVsync=bVsync_Key=FALSE; + + if(IsDlgButtonChecked(hW,IDC_TRANSPARENT)) // transparent menu + bTransparent=TRUE; else bTransparent=FALSE; + + if(IsDlgButtonChecked(hW,IDC_SHOWFPS)) // show fps + iShowFPS=1; else iShowFPS=0; + + if(IsDlgButtonChecked(hW,IDC_DEBUGMODE)) // debug mode + iDebugMode=1; else iDebugMode=0; + + hWC=GetDlgItem(hW,IDC_NOSTRETCH); + iUseNoStretchBlt=ComboBox_GetCurSel(hWC); + + hWC=GetDlgItem(hW,IDC_DITHER); + iUseDither=ComboBox_GetCurSel(hWC); + + if(IsDlgButtonChecked(hW,IDC_FRAMEAUTO)) // frame rate + iFrameLimit=2; + else iFrameLimit=1; + + GetDlgItemText(hW,IDC_FRAMELIM,cs,255); + fFrameRate=(float)atof(cs); + if(fFrameRate<10.0f) fFrameRate=10.0f; + if(fFrameRate>200.0f) fFrameRate=200.0f; +} + +void OnSoftOK(HWND hW) +{ + GetSettings(hW); + + if(!iWindowMode && !bTestModes()) // check fullscreen sets + { + MessageBox(hW,"Resolution/color depth not supported!","Error",MB_ICONERROR|MB_OK); + return; + } + + WriteConfig(); // write registry + + EndDialog(hW,TRUE); +} + +//////////////////////////////////////////////////////////////////////// +// on clipboard button +//////////////////////////////////////////////////////////////////////// + +void OnClipboard(HWND hW) +{ + HWND hWE=GetDlgItem(hW,IDC_CLPEDIT); + char * pB; + GetSettings(hW); + pB=pGetConfigInfos(1); + + if(pB) + { + SetDlgItemText(hW,IDC_CLPEDIT,pB); + SendMessage(hWE,EM_SETSEL,0,-1); + SendMessage(hWE,WM_COPY,0,0); + free(pB); + MessageBox(hW,"Configuration info successfully copied to the clipboard\nJust use the PASTE function in another program to retrieve the data!","Copy Info",MB_ICONINFORMATION|MB_OK); + } +} + +//////////////////////////////////////////////////////////////////////// +// Cancel +//////////////////////////////////////////////////////////////////////// + +void OnCfgCancel(HWND hW) +{ + EndDialog(hW,FALSE); +} + +//////////////////////////////////////////////////////////////////////// +// Bug fixes +//////////////////////////////////////////////////////////////////////// + +BOOL CALLBACK BugFixesDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + int i; + + for(i=0;i<32;i++) + { + if(dwCfgFixes&(1<<i)) + CheckDlgButton(hW,IDC_FIX1+i,TRUE); + } + } + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDCANCEL: EndDialog(hW,FALSE);return TRUE; + + case IDOK: + { + int i; + dwCfgFixes=0; + for(i=0;i<32;i++) + { + if(IsDlgButtonChecked(hW,IDC_FIX1+i)) + dwCfgFixes|=(1<<i); + } + EndDialog(hW,TRUE); + return TRUE; + } + } + } + } + return FALSE; +} + +void OnBugFixes(HWND hW) +{ + DialogBox(hInst,MAKEINTRESOURCE(IDD_FIXES), + hW,(DLGPROC)BugFixesDlgProc); +} + +//////////////////////////////////////////////////////////////////////// +// Recording options +//////////////////////////////////////////////////////////////////////// + +void RefreshCodec(HWND hW) +{ +char buffer[255]; +union { + char chFCC[5]; + DWORD dwFCC; + } fcc; +ICINFO icinfo; +memset(&icinfo,0,sizeof(icinfo)); +icinfo.dwSize = sizeof(icinfo); +strcpy(fcc.chFCC,"VIDC"); +RECORD_COMPRESSION1.hic = ICOpen(fcc.dwFCC,RECORD_COMPRESSION1.fccHandler,ICMODE_QUERY); +if(RECORD_COMPRESSION1.hic) + { + ICGetInfo(RECORD_COMPRESSION1.hic,&icinfo,sizeof(icinfo)); + ICClose(RECORD_COMPRESSION1.hic); + wsprintf(buffer,"16 bit Compression: %ws",icinfo.szDescription); + } +else + wsprintf(buffer,"16 bit Compression: Full Frames (Uncompressed)"); +SetDlgItemText(hW,IDC_COMPRESSION1,buffer); + +memset(&icinfo,0,sizeof(icinfo)); +icinfo.dwSize = sizeof(icinfo); +RECORD_COMPRESSION2.hic = ICOpen(fcc.dwFCC,RECORD_COMPRESSION2.fccHandler,ICMODE_QUERY); +if(RECORD_COMPRESSION2.hic) + { + ICGetInfo(RECORD_COMPRESSION2.hic,&icinfo,sizeof(icinfo)); + ICClose(RECORD_COMPRESSION2.hic); + wsprintf(buffer,"24 bit Compression: %ws",icinfo.szDescription); + } +else + wsprintf(buffer,"24 bit Compression: Full Frames (Uncompressed)"); +SetDlgItemText(hW,IDC_COMPRESSION2,buffer); +} + + +BOOL CALLBACK RecordingDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + HWND hWC; + CheckDlgButton(hW,IDC_REC_MODE1,RECORD_RECORDING_MODE==0); + CheckDlgButton(hW,IDC_REC_MODE2,RECORD_RECORDING_MODE==1); + hWC = GetDlgItem(hW,IDC_VIDEO_SIZE); + ComboBox_ResetContent(hWC); + ComboBox_AddString(hWC,"Full"); + ComboBox_AddString(hWC,"Half"); + ComboBox_AddString(hWC,"Quarter"); + ComboBox_SetCurSel(hWC,RECORD_VIDEO_SIZE); + + SetDlgItemInt(hW,IDC_REC_WIDTH,RECORD_RECORDING_WIDTH,FALSE); + SetDlgItemInt(hW,IDC_REC_HEIGHT,RECORD_RECORDING_HEIGHT,FALSE); + + hWC = GetDlgItem(hW,IDC_FRAME_RATE); + ComboBox_ResetContent(hWC); + ComboBox_AddString(hWC,"1"); + ComboBox_AddString(hWC,"2"); + ComboBox_AddString(hWC,"3"); + ComboBox_AddString(hWC,"4"); + ComboBox_AddString(hWC,"5"); + ComboBox_AddString(hWC,"6"); + ComboBox_AddString(hWC,"7"); + ComboBox_AddString(hWC,"8"); + ComboBox_SetCurSel(hWC,RECORD_FRAME_RATE_SCALE); + CheckDlgButton(hW,IDC_COMPRESSION1,RECORD_COMPRESSION_MODE==0); + CheckDlgButton(hW,IDC_COMPRESSION2,RECORD_COMPRESSION_MODE==1); + RefreshCodec(hW); + } + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDC_RECCFG: + { + if(IsDlgButtonChecked(hW,IDC_COMPRESSION1)) + { + BITMAPINFOHEADER bitmap = {40,640,480,1,16,0,640*480*2,2048,2048,0,0}; + if(!ICCompressorChoose(hW,ICMF_CHOOSE_DATARATE|ICMF_CHOOSE_KEYFRAME,&bitmap,NULL,&RECORD_COMPRESSION1,"16 bit Compression")) return TRUE; + if(RECORD_COMPRESSION1.cbState>sizeof(RECORD_COMPRESSION_STATE1)) + { + memset(&RECORD_COMPRESSION1,0,sizeof(RECORD_COMPRESSION1)); + memset(&RECORD_COMPRESSION_STATE1,0,sizeof(RECORD_COMPRESSION_STATE1)); + RECORD_COMPRESSION1.cbSize = sizeof(RECORD_COMPRESSION1); + } + else + { + if(RECORD_COMPRESSION1.lpState!=RECORD_COMPRESSION_STATE1) + memcpy(RECORD_COMPRESSION_STATE1,RECORD_COMPRESSION1.lpState,RECORD_COMPRESSION1.cbState); + } + RECORD_COMPRESSION1.lpState = RECORD_COMPRESSION_STATE1; + } + else + { + BITMAPINFOHEADER bitmap = {40,640,480,1,24,0,640*480*3,2048,2048,0,0}; + if(!ICCompressorChoose(hW,ICMF_CHOOSE_DATARATE|ICMF_CHOOSE_KEYFRAME,&bitmap,NULL,&RECORD_COMPRESSION2,"24 bit Compression")) return TRUE; + if(RECORD_COMPRESSION2.cbState>sizeof(RECORD_COMPRESSION_STATE2)) + { + memset(&RECORD_COMPRESSION2,0,sizeof(RECORD_COMPRESSION2)); + memset(&RECORD_COMPRESSION_STATE2,0,sizeof(RECORD_COMPRESSION_STATE2)); + RECORD_COMPRESSION2.cbSize = sizeof(RECORD_COMPRESSION2); + } + else + { + if(RECORD_COMPRESSION2.lpState!=RECORD_COMPRESSION_STATE2) + memcpy(RECORD_COMPRESSION_STATE2,RECORD_COMPRESSION2.lpState,RECORD_COMPRESSION2.cbState); + } + RECORD_COMPRESSION2.lpState = RECORD_COMPRESSION_STATE2; + } + RefreshCodec(hW); + return TRUE; + } + case IDCANCEL: EndDialog(hW,FALSE);return TRUE; + + case IDOK: + { + HWND hWC; + if(IsDlgButtonChecked(hW,IDC_REC_MODE1)) RECORD_RECORDING_MODE = 0; + else RECORD_RECORDING_MODE = 1; + hWC = GetDlgItem(hW,IDC_VIDEO_SIZE); + RECORD_VIDEO_SIZE = ComboBox_GetCurSel(hWC); + RECORD_RECORDING_WIDTH = GetDlgItemInt(hW,IDC_REC_WIDTH,NULL,FALSE); + RECORD_RECORDING_HEIGHT = GetDlgItemInt(hW,IDC_REC_HEIGHT,NULL,FALSE); + hWC = GetDlgItem(hW,IDC_FRAME_RATE); + RECORD_FRAME_RATE_SCALE = ComboBox_GetCurSel(hWC); + if(IsDlgButtonChecked(hW,IDC_COMPRESSION1)) RECORD_COMPRESSION_MODE = 0; + else RECORD_COMPRESSION_MODE = 1; + EndDialog(hW,TRUE); + return TRUE; + } + } + } + } + return FALSE; +} + +void OnRecording(HWND hW) +{ + DialogBox(hInst,MAKEINTRESOURCE(IDD_RECORDING), + hW,(DLGPROC)RecordingDlgProc); + +} + + +//////////////////////////////////////////////////////////////////////// +// default 1: fast +//////////////////////////////////////////////////////////////////////// + +void OnCfgDef1(HWND hW) +{ + HWND hWC; + + hWC=GetDlgItem(hW,IDC_RESOLUTION); + ComboBox_SetCurSel(hWC,1); + hWC=GetDlgItem(hW,IDC_COLDEPTH); + ComboBox_SetCurSel(hWC,0); + hWC=GetDlgItem(hW,IDC_SCANLINES); + ComboBox_SetCurSel(hWC,0); + CheckDlgButton(hW,IDC_USELIMIT,FALSE); + CheckDlgButton(hW,IDC_USESKIPPING,TRUE); + CheckRadioButton(hW,IDC_DISPMODE1,IDC_DISPMODE2,IDC_DISPMODE1); + CheckDlgButton(hW,IDC_FRAMEAUTO,FALSE); + CheckDlgButton(hW,IDC_FRAMEMANUELL,TRUE); + CheckDlgButton(hW,IDC_SHOWFPS,FALSE); + hWC=GetDlgItem(hW,IDC_NOSTRETCH); + ComboBox_SetCurSel(hWC,1); + hWC=GetDlgItem(hW,IDC_DITHER); + ComboBox_SetCurSel(hWC,0); + SetDlgItemInt(hW,IDC_FRAMELIM,200,FALSE); + SetDlgItemInt(hW,IDC_WINX,320,FALSE); + SetDlgItemInt(hW,IDC_WINY,240,FALSE); + CheckDlgButton(hW,IDC_VSYNC,FALSE); + CheckDlgButton(hW,IDC_TRANSPARENT,TRUE); + CheckDlgButton(hW,IDC_DEBUGMODE,FALSE); +} + +//////////////////////////////////////////////////////////////////////// +// default 2: nice +//////////////////////////////////////////////////////////////////////// + +void OnCfgDef2(HWND hW) +{ + HWND hWC; + + hWC=GetDlgItem(hW,IDC_RESOLUTION); + ComboBox_SetCurSel(hWC,2); + hWC=GetDlgItem(hW,IDC_COLDEPTH); + ComboBox_SetCurSel(hWC,0); + hWC=GetDlgItem(hW,IDC_SCANLINES); + ComboBox_SetCurSel(hWC,0); + CheckDlgButton(hW,IDC_USELIMIT,TRUE); + CheckDlgButton(hW,IDC_USESKIPPING,FALSE); + CheckRadioButton(hW,IDC_DISPMODE1,IDC_DISPMODE2,IDC_DISPMODE1); + CheckDlgButton(hW,IDC_FRAMEAUTO,TRUE); + CheckDlgButton(hW,IDC_FRAMEMANUELL,FALSE); + CheckDlgButton(hW,IDC_SHOWFPS,FALSE); + CheckDlgButton(hW,IDC_VSYNC,FALSE); + CheckDlgButton(hW,IDC_TRANSPARENT,TRUE); + CheckDlgButton(hW,IDC_DEBUGMODE,FALSE); + hWC=GetDlgItem(hW,IDC_NOSTRETCH); + ComboBox_SetCurSel(hWC,0); + hWC=GetDlgItem(hW,IDC_DITHER); + ComboBox_SetCurSel(hWC,2); + + SetDlgItemInt(hW,IDC_FRAMELIM,200,FALSE); + SetDlgItemInt(hW,IDC_WINX,640,FALSE); + SetDlgItemInt(hW,IDC_WINY,480,FALSE); +} + +//////////////////////////////////////////////////////////////////////// +// read registry +//////////////////////////////////////////////////////////////////////// + +void ReadConfig(void) +{ + HKEY myKey; + DWORD temp; + DWORD type; + DWORD size; + + // predefines + iResX=640;iResY=480; + iColDepth=16; + iWindowMode=0; + UseFrameLimit=1; + UseFrameSkip=0; + iFrameLimit=2; + fFrameRate=200.0f; + iWinSize=MAKELONG(640,480); + dwCfgFixes=0; + iUseFixes=0; + iUseGammaVal=2048; + iUseScanLines=0; + iUseNoStretchBlt=0; + iUseDither=0; + iShowFPS=0; + iSysMemory=0; + iStopSaver=1; + bVsync=FALSE; + bTransparent=FALSE; + iRefreshRate=0; + iDebugMode=0; + lstrcpy(szGPUKeys,szKeyDefaults); + + memset(szDevName,0,128); + memset(&guiDev,0,sizeof(GUID)); + + // standard Windows psx config (registry) + if(RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\DFXVideo",0,KEY_ALL_ACCESS,&myKey)==ERROR_SUCCESS) + { + size = 4; + if(RegQueryValueEx(myKey,"ResX",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iResX=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"ResY",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iResY=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"RefreshRate",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iRefreshRate=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"WinSize",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iWinSize=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"WindowMode",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iWindowMode=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"ColDepth",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iColDepth=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseFrameLimit",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + UseFrameLimit=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseFrameSkip",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + UseFrameSkip=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"FrameLimit",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iFrameLimit=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"CfgFixes",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + dwCfgFixes=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseFixes",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iUseFixes=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseScanLines",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iUseScanLines=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"ShowFPS",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iShowFPS=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseNoStrechBlt",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iUseNoStretchBlt=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseDither",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iUseDither=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseGamma",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iUseGammaVal=(int)temp; + if(!iFrameLimit) {UseFrameLimit=0;UseFrameSkip=0;iFrameLimit=2;} + + // try to get the float framerate... if none: take int framerate + fFrameRate=0.0f; + size = 4; + if(RegQueryValueEx(myKey,"FrameRateFloat",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + fFrameRate=*((float *)(&temp)); + if(fFrameRate==0.0f) + { + fFrameRate=200.0f; + size = 4; + if(RegQueryValueEx(myKey,"FrameRate",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + fFrameRate=(float)temp; + } + + size = 4; + if(RegQueryValueEx(myKey,"UseSysMemory",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iSysMemory=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"StopSaver",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iStopSaver=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"WaitVSYNC",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bVsync=bVsync_Key=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"Transparent",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bTransparent=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"DebugMode",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iDebugMode=(BOOL)temp; + size=11; + RegQueryValueEx(myKey,"GPUKeys",0,&type,(LPBYTE)&szGPUKeys,&size); + size=128; + RegQueryValueEx(myKey,"DeviceName",0,&type,(LPBYTE)szDevName,&size); + size=sizeof(GUID); + RegQueryValueEx(myKey,"GuiDev",0,&type,(LPBYTE)&guiDev,&size); + +// +// Recording options +// +#define GetDWORD(xa,xb) size=4;if(RegQueryValueEx(myKey,xa,0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) xb=(unsigned long)temp; +#define GetBINARY(xa,xb) size=sizeof(xb);RegQueryValueEx(myKey,xa,0,&type,(LPBYTE)&xb,&size); + + GetDWORD("RecordingMode", RECORD_RECORDING_MODE); + GetDWORD("RecordingVideoSize", RECORD_VIDEO_SIZE); + GetDWORD("RecordingWidth", RECORD_RECORDING_WIDTH); + GetDWORD("RecordingHeight", RECORD_RECORDING_HEIGHT); + GetDWORD("RecordingFrameRateScale", RECORD_FRAME_RATE_SCALE); + GetDWORD("RecordingCompressionMode", RECORD_COMPRESSION_MODE); + GetBINARY("RecordingCompression1", RECORD_COMPRESSION1); + GetBINARY("RecordingCompressionState1", RECORD_COMPRESSION_STATE1); + GetBINARY("RecordingCompression2", RECORD_COMPRESSION2); + GetBINARY("RecordingCompressionState2", RECORD_COMPRESSION_STATE2); + + if(RECORD_RECORDING_WIDTH>1024) RECORD_RECORDING_WIDTH = 1024; + if(RECORD_RECORDING_HEIGHT>768) RECORD_RECORDING_HEIGHT = 768; + if(RECORD_VIDEO_SIZE>2) RECORD_VIDEO_SIZE = 2; + if(RECORD_FRAME_RATE_SCALE>7) RECORD_FRAME_RATE_SCALE = 7; + if(RECORD_COMPRESSION1.cbSize != sizeof(RECORD_COMPRESSION1)) + { + memset(&RECORD_COMPRESSION1,0,sizeof(RECORD_COMPRESSION1)); + RECORD_COMPRESSION1.cbSize = sizeof(RECORD_COMPRESSION1); + } + RECORD_COMPRESSION1.lpState = RECORD_COMPRESSION_STATE1; + if(RECORD_COMPRESSION2.cbSize != sizeof(RECORD_COMPRESSION2)) + { + memset(&RECORD_COMPRESSION2,0,sizeof(RECORD_COMPRESSION2)); + RECORD_COMPRESSION2.cbSize = sizeof(RECORD_COMPRESSION2); + } + RECORD_COMPRESSION2.lpState = RECORD_COMPRESSION_STATE2; + +// +// end of recording options +// + + RegCloseKey(myKey); + } + + if(!iColDepth) iColDepth=32; + if(iUseFixes) dwActFixes=dwCfgFixes; + SetFixes(); + + if(iUseGammaVal<0 || iUseGammaVal>1536) iUseGammaVal=2048; +} + +//////////////////////////////////////////////////////////////////////// + +void ReadWinSizeConfig(void) +{ + HKEY myKey; + DWORD temp; + DWORD type; + DWORD size; + + iResX=640;iResY=480; + iWinSize=MAKELONG(320,240); + + if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\DFXVideo",0,KEY_ALL_ACCESS,&myKey)==ERROR_SUCCESS) + { + size = 4; + if(RegQueryValueEx(myKey,"ResX",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iResX=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"ResY",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iResY=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"WinSize",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iWinSize=(int)temp; + + RegCloseKey(myKey); + } +} + +//////////////////////////////////////////////////////////////////////// +// write registry +//////////////////////////////////////////////////////////////////////// + +void WriteConfig(void) +{ + HKEY myKey; + DWORD myDisp; + DWORD temp; + + RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\DFXVideo",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&myKey,&myDisp); + temp=iResX; + RegSetValueEx(myKey,"ResX",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iResY; + RegSetValueEx(myKey,"ResY",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iRefreshRate; + RegSetValueEx(myKey,"RefreshRate",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iWinSize; + RegSetValueEx(myKey,"WinSize",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iWindowMode; + RegSetValueEx(myKey,"WindowMode",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iColDepth; + RegSetValueEx(myKey,"ColDepth",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=UseFrameLimit; + RegSetValueEx(myKey,"UseFrameLimit",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=UseFrameSkip; + RegSetValueEx(myKey,"UseFrameSkip",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=dwCfgFixes; + RegSetValueEx(myKey,"CfgFixes",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iUseFixes; + RegSetValueEx(myKey,"UseFixes",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iUseScanLines; + RegSetValueEx(myKey,"UseScanLines",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iShowFPS; + RegSetValueEx(myKey,"ShowFPS",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iUseNoStretchBlt; + RegSetValueEx(myKey,"UseNoStrechBlt",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iUseDither; + RegSetValueEx(myKey,"UseDither",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iFrameLimit; + RegSetValueEx(myKey,"FrameLimit",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iUseGammaVal; + RegSetValueEx(myKey,"UseGamma",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=(DWORD)fFrameRate; + RegSetValueEx(myKey,"FrameRate",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=*((DWORD *)&fFrameRate); + RegSetValueEx(myKey,"FrameRateFloat",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bVsync; + RegSetValueEx(myKey,"WaitVSYNC",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bTransparent; + RegSetValueEx(myKey,"Transparent",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iSysMemory; + RegSetValueEx(myKey,"UseSysMemory",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iStopSaver; + RegSetValueEx(myKey,"StopSaver",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iDebugMode; + RegSetValueEx(myKey,"DebugMode",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + RegSetValueEx(myKey,"GPUKeys",0,REG_BINARY,(LPBYTE)szGPUKeys,11); + RegSetValueEx(myKey,"DeviceName",0,REG_BINARY,(LPBYTE)szDevName,128); + RegSetValueEx(myKey,"GuiDev",0,REG_BINARY,(LPBYTE)&guiDev,sizeof(GUID)); + +// +// Recording options +// +if(RECORD_COMPRESSION1.cbState>sizeof(RECORD_COMPRESSION_STATE1) || RECORD_COMPRESSION1.lpState!=RECORD_COMPRESSION_STATE1) + { + memset(&RECORD_COMPRESSION1,0,sizeof(RECORD_COMPRESSION1)); + memset(&RECORD_COMPRESSION_STATE1,0,sizeof(RECORD_COMPRESSION_STATE1)); + RECORD_COMPRESSION1.cbSize = sizeof(RECORD_COMPRESSION1); + RECORD_COMPRESSION1.lpState = RECORD_COMPRESSION_STATE1; + } +if(RECORD_COMPRESSION2.cbState>sizeof(RECORD_COMPRESSION_STATE2) || RECORD_COMPRESSION2.lpState!=RECORD_COMPRESSION_STATE2) + { + memset(&RECORD_COMPRESSION2,0,sizeof(RECORD_COMPRESSION2)); + memset(&RECORD_COMPRESSION_STATE2,0,sizeof(RECORD_COMPRESSION_STATE2)); + RECORD_COMPRESSION2.cbSize = sizeof(RECORD_COMPRESSION2); + RECORD_COMPRESSION2.lpState = RECORD_COMPRESSION_STATE2; + } + +#define SetDWORD(xa,xb) RegSetValueEx(myKey,xa,0,REG_DWORD,(LPBYTE)&xb,sizeof(xb)); +#define SetBINARY(xa,xb) RegSetValueEx(myKey,xa,0,REG_BINARY,(LPBYTE)&xb,sizeof(xb)); + +SetDWORD("RecordingMode", RECORD_RECORDING_MODE); +SetDWORD("RecordingVideoSize", RECORD_VIDEO_SIZE); +SetDWORD("RecordingWidth", RECORD_RECORDING_WIDTH); +SetDWORD("RecordingHeight", RECORD_RECORDING_HEIGHT); +SetDWORD("RecordingFrameRateScale", RECORD_FRAME_RATE_SCALE); +SetDWORD("RecordingCompressionMode", RECORD_COMPRESSION_MODE); +SetBINARY("RecordingCompression1", RECORD_COMPRESSION1); +SetBINARY("RecordingCompressionState1", RECORD_COMPRESSION_STATE1); +SetBINARY("RecordingCompression2", RECORD_COMPRESSION2); +SetBINARY("RecordingCompressionState2", RECORD_COMPRESSION_STATE2); +// +// +// + RegCloseKey(myKey); +} + +//////////////////////////////////////////////////////////////////////// + +HWND gHWND; + +static HRESULT WINAPI Enum3DDevicesCallback( GUID* pGUID, LPSTR strDesc, + LPSTR strName, LPD3DDEVICEDESC pHALDesc, + LPD3DDEVICEDESC pHELDesc, LPVOID pvContext ) +{ + BOOL IsHardware; + + // Check params + if( NULL==pGUID || NULL==pHALDesc || NULL==pHELDesc) + return D3DENUMRET_CANCEL; + + // Handle specific device GUIDs. NullDevice renders nothing + if( IsEqualGUID( pGUID, &IID_IDirect3DNullDevice ) ) + return D3DENUMRET_OK; + + IsHardware = ( 0 != pHALDesc->dwFlags ); + if(!IsHardware) return D3DENUMRET_OK; + + bDeviceOK=TRUE; + + return D3DENUMRET_OK; +} + +static BOOL WINAPI DirectDrawEnumCallbackEx( GUID FAR* pGUID, LPSTR strDesc, + LPSTR strName, VOID* pV, + HMONITOR hMonitor ) +{ + // Use the GUID to create the DirectDraw object, so that information + // can be extracted from it. + + LPDIRECTDRAW pDD; + LPDIRECTDRAW4 g_pDD; + LPDIRECT3D3 pD3D; + + if( FAILED( DirectDrawCreate( pGUID, &pDD, 0L ) ) ) + { + return D3DENUMRET_OK; + } + + // Query the DirectDraw driver for access to Direct3D. + if( FAILED(IDirectDraw_QueryInterface(pDD, &IID_IDirectDraw4, (VOID**)&g_pDD))) + { + IDirectDraw_Release(pDD); + return D3DENUMRET_OK; + } + IDirectDraw_Release(pDD); + + // Query the DirectDraw driver for access to Direct3D. + + if( FAILED( IDirectDraw4_QueryInterface(g_pDD,&IID_IDirect3D3, (VOID**)&pD3D))) + { + IDirectDraw4_Release(g_pDD); + return D3DENUMRET_OK; + } + + bDeviceOK=FALSE; + + // Now, enumerate all the 3D devices + IDirect3D3_EnumDevices(pD3D,Enum3DDevicesCallback,NULL); + + if(bDeviceOK) + { + HWND hWC=GetDlgItem(gHWND,IDC_DEVICE); + int i=ComboBox_AddString(hWC,strDesc); + GUID * g=(GUID *)malloc(sizeof(GUID)); + if(NULL != pGUID) *g=*pGUID; + else memset(g,0,sizeof(GUID)); + ComboBox_SetItemData(hWC,i,g); + } + + IDirect3D3_Release(pD3D); + IDirectDraw4_Release(g_pDD); + return DDENUMRET_OK; +} + +//----------------------------------------------------------------------------- + +static BOOL WINAPI DirectDrawEnumCallback( GUID FAR* pGUID, LPSTR strDesc, + LPSTR strName, VOID* pV) +{ + return DirectDrawEnumCallbackEx( pGUID, strDesc, strName, NULL, NULL ); +} + +//----------------------------------------------------------------------------- + +void DoDevEnum(HWND hW) +{ + LPDIRECTDRAWENUMERATEEX pDDrawEnumFn; + + HMODULE hDDrawDLL = GetModuleHandle("DDRAW.DLL"); + if(NULL == hDDrawDLL) return; + + gHWND=hW; + + pDDrawEnumFn = (LPDIRECTDRAWENUMERATEEX) + GetProcAddress( hDDrawDLL, "DirectDrawEnumerateExA" ); + + if(pDDrawEnumFn) + pDDrawEnumFn( DirectDrawEnumCallbackEx, NULL, + DDENUM_ATTACHEDSECONDARYDEVICES | + DDENUM_DETACHEDSECONDARYDEVICES | + DDENUM_NONDISPLAYDEVICES ); + else + DirectDrawEnumerate( DirectDrawEnumCallback, NULL ); +} + +//////////////////////////////////////////////////////////////////////// + +void FreeGui(HWND hW) +{ + int i,iCnt; + HWND hWC=GetDlgItem(hW,IDC_DEVICE); + iCnt=ComboBox_GetCount(hWC); + for(i=0;i<iCnt;i++) + { + free((GUID *)ComboBox_GetItemData(hWC,i)); + } +} + +//////////////////////////////////////////////////////////////////////// + +BOOL CALLBACK DeviceDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + HWND hWC;int i; + DoDevEnum(hW); + hWC=GetDlgItem(hW,IDC_DEVICE); + i=ComboBox_FindStringExact(hWC,-1,szDevName); + if(i==CB_ERR) i=0; + ComboBox_SetCurSel(hWC,i); + hWC=GetDlgItem(hW,IDC_GAMMA); + ScrollBar_SetRange(hWC,0,1024,FALSE); + if(iUseGammaVal==2048) ScrollBar_SetPos(hWC,512,FALSE); + else + { + ScrollBar_SetPos(hWC,iUseGammaVal,FALSE); + CheckDlgButton(hW,IDC_USEGAMMA,TRUE); + } + } + + case WM_HSCROLL: + { + HWND hWC=GetDlgItem(hW,IDC_GAMMA); + int pos=ScrollBar_GetPos(hWC); + switch(LOWORD(wParam)) + { + case SB_THUMBPOSITION: + pos=HIWORD(wParam);break; + case SB_LEFT: + pos=0;break; + case SB_RIGHT: + pos=1024;break; + case SB_LINELEFT: + pos-=16;break; + case SB_LINERIGHT: + pos+=16;break; + case SB_PAGELEFT: + pos-=128;break; + case SB_PAGERIGHT: + pos+=128;break; + + } + ScrollBar_SetPos(hWC,pos,TRUE); + return TRUE; + } + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDCANCEL: FreeGui(hW); + EndDialog(hW,FALSE);return TRUE; + case IDOK: + { + HWND hWC=GetDlgItem(hW,IDC_DEVICE); + int i=ComboBox_GetCurSel(hWC); + if(i==CB_ERR) return TRUE; + guiDev=*((GUID *)ComboBox_GetItemData(hWC,i)); + ComboBox_GetLBText(hWC,i,szDevName); + FreeGui(hW); + + if(!IsDlgButtonChecked(hW,IDC_USEGAMMA)) + iUseGammaVal=2048; + else + iUseGammaVal=ScrollBar_GetPos(GetDlgItem(hW,IDC_GAMMA)); + + EndDialog(hW,TRUE); + return TRUE; + } + } + } + } + return FALSE; +} + +//////////////////////////////////////////////////////////////////////// + +void SelectDev(HWND hW) +{ + if(DialogBox(hInst,MAKEINTRESOURCE(IDD_DEVICE), + hW,(DLGPROC)DeviceDlgProc)==IDOK) + { + SetDlgItemText(hW,IDC_DEVICETXT,szDevName); + } +} + + +//////////////////////////////////////////////////////////////////////// + +static HRESULT WINAPI EnumDisplayModesCallback( DDSURFACEDESC2* pddsd, + VOID* pvContext ) +{ + if(NULL==pddsd) return DDENUMRET_CANCEL; + + if(pddsd->ddpfPixelFormat.dwRGBBitCount==(unsigned int)iColDepth && + pddsd->dwWidth==(unsigned int)iResX && + pddsd->dwHeight==(unsigned int)iResY) + { + bDeviceOK=TRUE; + return DDENUMRET_CANCEL; + } + + return DDENUMRET_OK; +} + +//////////////////////////////////////////////////////////////////////// + +BOOL bTestModes(void) +{ + LPDIRECTDRAW pDD; + LPDIRECTDRAW4 g_pDD; + + GUID FAR * guid=0; + int i;unsigned char * c=(unsigned char *)&guiDev; + for(i=0;i<sizeof(GUID);i++,c++) + {if(*c) {guid=&guiDev;break;}} + + bDeviceOK=FALSE; + + if( FAILED( DirectDrawCreate(guid, &pDD, 0L ) ) ) + return FALSE; + + if(FAILED(IDirectDraw_QueryInterface(pDD, &IID_IDirectDraw4, (VOID**)&g_pDD))) + { + IDirectDraw_Release(pDD); + return FALSE; + } + IDirectDraw_Release(pDD); + + IDirectDraw4_EnumDisplayModes(g_pDD,0,NULL,NULL,EnumDisplayModesCallback); + + IDirectDraw4_Release(g_pDD); + + return bDeviceOK; +} + +//////////////////////////////////////////////////////////////////////// +// define key dialog +//////////////////////////////////////////////////////////////////////// + +typedef struct KEYSETSTAG +{ + char szName[10]; + char cCode; +} +KEYSETS; + +KEYSETS tMKeys[]= +{ + {"SPACE", 0x20}, + {"PRIOR", 0x21}, + {"NEXT", 0x22}, + {"END", 0x23}, + {"HOME", 0x24}, + {"LEFT", 0x25}, + {"UP", 0x26}, + {"RIGHT", 0x27}, + {"DOWN", 0x28}, + {"SELECT", 0x29}, + {"PRINT", 0x2A}, + {"EXECUTE", 0x2B}, + {"SNAPSHOT", 0x2C}, + {"INSERT", 0x2D}, + {"DELETE", 0x2E}, + {"HELP", 0x2F}, + {"NUMPAD0", 0x60}, + {"NUMPAD1", 0x61}, + {"NUMPAD2", 0x62}, + {"NUMPAD3", 0x63}, + {"NUMPAD4", 0x64}, + {"NUMPAD5", 0x65}, + {"NUMPAD6", 0x66}, + {"NUMPAD7", 0x67}, + {"NUMPAD8", 0x68}, + {"NUMPAD9", 0x69}, + {"MULTIPLY", 0x6A}, + {"ADD", 0x6B}, + {"SEPARATOR", 0x6C}, + {"SUBTRACT", 0x6D}, + {"DECIMAL", 0x6E}, + {"DIVIDE", 0x6F}, + {"F9", VK_F9}, + {"F10", VK_F10}, + {"F11", VK_F11}, + {"F12", VK_F12}, + {"", 0x00} +}; + +void SetGPUKey(HWND hWC,char szKey) +{ + int i,iCnt=ComboBox_GetCount(hWC); + for(i=0;i<iCnt;i++) + { + if(ComboBox_GetItemData(hWC,i)==szKey) break; + } + if(i!=iCnt) ComboBox_SetCurSel(hWC,i); +} + +BOOL CALLBACK KeyDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + int i,j,k;char szB[2];HWND hWC; + for(i=IDC_KEY1;i<=IDC_KEY10;i++) + { + hWC=GetDlgItem(hW,i); + + for(j=0;tMKeys[j].cCode!=0;j++) + { + k=ComboBox_AddString(hWC,tMKeys[j].szName); + ComboBox_SetItemData(hWC,k,tMKeys[j].cCode); + } + for(j=0x30;j<=0x39;j++) + { + wsprintf(szB,"%c",j); + k=ComboBox_AddString(hWC,szB); + ComboBox_SetItemData(hWC,k,j); + } + for(j=0x41;j<=0x5a;j++) + { + wsprintf(szB,"%c",j); + k=ComboBox_AddString(hWC,szB); + ComboBox_SetItemData(hWC,k,j); + } + SetGPUKey(GetDlgItem(hW,i),szGPUKeys[i-IDC_KEY1]); + } + }return TRUE; + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDC_DEFAULT: + { + int i; + for(i=IDC_KEY1;i<=IDC_KEY10;i++) + SetGPUKey(GetDlgItem(hW,i),szKeyDefaults[i-IDC_KEY1]); + }break; + + case IDCANCEL: EndDialog(hW,FALSE); return TRUE; + case IDOK: + { + HWND hWC;int i; + for(i=IDC_KEY1;i<=IDC_KEY10;i++) + { + hWC=GetDlgItem(hW,i); + szGPUKeys[i-IDC_KEY1]=(char)ComboBox_GetItemData(hWC,ComboBox_GetCurSel(hWC)); + if(szGPUKeys[i-IDC_KEY1]<0x20) szGPUKeys[i-IDC_KEY1]=0x20; + } + EndDialog(hW,TRUE); + return TRUE; + } + } + } + } + return FALSE; +} + +void OnKeyConfig(HWND hW) +{ + DialogBox(hInst,MAKEINTRESOURCE(IDD_KEYS), + hW,(DLGPROC)KeyDlgProc); +} + diff --git a/win32/plugins/dfxvideo/winsrc/draw.c b/win32/plugins/dfxvideo/winsrc/draw.c new file mode 100644 index 00000000..d25104d6 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/draw.c @@ -0,0 +1,4762 @@ +/*************************************************************************** + draw.c - description + ------------------- + begin : Sun Oct 28 2001 + copyright : (C) 2001 by Pete Bernert + email : BlackDove@addcom.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ + +#define _IN_DRAW + +#include "externals.h" +#include "gpu.h" +#include "draw.h" +#include "prim.h" +#include "menu.h" +#include "interp.h" + +//////////////////////////////////////////////////////////////////////////////////// +// misc globals +//////////////////////////////////////////////////////////////////////////////////// + +int iResX; +int iResY; +long lLowerpart; +BOOL bIsFirstFrame = TRUE; +BOOL bCheckMask=FALSE; +unsigned short sSetMask=0; +unsigned long lSetMask=0; +int iDesktopCol=16; +int iShowFPS=0; +int iWinSize; +int iUseScanLines=0; +int iUseNoStretchBlt=0; +int iFastFwd=0; +int iDebugMode=0; +int iFVDisplay=0; +PSXPoint_t ptCursorPoint[8]; +unsigned short usCursorActive=0; + +unsigned int LUT16to32[65536]; +unsigned int RGBtoYUV[65536]; + +// prototypes +void hq2x_32( unsigned char * srcPtr, DWORD srcPitch, unsigned char * dstPtr, int width, int height); +void hq2x( unsigned char * srcPtr, DWORD srcPitch, unsigned char * dstPtr, int width, int height); +void hq3x_16( unsigned char * srcPtr, DWORD srcPitch, unsigned char * dstPtr, int width, int height); +void hq3x_32( unsigned char * srcPtr, DWORD srcPitch, unsigned char * dstPtr, int width, int height); + +//////////////////////////////////////////////////////////////////////// +// generic 2xSaI helpers +//////////////////////////////////////////////////////////////////////// + +void * pSaISmallBuff=NULL; +void * pSaIBigBuff=NULL; + +#define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D)) + +static __inline int GetResult1(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E) +{ + int x = 0; + int y = 0; + int r = 0; + if (A == C) x+=1; else if (B == C) y+=1; + if (A == D) x+=1; else if (B == D) y+=1; + if (x <= 1) r+=1; + if (y <= 1) r-=1; + return r; +} + +static __inline int GetResult2(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E) +{ + int x = 0; + int y = 0; + int r = 0; + if (A == C) x+=1; else if (B == C) y+=1; + if (A == D) x+=1; else if (B == D) y+=1; + if (x <= 1) r-=1; + if (y <= 1) r+=1; + return r; +} + +#define colorMask8 0x00FEFEFE +#define lowPixelMask8 0x00010101 +#define qcolorMask8 0x00FCFCFC +#define qlowpixelMask8 0x00030303 + +#define INTERPOLATE8(A, B) ((((A & colorMask8) >> 1) + ((B & colorMask8) >> 1) + (A & B & lowPixelMask8))) +#define Q_INTERPOLATE8(A, B, C, D) (((((A & qcolorMask8) >> 2) + ((B & qcolorMask8) >> 2) + ((C & qcolorMask8) >> 2) + ((D & qcolorMask8) >> 2) \ + + ((((A & qlowpixelMask8) + (B & qlowpixelMask8) + (C & qlowpixelMask8) + (D & qlowpixelMask8)) >> 2) & qlowpixelMask8)))) + + +void Super2xSaI_ex8(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + DWORD srcPitchHalf = srcPitch>>1; + int finWidth = srcPitch>>2; + DWORD line; + DWORD *dP; + DWORD *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + DWORD color4, color5, color6; + DWORD color1, color2, color3; + DWORD colorA0, colorA1, colorA2, colorA3, + colorB0, colorB1, colorB2, colorB3, + colorS1, colorS2; + DWORD product1a, product1b, + product2a, product2b; + + line = 0; + + { + for (; height; height-=1) + { + bP = (DWORD *)srcPtr; + dP = (DWORD *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { +//--------------------------------------- B1 B2 +// 4 5 6 S2 +// 1 2 3 S1 +// A1 A2 + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) {iYA=0;} + else {iYA=finWidth;} + if(height>4) {iYB=finWidth;iYC=srcPitchHalf;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + colorB0 = *(bP- iYA - iXA); + colorB1 = *(bP- iYA); + colorB2 = *(bP- iYA + iXB); + colorB3 = *(bP- iYA + iXC); + + color4 = *(bP - iXA); + color5 = *(bP); + color6 = *(bP + iXB); + colorS2 = *(bP + iXC); + + color1 = *(bP + iYB - iXA); + color2 = *(bP + iYB); + color3 = *(bP + iYB + iXB); + colorS1= *(bP + iYB + iXC); + + colorA0 = *(bP + iYC - iXA); + colorA1 = *(bP + iYC); + colorA2 = *(bP + iYC + iXB); + colorA3 = *(bP + iYC + iXC); + + if (color2 == color6 && color5 != color3) + { + product2b = product1b = color2; + } + else + if (color5 == color3 && color2 != color6) + { + product2b = product1b = color5; + } + else + if (color5 == color3 && color2 == color6) + { + register int r = 0; + + r += GET_RESULT ((color6&0x00ffffff), (color5&0x00ffffff), (color1&0x00ffffff), (colorA1&0x00ffffff)); + r += GET_RESULT ((color6&0x00ffffff), (color5&0x00ffffff), (color4&0x00ffffff), (colorB1&0x00ffffff)); + r += GET_RESULT ((color6&0x00ffffff), (color5&0x00ffffff), (colorA2&0x00ffffff), (colorS1&0x00ffffff)); + r += GET_RESULT ((color6&0x00ffffff), (color5&0x00ffffff), (colorB2&0x00ffffff), (colorS2&0x00ffffff)); + + if (r > 0) + product2b = product1b = color6; + else + if (r < 0) + product2b = product1b = color5; + else + { + product2b = product1b = INTERPOLATE8(color5, color6); + } + } + else + { + if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0) + product2b = Q_INTERPOLATE8 (color3, color3, color3, color2); + else + if (color5 == color2 && color2 == colorA2 && colorA1 != color3 && color2 != colorA3) + product2b = Q_INTERPOLATE8 (color2, color2, color2, color3); + else + product2b = INTERPOLATE8 (color2, color3); + + if (color6 == color3 && color6 == colorB1 && color5 != colorB2 && color6 != colorB0) + product1b = Q_INTERPOLATE8 (color6, color6, color6, color5); + else + if (color5 == color2 && color5 == colorB2 && colorB1 != color6 && color5 != colorB3) + product1b = Q_INTERPOLATE8 (color6, color5, color5, color5); + else + product1b = INTERPOLATE8 (color5, color6); + } + + if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2) + product2a = INTERPOLATE8(color2, color5); + else + if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0) + product2a = INTERPOLATE8(color2, color5); + else + product2a = color2; + + if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2) + product1a = INTERPOLATE8(color2, color5); + else + if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0) + product1a = INTERPOLATE8(color2, color5); + else + product1a = color5; + + *dP=product1a; + *(dP+1)=product1b; + *(dP+(srcPitchHalf))=product2a; + *(dP+1+(srcPitchHalf))=product2b; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +//////////////////////////////////////////////////////////////////////// + +void Std2xSaI_ex8(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + DWORD srcPitchHalf = srcPitch>>1; + int finWidth = srcPitch>>2; + DWORD line; + DWORD *dP; + DWORD *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + + DWORD colorA, colorB; + DWORD colorC, colorD, + colorE, colorF, colorG, colorH, + colorI, colorJ, colorK, colorL, + colorM, colorN, colorO, colorP; + DWORD product, product1, product2; + + line = 0; + + { + for (; height; height-=1) + { + bP = (DWORD *)srcPtr; + dP = (DWORD *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { +//--------------------------------------- +// Map of the pixels: I|E F|J +// G|A B|K +// H|C D|L +// M|N O|P + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) {iYA=0;} + else {iYA=finWidth;} + if(height>4) {iYB=finWidth;iYC=srcPitchHalf;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + colorI = *(bP- iYA - iXA); + colorE = *(bP- iYA); + colorF = *(bP- iYA + iXB); + colorJ = *(bP- iYA + iXC); + + colorG = *(bP - iXA); + colorA = *(bP); + colorB = *(bP + iXB); + colorK = *(bP + iXC); + + colorH = *(bP + iYB - iXA); + colorC = *(bP + iYB); + colorD = *(bP + iYB + iXB); + colorL = *(bP + iYB + iXC); + + colorM = *(bP + iYC - iXA); + colorN = *(bP + iYC); + colorO = *(bP + iYC + iXB); + colorP = *(bP + iYC + iXC); + + + if((colorA == colorD) && (colorB != colorC)) + { + if(((colorA == colorE) && (colorB == colorL)) || + ((colorA == colorC) && (colorA == colorF) && + (colorB != colorE) && (colorB == colorJ))) + { + product = colorA; + } + else + { + product = INTERPOLATE8(colorA, colorB); + } + + if(((colorA == colorG) && (colorC == colorO)) || + ((colorA == colorB) && (colorA == colorH) && + (colorG != colorC) && (colorC == colorM))) + { + product1 = colorA; + } + else + { + product1 = INTERPOLATE8(colorA, colorC); + } + product2 = colorA; + } + else + if((colorB == colorC) && (colorA != colorD)) + { + if(((colorB == colorF) && (colorA == colorH)) || + ((colorB == colorE) && (colorB == colorD) && + (colorA != colorF) && (colorA == colorI))) + { + product = colorB; + } + else + { + product = INTERPOLATE8(colorA, colorB); + } + + if(((colorC == colorH) && (colorA == colorF)) || + ((colorC == colorG) && (colorC == colorD) && + (colorA != colorH) && (colorA == colorI))) + { + product1 = colorC; + } + else + { + product1=INTERPOLATE8(colorA, colorC); + } + product2 = colorB; + } + else + if((colorA == colorD) && (colorB == colorC)) + { + if (colorA == colorB) + { + product = colorA; + product1 = colorA; + product2 = colorA; + } + else + { + register int r = 0; + product1 = INTERPOLATE8(colorA, colorC); + product = INTERPOLATE8(colorA, colorB); + + r += GetResult1 (colorA&0x00FFFFFF, colorB&0x00FFFFFF, colorG&0x00FFFFFF, colorE&0x00FFFFFF, colorI&0x00FFFFFF); + r += GetResult2 (colorB&0x00FFFFFF, colorA&0x00FFFFFF, colorK&0x00FFFFFF, colorF&0x00FFFFFF, colorJ&0x00FFFFFF); + r += GetResult2 (colorB&0x00FFFFFF, colorA&0x00FFFFFF, colorH&0x00FFFFFF, colorN&0x00FFFFFF, colorM&0x00FFFFFF); + r += GetResult1 (colorA&0x00FFFFFF, colorB&0x00FFFFFF, colorL&0x00FFFFFF, colorO&0x00FFFFFF, colorP&0x00FFFFFF); + + if (r > 0) + product2 = colorA; + else + if (r < 0) + product2 = colorB; + else + { + product2 = Q_INTERPOLATE8(colorA, colorB, colorC, colorD); + } + } + } + else + { + product2 = Q_INTERPOLATE8(colorA, colorB, colorC, colorD); + + if ((colorA == colorC) && (colorA == colorF) && + (colorB != colorE) && (colorB == colorJ)) + { + product = colorA; + } + else + if ((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI)) + { + product = colorB; + } + else + { + product = INTERPOLATE8(colorA, colorB); + } + + if ((colorA == colorB) && (colorA == colorH) && + (colorG != colorC) && (colorC == colorM)) + { + product1 = colorA; + } + else + if ((colorC == colorG) && (colorC == colorD) && + (colorA != colorH) && (colorA == colorI)) + { + product1 = colorC; + } + else + { + product1 = INTERPOLATE8(colorA, colorC); + } + } + +////////////////////////// + + *dP=colorA; + *(dP+1)=product; + *(dP+(srcPitchHalf))=product1; + *(dP+1+(srcPitchHalf))=product2; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +//////////////////////////////////////////////////////////////////////// + +void SuperEagle_ex8(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + DWORD srcPitchHalf = srcPitch>>1; + int finWidth = srcPitch>>2; + DWORD line; + DWORD *dP; + DWORD *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + DWORD color4, color5, color6; + DWORD color1, color2, color3; + DWORD colorA1, colorA2, + colorB1, colorB2, + colorS1, colorS2; + DWORD product1a, product1b, + product2a, product2b; + + line = 0; + + { + for (; height; height-=1) + { + bP = (DWORD *)srcPtr; + dP = (DWORD *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) {iYA=0;} + else {iYA=finWidth;} + if(height>4) {iYB=finWidth;iYC=srcPitchHalf;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + colorB1 = *(bP- iYA); + colorB2 = *(bP- iYA + iXB); + + color4 = *(bP - iXA); + color5 = *(bP); + color6 = *(bP + iXB); + colorS2 = *(bP + iXC); + + color1 = *(bP + iYB - iXA); + color2 = *(bP + iYB); + color3 = *(bP + iYB + iXB); + colorS1= *(bP + iYB + iXC); + + colorA1 = *(bP + iYC); + colorA2 = *(bP + iYC + iXB); + + if(color2 == color6 && color5 != color3) + { + product1b = product2a = color2; + if((color1 == color2) || + (color6 == colorB2)) + { + product1a = INTERPOLATE8(color2, color5); + product1a = INTERPOLATE8(color2, product1a); + } + else + { + product1a = INTERPOLATE8(color5, color6); + } + + if((color6 == colorS2) || + (color2 == colorA1)) + { + product2b = INTERPOLATE8(color2, color3); + product2b = INTERPOLATE8(color2, product2b); + } + else + { + product2b = INTERPOLATE8(color2, color3); + } + } + else + if (color5 == color3 && color2 != color6) + { + product2b = product1a = color5; + + if ((colorB1 == color5) || + (color3 == colorS1)) + { + product1b = INTERPOLATE8(color5, color6); + product1b = INTERPOLATE8(color5, product1b); + } + else + { + product1b = INTERPOLATE8(color5, color6); + } + + if ((color3 == colorA2) || + (color4 == color5)) + { + product2a = INTERPOLATE8(color5, color2); + product2a = INTERPOLATE8(color5, product2a); + } + else + { + product2a = INTERPOLATE8(color2, color3); + } + } + else + if (color5 == color3 && color2 == color6) + { + register int r = 0; + + r += GET_RESULT ((color6&0x00ffffff), (color5&0x00ffffff), (color1&0x00ffffff), (colorA1&0x00ffffff)); + r += GET_RESULT ((color6&0x00ffffff), (color5&0x00ffffff), (color4&0x00ffffff), (colorB1&0x00ffffff)); + r += GET_RESULT ((color6&0x00ffffff), (color5&0x00ffffff), (colorA2&0x00ffffff), (colorS1&0x00ffffff)); + r += GET_RESULT ((color6&0x00ffffff), (color5&0x00ffffff), (colorB2&0x00ffffff), (colorS2&0x00ffffff)); + + if (r > 0) + { + product1b = product2a = color2; + product1a = product2b = INTERPOLATE8(color5, color6); + } + else + if (r < 0) + { + product2b = product1a = color5; + product1b = product2a = INTERPOLATE8(color5, color6); + } + else + { + product2b = product1a = color5; + product1b = product2a = color2; + } + } + else + { + product2b = product1a = INTERPOLATE8(color2, color6); + product2b = Q_INTERPOLATE8(color3, color3, color3, product2b); + product1a = Q_INTERPOLATE8(color5, color5, color5, product1a); + + product2a = product1b = INTERPOLATE8(color5, color3); + product2a = Q_INTERPOLATE8(color2, color2, color2, product2a); + product1b = Q_INTERPOLATE8(color6, color6, color6, product1b); + } + +//////////////////////////////// + + *dP=product1a; + *(dP+1)=product1b; + *(dP+(srcPitchHalf))=product2a; + *(dP+1+(srcPitchHalf))=product2b; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +///////////////////////// + +static __inline void scale2x_32_def_whole(unsigned long* dst0, unsigned long* dst1, const unsigned long* src0, const unsigned long* src1, const unsigned long* src2, unsigned count) +{ + // first pixel + if (src0[0] != src2[0] && src1[0] != src1[1]) { + dst0[0] = src1[0] == src0[0] ? src0[0] : src1[0]; + dst0[1] = src1[1] == src0[0] ? src0[0] : src1[0]; + dst1[0] = src1[0] == src2[0] ? src2[0] : src1[0]; + dst1[1] = src1[1] == src2[0] ? src2[0] : src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + } + ++src0; + ++src1; + ++src2; + dst0 += 2; + dst1 += 2; + + // central pixels + count -= 2; + while (count) { + if (src0[0] != src2[0] && src1[-1] != src1[1]) { + dst0[0] = src1[-1] == src0[0] ? src0[0] : src1[0]; + dst0[1] = src1[1] == src0[0] ? src0[0] : src1[0]; + dst1[0] = src1[-1] == src2[0] ? src2[0] : src1[0]; + dst1[1] = src1[1] == src2[0] ? src2[0] : src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + } + + ++src0; + ++src1; + ++src2; + dst0 += 2; + dst1 += 2; + --count; + } + + // last pixel + if (src0[0] != src2[0] && src1[-1] != src1[0]) { + dst0[0] = src1[-1] == src0[0] ? src0[0] : src1[0]; + dst0[1] = src1[0] == src0[0] ? src0[0] : src1[0]; + dst1[0] = src1[-1] == src2[0] ? src2[0] : src1[0]; + dst1[1] = src1[0] == src2[0] ? src2[0] : src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + } +} + +void Scale2x_ex8(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstPtr, int width, int height) +{ + const int dstPitch = srcPitch<<1; + + int count = height; + + unsigned long *dst0 = (unsigned long *)dstPtr; + unsigned long *dst1 = dst0 + (dstPitch >> 2); + + unsigned long *src0 = (unsigned long *)srcPtr; + unsigned long *src1 = src0 + (srcPitch >> 2); + unsigned long *src2 = src1 + (srcPitch >> 2); + scale2x_32_def_whole(dst0, dst1, src0, src0, src1, width); + + count -= 2; + while(count) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + scale2x_32_def_whole(dst0, dst1, src0, src0, src1, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + scale2x_32_def_whole(dst0, dst1, src0, src1, src1, width); + +} + +//////////////////////////////////////////////////////////////////////// + +static __inline void scale3x_32_def_whole(unsigned long* dst0, unsigned long* dst1, unsigned long* dst2, const unsigned long* src0, const unsigned long* src1, const unsigned long* src2, unsigned count) +{ + //first pixel + if (src0[0] != src2[0] && src1[0] != src1[1]) { + dst0[0] = src1[0]; + dst0[1] = (src1[0] == src0[0] && src1[0] != src0[1]) || (src1[1] == src0[0] && src1[0] != src0[0]) ? src0[0] : src1[0]; + dst0[2] = src1[1] == src0[0] ? src1[1] : src1[0]; + dst1[0] = (src1[0] == src0[0] && src1[0] != src2[0]) || (src1[0] == src2[0] && src1[0] != src0[0]) ? src1[0] : src1[0]; + dst1[1] = src1[0]; + dst1[2] = (src1[1] == src0[0] && src1[0] != src2[1]) || (src1[1] == src2[0] && src1[0] != src0[1]) ? src1[1] : src1[0]; + dst2[0] = src1[0]; + dst2[1] = (src1[0] == src2[0] && src1[0] != src2[1]) || (src1[1] == src2[0] && src1[0] != src2[0]) ? src2[0] : src1[0]; + dst2[2] = src1[1] == src2[0] ? src1[1] : src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst0[2] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + dst1[2] = src1[0]; + dst2[0] = src1[0]; + dst2[1] = src1[0]; + dst2[2] = src1[0]; + } + ++src0; + ++src1; + ++src2; + dst0 += 3; + dst1 += 3; + dst2 += 3; + + //central pixels + count -= 2; + while (count) { + if (src0[0] != src2[0] && src1[-1] != src1[1]) { + dst0[0] = src1[-1] == src0[0] ? src1[-1] : src1[0]; + dst0[1] = (src1[-1] == src0[0] && src1[0] != src0[1]) || (src1[1] == src0[0] && src1[0] != src0[-1]) ? src0[0] : src1[0]; + dst0[2] = src1[1] == src0[0] ? src1[1] : src1[0]; + dst1[0] = (src1[-1] == src0[0] && src1[0] != src2[-1]) || (src1[-1] == src2[0] && src1[0] != src0[-1]) ? src1[-1] : src1[0]; + dst1[1] = src1[0]; + dst1[2] = (src1[1] == src0[0] && src1[0] != src2[1]) || (src1[1] == src2[0] && src1[0] != src0[1]) ? src1[1] : src1[0]; + dst2[0] = src1[-1] == src2[0] ? src1[-1] : src1[0]; + dst2[1] = (src1[-1] == src2[0] && src1[0] != src2[1]) || (src1[1] == src2[0] && src1[0] != src2[-1]) ? src2[0] : src1[0]; + dst2[2] = src1[1] == src2[0] ? src1[1] : src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst0[2] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + dst1[2] = src1[0]; + dst2[0] = src1[0]; + dst2[1] = src1[0]; + dst2[2] = src1[0]; + } + + ++src0; + ++src1; + ++src2; + dst0 += 3; + dst1 += 3; + dst2 += 3; + --count; + } + + // last pixel + if (src0[0] != src2[0] && src1[-1] != src1[0]) { + dst0[0] = src1[-1] == src0[0] ? src1[-1] : src1[0]; + dst0[1] = (src1[-1] == src0[0] && src1[0] != src0[0]) || (src1[0] == src0[0] && src1[0] != src0[-1]) ? src0[0] : src1[0]; + dst0[2] = src1[0]; + dst1[0] = (src1[-1] == src0[0] && src1[0] != src2[-1]) || (src1[-1] == src2[0] && src1[0] != src0[-1]) ? src1[-1] : src1[0]; + dst1[1] = src1[0]; + dst1[2] = (src1[0] == src0[0] && src1[0] != src2[0]) || (src1[0] == src2[0] && src1[0] != src0[0]) ? src1[0] : src1[0]; + dst2[0] = src1[-1] == src2[0] ? src1[-1] : src1[0]; + dst2[1] = (src1[-1] == src2[0] && src1[0] != src2[0]) || (src1[0] == src2[0] && src1[0] != src2[-1]) ? src2[0] : src1[0]; + dst2[2] = src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst0[2] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + dst1[2] = src1[0]; + dst2[0] = src1[0]; + dst2[1] = src1[0]; + dst2[2] = src1[0]; + } +} + + +void Scale3x_ex8(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstPtr, int width, int height) +{ + int count = height; + + int dstPitch = srcPitch >> 1; + + + unsigned long *dst0 = (unsigned long *)dstPtr; + unsigned long *dst1 = dst0 + dstPitch; + unsigned long *dst2 = dst1 + dstPitch; + + unsigned long *src0 = (unsigned long *)srcPtr; + unsigned long *src1 = src0 + (srcPitch >> 2); + unsigned long *src2 = src1 + (srcPitch >> 2); + scale3x_32_def_whole(dst0, dst1, dst2, src0, src0, src2, width); + + count -= 2; + while(count) { + dst0 += dstPitch * 3; + dst1 += dstPitch * 3; + dst2 += dstPitch * 3; + + scale3x_32_def_whole(dst0, dst1, dst2, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch * 3; + dst1 += dstPitch * 3; + dst2 += dstPitch * 3; + + scale3x_32_def_whole(dst0, dst1, dst2, src0, src1, src1, width); +} + + +//////////////////////////////////////////////////////////////////////// + +#define colorMask6 0x0000F7DE +#define lowPixelMask6 0x00000821 +#define qcolorMask6 0x0000E79c +#define qlowpixelMask6 0x00001863 + +#define INTERPOLATE6(A, B) ((((A & colorMask6) >> 1) + ((B & colorMask6) >> 1) + (A & B & lowPixelMask6))) +#define Q_INTERPOLATE6(A, B, C, D) (((((A & qcolorMask6) >> 2) + ((B & qcolorMask6) >> 2) + ((C & qcolorMask6) >> 2) + ((D & qcolorMask6) >> 2) \ + + ((((A & qlowpixelMask6) + (B & qlowpixelMask6) + (C & qlowpixelMask6) + (D & qlowpixelMask6)) >> 2) & qlowpixelMask6)))) + +void Super2xSaI_ex6(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + int finWidth = srcPitch>>1; + DWORD line; + unsigned short *dP; + unsigned short *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + DWORD color4, color5, color6; + DWORD color1, color2, color3; + DWORD colorA0, colorA1, colorA2, colorA3, + colorB0, colorB1, colorB2, colorB3, + colorS1, colorS2; + DWORD product1a, product1b, + product2a, product2b; + + line = 0; + + { + for (; height; height-=1) + { + bP = (unsigned short *)srcPtr; + dP = (unsigned short *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { +//--------------------------------------- B1 B2 +// 4 5 6 S2 +// 1 2 3 S1 +// A1 A2 + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) iYA=0; + else iYA=finWidth; + if(height>4) {iYB=finWidth;iYC=srcPitch;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + + colorB0 = *(bP- iYA - iXA); + colorB1 = *(bP- iYA); + colorB2 = *(bP- iYA + iXB); + colorB3 = *(bP- iYA + iXC); + + color4 = *(bP - iXA); + color5 = *(bP); + color6 = *(bP + iXB); + colorS2 = *(bP + iXC); + + color1 = *(bP + iYB - iXA); + color2 = *(bP + iYB); + color3 = *(bP + iYB + iXB); + colorS1= *(bP + iYB + iXC); + + colorA0 = *(bP + iYC - iXA); + colorA1 = *(bP + iYC); + colorA2 = *(bP + iYC + iXB); + colorA3 = *(bP + iYC + iXC); + +//-------------------------------------- + if (color2 == color6 && color5 != color3) + { + product2b = product1b = color2; + } + else + if (color5 == color3 && color2 != color6) + { + product2b = product1b = color5; + } + else + if (color5 == color3 && color2 == color6) + { + register int r = 0; + + r += GET_RESULT ((color6), (color5), (color1), (colorA1)); + r += GET_RESULT ((color6), (color5), (color4), (colorB1)); + r += GET_RESULT ((color6), (color5), (colorA2), (colorS1)); + r += GET_RESULT ((color6), (color5), (colorB2), (colorS2)); + + if (r > 0) + product2b = product1b = color6; + else + if (r < 0) + product2b = product1b = color5; + else + { + product2b = product1b = INTERPOLATE6 (color5, color6); + } + } + else + { + if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0) + product2b = Q_INTERPOLATE6 (color3, color3, color3, color2); + else + if (color5 == color2 && color2 == colorA2 && colorA1 != color3 && color2 != colorA3) + product2b = Q_INTERPOLATE6 (color2, color2, color2, color3); + else + product2b = INTERPOLATE6 (color2, color3); + + if (color6 == color3 && color6 == colorB1 && color5 != colorB2 && color6 != colorB0) + product1b = Q_INTERPOLATE6 (color6, color6, color6, color5); + else + if (color5 == color2 && color5 == colorB2 && colorB1 != color6 && color5 != colorB3) + product1b = Q_INTERPOLATE6 (color6, color5, color5, color5); + else + product1b = INTERPOLATE6 (color5, color6); + } + + if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2) + product2a = INTERPOLATE6 (color2, color5); + else + if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0) + product2a = INTERPOLATE6(color2, color5); + else + product2a = color2; + + if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2) + product1a = INTERPOLATE6(color2, color5); + else + if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0) + product1a = INTERPOLATE6(color2, color5); + else + product1a = color5; + + *dP=(unsigned short)product1a; + *(dP+1)=(unsigned short)product1b; + *(dP+(srcPitch))=(unsigned short)product2a; + *(dP+1+(srcPitch))=(unsigned short)product2b; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +//////////////////////////////////////////////////////////////////////// + +void Std2xSaI_ex6(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + int finWidth = srcPitch>>1; + DWORD line; + unsigned short *dP; + unsigned short *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + + DWORD colorA, colorB; + DWORD colorC, colorD, + colorE, colorF, colorG, colorH, + colorI, colorJ, colorK, colorL, + colorM, colorN, colorO, colorP; + DWORD product, product1, product2; + + line = 0; + + { + for (; height; height-=1) + { + bP = (unsigned short *)srcPtr; + dP = (unsigned short *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { +//--------------------------------------- +// Map of the pixels: I|E F|J +// G|A B|K +// H|C D|L +// M|N O|P + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) iYA=0; + else iYA=finWidth; + if(height>4) {iYB=finWidth;iYC=srcPitch;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + colorI = *(bP- iYA - iXA); + colorE = *(bP- iYA); + colorF = *(bP- iYA + iXB); + colorJ = *(bP- iYA + iXC); + + colorG = *(bP - iXA); + colorA = *(bP); + colorB = *(bP + iXB); + colorK = *(bP + iXC); + + colorH = *(bP + iYB - iXA); + colorC = *(bP + iYB); + colorD = *(bP + iYB + iXB); + colorL = *(bP + iYB + iXC); + + colorM = *(bP + iYC - iXA); + colorN = *(bP + iYC); + colorO = *(bP + iYC + iXB); + colorP = *(bP + iYC + iXC); + + if((colorA == colorD) && (colorB != colorC)) + { + if(((colorA == colorE) && (colorB == colorL)) || + ((colorA == colorC) && (colorA == colorF) && + (colorB != colorE) && (colorB == colorJ))) + { + product = colorA; + } + else + { + product = INTERPOLATE6(colorA, colorB); + } + + if(((colorA == colorG) && (colorC == colorO)) || + ((colorA == colorB) && (colorA == colorH) && + (colorG != colorC) && (colorC == colorM))) + { + product1 = colorA; + } + else + { + product1 = INTERPOLATE6(colorA, colorC); + } + product2 = colorA; + } + else + if((colorB == colorC) && (colorA != colorD)) + { + if(((colorB == colorF) && (colorA == colorH)) || + ((colorB == colorE) && (colorB == colorD) && + (colorA != colorF) && (colorA == colorI))) + { + product = colorB; + } + else + { + product = INTERPOLATE6(colorA, colorB); + } + + if(((colorC == colorH) && (colorA == colorF)) || + ((colorC == colorG) && (colorC == colorD) && + (colorA != colorH) && (colorA == colorI))) + { + product1 = colorC; + } + else + { + product1=INTERPOLATE6(colorA, colorC); + } + product2 = colorB; + } + else + if((colorA == colorD) && (colorB == colorC)) + { + if (colorA == colorB) + { + product = colorA; + product1 = colorA; + product2 = colorA; + } + else + { + register int r = 0; + product1 = INTERPOLATE6(colorA, colorC); + product = INTERPOLATE6(colorA, colorB); + + r += GetResult1 (colorA, colorB, colorG, colorE, colorI); + r += GetResult2 (colorB, colorA, colorK, colorF, colorJ); + r += GetResult2 (colorB, colorA, colorH, colorN, colorM); + r += GetResult1 (colorA, colorB, colorL, colorO, colorP); + + if (r > 0) + product2 = colorA; + else + if (r < 0) + product2 = colorB; + else + { + product2 = Q_INTERPOLATE6(colorA, colorB, colorC, colorD); + } + } + } + else + { + product2 = Q_INTERPOLATE6(colorA, colorB, colorC, colorD); + + if ((colorA == colorC) && (colorA == colorF) && + (colorB != colorE) && (colorB == colorJ)) + { + product = colorA; + } + else + if ((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI)) + { + product = colorB; + } + else + { + product = INTERPOLATE6(colorA, colorB); + } + + if ((colorA == colorB) && (colorA == colorH) && + (colorG != colorC) && (colorC == colorM)) + { + product1 = colorA; + } + else + if ((colorC == colorG) && (colorC == colorD) && + (colorA != colorH) && (colorA == colorI)) + { + product1 = colorC; + } + else + { + product1 = INTERPOLATE6(colorA, colorC); + } + } + + *dP=(unsigned short)colorA; + *(dP+1)=(unsigned short)product; + *(dP+(srcPitch))=(unsigned short)product1; + *(dP+1+(srcPitch))=(unsigned short)product2; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +//////////////////////////////////////////////////////////////////////// + +void SuperEagle_ex6(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + int finWidth = srcPitch>>1; + DWORD line; + unsigned short *dP; + unsigned short *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + DWORD color4, color5, color6; + DWORD color1, color2, color3; + DWORD colorA1, colorA2, + colorB1, colorB2, + colorS1, colorS2; + DWORD product1a, product1b, + product2a, product2b; + + line = 0; + + { + for (; height; height-=1) + { + bP = (unsigned short *)srcPtr; + dP = (unsigned short *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) iYA=0; + else iYA=finWidth; + if(height>4) {iYB=finWidth;iYC=srcPitch;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + colorB1 = *(bP- iYA); + colorB2 = *(bP- iYA + iXB); + + color4 = *(bP - iXA); + color5 = *(bP); + color6 = *(bP + iXB); + colorS2 = *(bP + iXC); + + color1 = *(bP + iYB - iXA); + color2 = *(bP + iYB); + color3 = *(bP + iYB + iXB); + colorS1= *(bP + iYB + iXC); + + colorA1 = *(bP + iYC); + colorA2 = *(bP + iYC + iXB); + + if(color2 == color6 && color5 != color3) + { + product1b = product2a = color2; + if((color1 == color2) || + (color6 == colorB2)) + { + product1a = INTERPOLATE6(color2, color5); + product1a = INTERPOLATE6(color2, product1a); + } + else + { + product1a = INTERPOLATE6(color5, color6); + } + + if((color6 == colorS2) || + (color2 == colorA1)) + { + product2b = INTERPOLATE6(color2, color3); + product2b = INTERPOLATE6(color2, product2b); + } + else + { + product2b = INTERPOLATE6(color2, color3); + } + } + else + if (color5 == color3 && color2 != color6) + { + product2b = product1a = color5; + + if ((colorB1 == color5) || + (color3 == colorS1)) + { + product1b = INTERPOLATE6(color5, color6); + product1b = INTERPOLATE6(color5, product1b); + } + else + { + product1b = INTERPOLATE6(color5, color6); + } + + if ((color3 == colorA2) || + (color4 == color5)) + { + product2a = INTERPOLATE6(color5, color2); + product2a = INTERPOLATE6(color5, product2a); + } + else + { + product2a = INTERPOLATE6(color2, color3); + } + } + else + if (color5 == color3 && color2 == color6) + { + register int r = 0; + + r += GET_RESULT ((color6), (color5), (color1), (colorA1)); + r += GET_RESULT ((color6), (color5), (color4), (colorB1)); + r += GET_RESULT ((color6), (color5), (colorA2), (colorS1)); + r += GET_RESULT ((color6), (color5), (colorB2), (colorS2)); + + if (r > 0) + { + product1b = product2a = color2; + product1a = product2b = INTERPOLATE6(color5, color6); + } + else + if (r < 0) + { + product2b = product1a = color5; + product1b = product2a = INTERPOLATE6(color5, color6); + } + else + { + product2b = product1a = color5; + product1b = product2a = color2; + } + } + else + { + product2b = product1a = INTERPOLATE6(color2, color6); + product2b = Q_INTERPOLATE6(color3, color3, color3, product2b); + product1a = Q_INTERPOLATE6(color5, color5, color5, product1a); + + product2a = product1b = INTERPOLATE6(color5, color3); + product2a = Q_INTERPOLATE6(color2, color2, color2, product2a); + product1b = Q_INTERPOLATE6(color6, color6, color6, product1b); + } + + *dP=(unsigned short)product1a; + *(dP+1)=(unsigned short)product1b; + *(dP+(srcPitch))=(unsigned short)product2a; + *(dP+1+(srcPitch))=(unsigned short)product2b; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +//////////////////////////////////////////////////////////////////////// + +#ifndef MAX +#define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +void Scale2x_ex6_5(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + int looph, loopw; + + unsigned char * srcpix = srcPtr; + unsigned char * dstpix = dstBitmap; + + const int srcpitch = srcPitch; + const int dstpitch = srcPitch<<1; + + unsigned short E0, E1, E2, E3, B, D, E, F, H; + for(looph = 0; looph < height; ++looph) + { + for(loopw = 0; loopw < width; ++ loopw) + { + B = *(unsigned short*)(srcpix + (MAX(0,looph-1)*srcpitch) + (2*loopw)); + D = *(unsigned short*)(srcpix + (looph*srcpitch) + (2*MAX(0,loopw-1))); + E = *(unsigned short*)(srcpix + (looph*srcpitch) + (2*loopw)); + F = *(unsigned short*)(srcpix + (looph*srcpitch) + (2*MIN(width-1,loopw+1))); + H = *(unsigned short*)(srcpix + (MIN(height-1,looph+1)*srcpitch) + (2*loopw)); + + if (B != H && D != F) { + E0 = D == B ? D : E; + E1 = B == F ? F : E; + E2 = D == H ? D : E; + E3 = H == F ? F : E; + } else { + E0 = E; + E1 = E; + E2 = E; + E3 = E; + } + + + *(unsigned short*)(dstpix + looph*2*dstpitch + loopw*2*2) = E0; + *(unsigned short*)(dstpix + looph*2*dstpitch + (loopw*2+1)*2) = E1; + *(unsigned short*)(dstpix + (looph*2+1)*dstpitch + loopw*2*2) = E2; + *(unsigned short*)(dstpix + (looph*2+1)*dstpitch + (loopw*2+1)*2) = E3; + } + } +} + +//////////////////////////////////////////////////////////////////////// +static __inline void scale3x_16_def_whole(unsigned short* dst0, unsigned short *dst1, unsigned short *dst2, const unsigned short *src0, const unsigned short *src1, const unsigned short *src2, unsigned count) +{ + //assert(count >= 2); + + /* first pixel */ + if (src0[0] != src2[0] && src1[0] != src1[1]) { + dst0[0] = src1[0]; + dst0[1] = (src1[0] == src0[0] && src1[0] != src0[1]) || (src1[1] == src0[0] && src1[0] != src0[0]) ? src0[0] : src1[0]; + dst0[2] = src1[1] == src0[0] ? src1[1] : src1[0]; + dst1[0] = (src1[0] == src0[0] && src1[0] != src2[0]) || (src1[0] == src2[0] && src1[0] != src0[0]) ? src1[0] : src1[0]; + dst1[1] = src1[0]; + dst1[2] = (src1[1] == src0[0] && src1[0] != src2[1]) || (src1[1] == src2[0] && src1[0] != src0[1]) ? src1[1] : src1[0]; + dst2[0] = src1[0]; + dst2[1] = (src1[0] == src2[0] && src1[0] != src2[1]) || (src1[1] == src2[0] && src1[0] != src2[0]) ? src2[0] : src1[0]; + dst2[2] = src1[1] == src2[0] ? src1[1] : src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst0[2] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + dst1[2] = src1[0]; + dst2[0] = src1[0]; + dst2[1] = src1[0]; + dst2[2] = src1[0]; + } + ++src0; + ++src1; + ++src2; + dst0 += 3; + dst1 += 3; + dst2 += 3; + + /* central pixels */ + count -= 2; + while (count) { + if (src0[0] != src2[0] && src1[-1] != src1[1]) { + dst0[0] = src1[-1] == src0[0] ? src1[-1] : src1[0]; + dst0[1] = (src1[-1] == src0[0] && src1[0] != src0[1]) || (src1[1] == src0[0] && src1[0] != src0[-1]) ? src0[0] : src1[0]; + dst0[2] = src1[1] == src0[0] ? src1[1] : src1[0]; + dst1[0] = (src1[-1] == src0[0] && src1[0] != src2[-1]) || (src1[-1] == src2[0] && src1[0] != src0[-1]) ? src1[-1] : src1[0]; + dst1[1] = src1[0]; + dst1[2] = (src1[1] == src0[0] && src1[0] != src2[1]) || (src1[1] == src2[0] && src1[0] != src0[1]) ? src1[1] : src1[0]; + dst2[0] = src1[-1] == src2[0] ? src1[-1] : src1[0]; + dst2[1] = (src1[-1] == src2[0] && src1[0] != src2[1]) || (src1[1] == src2[0] && src1[0] != src2[-1]) ? src2[0] : src1[0]; + dst2[2] = src1[1] == src2[0] ? src1[1] : src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst0[2] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + dst1[2] = src1[0]; + dst2[0] = src1[0]; + dst2[1] = src1[0]; + dst2[2] = src1[0]; + } + + ++src0; + ++src1; + ++src2; + dst0 += 3; + dst1 += 3; + dst2 += 3; + --count; + } + + /* last pixel */ + if (src0[0] != src2[0] && src1[-1] != src1[0]) { + dst0[0] = src1[-1] == src0[0] ? src1[-1] : src1[0]; + dst0[1] = (src1[-1] == src0[0] && src1[0] != src0[0]) || (src1[0] == src0[0] && src1[0] != src0[-1]) ? src0[0] : src1[0]; + dst0[2] = src1[0]; + dst1[0] = (src1[-1] == src0[0] && src1[0] != src2[-1]) || (src1[-1] == src2[0] && src1[0] != src0[-1]) ? src1[-1] : src1[0]; + dst1[1] = src1[0]; + dst1[2] = (src1[0] == src0[0] && src1[0] != src2[0]) || (src1[0] == src2[0] && src1[0] != src0[0]) ? src1[0] : src1[0]; + dst2[0] = src1[-1] == src2[0] ? src1[-1] : src1[0]; + dst2[1] = (src1[-1] == src2[0] && src1[0] != src2[0]) || (src1[0] == src2[0] && src1[0] != src2[-1]) ? src2[0] : src1[0]; + dst2[2] = src1[0]; + } else { + dst0[0] = src1[0]; + dst0[1] = src1[0]; + dst0[2] = src1[0]; + dst1[0] = src1[0]; + dst1[1] = src1[0]; + dst1[2] = src1[0]; + dst2[0] = src1[0]; + dst2[1] = src1[0]; + dst2[2] = src1[0]; + } +} + + + +void Scale3x_ex6_5(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstPtr, int width, int height) +{ + int count = height; + int dstPitch = srcPitch; + + unsigned short *dst0 = (unsigned short *)dstPtr; + unsigned short *dst1 = dst0 + dstPitch; + unsigned short *dst2 = dst1 + dstPitch; + + unsigned short *src0 = (unsigned short *)srcPtr; + unsigned short *src1 = src0 + (srcPitch >> 1); + unsigned short *src2 = src1 + (srcPitch >> 1); + scale3x_16_def_whole(dst0, dst1, dst2, src0, src1, src2, count); + + count -= 2; + while(count) { + + dst0 += dstPitch * 3; + dst1 += dstPitch * 3; + dst2 += dstPitch * 3; + + scale3x_16_def_whole(dst0, dst1, dst2, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } + dst0 += dstPitch * 3; + dst1 += dstPitch * 3; + dst2 += dstPitch * 3; + + scale3x_16_def_whole(dst0, dst1, dst2, src0, src1, src1, width); +} + +//////////////////////////////////////////////////////////////////////// + +/* +#define colorMask5 0x0000F7DE +#define lowPixelMask5 0x00000821 +#define qcolorMask5 0x0000E79c +#define qlowpixelMask5 0x00001863 +*/ + +#define colorMask5 0x00007BDE +#define lowPixelMask5 0x00000421 +#define qcolorMask5 0x0000739c +#define qlowpixelMask5 0x00000C63 + +#define INTERPOLATE5(A, B) ((((A & colorMask5) >> 1) + ((B & colorMask5) >> 1) + (A & B & lowPixelMask5))) +#define Q_INTERPOLATE5(A, B, C, D) (((((A & qcolorMask5) >> 2) + ((B & qcolorMask5) >> 2) + ((C & qcolorMask5) >> 2) + ((D & qcolorMask5) >> 2) \ + + ((((A & qlowpixelMask5) + (B & qlowpixelMask5) + (C & qlowpixelMask5) + (D & qlowpixelMask5)) >> 2) & qlowpixelMask5)))) + +void Super2xSaI_ex5(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + int finWidth = srcPitch>>1; + DWORD line; + unsigned short *dP; + unsigned short *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + DWORD color4, color5, color6; + DWORD color1, color2, color3; + DWORD colorA0, colorA1, colorA2, colorA3, + colorB0, colorB1, colorB2, colorB3, + colorS1, colorS2; + DWORD product1a, product1b, + product2a, product2b; + + line = 0; + + { + for (; height; height-=1) + { + bP = (unsigned short *)srcPtr; + dP = (unsigned short *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { +//--------------------------------------- B1 B2 +// 4 5 6 S2 +// 1 2 3 S1 +// A1 A2 + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) iYA=0; + else iYA=finWidth; + if(height>4) {iYB=finWidth;iYC=srcPitch;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + + colorB0 = *(bP- iYA - iXA); + colorB1 = *(bP- iYA); + colorB2 = *(bP- iYA + iXB); + colorB3 = *(bP- iYA + iXC); + + color4 = *(bP - iXA); + color5 = *(bP); + color6 = *(bP + iXB); + colorS2 = *(bP + iXC); + + color1 = *(bP + iYB - iXA); + color2 = *(bP + iYB); + color3 = *(bP + iYB + iXB); + colorS1= *(bP + iYB + iXC); + + colorA0 = *(bP + iYC - iXA); + colorA1 = *(bP + iYC); + colorA2 = *(bP + iYC + iXB); + colorA3 = *(bP + iYC + iXC); + +//-------------------------------------- + if (color2 == color6 && color5 != color3) + { + product2b = product1b = color2; + } + else + if (color5 == color3 && color2 != color6) + { + product2b = product1b = color5; + } + else + if (color5 == color3 && color2 == color6) + { + register int r = 0; + + r += GET_RESULT ((color6), (color5), (color1), (colorA1)); + r += GET_RESULT ((color6), (color5), (color4), (colorB1)); + r += GET_RESULT ((color6), (color5), (colorA2), (colorS1)); + r += GET_RESULT ((color6), (color5), (colorB2), (colorS2)); + + if (r > 0) + product2b = product1b = color6; + else + if (r < 0) + product2b = product1b = color5; + else + { + product2b = product1b = INTERPOLATE5 (color5, color6); + } + } + else + { + if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0) + product2b = Q_INTERPOLATE5 (color3, color3, color3, color2); + else + if (color5 == color2 && color2 == colorA2 && colorA1 != color3 && color2 != colorA3) + product2b = Q_INTERPOLATE5 (color2, color2, color2, color3); + else + product2b = INTERPOLATE5 (color2, color3); + + if (color6 == color3 && color6 == colorB1 && color5 != colorB2 && color6 != colorB0) + product1b = Q_INTERPOLATE5 (color6, color6, color6, color5); + else + if (color5 == color2 && color5 == colorB2 && colorB1 != color6 && color5 != colorB3) + product1b = Q_INTERPOLATE5 (color6, color5, color5, color5); + else + product1b = INTERPOLATE5 (color5, color6); + } + + if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2) + product2a = INTERPOLATE5 (color2, color5); + else + if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0) + product2a = INTERPOLATE5(color2, color5); + else + product2a = color2; + + if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2) + product1a = INTERPOLATE5(color2, color5); + else + if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0) + product1a = INTERPOLATE5(color2, color5); + else + product1a = color5; + + *dP=(unsigned short)product1a; + *(dP+1)=(unsigned short)product1b; + *(dP+(srcPitch))=(unsigned short)product2a; + *(dP+1+(srcPitch))=(unsigned short)product2b; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +//////////////////////////////////////////////////////////////////////// + +void Std2xSaI_ex5(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + int finWidth = srcPitch>>1; + DWORD line; + unsigned short *dP; + unsigned short *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + DWORD colorA, colorB; + DWORD colorC, colorD, + colorE, colorF, colorG, colorH, + colorI, colorJ, colorK, colorL, + colorM, colorN, colorO, colorP; + DWORD product, product1, product2; + + line = 0; + + { + for (; height; height-=1) + { + bP = (unsigned short *)srcPtr; + dP = (unsigned short *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { +//--------------------------------------- +// Map of the pixels: I|E F|J +// G|A B|K +// H|C D|L +// M|N O|P + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) iYA=0; + else iYA=finWidth; + if(height>4) {iYB=finWidth;iYC=srcPitch;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + colorI = *(bP- iYA - iXA); + colorE = *(bP- iYA); + colorF = *(bP- iYA + iXB); + colorJ = *(bP- iYA + iXC); + + colorG = *(bP - iXA); + colorA = *(bP); + colorB = *(bP + iXB); + colorK = *(bP + iXC); + + colorH = *(bP + iYB - iXA); + colorC = *(bP + iYB); + colorD = *(bP + iYB + iXB); + colorL = *(bP + iYB + iXC); + + colorM = *(bP + iYC - iXA); + colorN = *(bP + iYC); + colorO = *(bP + iYC + iXB); + colorP = *(bP + iYC + iXC); + + if((colorA == colorD) && (colorB != colorC)) + { + if(((colorA == colorE) && (colorB == colorL)) || + ((colorA == colorC) && (colorA == colorF) && + (colorB != colorE) && (colorB == colorJ))) + { + product = colorA; + } + else + { + product = INTERPOLATE5(colorA, colorB); + } + + if(((colorA == colorG) && (colorC == colorO)) || + ((colorA == colorB) && (colorA == colorH) && + (colorG != colorC) && (colorC == colorM))) + { + product1 = colorA; + } + else + { + product1 = INTERPOLATE5(colorA, colorC); + } + product2 = colorA; + } + else + if((colorB == colorC) && (colorA != colorD)) + { + if(((colorB == colorF) && (colorA == colorH)) || + ((colorB == colorE) && (colorB == colorD) && + (colorA != colorF) && (colorA == colorI))) + { + product = colorB; + } + else + { + product = INTERPOLATE5(colorA, colorB); + } + + if(((colorC == colorH) && (colorA == colorF)) || + ((colorC == colorG) && (colorC == colorD) && + (colorA != colorH) && (colorA == colorI))) + { + product1 = colorC; + } + else + { + product1=INTERPOLATE5(colorA, colorC); + } + product2 = colorB; + } + else + if((colorA == colorD) && (colorB == colorC)) + { + if (colorA == colorB) + { + product = colorA; + product1 = colorA; + product2 = colorA; + } + else + { + register int r = 0; + product1 = INTERPOLATE5(colorA, colorC); + product = INTERPOLATE5(colorA, colorB); + + r += GetResult1 (colorA, colorB, colorG, colorE, colorI); + r += GetResult2 (colorB, colorA, colorK, colorF, colorJ); + r += GetResult2 (colorB, colorA, colorH, colorN, colorM); + r += GetResult1 (colorA, colorB, colorL, colorO, colorP); + + if (r > 0) + product2 = colorA; + else + if (r < 0) + product2 = colorB; + else + { + product2 = Q_INTERPOLATE5(colorA, colorB, colorC, colorD); + } + } + } + else + { + product2 = Q_INTERPOLATE5(colorA, colorB, colorC, colorD); + + if ((colorA == colorC) && (colorA == colorF) && + (colorB != colorE) && (colorB == colorJ)) + { + product = colorA; + } + else + if ((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI)) + { + product = colorB; + } + else + { + product = INTERPOLATE5(colorA, colorB); + } + + if ((colorA == colorB) && (colorA == colorH) && + (colorG != colorC) && (colorC == colorM)) + { + product1 = colorA; + } + else + if ((colorC == colorG) && (colorC == colorD) && + (colorA != colorH) && (colorA == colorI)) + { + product1 = colorC; + } + else + { + product1 = INTERPOLATE5(colorA, colorC); + } + } + + *dP=(unsigned short)colorA; + *(dP+1)=(unsigned short)product; + *(dP+(srcPitch))=(unsigned short)product1; + *(dP+1+(srcPitch))=(unsigned short)product2; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +//////////////////////////////////////////////////////////////////////// + +void SuperEagle_ex5(unsigned char *srcPtr, DWORD srcPitch, + unsigned char *dstBitmap, int width, int height) +{ + DWORD dstPitch = srcPitch<<1; + int finWidth = srcPitch>>1; + DWORD line; + unsigned short *dP; + unsigned short *bP; + int iXA,iXB,iXC,iYA,iYB,iYC,finish; + DWORD color4, color5, color6; + DWORD color1, color2, color3; + DWORD colorA1, colorA2, + colorB1, colorB2, + colorS1, colorS2; + DWORD product1a, product1b, + product2a, product2b; + + line = 0; + + { + for (; height; height-=1) + { + bP = (unsigned short *)srcPtr; + dP = (unsigned short *)(dstBitmap + line*dstPitch); + for (finish = width; finish; finish -= 1 ) + { + if(finish==finWidth) iXA=0; + else iXA=1; + if(finish>4) {iXB=1;iXC=2;} + else + if(finish>3) {iXB=1;iXC=1;} + else {iXB=0;iXC=0;} + if(line==0) iYA=0; + else iYA=finWidth; + if(height>4) {iYB=finWidth;iYC=srcPitch;} + else + if(height>3) {iYB=finWidth;iYC=finWidth;} + else {iYB=0;iYC=0;} + + colorB1 = *(bP- iYA); + colorB2 = *(bP- iYA + iXB); + + color4 = *(bP - iXA); + color5 = *(bP); + color6 = *(bP + iXB); + colorS2 = *(bP + iXC); + + color1 = *(bP + iYB - iXA); + color2 = *(bP + iYB); + color3 = *(bP + iYB + iXB); + colorS1= *(bP + iYB + iXC); + + colorA1 = *(bP + iYC); + colorA2 = *(bP + iYC + iXB); + + if(color2 == color6 && color5 != color3) + { + product1b = product2a = color2; + if((color1 == color2) || + (color6 == colorB2)) + { + product1a = INTERPOLATE5(color2, color5); + product1a = INTERPOLATE5(color2, product1a); + } + else + { + product1a = INTERPOLATE5(color5, color6); + } + + if((color6 == colorS2) || + (color2 == colorA1)) + { + product2b = INTERPOLATE5(color2, color3); + product2b = INTERPOLATE5(color2, product2b); + } + else + { + product2b = INTERPOLATE5(color2, color3); + } + } + else + if (color5 == color3 && color2 != color6) + { + product2b = product1a = color5; + + if ((colorB1 == color5) || + (color3 == colorS1)) + { + product1b = INTERPOLATE5(color5, color6); + product1b = INTERPOLATE5(color5, product1b); + } + else + { + product1b = INTERPOLATE5(color5, color6); + } + + if ((color3 == colorA2) || + (color4 == color5)) + { + product2a = INTERPOLATE5(color5, color2); + product2a = INTERPOLATE5(color5, product2a); + } + else + { + product2a = INTERPOLATE5(color2, color3); + } + } + else + if (color5 == color3 && color2 == color6) + { + register int r = 0; + + r += GET_RESULT ((color6), (color5), (color1), (colorA1)); + r += GET_RESULT ((color6), (color5), (color4), (colorB1)); + r += GET_RESULT ((color6), (color5), (colorA2), (colorS1)); + r += GET_RESULT ((color6), (color5), (colorB2), (colorS2)); + + if (r > 0) + { + product1b = product2a = color2; + product1a = product2b = INTERPOLATE5(color5, color6); + } + else + if (r < 0) + { + product2b = product1a = color5; + product1b = product2a = INTERPOLATE5(color5, color6); + } + else + { + product2b = product1a = color5; + product1b = product2a = color2; + } + } + else + { + product2b = product1a = INTERPOLATE5(color2, color6); + product2b = Q_INTERPOLATE5(color3, color3, color3, product2b); + product1a = Q_INTERPOLATE5(color5, color5, color5, product1a); + + product2a = product1b = INTERPOLATE5(color5, color3); + product2a = Q_INTERPOLATE5(color2, color2, color2, product2a); + product1b = Q_INTERPOLATE5(color6, color6, color6, product1b); + } + + *dP=(unsigned short)product1a; + *(dP+1)=(unsigned short)product1b; + *(dP+(srcPitch))=(unsigned short)product2a; + *(dP+1+(srcPitch))=(unsigned short)product2b; + + bP += 1; + dP += 2; + }//end of for ( finish= width etc..) + + line += 2; + srcPtr += srcPitch; + }; //endof: for (; height; height--) + } +} + +//////////////////////////////////////////////////////////////////////// +// own swap buffer func (window/fullscreen) +//////////////////////////////////////////////////////////////////////// + +sDX DX; +static DDSURFACEDESC ddsd; +GUID guiDev; +BOOL bDeviceOK; +HWND hWGPU; +int iSysMemory=0; +int iFPSEInterface=0; +int iRefreshRate; +BOOL bVsync=FALSE; +BOOL bVsync_Key=FALSE; + +void (*BlitScreen) (unsigned char *,long,long); +void (*pExtraBltFunc) (void); +void (*p2XSaIFunc) (unsigned char *,DWORD,unsigned char *,int,int); + +//////////////////////////////////////////////////////////////////////// + +static __inline void WaitVBlank(void) +{ + if(bVsync_Key) + { + IDirectDraw2_WaitForVerticalBlank(DX.DD,DDWAITVB_BLOCKBEGIN,0); + } +} + +//////////////////////////////////////////////////////////////////////// + +void BlitScreen32(unsigned char * surf,long x,long y) // BLIT IN 32bit COLOR MODE +{ + unsigned char * pD;unsigned long lu;unsigned short s; + unsigned int startxy; + short row,column; + short dx=(short)PreviousPSXDisplay.Range.x1; + short dy=(short)PreviousPSXDisplay.DisplayMode.y; + + if(iDebugMode && iFVDisplay) + { + dx=1024; + dy=iGPUHeight; + x=0;y=0; + + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + for(row=0;row<dx;row++) + { + s=psxVuw[startxy++]; + *((unsigned long *)((surf)+(column*ddsd.lPitch)+row*4))= + ((((s<<19)&0xf80000)|((s<<6)&0xf800)|((s>>7)&0xf8))&0xffffff)|0xff000000; + } + } + return; + } + + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + surf+=PreviousPSXDisplay.Range.y0*ddsd.lPitch; + dy-=PreviousPSXDisplay.Range.y0; + } + + surf+=PreviousPSXDisplay.Range.x0<<2; + + if(PSXDisplay.RGB24) + { + if(iFPSEInterface) + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned long *)((surf)+(column*ddsd.lPitch)+row*4))= + 0xff000000|(BLUE(lu)<<16)|(GREEN(lu)<<8)|(RED(lu)); + pD+=3; + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned long *)((surf)+(column*ddsd.lPitch)+row*4))= + 0xff000000|(RED(lu)<<16)|(GREEN(lu)<<8)|(BLUE(lu)); + pD+=3; + } + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + for(row=0;row<dx;row++) + { + s=psxVuw[startxy++]; + *((unsigned long *)((surf)+(column*ddsd.lPitch)+row*4))= + ((((s<<19)&0xf80000)|((s<<6)&0xf800)|((s>>7)&0xf8))&0xffffff)|0xff000000; + } + } + } +} + +//////////////////////////////////////////////////////////////////////// + +void BlitScreen32_2xSaI(unsigned char * surf,long x,long y) // BLIT IN 32bit COLOR MODE +{ + unsigned char * pD;unsigned long lu;unsigned short s; + unsigned int startxy,off1,off2; + short row,column; + short dx=(short)PreviousPSXDisplay.Range.x1; + short dy=(short)PreviousPSXDisplay.DisplayMode.y; + unsigned char * pS=(unsigned char *)pSaISmallBuff; + unsigned long * pS1, * pS2; + + if(PreviousPSXDisplay.DisplayMode.x>512) + {BlitScreen32(surf,x,y);return;} + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + pS+=PreviousPSXDisplay.Range.y0*2048; + dy-=PreviousPSXDisplay.Range.y0; + } + + pS+=PreviousPSXDisplay.Range.x0<<2; + + if(PSXDisplay.RGB24) + { + if(iFPSEInterface) + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned long *)((pS)+(column*2048)+row*4))= + 0xff000000|(BLUE(lu)<<16)|(GREEN(lu)<<8)|(RED(lu)); + pD+=3; + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned long *)((pS)+(column*2048)+row*4))= + 0xff000000|(RED(lu)<<16)|(GREEN(lu)<<8)|(BLUE(lu)); + pD+=3; + } + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + for(row=0;row<dx;row++) + { + s=psxVuw[startxy++]; + *((unsigned long *)((pS)+(column*2048)+row*4))= + ((((s<<19)&0xf80000)|((s<<6)&0xf800)|((s>>7)&0xf8))&0xffffff)|0xff000000; + } + } + } + + // ok, here we have filled pSaISmallBuff with PreviousPSXDisplay.DisplayMode.x * PreviousPSXDisplay.DisplayMode.y (*4) data + // now do a 2xSai blit to pSaIBigBuff + + p2XSaIFunc((unsigned char *)pSaISmallBuff, 2048, + (unsigned char *)pSaIBigBuff, + PreviousPSXDisplay.DisplayMode.x, + PreviousPSXDisplay.DisplayMode.y); + + // ok, here we have pSaIBigBuff filled with the 2xSai image... + // now transfer it to the surface + + dx=(short)PreviousPSXDisplay.DisplayMode.x<<1; + dy=(short)PreviousPSXDisplay.DisplayMode.y<<1; + off1=(ddsd.lPitch>>2)-dx; + off2=1024-dx; + + pS1=(unsigned long *)surf; + pS2=(unsigned long *)pSaIBigBuff; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + *(pS1++)=*(pS2++); + } + pS1+=off1; + pS2+=off2; + } +} + +//////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////// +void BlitScreen32_3xSaI(unsigned char * surf,long x,long y) // BLIT IN 32bit COLOR MODE +{ + unsigned char * pD;unsigned long lu;unsigned short s; + unsigned int startxy,off1,off2; + short row,column; + short dx=(short)PreviousPSXDisplay.Range.x1; + short dy=(short)PreviousPSXDisplay.DisplayMode.y; + unsigned char * pS=(unsigned char *)pSaISmallBuff; + unsigned long * pS1, * pS2; + + if(PreviousPSXDisplay.DisplayMode.x>512) + {BlitScreen32(surf,x,y);return;} + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + pS+=PreviousPSXDisplay.Range.y0*2048; + dy-=PreviousPSXDisplay.Range.y0; + } + + pS+=PreviousPSXDisplay.Range.x0<<2; + + if(PSXDisplay.RGB24) + { + if(iFPSEInterface) + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned long *)((pS)+(column*2048)+row*4))= + 0xff000000|(BLUE(lu)<<16)|(GREEN(lu)<<8)|(RED(lu)); + pD+=3; + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned long *)((pS)+(column*2048)+row*4))= + 0xff000000|(RED(lu)<<16)|(GREEN(lu)<<8)|(BLUE(lu)); + pD+=3; + } + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + for(row=0;row<dx;row++) + { + s=psxVuw[startxy++]; + *((unsigned long *)((pS)+(column*2048)+row*4))= + ((((s<<19)&0xf80000)|((s<<6)&0xf800)|((s>>7)&0xf8))&0xffffff)|0xff000000; + } + } + } + + // ok, here we have filled pSaISmallBuff with PreviousPSXDisplay.DisplayMode.x * PreviousPSXDisplay.DisplayMode.y (*4) data + // now do a 2xSai blit to pSaIBigBuff + + p2XSaIFunc((unsigned char *)pSaISmallBuff, 2048, + (unsigned char *)pSaIBigBuff, + PreviousPSXDisplay.DisplayMode.x, + PreviousPSXDisplay.DisplayMode.y); + + // ok, here we have pSaIBigBuff filled with the 2xSai image... + // now transfer it to the surface + //CHANGED << 1 to * 3 + + dx=(short)PreviousPSXDisplay.DisplayMode.x * 3; + dy=(short)PreviousPSXDisplay.DisplayMode.y * 3; + + off1=(ddsd.lPitch>>2)-dx; + off2=1024-dx; + + pS1=(unsigned long *)surf; + pS2=(unsigned long *)pSaIBigBuff; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + *(pS1++)=*(pS2++); + } + pS1+=off1; + pS2+=off2; + } +} +////////////////////////////////////////////////////////////////////// +void BlitScreen16(unsigned char * surf,long x,long y) // BLIT IN 16bit COLOR MODE +{ + unsigned long lu; + unsigned short row,column; + unsigned short dx=(unsigned short)PreviousPSXDisplay.Range.x1; + unsigned short dy=(unsigned short)PreviousPSXDisplay.DisplayMode.y; + + if(iDebugMode && iFVDisplay) + { + unsigned short LineOffset,SurfOffset; + unsigned long * SRCPtr; + unsigned long * DSTPtr; + + dx=1024; + dy=iGPUHeight; + x=0;y=0; + + SRCPtr = (unsigned long *)(psxVuw); + DSTPtr = ((unsigned long *)surf); + + dx>>=1; + + LineOffset = 512 - dx; + SurfOffset = (ddsd.lPitch>>2) - dx; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + lu=*SRCPtr++; + + *DSTPtr++= + ((lu<<11)&0xf800f800)|((lu<<1)&0x7c007c0)|((lu>>10)&0x1f001f); + } + SRCPtr += LineOffset; + DSTPtr += SurfOffset; + } + return; + } + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + surf+=PreviousPSXDisplay.Range.y0*ddsd.lPitch; + dy-=PreviousPSXDisplay.Range.y0; + } + + if(PSXDisplay.RGB24) + { + unsigned char * pD;unsigned int startxy; + + surf+=PreviousPSXDisplay.Range.x0<<1; + + if(iFPSEInterface) + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((surf)+(column*ddsd.lPitch)+(row<<1)))= + (unsigned short)(((BLUE(lu)<<8)&0xf800)|((GREEN(lu)<<3)&0x7e0)|(RED(lu)>>3)); + pD+=3; + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((surf)+(column*ddsd.lPitch)+(row<<1)))= + (unsigned short)(((RED(lu)<<8)&0xf800)|((GREEN(lu)<<3)&0x7e0)|(BLUE(lu)>>3)); + pD+=3; + } + } + } + } + else + { + unsigned short LineOffset,SurfOffset; + unsigned long * SRCPtr = (unsigned long *)(psxVuw + + (y<<10) + x); + unsigned long * DSTPtr = + ((unsigned long *)surf)+(PreviousPSXDisplay.Range.x0>>1); + + dx>>=1; + + LineOffset = 512 - dx; + SurfOffset = (ddsd.lPitch>>2) - dx; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + lu=*SRCPtr++; + + *DSTPtr++= + ((lu<<11)&0xf800f800)|((lu<<1)&0x7c007c0)|((lu>>10)&0x1f001f); + } + SRCPtr += LineOffset; + DSTPtr += SurfOffset; + } + } +} + +//////////////////////////////////////////////////////////////////////// + +void BlitScreen16_2xSaI(unsigned char * surf,long x,long y) // BLIT IN 16bit COLOR MODE +{ + unsigned long lu; + unsigned short row,column,off1,off2; + unsigned short dx=(unsigned short)PreviousPSXDisplay.Range.x1; + unsigned short dy=(unsigned short)PreviousPSXDisplay.DisplayMode.y; + unsigned char * pS=(unsigned char *)pSaISmallBuff; + unsigned long * pS1, * pS2; + + if(PreviousPSXDisplay.DisplayMode.x>512) + {BlitScreen16(surf,x,y);return;} + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + pS+=PreviousPSXDisplay.Range.y0*1024; + dy-=PreviousPSXDisplay.Range.y0; + } + + if(PSXDisplay.RGB24) + { + unsigned char * pD;unsigned int startxy; + + pS+=PreviousPSXDisplay.Range.x0<<1; + + if(iFPSEInterface) + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((pS)+(column*1024)+(row<<1)))= + (unsigned short)(((BLUE(lu)<<8)&0xf800)|((GREEN(lu)<<3)&0x7e0)|(RED(lu)>>3)); + pD+=3; + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((pS)+(column*1024)+(row<<1)))= + (unsigned short)(((RED(lu)<<8)&0xf800)|((GREEN(lu)<<3)&0x7e0)|(BLUE(lu)>>3)); + pD+=3; + } + } + } + } + else + { + unsigned short LineOffset,SurfOffset; + unsigned long * SRCPtr = (unsigned long *)(psxVuw + + (y<<10) + x); + unsigned long * DSTPtr = + ((unsigned long *)pS)+(PreviousPSXDisplay.Range.x0>>1); + + dx>>=1; + + LineOffset = 512 - dx; + SurfOffset = 256 - dx; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + lu=*SRCPtr++; + + *DSTPtr++= + ((lu<<11)&0xf800f800)|((lu<<1)&0x7c007c0)|((lu>>10)&0x1f001f); + } + SRCPtr += LineOffset; + DSTPtr += SurfOffset; + } + } + + // ok, here we have filled pSaISmallBuff with PreviousPSXDisplay.DisplayMode.x * PreviousPSXDisplay.DisplayMode.y (*4) data + // now do a 2xSai blit to pSaIBigBuff + + p2XSaIFunc((unsigned char *)pSaISmallBuff, 1024, + (unsigned char *)pSaIBigBuff, + PreviousPSXDisplay.DisplayMode.x, + PreviousPSXDisplay.DisplayMode.y); + + // ok, here we have pSaIBigBuff filled with the 2xSai image... + // now transfer it to the surface + + dx=(short)PreviousPSXDisplay.DisplayMode.x; + dy=(short)PreviousPSXDisplay.DisplayMode.y<<1; + off1=(ddsd.lPitch>>2)-dx; + off2=512-dx; + + pS1=(unsigned long *)surf; + pS2=(unsigned long *)pSaIBigBuff; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + *(pS1++)=*(pS2++); + } + pS1+=off1; + pS2+=off2; + } +} + +void BlitScreen16_3xSaI(unsigned char * surf,long x,long y) // BLIT IN 16bit COLOR MODE +{ + unsigned long lu; + unsigned short row,column,off1,off2; + unsigned short dx=(unsigned short)PreviousPSXDisplay.Range.x1; + unsigned short dy=(unsigned short)PreviousPSXDisplay.DisplayMode.y; + unsigned char * pS=(unsigned char *)pSaISmallBuff; + unsigned long * pS1, * pS2; + + if(PreviousPSXDisplay.DisplayMode.x>512) + {BlitScreen16(surf,x,y);return;} + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + pS+=PreviousPSXDisplay.Range.y0*1024; + dy-=PreviousPSXDisplay.Range.y0; + } + + if(PSXDisplay.RGB24) + { + unsigned char * pD;unsigned int startxy; + + pS+=PreviousPSXDisplay.Range.x0<<1; + + if(iFPSEInterface) + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((pS)+(column*1024)+(row<<1)))= + (unsigned short)(((BLUE(lu)<<8)&0xf800)|((GREEN(lu)<<3)&0x7e0)|(RED(lu)>>3)); + pD+=3; + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((pS)+(column*1024)+(row<<1)))= + (unsigned short)(((RED(lu)<<8)&0xf800)|((GREEN(lu)<<3)&0x7e0)|(BLUE(lu)>>3)); + pD+=3; + } + } + } + } + else + { + unsigned short LineOffset,SurfOffset; + unsigned long * SRCPtr = (unsigned long *)(psxVuw + + (y<<10) + x); + unsigned long * DSTPtr = + ((unsigned long *)pS)+(PreviousPSXDisplay.Range.x0>>1); + + dx>>=1; + + LineOffset = 512 - dx; + SurfOffset = 256 - dx; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + lu=*SRCPtr++; + + *DSTPtr++= + ((lu<<11)&0xf800f800)|((lu<<1)&0x7c007c0)|((lu>>10)&0x1f001f); + } + SRCPtr += LineOffset; + DSTPtr += SurfOffset; + } + } + + // ok, here we have filled pSaISmallBuff with PreviousPSXDisplay.DisplayMode.x * PreviousPSXDisplay.DisplayMode.y (*4) data + // now do a 2xSai blit to pSaIBigBuff + + p2XSaIFunc((unsigned char *)pSaISmallBuff, 1024, + (unsigned char *)pSaIBigBuff, + PreviousPSXDisplay.DisplayMode.x, + PreviousPSXDisplay.DisplayMode.y); + + // ok, here we have pSaIBigBuff filled with the 2xSai image... + // now transfer it to the surface + + dx=(short)(PreviousPSXDisplay.DisplayMode.x * 1.5); + dy=(short)PreviousPSXDisplay.DisplayMode.y*3; + off1=(ddsd.lPitch>>2)-dx; + off2=512-dx; + + pS1=(unsigned long *)surf; + pS2=(unsigned long *)pSaIBigBuff; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + *(pS1++)=*(pS2++); + } + pS1+=off1; + pS2+=off2; + } +} + +//////////////////////////////////////////////////////////////////////// + +void BlitScreen15(unsigned char * surf,long x,long y) // BLIT IN 16bit COLOR MODE +{ + unsigned long lu; + unsigned short row,column; + unsigned short dx=(unsigned short)PreviousPSXDisplay.Range.x1; + unsigned short dy=(unsigned short)PreviousPSXDisplay.DisplayMode.y; + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + surf+=PreviousPSXDisplay.Range.y0*ddsd.lPitch; + dy-=PreviousPSXDisplay.Range.y0; + } + + if(PSXDisplay.RGB24) + { + unsigned char * pD;unsigned int startxy; + + surf+=PreviousPSXDisplay.Range.x0<<1; + + if(iFPSEInterface) + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((surf)+(column*ddsd.lPitch)+(row<<1)))= + (unsigned short) + (((BLUE(lu)<<7)&0x7c00)| + ((GREEN(lu)<<2)&0x3e0)| + (RED(lu)>>3)); + pD+=3; + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((surf)+(column*ddsd.lPitch)+(row<<1)))= + (unsigned short) + (((RED(lu)<<7)&0x7c00)| + ((GREEN(lu)<<2)&0x3e0)| + (BLUE(lu)>>3)); + pD+=3; + } + } + } + } + else + { + unsigned short LineOffset,SurfOffset; + unsigned long * SRCPtr = (unsigned long *)(psxVuw + + (y<<10) + x); + + unsigned long * DSTPtr = + ((unsigned long *)surf)+(PreviousPSXDisplay.Range.x0>>1); + + dx>>=1; + + LineOffset = 512 - dx; + SurfOffset = (ddsd.lPitch>>2) - dx; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + lu=*SRCPtr++; + + *DSTPtr++= + ((lu<<10)&0x7c007c00)| + ((lu)&0x3e003e0)| + ((lu>>10)&0x1f001f); + } + SRCPtr += LineOffset; + DSTPtr += SurfOffset; + } + } +} + +//////////////////////////////////////////////////////////////////////// + +void BlitScreen15_2xSaI(unsigned char * surf,long x,long y) // BLIT IN 16bit COLOR MODE +{ + unsigned long lu; + unsigned short row,column,off1,off2; + unsigned short dx=(unsigned short)PreviousPSXDisplay.Range.x1; + unsigned short dy=(unsigned short)PreviousPSXDisplay.DisplayMode.y; + unsigned char * pS=(unsigned char *)pSaISmallBuff; + unsigned long * pS1, * pS2; + + if(PreviousPSXDisplay.DisplayMode.x>512) + {BlitScreen15(surf,x,y);return;} + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + pS+=PreviousPSXDisplay.Range.y0*1024; + dy-=PreviousPSXDisplay.Range.y0; + } + + if(PSXDisplay.RGB24) + { + unsigned char * pD;unsigned int startxy; + + pS+=PreviousPSXDisplay.Range.x0<<1; + + if(iFPSEInterface) + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((pS)+(column*1024)+(row<<1)))= + (unsigned short) + (((BLUE(lu)<<7)&0x7c00)| + ((GREEN(lu)<<2)&0x3e0)| + (RED(lu)>>3)); + pD+=3; + } + } + } + else + { + for(column=0;column<dy;column++) + { + startxy=((1024)*(column+y))+x; + + pD=(unsigned char *)&psxVuw[startxy]; + + for(row=0;row<dx;row++) + { + lu=*((unsigned long *)pD); + *((unsigned short *)((pS)+(column*1024)+(row<<1)))= + (unsigned short) + (((RED(lu)<<7)&0x7c00)| + ((GREEN(lu)<<2)&0x3e0)| + (BLUE(lu)>>3)); + pD+=3; + } + } + } + } + else + { + unsigned short LineOffset,SurfOffset; + unsigned long * SRCPtr = (unsigned long *)(psxVuw + + (y<<10) + x); + unsigned long * DSTPtr = + ((unsigned long *)pS)+(PreviousPSXDisplay.Range.x0>>1); + + dx>>=1; + + LineOffset = 512 - dx; + SurfOffset = 256 - dx; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + lu=*SRCPtr++; + + *DSTPtr++= + ((lu<<10)&0x7c007c00)| + ((lu)&0x3e003e0)| + ((lu>>10)&0x1f001f); + } + SRCPtr += LineOffset; + DSTPtr += SurfOffset; + } + } + + // ok, here we have filled pSaISmallBuff with PreviousPSXDisplay.DisplayMode.x * PreviousPSXDisplay.DisplayMode.y (*4) data + // now do a 2xSai blit to pSaIBigBuff + + p2XSaIFunc((unsigned char *)pSaISmallBuff, 1024, + (unsigned char *)pSaIBigBuff, + PreviousPSXDisplay.DisplayMode.x, + PreviousPSXDisplay.DisplayMode.y); + + // ok, here we have pSaIBigBuff filled with the 2xSai image... + // now transfer it to the surface + + dx=(short)PreviousPSXDisplay.DisplayMode.x; + dy=(short)PreviousPSXDisplay.DisplayMode.y<<1; + off1=(ddsd.lPitch>>2)-dx; + off2=512-dx; + + pS1=(unsigned long *)surf; + pS2=(unsigned long *)pSaIBigBuff; + + for(column=0;column<dy;column++) + { + for(row=0;row<dx;row++) + { + *(pS1++)=*(pS2++); + } + pS1+=off1; + pS2+=off2; + } +} + +//////////////////////////////////////////////////////////////////////// + +void DoClearScreenBuffer(void) // CLEAR DX BUFFER +{ + DDBLTFX ddbltfx; + + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + + IDirectDrawSurface_Blt(DX.DDSRender,NULL,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + + if(iUseNoStretchBlt>=3) + { + if(pSaISmallBuff) memset(pSaISmallBuff,0,512*512*4); + } +} + +//////////////////////////////////////////////////////////////////////// + +void DoClearFrontBuffer(void) // CLEAR PRIMARY BUFFER +{ + DDBLTFX ddbltfx; + + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + + IDirectDrawSurface_Blt(DX.DDSPrimary,NULL,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); +} + +//////////////////////////////////////////////////////////////////////// + +void NoStretchedBlit(void) +{ + static int iOldDX=0; + static int iOldDY=0; + + int iDX,iDY; + int iX=iResX-PreviousPSXDisplay.DisplayMode.x; + int iY=iResY-PreviousPSXDisplay.DisplayMode.y; + +/* +float fXS,fYS,fS; +fXS=(float)iResX/(float)PreviousPSXDisplay.DisplayMode.x; +fYS=(float)iResY/(float)PreviousPSXDisplay.DisplayMode.y; +if(fXS<fYS) fS=fXS; else fS=fYS; +*/ + + if(iX<0) {iX=0;iDX=iResX;} + else {iX=iX/2;iDX=PreviousPSXDisplay.DisplayMode.x;} + + if(iY<0) {iY=0;iDY=iResY;} + else {iY=iY/2;iDY=PreviousPSXDisplay.DisplayMode.y;} + + if(iOldDX!=iDX || iOldDY!=iDY) + { + DDBLTFX ddbltfx; + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + IDirectDrawSurface_Blt(DX.DDSPrimary,NULL,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + iOldDX=iDX;iOldDY=iDY; + } + + if(iWindowMode) + { + RECT ScreenRect,ViewportRect; + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + Point.x+=iX;Point.y+=iY; + + ScreenRect.left = Point.x; + ScreenRect.top = Point.y; + ScreenRect.right = iDX+Point.x; + ScreenRect.bottom = iDY+Point.y; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = iDX; + ViewportRect.bottom = iDY; + + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + else + { + RECT ScreenRect,ViewportRect; + + ScreenRect.left = iX; + ScreenRect.top = iY; + ScreenRect.right = iDX+iX; + ScreenRect.bottom = iDY+iY; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = iDX; + ViewportRect.bottom = iDY; + + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + if(DX.DDSScreenPic) DisplayPic(); +} + +//////////////////////////////////////////////////////////////////////// + +void NoStretchedBlitEx(void) +{ + static int iOldDX=0; + static int iOldDY=0; + + int iDX,iDY,iX,iY;float fXS,fYS,fS; + + if(!PreviousPSXDisplay.DisplayMode.x) return; + if(!PreviousPSXDisplay.DisplayMode.y) return; + + fXS=(float)iResX/(float)PreviousPSXDisplay.DisplayMode.x; + fYS=(float)iResY/(float)PreviousPSXDisplay.DisplayMode.y; + if(fXS<fYS) fS=fXS; else fS=fYS; + + iDX=(int)(PreviousPSXDisplay.DisplayMode.x*fS); + iDY=(int)(PreviousPSXDisplay.DisplayMode.y*fS); + + iX=iResX-iDX; + iY=iResY-iDY; + + if(iX<0) iX=0; + else iX=iX/2; + + if(iY<0) iY=0; + else iY=iY/2; + + if(iOldDX!=iDX || iOldDY!=iDY) + { + DDBLTFX ddbltfx; + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + IDirectDrawSurface_Blt(DX.DDSPrimary,NULL,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + iOldDX=iDX;iOldDY=iDY; + } + + if(iWindowMode) + { + RECT ScreenRect,ViewportRect; + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + Point.x+=iX;Point.y+=iY; + + ScreenRect.left = Point.x; + ScreenRect.top = Point.y; + ScreenRect.right = iDX+Point.x; + ScreenRect.bottom = iDY+Point.y; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = PreviousPSXDisplay.DisplayMode.x; + ViewportRect.bottom = PreviousPSXDisplay.DisplayMode.y; + + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + else + { + RECT ScreenRect,ViewportRect; + + ScreenRect.left = iX; + ScreenRect.top = iY; + ScreenRect.right = iDX+iX; + ScreenRect.bottom = iDY+iY; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = PreviousPSXDisplay.DisplayMode.x; + ViewportRect.bottom = PreviousPSXDisplay.DisplayMode.y; + + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + if(DX.DDSScreenPic) DisplayPic(); +} + +//////////////////////////////////////////////////////////////////////// + +void StretchedBlit2x(void) +{ + if(iWindowMode) + { + RECT ScreenRect,ViewportRect; + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + + ScreenRect.left = Point.x; + ScreenRect.top = Point.y; + ScreenRect.right = iResX+Point.x; + ScreenRect.bottom = iResY+Point.y; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = PreviousPSXDisplay.DisplayMode.x; + ViewportRect.bottom = PreviousPSXDisplay.DisplayMode.y; + + if(ViewportRect.right<=512) + { + ViewportRect.right+=ViewportRect.right; + ViewportRect.bottom+=ViewportRect.bottom; + } + + if(iUseScanLines==2) // stupid nvidia scanline mode + { + RECT HelperRect={0,0,iResX,iResY}; + + WaitVBlank(); + + IDirectDrawSurface_Blt(DX.DDSHelper,&HelperRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSHelper,&HelperRect, + DDBLT_WAIT,NULL); + } + else + { + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + } + else + { + RECT ScreenRect={0,0,iResX,iResY}, + ViewportRect={0,0,PreviousPSXDisplay.DisplayMode.x, + PreviousPSXDisplay.DisplayMode.y}; + + if(ViewportRect.right<=512) + { + ViewportRect.right+=ViewportRect.right; + ViewportRect.bottom+=ViewportRect.bottom; + } + + if(iUseScanLines==2) // stupid nvidia scanline mode + { + WaitVBlank(); + + IDirectDrawSurface_Blt(DX.DDSHelper,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSHelper,&ScreenRect, + DDBLT_WAIT,NULL); + } + else + { + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL ); + } + } + + if(DX.DDSScreenPic) DisplayPic(); + +} + +//////////////////////////////////////////////////////////////////////// + +void NoStretchedBlit2x(void) +{ + static int iOldDX=0; + static int iOldDY=0; + + int iX,iY,iDX,iDY; + int iDX2=PreviousPSXDisplay.DisplayMode.x; + int iDY2=PreviousPSXDisplay.DisplayMode.y; + if(PreviousPSXDisplay.DisplayMode.x<=512) + { + iDX2<<=1; + iDY2<<=1; + } + + iX=iResX-iDX2; + iY=iResY-iDY2; + + if(iX<0) {iX=0;iDX=iResX;} + else {iX=iX/2;iDX=iDX2;} + + if(iY<0) {iY=0;iDY=iResY;} + else {iY=iY/2;iDY=iDY2;} + + if(iOldDX!=iDX || iOldDY!=iDY) + { + DDBLTFX ddbltfx; + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + IDirectDrawSurface_Blt(DX.DDSPrimary,NULL,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + iOldDX=iDX;iOldDY=iDY; + } + + if(iWindowMode) + { + RECT ScreenRect,ViewportRect; + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + Point.x+=iX;Point.y+=iY; + + ScreenRect.left = Point.x; + ScreenRect.top = Point.y; + ScreenRect.right = iDX+Point.x; + ScreenRect.bottom = iDY+Point.y; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = iDX; + ViewportRect.bottom = iDY; + + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + else + { + RECT ScreenRect,ViewportRect; + + ScreenRect.left = iX; + ScreenRect.top = iY; + ScreenRect.right = iDX+iX; + ScreenRect.bottom = iDY+iY; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = iDX; + ViewportRect.bottom = iDY; + + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + if(DX.DDSScreenPic) DisplayPic(); +} + +//////////////////////////////////////////////////////////////////////// +void NoStretchedBlit3x(void) +{ + static int iOldDX=0; + static int iOldDY=0; + + int iX,iY,iDX,iDY; + int iDX2=PreviousPSXDisplay.DisplayMode.x; + int iDY2=PreviousPSXDisplay.DisplayMode.y; + + if(PreviousPSXDisplay.DisplayMode.x<=512) + { + iDX2*=3; + iDY2*=3; + } + + iX=iResX-iDX2; + iY=iResY-iDY2; + + if(iX<0) {iX=0;iDX=iResX;} + else {iX=iX/2;iDX=iDX2;} + + if(iY<0) {iY=0;iDY=iResY;} + else {iY=iY/2;iDY=iDY2;} + + if(iOldDX!=iDX || iOldDY!=iDY) + { + DDBLTFX ddbltfx; + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + IDirectDrawSurface_Blt(DX.DDSPrimary,NULL,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + iOldDX=iDX;iOldDY=iDY; + } + + if(iWindowMode) + { + RECT ScreenRect,ViewportRect; + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + Point.x+=iX;Point.y+=iY; + + ScreenRect.left = Point.x; + ScreenRect.top = Point.y; + ScreenRect.right = iDX+Point.x; + ScreenRect.bottom = iDY+Point.y; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = iDX; + ViewportRect.bottom = iDY; + + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + else + { + RECT ScreenRect,ViewportRect; + + ScreenRect.left = iX; + ScreenRect.top = iY; + ScreenRect.right = iDX+iX; + ScreenRect.bottom = iDY+iY; + + ViewportRect.left = 0; + ViewportRect.top = 0; + ViewportRect.right = iDX; + ViewportRect.bottom = iDY; + + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + if(DX.DDSScreenPic) DisplayPic(); +} + + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +void ShowGunCursor(unsigned char * surf) +{ + unsigned short dx=(unsigned short)PreviousPSXDisplay.Range.x1; + unsigned short dy=(unsigned short)PreviousPSXDisplay.DisplayMode.y; + int x,y,iPlayer,sx,ex,sy,ey; + + if(PreviousPSXDisplay.Range.y0) // centering needed? + { + surf+=PreviousPSXDisplay.Range.y0*ddsd.lPitch; + dy-=PreviousPSXDisplay.Range.y0; + } + + if(iUseNoStretchBlt>=3 &&iUseNoStretchBlt < 13) // 2xsai is twice as big, of course + {dx*=2;dy*=2;} + else if(iUseNoStretchBlt >= 13) + {dx*=3;dy*=3;} + + if(iDesktopCol==32) // 32 bit color depth + { + const unsigned long crCursorColor32[8]={0xffff0000,0xff00ff00,0xff0000ff,0xffff00ff,0xffffff00,0xff00ffff,0xffffffff,0xff7f7f7f}; + + surf+=PreviousPSXDisplay.Range.x0<<2; // -> add x left border + + for(iPlayer=0;iPlayer<8;iPlayer++) // -> loop all possible players + { + if(usCursorActive&(1<<iPlayer)) // -> player active? + { + const int ty=(ptCursorPoint[iPlayer].y*dy)/256; // -> calculate the cursor pos in the current display + const int tx=(ptCursorPoint[iPlayer].x*dx)/512; + sx=tx-5;if(sx<0) {if(sx&1) sx=1; else sx=0;} + sy=ty-5;if(sy<0) {if(sy&1) sy=1; else sy=0;} + ex=tx+6;if(ex>dx) ex=dx; + ey=ty+6;if(ey>dy) ey=dy; + + for(x=tx,y=sy;y<ey;y+=2) // -> do dotted y line + *((unsigned long *)((surf)+(y*ddsd.lPitch)+x*4))=crCursorColor32[iPlayer]; + for(y=ty,x=sx;x<ex;x+=2) // -> do dotted x line + *((unsigned long *)((surf)+(y*ddsd.lPitch)+x*4))=crCursorColor32[iPlayer]; + } + } + } + else // 16 bit color depth + { + const unsigned short crCursorColor16[8]={0xf800,0x07c0,0x001f,0xf81f,0xffc0,0x07ff,0xffff,0x7bdf}; + + surf+=PreviousPSXDisplay.Range.x0<<1; // -> same stuff as above + + for(iPlayer=0;iPlayer<8;iPlayer++) + { + if(usCursorActive&(1<<iPlayer)) + { + const int ty=(ptCursorPoint[iPlayer].y*dy)/256; + const int tx=(ptCursorPoint[iPlayer].x*dx)/512; + sx=tx-5;if(sx<0) {if(sx&1) sx=1; else sx=0;} + sy=ty-5;if(sy<0) {if(sy&1) sy=1; else sy=0;} + ex=tx+6;if(ex>dx) ex=dx; + ey=ty+6;if(ey>dy) ey=dy; + + for(x=tx,y=sy;y<ey;y+=2) + *((unsigned short *)((surf)+(y*ddsd.lPitch)+x*2))=crCursorColor16[iPlayer]; + for(y=ty,x=sx;x<ex;x+=2) + *((unsigned short *)((surf)+(y*ddsd.lPitch)+x*2))=crCursorColor16[iPlayer]; + } + } + } +} + +//////////////////////////////////////////////////////////////////////// + +void DoBufferSwap(void) // SWAP BUFFERS +{ // (we don't swap... we blit only) + HRESULT ddrval;long x,y; + + ddrval=IDirectDrawSurface_Lock(DX.DDSRender,NULL, &ddsd, DDLOCK_WAIT|DDLOCK_WRITEONLY, NULL); + + if(ddrval==DDERR_SURFACELOST) + { + IDirectDrawSurface_Restore(DX.DDSRender); + } + + if(ddrval!=DD_OK) + { + IDirectDrawSurface_Unlock(DX.DDSRender,&ddsd); + return; + } + + //----------------------------------------------------// + + x=PSXDisplay.DisplayPosition.x; + y=PSXDisplay.DisplayPosition.y; + + //----------------------------------------------------// + + BlitScreen((unsigned char *)ddsd.lpSurface,x,y); // fill DDSRender surface + + if(usCursorActive) ShowGunCursor((unsigned char *)ddsd.lpSurface); + + IDirectDrawSurface_Unlock(DX.DDSRender,&ddsd); + + if(ulKeybits&KEY_SHOWFPS) DisplayText(); // paint menu text + + if(pExtraBltFunc) {pExtraBltFunc();return;} + + if(iWindowMode) + { + RECT ScreenRect,ViewportRect; + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + + ScreenRect.left = Point.x; + ScreenRect.top = Point.y; + ScreenRect.right = iResX+Point.x; + ScreenRect.bottom = iResY+Point.y; + + ViewportRect.left = 0; + ViewportRect.top = 0; + + if(iDebugMode) + { + if(iFVDisplay) + { + ViewportRect.right = 1024; + ViewportRect.bottom = iGPUHeight; + } + else + { + ViewportRect.right = PreviousPSXDisplay.DisplayMode.x; + ViewportRect.bottom = PreviousPSXDisplay.DisplayMode.y; + } + } + else + { + ViewportRect.right = PreviousPSXDisplay.DisplayMode.x; + ViewportRect.bottom = PreviousPSXDisplay.DisplayMode.y; + } + + if(iUseScanLines==2) // stupid nvidia scanline mode + { + RECT HelperRect={0,0,iResX,iResY}; + + WaitVBlank(); + + IDirectDrawSurface_Blt(DX.DDSHelper,&HelperRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSHelper,&HelperRect, + DDBLT_WAIT,NULL); + } + else + { + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + } + } + else + { + RECT ScreenRect={0,0,iResX,iResY}, + ViewportRect={0,0,PreviousPSXDisplay.DisplayMode.x, + PreviousPSXDisplay.DisplayMode.y}; + + if(iDebugMode && iFVDisplay) + { + ViewportRect.right=1024; + ViewportRect.bottom=iGPUHeight; + } + + if(iUseScanLines==2) // stupid nvidia scanline mode + { + WaitVBlank(); + + IDirectDrawSurface_Blt(DX.DDSHelper,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSHelper,&ScreenRect, + DDBLT_WAIT,NULL); + } + else + { + WaitVBlank(); + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSRender,&ViewportRect, + DDBLT_WAIT,NULL ); + } + } + + if(DX.DDSScreenPic) DisplayPic(); +} + +//////////////////////////////////////////////////////////////////////// +// GAMMA +//////////////////////////////////////////////////////////////////////// + +int iUseGammaVal=2048; + +void DXSetGamma(void) +{ + float g; + if(iUseGammaVal==2048) return; + + g=(float)iUseGammaVal; + if(g>512) g=((g-512)*2)+512; + g=0.5f+((g)/1024.0f); + +// some cards will cheat... so we don't trust the caps here +// if (DD_Caps.dwCaps2 & DDCAPS2_PRIMARYGAMMA) + { + float f;DDGAMMARAMP ramp;int i; + LPDIRECTDRAWGAMMACONTROL DD_Gamma = NULL; + + if FAILED(IDirectDrawSurface_QueryInterface(DX.DDSPrimary,&IID_IDirectDrawGammaControl,(void**)&DD_Gamma)) + return; + + for (i=0;i<256;i++) + { + f=(((float)(i*256))*g); + if(f>65535) f=65535; + ramp.red[i]=ramp.green[i]=ramp.blue[i]=(WORD)f; + } + + IDirectDrawGammaControl_SetGammaRamp(DD_Gamma,0,&ramp); + IDirectDrawGammaControl_Release(DD_Gamma); + } +} + +//////////////////////////////////////////////////////////////////////// +// SCAN LINE STUFF +//////////////////////////////////////////////////////////////////////// + +void SetScanLineList(LPDIRECTDRAWCLIPPER Clipper) +{ + LPRGNDATA lpCL;RECT * pr;int y;POINT Point={0,0}; + + IDirectDrawClipper_SetClipList(Clipper,NULL,0); + + lpCL=(LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+((iResY/2)+1)*sizeof(RECT)); + if(iWindowMode) ClientToScreen(DX.hWnd,&Point); + + lpCL->rdh.dwSize=sizeof(RGNDATAHEADER); + lpCL->rdh.iType=RDH_RECTANGLES; + lpCL->rdh.nCount=iResY/2; + lpCL->rdh.nRgnSize=0; + lpCL->rdh.rcBound.left=Point.x; + lpCL->rdh.rcBound.top=Point.y; + lpCL->rdh.rcBound.bottom=Point.y+iResY; + lpCL->rdh.rcBound.right=Point.x+iResX; + + pr=(RECT *)lpCL->Buffer; + for(y=0;y<iResY;y+=2) + { + pr->left=Point.x; + pr->top=Point.y+y; + pr->right=Point.x+iResX; + pr->bottom=Point.y+y+1; + pr++; + } + + IDirectDrawClipper_SetClipList(Clipper,lpCL,0); + + free(lpCL); +} + +//////////////////////////////////////////////////////////////////////// + +void MoveScanLineArea(HWND hwnd) +{ + LPDIRECTDRAWCLIPPER Clipper;HRESULT h; + DDBLTFX ddbltfx;RECT r; + + if(FAILED(h=IDirectDraw_CreateClipper(DX.DD,0,&Clipper,NULL))) + return; + + IDirectDrawSurface_SetClipper(DX.DDSPrimary,NULL); + + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + + GetClientRect(hwnd,&r); + ClientToScreen(hwnd,(LPPOINT)&r.left); + r.right+=r.left; + r.bottom+=r.top; + + IDirectDrawSurface_Blt(DX.DDSPrimary,&r,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + + SetScanLineList(Clipper); + + IDirectDrawSurface_SetClipper(DX.DDSPrimary,Clipper); + IDirectDrawClipper_Release(Clipper); +} + +//////////////////////////////////////////////////////////////////////// +// MAIN DIRECT DRAW INIT +//////////////////////////////////////////////////////////////////////// + +BOOL ReStart=FALSE; + +int DXinitialize() +{ + LPDIRECTDRAW DD;int i; + LPDIRECTDRAWCLIPPER Clipper;HRESULT h; + GUID FAR * guid=0; + unsigned char * c; + DDSCAPS ddscaps; + DDBLTFX ddbltfx; + DDPIXELFORMAT dd; + + // init some DX vars + DX.hWnd = (HWND)hWGPU; + DX.DDSHelper=0; + DX.DDSScreenPic=0; + + // make guid ! + c=(unsigned char *)&guiDev; + for(i=0;i<sizeof(GUID);i++,c++) + {if(*c) {guid=&guiDev;break;}} + + // create dd + if(DirectDrawCreate(guid,&DD,0)) + { + MessageBox(NULL, "This GPU requires DirectX!", "Error", MB_OK); + return 0; + } + + DX.DD=DD; + + //////////////////////////////////////////////////////// co-op level + + if(iWindowMode) // win mode? + { + if(IDirectDraw_SetCooperativeLevel(DX.DD,DX.hWnd,DDSCL_NORMAL)) + return 0; + } + else + { + if(ReStart) + { + if(IDirectDraw_SetCooperativeLevel(DX.DD,DX.hWnd, DDSCL_NORMAL | DDSCL_FULLSCREEN | DDSCL_FPUSETUP)) + return 0; + } + else + { + if(IDirectDraw_SetCooperativeLevel(DX.DD,DX.hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_FPUSETUP)) + return 0; + } + + if(iRefreshRate) + { + LPDIRECTDRAW2 DD2; + IDirectDraw_QueryInterface(DX.DD,&IID_IDirectDraw2,(LPVOID *)&DD2); + if(IDirectDraw2_SetDisplayMode(DD2,iResX,iResY,iColDepth,iRefreshRate,0)) + return 0; + } + else + { + if(IDirectDraw_SetDisplayMode(DX.DD,iResX,iResY,iColDepth)) + return 0; + } + } + + //////////////////////////////////////////////////////// main surfaces + + memset(&ddsd, 0, sizeof(DDSURFACEDESC)); + memset(&ddscaps, 0, sizeof(DDSCAPS)); + ddsd.dwSize = sizeof(DDSURFACEDESC); + + ddsd.dwFlags = DDSD_CAPS; // front buffer + + if(iSysMemory) + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_SYSTEMMEMORY; + else + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY; + + //ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;//|DDSCAPS_VIDEOMEMORY; + if(IDirectDraw_CreateSurface(DX.DD,&ddsd, &DX.DDSPrimary, NULL)) + return 0; + + //----------------------------------------------------// + if(iSysMemory && iUseScanLines==2) iUseScanLines=1; // pete: nvidia hack not needed on system mem + + if(iUseScanLines==2) // special nvidia hack + { + memset(&ddsd, 0, sizeof(DDSURFACEDESC)); + ddsd.dwSize = sizeof(DDSURFACEDESC); + ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + ddsd.dwWidth = iResX; + ddsd.dwHeight = iResY; + + if(IDirectDraw_CreateSurface(DX.DD,&ddsd, &DX.DDSHelper, NULL)) + return 0; + } + //----------------------------------------------------// + + memset(&ddsd, 0, sizeof(DDSURFACEDESC)); // back buffer + ddsd.dwSize = sizeof(DDSURFACEDESC); + ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; +// ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;//|DDSCAPS_VIDEOMEMORY; + if(iSysMemory) + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + else + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; + + if(iDebugMode || iUseNoStretchBlt>=3) + ddsd.dwWidth = 1024; + else ddsd.dwWidth = 640; + + if(iUseNoStretchBlt>=3) + ddsd.dwHeight = 1024; + else + { + if(iDebugMode) ddsd.dwHeight = iGPUHeight; + else ddsd.dwHeight = 512; + } + + if(IDirectDraw_CreateSurface(DX.DD,&ddsd, &DX.DDSRender, NULL)) + return 0; + + // check for desktop color depth + dd.dwSize=sizeof(DDPIXELFORMAT); + IDirectDrawSurface_GetPixelFormat(DX.DDSRender,&dd); + + if(dd.dwRBitMask==0x00007c00 && + dd.dwGBitMask==0x000003e0 && + dd.dwBBitMask==0x0000001f) + { + if(iUseNoStretchBlt>=3) + BlitScreen=BlitScreen15_2xSaI; + else BlitScreen=BlitScreen15; + iDesktopCol=15; + } + else + if(dd.dwRBitMask==0x0000f800 && + dd.dwGBitMask==0x000007e0 && + dd.dwBBitMask==0x0000001f) + { + if(iUseNoStretchBlt < 4) + BlitScreen = BlitScreen16; + else if(iUseNoStretchBlt < 13) + BlitScreen = BlitScreen16_2xSaI; + else + BlitScreen = BlitScreen16_3xSaI; + iDesktopCol=16; + } + else + { + if(iUseNoStretchBlt < 4) + BlitScreen = BlitScreen32; + else if(iUseNoStretchBlt < 13) + BlitScreen = BlitScreen32_2xSaI; + else + BlitScreen = BlitScreen32_3xSaI; + iDesktopCol=32; + } + + //////////////////////////////////////////////////////// extra blts + + switch(iUseNoStretchBlt) + { + case 1: + pExtraBltFunc=NoStretchedBlit; + p2XSaIFunc=NULL; + break; + case 2: + pExtraBltFunc=NoStretchedBlitEx; + p2XSaIFunc=NULL; + break; + case 3: + pExtraBltFunc=StretchedBlit2x; + if (iDesktopCol==15) p2XSaIFunc=Std2xSaI_ex5; + else if(iDesktopCol==16) p2XSaIFunc=Std2xSaI_ex6; + else p2XSaIFunc=Std2xSaI_ex8; + break; + case 4: + pExtraBltFunc=NoStretchedBlit2x; + if (iDesktopCol==15) p2XSaIFunc=Std2xSaI_ex5; + else if(iDesktopCol==16) p2XSaIFunc=Std2xSaI_ex6; + else p2XSaIFunc=Std2xSaI_ex8; + break; + case 5: + pExtraBltFunc=StretchedBlit2x; + if (iDesktopCol==15) p2XSaIFunc=Super2xSaI_ex5; + else if(iDesktopCol==16) p2XSaIFunc=Super2xSaI_ex6; + else p2XSaIFunc=Super2xSaI_ex8; + break; + case 6: + pExtraBltFunc=NoStretchedBlit2x; + if (iDesktopCol==15) p2XSaIFunc=Super2xSaI_ex5; + else if(iDesktopCol==16) p2XSaIFunc=Super2xSaI_ex6; + else p2XSaIFunc=Super2xSaI_ex8; + break; + case 7: + pExtraBltFunc=StretchedBlit2x; + if (iDesktopCol==15) p2XSaIFunc=SuperEagle_ex5; + else if(iDesktopCol==16) p2XSaIFunc=SuperEagle_ex6; + else p2XSaIFunc=SuperEagle_ex8; + break; + case 8: + pExtraBltFunc=NoStretchedBlit2x; + if (iDesktopCol==15) p2XSaIFunc=SuperEagle_ex5; + else if(iDesktopCol==16) p2XSaIFunc=SuperEagle_ex6; + else p2XSaIFunc=SuperEagle_ex8; + break; + case 9: + pExtraBltFunc=StretchedBlit2x; + if (iDesktopCol==15) p2XSaIFunc=Scale2x_ex6_5; + else if(iDesktopCol==16) p2XSaIFunc=Scale2x_ex6_5; + else p2XSaIFunc=Scale2x_ex8; + break; + case 10: + pExtraBltFunc=NoStretchedBlit2x; + if (iDesktopCol==15) p2XSaIFunc=Scale2x_ex6_5; + else if(iDesktopCol==16) p2XSaIFunc=Scale2x_ex6_5; + else p2XSaIFunc=Scale2x_ex8; + break; + case 11: + pExtraBltFunc=NoStretchedBlit2x; + if(iDesktopCol==15) p2XSaIFunc=hq2x; + else if(iDesktopCol==16) p2XSaIFunc=hq2x; + else p2XSaIFunc=hq2x_32; + break; + case 12: + pExtraBltFunc=StretchedBlit2x; + if(iDesktopCol==15) p2XSaIFunc=hq2x; + else if(iDesktopCol==16) p2XSaIFunc=hq2x; + else p2XSaIFunc=hq2x_32; + break; + case 13: + pExtraBltFunc=StretchedBlit2x; + if(iDesktopCol==15) p2XSaIFunc=Scale3x_ex6_5; + else if(iDesktopCol==16) p2XSaIFunc=Scale3x_ex6_5; + else p2XSaIFunc=Scale3x_ex8; + break; + case 14: + pExtraBltFunc=NoStretchedBlit3x; + if(iDesktopCol==15) p2XSaIFunc=Scale3x_ex6_5; + else if(iDesktopCol==16) p2XSaIFunc=Scale3x_ex6_5; + else p2XSaIFunc=Scale3x_ex8; + break; + case 15: + pExtraBltFunc=NoStretchedBlit3x; + if (iDesktopCol==15) p2XSaIFunc=hq3x_16; + else if(iDesktopCol==16) p2XSaIFunc=hq3x_16; + else p2XSaIFunc=hq3x_32; + break; + default: + pExtraBltFunc=NULL; + p2XSaIFunc=NULL; + break; + } + + //////////////////////////////////////////////////////// clipper init + + if(FAILED(h=IDirectDraw_CreateClipper(DX.DD,0,&Clipper,NULL))) + return 0; + + if(iUseScanLines) + SetScanLineList(Clipper); + else IDirectDrawClipper_SetHWnd(Clipper,0,DX.hWnd); + + IDirectDrawSurface_SetClipper(DX.DDSPrimary,Clipper); + IDirectDrawClipper_Release(Clipper); + + //////////////////////////////////////////////////////// small screen clean up + + DXSetGamma(); + + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + + IDirectDrawSurface_Blt(DX.DDSPrimary,NULL,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + IDirectDrawSurface_Blt(DX.DDSRender,NULL,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + + //////////////////////////////////////////////////////// finish init + + if(iUseNoStretchBlt>=3) + { + pSaISmallBuff=malloc(512*512*4); + memset(pSaISmallBuff,0,512*512*4); + pSaIBigBuff=malloc(1024*1024*4); + memset(pSaIBigBuff,0,1024*1024*4); + } + + bUsingTWin=FALSE; + + InitMenu(); // menu init + + if(iShowFPS) // fps on startup + { + ulKeybits|=KEY_SHOWFPS; + szDispBuf[0]=0; + BuildDispMenu(0); + } + + bIsFirstFrame = FALSE; // done + + return 0; +} + +//////////////////////////////////////////////////////////////////////// +// clean up DX stuff +//////////////////////////////////////////////////////////////////////// + +void DXcleanup() // DX CLEANUP +{ + CloseMenu(); // bye display lists + + if(iUseNoStretchBlt>=3) + { + if(pSaISmallBuff) free(pSaISmallBuff); + pSaISmallBuff=NULL; + if(pSaIBigBuff) free(pSaIBigBuff); + pSaIBigBuff=NULL; + } + + if(!bIsFirstFrame) + { + if(DX.DDSHelper) IDirectDrawSurface_Release(DX.DDSHelper); + DX.DDSHelper=0; + if(DX.DDSScreenPic) IDirectDrawSurface_Release(DX.DDSScreenPic); + DX.DDSScreenPic=0; + IDirectDrawSurface_Release(DX.DDSRender); + IDirectDrawSurface_Release(DX.DDSPrimary); + IDirectDraw_SetCooperativeLevel(DX.DD,DX.hWnd, DDSCL_NORMAL); + IDirectDraw_RestoreDisplayMode(DX.DD); + IDirectDraw_Release(DX.DD); + + ReStart=TRUE; + bIsFirstFrame = TRUE; + } +} + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +DWORD dwGPUStyle=0; // vars to store some wimdows stuff +HANDLE hGPUMenu=NULL; + +unsigned long ulInitDisplay(void) +{ + HDC hdc;RECT r; + + if(iWindowMode) // win mode? + { + DWORD dw=GetWindowLong(hWGPU, GWL_STYLE); // -> adjust wnd style + dwGPUStyle=dw; + dw&=~WS_THICKFRAME; + dw|=WS_BORDER|WS_CAPTION; + SetWindowLong(hWGPU, GWL_STYLE, dw); + + iResX=LOWORD(iWinSize);iResY=HIWORD(iWinSize); + ShowWindow(hWGPU,SW_SHOWNORMAL); + + if(iUseScanLines) + SetWindowPos(hWGPU,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + + MoveWindow(hWGPU, // -> move 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(hWGPU); // -> let windows do some update + } + else // no window mode: + { + DWORD dw=GetWindowLong(hWGPU, GWL_STYLE); // -> adjust wnd style + dwGPUStyle=dw; + hGPUMenu=GetMenu(hWGPU); + + dw&=~(WS_THICKFRAME|WS_BORDER|WS_CAPTION); + SetWindowLong(hWGPU, GWL_STYLE, dw); + SetMenu(hWGPU,NULL); + + ShowWindow(hWGPU,SW_SHOWMAXIMIZED); // -> max mode + } + + r.left=r.top=0;r.right=iResX;r.bottom=iResY; // init bkg with black + hdc = GetDC(hWGPU); + FillRect(hdc,&r,(HBRUSH)GetStockObject(BLACK_BRUSH)); + ReleaseDC(hWGPU, hdc); + + DXinitialize(); // init direct draw (not D3D... oh, well) + + if(!iWindowMode) // fullscreen mode? + ShowWindow(hWGPU,SW_SHOWMAXIMIZED); // -> maximize again (fixes strange DX behavior) + + return 1; +} + +//////////////////////////////////////////////////////////////////////// + +void CloseDisplay(void) +{ + DXcleanup(); // cleanup dx + + SetWindowLong(hWGPU, GWL_STYLE,dwGPUStyle); // repair window + if(hGPUMenu) SetMenu(hWGPU,(HMENU)hGPUMenu); +} + +//////////////////////////////////////////////////////////////////////// + +void CreatePic(unsigned char * pMem) +{ + DDSURFACEDESC xddsd;HRESULT ddrval; + unsigned char * ps;int x,y; + + memset(&xddsd, 0, sizeof(DDSURFACEDESC)); + xddsd.dwSize = sizeof(DDSURFACEDESC); + xddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; +// xddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + + if(iSysMemory) + xddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + else + xddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; + + xddsd.dwWidth = 128; + xddsd.dwHeight = 96; + + if(IDirectDraw_CreateSurface(DX.DD,&xddsd, &DX.DDSScreenPic, NULL)) + {DX.DDSScreenPic=0;return;} + + ddrval=IDirectDrawSurface_Lock(DX.DDSScreenPic,NULL, &xddsd, DDLOCK_WAIT|DDLOCK_WRITEONLY, NULL); + + if(ddrval==DDERR_SURFACELOST) + { + IDirectDrawSurface_Restore(DX.DDSScreenPic); + } + + if(ddrval!=DD_OK) + { + IDirectDrawSurface_Unlock(DX.DDSScreenPic,&xddsd); + return; + } + + ps=(unsigned char *)xddsd.lpSurface; + + if(iDesktopCol==16) + { + unsigned short s; + for(y=0;y<96;y++) + { + for(x=0;x<128;x++) + { + s=(*(pMem+0))>>3; + s|=((*(pMem+1))&0xfc)<<3; + s|=((*(pMem+2))&0xf8)<<8; + pMem+=3; + *((unsigned short *)(ps+y*xddsd.lPitch+x*2))=s; + } + } + } + else + if(iDesktopCol==15) + { + unsigned short s; + for(y=0;y<96;y++) + { + for(x=0;x<128;x++) + { + s=(*(pMem+0))>>3; + s|=((*(pMem+1))&0xfc)<<2; + s|=((*(pMem+2))&0xf8)<<7; + pMem+=3; + *((unsigned short *)(ps+y*xddsd.lPitch+x*2))=s; + } + } + } + else + if(iDesktopCol==32) + { + unsigned long l; + for(y=0;y<96;y++) + { + for(x=0;x<128;x++) + { + l= *(pMem+0); + l|=(*(pMem+1))<<8; + l|=(*(pMem+2))<<16; + pMem+=3; + *((unsigned long *)(ps+y*xddsd.lPitch+x*4))=l; + } + } + } + + IDirectDrawSurface_Unlock(DX.DDSScreenPic,&xddsd); +} + +/////////////////////////////////////////////////////////////////////////////////////// + +void DestroyPic(void) +{ + if(DX.DDSScreenPic) + { + RECT ScreenRect={iResX-128,0,iResX,96}; + DDBLTFX ddbltfx; + + if(iWindowMode) + { + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + ScreenRect.left+=Point.x; + ScreenRect.right+=Point.x; + ScreenRect.top+=Point.y; + ScreenRect.bottom+=Point.y; + } + + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0x00000000; + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,NULL,NULL,DDBLT_COLORFILL,&ddbltfx); + + IDirectDrawSurface_Release(DX.DDSScreenPic); + DX.DDSScreenPic=0; + } +} + +/////////////////////////////////////////////////////////////////////////////////////// + +void DisplayPic(void) +{ + RECT ScreenRect={iResX-128,0,iResX,96}, + HelperRect={0,0,128,96}; + if(iWindowMode) + { + POINT Point={0,0}; + ClientToScreen(DX.hWnd,&Point); + ScreenRect.left+=Point.x; + ScreenRect.right+=Point.x; + ScreenRect.top+=Point.y; + ScreenRect.bottom+=Point.y; + } + +// ??? eh... no need to wait here! +// WaitVBlank(); + + IDirectDrawSurface_Blt(DX.DDSPrimary,&ScreenRect,DX.DDSScreenPic,&HelperRect, + DDBLT_WAIT,NULL); +} + +/////////////////////////////////////////////////////////////////////////////////////// + +void ShowGpuPic(void) +{ + HRSRC hR;HGLOBAL hG;unsigned long * pRMem; + unsigned char * pMem;int x,y;unsigned long * pDMem; + + // turn off any screen pic, if it does already exist + if(DX.DDSScreenPic) {DestroyPic();return;} + + if(ulKeybits&KEY_SHOWFPS) {ShowTextGpuPic();return;} + + // load and lock the bitmap (lock is kinda obsolete in win32) + hR=FindResource(hInst,MAKEINTRESOURCE(IDB_GPU),RT_BITMAP); + hG=LoadResource(hInst,hR); + + // get long ptr to bmp data + pRMem=((unsigned long *)LockResource(hG))+10; + + // change the data upside-down + pMem=(unsigned char *)malloc(128*96*3); + + for(y=0;y<96;y++) + { + pDMem=(unsigned long *)(pMem+(95-y)*128*3); + for(x=0;x<96;x++) *pDMem++=*pRMem++; + } + + // show the pic + CreatePic(pMem); + + // clean up + free(pMem); + 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(128,255,128); // some example color inits + COLORREF crBkg = RGB(0,0,0); + COLORREF crText = RGB(0,255,0); + + if(DX.DDSScreenPic) 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); +} + +/////////////////////////////////////////////////////////////////////// + +static void hqx_init(unsigned bits_per_pixel) +{ + interp_set(bits_per_pixel); +} + +static void hq2x_16_def(unsigned short* dst0, unsigned short* dst1, const unsigned short* src0, const unsigned short* src1, const unsigned short* src2, unsigned count) +{ + unsigned i; + + for(i=0;i<count;++i) { + unsigned char mask; + + unsigned short c[9]; + + c[1] = src0[0]; + c[4] = src1[0]; + c[7] = src2[0]; + + if (i>0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } + + if (i<count-1) { + c[2] = src0[1]; + c[5] = src1[1]; + c[8] = src2[1]; + } else { + c[2] = c[1]; + c[5] = c[4]; + c[8] = c[7]; + } + + mask = 0; + + if (interp_16_diff(c[0], c[4])) + mask |= 1 << 0; + if (interp_16_diff(c[1], c[4])) + mask |= 1 << 1; + if (interp_16_diff(c[2], c[4])) + mask |= 1 << 2; + if (interp_16_diff(c[3], c[4])) + mask |= 1 << 3; + if (interp_16_diff(c[5], c[4])) + mask |= 1 << 4; + if (interp_16_diff(c[6], c[4])) + mask |= 1 << 5; + if (interp_16_diff(c[7], c[4])) + mask |= 1 << 6; + if (interp_16_diff(c[8], c[4])) + mask |= 1 << 7; + + switch (mask) { +#include "hq2x.h" + } + + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 2; + dst1 += 2; + } +} + +void hq2x( unsigned char * srcPtr, DWORD srcPitch, unsigned char * dstPtr, int width, int height) +{ + + //const int srcpitch = srcPitch; + const int dstPitch = srcPitch; + + int count = height; + + unsigned short *dst0 = (unsigned short *)dstPtr; + unsigned short *dst1 = dst0 + dstPitch; + + unsigned short *src0 = (unsigned short *)srcPtr; + unsigned short *src1 = src0 + (srcPitch >> 1); + unsigned short *src2 = src1 + (srcPitch >> 1); + hqx_init(16); + hq2x_16_def(dst0, dst1, src0, src0, src1, width); + + count -= 2; + while(count) { + dst0 += dstPitch << 1; + dst1 += dstPitch << 1; + hq2x_16_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } + dst0 += dstPitch << 1; + dst1 += dstPitch << 1; + hq2x_16_def(dst0, dst1, src0, src1, src1, width); +} + +/////////////////////////////////////////////////////////////////// + +static void hq2x_32_def(unsigned long * dst0, unsigned long * dst1, const unsigned long * src0, const unsigned long * src1, const unsigned long * src2, unsigned count) +{ + unsigned i; + + for(i=0;i<count;++i) { + unsigned char mask; + + unsigned long c[9]; + + c[1] = src0[0]; + c[4] = src1[0]; + c[7] = src2[0]; + + if (i>0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } + + if (i<count-1) { + c[2] = src0[1]; + c[5] = src1[1]; + c[8] = src2[1]; + } else { + c[2] = c[1]; + c[5] = c[4]; + c[8] = c[7]; + } + + mask = 0; + + if (interp_32_diff(c[0], c[4])) + mask |= 1 << 0; + if (interp_32_diff(c[1], c[4])) + mask |= 1 << 1; + if (interp_32_diff(c[2], c[4])) + mask |= 1 << 2; + if (interp_32_diff(c[3], c[4])) + mask |= 1 << 3; + if (interp_32_diff(c[5], c[4])) + mask |= 1 << 4; + if (interp_32_diff(c[6], c[4])) + mask |= 1 << 5; + if (interp_32_diff(c[7], c[4])) + mask |= 1 << 6; + if (interp_32_diff(c[8], c[4])) + mask |= 1 << 7; + + switch (mask) { +#include "hq2x.h" + } + + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 2; + dst1 += 2; + } +} + + + +void hq2x_32( unsigned char * srcPtr, DWORD srcPitch, unsigned char * dstPtr, int width, int height) +{ + const int dstPitch = srcPitch<<1; + + int count = height; + + unsigned long *dst0 = (unsigned long *)dstPtr; + unsigned long *dst1 = dst0 + (dstPitch >> 2); + + unsigned long *src0 = (unsigned long *)srcPtr; + unsigned long *src1 = src0 + (srcPitch >> 2); + unsigned long *src2 = src1 + (srcPitch >> 2); + hq2x_32_def(dst0, dst1, src0, src0, src1, width); + + + + count -= 2; + while(count) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2x_32_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2x_32_def(dst0, dst1, src0, src1, src1, width); +} + +static void hq3x_32_def(unsigned long* dst0, unsigned long* dst1, unsigned long* dst2, const unsigned long* src0, const unsigned long* src1, const unsigned long* src2, unsigned count) +{ + + unsigned i; + + for(i=0;i<count;++i) { + unsigned char mask; + + unsigned long c[9]; + + c[1] = src0[0]; + c[4] = src1[0]; + c[7] = src2[0]; + + if (i>0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } + + if (i<count-1) { + c[2] = src0[1]; + c[5] = src1[1]; + c[8] = src2[1]; + } else { + c[2] = c[1]; + c[5] = c[4]; + c[8] = c[7]; + } + + mask = 0; + + if (interp_32_diff(c[0], c[4])) + mask |= 1 << 0; + if (interp_32_diff(c[1], c[4])) + mask |= 1 << 1; + if (interp_32_diff(c[2], c[4])) + mask |= 1 << 2; + if (interp_32_diff(c[3], c[4])) + mask |= 1 << 3; + if (interp_32_diff(c[5], c[4])) + mask |= 1 << 4; + if (interp_32_diff(c[6], c[4])) + mask |= 1 << 5; + if (interp_32_diff(c[7], c[4])) + mask |= 1 << 6; + if (interp_32_diff(c[8], c[4])) + mask |= 1 << 7; + +#define P0 dst0[0] +#define P1 dst0[1] +#define P2 dst0[2] +#define P3 dst1[0] +#define P4 dst1[1] +#define P5 dst1[2] +#define P6 dst2[0] +#define P7 dst2[1] +#define P8 dst2[2] +#define MUR interp_32_diff(c[1], c[5]) +#define MDR interp_32_diff(c[5], c[7]) +#define MDL interp_32_diff(c[7], c[3]) +#define MUL interp_32_diff(c[3], c[1]) +#define IC(p0) c[p0] +#define I11(p0,p1) interp_32_11(c[p0], c[p1]) +#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2]) +#define I31(p0,p1) interp_32_31(c[p0], c[p1]) +#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2]) +#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2]) +#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2]) +#define I53(p0,p1) interp_32_53(c[p0], c[p1]) +#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2]) +#define I71(p0,p1) interp_32_71(c[p0], c[p1]) +#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2]) +#define I97(p0,p1) interp_32_97(c[p0], c[p1]) +#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2]) +#define I151(p0,p1) interp_32_151(c[p0], c[p1]) + + switch (mask) { +#include "hq3x.h" + } + + +#undef P0 +#undef P1 +#undef P2 +#undef P3 +#undef P4 +#undef P5 +#undef P6 +#undef P7 +#undef P8 +#undef MUR +#undef MDR +#undef MDL +#undef MUL +#undef IC +#undef I11 +#undef I211 +#undef I31 +#undef I332 +#undef I431 +#undef I521 +#undef I53 +#undef I611 +#undef I71 +#undef I772 +#undef I97 +#undef I1411 +#undef I151 + + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 3; + dst1 += 3; + dst2 += 3; + } +} + +void hq3x_32( unsigned char * srcPtr, DWORD srcPitch, unsigned char * dstPtr, int width, int height) +{ + + + + int count = height; + + int dstPitch = srcPitch >> 1; + + unsigned long *dst0 = (unsigned long *)dstPtr; + unsigned long *dst1 = dst0 + dstPitch; + unsigned long *dst2 = dst1 + dstPitch; + + unsigned long *src0 = (unsigned long *)srcPtr; + unsigned long *src1 = src0 + (srcPitch >> 2); + unsigned long *src2 = src1 + (srcPitch >> 2); + hq3x_32_def(dst0, dst1, dst2, src0, src0, src2, width); + + count -= 2; + while(count) { + + dst0 += dstPitch * 3; + dst1 += dstPitch * 3; + dst2 += dstPitch * 3; + + hq3x_32_def(dst0, dst1, dst2, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch * 3; + dst1 += dstPitch * 3; + dst2 += dstPitch * 3; + + + hq3x_32_def(dst0, dst1, dst2, src0, src1, src1, width); + +} + +static void hq3x_16_def(unsigned short* dst0, unsigned short* dst1, unsigned short* dst2, const unsigned short* src0, const unsigned short* src1, const unsigned short* src2, unsigned count) +{ + unsigned i; + + for(i=0;i<count;++i) { + unsigned char mask; + + unsigned short c[9]; + + c[1] = src0[0]; + c[4] = src1[0]; + c[7] = src2[0]; + + if (i>0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } + + if (i<count-1) { + c[2] = src0[1]; + c[5] = src1[1]; + c[8] = src2[1]; + } else { + c[2] = c[1]; + c[5] = c[4]; + c[8] = c[7]; + } + + mask = 0; + + if (interp_16_diff(c[0], c[4])) + mask |= 1 << 0; + if (interp_16_diff(c[1], c[4])) + mask |= 1 << 1; + if (interp_16_diff(c[2], c[4])) + mask |= 1 << 2; + if (interp_16_diff(c[3], c[4])) + mask |= 1 << 3; + if (interp_16_diff(c[5], c[4])) + mask |= 1 << 4; + if (interp_16_diff(c[6], c[4])) + mask |= 1 << 5; + if (interp_16_diff(c[7], c[4])) + mask |= 1 << 6; + if (interp_16_diff(c[8], c[4])) + mask |= 1 << 7; + + switch (mask) { + #include "hq3x.h" + } + + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 3; + dst1 += 3; + dst2 += 3; + } +} + +void hq3x_16( unsigned char * srcPtr, DWORD srcPitch, unsigned char * dstPtr, int width, int height) +{ + int count = height; + int dstPitch = srcPitch; + + unsigned short *dst0 = (unsigned short *)dstPtr; + unsigned short *dst1 = dst0 + dstPitch; + unsigned short *dst2 = dst1 + dstPitch; + + unsigned short *src0 = (unsigned short *)srcPtr; + unsigned short *src1 = src0 + (srcPitch >> 1); + unsigned short *src2 = src1 + (srcPitch >> 1); + hqx_init(16); + hq3x_16_def(dst0, dst1, dst2, src0, src0, src2, width); + + count -= 2; + while(count) { + + dst0 += dstPitch * 3; + dst1 += dstPitch * 3; + dst2 += dstPitch * 3; + + hq3x_16_def(dst0, dst1, dst2, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } + dst0 += dstPitch * 3; + dst1 += dstPitch * 3; + dst2 += dstPitch * 3; + + hq3x_16_def(dst0, dst1, dst2, src0, src1, src1, width); +} + diff --git a/win32/plugins/dfxvideo/winsrc/fps.c b/win32/plugins/dfxvideo/winsrc/fps.c new file mode 100644 index 00000000..728a8dd0 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/fps.c @@ -0,0 +1,571 @@ +/*************************************************************************** + fps.c - description + ------------------- + begin : Sun Oct 28 2001 + copyright : (C) 2001 by Pete Bernert + email : BlackDove@addcom.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ +
+#define _IN_FPS + +#include "externals.h" +#include "fps.h"
+#include "gpu.h" + +//////////////////////////////////////////////////////////////////////// +// FPS stuff +//////////////////////////////////////////////////////////////////////// + +LARGE_INTEGER CPUFrequency, PerformanceCounter; + +float fFrameRateHz=0; +DWORD dwFrameRateTicks=16; +float fFrameRate; +int iFrameLimit; +int UseFrameLimit=0; +int UseFrameSkip=0; + +//////////////////////////////////////////////////////////////////////// +// FPS skipping / limit +//////////////////////////////////////////////////////////////////////// + +BOOL bInitCap = TRUE; +float fps_skip = 0; +float fps_cur = 0; +
+////////////////////////////////////////////////////////////////////////
+
+#define MAXLACE 16
+
+void CheckFrameRate(void)
+{
+ if(UseFrameSkip) // skipping mode?
+ {
+ if(!(dwActFixes&0x80)) // not old skipping mode?
+ {
+ dwLaceCnt++; // -> store cnt of vsync between frames
+ if(dwLaceCnt>=MAXLACE && UseFrameLimit) // -> if there are many laces without screen toggling,
+ { // do std frame limitation
+ if(dwLaceCnt==MAXLACE) bInitCap=TRUE;
+ FrameCap();
+ }
+ }
+ else if(UseFrameLimit) FrameCap();
+ calcfps(); // -> calc fps display in skipping mode
+ }
+ else // non-skipping mode:
+ {
+ if(UseFrameLimit) FrameCap(); // -> do it
+ if(ulKeybits&KEY_SHOWFPS) calcfps(); // -> and calc fps display
+ }
+}
+ +//////////////////////////////////////////////////////////////////////// +// WIN VERSION +//////////////////////////////////////////////////////////////////////// + +BOOL IsPerformanceCounter = FALSE; + +void FrameCap (void) // frame limit func +{ + static DWORD curticks, lastticks, _ticks_since_last_update; + static DWORD TicksToWait = 0; + static LARGE_INTEGER CurrentTime; + static LARGE_INTEGER LastTime; + static BOOL SkipNextWait = FALSE; + BOOL Waiting = TRUE; + +//--------------------------------------------------------- + if(bInitCap) + { + bInitCap=FALSE; + if (IsPerformanceCounter) + QueryPerformanceCounter(&LastTime); + lastticks = timeGetTime(); + TicksToWait=0; + return; + } +//--------------------------------------------------------- + + if (IsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart; + + //--------------------------------------------------------- + curticks = timeGetTime(); + if(_ticks_since_last_update>(CPUFrequency.LowPart>>1)) + { + if(curticks < lastticks) + _ticks_since_last_update = dwFrameRateTicks+TicksToWait+1; + else _ticks_since_last_update = (CPUFrequency.LowPart * (curticks - lastticks))/1000; + } + //--------------------------------------------------------- + + if ((_ticks_since_last_update > TicksToWait) || + (CurrentTime.LowPart < LastTime.LowPart)) + { + LastTime.HighPart = CurrentTime.HighPart; + LastTime.LowPart = CurrentTime.LowPart; + + lastticks=curticks; + + if((_ticks_since_last_update-TicksToWait) > dwFrameRateTicks) + TicksToWait=0; + else TicksToWait=dwFrameRateTicks-(_ticks_since_last_update-TicksToWait); + } + else + { + while (Waiting) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart; + + //--------------------------------------------------------- + curticks = timeGetTime(); + if(_ticks_since_last_update>(CPUFrequency.LowPart>>1)) + { + if(curticks < lastticks) + _ticks_since_last_update = TicksToWait+1; + else _ticks_since_last_update = (CPUFrequency.LowPart * (curticks - lastticks))/1000; + } + //--------------------------------------------------------- + + if ((_ticks_since_last_update > TicksToWait) || + (CurrentTime.LowPart < LastTime.LowPart)) + { + Waiting = FALSE; + + lastticks=curticks; + + LastTime.HighPart = CurrentTime.HighPart; + LastTime.LowPart = CurrentTime.LowPart; + TicksToWait = dwFrameRateTicks; + } + } + } + } + else + { + curticks = timeGetTime(); + _ticks_since_last_update = curticks - lastticks; + + if ((_ticks_since_last_update > TicksToWait) || + (curticks < lastticks)) + { + lastticks = curticks; + + if((_ticks_since_last_update-TicksToWait) > dwFrameRateTicks) + TicksToWait=0; + else TicksToWait=dwFrameRateTicks-(_ticks_since_last_update-TicksToWait); + } + else + { + while (Waiting) + { + curticks = timeGetTime(); + _ticks_since_last_update = curticks - lastticks; + if ((_ticks_since_last_update > TicksToWait) || + (curticks < lastticks)) + { + Waiting = FALSE; + lastticks = curticks; + TicksToWait = dwFrameRateTicks; + } + } + } + } +} + +//////////////////////////////////////////////////////////////////////// + +#define MAXSKIP 120 + +void FrameSkip(void) +{ + static int iNumSkips=0,iAdditionalSkip=0; // number of additional frames to skip + static DWORD dwLastLace=0; // helper var for frame limitation + static DWORD curticks, lastticks, _ticks_since_last_update; + static LARGE_INTEGER CurrentTime; + static LARGE_INTEGER LastTime; + + if(!dwLaceCnt) return; // important: if no updatelace happened, we ignore it completely + + if(iNumSkips) // we are in pure skipping mode? + { + dwLastLace+=dwLaceCnt; // -> calc frame limit helper (number of laces) + bSkipNextFrame = TRUE; // -> we skip next frame as well + iNumSkips--; // -> ok, one done + } + else // ok, no additional skipping has to be done... + { // we check now, if some limitation is needed, or a new skipping has to get started + DWORD dwWaitTime; + + if(bInitCap || bSkipNextFrame) // first time or we skipped before? + { + if(UseFrameLimit && !bInitCap) // frame limit wanted and not first time called? + { + DWORD dwT=_ticks_since_last_update; // -> that's the time of the last drawn frame + dwLastLace+=dwLaceCnt; // -> and that's the number of updatelace since the start of the last drawn frame + + if (IsPerformanceCounter) // -> now we calc the time of the last drawn frame + the time we spent skipping + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update= dwT+CurrentTime.LowPart - LastTime.LowPart; + } + else + { + curticks = timeGetTime(); + _ticks_since_last_update= dwT+curticks - lastticks; + } + + dwWaitTime=dwLastLace*dwFrameRateTicks; // -> and now we calc the time the real psx would have needed + + if(_ticks_since_last_update<dwWaitTime) // -> we were too fast? + {
+ if((dwWaitTime-_ticks_since_last_update)> // -> some more security, to prevent
+ (60*dwFrameRateTicks)) // wrong waiting times
+ _ticks_since_last_update=dwWaitTime;
+ + while(_ticks_since_last_update<dwWaitTime) // -> loop until we have reached the real psx time + { // (that's the additional limitation, yup) + if (IsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = dwT+CurrentTime.LowPart - LastTime.LowPart; + } + else + { + curticks = timeGetTime(); + _ticks_since_last_update = dwT+curticks - lastticks; + } + } + } + else // we were still too slow ?!!? + { + if(iAdditionalSkip<MAXSKIP) // -> well, somewhen we really have to stop skipping on very slow systems + { + iAdditionalSkip++; // -> inc our watchdog var + dwLaceCnt=0; // -> reset lace count + if (IsPerformanceCounter) // -> ok, start time of the next frame + QueryPerformanceCounter(&LastTime); + lastticks = timeGetTime(); + return; // -> done, we will skip next frame to get more speed (SkipNextFrame still TRUE) + } + } + } + + bInitCap=FALSE; // -> ok, we have inited the frameskip func + iAdditionalSkip=0; // -> init additional skip + bSkipNextFrame=FALSE; // -> we don't skip the next frame + if (IsPerformanceCounter) // -> we store the start time of the next frame + QueryPerformanceCounter(&LastTime); + lastticks = timeGetTime(); + dwLaceCnt=0; // -> and we start to count the laces + dwLastLace=0; + _ticks_since_last_update=0; + return; // -> done, the next frame will get drawn + } + + bSkipNextFrame=FALSE; // init the frame skip signal to 'no skipping' first + + if (IsPerformanceCounter) // get the current time (we are now at the end of one drawn frame) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart; + } + else + { + curticks = timeGetTime(); + _ticks_since_last_update = curticks - lastticks; + } + + dwLastLace=dwLaceCnt; // store curr count (frame limitation helper) + dwWaitTime=dwLaceCnt*dwFrameRateTicks; // calc the 'real psx lace time' + + if(_ticks_since_last_update>dwWaitTime) // hey, we needed way too long for that frame... + {
+ if(UseFrameLimit) // if limitation, we skip just next frame,
+ { // and decide after, if we need to do more
+ iNumSkips=0;
+ }
+ else
+ { + iNumSkips=_ticks_since_last_update/dwWaitTime; // -> calc number of frames to skip to catch up
+ iNumSkips--; // -> since we already skip next frame, one down
+ if(iNumSkips>MAXSKIP) iNumSkips=MAXSKIP; // -> well, somewhere we have to draw a line
+ } + bSkipNextFrame = TRUE; // -> signal for skipping the next frame + } + else // we were faster than real psx? fine :) + if(UseFrameLimit) // frame limit used? so we wait til the 'real psx time' has been reached + {
+ if(dwLaceCnt>MAXLACE) // -> security check
+ _ticks_since_last_update=dwWaitTime;
+ + while(_ticks_since_last_update<dwWaitTime) // just do a waiting loop... + { + if (IsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart; + } + else + { + curticks = timeGetTime(); + _ticks_since_last_update = curticks - lastticks; + } + } + } + + if (IsPerformanceCounter) // ok, start time of the next frame + QueryPerformanceCounter(&LastTime); + lastticks = timeGetTime(); + } + + dwLaceCnt=0; // init lace counter +} + +//////////////////////////////////////////////////////////////////////// + +void calcfps(void) // fps calculations +{ + static DWORD curticks,_ticks_since_last_update,lastticks; + static long fps_cnt = 0; + static DWORD fps_tck = 1; + static LARGE_INTEGER CurrentTime; + static LARGE_INTEGER LastTime; + static long fpsskip_cnt = 0; + static DWORD fpsskip_tck = 1; + + if(IsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update=CurrentTime.LowPart-LastTime.LowPart; + + //--------------------------------------------------// + curticks = timeGetTime(); + if(_ticks_since_last_update>(CPUFrequency.LowPart>>1)) + _ticks_since_last_update = (CPUFrequency.LowPart * (curticks - lastticks))/1000; + lastticks=curticks; + //--------------------------------------------------// + + if(UseFrameSkip && !UseFrameLimit && _ticks_since_last_update) + fps_skip=min(fps_skip,(((float)CPUFrequency.LowPart) / ((float)_ticks_since_last_update) +1.0f)); + + LastTime.HighPart = CurrentTime.HighPart; + LastTime.LowPart = CurrentTime.LowPart; + } + else + { + curticks = timeGetTime(); + _ticks_since_last_update=curticks-lastticks; + + if(UseFrameSkip && !UseFrameLimit && _ticks_since_last_update) + fps_skip=min(fps_skip,((float)1000/(float)_ticks_since_last_update+1.0f)); + + lastticks = curticks; + } + + if(UseFrameSkip && UseFrameLimit) + { + fpsskip_tck += _ticks_since_last_update; + + if(++fpsskip_cnt==2) + { + if(IsPerformanceCounter) + fps_skip = ((float)CPUFrequency.LowPart) / ((float)fpsskip_tck) *2.0f; + else + fps_skip = (float)2000/(float)fpsskip_tck; + + fps_skip +=6.0f; + + fpsskip_cnt = 0; + fpsskip_tck = 1; + } + } + + fps_tck += _ticks_since_last_update; + + if(++fps_cnt==10) + { + if(IsPerformanceCounter) + fps_cur = ((float)CPUFrequency.LowPart) / ((float)fps_tck) *10.0f; + else + fps_cur = (float)10000/(float)fps_tck; + + fps_cnt = 0; + fps_tck = 1; + + if(UseFrameLimit && fps_cur>fFrameRateHz) // optical adjust ;) avoids flickering fps display + fps_cur=fFrameRateHz; + } +} + +//////////////////////////////////////////////////////////////////////// +// PC FPS skipping / limit +//////////////////////////////////////////////////////////////////////// + +void PCFrameCap (void) +{ + static DWORD curticks, lastticks, _ticks_since_last_update; + static DWORD TicksToWait = 0; + static LARGE_INTEGER CurrentTime; + static LARGE_INTEGER LastTime; + BOOL Waiting = TRUE; + + while (Waiting) + { + if (IsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart; + + //------------------------------------------------// + curticks = timeGetTime(); + if(_ticks_since_last_update>(CPUFrequency.LowPart>>1)) + { + if(curticks < lastticks) + _ticks_since_last_update = TicksToWait+1; + else _ticks_since_last_update = (CPUFrequency.LowPart * (curticks - lastticks))/1000; + } + //------------------------------------------------// + + if ((_ticks_since_last_update > TicksToWait) || + (CurrentTime.LowPart < LastTime.LowPart)) + { + Waiting = FALSE; + lastticks=curticks; + LastTime.HighPart = CurrentTime.HighPart; + LastTime.LowPart = CurrentTime.LowPart; + TicksToWait = (unsigned long)(CPUFrequency.LowPart / fFrameRateHz); + } + } + else + { + curticks = timeGetTime(); + _ticks_since_last_update = curticks - lastticks; + if ((_ticks_since_last_update > TicksToWait) || + (curticks < lastticks)) + { + Waiting = FALSE; + lastticks = curticks; + TicksToWait = (1000 / (DWORD)fFrameRateHz); + } + } + } +} + +//////////////////////////////////////////////////////////////////////// + +void PCcalcfps(void) +{ + static DWORD curticks,_ticks_since_last_update,lastticks; + static long fps_cnt = 0; + static float fps_acc = 0; + static LARGE_INTEGER CurrentTime; + static LARGE_INTEGER LastTime; + float CurrentFPS=0; + + if(IsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update=CurrentTime.LowPart-LastTime.LowPart; + + //--------------------------------------------------// + curticks = timeGetTime(); + if(_ticks_since_last_update>(CPUFrequency.LowPart>>1)) + _ticks_since_last_update = (CPUFrequency.LowPart * (curticks - lastticks))/1000; + lastticks=curticks; + //--------------------------------------------------// + + if(_ticks_since_last_update) + { + CurrentFPS = ((float)CPUFrequency.LowPart) / ((float)_ticks_since_last_update); + } + else CurrentFPS = 0; + LastTime.HighPart = CurrentTime.HighPart; + LastTime.LowPart = CurrentTime.LowPart; + } + else + { + curticks = timeGetTime(); + if(_ticks_since_last_update=curticks-lastticks) + CurrentFPS=(float)1000/(float)_ticks_since_last_update; + else CurrentFPS = 0; + lastticks = curticks; + } + + fps_acc += CurrentFPS; + + if(++fps_cnt==10) + { + fps_cur = fps_acc / 10; + fps_acc = 0; + fps_cnt = 0; + } + + fps_skip=CurrentFPS+1.0f; +} + +//////////////////////////////////////////////////////////////////////// + +void SetAutoFrameCap(void) +{ + if(iFrameLimit==1) + { + fFrameRateHz = fFrameRate; + if(IsPerformanceCounter) + dwFrameRateTicks=(DWORD)(CPUFrequency.LowPart / fFrameRateHz); + else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz); + return; + } + + if(dwActFixes&32) + { + if (PSXDisplay.Interlaced) + fFrameRateHz = PSXDisplay.PAL?50.0f:60.0f; + else fFrameRateHz = PSXDisplay.PAL?25.0f:30.0f; + } + else + { + fFrameRateHz = PSXDisplay.PAL?50.0f:59.94f; + if(IsPerformanceCounter) + dwFrameRateTicks=(DWORD)(CPUFrequency.LowPart / fFrameRateHz); + else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz); + } +} + +//////////////////////////////////////////////////////////////////////// + +void SetFPSHandler(void) +{ + if (QueryPerformanceFrequency (&CPUFrequency)) // timer mode + IsPerformanceCounter = TRUE; + else IsPerformanceCounter = FALSE; +} + +//////////////////////////////////////////////////////////////////////// + +void InitFPS(void) +{ + bInitCap = TRUE; + + if(fFrameRateHz==0) fFrameRateHz=fFrameRate; // set user framerate
+ + if(IsPerformanceCounter) + dwFrameRateTicks=(DWORD)(CPUFrequency.LowPart / fFrameRateHz); + else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz); +} + +//////////////////////////////////////////////////////////////////////// diff --git a/win32/plugins/dfxvideo/winsrc/gpu.bmp b/win32/plugins/dfxvideo/winsrc/gpu.bmp Binary files differnew file mode 100644 index 00000000..02d41302 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/gpu.bmp diff --git a/win32/plugins/dfxvideo/winsrc/key.c b/win32/plugins/dfxvideo/winsrc/key.c new file mode 100644 index 00000000..ad624243 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/key.c @@ -0,0 +1,137 @@ +/*************************************************************************** + key.c - description + ------------------- + begin : Sun Oct 28 2001 + copyright : (C) 2001 by Pete Bernert + email : BlackDove@addcom.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ + +#define _IN_KEY + +#include "externals.h" +#include "menu.h" +#include "gpu.h" +#include "draw.h" +#include "key.h" + +#include "record.h" + +//////////////////////////////////////////////////////////////////////// +// KeyBoard handler stuff +//////////////////////////////////////////////////////////////////////// + +WNDPROC wpOrgWndProc=0; +unsigned long ulKeybits=0; +char szGPUKeys[11]; +
+//////////////////////////////////////////////////////////////////////// +// keyboard handler +//////////////////////////////////////////////////////////////////////// + +void CALLBACK GPUshowScreenPic(unsigned char * pMem); +void CALLBACK GPUgetScreenPic(unsigned char * pMem); + +LRESULT CALLBACK KeyWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) +{ + switch(message) + { + //--------------------------------------------------// + case WM_ACTIVATE: // some scanline window mode fixing stuff + case WM_MOVE: + { + if(!iUseScanLines) break; + if(!iWindowMode) break; + if(bIsFirstFrame) break; + MoveScanLineArea(hwnd); + }break; + //--------------------------------------------------// + case WM_KEYDOWN: // keydown + if(wParam==(WPARAM)szGPUKeys[2]) ulKeybits|=KEY_RESETTEXSTORE; + break; + //--------------------------------------------------// + case WM_SYSKEYUP: // alt+enter + if(wParam==VK_RETURN) bChangeWinMode=TRUE; + break; + //--------------------------------------------------// + case WM_KEYUP: // key up
+
+ if(iDebugMode && wParam==(WPARAM)szGPUKeys[9])
+ iFVDisplay=!iFVDisplay;
+ + if(wParam==(WPARAM)szGPUKeys[0]) + { + if(ulKeybits&KEY_SHOWFPS) + { + DestroyPic(); + ulKeybits&=~KEY_SHOWFPS; + DoClearScreenBuffer(); + } + else + { + ulKeybits|=KEY_SHOWFPS; + szDispBuf[0]=0; + BuildDispMenu(0); + } + break; + } + if(wParam==(WPARAM)szGPUKeys[1]) {ShowGpuPic();break;} + + if(wParam==(WPARAM)szGPUKeys[6]) + { + if(RECORD_RECORDING==TRUE) + {RECORD_RECORDING=FALSE;RECORD_Stop();} + else + {RECORD_RECORDING=TRUE;RECORD_Start();} + BuildDispMenu(0); + break; + } + + if(wParam==(WPARAM)szGPUKeys[2]) {SwitchDispMenu(-1); break;} + if(wParam==(WPARAM)szGPUKeys[3]) {SwitchDispMenu(1); break;} + if(wParam==(WPARAM)szGPUKeys[4]) {BuildDispMenu(-1); break;} + if(wParam==(WPARAM)szGPUKeys[5]) {BuildDispMenu( 1); break;} + if(wParam==(WPARAM)szGPUKeys[7]) {bVsync_Key = bVsync_Key==TRUE ? FALSE : TRUE; BuildDispMenu(0);break;} + if(wParam==(WPARAM)szGPUKeys[8])
+ {
+ iFastFwd = 1 - iFastFwd;
+ bSkipNextFrame = FALSE;
+ UseFrameSkip=iFastFwd;
+ BuildDispMenu(0);
+ break;
+ }
+ break; + //--------------------------------------------------// + } + return wpOrgWndProc( hwnd, message, wParam, lParam ); +} + +//////////////////////////////////////////////////////////////////////// + +void SetKeyHandler(void) +{ + if(!wpOrgWndProc) // setup keyhandler + { + wpOrgWndProc = (WNDPROC)GetWindowLong(hWGPU, GWL_WNDPROC ); + SetWindowLong(hWGPU, GWL_WNDPROC, (long)KeyWndProc); + } +} + +//////////////////////////////////////////////////////////////////////// + +void ReleaseKeyHandler(void) +{ + if(wpOrgWndProc) + SetWindowLong(hWGPU,GWL_WNDPROC, // set old proc + (long)wpOrgWndProc); + wpOrgWndProc = 0; +} diff --git a/win32/plugins/dfxvideo/winsrc/record.c b/win32/plugins/dfxvideo/winsrc/record.c new file mode 100644 index 00000000..c6d3b86e --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/record.c @@ -0,0 +1,258 @@ +/*************************************************************************** + record.c - description + ------------------- + begin : Fri Nov 09 2001 + copyright : (C) 2001 by Darko Matesic + email : thedarkma@ptt.yu + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ + +#include "externals.h"
+#include "record.h"
+#include "gpu.h"
+#include <direct.h> + +extern BOOL RECORD_RECORDING = FALSE; +BITMAPINFOHEADER RECORD_BI = {40,0,0,1,16,0,0,2048,2048,0,0}; +unsigned char RECORD_BUFFER[1600*1200*3]; +unsigned long RECORD_INDEX; +unsigned long RECORD_RECORDING_MODE; +unsigned long RECORD_VIDEO_SIZE; +unsigned long RECORD_RECORDING_WIDTH; +unsigned long RECORD_RECORDING_HEIGHT; +unsigned long RECORD_FRAME_RATE_SCALE; +unsigned long RECORD_COMPRESSION_MODE; +COMPVARS RECORD_COMPRESSION1; +unsigned char RECORD_COMPRESSION_STATE1[4096]; +COMPVARS RECORD_COMPRESSION2; +unsigned char RECORD_COMPRESSION_STATE2[4096]; + + +PCOMPVARS pCompression = NULL; +AVISTREAMINFO strhdr; +PAVIFILE pfile = NULL; +PAVISTREAM ps = NULL; +PAVISTREAM psCompressed = NULL; +AVICOMPRESSOPTIONS opts; + +unsigned long frame; +unsigned long skip; + +//-------------------------------------------------------------------- + +BOOL RECORD_Start() +{ +static FILE *data; +static char filename[255]; +RECORD_INDEX = 0; +if(HIWORD(VideoForWindowsVersion())<0x010a) {MessageBox(NULL,"Video for Windows version is too old !\nAbording Recording.","Error", MB_OK|MB_ICONSTOP);return FALSE;} +mkdir("demo"); +while(TRUE) + { + sprintf(filename,"demo\\demo%04d.AVI",RECORD_INDEX++); + if((data=fopen(filename,"rb"))==NULL) break; + fclose(data); + if(RECORD_INDEX>9999) goto error; + } +if((data=fopen(filename,"wb"))==NULL) goto error; +if(RECORD_RECORDING_MODE==0) + { + switch(RECORD_VIDEO_SIZE) + { + case 0: + RECORD_BI.biWidth = iResX; + RECORD_BI.biHeight = iResY; + break; + case 1: + RECORD_BI.biWidth = iResX/2; + RECORD_BI.biHeight = iResY/2; + break; + default: + RECORD_BI.biWidth = iResX/4; + RECORD_BI.biHeight = iResY/4; + break; + } + } +else + { + RECORD_BI.biWidth = RECORD_RECORDING_WIDTH; + RECORD_BI.biHeight = RECORD_RECORDING_HEIGHT; + } +if(RECORD_COMPRESSION_MODE==0) + { + RECORD_BI.biBitCount = 16; + RECORD_BI.biSizeImage = RECORD_BI.biWidth*RECORD_BI.biHeight*2; + pCompression = &RECORD_COMPRESSION1; + } +else + { + RECORD_BI.biBitCount = 24; + RECORD_BI.biSizeImage = RECORD_BI.biWidth*RECORD_BI.biHeight*3; + pCompression = &RECORD_COMPRESSION2; + } +AVIFileInit(); +if(AVIFileOpen(&pfile,filename,OF_WRITE | OF_CREATE,NULL)!=AVIERR_OK) goto error; +memset(&strhdr,0,sizeof(strhdr)); +strhdr.fccType = streamtypeVIDEO; +strhdr.fccHandler = pCompression->fccHandler; +strhdr.dwScale = RECORD_FRAME_RATE_SCALE + 1; +strhdr.dwRate = (PSXDisplay.PAL)?50:60;// FPS +strhdr.dwSuggestedBufferSize = RECORD_BI.biSizeImage; +SetRect(&strhdr.rcFrame,0,0,RECORD_BI.biWidth,RECORD_BI.biHeight); +if(AVIFileCreateStream(pfile,&ps,&strhdr)!=AVIERR_OK) goto error; + +opts.fccType = pCompression->fccType; +opts.fccHandler = pCompression->fccHandler; +opts.dwKeyFrameEvery = pCompression->lKey; +opts.dwQuality = pCompression->lQ; +opts.dwBytesPerSecond = pCompression->lDataRate; +opts.dwFlags = AVICOMPRESSF_DATARATE|AVICOMPRESSF_KEYFRAMES|AVICOMPRESSF_VALID; +opts.lpFormat = &RECORD_BI; +opts.cbFormat = sizeof(RECORD_BI); +opts.lpParms = pCompression->lpState; +opts.cbParms = pCompression->cbState; +opts.dwInterleaveEvery = 0; + +if(AVIMakeCompressedStream(&psCompressed,ps,&opts,NULL)!=AVIERR_OK) goto error; +
+//if(AVIStreamSetFormat(psCompressed,0,&RECORD_BI,RECORD_BI.biSizeImage)!=AVIERR_OK) goto error;
+// fixed:
+if(AVIStreamSetFormat(psCompressed,0,&RECORD_BI,sizeof(RECORD_BI))!=AVIERR_OK) goto error;
+
+frame = 0; +skip = RECORD_FRAME_RATE_SCALE; +return TRUE; +error: +RECORD_Stop(); +RECORD_RECORDING = FALSE; +return FALSE; +} + +//-------------------------------------------------------------------- + +void RECORD_Stop() +{ +if(ps) AVIStreamClose(ps); +if(psCompressed) AVIStreamClose(psCompressed); +if(pfile) AVIFileClose(pfile); +AVIFileExit(); +} + +//-------------------------------------------------------------------- + +BOOL RECORD_WriteFrame() +{ +if(skip) {skip--;return TRUE;} +skip=RECORD_FRAME_RATE_SCALE; +if(!RECORD_GetFrame()) return FALSE; +if(FAILED(AVIStreamWrite(psCompressed,frame,1,RECORD_BUFFER,RECORD_BI.biSizeImage,AVIIF_KEYFRAME,NULL,NULL))) + {RECORD_Stop();return FALSE;} +frame++; +return TRUE; +} + +//-------------------------------------------------------------------- + +BOOL RECORD_GetFrame() +{ +static unsigned short *srcs,*src,*dests,cs; +static unsigned char *srcc,*destc; +static long x,y,cx,cy,ax,ay; +static unsigned long cl; + +if(PSXDisplay.Disabled) + { + memset(RECORD_BUFFER,0,RECORD_BI.biSizeImage); + return TRUE; + } + +srcs = (unsigned short*)&psxVuw[PSXDisplay.DisplayPosition.x+(PSXDisplay.DisplayPosition.y<<10)]; +dests = (unsigned short*)RECORD_BUFFER; +destc = (unsigned char*)RECORD_BUFFER; +ax = (PSXDisplay.DisplayMode.x*65535L)/RECORD_BI.biWidth; +ay = (PSXDisplay.DisplayMode.y*65535L)/RECORD_BI.biHeight; +cy = (PSXDisplay.DisplayMode.y-1)<<16; +if(RECORD_BI.biBitCount==16) + { + if(PSXDisplay.RGB24) + { + for(y=0;y<RECORD_BI.biHeight;y++) + { + srcc = (unsigned char*)&srcs[(cy&0xffff0000)>>6]; + cx = 0; + for(x=0;x<RECORD_BI.biWidth;x++) + { + cl = *((unsigned long*)&srcc[(cx>>16)*3]); + *(dests++) = (unsigned short)(((cl&0xf8)<<7)|((cl&0xf800)>>6)|((cl&0xf80000)>>19)); + cx += ax; + } + cy -= ay;if(cy<0) cy=0; + } + } + else + { + for(y=0;y<RECORD_BI.biHeight;y++) + { + src = &srcs[(cy&0xffff0000)>>6]; + cx = 0; + for(x=0;x<RECORD_BI.biWidth;x++) + { + cs = src[cx>>16]; + *(dests++) = ((cs&0x7c00)>>10)|(cs&0x03e0)|((cs&0x001f)<<10); + cx += ax; + } + cy -= ay;if(cy<0) cy=0; + } + } + } +else if(RECORD_BI.biBitCount==24) + { + if(PSXDisplay.RGB24) + { + for(y=0;y<RECORD_BI.biHeight;y++) + { + srcc = (unsigned char*)&srcs[(cy&0xffff0000)>>6]; + cx = 0; + for(x=0;x<RECORD_BI.biWidth;x++) + { + cl = *((unsigned long*)&srcc[(cx>>16)*3]); + *(destc++) = (unsigned char)((cl&0xff0000)>>16); + *(destc++) = (unsigned char)((cl&0xff00)>>8); + *(destc++) = (unsigned char)(cl&0xff); + cx += ax; + } + cy -= ay;if(cy<0) cy=0; + } + } + else + { + for(y=0;y<RECORD_BI.biHeight;y++) + { + src = &srcs[(cy&0xffff0000)>>6]; + cx = 0; + for(x=0;x<RECORD_BI.biWidth;x++) + { + cs = src[cx>>16]; + *(destc++) = (unsigned char)((cs&0x7c00)>>7); + *(destc++) = (unsigned char)((cs&0x03e0)>>2); + *(destc++) = (unsigned char)((cs&0x001f)<<3); + cx += ax; + } + cy -= ay;if(cy<0) cy=0; + } + } + } +else + memset(RECORD_BUFFER,0,RECORD_BI.biSizeImage); + +return TRUE; +} diff --git a/win32/plugins/dfxvideo/winsrc/record.h b/win32/plugins/dfxvideo/winsrc/record.h new file mode 100644 index 00000000..498354f3 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/record.h @@ -0,0 +1,56 @@ +/*************************************************************************** + record.h - description + ------------------- + begin : Fri Nov 09 2001 + copyright : (C) 2001 by Darko Matesic + email : thedarkma@ptt.yu + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ + +//*************************************************************************// +// History of changes: +// +// 2001/12/18 - Darko Matesic +// - two types of compression (16bit & 24bit) +// - FPSE 24bit MDEC support +// +// 2001/11/09 - Darko Matesic +// - first revision +// +//*************************************************************************// + +#ifndef _RECORD_H_ +#define _RECORD_H_ + +#include <vfw.h> + +extern BOOL RECORD_RECORDING; +extern BITMAPINFOHEADER RECORD_BI; +extern unsigned char RECORD_BUFFER[1600*1200*3]; +extern unsigned long RECORD_INDEX; +extern unsigned long RECORD_RECORDING_MODE; +extern unsigned long RECORD_VIDEO_SIZE; +extern unsigned long RECORD_RECORDING_WIDTH; +extern unsigned long RECORD_RECORDING_HEIGHT; +extern unsigned long RECORD_FRAME_RATE_SCALE; +extern unsigned long RECORD_COMPRESSION_MODE; +extern COMPVARS RECORD_COMPRESSION1; +extern unsigned char RECORD_COMPRESSION_STATE1[4096]; +extern COMPVARS RECORD_COMPRESSION2; +extern unsigned char RECORD_COMPRESSION_STATE2[4096]; + +BOOL RECORD_Start(); +void RECORD_Stop(); +BOOL RECORD_WriteFrame(); +BOOL RECORD_GetFrame(); + +#endif
\ No newline at end of file diff --git a/win32/plugins/dfxvideo/winsrc/resource.h b/win32/plugins/dfxvideo/winsrc/resource.h new file mode 100644 index 00000000..187dee48 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/resource.h @@ -0,0 +1,143 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by gpuPeopsSoft.rc
+//
+#define IDS_INFO0 1
+#define IDS_INFO1 2
+#define IDS_INFO2 3
+#define IDC_DEFAULT 3
+#define IDC_DEF1 127
+#define IDC_DEF2 128
+#define IDD_DEVICE 133
+#define IDD_ABOUT 135
+#define IDD_FIXES 136
+#define IDB_GPU 137
+#define IDD_KEYS 138
+#define IDD_RECORDING 139
+#define IDC_CURSOR1 142
+#define IDD_CFGDLG 500
+#define IDD_CFGSOFT 501
+#define IDC_KEY1 1030
+#define IDC_KEY2 1031
+#define IDC_KEY3 1032
+#define IDC_KEY4 1033
+#define IDC_KEY5 1034
+#define IDC_KEY6 1035
+#define IDC_KEY7 1036
+#define IDC_KEY8 1037
+#define IDC_KEY9 1038
+#define IDC_KEY10 1039
+#define IDC_CLIPBOARD 1040
+#define IDC_CLPEDIT 1041
+#define IDC_TEXWINDOWS 2001
+#define IDC_TEXFIX 2002
+#define IDC_TEXLINEAR 2003
+#define IDC_RESOLUTION 2004
+#define IDC_DRAWDITHER 2005
+#define IDC_SCANLINES 2005
+#define IDC_CACHESIZE 2006
+#define IDC_COLDEPTH 2006
+#define IDC_CACHETXT 2007
+#define IDC_NOSTRETCH 2007
+#define IDC_USELINES 2008
+#define IDC_USEMASK 2008
+#define IDC_DITHER 2008
+#define IDC_COLORDEPTH 2009
+#define IDC_CHANGEDESK 2010
+#define IDC_GAMEFIX 2010
+#define IDC_USELIMIT 2011
+#define IDC_FRAMELIMIT 2012
+#define IDC_USESKIPPING 2012
+#define IDC_FRAMEAUTO 2013
+#define IDC_FRAMEMANUELL 2014
+#define IDC_ADVBLEND 2015
+#define IDC_DELAYEDFB 2015
+#define IDC_SHOWFPS 2015
+#define IDC_OFFSCREEN 2016
+#define IDC_SYSMEMORY 2016
+#define IDC_OPAQUE 2017
+#define IDC_STOPSAVER 2017
+#define IDC_TEXQUALITY 2018
+#define IDC_QUALTXT 2019
+#define IDC_USESKIP 2020
+#define IDC_QUALTXT2 2020
+#define IDC_DEVICE 2020
+#define IDC_DISPMODE1 2021
+#define IDC_DISPMODE2 2022
+#define IDC_SUBCACHE 2023
+#define IDC_WINDOWFREE 2024
+#define IDC_EXTCOLCHECK 2024
+#define IDC_TEXUSE 2024
+#define IDC_WINDOWAUTO 2025
+#define IDC_USETEXPRIO 2025
+#define IDC_WINX 2026
+#define IDC_WINY 2027
+#define IDC_SELDEV 2028
+#define IDC_DEVICETXT 2029
+#define IDC_DB1 2030
+#define IDC_FILTERTYPE 2030
+#define IDC_DB2 2031
+#define IDC_QUALTXT3 2031
+#define IDC_DB3 2032
+#define IDC_EXTCOL 2033
+#define IDC_FRAMELIM 2034
+#define IDC_SELFIX 2037
+#define IDC_USEGAMMA 2037
+#define IDC_FIX1 2038
+#define IDC_KEYCONFIG 2038
+#define IDC_FIX2 2039
+#define IDC_RECORDING 2039
+#define IDC_FIX3 2040
+#define IDC_FIX4 2041
+#define IDC_FIX5 2042
+#define IDC_FIX6 2043
+#define IDC_FIX7 2044
+#define IDC_FIX8 2045
+#define IDC_FIX9 2046
+#define IDC_FIX10 2047
+#define IDC_FIX11 2048
+#define IDC_FIX12 2049
+#define IDC_FIX13 2050
+#define IDC_FIX14 2051
+#define IDC_FIX15 2052
+#define IDC_FIX16 2053
+#define IDC_FIX17 2054
+#define IDC_FIX18 2055
+#define IDC_FIX19 2056
+#define IDC_FIX20 2057
+#define IDC_FIX21 2058
+#define IDC_FIX22 2059
+#define IDC_FIX23 2060
+#define IDC_FIX24 2061
+#define IDC_FIX25 2062
+#define IDC_FIX26 2063
+#define IDC_FIX27 2064
+#define IDC_FIX28 2065
+#define IDC_FIX29 2066
+#define IDC_FIX30 2067
+#define IDC_FIX31 2068
+#define IDC_FIX32 2069
+#define IDC_GAMMA 2070
+#define IDC_REC_MODE1 2071
+#define IDC_REC_MODE2 2072
+#define IDC_VIDEO_SIZE 2073
+#define IDC_REC_WIDTH 2074
+#define IDC_REC_HEIGHT 2075
+#define IDC_FRAME_RATE 2076
+#define IDC_COMPRESSION1 2077
+#define IDC_COMPRESSION2 2078
+#define IDC_RECCFG 2079
+#define IDC_VSYNC 2080
+#define IDC_TRANSPARENT 2081
+#define IDC_DEBUGMODE 2082
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 143
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 2083
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/win32/plugins/dfxvideo/winsrc/winmain.c b/win32/plugins/dfxvideo/winsrc/winmain.c new file mode 100644 index 00000000..583e5716 --- /dev/null +++ b/win32/plugins/dfxvideo/winsrc/winmain.c @@ -0,0 +1,34 @@ +/*************************************************************************** + gpuPeopsSoft.c - description + ------------------- + begin : Sun Oct 28 2001 + copyright : (C) 2001 by Pete Bernert + email : BlackDove@addcom.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ + +#include "externals.h" + +/////////////////////////////////////////////////////////////////////////// +// GENERIC FUNCS ////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +HINSTANCE hInst=NULL; + +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) +{ + hInst=(HINSTANCE)hModule; + return TRUE; // very quick :) +} + |
