diff options
author | 2021-05-31 11:20:28 -0700 | |
---|---|---|
committer | 2021-05-31 11:20:28 -0700 | |
commit | 05cacea947d7db129c25f33c85aca7ec74be6799 (patch) | |
tree | 1211caac4a3428254f73596af8c61b0b6fe9f9b1 /src/devices/sound/ym2154.h | |
parent | b1e775504bb02c1168d64853ca058cbcce6b5978 (diff) |
ympsr60: Fleshed out the PSR60/PSR70 drivers
* Split YM2154 into a separate device
* Created fake YM2154 ROMs as placeholders
* Created new BBD sound device in src/devices/sound/bbd.cpp
* Created new mixer device in src/devices/sound/mixer.cpp
* Connected YM2154 and BBD devices
* Approximated BBD driver behavior
* Exposed analog sliders as adjusters (accessible via ` menu)
* Added sliders to layout and animated them
Diffstat (limited to 'src/devices/sound/ym2154.h')
-rw-r--r-- | src/devices/sound/ym2154.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/src/devices/sound/ym2154.h b/src/devices/sound/ym2154.h new file mode 100644 index 00000000000..58976f0177b --- /dev/null +++ b/src/devices/sound/ym2154.h @@ -0,0 +1,99 @@ +// license:BSD-3-Clause +// copyright-holders:Aaron Giles +#ifndef MAME_SOUND_YM2154_H +#define MAME_SOUND_YM2154_H + +#pragma once + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +DECLARE_DEVICE_TYPE(YM2154, ym2154_device) + +// ======================> ym2154_device + +class ym2154_device : public device_t, public device_sound_interface, public device_memory_interface +{ + static constexpr uint8_t ADDR_SHIFT = 6; + +public: + // internal constructor + ym2154_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + // configuration helpers + auto irq_handler() { return m_update_irq.bind(); } + auto io_read_handler() { return m_io_read.bind(); } + auto io_write_handler() { return m_io_write.bind(); } + + // register reads + u8 read(offs_t offset); + + // register writes + void write(offs_t offset, u8 data); + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_clock_changed() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + + // sound overrides + virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + + // memory space configuration + virtual space_config_vector memory_space_config() const override; + +private: + struct channel + { + channel() : + m_pos(0xfffffff), m_start(0), m_end(0), m_panpot(0), m_output_level(0), m_rate(0) { } + + void reset() + { + m_pos = 0; + m_start = m_end = 0; + m_panpot = 0; + m_output_level = 0; + m_rate = 0; + } + + void start() + { + m_pos = m_start << ADDR_SHIFT; + } + + uint32_t m_pos; + uint16_t m_start; + uint16_t m_end; + uint8_t m_panpot; + uint8_t m_output_level; + uint8_t m_rate; + }; + + // internal helpers + u32 sample_rate() const { return device_t::clock() / 18 / 6; } + void update_irq_state(u8 state) { if (m_irq_state != state) { m_irq_state = state; m_update_irq(state); } } + + // internal state + sound_stream *m_stream; // sound stream + emu_timer *m_timer; // two timers + uint16_t m_timer_count; // current timer count + uint8_t m_timer_enable; // timer enable + uint8_t m_irq_state; // current IRQ state + uint8_t m_irq_count; // current IRQ count + uint8_t m_total_level; // master volume + channel m_channel[12]; // output channels + devcb_write_line m_update_irq; // IRQ update callback + devcb_read8 m_io_read; // input port handler + devcb_write8 m_io_write; // output port handler + address_space_config const m_group0_config; // address space 0 config + address_space_config const m_group1_config; // address space 1 config + optional_memory_region m_group0_region; // group 0 memory region + optional_memory_region m_group1_region; // group 1 memory region +}; + + +#endif // MAME_SOUND_YM2154_H |