262 lines
8.4 KiB
C++
262 lines
8.4 KiB
C++
|
//
|
|||
|
// <20>O<EFBFBD><4F><EFBFBD>t<EFBFBD>B<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>_<EFBFBD>C<EFBFBD>A<EFBFBD><41><EFBFBD>O<EFBFBD>N<EFBFBD><4E><EFBFBD>X
|
|||
|
//
|
|||
|
//
|
|||
|
#define WIN32_LEAN_AND_MEAN
|
|||
|
#include <windows.h>
|
|||
|
#include <commdlg.h>
|
|||
|
|
|||
|
#include <string>
|
|||
|
using namespace std;
|
|||
|
|
|||
|
#include "VirtuaNESres.h"
|
|||
|
#include "DebugOut.h"
|
|||
|
#include "App.h"
|
|||
|
#include "Pathlib.h"
|
|||
|
|
|||
|
#include "Wnd.h"
|
|||
|
#include "GraphicsDlg.h"
|
|||
|
|
|||
|
#include "DirectDraw.h"
|
|||
|
|
|||
|
DLG_MESSAGE_BEGIN(CGraphicsDlg)
|
|||
|
// <20><><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W
|
|||
|
DLG_ON_MESSAGE( WM_INITDIALOG, OnInitDialog )
|
|||
|
DLG_ON_MESSAGE( WM_HSCROLL, OnHScroll )
|
|||
|
// NOTIFY<46><59><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W
|
|||
|
DLG_NOTIFY_BEGIN()
|
|||
|
DLG_NOTIFY_END()
|
|||
|
// <20>R<EFBFBD>}<7D><><EFBFBD>h
|
|||
|
DLG_COMMAND_BEGIN()
|
|||
|
DLG_ON_COMMAND( IDOK, OnOK )
|
|||
|
DLG_ON_COMMAND( IDCANCEL, OnCancel )
|
|||
|
DLG_ON_COMMAND( IDDEFAULT, OnDefault )
|
|||
|
DLG_ON_COMMAND( IDC_GRA_PALETTE_BROWSE, OnPaletteBrowse )
|
|||
|
DLG_ON_COMMAND_NOTIFY( IDC_GRA_PALETTE_USE, BN_CLICKED, OnPaletteUseClick )
|
|||
|
DLG_ON_COMMAND_NOTIFY( IDC_GRA_NOSQUARELIST, BN_CLICKED, OnNoSquareListClick )
|
|||
|
DLG_COMMAND_END()
|
|||
|
DLG_MESSAGE_END()
|
|||
|
|
|||
|
INT CGraphicsDlg::DoModal( HWND hWndParent )
|
|||
|
{
|
|||
|
return ::DialogBoxParam( CApp::GetPlugin(), MAKEINTRESOURCE(IDD_CFG_GRAPHICS),
|
|||
|
hWndParent, g_DlgProc, (LPARAM)this );
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicsDlg::OnInitialMember()
|
|||
|
{
|
|||
|
BTNCHECK( IDC_GRA_ASPECT, Config.graphics.bAspect );
|
|||
|
BTNCHECK( IDC_GRA_ALLSPRITE, Config.graphics.bAllSprite );
|
|||
|
BTNCHECK( IDC_GRA_ALLLINE, Config.graphics.bAllLine );
|
|||
|
BTNCHECK( IDC_GRA_FPS, Config.graphics.bFPSDisp );
|
|||
|
BTNCHECK( IDC_GRA_TVFRAME, Config.graphics.bTVFrame );
|
|||
|
BTNCHECK( IDC_GRA_SCANLINE, Config.graphics.bScanline );
|
|||
|
BTNCHECK( IDC_GRA_SYNCDRAW, Config.graphics.bSyncDraw );
|
|||
|
BTNCHECK( IDC_GRA_FITZOOM, Config.graphics.bFitZoom );
|
|||
|
BTNCHECK( IDC_GRA_LEFTCLIP, Config.graphics.bLeftClip );
|
|||
|
BTNCHECK( IDC_GRA_DOUBLESIZE, Config.graphics.bDoubleSize );
|
|||
|
BTNCHECK( IDC_GRA_SYSTEMMEMORY, Config.graphics.bSystemMemory );
|
|||
|
BTNCHECK( IDC_GRA_USEHEL, Config.graphics.bUseHEL );
|
|||
|
BTNCHECK( IDC_GRA_WAITVSYNC, Config.graphics.bWindowVSync );
|
|||
|
BTNCHECK( IDC_GRA_DISKACCESSLAMP, Config.graphics.bDiskAccessLamp );
|
|||
|
BTNCHECK( IDC_GRA_NOSQUARELIST, Config.graphics.bNoSquareList );
|
|||
|
BTNCHECK( IDC_GRA_SYNCNOSLEEP, !Config.graphics.bSyncNoSleep );
|
|||
|
|
|||
|
// <20>X<EFBFBD><58><EFBFBD>C<EFBFBD>_
|
|||
|
::SendDlgItemMessage( m_hWnd, IDC_GRA_SCANLINE_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(0,100) );
|
|||
|
::SendDlgItemMessage( m_hWnd, IDC_GRA_SCANLINE_SLIDER, TBM_SETPOS, TRUE, (WPARAM)Config.graphics.nScanlineColor );
|
|||
|
::SendDlgItemMessage( m_hWnd, IDC_GRA_SCANLINE_SLIDER, TBM_SETLINESIZE, 0, 1 );
|
|||
|
::SendDlgItemMessage( m_hWnd, IDC_GRA_SCANLINE_SLIDER, TBM_SETPAGESIZE, 0, 10 );
|
|||
|
|
|||
|
// <20>X<EFBFBD>L<EFBFBD><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>J<EFBFBD><4A><EFBFBD>[<5B>l
|
|||
|
CHAR str[64];
|
|||
|
::wsprintf( str, "%d%%", Config.graphics.nScanlineColor );
|
|||
|
::SetDlgItemText( m_hWnd, IDC_GRA_SCANLINE_COLOR, str );
|
|||
|
|
|||
|
// <20>p<EFBFBD><70><EFBFBD>b<EFBFBD>g
|
|||
|
BTNCHECK( IDC_GRA_PALETTE_USE, Config.graphics.bPaletteFile );
|
|||
|
::SetDlgItemText( m_hWnd, IDC_GRA_PALETTE_EDIT, Config.graphics.szPaletteFile );
|
|||
|
|
|||
|
// <20>𑜓x<F0919C93>R<EFBFBD><52><EFBFBD>{<7B>{<7B>b<EFBFBD>N<EFBFBD>X
|
|||
|
OnUpdateComboBox();
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicsDlg::OnUpdateComboBox()
|
|||
|
{
|
|||
|
// <20>𑜓x<F0919C93>R<EFBFBD><52><EFBFBD>{<7B>{<7B>b<EFBFBD>N<EFBFBD>X
|
|||
|
::SendDlgItemMessage( m_hWnd, IDC_GRA_RESOLUTION_COMBO, CB_RESETCONTENT, 0, 0 );
|
|||
|
INT i, listno, select = 0;
|
|||
|
CHAR szMode[64];
|
|||
|
for( i = 0, listno = 0; i < DirectDraw.GetDisplayModeNum(); i++ ) {
|
|||
|
DWORD dwWidth, dwHeight, dwDepth, dwRate;
|
|||
|
DirectDraw.GetDisplayMode( i, dwWidth, dwHeight, dwDepth, dwRate );
|
|||
|
|
|||
|
if( !Config.graphics.bNoSquareList && dwWidth*3 != dwHeight*4 )
|
|||
|
continue;
|
|||
|
|
|||
|
if( Config.graphics.dwDisplayWidth == dwWidth
|
|||
|
&& Config.graphics.dwDisplayHeight == dwHeight
|
|||
|
&& Config.graphics.dwDisplayDepth == dwDepth
|
|||
|
&& Config.graphics.dwDisplayRate == dwRate ) {
|
|||
|
select = listno;
|
|||
|
}
|
|||
|
|
|||
|
::wsprintf( szMode, "%4dx%4d %dbit %dHz", dwWidth, dwHeight, dwDepth, dwRate );
|
|||
|
::SendDlgItemMessage( m_hWnd, IDC_GRA_RESOLUTION_COMBO, CB_INSERTSTRING, (WPARAM)listno, (LPARAM)szMode );
|
|||
|
::SendDlgItemMessage( m_hWnd, IDC_GRA_RESOLUTION_COMBO, CB_SETITEMDATA, (WPARAM)listno, (LPARAM)i );
|
|||
|
|
|||
|
listno++;
|
|||
|
}
|
|||
|
::SendDlgItemMessage( m_hWnd, IDC_GRA_RESOLUTION_COMBO, CB_SETCURSEL, (WPARAM)select, 0 );
|
|||
|
}
|
|||
|
|
|||
|
DLGMSG CGraphicsDlg::OnInitDialog( DLGMSGPARAM )
|
|||
|
{
|
|||
|
// DEBUGOUT( "CGraphicsDlg::OnInitDialog\n" );
|
|||
|
m_ConfigSave = Config.graphics;
|
|||
|
|
|||
|
OnInitialMember();
|
|||
|
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|
|||
|
DLGMSG CGraphicsDlg::OnHScroll( DLGMSGPARAM )
|
|||
|
{
|
|||
|
// DEBUGOUT( "CGraphicsDlg::OnHScroll\n" );
|
|||
|
|
|||
|
INT pos;
|
|||
|
CHAR str[16];
|
|||
|
::wsprintf( str, "%d%%", pos = ::SendDlgItemMessage( m_hWnd, IDC_GRA_SCANLINE_SLIDER, TBM_GETPOS, 0, 0 ) );
|
|||
|
::SetDlgItemText( m_hWnd, IDC_GRA_SCANLINE_COLOR, str );
|
|||
|
|
|||
|
// <20>X<EFBFBD>L<EFBFBD><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>J<EFBFBD><4A><EFBFBD>[<5B>̕ύX
|
|||
|
DirectDraw.SetScanlineColor( pos );
|
|||
|
// <20>p<EFBFBD><70><EFBFBD>b<EFBFBD>g<EFBFBD>e<EFBFBD>[<5B>u<EFBFBD><75><EFBFBD>̌v<CC8C>Z
|
|||
|
DirectDraw.CalcPaletteTable();
|
|||
|
|
|||
|
// <20>F<EFBFBD><46><EFBFBD>ς<EFBFBD><CF82><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂Ńy<C583>C<EFBFBD><43><EFBFBD>g<EFBFBD><67><EFBFBD>Ă<EFBFBD>
|
|||
|
::PostMessage( CApp::GetHWnd(), WM_PAINT, 0, 0 );
|
|||
|
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
|
|||
|
DLGCMD CGraphicsDlg::OnOK( DLGCMDPARAM )
|
|||
|
{
|
|||
|
// DEBUGOUT( "CGraphicsDlg::OnOK\n" );
|
|||
|
|
|||
|
Config.graphics.bAspect = IsBTNCHECK( IDC_GRA_ASPECT );
|
|||
|
Config.graphics.bAllSprite = IsBTNCHECK( IDC_GRA_ALLSPRITE );
|
|||
|
Config.graphics.bAllLine = IsBTNCHECK( IDC_GRA_ALLLINE );
|
|||
|
Config.graphics.bFPSDisp = IsBTNCHECK( IDC_GRA_FPS );
|
|||
|
Config.graphics.bTVFrame = IsBTNCHECK( IDC_GRA_TVFRAME );
|
|||
|
Config.graphics.bScanline = IsBTNCHECK( IDC_GRA_SCANLINE );
|
|||
|
Config.graphics.bSyncDraw = IsBTNCHECK( IDC_GRA_SYNCDRAW );
|
|||
|
Config.graphics.bFitZoom = IsBTNCHECK( IDC_GRA_FITZOOM );
|
|||
|
Config.graphics.bLeftClip = IsBTNCHECK( IDC_GRA_LEFTCLIP );
|
|||
|
Config.graphics.bDoubleSize = IsBTNCHECK( IDC_GRA_DOUBLESIZE );
|
|||
|
Config.graphics.bSystemMemory = IsBTNCHECK( IDC_GRA_SYSTEMMEMORY );
|
|||
|
Config.graphics.bUseHEL = IsBTNCHECK( IDC_GRA_USEHEL );
|
|||
|
Config.graphics.bWindowVSync = IsBTNCHECK( IDC_GRA_WAITVSYNC );
|
|||
|
Config.graphics.bDiskAccessLamp = IsBTNCHECK( IDC_GRA_DISKACCESSLAMP );
|
|||
|
Config.graphics.bNoSquareList = IsBTNCHECK( IDC_GRA_NOSQUARELIST );
|
|||
|
Config.graphics.bSyncNoSleep = !IsBTNCHECK( IDC_GRA_SYNCNOSLEEP );
|
|||
|
|
|||
|
Config.graphics.nScanlineColor = ::SendDlgItemMessage( m_hWnd, IDC_GRA_SCANLINE_SLIDER, TBM_GETPOS, 0, 0 );
|
|||
|
|
|||
|
INT sel = ::SendDlgItemMessage( m_hWnd, IDC_GRA_RESOLUTION_COMBO, CB_GETCURSEL, 0, 0 );
|
|||
|
INT no = ::SendDlgItemMessage( m_hWnd, IDC_GRA_RESOLUTION_COMBO, CB_GETITEMDATA, (WPARAM)sel, 0 );
|
|||
|
|
|||
|
DirectDraw.GetDisplayMode( no, Config.graphics.dwDisplayWidth,
|
|||
|
Config.graphics.dwDisplayHeight,
|
|||
|
Config.graphics.dwDisplayDepth,
|
|||
|
Config.graphics.dwDisplayRate );
|
|||
|
|
|||
|
Config.graphics.bPaletteFile = IsBTNCHECK( IDC_GRA_PALETTE_USE );
|
|||
|
::GetDlgItemText( m_hWnd, IDC_GRA_PALETTE_EDIT, Config.graphics.szPaletteFile, _MAX_PATH );
|
|||
|
|
|||
|
::EndDialog( m_hWnd, IDOK );
|
|||
|
}
|
|||
|
|
|||
|
DLGCMD CGraphicsDlg::OnCancel( DLGCMDPARAM )
|
|||
|
{
|
|||
|
// DEBUGOUT( "CGraphicsDlg::OnCancel\n" );
|
|||
|
Config.graphics = m_ConfigSave;
|
|||
|
::EndDialog( m_hWnd, IDCANCEL );
|
|||
|
}
|
|||
|
|
|||
|
DLGCMD CGraphicsDlg::OnDefault( DLGCMDPARAM )
|
|||
|
{
|
|||
|
// DEBUGOUT( "CGraphicsDlg::OnDefault\n" );
|
|||
|
Config.graphics.Default();
|
|||
|
OnInitialMember();
|
|||
|
}
|
|||
|
|
|||
|
DLGCMD CGraphicsDlg::OnPaletteBrowse( DLGCMDPARAM )
|
|||
|
{
|
|||
|
// DEBUGOUT( "CGraphicsDlg::OnPaletteBrowse\n" );
|
|||
|
|
|||
|
CHAR szTemp[ _MAX_PATH ];
|
|||
|
::GetDlgItemText( m_hWnd, IDC_GRA_PALETTE_EDIT, szTemp, _MAX_PATH );
|
|||
|
|
|||
|
CHAR szPath[ _MAX_PATH ];
|
|||
|
CHAR szFile[ _MAX_PATH ];
|
|||
|
string temp;
|
|||
|
temp = CPathlib::SplitPath( szTemp );
|
|||
|
::strcpy( szPath, temp.c_str() );
|
|||
|
temp = CPathlib::SplitFnameExt( szTemp );
|
|||
|
::strcpy( szFile, temp.c_str() );
|
|||
|
|
|||
|
OPENFILENAME ofn;
|
|||
|
ZeroMemory( &ofn, sizeof(ofn) );
|
|||
|
|
|||
|
if( strlen( szPath ) > 0 ) {
|
|||
|
// <20>ݒ<EFBFBD><DD92>ς݂Ȃ<DD82><C882>p<CE83>X<EFBFBD>^<5E>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>l<EFBFBD>[<5B><><EFBFBD>̐ݒ<CC90>
|
|||
|
ofn.lpstrInitialDir = szPath;
|
|||
|
} else {
|
|||
|
// <20><><EFBFBD>ݒ<EFBFBD><DD92>Ȃ<EFBFBD><C882>Ύ<EFBFBD><CE8E>s<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>Ɠ<EFBFBD><C693><EFBFBD><EFBFBD>p<EFBFBD>X<EFBFBD>̐ݒ<CC90>
|
|||
|
ofn.lpstrInitialDir = CApp::GetModulePath();
|
|||
|
szFile[0] = '\0';
|
|||
|
}
|
|||
|
ofn.lStructSize = sizeof(ofn);
|
|||
|
ofn.hwndOwner = m_hWnd;
|
|||
|
ofn.lpstrFile = szFile;
|
|||
|
ofn.nMaxFile = sizeof(szFile);
|
|||
|
|
|||
|
CHAR szTitle[256];
|
|||
|
CApp::LoadString( IDS_UI_OPENPALETTE, szTitle, sizeof(szTitle) );
|
|||
|
ofn.lpstrTitle = szTitle;
|
|||
|
|
|||
|
ofn.lpstrFilter = "Palette File(*.PAL)\0*.PAL\0All File(*.*)\0*.*\0";
|
|||
|
ofn.nFilterIndex = 1;
|
|||
|
ofn.Flags = OFN_READONLY|OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST;
|
|||
|
|
|||
|
if( ::GetOpenFileName( &ofn ) ) {
|
|||
|
BTNCHECK( IDC_GRA_PALETTE_USE, TRUE );
|
|||
|
::SetDlgItemText( m_hWnd, IDC_GRA_PALETTE_EDIT, szFile );
|
|||
|
|
|||
|
DirectDraw.SetPaletteFile( szFile );
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
DLGCMD CGraphicsDlg::OnPaletteUseClick( DLGCMDPARAM )
|
|||
|
{
|
|||
|
if( IsBTNCHECK(IDC_GRA_PALETTE_USE) ) {
|
|||
|
CHAR szTemp[ _MAX_PATH ];
|
|||
|
::GetDlgItemText( m_hWnd, IDC_GRA_PALETTE_EDIT, szTemp, _MAX_PATH );
|
|||
|
DirectDraw.SetPaletteFile( szTemp );
|
|||
|
} else {
|
|||
|
DirectDraw.SetPaletteTable( (LPBYTE)NULL );
|
|||
|
}
|
|||
|
|
|||
|
::PostMessage( CApp::GetHWnd(), WM_PAINT, 0, 0 );
|
|||
|
}
|
|||
|
|
|||
|
DLGCMD CGraphicsDlg::OnNoSquareListClick( DLGCMDPARAM )
|
|||
|
{
|
|||
|
Config.graphics.bNoSquareList = IsBTNCHECK( IDC_GRA_NOSQUARELIST );
|
|||
|
|
|||
|
// <20>𑜓x<F0919C93>R<EFBFBD><52><EFBFBD>{<7B>{<7B>b<EFBFBD>N<EFBFBD>X<EFBFBD>̍X<CC8D>V
|
|||
|
OnUpdateComboBox();
|
|||
|
}
|
|||
|
|