|
| 1 | +// license:BSD-3-Clause |
| 2 | +// copyright-holders:Andrei I. Holub |
| 3 | +/* |
| 4 | + * The Music Machine - MIDI and sampling expansion |
| 5 | + * by Ram Electronics Ltd |
| 6 | + */ |
| 7 | + |
| 8 | +#include "emu.h" |
| 9 | +#include "musicmachine.h" |
| 10 | + |
| 11 | +#include "bus/midi/midi.h" |
| 12 | +#include "machine/clock.h" |
| 13 | +#include "speaker.h" |
| 14 | + |
| 15 | + |
| 16 | +//************************************************************************** |
| 17 | +// DEVICE DEFINITIONS |
| 18 | +//************************************************************************** |
| 19 | + |
| 20 | +DEFINE_DEVICE_TYPE(SPECTRUM_MUSICMACHINE, spectrum_musicmachine_device, "spectrummusic", "The Music Machine (ZX)") |
| 21 | + |
| 22 | + |
| 23 | +void spectrum_musicmachine_device::device_add_mconfig(machine_config &config) |
| 24 | +{ |
| 25 | + ACIA6850(config, m_acia).txd_handler().set("mdout", FUNC(midi_port_device::write_txd)); |
| 26 | + m_acia->irq_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::nmi_w)); |
| 27 | + MIDI_PORT(config, "mdin", midiin_slot, "midiin").rxd_handler().set(m_acia, FUNC(acia6850_device::write_rxd)); |
| 28 | + MIDI_PORT(config, "mdout", midiout_slot, "midiout"); |
| 29 | + clock_device &acia_clock(CLOCK(config, "acia_clock", 31250*16)); |
| 30 | + acia_clock.signal_handler().set(FUNC(spectrum_musicmachine_device::write_acia_clock)); |
| 31 | + |
| 32 | + SPEAKER(config, "speaker").front_center(); |
| 33 | + ZN429E(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.2); |
| 34 | +} |
| 35 | + |
| 36 | +//************************************************************************** |
| 37 | +// LIVE DEVICE |
| 38 | +//************************************************************************** |
| 39 | + |
| 40 | +spectrum_musicmachine_device::spectrum_musicmachine_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : |
| 41 | + device_t(mconfig, SPECTRUM_MUSICMACHINE, tag, owner, clock) |
| 42 | + , device_spectrum_expansion_interface(mconfig, *this) |
| 43 | + , m_acia(*this,"acia") |
| 44 | + , m_dac(*this,"dac") |
| 45 | +{ |
| 46 | +} |
| 47 | + |
| 48 | +//------------------------------------------------- |
| 49 | +// device_start - device-specific startup |
| 50 | +//------------------------------------------------- |
| 51 | + |
| 52 | +void spectrum_musicmachine_device::device_start() |
| 53 | +{ |
| 54 | +} |
| 55 | + |
| 56 | +//------------------------------------------------- |
| 57 | +// device_reset - device-specific reset |
| 58 | +//------------------------------------------------- |
| 59 | + |
| 60 | +void spectrum_musicmachine_device::device_reset() |
| 61 | +{ |
| 62 | + m_irq_select = false; |
| 63 | +} |
| 64 | + |
| 65 | +void spectrum_musicmachine_device::write_acia_clock(u8 data) |
| 66 | +{ |
| 67 | + m_acia->write_txc(data); |
| 68 | + m_acia->write_rxc(data); |
| 69 | +} |
| 70 | + |
| 71 | +u8 spectrum_musicmachine_device::iorq_r(offs_t offset) |
| 72 | +{ |
| 73 | + u8 data = offset & 1 ? m_slot->fb_r() : 0xff; |
| 74 | + |
| 75 | + switch (offset & 0xff) |
| 76 | + { |
| 77 | + case 0x7f: |
| 78 | + if (offset == 0xfc7f) |
| 79 | + data = m_acia->status_r(); |
| 80 | + else |
| 81 | + data = m_acia->data_r(); |
| 82 | + break; |
| 83 | + case 0xbf: |
| 84 | + // TODO ADC_READ |
| 85 | + break; |
| 86 | + case 0xdf: |
| 87 | + // TODO Strobe: ADC_START |
| 88 | + break; |
| 89 | + } |
| 90 | + |
| 91 | + return data; |
| 92 | +} |
| 93 | + |
| 94 | +void spectrum_musicmachine_device::iorq_w(offs_t offset, u8 data) |
| 95 | +{ |
| 96 | + switch (offset & 0xff) |
| 97 | + { |
| 98 | + case 0x5f: |
| 99 | + m_irq_select = data & 1; |
| 100 | + break; |
| 101 | + case 0x7f: |
| 102 | + if (offset == 0xfc7f) |
| 103 | + m_acia->control_w(data); |
| 104 | + else |
| 105 | + m_acia->data_w(data); |
| 106 | + break; |
| 107 | + case 0x9f: |
| 108 | + m_dac->write(data); |
| 109 | + break; |
| 110 | + case 0xdf: |
| 111 | + // TODO Strobe: ADC_START |
| 112 | + break; |
| 113 | + } |
| 114 | +} |
0 commit comments