Adding new browsing Listcontrol!

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@79 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
gunfight 2002-04-25 13:44:23 +00:00
parent 9fbb171a56
commit efcb6fa969
10 changed files with 189 additions and 524 deletions

View File

@ -100,10 +100,6 @@ SOURCE=.\AudioStream.cxx
# End Source File
# Begin Source File
SOURCE=.\BrowseForFolder.cxx
# End Source File
# Begin Source File
SOURCE=.\CRegBinding.cpp
# End Source File
# Begin Source File
@ -140,6 +136,10 @@ SOURCE=.\DirectXWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\GameList.cpp
# End Source File
# Begin Source File
SOURCE=.\GlobalData.cxx
# End Source File
# Begin Source File
@ -148,10 +148,6 @@ SOURCE=.\HyperLink.cpp
# End Source File
# Begin Source File
SOURCE=.\ListData.cxx
# End Source File
# Begin Source File
SOURCE=.\MainFrm.cpp
# End Source File
# Begin Source File
@ -184,10 +180,6 @@ SOURCE=.\AudioStream.hxx
# End Source File
# Begin Source File
SOURCE=.\BrowseForFolder.hxx
# End Source File
# Begin Source File
SOURCE=.\CRegBinding.h
# End Source File
# Begin Source File
@ -220,6 +212,10 @@ SOURCE=.\DirectXWindow.hxx
# End Source File
# Begin Source File
SOURCE=.\GameList.h
# End Source File
# Begin Source File
SOURCE=.\GlobalData.hxx
# End Source File
# Begin Source File
@ -228,10 +224,6 @@ SOURCE=.\HyperLink.h
# End Source File
# Begin Source File
SOURCE=.\ListData.hxx
# End Source File
# Begin Source File
SOURCE=.\MainFrm.h
# End Source File
# Begin Source File
@ -260,15 +252,19 @@ SOURCE=.\Timer.hxx
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\Cyberstella.ico
# End Source File
# Begin Source File
SOURCE=.\res\Cyberstella.rc2
# End Source File
# Begin Source File
SOURCE=.\res\CyberstellaDoc.ico
SOURCE=.\Dir.ico
# End Source File
# Begin Source File
SOURCE=.\res\Dir.ico
# End Source File
# Begin Source File
SOURCE=.\res\Stella.ico
# End Source File
# Begin Source File

View File

@ -58,6 +58,15 @@ END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_FOLDER ICON DISCARDABLE "res\\DIR.ICO"
#endif // German (Germany) resources
/////////////////////////////////////////////////////////////////////////////
@ -78,8 +87,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "STELLA.ICO"
IDR_CYBERSTYPE ICON DISCARDABLE "res\\CyberstellaDoc.ico"
IDR_MAINFRAME ICON DISCARDABLE "res\\STELLA.ICO"
/////////////////////////////////////////////////////////////////////////////
//
@ -158,70 +166,62 @@ END
IDD_CYBERSTELLA_FORM DIALOGEX 0, 0, 409, 169
STYLE WS_CHILD
FONT 8, "MS Shell Dlg"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "&Files found in:",-1,"Static",SS_LEFTNOWORDWRAP |
WS_GROUP,7,7,44,8
CONTROL "List1",IDC_ROMLIST,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE |
WS_BORDER | WS_TABSTOP,7,19,395,143,WS_EX_STATICEDGE
LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,7,19,395,143,WS_EX_CLIENTEDGE
RTEXT "<status>",IDC_ROMCOUNT,322,7,80,8,SS_NOPREFIX
CONTROL "Static",IDC_ROMPATH,"Static",SS_LEFTNOWORDWRAP |
SS_NOPREFIX | WS_GROUP,57,7,254,8
END
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 390, 176
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 390, 133
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Information"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "You must own legal copies of all ROM images you are using. Neither Jeff Miller nor the rest of the Stella team can tell you where to find ROM images so DON'T ASK. All requests will either be deleted or sent to the appropriate authorities.",
-1,7,7,376,18,SS_NOPREFIX
LTEXT "If you have a question or a problem, please try one of these contacts:",
-1,7,93,376,8,SS_NOPREFIX
LTEXT "Jeff Miller:",-1,7,109,32,8,SS_NOPREFIX
LTEXT "miller@zipcon.net",IDC_EMAIL_JEFFMILL,73,109,56,8,
LTEXT "You must own legal copies of all ROM images you are using. Neither Manuel Polik nor the rest of the Stella team can tell you where to find ROM images so DON'T ASK. All requests will either be deleted or sent to the appropriate authorities.",
-1,7,27,376,18,SS_NOPREFIX
LTEXT "If you have a question or a problem with Cyberstella, please try one of these contacts:",
-1,7,58,376,8,SS_NOPREFIX
LTEXT "Manuel Polik:",-1,7,76,62,8,SS_NOPREFIX
LTEXT "cybergoth@nexgo.de",IDC_EMAIL_JEFFMILL,73,76,103,8,
SS_NOPREFIX | SS_NOTIFY
LTEXT "http://www.emuunlim.com/stellax/",IDC_WEB_JEFFMILL,178,
109,110,8,SS_NOPREFIX | SS_NOTIFY
LTEXT "Stella dev team:",-1,7,121,52,8,SS_NOPREFIX
LTEXT "stella@csc.ncsu.edu",IDC_EMAIL_STELLA,73,121,67,8,
76,110,8,SS_NOPREFIX | SS_NOTIFY
LTEXT "Stella dev team:",-1,7,88,52,8,SS_NOPREFIX
LTEXT "stella@csc.ncsu.edu",IDC_EMAIL_STELLA,73,88,67,8,
SS_NOPREFIX | SS_NOTIFY
LTEXT "http://stella.atari.org",IDC_WEB_STELLA,178,121,65,8,
LTEXT "http://stella.atari.org",IDC_WEB_STELLA,178,88,65,8,
SS_NOPREFIX | SS_NOTIFY
LTEXT "StellaX is free software. It may not be sold or offered as part of a collection for sale without permission from Jeff Miller. When distributing StellaX, the original distribution (the .zip file) must not be altered.",
-1,7,32,376,19,SS_NOPREFIX
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,81,376,1
LTEXT "TIPS: F12 will create a screen shot of the current game screen. Open up stella.ini in notepad to see configurable options.",
-1,7,56,376,18
PUSHBUTTON "&Continue",IDC_CONTINUE,136,144,118,14
LTEXT "Cyberstella is free software. It may not be sold or offered as part of a collection for sale without permission from Manuel Polik. When distributing Cyberstella, the original distribution (the .zip file) must not be altered.",
-1,7,7,376,19,SS_NOPREFIX
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,50,375,1
PUSHBUTTON "&Continue",IDC_CONTINUE,136,111,118,14
END
IDD_CONFIG_PAGE DIALOG DISCARDABLE 0, 0, 390, 149
IDD_CONFIG_PAGE DIALOG DISCARDABLE 0, 0, 390, 112
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Cyberstella Configuration"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&ROM (.bin) file path:",-1,7,10,64,8
EDITTEXT IDC_ROMPATH,82,7,246,14,ES_AUTOHSCROLL
PUSHBUTTON "&Browse...",IDC_BROWSE,333,7,50,14
LTEXT "Set this to the path where your .bin rom files are located.",
-1,7,25,376,8
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,39,376,1
LTEXT "Mouse should emulate &paddle:",-1,7,49,97,8
COMBOBOX IDC_PADDLE,109,46,48,82,CBS_DROPDOWNLIST | WS_VSCROLL |
LTEXT "Mouse should emulate &paddle:",-1,7,10,97,8
COMBOBOX IDC_PADDLE,109,7,48,82,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,66,374,1
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,27,374,1
CONTROL "&Auto select video mode",IDC_AUTO_SELECT_VIDEOMODE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,73,90,10
LTEXT "If this is not checked, then a standard video mode (640x480) will be used. Otherwise, StellaX will use the video mode which it believes will work best. You should only uncheck this if you are having video problems while running StellaX.",
-1,7,84,376,18
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,108,373,1
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,34,90,10
LTEXT "If this is not checked, then a standard video mode (640x480) will be used. Otherwise, Cyberstella will use the video mode which it believes will work best. You should only uncheck this if you are having video problems while running Cyberstella.",
-1,7,45,376,18
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,69,373,1
CONTROL "Disable &Sound",IDC_SOUND,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,116,62,10
WS_TABSTOP,7,77,62,10
CONTROL "Disable &Joysticks",IDC_JOYSTICK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,130,70,10
PUSHBUTTON "&Continue",IDC_CONTINUE,265,128,118,14
BS_AUTOCHECKBOX | WS_TABSTOP,7,96,70,10
PUSHBUTTON "&Continue",IDC_CONTINUE,265,92,118,14
END
@ -289,7 +289,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 383
TOPMARGIN, 7
BOTTOMMARGIN, 169
BOTTOMMARGIN, 126
END
IDD_CONFIG_PAGE, DIALOG
@ -297,7 +297,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 383
TOPMARGIN, 7
BOTTOMMARGIN, 142
BOTTOMMARGIN, 106
END
END
#endif // APSTUDIO_INVOKED
@ -445,11 +445,11 @@ BEGIN
IDS_DSCSBFAILED "IDirectSound::CreateSoundBuffer failed"
IDS_DSSCLFAILED "IDirectSound::SetCooperativeLevel failed"
IDS_FILEFILTER "Stella Files (*.bin)|*.bin|All Files (*.*)|*.*||"
IDS_FILENAME "Filename"
IDS_MANUFACTURER "Manufacturer"
IDS_MIKE """I've heard some folks discussing the possibility of writing an 2600 emulator in a high level language - forget it, not possible."" -- Mike Livesay on rec.games.video.classic"
IDS_NAME "Name"
IDS_NODIRECTDRAW "DirectDraw does not appear to be installed on this system!"
IDS_FILE "File"
IDS_RARITY "Rarity"
END

View File

@ -7,8 +7,6 @@
#include "CyberstellaDoc.h"
#include "CyberstellaView.h"
#include "StellaConfig.h"
#include "MD5.hxx"
#include "PropsSet.hxx"
#include "Console.hxx"
#include "SoundWin32.hxx"
@ -22,7 +20,7 @@ static char THIS_FILE[] = __FILE__;
// Undefining USE_FS will use the (untested) windowed mode
//
//#define USE_FS
#define USE_FS
#ifdef USE_FS
#include "DirectXFullScreen.hxx"
@ -42,6 +40,7 @@ BEGIN_MESSAGE_MAP(CCyberstellaView, CFormView)
//{{AFX_MSG_MAP(CCyberstellaView)
ON_BN_CLICKED(IDC_CONFIG, OnConfig)
ON_BN_CLICKED(IDC_PLAY, OnPlay)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@ -88,89 +87,25 @@ void CCyberstellaView::OnInitialUpdate()
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
DWORD dwRet;
// Init ListControl, parse stella.pro
Initialize();
HWND hwnd = *this;
dwRet = Initialize();
if ( dwRet != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwRet, _T("CStellaX::Initialize") );
AfxGetMainWnd()->SendMessage(WM_CLOSE, 0, 0);
}
const int nMaxString = 256;
TCHAR psz[nMaxString + 1];
// LVS_EX_ONECLICKACTIVATE was causing a/vs in kernel32
::SendMessage( m_List,
LVM_SETEXTENDEDLISTVIEWSTYLE,
0,
LVS_EX_FULLROWSELECT );
RECT rc;
::GetClientRect( m_List, &rc );
LONG lTotalWidth = rc.right-rc.left - GetSystemMetrics(SM_CXVSCROLL);
int cx = lTotalWidth / CListData::GetColumnCount();
for (int i = 0; i < CListData::GetColumnCount(); ++i)
{
LoadString(GetModuleHandle(NULL),
CListData::GetColumnNameIdForColumn( i ),
psz, nMaxString );
LV_COLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_LEFT;
lvc.cx = cx;
lvc.pszText = psz;
ListView_InsertColumn( m_List, i, &lvc );
}
DWORD dwError = PopulateRomList();
if ( dwError != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwError, _T("PopulateRomList") );
AfxGetMainWnd()->SendMessage(WM_CLOSE, 0, 0);
}
// if items added, select first item and enable play button
int nCount = ListView_GetItemCount( m_List );
if (nCount != 0)
{
m_List.SortItems(ListViewCompareFunc, 0);
ListView_SetItemState( m_List, 0, LVIS_SELECTED | LVIS_FOCUSED,
LVIS_SELECTED | LVIS_FOCUSED );
}
else
{
::EnableWindow(::GetDlgItem( hwnd, IDC_PLAY), FALSE );
}
//
// Show status text
//
TCHAR pszStatus[256 + 1];
LoadString(GetModuleHandle(NULL), IDS_STATUSTEXT, pszStatus, 256);
wsprintf( psz, pszStatus, nCount );
SetDlgItemText(IDC_ROMCOUNT, psz );
CString status;
status.Format(IDS_STATUSTEXT, m_List.GetItemCount());
SetDlgItemText(IDC_ROMCOUNT,status);
//
// Show rom path
//
SetDlgItemText(IDC_ROMPATH, m_pGlobalData->romDir);
//ToDo: SetDlgItemText(IDC_ROMPATH, m_pGlobalData->romDir);
//
// Set default button
//
::SendMessage( hwnd, DM_SETDEFID, IDC_PLAY, 0 );
::SendMessage( *this, DM_SETDEFID, IDC_PLAY, 0 );
}
/////////////////////////////////////////////////////////////////////////////
@ -194,356 +129,40 @@ CCyberstellaDoc* CCyberstellaView::GetDocument() // non-debug version is inline
}
#endif //_DEBUG
////////////////////////////
// Listview compare function
int CALLBACK CCyberstellaView::ListViewCompareFunc(LPARAM lParam1, LPARAM lParam2,
LPARAM lParamSort)
{
CCyberstellaView* pThis = reinterpret_cast<CCyberstellaView*>( lParamSort );
//
// I assume that the metadata for column 0 is always available,
// while other column metadata requires a call to ReadRomData
//
int nSortCol = lParamSort;
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 );
}
void CCyberstellaView::OnConfig()
{
StellaConfig dlg(m_pGlobalData);
dlg.DoModal();
}
DWORD CCyberstellaView::PopulateRomList()
{
DWORD dwRet;
ClearList();
TCHAR pszPath[ MAX_PATH ];
lstrcpy( pszPath, m_pGlobalData->romDir);
lstrcat( pszPath, _T("\\*.bin") );
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile( pszPath, &ffd );
ListView_SetItemCount(m_List, 100);
int iItem = 0;
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;
}
dwRet = pListData->Initialize();
if ( dwRet != ERROR_SUCCESS )
{
return dwRet;
}
if ( ! pListData->m_strFileName.Set( ffd.cFileName ) )
{
return FALSE;
}
LV_ITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iItem = iItem++;
lvi.iSubItem = 0;
lvi.pszText = ffd.cFileName;
lvi.lParam = (LPARAM)pListData;
m_List.InsertItem (&lvi);
//TODO: Display the Rest
/*int nItem = ListView_InsertItem(m_List, &lvi);
ASSERT( nItem != -1 );
ListView_SetItemText(m_List, nItem,
CListData::FILENAME_COLUMN, LPSTR_TEXTCALLBACK );
ListView_SetItemText(m_List, nItem,
CListData::MANUFACTURER_COLUMN, LPSTR_TEXTCALLBACK);
ListView_SetItemText(m_List, nItem,
CListData::RARITY_COLUMN, LPSTR_TEXTCALLBACK );*/
// go to the next rom file
fDone = !FindNextFile(hFind, &ffd);
}
if ( hFind != INVALID_HANDLE_VALUE )
{
VERIFY( ::FindClose( hFind ) );
}
return ERROR_SUCCESS;
}
void CCyberstellaView::ClearList()
{
int nCount = ListView_GetItemCount(m_List);
for (int i = 0; i < nCount; ++i)
{
ListView_DeleteItem(m_List,0);
}
ListView_DeleteAllItems(m_List);
}
DWORD CCyberstellaView::ReadRomData(CListData* pListData) const
{
// TODO: Move this method to ListData class (?)
if ( pListData == NULL )
{
ASSERT( FALSE );
return ERROR_BAD_ARGUMENTS;
}
// attempt to read the rom file
TCHAR pszPath[MAX_PATH + 1];
lstrcpy( pszPath, m_pGlobalData->romDir);
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 = GetPropertiesSet();
Properties properties;
propertiesSet.getMD5(md5, properties);
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;
}
}
delete[] pImage;
VERIFY( ::CloseHandle( hFile ) );
pListData->m_fPopulated = TRUE;
return ERROR_SUCCESS;
}
void CCyberstellaView::OnPlay()
{
CListData* pListData;
int nItem;
EnableWindow(FALSE);
nItem = (int)::SendMessage( m_List,
LVM_GETNEXTITEM,
(WPARAM)-1,
MAKELPARAM( LVNI_SELECTED, 0 ) );
ASSERT( nItem != -1 );
if ( nItem == -1 )
{
::MessageBox( GetModuleHandle(NULL),
*this,
IDS_NO_ITEM_SELECTED );
return;
}
CString fileName = m_List.getCurrentFile();
pListData = (CListData*)m_List.GetItemData(nItem);
TCHAR pszPathName[ MAX_PATH + 1 ];
lstrcpy( pszPathName, m_pGlobalData->romDir);
lstrcat( pszPathName, _T("\\") );
lstrcat( pszPathName,
pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
// Play the game!
::EnableWindow(*this, FALSE );
PlayROM( *this,
pszPathName,
pListData->GetTextForColumn( CListData::NAME_COLUMN ),
m_pGlobalData);
::EnableWindow( *this, TRUE );
// Set focus back to the rom list
::SetFocus(m_List);
}
// Toggles pausing of the emulator
void CCyberstellaView::togglePause()
{
m_bIsPause = !m_bIsPause;
//TODO: theConsole->mediaSource().pause(m_bIsPause);
}
DWORD CCyberstellaView::Initialize()
{
TRACE( "CStellaXMain::SetupProperties" );
// Create a properties set for us to use
if ( m_pPropertiesSet )
{
return ERROR_SUCCESS;
}
m_pPropertiesSet = new PropertiesSet();
if ( m_pPropertiesSet == NULL )
{
return ERROR_NOT_ENOUGH_MEMORY;
}
// Try to load the file stella.pro file
string filename( "stella.pro" );
// See if we can open the file and load properties from it
ifstream stream(filename.c_str());
if(stream)
{
// File was opened so load properties from it
stream.close();
m_pPropertiesSet->load(filename, &Console::defaultProperties());
}
else
{
m_pPropertiesSet->load("", &Console::defaultProperties());
}
return ERROR_SUCCESS;
}
HRESULT CCyberstellaView::PlayROM(HWND hwnd,
LPCTSTR pszPathName,
LPCTSTR pszFriendlyName,
CGlobalData* rGlobalData)
{
UNUSED_ALWAYS( hwnd );
HRESULT hr = S_OK;
TRACE("CStellaXMain::PlayROM");
//
// show wait cursor while loading
//
HCURSOR hcur = ::SetCursor( ::LoadCursor( NULL, IDC_WAIT ) );
//
// setup objects used here
//
BYTE* pImage = NULL;
LPCTSTR pszFileName = NULL;
// Safety Bail Out
if(fileName.GetLength() <= 0) return;
#ifdef USE_FS
CDirectXFullScreen* pwnd = NULL;
#else
CDirectXWindow* pwnd = NULL;
#endif
BYTE* pImage = NULL;
LPCTSTR pszFileName = NULL;
Console* pConsole = NULL;
Sound* pSound = NULL;
Event rEvent;
//
// Load the rom file
//
// show wait cursor while loading
HCURSOR hcur = ::SetCursor(::LoadCursor(NULL, IDC_WAIT));
// Load the rom file
HANDLE hFile;
DWORD dwImageSize;
hFile = ::CreateFile( pszPathName,
hFile = ::CreateFile( fileName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
@ -552,8 +171,6 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
NULL );
if (hFile == INVALID_HANDLE_VALUE)
{
HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hwnd, GWL_HINSTANCE );
DWORD dwLastError = ::GetLastError();
TCHAR pszCurrentDirectory[ MAX_PATH + 1 ];
@ -561,7 +178,7 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
// ::MessageBoxFromGetLastError( pszPathName );
TCHAR pszFormat[ 1024 ];
LoadString( hInstance,
LoadString(GetModuleHandle(NULL),
IDS_ROM_LOAD_FAILED,
pszFormat, 1023 );
@ -580,18 +197,17 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
wsprintf( pszError,
pszFormat,
pszCurrentDirectory,
pszPathName,
fileName,
dwLastError,
pszLastError );
::MessageBox( hwnd,
::MessageBox( *this,
pszError,
_T("Error"),
MB_OK | MB_ICONEXCLAMATION );
::LocalFree( pszLastError );
hr = HRESULT_FROM_WIN32( ::GetLastError() );
goto exit;
}
@ -600,7 +216,6 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
pImage = new BYTE[dwImageSize + 1];
if ( pImage == NULL )
{
hr = E_OUTOFMEMORY;
goto exit;
}
@ -609,9 +224,8 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
{
VERIFY( ::CloseHandle( hFile ) );
MessageBoxFromGetLastError( pszPathName );
MessageBoxFromGetLastError(fileName);
hr = HRESULT_FROM_WIN32( ::GetLastError() );
goto exit;
}
@ -622,7 +236,7 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
// (Will be initialized once we have a window handle below)
//
if (rGlobalData->bNoSound)
if (m_pGlobalData->bNoSound)
{
TRACE("Creating Sound driver");
pSound = new Sound;
@ -634,7 +248,6 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
}
if ( pSound == NULL )
{
hr = E_OUTOFMEMORY;
goto exit;
}
@ -642,14 +255,14 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
// get just the filename
//
pszFileName = _tcsrchr( pszPathName, _T('\\') );
pszFileName = _tcsrchr( fileName, _T('\\') );
if ( pszFileName )
{
++pszFileName;
}
else
{
pszFileName = pszPathName;
pszFileName = fileName;
}
try
@ -664,36 +277,36 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
*pSound );
if ( pConsole == NULL )
{
hr = E_OUTOFMEMORY;
goto exit;
}
}
catch (...)
{
::MessageBox(rGlobalData->instance,
::MessageBox(GetModuleHandle(NULL),
NULL, IDS_CANTSTARTCONSOLE);
goto exit;
}
#ifdef USE_FS
pwnd = new CDirectXFullScreen( rGlobalData,
pwnd = new CDirectXFullScreen( m_pGlobalData,
pConsole,
rEvent );
#else
pwnd = new CDirectXWindow( rGlobalData,
pwnd = new CDirectXWindow( m_pGlobalData,
pConsole,
rEvent );
#endif
if ( pwnd == NULL )
{
hr = E_OUTOFMEMORY;
goto exit;
}
HRESULT hr;
#ifdef USE_FS
if (rGlobalData->bAutoSelectVideoMode)
if (m_pGlobalData->bAutoSelectVideoMode)
{
hr = pwnd->Initialize( );
}
@ -706,7 +319,7 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
hr = pwnd->Initialize( FORCED_VIDEO_CX, FORCED_VIDEO_CY );
}
#else
hr = pwnd->Initialize( hwnd, pszFriendlyName );
hr = pwnd->Initialize(*this, m_List.getCurrentName());
#endif
if ( FAILED(hr) )
{
@ -714,7 +327,7 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
goto exit;
}
if (!rGlobalData->bNoSound)
if (!m_pGlobalData->bNoSound)
{
//
// 060499: Pass pwnd->GetHWND() in instead of hwnd as some systems
@ -736,11 +349,11 @@ HRESULT CCyberstellaView::PlayROM(HWND hwnd,
::SetCursor( hcur );
hcur = NULL;
::ShowWindow( hwnd, SW_HIDE );
::ShowWindow( *this, SW_HIDE );
(void)pwnd->Run();
::ShowWindow( hwnd, SW_SHOW );
::ShowWindow( *this, SW_SHOW );
exit:
@ -755,5 +368,69 @@ exit:
delete pSound;
delete pImage;
return hr;
EnableWindow(TRUE);
// Set focus back to the rom list
m_List.SetFocus();
}
// Toggles pausing of the emulator
void CCyberstellaView::togglePause()
{
m_bIsPause = !m_bIsPause;
//TODO: theConsole->mediaSource().pause(m_bIsPause);
}
void CCyberstellaView::Initialize()
{
// Create a properties set for us to use
m_pPropertiesSet = new PropertiesSet();
// Set up the image list.
HICON hFolder, hAtari;
m_imglist.Create ( 16, 16, ILC_COLOR16 | ILC_MASK, 4, 1 );
hFolder = reinterpret_cast<HICON>(
::LoadImage ( AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_FOLDER),
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR ));
hAtari = reinterpret_cast<HICON>(
::LoadImage ( AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR ));
m_imglist.Add (hFolder);
m_imglist.Add (hAtari);
m_List.SetImageList (&m_imglist, LVSIL_SMALL);
// Init ListCtrl
m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_List.insertColumns();
m_List.setPropertiesSet(m_pPropertiesSet);
// Try to load the file stella.pro file
string filename( "stella.pro" );
// See if we can open the file and load properties from it
ifstream stream(filename.c_str());
if(stream)
{
// File was opened so load properties from it
stream.close();
m_pPropertiesSet->load(filename, &Console::defaultProperties());
}
else
{
m_pPropertiesSet->load("", &Console::defaultProperties());
}
// Fill our game list
m_List.populateRomList();
}
void CCyberstellaView::OnDestroy()
{
CFormView::OnDestroy();
m_List.deleteItemsAndProperties();
}

View File

@ -10,8 +10,8 @@
#endif // _MSC_VER > 1000
#include "GlobalData.hxx"
#include "ListData.hxx"
#include "PropsSet.hxx"
#include "GameList.h"
class CCyberstellaView : public CFormView
{
@ -22,13 +22,14 @@ protected: // create from serialization only
public:
//{{AFX_DATA(CCyberstellaView)
enum { IDD = IDD_CYBERSTELLA_FORM };
CListCtrl m_List;
GameList m_List;
//}}AFX_DATA
// Attributes
public:
CCyberstellaDoc* GetDocument();
CGlobalData* m_pGlobalData;
CImageList m_imglist;
// Operations
public:
@ -58,21 +59,14 @@ protected:
//{{AFX_MSG(CCyberstellaView)
afx_msg void OnConfig();
afx_msg void OnPlay();
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
// methods
PropertiesSet& GetPropertiesSet() const {return *m_pPropertiesSet;}
static int CALLBACK ListViewCompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort );
DWORD PopulateRomList();
void ClearList();
void togglePause();
DWORD ReadRomData(CListData* pListData) const;
DWORD Initialize();
HRESULT PlayROM( HWND hwnd, LPCTSTR ctszPathName,
LPCTSTR pszFriendlyName,
CGlobalData* rGlobalData );
void Initialize();
// members
PropertiesSet* m_pPropertiesSet;
bool m_bIsPause;

View File

@ -11,7 +11,6 @@ CGlobalData::CGlobalData(HINSTANCE hInstance)
,bIsModified(FALSE)
,rs("GlobalData")
{
rs.Bind(romDir, "rom dir", "ROMS");
rs.Bind(desiredFrameRate, "desired frame rate", 60);
rs.Bind(bShowFPS, "Show FPS", false);
rs.Bind(bNoSound, "No Sound", false);

View File

@ -21,7 +21,6 @@ public:
Event::Type PaddleFireEvent( void ) const;
// Data Members in Registry
CString romDir;
int iPaddleMode;
BOOL bNoSound;
BOOL bJoystickIsDisabled;

View File

@ -1 +1,18 @@
Cyberstella V1.0 by Manuel Polik
Cyberstella V1.2 by Manuel Polik
Currently Open Todos:
Urgent:
- Make Listcontrol react on ENTER
- Update Displays when list changes
Later:
- More Columns / Advanced sorting
- Clean OnPlay Routine
- Make whole screen resizable
- Check other versions command line params
- Check other versions keyboard mapping
- Add Screenshots - F12
- Add Pause - F3
- Add Fullscreen / Windowed mode -F4
- Check Direct Draw implementation

View File

@ -4,7 +4,6 @@
#include "pch.hxx"
#include "Cyberstella.h"
#include "StellaConfig.h"
#include "BrowseForFolder.hxx"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -38,7 +37,6 @@ void StellaConfig::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(StellaConfig, CDialog)
//{{AFX_MSG_MAP(StellaConfig)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_BN_CLICKED(IDC_CONTINUE, OnContinue)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@ -52,10 +50,6 @@ BOOL StellaConfig::OnInitDialog()
int i;
// Set up ROMPATH
((CEdit*)GetDlgItem(IDC_ROMPATH))->SetLimitText(MAX_PATH);
((CEdit*)GetDlgItem(IDC_ROMPATH))->SetWindowText(m_pGlobalData->romDir);
// Set up PADDLE
CString paddle = "Paddle%d";
for (i=0; i<4; i++)
@ -93,7 +87,6 @@ BOOL StellaConfig::DestroyWindow()
void StellaConfig::retrieveData()
{
// Apply changes
((CEdit*)GetDlgItem(IDC_ROMPATH))->GetWindowText(m_pGlobalData->romDir);
m_pGlobalData->iPaddleMode = ((CComboBox*)GetDlgItem(IDC_PADDLE))->GetCurSel();
m_pGlobalData->bNoSound = ((CButton*)GetDlgItem(IDC_SOUND))->GetCheck();
m_pGlobalData->bAutoSelectVideoMode = ((CButton*)GetDlgItem(IDC_AUTO_SELECT_VIDEOMODE))->GetCheck();
@ -103,18 +96,6 @@ void StellaConfig::retrieveData()
m_pGlobalData->bIsModified = true;
}
void StellaConfig::OnBrowse()
{
CBrowseForFolder bff;
bff.SetFlags(BIF_RETURNONLYFSDIRS);
if (bff.SelectFolder())
{
((CEdit*)GetDlgItem(IDC_ROMPATH))->SetWindowText(bff.GetSelectedFolder());
}
// Set Focus to Continue Button
((CWnd*)GetDlgItem(IDC_CONTINUE))->SetFocus();
}
void StellaConfig::OnContinue()
{
EndDialog(1);

View File

@ -7,6 +7,7 @@
#define IDD_CONFIG_PAGE 108
#define IDR_MAINFRAME 128
#define IDR_CYBERSTYPE 129
#define IDI_FOLDER 133
#define IDS_ALREADYRUNNING 200
#define IDS_BADARGUMENT 201
#define IDS_CW_FAILED 208
@ -22,6 +23,7 @@
#define IDS_MIKE 279
#define IDS_NAME 280
#define IDS_NODIRECTDRAW 281
#define IDS_FILE 282
#define IDS_RARITY 284
#define IDS_STATUSTEXT 289
#define IDS_STELLA 290
@ -58,7 +60,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_RESOURCE_VALUE 134
#define _APS_NEXT_COMMAND_VALUE 32775
#define _APS_NEXT_CONTROL_VALUE 1005
#define _APS_NEXT_SYMED_VALUE 101