From e46631e47bb8f5654849fa7762e5a27c9b5959e5 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 13 Nov 2016 05:39:21 +0100 Subject: [PATCH] Reworked the menus so they're more logically grouped; Removed the lone Misc menu and mvoed Status to Settings; Added a SCSI CD-ROM option to the menu; Removed the atapi_cdrom_enabled option and replaced any usage of it with !scsi_cdrom_enabled; Disabling/enabling the CD-ROM drive is now separate from the drive's contents; The tertiary IDE controller now never gets enabled is the CD-ROM drive is either disabled or SCSI. --- src/ibm.h | 2 +- src/ide.c | 10 +++--- src/model.c | 28 ++++++++--------- src/pc.c | 4 +-- src/pc.rc | 27 ++++++++-------- src/resources.h | 1 + src/win.c | 84 +++++++++++++++++++++++++++++++++++-------------- 7 files changed, 95 insertions(+), 61 deletions(-) diff --git a/src/ibm.h b/src/ibm.h index 5484ee6f8..992acc1ba 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -571,7 +571,7 @@ extern int cdrom_drive; extern int old_cdrom_drive; extern int idecallback[3]; extern int cdrom_enabled; -extern int atapi_cdrom_enabled, scsi_cdrom_enabled; +extern int scsi_cdrom_enabled; #define CD_STATUS_EMPTY 0 #define CD_STATUS_DATA_ONLY 1 diff --git a/src/ide.c b/src/ide.c index 2da874e3b..ffb02a853 100644 --- a/src/ide.c +++ b/src/ide.c @@ -629,10 +629,9 @@ void resetide(void) { ide_drives[d].packetstatus = 0xFF; - if ((atapi_cdrom_channel == d) && atapi_cdrom_enabled) + if ((atapi_cdrom_channel == d) && cdrom_enabled && !scsi_cdrom_enabled) { - if (cdrom_enabled) - ide_drives[d].type = IDE_CDROM; + ide_drives[d].type = IDE_CDROM; } else { @@ -654,10 +653,9 @@ void resetide(void) { ide_drives[d].packetstatus = 0xFF; - if ((atapi_cdrom_channel == d) && atapi_cdrom_enabled) + if ((atapi_cdrom_channel == d) && cdrom_enabled && !scsi_cdrom_enabled) { - if (cdrom_enabled) - ide_drives[d].type = IDE_CDROM; + ide_drives[d].type = IDE_CDROM; } else { diff --git a/src/model.c b/src/model.c index d84dd59f4..4c4955214 100644 --- a/src/model.c +++ b/src/model.c @@ -429,7 +429,7 @@ void at_sis496_init() mouse_serial_init(); pci_init(PCI_CONFIG_TYPE_1, 0, 31); device_add(&sis496_device); - ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_r418_init() @@ -440,7 +440,7 @@ void at_r418_init() pci_init(PCI_CONFIG_TYPE_1, 0, 31); fdc37c665_init(); device_add(&sis496_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_batman_init() @@ -453,7 +453,7 @@ void at_batman_init() fdc37c665_init(); intel_batman_init(); device_add(&intel_flash_bxt_ami_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_586mc1_init() @@ -479,7 +479,7 @@ void at_plato_init() /* It seems it uses the same interface as Batman. */ intel_batman_init(); device_add(&intel_flash_bxt_ami_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_advanced_common_init() @@ -491,7 +491,7 @@ void at_advanced_common_init() piix_init(7); // pc87306_init(); intel_endeavor_init(); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_endeavor_init() @@ -518,7 +518,7 @@ void at_mb500n_init() fdc37c665_init(); intel_endeavor_init(); device_add(&intel_flash_bxt_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } #if 0 @@ -533,7 +533,7 @@ void at_p54tp4xe_init() fdc37c665_init(); intel_endeavor_init(); device_add(&intel_flash_bxt_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } #endif @@ -548,7 +548,7 @@ void at_acerm3a_init() fdc37c932fr_init(); acerm3a_io_init(); device_add(&intel_flash_bxb_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_acerv35n_init() @@ -562,7 +562,7 @@ void at_acerv35n_init() fdc37c932fr_init(); acerm3a_io_init(); device_add(&intel_flash_bxb_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } #if 0 @@ -576,7 +576,7 @@ void at_p55t2p4_init() piix3_init(7); w83877f_init(); device_add(&intel_flash_bxt_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } #endif @@ -590,7 +590,7 @@ void at_i430vx_init() piix3_init(7); um8669f_init(); device_add(&intel_flash_bxt_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } // rom_t ami_ec_rom; @@ -612,7 +612,7 @@ void at_p55tvp4_init() intel_endeavor_init(); */ - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } #endif @@ -626,7 +626,7 @@ void at_p55va_init() piix3_init(7); fdc37c932fr_init(); device_add(&intel_flash_bxt_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_i440fx_init() @@ -639,7 +639,7 @@ void at_i440fx_init() piix3_init(7); fdc37c665_init(); device_add(&intel_flash_bxt_device); - if (atapi_cdrom_channel >= 4) ide_ter_init(); + if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void model_init() diff --git a/src/pc.c b/src/pc.c index afa67a09b..d3c586584 100644 --- a/src/pc.c +++ b/src/pc.c @@ -60,7 +60,7 @@ int window_w, window_h, window_x, window_y, window_remember; int start_in_fullscreen = 0; int frame = 0; -int scsi_cdrom_enabled, atapi_cdrom_enabled; +int scsi_cdrom_enabled; int cdrom_enabled; int CPUID; int vid_resize, vid_api; @@ -670,7 +670,6 @@ void loadconfig(char *fn) old_cdrom_drive = cdrom_drive; cdrom_enabled = config_get_int(NULL, "cdrom_enabled", 0); - atapi_cdrom_enabled = config_get_int(NULL, "atapi_cdrom_enabled", 1); atapi_cdrom_channel = config_get_int(NULL, "atapi_cdrom_channel", 2); scsi_cdrom_enabled = config_get_int(NULL, "scsi_cdrom_enabled", 0); @@ -816,7 +815,6 @@ void saveconfig() config_set_int(NULL, "cdrom_drive", cdrom_drive); config_set_int(NULL, "cdrom_enabled", cdrom_enabled); - config_set_int(NULL, "atapi_cdrom_enabled", atapi_cdrom_enabled); config_set_int(NULL, "atapi_cdrom_channel", atapi_cdrom_channel); config_set_int(NULL, "scsi_cdrom_enabled", scsi_cdrom_enabled); diff --git a/src/pc.rc b/src/pc.rc index 008a59ccf..0fcea2214 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -20,21 +20,28 @@ BEGIN BEGIN MENUITEM "Change drive &A:...", IDM_DISC_A MENUITEM "Change drive A (&Write-protected):...", IDM_DISC_A_WP + MENUITEM "&Eject drive A:", IDM_EJECT_A + MENUITEM SEPARATOR MENUITEM "Change drive &B:...", IDM_DISC_B MENUITEM "Change drive B (W&rite-protected):...", IDM_DISC_B_WP - MENUITEM "&Eject drive A:", IDM_EJECT_A MENUITEM "E&ject drive B:", IDM_EJECT_B + MENUITEM SEPARATOR MENUITEM "&Configure hard discs...",IDM_HDCONF + POPUP "&CD-ROM" + BEGIN + MENUITEM "&Disabled", IDM_CDROM_DISABLED + MENUITEM "&SCSI", IDM_CDROM_SCSI + MENUITEM SEPARATOR + MENUITEM "&Empty",IDM_CDROM_EMPTY + MENUITEM "&ISO...",IDM_CDROM_ISO + END END POPUP "&Settings" BEGIN MENUITEM "&Configure...", IDM_CONFIG - POPUP "&CD-ROM" - BEGIN - MENUITEM "&Disabled", IDM_CDROM_DISABLED - MENUITEM "&Empty",IDM_CDROM_EMPTY - MENUITEM "&ISO...",IDM_CDROM_ISO - END + MENUITEM "&Load configuration...", IDM_CONFIG_LOAD + MENUITEM "&Save configuration...", IDM_CONFIG_SAVE + MENUITEM SEPARATOR POPUP "&Video" BEGIN MENUITEM "&Resizeable window",IDM_VID_RESIZE @@ -54,12 +61,6 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Take s&creenshot\tCtrl+F11", IDM_VID_SCREENSHOT END - MENUITEM SEPARATOR - MENUITEM "&Load configuration...", IDM_CONFIG_LOAD - MENUITEM "&Save configuration...", IDM_CONFIG_SAVE - END - POPUP "&Misc" - BEGIN MENUITEM "&Status", IDM_STATUS END END diff --git a/src/resources.h b/src/resources.h index f852af7e2..a19c28e2c 100644 --- a/src/resources.h +++ b/src/resources.h @@ -30,6 +30,7 @@ #define IDM_CDROM_EMPTY 40200 #define IDM_CDROM_REAL 40200 #define IDM_CDROM_DISABLED 40300 +#define IDM_CDROM_SCSI 40400 #define IDC_COMBO1 1000 #define IDC_COMBOVID 1001 diff --git a/src/win.c b/src/win.c index 0b26190d0..6b3ad8edb 100644 --- a/src/win.c +++ b/src/win.c @@ -321,8 +321,8 @@ static void initmenu(void) int c; HMENU m; char s[32]; - m=GetSubMenu(menu,2); /*Settings*/ - m=GetSubMenu(m,1); /*CD-ROM*/ + m=GetSubMenu(menu,1); /*Disc*/ + m=GetSubMenu(m,9); /*CD-ROM*/ /* Loop through each Windows drive letter and test to see if it's a CDROM */ @@ -617,15 +617,19 @@ int WINAPI WinMain (HINSTANCE hThisInstance, SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX); // pclog("Checking CD-ROM menu item...\n"); + + /* Note by Kiririn: I've redone this since the CD-ROM can be disabled but still have something inside it. */ if (!cdrom_enabled) CheckMenuItem(menu, IDM_CDROM_DISABLED, MF_CHECKED); - else - { - if (cdrom_drive == 200) - CheckMenuItem(menu, IDM_CDROM_ISO, MF_CHECKED); - else - CheckMenuItem(menu, IDM_CDROM_REAL + cdrom_drive, MF_CHECKED); - } + + if (scsi_cdrom_enabled) + CheckMenuItem(menu, IDM_CDROM_SCSI, MF_CHECKED); + + if (cdrom_drive == 200) + CheckMenuItem(menu, IDM_CDROM_ISO, MF_CHECKED); + else + CheckMenuItem(menu, IDM_CDROM_REAL + cdrom_drive, MF_CHECKED); + // pclog("Checking video resize menu item...\n"); if (vid_resize) CheckMenuItem(menu, IDM_VID_RESIZE, MF_CHECKED); // pclog("Checking video API menu item...\n"); @@ -1131,6 +1135,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM pause = 0; break; +#if 0 case IDM_CDROM_DISABLED: if (cdrom_enabled) { @@ -1161,14 +1166,43 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM pause = 0; } break; +#endif + case IDM_CDROM_DISABLED: + if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) + { + break; + } + pause = 1; + Sleep(100); + cdrom_enabled ^= 1; + CheckMenuItem(hmenu, IDM_CDROM_DISABLED, cdrom_enabled ? MF_UNCHECKED : MF_CHECKED); + saveconfig(); + resetpchard(); + pause = 0; + break; + + case IDM_CDROM_SCSI: + if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) + { + break; + } + pause = 1; + Sleep(100); + scsi_cdrom_enabled ^= 1; + CheckMenuItem(hmenu, IDM_CDROM_DISABLED, scsi_cdrom_enabled ? MF_CHECKED : MF_UNCHECKED); + saveconfig(); + resetpchard(); + pause = 0; + break; case IDM_CDROM_EMPTY: - if (!cdrom_enabled) + /* if (!cdrom_enabled) { if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) break; - } - if ((cdrom_drive == 0) && cdrom_enabled) + } */ + // if ((cdrom_drive == 0) && cdrom_enabled) + if (cdrom_drive == 0) { /* Switch from empty to empty. Do nothing. */ break; @@ -1188,7 +1222,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM cdrom_drive=0; CheckMenuItem(hmenu, IDM_CDROM_EMPTY, MF_CHECKED); saveconfig(); - if (!cdrom_enabled) + /* if (!cdrom_enabled) { pause = 1; Sleep(100); @@ -1196,20 +1230,21 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM saveconfig(); resetpchard(); pause = 0; - } + } */ break; case IDM_CDROM_ISO: if (!getfile(hwnd,"CD-ROM image (*.ISO)\0*.ISO\0All files (*.*)\0*.*\0",iso_path)) { - if (!cdrom_enabled) + /* if (!cdrom_enabled) { if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) break; - } + } */ old_cdrom_drive = cdrom_drive; strcpy(temp_iso_path, openfilestring); - if ((strcmp(iso_path, temp_iso_path) == 0) && (cdrom_drive == 200) && cdrom_enabled) + // if ((strcmp(iso_path, temp_iso_path) == 0) && (cdrom_drive == 200) && cdrom_enabled) + if ((strcmp(iso_path, temp_iso_path) == 0) && (cdrom_drive == 200)) { /* Switching from ISO to the same ISO. Do nothing. */ break; @@ -1228,7 +1263,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM cdrom_drive = 200; CheckMenuItem(hmenu, IDM_CDROM_ISO, MF_CHECKED); saveconfig(); - if (!cdrom_enabled) + /* if (!cdrom_enabled) { pause = 1; Sleep(100); @@ -1236,20 +1271,21 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM saveconfig(); resetpchard(); pause = 0; - } + } */ } break; default: if (LOWORD(wParam)>IDM_CDROM_REAL && LOWORD(wParam)<(IDM_CDROM_REAL+100)) { - if (!cdrom_enabled) + /* if (!cdrom_enabled) { if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) break; - } + } */ new_cdrom_drive = LOWORD(wParam)-IDM_CDROM_REAL; - if ((cdrom_drive == new_cdrom_drive) && cdrom_enabled) + // if ((cdrom_drive == new_cdrom_drive) && cdrom_enabled) + if (cdrom_drive == new_cdrom_drive) { /* Switching to the same drive. Do nothing. */ break; @@ -1269,7 +1305,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM cdrom_drive = new_cdrom_drive; CheckMenuItem(hmenu, IDM_CDROM_REAL + cdrom_drive, MF_CHECKED); saveconfig(); - if (!cdrom_enabled) + /* if (!cdrom_enabled) { pause = 1; Sleep(100); @@ -1277,7 +1313,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM saveconfig(); resetpchard(); pause = 0; - } + } */ } break; }