Some more code cleanups for the StellaX frontend. The configuration

dialog actually works now without crashing the program.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@250 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2004-05-27 22:02:35 +00:00
parent a0f6eaa4ff
commit 2f1d07c207
9 changed files with 735 additions and 1020 deletions

View File

@ -1,36 +1,45 @@
// //============================================================================
// StellaX //
// Jeff Miller 04/27/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: AboutPage.cxx,v 1.2 2004-05-27 22:02:35 stephena Exp $
//============================================================================
#include "pch.hxx" #include "pch.hxx"
#include "AboutPage.hxx" #include "AboutPage.hxx"
#include "resource.h" #include "resource.h"
CHelpPage::CHelpPage( CHelpPage::CHelpPage()
) : \ : CPropertyPage(IDD_ABOUT_PAGE)
CPropertyPage(IDD_ABOUT_PAGE)
{ {
} }
BOOL CHelpPage::OnInitDialog( BOOL CHelpPage::OnInitDialog( HWND hwnd )
HWND hwnd
)
{ {
m_hlMail_JSM.SubclassDlgItem( hwnd, IDC_EMAIL_MAINTAINER ); m_hlMail_JSM.SubclassDlgItem( hwnd, IDC_EMAIL_MAINTAINER );
m_hlMail_JSM.SetURL( _T("mailto:sa666_666@hotmail.com?Subject=StellaX") ); m_hlMail_JSM.SetURL( _T("mailto:sa666_666@hotmail.com?Subject=StellaX") );
m_hlWWW_JSM.SubclassDlgItem( hwnd, IDC_WEB_MAINTAINER ); m_hlWWW_JSM.SubclassDlgItem( hwnd, IDC_WEB_MAINTAINER );
m_hlWWW_JSM.SetURL( _T("http://minbar.org") ); m_hlWWW_JSM.SetURL( _T("http://minbar.org") );
m_hlMail_Stella.SubclassDlgItem( hwnd, IDC_EMAIL_STELLA ); m_hlMail_Stella.SubclassDlgItem( hwnd, IDC_EMAIL_STELLA );
m_hlMail_Stella.SetURL( _T("mailto:stella-main@lists.sourceforge.net") ); m_hlMail_Stella.SetURL( _T("mailto:stella-main@lists.sourceforge.net") );
m_hlWWW_Stella.SubclassDlgItem( hwnd, IDC_WEB_STELLA ); m_hlWWW_Stella.SubclassDlgItem( hwnd, IDC_WEB_STELLA );
m_hlWWW_Stella.SetURL( _T("http://stella.sf.net") ); m_hlWWW_Stella.SetURL( _T("http://stella.sf.net") );
m_hlWWW_Mame.SubclassDlgItem( hwnd, IDC_WWW_MAME ); // return FALSE if SetFocus is called
m_hlWWW_Mame.SetURL( _T("http://www.classicgaming.com/mame32qa/") ); return TRUE;
// return FALSE if SetFocus is called
return TRUE;
} }

View File

@ -1,34 +1,45 @@
// //============================================================================
// StellaX //
// Jeff Miller 05/01/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: AboutPage.hxx,v 1.2 2004-05-27 22:02:35 stephena Exp $
//============================================================================
#ifndef ABOUTPG_H #ifndef ABOUTPG_H
#define ABOUTPG_H #define ABOUTPG_H
#pragma once //FIXME#pragma once
#include "PropertySheet.hxx" #include "PropertySheet.hxx"
#include "HyperLink.hxx" #include "HyperLink.hxx"
class CHelpPage : public CPropertyPage class CHelpPage : public CPropertyPage
{ {
public: public:
CHelpPage();
CHelpPage(); protected:
virtual BOOL OnInitDialog( HWND hwnd );
protected: private:
CHyperLink m_hlMail_JSM;
CHyperLink m_hlWWW_JSM;
CHyperLink m_hlMail_Stella;
CHyperLink m_hlWWW_Stella;
virtual BOOL OnInitDialog( HWND hwnd ); CHelpPage( const CHelpPage& ); // no implementation
void operator=( const CHelpPage& ); // no implementation
private:
CHyperLink m_hlMail_JSM;
CHyperLink m_hlWWW_JSM;
CHyperLink m_hlMail_Stella;
CHyperLink m_hlWWW_Stella;
CHyperLink m_hlWWW_Mame;
CHelpPage( const CHelpPage& ); // no implementation
void operator=( const CHelpPage& ); // no implementation
}; };
#endif #endif

View File

@ -1,154 +1,106 @@
// //============================================================================
// StellaX //
// Jeff Miller 05/07/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: ConfigPage.cxx,v 1.2 2004-05-27 22:02:35 stephena Exp $
//============================================================================
#include "pch.hxx" #include "pch.hxx"
#include "ConfigPage.hxx" #include "ConfigPage.hxx"
#include "resource.h" #include "resource.h"
#include "BrowseForFolder.hxx" #include "BrowseForFolder.hxx"
CConfigPage::CConfigPage( CConfigPage::CConfigPage( CGlobalData& rGlobalData )
CGlobalData& rGlobalData : m_rGlobalData( rGlobalData ),
) : \ CPropertyPage( IDD_CONFIG_PAGE )
m_rGlobalData( rGlobalData ),
CPropertyPage( IDD_CONFIG_PAGE )
{ {
} }
BOOL CConfigPage::OnInitDialog( BOOL CConfigPage::OnInitDialog( HWND hwnd )
HWND hwnd
)
{ {
// return FALSE if SetFocus is called // return FALSE if SetFocus is called
m_hwnd = hwnd;
m_hwnd = hwnd; HWND hwndCtrl;
HWND hwndCtrl;
// // Set up ROMPATH
// Set up ROMPATH hwndCtrl = ::GetDlgItem( hwnd, IDC_ROMPATH );
// ::SendMessage( hwndCtrl, EM_LIMITTEXT, MAX_PATH, 0 );
::SetWindowText( hwndCtrl, m_rGlobalData.RomDir() );
hwndCtrl = ::GetDlgItem( hwnd, IDC_ROMPATH ); // Set up PADDLE
::SendMessage( hwndCtrl, EM_LIMITTEXT, MAX_PATH, 0 ); hwndCtrl = ::GetDlgItem( hwnd, IDC_PADDLE );
::SetWindowText( hwndCtrl, m_rGlobalData.RomDir() );
// TCHAR psz[4] = _T("0");
// Set up PADDLE TCHAR i;
// for ( i = 0; i < 4; ++i )
{
psz[0] = _T('0') + i;
::SendMessage( hwndCtrl, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)psz );
}
hwndCtrl = ::GetDlgItem( hwnd, IDC_PADDLE ); ::SendMessage( hwndCtrl, CB_SETCURSEL, m_rGlobalData.PaddleMode(), 0 );
LPTSTR psz = _T("0"); // Set up SOUND
TCHAR i; hwndCtrl = ::GetDlgItem( hwnd, IDC_SOUND );
for ( i = 0; i < 4; ++i ) ::SendMessage( hwndCtrl, BM_SETCHECK, m_rGlobalData.NoSound() ? BST_CHECKED : BST_UNCHECKED, 0 );
{
psz[0] = _T('0') + i;
::SendMessage( hwndCtrl, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)psz );
}
::SendMessage( hwndCtrl, CB_SETCURSEL, return TRUE;
m_rGlobalData.PaddleMode(), 0 );
//
// Set up SOUND
//
hwndCtrl = ::GetDlgItem( hwnd, IDC_SOUND );
::SendMessage( hwndCtrl, BM_SETCHECK,
m_rGlobalData.NoSound() ? BST_CHECKED : BST_UNCHECKED,
0 );
//
// Set up AutoSelectVideoMode
//
hwndCtrl = ::GetDlgItem( hwnd, IDC_AUTO_SELECT_VIDEOMODE );
::SendMessage( hwndCtrl, BM_SETCHECK,
m_rGlobalData.AutoSelectVideoMode() ? BST_CHECKED : BST_UNCHECKED,
0 );
//
// Set up JOYSTICK
//
hwndCtrl = ::GetDlgItem( hwnd, IDC_JOYSTICK );
::SendMessage( hwndCtrl, BM_SETCHECK,
m_rGlobalData.DisableJoystick() ? BST_CHECKED : BST_UNCHECKED,
0 );
return TRUE;
} }
void CConfigPage::OnDestroy( void CConfigPage::OnDestroy( void )
void
)
{ {
} }
LONG CConfigPage::OnApply( LONG CConfigPage::OnApply( LPPSHNOTIFY lppsn )
LPPSHNOTIFY lppsn
)
{ {
UNUSED_ALWAYS( lppsn ); UNUSED_ALWAYS( lppsn );
// // Apply the changes
// Apply the changes // HWND hwnd = lppsn->hdr.hwndFrom; <<-- points to the sheet!
//
// HWND hwnd = lppsn->hdr.hwndFrom; <<-- points to the sheet! HWND hwndCtrl;
HWND hwndCtrl; hwndCtrl = ::GetDlgItem( m_hwnd, IDC_ROMPATH );
ASSERT( hwndCtrl );
::GetWindowText( hwndCtrl, m_rGlobalData.m_pszRomDir, MAX_PATH );
hwndCtrl = ::GetDlgItem( m_hwnd, IDC_ROMPATH ); hwndCtrl = ::GetDlgItem( m_hwnd, IDC_PADDLE );
ASSERT( hwndCtrl ); ASSERT( hwndCtrl );
::GetWindowText( hwndCtrl, m_rGlobalData.m_pszRomDir, MAX_PATH ); m_rGlobalData.m_nPaddleMode = ::SendMessage( hwndCtrl, CB_GETCURSEL, 0, 0 );
hwndCtrl = ::GetDlgItem( m_hwnd, IDC_PADDLE ); hwndCtrl = ::GetDlgItem( m_hwnd, IDC_SOUND );
ASSERT( hwndCtrl ); ASSERT( hwndCtrl );
m_rGlobalData.m_nPaddleMode = ::SendMessage( hwndCtrl, CB_GETCURSEL, 0, 0 ); m_rGlobalData.m_fNoSound = ( ::SendMessage( hwndCtrl, BM_GETCHECK, 0, 0 ) == BST_CHECKED );
hwndCtrl = ::GetDlgItem( m_hwnd, IDC_SOUND ); m_rGlobalData.SetModified();
ASSERT( hwndCtrl );
m_rGlobalData.m_fNoSound = ( ::SendMessage( hwndCtrl, BM_GETCHECK, 0, 0 )
== BST_CHECKED );
hwndCtrl = ::GetDlgItem( m_hwnd, IDC_AUTO_SELECT_VIDEOMODE ); return PSNRET_NOERROR;
ASSERT( hwndCtrl );
m_rGlobalData.m_fAutoSelectVideoMode = ( ::SendMessage( hwndCtrl, BM_GETCHECK, 0, 0 )
== BST_CHECKED );
hwndCtrl = ::GetDlgItem( m_hwnd, IDC_JOYSTICK );
ASSERT( hwndCtrl );
m_rGlobalData.m_fDisableJoystick= ( ::SendMessage( hwndCtrl, BM_GETCHECK, 0, 0 )
== BST_CHECKED );
m_rGlobalData.SetModified();
return PSNRET_NOERROR;
} }
BOOL CConfigPage::OnCommand( BOOL CConfigPage::OnCommand( WORD wNotifyCode, WORD wID, HWND hwndCtl )
WORD wNotifyCode,
WORD wID,
HWND hwndCtl
)
{ {
UNUSED_ALWAYS( wNotifyCode ); UNUSED_ALWAYS( wNotifyCode );
UNUSED_ALWAYS( hwndCtl ); UNUSED_ALWAYS( hwndCtl );
if ( wID == IDC_BROWSE ) if ( wID == IDC_BROWSE )
{ {
CBrowseForFolder bff( m_hwnd ); CBrowseForFolder bff( m_hwnd );
bff.SetFlags( BIF_RETURNONLYFSDIRS ); 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

@ -1,37 +1,47 @@
// //============================================================================
// StellaX //
// Jeff Miller 05/07/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: ConfigPage.hxx,v 1.2 2004-05-27 22:02:35 stephena Exp $
//============================================================================
#ifndef CONFIGPG_H #ifndef CONFIGPG_H
#define CONFIGPG_H #define CONFIGPG_H
#pragma once //FIXME #pragma once
#include "PropertySheet.hxx" #include "PropertySheet.hxx"
#include "GlobalData.hxx" #include "GlobalData.hxx"
class CConfigPage : public CPropertyPage class CConfigPage : public CPropertyPage
{ {
public: public:
CConfigPage( CGlobalData& rGlobalData );
CConfigPage( CGlobalData& rGlobalData ); protected:
virtual BOOL OnInitDialog( HWND hwnd );
virtual void OnDestroy();
virtual LONG OnApply( LPPSHNOTIFY lppsn );
protected: virtual BOOL OnCommand( WORD /* wNotifyCode */, WORD /* wID */, HWND /* hwndCtl */ );
virtual BOOL OnInitDialog( HWND hwnd );
virtual void OnDestroy();
virtual LONG OnApply( LPPSHNOTIFY lppsn );
virtual BOOL OnCommand( WORD /* wNotifyCode */, WORD /* wID */, HWND /* hwndCtl */ );
private:
private:
CGlobalData& m_rGlobalData; CGlobalData& m_rGlobalData;
HWND m_hwnd; HWND m_hwnd;
CConfigPage( const CConfigPage& ); // no implementation CConfigPage( const CConfigPage& ); // no implementation
void operator=( const CConfigPage& ); // no implementation void operator=( const CConfigPage& ); // no implementation
}; };
#endif #endif

View File

@ -1,22 +1,33 @@
// //============================================================================
// StellaX //
// Jeff Miller 05/06/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: GlobalData.cxx,v 1.2 2004-05-27 22:02:35 stephena Exp $
//============================================================================
#include "pch.hxx" #include "pch.hxx"
#include "GlobalData.hxx" #include "GlobalData.hxx"
#include "resource.h" #include "resource.h"
static LPCTSTR g_pszIniFile = _T(".\\stella.ini"); static LPCTSTR g_pszIniFile = _T(".\\stellax.ini");
static LPCTSTR g_pszIniSection = _T("Options"); static LPCTSTR g_pszIniSection = _T("Options");
static LPCTSTR g_pszKeyNameRomPath = _T("RomPath"); static LPCTSTR g_pszKeyNameRomPath = _T("RomPath");
static LPCTSTR g_pszKeyNameFrameRate = _T("FrameRate"); static LPCTSTR g_pszKeyNameFrameRate = _T("FrameRate");
static LPCTSTR g_pszKeyNameShowFPS = _T("ShowFPS");
static LPCTSTR g_pszKeyNameMute = _T("Mute"); static LPCTSTR g_pszKeyNameMute = _T("Mute");
static LPCTSTR g_pszKeyNamePaddle = _T("Paddle"); static LPCTSTR g_pszKeyNamePaddle = _T("Paddle");
static LPCTSTR g_pszKeyNameDisableJoystick = _T("DisableJoystick");
static LPCTSTR g_pszKeyNameAutoSelectVideoMode = _T("AutoSelectVideoMode");
BOOL WritePrivateProfileInt( BOOL WritePrivateProfileInt(
LPCTSTR lpAppName, // section name LPCTSTR lpAppName, // section name
@ -25,133 +36,80 @@ BOOL WritePrivateProfileInt(
LPCTSTR lpFileName // initialization file LPCTSTR lpFileName // initialization file
) )
{ {
TCHAR psz[ 50 ]; TCHAR psz[ 50 ];
_itoa( nValue, psz, 10 ); _itoa( nValue, psz, 10 );
return ::WritePrivateProfileString( lpAppName, return ::WritePrivateProfileString( lpAppName, lpKeyName, psz, lpFileName );
lpKeyName,
psz,
lpFileName );
} }
CGlobalData::CGlobalData( CGlobalData::CGlobalData( HINSTANCE hInstance )
HINSTANCE hInstance : m_hInstance(hInstance),
) : \ m_fIsModified( FALSE )
m_hInstance(hInstance),
m_fIsModified( FALSE )
{ {
m_pszPathName[0] = _T('\0'); m_pszPathName[0] = _T('\0');
// // Read the ROM directory from the stella.ini file
// Read the ROM directory from the stella.ini file // default to "ROMS" directory for compatibility with older StellaX
// default to "ROMS" directory for compatibility with older StellaX ::GetPrivateProfileString( g_pszIniSection,
// g_pszKeyNameRomPath,
_T("ROMS"),
m_pszRomDir, _MAX_PATH,
g_pszIniFile);
::GetPrivateProfileString( g_pszIniSection, // Read the desired frame rate
g_pszKeyNameRomPath, m_nDesiredFrameRate = (int)::GetPrivateProfileInt( g_pszIniSection,
_T("ROMS"), g_pszKeyNameFrameRate,
m_pszRomDir, _MAX_PATH, 60,
g_pszIniFile); g_pszIniFile );
if (m_nDesiredFrameRate < 1 || m_nDesiredFrameRate > 300)
m_nDesiredFrameRate = 60;
// Read the desired frame rate // Read Mute
m_fNoSound = (BOOL)::GetPrivateProfileInt( g_pszIniSection,
g_pszKeyNameMute,
FALSE,
g_pszIniFile );
m_nDesiredFrameRate = (int)::GetPrivateProfileInt( g_pszIniSection, // Read the Paddle mode
g_pszKeyNameFrameRate, m_nPaddleMode = (int)::GetPrivateProfileInt( g_pszIniSection,
60, g_pszKeyNamePaddle,
g_pszIniFile ); 0,
if (m_nDesiredFrameRate < 1 || m_nDesiredFrameRate > 300)
{
m_nDesiredFrameRate = 60;
}
// Read ShowFPS
m_fShowFPS = (BOOL)::GetPrivateProfileInt( g_pszIniSection,
g_pszKeyNameShowFPS,
FALSE,
g_pszIniFile); g_pszIniFile);
if ( m_nPaddleMode < 0 || m_nPaddleMode > 3 )
// m_nPaddleMode = 0;
// Read Mute
//
m_fNoSound = (BOOL)::GetPrivateProfileInt( g_pszIniSection,
g_pszKeyNameMute,
FALSE,
g_pszIniFile );
//
// Get AutoSelectVideoMode
//
m_fAutoSelectVideoMode =
(BOOL)::GetPrivateProfileInt( g_pszIniSection,
g_pszKeyNameAutoSelectVideoMode,
TRUE,
g_pszIniFile );
//
// Read the Paddle mode
//
m_nPaddleMode = (int)::GetPrivateProfileInt( g_pszIniSection,
g_pszKeyNamePaddle,
0,
g_pszIniFile);
if ( m_nPaddleMode < 0 || m_nPaddleMode > 3 )
{
m_nPaddleMode = 0;
}
// Read DisableJoystick
m_fDisableJoystick = (BOOL)::GetPrivateProfileInt( g_pszIniSection,
g_pszKeyNameDisableJoystick,
FALSE,
g_pszIniFile );
} }
CGlobalData::~CGlobalData( CGlobalData::~CGlobalData()
)
{ {
// // Write out settings (if changed)
// Write out settings (if changed) if ( m_fIsModified )
// {
// RomPath
::WritePrivateProfileString( g_pszIniSection,
g_pszKeyNameRomPath,
m_pszRomDir,
g_pszIniFile );
if ( m_fIsModified ) // FrameRate
{ ::WritePrivateProfileInt( g_pszIniSection,
::WritePrivateProfileString( g_pszIniSection, g_pszKeyNameFrameRate,
g_pszKeyNameRomPath, m_nDesiredFrameRate,
m_pszRomDir, g_pszIniFile );
g_pszIniFile );
::WritePrivateProfileInt( g_pszIniSection, // Mute
g_pszKeyNameFrameRate, ::WritePrivateProfileInt( g_pszIniSection,
m_nDesiredFrameRate, g_pszKeyNameMute,
g_pszIniFile ); m_fNoSound,
g_pszIniFile );
::WritePrivateProfileInt( g_pszIniSection, // Paddle
g_pszKeyNameMute, ::WritePrivateProfileInt( g_pszIniSection,
m_fNoSound, g_pszKeyNamePaddle,
g_pszIniFile ); m_nPaddleMode,
g_pszIniFile );
::WritePrivateProfileInt( g_pszIniSection, }
g_pszKeyNameAutoSelectVideoMode,
m_fAutoSelectVideoMode,
g_pszIniFile );
::WritePrivateProfileInt( g_pszIniSection,
g_pszKeyNamePaddle,
m_nPaddleMode,
g_pszIniFile );
::WritePrivateProfileInt( g_pszIniSection,
g_pszKeyNameDisableJoystick,
m_fDisableJoystick,
g_pszIniFile );
}
} }
BOOL CGlobalData::ParseCommandLine( BOOL CGlobalData::ParseCommandLine(

View File

@ -1,10 +1,24 @@
// //============================================================================
// StellaX //
// Jeff Miller 05/06/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: GlobalData.hxx,v 1.2 2004-05-27 22:02:35 stephena Exp $
//============================================================================
#ifndef GLOBALS_H #ifndef GLOBALS_H
#define GLOBALS_H #define GLOBALS_H
#pragma once
#include "pch.hxx" #include "pch.hxx"
@ -12,111 +26,75 @@ class CConfigPage;
class CGlobalData class CGlobalData
{ {
friend CConfigPage; friend CConfigPage;
public:
public:
CGlobalData( HINSTANCE hInstance ); CGlobalData( HINSTANCE hInstance );
~CGlobalData( ); ~CGlobalData( );
BOOL ParseCommandLine( int argc, TCHAR* argv[] ); BOOL ParseCommandLine( int argc, TCHAR* argv[] );
int DesiredFrameRate( void ) const int DesiredFrameRate( void ) const
{ {
return m_nDesiredFrameRate; return m_nDesiredFrameRate;
} }
//
// Booleans // Booleans
//
BOOL ShowFPS( void ) const
{
return m_fShowFPS;
}
BOOL NoSound() const BOOL NoSound() const
{ {
return m_fNoSound; return m_fNoSound;
} }
BOOL DisableJoystick( void ) const int PaddleMode( void ) const
{ {
return m_fDisableJoystick; return m_nPaddleMode;
} }
BOOL AutoSelectVideoMode( void ) const
{
return m_fAutoSelectVideoMode;
}
int PaddleMode( void ) const;
LPCTSTR PathName( void ) const LPCTSTR PathName( void ) const
{ {
if ( m_pszPathName[0] == _T('\0') ) if ( m_pszPathName[0] == _T('\0') )
{ return NULL;
return NULL;
} return m_pszPathName;
return m_pszPathName;
} }
LPCTSTR RomDir( void ) const LPCTSTR RomDir( void ) const
{ {
return m_pszRomDir; return m_pszRomDir;
} }
HINSTANCE ModuleInstance( void ) const HINSTANCE ModuleInstance( void ) const
{ {
return m_hInstance; return m_hInstance;
} }
//
// Modified flags // Modified flags
//
void SetModified( void ) void SetModified( void )
{ {
m_fIsModified = TRUE; m_fIsModified = TRUE;
} }
BOOL IsModified( void ) const BOOL IsModified( void ) const
{ {
return m_fIsModified; return m_fIsModified;
} }
private:
private:
// Basic options // Basic options
TCHAR m_pszRomDir[ MAX_PATH ]; TCHAR m_pszRomDir[ MAX_PATH ];
int m_nPaddleMode; int m_nPaddleMode;
BOOL m_fNoSound; BOOL m_fNoSound;
BOOL m_fDisableJoystick;
// Advanced options // Advanced options
BOOL m_fShowFPS;
int m_nDesiredFrameRate; int m_nDesiredFrameRate;
BOOL m_fAutoSelectVideoMode;
HINSTANCE m_hInstance; HINSTANCE m_hInstance;
TCHAR m_pszPathName[ MAX_PATH ]; TCHAR m_pszPathName[ MAX_PATH ];
BOOL m_fIsModified; BOOL m_fIsModified;
CGlobalData( const CGlobalData& ); // no implementation CGlobalData( const CGlobalData& ); // no implementation
void operator=( const CGlobalData& ); // no implementation void operator=( const CGlobalData& ); // no implementation
}; };
inline int CGlobalData::PaddleMode(
void
) const
{
return m_nPaddleMode;
}
#endif #endif

View File

@ -1,579 +1,484 @@
// //============================================================================
// 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: MainDlg.cxx,v 1.2 2004-05-27 22:02:35 stephena Exp $
//============================================================================
#include "pch.hxx" #include "pch.hxx"
#include "MainDlg.hxx" #include "MainDlg.hxx"
#include "GlobalData.hxx" #include "GlobalData.hxx"
#include "PropertySheet.hxx" #include "PropertySheet.hxx"
#include "AboutPage.hxx" #include "AboutPage.hxx"
#include "DocPage.hxx" #include "DocPage.hxx"
#include "ConfigPage.hxx" #include "ConfigPage.hxx"
#include "resource.h" #include "resource.h"
#define BKGND_BITMAP_TOP 64 #define BKGND_BITMAP_TOP 64
#define BKGND_BITMAP_BOTTOM 355 #define BKGND_BITMAP_BOTTOM 355
// NOTE: LVS_OWNERDATA doesn't support LVM_SORTITEMS! // NOTE: LVS_OWNERDATA doesn't support LVM_SORTITEMS!
inline LPARAM ListView_GetItemData( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HWND hwndList, inline LPARAM ListView_GetItemData( HWND hwndList, int iItem )
int iItem
)
{ {
LVITEM lvi; LVITEM lvi;
lvi.mask = LVIF_PARAM; lvi.mask = LVIF_PARAM;
lvi.iItem = iItem; lvi.iItem = iItem;
lvi.iSubItem = 0; lvi.iSubItem = 0;
ListView_GetItem(hwndList, &lvi);
return lvi.lParam; ListView_GetItem(hwndList, &lvi);
return lvi.lParam;
} }
CMainDlg::CMainDlg( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CGlobalData& rGlobalData, CMainDlg::CMainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance )
HINSTANCE hInstance : m_rGlobalData(rGlobalData),
) : \ m_hInstance(hInstance)
m_rGlobalData(rGlobalData),
m_hInstance(hInstance)
{ {
} }
void CMainDlg::ClearList( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void void CMainDlg::ClearList( void )
)
{ {
int nCount = ListView_GetItemCount( m_hwndList ); int nCount = ListView_GetItemCount( m_hwndList );
for (int i = 0; i < nCount; ++i) for (int i = 0; i < nCount; ++i)
{ delete (CListData*)ListView_GetItemData( m_hwndList, i );
delete (CListData*)ListView_GetItemData( m_hwndList, i );
}
ListView_DeleteAllItems( m_hwndList ); ListView_DeleteAllItems( m_hwndList );
} }
int CMainDlg::DoModal( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HWND hwndParent int CMainDlg::DoModal( HWND hwndParent )
)
{ {
return DialogBoxParam( m_hInstance, return DialogBoxParam( m_hInstance,
MAKEINTRESOURCE(IDD), MAKEINTRESOURCE(IDD),
hwndParent, hwndParent,
StaticDialogFunc, StaticDialogFunc,
(LPARAM)this ); (LPARAM)this );
} }
BOOL CALLBACK CMainDlg::StaticDialogFunc( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HWND hDlg, BOOL CALLBACK
UINT uMsg, CMainDlg::StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
WPARAM wParam,
LPARAM lParam
)
{ {
CMainDlg* pDlg; CMainDlg* pDlg;
switch ( uMsg ) switch ( uMsg )
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
pDlg = reinterpret_cast<CMainDlg*>( lParam ); pDlg = reinterpret_cast<CMainDlg*>( lParam );
pDlg->m_hwnd = hDlg; pDlg->m_hwnd = hDlg;
(void)::SetWindowLong( hDlg, (void)::SetWindowLong( hDlg, DWL_USER, reinterpret_cast<LONG>( pDlg ) );
DWL_USER, break;
reinterpret_cast<LONG>( pDlg ) );
break;
default: default:
pDlg = reinterpret_cast<CMainDlg*>( pDlg = reinterpret_cast<CMainDlg*>( ::GetWindowLong( hDlg, DWL_USER ) );
::GetWindowLong( hDlg, DWL_USER ) ); if ( pDlg == NULL )
if ( pDlg == NULL ) return FALSE;
{ break;
return FALSE; }
}
break;
}
return pDlg->DialogFunc( uMsg, wParam, lParam ); return pDlg->DialogFunc( uMsg, wParam, lParam );
} }
BOOL CALLBACK CMainDlg::DialogFunc( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UINT uMsg, BOOL CALLBACK
WPARAM wParam, CMainDlg::DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam )
LPARAM lParam
)
{ {
BOOL b; BOOL b;
switch (uMsg) switch (uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
return OnCommand( LOWORD(wParam), (HWND)lParam, HIWORD(wParam) ); return OnCommand( LOWORD(wParam), (HWND)lParam, HIWORD(wParam) );
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
b = (BOOL)OnCtlColorStatic( (HDC)wParam, (HWND)lParam ); b = (BOOL)OnCtlColorStatic( (HDC)wParam, (HWND)lParam );
if (b) if (b)
{ return b;
return b; break;
}
break;
case WM_ERASEBKGND: case WM_ERASEBKGND:
if ( OnEraseBkgnd( (HDC)wParam ) ) if ( OnEraseBkgnd( (HDC)wParam ) )
{ return TRUE;
return TRUE; break;
}
break;
case WM_INITDIALOG: case WM_INITDIALOG:
return OnInitDialog( ); return OnInitDialog( );
case WM_NOTIFY: case WM_NOTIFY:
return OnNotify( (int)wParam, (LPNMHDR)lParam ); return OnNotify( (int)wParam, (LPNMHDR)lParam );
case WM_PALETTECHANGED: case WM_PALETTECHANGED:
TRACE( "WM_PALETTECHANGED from maindlg" ); TRACE( "WM_PALETTECHANGED from maindlg" );
return FALSE; return FALSE;
case WM_QUERYNEWPALETTE: case WM_QUERYNEWPALETTE:
TRACE( "WM_QUERYNEWPALETTE from maindlg" ); TRACE( "WM_QUERYNEWPALETTE from maindlg" );
return FALSE; return FALSE;
//
// Cool caption handlers // Cool caption handlers
//
case WM_DESTROY: case WM_DESTROY:
OnDestroy( ); OnDestroy( );
break; break;
case WM_DRAWITEM: case WM_DRAWITEM:
// Forward this onto the control // Forward this onto the control
::SendMessage( ((LPDRAWITEMSTRUCT)lParam)->hwndItem, WM_DRAWITEM, ::SendMessage( ((LPDRAWITEMSTRUCT)lParam)->hwndItem, WM_DRAWITEM, wParam, lParam );
wParam, lParam ); return TRUE;
return TRUE;
case WM_NCPAINT: case WM_NCPAINT:
// DefWindowProc(hDlg, uMsg, wParam, lParam); // DefWindowProc(hDlg, uMsg, wParam, lParam);
OnNcPaint( (HRGN)wParam ); OnNcPaint( (HRGN)wParam );
return TRUE; return TRUE;
case WM_NCACTIVATE: case WM_NCACTIVATE:
OnNcActivate( (BOOL)wParam ); OnNcActivate( (BOOL)wParam );
// When the fActive parameter is FALSE, an application should return // When the fActive parameter is FALSE, an application should return
// TRUE to indicate that the system should proceed with the default // TRUE to indicate that the system should proceed with the default
// processing // processing
SetWindowLong( m_hwnd, DWL_MSGRESULT, TRUE ); SetWindowLong( m_hwnd, DWL_MSGRESULT, TRUE );
return TRUE; return TRUE;
case WM_NCLBUTTONDOWN: case WM_NCLBUTTONDOWN:
return OnNcLButtonDown( (INT)wParam, MAKEPOINTS(lParam) ); return OnNcLButtonDown( (INT)wParam, MAKEPOINTS(lParam) );
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
// Allow Alt-F4 to close the window // Allow Alt-F4 to close the window
if ( wParam == SC_CLOSE ) if ( wParam == SC_CLOSE )
{ ::EndDialog( m_hwnd, IDCANCEL );
::EndDialog( m_hwnd, IDCANCEL ); break;
} }
break;
}
// // Message not handled
// Message not handled return FALSE;
// }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL CMainDlg::OnInitDialog( void )
{
DWORD dwRet;
HWND hwnd = *this;
dwRet = m_stella.Initialize();
if ( dwRet != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwRet, _T("CStellaX::Initialize") );
SendMessage( hwnd, WM_CLOSE, 0, 0 );
return FALSE; return FALSE;
}
// Set dialog icon
HICON hicon = ::LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_APP));
::SendMessage( hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon );
::SendMessage( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon );
// Make the Rom note have bold text
HWND hwndCtrl;
hwndCtrl = ::GetDlgItem( hwnd, IDC_ROMNOTE );
HFONT hfont = (HFONT)::SendMessage( hwndCtrl, WM_GETFONT, 0, 0 );
LOGFONT lf;
::GetObject( hfont, sizeof(LOGFONT), &lf );
lf.lfWeight = FW_BOLD;
m_hfontRomNote = ::CreateFontIndirect( &lf );
if ( m_hfontRomNote )
::SendMessage( hwndCtrl, WM_SETFONT, (WPARAM)m_hfontRomNote, 0 );
// Do subclassing
m_CoolCaption.OnInitDialog( hwnd );
m_header.SubclassDlgItem( hwnd, IDC_ROMLIST );
m_btn3d.SubclassDlgItem( hwnd, IDC_TITLE );
m_btnPlay.SubclassDlgItem( hwnd, IDC_PLAY );
m_btnHelp.SubclassDlgItem( hwnd, IDC_ABOUT );
m_btnConfig.SubclassDlgItem( hwnd, IDC_CONFIG );
m_btnExit.SubclassDlgItem( hwnd, IDC_EXIT );
const int nMaxString = 256;
TCHAR psz[nMaxString + 1];
// Initialize the list view
m_hwndList = ::GetDlgItem( hwnd, IDC_ROMLIST );
ASSERT( m_hwndList );
// LVS_EX_ONECLICKACTIVATE was causing a/vs in kernel32
::SendMessage( m_hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE,
0, LVS_EX_FULLROWSELECT );
RECT rc;
::GetClientRect( m_hwndList, &rc );
LONG lTotalWidth = rc.right-rc.left - GetSystemMetrics(SM_CXVSCROLL);
int cx = lTotalWidth / CListData::GetColumnCount();
for (int i = 0; i < CListData::GetColumnCount(); ++i)
{
::LoadString( m_hInstance, 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_hwndList, i, &lvc );
}
DWORD dwError = PopulateRomList();
if ( dwError != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwError, _T("PopulateRomList") );
return FALSE;
}
// if items added, select first item and enable play button
int nCount = ListView_GetItemCount( m_hwndList );
if (nCount != 0)
{
m_header.SetSortCol( 0, TRUE );
ListView_SortItems( m_hwndList, ListViewCompareFunc, (LPARAM)this );
ListView_SetItemState( m_hwndList, 0, LVIS_SELECTED | LVIS_FOCUSED,
LVIS_SELECTED | LVIS_FOCUSED );
}
else
{
::EnableWindow(::GetDlgItem( hwnd, IDC_PLAY), FALSE );
}
// Show status text
TCHAR pszStatus[256 + 1];
LoadString(m_hInstance, IDS_STATUSTEXT, pszStatus, 256);
wsprintf( psz, pszStatus, nCount );
SetDlgItemText( hwnd, IDC_ROMCOUNT, psz );
// Show rom path
SetDlgItemText( hwnd, IDC_ROMPATH, m_rGlobalData.RomDir() );
// Set default button
::SendMessage( hwnd, DM_SETDEFID, IDC_PLAY, 0 );
// return FALSE if SetFocus is called
return TRUE;
} }
BOOL CMainDlg::OnInitDialog( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
)
{ {
DWORD dwRet; UNUSED_ALWAYS( hwndCtl );
UNUSED_ALWAYS( codeNotify );
HWND hwnd = *this; HWND hwnd = *this;
CListData* pListData;
dwRet = m_stella.Initialize(); int nItem;
if ( dwRet != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwRet, _T("CStellaX::Initialize") );
SendMessage( hwnd, WM_CLOSE, 0, 0 );
return FALSE;
}
// Set dialog icon switch (id)
{
HICON hicon = ::LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_APP));
::SendMessage( hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon );
::SendMessage( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon );
//
// Make the Rom note have bold text
//
HWND hwndCtrl;
hwndCtrl = ::GetDlgItem( hwnd, IDC_ROMNOTE );
HFONT hfont = (HFONT)::SendMessage( hwndCtrl, WM_GETFONT, 0, 0 );
LOGFONT lf;
::GetObject( hfont, sizeof(LOGFONT), &lf );
lf.lfWeight = FW_BOLD;
m_hfontRomNote = ::CreateFontIndirect( &lf );
if ( m_hfontRomNote )
{
::SendMessage( hwndCtrl, WM_SETFONT, (WPARAM)m_hfontRomNote, 0 );
}
// Do subclassing
m_CoolCaption.OnInitDialog( hwnd );
m_header.SubclassDlgItem( hwnd, IDC_ROMLIST );
m_btn3d.SubclassDlgItem( hwnd, IDC_TITLE );
m_btnPlay.SubclassDlgItem( hwnd, IDC_PLAY );
m_btnHelp.SubclassDlgItem( hwnd, IDC_ABOUT );
m_btnConfig.SubclassDlgItem( hwnd, IDC_CONFIG );
m_btnExit.SubclassDlgItem( hwnd, IDC_EXIT );
const int nMaxString = 256;
TCHAR psz[nMaxString + 1];
// Initialize the list view
m_hwndList = ::GetDlgItem( hwnd, IDC_ROMLIST );
ASSERT( m_hwndList );
// LVS_EX_ONECLICKACTIVATE was causing a/vs in kernel32
::SendMessage( m_hwndList,
LVM_SETEXTENDEDLISTVIEWSTYLE,
0,
LVS_EX_FULLROWSELECT );
RECT rc;
::GetClientRect( m_hwndList, &rc );
LONG lTotalWidth = rc.right-rc.left - GetSystemMetrics(SM_CXVSCROLL);
int cx = lTotalWidth / CListData::GetColumnCount();
for (int i = 0; i < CListData::GetColumnCount(); ++i)
{
::LoadString( m_hInstance,
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_hwndList, i, &lvc );
}
DWORD dwError = PopulateRomList();
if ( dwError != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwError, _T("PopulateRomList") );
return FALSE;
}
// if items added, select first item and enable play button
int nCount = ListView_GetItemCount( m_hwndList );
if (nCount != 0)
{
#ifdef _DEBUG
DWORD dwStartTick = ::GetTickCount();
#endif
m_header.SetSortCol( 0, TRUE );
ListView_SortItems( m_hwndList,
ListViewCompareFunc,
(LPARAM)this );
#ifdef _DEBUG
TRACE("\tElapsed ticks for ListView_SortItems = %ld", ::GetTickCount()-dwStartTick);
#endif
ListView_SetItemState( m_hwndList, 0, LVIS_SELECTED | LVIS_FOCUSED,
LVIS_SELECTED | LVIS_FOCUSED );
}
else
{
::EnableWindow(::GetDlgItem( hwnd, IDC_PLAY), FALSE );
}
//
// Show status text
//
TCHAR pszStatus[256 + 1];
LoadString(m_hInstance, IDS_STATUSTEXT, pszStatus, 256);
wsprintf( psz, pszStatus, nCount );
SetDlgItemText( hwnd, IDC_ROMCOUNT, psz );
//
// Show rom path
//
SetDlgItemText( hwnd, IDC_ROMPATH, m_rGlobalData.RomDir() );
//
// Set default button
//
::SendMessage( hwnd, DM_SETDEFID, IDC_PLAY, 0 );
// return FALSE if SetFocus is called
return TRUE;
}
BOOL CMainDlg::OnCommand(
int id,
HWND hwndCtl,
UINT codeNotify
)
{
UNUSED_ALWAYS( hwndCtl );
UNUSED_ALWAYS( codeNotify );
HWND hwnd = *this;
CListData* pListData;
int nItem;
switch (id)
{
case IDC_PLAY: case IDC_PLAY:
nItem = (int)::SendMessage( m_hwndList, LVM_GETNEXTITEM,
nItem = (int)::SendMessage( m_hwndList, (WPARAM)-1, MAKELPARAM( LVNI_SELECTED, 0 ) );
LVM_GETNEXTITEM, ASSERT( nItem != -1 );
(WPARAM)-1, if ( nItem == -1 )
MAKELPARAM( LVNI_SELECTED, 0 ) ); {
ASSERT( nItem != -1 ); ::MessageBox( m_hInstance, hwnd, IDS_NO_ITEM_SELECTED );
if ( nItem == -1 )
{
::MessageBox( m_hInstance,
hwnd,
IDS_NO_ITEM_SELECTED );
return TRUE;
}
#if 0
TCHAR pszFile[MAX_PATH + 1];
// BUGBUG: On Win95b pszFile is coming back empty!
LVITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.iItem = nItem;
lvi.iSubItem = CListData::FILENAME_COLUMN;
lvi.pszText = pszFile;
lvi.cchTextMax = MAX_PATH;
::SendMessage( m_hwndList, LVM_GETITEM, 0, (LPARAM)&lvi );
#endif
pListData = (CListData*)ListView_GetItemData( m_hwndList, nItem );
TCHAR pszPathName[ MAX_PATH + 1 ];
lstrcpy( pszPathName, m_rGlobalData.RomDir() );
lstrcat( pszPathName, _T("\\") );
lstrcat( pszPathName,
pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
// Play the game!
::EnableWindow( hwnd, FALSE );
(void)m_stella.PlayROM( hwnd,
pszPathName,
pListData->GetTextForColumn( CListData::NAME_COLUMN ),
m_rGlobalData );
::EnableWindow( hwnd, TRUE );
// Set focus back to the rom list
::SetFocus( m_hwndList );
return TRUE; return TRUE;
}
pListData = (CListData*)ListView_GetItemData( m_hwndList, nItem );
TCHAR pszPathName[ MAX_PATH + 1 ];
lstrcpy( pszPathName, m_rGlobalData.RomDir() );
lstrcat( pszPathName, _T("\\") );
lstrcat( pszPathName,
pListData->GetTextForColumn( CListData::FILENAME_COLUMN ) );
// Play the game!
::EnableWindow( hwnd, FALSE );
(void)m_stella.PlayROM( hwnd, pszPathName,
pListData->GetTextForColumn( CListData::NAME_COLUMN ),
m_rGlobalData );
::EnableWindow( hwnd, TRUE );
// Set focus back to the rom list
::SetFocus( m_hwndList );
return TRUE;
break; // case IDC_PLAY
case IDC_EXIT: case IDC_EXIT:
ClearList(); ClearList();
::EndDialog( hwnd, IDCANCEL ); ::EndDialog( hwnd, IDCANCEL );
return TRUE; return TRUE;
break; // case IDC_EXIT
case IDC_CONFIG: case IDC_CONFIG:
{ {
CPropertySheet ps( _T("Configure"), hwnd ); CPropertySheet ps( _T("Configure"), hwnd );
CConfigPage pgConfig( m_rGlobalData ); CConfigPage pgConfig( m_rGlobalData );
ps.AddPage( &pgConfig ); ps.AddPage( &pgConfig );
(void)ps.DoModal(); (void)ps.DoModal();
}
return TRUE; return TRUE;
break; // case IDC_CONFIG
}
case IDC_ABOUT: case IDC_ABOUT:
{ {
CPropertySheet ps(_T("Help"), hwnd); CPropertySheet ps(_T("Help"), hwnd);
CHelpPage pgAbout; CHelpPage pgAbout;
ps.AddPage(&pgAbout); ps.AddPage(&pgAbout);
CDocPage pgDoc; CDocPage pgDoc;
ps.AddPage(&pgDoc); ps.AddPage(&pgDoc);
ps.DoModal(); ps.DoModal();
} return TRUE;
return TRUE; break; // case IDC_ABOUT
} }
}
return FALSE; return FALSE;
} }
BOOL CMainDlg::OnNotify( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int idCtrl, BOOL CMainDlg::OnNotify( int idCtrl, LPNMHDR pnmh )
LPNMHDR pnmh
)
{ {
UNUSED_ALWAYS( idCtrl ); UNUSED_ALWAYS( idCtrl );
switch ( pnmh->code ) switch ( pnmh->code )
{ {
case LVN_GETDISPINFO: case LVN_GETDISPINFO:
OnGetDispInfo( (NMLVDISPINFO*)pnmh ); OnGetDispInfo( (NMLVDISPINFO*)pnmh );
return TRUE; return TRUE;
case LVN_COLUMNCLICK: case LVN_COLUMNCLICK:
OnColumnClick( (LPNMLISTVIEW)pnmh ); OnColumnClick( (LPNMLISTVIEW)pnmh );
return TRUE; return TRUE;
case LVN_ITEMCHANGED: case LVN_ITEMCHANGED:
OnItemChanged( (LPNMLISTVIEW)pnmh ); OnItemChanged( (LPNMLISTVIEW)pnmh );
return TRUE; 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 );
return TRUE; return TRUE;
} }
// not handled // not handled
return FALSE;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static void ScreenToClient( HWND hwnd, LPRECT lpRect )
{
::ScreenToClient(hwnd, (LPPOINT)lpRect);
::ScreenToClient(hwnd, ((LPPOINT)lpRect)+1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static void FillSolidRect( HDC hdc, LPCRECT lpRect, COLORREF clr )
{
COLORREF crOld = ::SetBkColor(hdc, clr);
::ExtTextOut(hdc, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL);
::SetBkColor(hdc, crOld);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOL CMainDlg::OnEraseBkgnd( HDC hdc )
{
// don't do this in 256 color
if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
return FALSE; return FALSE;
}
static void ScreenToClient( RECT rcWindow;
HWND hwnd, ::GetWindowRect( *this, &rcWindow );
LPRECT lpRect ::ScreenToClient( *this, &rcWindow );
)
{
::ScreenToClient(hwnd, (LPPOINT)lpRect);
::ScreenToClient(hwnd, ((LPPOINT)lpRect)+1);
}
static void FillSolidRect( FillSolidRect( hdc, &rcWindow, ::GetSysColor( COLOR_3DFACE ) );
HDC hdc,
LPCRECT lpRect,
COLORREF clr
)
{
COLORREF crOld = ::SetBkColor(hdc, clr);
::ExtTextOut(hdc, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL);
::SetBkColor(hdc, crOld);
}
BOOL CMainDlg::OnEraseBkgnd( RECT rc;
HDC hdc ::SetRect( &rc, rcWindow.left, BKGND_BITMAP_TOP, rcWindow.right, BKGND_BITMAP_BOTTOM );
)
{
// don't do this in 256 color
if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) long lWidth = rc.right - rc.left;
long lHeight = rc.bottom - rc.top;
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmpTile = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_TILE) );
BITMAP bm;
GetObject(hbmpTile, sizeof(bm), &bm);
HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcMem, hbmpTile);
for (long x = 0; x < lWidth; x += bm.bmWidth)
{
for (long y = 0; y < lHeight; y += bm.bmHeight)
{ {
return FALSE; ::BitBlt( hdc,
}
RECT rcWindow;
::GetWindowRect( *this, &rcWindow );
::ScreenToClient( *this, &rcWindow );
FillSolidRect( hdc, &rcWindow, ::GetSysColor( COLOR_3DFACE ) );
RECT rc;
::SetRect( &rc, rcWindow.left, BKGND_BITMAP_TOP,
rcWindow.right, BKGND_BITMAP_BOTTOM );
long lWidth = rc.right - rc.left;
long lHeight = rc.bottom - rc.top;
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmpTile = LoadBitmap( m_hInstance,
MAKEINTRESOURCE(IDB_TILE) );
BITMAP bm;
GetObject(hbmpTile, sizeof(bm), &bm);
HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcMem, hbmpTile);
for (long x = 0; x < lWidth; x += bm.bmWidth)
{
for (long y = 0; y < lHeight; y += bm.bmHeight)
{
::BitBlt( hdc,
rc.left + x, rc.top + y, rc.left + x, rc.top + y,
( (rc.left + x + bm.bmWidth) > rc.right ) ? rc.right-(rc.left+x) : bm.bmWidth, ( (rc.left + x + bm.bmWidth) > rc.right ) ? rc.right-(rc.left+x) : bm.bmWidth,
( (rc.top + y + bm.bmHeight) > rc.bottom ) ? rc.bottom-(rc.top+y) : bm.bmHeight, ( (rc.top + y + bm.bmHeight) > rc.bottom ) ? rc.bottom-(rc.top+y) : bm.bmHeight,
hdcMem, hdcMem,
0, 0, SRCCOPY ); 0, 0, SRCCOPY );
}
} }
}
SelectObject(hdcMem, hbmpOld); SelectObject(hdcMem, hbmpOld);
DeleteObject(hbmpTile);
DeleteDC(hdcMem);
DeleteObject(hbmpTile); return TRUE;
DeleteDC(hdcMem);
return TRUE;
} }
HBRUSH CMainDlg::OnCtlColorStatic( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HDC hdcStatic, HBRUSH CMainDlg::OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic )
HWND hwndStatic
)
{ {
// don't do this in 256 color // don't do this in 256 color
if (GetDeviceCaps(hdcStatic, RASTERCAPS) & RC_PALETTE) if (GetDeviceCaps(hdcStatic, RASTERCAPS) & RC_PALETTE)
{ return FALSE;
return FALSE;
}
if ((GetWindowLong(hwndStatic, GWL_STYLE) & SS_ICON) == SS_ICON) if ((GetWindowLong(hwndStatic, GWL_STYLE) & SS_ICON) == SS_ICON)
{ return NULL;
return NULL;
}
SetBkMode(hdcStatic, TRANSPARENT); SetBkMode(hdcStatic, TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
return (HBRUSH)GetStockObject(NULL_BRUSH);
} }
// --------------------------------------------------------------------------- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DWORD CMainDlg::PopulateRomList( void )
DWORD CMainDlg::PopulateRomList(
void
)
{ {
TRACE("CMainDlg::PopulateRomList");
TRACE("CMainDlg::PopulateRomList"); DWORD dwRet;
DWORD dwRet;
#ifdef _DEBUG #ifdef _DEBUG
DWORD dwStartTick = ::GetTickCount(); DWORD dwStartTick = ::GetTickCount();

View File

@ -1,58 +1,21 @@
/* //============================================================================
//
StellaX // SSSS tt lll lll
Win32 DirectX port of Stella // SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
Written by Jeff Miller (contact Bradford for current email address) // SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
Stella core developed by Bradford W. Mott // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
This software is Copyright (c) 1995-2000, Jeff Miller //
// Copyright (c) 1995-2000 by Jeff Miller
REVISIONS: // Copyright (c) 2004 by Stephen Anthony
//
14-Mar-99 1.1.0 new code base // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
19-Mar-99 1.1.1 took into account video width //
fixed no sound card bug // $Id: main.cxx,v 1.2 2004-05-27 22:02:35 stephena Exp $
-mute option //============================================================================
fixed mame32 www link
11-Jun-99 1.1.2 removed registerfiletypes call
fixed directsound
added directinput support for keyboard, mouse, joystick
fixed minimize button bug
created virtual list view to speed load time
add screen capture (f12 key)
added romdir read from STELLA.INI file
(defaults to ROMS directory)
I now use WM_SETICON so the stella icon shows on the task list
Works on NT4 (dont fail if DirectInput not available)
Added UI field for a cartridge.note
Changed stellax web site address
Added really cool help property sheet w/adobe doc
9-Sep-99 1.1.3 Improved video detection logic
Added DisableJoystick and ListSort options to .ini
Rewrote the sound driver code
Added multiple screen shot support - first writes to
stella00.bmp then stella01.bmp, etc.
Added cool round buttons on main screen
18-Apr-00 Started removing all exceptions
Fixed sound code (now uses streaming properly)
Added configuration dialog
Fixed it so that Alt-F4 will close the dialog
Updated the master ROM list
02-May-00 1.1.3a Fixed joystick handling regression
Fixed repaint problem on doc page
Fixed problem where some machines would report path not found
Added force 640x480 video mode
Added browse button on config dialog
05-Jan-02 n/a Wow, it's been awhile...Released source code
*/
#include "pch.hxx" #include "pch.hxx"
#include "resource.h" #include "resource.h"
@ -62,124 +25,97 @@ REVISIONS:
class CSingleInstance class CSingleInstance
{ {
public: public:
CSingleInstance( LPCTSTR pszName ) CSingleInstance( LPCTSTR pszName )
{ {
::SetLastError( ERROR_SUCCESS ); ::SetLastError( ERROR_SUCCESS );
m_hMutex = ::CreateMutex( NULL, TRUE, pszName );
m_hMutex = ::CreateMutex( NULL, TRUE, pszName ); m_dwError = ::GetLastError();
}
m_dwError = ::GetLastError();
}
~CSingleInstance() ~CSingleInstance()
{ {
if ( m_hMutex != INVALID_HANDLE_VALUE && if ( m_hMutex != INVALID_HANDLE_VALUE && m_dwError != ERROR_ALREADY_EXISTS )
m_dwError != ERROR_ALREADY_EXISTS ) {
{ VERIFY( ::ReleaseMutex( m_hMutex ) );
VERIFY( ::ReleaseMutex( m_hMutex ) ); VERIFY( ::CloseHandle( m_hMutex ) );
VERIFY( ::CloseHandle( m_hMutex ) ); }
} }
}
BOOL AlreadyExists( void ) const BOOL AlreadyExists( void ) const
{ {
return ( m_dwError == ERROR_ALREADY_EXISTS ); return ( m_dwError == ERROR_ALREADY_EXISTS );
} }
private:
private:
HANDLE m_hMutex; HANDLE m_hMutex;
DWORD m_dwError; DWORD m_dwError;
CSingleInstance( const CSingleInstance& ); // no implementation CSingleInstance( const CSingleInstance& ); // no implementation
void operator=( const CSingleInstance& ); // no implementation void operator=( const CSingleInstance& ); // no implementation
}; };
// see debug.cpp // see debug.cpp
LPCTSTR g_ctszDebugLog = _T("stella.log"); LPCTSTR g_ctszDebugLog = _T("stella.log");
int WINAPI _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
int WINAPI _tWinMain( LPTSTR lpCmdLine, int nCmdShow )
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow
)
{ {
UNUSED_ALWAYS( hPrevInstance ); UNUSED_ALWAYS( hPrevInstance );
UNUSED_ALWAYS( lpCmdLine ); UNUSED_ALWAYS( lpCmdLine );
UNUSED_ALWAYS( nCmdShow ); UNUSED_ALWAYS( nCmdShow );
DWORD dwRet; DWORD dwRet;
(void)::DeleteFile(g_ctszDebugLog); (void)::DeleteFile(g_ctszDebugLog);
CSingleInstance mutex( _T("StellaXMutex") ); CSingleInstance mutex( _T("StellaXMutex") );
if ( mutex.AlreadyExists() ) if ( mutex.AlreadyExists() )
{
MessageBox( hInstance, NULL, IDS_ALREADYRUNNING );
return 1;
}
HRESULT hrCoInit = ::CoInitialize( NULL );
if ( FAILED(hrCoInit) )
MessageBox( hInstance, NULL, IDS_COINIT_FAILED );
::InitCommonControls();
BOOL fOk = FALSE;
CGlobalData globaldata( hInstance );
fOk = globaldata.ParseCommandLine( __argc, __argv );
if (!fOk)
{
MessageBox( hInstance, NULL, IDS_BADARGUMENT );
}
else
{
LPCTSTR ctszPathName = globaldata.PathName();
if (ctszPathName != NULL)
{ {
MessageBox( hInstance, NULL, IDS_ALREADYRUNNING ); // a filename was given on the commandline, skip the UI
return 1; CStellaXMain stellax;
}
HRESULT hrCoInit = ::CoInitialize( NULL ); dwRet = stellax.Initialize();
if ( FAILED(hrCoInit) ) if ( dwRet != ERROR_SUCCESS )
{ MessageBoxFromWinError( dwRet, _T("CStellaX::Initialize") );
MessageBox( hInstance, NULL, IDS_COINIT_FAILED ); else
} dwRet = stellax.PlayROM( GetDesktopWindow(), ctszPathName,
_T("StellaX"), globaldata );
::InitCommonControls();
BOOL fOk = FALSE;
CGlobalData globaldata( hInstance );
fOk = globaldata.ParseCommandLine( __argc, __argv );
if (!fOk)
{
MessageBox( hInstance, NULL, IDS_BADARGUMENT );
} }
else else
{ {
LPCTSTR ctszPathName = globaldata.PathName(); // show the ui
if (ctszPathName != NULL) CMainDlg dlg( globaldata, hInstance );
{ dlg.DoModal( NULL );
//
// a filename was given on the commandline, skip the UI
//
CStellaXMain stellax;
dwRet = stellax.Initialize();
if ( dwRet != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwRet, _T("CStellaX::Initialize") );
}
else
{
dwRet = stellax.PlayROM( GetDesktopWindow(),
ctszPathName,
_T("StellaX"), // Dont knwo the friendly name
globaldata );
}
}
else
{
//
// show the ui
//
CMainDlg dlg( globaldata, hInstance );
dlg.DoModal( NULL );
}
} }
}
if ( hrCoInit == S_OK ) if ( hrCoInit == S_OK )
{ ::CoUninitialize();
::CoUninitialize();
}
return 0; return 0;
} }

View File

@ -1,49 +1,5 @@
[Options] [Options]
RomPath=C:\Dell
; ----------------------------------------------------------------------------
; Set this to the path where your .bin rom files are located
; If this isn't specified, ROMS will be used
RomPath=ROMS
; ----------------------------------------------------------------------------
; Set this to specify which paddle the mouse should emulate. This can be any
; number from 0 to 3 inclusive.
; If this isn't specified, 0 will be used (the mouse will emulate paddle 0)
Paddle=0
; ----------------------------------------------------------------------------
; Set this to 1 if you don't want any sound effects.
; If this isn't specified, 0 will be used
Mute=0
; ----------------------------------------------------------------------------
; Set this to 1 to have StellaX not use any joysticks. This may speed up
; StellaX, but you won't be able to play using joystick!
DisableJoystick=0
; ============================================================================
; ADVANCED OPTIONS FOLLOW
; ============================================================================
; ----------------------------------------------------------------------------
; Set this to 1 if you want to see the FPS count after a game is played
; If this isn't specified, 0 will be used
ShowFps=0
; ----------------------------------------------------------------------------
; Set this to the desired frame rate. This normally should not be changed.
; Any value from 1 to 300 is allowed.
; If this isn't specified, 60 will be used
FrameRate=60 FrameRate=60
Mute=1
; ---------------------------------------------------------------------------- Paddle=3
; Set this to 0 if you want stella to always use 640x480 as the video mode.
; If this isn't specified, 1 will be used
AutoSelectVideoMode=1