summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2016-11-26 15:56:05 -0600
committer cracyc <cracyc@users.noreply.github.com>2016-11-26 15:56:05 -0600
commit1637c91a5ccf77dae40a3edab7af1e0b64b92bf7 (patch)
tree9482545ef58b0a6149a3503299fe4bc09a86cbfa /src/mame/machine
parent1287e5687db08bfa9977f2dfd1195b98e6b3e963 (diff)
isbc_208: add device [Carl]
Diffstat (limited to 'src/mame/machine')
-rw-r--r--src/mame/machine/isbc_208.cpp122
-rw-r--r--src/mame/machine/isbc_208.h53
2 files changed, 175 insertions, 0 deletions
diff --git a/src/mame/machine/isbc_208.cpp b/src/mame/machine/isbc_208.cpp
new file mode 100644
index 00000000000..b4c9abb723a
--- /dev/null
+++ b/src/mame/machine/isbc_208.cpp
@@ -0,0 +1,122 @@
+// license:BSD-3-Clause
+// copyright-holders:Carl
+
+// TODO: multibus
+
+#include "isbc_208.h"
+
+const device_type ISBC_208 = &device_creator<isbc_208_device>;
+
+isbc_208_device::isbc_208_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, ISBC_208, "ISBC 208 Flexible Disk Drive Controller", tag, owner, clock, "isbc_208", __FILE__),
+ m_dmac(*this, "dmac"),
+ m_fdc(*this, "fdc"),
+ m_out_irq_func(*this)
+{
+}
+
+FLOPPY_FORMATS_MEMBER( isbc_208_device::floppy_formats )
+ FLOPPY_PC_FORMAT
+FLOPPY_FORMATS_END
+
+static SLOT_INTERFACE_START( isbc_208_floppies )
+ SLOT_INTERFACE( "8dd", FLOPPY_8_DSDD )
+ SLOT_INTERFACE( "525dd", FLOPPY_525_DD )
+SLOT_INTERFACE_END
+
+static MACHINE_CONFIG_FRAGMENT( isbc_208 )
+ MCFG_DEVICE_ADD("dmac", AM9517A, XTAL_8MHz/4)
+ MCFG_I8237_OUT_HREQ_CB(WRITELINE(isbc_208_device, hreq_w))
+ MCFG_I8237_OUT_EOP_CB(WRITELINE(isbc_208_device, out_eop_w))
+ MCFG_I8237_IN_MEMR_CB(READ8(isbc_208_device, dma_read_byte))
+ MCFG_I8237_OUT_MEMW_CB(WRITE8(isbc_208_device, dma_write_byte))
+ MCFG_I8237_IN_IOR_0_CB(DEVREAD8("fdc", i8272a_device, mdma_r))
+ MCFG_I8237_OUT_IOW_0_CB(DEVWRITE8("fdc", i8272a_device, mdma_w))
+
+ MCFG_I8272A_ADD("fdc", true)
+ MCFG_UPD765_INTRQ_CALLBACK(WRITELINE(isbc_208_device, irq_w))
+ MCFG_UPD765_DRQ_CALLBACK(DEVWRITELINE("dmac", am9517a_device, dreq0_w))
+ MCFG_FLOPPY_DRIVE_ADD("fdc:0", isbc_208_floppies, "525dd", isbc_208_device::floppy_formats)
+ MCFG_FLOPPY_DRIVE_ADD("fdc:1", isbc_208_floppies, "525dd", isbc_208_device::floppy_formats)
+MACHINE_CONFIG_END
+
+DEVICE_ADDRESS_MAP_START( map, 8, isbc_208_device )
+ AM_RANGE(0x00, 0x0f) AM_DEVREADWRITE("dmac", am9517a_device, read, write)
+ AM_RANGE(0x10, 0x11) AM_DEVICE("fdc", i8272a_device, map)
+ AM_RANGE(0x12, 0x15) AM_READWRITE(stat_r, aux_w)
+ADDRESS_MAP_END
+
+machine_config_constructor isbc_208_device::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME( isbc_208 );
+}
+
+WRITE_LINE_MEMBER(isbc_208_device::out_eop_w)
+{
+ m_fdc->tc_w(state);
+}
+
+WRITE_LINE_MEMBER(isbc_208_device::irq_w)
+{
+ m_out_irq_func(state);
+}
+
+WRITE_LINE_MEMBER(isbc_208_device::hreq_w)
+{
+ machine().device<cpu_device>(m_maincpu_tag)->set_input_line(INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE);
+ /* Assert HLDA */
+ m_dmac->hack_w(state);
+}
+
+READ8_MEMBER(isbc_208_device::dma_read_byte)
+{
+ return m_maincpu_mem->read_byte(((offset + (m_seg << 4)) & 0xfffff) | ((m_aux & 0xf0) << 16));
+}
+
+
+WRITE8_MEMBER(isbc_208_device::dma_write_byte)
+{
+ return m_maincpu_mem->write_byte(((offset + (m_seg << 4)) & 0xfffff) | ((m_aux & 0xf0) << 16), data);
+}
+
+READ8_MEMBER(isbc_208_device::stat_r)
+{
+ if(!offset)
+ return m_fdc->get_irq() ? 1 : 0;
+ return 0;
+}
+
+WRITE8_MEMBER( isbc_208_device::aux_w )
+{
+ switch(offset)
+ {
+ case 0:
+ m_aux = data;
+ m_fdc->subdevice<floppy_connector>("0")->get_device()->mon_w(!(data & 1));
+ m_fdc->subdevice<floppy_connector>("1")->get_device()->mon_w(!(data & 2));
+ break;
+ case 1:
+ m_fdc->soft_reset();
+ m_dmac->reset();
+ break;
+ case 2:
+ m_seg = (m_seg & 0xff00) | data;
+ break;
+ case 3:
+ m_seg = (m_seg & 0xff) | (data << 8);
+ break;
+ }
+}
+
+void isbc_208_device::device_reset()
+{
+ m_aux = 0;
+ m_seg = 0;
+}
+
+void isbc_208_device::device_start()
+{
+ m_maincpu_mem = &machine().device<cpu_device>(m_maincpu_tag)->space(AS_PROGRAM);
+ m_out_irq_func.resolve_safe();
+}
+
diff --git a/src/mame/machine/isbc_208.h b/src/mame/machine/isbc_208.h
new file mode 100644
index 00000000000..43c08b9b98d
--- /dev/null
+++ b/src/mame/machine/isbc_208.h
@@ -0,0 +1,53 @@
+// license:BSD-3-Clause
+// copyright-holders:Carl
+
+#ifndef ISBC_208_H_
+#define ISBC_208_H_
+
+#include "emu.h"
+#include "formats/pc_dsk.h"
+#include "machine/upd765.h"
+#include "machine/am9517a.h"
+
+class isbc_208_device : public device_t
+{
+public:
+ isbc_208_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual machine_config_constructor device_mconfig_additions() const override;
+ DECLARE_ADDRESS_MAP(map, 8);
+ DECLARE_READ8_MEMBER(stat_r);
+ DECLARE_WRITE8_MEMBER(aux_w);
+ DECLARE_WRITE_LINE_MEMBER(out_eop_w);
+ DECLARE_WRITE_LINE_MEMBER(hreq_w);
+ DECLARE_READ8_MEMBER(dma_read_byte);
+ DECLARE_WRITE8_MEMBER(dma_write_byte);
+ DECLARE_WRITE_LINE_MEMBER(irq_w);
+ DECLARE_FLOPPY_FORMATS( floppy_formats );
+
+ template<class _Object> static devcb_base &static_set_irq_callback(device_t &device, _Object object) { return downcast<isbc_208_device &>(device).m_out_irq_func.set_callback(object); }
+ static void static_set_maincpu_tag(device_t &device, const char *maincpu_tag) { downcast<isbc_208_device &>(device).m_maincpu_tag = maincpu_tag; }
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+private:
+ required_device<am9517a_device> m_dmac;
+ required_device<i8272a_device> m_fdc;
+
+ devcb_write_line m_out_irq_func;
+ u8 m_aux;
+ u16 m_seg;
+ const char *m_maincpu_tag;
+ address_space *m_maincpu_mem;
+};
+#define MCFG_ISBC_208_MAINCPU(_maincpu_tag) \
+ isbc_208_device::static_set_maincpu_tag(*device, _maincpu_tag);
+
+#define MCFG_ISBC_208_IRQ(_irq_line) \
+ devcb = &isbc_208_device::static_set_irq_callback(*device, DEVCB_##_irq_line);
+
+extern const device_type ISBC_208;
+
+#endif /* ISBC_208_H_ */