diff --git a/src/acpi.c b/src/acpi.c index 411662e39..0654754e8 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -1222,7 +1222,7 @@ acpi_reg_write_intel(int size, uint16_t addr, uint8_t val, void *priv) /* GPOREG - General Purpose Output Register (IO) */ if (size == 1) { dev->regs.gporeg[addr & 3] = val; - if ((addr == 0x34) && !strcmp(machine_get_internal_name(), "cubx")) + if ((addr == 0x34) && (machines[machine].init == machine_at_cubx_init)) hdc_onboard_enabled = (val & 0x01); } break; @@ -1749,7 +1749,7 @@ acpi_reg_write_sis_5595(int size, uint16_t addr, uint8_t val, void *priv) break; case 0x1c: dev->regs.gpe_pin = ((dev->regs.gpe_pin & ~(0xff << shift32)) | ((val & 0xff) << shift32)); - if (!strcmp(machine_get_internal_name(), "m747") && (val & 0x10) && + if ((machines[machine].init == machine_at_m747_init) && (val & 0x10) && !(dev->regs.gpe_io & 0x00000010)) resetx86(); break; @@ -2365,7 +2365,7 @@ acpi_reset(void *priv) /* PC Chips M773: - Bit 3: 80-conductor cable on unknown IDE channel (active low) - Bit 1: 80-conductor cable on unknown IDE channel (active low) */ - dev->regs.gpireg[0] = !strcmp(machine_get_internal_name(), "m773") ? 0xf5 : 0xff; + dev->regs.gpireg[0] = (machines[machine].init == machine_at_m773_init) ? 0xf5 : 0xff; dev->regs.gpireg[1] = 0xff; /* A-Trend ATC7020BXII: - Bit 3: 80-conductor cable on secondary IDE channel (active low) @@ -2399,9 +2399,9 @@ acpi_reset(void *priv) - Bit 19: password cleared (active low). */ dev->regs.gpi_val = 0xfff57fc1; - if (!strcmp(machine_get_internal_name(), "ficva503a") || !strcmp(machine_get_internal_name(), "6via90ap")) + if ((machines[machine].init == machine_at_ficva503a_init) || (machines[machine].init == machine_at_6via90ap_init)) dev->regs.gpi_val |= 0x00000004; - else if (!strcmp(machine_get_internal_name(), "ficka6130")) + else if ((machines[machine].init == machine_at_ficka6130_init)) dev->regs.gpi_val |= 0x00080000; /* TriGem Delhi-III second GPI word: @@ -2409,7 +2409,7 @@ acpi_reset(void *priv) - Bit 6 = Password jumper (must be set); - Bit 5 = Enable Setup (must be set). */ - else if (!strcmp(machine_get_internal_name(), "delhi3")) + else if (machines[machine].init == machine_at_delhi3_init) dev->regs.gpi_val |= 0x00008000; } @@ -2420,7 +2420,7 @@ acpi_reset(void *priv) } /* The Gateway Tomahawk requires the LID polarity bit to be set. */ - if (!strcmp(machine_get_internal_name(), "tomahawk")) + if (machines[machine].init == machine_at_tomahawk_init) dev->regs.glbctl |= 0x02000000; acpi_rtc_status = 0; diff --git a/src/chipset/cs8220.c b/src/chipset/cs8220.c index 4c08ecef5..3c3c23767 100644 --- a/src/chipset/cs8220.c +++ b/src/chipset/cs8220.c @@ -160,7 +160,7 @@ cs8220_init(UNUSED(const device_t *info)) /* Dell System 200: 640 kB soldered on-board, any other RAM is expansion. */ - if (!strcmp(machine_get_internal_name(), "dells200")) switch (mem_size) { + if ((machines[machine].init == machine_at_dells200_init)) switch (mem_size) { default: dev->ram_banks[2].virt = 0x00100000; dev->ram_banks[2].phys = 0x000a0000; diff --git a/src/chipset/intel_4x0.c b/src/chipset/intel_4x0.c index 8e6ce97c3..7d59653e8 100644 --- a/src/chipset/intel_4x0.c +++ b/src/chipset/intel_4x0.c @@ -1549,7 +1549,7 @@ i4x0_read(int func, int addr, void *priv) with the addition of bits 3 and 0. */ if ((func == 0) && (addr == 0x93) && ((dev->type == INTEL_440FX) || (dev->type == INTEL_440LX) || (dev->type == INTEL_440EX))) ret = (ret & 0xf9) | (pci_read(0x0cf9, NULL) & 0x06); - else if ((func == 0) && (addr == 0x52) && (dev->type == INTEL_430TX) && !strcmp(machine_get_internal_name(), "tomahawk")) + else if ((func == 0) && (addr == 0x52) && (dev->type == INTEL_430TX) && (machines[machine].init == machine_at_tomahawk_init)) ret = 0xb2; } diff --git a/src/chipset/intel_piix.c b/src/chipset/intel_piix.c index 5d0c18441..d3ef943ac 100644 --- a/src/chipset/intel_piix.c +++ b/src/chipset/intel_piix.c @@ -1595,7 +1595,7 @@ piix_init(const device_t *info) - Bit 4: CMOS clear jumper, must be clear; - Bit 0: Password switch, must be clear. */ - if (!strcmp(machine_get_internal_name(), "richmond")) + if (machines[machine].init == machine_at_richmond_init) acpi_set_gpireg2_default(dev->acpi, 0xee); else acpi_set_gpireg2_default(dev->acpi, (dev->type > 4) ? 0xf1 : 0xdd); diff --git a/src/chipset/intel_sio.c b/src/chipset/intel_sio.c index b11ec0765..87730b20f 100644 --- a/src/chipset/intel_sio.c +++ b/src/chipset/intel_sio.c @@ -368,7 +368,7 @@ sio_config_read(uint16_t port, UNUSED(void *priv)) - 1, 0 = M; - 1, 1 = M. */ - if (!strcmp(machine_get_internal_name(), "opti560l")) + if (machines[machine].init == machine_at_opti560l_init) ret = 0x20; else ret = 0xd3; diff --git a/src/chipset/sis_85c4xx.c b/src/chipset/sis_85c4xx.c index 49d0418ce..1b0eeceed 100644 --- a/src/chipset/sis_85c4xx.c +++ b/src/chipset/sis_85c4xx.c @@ -766,7 +766,7 @@ sis_85c4xx_reset(void *priv) if (dev->is_471) { dev->regs[0x09] = 0x40; - if (!strcmp(machine_get_internal_name(), "vli486sv2g")) { + if (machines[machine].init == machine_at_vli486sv2g_init) { if (mem_size_mb == 64) dev->regs[0x09] |= 0x1f; else @@ -784,7 +784,7 @@ sis_85c4xx_reset(void *priv) dev->regs[0x09] |= 0x34; else dev->regs[0x09] |= 0x35; - } else if (!strcmp(machine_get_internal_name(), "tg486g")) + } else if (machines[machine].init == machine_at_tg486g_init) dev->regs[0x09] |= ram_tg486g[mem_size_mb]; else dev->regs[0x09] |= ram_471[mem_size_mb]; diff --git a/src/chipset/vl82c480.c b/src/chipset/vl82c480.c index acb3568af..a31c35418 100644 --- a/src/chipset/vl82c480.c +++ b/src/chipset/vl82c480.c @@ -30,6 +30,8 @@ #include <86box/port_92.h> #include <86box/chipset.h> +#define machine_at_prolineamt_init NULL /* checks for a removed machine */ + typedef struct vl82c480_t { uint8_t idx; uint8_t regs[256]; @@ -132,8 +134,8 @@ vl82c480_write(uint16_t addr, uint8_t val, void *priv) break; case 0x02: case 0x03: dev->regs[dev->idx] = val; - if (!strcmp(machine_get_internal_name(), "martin") || - !strcmp(machine_get_internal_name(), "prolineamt")) + if ((machines[machine].init == machine_at_martin_init) || + (machines[machine].init == machine_at_prolineamt_init)) vl82c480_recalc_banks(dev); break; case 0x04: @@ -220,9 +222,9 @@ vl82c480_init(const device_t *info) vl82c480_t *dev = (vl82c480_t *) calloc(1, sizeof(vl82c480_t)); uint32_t sizes[8] = { 0, 0, 1024, 2048, 4096, 8192, 16384, 32768 }; uint32_t ms = mem_size; - uint8_t min_i = !strcmp(machine_get_internal_name(), "prolineamt") ? 1 : 0; - uint8_t min_j = !strcmp(machine_get_internal_name(), "prolineamt") ? 4 : 2; - uint8_t max_j = !strcmp(machine_get_internal_name(), "prolineamt") ? 8 : 7; + uint8_t min_i = (machines[machine].init == machine_at_prolineamt_init) ? 1 : 0; + uint8_t min_j = (machines[machine].init == machine_at_prolineamt_init) ? 4 : 2; + uint8_t max_j = (machines[machine].init == machine_at_prolineamt_init) ? 8 : 7; dev->regs[0x00] = info->local; dev->regs[0x01] = 0xff; @@ -233,7 +235,7 @@ vl82c480_init(const device_t *info) dev->regs[0x07] = 0x21; dev->regs[0x08] = 0x38; - if (!strcmp(machine_get_internal_name(), "prolineamt")) { + if (machines[machine].init == machine_at_prolineamt_init) { dev->banks[0] = 4096; /* Bank 0 is ignored if 64 MB is installed. */ diff --git a/src/config.c b/src/config.c index 53d00a6bf..42d4fe012 100644 --- a/src/config.c +++ b/src/config.c @@ -572,7 +572,7 @@ load_input_devices(void) p = ini_section_get_string(cat, "keyboard_type", NULL); if (p != NULL) keyboard_type = keyboard_get_from_internal_name(p); - else if (strstr(machine_get_internal_name(), "pc5086")) + else if (machines[machine].init == machine_xt_pc5086_init) keyboard_type = KEYBOARD_TYPE_PC_XT; else if (machine_has_bus(machine, MACHINE_BUS_PS2_PORTS)) { if (machine_has_flags(machine, MACHINE_KEYBOARD_JIS)) diff --git a/src/device/isartc.c b/src/device/isartc.c index 664793db3..88f03e7c5 100644 --- a/src/device/isartc.c +++ b/src/device/isartc.c @@ -523,7 +523,7 @@ isartc_init(const device_t *info) { rtcdev_t *dev; int is_at = IS_AT(machine); - is_at = is_at || !strcmp(machine_get_internal_name(), "xi8088"); + is_at = is_at || (machines[machine].init == machine_xt_xi8088_init); /* Create a device instance. */ dev = (rtcdev_t *) calloc(1, sizeof(rtcdev_t)); diff --git a/src/device/kbc_at.c b/src/device/kbc_at.c index 186804e22..0f3bd5600 100644 --- a/src/device/kbc_at.c +++ b/src/device/kbc_at.c @@ -806,15 +806,15 @@ write_p2(atkbc_t *dev, uint8_t val) cpu_set_edx(); flushmmucache(); if ((kbc_ven == KBC_VEN_ALI) || - !strcmp(machine_get_internal_name(), "spc7700plw") || - !strcmp(machine_get_internal_name(), "pl4600c")) + (machines[machine].init == machine_at_spc7700plw_init) || + (machines[machine].init == machine_at_pl4600c_init)) smbase = 0x00030000; /* Yes, this is a hack, but until someone gets ahold of the real PCD-2L and can find out what they actually did to make it boot from FFFFF0 correctly despite A20 being gated when the CPU is reset, this will have to do. */ - if ((kbc_ven == KBC_VEN_SIEMENS) || !strcmp(machine_get_internal_name(), "acera1g")) + if ((kbc_ven == KBC_VEN_SIEMENS) || (machines[machine].init == machine_at_acera1g_init)) is486 ? loadcs(0xf000) : loadcs_2386(0xf000); } } @@ -1187,7 +1187,7 @@ write_cmd_ami(void *priv, uint8_t val) kbc_at_log("ATkbc: set KBC lines P22-P23 (P2 bits 2-3) low\n"); if (!(dev->flags & DEVICE_PCI)) write_p2(dev, dev->p2 & ~(4 << (val & 0x01))); - if (strstr(machine_get_internal_name(), "sb486pv") != NULL) + if (machines[machine].init == machine_at_sb486pv_init) kbc_delay_to_ob(dev, 0x03, 0, 0x00); else kbc_delay_to_ob(dev, dev->ob, 0, 0x00); @@ -2627,7 +2627,7 @@ kbc_at_process_cmd(void *priv) if (dev->ib == 0xbb) break; - if (strstr(machine_get_internal_name(), "pb41") != NULL) + if (machines[machine].init == machine_at_pb410a_init) cpu_override_dynarec = 1; if (dev->misc_flags & FLAG_PS2) { @@ -2759,7 +2759,7 @@ kbc_at_port_1_read(uint16_t port, void *priv) */ if (!(dev->misc_flags & FLAG_PS2) && (dev->irq[0] != 0xffff)) picintclevel(1 << dev->irq[0], &dev->irq_state); - if ((strstr(machine_get_internal_name(), "pb41") != NULL) && (cpu_override_dynarec == 1)) + if ((machines[machine].init == machine_at_pb410a_init) && (cpu_override_dynarec == 1)) cpu_override_dynarec = 0; kbc_at_log("ATkbc: [%04X:%08X] read (%04X) = %02X\n", CS, cpu_state.pc, port, ret); diff --git a/src/dma.c b/src/dma.c index 2265947b9..60e36b3cd 100644 --- a/src/dma.c +++ b/src/dma.c @@ -1008,7 +1008,7 @@ dma_page_read(uint16_t addr, UNUSED(void *priv)) if (((addr & 0xfffc) == 0x80) && (CS == 0xf000) && ((cpu_state.pc & 0xfffffff8) == 0x00007278) && - !strcmp(machine_get_internal_name(), "megapc")) switch (addr) { + (machines[machine].init == machine_at_wd76c10_init)) switch (addr) { /* The Amstrad MegaPC Quadtel BIOS times a sequence of: mov ax,di div bx diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 9d68365d2..af00af561 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -2402,10 +2402,10 @@ fdc_reset(void *priv) need to use a dual-RPM 5.25" drive - but hey, that finally gets those drives some usage as well. */ - fdc_update_drvrate(fdc, 0, !strcmp(machine_get_internal_name(), "if386sx")); - fdc_update_drvrate(fdc, 1, !strcmp(machine_get_internal_name(), "if386sx")); - fdc_update_drvrate(fdc, 2, !strcmp(machine_get_internal_name(), "if386sx")); - fdc_update_drvrate(fdc, 3, !strcmp(machine_get_internal_name(), "if386sx")); + fdc_update_drvrate(fdc, 0, (machines[machine].init == machine_at_if386sx_init)); + fdc_update_drvrate(fdc, 1, (machines[machine].init == machine_at_if386sx_init)); + fdc_update_drvrate(fdc, 2, (machines[machine].init == machine_at_if386sx_init)); + fdc_update_drvrate(fdc, 3, (machines[machine].init == machine_at_if386sx_init)); fdc_update_drv2en(fdc, 1); fdc_update_rates(fdc); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index f69544ecd..aa4f44c2e 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -19531,7 +19531,7 @@ machine_has_bus(int m, int bus_flags) if ((bus_flags & MACHINE_BUS_XT_KBD) && !(machines[m].bus_flags & MACHINE_BUS_ISA16) && (!(machines[m].bus_flags & MACHINE_BUS_PS2_PORTS) || - !(strcmp(machine_get_internal_name(), "pc5086")))) + (machines[m].init == machine_xt_pc5086_init))) ret |= MACHINE_BUS_XT_KBD; #ifdef ONLY_AT_KBD_ON_AT_KBC diff --git a/src/mem/sst_flash.c b/src/mem/sst_flash.c index 34bfae83a..7a836792f 100644 --- a/src/mem/sst_flash.c +++ b/src/mem/sst_flash.c @@ -524,7 +524,7 @@ sst_init(const device_t *info) dev->is_39 = 1; dev->size = info->local & 0xffff0000; - if ((dev->size == 0x20000) && (strstr(machine_get_internal_name_ex(machine), "xi8088")) && !xi8088_bios_128kb()) + if ((dev->size == 0x20000) && ((machines[machine].init == machine_xt_xi8088_init) && !xi8088_bios_128kb())) dev->size = 0x10000; dev->mask = dev->size - 1; diff --git a/src/nvr_at.c b/src/nvr_at.c index 6853867ec..ae7bd8bb4 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -1213,7 +1213,7 @@ nvr_at_init(const device_t *info) } /* This is a hack but it is required for the machine to boot properly, no idea why. */ - if (nvr->is_new && !strcmp(machine_get_internal_name(), "spitfire")) + if (nvr->is_new && (machines[machine].init == machine_at_spitfire_init)) nvr->regs[0x33] = nvr->regs[0x34] = 0xff; return nvr; diff --git a/src/pic.c b/src/pic.c index 446ea1361..50802552f 100644 --- a/src/pic.c +++ b/src/pic.c @@ -254,7 +254,7 @@ void pic_reset(void) { int is_at = IS_AT(machine); - is_at = is_at || !strcmp(machine_get_internal_name(), "xi8088"); + is_at = is_at || (machines[machine].init == machine_xt_xi8088_init); memset(&pic, 0, sizeof(pic_t)); memset(&pic2, 0, sizeof(pic_t)); diff --git a/src/qt/qt_settingsinput.cpp b/src/qt/qt_settingsinput.cpp index 50e3662e9..c540aa2ed 100644 --- a/src/qt/qt_settingsinput.cpp +++ b/src/qt/qt_settingsinput.cpp @@ -123,7 +123,7 @@ SettingsInput::onCurrentMachineChanged(int machineId) int ikbd = (i == KEYBOARD_TYPE_INTERNAL); int pc5086_filter = (strstr(keyboard_get_internal_name(i), "ps") && - strstr(machine_get_internal_name_ex(machineId), "pc5086")); + machines[machineId].init == machine_xt_pc5086_init); if ((ikbd != has_int_kbd) || !device_is_valid(dev, machineId) || pc5086_filter) continue; diff --git a/src/sio/sio_f82c710.c b/src/sio/sio_f82c710.c index f7ff1409f..46cb61a40 100644 --- a/src/sio/sio_f82c710.c +++ b/src/sio/sio_f82c710.c @@ -349,7 +349,7 @@ f82c710_init(const device_t *info) { upc_t *dev = (upc_t *) calloc(1, sizeof(upc_t)); - if (strstr(machine_get_internal_name(), "5086") != NULL) + if (machines[machine].init == machine_xt_pc5086_init) dev->fdc = device_add(&fdc_at_actlow_device); else dev->fdc = device_add(&fdc_at_device); diff --git a/src/sio/sio_fdc37c93x.c b/src/sio/sio_fdc37c93x.c index 47e73ebae..399469424 100644 --- a/src/sio/sio_fdc37c93x.c +++ b/src/sio/sio_fdc37c93x.c @@ -143,7 +143,7 @@ static __inline uint8_t fdc37c93x_do_read_gp(fdc37c93x_t *dev, int reg, int bit) { /* Update bit 2 on the Acer V35N according to the selected graphics card type. */ - if ((reg == 2) && (strstr(machine_get_internal_name(), "acer") != NULL)) + if ((reg == 2) && !strncmp(machine_get_internal_name(), "acer", 4)) dev->gpio_pulldn[reg] = (dev->gpio_pulldn[reg] & 0xfb) | (video_is_mda() ? 0x00 : 0x04); return dev->gpio_regs[reg] & dev->gpio_pulldn[reg] & (1 << bit); @@ -1812,7 +1812,7 @@ fdc37c93x_reset(void *priv) memset(dev->gpio_pulldn, 0xff, 8); /* Acer V62X requires bit 0 to be clear to not be stuck in "clear password" mode. */ - if (!strcmp(machine_get_internal_name(), "vectra54")) { + if (machines[machine].init == machine_at_vectra54_init) { dev->gpio_pulldn[1] = 0x40; /* @@ -1850,12 +1850,12 @@ fdc37c93x_reset(void *priv) dev->gpio_pulldn[1] |= 0x00; else if (cpu_dmulti > 2.5) dev->gpio_pulldn[1] |= 0x80; - } else if (!strcmp(machine_get_internal_name(), "acerv62x")) + } else if (machines[machine].init == machine_at_acerv62x_init) dev->gpio_pulldn[1] = 0xfe; else dev->gpio_pulldn[1] = (dev->chip_id == 0x30) ? 0xff : 0xfd; - if (strstr(machine_get_internal_name(), "acer") != NULL) + if (!strncmp(machine_get_internal_name(), "acer", 4)) /* Bit 2 on the Acer V35N is the text/graphics toggle, bits 1 and 3 = ????. */ dev->gpio_pulldn[2] = 0x10; diff --git a/src/sio/sio_vl82c113.c b/src/sio/sio_vl82c113.c index bf63e9023..b5ecde3c9 100644 --- a/src/sio/sio_vl82c113.c +++ b/src/sio/sio_vl82c113.c @@ -134,7 +134,7 @@ vl82c113_init(UNUSED(const device_t *info)) { vl82c113_t *dev = (vl82c113_t *) calloc(1, sizeof(vl82c113_t)); - if (!strcmp(machine_get_internal_name(), "martin")) + if (machines[machine].init == machine_at_martin_init) dev->nvr = device_add(&martin_nvr_device); else dev->nvr = device_add(&amstrad_megapc_nvr_device); diff --git a/src/sio/sio_w83877.c b/src/sio/sio_w83877.c index a7a2b4ea2..55ee9dd6a 100644 --- a/src/sio/sio_w83877.c +++ b/src/sio/sio_w83877.c @@ -527,7 +527,7 @@ w83877_init(const device_t *info) dev->has_ide = (info->local >> 16) & 0xff; - if (!strcmp(machine_get_internal_name(), "ficpa2012")) { + if (machines[machine].init == machine_at_ficpa2012_init) { dev->dma_map[0] = 4; dev->dma_map[1] = 3; dev->dma_map[2] = 1; diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index 0a43ab4ce..d9c3d1a98 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -4339,7 +4339,7 @@ gd54xx_init(const device_t *info) case CIRRUS_ID_CLGD5436: if ((info->local & 0x200) && - !strstr(machine_get_internal_name(), "sb486pv")) { + (machines[machine].init == machine_at_sb486pv_init)) { romfn = NULL; gd54xx->has_bios = 0; } else