diff options
author | 2025-04-14 11:31:53 +0200 | |
---|---|---|
committer | 2025-04-14 22:28:31 +0200 | |
commit | cef6157803320544651bfc96457d2f8a6df0abd6 (patch) | |
tree | f8a64867e3d654cdcad5f4c24824ea82e2c77194 /src/devices/bus/st | |
parent | 9473c027358e1a2d5c93d240a48052368f9d3b84 (diff) |
New sound infrastructure.sound
Should be added soon:
- mute
- lua hookup (with documentation)
- speaker/microphone resampling
To be added a little later:
- compression
- reverb
Needs to be added by someone else:
- coreaudio
- direct
- portaudio
- xaudio2
- js
Diffstat (limited to 'src/devices/bus/st')
-rw-r--r-- | src/devices/bus/st/replay.cpp | 108 | ||||
-rw-r--r-- | src/devices/bus/st/replay.h | 15 | ||||
-rw-r--r-- | src/devices/bus/st/stcart.cpp | 40 | ||||
-rw-r--r-- | src/devices/bus/st/stcart.h | 50 |
4 files changed, 213 insertions, 0 deletions
diff --git a/src/devices/bus/st/replay.cpp b/src/devices/bus/st/replay.cpp new file mode 100644 index 00000000000..f7df23a2dcc --- /dev/null +++ b/src/devices/bus/st/replay.cpp @@ -0,0 +1,108 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// Microdeal ST Replay + +// A 8-bit mono DAC and a 8-bit mono ADC on a cartridge, with a vague +// lowpass filter. + +// A peculiarity of the ST cartridge port is that it's readonly. So +// writing to the DAC is done by reading at an appropriate address. + +#include "emu.h" +#include "replay.h" + +#include "sound/adc.h" +#include "sound/dac.h" +#include "speaker.h" + +namespace { + +class st_replay_device : public device_t, public device_stcart_interface +{ +public: + st_replay_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + virtual ~st_replay_device(); + + virtual void map(address_space_installer &space) override; + +protected: + virtual void device_start() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; + +private: + required_device<zn449_device> m_adc; + required_device<zn429e_device> m_dac; + required_device<microphone_device> m_mic; + required_device<speaker_device> m_speaker; + + void cartmap(address_map &map) ATTR_COLD; + + u16 dac_w(offs_t data); + u8 adc_r(); +}; + +st_replay_device::st_replay_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, ST_REPLAY, tag, owner, clock), + device_stcart_interface(mconfig, *this), + m_adc(*this, "adc"), + m_dac(*this, "dac"), + m_mic(*this, "mic"), + m_speaker(*this, "speaker") +{ +} + +st_replay_device::~st_replay_device() +{ +} + +u16 st_replay_device::dac_w(offs_t data) +{ + m_dac->write(data); + return 0xffff; +} + +u8 st_replay_device::adc_r() +{ + double tm = machine().time().as_double(); + s8 level = 127 * sin(tm*440*2*M_PI); + return level + 0x80; +} + +void st_replay_device::map(address_space_installer &space) +{ + space.install_device(0xfa0000, 0xfbffff, *this, &st_replay_device::cartmap); +} + +void st_replay_device::cartmap(address_map &map) +{ + map(0x00000, 0x001ff).r(FUNC(st_replay_device::dac_w)).mirror(0xfe00); + map(0x10001, 0x10001).r(m_adc, FUNC(zn449_device::read)).mirror(0xfffe); +} + +void st_replay_device::device_add_mconfig(machine_config &config) +{ + MICROPHONE(config, m_mic, 1).front_center(); + m_mic->add_route(0, m_adc, 1.0, 0); + + ZN449(config, m_adc); + + // ZN429D the schematics say, not sure if any significant difference + ZN429E(config, m_dac); + m_dac->add_route(0, m_speaker, 1.0, 0); + + SPEAKER(config, m_speaker, 1).front_center(); +} + +void st_replay_device::device_start() +{ +} + +void st_replay_device::device_reset() +{ +} + +} // anonymous namespace + +DEFINE_DEVICE_TYPE_PRIVATE(ST_REPLAY, device_stcart_interface, st_replay_device, "st_replay", "Microdeal ST Replay") diff --git a/src/devices/bus/st/replay.h b/src/devices/bus/st/replay.h new file mode 100644 index 00000000000..b6e2c73a062 --- /dev/null +++ b/src/devices/bus/st/replay.h @@ -0,0 +1,15 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#ifndef MAME_BUS_ST_REPLAY_H +#define MAME_BUS_ST_REPLAY_H + +// Microdeal ST Replay + +#pragma once + +#include "stcart.h" + +DECLARE_DEVICE_TYPE(ST_REPLAY, device_stcart_interface) + +#endif // MAME_BUS_ST_REPLAY_H diff --git a/src/devices/bus/st/stcart.cpp b/src/devices/bus/st/stcart.cpp new file mode 100644 index 00000000000..0e53093bf92 --- /dev/null +++ b/src/devices/bus/st/stcart.cpp @@ -0,0 +1,40 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "stcart.h" + +#include "replay.h" + +DEFINE_DEVICE_TYPE(STCART_CONNECTOR, stcart_connector, "stcart_connector", "Atari ST cartridge connector") + +stcart_connector::stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, STCART_CONNECTOR, tag, owner, clock), + device_single_card_slot_interface<device_stcart_interface>(mconfig, *this) +{ +} + +void stcart_connector::device_start() +{ +} + +void stcart_connector::map(address_space_installer &space) +{ + auto card = get_card_device(); + if(card) + card->map(space); +} + +void stcart_intf(device_slot_interface &device) +{ + device.option_add("replay", ST_REPLAY); +} + +device_stcart_interface::device_stcart_interface(const machine_config &mconfig, device_t &device) : + device_interface(device, "stcart") +{ +} + +device_stcart_interface::~device_stcart_interface() +{ +} diff --git a/src/devices/bus/st/stcart.h b/src/devices/bus/st/stcart.h new file mode 100644 index 00000000000..49ccb78a2e6 --- /dev/null +++ b/src/devices/bus/st/stcart.h @@ -0,0 +1,50 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +// Atari ST cartridges + +#ifndef MAME_BUS_ST_STCART_H +#define MAME_BUS_ST_STCART_H + +#pragma once + +class device_stcart_interface; + +class stcart_connector: public device_t, public device_single_card_slot_interface<device_stcart_interface> +{ +public: + template <typename T> + stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt) + : stcart_connector(mconfig, tag, owner, (uint32_t)0) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + + stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + void map(address_space_installer &space); + +protected: + virtual void device_start() override ATTR_COLD; +}; + +class device_stcart_interface: public device_interface +{ +public: + device_stcart_interface(const machine_config &mconfig, device_t &device); + virtual ~device_stcart_interface(); + + virtual void map(address_space_installer &space) = 0; + +protected: + +}; + +DECLARE_DEVICE_TYPE(STCART_CONNECTOR, stcart_connector) + +void stcart_intf(device_slot_interface &device); + +#endif // MAME_BUS_ST_STCART_H |