From 57326230089f1419030973207cbeabb9c3e244ee Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Tue, 7 Apr 2015 15:32:42 +0300 Subject: [PATCH] (MESS) abc80: Emulated the Scandia Metric ABC FD2 floppy controller. [Curt Coder] --- scripts/src/lib.lua | 1 + src/emu/bus/abcbus/fd2.c | 276 ++++++++++++++++++++++++++++++----- src/emu/bus/abcbus/fd2.h | 31 +++- src/lib/formats/abcfd2_dsk.c | 62 ++++++++ src/lib/formats/abcfd2_dsk.h | 30 ++++ 5 files changed, 361 insertions(+), 39 deletions(-) create mode 100644 src/lib/formats/abcfd2_dsk.c create mode 100644 src/lib/formats/abcfd2_dsk.h diff --git a/scripts/src/lib.lua b/scripts/src/lib.lua index a0a2471cf1a..bc6e0354d61 100644 --- a/scripts/src/lib.lua +++ b/scripts/src/lib.lua @@ -79,6 +79,7 @@ project "formats" MAME_DIR .. "src/lib/formats/a26_cas.c", MAME_DIR .. "src/lib/formats/a5105_dsk.c", MAME_DIR .. "src/lib/formats/abc800_dsk.c", + MAME_DIR .. "src/lib/formats/abcfd2_dsk.c", MAME_DIR .. "src/lib/formats/ace_tap.c", MAME_DIR .. "src/lib/formats/adam_cas.c", MAME_DIR .. "src/lib/formats/adam_dsk.c", diff --git a/src/emu/bus/abcbus/fd2.c b/src/emu/bus/abcbus/fd2.c index cc01e0f4082..a792b0d88ab 100644 --- a/src/emu/bus/abcbus/fd2.c +++ b/src/emu/bus/abcbus/fd2.c @@ -2,7 +2,7 @@ // copyright-holders:Curt Coder /********************************************************************** - Scandia Metric FD2 floppy controller emulation + Scandia Metric ABC FD2 floppy controller emulation Copyright MESS Team. Visit http://mamedev.org for licensing and usage restrictions. @@ -57,7 +57,7 @@ Notes: // DEVICE DEFINITIONS //************************************************************************** -const device_type ABC_FD2 = &device_creator; +const device_type ABC_FD2 = &device_creator; //------------------------------------------------- @@ -65,11 +65,12 @@ const device_type ABC_FD2 = &device_creator; //------------------------------------------------- ROM_START( abc_fd2 ) + ROM_REGION( 0x1000, "dos", 0 ) + ROM_LOAD( "ami 8005saj.1a", 0x000, 0x800, CRC(d865213f) SHA1(ae7399ede74520ccb2dd5be2e6bb13c33ee81bd0) ) // what's this? + ROM_LOAD( "abcdos.3d", 0x0000, 0x1000, CRC(2cb2192f) SHA1(a6b3a9587714f8db807c05bee6c71c0684363744) ) + ROM_REGION( 0x400, Z80_TAG, 0 ) ROM_LOAD( "1.02.3f", 0x000, 0x400, CRC(a19fbdc2) SHA1(d500377c34ac6c679c155f4a5208e1c3e00cd920) ) - - ROM_REGION( 0x800, "abc80", 0 ) - ROM_LOAD( "ami 8005saj.1a", 0x000, 0x800, CRC(d865213f) SHA1(ae7399ede74520ccb2dd5be2e6bb13c33ee81bd0) ) ROM_END @@ -77,17 +78,45 @@ ROM_END // rom_region - device-specific ROM region //------------------------------------------------- -const rom_entry *abc_fd2_device::device_rom_region() const +const rom_entry *abc_fd2_t::device_rom_region() const { return ROM_NAME( abc_fd2 ); } +//------------------------------------------------- +// status_w - +//------------------------------------------------- + +WRITE8_MEMBER( abc_fd2_t::status_w ) +{ + /* + + bit description + + 0 _INT to main Z80 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + */ + + m_status = data & 0xfe; + + // interrupt + m_slot->irq_w(BIT(data, 0) ? ASSERT_LINE : CLEAR_LINE); +} + + //------------------------------------------------- // ADDRESS_MAP( abc_fd2_mem ) //------------------------------------------------- -static ADDRESS_MAP_START( abc_fd2_mem, AS_PROGRAM, 8, abc_fd2_device ) +static ADDRESS_MAP_START( abc_fd2_mem, AS_PROGRAM, 8, abc_fd2_t ) AM_RANGE(0x0000, 0x03ff) AM_ROM AM_REGION(Z80_TAG, 0) AM_RANGE(0x0800, 0x0bff) AM_RAM ADDRESS_MAP_END @@ -97,13 +126,88 @@ ADDRESS_MAP_END // ADDRESS_MAP( abc_fd2_io ) //------------------------------------------------- -static ADDRESS_MAP_START( abc_fd2_io, AS_IO, 8, abc_fd2_device ) - ADDRESS_MAP_GLOBAL_MASK(0xff) - AM_RANGE(0xb0, 0xb3) AM_DEVREADWRITE(Z80PIO_TAG, z80pio_device, read_alt, write_alt) - AM_RANGE(0xd0, 0xd3) AM_DEVREADWRITE(FD1771_TAG, fd1771_t, read, write) +static ADDRESS_MAP_START( abc_fd2_io, AS_IO, 8, abc_fd2_t ) + ADDRESS_MAP_GLOBAL_MASK(0x73) + AM_RANGE(0x30, 0x33) AM_DEVREADWRITE(Z80PIO_TAG, z80pio_device, read_alt, write_alt) + AM_RANGE(0x50, 0x53) AM_DEVREADWRITE(FD1771_TAG, fd1771_t, read, write) + AM_RANGE(0x60, 0x60) AM_WRITE(status_w) ADDRESS_MAP_END +//------------------------------------------------- +// Z80PIO +//------------------------------------------------- + +READ8_MEMBER( abc_fd2_t::pio_pa_r ) +{ + return m_data; +} + +WRITE8_MEMBER( abc_fd2_t::pio_pa_w ) +{ + m_data = data; +} + +READ8_MEMBER( abc_fd2_t::pio_pb_r ) +{ + /* + + bit description + + 0 + 1 + 2 + 3 + 4 + 5 DRQ + 6 HLD + 7 INTRQ + + */ + + UINT8 data = 0; + + data |= m_fdc->drq_r() << 5; + data |= m_fdc->hld_r() << 6; + data |= m_fdc->intrq_r() << 7; + + return data; +} + +WRITE8_MEMBER( abc_fd2_t::pio_pb_w ) +{ + /* + + bit description + + 0 SEL1 + 1 SEL2 + 2 TG43 + 3 MON + 4 HLT + 5 + 6 + 7 + + */ + + floppy_image_device *floppy = NULL; + + if (BIT(data, 0)) floppy = m_floppy0->get_device(); + if (BIT(data, 1)) floppy = m_floppy1->get_device(); + + m_fdc->set_floppy(floppy); + + if (floppy) + { + // motor enable + floppy->mon_w(BIT(data, 3)); + } + + m_fdc->hlt_w(BIT(data, 4)); +} + + //------------------------------------------------- // z80_daisy_config daisy_chain //------------------------------------------------- @@ -123,23 +227,35 @@ static SLOT_INTERFACE_START( abc_fd2_floppies ) SLOT_INTERFACE( "525sssd", FLOPPY_525_SSSD ) SLOT_INTERFACE_END +FLOPPY_FORMATS_MEMBER( abc_fd2_t::floppy_formats ) + FLOPPY_ABC_FD2_FORMAT +FLOPPY_FORMATS_END + //------------------------------------------------- // MACHINE_DRIVER( abc_fd2 ) //------------------------------------------------- static MACHINE_CONFIG_FRAGMENT( abc_fd2 ) - MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_4MHz) + MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_4MHz/2) MCFG_CPU_PROGRAM_MAP(abc_fd2_mem) MCFG_CPU_IO_MAP(abc_fd2_io) MCFG_CPU_CONFIG(daisy_chain) - MCFG_DEVICE_ADD(Z80PIO_TAG, Z80PIO, XTAL_4MHz) + MCFG_DEVICE_ADD(Z80PIO_TAG, Z80PIO, XTAL_4MHz/2) + MCFG_Z80PIO_OUT_INT_CB(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0)) + MCFG_Z80PIO_IN_PA_CB(READ8(abc_fd2_t, pio_pa_r)) + MCFG_Z80PIO_OUT_PA_CB(WRITE8(abc_fd2_t, pio_pa_w)) + MCFG_Z80PIO_IN_PB_CB(READ8(abc_fd2_t, pio_pb_r)) + MCFG_Z80PIO_OUT_PB_CB(WRITE8(abc_fd2_t, pio_pb_w)) - MCFG_FD1771x_ADD(FD1771_TAG, XTAL_4MHz/2) + MCFG_FD1771x_ADD(FD1771_TAG, XTAL_4MHz/4) + MCFG_WD_FDC_INTRQ_CALLBACK(DEVWRITELINE(Z80PIO_TAG, z80pio_device, pb7_w)) + MCFG_WD_FDC_DRQ_CALLBACK(DEVWRITELINE(Z80PIO_TAG, z80pio_device, pb5_w)) + MCFG_WD_FDC_HLD_CALLBACK(DEVWRITELINE(Z80PIO_TAG, z80pio_device, pb6_w)) - MCFG_FLOPPY_DRIVE_ADD(FD1771_TAG":0", abc_fd2_floppies, "525sssd", floppy_image_device::default_floppy_formats) - MCFG_FLOPPY_DRIVE_ADD(FD1771_TAG":1", abc_fd2_floppies, "525sssd", floppy_image_device::default_floppy_formats) + MCFG_FLOPPY_DRIVE_ADD(FD1771_TAG ":0", abc_fd2_floppies, "525sssd", abc_fd2_t::floppy_formats) + MCFG_FLOPPY_DRIVE_ADD(FD1771_TAG ":1", abc_fd2_floppies, "525sssd", abc_fd2_t::floppy_formats) MACHINE_CONFIG_END @@ -148,7 +264,7 @@ MACHINE_CONFIG_END // machine configurations //------------------------------------------------- -machine_config_constructor abc_fd2_device::device_mconfig_additions() const +machine_config_constructor abc_fd2_t::device_mconfig_additions() const { return MACHINE_CONFIG_NAME( abc_fd2 ); } @@ -160,18 +276,19 @@ machine_config_constructor abc_fd2_device::device_mconfig_additions() const //************************************************************************** //------------------------------------------------- -// abc_fd2_device - constructor +// abc_fd2_t - constructor //------------------------------------------------- -abc_fd2_device::abc_fd2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ABC_FD2, "ABC FD2", tag, owner, clock, "abc_fd2", __FILE__), - device_abcbus_card_interface(mconfig, *this), - m_maincpu(*this, Z80_TAG), - m_pio(*this, Z80PIO_TAG), - m_fdc(*this, FD1771_TAG), - m_floppy0(*this, FD1771_TAG":0"), - m_floppy1(*this, FD1771_TAG":1"), - m_rom(*this, "abc80") +abc_fd2_t::abc_fd2_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, ABC_FD2, "ABC FD2", tag, owner, clock, "abc_fd2", __FILE__), + device_abcbus_card_interface(mconfig, *this), + m_maincpu(*this, Z80_TAG), + m_pio(*this, Z80PIO_TAG), + m_fdc(*this, FD1771_TAG), + m_floppy0(*this, FD1771_TAG ":0"), + m_floppy1(*this, FD1771_TAG ":1"), + m_dos_rom(*this, "dos"), + m_cs(false) { } @@ -180,7 +297,7 @@ abc_fd2_device::abc_fd2_device(const machine_config &mconfig, const char *tag, d // device_start - device-specific startup //------------------------------------------------- -void abc_fd2_device::device_start() +void abc_fd2_t::device_start() { } @@ -189,8 +306,15 @@ void abc_fd2_device::device_start() // device_reset - device-specific reset //------------------------------------------------- -void abc_fd2_device::device_reset() +void abc_fd2_t::device_reset() { + m_cs = false; + + m_status = 0; + m_slot->irq_w(CLEAR_LINE); + + m_maincpu->reset(); + m_fdc->soft_reset(); } @@ -203,8 +327,94 @@ void abc_fd2_device::device_reset() // abcbus_cs - //------------------------------------------------- -void abc_fd2_device::abcbus_cs(UINT8 data) +void abc_fd2_t::abcbus_cs(UINT8 data) { + m_cs = (data == 0x2d); +} + + +//------------------------------------------------- +// abcbus_stat - +//------------------------------------------------- + +UINT8 abc_fd2_t::abcbus_stat() +{ + UINT8 data = 0xff; + + if (m_cs) + { + data = (m_status & 0xfe) | m_pio->rdy_a(); + } + + return data; +} + + +//------------------------------------------------- +// abcbus_inp - +//------------------------------------------------- + +UINT8 abc_fd2_t::abcbus_inp() +{ + UINT8 data = 0xff; + + if (m_cs) + { + if (!BIT(m_status, 6)) + { + data = m_data; + } + + m_pio->strobe_a(0); + m_pio->strobe_a(1); + } + + return data; +} + + +//------------------------------------------------- +// abcbus_out - +//------------------------------------------------- + +void abc_fd2_t::abcbus_out(UINT8 data) +{ + if (!m_cs) return; + + if (BIT(m_status, 6)) + { + m_data = data; + } + + m_pio->strobe_a(0); + m_pio->strobe_a(1); +} + + +//------------------------------------------------- +// abcbus_c1 - +//------------------------------------------------- + +void abc_fd2_t::abcbus_c1(UINT8 data) +{ + if (m_cs) + { + m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); + m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + } +} + + +//------------------------------------------------- +// abcbus_c3 - +//------------------------------------------------- + +void abc_fd2_t::abcbus_c3(UINT8 data) +{ + if (m_cs) + { + device_reset(); + } } @@ -212,13 +422,13 @@ void abc_fd2_device::abcbus_cs(UINT8 data) // abcbus_xmemfl - //------------------------------------------------- -UINT8 abc_fd2_device::abcbus_xmemfl(offs_t offset) +UINT8 abc_fd2_t::abcbus_xmemfl(offs_t offset) { UINT8 data = 0xff; - if (offset >= 0x6000 && offset < 0x6400) // TODO is this mirrored? + if ((offset & 0xf000) == 0x6000) { - data = m_rom->base()[offset & 0x3ff]; + data = m_dos_rom->base()[offset & 0xfff]; } return data; diff --git a/src/emu/bus/abcbus/fd2.h b/src/emu/bus/abcbus/fd2.h index fdb89809254..e41fa8d66e5 100644 --- a/src/emu/bus/abcbus/fd2.h +++ b/src/emu/bus/abcbus/fd2.h @@ -2,7 +2,7 @@ // copyright-holders:Curt Coder /********************************************************************** - Scandia Metric FD2 floppy controller emulation + Scandia Metric ABC FD2 floppy controller emulation Copyright MESS Team. Visit http://mamedev.org for licensing and usage restrictions. @@ -18,6 +18,7 @@ #include "abcbus.h" #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" +#include "formats/abcfd2_dsk.h" #include "machine/wd_fdc.h" #include "machine/z80pio.h" @@ -27,19 +28,28 @@ // TYPE DEFINITIONS //************************************************************************** -// ======================> abc_fd2_device +// ======================> abc_fd2_t -class abc_fd2_device : public device_t, - public device_abcbus_card_interface +class abc_fd2_t : public device_t, + public device_abcbus_card_interface { public: // construction/destruction - abc_fd2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + abc_fd2_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); // optional information overrides virtual const rom_entry *device_rom_region() const; virtual machine_config_constructor device_mconfig_additions() const; + DECLARE_WRITE8_MEMBER( status_w ); + + DECLARE_READ8_MEMBER( pio_pa_r ); + DECLARE_WRITE8_MEMBER( pio_pa_w ); + DECLARE_READ8_MEMBER( pio_pb_r ); + DECLARE_WRITE8_MEMBER( pio_pb_w ); + + DECLARE_FLOPPY_FORMATS( floppy_formats ); + protected: // device-level overrides virtual void device_start(); @@ -47,6 +57,11 @@ protected: // device_abcbus_interface overrides virtual void abcbus_cs(UINT8 data); + virtual UINT8 abcbus_inp(); + virtual void abcbus_out(UINT8 data); + virtual UINT8 abcbus_stat(); + virtual void abcbus_c1(UINT8 data); + virtual void abcbus_c3(UINT8 data); virtual UINT8 abcbus_xmemfl(offs_t offset); private: @@ -55,7 +70,11 @@ private: required_device m_fdc; required_device m_floppy0; required_device m_floppy1; - required_memory_region m_rom; + required_memory_region m_dos_rom; + + bool m_cs; + UINT8 m_status; + UINT8 m_data; }; diff --git a/src/lib/formats/abcfd2_dsk.c b/src/lib/formats/abcfd2_dsk.c new file mode 100644 index 00000000000..8cc87ae20cd --- /dev/null +++ b/src/lib/formats/abcfd2_dsk.c @@ -0,0 +1,62 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************* + + formats/abcfd2_dsk.c + + Scandia Metric ABC FD2 disk image formats + +*********************************************************************/ + +#include + +#include "formats/abcfd2_dsk.h" + +abc_fd2_format::abc_fd2_format() : wd177x_format(formats) +{ +} + +const char *abc_fd2_format::name() const +{ + return "abc_fd2"; +} + +const char *abc_fd2_format::description() const +{ + return "Scandia Metric ABC FD2 disk image"; +} + +const char *abc_fd2_format::extensions() const +{ + return "dsk"; +} + +const abc_fd2_format::format abc_fd2_format::formats[] = { + // track description + // 28xff 6x00 fe 2x00 01 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 02 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 03 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 04 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 05 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 06 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 07 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 08 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 09 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 0a 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 0b 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 0c 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 0d 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 0e 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 0f 00 f7 11xff 6x00 fb 128xe5 f7 + // 27xff 6x00 fe 2x00 10 00 f7 11xff 6x00 fb 128xe5 f7 + // 117xff + + { // 80K 5 1/4 inch single density single sided + floppy_image::FF_525, floppy_image::SSSD, floppy_image::FM, + 4000, 16, 40, 1, 128, {}, 1, {}, 28, 11, 27 + }, + + {} +}; + +const floppy_format_type FLOPPY_ABC_FD2_FORMAT = &floppy_image_format_creator; diff --git a/src/lib/formats/abcfd2_dsk.h b/src/lib/formats/abcfd2_dsk.h new file mode 100644 index 00000000000..a97e46cb5ed --- /dev/null +++ b/src/lib/formats/abcfd2_dsk.h @@ -0,0 +1,30 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************* + + formats/abcfd2_dsk.h + + Scandia Metric ABC FD2 disk image formats + +*********************************************************************/ + +#ifndef ABC_FD2_DSK_H_ +#define ABC_FD2_DSK_H_ + +#include "wd177x_dsk.h" + +class abc_fd2_format : public wd177x_format { +public: + abc_fd2_format(); + + virtual const char *name() const; + virtual const char *description() const; + virtual const char *extensions() const; + +private: + static const format formats[]; +}; + +extern const floppy_format_type FLOPPY_ABC_FD2_FORMAT; + +#endif