summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar mahlemiut <bsr@xnet.co.nz>2019-08-16 14:42:48 +1200
committerGravatarGravatar mahlemiut <bsr@xnet.co.nz>2019-08-16 14:43:49 +1200
commitdaa3de1f6ae726b0f642e973eafae63bf86e5f21 (patch) (github)
tree087f44c7eb723eb172376868732d31499a65437b
parent5ca8e228fddd7556f1bb64a2033f185d1b8da128 (diff)
downloadmame-daa3de1f6ae726b0f642e973eafae63bf86e5f21.tar.bz2
mame-daa3de1f6ae726b0f642e973eafae63bf86e5f21.zip
amstrad: add Ram Electronics Music Machine MIDI and sampler expansion. [Barry Rodewald]
-rw-r--r--scripts/src/bus.lua2
-rw-r--r--src/devices/bus/cpc/musicmachine.cpp128
-rw-r--r--src/devices/bus/cpc/musicmachine.h54
-rw-r--r--src/mame/drivers/amstrad.cpp4
-rw-r--r--src/mame/includes/amstrad.h1
5 files changed, 189 insertions, 0 deletions
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index b55820fb163..2d513250198 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -3130,6 +3130,8 @@ if (BUSES["CPC"]~=null) then
MAME_DIR .. "src/devices/bus/cpc/doubler.h",
MAME_DIR .. "src/devices/bus/cpc/transtape.cpp",
MAME_DIR .. "src/devices/bus/cpc/transtape.h",
+ MAME_DIR .. "src/devices/bus/cpc/musicmachine.cpp",
+ MAME_DIR .. "src/devices/bus/cpc/musicmachine.h",
}
end
diff --git a/src/devices/bus/cpc/musicmachine.cpp b/src/devices/bus/cpc/musicmachine.cpp
new file mode 100644
index 00000000000..5874b08fa0a
--- /dev/null
+++ b/src/devices/bus/cpc/musicmachine.cpp
@@ -0,0 +1,128 @@
+// license:BSD-3-Clause
+// copyright-holders:Barry Rodewald
+/*
+ * The Music Machine - MIDI and sampling expansion
+ * by Ram Electronics
+ */
+
+#include "emu.h"
+#include "musicmachine.h"
+
+#include "sound/volt_reg.h"
+#include "bus/midi/midi.h"
+#include "machine/clock.h"
+#include "speaker.h"
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(CPC_MUSICMACHINE, cpc_musicmachine_device, "cpcmusic", "The Music Machine")
+
+
+void cpc_musicmachine_device::device_add_mconfig(machine_config &config)
+{
+ ACIA6850(config, m_acia).txd_handler().set("mdout", FUNC(midi_port_device::write_txd));
+ m_acia->irq_handler().set(DEVICE_SELF_OWNER, FUNC(cpc_expansion_slot_device::nmi_w));
+ MIDI_PORT(config, "mdin", midiin_slot, "midiin").rxd_handler().set(m_acia, FUNC(acia6850_device::write_rxd));
+ MIDI_PORT(config, "mdout", midiout_slot, "midiout");
+ clock_device &acia_clock(CLOCK(config, "acia_clock", 31250*16));
+ acia_clock.signal_handler().set(FUNC(cpc_musicmachine_device::write_acia_clock));
+
+ SPEAKER(config, "speaker").front_center();
+ ZN429E(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.2);
+ voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref"));
+ vref.add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT);
+ vref.add_route(0, "dac", -1.0, DAC_VREF_NEG_INPUT);
+
+ // no pass-through
+}
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+cpc_musicmachine_device::cpc_musicmachine_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, CPC_MUSICMACHINE, tag, owner, clock),
+ device_cpc_expansion_card_interface(mconfig, *this),
+ m_slot(nullptr),
+ m_acia(*this,"acia"),
+ m_dac(*this,"dac"),
+ m_irq_select(false)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void cpc_musicmachine_device::device_start()
+{
+ m_slot = dynamic_cast<cpc_expansion_slot_device *>(owner());
+ address_space &space = m_slot->cpu().space(AS_IO);
+
+ space.install_write_handler(0xf8e8,0xf8e8,write8_delegate(FUNC(cpc_musicmachine_device::irqsel_w),this));
+ space.install_readwrite_handler(0xf8ec,0xf8ef,read8_delegate(FUNC(cpc_musicmachine_device::acia_r), this),write8_delegate(FUNC(cpc_musicmachine_device::acia_w),this));
+ space.install_write_handler(0xf8f0,0xf8f0,write8_delegate(FUNC(cpc_musicmachine_device::dac_w),this));
+ // 0xf8f4 - ADC read8_delegate
+ // 0xf8f8 - ADC start
+}
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void cpc_musicmachine_device::device_reset()
+{
+ // TODO
+}
+
+WRITE8_MEMBER(cpc_musicmachine_device::dac_w)
+{
+ m_dac->write(data);
+}
+
+READ8_MEMBER(cpc_musicmachine_device::acia_r)
+{
+ uint8_t ret = 0;
+
+ switch(offset)
+ {
+ case 2:
+ ret = m_acia->status_r();
+ break;
+ case 3:
+ ret = m_acia->data_r();
+ break;
+ }
+
+ return ret;
+}
+
+WRITE8_MEMBER(cpc_musicmachine_device::acia_w)
+{
+ switch(offset)
+ {
+ case 0:
+ m_acia->control_w(data);
+ break;
+ case 1:
+ m_acia->data_w(data);
+ break;
+ }
+}
+
+WRITE8_MEMBER(cpc_musicmachine_device::irqsel_w)
+{
+ if(data == 0x01)
+ m_irq_select = true;
+ else
+ m_irq_select = false;
+}
+
+WRITE_LINE_MEMBER(cpc_musicmachine_device::irq_w)
+{
+ if(m_irq_select)
+ m_slot->nmi_w(state);
+}
+
diff --git a/src/devices/bus/cpc/musicmachine.h b/src/devices/bus/cpc/musicmachine.h
new file mode 100644
index 00000000000..185882814e1
--- /dev/null
+++ b/src/devices/bus/cpc/musicmachine.h
@@ -0,0 +1,54 @@
+// license:BSD-3-Clause
+// copyright-holders:Barry Rodewald
+/*
+ * The Music Machine - MIDI and sampling expansion
+ * by Ram Electronics
+ *
+ * Contains a 6850 AICA, Ferranti ZN429E8 DAC and ZN449 ADC
+ */
+
+#ifndef MAME_BUS_CPC_MUSICMACHINE_H
+#define MAME_BUS_CPC_MUSICMACHINE_H
+
+#pragma once
+
+#include "cpcexp.h"
+#include "machine/6850acia.h"
+#include "sound/dac.h"
+
+class cpc_musicmachine_device : public device_t,
+ public device_cpc_expansion_card_interface
+{
+public:
+ // construction/destruction
+ cpc_musicmachine_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ DECLARE_WRITE8_MEMBER(dac_w);
+ DECLARE_READ8_MEMBER(acia_r);
+ DECLARE_WRITE8_MEMBER(acia_w);
+ DECLARE_WRITE8_MEMBER(irqsel_w);
+ DECLARE_WRITE_LINE_MEMBER(irq_w);
+
+ void write_acia_clock(u8 data) { m_acia->write_txc(data); m_acia->write_rxc(data); }
+
+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;
+
+private:
+ cpc_expansion_slot_device *m_slot;
+
+ required_device<acia6850_device> m_acia;
+ required_device<dac_byte_interface> m_dac;
+
+ bool m_irq_select;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(CPC_MUSICMACHINE, cpc_musicmachine_device)
+
+#endif // MAME_BUS_CPC_MUSICMACHINE_H
diff --git a/src/mame/drivers/amstrad.cpp b/src/mame/drivers/amstrad.cpp
index b346a125a5d..d66c9a3b7f9 100644
--- a/src/mame/drivers/amstrad.cpp
+++ b/src/mame/drivers/amstrad.cpp
@@ -833,6 +833,7 @@ void cpc464_exp_cards(device_slot_interface &device)
device.option_add("hd20", CPC_HD20);
device.option_add("doubler", CPC_DOUBLER);
device.option_add("transtape", CPC_TRANSTAPE);
+ device.option_add("musicmachine", CPC_MUSICMACHINE);
}
void cpc_exp_cards(device_slot_interface &device)
@@ -852,6 +853,7 @@ void cpc_exp_cards(device_slot_interface &device)
device.option_add("hd20", CPC_HD20);
device.option_add("doubler", CPC_DOUBLER);
device.option_add("transtape", CPC_TRANSTAPE);
+ device.option_add("musicmachine", CPC_MUSICMACHINE);
}
void cpcplus_exp_cards(device_slot_interface &device)
@@ -869,6 +871,7 @@ void cpcplus_exp_cards(device_slot_interface &device)
device.option_add("hd20", CPC_HD20);
device.option_add("doubler", CPC_DOUBLER);
device.option_add("transtape", CPC_TRANSTAPE); // Plus compatible?
+ device.option_add("musicmachine", CPC_MUSICMACHINE);
}
void aleste_exp_cards(device_slot_interface &device)
@@ -888,6 +891,7 @@ void aleste_exp_cards(device_slot_interface &device)
device.option_add("hd20", CPC_HD20);
device.option_add("doubler", CPC_DOUBLER);
device.option_add("transtape", CPC_TRANSTAPE);
+ device.option_add("musicmachine", CPC_MUSICMACHINE);
device.option_add("magicsound", AL_MAGICSOUND);
}
diff --git a/src/mame/includes/amstrad.h b/src/mame/includes/amstrad.h
index b14adeb368e..4019afdbd52 100644
--- a/src/mame/includes/amstrad.h
+++ b/src/mame/includes/amstrad.h
@@ -34,6 +34,7 @@
#include "bus/cpc/magicsound.h"
#include "bus/cpc/doubler.h"
#include "bus/cpc/transtape.h"
+#include "bus/cpc/musicmachine.h"
#include "machine/ram.h"
#include "imagedev/cassette.h"
#include "bus/centronics/ctronics.h"