diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 1a8a700e78bc8..62d7620c53219 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -919,6 +919,8 @@ if (BUSES["BK_PARALLEL"]~=null) then MAME_DIR .. "src/devices/bus/bk/joystick.h", MAME_DIR .. "src/devices/bus/bk/loopback.cpp", MAME_DIR .. "src/devices/bus/bk/loopback.h", + MAME_DIR .. "src/devices/bus/bk/menestrel.cpp", + MAME_DIR .. "src/devices/bus/bk/menestrel.h", MAME_DIR .. "src/devices/bus/bk/printer.cpp", MAME_DIR .. "src/devices/bus/bk/printer.h", } diff --git a/src/devices/bus/bk/ay.cpp b/src/devices/bus/bk/ay.cpp index 993ecf5dbf525..7eb9f119c0e49 100644 --- a/src/devices/bus/bk/ay.cpp +++ b/src/devices/bus/bk/ay.cpp @@ -102,4 +102,4 @@ void bk_ay_device::io_w(uint16_t data, bool word) // DEVICE DEFINITIONS //************************************************************************** -DEFINE_DEVICE_TYPE_PRIVATE(BK_AY, device_qbus_card_interface, bk_ay_device, "bk_ay", "BK Single AY Interface") +DEFINE_DEVICE_TYPE_PRIVATE(BK_AY, device_bk_parallel_interface, bk_ay_device, "bk_ay", "BK Single AY Interface") diff --git a/src/devices/bus/bk/ay.h b/src/devices/bus/bk/ay.h index 50aca4f1562d4..f4cded2035383 100644 --- a/src/devices/bus/bk/ay.h +++ b/src/devices/bus/bk/ay.h @@ -14,6 +14,6 @@ #include "parallel.h" -DECLARE_DEVICE_TYPE(BK_AY, device_qbus_card_interface) +DECLARE_DEVICE_TYPE(BK_AY, device_bk_parallel_interface) #endif diff --git a/src/devices/bus/bk/carts.cpp b/src/devices/bus/bk/carts.cpp index 410e921607fc9..38ad33ebb1539 100644 --- a/src/devices/bus/bk/carts.cpp +++ b/src/devices/bus/bk/carts.cpp @@ -13,6 +13,7 @@ #include "covox.h" #include "joystick.h" #include "loopback.h" +#include "menestrel.h" #include "printer.h" @@ -20,7 +21,9 @@ void bk_parallel_devices(device_slot_interface &device) { device.option_add("ay", BK_AY); device.option_add("covox", BK_COVOX); + device.option_add("covox_stereo", BK_COVOX_STEREO); device.option_add("joystick", BK_JOYSTICK); device.option_add("loopback", BK_LOOPBACK); + device.option_add("menestrel", BK_MENESTREL); device.option_add("printer", BK_PRINTER); } diff --git a/src/devices/bus/bk/covox.cpp b/src/devices/bus/bk/covox.cpp index 142b146167365..8c119787e99d2 100644 --- a/src/devices/bus/bk/covox.cpp +++ b/src/devices/bus/bk/covox.cpp @@ -2,7 +2,7 @@ // copyright-holders:Sergey Svishchev /*************************************************************************** - Mono Covox interface with passthrough for loopback cart + BK Covox interfaces with passthrough for loopback cart (used by "In Your Space" demo.) ***************************************************************************/ @@ -81,6 +81,75 @@ void bk_covox_device::io_w(uint16_t data, bool word) m_up->write(0, data ^ 0xffff, word); } + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class bk_covox_stereo_device : public device_t, public device_bk_parallel_interface +{ +public: + // construction/destruction + bk_covox_stereo_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + virtual void device_start() override ATTR_COLD {}; + + virtual uint16_t io_r() override; + virtual void io_w(uint16_t data, bool word) override; + +private: + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; + + required_device m_ldac; + required_device m_rdac; + required_device m_up; +}; + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// bk_covox_stereo_device - constructor +//------------------------------------------------- + +bk_covox_stereo_device::bk_covox_stereo_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BK_COVOX_STEREO, tag, owner, clock) + , device_bk_parallel_interface(mconfig, *this) + , m_ldac(*this, "ldac") + , m_rdac(*this, "rdac") + , m_up(*this, "up") +{ +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +void bk_covox_stereo_device::device_add_mconfig(machine_config &config) +{ + SPEAKER(config, "covox", 2).front(); + DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "covox", 0.5, 0); // unknown DAC + DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "covox", 0.5, 1); // unknown DAC + + BK_PARALLEL_SLOT(config, m_up, DERIVED_CLOCK(1, 1), bk_parallel_devices, nullptr); +} + +uint16_t bk_covox_stereo_device::io_r() +{ + return m_up->read() ^ 0xffff; +} + +void bk_covox_stereo_device::io_w(uint16_t data, bool word) +{ + m_ldac->write(data); + m_rdac->write(data >> 8); + m_up->write(0, data ^ 0xffff, word); +} + + } // anonymous namespace @@ -88,4 +157,5 @@ void bk_covox_device::io_w(uint16_t data, bool word) // DEVICE DEFINITIONS //************************************************************************** -DEFINE_DEVICE_TYPE_PRIVATE(BK_COVOX, device_qbus_card_interface, bk_covox_device, "bk_covox", "BK Mono Covox Interface") +DEFINE_DEVICE_TYPE_PRIVATE(BK_COVOX, device_bk_parallel_interface, bk_covox_device, "bk_covox", "BK Mono Covox Interface") +DEFINE_DEVICE_TYPE_PRIVATE(BK_COVOX_STEREO, device_bk_parallel_interface, bk_covox_stereo_device, "bk_covox_stereo", "BK Stereo Covox Interface") diff --git a/src/devices/bus/bk/covox.h b/src/devices/bus/bk/covox.h index 80d8150339095..ec00670d1e3b9 100644 --- a/src/devices/bus/bk/covox.h +++ b/src/devices/bus/bk/covox.h @@ -2,7 +2,7 @@ // copyright-holders:Sergey Svishchev /*************************************************************************** - Mono Covox interface + BK Covox interface ***************************************************************************/ @@ -14,6 +14,7 @@ #include "parallel.h" -DECLARE_DEVICE_TYPE(BK_COVOX, device_qbus_card_interface) +DECLARE_DEVICE_TYPE(BK_COVOX, device_bk_parallel_interface) +DECLARE_DEVICE_TYPE(BK_COVOX_STEREO, device_bk_parallel_interface) #endif diff --git a/src/devices/bus/bk/joystick.cpp b/src/devices/bus/bk/joystick.cpp index 75268ee826e9b..1e570d39e2a33 100644 --- a/src/devices/bus/bk/joystick.cpp +++ b/src/devices/bus/bk/joystick.cpp @@ -96,4 +96,4 @@ uint16_t bk_joystick_device::io_r() // DEVICE DEFINITIONS //************************************************************************** -DEFINE_DEVICE_TYPE_PRIVATE(BK_JOYSTICK, device_qbus_card_interface, bk_joystick_device, "bk_joystick", "BK Joystick Interface") +DEFINE_DEVICE_TYPE_PRIVATE(BK_JOYSTICK, device_bk_parallel_interface, bk_joystick_device, "bk_joystick", "BK Joystick Interface") diff --git a/src/devices/bus/bk/joystick.h b/src/devices/bus/bk/joystick.h index 71190540e81ff..5d0f705bb289c 100644 --- a/src/devices/bus/bk/joystick.h +++ b/src/devices/bus/bk/joystick.h @@ -14,6 +14,6 @@ #include "parallel.h" -DECLARE_DEVICE_TYPE(BK_JOYSTICK, device_qbus_card_interface) +DECLARE_DEVICE_TYPE(BK_JOYSTICK, device_bk_parallel_interface) #endif diff --git a/src/devices/bus/bk/loopback.cpp b/src/devices/bus/bk/loopback.cpp index 96885322f0cde..1f6c56b0805ec 100644 --- a/src/devices/bus/bk/loopback.cpp +++ b/src/devices/bus/bk/loopback.cpp @@ -76,4 +76,4 @@ void bk_loopback_device::io_w(uint16_t data, bool word) // DEVICE DEFINITIONS //************************************************************************** -DEFINE_DEVICE_TYPE_PRIVATE(BK_LOOPBACK, device_qbus_card_interface, bk_loopback_device, "bk_loopback", "BK Loopback") +DEFINE_DEVICE_TYPE_PRIVATE(BK_LOOPBACK, device_bk_parallel_interface, bk_loopback_device, "bk_loopback", "BK Loopback") diff --git a/src/devices/bus/bk/loopback.h b/src/devices/bus/bk/loopback.h index 33b0df32e6858..36b1166c5e220 100644 --- a/src/devices/bus/bk/loopback.h +++ b/src/devices/bus/bk/loopback.h @@ -14,6 +14,6 @@ #include "parallel.h" -DECLARE_DEVICE_TYPE(BK_LOOPBACK, device_qbus_card_interface) +DECLARE_DEVICE_TYPE(BK_LOOPBACK, device_bk_parallel_interface) #endif diff --git a/src/devices/bus/bk/menestrel.cpp b/src/devices/bus/bk/menestrel.cpp new file mode 100644 index 0000000000000..7ff86db8b2592 --- /dev/null +++ b/src/devices/bus/bk/menestrel.cpp @@ -0,0 +1,209 @@ +// license:BSD-3-Clause +// copyright-holders:Sergey Svishchev +/*************************************************************************** + + BK "Menestrel" sound interface. + + Six channels of filtered square wave output from two 8253 timers. + Stereo output via DIN connector, no balance or volume controls. + + Has software support in ROM 370. + + Not implemented: filter, clock phase offset. + +***************************************************************************/ + +#include "emu.h" +#include "menestrel.h" + +#include "machine/pit8253.h" +#include "sound/spkrdev.h" +#include "speaker.h" + + +namespace { + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> bk_menestrel_device + +class bk_menestrel_device : public device_t, public device_bk_parallel_interface +{ +public: + // construction/destruction + bk_menestrel_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + virtual void device_start() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; + + virtual ioport_constructor device_input_ports() const override ATTR_COLD; + + virtual void io_w(uint16_t data, bool word) override; + +private: + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; + + required_device_array m_timer; + required_ioport m_config; + required_device m_lspeaker; + required_device m_rspeaker; + + uint16_t m_data; + + int m_out[6]; + + template void lspeaker_changed(int state); + template void rspeaker_changed(int state); + void out5_changed(int state); +}; + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +static INPUT_PORTS_START(config) + PORT_START("CONFIG") + PORT_DIPNAME(0x01, 0x00, "Timer interrupt") + PORT_DIPSETTING(0x01, DEF_STR(Yes) ) + PORT_DIPSETTING(0x00, DEF_STR(No) ) +INPUT_PORTS_END + +ioport_constructor bk_menestrel_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(config); +} + +static const double speaker_levels[] = {-1.0, -0.33333, 0.33333, 1.0}; + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// bk_menestrel_device - constructor +//------------------------------------------------- + +bk_menestrel_device::bk_menestrel_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BK_MENESTREL, tag, owner, clock) + , device_bk_parallel_interface(mconfig, *this) + , m_timer(*this, "timer%u", 0U) + , m_config(*this, "CONFIG") + , m_lspeaker(*this, "lspeaker") + , m_rspeaker(*this, "rspeaker") +{ +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +void bk_menestrel_device::device_add_mconfig(machine_config &config) +{ + PIT8253(config, m_timer[0], 0); + m_timer[0]->set_clk<0>(XTAL(1'000'000)); + m_timer[0]->out_handler<0>().set(FUNC(bk_menestrel_device::lspeaker_changed<0>)); + m_timer[0]->set_clk<1>(XTAL(1'000'000)); + m_timer[0]->out_handler<1>().set(FUNC(bk_menestrel_device::lspeaker_changed<1>)); + m_timer[0]->set_clk<2>(XTAL(1'000'000)); + m_timer[0]->out_handler<2>().set(FUNC(bk_menestrel_device::lspeaker_changed<2>)); + + PIT8253(config, m_timer[1], 0); + m_timer[1]->set_clk<0>(XTAL(1'000'000)); + m_timer[1]->out_handler<0>().set(FUNC(bk_menestrel_device::rspeaker_changed<0>)); + m_timer[1]->set_clk<1>(XTAL(1'000'000)); + m_timer[1]->out_handler<1>().set(FUNC(bk_menestrel_device::rspeaker_changed<1>)); + m_timer[1]->set_clk<2>(XTAL(1'000'000)); + m_timer[1]->out_handler<2>().set(FUNC(bk_menestrel_device::out5_changed)); + + SPEAKER(config, "dd1").front_left(); + SPEAKER_SOUND(config, m_lspeaker); + m_lspeaker->set_levels(4, speaker_levels); + m_lspeaker->add_route(ALL_OUTPUTS, "dd1", 0.25); + + SPEAKER(config, "dd2").front_right(); + SPEAKER_SOUND(config, m_rspeaker); + m_rspeaker->set_levels(4, speaker_levels); + m_rspeaker->add_route(ALL_OUTPUTS, "dd2", 0.25); +} + + +template void bk_menestrel_device::lspeaker_changed(int state) +{ + if (state > 1) return; + m_out[channel] = state; + m_lspeaker->level_w(m_out[0] + m_out[1] + m_out[2]); +} + +template void bk_menestrel_device::rspeaker_changed(int state) +{ + if (state > 1) return; + m_out[3 + channel] = state; + m_rspeaker->level_w(m_out[3] + m_out[4] + m_out[5]); +} + +void bk_menestrel_device::out5_changed(int state) +{ + if (state > 1) return; + if (m_config->read()) + { + m_slot->irq2_w(!state); + } + else + { + m_out[5] = state; + m_rspeaker->level_w(m_out[3] + m_out[4] + m_out[5]); + } +} + + +void bk_menestrel_device::device_start() +{ + save_item(NAME(m_data)); + save_item(NAME(m_out)); + + std::fill(std::begin(m_out), std::end(m_out), 0); +} + +void bk_menestrel_device::device_reset() +{ + m_slot->irq2_w(0); + m_lspeaker->level_w(0); + m_rspeaker->level_w(0); +} + +void bk_menestrel_device::io_w(uint16_t data, bool word) +{ + if (BIT(data ^ m_data, 12) && !BIT(data, 12)) // ~WR edge + { + if (!BIT(data, 10)) m_timer[0]->write(bitswap<2>(data, 9, 8), data & 255); + if (!BIT(data, 11)) m_timer[1]->write(bitswap<2>(data, 9, 8), data & 255); + } + + if (BIT(data ^ m_data, 15)) + { + const int gate = BIT(data, 15); + m_timer[0]->write_gate0(gate); + m_timer[0]->write_gate1(gate); + m_timer[0]->write_gate2(gate); + m_timer[1]->write_gate0(gate); + m_timer[1]->write_gate1(gate); + m_timer[1]->write_gate2(gate); + } + + m_data = data; +} + +} // anonymous namespace + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE_PRIVATE(BK_MENESTREL, device_bk_parallel_interface, bk_menestrel_device, "bk_menestrel", "Menestrel Interface") diff --git a/src/devices/bus/bk/menestrel.h b/src/devices/bus/bk/menestrel.h new file mode 100644 index 0000000000000..4a33ff55e58e3 --- /dev/null +++ b/src/devices/bus/bk/menestrel.h @@ -0,0 +1,19 @@ +// license:BSD-3-Clause +// copyright-holders:Sergey Svishchev +/*************************************************************************** + + BK "Menestrel" sound interface. + +***************************************************************************/ + +#ifndef MAME_BUS_BK_MENESTREL_H +#define MAME_BUS_BK_MENESTREL_H + +#pragma once + +#include "parallel.h" + + +DECLARE_DEVICE_TYPE(BK_MENESTREL, device_bk_parallel_interface) + +#endif diff --git a/src/devices/bus/bk/printer.cpp b/src/devices/bus/bk/printer.cpp index 9e38c90033827..548c374572b64 100644 --- a/src/devices/bus/bk/printer.cpp +++ b/src/devices/bus/bk/printer.cpp @@ -98,4 +98,4 @@ void bk_printer_device::io_w(uint16_t data, bool word) // DEVICE DEFINITIONS //************************************************************************** -DEFINE_DEVICE_TYPE_PRIVATE(BK_PRINTER, device_qbus_card_interface, bk_printer_device, "bk_printer", "BK Printer Interface") +DEFINE_DEVICE_TYPE_PRIVATE(BK_PRINTER, device_bk_parallel_interface, bk_printer_device, "bk_printer", "BK Printer Interface") diff --git a/src/devices/bus/bk/printer.h b/src/devices/bus/bk/printer.h index 6eead39cba838..ad75862d3b8e4 100644 --- a/src/devices/bus/bk/printer.h +++ b/src/devices/bus/bk/printer.h @@ -14,6 +14,6 @@ #include "parallel.h" -DECLARE_DEVICE_TYPE(BK_PRINTER, device_qbus_card_interface) +DECLARE_DEVICE_TYPE(BK_PRINTER, device_bk_parallel_interface) #endif