The migration of the legacy SCSI controller is now perfectly seamless, thanks, Ryuzaki!

This commit is contained in:
OBattler
2021-07-23 01:20:14 +02:00
parent 729b6d5069
commit c47e766bc4
8 changed files with 54 additions and 74 deletions

View File

@@ -158,6 +158,23 @@ find_section(char *name)
}
void *
config_find_section(char *name)
{
return (void *) find_section(name);
}
void
config_rename_section(void *priv, char *name)
{
section_t *sec = (section_t *) priv;
memset(sec->name, 0x00, sizeof(sec->name));
memcpy(sec->name, name, MIN(128, strlen(name) + 1));
}
static entry_t *
find_entry(section_t *section, char *name)
{
@@ -1015,7 +1032,7 @@ load_storage_controllers(void)
{
char *cat = "Storage controllers";
char *p, temp[512];
int c;
int c, min = 0;
int free_p = 0;
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
@@ -1023,12 +1040,13 @@ load_storage_controllers(void)
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
p = config_get_string(cat, "scsicard", NULL);
if (p != NULL)
scsi_card_current_legacy = scsi_card_get_from_internal_name(p);
else
scsi_card_current_legacy = 0;
if (p != NULL) {
scsi_card_current[0] = scsi_card_get_from_internal_name(p);
min++;
}
config_delete_var(cat, "scsi_card");
for (c = 0; c < SCSI_BUS_MAX; c++) {
for (c = min; c < SCSI_BUS_MAX; c++) {
sprintf(temp, "scsicard_%d", c + 1);
p = config_get_string(cat, temp, NULL);
@@ -1816,9 +1834,9 @@ load_other_peripherals(void)
if (backwards_compat2) {
p = config_get_string(cat, "scsicard", NULL);
if (p != NULL)
scsi_card_current_legacy = scsi_card_get_from_internal_name(p);
scsi_card_current[0] = scsi_card_get_from_internal_name(p);
else
scsi_card_current_legacy = 0;
scsi_card_current[0] = 0;
config_delete_var(cat, "scsicard");
p = config_get_string(cat, "fdc", NULL);
@@ -2421,12 +2439,6 @@ save_storage_controllers(void)
char temp[512];
int c;
if (scsi_card_current_legacy == 0)
config_delete_var(cat, "scsicard");
else
config_set_string(cat, "scsicard",
scsi_card_get_internal_name(scsi_card_current_legacy));
for (c = 0; c < SCSI_BUS_MAX; c++) {
sprintf(temp, "scsicard_%d", c + 1);

View File

@@ -90,11 +90,22 @@ device_init(void)
void
device_set_context(device_context_t *c, const device_t *d, int inst)
{
void *sec, *single_sec;
memset(c, 0, sizeof(device_context_t));
c->dev = d;
if (inst)
if (inst) {
sprintf(c->name, "%s #%i", d->name, inst);
else
/* If this is the first instance and a numbered section is not present, but a non-numbered
section of the same name is, rename the non-numbered section to numbered. */
if (inst == 1) {
sec = config_find_section(c->name);
single_sec = config_find_section((char *) d->name);
if ((sec == NULL) && (single_sec != NULL))
config_rename_section(single_sec, c->name);
}
} else
sprintf(c->name, "%s", d->name);
}

View File

@@ -158,6 +158,9 @@ extern void config_set_mac(char *head, char *name, int val);
extern void config_set_string(char *head, char *name, char *val);
extern void config_set_wstring(char *head, char *name, wchar_t *val);
extern void * config_find_section(char *name);
extern void config_rename_section(void *priv, char *name);
#ifdef __cplusplus
}
#endif

View File

@@ -22,7 +22,6 @@
#define EMU_SCSI_H
extern int scsi_card_current[4];
extern int scsi_card_current_legacy;
extern int scsi_card_available(int card);
#ifdef EMU_DEVICE_H

View File

@@ -46,7 +46,6 @@
#endif
int scsi_card_current_legacy = 0;
int scsi_card_current[SCSI_BUS_MAX] = { 0, 0 };
static uint8_t next_scsi_bus = 0;
@@ -170,12 +169,6 @@ scsi_card_init(void)
if (machines[machine].flags & MACHINE_SCSI)
max--;
/* This is for grandfathering legacy single-controller configurations. */
if (scsi_cards[scsi_card_current_legacy].device) {
device_add(scsi_cards[scsi_card_current_legacy].device);
max--;
}
/* Do not initialize any controllers if we have do not have any SCSI
bus left. */
if (max > 0) {

View File

@@ -295,7 +295,7 @@ is_valid_cdrom(int i)
{
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && !MACHINE_HAS_IDE && memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
return 0;
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !MACHINE_HAS_SCSI && (scsi_card_current_legacy == 0) &&
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !MACHINE_HAS_SCSI &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
return 0;
@@ -307,7 +307,7 @@ is_valid_zip(int i)
{
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && !MACHINE_HAS_IDE && memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
return 0;
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !MACHINE_HAS_SCSI && (scsi_card_current_legacy == 0) &&
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !MACHINE_HAS_SCSI &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
return 0;
@@ -319,7 +319,7 @@ is_valid_mo(int i)
{
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && !MACHINE_HAS_IDE && memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
return 0;
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !MACHINE_HAS_SCSI && (scsi_card_current_legacy == 0) &&
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !MACHINE_HAS_SCSI &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
return 0;

View File

@@ -103,7 +103,7 @@ static int temp_lpt_devices[3];
static int temp_serial[4], temp_lpt[3];
/* Other peripherals category */
static int temp_fdc_card, temp_hdc, temp_scsi_card_legacy, temp_ide_ter, temp_ide_qua;
static int temp_fdc_card, temp_hdc, temp_ide_ter, temp_ide_qua;
static int temp_scsi_card[SCSI_BUS_MAX];
static int temp_bugger;
static int temp_postcard;
@@ -370,7 +370,6 @@ win_settings_init(void)
temp_serial[i] = serial_enabled[i];
/* Other peripherals category */
temp_scsi_card_legacy = scsi_card_current_legacy;
for (i = 0; i < SCSI_BUS_MAX; i++)
temp_scsi_card[i] = scsi_card_current[i];
temp_fdc_card = fdc_type;
@@ -488,7 +487,6 @@ win_settings_changed(void)
i = i || (temp_serial[j] != serial_enabled[j]);
/* Peripherals category */
i = i || (scsi_card_current_legacy != temp_scsi_card_legacy);
for (j = 0; j < SCSI_BUS_MAX; j++)
i = i || (temp_scsi_card[j] != scsi_card_current[j]);
i = i || (fdc_type != temp_fdc_card);
@@ -577,7 +575,6 @@ win_settings_save(void)
serial_enabled[i] = temp_serial[i];
/* Peripherals category */
scsi_card_current_legacy = temp_scsi_card_legacy;
for (i = 0; i < SCSI_BUS_MAX; i++)
scsi_card_current[i] = temp_scsi_card[i];
hdc_current = temp_hdc;
@@ -1629,14 +1626,6 @@ win_settings_storage_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
scsi_dev = scsi_card_getdevice(c);
if (device_is_valid(scsi_dev, machines[temp_machine].flags)) {
if (c == 0)
settings_add_string(hdlg, IDC_COMBO_SCSI, win_get_string(IDS_2103));
else
settings_add_string(hdlg, IDC_COMBO_SCSI, (LPARAM) device_name);
if ((c == 0) || (c == temp_scsi_card_legacy))
settings_set_cur_sel(hdlg, IDC_COMBO_SCSI, d);
for (e = 0; e < SCSI_BUS_MAX; e++) {
if (c == 0)
settings_add_string(hdlg, IDC_COMBO_SCSI_1 + e, win_get_string(IDS_2103));
@@ -1655,16 +1644,6 @@ win_settings_storage_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
c++;
}
settings_show_window(hdlg, IDT_1717, temp_scsi_card_legacy != 0);
settings_show_window(hdlg, IDC_COMBO_SCSI, temp_scsi_card_legacy != 0);
settings_show_window(hdlg, IDC_CONFIGURE_SCSI, temp_scsi_card_legacy != 0);
if (temp_scsi_card_legacy != 0) {
settings_enable_window(hdlg, IDC_COMBO_SCSI, d);
settings_enable_window(hdlg, IDC_CONFIGURE_SCSI, scsi_card_has_config(temp_scsi_card_legacy));
} else {
settings_enable_window(hdlg, IDC_COMBO_SCSI, 0);
settings_enable_window(hdlg, IDC_CONFIGURE_SCSI, 0);
}
for (c = 0; c < SCSI_BUS_MAX; c++) {
settings_enable_window(hdlg, IDC_COMBO_SCSI_1 + c, d);
settings_enable_window(hdlg, IDC_CONFIGURE_SCSI_1 + c, scsi_card_has_config(temp_scsi_card[c]));
@@ -1704,16 +1683,6 @@ win_settings_storage_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
settings_enable_window(hdlg, IDC_CONFIGURE_HDC, hdc_has_config(temp_hdc));
break;
case IDC_CONFIGURE_SCSI:
temp_scsi_card_legacy = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_SCSI)];
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)scsi_card_getdevice(temp_scsi_card_legacy));
break;
case IDC_COMBO_SCSI:
temp_scsi_card_legacy = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_SCSI)];
settings_enable_window(hdlg, IDC_CONFIGURE_SCSI, scsi_card_has_config(temp_scsi_card_legacy));
break;
case IDC_CONFIGURE_SCSI_1 ... IDC_CONFIGURE_SCSI_4:
c = LOWORD(wParam) - IDC_CONFIGURE_SCSI_1;
temp_scsi_card[c] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_SCSI_1 + c)];
@@ -1749,7 +1718,6 @@ win_settings_storage_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_SAVESETTINGS:
temp_hdc = settings_list_to_hdc[settings_get_cur_sel(hdlg, IDC_COMBO_HDC)];
temp_fdc_card = settings_list_to_fdc[settings_get_cur_sel(hdlg, IDC_COMBO_FDC)];
temp_scsi_card_legacy = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_SCSI)];
for (c = 0; c < SCSI_BUS_MAX; c++)
temp_scsi_card[c] = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_SCSI_1 + c)];
temp_ide_ter = settings_get_check(hdlg, IDC_CHECK_IDE_TER);

View File

@@ -503,8 +503,7 @@ ui_sb_update_panes(void)
!ide_int && memcmp(hdc_name, "ide", 3))
continue;
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) &&
!scsi_int && (scsi_card_current_legacy == 0) &&
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
@@ -517,8 +516,7 @@ ui_sb_update_panes(void)
!ide_int && memcmp(hdc_name, "ide", 3))
continue;
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) &&
!scsi_int && (scsi_card_current_legacy == 0) &&
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
@@ -531,8 +529,7 @@ ui_sb_update_panes(void)
!ide_int && memcmp(hdc_name, "ide", 3))
continue;
if ((mo_drives[i].bus_type == MO_BUS_SCSI) &&
!scsi_int && (scsi_card_current_legacy == 0) &&
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
@@ -551,7 +548,7 @@ ui_sb_update_panes(void)
sb_parts++;
if (c_ide && (ide_int || !memcmp(hdc_name, "xtide", 5) || !memcmp(hdc_name, "ide", 3)))
sb_parts++;
if (c_scsi && (scsi_int || (scsi_card_current_legacy != 0) || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) ||
if (c_scsi && (scsi_int || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) ||
(scsi_card_current[2] != 0) || (scsi_card_current[3] != 0)))
sb_parts++;
if (do_net)
@@ -582,8 +579,7 @@ ui_sb_update_panes(void)
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "ide", 3))
continue;
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) &&
!scsi_int && (scsi_card_current_legacy == 0) &&
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
@@ -600,8 +596,7 @@ ui_sb_update_panes(void)
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "ide", 3))
continue;
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) &&
!scsi_int && (scsi_card_current_legacy == 0) &&
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
@@ -618,8 +613,7 @@ ui_sb_update_panes(void)
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "ide", 3))
continue;
if ((mo_drives[i].bus_type == MO_BUS_SCSI) &&
!scsi_int && (scsi_card_current_legacy == 0) &&
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
@@ -659,7 +653,7 @@ ui_sb_update_panes(void)
sb_map[SB_HDD | HDD_BUS_IDE] = sb_parts;
sb_parts++;
}
if (c_scsi && (scsi_int || (scsi_card_current_legacy != 0) || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) ||
if (c_scsi && (scsi_int || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) ||
(scsi_card_current[2] != 0) || (scsi_card_current[3] != 0))) {
edge += icon_width;
iStatusWidths[sb_parts] = edge;