Standardize hdc_current into an array

This commit is contained in:
Jasmine Iwanek
2024-07-20 03:08:04 -04:00
parent 539dccdcd1
commit 680f65cf19
13 changed files with 28 additions and 28 deletions

View File

@@ -829,15 +829,15 @@ load_storage_controllers(void)
}
/* Migrate renamed and merged cards. */
if (!strcmp(p, "xtide_plus")) {
hdc_current = hdc_get_from_internal_name("xtide");
hdc_current[0] = hdc_get_from_internal_name("xtide");
migration_cat = ini_find_or_create_section(config, "PC/XT XTIDE");
ini_section_set_string(migration_cat, "bios", "xt_plus");
} else if (!strcmp(p, "xtide_at_386")) {
hdc_current = hdc_get_from_internal_name("xtide_at");
hdc_current[0] = hdc_get_from_internal_name("xtide_at");
migration_cat = ini_find_or_create_section(config, "PC/AT XTIDE");
ini_section_set_string(migration_cat, "bios", "at_386");
} else
hdc_current = hdc_get_from_internal_name(p);
hdc_current[0] = hdc_get_from_internal_name(p);
if (free_p) {
free(p);
@@ -1631,7 +1631,7 @@ config_load(void)
video_fullscreen_first = 1;
video_fullscreen_scale = 1;
time_sync = TIME_SYNC_ENABLED;
hdc_current = hdc_get_from_internal_name("none");
hdc_current[0] = hdc_get_from_internal_name("none");
com_ports[0].enabled = 1;
com_ports[1].enabled = 1;
@@ -2303,7 +2303,7 @@ save_storage_controllers(void)
fdc_card_get_internal_name(fdc_current[0]));
ini_section_set_string(cat, "hdc",
hdc_get_internal_name(hdc_current));
hdc_get_internal_name(hdc_current[0]));
if (cdrom_interface_current == 0)
ini_section_delete_var(cat, "cdrom_interface");

View File

@@ -30,7 +30,7 @@
#include <86box/hdc_ide.h>
#include <86box/hdd.h>
int hdc_current;
int hdc_current[2];
#ifdef ENABLE_HDC_LOG
int hdc_do_log = ENABLE_HDC_LOG;
@@ -101,11 +101,11 @@ void
hdc_reset(void)
{
hdc_log("HDC: reset(current=%d, internal=%d)\n",
hdc_current, (machines[machine].flags & MACHINE_HDC) ? 1 : 0);
hdc_current[0], (machines[machine].flags & MACHINE_HDC) ? 1 : 0);
/* If we have a valid controller, add its device. */
if (hdc_current > HDC_INTERNAL)
device_add(controllers[hdc_current].device);
if (hdc_current[0] > HDC_INTERNAL)
device_add(controllers[hdc_current[0]].device);
/* Now, add the tertiary and/or quaternary IDE controllers. */
if (ide_ter_enabled)

View File

@@ -114,7 +114,7 @@ typedef struct config_t {
/* Other peripherals category */
int fdc_current[2]; /* Floppy disk controller type */
int hdc_current; /* Hard disk controller type */
int hdc_current[2]; /* Hard disk controller type */
int hdc; /* Hard disk controller */
int scsi_card; /* SCSI controller */
int ide_ter_enabled; /* Tertiary IDE controller enabled */

View File

@@ -32,7 +32,7 @@
#define HDC_NONE 0
#define HDC_INTERNAL 1
extern int hdc_current;
extern int hdc_current[2];
extern const device_t st506_xt_xebec_device; /* st506_xt_xebec */
extern const device_t st506_xt_wdxt_gen_device; /* st506_xt_wdxt_gen */

View File

@@ -798,7 +798,7 @@ machine_at_compaq_init(const machine_t *model, int type)
break;
case COMPAQ_PORTABLEIII:
if (hdc_current == HDC_INTERNAL)
if (hdc_current[0] == HDC_INTERNAL)
device_add(&ide_isa_device);
if (gfxcard[0] == VID_INTERNAL)
device_add(&compaq_plasma_device);
@@ -806,7 +806,7 @@ machine_at_compaq_init(const machine_t *model, int type)
break;
case COMPAQ_PORTABLEIII386:
if (hdc_current == HDC_INTERNAL)
if (hdc_current[0] == HDC_INTERNAL)
device_add(&ide_isa_device);
if (gfxcard[0] == VID_INTERNAL)
device_add(&compaq_plasma_device);

View File

@@ -660,7 +660,7 @@ europc_boot(UNUSED(const device_t *info))
*
* We only do this if we have not configured another one.
*/
if (hdc_current == HDC_INTERNAL)
if (hdc_current[0] == HDC_INTERNAL)
(void) device_add(&xta_hd20_device);
return sys;

View File

@@ -353,7 +353,7 @@ ps1_setup(int model)
device_add(&fdc_at_ps1_device);
/* Enable the builtin HDC. */
if (hdc_current == HDC_INTERNAL) {
if (hdc_current[0] == HDC_INTERNAL) {
priv = device_add(&ps1_hdc_device);
ps1_hdc_inform(priv, &ps->ps1_91);

View File

@@ -179,7 +179,7 @@ ps2_isa_setup(int model, int cpu_type)
device_add(&fdc_at_ps1_device);
/* Enable the builtin HDC. */
if (hdc_current == HDC_INTERNAL) {
if (hdc_current[0] == HDC_INTERNAL) {
priv = device_add(&ps1_hdc_device);
ps1_hdc_inform(priv, &ps2->ps2_91);
}

View File

@@ -94,7 +94,7 @@ machine_v86p_init(const machine_t *model)
if (gfxcard[0] == VID_INTERNAL)
device_add(&f82c425_video_device);
if (hdc_current <= HDC_INTERNAL)
if (hdc_current[0] <= HDC_INTERNAL)
device_add(&st506_xt_victor_v86p_device);
return ret;

View File

@@ -591,7 +591,7 @@ m24_kbd_write(uint16_t port, uint8_t val, void *priv)
* bit 7 - use BIOS HD on mainboard (on) / on controller (off)
* bit 6 - use OCG/CGA display adapter (on) / other display adapter (off)
*/
ret = (hdc_current == HDC_INTERNAL) ? 0x00 : 0x80;
ret = (hdc_current[0] == HDC_INTERNAL) ? 0x00 : 0x80;
ret |= video_is_cga() ? 0x40 : 0x00;
m24_kbd_adddata(ret);
@@ -2219,7 +2219,7 @@ m24_read(uint16_t port, UNUSED(void *priv))
"Reserved for HDU", same as for Switch 3 */
/* Switch 3 - Disable internal BIOS HD */
if (hdc_current != HDC_INTERNAL)
if (hdc_current[0] != HDC_INTERNAL)
ret |= 0x4;
/* Switch 2 - Set fast startup */
@@ -2349,7 +2349,7 @@ machine_xt_m24_init(const machine_t *model)
m24_kbd_init(m24_kbd);
device_add_ex(&m24_kbd_device, m24_kbd);
if (hdc_current == HDC_INTERNAL)
if (hdc_current[0] == HDC_INTERNAL)
device_add(&st506_xt_wd1002a_wx1_nobios_device);
return ret;
@@ -2409,7 +2409,7 @@ machine_xt_m240_init(const machine_t *model)
mm58274_init(nvr, model->nvrmask + 1);
if (hdc_current == HDC_INTERNAL)
if (hdc_current[0] == HDC_INTERNAL)
device_add(&st506_xt_wd1002a_wx1_nobios_device);
return ret;

View File

@@ -969,7 +969,7 @@ machine_xt_t1200_init(const machine_t *model)
if (gfxcard[0] == VID_INTERNAL)
device_add(&t1200_video_device);
if (hdc_current <= HDC_INTERNAL)
if (hdc_current[0] <= HDC_INTERNAL)
device_add(&st506_xt_toshiba_t1200_device);
return ret;

View File

@@ -294,7 +294,7 @@ MachineStatus::iterateFDD(const std::function<void(int)> &cb)
void
MachineStatus::iterateCDROM(const std::function<void(int)> &cb)
{
auto hdc_name = QString(hdc_get_internal_name(hdc_current));
auto hdc_name = QString(hdc_get_internal_name(hdc_current[0]));
for (size_t i = 0; i < CDROM_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && !hasIDE() &&
@@ -317,7 +317,7 @@ MachineStatus::iterateCDROM(const std::function<void(int)> &cb)
void
MachineStatus::iterateZIP(const std::function<void(int)> &cb)
{
auto hdc_name = QString(hdc_get_internal_name(hdc_current));
auto hdc_name = QString(hdc_get_internal_name(hdc_current[0]));
for (size_t i = 0; i < ZIP_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && !hasIDE() &&
@@ -338,7 +338,7 @@ MachineStatus::iterateZIP(const std::function<void(int)> &cb)
void
MachineStatus::iterateMO(const std::function<void(int)> &cb)
{
auto hdc_name = QString(hdc_get_internal_name(hdc_current));
auto hdc_name = QString(hdc_get_internal_name(hdc_current[0]));
for (size_t i = 0; i < MO_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && !hasIDE() &&
@@ -602,7 +602,7 @@ MachineStatus::refresh(QStatusBar *sbar)
sbar->addWidget(d->net[i].label.get());
});
auto hdc_name = QString(hdc_get_internal_name(hdc_current));
auto hdc_name = QString(hdc_get_internal_name(hdc_current[0]));
if ((has_mfm || (hdc_name.left(5) == QStringLiteral("st506"))) && (c_mfm > 0)) {
d->hdds[HDD_BUS_MFM].label = std::make_unique<QLabel>();
d->hdds[HDD_BUS_MFM].setActive(false);

View File

@@ -56,7 +56,7 @@ SettingsStorageControllers::save()
auto *cbox = findChild<QComboBox *>(QString("comboBoxSCSI%1").arg(i + 1));
scsi_card_current[i] = cbox->currentData().toInt();
}
hdc_current = ui->comboBoxHD->currentData().toInt();
hdc_current[0] = ui->comboBoxHD->currentData().toInt();
fdc_current[0] = ui->comboBoxFD->currentData().toInt();
cdrom_interface_current = ui->comboBoxCDInterface->currentData().toInt();
ide_ter_enabled = ui->checkBoxTertiaryIDE->isChecked() ? 1 : 0;
@@ -92,7 +92,7 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId)
if (device_is_valid(hdc_dev, machineId)) {
int row = Models::AddEntry(model, name, c);
if (c == hdc_current) {
if (c == hdc_current[0]) {
selectedRow = row - removeRows;
}
}