Add magneto-optical configuration.

This commit is contained in:
2020-03-28 03:48:59 +00:00
parent 3682eae8c4
commit cf53888c30
25 changed files with 452 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -295,6 +295,7 @@
#define STR_3580 "ATAPI"
#define STR_3581 "SCSI"
#define STR_3582 "USB"
#define STR_3583 "Magneto-optical drives:"
/* UI: Status Bar (3900.) */

View File

@@ -249,6 +249,7 @@
#define ICON_FLOPPY_D 248 /* "floppy_disabled.ico" */
#define ICON_CDROM_D 249 /* "cdrom_disabled.ico" */
#define ICON_ZIP_D 250 /* "zip_disabled.ico" */
#define ICON_MO_D 255 /* "mo_disabled.ico" */
/* String IDs. */

View File

@@ -622,6 +622,32 @@ BEGIN
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
DLG_CFG_MO_DEVICES DIALOG 97, 0, 267, 221
STYLE DS_CONTROL | WS_CHILD
FONT 9, FONT_NAME
BEGIN
LTEXT STR_3583,IDT_1768,7,7,80,8
CONTROL "List2",IDC_LIST_MO_DRIVES,"SysListView32",
LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL |
WS_BORDER | WS_TABSTOP,7,18,253,60
LTEXT STR_BUS,IDT_1753,50,87,25,8
COMBOBOX IDC_COMBO_MO_BUS,80,85,70,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT STR_CHANNEL,IDT_1756,170,87,30,8
COMBOBOX IDC_COMBO_MO_CHANNEL_IDE,210,85,50,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT STR_ID,IDT_1754,165,87,20,8
COMBOBOX IDC_COMBO_MO_ID,185,85,20,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT STR_LUN,IDT_1755,210,87,20,8
COMBOBOX IDC_COMBO_MO_LUN,235,85,20,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
/* The string table. */
#define STRTBL(num,str) num str

View File

@@ -58,6 +58,7 @@
#define DLG_CFG_FLOPPY 1040 /* sub-dialog of config */
#define DLG_CFG_MMC_DEVICES 1041 /* sub-dialog of config */
#define DLG_CFG_IOMEGA_DEVICES 1042 /* sub-dialog of config */
#define DLG_CFG_MO_DEVICES 1043 /* sub-dialog of config */
/* Static text label IDs. */
#define IDT_1700 1700 /* Language: */
@@ -117,6 +118,7 @@
#define IDT_1765 1765 /* ISAMEM #3: */
#define IDT_1766 1766 /* ISAMEM #4: */
#define IDT_1767 1767 /* ISARTC: */
#define IDT_1768 1768 /* Magneto-optical drives: */
#define IDT_TITLE 1790 /* "VARCem for Plaform" */
#define IDT_VERSION 1791 /* "version.." */
@@ -248,6 +250,11 @@
#define IDC_COMBO_ZIP_CHANNEL_IDE 1184
#define IDC_CHECK250 1185
#define IDC_COMBO_CD_SPEED 1186
#define IDC_LIST_MO_DRIVES 1300
#define IDC_COMBO_MO_BUS 1301
#define IDC_COMBO_MO_ID 1302
#define IDC_COMBO_MO_LUN 1304
#define IDC_COMBO_MO_CHANNEL_IDE 1305
#define IDC_SLIDER_GAIN 1190 /* sound gain dialog */

View File

@@ -71,6 +71,7 @@
#include "../devices/scsi/scsi_device.h"
#include "../devices/cdrom/cdrom.h"
#include "../devices/disk/zip.h"
#include "../devices/disk/mo.h"
#include "../devices/network/network.h"
#include "../devices/sound/sound.h"
#include "../devices/sound/midi.h"
@@ -92,6 +93,7 @@ static int temp_fdd_types[FDD_NUM],
static hard_disk_t temp_hdd[HDD_NUM];
static cdrom_t temp_cdrom_drives[CDROM_NUM];
static zip_drive_t temp_zip_drives[ZIP_NUM];
static mo_drive_t temp_mo_drives[MO_NUM];
static HWND hwndParentDialog,
@@ -346,8 +348,8 @@ show_child(HWND hwndParent, DWORD child_id)
case PAGE_MAGNETO_OPTICAL_DEVICES:
hwndChildDialog = CreateDialog(plat_lang_dll(),
(LPCWSTR)DLG_CFG_IOMEGA_DEVICES,
hwndParent, iomega_devices_proc);
(LPCWSTR)DLG_CFG_MO_DEVICES,
hwndParent, mo_devices_proc);
break;
default:

View File

@@ -46,6 +46,7 @@
static int rd_ignore_change = 0;
static int cdlv_current_sel;
static int zdlv_current_sel;
static int modlv_current_sel;
static void
@@ -1010,3 +1011,415 @@ iomega_devices_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
}
static void
mo_track_init(void)
{
int i;
for (i = 0; i < MO_NUM; i++) {
if (mo_drives[i].bus_type == MO_BUS_ATAPI)
ide_tracking |= (4 << (mo_drives[i].bus_id.ide_channel << 3));
else if (mo_drives[i].bus_type == MO_BUS_SCSI)
scsi_tracking[mo_drives[i].bus_id.scsi.id] |= (4 << (mo_drives[i].bus_id.scsi.lun << 3));
}
}
static void
mo_image_list_init(HWND hwndList)
{
HICON hiconItem;
HIMAGELIST hSmall;
hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
ILC_MASK | ILC_COLOR32, 1, 1);
hiconItem = LoadIcon(hInstance, (LPCWSTR)ICON_MO_D);
ImageList_AddIcon(hSmall, hiconItem);
DestroyIcon(hiconItem);
hiconItem = LoadIcon(hInstance, (LPCWSTR)ICON_MO);
ImageList_AddIcon(hSmall, hiconItem);
DestroyIcon(hiconItem);
ListView_SetImageList(hwndList, hSmall, LVSIL_SMALL);
}
static BOOL
mo_recalc_list(HWND hwndList)
{
WCHAR temp[256];
LVITEM lvI;
int fsid, i;
lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
lvI.stateMask = lvI.iSubItem = lvI.state = 0;
for (i = 0; i < MO_NUM; i++) {
fsid = temp_mo_drives[i].bus_type;
lvI.iSubItem = 0;
switch (fsid) {
case MO_BUS_DISABLED:
default:
lvI.pszText = (LPTSTR)get_string(IDS_DISABLED);
lvI.iImage = 0;
break;
case MO_BUS_ATAPI:
swprintf(temp, sizeof_w(temp), L"%ls (%01i:%01i)",
get_string(combo_to_string(fsid)),
temp_mo_drives[i].bus_id.ide_channel >> 1,
temp_mo_drives[i].bus_id.ide_channel & 1);
lvI.pszText = temp;
lvI.iImage = 1;
break;
case MO_BUS_SCSI:
swprintf(temp, sizeof_w(temp), L"%ls (%02i:%02i)",
get_string(combo_to_string(fsid)),
temp_mo_drives[i].bus_id.scsi.id,
temp_mo_drives[i].bus_id.scsi.lun);
lvI.pszText = temp;
lvI.iImage = 1;
break;
}
lvI.iItem = i;
if (ListView_InsertItem(hwndList, &lvI) == -1)
return FALSE;
}
return TRUE;
}
static BOOL
mo_init_columns(HWND hwndList)
{
LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.iSubItem = 0;
lvc.pszText = (LPTSTR)get_string(IDS_BUS);
lvc.cx = 342;
lvc.fmt = LVCFMT_LEFT;
if (ListView_InsertColumn(hwndList, 0, &lvc) == -1)
return FALSE;
lvc.iSubItem = 1;
lvc.pszText = (LPTSTR)get_string(IDS_TYPE);
lvc.cx = 50;
lvc.fmt = LVCFMT_LEFT;
if (ListView_InsertColumn(hwndList, 1, &lvc) == -1)
return FALSE;
return TRUE;
}
static int
mo_get_selected(HWND hdlg)
{
int drive = -1;
int i, j = 0;
HWND h;
for (i = 0; i < 6; i++) { // FIXME: MO_NUM ?
h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES);
j = ListView_GetItemState(h, i, LVIS_SELECTED);
if (j)
drive = i;
}
return drive;
}
static void
mo_update_item(HWND hwndList, int i)
{
WCHAR temp[128];
LVITEM lvI;
int fsid;
lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
lvI.stateMask = lvI.iSubItem = lvI.state = 0;
lvI.iSubItem = 0;
lvI.iItem = i;
fsid = temp_mo_drives[i].bus_type;
switch (fsid) {
case MO_BUS_DISABLED:
default:
lvI.pszText = (LPTSTR)get_string(IDS_DISABLED);
lvI.iImage = 0;
break;
case MO_BUS_ATAPI:
swprintf(temp, sizeof_w(temp), L"%ls (%01i:%01i)",
get_string(combo_to_string(fsid)),
temp_mo_drives[i].bus_id.ide_channel >> 1,
temp_mo_drives[i].bus_id.ide_channel & 1);
lvI.pszText = temp;
lvI.iImage = 1;
break;
case MO_BUS_SCSI:
swprintf(temp, sizeof_w(temp), L"%ls (%02i:%02i)",
get_string(combo_to_string(fsid)),
temp_mo_drives[i].bus_id.scsi.id,
temp_mo_drives[i].bus_id.scsi.lun);
lvI.pszText = temp;
lvI.iImage = 1;
break;
}
if (ListView_SetItem(hwndList, &lvI) == -1)
return;
}
static void
mo_add_locations(HWND hdlg)
{
WCHAR temp[128];
HWND h;
int i;
h = GetDlgItem(hdlg, IDC_COMBO_MO_BUS);
for (i = MO_BUS_DISABLED; i < MO_BUS_MAX; i++)
SendMessage(h, CB_ADDSTRING, 0, win_string(combo_to_string(i)));
h = GetDlgItem(hdlg, IDC_COMBO_MO_ID);
id_to_combo(h, 16);
h = GetDlgItem(hdlg, IDC_COMBO_MO_LUN);
id_to_combo(h, 8);
h = GetDlgItem(hdlg, IDC_COMBO_MO_CHANNEL_IDE);
for (i = 0; i < 8; i++) {
swprintf(temp, sizeof_w(temp), L"%01i:%01i", i >> 1, i & 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp);
}
}
static void
mo_recalc_location_controls(HWND hdlg, int assign_id)
{
HWND h;
int i;
int bus = temp_mo_drives[modlv_current_sel].bus_type;
for (i = IDT_1754; i < (IDT_1756 + 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_LUN);
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
h = GetDlgItem(hdlg, IDC_COMBO_MO_CHANNEL_IDE);
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
switch (bus) {
case MO_BUS_ATAPI:
h = GetDlgItem(hdlg, IDT_1756);
ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE);
if (assign_id)
temp_mo_drives[modlv_current_sel].bus_id.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[modlv_current_sel].bus_id.ide_channel, 0);
break;
case MO_BUS_SCSI:
h = GetDlgItem(hdlg, IDT_1754);
ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE);
h = GetDlgItem(hdlg, IDT_1755);
ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE);
if (assign_id)
next_free_scsi_id_and_lun((uint8_t*)&temp_mo_drives[modlv_current_sel].bus_id.scsi.id, (uint8_t*)&temp_mo_drives[modlv_current_sel].bus_id.scsi.lun);
h = GetDlgItem(hdlg, IDC_COMBO_MO_ID);
ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE);
SendMessage(h, CB_SETCURSEL,
temp_mo_drives[modlv_current_sel].bus_id.scsi.id, 0);
h = GetDlgItem(hdlg, IDC_COMBO_MO_LUN);
ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE);
SendMessage(h, CB_SETCURSEL,
temp_mo_drives[modlv_current_sel].bus_id.scsi.lun, 0);
break;
}
}
static void
mo_track(uint8_t id)
{
if (temp_mo_drives[id].bus_type == MO_BUS_ATAPI)
ide_tracking |= (1ULL << temp_mo_drives[id].bus_id.ide_channel);
else if (temp_mo_drives[id].bus_type == MO_BUS_SCSI)
scsi_tracking[temp_mo_drives[id].bus_id.scsi.id] |= (1ULL << temp_mo_drives[id].bus_id.scsi.lun);
}
static void
mo_untrack(uint8_t id)
{
if (temp_mo_drives[id].bus_type == MO_BUS_ATAPI)
ide_tracking &= ~(1ULL << temp_mo_drives[id].bus_id.ide_channel);
else if (temp_mo_drives[id].bus_type == MO_BUS_SCSI)
scsi_tracking[temp_mo_drives[id].bus_id.scsi.id] &= ~(1ULL << temp_mo_drives[id].bus_id.scsi.lun);
}
static WIN_RESULT CALLBACK
mo_devices_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND h = NULL;
int old_sel = 0;
int assign = 0;
int b;
switch (message) {
case WM_INITDIALOG:
rd_ignore_change = 1;
zdlv_current_sel = 0;
h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES);
mo_init_columns(h);
mo_image_list_init(h);
mo_recalc_list(h);
mo_add_locations(hdlg);
h = GetDlgItem(hdlg, IDC_COMBO_MO_BUS);
b = temp_mo_drives[modlv_current_sel].bus_type;
SendMessage(h, CB_SETCURSEL, b, 0);
mo_recalc_location_controls(hdlg, 0);
rd_ignore_change = 0;
return TRUE;
case WM_NOTIFY:
if (rd_ignore_change)
return FALSE;
if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_LIST_MO_DRIVES)) {
old_sel = modlv_current_sel;
h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES);
modlv_current_sel = mo_get_selected(hdlg);
if (modlv_current_sel == old_sel)
return FALSE;
if (modlv_current_sel == -1) {
rd_ignore_change = 1;
modlv_current_sel = old_sel;
ListView_SetItemState(h, modlv_current_sel, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
rd_ignore_change = 0;
return FALSE;
}
rd_ignore_change = 1;
h = GetDlgItem(hdlg, IDC_COMBO_MO_BUS);
b = temp_mo_drives[modlv_current_sel].bus_type;
SendMessage(h, CB_SETCURSEL, b, 0);
mo_recalc_location_controls(hdlg, 0);
}
rd_ignore_change = 0;
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_COMBO_MO_BUS:
if (rd_ignore_change)
return FALSE;
rd_ignore_change = 1;
h = GetDlgItem(hdlg, IDC_COMBO_MO_BUS);
b = (int)SendMessage(h, CB_GETCURSEL, 0, 0);
if (temp_mo_drives[modlv_current_sel].bus_type == b)
goto mo_bus_skip;
mo_untrack(modlv_current_sel);
assign = (temp_mo_drives[modlv_current_sel].bus_type == b) ? 0 : 1;
temp_mo_drives[modlv_current_sel].bus_type = b;
mo_recalc_location_controls(hdlg, assign);
mo_track(modlv_current_sel);
h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES);
mo_update_item(h, modlv_current_sel);
mo_bus_skip:
rd_ignore_change = 0;
return FALSE;
case IDC_COMBO_MO_ID:
if (rd_ignore_change)
return FALSE;
rd_ignore_change = 1;
h = GetDlgItem(hdlg, IDC_COMBO_MO_ID);
zip_untrack(zdlv_current_sel);
b = (int)SendMessage(h, CB_GETCURSEL, 0, 0);
temp_mo_drives[modlv_current_sel].bus_id.scsi.id = (uint8_t)b;
mo_track(modlv_current_sel);
h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES);
mo_update_item(h, modlv_current_sel);
rd_ignore_change = 0;
return FALSE;
case IDC_COMBO_MO_LUN:
if (rd_ignore_change)
return FALSE;
rd_ignore_change = 1;
h = GetDlgItem(hdlg, IDC_COMBO_MO_LUN);
mo_untrack(modlv_current_sel);
b = (int)SendMessage(h, CB_GETCURSEL, 0, 0);
temp_mo_drives[modlv_current_sel].bus_id.scsi.lun = (uint8_t)b;
mo_track(modlv_current_sel);
h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES);
mo_update_item(h, modlv_current_sel);
rd_ignore_change = 0;
return FALSE;
case IDC_COMBO_ZIP_CHANNEL_IDE:
if (rd_ignore_change)
return FALSE;
rd_ignore_change = 1;
h = GetDlgItem(hdlg, IDC_COMBO_MO_CHANNEL_IDE);
mo_untrack(modlv_current_sel);
b = (int)SendMessage(h, CB_GETCURSEL, 0, 0);
temp_mo_drives[modlv_current_sel].bus_id.ide_channel = (uint8_t)b;
mo_track(modlv_current_sel);
h = GetDlgItem(hdlg, IDC_LIST_MO_DRIVES);
mo_update_item(h, modlv_current_sel);
rd_ignore_change = 0;
return FALSE;
}
return FALSE;
default:
break;
}
return FALSE;
}