Merge branch 'master' into mke
This commit is contained in:
212
src/config.c
212
src/config.c
@@ -65,7 +65,7 @@
|
||||
#include <86box/scsi_device.h>
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/cdrom_interface.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/rdisk.h>
|
||||
#include <86box/mo.h>
|
||||
#include <86box/sound.h>
|
||||
#include <86box/midi.h>
|
||||
@@ -1459,32 +1459,35 @@ load_other_removable_devices(void)
|
||||
unsigned int board = 0;
|
||||
unsigned int dev = 0;
|
||||
int c;
|
||||
int legacy_zip_drives = 0;
|
||||
|
||||
memset(temp, 0x00, sizeof(temp));
|
||||
for (c = 0; c < ZIP_NUM; c++) {
|
||||
for (c = 0; c < RDISK_NUM; c++) {
|
||||
sprintf(temp, "zip_%02i_parameters", c + 1);
|
||||
p = ini_section_get_string(cat, temp, NULL);
|
||||
if (p != NULL)
|
||||
sscanf(p, "%01u, %s", &zip_drives[c].is_250, s);
|
||||
else
|
||||
sscanf("0, none", "%01u, %s", &zip_drives[c].is_250, s);
|
||||
zip_drives[c].bus_type = hdd_string_to_bus(s, 1);
|
||||
if (p != NULL) {
|
||||
sscanf(p, "%01u, %s", &rdisk_drives[c].type, s);
|
||||
legacy_zip_drives++;
|
||||
} else
|
||||
sscanf("0, none", "%01u, %s", &rdisk_drives[c].type, s);
|
||||
rdisk_drives[c].type++;
|
||||
rdisk_drives[c].bus_type = hdd_string_to_bus(s, 1);
|
||||
|
||||
/* Default values, needed for proper operation of the Settings dialog. */
|
||||
zip_drives[c].ide_channel = zip_drives[c].scsi_device_id = c + 2;
|
||||
rdisk_drives[c].ide_channel = rdisk_drives[c].scsi_device_id = c + 2;
|
||||
|
||||
if (zip_drives[c].bus_type == ZIP_BUS_ATAPI) {
|
||||
if (rdisk_drives[c].bus_type == RDISK_BUS_ATAPI) {
|
||||
sprintf(temp, "zip_%02i_ide_channel", c + 1);
|
||||
sprintf(tmp2, "%01u:%01u", (c + 2) >> 1, (c + 2) & 1);
|
||||
p = ini_section_get_string(cat, temp, tmp2);
|
||||
sscanf(p, "%01u:%01u", &board, &dev);
|
||||
board &= 3;
|
||||
dev &= 1;
|
||||
zip_drives[c].ide_channel = (board << 1) + dev;
|
||||
rdisk_drives[c].ide_channel = (board << 1) + dev;
|
||||
|
||||
if (zip_drives[c].ide_channel > 7)
|
||||
zip_drives[c].ide_channel = 7;
|
||||
} else if (zip_drives[c].bus_type == ZIP_BUS_SCSI) {
|
||||
if (rdisk_drives[c].ide_channel > 7)
|
||||
rdisk_drives[c].ide_channel = 7;
|
||||
} else if (rdisk_drives[c].bus_type == RDISK_BUS_SCSI) {
|
||||
sprintf(temp, "zip_%02i_scsi_location", c + 1);
|
||||
sprintf(tmp2, "%01u:%02u", SCSI_BUS_MAX, c + 2);
|
||||
p = ini_section_get_string(cat, temp, tmp2);
|
||||
@@ -1492,23 +1495,23 @@ load_other_removable_devices(void)
|
||||
if (board >= SCSI_BUS_MAX) {
|
||||
/* Invalid bus - check legacy ID */
|
||||
sprintf(temp, "zip_%02i_scsi_id", c + 1);
|
||||
zip_drives[c].scsi_device_id = ini_section_get_int(cat, temp, c + 2);
|
||||
rdisk_drives[c].scsi_device_id = ini_section_get_int(cat, temp, c + 2);
|
||||
|
||||
if (zip_drives[c].scsi_device_id > 15)
|
||||
zip_drives[c].scsi_device_id = 15;
|
||||
if (rdisk_drives[c].scsi_device_id > 15)
|
||||
rdisk_drives[c].scsi_device_id = 15;
|
||||
} else {
|
||||
board %= SCSI_BUS_MAX;
|
||||
dev &= 15;
|
||||
zip_drives[c].scsi_device_id = (board << 4) + dev;
|
||||
rdisk_drives[c].scsi_device_id = (board << 4) + dev;
|
||||
}
|
||||
}
|
||||
|
||||
if (zip_drives[c].bus_type != ZIP_BUS_ATAPI) {
|
||||
if (rdisk_drives[c].bus_type != RDISK_BUS_ATAPI) {
|
||||
sprintf(temp, "zip_%02i_ide_channel", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
}
|
||||
|
||||
if (zip_drives[c].bus_type != ZIP_BUS_SCSI) {
|
||||
if (rdisk_drives[c].bus_type != RDISK_BUS_SCSI) {
|
||||
sprintf(temp, "zip_%02i_scsi_location", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
}
|
||||
@@ -1520,49 +1523,154 @@ load_other_removable_devices(void)
|
||||
p = ini_section_get_string(cat, temp, "");
|
||||
|
||||
sprintf(temp, "zip_%02i_writeprot", c + 1);
|
||||
zip_drives[c].read_only = ini_section_get_int(cat, temp, 0);
|
||||
rdisk_drives[c].read_only = ini_section_get_int(cat, temp, 0);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
if (!strcmp(p, usr_path))
|
||||
p[0] = 0x00;
|
||||
|
||||
if (p[0] != 0x00) {
|
||||
if (load_image_file(zip_drives[c].image_path, p, &(zip_drives[c].read_only)))
|
||||
if (load_image_file(rdisk_drives[c].image_path, p, &(rdisk_drives[c].read_only)))
|
||||
fatal("Configuration: Length of zip_%02i_image_path is more than 511\n", c + 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
|
||||
zip_drives[c].image_history[i] = (char *) calloc((MAX_IMAGE_PATH_LEN + 1) << 1, sizeof(char));
|
||||
rdisk_drives[c].image_history[i] = (char *) calloc((MAX_IMAGE_PATH_LEN + 1) << 1, sizeof(char));
|
||||
sprintf(temp, "zip_%02i_image_history_%02i", c + 1, i + 1);
|
||||
p = ini_section_get_string(cat, temp, NULL);
|
||||
if (p) {
|
||||
if (load_image_file(zip_drives[c].image_history[i], p, NULL))
|
||||
if (load_image_file(rdisk_drives[c].image_history[i], p, NULL))
|
||||
fatal("Configuration: Length of zip_%02i_image_history_%02i is more than %i\n",
|
||||
c + 1, i + 1, MAX_IMAGE_PATH_LEN - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* If the ZIP drive is disabled, delete all its variables. */
|
||||
if (zip_drives[c].bus_type == ZIP_BUS_DISABLED) {
|
||||
sprintf(temp, "zip_%02i_parameters", c + 1);
|
||||
sprintf(temp, "zip_%02i_parameters", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "zip_%02i_ide_channel", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "zip_%02i_scsi_location", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "zip_%02i_image_path", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
|
||||
sprintf(temp, "zip_%02i_image_history_%02i", c + 1, i + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
}
|
||||
}
|
||||
|
||||
if (legacy_zip_drives > 0)
|
||||
goto go_to_mo;
|
||||
|
||||
memset(temp, 0x00, sizeof(temp));
|
||||
for (c = 0; c < RDISK_NUM; c++) {
|
||||
sprintf(temp, "rdisk_%02i_parameters", c + 1);
|
||||
p = ini_section_get_string(cat, temp, NULL);
|
||||
if (p != NULL) {
|
||||
sscanf(p, "%01u, %s", &rdisk_drives[c].type, s);
|
||||
legacy_zip_drives++;
|
||||
} else
|
||||
sscanf("0, none", "%01u, %s", &rdisk_drives[c].type, s);
|
||||
rdisk_drives[c].bus_type = hdd_string_to_bus(s, 1);
|
||||
|
||||
/* Default values, needed for proper operation of the Settings dialog. */
|
||||
rdisk_drives[c].ide_channel = rdisk_drives[c].scsi_device_id = c + 2;
|
||||
|
||||
if (rdisk_drives[c].bus_type == RDISK_BUS_ATAPI) {
|
||||
sprintf(temp, "rdisk_%02i_ide_channel", c + 1);
|
||||
sprintf(tmp2, "%01u:%01u", (c + 2) >> 1, (c + 2) & 1);
|
||||
p = ini_section_get_string(cat, temp, tmp2);
|
||||
sscanf(p, "%01u:%01u", &board, &dev);
|
||||
board &= 3;
|
||||
dev &= 1;
|
||||
rdisk_drives[c].ide_channel = (board << 1) + dev;
|
||||
|
||||
if (rdisk_drives[c].ide_channel > 7)
|
||||
rdisk_drives[c].ide_channel = 7;
|
||||
} else if (rdisk_drives[c].bus_type == RDISK_BUS_SCSI) {
|
||||
sprintf(temp, "rdisk_%02i_scsi_location", c + 1);
|
||||
sprintf(tmp2, "%01u:%02u", SCSI_BUS_MAX, c + 2);
|
||||
p = ini_section_get_string(cat, temp, tmp2);
|
||||
sscanf(p, "%01u:%02u", &board, &dev);
|
||||
if (board >= SCSI_BUS_MAX) {
|
||||
/* Invalid bus - check legacy ID */
|
||||
sprintf(temp, "rdisk_%02i_scsi_id", c + 1);
|
||||
rdisk_drives[c].scsi_device_id = ini_section_get_int(cat, temp, c + 2);
|
||||
|
||||
if (rdisk_drives[c].scsi_device_id > 15)
|
||||
rdisk_drives[c].scsi_device_id = 15;
|
||||
} else {
|
||||
board %= SCSI_BUS_MAX;
|
||||
dev &= 15;
|
||||
rdisk_drives[c].scsi_device_id = (board << 4) + dev;
|
||||
}
|
||||
}
|
||||
|
||||
if (rdisk_drives[c].bus_type != RDISK_BUS_ATAPI) {
|
||||
sprintf(temp, "rdisk_%02i_ide_channel", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
}
|
||||
|
||||
if (rdisk_drives[c].bus_type != RDISK_BUS_SCSI) {
|
||||
sprintf(temp, "rdisk_%02i_scsi_location", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
}
|
||||
|
||||
sprintf(temp, "rdisk_%02i_scsi_id", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "rdisk_%02i_image_path", c + 1);
|
||||
p = ini_section_get_string(cat, temp, "");
|
||||
|
||||
sprintf(temp, "rdisk_%02i_writeprot", c + 1);
|
||||
rdisk_drives[c].read_only = ini_section_get_int(cat, temp, 0);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
if (!strcmp(p, usr_path))
|
||||
p[0] = 0x00;
|
||||
|
||||
if (p[0] != 0x00) {
|
||||
if (load_image_file(rdisk_drives[c].image_path, p, &(rdisk_drives[c].read_only)))
|
||||
fatal("Configuration: Length of rdisk_%02i_image_path is more than 511\n", c + 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
|
||||
rdisk_drives[c].image_history[i] = (char *) calloc((MAX_IMAGE_PATH_LEN + 1) << 1, sizeof(char));
|
||||
sprintf(temp, "rdisk_%02i_image_history_%02i", c + 1, i + 1);
|
||||
p = ini_section_get_string(cat, temp, NULL);
|
||||
if (p) {
|
||||
if (load_image_file(rdisk_drives[c].image_history[i], p, NULL))
|
||||
fatal("Configuration: Length of rdisk_%02i_image_history_%02i is more than %i\n",
|
||||
c + 1, i + 1, MAX_IMAGE_PATH_LEN - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* If the removable disk drive is disabled, delete all its variables. */
|
||||
if (rdisk_drives[c].bus_type == RDISK_BUS_DISABLED) {
|
||||
sprintf(temp, "rdisk_%02i_parameters", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "zip_%02i_ide_channel", c + 1);
|
||||
sprintf(temp, "rdisk_%02i_ide_channel", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "zip_%02i_scsi_location", c + 1);
|
||||
sprintf(temp, "rdisk_%02i_scsi_location", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "zip_%02i_image_path", c + 1);
|
||||
sprintf(temp, "rdisk_%02i_image_path", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
|
||||
sprintf(temp, "zip_%02i_image_history_%02i", c + 1, i + 1);
|
||||
sprintf(temp, "rdisk_%02i_image_history_%02i", c + 1, i + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
go_to_mo:
|
||||
memset(temp, 0x00, sizeof(temp));
|
||||
for (c = 0; c < MO_NUM; c++) {
|
||||
sprintf(temp, "mo_%02i_parameters", c + 1);
|
||||
@@ -1821,7 +1929,7 @@ config_load(void)
|
||||
#ifdef USE_IOCTL
|
||||
memset(cdrom_ioctl, 0, sizeof(cdrom_ioctl_t) * CDROM_NUM);
|
||||
#endif
|
||||
memset(zip_drives, 0, sizeof(zip_drive_t));
|
||||
memset(rdisk_drives, 0, sizeof(rdisk_drive_t));
|
||||
|
||||
config = ini_read(cfg_path);
|
||||
|
||||
@@ -3046,52 +3154,52 @@ save_other_removable_devices(void)
|
||||
char tmp2[512];
|
||||
int c;
|
||||
|
||||
for (c = 0; c < ZIP_NUM; c++) {
|
||||
sprintf(temp, "zip_%02i_parameters", c + 1);
|
||||
if (zip_drives[c].bus_type == 0) {
|
||||
for (c = 0; c < RDISK_NUM; c++) {
|
||||
sprintf(temp, "rdisk_%02i_parameters", c + 1);
|
||||
if (rdisk_drives[c].bus_type == 0) {
|
||||
ini_section_delete_var(cat, temp);
|
||||
} else {
|
||||
sprintf(tmp2, "%u, %s", zip_drives[c].is_250,
|
||||
hdd_bus_to_string(zip_drives[c].bus_type, 1));
|
||||
sprintf(tmp2, "%u, %s", rdisk_drives[c].type,
|
||||
hdd_bus_to_string(rdisk_drives[c].bus_type, 1));
|
||||
ini_section_set_string(cat, temp, tmp2);
|
||||
}
|
||||
|
||||
sprintf(temp, "zip_%02i_ide_channel", c + 1);
|
||||
if (zip_drives[c].bus_type != ZIP_BUS_ATAPI)
|
||||
sprintf(temp, "rdisk_%02i_ide_channel", c + 1);
|
||||
if (rdisk_drives[c].bus_type != RDISK_BUS_ATAPI)
|
||||
ini_section_delete_var(cat, temp);
|
||||
else {
|
||||
sprintf(tmp2, "%01u:%01u", zip_drives[c].ide_channel >> 1,
|
||||
zip_drives[c].ide_channel & 1);
|
||||
sprintf(tmp2, "%01u:%01u", rdisk_drives[c].ide_channel >> 1,
|
||||
rdisk_drives[c].ide_channel & 1);
|
||||
ini_section_set_string(cat, temp, tmp2);
|
||||
}
|
||||
|
||||
sprintf(temp, "zip_%02i_scsi_id", c + 1);
|
||||
sprintf(temp, "rdisk_%02i_scsi_id", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "zip_%02i_writeprot", c + 1);
|
||||
sprintf(temp, "rdisk_%02i_writeprot", c + 1);
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
sprintf(temp, "zip_%02i_scsi_location", c + 1);
|
||||
if (zip_drives[c].bus_type != ZIP_BUS_SCSI)
|
||||
sprintf(temp, "rdisk_%02i_scsi_location", c + 1);
|
||||
if (rdisk_drives[c].bus_type != RDISK_BUS_SCSI)
|
||||
ini_section_delete_var(cat, temp);
|
||||
else {
|
||||
sprintf(tmp2, "%01u:%02u", zip_drives[c].scsi_device_id >> 4,
|
||||
zip_drives[c].scsi_device_id & 15);
|
||||
sprintf(tmp2, "%01u:%02u", rdisk_drives[c].scsi_device_id >> 4,
|
||||
rdisk_drives[c].scsi_device_id & 15);
|
||||
ini_section_set_string(cat, temp, tmp2);
|
||||
}
|
||||
|
||||
sprintf(temp, "zip_%02i_image_path", c + 1);
|
||||
if ((zip_drives[c].bus_type == 0) || (strlen(zip_drives[c].image_path) == 0))
|
||||
sprintf(temp, "rdisk_%02i_image_path", c + 1);
|
||||
if ((rdisk_drives[c].bus_type == 0) || (strlen(rdisk_drives[c].image_path) == 0))
|
||||
ini_section_delete_var(cat, temp);
|
||||
else
|
||||
save_image_file(cat, temp, zip_drives[c].image_path);
|
||||
save_image_file(cat, temp, rdisk_drives[c].image_path);
|
||||
|
||||
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
|
||||
sprintf(temp, "zip_%02i_image_history_%02i", c + 1, i + 1);
|
||||
if ((zip_drives[c].image_history[i] == 0) || strlen(zip_drives[c].image_history[i]) == 0)
|
||||
sprintf(temp, "rdisk_%02i_image_history_%02i", c + 1, i + 1);
|
||||
if ((rdisk_drives[c].image_history[i] == 0) || strlen(rdisk_drives[c].image_history[i]) == 0)
|
||||
ini_section_delete_var(cat, temp);
|
||||
else
|
||||
save_image_file(cat, temp, zip_drives[c].image_history[i]);
|
||||
save_image_file(cat, temp, rdisk_drives[c].image_history[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user