From a0a7ee67ccb4b400e3f2c8c7697ea3d5ebe56347 Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:27:14 +0200 Subject: [PATCH 1/4] FDC workaround The Internal FDC is added when needed for AT machines too. Some speculative "work" on the main FDC code --- src/floppy/fdc.c | 2 +- src/floppy/fdc_magitronic.c | 2 +- src/floppy/fdc_pii15xb.c | 4 ++-- src/machine/m_at_286_386sx.c | 39 ++++++++++++++++++++++++++++++++++++ src/machine/m_at_386dx_486.c | 39 +++++++++++++++++++++++++++++++++++- src/machine/m_at_commodore.c | 3 +++ src/machine/m_at_socket4_5.c | 4 ++++ src/machine/m_at_t3100e.c | 7 ++++++- src/machine/m_ps2_mca.c | 3 +++ src/machine/m_xt_laserxt.c | 3 +++ src/machine/m_xt_olivetti.c | 4 ++++ src/machine/m_xt_xi8088.c | 4 ++++ 12 files changed, 108 insertions(+), 6 deletions(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 459370724..6fd73d57b 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -2326,7 +2326,7 @@ fdc_3f1_enable(fdc_t *fdc, int enable) const device_t fdc_xt_device = { "PC/XT Floppy Drive Controller", 0, - 0, + FDC_FLAG_AT, fdc_init, fdc_close, fdc_reset, diff --git a/src/floppy/fdc_magitronic.c b/src/floppy/fdc_magitronic.c index 3b7ceb64d..bdc8149ef 100644 --- a/src/floppy/fdc_magitronic.c +++ b/src/floppy/fdc_magitronic.c @@ -56,7 +56,7 @@ b215_init(const device_t *info) rom_init(&dev->rom, ROM_B215, ROM_ADDR, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL); - device_add(&fdc_at_device); + device_add(&fdc_xt_device); return dev; } diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c index 1a6fc8fad..cf97a1fba 100644 --- a/src/floppy/fdc_pii15xb.c +++ b/src/floppy/fdc_pii15xb.c @@ -54,7 +54,7 @@ MiniMicro 4 uses a Zilog Z0765A08PSC(Clone of the NEC 765) MiniMicro 1 uses a National Semiconductor DP8473(Clone of the NEC 765 with additional NSC commands) Issues: -MiniMicro 4 WON'T WORK with XT machines. This statement has to be confirmed by someone with the real card itself. +MiniMicro 4 works only with a few XT machines. This statement has to be confirmed by someone with the real card itself. MiniMicro 4 also won't work with the XT FDC which the Zilog claims to be. */ @@ -77,7 +77,7 @@ MiniMicro 4 also won't work with the XT FDC which the Zilog claims to be. #include <86box/fdc_ext.h> #define DTK_VARIANT ((info->local == 158) ? ROM_PII_158B : ROM_PII_151B) -#define DTK_CHIP ((info->local == 158) ? &fdc_at_device : &fdc_dp8473_device) +#define DTK_CHIP ((info->local == 158) ? &fdc_xt_device : &fdc_dp8473_device) #define BIOS_ADDR (uint32_t)(device_get_config_hex20("bios_addr") & 0x000fffff) #define ROM_PII_151B L"roms/floppy/dtk/pii-151b.rom" #define ROM_PII_158B L"roms/floppy/dtk/pii-158b.rom" diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index 9aac75d6a..274eedad0 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -35,6 +35,7 @@ #include <86box/rom.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/hdc.h> #include <86box/sio.h> #include <86box/serial.h> @@ -56,6 +57,8 @@ machine_at_mr286_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&keyboard_at_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -66,6 +69,8 @@ static void machine_at_headland_common_init(int ht386) { device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); if (ht386) @@ -136,7 +141,10 @@ machine_at_quadt286_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); + device_add(&headland_gc10x_device); return ret; @@ -157,6 +165,8 @@ machine_at_neat_init(const machine_t *model) machine_at_init(model); device_add(&neat_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -177,6 +187,8 @@ machine_at_neat_ami_init(const machine_t *model) machine_at_common_init(model); device_add(&neat_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&keyboard_at_ami_device); @@ -198,7 +210,10 @@ machine_at_px286_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); + device_add(&neat_device); return ret; @@ -219,6 +234,8 @@ machine_at_micronics386_init(const machine_t *model) machine_at_init(model); device_add(&neat_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -230,6 +247,8 @@ machine_at_scat_init(const machine_t *model, int is_v4) { machine_at_common_init(model); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); if (is_v4) @@ -245,6 +264,8 @@ machine_at_scatsx_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&scat_sx_device); @@ -434,6 +455,8 @@ machine_at_shuttle386sx_init(const machine_t *model) device_add(&intel_82335_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -456,6 +479,8 @@ machine_at_adi386sx_init(const machine_t *model) device_add(&intel_82335_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -502,7 +527,10 @@ machine_at_commodore_sl386sx16_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&keyboard_at_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); + device_add(&neat_device); /* Two serial ports - on the real hardware SL386SX-16, they are on the single UMC UM82C452. */ device_add_inst(&ns16450_device, 1); @@ -518,7 +546,10 @@ machine_at_scamp_common_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&keyboard_ps2_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); + device_add(&vlsi_scamp_device); } @@ -591,6 +622,8 @@ machine_at_awardsx_init(const machine_t *model) machine_at_init(model); device_add(&opti291_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -704,6 +737,8 @@ machine_at_olim290_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); io_sethandler(0x069, 1, m290_read, NULL, NULL, NULL, NULL, NULL, NULL); @@ -730,6 +765,8 @@ machine_at_ncrpc8_init(const machine_t *model) machine_at_common_init(model); device_add(&keyboard_at_ncr_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -758,6 +795,8 @@ machine_at_ncr3302_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&neat_device); device_add(&keyboard_at_ncr_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); if (gfxcard == VID_INTERNAL) diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index a0f8494b3..6cbfa1fa1 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -34,6 +34,7 @@ #include <86box/pci.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/rom.h> #include <86box/sio.h> #include <86box/hdc.h> @@ -57,6 +58,8 @@ machine_at_acc386_init(const machine_t *model) machine_at_common_init(model); device_add(&acc2168_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -77,6 +80,8 @@ machine_at_asus386_init(const machine_t *model) machine_at_common_init(model); device_add(&rabbit_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -97,6 +102,8 @@ machine_at_sis401_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&sis_85c401_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -117,6 +124,8 @@ machine_at_av4_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&sis_85c460_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -137,6 +146,8 @@ machine_at_valuepoint433_init(const machine_t *model) // hangs without the PS/2 machine_at_common_ide_init(model); device_add(&sis_85c461_device); device_add(&keyboard_ps2_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -157,7 +168,10 @@ machine_at_ecs386_init(const machine_t *model) machine_at_common_init(model); device_add(&cs8230_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); + device_add(&keyboard_at_ami_device); return ret; @@ -178,7 +192,10 @@ machine_at_spc6000a_init(const machine_t *model) machine_at_common_init_ex(model, 1); device_add(&cs8230_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); + device_add(&keyboard_at_samsung_device); return ret; @@ -200,6 +217,8 @@ machine_at_rycleopardlx_init(const machine_t *model) device_add(&opti283_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -221,6 +240,8 @@ machine_at_486vchd_init(const machine_t *model) device_add(&via_vt82c49x_device); device_add(&keyboard_at_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -241,6 +262,8 @@ machine_at_cs4031_init(const machine_t *model) machine_at_common_init(model); device_add(&cs4031_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -326,9 +349,11 @@ machine_at_acera1g_init(const machine_t *model) device_add(&ali1429_device); device_add(&keyboard_ps2_acer_pci_device); - device_add(&fdc_at_device); device_add(&ide_isa_2ch_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_at_device); + return ret; } @@ -348,6 +373,8 @@ machine_at_ali1429_common_init(const machine_t *model) device_add(&ali1429_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); } @@ -402,6 +429,8 @@ machine_at_opti495_init(const machine_t *model) device_add(&opti495_device); device_add(&keyboard_at_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -416,6 +445,8 @@ machine_at_opti495_ami_common_init(const machine_t *model) device_add(&opti495_device); device_add(&keyboard_at_ami_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); } @@ -469,6 +500,8 @@ machine_at_403tg_init(const machine_t *model) device_add(&opti895_device); device_add(&keyboard_at_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); return ret; @@ -522,6 +555,8 @@ static void machine_at_sis_85c471_common_init(const machine_t *model) { machine_at_common_init(model); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); device_add(&sis_85c471_device); @@ -884,6 +919,8 @@ machine_at_486ap4_init(const machine_t *model) pci_register_slot(0x0b, PCI_CARD_NORMAL, 3, 4, 1, 2); /* 0b = Slot 3 */ 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) device_add(&fdc_at_device); device_add(&i420ex_device); diff --git a/src/machine/m_at_commodore.c b/src/machine/m_at_commodore.c index 51f8e56b4..eaf847602 100644 --- a/src/machine/m_at_commodore.c +++ b/src/machine/m_at_commodore.c @@ -45,6 +45,7 @@ #include <86box/timer.h> #include <86box/io.h> #include <86box/mem.h> +#include <86box/fdc_ext.h> #include <86box/lpt.h> #include <86box/rom.h> #include <86box/serial.h> @@ -108,7 +109,9 @@ machine_at_cmdpc_init(const machine_t *model) mem_remap_top(384); + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); + cmd_uart = device_add(&i8250_device); cbm_io_init(); diff --git a/src/machine/m_at_socket4_5.c b/src/machine/m_at_socket4_5.c index 84c6e97d2..3fdea739d 100644 --- a/src/machine/m_at_socket4_5.c +++ b/src/machine/m_at_socket4_5.c @@ -28,6 +28,7 @@ #include <86box/pci.h> #include <86box/device.h> #include <86box/chipset.h> +#include <86box/fdc_ext.h> #include <86box/hdc.h> #include <86box/hdc_ide.h> #include <86box/timer.h> @@ -98,7 +99,10 @@ machine_at_award_common_init(const machine_t *model) pci_register_slot(0x06, PCI_CARD_NORMAL, 4, 1, 2, 3); /* 06 = Slot 4 */ 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) device_add(&fdc_at_device); + device_add(&keyboard_ps2_pci_device); } diff --git a/src/machine/m_at_t3100e.c b/src/machine/m_at_t3100e.c index a5a7b9903..d04c4e2a0 100644 --- a/src/machine/m_at_t3100e.c +++ b/src/machine/m_at_t3100e.c @@ -163,6 +163,7 @@ #include "cpu.h" #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/machine.h> #include <86box/m_at_t3100e.h> @@ -761,8 +762,12 @@ int machine_at_t3100e_init(const machine_t *model) machine_at_common_ide_init(model); device_add(&keyboard_at_toshiba_device); - device_add(&fdc_at_device); + if (fdc_type == FDC_INTERNAL) + { + device_add(&fdc_at_device); + } + /* Hook up system control port */ io_sethandler(0x8084, 0x0001, t3100e_sys_in, NULL, NULL, diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index 3295fc884..bb87bfb85 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -57,6 +57,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/nvr.h> #include <86box/nvr_ps2.h> #include <86box/keyboard.h> @@ -1259,6 +1260,8 @@ static void machine_ps2_common_init(const machine_t *model) { machine_common_init(model); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); dma16_init(); diff --git a/src/machine/m_xt_laserxt.c b/src/machine/m_xt_laserxt.c index 20c0e21ff..6b360353d 100644 --- a/src/machine/m_xt_laserxt.c +++ b/src/machine/m_xt_laserxt.c @@ -16,6 +16,7 @@ #include <86box/timer.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/keyboard.h> @@ -169,6 +170,8 @@ machine_xt_lxt3_init(const machine_t *model) pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); device_add(&keyboard_xt_lxt3_device); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_xt_device); nmi_init(); if (joystick_type) diff --git a/src/machine/m_xt_olivetti.c b/src/machine/m_xt_olivetti.c index a2f3d2725..cd0790a3c 100644 --- a/src/machine/m_xt_olivetti.c +++ b/src/machine/m_xt_olivetti.c @@ -724,6 +724,8 @@ machine_xt_olim24_init(const machine_t *model) memset(m24_kbd, 0x00, sizeof(olim24_kbd_t)); machine_common_init(model); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_xt_device); /* Address 66-67 = mainboard dip-switch settings */ @@ -809,6 +811,8 @@ machine_xt_olim19_init(const machine_t *model) memset(vid, 0x00, sizeof(olim19_vid_t)); machine_common_init(model); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_xt_device); m19_vid_init(vid); diff --git a/src/machine/m_xt_xi8088.c b/src/machine/m_xt_xi8088.c index 39fe5e2cf..93948bddf 100644 --- a/src/machine/m_xt_xi8088.c +++ b/src/machine/m_xt_xi8088.c @@ -11,6 +11,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/nmi.h> #include <86box/nvr.h> #include <86box/gameport.h> @@ -172,7 +173,10 @@ machine_xt_xi8088_init(const machine_t *model) /* TODO: set UMBs? See if PCem always sets when we have > 640KB ram and avoids conflicts when a peripheral uses the same memory space */ machine_common_init(model); + + if (fdc_type == FDC_INTERNAL) device_add(&fdc_at_device); + device_add(&keyboard_ps2_xi8088_device); nmi_init(); device_add(&ibmat_nvr_device); From 259db0979eb6455472d12d8b1de6f7283bf51f9c Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sun, 7 Feb 2021 19:18:15 +0200 Subject: [PATCH 2/4] Reverted the XT FDC with no flags Turns out it was working as intended --- src/floppy/fdc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 6fd73d57b..459370724 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -2326,7 +2326,7 @@ fdc_3f1_enable(fdc_t *fdc, int enable) const device_t fdc_xt_device = { "PC/XT Floppy Drive Controller", 0, - FDC_FLAG_AT, + 0, fdc_init, fdc_close, fdc_reset, From 3d5072dab2bf1a8427e2479e025ec1e87ffbff56 Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Mon, 8 Feb 2021 18:01:43 +0200 Subject: [PATCH 3/4] Implemented the Magitronics B215 Jumper Readout Also added a preliminary UMC 8398 --- src/floppy/fdc.c | 27 ++++++++++++++++++--- src/floppy/fdc_magitronic.c | 47 ++++++++++++++++++++++++++++++++++++- src/include/86box/fdc.h | 2 ++ 3 files changed, 72 insertions(+), 4 deletions(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 459370724..d87193538 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -1245,7 +1245,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) } return; case 7: - if (!(fdc->flags & FDC_FLAG_TOSHIBA) && !(fdc->flags & FDC_FLAG_AT)) + if (!(fdc->flags & FDC_FLAG_TOSHIBA) && !(fdc->flags & FDC_FLAG_AT) && !(fdc->flags & FDC_FLAG_UMC)) return; fdc->rate = val & 0x03; if (fdc->flags & FDC_FLAG_PS1) @@ -1294,7 +1294,7 @@ fdc_read(uint16_t addr, void *priv) ret = 0x00; /* -Drive 2 Installed */ if (!fdd_get_type(1)) - ret |= 80; + ret |= 0x80; /* -Drive Select 1,0 */ switch (drive) { case 0: @@ -1313,6 +1313,12 @@ fdc_read(uint16_t addr, void *priv) } else { if (is486 || !fdc->enable_3f1) ret = 0xff; + else{ + if(fdc->flags & FDC_FLAG_UMC) + { + drive = real_drive(fdc, fdc->dor & 1); + ret = !fdd_is_dd(drive) ? ((fdc->dor & 1) ? 2 : 1) : 0; + } else { ret = 0x70; @@ -1328,6 +1334,7 @@ fdc_read(uint16_t addr, void *priv) if (fdc->dor & 0x20) ret |= 2; } + } } break; case 2: @@ -2173,10 +2180,12 @@ fdc_set_base(fdc_t *fdc, int base) if (fdc->flags & FDC_FLAG_PCJR) io_sethandler(base, 0x0010, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); else { + if(fdc->flags & FDC_FLAG_UMC) + io_sethandler(base + 0x0001, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc); io_sethandler(base + 0x0002, 0x0001, NULL, NULL, NULL, fdc_write, NULL, NULL, fdc); io_sethandler(base + 0x0004, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc); io_sethandler(base + 0x0005, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); - if (fdc->flags & FDC_FLAG_TOSHIBA) + if ((fdc->flags & FDC_FLAG_TOSHIBA) || (fdc->flags & FDC_FLAG_UMC)) io_sethandler(base + 0x0007, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); } } @@ -2198,6 +2207,8 @@ fdc_remove(fdc_t *fdc) if (fdc->flags & FDC_FLAG_PCJR) io_removehandler(fdc->base_address, 0x0010, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); else { + if(fdc->flags & FDC_FLAG_UMC) + io_removehandler(fdc->base_address + 0x0001, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc); io_removehandler(fdc->base_address + 0x0002, 0x0001, NULL, NULL, NULL, fdc_write, NULL, NULL, fdc); io_removehandler(fdc->base_address + 0x0004, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc); io_removehandler(fdc->base_address + 0x0005, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); @@ -2433,3 +2444,13 @@ const device_t fdc_dp8473_device = { fdc_reset, { NULL }, NULL, NULL }; + +const device_t fdc_um8398_device = { + "UMC UM8398 Floppy Drive Controller", + 0, + FDC_FLAG_UMC, + fdc_init, + fdc_close, + fdc_reset, + { NULL }, NULL, NULL +}; diff --git a/src/floppy/fdc_magitronic.c b/src/floppy/fdc_magitronic.c index bdc8149ef..ea754187e 100644 --- a/src/floppy/fdc_magitronic.c +++ b/src/floppy/fdc_magitronic.c @@ -34,12 +34,56 @@ #define ROM_B215 L"roms/floppy/magitronic/Magitronic B215 - BIOS ROM.bin" #define ROM_ADDR (uint32_t)(device_get_config_hex20("bios_addr") & 0x000fffff) +#define DRIVE_SELECT (int)(real_drive(dev->fdc_controller, i)) typedef struct { fdc_t *fdc_controller; rom_t rom; } b215_t; +static uint8_t +b215_read(uint16_t addr, void *priv) +{ + b215_t *dev = (b215_t *)priv; + + /* + Register 3F0h + + Bit (3-2) for Drive B: + Bit (1-0) for Drive A: + 0: 360KB + 1: 1.2MB + 2: 720KB + 3: 1.44MB + 4: +*/ + int drive_spec[2]; + + for (int i = 0; i <= 1; i++) + { + if (fdd_is_525(DRIVE_SELECT)) + { + if (!fdd_is_dd(DRIVE_SELECT)) + drive_spec[i] = 1; + else if (fdd_doublestep_40(DRIVE_SELECT)) + drive_spec[i] = 2; + else + drive_spec[i] = 0; + } + else + { + if (fdd_is_dd(DRIVE_SELECT) && !fdd_is_double_sided(DRIVE_SELECT)) + drive_spec[i] = 0; + else if (fdd_is_dd(DRIVE_SELECT) && fdd_is_double_sided(DRIVE_SELECT)) + drive_spec[i] = 2; + else + drive_spec[i] = 3; + } + } + + return ((drive_spec[1] << 2) | drive_spec[0]) & 0x0f; +} + static void b215_close(void *priv) { @@ -56,7 +100,8 @@ b215_init(const device_t *info) rom_init(&dev->rom, ROM_B215, ROM_ADDR, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL); - device_add(&fdc_xt_device); + dev->fdc_controller = device_add(&fdc_um8398_device); + io_sethandler(0x03f0, 1, b215_read, NULL, NULL, NULL, NULL, NULL, dev); return dev; } diff --git a/src/include/86box/fdc.h b/src/include/86box/fdc.h index b818258de..b51f93625 100644 --- a/src/include/86box/fdc.h +++ b/src/include/86box/fdc.h @@ -34,6 +34,7 @@ extern int fdc_type; #define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */ #define FDC_FLAG_TOSHIBA 0x100 /* T1000, T1200 */ #define FDC_FLAG_AMSTRAD 0x200 /* Non-AT Amstrad machines */ +#define FDC_FLAG_UMC 0x400 /* UMC UM8398 */ typedef struct { @@ -179,6 +180,7 @@ extern const device_t fdc_at_smc_device; extern const device_t fdc_at_winbond_device; extern const device_t fdc_at_nsc_device; extern const device_t fdc_dp8473_device; +extern const device_t fdc_um8398_device; #endif #endif /*EMU_FDC_H*/ From 6fd19ef4f7b89a24e9a74b1c2669e00ac3ab05b9 Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Mon, 8 Feb 2021 18:04:15 +0200 Subject: [PATCH 4/4] The UMC 8398 can now remove port 3F7h --- src/floppy/fdc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index d87193538..0f7bea3a1 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -2212,7 +2212,7 @@ fdc_remove(fdc_t *fdc) io_removehandler(fdc->base_address + 0x0002, 0x0001, NULL, NULL, NULL, fdc_write, NULL, NULL, fdc); io_removehandler(fdc->base_address + 0x0004, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc); io_removehandler(fdc->base_address + 0x0005, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); - if (fdc->flags & FDC_FLAG_TOSHIBA) + if ((fdc->flags & FDC_FLAG_TOSHIBA) || (fdc->flags & FDC_FLAG_UMC)) io_removehandler(fdc->base_address + 0x0007, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); } }