StellaX now loads metadata from the stella.pro file (Filename,

Manufacturer, Rarity, Note, etc).

Since the loading of the metadata is slow, I added a cachefile
for the gamelist (named 'stellax.cache').  If this file is present,
the gamelist is created based on the contents of the cachefile.
This is quite fast, since no stella.pro parsing or ROM loading
is done.  The cache file is recreated each time a full reload is
done.

Pressing the 'Reload' button always forces a full reload (not from
cache), so this is useful if you change the ROM directory (or add
ROMs).  Still TODO is add a check to see if the ROM dir has had
any files added to it since last time you ran StellaX, and do a
full reload.

Got rid of the filename field in the game listview.  Now only show
'Cartridge Name', 'Cartridge Manufacturer' and 'Cartridge Rarity'.
If some game doesn't have an entry in the stella.pro file, its
filename will be shown as cartridge name.

Still TODO are add sorting/permanent resizing options to the column
headers in the listview, and add options to the Config Page.  It's
getting close, folks.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@300 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2004-07-10 22:25:58 +00:00
parent 287bf03829
commit 6b644925cc
16 changed files with 453 additions and 566 deletions

View File

@ -13,7 +13,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: makefile,v 1.54 2004-06-28 02:06:21 stephena Exp $ ## $Id: makefile,v 1.55 2004-07-10 22:25:57 stephena Exp $
##============================================================================ ##============================================================================
##============================================================================ ##============================================================================
@ -25,7 +25,7 @@
### add your own compiler optimizations here ### add your own compiler optimizations here
### if none are provided, the defaults will be used ### if none are provided, the defaults will be used
OPTIMIZATIONS = OPTIMIZATIONS = -O2 -march=i586
### to include joystick support ### to include joystick support
JOYSTICK_SUPPORT = 1 JOYSTICK_SUPPORT = 1

View File

@ -0,0 +1,35 @@
//============================================================================
//
// 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) 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: Game.cxx,v 1.1 2004-07-10 22:25:58 stephena Exp $
//============================================================================
#include "Game.hxx"
Game::Game( void )
{
_available = false;
_rom = " ";
_md5 = " ";
_name = " ";
_rarity = " ";
_manufacturer = " ";
_note = " ";
}
Game::~Game( void )
{
}

View File

@ -0,0 +1,76 @@
//============================================================================
//
// 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) 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: Game.hxx,v 1.1 2004-07-10 22:25:58 stephena Exp $
//============================================================================
#ifndef GAME_H
#define GAME_H
#include "bspf.hxx"
/** Hold game info for an Atari2600 game. */
class Game
{
public:
Game( void );
~Game( void );
/** sets the rom of a game */
void setAvailable( bool available ) { _available = available; }
/** returns the rom of a game */
bool isAvailable( void ) { return _available; }
/** sets the rom of a game */
void setRom( const string& rom ) { _rom = rom; };
/** returns the rom of a game */
string rom( void ) const { return _rom; }
/** sets the md5 sum of a game */
void setMd5( const string& md5 ) { _md5 = md5; };
/** returns the md5 sum of a game */
string md5( void ) const { return _md5; }
/** sets the name of a game */
void setName( const string& name ) { _name = name; }
/** returns the name of a game */
string name( void ) const { return _name; }
/** sets the rarity of a game */
void setRarity( const string& rarity ) { _rarity = rarity; }
/** returns the rarity of a game */
string rarity( void ) const { return _rarity; }
/** sets the manufacturer of a game */
void setManufacturer( const string& manufacturer) { _manufacturer = manufacturer; }
/** returns the manufacturer of a game */
string manufacturer( void ) const { return _manufacturer; }
/** sets the note of a game */
void setNote( const string& note ) { _note = note; }
/** returns the note of a game */
string note( void ) const { return _note; }
protected:
bool _available;
string _rom;
string _md5;
string _name;
string _rarity;
string _manufacturer;
string _note;
};
#endif

View File

@ -14,21 +14,22 @@
// 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.2 2004-07-04 20:16:03 stephena Exp $ // $Id: GlobalData.cxx,v 1.3 2004-07-10 22:25:58 stephena Exp $
//============================================================================ //============================================================================
#include "pch.hxx" #include "pch.hxx"
#include "resource.h" #include "resource.h"
#include "bspf.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "SettingsWin32.hxx" #include "SettingsWin32.hxx"
#include "GlobalData.hxx" #include "GlobalData.hxx"
CGlobalData::CGlobalData( HINSTANCE hInstance ) CGlobalData::CGlobalData( HINSTANCE hInstance )
: myInstance(hInstance) : mySettings(0),
myInstance(hInstance)
{ {
myPathName[0] = _T('\0');
mySettings = new SettingsWin32(); mySettings = new SettingsWin32();
mySettings->loadConfig(); mySettings->loadConfig();
} }

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.hxx,v 1.1 2004-06-28 23:13:54 stephena Exp $ // $Id: GlobalData.hxx,v 1.2 2004-07-10 22:25:58 stephena Exp $
//============================================================================ //============================================================================
#ifndef GLOBAL_DATA_HXX #ifndef GLOBAL_DATA_HXX
@ -34,14 +34,6 @@ class CGlobalData
CGlobalData( HINSTANCE hInstance ); CGlobalData( HINSTANCE hInstance );
~CGlobalData( void ); ~CGlobalData( void );
LPCTSTR PathName( void ) const
{
if ( myPathName[0] == _T('\0') )
return NULL;
return myPathName;
}
HINSTANCE ModuleInstance( void ) const HINSTANCE ModuleInstance( void ) const
{ {
return myInstance; return myInstance;
@ -55,10 +47,7 @@ class CGlobalData
private: private:
Settings* mySettings; Settings* mySettings;
string myArgumentList;
HINSTANCE myInstance; HINSTANCE myInstance;
TCHAR myPathName[ MAX_PATH ];
CGlobalData( const CGlobalData& ); // no implementation CGlobalData( const CGlobalData& ); // no implementation
void operator=( const CGlobalData& ); // no implementation void operator=( const CGlobalData& ); // no implementation

View File

@ -14,54 +14,33 @@
// 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.3 2004-07-06 22:51:58 stephena Exp $ // $Id: MainDlg.cxx,v 1.4 2004-07-10 22:25:58 stephena Exp $
//============================================================================ //============================================================================
#include "pch.hxx" #include "pch.hxx"
#include "MainDlg.hxx" #include "MainDlg.hxx"
#include "Game.hxx"
#include "GlobalData.hxx" #include "GlobalData.hxx"
#include "PropertySheet.hxx" #include "PropertySheet.hxx"
#include "AboutPage.hxx" #include "AboutPage.hxx"
#include "ConfigPage.hxx" #include "ConfigPage.hxx"
#include "resource.h" #include "resource.h"
#include "Settings.hxx" #include "Settings.hxx"
#include "PropsSet.hxx"
#include "MD5.hxx"
#define BKGND_BITMAP_TOP 64 #define BKGND_BITMAP_TOP 64
#define BKGND_BITMAP_BOTTOM 355 #define BKGND_BITMAP_BOTTOM 355
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline LPARAM ListView_GetItemData( HWND hwndList, int iItem ) MainDlg::MainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance )
{
LVITEM lvi;
lvi.mask = LVIF_PARAM;
lvi.iItem = iItem;
lvi.iSubItem = 0;
ListView_GetItem(hwndList, &lvi);
return lvi.lParam;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CMainDlg::CMainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance )
: myGlobalData(rGlobalData), : myGlobalData(rGlobalData),
m_hInstance(hInstance) m_hInstance(hInstance)
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CMainDlg::ClearList( void ) int MainDlg::DoModal( HWND hwndParent )
{
int nCount = ListView_GetItemCount( myHwndList );
for (int i = 0; i < nCount; ++i)
delete (CListData*)ListView_GetItemData( myHwndList, i );
ListView_DeleteAllItems( myHwndList );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CMainDlg::DoModal( HWND hwndParent )
{ {
return DialogBoxParam( m_hInstance, return DialogBoxParam( m_hInstance,
MAKEINTRESOURCE(IDD), MAKEINTRESOURCE(IDD),
@ -72,20 +51,20 @@ int CMainDlg::DoModal( HWND hwndParent )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL CALLBACK BOOL CALLBACK
CMainDlg::StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) MainDlg::StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{ {
CMainDlg* pDlg; MainDlg* pDlg;
switch ( uMsg ) switch ( uMsg )
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
pDlg = reinterpret_cast<CMainDlg*>( lParam ); pDlg = reinterpret_cast<MainDlg*>( lParam );
pDlg->myHwnd = hDlg; pDlg->myHwnd = hDlg;
(void)::SetWindowLong( hDlg, DWL_USER, reinterpret_cast<LONG>( pDlg ) ); (void)::SetWindowLong( hDlg, DWL_USER, reinterpret_cast<LONG>( pDlg ) );
break; break;
default: default:
pDlg = reinterpret_cast<CMainDlg*>( ::GetWindowLong( hDlg, DWL_USER ) ); pDlg = reinterpret_cast<MainDlg*>( ::GetWindowLong( hDlg, DWL_USER ) );
if ( pDlg == NULL ) if ( pDlg == NULL )
return FALSE; return FALSE;
break; break;
@ -96,7 +75,7 @@ CMainDlg::StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL CALLBACK BOOL CALLBACK
CMainDlg::DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam ) MainDlg::DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam )
{ {
BOOL b; BOOL b;
@ -168,7 +147,7 @@ CMainDlg::DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam )
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL CMainDlg::OnInitDialog( void ) BOOL MainDlg::OnInitDialog( void )
{ {
DWORD dwRet; DWORD dwRet;
@ -181,9 +160,7 @@ BOOL CMainDlg::OnInitDialog( void )
// Make the Rom note have bold text // Make the Rom note have bold text
HWND hwndCtrl; HWND hwndCtrl;
hwndCtrl = ::GetDlgItem( hwnd, IDC_ROMNOTE ); hwndCtrl = ::GetDlgItem( hwnd, IDC_ROMNOTE );
HFONT hfont = (HFONT)::SendMessage( hwndCtrl, WM_GETFONT, 0, 0 ); HFONT hfont = (HFONT)::SendMessage( hwndCtrl, WM_GETFONT, 0, 0 );
LOGFONT lf; LOGFONT lf;
@ -218,18 +195,25 @@ BOOL CMainDlg::OnInitDialog( void )
RECT rc; RECT rc;
::GetClientRect( myHwndList, &rc ); ::GetClientRect( myHwndList, &rc );
LONG lTotalWidth = rc.right-rc.left - GetSystemMetrics(SM_CXVSCROLL); // Declare the column headings
int cx = lTotalWidth / CListData::GetColumnCount(); int columnHeader[] = { IDS_NAME, IDS_MANUFACTURER, IDS_RARITY };
for (int i = 0; i < CListData::GetColumnCount(); ++i) // Set the column widths
LONG lTotalWidth = rc.right-rc.left - GetSystemMetrics(SM_CXVSCROLL);
int columnWidth[3];
columnWidth[0] = (int) (0.58 * lTotalWidth);
columnWidth[1] = (int) (0.25 * lTotalWidth);
columnWidth[2] = lTotalWidth - columnWidth[0] - columnWidth[1];
// Set up the column headings
for (int i = 0; i < sizeof(columnHeader)/sizeof(int); ++i)
{ {
::LoadString( m_hInstance, CListData::GetColumnNameIdForColumn( i ), LoadString( m_hInstance, columnHeader[i], psz, nMaxString );
psz, nMaxString );
LV_COLUMN lvc; LV_COLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_LEFT; lvc.fmt = LVCFMT_LEFT;
lvc.cx = cx; lvc.cx = columnWidth[i];
lvc.pszText = psz; lvc.pszText = psz;
ListView_InsertColumn( myHwndList, i, &lvc ); ListView_InsertColumn( myHwndList, i, &lvc );
} }
@ -245,14 +229,14 @@ BOOL CMainDlg::OnInitDialog( void )
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify ) BOOL MainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
{ {
UNUSED_ALWAYS( hwndCtl ); UNUSED_ALWAYS( hwndCtl );
UNUSED_ALWAYS( codeNotify ); UNUSED_ALWAYS( codeNotify );
HWND hwnd = *this; HWND hwnd = *this;
CListData* pListData; Game* g;
string romfile;
int nItem; int nItem;
switch (id) switch (id)
@ -263,28 +247,23 @@ BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
ASSERT( nItem != -1 ); ASSERT( nItem != -1 );
if ( nItem == -1 ) if ( nItem == -1 )
{ {
::MessageBox( m_hInstance, hwnd, IDS_NO_ITEM_SELECTED ); MessageBox( m_hInstance, hwnd, IDS_NO_ITEM_SELECTED );
return TRUE; return TRUE;
} }
pListData = (CListData*)ListView_GetItemData( myHwndList, nItem ); g = (Game*) ListView_GetItemData( myHwndList, nItem );
romfile = myGlobalData.settings().getString("romdir") + "\\" + g->rom();
TCHAR pszPathName[ MAX_PATH + 1 ]; (void)m_stella.PlayROM( romfile, myGlobalData );
lstrcpy( pszPathName, myGlobalData.settings().getString("romdir").c_str() );
lstrcat( pszPathName, _T("\\") );
lstrcat( pszPathName, pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
(void)m_stella.PlayROM( pszPathName, myGlobalData );
// Set focus back to the rom list // Set focus back to the rom list
::SetFocus( myHwndList ); SetFocus( myHwndList );
return TRUE; return TRUE;
break; // case IDC_PLAY break; // case IDC_PLAY
case IDC_EXIT: case IDC_EXIT:
ClearList(); ListView_Clear();
::EndDialog( hwnd, IDCANCEL ); EndDialog( hwnd, IDCANCEL );
return TRUE; return TRUE;
break; // case IDC_EXIT break; // case IDC_EXIT
@ -315,7 +294,7 @@ BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
case IDC_RELOAD: case IDC_RELOAD:
{ {
UpdateRomList(); LoadRomListFromDisk();
return TRUE; return TRUE;
break; // case IDC_RELOAD break; // case IDC_RELOAD
@ -326,24 +305,20 @@ BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL CMainDlg::OnNotify( int idCtrl, LPNMHDR pnmh ) BOOL MainDlg::OnNotify( int idCtrl, LPNMHDR pnmh )
{ {
UNUSED_ALWAYS( idCtrl ); UNUSED_ALWAYS( idCtrl );
switch ( pnmh->code ) switch ( pnmh->code )
{ {
case LVN_GETDISPINFO:
OnGetDispInfo( (NMLVDISPINFO*)pnmh );
return TRUE;
case LVN_COLUMNCLICK:
OnColumnClick( (LPNMLISTVIEW)pnmh );
return TRUE;
case LVN_ITEMCHANGED: case LVN_ITEMCHANGED:
OnItemChanged( (LPNMLISTVIEW)pnmh ); OnItemChanged( (LPNMLISTVIEW)pnmh );
return TRUE; return TRUE;
// case LVN_COLUMNCLICK:
// OnColumnClick( (LPNMLISTVIEW)pnmh );
// return TRUE;
case NM_DBLCLK: case NM_DBLCLK:
// send out an ok click to play // send out an ok click to play
::SendDlgItemMessage( *this, IDC_PLAY, BM_CLICK, 0, 0 ); ::SendDlgItemMessage( *this, IDC_PLAY, BM_CLICK, 0, 0 );
@ -354,6 +329,33 @@ BOOL CMainDlg::OnNotify( int idCtrl, LPNMHDR pnmh )
return FALSE; return FALSE;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MainDlg::OnItemChanged( LPNMLISTVIEW pnmv )
{
HWND hwnd = *this;
HWND hwndNote = ::GetDlgItem( hwnd, IDC_ROMNOTE );
RECT rc;
GetWindowRect(hwndNote, &rc);
ScreenToClient( hwnd, (LPPOINT)&rc );
ScreenToClient( hwnd, ((LPPOINT)&rc)+1 );
int iItem = ListView_GetNextItem(pnmv->hdr.hwndFrom, -1, LVNI_SELECTED);
if (iItem == -1)
{
SetWindowText( hwndNote, _T("") );
EnableWindow( GetDlgItem( hwnd, IDC_PLAY ), FALSE );
InvalidateRect( hwnd, &rc, TRUE );
return;
}
Game* g = (Game*)ListView_GetItemData( pnmv->hdr.hwndFrom, pnmv->iItem );
SetWindowText( hwndNote, g->note().c_str() );
InvalidateRect( hwnd, &rc, TRUE );
EnableWindow( GetDlgItem( hwnd, IDC_PLAY ), TRUE );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static void ScreenToClient( HWND hwnd, LPRECT lpRect ) static void ScreenToClient( HWND hwnd, LPRECT lpRect )
{ {
@ -370,7 +372,7 @@ static void FillSolidRect( HDC hdc, LPCRECT lpRect, COLORREF clr )
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL CMainDlg::OnEraseBkgnd( HDC hdc ) BOOL MainDlg::OnEraseBkgnd( HDC hdc )
{ {
// don't do this in 256 color // don't do this in 256 color
@ -419,7 +421,7 @@ BOOL CMainDlg::OnEraseBkgnd( HDC hdc )
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HBRUSH CMainDlg::OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic ) HBRUSH MainDlg::OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic )
{ {
// don't do this in 256 color // don't do this in 256 color
@ -435,21 +437,20 @@ HBRUSH CMainDlg::OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic )
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CMainDlg::UpdateRomList( void ) void MainDlg::UpdateRomList( void )
{ {
HWND hwndText; HWND hwndText;
RECT rc; RECT rc;
DWORD dwError = PopulateRomList(); if ( !PopulateRomList() )
if ( dwError != ERROR_SUCCESS ) MessageBoxFromWinError( 0, _T("PopulateRomList") );
MessageBoxFromWinError( dwError, _T("PopulateRomList") );
// if items added, select first item and enable play button // if items added, select first item and enable play button
int nCount = ListView_GetItemCount( myHwndList ); int nCount = ListView_GetItemCount( myHwndList );
if (nCount != 0) if (nCount != 0)
{ {
myHeader.SetSortCol( 0, TRUE ); myHeader.SetSortCol( 0, TRUE );
ListView_SortItems( myHwndList, ListViewCompareFunc, (LPARAM)this ); // ListView_SortItems( myHwndList, ListViewCompareFunc, (LPARAM)this );
ListView_SetItemState( myHwndList, 0, LVIS_SELECTED | LVIS_FOCUSED, ListView_SetItemState( myHwndList, 0, LVIS_SELECTED | LVIS_FOCUSED,
LVIS_SELECTED | LVIS_FOCUSED ); LVIS_SELECTED | LVIS_FOCUSED );
} }
@ -480,287 +481,200 @@ void CMainDlg::UpdateRomList( void )
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DWORD CMainDlg::PopulateRomList( void ) bool MainDlg::PopulateRomList( void )
{ {
DWORD dwRet; bool result = false;
ClearList(); bool cacheFileExists = myGlobalData.settings().fileExists("stellax.cache");
bool cacheIsStale = false; // FIXME
TCHAR pszPath[ MAX_PATH ]; if(cacheFileExists && !cacheIsStale)
result = LoadRomListFromCache();
else
result = LoadRomListFromDisk();
lstrcpy( pszPath, myGlobalData.settings().getString("romdir").c_str() ); return result;
lstrcat( pszPath, _T("\\*.bin") ); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool MainDlg::LoadRomListFromDisk()
{
ListView_Clear();
// Get the location of the romfiles (*.bin)
string romdir = myGlobalData.settings().getString("romdir");
romdir += "\\";
string romfiles = romdir + "*.bin";
WIN32_FIND_DATA ffd; WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile( pszPath, &ffd ); HANDLE hFind = FindFirstFile( romfiles.c_str(), &ffd );
ListView_SetItemCount( myHwndList, 100 ); ListView_SetItemCount( myHwndList, 100 );
int iItem = 0; int iItem = 0;
BOOL fDone = (hFind == INVALID_HANDLE_VALUE); bool done = (hFind == INVALID_HANDLE_VALUE);
while(!fDone) while(!done)
{ {
// File metadata will be read in ReadRomData() Game* g = new Game();
CListData* pListData = new CListData; if( g == NULL )
if( pListData == NULL ) return false;
return ERROR_NOT_ENOUGH_MEMORY;
dwRet = pListData->Initialize();
if( dwRet != ERROR_SUCCESS )
return dwRet;
if ( !pListData->m_strFileName.Set( ffd.cFileName ) )
return FALSE;
LV_ITEM lvi; LV_ITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iItem = iItem++; lvi.iItem = iItem++;
lvi.iSubItem = 0; lvi.iSubItem = 0;
lvi.pszText = LPSTR_TEXTCALLBACK; lvi.pszText = "";
lvi.lParam = (LPARAM)pListData; lvi.lParam = (LPARAM) g;
int nItem = ListView_InsertItem( myHwndList, &lvi ); int nItem = ListView_InsertItem( myHwndList, &lvi );
ASSERT( nItem != -1 ); ASSERT( nItem != -1 );
ListView_SetItemText( myHwndList, nItem, g->setAvailable( true );
CListData::FILENAME_COLUMN, LPSTR_TEXTCALLBACK ); g->setRom( ffd.cFileName );
ListView_SetItemText(myHwndList, nItem,
CListData::MANUFACTURER_COLUMN, LPSTR_TEXTCALLBACK); // Set the name (shown onscreen) to be the rom
ListView_SetItemText( myHwndList, nItem, // It will be overwritten later if a name is found in the properties set
CListData::RARITY_COLUMN, LPSTR_TEXTCALLBACK ); g->setName( ffd.cFileName );
// go to the next rom file // go to the next rom file
fDone = !FindNextFile(hFind, &ffd); done = !FindNextFile(hFind, &ffd);
} }
if( hFind != INVALID_HANDLE_VALUE ) if( hFind != INVALID_HANDLE_VALUE )
VERIFY( ::FindClose( hFind ) ); VERIFY( ::FindClose( hFind ) );
return ERROR_SUCCESS; // Create a propertiesset object and load the properties
} // We don't create the propsSet until we need it, since it's
// a time-consuming process
PropertiesSet propsSet;
string theUserProFile = myGlobalData.settings().userPropertiesFilename();
string theSystemProFile = myGlobalData.settings().systemPropertiesFilename();
if(theUserProFile != "")
propsSet.load(theUserProFile, true);
else if(theSystemProFile != "")
propsSet.load(theSystemProFile, true);
else
propsSet.load("", false);
DWORD CMainDlg::ReadRomData(CListData* pListData) const // Now, rescan the items in the listview and update the onscreen
{ // text and game properties
/* // Also generate a cache file so the program will start faster next time
// TODO: Move this method to ListData class (?) ofstream cache("stellax.cache");
if( pListData == NULL ) int count = ListView_GetItemCount( myHwndList );
cache << count << endl;
for (int i = 0; i < count; ++i)
{ {
ASSERT( FALSE ); Game* g = (Game*) ListView_GetItemData(myHwndList, i);
return ERROR_BAD_ARGUMENTS;
// Get the MD5sum for this rom
// Use it to lookup the rom in the properties set
string rom = romdir + g->rom();
ifstream in(rom.c_str(), ios_base::binary);
if(!in)
return false;
uInt8* image = new uInt8[512 * 1024];
in.read((char*)image, 512 * 1024);
uInt32 size = in.gcount();
in.close();
string md5 = MD5( image, size );
delete[] image;
// Get the properties for this rom
Properties props;
propsSet.getMD5( md5, props );
// For some braindead reason, the ListView_SetItemText won't
// allow std::string::c_str(), so we create C-strings instead
char name[256], manufacturer[256], rarity[256];
strncpy(name, props.get("Cartridge.Name").c_str(), 255);
strncpy(manufacturer, props.get("Cartridge.Manufacturer").c_str(), 255);
strncpy(rarity, props.get("Cartridge.Rarity").c_str(), 255);
// Make sure the onscreen 'Name' field isn't blank
if(props.get("Cartridge.Name") == "")
strncpy(name, g->name().c_str(), 255);
// Update the current game
// To save memory, 'Note' is the only item that needs to be saved
g->setNote( props.get("Cartridge.Note") );
// Update the cachefile with this game
cache << g->rom() << endl
<< md5 << endl
<< name << endl
<< rarity << endl
<< manufacturer << endl
<< g->note() << endl;
// Finally, update the listview itself
ListView_SetItemText( myHwndList, i, 0, name );
ListView_SetItemText( myHwndList, i, 1, manufacturer );
ListView_SetItemText( myHwndList, i, 2, rarity );
} }
cache.close();
SetFocus( myHwndList );
// attempt to read the rom file return true;
TCHAR pszPath[MAX_PATH + 1];
lstrcpy( pszPath, myGlobalData.settings().getString("romdir").c_str() );
lstrcat( pszPath, _T("\\") );
lstrcat( pszPath, pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
HANDLE hFile;
hFile = CreateFile( pszPath,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
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();
uInt32 setSize = propertiesSet.size();
for (uInt32 i = 0; i < setSize; ++i)
{
if (propertiesSet.get(i).get("Cartridge.MD5") == md5)
{
// got it!
break;
}
}
if (i != setSize)
{
const Properties& properties = propertiesSet.get(i);
if ( ! pListData->m_strManufacturer.Set(
properties.get("Cartridge.Manufacturer").c_str() ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
if ( ! pListData->m_strName.Set(
properties.get("Cartridge.Name").c_str() ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
if (! pListData->m_strRarity.Set(
properties.get("Cartridge.Rarity").c_str() ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
if ( ! pListData->m_strNote.Set(
properties.get("Cartridge.Note").c_str() ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
}
else
{
//
// Any output here should be appended to the emucore\stella.pro file
//
TRACE( "\"Cartridge.MD5\" \"%s\"\n\"Cartridge.Name\" \"%s\"\n\"\"\n",
md5.c_str(),
pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
}
}
delete[] pImage;
VERIFY( ::CloseHandle( hFile ) );
pListData->m_fPopulated = TRUE;
*/
return ERROR_SUCCESS;
} }
void CMainDlg::OnColumnClick( LPNMLISTVIEW pnmv ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool MainDlg::LoadRomListFromCache()
{ {
HCURSOR hcur = ::SetCursor(::LoadCursor(NULL, IDC_WAIT)); ListView_Clear();
char count[10], rom[256], md5[256], name[256], rarity[256],
manufacturer[256], note[256];
myHeader.SetSortCol(pnmv->iSubItem, TRUE); // We don't scan the roms at all; just load directly from the cache file
ListView_SortItems(pnmv->hdr.hwndFrom, ListViewCompareFunc, (LPARAM)this); ifstream in("stellax.cache");
if (!in)
return false;
// ensure the selected item is visible in.getline(count, 9);
int numRoms = atoi(count);
ListView_SetItemCount( myHwndList, 100 );
int nItem = ListView_GetNextItem( myHwndList, -1, LVNI_SELECTED ); int iItem = 0;
if (nItem != -1) for(int i = 0; i < numRoms; i++)
{
ListView_EnsureVisible( myHwndList, nItem, TRUE );
}
::SetCursor(hcur);
}
void CMainDlg::OnItemChanged( LPNMLISTVIEW pnmv )
{
HWND hwnd = *this;
HWND hwndNote = ::GetDlgItem( hwnd, IDC_ROMNOTE );
RECT rc;
GetWindowRect(hwndNote, &rc);
ScreenToClient( hwnd, (LPPOINT)&rc );
ScreenToClient( hwnd, ((LPPOINT)&rc)+1 );
int iItem = ListView_GetNextItem(pnmv->hdr.hwndFrom, -1, LVNI_SELECTED);
if (iItem == -1)
{ {
SetWindowText( hwndNote, _T("") ); string line;
EnableWindow( ::GetDlgItem( hwnd, IDC_PLAY ), FALSE ); Game* g = new Game();
InvalidateRect( hwnd, &rc, TRUE ); if( g == NULL )
return; return false;
// Get the data from the cache file
in.getline(rom, 255);
in.getline(md5, 255);
in.getline(name, 255);
in.getline(rarity, 255);
in.getline(manufacturer, 255);
in.getline(note, 255);
// These are the only things we really need to save
g->setAvailable( true );
g->setRom( rom );
g->setNote( note );
LV_ITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iItem = iItem++;
lvi.iSubItem = 0;
lvi.pszText = "";
lvi.lParam = (LPARAM) g;
int nItem = ListView_InsertItem( myHwndList, &lvi );
ASSERT( nItem != -1 );
ListView_SetItemText( myHwndList, nItem, 0, name );
ListView_SetItemText( myHwndList, nItem, 1, manufacturer );
ListView_SetItemText( myHwndList, nItem, 2, rarity );
} }
SetFocus( myHwndList );
CListData* pListData = (CListData*)ListView_GetItemData( return true;
pnmv->hdr.hwndFrom,
pnmv->iItem );
SetWindowText( hwndNote, pListData->GetNote() );
InvalidateRect( hwnd, &rc, TRUE );
EnableWindow( ::GetDlgItem( hwnd, IDC_PLAY ), TRUE );
} }
// --------------------------------------------------------------------------- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// LPSTR_TEXTCALLBACK message handlers
void CMainDlg::OnGetDispInfo(NMLVDISPINFO* pnmv)
{
// Provide the item or subitem's text, if requested.
if( !(pnmv->item.mask & LVIF_TEXT ) )
return;
CListData* pListData = (CListData*)
ListView_GetItemData( pnmv->hdr.hwndFrom, pnmv->item.iItem );
ASSERT( pListData );
if( pListData == NULL )
return;
if( !pListData->IsPopulated() )
ReadRomData( pListData );
pnmv->item.pszText = const_cast<LPTSTR>( pListData->GetTextForColumn(pnmv->item.iSubItem) );
}
int CALLBACK CMainDlg::ListViewCompareFunc(
LPARAM lParam1,
LPARAM lParam2,
LPARAM lParamSort
)
{
CMainDlg* pThis = reinterpret_cast<CMainDlg*>( lParamSort );
//
// I assume that the metadata for column 0 is always available,
// while other column metadata requires a call to ReadRomData
//
int nSortCol = pThis->myHeader.GetSortCol();
CListData* pItem1 = reinterpret_cast<CListData*>( lParam1 );
if ( ! pItem1->IsPopulated() && nSortCol != 0 )
{
pThis->ReadRomData( pItem1 );
}
CListData* pItem2 = reinterpret_cast<CListData*>( lParam2 );
if ( ! pItem2->IsPopulated() && nSortCol != 0 )
{
pThis->ReadRomData( pItem2 );
}
LPCTSTR pszItem1 = pItem1->GetTextForColumn( nSortCol );
LPCTSTR pszItem2 = pItem2->GetTextForColumn( nSortCol );
//
// put blank items last
//
if ( pszItem1 == NULL || pszItem1[0] == _T('\0') )
{
return 1;
}
if ( pszItem2 == NULL || pszItem2[0] == _T('\0') )
{
return -1;
}
//
// Compare the specified column.
//
return lstrcmpi( pszItem1, pszItem2 );
}
// ---------------------------------------------------------------------------
// Cool caption message handlers // Cool caption message handlers
void MainDlg::OnDestroy(
void CMainDlg::OnDestroy(
void void
) )
{ {
@ -773,24 +687,51 @@ void CMainDlg::OnDestroy(
} }
} }
void CMainDlg::OnNcPaint( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MainDlg::OnNcPaint(
HRGN hrgn HRGN hrgn
) )
{ {
m_CoolCaption.OnNcPaint( hrgn ); m_CoolCaption.OnNcPaint( hrgn );
} }
void CMainDlg::OnNcActivate( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MainDlg::OnNcActivate(
BOOL fActive BOOL fActive
) )
{ {
m_CoolCaption.OnNcActivate( fActive ); m_CoolCaption.OnNcActivate( fActive );
} }
BOOL CMainDlg::OnNcLButtonDown( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL MainDlg::OnNcLButtonDown(
INT nHitTest, INT nHitTest,
POINTS pts POINTS pts
) )
{ {
return m_CoolCaption.OnNCLButtonDown( nHitTest, pts ); return m_CoolCaption.OnNCLButtonDown( nHitTest, pts );
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LPARAM MainDlg::ListView_GetItemData( HWND hwndList, int iItem )
{
LVITEM lvi;
lvi.mask = LVIF_PARAM;
lvi.iItem = iItem;
lvi.iSubItem = 0;
ListView_GetItem(hwndList, &lvi);
return lvi.lParam;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MainDlg::ListView_Clear( void )
{
int nCount = ListView_GetItemCount( myHwndList );
for (int i = 0; i < nCount; ++i)
delete (Game*) ListView_GetItemData( myHwndList, i );
ListView_DeleteAllItems( myHwndList );
}

View File

@ -1,10 +1,24 @@
// //============================================================================
// StellaX //
// Jeff Miller 05/10/2000 // SSSS tt lll lll
// // SS SS tt ll ll
#ifndef MAINDLG_H // SS tttttt eeee ll ll aaaa
#define MAINDLG_H // SSSS tt ee ee ll ll aa
#pragma once // 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: MainDlg.hxx,v 1.3 2004-07-10 22:25:58 stephena Exp $
//============================================================================
#ifndef __MAINDLG_H_
#define __MAINDLG_H_
#include "resource.h" #include "resource.h"
@ -16,175 +30,19 @@ class CGlobalData;
#include "HeaderCtrl.hxx" #include "HeaderCtrl.hxx"
#include "RoundButton.hxx" #include "RoundButton.hxx"
class CMainDlg;
class CListData class MainDlg
{ {
friend CMainDlg; public:
public:
CListData() :
m_fPopulated( FALSE )
{
}
DWORD Initialize()
{
//
// ListView control doesn't like NULLs returned, so initialize all
//
if ( ! m_strName.Set( _T("") ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
if ( ! m_strManufacturer.Set( _T("") ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
if ( ! m_strRarity.Set( _T("") ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
if ( ! m_strFileName.Set( _T("") ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
if ( ! m_strNote.Set( _T("") ) )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
return ERROR_SUCCESS;
}
//
// MetaData
//
static int GetColumnCount( void )
{
return 4;
}
enum ColumnIndex
{
FILENAME_COLUMN,
NAME_COLUMN,
MANUFACTURER_COLUMN,
RARITY_COLUMN,
};
static UINT GetColumnNameIdForColumn( int nCol )
{
UINT uID = 0;
switch ( nCol )
{
case NAME_COLUMN:
uID = IDS_NAME;
break;
case MANUFACTURER_COLUMN:
uID = IDS_MANUFACTURER;
break;
case RARITY_COLUMN:
uID = IDS_RARITY;
break;
case FILENAME_COLUMN:
uID = IDS_FILENAME;
break;
default:
ASSERT(FALSE);
break;
}
return uID;
}
LPCTSTR GetTextForColumn( int nCol ) const
{
LPCTSTR pszText = NULL;
switch (nCol)
{
case NAME_COLUMN:
pszText = m_strName.Get();
break;
case MANUFACTURER_COLUMN:
pszText = m_strManufacturer.Get();
break;
case RARITY_COLUMN:
pszText = m_strRarity.Get();
break;
case FILENAME_COLUMN:
pszText = m_strFileName.Get();
break;
default:
ASSERT( FALSE );
break;
}
return pszText;
}
LPCTSTR GetNote( void ) const
{
return m_strNote.Get();
}
BOOL IsPopulated( void ) const
{
return m_fPopulated;
}
private:
CSimpleString m_strName;
CSimpleString m_strManufacturer;
CSimpleString m_strRarity;
CSimpleString m_strFileName;
CSimpleString m_strNote;
BOOL m_fPopulated;
private:
CListData( const CListData& ); // no implementation
void operator=( const CListData& ); // no implementation
};
// ---------------------------------------------------------------------------
class CMainDlg
{
public:
enum { IDD = IDD_MAIN }; enum { IDD = IDD_MAIN };
CMainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance ); MainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance );
virtual int DoModal( HWND hwndParent ); virtual int DoModal( HWND hwndParent );
operator HWND( void ) const operator HWND( void ) const { return myHwnd; }
{
return myHwnd;
}
private:
private:
HWND myHwnd; HWND myHwnd;
CCoolCaption m_CoolCaption; CCoolCaption m_CoolCaption;
@ -196,66 +54,45 @@ private:
CRoundButton myConfigButton; CRoundButton myConfigButton;
CRoundButton myExitButton; CRoundButton myExitButton;
//
// Message handlers // Message handlers
//
BOOL OnInitDialog( void ); BOOL OnInitDialog( void );
BOOL OnCommand( int id, HWND hwndCtl, UINT codeNotify ); BOOL OnCommand( int id, HWND hwndCtl, UINT codeNotify );
BOOL OnNotify( int idCtrl, LPNMHDR pnmh ); BOOL OnNotify( int idCtrl, LPNMHDR pnmh );
BOOL OnEraseBkgnd( HDC hdc ); BOOL OnEraseBkgnd( HDC hdc );
HBRUSH OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic ); HBRUSH OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic );
//
// wm_notify handlers // wm_notify handlers
//
void OnGetDispInfo( NMLVDISPINFO* pnmh );
void OnColumnClick( LPNMLISTVIEW pnmv );
void OnItemChanged( LPNMLISTVIEW pnmv ); void OnItemChanged( LPNMLISTVIEW pnmv );
// void OnColumnClick( LPNMLISTVIEW pnmv );
//
// cool caption handlers // cool caption handlers
//
void OnDestroy( void ); void OnDestroy( void );
void OnNcPaint( HRGN hrgn ); void OnNcPaint( HRGN hrgn );
void OnNcActivate( BOOL fActive ); void OnNcActivate( BOOL fActive );
BOOL OnNcLButtonDown( INT nHitTest, POINTS pts ); BOOL OnNcLButtonDown( INT nHitTest, POINTS pts );
//
// callback methods // callback methods
//
BOOL CALLBACK DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam ); BOOL CALLBACK DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam );
static BOOL CALLBACK StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); static BOOL CALLBACK StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
static int CALLBACK ListViewCompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort );
// internal data // internal data
DWORD PopulateRomList();
void UpdateRomList(); void UpdateRomList();
DWORD ReadRomData( CListData* ) const; bool PopulateRomList();
bool LoadRomListFromDisk();
bool LoadRomListFromCache();
HINSTANCE m_hInstance; HINSTANCE m_hInstance;
// stuff in list // stuff in list
HWND myHwndList; HWND myHwndList;
void ClearList(); LPARAM ListView_GetItemData( HWND hwndList, int iItem );
void ListView_Clear();
HFONT m_hfontRomNote; HFONT m_hfontRomNote;
// Stella stuff // Stella stuff
CGlobalData& myGlobalData; CGlobalData& myGlobalData;
CStellaXMain m_stella; CStellaXMain m_stella;
CMainDlg( const CMainDlg& ); // no implementation
void operator=( const CMainDlg& ); // no implementation
}; };
#endif #endif

Binary file not shown.

View File

@ -130,7 +130,7 @@ BEGIN
CONTROL "Static",IDC_ROMPATH,"Static",SS_LEFTNOWORDWRAP | CONTROL "Static",IDC_ROMPATH,"Static",SS_LEFTNOWORDWRAP |
SS_NOPREFIX | WS_GROUP,57,45,254,8 SS_NOPREFIX | WS_GROUP,57,45,254,8
CONTROL "",IDC_ROMNOTE,"Static",SS_LEFTNOWORDWRAP | SS_NOPREFIX | CONTROL "",IDC_ROMNOTE,"Static",SS_LEFTNOWORDWRAP | SS_NOPREFIX |
WS_GROUP,93,205,309,8 WS_GROUP,105,205,297,8
LTEXT "Game notes (if available):",-1,7,205,98,8 LTEXT "Game notes (if available):",-1,7,205,98,8
CONTROL "&Reload",IDC_RELOAD,"Button",BS_OWNERDRAW | WS_TABSTOP, CONTROL "&Reload",IDC_RELOAD,"Button",BS_OWNERDRAW | WS_TABSTOP,
172,226,54,16 172,226,54,16

View File

@ -20,7 +20,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..\emucore;..\..\emucore\m6502\src\bspf\src;..\..\win32" AdditionalIncludeDirectories="..\..\emucore;..\..\emucore\m6502\src\bspf\src;..\..\win32"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;BSPF_WIN32;DISPLAY_OPENGL" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;BSPF_WIN32;JOYSTICK_SUPPORT;SNAPSHOT_SUPPORT;DISPLAY_OPENGL"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="5" RuntimeLibrary="5"
@ -68,7 +68,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\emucore;..\..\emucore\m6502\src\bspf\src;..\..\win32" AdditionalIncludeDirectories="..\..\emucore;..\..\emucore\m6502\src\bspf\src;..\..\win32"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;BSPF_WIN32;JOYSTICK_SUPPORT;SNAPSHOT_SUPPORT;DISPLAY_OPENGL"
RuntimeLibrary="4" RuntimeLibrary="4"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="1" WarningLevel="1"
@ -129,6 +129,9 @@
<File <File
RelativePath=".\debug.cxx"> RelativePath=".\debug.cxx">
</File> </File>
<File
RelativePath=".\Game.cxx">
</File>
<File <File
RelativePath=".\GlobalData.cxx"> RelativePath=".\GlobalData.cxx">
</File> </File>
@ -144,12 +147,21 @@
<File <File
RelativePath=".\MainDlg.cxx"> RelativePath=".\MainDlg.cxx">
</File> </File>
<File
RelativePath="..\..\emucore\MD5.cxx">
</File>
<File <File
RelativePath=".\pch.cxx"> RelativePath=".\pch.cxx">
</File> </File>
<File <File
RelativePath=".\PropertySheet.cxx"> RelativePath=".\PropertySheet.cxx">
</File> </File>
<File
RelativePath="..\..\emucore\Props.cxx">
</File>
<File
RelativePath="..\..\emucore\PropsSet.cxx">
</File>
<File <File
RelativePath=".\RoundButton.cxx"> RelativePath=".\RoundButton.cxx">
</File> </File>
@ -188,6 +200,9 @@
<File <File
RelativePath=".\debug.hxx"> RelativePath=".\debug.hxx">
</File> </File>
<File
RelativePath=".\Game.hxx">
</File>
<File <File
RelativePath=".\GlobalData.hxx"> RelativePath=".\GlobalData.hxx">
</File> </File>
@ -200,12 +215,21 @@
<File <File
RelativePath=".\MainDlg.hxx"> RelativePath=".\MainDlg.hxx">
</File> </File>
<File
RelativePath="..\..\emucore\MD5.hxx">
</File>
<File <File
RelativePath=".\pch.hxx"> RelativePath=".\pch.hxx">
</File> </File>
<File <File
RelativePath=".\PropertySheet.hxx"> RelativePath=".\PropertySheet.hxx">
</File> </File>
<File
RelativePath="..\..\emucore\Props.hxx">
</File>
<File
RelativePath="..\..\emucore\PropsSet.hxx">
</File>
<File <File
RelativePath=".\Resource.h"> RelativePath=".\Resource.h">
</File> </File>

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: StellaXMain.cxx,v 1.3 2004-07-06 22:51:58 stephena Exp $ // $Id: StellaXMain.cxx,v 1.4 2004-07-10 22:25:58 stephena Exp $
//============================================================================ //============================================================================
#include <iostream> #include <iostream>
@ -37,15 +37,14 @@ CStellaXMain::~CStellaXMain()
{ {
} }
void CStellaXMain::PlayROM( LPCTSTR filename, CGlobalData& globaldata ) void CStellaXMain::PlayROM( string& romfile, CGlobalData& globaldata )
{ {
string rom = filename;
ostringstream buf; ostringstream buf;
// Make sure the specfied ROM exists // Make sure the specfied ROM exists
if(!globaldata.settings().fileExists(filename)) if(!globaldata.settings().fileExists(romfile))
{ {
buf << "\"" << rom << "\" doesn't exist"; buf << "\"" << romfile << "\" doesn't exist";
MessageBox( NULL, buf.str().c_str(), "Unknown ROM", MB_ICONEXCLAMATION|MB_OK); MessageBox( NULL, buf.str().c_str(), "Unknown ROM", MB_ICONEXCLAMATION|MB_OK);
return; return;
@ -54,6 +53,6 @@ void CStellaXMain::PlayROM( LPCTSTR filename, CGlobalData& globaldata )
// Assume that the ROM file does exist, attempt to run external Stella // 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 // Since all settings are saved to the stella.ini file, we don't need
// to pass any arguments here ... // to pass any arguments here ...
buf << "\"" << rom << "\""; buf << "\"" << romfile << "\"";
ShellExecute(NULL, "open", "stella.exe", buf.str().c_str(), NULL, 0); ShellExecute(NULL, "open", "stella.exe", buf.str().c_str(), NULL, 0);
} }

View File

@ -14,12 +14,14 @@
// 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: StellaXMain.hxx,v 1.2 2004-07-04 20:16:03 stephena Exp $ // $Id: StellaXMain.hxx,v 1.3 2004-07-10 22:25:58 stephena Exp $
//============================================================================ //============================================================================
#ifndef STELLAX_H #ifndef STELLAX_H
#define STELLAX_H #define STELLAX_H
#include "bspf.hxx"
class CGlobalData; class CGlobalData;
class CStellaXMain class CStellaXMain
@ -28,7 +30,7 @@ class CStellaXMain
CStellaXMain(); CStellaXMain();
~CStellaXMain(); ~CStellaXMain();
void PlayROM( LPCTSTR filename, CGlobalData& globaldata ); void PlayROM( string& romfile, CGlobalData& globaldata );
private: private:
CStellaXMain( const CStellaXMain& ); // no implementation CStellaXMain( const CStellaXMain& ); // no implementation

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: main.cxx,v 1.1 2004-06-28 23:13:54 stephena Exp $ // $Id: main.cxx,v 1.2 2004-07-10 22:25:58 stephena Exp $
//============================================================================ //============================================================================
#include "pch.hxx" #include "pch.hxx"
@ -84,7 +84,7 @@ int WINAPI _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
CGlobalData globaldata( hInstance ); CGlobalData globaldata( hInstance );
// show the ui // show the ui
CMainDlg dlg( globaldata, hInstance ); MainDlg dlg( globaldata, hInstance );
dlg.DoModal( NULL ); dlg.DoModal( NULL );
if ( hrCoInit == S_OK ) if ( hrCoInit == S_OK )

View File

@ -4,29 +4,18 @@
// //
#ifndef PCH_H #ifndef PCH_H
#define PCH_H #define PCH_H
#pragma once
#ifndef _WIN32
#error This file can only be compiled for a Win32 platform
#endif
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define STRICT
#define DIRECTINPUT_VERSION 5 #define DIRECTINPUT_VERSION 5
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#include <tchar.h> #include <tchar.h>
// warning C4201: nonstandard extension used : nameless struct/union
#pragma warning ( once: 4201 )
#include <mmsystem.h> #include <mmsystem.h>
#include <commdlg.h> #include <commdlg.h>
#include <commctrl.h> #include <commctrl.h>
#include <ddraw.h>
#include <dsound.h>
#include <dinput.h> #include <dinput.h>
#include "debug.hxx" #include "debug.hxx"
@ -34,9 +23,6 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Conditional defines // Conditional defines
#define DOUBLE_WIDTH
//
// Macros // Macros
// //
@ -53,21 +39,19 @@
class CSimpleString class CSimpleString
{ {
public: public:
CSimpleString() : CSimpleString() :
m_psz( NULL ), m_psz( NULL ),
m_cch( -1 ) m_cch( -1 )
{ {
} }
~CSimpleString() ~CSimpleString()
{ {
delete[] m_psz; delete[] m_psz;
m_psz = NULL; m_psz = NULL;
m_cch = -1;
m_cch = -1; }
}
BOOL Set( LPCTSTR psz ) BOOL Set( LPCTSTR psz )
{ {
@ -135,5 +119,4 @@ void MessageBoxFromGetLastError(
LPCTSTR pszCaption /* = NULL */ LPCTSTR pszCaption /* = NULL */
); );
#endif #endif

Binary file not shown.

Binary file not shown.