2014-08-13 20:30:35 +00:00
/*
AppleWin : An Apple //e emulator for Windows
Copyright ( C ) 1994 - 1996 , Michael O ' Brien
Copyright ( C ) 1999 - 2001 , Oliver Schmidt
Copyright ( C ) 2002 - 2005 , Tom Charlesworth
Copyright ( C ) 2006 - 2014 , Tom Charlesworth , Michael Pohoreski , Nick Westgate
AppleWin is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
AppleWin is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with AppleWin ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
2012-03-27 21:20:36 +00:00
# include "StdAfx.h"
2014-08-13 20:30:35 +00:00
2020-11-11 21:15:27 +00:00
# include "PageDisk.h"
2020-12-28 16:25:29 +00:00
# include "PropertySheet.h"
2020-11-11 21:15:27 +00:00
2020-11-26 21:50:06 +00:00
# include "../Windows/AppleWin.h"
2022-11-17 21:08:11 +00:00
# include "../Windows/Win32Frame.h"
2019-12-19 19:42:30 +00:00
# include "../CardManager.h"
2018-02-25 15:09:25 +00:00
# include "../Disk.h" // Drive_e, Disk_Status_e
2022-05-19 18:30:34 +00:00
# include "../Harddisk.h"
2018-02-24 15:12:40 +00:00
# include "../Registry.h"
2022-05-08 15:26:01 +00:00
# include "../Interface.h"
2018-02-24 15:12:40 +00:00
# include "../resource/resource.h"
2012-03-27 21:20:36 +00:00
CPageDisk * CPageDisk : : ms_this = 0 ; // reinit'd in ctor
2014-10-01 23:18:46 +00:00
const TCHAR CPageDisk : : m_defaultDiskOptions [ ] =
TEXT ( " Select Disk... \0 " )
TEXT ( " Eject Disk \0 " ) ;
const TCHAR CPageDisk : : m_defaultHDDOptions [ ] =
TEXT ( " Select Hard Disk Image... \0 " )
TEXT ( " Unplug Hard Disk Image \0 " ) ;
2012-03-27 21:20:36 +00:00
2021-01-01 12:57:40 +00:00
INT_PTR CALLBACK CPageDisk : : DlgProc ( HWND hWnd , UINT message , WPARAM wparam , LPARAM lparam )
2012-03-27 21:20:36 +00:00
{
// Switch from static func to our instance
2012-05-06 22:14:03 +00:00
return CPageDisk : : ms_this - > DlgProcInternal ( hWnd , message , wparam , lparam ) ;
2012-03-27 21:20:36 +00:00
}
2021-01-01 12:57:40 +00:00
INT_PTR CPageDisk : : DlgProcInternal ( HWND hWnd , UINT message , WPARAM wparam , LPARAM lparam )
2012-03-27 21:20:36 +00:00
{
switch ( message )
{
case WM_NOTIFY :
{
// Property Sheet notifications
switch ( ( ( LPPSHNOTIFY ) lparam ) - > hdr . code )
{
2012-03-31 21:34:02 +00:00
case PSN_SETACTIVE :
// About to become the active page
m_PropertySheetHelper . SetLastPage ( m_Page ) ;
2012-05-06 22:14:03 +00:00
InitOptions ( hWnd ) ;
2012-03-31 21:34:02 +00:00
break ;
2012-03-27 21:20:36 +00:00
case PSN_KILLACTIVE :
2021-01-01 12:57:40 +00:00
SetWindowLongPtr ( hWnd , DWLP_MSGRESULT , FALSE ) ; // Changes are valid
2012-03-27 21:20:36 +00:00
break ;
case PSN_APPLY :
2012-05-06 22:14:03 +00:00
DlgOK ( hWnd ) ;
2021-01-01 12:57:40 +00:00
SetWindowLongPtr ( hWnd , DWLP_MSGRESULT , PSNRET_NOERROR ) ; // Changes are valid
2012-03-27 21:20:36 +00:00
break ;
case PSN_QUERYCANCEL :
// Can use this to ask user to confirm cancel
break ;
case PSN_RESET :
2021-08-29 10:39:51 +00:00
// Support 'Cancel' case for Slot-5 DiskII enabled/disabled - needed as the Disk2InterfaceCard object is created on toggling the checkbox. See [*1]
if ( m_PropertySheetHelper . GetConfigOld ( ) . m_Slot [ SLOT5 ] ! = m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ SLOT5 ] )
{
if ( m_PropertySheetHelper . GetConfigOld ( ) . m_Slot [ SLOT5 ] = = CT_Disk2 | | m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ SLOT5 ] = = CT_Disk2 )
m_PropertySheetHelper . SetSlot ( SLOT5 , m_PropertySheetHelper . GetConfigOld ( ) . m_Slot [ SLOT5 ] ) ;
}
2021-09-17 19:43:10 +00:00
// Support 'Cancel' case for Slot-7 HDD enabled/disabled - needed as the HarddiskInterfaceCard object is created on toggling the checkbox. See [*2]
if ( m_PropertySheetHelper . GetConfigOld ( ) . m_Slot [ SLOT7 ] ! = m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ SLOT7 ] )
{
if ( m_PropertySheetHelper . GetConfigOld ( ) . m_Slot [ SLOT7 ] = = CT_GenericHDD | | m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ SLOT7 ] = = CT_GenericHDD )
2021-11-01 20:12:42 +00:00
m_PropertySheetHelper . SetSlot ( SLOT7 , m_PropertySheetHelper . GetConfigOld ( ) . m_Slot [ SLOT7 ] ) ;
2021-09-17 19:43:10 +00:00
}
2012-05-06 22:14:03 +00:00
DlgCANCEL ( hWnd ) ;
2012-03-27 21:20:36 +00:00
break ;
}
}
break ;
case WM_COMMAND :
switch ( LOWORD ( wparam ) )
{
2021-08-29 10:39:51 +00:00
case IDC_DISKII_SLOT5_ENABLE :
{
const BOOL checked = IsDlgButtonChecked ( hWnd , IDC_DISKII_SLOT5_ENABLE ) ? TRUE : FALSE ;
m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ SLOT5 ] = checked ? CT_Disk2 : CT_Empty ;
// NB. Unusual as it creates slot object when checkbox is toggled (instead of after OK)
// Needed as we need a Disk2InterfaceCard object so that images can be inserted/ejected [*1]
m_PropertySheetHelper . SetSlot ( SLOT5 , m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ SLOT5 ] ) ;
InitOptions ( hWnd ) ;
EnableFloppyDrive ( hWnd , checked , SLOT5 ) ;
}
break ;
2014-10-01 23:18:46 +00:00
case IDC_COMBO_DISK1 :
2014-10-10 20:24:50 +00:00
if ( HIWORD ( wparam ) = = CBN_SELCHANGE )
{
2021-08-29 10:39:51 +00:00
HandleFloppyDriveCombo ( hWnd , DRIVE_1 , LOWORD ( wparam ) , IDC_COMBO_DISK2 , SLOT6 ) ;
2021-01-10 16:33:06 +00:00
GetFrame ( ) . FrameRefreshStatus ( DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS ) ;
2014-10-01 23:18:46 +00:00
}
2012-03-27 21:20:36 +00:00
break ;
2014-10-01 23:18:46 +00:00
case IDC_COMBO_DISK2 :
2014-10-10 20:24:50 +00:00
if ( HIWORD ( wparam ) = = CBN_SELCHANGE )
{
2021-08-29 10:39:51 +00:00
HandleFloppyDriveCombo ( hWnd , DRIVE_2 , LOWORD ( wparam ) , IDC_COMBO_DISK1 , SLOT6 ) ;
GetFrame ( ) . FrameRefreshStatus ( DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS ) ;
}
break ;
case IDC_COMBO_DISK1_SLOT5 :
if ( HIWORD ( wparam ) = = CBN_SELCHANGE )
{
HandleFloppyDriveCombo ( hWnd , DRIVE_1 , LOWORD ( wparam ) , IDC_COMBO_DISK2_SLOT5 , SLOT5 ) ;
GetFrame ( ) . FrameRefreshStatus ( DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS ) ;
}
break ;
case IDC_COMBO_DISK2_SLOT5 :
if ( HIWORD ( wparam ) = = CBN_SELCHANGE )
{
HandleFloppyDriveCombo ( hWnd , DRIVE_2 , LOWORD ( wparam ) , IDC_COMBO_DISK1_SLOT5 , SLOT5 ) ;
2021-01-10 16:33:06 +00:00
GetFrame ( ) . FrameRefreshStatus ( DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS ) ;
2014-10-01 23:18:46 +00:00
}
2012-03-27 21:20:36 +00:00
break ;
2014-10-01 23:18:46 +00:00
case IDC_COMBO_HDD1 :
2014-10-10 20:24:50 +00:00
if ( HIWORD ( wparam ) = = CBN_SELCHANGE )
{
HandleHDDCombo ( hWnd , HARDDISK_1 , LOWORD ( wparam ) ) ;
2012-03-27 21:20:36 +00:00
}
break ;
2014-10-01 23:18:46 +00:00
case IDC_COMBO_HDD2 :
2014-10-10 20:24:50 +00:00
if ( HIWORD ( wparam ) = = CBN_SELCHANGE )
{
HandleHDDCombo ( hWnd , HARDDISK_2 , LOWORD ( wparam ) ) ;
2012-03-27 21:20:36 +00:00
}
break ;
case IDC_HDD_ENABLE :
2021-09-17 19:43:10 +00:00
{
const BOOL checked = IsDlgButtonChecked ( hWnd , IDC_HDD_ENABLE ) ? TRUE : FALSE ;
2021-11-01 20:12:42 +00:00
// Add some user-protection, as (currently) removing the HDD images can't be undone!
if ( checked | | ! checked & & GetFrame ( ) . FrameMessageBox ( " This will unplug the HDD image(s)! Proceed? " , " Eject/Unplug Warning " , MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND ) ! = IDNO )
{
m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ SLOT7 ] = checked ? CT_GenericHDD : CT_Empty ;
// NB. Unusual as it creates slot object when checkbox is toggled (instead of after OK)
// Needed as we need a HarddiskInterfaceCard object so that images can be inserted/ejected [*2]
m_PropertySheetHelper . SetSlot ( SLOT7 , m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ SLOT7 ] ) ;
InitComboHDD ( hWnd , SLOT7 ) ; // disabling will remove the HDD images - so update drop-down to reflect this
EnableHDD ( hWnd , checked ) ;
}
else
{
CheckDlgButton ( hWnd , IDC_HDD_ENABLE , BST_CHECKED ) ;
}
2021-09-17 19:43:10 +00:00
}
2012-03-27 21:20:36 +00:00
break ;
2018-12-09 11:48:22 +00:00
case IDC_HDD_SWAP :
HandleHDDSwap ( hWnd ) ;
break ;
2012-03-27 21:20:36 +00:00
case IDC_CIDERPRESS_BROWSE :
{
2014-08-13 20:30:35 +00:00
std : : string CiderPressLoc = m_PropertySheetHelper . BrowseToFile ( hWnd , TEXT ( " Select path to CiderPress " ) , REGVALUE_CIDERPRESSLOC , TEXT ( " Applications (*.exe) \0 *.exe \0 " ) TEXT ( " All Files \0 *.* \0 " ) ) ;
2012-05-06 22:14:03 +00:00
SendDlgItemMessage ( hWnd , IDC_CIDERPRESS_FILENAME , WM_SETTEXT , 0 , ( LPARAM ) CiderPressLoc . c_str ( ) ) ;
2012-03-27 21:20:36 +00:00
}
break ;
}
break ;
2012-05-06 22:14:03 +00:00
case WM_INITDIALOG :
2012-03-27 21:20:36 +00:00
{
2021-08-29 10:39:51 +00:00
CheckDlgButton ( hWnd , IDC_ENHANCE_DISK_ENABLE , GetCardMgr ( ) . GetDisk2CardMgr ( ) . GetEnhanceDisk ( ) ? BST_CHECKED : BST_UNCHECKED ) ;
2022-11-17 21:08:11 +00:00
CheckDlgButton ( hWnd , IDC_DISKII_STATUS_ENABLE , Win32Frame : : GetWin32Frame ( ) . GetWindowedModeShowDiskiiStatus ( ) ? BST_CHECKED : BST_UNCHECKED ) ;
2014-10-01 23:18:46 +00:00
2021-08-29 10:39:51 +00:00
const UINT slot = SLOT6 ;
if ( GetCardMgr ( ) . QuerySlot ( slot ) = = CT_Disk2 ) // NB. SLOT6 not setup in m_PropertySheetHelper.GetConfigNew().m_Slot[]
InitComboFloppyDrive ( hWnd , slot ) ;
2020-01-04 13:58:59 +00:00
else
2021-08-29 10:39:51 +00:00
EnableFloppyDrive ( hWnd , FALSE , slot ) ; // disable if slot6 is empty (or has some other card in it)
2012-03-27 21:20:36 +00:00
2019-12-19 19:42:30 +00:00
InitComboHDD ( hWnd , SLOT7 ) ;
2012-03-27 21:20:36 +00:00
2019-08-09 03:50:29 +00:00
TCHAR PathToCiderPress [ MAX_PATH ] ;
RegLoadString ( TEXT ( REG_CONFIG ) , REGVALUE_CIDERPRESSLOC , 1 , PathToCiderPress , MAX_PATH , TEXT ( " " ) ) ;
2012-05-06 22:14:03 +00:00
SendDlgItemMessage ( hWnd , IDC_CIDERPRESS_FILENAME , WM_SETTEXT , 0 , ( LPARAM ) PathToCiderPress ) ;
2012-03-27 21:20:36 +00:00
2021-11-01 20:12:42 +00:00
CheckDlgButton ( hWnd , IDC_HDD_ENABLE , ( GetCardMgr ( ) . QuerySlot ( SLOT7 ) = = CT_GenericHDD ) ? BST_CHECKED : BST_UNCHECKED ) ;
2012-03-27 21:20:36 +00:00
2012-05-06 22:14:03 +00:00
EnableHDD ( hWnd , IsDlgButtonChecked ( hWnd , IDC_HDD_ENABLE ) ) ;
2021-08-29 10:39:51 +00:00
InitOptions ( hWnd ) ; // init for slot-5
2012-03-27 21:20:36 +00:00
break ;
}
}
return FALSE ;
}
2019-12-19 19:42:30 +00:00
void CPageDisk : : InitComboFloppyDrive ( HWND hWnd , UINT slot )
{
2020-10-11 16:34:44 +00:00
Disk2InterfaceCard & disk2Card = dynamic_cast < Disk2InterfaceCard & > ( GetCardMgr ( ) . GetRef ( slot ) ) ;
2019-12-19 19:42:30 +00:00
2021-08-29 10:39:51 +00:00
const UINT idcComboDisk1 = ( slot = = SLOT6 ) ? IDC_COMBO_DISK1 : IDC_COMBO_DISK1_SLOT5 ;
const UINT idcComboDisk2 = ( slot = = SLOT6 ) ? IDC_COMBO_DISK2 : IDC_COMBO_DISK2_SLOT5 ;
m_PropertySheetHelper . FillComboBox ( hWnd , idcComboDisk1 , m_defaultDiskOptions , - 1 ) ;
m_PropertySheetHelper . FillComboBox ( hWnd , idcComboDisk2 , m_defaultDiskOptions , - 1 ) ;
2019-12-19 19:42:30 +00:00
2020-01-04 13:58:59 +00:00
if ( ! disk2Card . GetFullName ( DRIVE_1 ) . empty ( ) )
2019-12-19 19:42:30 +00:00
{
2021-08-29 10:39:51 +00:00
SendDlgItemMessage ( hWnd , idcComboDisk1 , CB_INSERTSTRING , 0 , ( LPARAM ) disk2Card . GetFullName ( DRIVE_1 ) . c_str ( ) ) ;
SendDlgItemMessage ( hWnd , idcComboDisk1 , CB_SETCURSEL , 0 , 0 ) ;
2019-12-19 19:42:30 +00:00
}
2020-01-04 13:58:59 +00:00
if ( ! disk2Card . GetFullName ( DRIVE_2 ) . empty ( ) )
2019-12-19 19:42:30 +00:00
{
2021-08-29 10:39:51 +00:00
SendDlgItemMessage ( hWnd , idcComboDisk2 , CB_INSERTSTRING , 0 , ( LPARAM ) disk2Card . GetFullName ( DRIVE_2 ) . c_str ( ) ) ;
SendDlgItemMessage ( hWnd , idcComboDisk2 , CB_SETCURSEL , 0 , 0 ) ;
2019-12-19 19:42:30 +00:00
}
}
void CPageDisk : : InitComboHDD ( HWND hWnd , UINT /*slot*/ )
2018-12-09 11:48:22 +00:00
{
m_PropertySheetHelper . FillComboBox ( hWnd , IDC_COMBO_HDD1 , m_defaultHDDOptions , - 1 ) ;
m_PropertySheetHelper . FillComboBox ( hWnd , IDC_COMBO_HDD2 , m_defaultHDDOptions , - 1 ) ;
2021-11-01 20:12:42 +00:00
if ( GetCardMgr ( ) . QuerySlot ( SLOT7 ) ! = CT_GenericHDD )
return ;
HarddiskInterfaceCard & card = dynamic_cast < HarddiskInterfaceCard & > ( GetCardMgr ( ) . GetRef ( SLOT7 ) ) ;
if ( ! card . GetFullName ( HARDDISK_1 ) . empty ( ) )
2018-12-09 11:48:22 +00:00
{
2021-11-01 20:12:42 +00:00
SendDlgItemMessage ( hWnd , IDC_COMBO_HDD1 , CB_INSERTSTRING , 0 , ( LPARAM ) card . GetFullName ( HARDDISK_1 ) . c_str ( ) ) ;
2018-12-09 11:48:22 +00:00
SendDlgItemMessage ( hWnd , IDC_COMBO_HDD1 , CB_SETCURSEL , 0 , 0 ) ;
}
2021-11-01 20:12:42 +00:00
if ( ! card . GetFullName ( HARDDISK_2 ) . empty ( ) )
2018-12-09 11:48:22 +00:00
{
2021-11-01 20:12:42 +00:00
SendDlgItemMessage ( hWnd , IDC_COMBO_HDD2 , CB_INSERTSTRING , 0 , ( LPARAM ) card . GetFullName ( HARDDISK_2 ) . c_str ( ) ) ;
2018-12-09 11:48:22 +00:00
SendDlgItemMessage ( hWnd , IDC_COMBO_HDD2 , CB_SETCURSEL , 0 , 0 ) ;
}
}
2012-05-06 22:14:03 +00:00
void CPageDisk : : DlgOK ( HWND hWnd )
2012-03-27 21:20:36 +00:00
{
2020-10-25 17:14:23 +00:00
// Update CiderPress pathname
{
char szFilename [ MAX_PATH ] ;
memset ( szFilename , 0 , sizeof ( szFilename ) ) ;
* ( USHORT * ) szFilename = sizeof ( szFilename ) ;
UINT nLineLength = SendDlgItemMessage ( hWnd , IDC_CIDERPRESS_FILENAME , EM_LINELENGTH , 0 , 0 ) ;
SendDlgItemMessage ( hWnd , IDC_CIDERPRESS_FILENAME , EM_GETLINE , 0 , ( LPARAM ) szFilename ) ;
nLineLength = nLineLength > sizeof ( szFilename ) - 1 ? sizeof ( szFilename ) - 1 : nLineLength ;
szFilename [ nLineLength ] = 0x00 ;
RegSaveString ( TEXT ( REG_CONFIG ) , REGVALUE_CIDERPRESSLOC , 1 , szFilename ) ;
}
2021-08-29 10:39:51 +00:00
const bool bNewEnhanceDisk = IsDlgButtonChecked ( hWnd , IDC_ENHANCE_DISK_ENABLE ) ? true : false ;
2020-10-11 16:34:44 +00:00
if ( bNewEnhanceDisk ! = GetCardMgr ( ) . GetDisk2CardMgr ( ) . GetEnhanceDisk ( ) )
2012-03-27 21:20:36 +00:00
{
2020-10-11 16:34:44 +00:00
GetCardMgr ( ) . GetDisk2CardMgr ( ) . SetEnhanceDisk ( bNewEnhanceDisk ) ;
2018-02-25 15:09:25 +00:00
REGSAVE ( TEXT ( REGVALUE_ENHANCE_DISK_SPEED ) , ( DWORD ) bNewEnhanceDisk ) ;
2012-03-27 21:20:36 +00:00
}
2022-11-17 21:08:11 +00:00
Win32Frame & win32Frame = Win32Frame : : GetWin32Frame ( ) ;
const bool bNewDiskiiStatus = IsDlgButtonChecked ( hWnd , IDC_DISKII_STATUS_ENABLE ) ? true : false ;
if ( win32Frame . GetWindowedModeShowDiskiiStatus ( ) ! = bNewDiskiiStatus )
{
REGSAVE ( REGVALUE_SHOW_DISKII_STATUS , bNewDiskiiStatus ? 1 : 0 ) ;
win32Frame . SetWindowedModeShowDiskiiStatus ( bNewDiskiiStatus ) ;
if ( ! win32Frame . IsFullScreen ( ) )
win32Frame . FrameRefreshStatus ( DRAW_BACKGROUND | DRAW_LEDS | DRAW_DISK_STATUS ) ;
}
2012-05-06 22:14:03 +00:00
m_PropertySheetHelper . PostMsgAfterClose ( hWnd , m_Page ) ;
}
void CPageDisk : : InitOptions ( HWND hWnd )
{
2021-08-29 10:39:51 +00:00
// Changes made on other pages that affect this page:
// . slot-5: MB add/removed
// . slot-5: DiskII enabled/disabled
const UINT slot = SLOT5 ;
const SS_CARDTYPE cardInSlot5 = m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ slot ] ;
CheckDlgButton ( hWnd , IDC_DISKII_SLOT5_ENABLE , ( cardInSlot5 = = CT_Disk2 ) ? BST_CHECKED : BST_UNCHECKED ) ;
const BOOL enable = ( cardInSlot5 = = CT_Disk2 | | cardInSlot5 = = CT_Empty ) ? TRUE : FALSE ;
EnableWindow ( GetDlgItem ( hWnd , IDC_DISKII_SLOT5_ENABLE ) , enable ) ;
if ( cardInSlot5 = = CT_Disk2 )
InitComboFloppyDrive ( hWnd , slot ) ;
else
EnableFloppyDrive ( hWnd , FALSE , slot ) ; // disable if slot5 is empty (or has some other card in it)
2012-03-27 21:20:36 +00:00
}
2012-05-06 22:14:03 +00:00
void CPageDisk : : EnableHDD ( HWND hWnd , BOOL bEnable )
2012-03-27 21:20:36 +00:00
{
2014-10-01 23:18:46 +00:00
EnableWindow ( GetDlgItem ( hWnd , IDC_COMBO_HDD1 ) , bEnable ) ;
EnableWindow ( GetDlgItem ( hWnd , IDC_COMBO_HDD2 ) , bEnable ) ;
2018-12-09 11:48:22 +00:00
EnableWindow ( GetDlgItem ( hWnd , IDC_HDD_SWAP ) , bEnable ) ;
2014-10-01 23:18:46 +00:00
}
2021-08-29 10:39:51 +00:00
void CPageDisk : : EnableFloppyDrive ( HWND hWnd , BOOL bEnable , UINT slot )
2017-06-03 17:12:40 +00:00
{
2021-08-29 10:39:51 +00:00
_ASSERT ( slot = = SLOT6 | | slot = = SLOT5 ) ;
if ( slot = = SLOT6 )
{
EnableWindow ( GetDlgItem ( hWnd , IDC_COMBO_DISK1 ) , bEnable ) ;
EnableWindow ( GetDlgItem ( hWnd , IDC_COMBO_DISK2 ) , bEnable ) ;
}
else if ( slot = = SLOT5 )
{
EnableWindow ( GetDlgItem ( hWnd , IDC_COMBO_DISK1_SLOT5 ) , bEnable ) ;
EnableWindow ( GetDlgItem ( hWnd , IDC_COMBO_DISK2_SLOT5 ) , bEnable ) ;
}
2017-06-03 17:12:40 +00:00
}
2014-10-10 20:24:50 +00:00
void CPageDisk : : HandleHDDCombo ( HWND hWnd , UINT driveSelected , UINT comboSelected )
2014-10-01 23:18:46 +00:00
{
2017-06-03 17:21:27 +00:00
if ( ! IsDlgButtonChecked ( hWnd , IDC_HDD_ENABLE ) )
return ;
2021-11-01 20:12:42 +00:00
_ASSERT ( GetCardMgr ( ) . QuerySlot ( SLOT7 ) = = CT_GenericHDD ) ;
if ( GetCardMgr ( ) . QuerySlot ( SLOT7 ) ! = CT_GenericHDD )
return ;
HarddiskInterfaceCard & card = dynamic_cast < HarddiskInterfaceCard & > ( GetCardMgr ( ) . GetRef ( SLOT7 ) ) ;
2014-10-01 23:18:46 +00:00
// Search from "select hard drive"
DWORD dwOpenDialogIndex = ( DWORD ) SendDlgItemMessage ( hWnd , comboSelected , CB_FINDSTRINGEXACT , - 1 , ( LPARAM ) & m_defaultHDDOptions [ 0 ] ) ;
DWORD dwComboSelection = ( DWORD ) SendDlgItemMessage ( hWnd , comboSelected , CB_GETCURSEL , 0 , 0 ) ;
2017-06-03 17:21:27 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_SETCURSEL , - 1 , 0 ) ; // Set to "empty" item
if ( dwComboSelection = = dwOpenDialogIndex )
2014-10-10 20:24:50 +00:00
{
2017-06-03 17:21:27 +00:00
EnableHDD ( hWnd , FALSE ) ; // Prevent multiple Selection dialogs to be triggered
2021-11-01 20:12:42 +00:00
bool bRes = card . Select ( driveSelected ) ;
2017-06-03 17:21:27 +00:00
EnableHDD ( hWnd , TRUE ) ;
2017-06-03 17:12:40 +00:00
2017-06-03 17:21:27 +00:00
if ( ! bRes )
2014-10-10 20:24:50 +00:00
{
2017-06-03 17:21:27 +00:00
if ( SendDlgItemMessage ( hWnd , comboSelected , CB_GETCOUNT , 0 , 0 ) = = 3 ) // If there's already a HDD...
SendDlgItemMessage ( hWnd , comboSelected , CB_SETCURSEL , 0 , 0 ) ; // then reselect it in the ComboBox
return ;
}
2017-06-03 17:12:40 +00:00
2017-06-03 17:21:27 +00:00
// Add hard drive name as item 0 and select it
if ( dwOpenDialogIndex > 0 )
{
// Remove old item first
SendDlgItemMessage ( hWnd , comboSelected , CB_DELETESTRING , 0 , 0 ) ;
}
2017-06-03 17:12:40 +00:00
2021-11-01 20:12:42 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_INSERTSTRING , 0 , ( LPARAM ) card . GetFullName ( driveSelected ) . c_str ( ) ) ;
2017-06-03 17:21:27 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_SETCURSEL , 0 , 0 ) ;
2014-10-01 23:18:46 +00:00
2017-06-03 17:21:27 +00:00
// If the HD was in the other combo, remove now
DWORD comboOther = ( comboSelected = = IDC_COMBO_HDD1 ) ? IDC_COMBO_HDD2 : IDC_COMBO_HDD1 ;
2014-10-01 23:18:46 +00:00
2021-11-01 20:12:42 +00:00
DWORD duplicated = ( DWORD ) SendDlgItemMessage ( hWnd , comboOther , CB_FINDSTRINGEXACT , - 1 , ( LPARAM ) card . GetFullName ( driveSelected ) . c_str ( ) ) ;
2017-06-03 17:21:27 +00:00
if ( duplicated ! = CB_ERR )
{
SendDlgItemMessage ( hWnd , comboOther , CB_DELETESTRING , duplicated , 0 ) ;
SendDlgItemMessage ( hWnd , comboOther , CB_SETCURSEL , - 1 , 0 ) ;
2014-10-01 23:18:46 +00:00
}
2017-06-03 17:21:27 +00:00
}
else if ( dwComboSelection = = ( dwOpenDialogIndex + 1 ) )
{
if ( dwComboSelection > 1 )
2014-10-10 20:24:50 +00:00
{
2021-08-29 10:39:51 +00:00
if ( RemovalConfirmation ( comboSelected ) )
2017-06-03 17:21:27 +00:00
{
// Unplug selected disk
2021-11-01 20:12:42 +00:00
card . Unplug ( driveSelected ) ;
2017-06-03 17:21:27 +00:00
// Remove drive from list
SendDlgItemMessage ( hWnd , comboSelected , CB_DELETESTRING , 0 , 0 ) ;
}
else
2014-10-10 20:24:50 +00:00
{
2017-06-03 17:21:27 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_SETCURSEL , 0 , 0 ) ;
2014-10-01 23:18:46 +00:00
}
}
}
}
2021-08-29 10:39:51 +00:00
void CPageDisk : : HandleFloppyDriveCombo ( HWND hWnd , UINT driveSelected , UINT comboSelected , UINT comboOther , UINT slot )
2014-10-01 23:18:46 +00:00
{
2021-08-29 10:39:51 +00:00
_ASSERT ( slot = = SLOT6 | | slot = = SLOT5 ) ;
if ( m_PropertySheetHelper . GetConfigNew ( ) . m_Slot [ slot ] ! = CT_Disk2 )
2020-01-04 13:58:59 +00:00
{
_ASSERT ( 0 ) ; // Shouldn't come here, as the combo is disabled
return ;
}
2021-08-29 10:39:51 +00:00
Disk2InterfaceCard & disk2Card = dynamic_cast < Disk2InterfaceCard & > ( GetCardMgr ( ) . GetRef ( slot ) ) ;
2019-12-19 19:42:30 +00:00
2014-10-10 20:24:50 +00:00
// Search from "select floppy drive"
2014-10-01 23:18:46 +00:00
DWORD dwOpenDialogIndex = ( DWORD ) SendDlgItemMessage ( hWnd , comboSelected , CB_FINDSTRINGEXACT , - 1 , ( LPARAM ) & m_defaultDiskOptions [ 0 ] ) ;
DWORD dwComboSelection = ( DWORD ) SendDlgItemMessage ( hWnd , comboSelected , CB_GETCURSEL , 0 , 0 ) ;
2017-06-03 17:12:40 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_SETCURSEL , - 1 , 0 ) ; // Set to "empty" item
2014-10-10 20:24:50 +00:00
if ( dwComboSelection = = dwOpenDialogIndex )
{
2021-08-29 10:39:51 +00:00
EnableFloppyDrive ( hWnd , FALSE , slot ) ; // Prevent multiple Selection dialogs to be triggered
2020-01-04 13:58:59 +00:00
bool bRes = disk2Card . UserSelectNewDiskImage ( driveSelected ) ;
2021-08-29 10:39:51 +00:00
EnableFloppyDrive ( hWnd , TRUE , slot ) ;
2017-06-03 17:12:40 +00:00
if ( ! bRes )
{
if ( SendDlgItemMessage ( hWnd , comboSelected , CB_GETCOUNT , 0 , 0 ) = = 3 ) // If there's already a disk...
SendDlgItemMessage ( hWnd , comboSelected , CB_SETCURSEL , 0 , 0 ) ; // then reselect it in the ComboBox
return ;
}
2014-10-10 20:24:50 +00:00
// Add floppy drive name as item 0 and select it
if ( dwOpenDialogIndex > 0 )
{
2014-10-01 23:18:46 +00:00
//Remove old item first
SendDlgItemMessage ( hWnd , comboSelected , CB_DELETESTRING , 0 , 0 ) ;
}
2017-06-03 17:12:40 +00:00
2020-01-04 13:58:59 +00:00
std : : string fullname = disk2Card . GetFullName ( driveSelected ) ;
2019-12-19 19:42:30 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_INSERTSTRING , 0 , ( LPARAM ) fullname . c_str ( ) ) ;
2014-10-01 23:18:46 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_SETCURSEL , 0 , 0 ) ;
2012-03-27 21:20:36 +00:00
2014-10-10 20:24:50 +00:00
// If the FD was in the other combo, remove now
2019-12-19 19:42:30 +00:00
DWORD duplicated = ( DWORD ) SendDlgItemMessage ( hWnd , comboOther , CB_FINDSTRINGEXACT , - 1 , ( LPARAM ) fullname . c_str ( ) ) ;
2014-10-10 20:24:50 +00:00
if ( duplicated ! = CB_ERR )
{
2014-10-01 23:18:46 +00:00
SendDlgItemMessage ( hWnd , comboOther , CB_DELETESTRING , duplicated , 0 ) ;
SendDlgItemMessage ( hWnd , comboOther , CB_SETCURSEL , - 1 , 0 ) ;
}
}
2014-10-10 20:24:50 +00:00
else if ( dwComboSelection = = ( dwOpenDialogIndex + 1 ) )
{
if ( dwComboSelection > 1 )
{
2021-08-29 10:39:51 +00:00
if ( RemovalConfirmation ( comboSelected ) )
2014-10-10 20:24:50 +00:00
{
2017-06-03 17:12:40 +00:00
// Eject selected disk
2020-01-04 13:58:59 +00:00
disk2Card . EjectDisk ( driveSelected ) ;
2017-06-03 17:12:40 +00:00
// Remove drive from list
2014-10-01 23:18:46 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_DELETESTRING , 0 , 0 ) ;
}
2014-10-10 20:24:50 +00:00
else
{
2014-10-01 23:18:46 +00:00
SendDlgItemMessage ( hWnd , comboSelected , CB_SETCURSEL , 0 , 0 ) ;
}
}
}
2012-03-27 21:20:36 +00:00
}
2014-10-01 23:18:46 +00:00
2018-12-09 11:48:22 +00:00
void CPageDisk : : HandleHDDSwap ( HWND hWnd )
{
if ( ! RemovalConfirmation ( IDC_HDD_SWAP ) )
return ;
2021-11-01 20:12:42 +00:00
if ( GetCardMgr ( ) . QuerySlot ( SLOT7 ) ! = CT_GenericHDD )
return ;
if ( ! dynamic_cast < HarddiskInterfaceCard & > ( GetCardMgr ( ) . GetRef ( SLOT7 ) ) . ImageSwap ( ) )
2018-12-09 11:48:22 +00:00
return ;
2019-12-19 19:42:30 +00:00
InitComboHDD ( hWnd , SLOT7 ) ;
2018-12-09 11:48:22 +00:00
}
2014-10-01 23:18:46 +00:00
2014-10-10 20:24:50 +00:00
UINT CPageDisk : : RemovalConfirmation ( UINT uCommand )
2014-10-01 23:18:46 +00:00
{
bool bMsgBox = true ;
2014-10-10 20:24:50 +00:00
2021-08-29 10:39:51 +00:00
bool isDisk = false ;
UINT drive = 0 ;
2014-10-10 20:24:50 +00:00
if ( uCommand = = IDC_COMBO_DISK1 | | uCommand = = IDC_COMBO_DISK2 )
2021-08-29 10:39:51 +00:00
{
isDisk = true ;
drive = uCommand - IDC_COMBO_DISK1 ;
}
else if ( uCommand = = IDC_COMBO_DISK1_SLOT5 | | uCommand = = IDC_COMBO_DISK2_SLOT5 )
{
isDisk = true ;
drive = uCommand - IDC_COMBO_DISK1_SLOT5 ;
}
2022-02-15 18:48:20 +00:00
std : : string strText ;
2021-08-29 10:39:51 +00:00
if ( isDisk )
2022-02-15 18:48:20 +00:00
strText = StrFormat ( " Do you really want to eject the disk in drive-%c ? " , ' 1 ' + drive ) ;
2014-10-10 20:24:50 +00:00
else if ( uCommand = = IDC_COMBO_HDD1 | | uCommand = = IDC_COMBO_HDD2 )
2022-02-15 18:48:20 +00:00
strText = StrFormat ( " Do you really want to unplug harddisk-%c ? " , ' 1 ' + uCommand - IDC_COMBO_HDD1 ) ;
2018-12-09 11:48:22 +00:00
else if ( uCommand = = IDC_HDD_SWAP )
2022-02-15 18:48:20 +00:00
strText = " Do you really want to swap the harddisk images? " ;
2014-10-01 23:18:46 +00:00
else
bMsgBox = false ;
if ( bMsgBox )
{
2022-02-15 18:48:20 +00:00
int nRes = GetFrame ( ) . FrameMessageBox ( strText . c_str ( ) , " Eject/Unplug Warning " , MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND ) ;
2014-10-01 23:18:46 +00:00
if ( nRes = = IDNO )
2014-10-10 20:24:50 +00:00
uCommand = 0 ;
2014-10-01 23:18:46 +00:00
}
2014-10-10 20:24:50 +00:00
return uCommand ;
}