Some more code cleanups on StellaX. StellaX now launches the Stella

executable when you select 'Play' in the GUI.

Still todo are add more options to the config page, figure out why the
'Browse ROM Dir' button doesn't work, and have StellaX parse the
stella.pro file (so you can see romname, manufacturer, notes, etc).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@294 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2004-07-04 20:16:03 +00:00
parent f3fd04d5c4
commit 3496d66495
14 changed files with 186 additions and 462 deletions

View File

@ -14,12 +14,11 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: AboutPage.hxx,v 1.1 2004-06-28 23:13:54 stephena Exp $ // $Id: AboutPage.hxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
//============================================================================ //============================================================================
#ifndef ABOUTPG_H #ifndef ABOUTPG_H
#define ABOUTPG_H #define ABOUTPG_H
//FIXME#pragma once
#include "PropertySheet.hxx" #include "PropertySheet.hxx"
#include "HyperLink.hxx" #include "HyperLink.hxx"

View File

@ -6,34 +6,11 @@
#include "pch.hxx" #include "pch.hxx"
#include "BrowseForFolder.hxx" #include "BrowseForFolder.hxx"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// Construction/Destruction // Construction/Destruction
// //
#ifdef MFC
CBrowseForFolder::CBrowseForFolder(
const HWND hParent /*= NULL*/,
const LPITEMIDLIST pidl /*= NULL*/,
const int nTitleID /*= 0*/
)
{
m_hwnd = NULL;
SetOwner(hParent);
SetRoot(pidl);
SetTitle(nTitleID);
m_bi.lpfn = BrowseCallbackProc;
m_bi.lParam = reinterpret_cast<LPARAM>( this );
m_bi.pszDisplayName = m_szSelected;
}
#endif
CBrowseForFolder::CBrowseForFolder( CBrowseForFolder::CBrowseForFolder(
const HWND hParent, const HWND hParent,
const LPITEMIDLIST pidl, const LPITEMIDLIST pidl,
@ -41,20 +18,18 @@ CBrowseForFolder::CBrowseForFolder(
{ {
m_hwnd = NULL; m_hwnd = NULL;
SetOwner(hParent); myBrowseInfo.pidlRoot = pidl;
myBrowseInfo.hwndOwner = NULL;
myBrowseInfo.pszDisplayName = mySelected;
myBrowseInfo.lpszTitle = "Open ROM Folder ";
myBrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS|BIF_RETURNFSANCESTORS;
myBrowseInfo.lParam = reinterpret_cast<LPARAM>( this );
SetRoot(pidl); // myBrowseInfo.lpfn = BrowseCallbackProc;
SetTitle(strTitle);
m_bi.lpfn = BrowseCallbackProc;
m_bi.lParam = reinterpret_cast<LPARAM>( this );
m_bi.pszDisplayName = m_szSelected;
} }
CBrowseForFolder::~CBrowseForFolder() CBrowseForFolder::~CBrowseForFolder()
{ {
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -67,7 +42,7 @@ void CBrowseForFolder::SetOwner(const HWND hwndOwner)
if (m_hwnd != NULL) if (m_hwnd != NULL)
return; return;
m_bi.hwndOwner = hwndOwner; myBrowseInfo.hwndOwner = hwndOwner;
} }
void CBrowseForFolder::SetRoot(const LPITEMIDLIST pidl) void CBrowseForFolder::SetRoot(const LPITEMIDLIST pidl)
@ -75,12 +50,12 @@ void CBrowseForFolder::SetRoot(const LPITEMIDLIST pidl)
if (m_hwnd != NULL) if (m_hwnd != NULL)
return; return;
m_bi.pidlRoot = pidl; myBrowseInfo.pidlRoot = pidl;
} }
LPCTSTR CBrowseForFolder::GetTitle() const LPCTSTR CBrowseForFolder::GetTitle() const
{ {
return m_bi.lpszTitle; return myBrowseInfo.lpszTitle;
} }
bool CBrowseForFolder::SetTitle( bool CBrowseForFolder::SetTitle(
@ -100,40 +75,24 @@ bool CBrowseForFolder::SetTitle(
return false; return false;
} }
m_bi.lpszTitle = m_pchTitle.Get(); myBrowseInfo.lpszTitle = m_pchTitle.Get();
return true; return true;
} }
#ifdef MFC
bool CBrowseForFolder::SetTitle(const int nTitle)
{
if (nTitle <= 0)
return false;
CString strTitle;
if(!strTitle.LoadString(static_cast(nTitle)))
{
return false;
}
SetTitle(strTitle);
return true;
}
#endif
void CBrowseForFolder::SetFlags(const UINT ulFlags) void CBrowseForFolder::SetFlags(const UINT ulFlags)
{ {
if (m_hwnd != NULL) if (m_hwnd != NULL)
return; return;
m_bi.ulFlags = ulFlags; myBrowseInfo.ulFlags = ulFlags;
} }
LPCTSTR CBrowseForFolder::GetSelectedFolder( LPCTSTR CBrowseForFolder::GetSelectedFolder(
void void
) const ) const
{ {
return m_szSelected; return mySelected;
} }
bool CBrowseForFolder::SelectFolder() bool CBrowseForFolder::SelectFolder()
@ -141,13 +100,13 @@ bool CBrowseForFolder::SelectFolder()
bool bRet = false; bool bRet = false;
LPITEMIDLIST pidl; LPITEMIDLIST pidl;
if ((pidl = ::SHBrowseForFolder(&m_bi)) != NULL) if ((pidl = ::SHBrowseForFolder(&myBrowseInfo)) != NULL)
{ {
m_strPath.Set( _T("") ); myPath.Set( _T("") );
if (SUCCEEDED(::SHGetPathFromIDList(pidl, m_szSelected))) if (SUCCEEDED(::SHGetPathFromIDList(pidl, mySelected)))
{ {
bRet = true; bRet = true;
m_strPath.Set( m_szSelected ); myPath.Set( mySelected );
} }
LPMALLOC pMalloc; LPMALLOC pMalloc;

View File

@ -6,12 +6,8 @@
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#ifndef __SHELLBROWSER_H__ #ifndef __BROWSE_FOR_FOLDER_
#define __SHELLBROWSER_H__ #define __BROWSE_FOR_FOLDER_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <shlobj.h> #include <shlobj.h>
@ -23,12 +19,6 @@
class CBrowseForFolder class CBrowseForFolder
{ {
public: public:
#ifdef MFC
CBrowseForFolder(const HWND hParent = NULL,
const LPITEMIDLIST pidl = NULL,
const int nTitleID = 0);
#endif
CBrowseForFolder(const HWND hParent = NULL, CBrowseForFolder(const HWND hParent = NULL,
const LPITEMIDLIST pidl = NULL, const LPITEMIDLIST pidl = NULL,
LPCTSTR strTitle = NULL ); LPCTSTR strTitle = NULL );
@ -56,9 +46,6 @@ public:
// //
LPCTSTR GetTitle() const; LPCTSTR GetTitle() const;
bool SetTitle(LPCTSTR strTitle); bool SetTitle(LPCTSTR strTitle);
#ifdef MFC
bool SetTitle(const int nTitle);
#endif
// //
// ulFlags = Value specifying the types of folders to be listed in the dialog box // ulFlags = Value specifying the types of folders to be listed in the dialog box
@ -156,20 +143,20 @@ private:
CSimpleString m_pchTitle; CSimpleString m_pchTitle;
BROWSEINFO m_bi; BROWSEINFO myBrowseInfo;
char m_szSelected[MAX_PATH]; char mySelected[MAX_PATH];
CSimpleString m_strPath; CSimpleString myPath;
HWND m_hwnd; HWND m_hwnd;
}; };
inline UINT CBrowseForFolder::GetFlags() const inline UINT CBrowseForFolder::GetFlags() const
{ {
return m_bi.ulFlags; return myBrowseInfo.ulFlags;
} }
inline int CBrowseForFolder::GetImage() const inline int CBrowseForFolder::GetImage() const
{ {
return m_bi.iImage; return myBrowseInfo.iImage;
} }
#endif // __SHELLBROWSER_H__ #endif

View File

@ -14,7 +14,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: ConfigPage.cxx,v 1.1 2004-06-28 23:13:54 stephena Exp $ // $Id: ConfigPage.cxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
//============================================================================ //============================================================================
#include "pch.hxx" #include "pch.hxx"
@ -155,9 +155,9 @@ BOOL CConfigPage::OnCommand( WORD wNotifyCode, WORD wID, HWND hwndCtl )
if ( wID == IDC_BROWSE ) if ( wID == IDC_BROWSE )
{ {
CBrowseForFolder bff( m_hwnd ); CBrowseForFolder bff( m_hwnd );
bff.SetFlags( BIF_RETURNONLYFSDIRS );
if ( bff.SelectFolder() ) if ( bff.SelectFolder() )
::SetDlgItemText( m_hwnd, IDC_ROMPATH, bff.GetSelectedFolder() ); ;
// ::SetDlgItemText( m_hwnd, IDC_ROMPATH, bff.GetSelectedFolder() );
} }
return FALSE; return FALSE;

View File

@ -14,7 +14,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: GlobalData.cxx,v 1.1 2004-06-28 23:13:54 stephena Exp $ // $Id: GlobalData.cxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
//============================================================================ //============================================================================
#include "pch.hxx" #include "pch.hxx"
@ -30,6 +30,7 @@ CGlobalData::CGlobalData( HINSTANCE hInstance )
{ {
myPathName[0] = _T('\0'); myPathName[0] = _T('\0');
mySettings = new SettingsWin32(); mySettings = new SettingsWin32();
mySettings->loadConfig();
} }
CGlobalData::~CGlobalData() CGlobalData::~CGlobalData()

View File

@ -14,7 +14,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: MainDlg.cxx,v 1.1 2004-06-28 23:13:54 stephena Exp $ // $Id: MainDlg.cxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
//============================================================================ //============================================================================
#include "pch.hxx" #include "pch.hxx"
@ -176,14 +176,6 @@ BOOL CMainDlg::OnInitDialog( void )
HWND hwnd = *this; HWND hwnd = *this;
dwRet = m_stella.Initialize();
if ( dwRet != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwRet, _T("CStellaX::Initialize") );
SendMessage( hwnd, WM_CLOSE, 0, 0 );
return FALSE;
}
// Set dialog icon // Set dialog icon
HICON hicon = ::LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_APP)); HICON hicon = ::LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_APP));
::SendMessage( hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon ); ::SendMessage( hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon );
@ -309,17 +301,9 @@ BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
TCHAR pszPathName[ MAX_PATH + 1 ]; TCHAR pszPathName[ MAX_PATH + 1 ];
lstrcpy( pszPathName, myGlobalData.settings().getString("romdir").c_str() ); lstrcpy( pszPathName, myGlobalData.settings().getString("romdir").c_str() );
lstrcat( pszPathName, _T("\\") ); lstrcat( pszPathName, _T("\\") );
lstrcat( pszPathName, lstrcat( pszPathName, pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
// Play the game! (void)m_stella.PlayROM( pszPathName, myGlobalData );
::EnableWindow( hwnd, FALSE );
(void)m_stella.PlayROM( hwnd, pszPathName,
pListData->GetTextForColumn( CListData::NAME_COLUMN ),
myGlobalData );
::EnableWindow( hwnd, TRUE );
// Set focus back to the rom list // Set focus back to the rom list
::SetFocus( m_hwndList ); ::SetFocus( m_hwndList );
@ -474,147 +458,103 @@ HBRUSH CMainDlg::OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DWORD CMainDlg::PopulateRomList( void ) DWORD CMainDlg::PopulateRomList( void )
{ {
TRACE("CMainDlg::PopulateRomList");
DWORD dwRet; DWORD dwRet;
ClearList();
#ifdef _DEBUG // REVIEW: Support .zip files?
DWORD dwStartTick = ::GetTickCount(); TCHAR pszPath[ MAX_PATH ];
#endif
ClearList(); lstrcpy( pszPath, myGlobalData.settings().getString("romdir").c_str() );
lstrcat( pszPath, _T("\\*.bin") );
// REVIEW: Support .zip files? WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile( pszPath, &ffd );
TCHAR pszPath[ MAX_PATH ]; ListView_SetItemCount( m_hwndList, 100 );
lstrcpy( pszPath, myGlobalData.settings().getString("romdir").c_str() ); int iItem = 0;
lstrcat( pszPath, _T("\\*.bin") ); BOOL fDone = (hFind == INVALID_HANDLE_VALUE);
while(!fDone)
{
// File metadata will be read in ReadRomData()
CListData* pListData = new CListData;
if( pListData == NULL )
return ERROR_NOT_ENOUGH_MEMORY;
WIN32_FIND_DATA ffd; dwRet = pListData->Initialize();
HANDLE hFind = FindFirstFile( pszPath, &ffd ); if( dwRet != ERROR_SUCCESS )
return dwRet;
ListView_SetItemCount( m_hwndList, 100 ); if ( !pListData->m_strFileName.Set( ffd.cFileName ) )
return FALSE;
int iItem = 0; LV_ITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iItem = iItem++;
lvi.iSubItem = 0;
lvi.pszText = LPSTR_TEXTCALLBACK;
lvi.lParam = (LPARAM)pListData;
int nItem = ListView_InsertItem( m_hwndList, &lvi );
BOOL fDone = (hFind == INVALID_HANDLE_VALUE); ASSERT( nItem != -1 );
while (!fDone)
{
//
// File metadata will be read in ReadRomData()
//
CListData* pListData = new CListData; ListView_SetItemText( m_hwndList, nItem,
if( pListData == NULL ) CListData::FILENAME_COLUMN, LPSTR_TEXTCALLBACK );
{ ListView_SetItemText(m_hwndList, nItem,
return ERROR_NOT_ENOUGH_MEMORY; CListData::MANUFACTURER_COLUMN, LPSTR_TEXTCALLBACK);
} ListView_SetItemText( m_hwndList, nItem,
CListData::RARITY_COLUMN, LPSTR_TEXTCALLBACK );
dwRet = pListData->Initialize(); // go to the next rom file
if ( dwRet != ERROR_SUCCESS ) fDone = !FindNextFile(hFind, &ffd);
{ }
return dwRet;
}
if ( ! pListData->m_strFileName.Set( ffd.cFileName ) ) if( hFind != INVALID_HANDLE_VALUE )
{ VERIFY( ::FindClose( hFind ) );
return FALSE;
}
LV_ITEM lvi; return ERROR_SUCCESS;
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iItem = iItem++;
lvi.iSubItem = 0;
lvi.pszText = LPSTR_TEXTCALLBACK;
lvi.lParam = (LPARAM)pListData;
int nItem = ListView_InsertItem( m_hwndList, &lvi );
ASSERT( nItem != -1 );
ListView_SetItemText( m_hwndList, nItem,
CListData::FILENAME_COLUMN, LPSTR_TEXTCALLBACK );
ListView_SetItemText(m_hwndList, nItem,
CListData::MANUFACTURER_COLUMN, LPSTR_TEXTCALLBACK);
ListView_SetItemText( m_hwndList, nItem,
CListData::RARITY_COLUMN, LPSTR_TEXTCALLBACK );
// go to the next rom file
fDone = !FindNextFile(hFind, &ffd);
}
if ( hFind != INVALID_HANDLE_VALUE )
{
VERIFY( ::FindClose( hFind ) );
}
#ifdef _DEBUG
TRACE("\tElapsed ticks for PopulateRomList = %ld", ::GetTickCount()-dwStartTick);
#endif
return ERROR_SUCCESS;
} }
DWORD CMainDlg::ReadRomData( DWORD CMainDlg::ReadRomData(CListData* pListData) const
CListData* pListData
) const
{ {
// Add stella binary output for stella.pro info
// There should be no parsing of stella.pro in this application
// FIXME
/* /*
// TODO: Move this method to ListData class (?)
// TODO: Move this method to ListData class (?) if( pListData == NULL )
{
ASSERT( FALSE );
return ERROR_BAD_ARGUMENTS;
}
if ( pListData == NULL ) // attempt to read the rom file
{ TCHAR pszPath[MAX_PATH + 1];
ASSERT( FALSE ); lstrcpy( pszPath, myGlobalData.settings().getString("romdir").c_str() );
return ERROR_BAD_ARGUMENTS; lstrcat( pszPath, _T("\\") );
} lstrcat( pszPath, pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
// attempt to read the rom file HANDLE hFile;
hFile = CreateFile( pszPath,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL );
if(hFile == INVALID_HANDLE_VALUE)
return GetLastError();
TCHAR pszPath[MAX_PATH + 1]; DWORD dwFileSize = ::GetFileSize( hFile, NULL );
BYTE* pImage = new BYTE[dwFileSize];
lstrcpy( pszPath, myGlobalData.RomDir() ); if( pImage == NULL )
lstrcat( pszPath, _T("\\") ); return ERROR_NOT_ENOUGH_MEMORY;
lstrcat( pszPath, pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
HANDLE hFile;
hFile = CreateFile( pszPath, DWORD dwRead;
GENERIC_READ, if( ::ReadFile( hFile, pImage, dwFileSize, &dwRead, NULL ) )
FILE_SHARE_READ, {
NULL, // Read the file, now check the md5
OPEN_EXISTING, std::string md5 = MD5( pImage, dwFileSize );
FILE_ATTRIBUTE_NORMAL,
NULL );
if (hFile == INVALID_HANDLE_VALUE)
{
return GetLastError();
}
DWORD dwFileSize = ::GetFileSize( hFile, NULL );
BYTE* pImage = new BYTE[dwFileSize];
if ( pImage == NULL )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
DWORD dwRead;
if ( ::ReadFile( hFile, pImage, dwFileSize, &dwRead, NULL ) )
{
// Read the file, now check the md5
std::string md5 = MD5( pImage, dwFileSize ); // search through the properties set for this MD5
PropertiesSet& propertiesSet = m_stella.GetPropertiesSet();
// search through the properties set for this MD5
PropertiesSet& propertiesSet = m_stella.GetPropertiesSet();
uInt32 setSize = propertiesSet.size(); uInt32 setSize = propertiesSet.size();
@ -729,34 +669,22 @@ void CMainDlg::OnItemChanged(
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// LPSTR_TEXTCALLBACK message handlers // LPSTR_TEXTCALLBACK message handlers
void CMainDlg::OnGetDispInfo(NMLVDISPINFO* pnmv)
void CMainDlg::OnGetDispInfo(
NMLVDISPINFO* pnmv
)
{ {
// Provide the item or subitem's text, if requested. // Provide the item or subitem's text, if requested.
if( !(pnmv->item.mask & LVIF_TEXT ) )
return;
if ( ! (pnmv->item.mask & LVIF_TEXT ) ) CListData* pListData = (CListData*)
{ ListView_GetItemData( pnmv->hdr.hwndFrom, pnmv->item.iItem );
return; ASSERT( pListData );
} if( pListData == NULL )
return;
CListData* pListData = (CListData*)ListView_GetItemData( if( !pListData->IsPopulated() )
pnmv->hdr.hwndFrom, ReadRomData( pListData );
pnmv->item.iItem );
ASSERT( pListData );
if ( pListData == NULL )
{
return;
}
if ( ! pListData->IsPopulated() ) pnmv->item.pszText = const_cast<LPTSTR>( pListData->GetTextForColumn(pnmv->item.iSubItem) );
{
ReadRomData( pListData );
}
pnmv->item.pszText = const_cast<LPTSTR>( pListData->GetTextForColumn(pnmv->item.iSubItem) );
// ASSERT( pnmv->item.pszText );
} }
int CALLBACK CMainDlg::ListViewCompareFunc( int CALLBACK CMainDlg::ListViewCompareFunc(

Binary file not shown.

View File

@ -80,7 +80,7 @@ BEGIN
VALUE "FileDescription", "StellaX" VALUE "FileDescription", "StellaX"
VALUE "FileVersion", "1, 4, 0, 0" VALUE "FileVersion", "1, 4, 0, 0"
VALUE "InternalName", "StellaX" VALUE "InternalName", "StellaX"
VALUE "LegalCopyright", "Copyright (C) 2004 Jeff Miller, Copyright (C) 2004 Stephen Anthony" VALUE "LegalCopyright", "Copyright (C) 2000 Jeff Miller, Copyright (C) 2004 Stephen Anthony"
VALUE "LegalTrademarks", "n/a" VALUE "LegalTrademarks", "n/a"
VALUE "OriginalFilename", "StellaX.exe" VALUE "OriginalFilename", "StellaX.exe"
VALUE "PrivateBuild", "n/a" VALUE "PrivateBuild", "n/a"
@ -134,17 +134,6 @@ BEGIN
LTEXT "Game notes (if available):",-1,7,205,98,8 LTEXT "Game notes (if available):",-1,7,205,98,8
END END
IDD_DOC_PAGE DIALOG 0, 0, 390, 196
STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Documentation"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "To view the online documentation, you need to first install Adobe Acrobat Reader 4.0 software. Once you have done this, return to this page and you will be able to read the documentation.",
IDC_INSTRUCTIONS,7,7,376,21,NOT WS_VISIBLE
LTEXT "Click here to download the Adobe Acrobat Reader software",
IDC_ADOBE,7,35,376,10,SS_NOTIFY | NOT WS_VISIBLE
END
IDD_ABOUT_PAGE DIALOGEX 0, 0, 298, 136 IDD_ABOUT_PAGE DIALOGEX 0, 0, 298, 136
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Information" CAPTION "Information"
@ -220,14 +209,6 @@ BEGIN
BOTTOMMARGIN, 242 BOTTOMMARGIN, 242
END END
IDD_DOC_PAGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 383
TOPMARGIN, 7
BOTTOMMARGIN, 189
END
IDD_ABOUT_PAGE, DIALOG IDD_ABOUT_PAGE, DIALOG
BEGIN BEGIN
LEFTMARGIN, 7 LEFTMARGIN, 7

View File

@ -129,9 +129,6 @@
<File <File
RelativePath=".\debug.cxx"> RelativePath=".\debug.cxx">
</File> </File>
<File
RelativePath=".\FileDialog.cxx">
</File>
<File <File
RelativePath=".\GlobalData.cxx"> RelativePath=".\GlobalData.cxx">
</File> </File>
@ -191,9 +188,6 @@
<File <File
RelativePath=".\debug.hxx"> RelativePath=".\debug.hxx">
</File> </File>
<File
RelativePath=".\FileDialog.hxx">
</File>
<File <File
RelativePath=".\GlobalData.hxx"> RelativePath=".\GlobalData.hxx">
</File> </File>

View File

@ -1,183 +1,62 @@
// //============================================================================
// StellaX //
// Jeff Miller 05/13/2000 // SSSS tt lll lll
// // SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2000 by Jeff Miller
// Copyright (c) 2004 by Stephen Anthony
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: StellaXMain.cxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
//============================================================================
#include <iostream> #include <iostream>
#include <strstream> #include <sstream>
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <windows.h>
#include <shellapi.h>
#include "resource.h" #include "resource.h"
#include "GlobalData.hxx" #include "GlobalData.hxx"
#include "Settings.hxx"
#include "pch.hxx" #include "pch.hxx"
#include "StellaXMain.hxx" #include "StellaXMain.hxx"
//
// CStellaXMain // CStellaXMain
//
// equivalent to main() in the DOS version of stella // equivalent to main() in the DOS version of stella
//
CStellaXMain::CStellaXMain()
CStellaXMain::CStellaXMain(
) : \
m_pPropertiesSet( NULL )
{ {
TRACE( "CStellaXMain::CStellaXMain" );
} }
CStellaXMain::~CStellaXMain( CStellaXMain::~CStellaXMain()
)
{ {
TRACE( "CStellaXMain::~CStellaXMain" );
} }
DWORD CStellaXMain::Initialize( void CStellaXMain::PlayROM( LPCTSTR filename, CGlobalData& globaldata )
void
)
{ {
return ERROR_SUCCESS; string rom = filename;
}
// Make sure the specfied ROM exists
HRESULT CStellaXMain::PlayROM( if(!globaldata.settings().fileExists(filename))
HWND hwnd, {
LPCTSTR pszPathName, ostringstream out;
LPCTSTR pszFriendlyName, out << "\"" << rom << "\" doesn't exist";
CGlobalData& rGlobalData
) MessageBox( NULL, out.str().c_str(), "Unknown ROM", MB_ICONEXCLAMATION|MB_OK);
{ return;
UNUSED_ALWAYS( hwnd ); }
HRESULT hr = S_OK; // Assume that the ROM file does exist, attempt to run external Stella
// Since all settings are saved to the stella.ini file, we don't need
TRACE("CStellaXMain::PlayROM"); // to pass any arguments here ...
ShellExecute(NULL, "open", "stella.exe", rom.c_str(), NULL, 0);
//
// show wait cursor while loading
//
HCURSOR hcur = ::SetCursor( ::LoadCursor( NULL, IDC_WAIT ) );
//
// setup objects used here
//
BYTE* pImage = NULL;
LPCTSTR pszFileName = NULL;
//
// Load the rom file
//
HANDLE hFile;
DWORD dwImageSize;
hFile = ::CreateFile( pszPathName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL );
if (hFile == INVALID_HANDLE_VALUE)
{
HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hwnd, GWL_HINSTANCE );
DWORD dwLastError = ::GetLastError();
TCHAR pszCurrentDirectory[ MAX_PATH + 1 ];
::GetCurrentDirectory( MAX_PATH, pszCurrentDirectory );
// ::MessageBoxFromGetLastError( pszPathName );
TCHAR pszFormat[ 1024 ];
LoadString( hInstance,
IDS_ROM_LOAD_FAILED,
pszFormat, 1023 );
LPTSTR pszLastError = NULL;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwLastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&pszLastError,
0,
NULL);
TCHAR pszError[ 1024 ];
wsprintf( pszError,
pszFormat,
pszCurrentDirectory,
pszPathName,
dwLastError,
pszLastError );
::MessageBox( hwnd,
pszError,
_T("Error"),
MB_OK | MB_ICONEXCLAMATION );
::LocalFree( pszLastError );
hr = HRESULT_FROM_WIN32( ::GetLastError() );
goto exit;
}
dwImageSize = ::GetFileSize( hFile, NULL );
pImage = new BYTE[dwImageSize + 1];
if ( pImage == NULL )
{
hr = E_OUTOFMEMORY;
goto exit;
}
DWORD dwActualSize;
if ( ! ::ReadFile( hFile, pImage, dwImageSize, &dwActualSize, NULL ) )
{
VERIFY( ::CloseHandle( hFile ) );
MessageBoxFromGetLastError( pszPathName );
hr = HRESULT_FROM_WIN32( ::GetLastError() );
goto exit;
}
VERIFY( ::CloseHandle(hFile) );
//
// get just the filename
//
pszFileName = _tcsrchr( pszPathName, _T('\\') );
if ( pszFileName )
{
++pszFileName;
}
else
{
pszFileName = pszPathName;
}
// restore cursor
::SetCursor( hcur );
hcur = NULL;
::ShowWindow( hwnd, SW_HIDE );
// launch game here
::ShowWindow( hwnd, SW_SHOW );
exit:
if ( hcur )
{
::SetCursor( hcur );
}
return hr;
} }

View File

@ -1,41 +1,38 @@
// //============================================================================
// StellaX //
// Jeff Miller 05/12/2000 // SSSS tt lll lll
// // SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2000 by Jeff Miller
// Copyright (c) 2004 by Stephen Anthony
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: StellaXMain.hxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
//============================================================================
#ifndef STELLAX_H #ifndef STELLAX_H
#define STELLAX_H #define STELLAX_H
#pragma once
class PropertiesSet;
class CGlobalData; class CGlobalData;
class CStellaXMain class CStellaXMain
{ {
public: public:
CStellaXMain(); CStellaXMain();
~CStellaXMain(); ~CStellaXMain();
DWORD Initialize( void ); void PlayROM( LPCTSTR filename, CGlobalData& globaldata );
HRESULT PlayROM( HWND hwnd, LPCTSTR ctszPathName, private:
LPCTSTR pszFriendlyName, CStellaXMain( const CStellaXMain& ); // no implementation
CGlobalData& rGlobalData ); void operator=( const CStellaXMain& ); // no implementation
PropertiesSet& GetPropertiesSet() const;
private:
PropertiesSet* m_pPropertiesSet;
CStellaXMain( const CStellaXMain& ); // no implementation
void operator=( const CStellaXMain& ); // no implementation
}; };
inline PropertiesSet& CStellaXMain::GetPropertiesSet(
void
) const
{
return *m_pPropertiesSet;
}
#endif #endif

View File

@ -7,7 +7,6 @@
#define IDD_ABOUT 103 #define IDD_ABOUT 103
#define IDD_MAIN 104 #define IDD_MAIN 104
#define IDD_ABOUT_PAGE 106 #define IDD_ABOUT_PAGE 106
#define IDD_DOC_PAGE 107
#define IDD_CONFIG_PAGE 108 #define IDD_CONFIG_PAGE 108
#define IDS_ALREADYRUNNING 200 #define IDS_ALREADYRUNNING 200
#define IDS_BADARGUMENT 201 #define IDS_BADARGUMENT 201

Binary file not shown.

Binary file not shown.