summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus
diff options
context:
space:
mode:
author Nigel Barnes <Pernod70@users.noreply.github.com>2019-03-14 12:06:54 +0000
committer Nigel Barnes <Pernod70@users.noreply.github.com>2019-03-14 12:07:50 +0000
commit596c68e75559ef3b8f4aba82f3347091fbfde02e (patch)
treec1601b512b707d53f26e220675c13fef7da8a35c /src/devices/bus
parentcb60e245dcf3830669c44b240e40f60580625cc6 (diff)
spectrum: Added the Technology Research Beta 128 Disk Interface.
Diffstat (limited to 'src/devices/bus')
-rw-r--r--src/devices/bus/spectrum/beta.cpp256
-rw-r--r--src/devices/bus/spectrum/beta.h64
-rw-r--r--src/devices/bus/spectrum/exp.cpp7
3 files changed, 323 insertions, 4 deletions
diff --git a/src/devices/bus/spectrum/beta.cpp b/src/devices/bus/spectrum/beta.cpp
new file mode 100644
index 00000000000..e48bed34e52
--- /dev/null
+++ b/src/devices/bus/spectrum/beta.cpp
@@ -0,0 +1,256 @@
+// license:BSD-3-Clause
+// copyright-holders:Nigel Barnes
+/*********************************************************************
+
+ Technology Research Beta 128 Disk interface
+
+*********************************************************************/
+
+#include "emu.h"
+#include "beta.h"
+
+
+/***************************************************************************
+ DEVICE DEFINITIONS
+***************************************************************************/
+
+DEFINE_DEVICE_TYPE(SPECTRUM_BETA128, spectrum_beta128_device, "spectrum_beta128", "TR Beta 128 Disk Interface")
+
+
+//-------------------------------------------------
+// INPUT_PORTS( beta128 )
+//-------------------------------------------------
+
+INPUT_PORTS_START(beta128)
+ PORT_START("BUTTON")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Magic Button") PORT_CODE(KEYCODE_F12) PORT_CHANGED_MEMBER(DEVICE_SELF, spectrum_beta128_device, magic_button, nullptr)
+
+ PORT_START("SWITCH")
+ PORT_CONFNAME(0x03, 0x01, "System Switch") //PORT_CHANGED_MEMBER(DEVICE_SELF, spectrum_beta128_device, switch_changed, 0)
+ PORT_CONFSETTING(0x00, "Off (128)")
+ PORT_CONFSETTING(0x01, "Normal (auto-boot)")
+ //PORT_CONFSETTING(0x02, "Reset") // TODO: implement RESET callback
+INPUT_PORTS_END
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
+
+ioport_constructor spectrum_beta128_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(beta128);
+}
+
+//-------------------------------------------------
+// SLOT_INTERFACE( beta_floppies )
+//-------------------------------------------------
+
+static void beta_floppies(device_slot_interface &device)
+{
+ device.option_add("525qd", FLOPPY_525_QD);
+}
+
+//-------------------------------------------------
+// floppy_format_type floppy_formats
+//-------------------------------------------------
+
+FLOPPY_FORMATS_MEMBER(spectrum_beta128_device::floppy_formats)
+ FLOPPY_TRD_FORMAT
+FLOPPY_FORMATS_END
+
+//-------------------------------------------------
+// ROM( beta )
+//-------------------------------------------------
+
+ROM_START(beta128)
+ ROM_REGION(0x4000, "rom", 0)
+ ROM_DEFAULT_BIOS("trd504")
+ ROM_SYSTEM_BIOS(0, "trd501", "TR-DOS v5.01")
+ ROMX_LOAD("trd501.rom", 0x0000, 0x4000, CRC(3e3cdd4c) SHA1(8303ba0cc79daa6c04cd1e6ce27e8b6886a3f0de), ROM_BIOS(0))
+ ROM_SYSTEM_BIOS(1, "trd503", "TR-DOS v5.03")
+ ROMX_LOAD("trd503.rom", 0x0000, 0x4000, CRC(10751aba) SHA1(21695e3f2a8f796386ce66eea8a246b0ac44810c), ROM_BIOS(1))
+ ROM_SYSTEM_BIOS(2, "trd504", "TR-DOS v5.04")
+ ROMX_LOAD("trd504.rom", 0x0000, 0x4000, CRC(ba310874) SHA1(05e55e37df8eee6c68601ba9cf6c92195852ce3f), ROM_BIOS(2))
+ROM_END
+
+//-------------------------------------------------
+// device_add_mconfig - add device configuration
+//-------------------------------------------------
+
+void spectrum_beta128_device::device_add_mconfig(machine_config &config)
+{
+ FD1793(config, m_fdc, 4_MHz_XTAL / 4);
+ FLOPPY_CONNECTOR(config, "fdc:0", beta_floppies, "525qd", spectrum_beta128_device::floppy_formats).enable_sound(true);
+ FLOPPY_CONNECTOR(config, "fdc:1", beta_floppies, "525qd", spectrum_beta128_device::floppy_formats).enable_sound(true);
+ FLOPPY_CONNECTOR(config, "fdc:2", beta_floppies, nullptr, spectrum_beta128_device::floppy_formats).enable_sound(true);
+ FLOPPY_CONNECTOR(config, "fdc:3", beta_floppies, nullptr, spectrum_beta128_device::floppy_formats).enable_sound(true);
+
+ // passthru
+ SPECTRUM_EXPANSION_SLOT(config, m_exp, spectrum_expansion_devices, nullptr);
+ m_exp->irq_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::irq_w));
+ m_exp->nmi_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::nmi_w));
+}
+
+const tiny_rom_entry *spectrum_beta128_device::device_rom_region() const
+{
+ return ROM_NAME(beta128);
+}
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// spectrum_beta128_device - constructor
+//-------------------------------------------------
+
+spectrum_beta128_device::spectrum_beta128_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, SPECTRUM_BETA128, tag, owner, clock)
+ , device_spectrum_expansion_interface(mconfig, *this)
+ , m_rom(*this, "rom")
+ , m_fdc(*this, "fdc")
+ , m_floppy(*this, "fdc:%u", 0)
+ , m_exp(*this, "exp")
+ , m_switch(*this, "SWITCH")
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void spectrum_beta128_device::device_start()
+{
+ save_item(NAME(m_romcs));
+}
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void spectrum_beta128_device::device_reset()
+{
+ // Page in the ROM if auto-boot is selected
+ if (m_switch->read() == 0x01)
+ m_romcs = 1;
+ else
+ m_romcs = 0;
+}
+
+//**************************************************************************
+// IMPLEMENTATION
+//**************************************************************************
+
+READ_LINE_MEMBER(spectrum_beta128_device::romcs)
+{
+ return m_romcs | m_exp->romcs();
+}
+
+
+void spectrum_beta128_device::opcode_fetch(offs_t offset)
+{
+ m_exp->opcode_fetch(offset);
+
+ if (!machine().side_effects_disabled())
+ {
+ if ((offset == 0x0066) || (offset & 0xff00) == 0x3d00)
+ m_romcs = 1;
+ else if (offset >= 0x4000)
+ m_romcs = 0;
+ }
+}
+
+uint8_t spectrum_beta128_device::iorq_r(offs_t offset)
+{
+ uint8_t data = m_exp->iorq_r(offset);
+
+ if (m_romcs)
+ {
+ switch (offset & 0xff)
+ {
+ case 0x1f: case 0x3f: case 0x5f: case 0x7f:
+ data = m_fdc->read((offset >> 5) & 0x03);
+ break;
+
+ case 0xff:
+ data &= 0x3f; // actually open bus
+ data |= m_fdc->drq_r() ? 0x40 : 0;
+ data |= m_fdc->intrq_r() ? 0x80 : 0;
+ break;
+ }
+ }
+ return data;
+}
+
+void spectrum_beta128_device::iorq_w(offs_t offset, uint8_t data)
+{
+ if (m_romcs)
+ {
+ switch (offset & 0xff)
+ {
+ case 0x1f: case 0x3f: case 0x5f: case 0x7f:
+ m_fdc->write((offset >> 5) & 0x03, data);
+ break;
+
+ case 0xff:
+ floppy_image_device* floppy = m_floppy[data & 3]->get_device();
+
+ m_fdc->set_floppy(floppy);
+ if (floppy)
+ floppy->ss_w(BIT(data, 4) ? 0 : 1);
+ m_fdc->dden_w(BIT(data, 6));
+
+ // bit 3 connected to pin 23 "HLT" of FDC and via diode to INDEX
+ //m_fdc->hlt_w(BIT(data, 3)); // not handled in current wd_fdc
+
+ if (BIT(data, 2) == 0) // reset
+ {
+ m_fdc->reset();
+ if (floppy)
+ floppy->mon_w(ASSERT_LINE);
+ }
+ else
+ {
+ // TODO: implement correct motor control, FDD motor and RDY FDC pin controlled by HLD pin of FDC
+ if (floppy)
+ floppy->mon_w(CLEAR_LINE);
+ }
+ break;
+ }
+ }
+ m_exp->iorq_w(offset, data);
+}
+
+uint8_t spectrum_beta128_device::mreq_r(offs_t offset)
+{
+ uint8_t data = 0xff;
+
+ if (m_romcs)
+ {
+ data = m_rom->base()[offset & 0x3fff];
+ }
+
+ if (m_exp->romcs())
+ data &= m_exp->mreq_r(offset);
+
+ return data;
+}
+
+void spectrum_beta128_device::mreq_w(offs_t offset, uint8_t data)
+{
+ if (m_exp->romcs())
+ m_exp->mreq_w(offset, data);
+}
+
+INPUT_CHANGED_MEMBER(spectrum_beta128_device::magic_button)
+{
+ if (newval && !oldval)
+ {
+ m_slot->nmi_w(ASSERT_LINE);
+ }
+ else
+ {
+ m_slot->nmi_w(CLEAR_LINE);
+ }
+}
diff --git a/src/devices/bus/spectrum/beta.h b/src/devices/bus/spectrum/beta.h
new file mode 100644
index 00000000000..b759201d35d
--- /dev/null
+++ b/src/devices/bus/spectrum/beta.h
@@ -0,0 +1,64 @@
+// license:BSD-3-Clause
+// copyright-holders:Nigel Barnes
+/*********************************************************************
+
+ Technology Research Beta 128 Disk interface
+
+*********************************************************************/
+#ifndef MAME_BUS_SPECTRUM_BETA_H
+#define MAME_BUS_SPECTRUM_BETA_H
+
+#include "exp.h"
+#include "softlist.h"
+#include "imagedev/floppy.h"
+#include "machine/wd_fdc.h"
+#include "formats/trd_dsk.h"
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+class spectrum_beta128_device :
+ public device_t,
+ public device_spectrum_expansion_interface
+
+{
+public:
+ // construction/destruction
+ spectrum_beta128_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ DECLARE_FLOPPY_FORMATS(floppy_formats);
+ DECLARE_INPUT_CHANGED_MEMBER(magic_button);
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+ // optional information overrides
+ virtual void device_add_mconfig(machine_config &config) override;
+ virtual const tiny_rom_entry *device_rom_region() const override;
+ virtual ioport_constructor device_input_ports() const override;
+
+ virtual void opcode_fetch(offs_t offset) override;
+ virtual uint8_t mreq_r(offs_t offset) override;
+ virtual void mreq_w(offs_t offset, uint8_t data) override;
+ virtual uint8_t iorq_r(offs_t offset) override;
+ virtual void iorq_w(offs_t offset, uint8_t data) override;
+ virtual DECLARE_READ_LINE_MEMBER(romcs) override;
+
+ required_memory_region m_rom;
+ required_device<fd1793_device> m_fdc;
+ required_device_array<floppy_connector, 4> m_floppy;
+ required_device<spectrum_expansion_slot_device> m_exp;
+ required_ioport m_switch;
+
+ int m_romcs;
+};
+
+
+// device type definition
+DECLARE_DEVICE_TYPE(SPECTRUM_BETA128, spectrum_beta128_device)
+
+
+#endif // MAME_BUS_SPECTRUM_BETA_H
diff --git a/src/devices/bus/spectrum/exp.cpp b/src/devices/bus/spectrum/exp.cpp
index e888e5bb01b..ec71d31617a 100644
--- a/src/devices/bus/spectrum/exp.cpp
+++ b/src/devices/bus/spectrum/exp.cpp
@@ -158,7 +158,7 @@ void spectrum_expansion_slot_device::mreq_w(offs_t offset, uint8_t data)
// slot devices
-//#include "beta.h"
+#include "beta.h"
//#include "disciple.h"
#include "intf1.h"
#include "intf2.h"
@@ -178,8 +178,7 @@ void spectrum_expansion_slot_device::mreq_w(offs_t offset, uint8_t data)
void spectrum_expansion_devices(device_slot_interface &device)
{
- //device.option_add("beta", SPECTRUM_BETA);
- //device.option_add("betaplus", SPECTRUM_BETAPLUS);
+ device.option_add("beta128", SPECTRUM_BETA128);
//device.option_add("disciple", SPECTRUM_DISCIPLE);
device.option_add("intf1", SPECTRUM_INTF1);
device.option_add("intf2", SPECTRUM_INTF2);
@@ -200,7 +199,7 @@ void spectrum_expansion_devices(device_slot_interface &device)
void spec128_expansion_devices(device_slot_interface &device)
{
- //device.option_add("beta128", SPECTRUM_BETA128);
+ device.option_add("beta128", SPECTRUM_BETA128);
//device.option_add("disciple", SPECTRUM_DISCIPLE);
device.option_add("intf1", SPECTRUM_INTF1);
device.option_add("intf2", SPECTRUM_INTF2);