From 73f7325e93b27e71bc77d20654230f100dd6370c Mon Sep 17 00:00:00 2001 From: spacy51 Date: Wed, 9 Jan 2008 22:58:05 +0000 Subject: [PATCH] forgot to add these files git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@280 a31d4220-a93d-0410-bf67-fe4944624d44 --- res/todo.txt | 6 +-- src/win32/BIOSDialog.cpp | 107 +++++++++++++++++++++++++++++++++++++++ src/win32/BIOSDialog.h | 34 +++++++++++++ 3 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 src/win32/BIOSDialog.cpp create mode 100644 src/win32/BIOSDialog.h diff --git a/res/todo.txt b/res/todo.txt index 371cf31d..47ba78af 100644 --- a/res/todo.txt +++ b/res/todo.txt @@ -1,9 +1,9 @@ Important: -- Many games show emulation warnings in the log window (unaligned read, bad read/write addresse) - - Metroid Fusion, Advance Wars 2... +- Many games show emulation warnings in the log window (unaligned read, bad read/write address) + - Test: Metroid Fusion, Advance Wars 2 - Gfx.cpp/h optimization - - Test: final fantasy 4 airship intro + - Test: Final Fantasy 4 airship intro - Improve automatic 64k/128k flash save detection diff --git a/src/win32/BIOSDialog.cpp b/src/win32/BIOSDialog.cpp new file mode 100644 index 00000000..f710e415 --- /dev/null +++ b/src/win32/BIOSDialog.cpp @@ -0,0 +1,107 @@ +#include "stdafx.h" +#include "BIOSDialog.h" + + +// BIOSDialog dialog + +IMPLEMENT_DYNAMIC(BIOSDialog, CDialog) + +BIOSDialog::BIOSDialog(CWnd* pParent /*=NULL*/) + : CDialog(BIOSDialog::IDD, pParent) + , m_enableBIOS_GB(FALSE) + , m_enableBIOS_GBA(FALSE) + , m_skipLogo(FALSE) + , m_pathGB(_T("")) + , m_pathGBA(_T("")) +{ +} + +BIOSDialog::~BIOSDialog() +{ +} + +void BIOSDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Check(pDX, IDC_ENABLE_GB_BIOS, m_enableBIOS_GB); + DDX_Check(pDX, IDC_ENABLE_GBA_BIOS, m_enableBIOS_GBA); + DDX_Check(pDX, IDC_SKIP_BOOT_LOGO, m_skipLogo); + DDX_Text(pDX, IDC_GB_BIOS_PATH, m_pathGB); + DDX_Text(pDX, IDC_GBA_BIOS_PATH, m_pathGBA); + DDX_Control(pDX, IDC_GB_BIOS_PATH, m_editGB); + DDX_Control(pDX, IDC_GBA_BIOS_PATH, m_editGBA); + + if( pDX->m_bSaveAndValidate == TRUE ) { + // disable BIOS usage when it does not exist + if( !fileExists( m_pathGBA ) ) { + m_enableBIOS_GBA = FALSE; + } + if( !fileExists( m_pathGB ) ) { + m_enableBIOS_GB = FALSE; + } + } +} + + +BEGIN_MESSAGE_MAP(BIOSDialog, CDialog) + ON_BN_CLICKED(IDC_SELECT_GB_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbBiosPath) + ON_BN_CLICKED(IDC_SELECT_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath) +END_MESSAGE_MAP() + + +// BIOSDialog message handlers + +void BIOSDialog::OnBnClickedSelectGbBiosPath() +{ + CString current; + m_editGB.GetWindowText( current ); + if( !fileExists( current ) ) { + current = _T(""); + } + + CFileDialog dlg( + TRUE, + NULL, + current, + OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST, + _T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"), + this, + 0 ); + + if( IDOK == dlg.DoModal() ) { + m_editGB.SetWindowText( dlg.GetPathName() ); + } +} + +void BIOSDialog::OnBnClickedSelectGbaBiosPath() +{ + CString current; + m_editGBA.GetWindowText( current ); + if( !fileExists( current ) ) { + current = _T(""); + } + + CFileDialog dlg( + TRUE, + NULL, + current, + OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST, + _T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"), + this, + 0 ); + + if( IDOK == dlg.DoModal() ) { + m_editGBA.SetWindowText( dlg.GetPathName() ); + } +} + +bool BIOSDialog::fileExists(CString& file) +{ + CFileStatus stat; + BOOL retVal = CFile::GetStatus( file, stat ); + bool noFile = false; + if( retVal == TRUE ) { + noFile |= ( stat.m_attribute & CFile::directory ) != 0; + } + return ( retVal == TRUE ) && !noFile; +} diff --git a/src/win32/BIOSDialog.h b/src/win32/BIOSDialog.h new file mode 100644 index 00000000..396693a8 --- /dev/null +++ b/src/win32/BIOSDialog.h @@ -0,0 +1,34 @@ +#pragma once +#include "afxwin.h" + + +// BIOSDialog dialog + +class BIOSDialog : public CDialog +{ + DECLARE_DYNAMIC(BIOSDialog) + +public: + BIOSDialog(CWnd* pParent = NULL); // standard constructor + virtual ~BIOSDialog(); + +// Dialog Data + enum { IDD = IDD_BIOS }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +private: + CEdit m_editGB; + CEdit m_editGBA; + bool fileExists(CString& file); + afx_msg void OnBnClickedSelectGbBiosPath(); + afx_msg void OnBnClickedSelectGbaBiosPath(); +public: + BOOL m_enableBIOS_GB; + BOOL m_enableBIOS_GBA; + BOOL m_skipLogo; + CString m_pathGB; + CString m_pathGBA; +};