diff --git a/src/include/86box/language.h b/src/include/86box/language.h index 0e603e92f..ab8b0d0c1 100644 --- a/src/include/86box/language.h +++ b/src/include/86box/language.h @@ -112,6 +112,7 @@ #define IDS_2136 2136 // "Don't Exit" #define IDS_2137 2137 // "Reset" #define IDS_2138 2138 // "Don't Reset" +#define IDS_2139 2139 // "CD-ROM drives" #define IDS_4096 4096 // "Hard disk (%s)" #define IDS_4097 4097 // "%01i:%01i" @@ -198,7 +199,7 @@ #define IDS_LANG_ENUS IDS_7168 -#define STR_NUM_2048 71 +#define STR_NUM_2048 92 #define STR_NUM_3072 11 #define STR_NUM_4096 18 #define STR_NUM_4352 7 diff --git a/src/include/86box/mo.h b/src/include/86box/mo.h index 39587394d..59efe6795 100644 --- a/src/include/86box/mo.h +++ b/src/include/86box/mo.h @@ -59,7 +59,8 @@ typedef struct int8_t supported_media[KNOWN_MO_TYPES]; } mo_drive_type_t; -static const mo_drive_type_t mo_drive_types[22] = { +#define KNOWN_MO_DRIVE_TYPES 22 +static const mo_drive_type_t mo_drive_types[KNOWN_MO_DRIVE_TYPES] = { {"86BOX", "MAGNETO OPTICAL", "1.00",{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}, {"FUJITSU", "M2512A", "1314",{1, 1, 0, 0, 0, 0, 0, 0, 0}}, {"FUJITSU", "M2513-MCC3064SS", "1.00",{1, 1, 1, 1, 0, 0, 0, 0, 0, 0}}, @@ -117,35 +118,31 @@ typedef struct { } mo_drive_t; typedef struct { - uint8_t id, - error, status, - phase, - features, - is_dma, - do_page_save, - unit_attention; + mode_sense_pages_t ms_pages_saved; - mo_drive_t *drv; + mo_drive_t *drv; - uint16_t request_length, - max_transfer_len; + uint8_t *buffer, + atapi_cdb[16], + current_cdb[16], + sense[256]; - int requested_blocks, packet_status, - request_pos, old_len, - total_length; + uint8_t status, phase, + error, id, + features, pad0, + pad1, pad2; - uint32_t sector_pos, sector_len, - packet_len, pos, - seek_pos; + uint16_t request_length, max_transfer_len; - double callback; + int requested_blocks, packet_status, + total_length, do_page_save, + unit_attention, request_pos, + old_len, pad3; - mode_sense_pages_t ms_pages_saved; + uint32_t sector_pos, sector_len, + packet_len, pos; - uint8_t *buffer, - atapi_cdb[16], - current_cdb[16], - sense[256]; + double callback; } mo_t; diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index f3f962404..1b44bf73b 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -39,7 +39,8 @@ #define DLG_CFG_HARD_DISKS 118 /* sub-dialog of config */ #define DLG_CFG_HARD_DISKS_ADD 119 /* sub-dialog of config */ #define DLG_CFG_FLOPPY_DRIVES 120 /* sub-dialog of config */ -#define DLG_CFG_OTHER_REMOVABLE_DEVICES 121 /* sub-dialog of config */ +#define DLG_CFG_CDROM_DRIVES 121 /* sub-dialog of config */ +#define DLG_CFG_OTHER_REMOVABLE_DEVICES 122 /* sub-dialog of config */ /* Static text label IDs. */ #define IDT_1700 1700 /* Language: */ @@ -100,6 +101,11 @@ #define IDT_1766 1766 /* Board #4: */ #define IDT_1767 1767 /* ISA RTC: */ #define IDT_1768 1768 /* Ext FD Controller: */ +#define IDT_1769 1769 /* MO drives: */ +#define IDT_1770 1770 /* Bus: */ +#define IDT_1771 1771 /* ID: */ +#define IDT_1772 1772 /* Channel */ +#define IDT_1773 1773 /* Type: */ /* @@ -236,6 +242,7 @@ #define IDC_COMBO_MO_ID 1189 #define IDC_COMBO_MO_LUN 1191 #define IDC_COMBO_MO_CHANNEL_IDE 1192 +#define IDC_COMBO_MO_TYPE 1193 #define IDC_SLIDER_GAIN 1190 /* sound gain dialog */ diff --git a/src/include/86box/win.h b/src/include/86box/win.h index f73956656..9d7eeb6af 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -164,7 +164,8 @@ extern void NewFloppyDialogCreate(HWND hwnd, int id, int part); #define SETTINGS_PAGE_PERIPHERALS 6 #define SETTINGS_PAGE_HARD_DISKS 7 #define SETTINGS_PAGE_FLOPPY_DRIVES 8 -#define SETTINGS_PAGE_OTHER_REMOVABLE_DEVICES 9 +#define SETTINGS_PAGE_CDROM_DRIVES 9 +#define SETTINGS_PAGE_OTHER_REMOVABLE_DEVICES 10 extern void win_settings_open(HWND hwnd); extern void win_settings_open_ex(HWND hwnd, int category); diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 9db8502f1..f2f35efe2 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -627,7 +627,7 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,196,86,64,10 END -DLG_CFG_OTHER_REMOVABLE_DEVICES DIALOG DISCARDABLE 97, 0, 267, 221 +DLG_CFG_CDROM_DRIVES DIALOG DISCARDABLE 97, 0, 267, 150 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN @@ -647,6 +647,30 @@ BEGIN COMBOBOX IDC_COMBO_CD_SPEED,33,105,90,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Speed:",IDT_1758,7,107,24,8 +END + +DLG_CFG_OTHER_REMOVABLE_DEVICES DIALOG DISCARDABLE 97, 0, 267, 221 +STYLE DS_CONTROL | WS_CHILD +FONT 9, "Segoe UI" +BEGIN + + CONTROL "List1",IDC_LIST_MO_DRIVES,"SysListView32",LVS_REPORT | + LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | + WS_TABSTOP,7,18,253,60 + LTEXT "MO drives:",IDT_1769,7,7,50,8 + COMBOBOX IDC_COMBO_MO_BUS,33,85,90,12,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Bus:",IDT_1770,7,87,24,8 + COMBOBOX IDC_COMBO_MO_ID,170,85,90,12,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "ID:",IDT_1771,131,87,38,8 + COMBOBOX IDC_COMBO_MO_CHANNEL_IDE,170,85,90,12,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Channel:",IDT_1772,131,87,38,8 + COMBOBOX IDC_COMBO_MO_TYPE,33,105,120,12,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Type:",IDT_1773,7,107,24,8 + CONTROL "List1",IDC_LIST_ZIP_DRIVES,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,137,253,60 @@ -654,7 +678,7 @@ BEGIN COMBOBOX IDC_COMBO_ZIP_BUS,23,204,90,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Bus:",IDT_1753,7,206,14,8 - COMBOBOX IDC_COMBO_ZIP_ID,139,204,61,12,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_ZIP_ID,149,204,61,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "ID:",IDT_1754,120,206,28,8 COMBOBOX IDC_COMBO_ZIP_CHANNEL_IDE,149,204,61,12,CBS_DROPDOWNLIST | @@ -708,8 +732,8 @@ END 161 ICON DISCARDABLE "win/icons/cdrom_empty_active.ico" 176 ICON DISCARDABLE "win/icons/zip_empty.ico" 177 ICON DISCARDABLE "win/icons/zip_empty_active.ico" -183 ICON DISCARDABLE "win/icons/mo_empty.ico" -184 ICON DISCARDABLE "win/icons/mo_empty_active.ico" +184 ICON DISCARDABLE "win/icons/mo_empty.ico" +185 ICON DISCARDABLE "win/icons/mo_empty_active.ico" 240 ICON DISCARDABLE "win/icons/machine.ico" 241 ICON DISCARDABLE "win/icons/display.ico" 242 ICON DISCARDABLE "win/icons/input_devices.ico" @@ -955,7 +979,7 @@ BEGIN IDS_2112 "Are you sure you want to hard reset the emulated machine?" IDS_2113 "Are you sure you want to exit 86Box?" IDS_2114 "Unable to initialize Ghostscript" - IDS_2115 "MO %i (%03i): %ls" + IDS_2115 "MO %i (%ls): %ls" IDS_2116 "MO images (*.IM?)\0*.IM?\0All files (*.*)\0*.*\0" IDS_2117 "Welcome to 86Box!" IDS_2118 "Internal controller" @@ -999,6 +1023,7 @@ BEGIN IDS_2136 "Don't Exit" IDS_2137 "Reset" IDS_2138 "Don't Reset" + IDS_2139 "CD-ROM drives" END STRINGTABLE DISCARDABLE diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 0bbdf75a6..f13cc4f29 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -51,6 +51,7 @@ #include <86box/hdc.h> #include <86box/hdc_ide.h> #include <86box/zip.h> +#include <86box/mo.h> #include <86box/fdd.h> #include <86box/fdc.h> #include <86box/fdc_ext.h> @@ -116,6 +117,7 @@ static int temp_fdd_check_bpb[FDD_NUM]; /* Other removable devices category */ static cdrom_t temp_cdrom[CDROM_NUM]; static zip_drive_t temp_zip_drives[ZIP_NUM]; +static mo_drive_t temp_mo_drives[MO_NUM]; static HWND hwndParentDialog, hwndChildDialog; @@ -320,6 +322,13 @@ win_settings_init(void) else if (zip_drives[i].bus_type == ZIP_BUS_SCSI) scsi_tracking[zip_drives[i].scsi_device_id >> 3] |= (1 << ((zip_drives[i].scsi_device_id & 0x07) << 3)); } + memcpy(temp_mo_drives, mo_drives, MO_NUM * sizeof(mo_drive_t)); + for (i = 0; i < MO_NUM; i++) { + if (mo_drives[i].bus_type == MO_BUS_ATAPI) + ide_tracking |= (1 << (mo_drives[i].ide_channel << 3)); + else if (mo_drives[i].bus_type == MO_BUS_SCSI) + scsi_tracking[mo_drives[i].scsi_device_id >> 3] |= (1 << ((mo_drives[i].scsi_device_id & 0x07) << 3)); + } temp_deviceconfig = 0; } @@ -402,6 +411,7 @@ win_settings_changed(void) /* Other removable devices category */ i = i || memcmp(cdrom, temp_cdrom, CDROM_NUM * sizeof(cdrom_t)); i = i || memcmp(zip_drives, temp_zip_drives, ZIP_NUM * sizeof(zip_drive_t)); + i = i || memcmp(mo_drives, temp_mo_drives, MO_NUM * sizeof(mo_drive_t)); i = i || !!temp_deviceconfig; @@ -530,6 +540,11 @@ win_settings_save(void) zip_drives[i].f = NULL; zip_drives[i].priv = NULL; } + memcpy(mo_drives, temp_mo_drives, MO_NUM * sizeof(mo_drive_t)); + for (i = 0; i < MO_NUM; i++) { + mo_drives[i].f = NULL; + mo_drives[i].priv = NULL; + } /* Mark configuration as changed. */ config_changed = 1; @@ -3785,6 +3800,67 @@ win_settings_cdrom_drives_recalc_list(HWND hwndList) return TRUE; } +static BOOL +win_settings_mo_drives_recalc_list(HWND hwndList) +{ + LVITEM lvI; + int i = 0, fsid = 0; + WCHAR szText[256]; + char szType[30]; + + lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; + lvI.stateMask = lvI.iSubItem = lvI.state = 0; + + for (i = 0; i < MO_NUM; i++) { + fsid = combo_id_to_format_string_id(temp_mo_drives[i].bus_type); + + lvI.iSubItem = 0; + switch (temp_mo_drives[i].bus_type) { + case MO_BUS_DISABLED: + default: + lvI.pszText = plat_get_string(fsid); + lvI.iImage = 0; + break; + case MO_BUS_ATAPI: + wsprintf(szText, plat_get_string(fsid), temp_mo_drives[i].ide_channel >> 1, temp_mo_drives[i].ide_channel & 1); + lvI.pszText = szText; + lvI.iImage = 1; + break; + case MO_BUS_SCSI: + wsprintf(szText, plat_get_string(fsid), temp_mo_drives[i].scsi_device_id); + lvI.pszText = szText; + lvI.iImage = 1; + break; + } + + lvI.iItem = i; + + if (ListView_InsertItem(hwndList, &lvI) == -1) + return FALSE; + + lvI.iSubItem = 1; + if (temp_mo_drives[i].bus_type == MO_BUS_DISABLED) + lvI.pszText = plat_get_string(IDS_2103); + else { + memset(szType, 0, 30); + memcpy(szType, mo_drive_types[temp_mo_drives[i].type].vendor, 8); + szType[strlen(szType)] = ' '; + memcpy(szType + strlen(szType), mo_drive_types[temp_mo_drives[i].type].model, 16); + szType[strlen(szType)] = ' '; + memcpy(szType + strlen(szType), mo_drive_types[temp_mo_drives[i].type].revision, 4); + + mbstowcs(szText, szType, strlen(szType)+1); + lvI.pszText = szText; + } + lvI.iItem = i; + lvI.iImage = 0; + + if (ListView_SetItem(hwndList, &lvI) == -1) + return FALSE; + } + + return TRUE; +} static BOOL win_settings_zip_drives_recalc_list(HWND hwndList) @@ -3903,6 +3979,34 @@ win_settings_cdrom_drives_init_columns(HWND hwndList) } +static BOOL +win_settings_mo_drives_init_columns(HWND hwndList) +{ + LVCOLUMN lvc; + + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + + lvc.iSubItem = 0; + lvc.pszText = plat_get_string(IDS_2081); + + lvc.cx = 120; + lvc.fmt = LVCFMT_LEFT; + + if (ListView_InsertColumn(hwndList, 0, &lvc) == -1) + return FALSE; + + lvc.iSubItem = 1; + lvc.pszText = plat_get_string(IDS_2092); + + lvc.cx = 260; + lvc.fmt = LVCFMT_LEFT; + + if (ListView_InsertColumn(hwndList, 1, &lvc) == -1) + return FALSE; + + return TRUE; +} + static BOOL win_settings_zip_drives_init_columns(HWND hwndList) { @@ -4046,6 +4150,63 @@ win_settings_cdrom_drives_update_item(HWND hwndList, int i) return; } +static void +win_settings_mo_drives_update_item(HWND hwndList, int i) +{ + LVITEM lvI; + WCHAR szText[256]; + char szType[30]; + int fsid; + + lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; + lvI.stateMask = lvI.iSubItem = lvI.state = 0; + + lvI.iSubItem = 0; + lvI.iItem = i; + + fsid = combo_id_to_format_string_id(temp_mo_drives[i].bus_type); + + switch (temp_mo_drives[i].bus_type) { + case MO_BUS_DISABLED: + default: + lvI.pszText = plat_get_string(fsid); + lvI.iImage = 0; + break; + case MO_BUS_ATAPI: + wsprintf(szText, plat_get_string(fsid), temp_mo_drives[i].ide_channel >> 1, temp_mo_drives[i].ide_channel & 1); + lvI.pszText = szText; + lvI.iImage = 1; + break; + case MO_BUS_SCSI: + wsprintf(szText, plat_get_string(fsid), temp_mo_drives[i].scsi_device_id); + lvI.pszText = szText; + lvI.iImage = 1; + break; + } + + if (ListView_SetItem(hwndList, &lvI) == -1) + return; + + lvI.iSubItem = 1; + if (temp_mo_drives[i].bus_type == MO_BUS_DISABLED) + lvI.pszText = plat_get_string(IDS_2103); + else { + memset(szType, 0, 30); + memcpy(szType, mo_drive_types[temp_mo_drives[i].type].vendor, 8); + szType[strlen(szType)] = ' '; + memcpy(szType + strlen(szType), mo_drive_types[temp_mo_drives[i].type].model, 16); + szType[strlen(szType)] = ' '; + memcpy(szType + strlen(szType), mo_drive_types[temp_mo_drives[i].type].revision, 4); + mbstowcs(szText, szType, strlen(szType)+1); + lvI.pszText = szText; + } + lvI.iItem = i; + lvI.iImage = 0; + + if (ListView_SetItem(hwndList, &lvI) == -1) + return; +} + static void win_settings_zip_drives_update_item(HWND hwndList, int i) @@ -4200,6 +4361,124 @@ static void cdrom_recalc_location_controls(HWND hdlg, int assign_id) } } +static void +mo_add_locations(HWND hdlg) +{ + LPTSTR lptsTemp; + char *temp; + HWND h; + int i = 0; + + lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); + temp = (char*) malloc(30*sizeof(char)); + + h = GetDlgItem(hdlg, IDC_COMBO_MO_BUS); + for (i = MO_BUS_DISABLED; i <= MO_BUS_SCSI; i++) { + if ((i == MO_BUS_DISABLED) || (i >= MO_BUS_ATAPI)) + SendMessage(h, CB_ADDSTRING, 0, win_get_string(combo_id_to_string_id(i))); + } + + h = GetDlgItem(hdlg, IDC_COMBO_MO_ID); + for (i = 0; i < 16; i++) { + wsprintf(lptsTemp, plat_get_string(IDS_4098), i); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + + h = GetDlgItem(hdlg, IDC_COMBO_MO_CHANNEL_IDE); + for (i = 0; i < 8; i++) { + wsprintf(lptsTemp, plat_get_string(IDS_4097), i >> 1, i & 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + + h = GetDlgItem(hdlg, IDC_COMBO_MO_TYPE); + for (int i=0; i < KNOWN_MO_DRIVE_TYPES; i++) { + memset(temp, 0, 30); + memcpy(temp, mo_drive_types[i].vendor, 8); + temp[strlen(temp)] = ' '; + memcpy(temp + strlen(temp), mo_drive_types[i].model, 16); + temp[strlen(temp)] = ' '; + memcpy(temp + strlen(temp), mo_drive_types[i].revision, 4); + + mbstowcs(lptsTemp, temp, strlen(temp)+1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + + free(temp); + free(lptsTemp); +} + + +static void +mo_recalc_location_controls(HWND hdlg, int assign_id) +{ + int i = 0; + HWND h; + + int bus = temp_mo_drives[lv1_current_sel].bus_type; + + for (i = IDT_1771; i < (IDT_1772 + 1); i++) { + h = GetDlgItem(hdlg, i); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + } + + h = GetDlgItem(hdlg, IDC_COMBO_MO_ID); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + + h = GetDlgItem(hdlg, IDC_COMBO_MO_CHANNEL_IDE); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + + h = GetDlgItem(hdlg, IDC_COMBO_MO_TYPE); + if (bus == MO_BUS_DISABLED) { + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + } else { + ShowWindow(h, SW_SHOW); + EnableWindow(h, TRUE); + SendMessage(h, CB_SETCURSEL, temp_mo_drives[lv1_current_sel].type, 0); + } + + h = GetDlgItem(hdlg, IDT_1773); + if (bus == CDROM_BUS_DISABLED) { + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + } else { + ShowWindow(h, SW_SHOW); + EnableWindow(h, TRUE); + } + + switch(bus) { + case MO_BUS_ATAPI: /* ATAPI */ + h = GetDlgItem(hdlg, IDT_1772); + ShowWindow(h, SW_SHOW); + EnableWindow(h, TRUE); + + if (assign_id) + temp_mo_drives[lv1_current_sel].ide_channel = next_free_ide_channel(); + + h = GetDlgItem(hdlg, IDC_COMBO_MO_CHANNEL_IDE); + ShowWindow(h, SW_SHOW); + EnableWindow(h, TRUE); + SendMessage(h, CB_SETCURSEL, temp_mo_drives[lv1_current_sel].ide_channel, 0); + break; + case MO_BUS_SCSI: /* SCSI */ + h = GetDlgItem(hdlg, IDT_1771); + ShowWindow(h, SW_SHOW); + EnableWindow(h, TRUE); + + if (assign_id) + next_free_scsi_id((uint8_t *) &temp_mo_drives[lv1_current_sel].scsi_device_id); + + h = GetDlgItem(hdlg, IDC_COMBO_MO_ID); + ShowWindow(h, SW_SHOW); + EnableWindow(h, TRUE); + SendMessage(h, CB_SETCURSEL, temp_mo_drives[lv1_current_sel].scsi_device_id, 0); + break; + } +} + static void zip_add_locations(HWND hdlg) @@ -4335,6 +4614,26 @@ zip_untrack(uint8_t id) } +static void +mo_track(uint8_t id) +{ + if (temp_mo_drives[id].bus_type == MO_BUS_ATAPI) + ide_tracking |= (1 << (temp_zip_drives[id].ide_channel << 3)); + else if (temp_mo_drives[id].bus_type == MO_BUS_SCSI) + scsi_tracking[temp_mo_drives[id].scsi_device_id >> 3] |= (1 << (temp_mo_drives[id].scsi_device_id & 0x07)); +} + + +static void +mo_untrack(uint8_t id) +{ + if (temp_mo_drives[id].bus_type == MO_BUS_ATAPI) + ide_tracking &= ~(1 << (temp_zip_drives[id].ide_channel << 3)); + else if (temp_mo_drives[id].bus_type == MO_BUS_SCSI) + scsi_tracking[temp_mo_drives[id].scsi_device_id >> 3] &= ~(1 << (temp_mo_drives[id].scsi_device_id & 0x07)); +} + + #if defined(__amd64__) || defined(__aarch64__) static LRESULT CALLBACK #else @@ -4446,13 +4745,12 @@ static LRESULT CALLBACK #else static BOOL CALLBACK #endif -win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +win_settings_cdrom_drives_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h = NULL; int old_sel = 0, b = 0, assign = 0; uint32_t b2 = 0; const uint8_t cd_icons[3] = { 249, 32, 0 }; - const uint8_t zip_icons[3] = { 250, 48, 0 }; switch (message) { case WM_INITDIALOG: @@ -4485,33 +4783,6 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam cdrom_recalc_location_controls(hdlg, 0); - lv2_current_sel = 0; - h = GetDlgItem(hdlg, IDC_LIST_ZIP_DRIVES); - win_settings_zip_drives_init_columns(h); - image_list_init(h, (const uint8_t *) zip_icons); - win_settings_zip_drives_recalc_list(h); - ListView_SetItemState(h, 0, LVIS_FOCUSED | LVIS_SELECTED, 0x000F); - zip_add_locations(hdlg); - - h = GetDlgItem(hdlg, IDC_COMBO_ZIP_BUS); - - switch (temp_zip_drives[lv2_current_sel].bus_type) { - case ZIP_BUS_DISABLED: - default: - b = 0; - break; - case ZIP_BUS_ATAPI: - b = 1; - break; - case ZIP_BUS_SCSI: - b = 2; - break; - } - - SendMessage(h, CB_SETCURSEL, b, 0); - - zip_recalc_location_controls(hdlg, 0); - ignore_change = 0; return TRUE; @@ -4550,41 +4821,7 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam SendMessage(h, CB_SETCURSEL, b, 0); - cdrom_recalc_location_controls(hdlg, 0); - ignore_change = 0; - } else if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_LIST_ZIP_DRIVES)) { - old_sel = lv2_current_sel; - lv2_current_sel = get_selected_drive(hdlg, IDC_LIST_ZIP_DRIVES); - if (lv2_current_sel == old_sel) - return FALSE; - else if (lv2_current_sel == -1) { - ignore_change = 1; - lv2_current_sel = old_sel; - ListView_SetItemState(h, lv2_current_sel, LVIS_FOCUSED | LVIS_SELECTED, 0x000F); - ignore_change = 0; - return FALSE; - } - ignore_change = 1; - - h = GetDlgItem(hdlg, IDC_COMBO_ZIP_BUS); - - switch (temp_zip_drives[lv2_current_sel].bus_type) { - case ZIP_BUS_DISABLED: - default: - b = 0; - break; - case ZIP_BUS_ATAPI: - b = 1; - break; - case ZIP_BUS_SCSI: - b = 2; - break; - } - - SendMessage(h, CB_SETCURSEL, b, 0); - - zip_recalc_location_controls(hdlg, 0); - + mo_recalc_location_controls(hdlg, 0); ignore_change = 0; } break; @@ -4594,7 +4831,7 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam return FALSE; ignore_change = 1; - switch (LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_COMBO_CD_BUS: h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); b = SendMessage(h, CB_GETCURSEL, 0, 0); @@ -4646,6 +4883,221 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES); win_settings_cdrom_drives_update_item(h, lv1_current_sel); break; + } + ignore_change = 0; + + default: + return FALSE; + } + + return FALSE; +} + +#if defined(__amd64__) || defined(__aarch64__) +static LRESULT CALLBACK +#else +static BOOL CALLBACK +#endif +win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + HWND h = NULL; + int old_sel = 0, b = 0, assign = 0; + uint32_t b2 = 0; + const uint8_t mo_icons[3] = { 251, 56, 0 }; + const uint8_t zip_icons[3] = { 250, 48, 0 }; + + switch (message) { + case WM_INITDIALOG: + ignore_change = 1; + + lv1_current_sel = 0; + h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES); + win_settings_mo_drives_init_columns(h); + image_list_init(h, (const uint8_t *) mo_icons); + win_settings_mo_drives_recalc_list(h); + ListView_SetItemState(h, 0, LVIS_FOCUSED | LVIS_SELECTED, 0x000F); + mo_add_locations(hdlg); + + h = GetDlgItem(hdlg, IDC_COMBO_MO_BUS); + + switch (temp_mo_drives[lv1_current_sel].bus_type) { + case MO_BUS_DISABLED: + default: + b = 0; + break; + case MO_BUS_ATAPI: + b = 1; + break; + case MO_BUS_SCSI: + b = 2; + break; + } + + SendMessage(h, CB_SETCURSEL, b, 0); + + mo_recalc_location_controls(hdlg, 0); + + lv2_current_sel = 0; + h = GetDlgItem(hdlg, IDC_LIST_ZIP_DRIVES); + win_settings_zip_drives_init_columns(h); + image_list_init(h, (const uint8_t *) zip_icons); + win_settings_zip_drives_recalc_list(h); + ListView_SetItemState(h, 0, LVIS_FOCUSED | LVIS_SELECTED, 0x000F); + zip_add_locations(hdlg); + + h = GetDlgItem(hdlg, IDC_COMBO_ZIP_BUS); + + switch (temp_zip_drives[lv2_current_sel].bus_type) { + case ZIP_BUS_DISABLED: + default: + b = 0; + break; + case ZIP_BUS_ATAPI: + b = 1; + break; + case ZIP_BUS_SCSI: + b = 2; + break; + } + + SendMessage(h, CB_SETCURSEL, b, 0); + + zip_recalc_location_controls(hdlg, 0); + + ignore_change = 0; + return TRUE; + + case WM_NOTIFY: + if (ignore_change) + return FALSE; + + if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_LIST_MO_DRIVES)) { + old_sel = lv1_current_sel; + lv1_current_sel = get_selected_drive(hdlg, IDC_LIST_MO_DRIVES); + if (lv1_current_sel == old_sel) + return FALSE; + else if (lv1_current_sel == -1) { + ignore_change = 1; + lv1_current_sel = old_sel; + ListView_SetItemState(h, lv1_current_sel, LVIS_FOCUSED | LVIS_SELECTED, 0x000F); + ignore_change = 0; + return FALSE; + } + ignore_change = 1; + + h = GetDlgItem(hdlg, IDC_COMBO_MO_BUS); + + switch (temp_mo_drives[lv1_current_sel].bus_type) { + case MO_BUS_DISABLED: + default: + b = 0; + break; + case MO_BUS_ATAPI: + b = 1; + break; + case MO_BUS_SCSI: + b = 2; + break; + } + + SendMessage(h, CB_SETCURSEL, b, 0); + + mo_recalc_location_controls(hdlg, 0); + ignore_change = 0; + } else if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_LIST_ZIP_DRIVES)) { + old_sel = lv2_current_sel; + lv2_current_sel = get_selected_drive(hdlg, IDC_LIST_ZIP_DRIVES); + if (lv2_current_sel == old_sel) + return FALSE; + else if (lv2_current_sel == -1) { + ignore_change = 1; + lv2_current_sel = old_sel; + ListView_SetItemState(h, lv2_current_sel, LVIS_FOCUSED | LVIS_SELECTED, 0x000F); + ignore_change = 0; + return FALSE; + } + ignore_change = 1; + + h = GetDlgItem(hdlg, IDC_COMBO_ZIP_BUS); + + switch (temp_zip_drives[lv2_current_sel].bus_type) { + case ZIP_BUS_DISABLED: + default: + b = 0; + break; + case ZIP_BUS_ATAPI: + b = 1; + break; + case ZIP_BUS_SCSI: + b = 2; + break; + } + + SendMessage(h, CB_SETCURSEL, b, 0); + + zip_recalc_location_controls(hdlg, 0); + + ignore_change = 0; + } + break; + + case WM_COMMAND: + if (ignore_change) + return FALSE; + + ignore_change = 1; + switch (LOWORD(wParam)) { + case IDC_COMBO_MO_BUS: + h = GetDlgItem(hdlg, IDC_COMBO_MO_BUS); + b = SendMessage(h, CB_GETCURSEL, 0, 0); + switch (b) { + case 0: + b2 = MO_BUS_DISABLED; + break; + case 1: + b2 = MO_BUS_ATAPI; + break; + case 2: + b2 = MO_BUS_SCSI; + break; + } + if (b2 == temp_mo_drives[lv1_current_sel].bus_type) + break; + mo_untrack(lv1_current_sel); + assign = (temp_mo_drives[lv1_current_sel].bus_type == b2) ? 0 : 1; + if (temp_mo_drives[lv1_current_sel].bus_type == MO_BUS_DISABLED) + temp_mo_drives[lv1_current_sel].type = 0; + temp_mo_drives[lv1_current_sel].bus_type = b2; + mo_recalc_location_controls(hdlg, assign); + mo_track(lv1_current_sel); + h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES); + win_settings_mo_drives_update_item(h, lv1_current_sel); + break; + + case IDC_COMBO_MO_ID: + h = GetDlgItem(hdlg, IDC_COMBO_MO_ID); + mo_untrack(lv1_current_sel); + temp_mo_drives[lv1_current_sel].scsi_device_id = SendMessage(h, CB_GETCURSEL, 0, 0); + mo_track(lv1_current_sel); + h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES); + win_settings_mo_drives_update_item(h, lv1_current_sel); + break; + + case IDC_COMBO_MO_CHANNEL_IDE: + h = GetDlgItem(hdlg, IDC_COMBO_MO_CHANNEL_IDE); + mo_untrack(lv1_current_sel); + temp_mo_drives[lv1_current_sel].ide_channel = SendMessage(h, CB_GETCURSEL, 0, 0); + mo_track(lv1_current_sel); + h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES); + win_settings_mo_drives_update_item(h, lv1_current_sel); + break; + + case IDC_COMBO_MO_TYPE: + h = GetDlgItem(hdlg, IDC_COMBO_MO_TYPE); + temp_mo_drives[lv1_current_sel].type = SendMessage(h, CB_GETCURSEL, 0, 0); + h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES); + win_settings_mo_drives_update_item(h, lv1_current_sel); + break; case IDC_COMBO_ZIP_BUS: h = GetDlgItem(hdlg, IDC_COMBO_ZIP_BUS); @@ -4746,6 +5198,9 @@ void win_settings_show_child(HWND hwndParent, DWORD child_id) case SETTINGS_PAGE_FLOPPY_DRIVES: hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_FLOPPY_DRIVES, hwndParent, win_settings_floppy_drives_proc); break; + case SETTINGS_PAGE_CDROM_DRIVES: + hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_CDROM_DRIVES, hwndParent, win_settings_cdrom_drives_proc); + break; case SETTINGS_PAGE_OTHER_REMOVABLE_DEVICES: hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_OTHER_REMOVABLE_DEVICES, hwndParent, win_settings_other_removable_devices_proc); break; @@ -4767,13 +5222,18 @@ win_settings_main_insert_categories(HWND hwndList) lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; lvI.stateMask = lvI.iSubItem = lvI.state = 0; - for (i = 0; i < 10; i++) { - lvI.pszText = plat_get_string(IDS_2065+i); - lvI.iItem = i; - lvI.iImage = i; + for (i = 0; i < 11; i++) { + if (i <= 8) + lvI.pszText = plat_get_string(IDS_2065+i); + else if (i == 9) + lvI.pszText = plat_get_string(IDS_2139); + else if (i == 10) + lvI.pszText = plat_get_string(IDS_2074); + lvI.iItem = i; + lvI.iImage = i; - if (ListView_InsertItem(hwndList, &lvI) == -1) - return FALSE; + if (ListView_InsertItem(hwndList, &lvI) == -1) + return FALSE; } return TRUE; @@ -4815,7 +5275,7 @@ win_settings_main_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h = NULL; int category, i = 0, j = 0; - const uint8_t cat_icons[11] = { 240, 241, 242, 243, 80, 244, 245, 64, 246, 247, 0 }; + const uint8_t cat_icons[12] = { 240, 241, 242, 243, 80, 244, 245, 64, 246, 32, 247, 0 }; hwndParentDialog = hdlg; @@ -4831,7 +5291,7 @@ win_settings_main_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_NOTIFY: if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_SETTINGSCATLIST)) { category = -1; - for (i = 0; i < 10; i++) { + for (i = 0; i < 11; i++) { h = GetDlgItem(hdlg, IDC_SETTINGSCATLIST); j = ListView_GetItemState(h, i, LVIS_SELECTED); if (j) diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index f509b45a5..afd47a384 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -51,6 +51,7 @@ #include <86box/plat.h> #include <86box/ui.h> #include <86box/win.h> +#include <86box/mo.h> #ifndef GWL_WNDPROC #define GWL_WNDPROC GWLP_WNDPROC @@ -491,6 +492,18 @@ ui_sb_update_panes(void) continue; if (zip_drives[i].bus_type != 0) sb_parts++; + } + for (i=0; i