config: Rework HDC migration to be in line with previous migrations
This commit is contained in:
108
src/config.c
108
src/config.c
@@ -850,8 +850,6 @@ load_storage_controllers(void)
|
|||||||
char *p;
|
char *p;
|
||||||
char temp[512];
|
char temp[512];
|
||||||
int min = 0;
|
int min = 0;
|
||||||
int free_p = 0;
|
|
||||||
int migrate_hdc[HDC_MAX] = { 1, 1, 1, 1 };
|
|
||||||
|
|
||||||
for (int c = min; c < SCSI_CARD_MAX; c++) {
|
for (int c = min; c < SCSI_CARD_MAX; c++) {
|
||||||
sprintf(temp, "scsicard_%d", c + 1);
|
sprintf(temp, "scsicard_%d", c + 1);
|
||||||
@@ -870,6 +868,8 @@ load_storage_controllers(void)
|
|||||||
else
|
else
|
||||||
fdc_current[0] = FDC_INTERNAL;
|
fdc_current[0] = FDC_INTERNAL;
|
||||||
#else
|
#else
|
||||||
|
int free_p = 0;
|
||||||
|
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
if (machine_has_flags(machine, MACHINE_FDC)) {
|
if (machine_has_flags(machine, MACHINE_FDC)) {
|
||||||
p = (char *) malloc((strlen("internal") + 1) * sizeof(char));
|
p = (char *) malloc((strlen("internal") + 1) * sizeof(char));
|
||||||
@@ -894,74 +894,50 @@ load_storage_controllers(void)
|
|||||||
sprintf(temp, "hdc_%d", c + 1);
|
sprintf(temp, "hdc_%d", c + 1);
|
||||||
|
|
||||||
p = ini_section_get_string(cat, temp, NULL);
|
p = ini_section_get_string(cat, temp, NULL);
|
||||||
if (p != NULL) {
|
if (p != NULL)
|
||||||
hdc_current[c] = hdc_get_from_internal_name(p);
|
hdc_current[c] = hdc_get_from_internal_name(p);
|
||||||
migrate_hdc[c] = 0;
|
else
|
||||||
} else
|
|
||||||
hdc_current[c] = 0;
|
hdc_current[c] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (migrate_hdc[0]) {
|
/* Backwards compatibility for single HDC and standalone tertiary/quaternary IDE from v4.2 and older. */
|
||||||
|
const char *legacy_cards[] = { NULL, "ide_ter", "ide_qua" };
|
||||||
p = ini_section_get_string(cat, "hdc", NULL);
|
p = ini_section_get_string(cat, "hdc", NULL);
|
||||||
if (p == NULL) {
|
for (int i = !(p || machine_has_flags(machine, MACHINE_HDC)), j = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
|
||||||
if (machine_has_flags(machine, MACHINE_HDC)) {
|
if (!legacy_cards[i] || (ini_section_get_int(cat, legacy_cards[i], 0) == 1)) {
|
||||||
p = (char *) malloc((strlen("internal") + 1) * sizeof(char));
|
/* Migrate to the first available HDC slot. */
|
||||||
strcpy(p, "internal");
|
for (; j < (sizeof(hdc_current) / sizeof(hdc_current[0])); j++) {
|
||||||
} else {
|
if (!hdc_current[j]) {
|
||||||
p = (char *) malloc((strlen("none") + 1) * sizeof(char));
|
if (!legacy_cards[i]) {
|
||||||
strcpy(p, "none");
|
if (!p) {
|
||||||
}
|
hdc_current[j] = hdc_get_from_internal_name("internal");
|
||||||
free_p = 1;
|
} else if (!strcmp(p, "xtide_plus")) {
|
||||||
}
|
hdc_current[j] = hdc_get_from_internal_name("xtide");
|
||||||
|
sprintf(temp, "PC/XT XTIDE #%i", j + 1);
|
||||||
/* Migrate renamed and merged cards. */
|
migration_cat = ini_find_or_create_section(config, temp);
|
||||||
if (!strcmp(p, "xtide_plus")) {
|
|
||||||
hdc_current[0] = hdc_get_from_internal_name("xtide");
|
|
||||||
migration_cat = ini_find_or_create_section(config, "PC/XT XTIDE #1");
|
|
||||||
ini_section_set_string(migration_cat, "bios", "xt_plus");
|
ini_section_set_string(migration_cat, "bios", "xt_plus");
|
||||||
} else if (!strcmp(p, "xtide_at_386")) {
|
} else if (!strcmp(p, "xtide_at_386")) {
|
||||||
hdc_current[0] = hdc_get_from_internal_name("xtide_at");
|
hdc_current[j] = hdc_get_from_internal_name("xtide_at");
|
||||||
migration_cat = ini_find_or_create_section(config, "PC/AT XTIDE #1");
|
sprintf(temp, "PC/AT XTIDE #%i", j + 1);
|
||||||
|
migration_cat = ini_find_or_create_section(config, temp);
|
||||||
ini_section_set_string(migration_cat, "bios", "at_386");
|
ini_section_set_string(migration_cat, "bios", "at_386");
|
||||||
} else
|
} else {
|
||||||
hdc_current[0] = hdc_get_from_internal_name(p);
|
hdc_current[j] = hdc_get_from_internal_name(p);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hdc_current[j] = hdc_get_from_internal_name(legacy_cards[i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ini_section_delete_var(cat, "hdc");
|
ini_section_delete_var(cat, "hdc");
|
||||||
}
|
|
||||||
|
|
||||||
if (migrate_hdc[1]) {
|
|
||||||
int ide_ter_enabled = !!ini_section_get_int(cat, "ide_ter", 0);
|
|
||||||
|
|
||||||
if (ide_ter_enabled)
|
|
||||||
hdc_current[1] = hdc_get_from_internal_name("ide_ter");
|
|
||||||
|
|
||||||
ini_section_delete_var(cat, "ide_ter");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (migrate_hdc[2]) {
|
|
||||||
int ide_qua_enabled = !!ini_section_get_int(cat, "ide_qua", 0);
|
|
||||||
|
|
||||||
if (ide_qua_enabled)
|
|
||||||
hdc_current[2] = hdc_get_from_internal_name("ide_qua");
|
|
||||||
|
|
||||||
ini_section_delete_var(cat, "ide_qua");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (free_p) {
|
|
||||||
free(p);
|
|
||||||
p = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
free_p = 0;
|
|
||||||
p = ini_section_get_string(cat, "cdrom_interface", NULL);
|
p = ini_section_get_string(cat, "cdrom_interface", NULL);
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
cdrom_interface_current = cdrom_interface_get_from_internal_name(p);
|
cdrom_interface_current = cdrom_interface_get_from_internal_name(p);
|
||||||
|
|
||||||
if (free_p) {
|
|
||||||
free(p);
|
|
||||||
p = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (machine_has_bus(machine, MACHINE_BUS_CASSETTE))
|
if (machine_has_bus(machine, MACHINE_BUS_CASSETTE))
|
||||||
cassette_enable = !!ini_section_get_int(cat, "cassette_enabled", 0);
|
cassette_enable = !!ini_section_get_int(cat, "cassette_enabled", 0);
|
||||||
else
|
else
|
||||||
@@ -2803,15 +2779,29 @@ save_storage_controllers(void)
|
|||||||
hdc_get_internal_name(hdc_current[c]));
|
hdc_get_internal_name(hdc_current[c]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Downgrade compatibility for standalone tertiary/quaternary IDE from v4.2 and older. */
|
||||||
|
const char *legacy_cards[] = { "ide_ter", "ide_qua" };
|
||||||
|
for (int i = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
|
||||||
|
int card_id = hdc_get_from_internal_name(legacy_cards[i]);
|
||||||
|
for (int j = 0; j < (sizeof(sound_card_current) / sizeof(sound_card_current[0])); j++) {
|
||||||
|
if (hdc_current[j] == card_id) {
|
||||||
|
/* A special value of 2 still enables the cards on older versions,
|
||||||
|
but lets newer versions know that they've already been migrated. */
|
||||||
|
ini_section_set_int(cat, legacy_cards[i], 2);
|
||||||
|
card_id = 0; /* mark as found */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (card_id > 0) /* not found */
|
||||||
|
ini_section_delete_var(cat, legacy_cards[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (cdrom_interface_current == 0)
|
if (cdrom_interface_current == 0)
|
||||||
ini_section_delete_var(cat, "cdrom_interface");
|
ini_section_delete_var(cat, "cdrom_interface");
|
||||||
else
|
else
|
||||||
ini_section_set_string(cat, "cdrom_interface",
|
ini_section_set_string(cat, "cdrom_interface",
|
||||||
cdrom_interface_get_internal_name(cdrom_interface_current));
|
cdrom_interface_get_internal_name(cdrom_interface_current));
|
||||||
|
|
||||||
ini_section_delete_var(cat, "ide_ter");
|
|
||||||
ini_section_delete_var(cat, "ide_qua");
|
|
||||||
|
|
||||||
if (cassette_enable == 0)
|
if (cassette_enable == 0)
|
||||||
ini_section_delete_var(cat, "cassette_enabled");
|
ini_section_delete_var(cat, "cassette_enabled");
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ hdc_get_internal_name(int hdc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
hdc_get_from_internal_name(char *s)
|
hdc_get_from_internal_name(const char *s)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ extern void hdc_init(void);
|
|||||||
extern void hdc_reset(void);
|
extern void hdc_reset(void);
|
||||||
|
|
||||||
extern const char *hdc_get_internal_name(int hdc);
|
extern const char *hdc_get_internal_name(int hdc);
|
||||||
extern int hdc_get_from_internal_name(char *s);
|
extern int hdc_get_from_internal_name(const char *s);
|
||||||
extern int hdc_has_config(int hdc);
|
extern int hdc_has_config(int hdc);
|
||||||
extern const device_t *hdc_get_device(int hdc);
|
extern const device_t *hdc_get_device(int hdc);
|
||||||
extern int hdc_get_flags(int hdc);
|
extern int hdc_get_flags(int hdc);
|
||||||
|
|||||||
Reference in New Issue
Block a user