diff options
Diffstat (limited to 'win32/plugins/peopsxgl/winsrc')
| -rwxr-xr-x[-rw-r--r--] | win32/plugins/peopsxgl/winsrc/cfg.c | 2082 | ||||
| -rwxr-xr-x[-rw-r--r--] | win32/plugins/peopsxgl/winsrc/fps.c | 1282 | ||||
| -rwxr-xr-x[-rw-r--r--] | win32/plugins/peopsxgl/winsrc/key.c | 406 | ||||
| -rwxr-xr-x[-rw-r--r--] | win32/plugins/peopsxgl/winsrc/ssave.c | 130 | ||||
| -rwxr-xr-x[-rw-r--r--] | win32/plugins/peopsxgl/winsrc/ssave.h | 56 | ||||
| -rwxr-xr-x[-rw-r--r--] | win32/plugins/peopsxgl/winsrc/winmain.c | 84 |
6 files changed, 2020 insertions, 2020 deletions
diff --git a/win32/plugins/peopsxgl/winsrc/cfg.c b/win32/plugins/peopsxgl/winsrc/cfg.c index 99c29b27..eef8f650 100644..100755 --- a/win32/plugins/peopsxgl/winsrc/cfg.c +++ b/win32/plugins/peopsxgl/winsrc/cfg.c @@ -1,1041 +1,1041 @@ -/***************************************************************************
- cfg.c - description
- -------------------
- begin : Sun Mar 08 2009
- copyright : (C) 1999-2009 by Pete Bernert
- web : www.pbernert.com
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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
-
-/////////////////////////////////////////////////////////////////////////////
-// Windows config handling
-
-#include "stdafx.h"
-#include "resource.h"
-#include "externals.h"
-#include "cfg.h"
-#include <stdio.h>
-
-char szKeyDefaults[7]={VK_DELETE,VK_INSERT,VK_HOME,VK_END,VK_PRIOR,VK_NEXT,0x00};
-
-/////////////////////////////////////////////////////////////////////////////
-// CCfgDlg dialog
-
-BOOL OnInitCfgDialog(HWND hW);
-void OnCfgOK(HWND hW);
-void OnCfgCancel(HWND hW);
-void OnCfgDef1(HWND hW);
-void OnCfgDef2(HWND hW);
-void OnBugFixes(HWND hW);
-void OnKeyConfig(HWND hW);
-void GetSettings(HWND hW);
-void OnClipboard(HWND hW);
-char * GetConfigInfos(HWND hWE);
-
-BOOL CALLBACK CfgDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- return OnInitCfgDialog(hW);
-
- case WM_COMMAND:
- {
- switch(LOWORD(wParam))
- {
- 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 IDCANCEL: OnCfgCancel(hW); return TRUE;
- case IDOK: OnCfgOK(hW); return TRUE;
- case IDC_CLIPBOARD: OnClipboard(hW); return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CCfgDlg message handlers
-
-////////////////////////////////////////////////////////////////////////
-// init dlg
-////////////////////////////////////////////////////////////////////////
-
-void ComboBoxAddRes(HWND hWC,char * cs) // ADD COMBOBOX RESOURCES
-{
- int i=ComboBox_FindString(hWC,-1,cs);
- if(i!=CB_ERR) return;
- ComboBox_AddString(hWC,cs);
-}
-
-
-BOOL OnInitCfgDialog(HWND hW) // INIT CONFIG DIALOG
-{
- HWND hWC;char cs[256];int i;DEVMODE dv;
-
- ReadConfig(); // read registry stuff
-
- //----------------------------------------------------// fill combo with available resolutions
-
- hWC=GetDlgItem(hW,IDC_RESOLUTION);
-
- memset(&dv,0,sizeof(DEVMODE));
- dv.dmSize=sizeof(DEVMODE);
- i=0;
-
- while(EnumDisplaySettings(NULL,i,&dv)) // add all resolutions from the driver
- {
- wsprintf(cs,"%4d x %4d",dv.dmPelsWidth,dv.dmPelsHeight);
- ComboBoxAddRes(hWC,cs);
- i++;
- }
-
- ComboBoxAddRes(hWC," 640 x 480"); // and also add some common ones
- ComboBoxAddRes(hWC," 800 x 600");
- ComboBoxAddRes(hWC,"1024 x 768");
- ComboBoxAddRes(hWC,"1152 x 864");
- ComboBoxAddRes(hWC,"1280 x 1024");
- ComboBoxAddRes(hWC,"1600 x 1200");
-
- wsprintf(cs,"%4d x %4d",iResX,iResY); // search curr resolution in combo
- i=ComboBox_FindString(hWC,-1,cs);
- if(i==CB_ERR) i=0;
- ComboBox_SetCurSel(hWC,i); // and select this one
-
- //----------------------------------------------------// window size
-
- SetDlgItemInt(hW,IDC_WINX,LOWORD(iWinSize),FALSE);
- SetDlgItemInt(hW,IDC_WINY,HIWORD(iWinSize),FALSE);
-
- //----------------------------------------------------// color depth
-
- hWC=GetDlgItem(hW,IDC_COLORDEPTH);
- ComboBox_AddString(hWC,"16 Bit");
- ComboBox_AddString(hWC,"32 Bit");
- wsprintf(cs,"%d Bit",iColDepth);
- i=ComboBox_FindString(hWC,-1,cs);
- if(i==CB_ERR) i=0;
- ComboBox_SetCurSel(hWC,i);
-
- //----------------------------------------------------// vsync
-
- hWC=GetDlgItem(hW,IDC_VSYNC);
- ComboBox_AddString(hWC,"Driver");
- ComboBox_AddString(hWC,"Off");
- ComboBox_AddString(hWC,"On");
- ComboBox_SetCurSel(hWC,iForceVSync+1);
-
- //----------------------------------------------------// vram size
-
- hWC=GetDlgItem(hW,IDC_VRAMSIZE);
- ComboBox_AddString(hWC,"0 (Autodetect)");
- ComboBox_AddString(hWC,"2");
- ComboBox_AddString(hWC,"4");
- ComboBox_AddString(hWC,"8");
- ComboBox_AddString(hWC,"16");
- ComboBox_AddString(hWC,"32");
- ComboBox_AddString(hWC,"64");
- ComboBox_AddString(hWC,"128 (or more)");
-
- if(!iVRamSize) ComboBox_SetCurSel(hWC,0);
- else {wsprintf(cs,"%d",iVRamSize);ComboBox_SetText(hWC,cs);}
-
- //----------------------------------------------------// texture quality
-
- hWC=GetDlgItem(hW,IDC_TEXQUALITY);
- ComboBox_AddString(hWC,"don't care - Use driver's default textures");
- ComboBox_AddString(hWC,"R4 G4 B4 A4 - Fast, but less colorful");
- ComboBox_AddString(hWC,"R5 G5 B5 A1 - Nice colors, bad transparency");
- ComboBox_AddString(hWC,"R8 G8 B8 A8 - Best colors, more ram needed");
- ComboBox_AddString(hWC,"B8 G8 R8 A8 - Slightly faster with some cards");
- ComboBox_SetCurSel(hWC,iTexQuality);
-
- //----------------------------------------------------// all kind of on/off options
-
- if(bDrawDither) CheckDlgButton(hW,IDC_DRAWDITHER,TRUE);
- if(bUseLines) CheckDlgButton(hW,IDC_USELINES,TRUE);
- if(bUseFrameLimit) CheckDlgButton(hW,IDC_USELIMIT,TRUE);
- if(bUseFrameSkip) CheckDlgButton(hW,IDC_USESKIP,TRUE);
- if(bAdvancedBlend) CheckDlgButton(hW,IDC_ADVBLEND,TRUE);
- if(bOpaquePass) CheckDlgButton(hW,IDC_OPAQUE,TRUE);
-// if(bUseAntiAlias) CheckDlgButton(hW,IDC_USEANTIALIAS,TRUE);
- if(bWindowMode) CheckDlgButton(hW,IDC_DISPMODE2,TRUE);
- else CheckDlgButton(hW,IDC_DISPMODE1,TRUE);
- if(iUseMask) CheckDlgButton(hW,IDC_USEMASK,TRUE);
- if(bUseFastMdec) CheckDlgButton(hW,IDC_FASTMDEC,TRUE);
- if(bUse15bitMdec) CheckDlgButton(hW,IDC_FASTMDEC2,TRUE);
- if(bUseFixes) CheckDlgButton(hW,IDC_GAMEFIX,TRUE);
- if(bGteAccuracy) CheckDlgButton(hW,IDC_GTEACCURACY,TRUE);
- if(iUseScanLines) CheckDlgButton(hW,IDC_USESCANLINES,TRUE);
- if(iShowFPS) CheckDlgButton(hW,IDC_SHOWFPS,TRUE);
- if(bKeepRatio) CheckDlgButton(hW,IDC_ARATIO,TRUE);
- if(iBlurBuffer) CheckDlgButton(hW,IDC_BLUR,TRUE);
- if(iNoScreenSaver) CheckDlgButton(hW,IDC_SSAVE,TRUE);
-
- //----------------------------------------------------// texture filter
-
- hWC=GetDlgItem(hW,IDC_FILTERTYPE);
- ComboBox_AddString(hWC,"0: None");
- ComboBox_AddString(hWC,"1: Standard - Glitches will happen");
- ComboBox_AddString(hWC,"2: Extended - Removes black borders");
- ComboBox_AddString(hWC,"3: Standard w/o Sprites - unfiltered 2D");
- ComboBox_AddString(hWC,"4: Extended w/o Sprites - unfiltered 2D");
- ComboBox_AddString(hWC,"5: Standard + smoothed Sprites");
- ComboBox_AddString(hWC,"6: Extended + smoothed Sprites");
- ComboBox_SetCurSel(hWC,iFilterType);
-
- //----------------------------------------------------// hires texture mode
-
- hWC=GetDlgItem(hW,IDC_HIRESTEX);
- ComboBox_AddString(hWC,"0: None (standard)");
- ComboBox_AddString(hWC,"1: 2xSaI (much vram needed)");
- ComboBox_AddString(hWC,"2: Stretched (filtering needed)");
- ComboBox_SetCurSel(hWC,iHiResTextures);
-
- //----------------------------------------------------// offscreen drawing
-
- hWC=GetDlgItem(hW,IDC_OFFSCREEN);
- ComboBox_AddString(hWC,"0: None - Fastest, most glitches");
- ComboBox_AddString(hWC,"1: Minimum - Missing screens");
- ComboBox_AddString(hWC,"2: Standard - OK for most games");
- ComboBox_AddString(hWC,"3: Enhanced - Shows more stuff");
- ComboBox_AddString(hWC,"4: Extended - Can cause garbage");
- ComboBox_SetCurSel(hWC,iOffscreenDrawing);
-
- //----------------------------------------------------// texture quality
-
- hWC=GetDlgItem(hW,IDC_FRAMETEX);
- ComboBox_AddString(hWC,"0: Emulated vram - effects need FVP");
- ComboBox_AddString(hWC,"1: Black - Fast but no special effects");
- ComboBox_AddString(hWC,"2: Gfx card buffer - Can be slow");
- ComboBox_AddString(hWC,"3: Gfx card buffer & software - slow");
- ComboBox_SetCurSel(hWC,iFrameTexType);
-
- //----------------------------------------------------// framebuffer read mode
-
- hWC=GetDlgItem(hW,IDC_FRAMEREAD);
- ComboBox_AddString(hWC,"0: Emulated vram - OK for most games");
- ComboBox_AddString(hWC,"1: Gfx card buffer reads");
- ComboBox_AddString(hWC,"2: Gfx card buffer moves");
- ComboBox_AddString(hWC,"3: Gfx card buffer reads & moves");
- ComboBox_AddString(hWC,"4: Full software drawing (FVP)");
- ComboBox_SetCurSel(hWC,iFrameReadType);
-
- //----------------------------------------------------// framerate stuff
-
- if(iFrameLimit==2)
- CheckDlgButton(hW,IDC_FRAMEAUTO,TRUE);
- else CheckDlgButton(hW,IDC_FRAMEMANUELL,TRUE);
-
- sprintf(cs,"%.2f",fFrameRate);
- SetDlgItemText(hW,IDC_FRAMELIMIT,cs);
- SetDlgItemInt(hW,IDC_SCANBLEND,iScanBlend,TRUE);
-
- return TRUE;
-}
-
-////////////////////////////////////////////////////////////////////////
-// on ok: take vals
-////////////////////////////////////////////////////////////////////////
-
-void GetSettings(HWND hW)
-{
- HWND hWC;char cs[256];int i,j;char * p;
-
- hWC=GetDlgItem(hW,IDC_VRAMSIZE); // get vram size
- ComboBox_GetText(hWC,cs,255);
- iVRamSize=atoi(cs);
- if(iVRamSize<0) iVRamSize=0;
- if(iVRamSize>1024) iVRamSize=1024;
-
- hWC=GetDlgItem(hW,IDC_RESOLUTION); // get resolution
- i=ComboBox_GetCurSel(hWC);
- ComboBox_GetLBText(hWC,i,cs);
- iResX=atol(cs);
- p=strchr(cs,'x');
- if(p) iResY=atol(p+1);
- else iResY=480;
-
- hWC=GetDlgItem(hW,IDC_COLORDEPTH); // get color depth
- i=ComboBox_GetCurSel(hWC);
- ComboBox_GetLBText(hWC,i,cs);
- iColDepth=atol(cs);
-
- hWC=GetDlgItem(hW,IDC_VSYNC); // get vsync
- iForceVSync=ComboBox_GetCurSel(hWC)-1;
-
- i=GetDlgItemInt(hW,IDC_WINX,NULL,FALSE); // get win size
- if(i<100) i=100; if(i>16384) i=16384;
- j=GetDlgItemInt(hW,IDC_WINY,NULL,FALSE);
- if(j<100) j=100; if(j>16384) j=16384;
- iWinSize=MAKELONG(i,j);
-
- hWC=GetDlgItem(hW,IDC_TEXQUALITY); // texture quality
- iTexQuality=ComboBox_GetCurSel(hWC);
-
- hWC=GetDlgItem(hW,IDC_FILTERTYPE); // all kind of options
- iFilterType=ComboBox_GetCurSel(hWC);
-
- if(IsDlgButtonChecked(hW,IDC_DRAWDITHER))
- bDrawDither=TRUE; else bDrawDither=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_USELINES))
- bUseLines=TRUE; else bUseLines=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_DISPMODE2))
- bWindowMode=TRUE; else bWindowMode=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_ADVBLEND))
- bAdvancedBlend=TRUE; else bAdvancedBlend=FALSE;
-
- iOffscreenDrawing=ComboBox_GetCurSel(GetDlgItem(hW,IDC_OFFSCREEN));
-
- iFrameTexType=ComboBox_GetCurSel(GetDlgItem(hW,IDC_FRAMETEX));
- iFrameReadType=ComboBox_GetCurSel(GetDlgItem(hW,IDC_FRAMEREAD));
-
- if(IsDlgButtonChecked(hW,IDC_USELIMIT))
- bUseFrameLimit=TRUE; else bUseFrameLimit=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_USESKIP))
- bUseFrameSkip=TRUE; else bUseFrameSkip=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_OPAQUE))
- bOpaquePass=TRUE; else bOpaquePass=FALSE;
-
-// if(IsDlgButtonChecked(hW,IDC_USEANTIALIAS))
-// bUseAntiAlias=TRUE; else bUseAntiAlias=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_FASTMDEC))
- bUseFastMdec=TRUE; else bUseFastMdec=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_FASTMDEC2))
- bUse15bitMdec=TRUE; else bUse15bitMdec=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_GAMEFIX))
- bUseFixes=TRUE; else bUseFixes=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_GTEACCURACY))
- bGteAccuracy=TRUE; else bGteAccuracy=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_USESCANLINES))
- iUseScanLines=1; else iUseScanLines=0;
-
- if(IsDlgButtonChecked(hW,IDC_SHOWFPS))
- iShowFPS=1; else iShowFPS=0;
-
- if(IsDlgButtonChecked(hW,IDC_ARATIO))
- bKeepRatio=TRUE; else bKeepRatio=FALSE;
-
- if(IsDlgButtonChecked(hW,IDC_BLUR))
- iBlurBuffer=1; else iBlurBuffer=0;
-
- if(IsDlgButtonChecked(hW,IDC_SSAVE))
- iNoScreenSaver=1; else iNoScreenSaver=0;
-
- hWC=GetDlgItem(hW,IDC_HIRESTEX);
- iHiResTextures=ComboBox_GetCurSel(hWC);
-
- if(IsDlgButtonChecked(hW,IDC_USEMASK))
- {iUseMask=1;iZBufferDepth=16;}
- else {iUseMask=0;iZBufferDepth=0; }
-
- iScanBlend=GetDlgItemInt(hW,IDC_SCANBLEND,NULL,TRUE);
- if(iScanBlend>255) iScanBlend=0;
- if(iScanBlend<-1) iScanBlend=-1;
-
- if(IsDlgButtonChecked(hW,IDC_FRAMEAUTO)) // frame rate settings
- iFrameLimit=2;
- else iFrameLimit=1;
-
- GetDlgItemText(hW,IDC_FRAMELIMIT,cs,255);
- fFrameRate=(float)atof(cs);
- if(fFrameRate<10.0f) fFrameRate=10.0f;
- if(fFrameRate>1000.0f) fFrameRate=1000.0f;
-}
-
-////////////////////////////////////////////////////////////////////////
-// OK button
-////////////////////////////////////////////////////////////////////////
-
-void OnCfgOK(HWND hW)
-{
- GetSettings(hW); // get dialog settings
-
- WriteConfig(); // write registry
-
- EndDialog(hW,TRUE); // close dialog
-}
-
-////////////////////////////////////////////////////////////////////////
-// Clipboard button
-////////////////////////////////////////////////////////////////////////
-
-void OnClipboard(HWND hW)
-{
- HWND hWE=GetDlgItem(hW,IDC_CLPEDIT);
- char * pB;
-
- GetSettings(hW); // get dialog setings
- pB=GetConfigInfos(hWE); // get text infos
-
- if(pB) // some text got?
- {
- SetDlgItemText(hW,IDC_CLPEDIT,pB); // -> set text in invisible edit
- SendMessage(hWE,EM_SETSEL,0,-1); // -> sel all in edit
- SendMessage(hWE,WM_COPY,0,0); // -> copy sel to clipboard
- free(pB); // -> free helper text buffer
-
- 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 button (just closes window)
-////////////////////////////////////////////////////////////////////////
-
-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: // init dialog:
- {
- int i;
-
- for(i=0;i<32;i++) // -> loop all 32 checkboxes
- {
- if(dwCfgFixes&(1<<i)) // --> if fix is active: check box
- CheckDlgButton(hW,IDC_FIX1+i,TRUE);
- }
- }
-
- case WM_COMMAND:
- {
- switch(LOWORD(wParam))
- {
- case IDCANCEL: EndDialog(hW,FALSE);return TRUE; // cancel: close window
-
- case IDOK: // ok: take settings and close
- {
- 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) // bug fix button:
-{
- DialogBox(hInst,MAKEINTRESOURCE(IDD_FIXES), // show fix window
- hW,(DLGPROC)BugFixesDlgProc);
-}
-
-////////////////////////////////////////////////////////////////////////
-// default 1: fast
-////////////////////////////////////////////////////////////////////////
-
-void OnCfgDef1(HWND hW)
-{
- HWND hWC;
-
- hWC=GetDlgItem(hW,IDC_RESOLUTION);
- ComboBox_SetCurSel(hWC,0);
- hWC=GetDlgItem(hW,IDC_COLORDEPTH);
- ComboBox_SetCurSel(hWC,0);
- hWC=GetDlgItem(hW,IDC_VSYNC);
- ComboBox_SetCurSel(hWC,1);
- hWC=GetDlgItem(hW,IDC_TEXQUALITY);
- ComboBox_SetCurSel(hWC,0);
- hWC=GetDlgItem(hW,IDC_FILTERTYPE);
- ComboBox_SetCurSel(hWC,0);
- hWC=GetDlgItem(hW,IDC_OFFSCREEN);
- ComboBox_SetCurSel(hWC,1);
- hWC=GetDlgItem(hW,IDC_VRAMSIZE);
- ComboBox_SetCurSel(hWC,0);
-
- CheckDlgButton(hW,IDC_TEXLINEAR,FALSE);
- CheckDlgButton(hW,IDC_DRAWDITHER,FALSE);
- CheckDlgButton(hW,IDC_USELINES,FALSE);
- CheckDlgButton(hW,IDC_USELIMIT,FALSE);
- CheckDlgButton(hW,IDC_USESKIP,FALSE);
- CheckDlgButton(hW,IDC_ADVBLEND,FALSE);
- CheckDlgButton(hW,IDC_OPAQUE,TRUE);
-// CheckDlgButton(hW,IDC_USEANTIALIAS,FALSE);
- CheckDlgButton(hW,IDC_DISPMODE2,FALSE);
- CheckDlgButton(hW,IDC_DISPMODE1,TRUE);
- CheckDlgButton(hW,IDC_FRAMEAUTO,TRUE);
- CheckDlgButton(hW,IDC_FRAMEMANUELL,FALSE);
- CheckDlgButton(hW,IDC_SHOWFPS,FALSE);
-
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_SUBCACHE),2);
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_FRAMETEX),1);
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_FRAMEREAD),0);
-
- CheckDlgButton(hW,IDC_USEMASK,FALSE);
- CheckDlgButton(hW,IDC_FASTMDEC,TRUE);
- CheckDlgButton(hW,IDC_FASTMDEC2,TRUE);
- CheckDlgButton(hW,IDC_USESCANLINES,FALSE);
-
- SetDlgItemInt(hW,IDC_FRAMELIMIT,200,FALSE);
- SetDlgItemInt(hW,IDC_WINX,640,FALSE);
- SetDlgItemInt(hW,IDC_WINY,480,FALSE);
-
- CheckDlgButton(hW,IDC_ARATIO,FALSE);
- CheckDlgButton(hW,IDC_BLUR,FALSE);
-
- SetDlgItemInt(hW,IDC_SCANBLEND,0,TRUE);
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_HIRESTEX),0);
- CheckDlgButton(hW,IDC_SSAVE,FALSE);
-}
-
-////////////////////////////////////////////////////////////////////////
-// default 2: nice
-////////////////////////////////////////////////////////////////////////
-
-void OnCfgDef2(HWND hW)
-{
- HWND hWC;
-
- hWC=GetDlgItem(hW,IDC_RESOLUTION);
- ComboBox_SetCurSel(hWC,1);
- hWC=GetDlgItem(hW,IDC_COLORDEPTH);
- ComboBox_SetCurSel(hWC,1);
- hWC=GetDlgItem(hW,IDC_VSYNC);
- ComboBox_SetCurSel(hWC,2);
- hWC=GetDlgItem(hW,IDC_TEXQUALITY);
- ComboBox_SetCurSel(hWC,3);
- hWC=GetDlgItem(hW,IDC_FILTERTYPE);
- ComboBox_SetCurSel(hWC,0);
- hWC=GetDlgItem(hW,IDC_OFFSCREEN);
- ComboBox_SetCurSel(hWC,3);
- hWC=GetDlgItem(hW,IDC_VRAMSIZE);
- ComboBox_SetCurSel(hWC,0);
-
- CheckDlgButton(hW,IDC_TEXLINEAR,FALSE);
- CheckDlgButton(hW,IDC_DRAWDITHER,FALSE);
- CheckDlgButton(hW,IDC_USELINES,FALSE);
- CheckDlgButton(hW,IDC_USELIMIT,TRUE);
- CheckDlgButton(hW,IDC_USESKIP,FALSE);
- CheckDlgButton(hW,IDC_ADVBLEND,TRUE);
- CheckDlgButton(hW,IDC_OPAQUE,TRUE);
-// CheckDlgButton(hW,IDC_USEANTIALIAS,FALSE);
- CheckDlgButton(hW,IDC_DISPMODE2,FALSE);
- CheckDlgButton(hW,IDC_DISPMODE1,TRUE);
- CheckDlgButton(hW,IDC_FRAMEAUTO,TRUE);
- CheckDlgButton(hW,IDC_FRAMEMANUELL,FALSE);
- CheckDlgButton(hW,IDC_SHOWFPS,FALSE);
-
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_SUBCACHE),2);
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_FRAMETEX),2);
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_FRAMEREAD),0);
-
- CheckDlgButton(hW,IDC_USEMASK,TRUE);
- CheckDlgButton(hW,IDC_FASTMDEC,FALSE);
- CheckDlgButton(hW,IDC_FASTMDEC2,FALSE);
- CheckDlgButton(hW,IDC_USESCANLINES,FALSE);
-
- SetDlgItemInt(hW,IDC_FRAMELIMIT,200,FALSE);
- SetDlgItemInt(hW,IDC_WINX,640,FALSE);
- SetDlgItemInt(hW,IDC_WINY,480,FALSE);
- CheckDlgButton(hW,IDC_ARATIO,FALSE);
- CheckDlgButton(hW,IDC_BLUR,FALSE);
- SetDlgItemInt(hW,IDC_SCANBLEND,0,TRUE);
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_HIRESTEX),0);
- CheckDlgButton(hW,IDC_SSAVE,FALSE);
-}
-
-////////////////////////////////////////////////////////////////////////
-// read registry
-////////////////////////////////////////////////////////////////////////
-
-void ReadConfig(void) // read all config vals
-{
- HKEY myKey;
- DWORD temp;
- DWORD type;
- DWORD size;
-
- // pre-init all relevant globals
-
- iResX=800;iResY=600;
- iColDepth=32;
- bChangeRes=FALSE;
- bWindowMode=FALSE;
- bFullVRam=FALSE;
- iFilterType=0;
- bAdvancedBlend=FALSE;
- bDrawDither=FALSE;
- bUseLines=FALSE;
- bUseFrameLimit=TRUE;
- bUseFrameSkip=FALSE;
- iFrameLimit=2;
- fFrameRate=200.0f;
- iOffscreenDrawing=1;
- bOpaquePass=TRUE;
- bUseAntiAlias=FALSE;
- iTexQuality=0;
- iWinSize=MAKELONG(400,300);
- iUseMask=0;
- iZBufferDepth=0;
- bUseFastMdec=FALSE;
- bUse15bitMdec=FALSE;
- dwCfgFixes=0;
- bUseFixes=FALSE;
- bGteAccuracy=FALSE;
- iUseScanLines=0;
- iFrameTexType=0;
- iFrameReadType=0;
- iShowFPS=0;
- bKeepRatio=FALSE;
- iScanBlend=0;
- iVRamSize=0;
- iTexGarbageCollection=1;
- iBlurBuffer=0;
- iHiResTextures=0;
- iNoScreenSaver=1;
- iForceVSync=-1;
-
- lstrcpy(szGPUKeys,szKeyDefaults);
-
- // registry key: still "psemu pro/pete tnt" for compatibility reasons
-
- if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\PeteTNT",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;
- size = 4;
- if(RegQueryValueEx(myKey,"FilterType",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iFilterType=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"DrawDither",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bDrawDither=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"UseLines",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bUseLines=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"WindowMode",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bWindowMode=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"ColDepth",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iColDepth=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"ForceVSync",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iForceVSync=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"UseFrameLimit",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bUseFrameLimit=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"UseFrameSkip",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bUseFrameSkip=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"FrameLimit",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iFrameLimit=(int)temp;
- if(!iFrameLimit) {bUseFrameLimit=TRUE;bUseFrameSkip=FALSE;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,"UseMultiPass",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bAdvancedBlend=(int)temp;
- size = 4;
- iOffscreenDrawing=-1;
- if(RegQueryValueEx(myKey,"OffscreenDrawingEx",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iOffscreenDrawing=temp;
- if(iOffscreenDrawing==-1 &&
- RegQueryValueEx(myKey,"OffscreenDrawing",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iOffscreenDrawing=temp*2;
- size = 4;
- if(RegQueryValueEx(myKey,"OpaquePass",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bOpaquePass=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"VRamSize",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iVRamSize=(int)temp;
-// size = 4;
-// if(RegQueryValueEx(myKey,"UseAntiAlias",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
-// bUseAntiAlias=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"TexQuality",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iTexQuality=(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)
- bUseFixes=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"GteAccuracy",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bGteAccuracy=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"UseMask",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iUseMask=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"FastMdec",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bUseFastMdec=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"15BitMdec",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bUse15bitMdec=(BOOL)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,"KeepRatio",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- bKeepRatio=(BOOL)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"ScanBlend",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iScanBlend=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"FrameTexType",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iFrameTexType=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"FrameReadType",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iFrameReadType=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"FullscreenBlur",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iBlurBuffer=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"HiResTextures",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iHiResTextures=(int)temp;
- size = 4;
- if(RegQueryValueEx(myKey,"NoScreenSaver",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iNoScreenSaver=(int)temp;
-
- size=7;
- RegQueryValueEx(myKey,"GPUKeys",0,&type,(LPBYTE)&szGPUKeys,&size);
-
- RegCloseKey(myKey);
- }
- if(!iColDepth) iColDepth=32; // adjust color info
- if(iUseMask) iZBufferDepth=16; // set zbuffer depth
- else iZBufferDepth=0;
- if(bUseFixes) dwActFixes=dwCfgFixes; // init game fix global
- if(iFrameReadType==4) bFullVRam=TRUE; // set fullvram render flag (soft gpu)
-}
-
-////////////////////////////////////////////////////////////////////////
-// read registry: window size (called on fullscreen/window resize)
-////////////////////////////////////////////////////////////////////////
-
-void ReadWinSizeConfig(void)
-{
- HKEY myKey;
- DWORD temp;
- DWORD type;
- DWORD size;
-
- iResX=800;iResY=600;
- iWinSize=MAKELONG(400,300);
- iBlurBuffer=0;
-
- // registry key: still "psemu pro/pete tnt" for compatibility reasons
-
- if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\PeteTNT",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;
- size = 4;
- if(RegQueryValueEx(myKey,"FullscreenBlur",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS)
- iBlurBuffer=(int)temp;
- RegCloseKey(myKey);
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-// write registry
-////////////////////////////////////////////////////////////////////////
-
-void WriteConfig(void)
-{
- HKEY myKey;
- DWORD myDisp;
- DWORD temp;
-
- // registry key: still "psemu pro/pete tnt" for compatibility reasons
-
- RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\PeteTNT",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=iWinSize;
- RegSetValueEx(myKey,"WinSize",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iFilterType;
- RegSetValueEx(myKey,"FilterType",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bDrawDither;
- RegSetValueEx(myKey,"DrawDither",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bUseLines;
- RegSetValueEx(myKey,"UseLines",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bWindowMode;
- RegSetValueEx(myKey,"WindowMode",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iColDepth;
- RegSetValueEx(myKey,"ColDepth",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iForceVSync;
- RegSetValueEx(myKey,"ForceVSync",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bUseFrameLimit;
- RegSetValueEx(myKey,"UseFrameLimit",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bUseFrameSkip;
- RegSetValueEx(myKey,"UseFrameSkip",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iFrameLimit;
- RegSetValueEx(myKey,"FrameLimit",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=bAdvancedBlend;
- RegSetValueEx(myKey,"UseMultiPass",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iOffscreenDrawing/2;
- RegSetValueEx(myKey,"OffscreenDrawing",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iOffscreenDrawing;
- RegSetValueEx(myKey,"OffscreenDrawingEx",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bOpaquePass;
- RegSetValueEx(myKey,"OpaquePass",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iVRamSize;
- RegSetValueEx(myKey,"VRamSize",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
-// temp=bUseAntiAlias;
-// RegSetValueEx(myKey,"UseAntiAlias",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iTexQuality;
- RegSetValueEx(myKey,"TexQuality",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=dwCfgFixes;
- RegSetValueEx(myKey,"CfgFixes",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bUseFixes;
- RegSetValueEx(myKey,"UseFixes",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bGteAccuracy;
- RegSetValueEx(myKey,"GteAccuracy",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iUseMask;
- RegSetValueEx(myKey,"UseMask",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bUseFastMdec;
- RegSetValueEx(myKey,"FastMdec",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bUse15bitMdec;
- RegSetValueEx(myKey,"15BitMdec",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=iFrameTexType;
- RegSetValueEx(myKey,"FrameTexType",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iFrameReadType;
- RegSetValueEx(myKey,"FrameReadType",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=bKeepRatio;
- RegSetValueEx(myKey,"KeepRatio",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iBlurBuffer;
- RegSetValueEx(myKey,"FullscreenBlur",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iHiResTextures;
- RegSetValueEx(myKey,"HiResTextures",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iNoScreenSaver;
- RegSetValueEx(myKey,"NoScreenSaver",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- temp=iScanBlend;
- RegSetValueEx(myKey,"ScanBlend",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp));
- RegSetValueEx(myKey,"GPUKeys",0,REG_BINARY,(LPBYTE)szGPUKeys,7);
-
- RegCloseKey(myKey);
-}
-
-////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////
-// Key definition window
-
-typedef struct
-{
- char szName[10];
- char cCode;
-}
-KEYSETS;
-
-// sepcial keys:
-
-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},
- {"", 0x00}
-};
-
-// select key entry in combo box
-
-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);
-}
-
-// key window proc
-
-BOOL CALLBACK KeyDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch(uMsg)
- {
- case WM_INITDIALOG: // init dialog
- {
- int i,j,k;char szB[2];HWND hWC;
- for(i=IDC_KEY1;i<=IDC_KEY6;i++)
- {
- hWC=GetDlgItem(hW,i);
-
- for(j=0;tMKeys[j].cCode!=0;j++) // fill special keys in combo
- {
- k=ComboBox_AddString(hWC,tMKeys[j].szName);
- ComboBox_SetItemData(hWC,k,tMKeys[j].cCode);
- }
- for(j=0x30;j<=0x39;j++) // fill numbers in combo
- {
- wsprintf(szB,"%c",j);
- k=ComboBox_AddString(hWC,szB);
- ComboBox_SetItemData(hWC,k,j);
- }
- for(j=0x41;j<=0x5a;j++) // fill alphas in combo
- {
- 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: // default button:
- {
- int i; // -> set defaults
- for(i=IDC_KEY1;i<=IDC_KEY6;i++)
- SetGPUKey(GetDlgItem(hW,i),szKeyDefaults[i-IDC_KEY1]);
- }break;
-
- case IDCANCEL: // cancel: just close window
- EndDialog(hW,FALSE); return TRUE;
-
- case IDOK: // ok: take key bindings
- {
- HWND hWC;int i;
- for(i=IDC_KEY1;i<=IDC_KEY6;i++)
- {
- hWC=GetDlgItem(hW,i);
- szGPUKeys[i-IDC_KEY1]=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) // call key dialog
-{
- DialogBox(hInst,MAKEINTRESOURCE(IDD_KEYS),
- hW,(DLGPROC)KeyDlgProc);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// AboutDlg dialog (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;
-}
+/*************************************************************************** + cfg.c - description + ------------------- + begin : Sun Mar 08 2009 + copyright : (C) 1999-2009 by Pete Bernert + web : www.pbernert.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 + +///////////////////////////////////////////////////////////////////////////// +// Windows config handling + +#include "stdafx.h" +#include "resource.h" +#include "externals.h" +#include "cfg.h" +#include <stdio.h> + +char szKeyDefaults[7]={VK_DELETE,VK_INSERT,VK_HOME,VK_END,VK_PRIOR,VK_NEXT,0x00}; + +///////////////////////////////////////////////////////////////////////////// +// CCfgDlg dialog + +BOOL OnInitCfgDialog(HWND hW); +void OnCfgOK(HWND hW); +void OnCfgCancel(HWND hW); +void OnCfgDef1(HWND hW); +void OnCfgDef2(HWND hW); +void OnBugFixes(HWND hW); +void OnKeyConfig(HWND hW); +void GetSettings(HWND hW); +void OnClipboard(HWND hW); +char * GetConfigInfos(HWND hWE); + +BOOL CALLBACK CfgDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + return OnInitCfgDialog(hW); + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + 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 IDCANCEL: OnCfgCancel(hW); return TRUE; + case IDOK: OnCfgOK(hW); return TRUE; + case IDC_CLIPBOARD: OnClipboard(hW); return TRUE; + } + } + } + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////// +// CCfgDlg message handlers + +//////////////////////////////////////////////////////////////////////// +// init dlg +//////////////////////////////////////////////////////////////////////// + +void ComboBoxAddRes(HWND hWC,char * cs) // ADD COMBOBOX RESOURCES +{ + int i=ComboBox_FindString(hWC,-1,cs); + if(i!=CB_ERR) return; + ComboBox_AddString(hWC,cs); +} + + +BOOL OnInitCfgDialog(HWND hW) // INIT CONFIG DIALOG +{ + HWND hWC;char cs[256];int i;DEVMODE dv; + + ReadConfig(); // read registry stuff + + //----------------------------------------------------// fill combo with available resolutions + + hWC=GetDlgItem(hW,IDC_RESOLUTION); + + memset(&dv,0,sizeof(DEVMODE)); + dv.dmSize=sizeof(DEVMODE); + i=0; + + while(EnumDisplaySettings(NULL,i,&dv)) // add all resolutions from the driver + { + wsprintf(cs,"%4d x %4d",dv.dmPelsWidth,dv.dmPelsHeight); + ComboBoxAddRes(hWC,cs); + i++; + } + + ComboBoxAddRes(hWC," 640 x 480"); // and also add some common ones + ComboBoxAddRes(hWC," 800 x 600"); + ComboBoxAddRes(hWC,"1024 x 768"); + ComboBoxAddRes(hWC,"1152 x 864"); + ComboBoxAddRes(hWC,"1280 x 1024"); + ComboBoxAddRes(hWC,"1600 x 1200"); + + wsprintf(cs,"%4d x %4d",iResX,iResY); // search curr resolution in combo + i=ComboBox_FindString(hWC,-1,cs); + if(i==CB_ERR) i=0; + ComboBox_SetCurSel(hWC,i); // and select this one + + //----------------------------------------------------// window size + + SetDlgItemInt(hW,IDC_WINX,LOWORD(iWinSize),FALSE); + SetDlgItemInt(hW,IDC_WINY,HIWORD(iWinSize),FALSE); + + //----------------------------------------------------// color depth + + hWC=GetDlgItem(hW,IDC_COLORDEPTH); + ComboBox_AddString(hWC,"16 Bit"); + ComboBox_AddString(hWC,"32 Bit"); + wsprintf(cs,"%d Bit",iColDepth); + i=ComboBox_FindString(hWC,-1,cs); + if(i==CB_ERR) i=0; + ComboBox_SetCurSel(hWC,i); + + //----------------------------------------------------// vsync + + hWC=GetDlgItem(hW,IDC_VSYNC); + ComboBox_AddString(hWC,"Driver"); + ComboBox_AddString(hWC,"Off"); + ComboBox_AddString(hWC,"On"); + ComboBox_SetCurSel(hWC,iForceVSync+1); + + //----------------------------------------------------// vram size + + hWC=GetDlgItem(hW,IDC_VRAMSIZE); + ComboBox_AddString(hWC,"0 (Autodetect)"); + ComboBox_AddString(hWC,"2"); + ComboBox_AddString(hWC,"4"); + ComboBox_AddString(hWC,"8"); + ComboBox_AddString(hWC,"16"); + ComboBox_AddString(hWC,"32"); + ComboBox_AddString(hWC,"64"); + ComboBox_AddString(hWC,"128 (or more)"); + + if(!iVRamSize) ComboBox_SetCurSel(hWC,0); + else {wsprintf(cs,"%d",iVRamSize);ComboBox_SetText(hWC,cs);} + + //----------------------------------------------------// texture quality + + hWC=GetDlgItem(hW,IDC_TEXQUALITY); + ComboBox_AddString(hWC,"don't care - Use driver's default textures"); + ComboBox_AddString(hWC,"R4 G4 B4 A4 - Fast, but less colorful"); + ComboBox_AddString(hWC,"R5 G5 B5 A1 - Nice colors, bad transparency"); + ComboBox_AddString(hWC,"R8 G8 B8 A8 - Best colors, more ram needed"); + ComboBox_AddString(hWC,"B8 G8 R8 A8 - Slightly faster with some cards"); + ComboBox_SetCurSel(hWC,iTexQuality); + + //----------------------------------------------------// all kind of on/off options + + if(bDrawDither) CheckDlgButton(hW,IDC_DRAWDITHER,TRUE); + if(bUseLines) CheckDlgButton(hW,IDC_USELINES,TRUE); + if(bUseFrameLimit) CheckDlgButton(hW,IDC_USELIMIT,TRUE); + if(bUseFrameSkip) CheckDlgButton(hW,IDC_USESKIP,TRUE); + if(bAdvancedBlend) CheckDlgButton(hW,IDC_ADVBLEND,TRUE); + if(bOpaquePass) CheckDlgButton(hW,IDC_OPAQUE,TRUE); +// if(bUseAntiAlias) CheckDlgButton(hW,IDC_USEANTIALIAS,TRUE); + if(bWindowMode) CheckDlgButton(hW,IDC_DISPMODE2,TRUE); + else CheckDlgButton(hW,IDC_DISPMODE1,TRUE); + if(iUseMask) CheckDlgButton(hW,IDC_USEMASK,TRUE); + if(bUseFastMdec) CheckDlgButton(hW,IDC_FASTMDEC,TRUE); + if(bUse15bitMdec) CheckDlgButton(hW,IDC_FASTMDEC2,TRUE); + if(bUseFixes) CheckDlgButton(hW,IDC_GAMEFIX,TRUE); + if(bGteAccuracy) CheckDlgButton(hW,IDC_GTEACCURACY,TRUE); + if(iUseScanLines) CheckDlgButton(hW,IDC_USESCANLINES,TRUE); + if(iShowFPS) CheckDlgButton(hW,IDC_SHOWFPS,TRUE); + if(bKeepRatio) CheckDlgButton(hW,IDC_ARATIO,TRUE); + if(iBlurBuffer) CheckDlgButton(hW,IDC_BLUR,TRUE); + if(iNoScreenSaver) CheckDlgButton(hW,IDC_SSAVE,TRUE); + + //----------------------------------------------------// texture filter + + hWC=GetDlgItem(hW,IDC_FILTERTYPE); + ComboBox_AddString(hWC,"0: None"); + ComboBox_AddString(hWC,"1: Standard - Glitches will happen"); + ComboBox_AddString(hWC,"2: Extended - Removes black borders"); + ComboBox_AddString(hWC,"3: Standard w/o Sprites - unfiltered 2D"); + ComboBox_AddString(hWC,"4: Extended w/o Sprites - unfiltered 2D"); + ComboBox_AddString(hWC,"5: Standard + smoothed Sprites"); + ComboBox_AddString(hWC,"6: Extended + smoothed Sprites"); + ComboBox_SetCurSel(hWC,iFilterType); + + //----------------------------------------------------// hires texture mode + + hWC=GetDlgItem(hW,IDC_HIRESTEX); + ComboBox_AddString(hWC,"0: None (standard)"); + ComboBox_AddString(hWC,"1: 2xSaI (much vram needed)"); + ComboBox_AddString(hWC,"2: Stretched (filtering needed)"); + ComboBox_SetCurSel(hWC,iHiResTextures); + + //----------------------------------------------------// offscreen drawing + + hWC=GetDlgItem(hW,IDC_OFFSCREEN); + ComboBox_AddString(hWC,"0: None - Fastest, most glitches"); + ComboBox_AddString(hWC,"1: Minimum - Missing screens"); + ComboBox_AddString(hWC,"2: Standard - OK for most games"); + ComboBox_AddString(hWC,"3: Enhanced - Shows more stuff"); + ComboBox_AddString(hWC,"4: Extended - Can cause garbage"); + ComboBox_SetCurSel(hWC,iOffscreenDrawing); + + //----------------------------------------------------// texture quality + + hWC=GetDlgItem(hW,IDC_FRAMETEX); + ComboBox_AddString(hWC,"0: Emulated vram - effects need FVP"); + ComboBox_AddString(hWC,"1: Black - Fast but no special effects"); + ComboBox_AddString(hWC,"2: Gfx card buffer - Can be slow"); + ComboBox_AddString(hWC,"3: Gfx card buffer & software - slow"); + ComboBox_SetCurSel(hWC,iFrameTexType); + + //----------------------------------------------------// framebuffer read mode + + hWC=GetDlgItem(hW,IDC_FRAMEREAD); + ComboBox_AddString(hWC,"0: Emulated vram - OK for most games"); + ComboBox_AddString(hWC,"1: Gfx card buffer reads"); + ComboBox_AddString(hWC,"2: Gfx card buffer moves"); + ComboBox_AddString(hWC,"3: Gfx card buffer reads & moves"); + ComboBox_AddString(hWC,"4: Full software drawing (FVP)"); + ComboBox_SetCurSel(hWC,iFrameReadType); + + //----------------------------------------------------// framerate stuff + + if(iFrameLimit==2) + CheckDlgButton(hW,IDC_FRAMEAUTO,TRUE); + else CheckDlgButton(hW,IDC_FRAMEMANUELL,TRUE); + + sprintf(cs,"%.2f",fFrameRate); + SetDlgItemText(hW,IDC_FRAMELIMIT,cs); + SetDlgItemInt(hW,IDC_SCANBLEND,iScanBlend,TRUE); + + return TRUE; +} + +//////////////////////////////////////////////////////////////////////// +// on ok: take vals +//////////////////////////////////////////////////////////////////////// + +void GetSettings(HWND hW) +{ + HWND hWC;char cs[256];int i,j;char * p; + + hWC=GetDlgItem(hW,IDC_VRAMSIZE); // get vram size + ComboBox_GetText(hWC,cs,255); + iVRamSize=atoi(cs); + if(iVRamSize<0) iVRamSize=0; + if(iVRamSize>1024) iVRamSize=1024; + + hWC=GetDlgItem(hW,IDC_RESOLUTION); // get resolution + i=ComboBox_GetCurSel(hWC); + ComboBox_GetLBText(hWC,i,cs); + iResX=atol(cs); + p=strchr(cs,'x'); + if(p) iResY=atol(p+1); + else iResY=480; + + hWC=GetDlgItem(hW,IDC_COLORDEPTH); // get color depth + i=ComboBox_GetCurSel(hWC); + ComboBox_GetLBText(hWC,i,cs); + iColDepth=atol(cs); + + hWC=GetDlgItem(hW,IDC_VSYNC); // get vsync + iForceVSync=ComboBox_GetCurSel(hWC)-1; + + i=GetDlgItemInt(hW,IDC_WINX,NULL,FALSE); // get win size + if(i<100) i=100; if(i>16384) i=16384; + j=GetDlgItemInt(hW,IDC_WINY,NULL,FALSE); + if(j<100) j=100; if(j>16384) j=16384; + iWinSize=MAKELONG(i,j); + + hWC=GetDlgItem(hW,IDC_TEXQUALITY); // texture quality + iTexQuality=ComboBox_GetCurSel(hWC); + + hWC=GetDlgItem(hW,IDC_FILTERTYPE); // all kind of options + iFilterType=ComboBox_GetCurSel(hWC); + + if(IsDlgButtonChecked(hW,IDC_DRAWDITHER)) + bDrawDither=TRUE; else bDrawDither=FALSE; + + if(IsDlgButtonChecked(hW,IDC_USELINES)) + bUseLines=TRUE; else bUseLines=FALSE; + + if(IsDlgButtonChecked(hW,IDC_DISPMODE2)) + bWindowMode=TRUE; else bWindowMode=FALSE; + + if(IsDlgButtonChecked(hW,IDC_ADVBLEND)) + bAdvancedBlend=TRUE; else bAdvancedBlend=FALSE; + + iOffscreenDrawing=ComboBox_GetCurSel(GetDlgItem(hW,IDC_OFFSCREEN)); + + iFrameTexType=ComboBox_GetCurSel(GetDlgItem(hW,IDC_FRAMETEX)); + iFrameReadType=ComboBox_GetCurSel(GetDlgItem(hW,IDC_FRAMEREAD)); + + if(IsDlgButtonChecked(hW,IDC_USELIMIT)) + bUseFrameLimit=TRUE; else bUseFrameLimit=FALSE; + + if(IsDlgButtonChecked(hW,IDC_USESKIP)) + bUseFrameSkip=TRUE; else bUseFrameSkip=FALSE; + + if(IsDlgButtonChecked(hW,IDC_OPAQUE)) + bOpaquePass=TRUE; else bOpaquePass=FALSE; + +// if(IsDlgButtonChecked(hW,IDC_USEANTIALIAS)) +// bUseAntiAlias=TRUE; else bUseAntiAlias=FALSE; + + if(IsDlgButtonChecked(hW,IDC_FASTMDEC)) + bUseFastMdec=TRUE; else bUseFastMdec=FALSE; + + if(IsDlgButtonChecked(hW,IDC_FASTMDEC2)) + bUse15bitMdec=TRUE; else bUse15bitMdec=FALSE; + + if(IsDlgButtonChecked(hW,IDC_GAMEFIX)) + bUseFixes=TRUE; else bUseFixes=FALSE; + + if(IsDlgButtonChecked(hW,IDC_GTEACCURACY)) + bGteAccuracy=TRUE; else bGteAccuracy=FALSE; + + if(IsDlgButtonChecked(hW,IDC_USESCANLINES)) + iUseScanLines=1; else iUseScanLines=0; + + if(IsDlgButtonChecked(hW,IDC_SHOWFPS)) + iShowFPS=1; else iShowFPS=0; + + if(IsDlgButtonChecked(hW,IDC_ARATIO)) + bKeepRatio=TRUE; else bKeepRatio=FALSE; + + if(IsDlgButtonChecked(hW,IDC_BLUR)) + iBlurBuffer=1; else iBlurBuffer=0; + + if(IsDlgButtonChecked(hW,IDC_SSAVE)) + iNoScreenSaver=1; else iNoScreenSaver=0; + + hWC=GetDlgItem(hW,IDC_HIRESTEX); + iHiResTextures=ComboBox_GetCurSel(hWC); + + if(IsDlgButtonChecked(hW,IDC_USEMASK)) + {iUseMask=1;iZBufferDepth=16;} + else {iUseMask=0;iZBufferDepth=0; } + + iScanBlend=GetDlgItemInt(hW,IDC_SCANBLEND,NULL,TRUE); + if(iScanBlend>255) iScanBlend=0; + if(iScanBlend<-1) iScanBlend=-1; + + if(IsDlgButtonChecked(hW,IDC_FRAMEAUTO)) // frame rate settings + iFrameLimit=2; + else iFrameLimit=1; + + GetDlgItemText(hW,IDC_FRAMELIMIT,cs,255); + fFrameRate=(float)atof(cs); + if(fFrameRate<10.0f) fFrameRate=10.0f; + if(fFrameRate>1000.0f) fFrameRate=1000.0f; +} + +//////////////////////////////////////////////////////////////////////// +// OK button +//////////////////////////////////////////////////////////////////////// + +void OnCfgOK(HWND hW) +{ + GetSettings(hW); // get dialog settings + + WriteConfig(); // write registry + + EndDialog(hW,TRUE); // close dialog +} + +//////////////////////////////////////////////////////////////////////// +// Clipboard button +//////////////////////////////////////////////////////////////////////// + +void OnClipboard(HWND hW) +{ + HWND hWE=GetDlgItem(hW,IDC_CLPEDIT); + char * pB; + + GetSettings(hW); // get dialog setings + pB=GetConfigInfos(hWE); // get text infos + + if(pB) // some text got? + { + SetDlgItemText(hW,IDC_CLPEDIT,pB); // -> set text in invisible edit + SendMessage(hWE,EM_SETSEL,0,-1); // -> sel all in edit + SendMessage(hWE,WM_COPY,0,0); // -> copy sel to clipboard + free(pB); // -> free helper text buffer + + 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 button (just closes window) +//////////////////////////////////////////////////////////////////////// + +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: // init dialog: + { + int i; + + for(i=0;i<32;i++) // -> loop all 32 checkboxes + { + if(dwCfgFixes&(1<<i)) // --> if fix is active: check box + CheckDlgButton(hW,IDC_FIX1+i,TRUE); + } + } + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDCANCEL: EndDialog(hW,FALSE);return TRUE; // cancel: close window + + case IDOK: // ok: take settings and close + { + 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) // bug fix button: +{ + DialogBox(hInst,MAKEINTRESOURCE(IDD_FIXES), // show fix window + hW,(DLGPROC)BugFixesDlgProc); +} + +//////////////////////////////////////////////////////////////////////// +// default 1: fast +//////////////////////////////////////////////////////////////////////// + +void OnCfgDef1(HWND hW) +{ + HWND hWC; + + hWC=GetDlgItem(hW,IDC_RESOLUTION); + ComboBox_SetCurSel(hWC,0); + hWC=GetDlgItem(hW,IDC_COLORDEPTH); + ComboBox_SetCurSel(hWC,0); + hWC=GetDlgItem(hW,IDC_VSYNC); + ComboBox_SetCurSel(hWC,1); + hWC=GetDlgItem(hW,IDC_TEXQUALITY); + ComboBox_SetCurSel(hWC,0); + hWC=GetDlgItem(hW,IDC_FILTERTYPE); + ComboBox_SetCurSel(hWC,0); + hWC=GetDlgItem(hW,IDC_OFFSCREEN); + ComboBox_SetCurSel(hWC,1); + hWC=GetDlgItem(hW,IDC_VRAMSIZE); + ComboBox_SetCurSel(hWC,0); + + CheckDlgButton(hW,IDC_TEXLINEAR,FALSE); + CheckDlgButton(hW,IDC_DRAWDITHER,FALSE); + CheckDlgButton(hW,IDC_USELINES,FALSE); + CheckDlgButton(hW,IDC_USELIMIT,FALSE); + CheckDlgButton(hW,IDC_USESKIP,FALSE); + CheckDlgButton(hW,IDC_ADVBLEND,FALSE); + CheckDlgButton(hW,IDC_OPAQUE,TRUE); +// CheckDlgButton(hW,IDC_USEANTIALIAS,FALSE); + CheckDlgButton(hW,IDC_DISPMODE2,FALSE); + CheckDlgButton(hW,IDC_DISPMODE1,TRUE); + CheckDlgButton(hW,IDC_FRAMEAUTO,TRUE); + CheckDlgButton(hW,IDC_FRAMEMANUELL,FALSE); + CheckDlgButton(hW,IDC_SHOWFPS,FALSE); + + ComboBox_SetCurSel(GetDlgItem(hW,IDC_SUBCACHE),2); + ComboBox_SetCurSel(GetDlgItem(hW,IDC_FRAMETEX),1); + ComboBox_SetCurSel(GetDlgItem(hW,IDC_FRAMEREAD),0); + + CheckDlgButton(hW,IDC_USEMASK,FALSE); + CheckDlgButton(hW,IDC_FASTMDEC,TRUE); + CheckDlgButton(hW,IDC_FASTMDEC2,TRUE); + CheckDlgButton(hW,IDC_USESCANLINES,FALSE); + + SetDlgItemInt(hW,IDC_FRAMELIMIT,200,FALSE); + SetDlgItemInt(hW,IDC_WINX,640,FALSE); + SetDlgItemInt(hW,IDC_WINY,480,FALSE); + + CheckDlgButton(hW,IDC_ARATIO,FALSE); + CheckDlgButton(hW,IDC_BLUR,FALSE); + + SetDlgItemInt(hW,IDC_SCANBLEND,0,TRUE); + ComboBox_SetCurSel(GetDlgItem(hW,IDC_HIRESTEX),0); + CheckDlgButton(hW,IDC_SSAVE,FALSE); +} + +//////////////////////////////////////////////////////////////////////// +// default 2: nice +//////////////////////////////////////////////////////////////////////// + +void OnCfgDef2(HWND hW) +{ + HWND hWC; + + hWC=GetDlgItem(hW,IDC_RESOLUTION); + ComboBox_SetCurSel(hWC,1); + hWC=GetDlgItem(hW,IDC_COLORDEPTH); + ComboBox_SetCurSel(hWC,1); + hWC=GetDlgItem(hW,IDC_VSYNC); + ComboBox_SetCurSel(hWC,2); + hWC=GetDlgItem(hW,IDC_TEXQUALITY); + ComboBox_SetCurSel(hWC,3); + hWC=GetDlgItem(hW,IDC_FILTERTYPE); + ComboBox_SetCurSel(hWC,0); + hWC=GetDlgItem(hW,IDC_OFFSCREEN); + ComboBox_SetCurSel(hWC,3); + hWC=GetDlgItem(hW,IDC_VRAMSIZE); + ComboBox_SetCurSel(hWC,0); + + CheckDlgButton(hW,IDC_TEXLINEAR,FALSE); + CheckDlgButton(hW,IDC_DRAWDITHER,FALSE); + CheckDlgButton(hW,IDC_USELINES,FALSE); + CheckDlgButton(hW,IDC_USELIMIT,TRUE); + CheckDlgButton(hW,IDC_USESKIP,FALSE); + CheckDlgButton(hW,IDC_ADVBLEND,TRUE); + CheckDlgButton(hW,IDC_OPAQUE,TRUE); +// CheckDlgButton(hW,IDC_USEANTIALIAS,FALSE); + CheckDlgButton(hW,IDC_DISPMODE2,FALSE); + CheckDlgButton(hW,IDC_DISPMODE1,TRUE); + CheckDlgButton(hW,IDC_FRAMEAUTO,TRUE); + CheckDlgButton(hW,IDC_FRAMEMANUELL,FALSE); + CheckDlgButton(hW,IDC_SHOWFPS,FALSE); + + ComboBox_SetCurSel(GetDlgItem(hW,IDC_SUBCACHE),2); + ComboBox_SetCurSel(GetDlgItem(hW,IDC_FRAMETEX),2); + ComboBox_SetCurSel(GetDlgItem(hW,IDC_FRAMEREAD),0); + + CheckDlgButton(hW,IDC_USEMASK,TRUE); + CheckDlgButton(hW,IDC_FASTMDEC,FALSE); + CheckDlgButton(hW,IDC_FASTMDEC2,FALSE); + CheckDlgButton(hW,IDC_USESCANLINES,FALSE); + + SetDlgItemInt(hW,IDC_FRAMELIMIT,200,FALSE); + SetDlgItemInt(hW,IDC_WINX,640,FALSE); + SetDlgItemInt(hW,IDC_WINY,480,FALSE); + CheckDlgButton(hW,IDC_ARATIO,FALSE); + CheckDlgButton(hW,IDC_BLUR,FALSE); + SetDlgItemInt(hW,IDC_SCANBLEND,0,TRUE); + ComboBox_SetCurSel(GetDlgItem(hW,IDC_HIRESTEX),0); + CheckDlgButton(hW,IDC_SSAVE,FALSE); +} + +//////////////////////////////////////////////////////////////////////// +// read registry +//////////////////////////////////////////////////////////////////////// + +void ReadConfig(void) // read all config vals +{ + HKEY myKey; + DWORD temp; + DWORD type; + DWORD size; + + // pre-init all relevant globals + + iResX=800;iResY=600; + iColDepth=32; + bChangeRes=FALSE; + bWindowMode=FALSE; + bFullVRam=FALSE; + iFilterType=0; + bAdvancedBlend=FALSE; + bDrawDither=FALSE; + bUseLines=FALSE; + bUseFrameLimit=TRUE; + bUseFrameSkip=FALSE; + iFrameLimit=2; + fFrameRate=200.0f; + iOffscreenDrawing=1; + bOpaquePass=TRUE; + bUseAntiAlias=FALSE; + iTexQuality=0; + iWinSize=MAKELONG(400,300); + iUseMask=0; + iZBufferDepth=0; + bUseFastMdec=FALSE; + bUse15bitMdec=FALSE; + dwCfgFixes=0; + bUseFixes=FALSE; + bGteAccuracy=FALSE; + iUseScanLines=0; + iFrameTexType=0; + iFrameReadType=0; + iShowFPS=0; + bKeepRatio=FALSE; + iScanBlend=0; + iVRamSize=0; + iTexGarbageCollection=1; + iBlurBuffer=0; + iHiResTextures=0; + iNoScreenSaver=1; + iForceVSync=-1; + + lstrcpy(szGPUKeys,szKeyDefaults); + + // registry key: still "psemu pro/pete tnt" for compatibility reasons + + if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\PeteTNT",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; + size = 4; + if(RegQueryValueEx(myKey,"FilterType",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iFilterType=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"DrawDither",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bDrawDither=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseLines",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bUseLines=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"WindowMode",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bWindowMode=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"ColDepth",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iColDepth=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"ForceVSync",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iForceVSync=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseFrameLimit",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bUseFrameLimit=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseFrameSkip",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bUseFrameSkip=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"FrameLimit",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iFrameLimit=(int)temp; + if(!iFrameLimit) {bUseFrameLimit=TRUE;bUseFrameSkip=FALSE;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,"UseMultiPass",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bAdvancedBlend=(int)temp; + size = 4; + iOffscreenDrawing=-1; + if(RegQueryValueEx(myKey,"OffscreenDrawingEx",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iOffscreenDrawing=temp; + if(iOffscreenDrawing==-1 && + RegQueryValueEx(myKey,"OffscreenDrawing",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iOffscreenDrawing=temp*2; + size = 4; + if(RegQueryValueEx(myKey,"OpaquePass",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bOpaquePass=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"VRamSize",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iVRamSize=(int)temp; +// size = 4; +// if(RegQueryValueEx(myKey,"UseAntiAlias",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) +// bUseAntiAlias=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"TexQuality",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iTexQuality=(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) + bUseFixes=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"GteAccuracy",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bGteAccuracy=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"UseMask",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iUseMask=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"FastMdec",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bUseFastMdec=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"15BitMdec",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bUse15bitMdec=(BOOL)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,"KeepRatio",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + bKeepRatio=(BOOL)temp; + size = 4; + if(RegQueryValueEx(myKey,"ScanBlend",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iScanBlend=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"FrameTexType",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iFrameTexType=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"FrameReadType",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iFrameReadType=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"FullscreenBlur",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iBlurBuffer=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"HiResTextures",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iHiResTextures=(int)temp; + size = 4; + if(RegQueryValueEx(myKey,"NoScreenSaver",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iNoScreenSaver=(int)temp; + + size=7; + RegQueryValueEx(myKey,"GPUKeys",0,&type,(LPBYTE)&szGPUKeys,&size); + + RegCloseKey(myKey); + } + if(!iColDepth) iColDepth=32; // adjust color info + if(iUseMask) iZBufferDepth=16; // set zbuffer depth + else iZBufferDepth=0; + if(bUseFixes) dwActFixes=dwCfgFixes; // init game fix global + if(iFrameReadType==4) bFullVRam=TRUE; // set fullvram render flag (soft gpu) +} + +//////////////////////////////////////////////////////////////////////// +// read registry: window size (called on fullscreen/window resize) +//////////////////////////////////////////////////////////////////////// + +void ReadWinSizeConfig(void) +{ + HKEY myKey; + DWORD temp; + DWORD type; + DWORD size; + + iResX=800;iResY=600; + iWinSize=MAKELONG(400,300); + iBlurBuffer=0; + + // registry key: still "psemu pro/pete tnt" for compatibility reasons + + if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\PeteTNT",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; + size = 4; + if(RegQueryValueEx(myKey,"FullscreenBlur",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) + iBlurBuffer=(int)temp; + RegCloseKey(myKey); + } +} + +//////////////////////////////////////////////////////////////////////// +// write registry +//////////////////////////////////////////////////////////////////////// + +void WriteConfig(void) +{ + HKEY myKey; + DWORD myDisp; + DWORD temp; + + // registry key: still "psemu pro/pete tnt" for compatibility reasons + + RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\PeteTNT",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=iWinSize; + RegSetValueEx(myKey,"WinSize",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iFilterType; + RegSetValueEx(myKey,"FilterType",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bDrawDither; + RegSetValueEx(myKey,"DrawDither",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bUseLines; + RegSetValueEx(myKey,"UseLines",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bWindowMode; + RegSetValueEx(myKey,"WindowMode",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iColDepth; + RegSetValueEx(myKey,"ColDepth",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iForceVSync; + RegSetValueEx(myKey,"ForceVSync",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bUseFrameLimit; + RegSetValueEx(myKey,"UseFrameLimit",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bUseFrameSkip; + RegSetValueEx(myKey,"UseFrameSkip",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iFrameLimit; + RegSetValueEx(myKey,"FrameLimit",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=bAdvancedBlend; + RegSetValueEx(myKey,"UseMultiPass",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iOffscreenDrawing/2; + RegSetValueEx(myKey,"OffscreenDrawing",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iOffscreenDrawing; + RegSetValueEx(myKey,"OffscreenDrawingEx",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bOpaquePass; + RegSetValueEx(myKey,"OpaquePass",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iVRamSize; + RegSetValueEx(myKey,"VRamSize",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); +// temp=bUseAntiAlias; +// RegSetValueEx(myKey,"UseAntiAlias",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iTexQuality; + RegSetValueEx(myKey,"TexQuality",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=dwCfgFixes; + RegSetValueEx(myKey,"CfgFixes",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bUseFixes; + RegSetValueEx(myKey,"UseFixes",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bGteAccuracy; + RegSetValueEx(myKey,"GteAccuracy",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iUseMask; + RegSetValueEx(myKey,"UseMask",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bUseFastMdec; + RegSetValueEx(myKey,"FastMdec",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bUse15bitMdec; + RegSetValueEx(myKey,"15BitMdec",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=iFrameTexType; + RegSetValueEx(myKey,"FrameTexType",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iFrameReadType; + RegSetValueEx(myKey,"FrameReadType",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=bKeepRatio; + RegSetValueEx(myKey,"KeepRatio",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iBlurBuffer; + RegSetValueEx(myKey,"FullscreenBlur",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iHiResTextures; + RegSetValueEx(myKey,"HiResTextures",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iNoScreenSaver; + RegSetValueEx(myKey,"NoScreenSaver",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + temp=iScanBlend; + RegSetValueEx(myKey,"ScanBlend",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); + RegSetValueEx(myKey,"GPUKeys",0,REG_BINARY,(LPBYTE)szGPUKeys,7); + + RegCloseKey(myKey); +} + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +// Key definition window + +typedef struct +{ + char szName[10]; + char cCode; +} +KEYSETS; + +// sepcial keys: + +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}, + {"", 0x00} +}; + +// select key entry in combo box + +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); +} + +// key window proc + +BOOL CALLBACK KeyDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: // init dialog + { + int i,j,k;char szB[2];HWND hWC; + for(i=IDC_KEY1;i<=IDC_KEY6;i++) + { + hWC=GetDlgItem(hW,i); + + for(j=0;tMKeys[j].cCode!=0;j++) // fill special keys in combo + { + k=ComboBox_AddString(hWC,tMKeys[j].szName); + ComboBox_SetItemData(hWC,k,tMKeys[j].cCode); + } + for(j=0x30;j<=0x39;j++) // fill numbers in combo + { + wsprintf(szB,"%c",j); + k=ComboBox_AddString(hWC,szB); + ComboBox_SetItemData(hWC,k,j); + } + for(j=0x41;j<=0x5a;j++) // fill alphas in combo + { + 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: // default button: + { + int i; // -> set defaults + for(i=IDC_KEY1;i<=IDC_KEY6;i++) + SetGPUKey(GetDlgItem(hW,i),szKeyDefaults[i-IDC_KEY1]); + }break; + + case IDCANCEL: // cancel: just close window + EndDialog(hW,FALSE); return TRUE; + + case IDOK: // ok: take key bindings + { + HWND hWC;int i; + for(i=IDC_KEY1;i<=IDC_KEY6;i++) + { + hWC=GetDlgItem(hW,i); + szGPUKeys[i-IDC_KEY1]=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) // call key dialog +{ + DialogBox(hInst,MAKEINTRESOURCE(IDD_KEYS), + hW,(DLGPROC)KeyDlgProc); +} + +///////////////////////////////////////////////////////////////////////////// +// AboutDlg dialog (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; +} diff --git a/win32/plugins/peopsxgl/winsrc/fps.c b/win32/plugins/peopsxgl/winsrc/fps.c index 6faf82c6..2e751107 100644..100755 --- a/win32/plugins/peopsxgl/winsrc/fps.c +++ b/win32/plugins/peopsxgl/winsrc/fps.c @@ -1,641 +1,641 @@ -/***************************************************************************
- fps.c - description
- -------------------
- begin : Sun Mar 08 2009
- copyright : (C) 1999-2009 by Pete Bernert
- web : www.pbernert.com
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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:
-//
-// 2009/03/08 - Pete
-// - generic cleanup for the Peops release
-//
-//*************************************************************************//
-
-#include "stdafx.h"
-
-#define _IN_FPS
-
-#include "externals.h"
-
-////////////////////////////////////////////////////////////////////////
-// FPS stuff
-////////////////////////////////////////////////////////////////////////
-
-BOOL bIsPerformanceCounter=FALSE;
-float fFrameRateHz=0;
-DWORD dwFrameRateTicks=16;
-float fFrameRate;
-int iFrameLimit;
-BOOL bUseFrameLimit=FALSE;
-BOOL bUseFrameSkip=0;
-DWORD dwLaceCnt=0;
-
-LARGE_INTEGER liCPUFrequency;
-
-////////////////////////////////////////////////////////////////////////
-// FPS skipping / limit
-////////////////////////////////////////////////////////////////////////
-
-BOOL bInitCap = TRUE;
-float fps_skip = 0;
-float fps_cur = 0;
-
-void FrameCap (void)
-{
- 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;
-
- //---------------------------------------------------------
- // init some static vars...
- // bInitCap is TRUE on startup and everytime the user
- // is toggling the frame limit
- //---------------------------------------------------------
-
- if(bInitCap)
- {
- bInitCap=FALSE;
- if (bIsPerformanceCounter)
- QueryPerformanceCounter(&LastTime);
- lastticks = timeGetTime();
- TicksToWait=0;
- return;
- }
-
- //---------------------------------------------------------
-
- if(bIsPerformanceCounter)
- {
- QueryPerformanceCounter(&CurrentTime);
- _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart;
-
- //---------------------------------------------------------
- // check if diff > 1/2 sec, if yes: take mm timer value
- //---------------------------------------------------------
-
- curticks = timeGetTime();
- if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1))
- {
- if(curticks < lastticks)
- _ticks_since_last_update = dwFrameRateTicks+TicksToWait+1;
- else _ticks_since_last_update = (liCPUFrequency.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;
-
- //---------------------------------------------------------
- // check if diff > 1/2 sec, if yes: take mm timer value
- //---------------------------------------------------------
- curticks = timeGetTime();
- if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1))
- {
- if(curticks < lastticks)
- _ticks_since_last_update = TicksToWait+1;
- else _ticks_since_last_update = (liCPUFrequency.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
-#define MAXLACE 16
-
-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 skipping mode?
- {
- dwLastLace+=dwLaceCnt; // -> calc frame limit helper (number of laces)
- bSkipNextFrame = TRUE; // -> we skip next frame
- 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(bUseFrameLimit && !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(bIsPerformanceCounter) // -> 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(bIsPerformanceCounter)
- {
- 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(bIsPerformanceCounter) // -> ok, start time of the next frame
- QueryPerformanceCounter(&LastTime);
- lastticks = timeGetTime();
- return; // -> done, we will skip next frame to get more speed
- }
- }
- }
-
- bInitCap=FALSE; // -> ok, we have inited the frameskip func
- iAdditionalSkip=0; // -> init additional skip
- bSkipNextFrame=FALSE; // -> we don't skip the next frame
- if(bIsPerformanceCounter) // -> 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(bIsPerformanceCounter) // 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(bUseFrameLimit) // 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(bUseFrameLimit) // 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(bIsPerformanceCounter)
- {
- QueryPerformanceCounter(&CurrentTime);
- _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart;
- }
- else
- {
- curticks = timeGetTime();
- _ticks_since_last_update = curticks - lastticks;
- }
- }
- }
-
- if(bIsPerformanceCounter) // ok, start time of the next frame
- QueryPerformanceCounter(&LastTime);
- lastticks = timeGetTime();
- }
-
- dwLaceCnt=0; // init lace counter
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void calcfps(void)
-{
- 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(bIsPerformanceCounter)
- {
- QueryPerformanceCounter(&CurrentTime);
- _ticks_since_last_update=CurrentTime.LowPart-LastTime.LowPart;
-
- //--------------------------------------------------//
- curticks = timeGetTime();
- if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1))
- _ticks_since_last_update = (liCPUFrequency.LowPart * (curticks - lastticks))/1000;
- lastticks=curticks;
- //--------------------------------------------------//
-
- if(bUseFrameSkip && !bUseFrameLimit && _ticks_since_last_update)
- fps_skip=min(fps_skip,(((float)liCPUFrequency.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(bUseFrameSkip && !bUseFrameLimit && _ticks_since_last_update)
- fps_skip=min(fps_skip,((float)1000/(float)_ticks_since_last_update+1.0f));
-
- lastticks = curticks;
- }
-
- if(bUseFrameSkip && bUseFrameLimit)
- {
- fpsskip_tck += _ticks_since_last_update;
-
- if(++fpsskip_cnt==2)
- {
- if(bIsPerformanceCounter)
- fps_skip = ((float)liCPUFrequency.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(bIsPerformanceCounter)
- fps_cur = ((float)liCPUFrequency.LowPart) / ((float)fps_tck) *10.0f;
- else
- fps_cur = (float)10000/(float)fps_tck;
-
- fps_cnt = 0;
- fps_tck = 1;
-
- if(bUseFrameLimit && 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(bIsPerformanceCounter)
- {
- QueryPerformanceCounter(&CurrentTime);
- _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart;
-
- //------------------------------------------------//
- curticks = timeGetTime();
- if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1))
- {
- if(curticks < lastticks)
- _ticks_since_last_update = TicksToWait+1;
- else _ticks_since_last_update = (liCPUFrequency.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 = (liCPUFrequency.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(bIsPerformanceCounter)
- {
- QueryPerformanceCounter(&CurrentTime);
- _ticks_since_last_update=CurrentTime.LowPart-LastTime.LowPart;
-
- //--------------------------------------------------//
- curticks = timeGetTime();
- if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1))
- _ticks_since_last_update = (liCPUFrequency.LowPart * (curticks - lastticks))/1000;
- lastticks=curticks;
- //--------------------------------------------------//
-
- if(_ticks_since_last_update)
- {
- CurrentFPS = ((float)liCPUFrequency.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(bIsPerformanceCounter)
- dwFrameRateTicks=(liCPUFrequency.LowPart / fFrameRateHz);
- else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz);
- return;
- }
-
- if(dwActFixes&128)
- {
- 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(PSXDisplay.PAL)
- {
- if (STATUSREG&GPUSTATUS_INTERLACED)
- fFrameRateHz=33868800.0f/677343.75f; // 50.00238
- else fFrameRateHz=33868800.0f/680595.00f; // 49.76351
- }
- else
- {
- if (STATUSREG&GPUSTATUS_INTERLACED)
- fFrameRateHz=33868800.0f/565031.25f; // 59.94146
- else fFrameRateHz=33868800.0f/566107.50f; // 59.82750
- }
-
- if(bIsPerformanceCounter)
- dwFrameRateTicks=(liCPUFrequency.LowPart / fFrameRateHz);
- else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz);
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void InitFrameCap(void) // inits cpu frequency info (on gpu startup)
-{
- if (QueryPerformanceFrequency (&liCPUFrequency))
- bIsPerformanceCounter = TRUE;
- else bIsPerformanceCounter = FALSE;
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void ReInitFrameCap(void)
-{
- BOOL bOldPerformanceCounter=bIsPerformanceCounter; // store curr timer mode
-
- if(dwActFixes&0x10000) // check game fix... high performance counters are bad on some mb chipsets
- bIsPerformanceCounter=FALSE;
- else
- {
- if (QueryPerformanceFrequency (&liCPUFrequency))
- bIsPerformanceCounter = TRUE;
- else bIsPerformanceCounter = FALSE;
- }
-
- if(bOldPerformanceCounter!=bIsPerformanceCounter) // changed?
- {
- bInitCap = TRUE;
- SetAutoFrameCap();
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void SetFrameRateConfig(void)
-{
- if(fFrameRateHz==0)
- {
- if(iFrameLimit==2) fFrameRateHz=59.94f; // auto framerate? set some init val (no pal/ntsc known yet)
- else fFrameRateHz=fFrameRate; // else set user framerate
- }
-
- if(bIsPerformanceCounter)
- dwFrameRateTicks=(liCPUFrequency.LowPart / fFrameRateHz);
- else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz);
-}
-
-void CheckFrameRate(void) // called in updatelace (on every emulated psx vsync)
-{
- if(bUseFrameSkip)
- {
- if(!(dwActFixes&0x100))
- {
- dwLaceCnt++; // -> and store cnt of vsync between frames
- if(dwLaceCnt>=MAXLACE && bUseFrameLimit)
- {
- if(dwLaceCnt==MAXLACE) bInitCap=TRUE;
- FrameCap();
- }
- }
- else if(bUseFrameLimit) FrameCap();
- calcfps(); // -> calc fps display in skipping mode
- }
- else // -> non-skipping mode:
- {
- if(bUseFrameLimit) FrameCap();
- if(ulKeybits&KEY_SHOWFPS) calcfps();
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void CALLBACK GPUsetframelimit(unsigned long option) // new EPSXE interface func: main emu can enable/disable fps limitation this way
-{
- bInitCap = TRUE;
-
- if(option==1) // emu says: limit
- {
- bUseFrameLimit=TRUE;bUseFrameSkip=FALSE;iFrameLimit=2;
- SetAutoFrameCap();
- }
- else // emu says: no limit
- {
- bUseFrameLimit=FALSE;
- }
-}
-
-////////////////////////////////////////////////////////////////////////
+/*************************************************************************** + fps.c - description + ------------------- + begin : Sun Mar 08 2009 + copyright : (C) 1999-2009 by Pete Bernert + web : www.pbernert.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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: +// +// 2009/03/08 - Pete +// - generic cleanup for the Peops release +// +//*************************************************************************// + +#include "stdafx.h" + +#define _IN_FPS + +#include "externals.h" + +//////////////////////////////////////////////////////////////////////// +// FPS stuff +//////////////////////////////////////////////////////////////////////// + +BOOL bIsPerformanceCounter=FALSE; +float fFrameRateHz=0; +DWORD dwFrameRateTicks=16; +float fFrameRate; +int iFrameLimit; +BOOL bUseFrameLimit=FALSE; +BOOL bUseFrameSkip=0; +DWORD dwLaceCnt=0; + +LARGE_INTEGER liCPUFrequency; + +//////////////////////////////////////////////////////////////////////// +// FPS skipping / limit +//////////////////////////////////////////////////////////////////////// + +BOOL bInitCap = TRUE; +float fps_skip = 0; +float fps_cur = 0; + +void FrameCap (void) +{ + 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; + + //--------------------------------------------------------- + // init some static vars... + // bInitCap is TRUE on startup and everytime the user + // is toggling the frame limit + //--------------------------------------------------------- + + if(bInitCap) + { + bInitCap=FALSE; + if (bIsPerformanceCounter) + QueryPerformanceCounter(&LastTime); + lastticks = timeGetTime(); + TicksToWait=0; + return; + } + + //--------------------------------------------------------- + + if(bIsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart; + + //--------------------------------------------------------- + // check if diff > 1/2 sec, if yes: take mm timer value + //--------------------------------------------------------- + + curticks = timeGetTime(); + if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1)) + { + if(curticks < lastticks) + _ticks_since_last_update = dwFrameRateTicks+TicksToWait+1; + else _ticks_since_last_update = (liCPUFrequency.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; + + //--------------------------------------------------------- + // check if diff > 1/2 sec, if yes: take mm timer value + //--------------------------------------------------------- + curticks = timeGetTime(); + if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1)) + { + if(curticks < lastticks) + _ticks_since_last_update = TicksToWait+1; + else _ticks_since_last_update = (liCPUFrequency.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 +#define MAXLACE 16 + +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 skipping mode? + { + dwLastLace+=dwLaceCnt; // -> calc frame limit helper (number of laces) + bSkipNextFrame = TRUE; // -> we skip next frame + 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(bUseFrameLimit && !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(bIsPerformanceCounter) // -> 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(bIsPerformanceCounter) + { + 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(bIsPerformanceCounter) // -> ok, start time of the next frame + QueryPerformanceCounter(&LastTime); + lastticks = timeGetTime(); + return; // -> done, we will skip next frame to get more speed + } + } + } + + bInitCap=FALSE; // -> ok, we have inited the frameskip func + iAdditionalSkip=0; // -> init additional skip + bSkipNextFrame=FALSE; // -> we don't skip the next frame + if(bIsPerformanceCounter) // -> 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(bIsPerformanceCounter) // 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(bUseFrameLimit) // 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(bUseFrameLimit) // 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(bIsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart; + } + else + { + curticks = timeGetTime(); + _ticks_since_last_update = curticks - lastticks; + } + } + } + + if(bIsPerformanceCounter) // ok, start time of the next frame + QueryPerformanceCounter(&LastTime); + lastticks = timeGetTime(); + } + + dwLaceCnt=0; // init lace counter +} + +//////////////////////////////////////////////////////////////////////// + +void calcfps(void) +{ + 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(bIsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update=CurrentTime.LowPart-LastTime.LowPart; + + //--------------------------------------------------// + curticks = timeGetTime(); + if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1)) + _ticks_since_last_update = (liCPUFrequency.LowPart * (curticks - lastticks))/1000; + lastticks=curticks; + //--------------------------------------------------// + + if(bUseFrameSkip && !bUseFrameLimit && _ticks_since_last_update) + fps_skip=min(fps_skip,(((float)liCPUFrequency.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(bUseFrameSkip && !bUseFrameLimit && _ticks_since_last_update) + fps_skip=min(fps_skip,((float)1000/(float)_ticks_since_last_update+1.0f)); + + lastticks = curticks; + } + + if(bUseFrameSkip && bUseFrameLimit) + { + fpsskip_tck += _ticks_since_last_update; + + if(++fpsskip_cnt==2) + { + if(bIsPerformanceCounter) + fps_skip = ((float)liCPUFrequency.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(bIsPerformanceCounter) + fps_cur = ((float)liCPUFrequency.LowPart) / ((float)fps_tck) *10.0f; + else + fps_cur = (float)10000/(float)fps_tck; + + fps_cnt = 0; + fps_tck = 1; + + if(bUseFrameLimit && 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(bIsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update = CurrentTime.LowPart - LastTime.LowPart; + + //------------------------------------------------// + curticks = timeGetTime(); + if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1)) + { + if(curticks < lastticks) + _ticks_since_last_update = TicksToWait+1; + else _ticks_since_last_update = (liCPUFrequency.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 = (liCPUFrequency.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(bIsPerformanceCounter) + { + QueryPerformanceCounter(&CurrentTime); + _ticks_since_last_update=CurrentTime.LowPart-LastTime.LowPart; + + //--------------------------------------------------// + curticks = timeGetTime(); + if(_ticks_since_last_update>(liCPUFrequency.LowPart>>1)) + _ticks_since_last_update = (liCPUFrequency.LowPart * (curticks - lastticks))/1000; + lastticks=curticks; + //--------------------------------------------------// + + if(_ticks_since_last_update) + { + CurrentFPS = ((float)liCPUFrequency.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(bIsPerformanceCounter) + dwFrameRateTicks=(liCPUFrequency.LowPart / fFrameRateHz); + else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz); + return; + } + + if(dwActFixes&128) + { + 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(PSXDisplay.PAL) + { + if (STATUSREG&GPUSTATUS_INTERLACED) + fFrameRateHz=33868800.0f/677343.75f; // 50.00238 + else fFrameRateHz=33868800.0f/680595.00f; // 49.76351 + } + else + { + if (STATUSREG&GPUSTATUS_INTERLACED) + fFrameRateHz=33868800.0f/565031.25f; // 59.94146 + else fFrameRateHz=33868800.0f/566107.50f; // 59.82750 + } + + if(bIsPerformanceCounter) + dwFrameRateTicks=(liCPUFrequency.LowPart / fFrameRateHz); + else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz); + } +} + +//////////////////////////////////////////////////////////////////////// + +void InitFrameCap(void) // inits cpu frequency info (on gpu startup) +{ + if (QueryPerformanceFrequency (&liCPUFrequency)) + bIsPerformanceCounter = TRUE; + else bIsPerformanceCounter = FALSE; +} + +//////////////////////////////////////////////////////////////////////// + +void ReInitFrameCap(void) +{ + BOOL bOldPerformanceCounter=bIsPerformanceCounter; // store curr timer mode + + if(dwActFixes&0x10000) // check game fix... high performance counters are bad on some mb chipsets + bIsPerformanceCounter=FALSE; + else + { + if (QueryPerformanceFrequency (&liCPUFrequency)) + bIsPerformanceCounter = TRUE; + else bIsPerformanceCounter = FALSE; + } + + if(bOldPerformanceCounter!=bIsPerformanceCounter) // changed? + { + bInitCap = TRUE; + SetAutoFrameCap(); + } +} + +//////////////////////////////////////////////////////////////////////// + +void SetFrameRateConfig(void) +{ + if(fFrameRateHz==0) + { + if(iFrameLimit==2) fFrameRateHz=59.94f; // auto framerate? set some init val (no pal/ntsc known yet) + else fFrameRateHz=fFrameRate; // else set user framerate + } + + if(bIsPerformanceCounter) + dwFrameRateTicks=(liCPUFrequency.LowPart / fFrameRateHz); + else dwFrameRateTicks=(1000 / (DWORD)fFrameRateHz); +} + +void CheckFrameRate(void) // called in updatelace (on every emulated psx vsync) +{ + if(bUseFrameSkip) + { + if(!(dwActFixes&0x100)) + { + dwLaceCnt++; // -> and store cnt of vsync between frames + if(dwLaceCnt>=MAXLACE && bUseFrameLimit) + { + if(dwLaceCnt==MAXLACE) bInitCap=TRUE; + FrameCap(); + } + } + else if(bUseFrameLimit) FrameCap(); + calcfps(); // -> calc fps display in skipping mode + } + else // -> non-skipping mode: + { + if(bUseFrameLimit) FrameCap(); + if(ulKeybits&KEY_SHOWFPS) calcfps(); + } +} + +//////////////////////////////////////////////////////////////////////// + +void CALLBACK GPUsetframelimit(unsigned long option) // new EPSXE interface func: main emu can enable/disable fps limitation this way +{ + bInitCap = TRUE; + + if(option==1) // emu says: limit + { + bUseFrameLimit=TRUE;bUseFrameSkip=FALSE;iFrameLimit=2; + SetAutoFrameCap(); + } + else // emu says: no limit + { + bUseFrameLimit=FALSE; + } +} + +//////////////////////////////////////////////////////////////////////// diff --git a/win32/plugins/peopsxgl/winsrc/key.c b/win32/plugins/peopsxgl/winsrc/key.c index f1ad8ca3..5884b040 100644..100755 --- a/win32/plugins/peopsxgl/winsrc/key.c +++ b/win32/plugins/peopsxgl/winsrc/key.c @@ -1,203 +1,203 @@ -/***************************************************************************
- key.c - description
- -------------------
- begin : Sun Mar 08 2009
- copyright : (C) 1999-2009 by Pete Bernert
- web : www.pbernert.com
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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:
-//
-// 2009/03/08 - Pete
-// - generic cleanup for the Peops release
-//
-//*************************************************************************//
-
-#include "stdafx.h"
-
-#define _IN_KEY
-
-#include "externals.h"
-#include "menu.h"
-#include "texture.h"
-#include "draw.h"
-#include "fps.h"
-
-////////////////////////////////////////////////////////////////////////
-// KeyBoard handler stuff
-////////////////////////////////////////////////////////////////////////
-
-uint32_t ulKeybits;
-
-static WNDPROC pOldWinProc=0;
-char szGPUKeys[7];
-
-////////////////////////////////////////////////////////////////////////
-// keyboard handler (WINDOWS)
-////////////////////////////////////////////////////////////////////////
-
-LRESULT CALLBACK key_winproc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
-{
- switch(message)
- {
- case WM_SYSCOMMAND:
- if(iNoScreenSaver && wParam==SC_SCREENSAVE) return 0L;
- break;
-
- case WM_KEYDOWN:
- if(wParam==(WPARAM)szGPUKeys[1]) {ulKeybits|=KEY_RESETTEXSTORE;break;}
- break;
-
- case WM_SYSKEYUP:
- if(wParam==VK_RETURN) bChangeWinMode=TRUE;
- break;
-
- case WM_KEYUP:
- if(wParam==(WPARAM)szGPUKeys[0])
- {
- if(ulKeybits&KEY_SHOWFPS)
- {
- ulKeybits&=~KEY_SHOWFPS;
- HideText();
- DestroyPic();
- }
- else
- {
- ulKeybits|=KEY_SHOWFPS;
- szDispBuf[0]=0;
- BuildDispMenu(0);
- }
- break;
- }
- if(wParam==(WPARAM)szGPUKeys[1]) {ShowGpuPic();break;}
- if(wParam==(WPARAM)szGPUKeys[2]) {SwitchDispMenu(-1); break;}
- if(wParam==(WPARAM)szGPUKeys[3]) {SwitchDispMenu( 1); break;}
- if(wParam==(WPARAM)szGPUKeys[4])
- {
- if(GetAsyncKeyState(VK_SHIFT)&32768)
- {
- if(iBlurBuffer) iBlurBuffer=0;
- else iBlurBuffer=1;
- }
- BuildDispMenu(-1);
- break;
- }
- if(wParam==(WPARAM)szGPUKeys[5]) {BuildDispMenu( 1); break;}
-
- }
- return pOldWinProc( hwnd, message, wParam, lParam );
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void InitKeyHandler(void)
-{
- if(!pOldWinProc)
- {
- pOldWinProc = (WNDPROC)GetWindowLong(hWWindow, GWL_WNDPROC );
- SetWindowLong(hWWindow, GWL_WNDPROC, (long)key_winproc);
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void ExitKeyHandler(void)
-{
- if(pOldWinProc)
- SetWindowLong(hWWindow,GWL_WNDPROC, // set old proc
- (long)pOldWinProc);
- pOldWinProc = 0;
-}
-
-////////////////////////////////////////////////////////////////////////
-// reset stuff on special keyboard commands
-////////////////////////////////////////////////////////////////////////
-
-void ResetStuff(void)
-{
- ResetTextureArea(TRUE);
- ulKeybits&=~KEY_RESETTEXSTORE;
-
- if(ulKeybits&KEY_BLACKWHITE)
- {
- if(bUseFixes) {bUseFixes=FALSE;dwActFixes=0;}
- else {bUseFixes=TRUE; dwActFixes=dwCfgFixes;}
- SetExtGLFuncs();
- if(iFrameLimit==2) SetAutoFrameCap();
- ulKeybits&=~KEY_BLACKWHITE;
- }
-
- if(ulKeybits&KEY_RESETFILTER)
- {
- if(ulKeybits&KEY_STEPDOWN)
- iFilterType--;
- else iFilterType++;
- if(iFilterType>6) iFilterType=0;
- if(iFilterType<0) iFilterType=6;
- SetExtGLFuncs();
- ulKeybits&=~(KEY_RESETFILTER|KEY_STEPDOWN);
- BuildDispMenu(0);
- }
-
- if(ulKeybits&KEY_RESETOPAQUE)
- {
- bOpaquePass=!bOpaquePass;
- SetExtGLFuncs();
- ulKeybits&=~KEY_RESETOPAQUE;
- BuildDispMenu(0);
- }
-
- if(ulKeybits&KEY_RESETADVBLEND)
- {
- bAdvancedBlend=!bAdvancedBlend;
- SetExtGLFuncs();
- ulKeybits&=~KEY_RESETADVBLEND;
- BuildDispMenu(0);
- }
-
- if(ulKeybits&KEY_RESETDITHER)
- {
- bDrawDither=!bDrawDither;
- if(bDrawDither) glEnable(GL_DITHER);
- else glDisable(GL_DITHER);
- ulKeybits&=~KEY_RESETDITHER;
- BuildDispMenu(0);
- }
-
- if(ulKeybits & KEY_TOGGLEFBTEXTURE)
- {
- if(ulKeybits&KEY_STEPDOWN)
- iFrameTexType--;
- else iFrameTexType++;
- if(iFrameTexType>3) iFrameTexType=0;
- if(iFrameTexType<0) iFrameTexType=3;
- if(gTexFrameName!=0)
- glDeleteTextures(1, &gTexFrameName);
- gTexFrameName=0;
- ulKeybits&=~(KEY_TOGGLEFBTEXTURE|KEY_STEPDOWN);
- }
-
- if(ulKeybits & KEY_TOGGLEFBREAD)
- {
- if(ulKeybits&KEY_STEPDOWN)
- iFrameReadType--;
- else iFrameReadType++;
- if(iFrameReadType>4) iFrameReadType=0;
- if(iFrameReadType<0) iFrameReadType=4;
- if(iFrameReadType==4) bFullVRam=TRUE;
- else bFullVRam=FALSE;
- iRenderFVR=0;
- ulKeybits&=~(KEY_TOGGLEFBREAD|KEY_STEPDOWN);
- }
-}
+/*************************************************************************** + key.c - description + ------------------- + begin : Sun Mar 08 2009 + copyright : (C) 1999-2009 by Pete Bernert + web : www.pbernert.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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: +// +// 2009/03/08 - Pete +// - generic cleanup for the Peops release +// +//*************************************************************************// + +#include "stdafx.h" + +#define _IN_KEY + +#include "externals.h" +#include "menu.h" +#include "texture.h" +#include "draw.h" +#include "fps.h" + +//////////////////////////////////////////////////////////////////////// +// KeyBoard handler stuff +//////////////////////////////////////////////////////////////////////// + +uint32_t ulKeybits; + +static WNDPROC pOldWinProc=0; +char szGPUKeys[7]; + +//////////////////////////////////////////////////////////////////////// +// keyboard handler (WINDOWS) +//////////////////////////////////////////////////////////////////////// + +LRESULT CALLBACK key_winproc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) +{ + switch(message) + { + case WM_SYSCOMMAND: + if(iNoScreenSaver && wParam==SC_SCREENSAVE) return 0L; + break; + + case WM_KEYDOWN: + if(wParam==(WPARAM)szGPUKeys[1]) {ulKeybits|=KEY_RESETTEXSTORE;break;} + break; + + case WM_SYSKEYUP: + if(wParam==VK_RETURN) bChangeWinMode=TRUE; + break; + + case WM_KEYUP: + if(wParam==(WPARAM)szGPUKeys[0]) + { + if(ulKeybits&KEY_SHOWFPS) + { + ulKeybits&=~KEY_SHOWFPS; + HideText(); + DestroyPic(); + } + else + { + ulKeybits|=KEY_SHOWFPS; + szDispBuf[0]=0; + BuildDispMenu(0); + } + break; + } + if(wParam==(WPARAM)szGPUKeys[1]) {ShowGpuPic();break;} + if(wParam==(WPARAM)szGPUKeys[2]) {SwitchDispMenu(-1); break;} + if(wParam==(WPARAM)szGPUKeys[3]) {SwitchDispMenu( 1); break;} + if(wParam==(WPARAM)szGPUKeys[4]) + { + if(GetAsyncKeyState(VK_SHIFT)&32768) + { + if(iBlurBuffer) iBlurBuffer=0; + else iBlurBuffer=1; + } + BuildDispMenu(-1); + break; + } + if(wParam==(WPARAM)szGPUKeys[5]) {BuildDispMenu( 1); break;} + + } + return pOldWinProc( hwnd, message, wParam, lParam ); +} + +//////////////////////////////////////////////////////////////////////// + +void InitKeyHandler(void) +{ + if(!pOldWinProc) + { + pOldWinProc = (WNDPROC)GetWindowLong(hWWindow, GWL_WNDPROC ); + SetWindowLong(hWWindow, GWL_WNDPROC, (long)key_winproc); + } +} + +//////////////////////////////////////////////////////////////////////// + +void ExitKeyHandler(void) +{ + if(pOldWinProc) + SetWindowLong(hWWindow,GWL_WNDPROC, // set old proc + (long)pOldWinProc); + pOldWinProc = 0; +} + +//////////////////////////////////////////////////////////////////////// +// reset stuff on special keyboard commands +//////////////////////////////////////////////////////////////////////// + +void ResetStuff(void) +{ + ResetTextureArea(TRUE); + ulKeybits&=~KEY_RESETTEXSTORE; + + if(ulKeybits&KEY_BLACKWHITE) + { + if(bUseFixes) {bUseFixes=FALSE;dwActFixes=0;} + else {bUseFixes=TRUE; dwActFixes=dwCfgFixes;} + SetExtGLFuncs(); + if(iFrameLimit==2) SetAutoFrameCap(); + ulKeybits&=~KEY_BLACKWHITE; + } + + if(ulKeybits&KEY_RESETFILTER) + { + if(ulKeybits&KEY_STEPDOWN) + iFilterType--; + else iFilterType++; + if(iFilterType>6) iFilterType=0; + if(iFilterType<0) iFilterType=6; + SetExtGLFuncs(); + ulKeybits&=~(KEY_RESETFILTER|KEY_STEPDOWN); + BuildDispMenu(0); + } + + if(ulKeybits&KEY_RESETOPAQUE) + { + bOpaquePass=!bOpaquePass; + SetExtGLFuncs(); + ulKeybits&=~KEY_RESETOPAQUE; + BuildDispMenu(0); + } + + if(ulKeybits&KEY_RESETADVBLEND) + { + bAdvancedBlend=!bAdvancedBlend; + SetExtGLFuncs(); + ulKeybits&=~KEY_RESETADVBLEND; + BuildDispMenu(0); + } + + if(ulKeybits&KEY_RESETDITHER) + { + bDrawDither=!bDrawDither; + if(bDrawDither) glEnable(GL_DITHER); + else glDisable(GL_DITHER); + ulKeybits&=~KEY_RESETDITHER; + BuildDispMenu(0); + } + + if(ulKeybits & KEY_TOGGLEFBTEXTURE) + { + if(ulKeybits&KEY_STEPDOWN) + iFrameTexType--; + else iFrameTexType++; + if(iFrameTexType>3) iFrameTexType=0; + if(iFrameTexType<0) iFrameTexType=3; + if(gTexFrameName!=0) + glDeleteTextures(1, &gTexFrameName); + gTexFrameName=0; + ulKeybits&=~(KEY_TOGGLEFBTEXTURE|KEY_STEPDOWN); + } + + if(ulKeybits & KEY_TOGGLEFBREAD) + { + if(ulKeybits&KEY_STEPDOWN) + iFrameReadType--; + else iFrameReadType++; + if(iFrameReadType>4) iFrameReadType=0; + if(iFrameReadType<0) iFrameReadType=4; + if(iFrameReadType==4) bFullVRam=TRUE; + else bFullVRam=FALSE; + iRenderFVR=0; + ulKeybits&=~(KEY_TOGGLEFBREAD|KEY_STEPDOWN); + } +} diff --git a/win32/plugins/peopsxgl/winsrc/ssave.c b/win32/plugins/peopsxgl/winsrc/ssave.c index 40a75956..8665a5b3 100644..100755 --- a/win32/plugins/peopsxgl/winsrc/ssave.c +++ b/win32/plugins/peopsxgl/winsrc/ssave.c @@ -1,65 +1,65 @@ -/***************************************************************************
- ssave.c - description
- -------------------
- begin : Sun Mar 08 2009
- copyright : (C) 1999-2009 by Pete Bernert
- web : www.pbernert.com
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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:
-//
-// 2009/03/08 - Pete
-// - generic cleanup for the Peops release
-//
-//*************************************************************************//
-
-#include "stdafx.h"
-
-#include "externals.h"
-
-////////////////////////////////////////////////////////////////////////
-// screensaver stuff: dynamically load kernel32.dll to avoid export dependeny
-////////////////////////////////////////////////////////////////////////
-
-#ifdef __MINGW32__
-#define EXECUTION_STATE DWORD
-#endif
-
-void EnableScreenSaver(BOOL bEnab)
-{
- HINSTANCE hKernel32 = NULL;
- EXECUTION_STATE (WINAPI *D_SetThreadExecutionState)(EXECUTION_STATE esFlags);
-
- if(bEnab)
- {
- hKernel32 = LoadLibrary("kernel32.dll");
- if(hKernel32 != NULL)
- {
- if((D_SetThreadExecutionState=(EXECUTION_STATE (WINAPI *)(EXECUTION_STATE))GetProcAddress(hKernel32,"SetThreadExecutionState"))!=NULL)
- D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED);
- FreeLibrary(hKernel32);
- }
- }
- else
- {
- hKernel32 = LoadLibrary("kernel32.dll");
- if(hKernel32 != NULL)
- {
- if((D_SetThreadExecutionState=(EXECUTION_STATE (WINAPI *)(EXECUTION_STATE))GetProcAddress(hKernel32,"SetThreadExecutionState"))!=NULL)
- D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED|ES_CONTINUOUS);
- FreeLibrary(hKernel32);
- }
- }
-}
-
+/*************************************************************************** + ssave.c - description + ------------------- + begin : Sun Mar 08 2009 + copyright : (C) 1999-2009 by Pete Bernert + web : www.pbernert.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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: +// +// 2009/03/08 - Pete +// - generic cleanup for the Peops release +// +//*************************************************************************// + +#include "stdafx.h" + +#include "externals.h" + +//////////////////////////////////////////////////////////////////////// +// screensaver stuff: dynamically load kernel32.dll to avoid export dependeny +//////////////////////////////////////////////////////////////////////// + +#ifdef __MINGW32__ +#define EXECUTION_STATE DWORD +#endif + +void EnableScreenSaver(BOOL bEnab) +{ + HINSTANCE hKernel32 = NULL; + EXECUTION_STATE (WINAPI *D_SetThreadExecutionState)(EXECUTION_STATE esFlags); + + if(bEnab) + { + hKernel32 = LoadLibrary("kernel32.dll"); + if(hKernel32 != NULL) + { + if((D_SetThreadExecutionState=(EXECUTION_STATE (WINAPI *)(EXECUTION_STATE))GetProcAddress(hKernel32,"SetThreadExecutionState"))!=NULL) + D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED); + FreeLibrary(hKernel32); + } + } + else + { + hKernel32 = LoadLibrary("kernel32.dll"); + if(hKernel32 != NULL) + { + if((D_SetThreadExecutionState=(EXECUTION_STATE (WINAPI *)(EXECUTION_STATE))GetProcAddress(hKernel32,"SetThreadExecutionState"))!=NULL) + D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED|ES_CONTINUOUS); + FreeLibrary(hKernel32); + } + } +} + diff --git a/win32/plugins/peopsxgl/winsrc/ssave.h b/win32/plugins/peopsxgl/winsrc/ssave.h index 66ac0854..e498c960 100644..100755 --- a/win32/plugins/peopsxgl/winsrc/ssave.h +++ b/win32/plugins/peopsxgl/winsrc/ssave.h @@ -1,29 +1,29 @@ -/***************************************************************************
- ssave.h - description
- -------------------
- begin : Sun Mar 08 2009
- copyright : (C) 1999-2009 by Pete Bernert
- web : www.pbernert.com
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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:
-//
-// 2009/03/08 - Pete
-// - generic cleanup for the Peops release
-//
-//*************************************************************************//
-
-// prototype
-
+/*************************************************************************** + ssave.h - description + ------------------- + begin : Sun Mar 08 2009 + copyright : (C) 1999-2009 by Pete Bernert + web : www.pbernert.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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: +// +// 2009/03/08 - Pete +// - generic cleanup for the Peops release +// +//*************************************************************************// + +// prototype + void EnableScreenSaver(BOOL bEnab);
\ No newline at end of file diff --git a/win32/plugins/peopsxgl/winsrc/winmain.c b/win32/plugins/peopsxgl/winsrc/winmain.c index e69fe6e3..6b860505 100644..100755 --- a/win32/plugins/peopsxgl/winsrc/winmain.c +++ b/win32/plugins/peopsxgl/winsrc/winmain.c @@ -1,42 +1,42 @@ -/***************************************************************************
- gpuPeopsOpenGL.c - description
- -------------------
- begin : Sun Mar 08 2009
- copyright : (C) 1999-2009 by Pete Bernert
- web : www.pbernert.com
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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:
-//
-// 2009/03/08 - Pete
-// - generic cleanup for the Peops release
-//
-//*************************************************************************//
-
-#include "stdafx.h"
-
-///////////////////////////////////////////////////////////////////////////
-// GENERIC FUNCS //////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////
-
-HINSTANCE hInst=NULL;
-
-BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
- DWORD dwReason,
- LPVOID lpReserved)
-{
- hInst=(HINSTANCE)hModule;
- return TRUE; // very quick :)
-}
-
+/*************************************************************************** + gpuPeopsOpenGL.c - description + ------------------- + begin : Sun Mar 08 2009 + copyright : (C) 1999-2009 by Pete Bernert + web : www.pbernert.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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: +// +// 2009/03/08 - Pete +// - generic cleanup for the Peops release +// +//*************************************************************************// + +#include "stdafx.h" + +/////////////////////////////////////////////////////////////////////////// +// GENERIC FUNCS ////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// + +HINSTANCE hInst=NULL; + +BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT + DWORD dwReason, + LPVOID lpReserved) +{ + hInst=(HINSTANCE)hModule; + return TRUE; // very quick :) +} + |
