2010-03-19 00:31:15 +00:00
# include <stdio.h>
# include <windows.h>
# include <windowsx.h>
# include "resrc1.h"
# include "GS.h"
2010-04-30 04:40:31 +00:00
# include "zerogsshaders.h"
2010-03-19 00:31:15 +00:00
# include "Win32.h"
# include <map>
2010-05-01 23:34:44 +00:00
2010-03-19 00:31:15 +00:00
using namespace std ;
extern int g_nPixelShaderVer ;
static int prevbilinearfilter ;
2010-05-01 23:34:44 +00:00
HINSTANCE hInst = NULL ;
2010-03-19 00:31:15 +00:00
2010-05-01 23:34:44 +00:00
void CALLBACK GSkeyEvent ( keyEvent * ev )
{
2010-03-19 00:31:15 +00:00
// switch (ev->event) {
// case KEYPRESS:
// switch (ev->key) {
// case VK_PRIOR:
// if (conf.fps) fpspos++; break;
// case VK_NEXT:
// if (conf.fps) fpspos--; break;
// case VK_END:
// if (conf.fps) fpspress = 1; break;
// case VK_DELETE:
// conf.fps = 1 - conf.fps;
// break;
// }
// break;
// }
}
# include "Win32/resource.h"
2010-06-01 02:00:48 +00:00
BOOL CALLBACK LoggingDlgProc ( HWND hW , UINT uMsg , WPARAM wParam , LPARAM lParam )
2010-05-01 23:34:44 +00:00
{
switch ( uMsg )
{
2010-03-19 00:31:15 +00:00
case WM_INITDIALOG :
2010-05-01 23:34:44 +00:00
if ( conf . log ) CheckDlgButton ( hW , IDC_LOG , true ) ;
return true ;
2010-03-19 00:31:15 +00:00
case WM_COMMAND :
2010-05-01 23:34:44 +00:00
switch ( LOWORD ( wParam ) )
{
2010-03-19 00:31:15 +00:00
case IDCANCEL :
2010-05-01 23:34:44 +00:00
EndDialog ( hW , true ) ;
return true ;
2010-03-19 00:31:15 +00:00
case IDOK :
2010-05-01 23:34:44 +00:00
2010-03-19 00:31:15 +00:00
if ( IsDlgButtonChecked ( hW , IDC_LOG ) )
2010-04-25 07:21:29 +00:00
conf . log = 1 ;
2010-05-01 23:34:44 +00:00
else
2010-04-25 07:21:29 +00:00
conf . log = 0 ;
2010-03-19 00:31:15 +00:00
SaveConfig ( ) ;
2010-05-01 23:34:44 +00:00
EndDialog ( hW , false ) ;
return true ;
2010-03-19 00:31:15 +00:00
}
}
2010-05-01 23:34:44 +00:00
return false ;
2010-03-19 00:31:15 +00:00
}
map < int , int > mapConfOpts ;
# define PUT_CONF(id) mapConfOpts[IDC_CONFOPT_##id] = 0x##id;
void OnInitDialog ( HWND hW )
{
2010-07-24 08:08:42 +00:00
if ( ! ( conf . zz_options . loaded ) ) LoadConfig ( ) ;
2010-03-19 00:31:15 +00:00
CheckDlgButton ( hW , IDC_CONFIG_INTERLACE , conf . interlace ) ;
CheckDlgButton ( hW , IDC_CONFIG_BILINEAR , conf . bilinear ) ;
CheckDlgButton ( hW , IDC_CONFIG_DEPTHWRITE , conf . mrtdepth ) ;
2010-05-01 23:34:44 +00:00
CheckRadioButton ( hW , IDC_CONFIG_AANONE , IDC_CONFIG_AA4 , IDC_CONFIG_AANONE + conf . aa ) ;
2010-06-19 06:23:40 +00:00
CheckDlgButton ( hW , IDC_CONFIG_WIREFRAME , ( conf . wireframe ( ) ) ? 1 : 0 ) ;
CheckDlgButton ( hW , IDC_CONFIG_CAPTUREAVI , ( conf . captureAvi ( ) ) ? 1 : 0 ) ;
CheckDlgButton ( hW , IDC_CONFIG_FULLSCREEN , ( conf . fullscreen ( ) ) ? 1 : 0 ) ;
CheckDlgButton ( hW , IDC_CONFIG_WIDESCREEN , ( conf . widescreen ( ) ) ? 1 : 0 ) ;
2010-06-19 08:46:40 +00:00
CheckDlgButton ( hW , IDC_CONFIG_BMPSS , ( conf . zz_options . tga_snap ) ? 1 : 0 ) ;
CheckRadioButton ( hW , IDC_CONF_WIN640 , IDC_CONF_WIN1280 , IDC_CONF_WIN640 + conf . zz_options . dimensions ) ;
2010-03-19 00:31:15 +00:00
prevbilinearfilter = conf . bilinear ;
mapConfOpts . clear ( ) ;
2010-05-01 23:34:44 +00:00
2010-03-19 00:31:15 +00:00
PUT_CONF ( 00000001 ) ;
PUT_CONF ( 00000002 ) ;
PUT_CONF ( 00000004 ) ;
PUT_CONF ( 0000000 8 ) ;
PUT_CONF ( 00000010 ) ;
PUT_CONF ( 00000020 ) ;
PUT_CONF ( 00000040 ) ;
PUT_CONF ( 000000 80 ) ;
PUT_CONF ( 00000100 ) ;
PUT_CONF ( 00000200 ) ;
PUT_CONF ( 00000400 ) ;
PUT_CONF ( 00000 800 ) ;
PUT_CONF ( 00001000 ) ;
PUT_CONF ( 00002000 ) ;
PUT_CONF ( 00004000 ) ;
PUT_CONF ( 0000 8000 ) ;
PUT_CONF ( 00010000 ) ;
PUT_CONF ( 00020000 ) ;
PUT_CONF ( 00040000 ) ;
PUT_CONF ( 000 80000 ) ;
PUT_CONF ( 00100000 ) ;
PUT_CONF ( 00200000 ) ;
PUT_CONF ( 00 800000 ) ;
PUT_CONF ( 01000000 ) ;
PUT_CONF ( 02000000 ) ;
PUT_CONF ( 04000000 ) ;
PUT_CONF ( 10000000 ) ;
2010-05-01 23:34:44 +00:00
for ( map < int , int > : : iterator it = mapConfOpts . begin ( ) ; it ! = mapConfOpts . end ( ) ; + + it )
{
2010-07-24 08:05:53 +00:00
CheckDlgButton ( hW , it - > first , ( conf . settings ( ) . _u32 & it - > second ) ? 1 : 0 ) ;
2010-03-19 00:31:15 +00:00
}
}
2010-05-01 23:34:44 +00:00
void OnOK ( HWND hW )
{
2010-03-19 00:31:15 +00:00
u32 newinterlace = IsDlgButtonChecked ( hW , IDC_CONFIG_INTERLACE ) ;
2010-05-01 23:34:44 +00:00
if ( ! conf . interlace ) conf . interlace = newinterlace ;
else if ( ! newinterlace ) conf . interlace = 2 ; // off
2010-03-19 00:31:15 +00:00
conf . bilinear = IsDlgButtonChecked ( hW , IDC_CONFIG_BILINEAR ) ;
2010-05-01 23:34:44 +00:00
2010-03-19 00:31:15 +00:00
// restore
2010-05-01 23:34:44 +00:00
if ( conf . bilinear & & prevbilinearfilter )
2010-03-19 00:31:15 +00:00
conf . bilinear = prevbilinearfilter ;
//conf.mrtdepth = 1;//IsDlgButtonChecked(hW, IDC_CONFIG_DEPTHWRITE);
2010-05-01 23:34:44 +00:00
if ( SendDlgItemMessage ( hW , IDC_CONFIG_AANONE , BM_GETCHECK , 0 , 0 ) )
{
2010-03-19 00:31:15 +00:00
conf . aa = 0 ;
}
2010-05-01 23:34:44 +00:00
else if ( SendDlgItemMessage ( hW , IDC_CONFIG_AA2 , BM_GETCHECK , 0 , 0 ) )
{
2010-03-19 00:31:15 +00:00
conf . aa = 1 ;
}
2010-05-01 23:34:44 +00:00
else if ( SendDlgItemMessage ( hW , IDC_CONFIG_AA4 , BM_GETCHECK , 0 , 0 ) )
{
2010-03-19 00:31:15 +00:00
conf . aa = 2 ;
}
2010-05-01 23:34:44 +00:00
else if ( SendDlgItemMessage ( hW , IDC_CONFIG_AA8 , BM_GETCHECK , 0 , 0 ) )
{
2010-03-19 00:31:15 +00:00
conf . aa = 3 ;
}
2010-05-01 23:34:44 +00:00
else if ( SendDlgItemMessage ( hW , IDC_CONFIG_AA16 , BM_GETCHECK , 0 , 0 ) )
{
2010-03-19 00:31:15 +00:00
conf . aa = 4 ;
}
2010-05-01 23:34:44 +00:00
else
{
conf . aa = 0 ;
}
2010-03-19 00:31:15 +00:00
2010-05-01 23:34:44 +00:00
conf . negaa = 0 ;
2010-06-19 09:07:21 +00:00
conf . zz_options . _u32 = 0 ;
2010-05-01 23:34:44 +00:00
2010-06-19 08:46:40 +00:00
conf . zz_options . capture_avi = IsDlgButtonChecked ( hW , IDC_CONFIG_CAPTUREAVI ) ? 1 : 0 ;
conf . zz_options . wireframe = IsDlgButtonChecked ( hW , IDC_CONFIG_WIREFRAME ) ? 1 : 0 ;
conf . zz_options . fullscreen = IsDlgButtonChecked ( hW , IDC_CONFIG_FULLSCREEN ) ? 1 : 0 ;
conf . zz_options . widescreen = IsDlgButtonChecked ( hW , IDC_CONFIG_WIDESCREEN ) ? 1 : 0 ;
conf . zz_options . tga_snap = IsDlgButtonChecked ( hW , IDC_CONFIG_BMPSS ) ? 1 : 0 ;
2010-03-19 00:31:15 +00:00
2010-06-19 09:07:21 +00:00
conf . hacks . _u32 = 0 ;
2010-05-01 23:34:44 +00:00
for ( map < int , int > : : iterator it = mapConfOpts . begin ( ) ; it ! = mapConfOpts . end ( ) ; + + it )
{
2010-06-19 09:07:21 +00:00
if ( IsDlgButtonChecked ( hW , it - > first ) ) conf . hacks . _u32 | = it - > second ;
2010-03-19 00:31:15 +00:00
}
2010-05-01 23:34:44 +00:00
2010-06-19 09:07:21 +00:00
GSsetGameCRC ( g_LastCRC , conf . hacks . _u32 ) ;
2010-03-19 00:31:15 +00:00
2010-05-01 23:34:44 +00:00
if ( SendDlgItemMessage ( hW , IDC_CONF_WIN640 , BM_GETCHECK , 0 , 0 ) )
2010-06-19 08:46:40 +00:00
conf . zz_options . dimensions = GSDim_640 ;
2010-05-01 23:34:44 +00:00
else if ( SendDlgItemMessage ( hW , IDC_CONF_WIN800 , BM_GETCHECK , 0 , 0 ) )
2010-06-19 08:46:40 +00:00
conf . zz_options . dimensions = GSDim_800 ;
2010-05-01 23:34:44 +00:00
else if ( SendDlgItemMessage ( hW , IDC_CONF_WIN1024 , BM_GETCHECK , 0 , 0 ) )
2010-06-19 08:46:40 +00:00
conf . zz_options . dimensions = GSDim_1024 ;
2010-05-01 23:34:44 +00:00
else if ( SendDlgItemMessage ( hW , IDC_CONF_WIN1280 , BM_GETCHECK , 0 , 0 ) )
2010-06-19 08:46:40 +00:00
conf . zz_options . dimensions = GSDim_1280 ;
2010-03-19 00:31:15 +00:00
SaveConfig ( ) ;
2010-05-01 23:34:44 +00:00
EndDialog ( hW , false ) ;
2010-03-19 00:31:15 +00:00
}
2010-06-01 02:00:48 +00:00
BOOL CALLBACK ConfigureDlgProc ( HWND hW , UINT uMsg , WPARAM wParam , LPARAM lParam )
2010-05-01 23:34:44 +00:00
{
switch ( uMsg )
{
2010-03-19 00:31:15 +00:00
case WM_INITDIALOG :
OnInitDialog ( hW ) ;
2010-05-01 23:34:44 +00:00
return true ;
2010-03-19 00:31:15 +00:00
case WM_COMMAND :
2010-05-01 23:34:44 +00:00
switch ( LOWORD ( wParam ) )
{
2010-03-19 00:31:15 +00:00
case IDCANCEL :
2010-05-01 23:34:44 +00:00
EndDialog ( hW , true ) ;
return true ;
2010-03-19 00:31:15 +00:00
case IDOK :
OnOK ( hW ) ;
2010-05-01 23:34:44 +00:00
return true ;
2010-03-19 00:31:15 +00:00
}
}
2010-05-01 23:34:44 +00:00
return false ;
2010-03-19 00:31:15 +00:00
}
2010-06-01 02:00:48 +00:00
BOOL CALLBACK AboutDlgProc ( HWND hW , UINT uMsg , WPARAM wParam , LPARAM lParam )
2010-05-01 23:34:44 +00:00
{
switch ( uMsg )
{
2010-03-19 00:31:15 +00:00
case WM_INITDIALOG :
//ZeroGS uses floating point render targets because A8R8G8B8 format is not sufficient for ps2 blending and this requires alpha blending on floating point render targets
//There might be a problem with pixel shader precision with older geforce models (textures will look blocky).
2010-05-01 23:34:44 +00:00
return true ;
2010-03-19 00:31:15 +00:00
case WM_COMMAND :
2010-05-01 23:34:44 +00:00
switch ( LOWORD ( wParam ) )
{
2010-03-19 00:31:15 +00:00
case IDOK :
2010-05-01 23:34:44 +00:00
EndDialog ( hW , false ) ;
return true ;
2010-03-19 00:31:15 +00:00
}
}
2010-05-01 23:34:44 +00:00
return false ;
2010-03-19 00:31:15 +00:00
}
2010-05-01 23:34:44 +00:00
void CALLBACK GSconfigure ( )
{
2010-04-30 04:40:31 +00:00
DialogBox ( hInst ,
2010-05-01 23:34:44 +00:00
MAKEINTRESOURCE ( IDD_CONFIG ) ,
GetActiveWindow ( ) ,
( DLGPROC ) ConfigureDlgProc ) ;
2010-04-30 04:40:31 +00:00
if ( g_nPixelShaderVer = = SHADER_REDUCED ) conf . bilinear = 0 ;
}
2010-05-01 23:34:44 +00:00
s32 CALLBACK GStest ( )
{
2010-03-19 00:31:15 +00:00
return 0 ;
}
2010-05-01 23:34:44 +00:00
void CALLBACK GSabout ( )
{
2010-03-19 00:31:15 +00:00
DialogBox ( hInst ,
MAKEINTRESOURCE ( IDD_ABOUT ) ,
2010-04-25 00:31:27 +00:00
GetActiveWindow ( ) ,
2010-03-19 00:31:15 +00:00
( DLGPROC ) AboutDlgProc ) ;
}
2010-05-01 23:34:44 +00:00
bool APIENTRY DllMain ( HANDLE hModule , // DLL INIT
2010-04-25 00:31:27 +00:00
DWORD dwReason ,
2010-05-01 23:34:44 +00:00
LPVOID lpReserved )
{
2010-03-19 00:31:15 +00:00
hInst = ( HINSTANCE ) hModule ;
2010-05-01 23:34:44 +00:00
return true ; // very quick :)
2010-03-19 00:31:15 +00:00
}
static char * err = " Error Loading Symbol " ;
static int errval ;
2010-05-01 23:34:44 +00:00
void * SysLoadLibrary ( char * lib )
{
2010-03-19 00:31:15 +00:00
return LoadLibrary ( lib ) ;
}
2010-05-01 23:34:44 +00:00
void * SysLoadSym ( void * lib , char * sym )
{
2010-03-19 00:31:15 +00:00
void * tmp = GetProcAddress ( ( HINSTANCE ) lib , sym ) ;
2010-05-01 23:34:44 +00:00
if ( tmp = = NULL )
errval = 1 ;
else
errval = 0 ;
2010-03-19 00:31:15 +00:00
return tmp ;
}
2010-05-01 23:34:44 +00:00
char * SysLibError ( )
{
2010-03-19 00:31:15 +00:00
if ( errval ) { errval = 0 ; return err ; }
2010-05-01 23:34:44 +00:00
2010-03-19 00:31:15 +00:00
return NULL ;
}
2010-05-01 23:34:44 +00:00
void SysCloseLibrary ( void * lib )
{
2010-03-19 00:31:15 +00:00
FreeLibrary ( ( HINSTANCE ) lib ) ;
}
2010-04-30 04:40:31 +00:00
2010-05-01 23:34:44 +00:00
void SysMessage ( const char * fmt , . . . )
{
2010-04-30 04:40:31 +00:00
va_list list ;
char tmp [ 512 ] ;
2010-05-01 23:34:44 +00:00
va_start ( list , fmt ) ;
vsprintf ( tmp , fmt , list ) ;
2010-04-30 04:40:31 +00:00
va_end ( list ) ;
2010-05-01 23:34:44 +00:00
MessageBox ( 0 , tmp , " ZZOgl-PG Msg " , 0 ) ;
2010-04-30 04:40:31 +00:00
}