From 6a05e695415e092f3ffdd6c7c3b7730980e047d3 Mon Sep 17 00:00:00 2001 From: Olivier Galibert Date: Thu, 7 Dec 2023 10:03:35 +0100 Subject: wavesynth: Slotify the omniwave --- scripts/src/bus.lua | 14 +++++++ src/devices/bus/waveblaster/omniwave.cpp | 48 +++++++++++++++++++++++ src/devices/bus/waveblaster/omniwave.h | 30 +++++++++++++++ src/devices/bus/waveblaster/waveblaster.cpp | 50 ++++++++++++++++++++++++ src/devices/bus/waveblaster/waveblaster.h | 60 +++++++++++++++++++++++++++++ src/mame/virtual/wavesynth.cpp | 22 ++++------- 6 files changed, 210 insertions(+), 14 deletions(-) create mode 100644 src/devices/bus/waveblaster/omniwave.cpp create mode 100644 src/devices/bus/waveblaster/omniwave.h create mode 100644 src/devices/bus/waveblaster/waveblaster.cpp create mode 100644 src/devices/bus/waveblaster/waveblaster.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 9f513014e14..30eb2131b30 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -5364,3 +5364,17 @@ if (BUSES["MC68000_SYSBUS"]~=null) then MAME_DIR .. "src/devices/bus/mc68000/ram.h", } end + +--------------------------------------------------- +-- +--@src/devices/bus/waveblaster/waveblaster.h,BUSES["WAVEBLASTER"] = true +--------------------------------------------------- + +if (BUSES["WAVEBLASTER"]~=null) then + files { + MAME_DIR .. "src/devices/bus/waveblaster/waveblaster.cpp", + MAME_DIR .. "src/devices/bus/waveblaster/waveblaster.h", + MAME_DIR .. "src/devices/bus/waveblaster/omniwave.cpp", + MAME_DIR .. "src/devices/bus/waveblaster/omniwave.h", + } +end diff --git a/src/devices/bus/waveblaster/omniwave.cpp b/src/devices/bus/waveblaster/omniwave.cpp new file mode 100644 index 00000000000..a0f745a1691 --- /dev/null +++ b/src/devices/bus/waveblaster/omniwave.cpp @@ -0,0 +1,48 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// Samsung Omniwave + +#include "emu.h" +#include "omniwave.h" + +DEFINE_DEVICE_TYPE(OMNIWAVE, omniwave_device, "omniwave", "Samsung Omniwave") + +omniwave_device::omniwave_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, OMNIWAVE, tag, owner, clock), + device_waveblaster_interface(mconfig, *this), + m_ks0164(*this, "ks0164") +{ +} + +omniwave_device::~omniwave_device() +{ +} + +void omniwave_device::midi_rx(int state) +{ + m_ks0164->midi_rx(state); +} + +void omniwave_device::device_add_mconfig(machine_config &config) +{ + KS0164(config, m_ks0164, 16.9344_MHz_XTAL); + m_ks0164->add_route(0, "^", 1.0, AUTO_ALLOC_INPUT, 0); + m_ks0164->add_route(1, "^", 1.0, AUTO_ALLOC_INPUT, 1); + m_ks0164->midi_tx().set([this](int state) { m_connector->do_midi_tx(state); } ); +} + +ROM_START( omniwave ) + ROM_REGION16_BE( 0x100000, "ks0164", 0) + ROM_LOAD16_WORD_SWAP("ks0174-1m04.bin", 0, 0x100000, CRC(3cabaa2f) SHA1(1e894c0345eaf0ea713f36a75b065f7ee419c63c)) +ROM_END + +void omniwave_device::device_start() +{ +} + +const tiny_rom_entry *omniwave_device::device_rom_region() const +{ + return ROM_NAME(omniwave); +} + diff --git a/src/devices/bus/waveblaster/omniwave.h b/src/devices/bus/waveblaster/omniwave.h new file mode 100644 index 00000000000..d77a2d09619 --- /dev/null +++ b/src/devices/bus/waveblaster/omniwave.h @@ -0,0 +1,30 @@ +#ifndef MAME_BUS_WAVEBLASTER_OMNIWAVE_H +#define MAME_BUS_WAVEBLASTER_OMNIWAVE_H + +// Samsung Omniwave + +#pragma once + +#include "waveblaster.h" +#include "sound/ks0164.h" + +DECLARE_DEVICE_TYPE(OMNIWAVE, omniwave_device) + +class omniwave_device : public device_t, public device_waveblaster_interface +{ +public: + omniwave_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + virtual ~omniwave_device(); + + virtual void midi_rx(int state) override; + +protected: + virtual void device_start() override; + const tiny_rom_entry *device_rom_region() const override; + virtual void device_add_mconfig(machine_config &config) override; + +private: + required_device m_ks0164; +}; + +#endif // MAME_BUS_WAVEBLASTER_OMNIWAVE_H diff --git a/src/devices/bus/waveblaster/waveblaster.cpp b/src/devices/bus/waveblaster/waveblaster.cpp new file mode 100644 index 00000000000..add80223521 --- /dev/null +++ b/src/devices/bus/waveblaster/waveblaster.cpp @@ -0,0 +1,50 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "waveblaster.h" + +#include "omniwave.h" + + +DEFINE_DEVICE_TYPE(WAVEBLASTER_CONNECTOR, waveblaster_connector, "waveblaster_connector", "Waveblaster extension connector") + +waveblaster_connector::waveblaster_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, WAVEBLASTER_CONNECTOR, tag, owner, clock), + device_single_card_slot_interface(mconfig, *this), + device_mixer_interface(mconfig, *this, 2), + m_midi_tx(*this) +{ +} + +void waveblaster_connector::device_start() +{ + save_item(NAME(m_state_system_is_annoying)); +} + +void waveblaster_connector::midi_rx(int state) +{ + auto card = get_card_device(); + if(card) + card->midi_rx(state); +} + +void waveblaster_intf(device_slot_interface &device) +{ + device.option_add("omniwave", OMNIWAVE); +} + +device_waveblaster_interface::device_waveblaster_interface(const machine_config &mconfig, device_t &device) : + device_interface(device, "waveblaster"), + m_connector(nullptr) +{ +} + +device_waveblaster_interface::~device_waveblaster_interface() +{ +} + +void device_waveblaster_interface::interface_pre_start() +{ + m_connector = downcast(device().owner()); +} diff --git a/src/devices/bus/waveblaster/waveblaster.h b/src/devices/bus/waveblaster/waveblaster.h new file mode 100644 index 00000000000..342dfce9bcc --- /dev/null +++ b/src/devices/bus/waveblaster/waveblaster.h @@ -0,0 +1,60 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +// Waveblaster midi extension cards + +#ifndef MAME_BUS_WAVEBLASTER_WAVEBLASTER_H +#define MAME_BUS_WAVEBLASTER_WAVEBLASTER_H + +#pragma once + +class device_waveblaster_interface; + +class waveblaster_connector: public device_t, public device_single_card_slot_interface, public device_mixer_interface +{ +public: + template + waveblaster_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt) + : waveblaster_connector(mconfig, tag, owner, (uint32_t)0) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + + waveblaster_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + void midi_rx(int state); + auto midi_tx() { return m_midi_tx.bind(); } + + void do_midi_tx(int state) { m_midi_tx(state); } + +protected: + bool m_state_system_is_annoying = true; + devcb_write_line m_midi_tx; + + virtual void device_start() override; +}; + +class device_waveblaster_interface: public device_interface +{ +public: + virtual ~device_waveblaster_interface(); + + virtual void midi_rx(int state) = 0; + +protected: + waveblaster_connector *m_connector; + + device_waveblaster_interface(const machine_config &mconfig, device_t &device); + + virtual void interface_pre_start() override; +}; + +DECLARE_DEVICE_TYPE(WAVEBLASTER_CONNECTOR, waveblaster_connector) + +void waveblaster_intf(device_slot_interface &device); + +#endif // MAME_BUS_WAVEBLASTER_WAVEBLASTER_H + diff --git a/src/mame/virtual/wavesynth.cpp b/src/mame/virtual/wavesynth.cpp index 2f7c59a0f62..c9a9d7d5d1f 100644 --- a/src/mame/virtual/wavesynth.cpp +++ b/src/mame/virtual/wavesynth.cpp @@ -3,15 +3,11 @@ // A "virtual" driver to turn waveblaster cards into a screen-less expander -// Currently KS0164 only, and built-in. Eventually should be slot-based with -// multiple possible cards - #include "emu.h" #include "speaker.h" #include "bus/midi/midiinport.h" #include "bus/midi/midioutport.h" - -#include "sound/ks0164.h" +#include "bus/waveblaster/waveblaster.h" namespace { @@ -27,7 +23,7 @@ public: private: virtual void machine_start() override; - required_device m_waveblaster; + required_device m_waveblaster; }; @@ -41,13 +37,9 @@ void wavesynth_state::machine_start() { } -static INPUT_PORTS_START( wavesynth ) -INPUT_PORTS_END - - void wavesynth_state::wavesynth(machine_config &config) { - KS0164(config, m_waveblaster, 16.9344_MHz_XTAL); + WAVEBLASTER_CONNECTOR(config, m_waveblaster, waveblaster_intf, "omniwave"); m_waveblaster->add_route(0, "lspeaker", 1.0); m_waveblaster->add_route(1, "rspeaker", 1.0); @@ -56,18 +48,20 @@ void wavesynth_state::wavesynth(machine_config &config) auto &mdin(MIDI_PORT(config, "mdin")); midiin_slot(mdin); - mdin.rxd_handler().set(m_waveblaster, FUNC(ks0164_device::midi_rx)); + mdin.rxd_handler().set(m_waveblaster, FUNC(waveblaster_connector::midi_rx)); auto &mdout(MIDI_PORT(config, "mdout")); midiout_slot(mdout); m_waveblaster->midi_tx().set(mdout, FUNC(midi_port_device::write_txd)); } +static INPUT_PORTS_START( wavesynth ) +INPUT_PORTS_END + ROM_START( wavesynth ) - ROM_REGION( 0x100000, "waveblaster", 0) - ROM_LOAD16_WORD_SWAP("ks0174-1m04.bin", 0, 0x100000, CRC(3cabaa2f) SHA1(1e894c0345eaf0ea713f36a75b065f7ee419c63c)) ROM_END + } // anonymous namespace -- cgit v1.2.3