From 27c8bdd57e0bace39fb2c48db98799987b85e536 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sun, 30 Jun 2024 22:18:15 -0400 Subject: [PATCH 01/12] Less dummy devices --- src/device.c | 28 ++++++++++++++++++++++ src/device/isamem.c | 16 +------------ src/device/isartc.c | 26 +++++---------------- src/disk/hdc.c | 32 ++----------------------- src/floppy/fdc.c | 46 +++++++----------------------------- src/include/86box/device.h | 3 +++ src/network/network.c | 32 ++----------------------- src/scsi/scsi.c | 16 +------------ src/sound/midi.c | 48 ++++++++------------------------------ src/sound/sound.c | 32 ++----------------------- src/video/vid_table.c | 31 ++---------------------- 11 files changed, 66 insertions(+), 244 deletions(-) diff --git a/src/device.c b/src/device.c index be39847e6..cf0764946 100644 --- a/src/device.c +++ b/src/device.c @@ -843,3 +843,31 @@ device_context_get_device(void) { return device_current.dev; } + +const device_t device_none = { + .name = "None", + .internal_name = "none", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; + +const device_t device_internal = { + .name = "Internal", + .internal_name = "internal", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; diff --git a/src/device/isamem.c b/src/device/isamem.c index 278bc49a5..d6fa04a64 100644 --- a/src/device/isamem.c +++ b/src/device/isamem.c @@ -2040,25 +2040,11 @@ static const device_t iab_device = { }; #endif -static const device_t isa_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const struct { const device_t *dev; } boards[] = { // clang-format off - { &isa_none_device }, + { &device_none }, // XT Ram Expansion Cards { &ibmxt_32k_device }, { &ibmxt_64k_device }, diff --git a/src/device/isartc.c b/src/device/isartc.c index fea108426..7721d9885 100644 --- a/src/device/isartc.c +++ b/src/device/isartc.c @@ -752,30 +752,16 @@ const device_t vendex_xt_rtc_onboard_device = { .config = NULL }; -static const device_t isartc_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const struct { const device_t *dev; } boards[] = { // clang-format off - { &isartc_none_device }, - { &ev170_device }, - { &pii147_device }, - { &p5pak_device }, - { &a6pak_device }, - { NULL }, + { &device_none }, + { &ev170_device }, + { &pii147_device }, + { &p5pak_device }, + { &a6pak_device }, + { NULL }, // clang-format on }; diff --git a/src/disk/hdc.c b/src/disk/hdc.c index bb7adcd67..ee25e8574 100644 --- a/src/disk/hdc.c +++ b/src/disk/hdc.c @@ -50,40 +50,12 @@ hdc_log(const char *fmt, ...) # define hdc_log(fmt, ...) #endif -static const device_t hdc_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -static const device_t hdc_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const struct { const device_t *device; } controllers[] = { // clang-format off - { &hdc_none_device }, - { &hdc_internal_device }, + { &device_none }, + { &device_internal }, { &st506_xt_xebec_device }, { &st506_xt_wdxt_gen_device }, { &st506_xt_dtc5150x_device }, diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 49171ae30..7c7549ed7 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -97,49 +97,21 @@ fdc_log(const char *fmt, ...) # define fdc_log(fmt, ...) #endif -const device_t fdc_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -const device_t fdc_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - typedef const struct { const device_t *device; } fdc_cards_t; static fdc_cards_t fdc_cards[] = { // clang-format off - { &fdc_none_device }, - { &fdc_internal_device }, - { &fdc_xt_device }, - { &fdc_at_device }, - { &fdc_b215_device }, - { &fdc_pii151b_device }, - { &fdc_pii158b_device }, - { &fdc_monster_device }, - { NULL } + { &device_none }, + { &device_internal }, + { &fdc_xt_device }, + { &fdc_at_device }, + { &fdc_b215_device }, + { &fdc_pii151b_device }, + { &fdc_pii158b_device }, + { &fdc_monster_device }, + { NULL } // clang-format on }; diff --git a/src/include/86box/device.h b/src/include/86box/device.h index 30ce1c093..1a2a6fd8b 100644 --- a/src/include/86box/device.h +++ b/src/include/86box/device.h @@ -244,6 +244,9 @@ extern const char *device_get_internal_name(const device_t *dev); extern int machine_get_config_int(char *s); extern char *machine_get_config_string(char *s); +extern const device_t device_none; +extern const device_t device_internal; + #ifdef __cplusplus } #endif diff --git a/src/network/network.c b/src/network/network.c index 10f81b938..c972e80da 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -77,37 +77,9 @@ # include #endif -static const device_t net_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = NET_TYPE_NONE, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -static const device_t net_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = NET_TYPE_NONE, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const device_t *net_cards[] = { - &net_none_device, - &net_internal_device, + &device_none, + &device_internal, &threec501_device, &threec503_device, &pcnet_am79c960_device, diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index 23c3e65f3..591ef2aa3 100644 --- a/src/scsi/scsi.c +++ b/src/scsi/scsi.c @@ -47,27 +47,13 @@ double scsi_bus_speed[SCSI_BUS_MAX] = { 0.0, 0.0, 0.0, 0.0 }; static uint8_t next_scsi_bus = 0; -static const device_t scsi_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - typedef const struct { const device_t *device; } SCSI_CARD; static SCSI_CARD scsi_cards[] = { // clang-format off - { &scsi_none_device, }, + { &device_none, }, { &aha154xa_device, }, { &aha154xb_device, }, { &aha154xc_device, }, diff --git a/src/sound/midi.c b/src/sound/midi.c index bb107acbf..18fad1886 100644 --- a/src/sound/midi.c +++ b/src/sound/midi.c @@ -71,59 +71,31 @@ typedef struct const device_t *device; } MIDI_OUT_DEVICE, MIDI_IN_DEVICE; -static const device_t midi_out_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const MIDI_OUT_DEVICE devices[] = { // clang-format off - { &midi_out_none_device }, + { &device_none }, #ifdef USE_FLUIDSYNTH - { &fluidsynth_device }, + { &fluidsynth_device }, #endif #ifdef USE_MUNT - { &mt32_old_device }, - { &mt32_new_device }, - { &cm32l_device }, - { &cm32ln_device }, + { &mt32_old_device }, + { &mt32_new_device }, + { &cm32l_device }, + { &cm32ln_device }, #endif #ifdef USE_RTMIDI - { &rtmidi_output_device }, + { &rtmidi_output_device }, #endif #if defined(DEV_BRANCH) && defined(USE_OPL4ML) - { &opl4_midi_device }, + { &opl4_midi_device }, #endif - { NULL } + { NULL } // clang-format on }; -static const device_t midi_in_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const MIDI_IN_DEVICE midi_in_devices[] = { // clang-format off - { &midi_in_none_device }, + { &device_none }, #ifdef USE_RTMIDI { &rtmidi_input_device }, #endif diff --git a/src/sound/sound.c b/src/sound/sound.c index 794e21359..4820c45f9 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -96,38 +96,10 @@ static void *filter_cd_audio_p = NULL; void (*filter_pc_speaker)(int channel, double *buffer, void *priv) = NULL; void *filter_pc_speaker_p = NULL; -static const device_t sound_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -static const device_t sound_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const SOUND_CARD sound_cards[] = { // clang-format off - { &sound_none_device }, - { &sound_internal_device }, + { &device_none }, + { &device_internal }, { &acermagic_s20_device }, { &mirosound_pcm10_device }, { &adlib_device }, diff --git a/src/video/vid_table.c b/src/video/vid_table.c index c99a41544..bcc7d5de8 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -47,38 +47,11 @@ static video_timings_t timing_default = { .type = VIDEO_ISA, .write_b = 8, .writ static int was_reset = 0; -static const device_t vid_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; -static const device_t vid_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const VIDEO_CARD video_cards[] = { // clang-format off - { &vid_none_device }, - { &vid_internal_device }, + { &device_none }, + { &device_internal }, { &atiega800p_device }, { &mach8_vga_isa_device, VIDEO_FLAG_TYPE_8514 }, { &mach32_isa_device, VIDEO_FLAG_TYPE_8514 }, From 3f14c7f5905a2619cacf1c9203cd87b9bf60762f Mon Sep 17 00:00:00 2001 From: TC1995 Date: Sat, 20 Jul 2024 01:09:42 +0200 Subject: [PATCH 02/12] Chips PCI card fixes (July 20th, 2024) Cleaned up the code and fixed the reset and LFB accesses. NT 4.0 now works with its v2.47 drivers without a soft reset (it used to only with a soft reset originally and, without it, hang with a blank screen upon reaching the GUI). --- src/video/vid_chips_69000.c | 101 ++++++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 32 deletions(-) diff --git a/src/video/vid_chips_69000.c b/src/video/vid_chips_69000.c index fd4ff5c8e..5d41dc4a7 100644 --- a/src/video/vid_chips_69000.c +++ b/src/video/vid_chips_69000.c @@ -161,6 +161,8 @@ typedef struct chips_69000_t { uint8_t st01; } chips_69000_t; +static chips_69000_t *reset_state = NULL; + /* TODO: Probe timings on real hardware. */ static video_timings_t timing_chips = { .type = VIDEO_PCI, .write_b = 2, .write_w = 2, .write_l = 1, .read_b = 10, .read_w = 10, .read_l = 10 }; @@ -777,7 +779,7 @@ chips_69000_recalctimings(svga_t *svga) if (!(chips->ext_regs[0x81] & 0x10)) svga->htotal += 5; - + svga->hblank_end_val = ((svga->crtc[3] & 0x1f) | ((svga->crtc[5] & 0x80) ? 0x20 : 0x00)) | (svga->crtc[0x3c] & 0b11000000); svga->hblank_end_mask = 0xff; @@ -980,7 +982,7 @@ chips_69000_process_pixel(chips_69000_t* chips, uint32_t pixel) if (!!(color_key == dest_pixel) == !!(chips->bitblt_running.bitblt.bitblt_control & (1 << 16))) { return; } - + break; } } @@ -1018,7 +1020,7 @@ chips_69000_process_pixel(chips_69000_t* chips, uint32_t pixel) if (!!(color_key == dest_pixel) == !!(chips->bitblt_running.bitblt.bitblt_control & (1 << 16))) { return; } - + break; } } @@ -1191,7 +1193,7 @@ chips_69000_setup_bitblt(chips_69000_t* chips) chips->bitblt_running.mono_bytes_pitch = ((chips->bitblt_running.actual_destination_width + chips->bitblt_running.bitblt.monochrome_source_left_clip + 63) & ~63) / 8; } } - + return; } @@ -1273,7 +1275,7 @@ chips_69000_setup_bitblt(chips_69000_t* chips) do { uint32_t pixel = 0; uint32_t source_addr = chips->bitblt_running.bitblt.source_addr + (chips->bitblt_running.y * chips->bitblt.source_span) + (chips->bitblt_running.x * chips->bitblt_running.bytes_per_pixel); - + switch (chips->bitblt_running.bytes_per_pixel) { case 1: /* 8 bits-per-pixel. */ { @@ -1423,7 +1425,7 @@ chips_69000_bitblt_write(chips_69000_t* chips, uint8_t data) { source_pixel |= (chips->bitblt_running.bytes_port[1] << 8); if (chips->bitblt_running.bytes_per_pixel >= 3) source_pixel |= (chips->bitblt_running.bytes_port[2] << 16); - + chips->bitblt_running.bytes_in_line_written += chips->bitblt_running.bytes_per_pixel; chips_69000_process_pixel(chips, source_pixel); @@ -1446,7 +1448,7 @@ chips_69000_bitblt_write(chips_69000_t* chips, uint8_t data) { chips->bitblt_running.count_x = 0; chips->bitblt_running.x = 0; - + if (chips->bitblt_running.count_y >= chips->bitblt_running.actual_destination_height) { chips_69000_bitblt_interrupt(chips); return; @@ -1498,7 +1500,7 @@ chips_69000_read_ext_reg(chips_69000_t* chips) val = chips->ext_regs[index]; if (!(chips->ext_regs[0x62] & 0x8)) val = (val & ~8) | (i2c_gpio_get_scl(chips->i2c) << 3); - + if (!(chips->ext_regs[0x62] & 0x4)) val = (val & ~4) | (i2c_gpio_get_sda(chips->i2c) << 2); @@ -1561,12 +1563,12 @@ chips_69000_write_ext_reg(chips_69000_t* chips, uint8_t val) scl = !!(val & 8); else scl = i2c_gpio_get_scl(chips->i2c); - + if (chips->ext_regs[0x62] & 0x4) sda = !!(val & 4); else scl = i2c_gpio_get_sda(chips->i2c); - + i2c_gpio_set(chips->i2c, scl, sda); chips->ext_regs[chips->ext_index] = val & 0x9F; @@ -1742,7 +1744,7 @@ chips_69000_out(uint16_t addr, uint8_t val, void *p) case 0x3B7: case 0x3D7: return chips_69000_write_ext_reg(chips, val); - + } svga_out(addr, val, svga); } @@ -1901,17 +1903,15 @@ chips_69000_pci_write(int func, int addr, uint8_t val, void *p) if (chips->pci_conf_status & PCI_COMMAND_MEM) { mem_mapping_enable(&chips->svga.mapping); if (chips->linear_mapping.base) - mem_mapping_enable(&chips->linear_mapping); + mem_mapping_set_addr(&chips->linear_mapping, chips->linear_mapping.base, (1 << 24)); } break; } case 0x13: { - if (!chips->linear_mapping.enable) { - chips->linear_mapping.base = val << 24; - break; - } - mem_mapping_set_addr(&chips->linear_mapping, val << 24, (1 << 24)); + chips->linear_mapping.base = val << 24; + if (chips->linear_mapping.base) + mem_mapping_set_addr(&chips->linear_mapping, chips->linear_mapping.base, (1 << 24)); break; } case 0x3c: @@ -2093,7 +2093,7 @@ chips_69000_writeb_mmio(uint32_t addr, uint8_t val, chips_69000_t* chips) chips->mem_regs_b[addr & 0xF] = val; break; } - + } chips->mem_regs_b[addr & 0xF] = val; break; @@ -2213,7 +2213,7 @@ chips_69000_readw_linear(uint32_t addr, void *p) if (addr & 0x800000) { if (addr & 0x400000) return bswap16(chips_69000_readw_mmio(addr, chips)); - + return bswap16(svga_readw_linear(addr & 0x1FFFFF, p)); } @@ -2232,7 +2232,7 @@ chips_69000_readl_linear(uint32_t addr, void *p) if (addr & 0x800000) { if (addr & 0x400000) return bswap32(chips_69000_readl_mmio(addr, chips)); - + return bswap32(svga_readl_linear(addr & 0x1FFFFF, p)); } @@ -2290,7 +2290,7 @@ chips_69000_vblank_start(svga_t *svga) chips_69000_t *chips = (chips_69000_t *) svga->priv; chips->mem_regs[1] |= 1 << 14; chips->svga.crtc[0x40] &= ~0x80; - + chips_69000_interrupt(chips); } @@ -2307,13 +2307,13 @@ chips_69000_hwcursor_draw_64x64(svga_t *svga, int displine) dat[1] = bswap64(*(uint64_t *) (&svga->vram[svga->hwcursor_latch.addr])); dat[0] = bswap64(*(uint64_t *) (&svga->vram[svga->hwcursor_latch.addr + 8])); svga->hwcursor_latch.addr += 16; - + for (uint8_t x = 0; x < 64; x++) { if (!(dat[1] & (1ULL << 63))) svga->monitor->target_buffer->line[displine][(offset + svga->x_add) & 2047] = (dat[0] & (1ULL << 63)) ? svga_lookup_lut_ram(svga, chips->cursor_pallook[5]) : svga_lookup_lut_ram(svga, chips->cursor_pallook[4]); else if (dat[0] & (1ULL << 63)) svga->monitor->target_buffer->line[displine][(offset + svga->x_add) & 2047] ^= 0xffffff; - + offset++; dat[0] <<= 1; dat[1] <<= 1; @@ -2430,14 +2430,48 @@ chips_69000_line_compare(svga_t* svga) if (chips->ext_regs[0x81] & 0xF) { return 0; } - + return 1; } +static void +chips_69000_disable_handlers(chips_69000_t *chips) +{ + io_removehandler(0x03c0, 0x0020, chips_69000_in, NULL, NULL, chips_69000_out, NULL, NULL, chips); + + mem_mapping_disable(&chips->linear_mapping); + mem_mapping_disable(&chips->svga.mapping); + if (!chips->on_board) + mem_mapping_disable(&chips->bios_rom.mapping); + + /* Save all the mappings and the timers because they are part of linked lists. */ + reset_state->linear_mapping = chips->linear_mapping; + reset_state->svga.mapping = chips->svga.mapping; + reset_state->bios_rom.mapping = chips->bios_rom.mapping; + + reset_state->decrement_timer = chips->decrement_timer; + reset_state->svga.timer = chips->svga.timer; + reset_state->svga.timer8514 = chips->svga.timer8514; +} + +static void +chips_69000_reset(void *priv) +{ + chips_69000_t *chips = (chips_69000_t *) priv; + + if (reset_state != NULL) { + chips_69000_disable_handlers(chips); + reset_state->slot = chips->slot; + + *chips = *reset_state; + } +} + static void * chips_69000_init(const device_t *info) { chips_69000_t *chips = calloc(1, sizeof(chips_69000_t)); + reset_state = calloc(1, sizeof(chips_69000_t)); /* Appears to have an odd VBIOS size. */ if (!info->local) { @@ -2450,7 +2484,7 @@ chips_69000_init(const device_t *info) svga_init(info, &chips->svga, chips, 1 << 21, /*2048kb*/ chips_69000_recalctimings, chips_69000_in, chips_69000_out, - NULL, + chips_69000_hwcursor_draw, NULL); io_sethandler(0x03c0, 0x0020, chips_69000_in, NULL, NULL, chips_69000_out, NULL, NULL, chips); @@ -2459,9 +2493,7 @@ chips_69000_init(const device_t *info) chips->svga.bpp = 8; chips->svga.miscout = 1; - chips->svga.recalctimings_ex = chips_69000_recalctimings; chips->svga.vblank_start = chips_69000_vblank_start; - chips->svga.hwcursor_draw = chips_69000_hwcursor_draw; chips->svga.getclock = chips_69000_getclock; chips->svga.conv_16to32 = chips_69000_conv_16to32; chips->svga.line_compare = chips_69000_line_compare; @@ -2471,7 +2503,7 @@ chips_69000_init(const device_t *info) chips->quit = 0; chips->engine_active = 0; chips->on_board = !!(info->local); - + chips->svga.packed_chain4 = 1; timer_add(&chips->decrement_timer, chips_69000_decrement_timer, chips, 0); @@ -2479,9 +2511,11 @@ chips_69000_init(const device_t *info) chips->i2c = i2c_gpio_init("ddc_chips_69000"); chips->ddc = ddc_init(i2c_gpio_get_bus(chips->i2c)); - + chips->flat_panel_regs[0x01] = 1; + *reset_state = *chips; + return chips; } @@ -2503,6 +2537,9 @@ chips_69000_close(void *p) i2c_gpio_close(chips->i2c); svga_close(&chips->svga); + free(reset_state); + reset_state = NULL; + free(chips); } @@ -2519,7 +2556,7 @@ chips_69000_force_redraw(void *p) { chips_69000_t *chips = (chips_69000_t *) p; - chips->svga.fullchange = changeframecount; + chips->svga.fullchange = chips->svga.monitor->mon_changeframecount; } const device_t chips_69000_device = { @@ -2529,7 +2566,7 @@ const device_t chips_69000_device = { .local = 0, .init = chips_69000_init, .close = chips_69000_close, - .reset = NULL, + .reset = chips_69000_reset, { .available = chips_69000_available }, .speed_changed = chips_69000_speed_changed, .force_redraw = chips_69000_force_redraw, @@ -2543,7 +2580,7 @@ const device_t chips_69000_onboard_device = { .local = 1, .init = chips_69000_init, .close = chips_69000_close, - .reset = NULL, + .reset = chips_69000_reset, { .available = chips_69000_available }, .speed_changed = chips_69000_speed_changed, .force_redraw = chips_69000_force_redraw, From 322adf1c2be2936cbf4b96c212f2f9530fd35add Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 29 Jun 2024 19:43:42 -0400 Subject: [PATCH 03/12] Initial underlying code support for more than 2 video cards --- src/86box.c | 17 ++++++++++------- src/config.c | 22 ++++++++++++++-------- src/include/86box/86box.h | 3 ++- src/qt/qt_main.cpp | 8 +++++--- src/qt/qt_settingsdisplay.cpp | 14 +++++++++----- src/qt/qt_settingsdisplay.hpp | 4 +++- src/unix/unix.c | 5 +++-- src/video/vid_table.c | 14 ++++++++------ 8 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/86box.c b/src/86box.c index 16d7cf3de..5e1f58413 100644 --- a/src/86box.c +++ b/src/86box.c @@ -179,7 +179,7 @@ int postcard_enabled = 0; /* (C) enable int unittester_enabled = 0; /* (C) enable unit tester device */ int isamem_type[ISAMEM_MAX] = { 0, 0, 0, 0 }; /* (C) enable ISA mem cards */ int isartc_type = 0; /* (C) enable ISA RTC card */ -int gfxcard[2] = { 0, 0 }; /* (C) graphics/video card */ +int gfxcard[GFXCARD_MAX] = { 0, 0 }; /* (C) graphics/video card */ int show_second_monitors = 1; /* (C) show non-primary monitors */ int sound_is_float = 1; /* (C) sound uses FP values */ int voodoo_enabled = 0; /* (C) video option */ @@ -1004,12 +1004,15 @@ pc_init_modules(void) } } - if (!video_card_available(gfxcard[1])) { - char tempc[512] = { 0 }; - device_get_name(video_card_getdevice(gfxcard[1]), 0, tempc); - swprintf(temp, sizeof_w(temp), plat_get_string(STRING_HW_NOT_AVAILABLE_VIDEO2), tempc); - ui_msgbox_header(MBX_INFO, plat_get_string(STRING_HW_NOT_AVAILABLE_TITLE), temp); - gfxcard[1] = 0; + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + if (!video_card_available(gfxcard[i])) { + char tempc[512] = { 0 }; + device_get_name(video_card_getdevice(gfxcard[i]), 0, tempc); + swprintf(temp, sizeof_w(temp), plat_get_string(STRING_HW_NOT_AVAILABLE_VIDEO2), tempc); + ui_msgbox_header(MBX_INFO, plat_get_string(STRING_HW_NOT_AVAILABLE_TITLE), temp); + gfxcard[i] = 0; + } } atfullspeed = 0; diff --git a/src/config.c b/src/config.c index 8a837cf56..43555a704 100644 --- a/src/config.c +++ b/src/config.c @@ -459,10 +459,13 @@ load_video(void) show_second_monitors = !!ini_section_get_int(cat, "show_second_monitors", 1); video_fullscreen_scale_maximized = !!ini_section_get_int(cat, "video_fullscreen_scale_maximized", 0); - p = ini_section_get_string(cat, "gfxcard_2", NULL); - if (!p) - p = "none"; - gfxcard[1] = video_get_video_from_internal_name(p); + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + p = ini_section_get_string(cat, "gfxcard_2", NULL); + if (!p) + p = "none"; + gfxcard[i] = video_get_video_from_internal_name(p); + } } /* Load "Input Devices" section. */ @@ -2010,10 +2013,13 @@ save_video(void) else ini_section_set_int(cat, "xga", xga_standalone_enabled); - if (gfxcard[1] == 0) - ini_section_delete_var(cat, "gfxcard_2"); - else - ini_section_set_string(cat, "gfxcard_2", video_get_internal_name(gfxcard[1])); + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + if (gfxcard[i] == 0) + ini_section_delete_var(cat, "gfxcard_2"); + else + ini_section_set_string(cat, "gfxcard_2", video_get_internal_name(gfxcard[i])); + } if (show_second_monitors == 1) ini_section_delete_var(cat, "show_second_monitors"); diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index 0d57b4cae..c91b8d406 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -21,6 +21,7 @@ #define EMU_86BOX_H /* Configuration values. */ +#define GFXCARD_MAX 2 #define SERIAL_MAX 7 #define PARALLEL_MAX 4 #define SCREEN_RES_X 640 @@ -124,7 +125,7 @@ extern int force_43; /* (C) video */ extern int video_filter_method; /* (C) video */ extern int video_vsync; /* (C) video */ extern int video_framerate; /* (C) video */ -extern int gfxcard[2]; /* (C) graphics/video card */ +extern int gfxcard[GFXCARD_MAX]; /* (C) graphics/video card */ extern char video_shader[512]; /* (C) video */ extern int bugger_enabled; /* (C) enable ISAbugger */ extern int novell_keycard_enabled; /* (C) enable Novell NetWare 2.x key card emulation. */ diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 049a7907b..c39007864 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -145,9 +145,11 @@ main_thread_fn() } is_quit = 1; - if (gfxcard[1]) { - ui_deinit_monitor(1); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + if (gfxcard[i]) { + ui_deinit_monitor(i); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } } QTimer::singleShot(0, QApplication::instance(), []() { QApplication::processEvents(); QApplication::instance()->quit(); }); } diff --git a/src/qt/qt_settingsdisplay.cpp b/src/qt/qt_settingsdisplay.cpp index 6969a1c2c..db8c30e5d 100644 --- a/src/qt/qt_settingsdisplay.cpp +++ b/src/qt/qt_settingsdisplay.cpp @@ -36,8 +36,8 @@ SettingsDisplay::SettingsDisplay(QWidget *parent) { ui->setupUi(this); - videoCard[0] = gfxcard[0]; - videoCard[1] = gfxcard[1]; + for (uint8_t i = 0; i < GFXCARD_MAX; i ++) + videoCard[i] = gfxcard[i]; onCurrentMachineChanged(machine); } @@ -50,7 +50,9 @@ void SettingsDisplay::save() { gfxcard[0] = ui->comboBoxVideo->currentData().toInt(); - gfxcard[1] = ui->comboBoxVideoSecondary->currentData().toInt(); + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) + gfxcard[i] = ui->comboBoxVideoSecondary->currentData().toInt(); voodoo_enabled = ui->checkBoxVoodoo->isChecked() ? 1 : 0; ibm8514_standalone_enabled = ui->checkBox8514->isChecked() ? 1 : 0; xga_standalone_enabled = ui->checkBoxXga->isChecked() ? 1 : 0; @@ -103,8 +105,10 @@ SettingsDisplay::onCurrentMachineChanged(int machineId) ui->pushButtonConfigureSecondary->setEnabled(true); } ui->comboBoxVideo->setCurrentIndex(selectedRow); - if (gfxcard[1] == 0) - ui->pushButtonConfigureSecondary->setEnabled(false); + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) + if (gfxcard[i] == 0) + ui->pushButtonConfigureSecondary->setEnabled(false); } void diff --git a/src/qt/qt_settingsdisplay.hpp b/src/qt/qt_settingsdisplay.hpp index 8331bbb5b..6297f7eae 100644 --- a/src/qt/qt_settingsdisplay.hpp +++ b/src/qt/qt_settingsdisplay.hpp @@ -3,6 +3,8 @@ #include +#define VIDEOCARD_MAX 2 + namespace Ui { class SettingsDisplay; } @@ -36,7 +38,7 @@ private slots: private: Ui::SettingsDisplay *ui; int machineId = 0; - int videoCard[2] = { 0, 0 }; + int videoCard[VIDEOCARD_MAX] = { 0, 0 }; }; #endif // QT_SETTINGSDISPLAY_HPP diff --git a/src/unix/unix.c b/src/unix/unix.c index e08b82133..1fe477a23 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -1168,7 +1168,7 @@ monitor_thread(void *param) #endif } -extern int gfxcard[2]; +extern int gfxcard[GFXCARD_MAX]; int main(int argc, char **argv) { @@ -1186,7 +1186,8 @@ main(int argc, char **argv) return 6; } - gfxcard[1] = 0; + for (uint8_t i = 1; i < GFXCARD_MAX; i++) + gfxcard[i] = 0; eventthread = SDL_ThreadID(); blitmtx = SDL_CreateMutex(); if (!blitmtx) { diff --git a/src/video/vid_table.c b/src/video/vid_table.c index c99a41544..40c5e1110 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -349,12 +349,14 @@ video_reset(int card) monitor_index_global = 0; loadfont("roms/video/mda/mda.rom", 0); - if ((card != VID_NONE) && !machine_has_flags(machine, MACHINE_VIDEO_ONLY) && - (gfxcard[1] > VID_INTERNAL) && device_is_valid(video_card_getdevice(gfxcard[1]), machine)) { - video_monitor_init(1); - monitor_index_global = 1; - device_add(video_cards[gfxcard[1]].device); - monitor_index_global = 0; + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + if ((card != VID_NONE) && !machine_has_flags(machine, MACHINE_VIDEO_ONLY) && + (gfxcard[i] > VID_INTERNAL) && device_is_valid(video_card_getdevice(gfxcard[i]), machine)) { + video_monitor_init(i); + monitor_index_global = 1; + device_add(video_cards[gfxcard[i]].device); + monitor_index_global = 0; + } } /* Do not initialize internal cards here. */ From 20439f24fadf0f7a727cef4a2bc9c477434c9cce Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 29 Jun 2024 19:11:59 -0400 Subject: [PATCH 04/12] Cleanups in qt_settingsports.hpp --- src/qt/qt_settingsports.cpp | 21 +++++++++------------ src/qt/qt_settingsports.hpp | 6 +----- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index f6486aa9a..2547c2ab4 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -66,18 +66,17 @@ SettingsPorts::SettingsPorts(QWidget *parent) } for (int i = 0; i < SERIAL_MAX; i++) { - auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); + auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); + auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); if (checkBox != NULL) checkBox->setChecked(com_ports[i].enabled > 0); + if (checkBoxPass != NULL) + checkBoxPass->setChecked(serial_passthrough_enabled[i]); } - ui->checkBoxSerialPassThru1->setChecked(serial_passthrough_enabled[0]); ui->pushButtonSerialPassThru1->setEnabled(serial_passthrough_enabled[0]); - ui->checkBoxSerialPassThru2->setChecked(serial_passthrough_enabled[1]); ui->pushButtonSerialPassThru2->setEnabled(serial_passthrough_enabled[1]); - ui->checkBoxSerialPassThru3->setChecked(serial_passthrough_enabled[2]); ui->pushButtonSerialPassThru3->setEnabled(serial_passthrough_enabled[2]); - ui->checkBoxSerialPassThru4->setChecked(serial_passthrough_enabled[3]); ui->pushButtonSerialPassThru4->setEnabled(serial_passthrough_enabled[3]); } @@ -90,7 +89,7 @@ void SettingsPorts::save() { for (int i = 0; i < PARALLEL_MAX; i++) { - auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); + auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); if (cbox != NULL) lpt_ports[i].device = cbox->currentData().toInt(); @@ -99,15 +98,13 @@ SettingsPorts::save() } for (int i = 0; i < SERIAL_MAX; i++) { - auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); + auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); + auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); if (checkBox != NULL) com_ports[i].enabled = checkBox->isChecked() ? 1 : 0; + if (checkBoxPass != NULL) + serial_passthrough_enabled[i] = checkBoxPass->isChecked(); } - - serial_passthrough_enabled[0] = ui->checkBoxSerialPassThru1->isChecked(); - serial_passthrough_enabled[1] = ui->checkBoxSerialPassThru2->isChecked(); - serial_passthrough_enabled[2] = ui->checkBoxSerialPassThru3->isChecked(); - serial_passthrough_enabled[3] = ui->checkBoxSerialPassThru4->isChecked(); } void diff --git a/src/qt/qt_settingsports.hpp b/src/qt/qt_settingsports.hpp index a5129d35f..fb811f771 100644 --- a/src/qt/qt_settingsports.hpp +++ b/src/qt/qt_settingsports.hpp @@ -37,15 +37,11 @@ private slots: void on_pushButtonSerialPassThru1_clicked(); private slots: - void on_checkBoxSerialPassThru1_clicked(bool checked); - -private slots: + void on_checkBoxParallel4_stateChanged(int arg1); void on_checkBoxParallel3_stateChanged(int arg1); void on_checkBoxParallel2_stateChanged(int arg1); void on_checkBoxParallel1_stateChanged(int arg1); - void on_checkBoxParallel4_stateChanged(int arg1); - private: Ui::SettingsPorts *ui; }; From de21053e5d54b5f1218a3af2f69cbe3e6eb01575 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 29 Jun 2024 19:11:37 -0400 Subject: [PATCH 05/12] Add logic for serial 5-7 in QT UI --- src/qt/qt_settingsports.cpp | 43 +++++++++++++++++++++++++++++++++++++ src/qt/qt_settingsports.hpp | 24 +++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index 2547c2ab4..01d7d3f9f 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -78,6 +78,11 @@ SettingsPorts::SettingsPorts(QWidget *parent) ui->pushButtonSerialPassThru2->setEnabled(serial_passthrough_enabled[1]); ui->pushButtonSerialPassThru3->setEnabled(serial_passthrough_enabled[2]); ui->pushButtonSerialPassThru4->setEnabled(serial_passthrough_enabled[3]); +#if 0 + ui->pushButtonSerialPassThru5->setEnabled(serial_passthrough_enabled[4]); + ui->pushButtonSerialPassThru6->setEnabled(serial_passthrough_enabled[5]); + ui->pushButtonSerialPassThru7->setEnabled(serial_passthrough_enabled[6]); +#endif } SettingsPorts::~SettingsPorts() @@ -155,6 +160,24 @@ SettingsPorts::on_pushButtonSerialPassThru4_clicked() DeviceConfig::ConfigureDevice(&serial_passthrough_device, 4, qobject_cast(Settings::settings)); } +void +SettingsPorts::on_pushButtonSerialPassThru5_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 5, qobject_cast(Settings::settings)); +} + +void +SettingsPorts::on_pushButtonSerialPassThru6_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 6, qobject_cast(Settings::settings)); +} + +void +SettingsPorts::on_pushButtonSerialPassThru7_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 7, qobject_cast(Settings::settings)); +} + void SettingsPorts::on_checkBoxSerialPassThru1_clicked(bool checked) { @@ -178,3 +201,23 @@ SettingsPorts::on_checkBoxSerialPassThru4_clicked(bool checked) { ui->pushButtonSerialPassThru4->setEnabled(checked); } + +#if 0 +void +SettingsPorts::on_checkBoxSerialPassThru5_clicked(bool checked) +{ + ui->pushButtonSerialPassThru5->setEnabled(checked); +} + +void +SettingsPorts::on_checkBoxSerialPassThru6_clicked(bool checked) +{ + ui->pushButtonSerialPassThru6->setEnabled(checked); +} + +void +SettingsPorts::on_checkBoxSerialPassThru7_clicked(bool checked) +{ + ui->pushButtonSerialPassThru7->setEnabled(checked); +} +#endif \ No newline at end of file diff --git a/src/qt/qt_settingsports.hpp b/src/qt/qt_settingsports.hpp index fb811f771..1ecb051af 100644 --- a/src/qt/qt_settingsports.hpp +++ b/src/qt/qt_settingsports.hpp @@ -15,6 +15,18 @@ public: ~SettingsPorts(); void save(); + +#if 0 +private slots: + void on_checkBoxSerialPassThru7_clicked(bool checked); + +private slots: + void on_checkBoxSerialPassThru6_clicked(bool checked); + +private slots: + void on_checkBoxSerialPassThru5_clicked(bool checked); +#endif + private slots: void on_checkBoxSerialPassThru4_clicked(bool checked); @@ -24,6 +36,18 @@ private slots: private slots: void on_checkBoxSerialPassThru2_clicked(bool checked); +private slots: + void on_checkBoxSerialPassThru1_clicked(bool checked); + +private slots: + void on_pushButtonSerialPassThru7_clicked(); + +private slots: + void on_pushButtonSerialPassThru6_clicked(); + +private slots: + void on_pushButtonSerialPassThru5_clicked(); + private slots: void on_pushButtonSerialPassThru4_clicked(); From 529cef56e388c69378a7f013b4f608ed1817e9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miran=20Gr=C4=8Da?= Date: Sat, 20 Jul 2024 19:55:47 +0200 Subject: [PATCH 06/12] Revert win_cdrom_ioctl.c to the previous version, fixes regressions. --- src/qt/win_cdrom_ioctl.c | 74 ++++++++-------------------------------- 1 file changed, 15 insertions(+), 59 deletions(-) diff --git a/src/qt/win_cdrom_ioctl.c b/src/qt/win_cdrom_ioctl.c index 510a1143f..ff422bcd2 100644 --- a/src/qt/win_cdrom_ioctl.c +++ b/src/qt/win_cdrom_ioctl.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #define HAVE_STDARG_H #include <86box/86box.h> @@ -327,55 +326,17 @@ plat_cdrom_get_audio_sub(UNUSED(uint32_t sector), uint8_t *attr, uint8_t *track, } int -plat_cdrom_get_sector_size(uint32_t sector) +plat_cdrom_get_sector_size(UNUSED(uint32_t sector)) { - /* Sector size returned by Windows is always a power of two, which is pointless. */ - return 2352; -} + long size; + DISK_GEOMETRY dgCDROM; -/* Used EXCLUSIVELY to read raw sectors, not to detect tracks. */ -static int -plat_cdrom_read_scsi_direct(uint32_t sector, uint8_t *buffer) -{ - DWORD unused; - int ret; - typedef struct SCSI_PASS_THROUGH_DIRECT_BUF { - SCSI_PASS_THROUGH_DIRECT spt; - ULONG Filler; - UCHAR SenseBuf[32]; - } SCSI_PASS_THROUGH_DIRECT_BUF; + plat_cdrom_open(); + DeviceIoControl(handle, IOCTL_CDROM_GET_DRIVE_GEOMETRY, NULL, 0, &dgCDROM, sizeof(dgCDROM), (LPDWORD)&size, NULL); + plat_cdrom_close(); - SCSI_PASS_THROUGH_DIRECT_BUF req; - - memset(&req, 0, sizeof(req)); - req.Filler = 0; - req.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT); - req.spt.CdbLength = 12; - req.spt.DataIn = SCSI_IOCTL_DATA_IN; - req.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_DIRECT_BUF, SenseBuf); - req.spt.SenseInfoLength = sizeof(req.SenseBuf); - req.spt.TimeOutValue = 6; - req.spt.DataTransferLength = 2352; - req.spt.DataBuffer = buffer; - - /* Fill in the CDB. */ - req.spt.Cdb[0] = 0xBE; /* READ CD */ - req.spt.Cdb[1] = 0x00; /* DAP = 0, Any Sector Type. */ - req.spt.Cdb[2] = (sector & 0xFF000000) >> 24; - req.spt.Cdb[3] = (sector & 0xFF0000) >> 16; - req.spt.Cdb[4] = (sector & 0xFF00) >> 8; - req.spt.Cdb[5] = (sector & 0xFF); /* Starting Logical Block Address. */ - req.spt.Cdb[6] = 0; - req.spt.Cdb[7] = 0; - req.spt.Cdb[8] = 1; /* Transfer Length. */ - req.spt.Cdb[9] = 0xF8; /* 2352 bytes of data (non-subchannel). */ - req.spt.Cdb[10] = 0; /* No subchannel data. */ - req.spt.Cdb[11] = 0; - - ret = DeviceIoControl(handle, IOCTL_SCSI_PASS_THROUGH_DIRECT, &req, sizeof(req), &req, sizeof(req), &unused, NULL) && req.spt.DataTransferLength == 2352; - - win_cdrom_ioctl_log("plat_cdrom_read_scsi_direct: ret = %d, req.spt.DataTransferLength = %lu\n", ret, req.spt.DataTransferLength); - return ret; + win_cdrom_ioctl_log("BytesPerSector=%d\n", dgCDROM.BytesPerSector); + return dgCDROM.BytesPerSector; } int @@ -390,18 +351,13 @@ plat_cdrom_read_sector(uint8_t *buffer, int raw, uint32_t sector) if (raw) { win_cdrom_ioctl_log("Raw\n"); /* Raw */ - status = plat_cdrom_read_scsi_direct(sector, buffer); - if (status) { - return 1; - } else { - RAW_READ_INFO in; - in.DiskOffset.LowPart = sector * COOKED_SECTOR_SIZE; - in.DiskOffset.HighPart = 0; - in.SectorCount = 1; - in.TrackMode = CDDA; - status = DeviceIoControl(handle, IOCTL_CDROM_RAW_READ, &in, sizeof(in), - buffer, buflen, (LPDWORD)&size, NULL); - } + RAW_READ_INFO in; + in.DiskOffset.LowPart = sector * COOKED_SECTOR_SIZE; + in.DiskOffset.HighPart = 0; + in.SectorCount = 1; + in.TrackMode = CDDA; + status = DeviceIoControl(handle, IOCTL_CDROM_RAW_READ, &in, sizeof(in), + buffer, buflen, (LPDWORD)&size, NULL); } else { win_cdrom_ioctl_log("Cooked\n"); /* Cooked */ From 05e7d9239c8c39347ccba800580d4c16e5cc46c1 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 20 Jul 2024 01:14:35 -0400 Subject: [PATCH 07/12] Standardize fdc_type into fdc_current Also make it into an array --- src/config.c | 10 ++--- src/floppy/fdc.c | 6 +-- src/include/86box/config.h | 2 +- src/include/86box/fdc.h | 2 +- src/include/86box/fdc_ext.h | 2 +- src/machine/m_at.c | 4 +- src/machine/m_at_286_386sx.c | 56 +++++++++++------------ src/machine/m_at_386dx_486.c | 57 ++++++++++++------------ src/machine/m_at_commodore.c | 2 +- src/machine/m_at_compaq.c | 2 +- src/machine/m_at_socket4.c | 4 +- src/machine/m_at_socket5.c | 4 +- src/machine/m_at_t3100e.c | 2 +- src/machine/m_elt.c | 2 +- src/machine/m_ps2_mca.c | 2 +- src/machine/m_tandy.c | 2 +- src/machine/m_v86p.c | 2 +- src/machine/m_xt.c | 2 +- src/machine/m_xt_compaq.c | 4 +- src/machine/m_xt_laserxt.c | 2 +- src/machine/m_xt_olivetti.c | 4 +- src/machine/m_xt_xi8088.c | 2 +- src/machine/m_xt_zenith.c | 6 +-- src/qt/qt_settingsstoragecontrollers.cpp | 4 +- 24 files changed, 92 insertions(+), 93 deletions(-) diff --git a/src/config.c b/src/config.c index 43555a704..4a7bd45fa 100644 --- a/src/config.c +++ b/src/config.c @@ -792,9 +792,9 @@ load_storage_controllers(void) p = ini_section_get_string(cat, "fdc", NULL); #if 1 if (p != NULL) - fdc_type = fdc_card_get_from_internal_name(p); + fdc_current[0] = fdc_card_get_from_internal_name(p); else - fdc_type = FDC_INTERNAL; + fdc_current[0] = FDC_INTERNAL; #else if (p == NULL) { if (machine_has_flags(machine, MACHINE_FDC)) { @@ -807,7 +807,7 @@ load_storage_controllers(void) free_p = 1; } - fdc_type = fdc_card_get_from_internal_name(p); + fdc_current[0] = fdc_card_get_from_internal_name(p); if (free_p) { free(p); @@ -2296,11 +2296,11 @@ save_storage_controllers(void) scsi_card_get_internal_name(scsi_card_current[c])); } - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) ini_section_delete_var(cat, "fdc"); else ini_section_set_string(cat, "fdc", - fdc_card_get_internal_name(fdc_type)); + fdc_card_get_internal_name(fdc_current[0])); ini_section_set_string(cat, "hdc", hdc_get_internal_name(hdc_current)); diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 7c7549ed7..756f43448 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -77,7 +77,7 @@ int lastbyte = 0; int floppymodified[4]; int floppyrate[4]; -int fdc_type = 0; +int fdc_current[2] = { 0, 0 }; #ifdef ENABLE_FDC_LOG int fdc_do_log = ENABLE_FDC_LOG; @@ -162,8 +162,8 @@ fdc_card_get_from_internal_name(char *s) void fdc_card_init(void) { - if ((fdc_type > FDC_INTERNAL) && fdc_cards[fdc_type].device) - device_add_inst(fdc_cards[fdc_type].device, 0); + if ((fdc_current[0] > FDC_INTERNAL) && fdc_cards[fdc_current[0]].device) + device_add_inst(fdc_cards[fdc_current[0]].device, 0); } uint8_t diff --git a/src/include/86box/config.h b/src/include/86box/config.h index 8ce6f4cfe..0f596b7ac 100644 --- a/src/include/86box/config.h +++ b/src/include/86box/config.h @@ -113,7 +113,7 @@ typedef struct config_t { # endif /* Other peripherals category */ - int fdc_type; /* Floppy disk controller type */ + int fdc_current[2]; /* Floppy disk controller type */ int hdc_current; /* Hard disk controller type */ int hdc; /* Hard disk controller */ int scsi_card; /* SCSI controller */ diff --git a/src/include/86box/fdc.h b/src/include/86box/fdc.h index cee1fed62..a00f59cd6 100644 --- a/src/include/86box/fdc.h +++ b/src/include/86box/fdc.h @@ -22,7 +22,7 @@ #ifndef EMU_FDC_H #define EMU_FDC_H -extern int fdc_type; +extern int fdc_current[2]; #define FDC_PRIMARY_ADDR 0x03f0 #define FDC_PRIMARY_IRQ 6 diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h index 2c46d0704..2467b4901 100644 --- a/src/include/86box/fdc_ext.h +++ b/src/include/86box/fdc_ext.h @@ -22,7 +22,7 @@ #ifndef EMU_FDC_EXT_H #define EMU_FDC_EXT_H -extern int fdc_type; +extern int fdc_current[2]; /* Controller types. */ #define FDC_NONE 0 diff --git a/src/machine/m_at.c b/src/machine/m_at.c index 9fc53ebcd..7b133a822 100644 --- a/src/machine/m_at.c +++ b/src/machine/m_at.c @@ -105,7 +105,7 @@ machine_at_ibm_common_init(const machine_t *model) mem_remap_top(384); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); } @@ -252,7 +252,7 @@ machine_at_siemens_init(const machine_t *model) mem_remap_top(384); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index a1c3d7772..9e9186040 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -59,7 +59,7 @@ machine_at_mr286_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -70,7 +70,7 @@ machine_at_headland_common_init(int type) { device_add(&keyboard_at_ami_device); - if ((type != 2) && (fdc_type == FDC_INTERNAL)) + if ((type != 2) && (fdc_current[0] == FDC_INTERNAL)) device_add(&fdc_at_device); if (type == 2) @@ -137,7 +137,7 @@ machine_at_quadt286_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&headland_gc10x_device); @@ -160,7 +160,7 @@ machine_at_quadt386sx_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&headland_gc10x_device); @@ -183,7 +183,7 @@ machine_at_neat_init(const machine_t *model) device_add(&neat_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -204,7 +204,7 @@ machine_at_neat_ami_init(const machine_t *model) device_add(&neat_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&keyboard_at_ami_device); @@ -226,7 +226,7 @@ machine_at_px286_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&neat_device); @@ -248,7 +248,7 @@ machine_at_micronics386_init(const machine_t *model) machine_at_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -284,7 +284,7 @@ machine_at_scatsx_init(const machine_t *model) device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&scat_sx_device); @@ -303,7 +303,7 @@ machine_at_award286_init(const machine_t *model) machine_at_scat_init(model, 0, 1); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&ide_isa_device); @@ -324,7 +324,7 @@ machine_at_gdc212m_init(const machine_t *model) machine_at_scat_init(model, 0, 1); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&ide_isa_device); @@ -365,7 +365,7 @@ machine_at_senor_scat286_init(const machine_t *model) machine_at_scat_init(model, 0, 1); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -386,7 +386,7 @@ machine_at_super286c_init(const machine_t *model) device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&neat_device); @@ -407,7 +407,7 @@ machine_at_super286tr_init(const machine_t *model) machine_at_scat_init(model, 0, 1); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -426,7 +426,7 @@ machine_at_spc4200p_init(const machine_t *model) machine_at_scat_init(model, 0, 1); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&ide_isa_device); @@ -448,7 +448,7 @@ machine_at_spc4216p_init(const machine_t *model) machine_at_scat_init(model, 1, 1); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -471,7 +471,7 @@ machine_at_spc4620p_init(const machine_t *model) machine_at_scat_init(model, 1, 1); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&ide_isa_device); @@ -508,7 +508,7 @@ machine_at_deskmaster286_init(const machine_t *model) machine_at_scat_init(model, 0, 1); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&ide_isa_device); @@ -533,7 +533,7 @@ machine_at_shuttle386sx_init(const machine_t *model) device_add(&intel_82335_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -557,7 +557,7 @@ machine_at_adi386sx_init(const machine_t *model) device_add(&intel_82335_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -603,7 +603,7 @@ machine_at_cmdsl386sx16_init(const machine_t *model) device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&neat_device); @@ -624,7 +624,7 @@ machine_at_scamp_common_init(const machine_t *model, int is_ps2) else device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&vlsi_scamp_device); @@ -699,7 +699,7 @@ machine_at_awardsx_init(const machine_t *model) device_add(&opti291_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -718,7 +718,7 @@ machine_at_acer100t_init(const machine_t *model) machine_at_ps2_ide_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&ali1409_device); @@ -896,7 +896,7 @@ machine_at_pc8_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_ncr_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -921,7 +921,7 @@ machine_at_3302_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&neat_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); if (gfxcard[0] == VID_INTERNAL) @@ -953,7 +953,7 @@ machine_at_pc916sx_init(const machine_t *model) device_add(&keyboard_at_ncr_device); mem_remap_top(384); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -975,7 +975,7 @@ machine_at_m290_init(const machine_t *model) device_add(&keyboard_at_olivetti_device); device_add(&port_6x_olivetti_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&olivetti_eva_device); diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 1a6a6db67..07ed218ff 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -63,7 +63,7 @@ machine_at_acc386_init(const machine_t *model) device_add(&acc2168_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -84,7 +84,7 @@ machine_at_asus386_init(const machine_t *model) device_add(&rabbit_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -104,7 +104,7 @@ machine_at_tandy4000_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -117,7 +117,7 @@ machine_at_sis401_common_init(const machine_t *model) device_add(&sis_85c401_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); } @@ -168,7 +168,7 @@ machine_at_av4_init(const machine_t *model) device_add(&sis_85c460_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -192,7 +192,7 @@ machine_at_valuepoint433_init(const machine_t *model) // hangs without the PS/2 device_add(&keyboard_ps2_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -213,7 +213,7 @@ machine_at_ecs386_init(const machine_t *model) machine_at_common_init(model); device_add(&cs8230_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&keyboard_at_ami_device); @@ -236,7 +236,7 @@ machine_at_spc6000a_init(const machine_t *model) machine_at_common_init_ex(model, 1); device_add(&cs8230_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&keyboard_at_ami_device); @@ -259,7 +259,7 @@ machine_at_ecs386v_init(const machine_t *model) device_add(&ali1429_device); device_add(&keyboard_ps2_intel_ami_pci_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -281,7 +281,7 @@ machine_at_rycleopardlx_init(const machine_t *model) device_add(&opti283_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -303,7 +303,7 @@ machine_at_486vchd_init(const machine_t *model) device_add(&via_vt82c49x_device); device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -324,7 +324,7 @@ machine_at_cs4031_init(const machine_t *model) device_add(&cs4031_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -448,7 +448,7 @@ machine_at_acerv10_init(const machine_t *model) device_add(&keyboard_ps2_acer_pci_device); device_add(&ide_isa_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -492,7 +492,7 @@ machine_at_ali1429_common_init(const machine_t *model, int is_green) device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); } @@ -545,7 +545,7 @@ machine_at_opti495_init(const machine_t *model) device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -560,7 +560,7 @@ machine_at_opti495_ami_common_init(const machine_t *model) device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); } @@ -612,7 +612,7 @@ machine_at_exp4349_init(const machine_t *model) device_add(&ali1429g_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; } @@ -630,7 +630,7 @@ machine_at_403tg_common_init(const machine_t *model, int nvr_hack) device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); } @@ -801,7 +801,7 @@ machine_at_sis_85c471_common_init(const machine_t *model) { machine_at_common_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&sis_85c471_device); @@ -920,7 +920,7 @@ machine_at_pci400ca_init(const machine_t *model) device_add(&i420tx_device); device_add(&ncr53c810_onboard_pci_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -956,7 +956,7 @@ machine_at_greenb_init(const machine_t *model) machine_at_common_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&contaq_82c597_device); @@ -979,7 +979,7 @@ machine_at_4gpv5_init(const machine_t *model) machine_at_common_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&contaq_82c596a_device); @@ -1417,7 +1417,7 @@ machine_at_pci400cb_init(const machine_t *model) device_add(&ims8848_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -1446,7 +1446,7 @@ machine_at_g486ip_init(const machine_t *model) device_add(&ims8848_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -1506,7 +1506,7 @@ machine_at_486ap4_init(const machine_t *model) pci_register_slot(0x0c, PCI_CARD_NORMAL, 4, 1, 2, 3); /* 0c = Slot 4 */ device_add(&keyboard_ps2_ami_pci_device); /* Uses the AMIKEY KBC */ - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&i420ex_device); @@ -1986,7 +1986,7 @@ machine_at_atc1415_init(const machine_t *model) device_add(&intel_flash_bxt_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -2247,7 +2247,7 @@ machine_at_ecsal486_init(const machine_t *model) device_add(&ali1429g_device); device_add(&keyboard_ps2_ami_pci_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -2290,9 +2290,8 @@ machine_at_atc1762_init(const machine_t *model) device_add(&ali1429g_device); device_add(&keyboard_ps2_ami_pci_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); - return ret; } diff --git a/src/machine/m_at_commodore.c b/src/machine/m_at_commodore.c index a0b522371..0b45fe60c 100644 --- a/src/machine/m_at_commodore.c +++ b/src/machine/m_at_commodore.c @@ -112,7 +112,7 @@ machine_at_cmdpc_init(const machine_t *model) mem_remap_top(384); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); cmd_uart = device_add(&ns8250_device); diff --git a/src/machine/m_at_compaq.c b/src/machine/m_at_compaq.c index b628ea095..2d4597007 100644 --- a/src/machine/m_at_compaq.c +++ b/src/machine/m_at_compaq.c @@ -779,7 +779,7 @@ machine_at_compaq_init(const machine_t *model, int type) { compaq_machine_type = type; - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); if (type < COMPAQ_PORTABLEIII386) { diff --git a/src/machine/m_at_socket4.c b/src/machine/m_at_socket4.c index f7aad92ec..e39ab87be 100644 --- a/src/machine/m_at_socket4.c +++ b/src/machine/m_at_socket4.c @@ -293,7 +293,7 @@ machine_at_award_common_init(const machine_t *model) pci_register_slot(0x07, PCI_CARD_SCSI, 1, 2, 3, 4); /* 07 = SCSI */ pci_register_slot(0x02, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&keyboard_ps2_ami_pci_device); @@ -402,7 +402,7 @@ machine_at_p5vl_init(const machine_t *model) device_add(&sst_flash_29ee010_device); device_add(&keyboard_at_ami_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; diff --git a/src/machine/m_at_socket5.c b/src/machine/m_at_socket5.c index ff59ec65f..3afd96ca7 100644 --- a/src/machine/m_at_socket5.c +++ b/src/machine/m_at_socket5.c @@ -370,7 +370,7 @@ machine_at_pat54pv_init(const machine_t *model) device_add(&opti5x7_device); device_add(&keyboard_ps2_intel_ami_pci_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -400,7 +400,7 @@ machine_at_hot543_init(const machine_t *model) device_add(&sst_flash_29ee010_device); device_add(&keyboard_at_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); return ret; diff --git a/src/machine/m_at_t3100e.c b/src/machine/m_at_t3100e.c index e3e24cf2c..357f012f2 100644 --- a/src/machine/m_at_t3100e.c +++ b/src/machine/m_at_t3100e.c @@ -815,7 +815,7 @@ machine_at_t3100e_init(const machine_t *model) device_add(&keyboard_at_toshiba_device); - if (fdc_type == FDC_INTERNAL) { + if (fdc_current[0] == FDC_INTERNAL) { device_add(&fdc_at_device); } diff --git a/src/machine/m_elt.c b/src/machine/m_elt.c index a69b62184..812755898 100644 --- a/src/machine/m_elt.c +++ b/src/machine/m_elt.c @@ -178,7 +178,7 @@ machine_elt_init(const machine_t *model) pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_device); if (gfxcard[0] == VID_INTERNAL) { diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index 8ad69e314..cb83d9be7 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -1395,7 +1395,7 @@ machine_ps2_common_init(const machine_t *model) { machine_common_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); dma16_init(); diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index 437ac7d54..e677ff8b4 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -1738,7 +1738,7 @@ machine_tandy1k_init(const machine_t *model, int type) device_add(&keyboard_tandy_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_tandy_device); video_reset(gfxcard[0]); diff --git a/src/machine/m_v86p.c b/src/machine/m_v86p.c index 5d132a839..f8358a8ff 100644 --- a/src/machine/m_v86p.c +++ b/src/machine/m_v86p.c @@ -88,7 +88,7 @@ machine_v86p_init(const machine_t *model) device_add(&keyboard_xt_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_device); if (gfxcard[0] == VID_INTERNAL) diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index adca9f4de..355f45b23 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -25,7 +25,7 @@ extern const device_t vendex_xt_rtc_onboard_device; static void machine_xt_common_init(const machine_t *model, int fixed_floppy) { - if ((fdc_type == FDC_INTERNAL) || fixed_floppy) + if ((fdc_current[0] == FDC_INTERNAL) || fixed_floppy) device_add(&fdc_xt_device); machine_common_init(model); diff --git a/src/machine/m_xt_compaq.c b/src/machine/m_xt_compaq.c index f5dca48a7..ed1b3e26c 100644 --- a/src/machine/m_xt_compaq.c +++ b/src/machine/m_xt_compaq.c @@ -53,7 +53,7 @@ machine_xt_compaq_deskpro_init(const machine_t *model) pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt); device_add(&keyboard_xt_compaq_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_device); nmi_init(); standalone_gameport_type = &gameport_device; @@ -80,7 +80,7 @@ machine_xt_compaq_portable_init(const machine_t *model) pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt); device_add(&keyboard_xt_compaq_device); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_device); nmi_init(); if (joystick_type) diff --git a/src/machine/m_xt_laserxt.c b/src/machine/m_xt_laserxt.c index 87c2fe362..877d26ff5 100644 --- a/src/machine/m_xt_laserxt.c +++ b/src/machine/m_xt_laserxt.c @@ -147,7 +147,7 @@ machine_xt_laserxt_common_init(const machine_t *model,int is_lxt3) pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_device); nmi_init(); diff --git a/src/machine/m_xt_olivetti.c b/src/machine/m_xt_olivetti.c index 172880361..94c7376c8 100644 --- a/src/machine/m_xt_olivetti.c +++ b/src/machine/m_xt_olivetti.c @@ -2317,7 +2317,7 @@ machine_xt_m24_init(const machine_t *model) machine_common_init(model); /* On-board FDC can be disabled only on M24SP */ - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_device); /* Address 66-67 = mainboard dip-switch settings */ @@ -2393,7 +2393,7 @@ machine_xt_m240_init(const machine_t *model) m24_kbd_init(m24_kbd); device_add_ex(&m24_kbd_device, m24_kbd); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); /* io.c logs clearly show it using port 3F7 */ if (joystick_type) diff --git a/src/machine/m_xt_xi8088.c b/src/machine/m_xt_xi8088.c index 3f07e6a4e..8515ea27a 100644 --- a/src/machine/m_xt_xi8088.c +++ b/src/machine/m_xt_xi8088.c @@ -201,7 +201,7 @@ machine_xt_xi8088_init(const machine_t *model) machine_common_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&keyboard_ps2_xi8088_device); diff --git a/src/machine/m_xt_zenith.c b/src/machine/m_xt_zenith.c index 0da091917..f5e231772 100644 --- a/src/machine/m_xt_zenith.c +++ b/src/machine/m_xt_zenith.c @@ -140,7 +140,7 @@ machine_xt_z184_init(const machine_t *model) machine_zenith_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_device); lpt1_remove(); /* only one parallel port */ @@ -170,7 +170,7 @@ machine_xt_z151_init(const machine_t *model) machine_zenith_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_tandy_device); return ret; @@ -193,7 +193,7 @@ machine_xt_z159_init(const machine_t *model) machine_zenith_init(model); - if (fdc_type == FDC_INTERNAL) + if (fdc_current[0] == FDC_INTERNAL) device_add(&fdc_xt_tandy_device); /* parallel port is on the memory board */ diff --git a/src/qt/qt_settingsstoragecontrollers.cpp b/src/qt/qt_settingsstoragecontrollers.cpp index fa02ce613..ff30696c4 100644 --- a/src/qt/qt_settingsstoragecontrollers.cpp +++ b/src/qt/qt_settingsstoragecontrollers.cpp @@ -57,7 +57,7 @@ SettingsStorageControllers::save() scsi_card_current[i] = cbox->currentData().toInt(); } hdc_current = ui->comboBoxHD->currentData().toInt(); - fdc_type = ui->comboBoxFD->currentData().toInt(); + fdc_current[0] = ui->comboBoxFD->currentData().toInt(); cdrom_interface_current = ui->comboBoxCDInterface->currentData().toInt(); ide_ter_enabled = ui->checkBoxTertiaryIDE->isChecked() ? 1 : 0; ide_qua_enabled = ui->checkBoxQuaternaryIDE->isChecked() ? 1 : 0; @@ -128,7 +128,7 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId) if (device_is_valid(fdc_dev, machineId)) { int row = Models::AddEntry(model, name, c); - if (c == fdc_type) { + if (c == fdc_current[0]) { selectedRow = row - removeRows; } } From 539dccdcd169abe65e136a4da8b657a57a7556f7 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 20 Jul 2024 01:39:07 -0400 Subject: [PATCH 08/12] Simplify sound_card_init() by using a loop --- src/sound/sound.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/sound/sound.c b/src/sound/sound.c index 4820c45f9..254e529ca 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -221,14 +221,9 @@ sound_card_get_from_internal_name(const char *s) void sound_card_init(void) { - if ((sound_card_current[0] > SOUND_INTERNAL) && (sound_cards[sound_card_current[0]].device)) - device_add_inst(sound_cards[sound_card_current[0]].device, 1); - if ((sound_card_current[1] > SOUND_INTERNAL) && (sound_cards[sound_card_current[1]].device)) - device_add_inst(sound_cards[sound_card_current[1]].device, 2); - if ((sound_card_current[2] > SOUND_INTERNAL) && (sound_cards[sound_card_current[2]].device)) - device_add_inst(sound_cards[sound_card_current[2]].device, 3); - if ((sound_card_current[3] > SOUND_INTERNAL) && (sound_cards[sound_card_current[3]].device)) - device_add_inst(sound_cards[sound_card_current[3]].device, 4); + for (uint8_t i = 0; i < SOUND_CARD_MAX; i++) + if ((sound_card_current[i] > SOUND_INTERNAL) && (sound_cards[sound_card_current[i]].device)) + device_add_inst(sound_cards[sound_card_current[i]].device, i + 1); } void From 680f65cf1948cc483e535a0bb266676329643ea1 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 20 Jul 2024 03:08:04 -0400 Subject: [PATCH 09/12] 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; } } From 7817336567f211269f52b99aa2eeca2e2ba54cc5 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 20 Jul 2024 20:02:34 -0400 Subject: [PATCH 10/12] Use a define for max FDC's --- src/floppy/fdc.c | 2 +- src/include/86box/config.h | 2 +- src/include/86box/fdc.h | 2 -- src/include/86box/fdc_ext.h | 4 +++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 756f43448..bce34e327 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -77,7 +77,7 @@ int lastbyte = 0; int floppymodified[4]; int floppyrate[4]; -int fdc_current[2] = { 0, 0 }; +int fdc_current[FDC_MAX] = { 0, 0 }; #ifdef ENABLE_FDC_LOG int fdc_do_log = ENABLE_FDC_LOG; diff --git a/src/include/86box/config.h b/src/include/86box/config.h index d0b2857e7..4691686c7 100644 --- a/src/include/86box/config.h +++ b/src/include/86box/config.h @@ -113,7 +113,7 @@ typedef struct config_t { # endif /* Other peripherals category */ - int fdc_current[2]; /* Floppy disk controller type */ + int fdc_current[FDC_MAX]; /* Floppy disk controller type */ int hdc_current[2]; /* Hard disk controller type */ int hdc; /* Hard disk controller */ int scsi_card; /* SCSI controller */ diff --git a/src/include/86box/fdc.h b/src/include/86box/fdc.h index a00f59cd6..e03785df6 100644 --- a/src/include/86box/fdc.h +++ b/src/include/86box/fdc.h @@ -22,8 +22,6 @@ #ifndef EMU_FDC_H #define EMU_FDC_H -extern int fdc_current[2]; - #define FDC_PRIMARY_ADDR 0x03f0 #define FDC_PRIMARY_IRQ 6 #define FDC_PRIMARY_DMA 2 diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h index 2467b4901..188881f77 100644 --- a/src/include/86box/fdc_ext.h +++ b/src/include/86box/fdc_ext.h @@ -22,7 +22,9 @@ #ifndef EMU_FDC_EXT_H #define EMU_FDC_EXT_H -extern int fdc_current[2]; +#define FDC_MAX 2 + +extern int fdc_current[FDC_MAX]; /* Controller types. */ #define FDC_NONE 0 From 2a7d300078dff5fb2bb3fe52ba32acf27f4c73c4 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 20 Jul 2024 20:05:00 -0400 Subject: [PATCH 11/12] Use a define for max HDC's --- src/disk/hdc.c | 2 +- src/include/86box/config.h | 2 +- src/include/86box/hdc.h | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/disk/hdc.c b/src/disk/hdc.c index 08a290aef..908cbce07 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[2]; +int hdc_current[HDC_MAX] = { 0, 0 }; #ifdef ENABLE_HDC_LOG int hdc_do_log = ENABLE_HDC_LOG; diff --git a/src/include/86box/config.h b/src/include/86box/config.h index 4691686c7..a043fb22a 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[FDC_MAX]; /* Floppy disk controller type */ - int hdc_current[2]; /* Hard disk controller type */ + int hdc_current[HDC_MAX]; /* 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 8e09119bf..48235bb1e 100644 --- a/src/include/86box/hdc.h +++ b/src/include/86box/hdc.h @@ -32,7 +32,9 @@ #define HDC_NONE 0 #define HDC_INTERNAL 1 -extern int hdc_current[2]; +#define HDC_MAX 2 + +extern int hdc_current[HDC_MAX]; extern const device_t st506_xt_xebec_device; /* st506_xt_xebec */ extern const device_t st506_xt_wdxt_gen_device; /* st506_xt_wdxt_gen */ From 1ebbc25c2a39a69703d3256748f9a5b630e9ac0f Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 20 Jul 2024 20:09:17 -0400 Subject: [PATCH 12/12] Correct endif comment in fdc_ext.h --- src/include/86box/fdc_ext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h index 188881f77..4b33ed7a1 100644 --- a/src/include/86box/fdc_ext.h +++ b/src/include/86box/fdc_ext.h @@ -44,4 +44,4 @@ extern const device_t *fdc_card_getdevice(int card); extern int fdc_card_has_config(int card); extern int fdc_card_available(int card); -#endif /*EMU_FDC_H*/ +#endif /*EMU_FDC_EXT_H*/