From 680f65cf1948cc483e535a0bb266676329643ea1 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 20 Jul 2024 03:08:04 -0400 Subject: [PATCH] Standardize hdc_current into an array --- src/config.c | 10 +++++----- src/disk/hdc.c | 8 ++++---- src/include/86box/config.h | 2 +- src/include/86box/hdc.h | 2 +- src/machine/m_at_compaq.c | 4 ++-- src/machine/m_europc.c | 2 +- src/machine/m_ps1.c | 2 +- src/machine/m_ps2_isa.c | 2 +- src/machine/m_v86p.c | 2 +- src/machine/m_xt_olivetti.c | 8 ++++---- src/machine/m_xt_t1000.c | 2 +- src/qt/qt_machinestatus.cpp | 8 ++++---- src/qt/qt_settingsstoragecontrollers.cpp | 4 ++-- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/config.c b/src/config.c index 4a7bd45fa..23b78f117 100644 --- a/src/config.c +++ b/src/config.c @@ -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"); diff --git a/src/disk/hdc.c b/src/disk/hdc.c index ee25e8574..08a290aef 100644 --- a/src/disk/hdc.c +++ b/src/disk/hdc.c @@ -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) diff --git a/src/include/86box/config.h b/src/include/86box/config.h index 0f596b7ac..d0b2857e7 100644 --- a/src/include/86box/config.h +++ b/src/include/86box/config.h @@ -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 */ diff --git a/src/include/86box/hdc.h b/src/include/86box/hdc.h index 38c0a6e9a..8e09119bf 100644 --- a/src/include/86box/hdc.h +++ b/src/include/86box/hdc.h @@ -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 */ diff --git a/src/machine/m_at_compaq.c b/src/machine/m_at_compaq.c index 2d4597007..0ac541e90 100644 --- a/src/machine/m_at_compaq.c +++ b/src/machine/m_at_compaq.c @@ -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); diff --git a/src/machine/m_europc.c b/src/machine/m_europc.c index c53061c4e..42034e2f6 100644 --- a/src/machine/m_europc.c +++ b/src/machine/m_europc.c @@ -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; diff --git a/src/machine/m_ps1.c b/src/machine/m_ps1.c index 25d21cfb9..a6a16d65c 100644 --- a/src/machine/m_ps1.c +++ b/src/machine/m_ps1.c @@ -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); diff --git a/src/machine/m_ps2_isa.c b/src/machine/m_ps2_isa.c index 4f6d9bc2b..2887cca20 100644 --- a/src/machine/m_ps2_isa.c +++ b/src/machine/m_ps2_isa.c @@ -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); } diff --git a/src/machine/m_v86p.c b/src/machine/m_v86p.c index f8358a8ff..f152383d1 100644 --- a/src/machine/m_v86p.c +++ b/src/machine/m_v86p.c @@ -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; diff --git a/src/machine/m_xt_olivetti.c b/src/machine/m_xt_olivetti.c index 94c7376c8..b13db6bf9 100644 --- a/src/machine/m_xt_olivetti.c +++ b/src/machine/m_xt_olivetti.c @@ -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; diff --git a/src/machine/m_xt_t1000.c b/src/machine/m_xt_t1000.c index 88fc6ada2..5a787292f 100644 --- a/src/machine/m_xt_t1000.c +++ b/src/machine/m_xt_t1000.c @@ -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; diff --git a/src/qt/qt_machinestatus.cpp b/src/qt/qt_machinestatus.cpp index d6f84ea71..64f3b0e43 100644 --- a/src/qt/qt_machinestatus.cpp +++ b/src/qt/qt_machinestatus.cpp @@ -294,7 +294,7 @@ MachineStatus::iterateFDD(const std::function &cb) void MachineStatus::iterateCDROM(const std::function &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 &cb) void MachineStatus::iterateZIP(const std::function &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 &cb) void MachineStatus::iterateMO(const std::function &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(); d->hdds[HDD_BUS_MFM].setActive(false); diff --git a/src/qt/qt_settingsstoragecontrollers.cpp b/src/qt/qt_settingsstoragecontrollers.cpp index ff30696c4..a86362909 100644 --- a/src/qt/qt_settingsstoragecontrollers.cpp +++ b/src/qt/qt_settingsstoragecontrollers.cpp @@ -56,7 +56,7 @@ SettingsStorageControllers::save() auto *cbox = findChild(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; } }