diff options
author | Vas Crabb <vas@vastheman.com> | 2018-05-06 19:19:48 +1000 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2018-05-06 19:19:48 +1000 |
commit | 138b60e6c6078260b12becbc6706fa0523eea506 (patch) | |
tree | 6c5bb013da8e6ea0500148169adf2c8436e900ab /src/devices/sound | |
parent | 495ec11fdf79e06fb5102b395b7316fa273006a7 (diff) |
(nw) misc follow-up
Fix MT06964
Fix µPD7759 class hierarchy, and reset callback before resolving it
(fixed assert in Sega C2)
Remove some more low-value device add indirection macros, default some
more clocks
Make cards inherit clock from slot by default
Diffstat (limited to 'src/devices/sound')
-rw-r--r-- | src/devices/sound/315-5641.cpp | 34 | ||||
-rw-r--r-- | src/devices/sound/315-5641.h | 4 | ||||
-rw-r--r-- | src/devices/sound/segapcm.h | 6 | ||||
-rw-r--r-- | src/devices/sound/snkwave.h | 9 | ||||
-rw-r--r-- | src/devices/sound/upd7759.cpp | 178 | ||||
-rw-r--r-- | src/devices/sound/upd7759.h | 17 | ||||
-rw-r--r-- | src/devices/sound/vrc6.h | 10 | ||||
-rw-r--r-- | src/devices/sound/ym2151.h | 3 | ||||
-rw-r--r-- | src/devices/sound/ymz770.h | 16 |
9 files changed, 65 insertions, 212 deletions
diff --git a/src/devices/sound/315-5641.cpp b/src/devices/sound/315-5641.cpp index f45f3071ae7..10ab5502691 100644 --- a/src/devices/sound/315-5641.cpp +++ b/src/devices/sound/315-5641.cpp @@ -8,38 +8,38 @@ DEFINE_DEVICE_TYPE(SEGA_315_5641_PCM, sega_315_5641_pcm_device, "315_5641_pcm", "Sega 315-5641 PCM") sega_315_5641_pcm_device::sega_315_5641_pcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : upd7759_device(mconfig, SEGA_315_5641_PCM, tag, owner, clock), m_fifo_read(0), m_fifo_write(0) + : upd7756_device(mconfig, SEGA_315_5641_PCM, tag, owner, clock), m_fifo_read(0), m_fifo_write(0) { } void sega_315_5641_pcm_device::device_start() { + upd7756_device::device_start(); + save_item(NAME(m_fifo_data), 0x40); save_item(NAME(m_fifo_read)); save_item(NAME(m_fifo_write)); - - upd7759_device::device_start(); } void sega_315_5641_pcm_device::advance_state() { switch (m_state) { - case STATE_DROP_DRQ: - if (m_rombase == nullptr) + case STATE_DROP_DRQ: + if (m_rombase == nullptr) + { + // Slave Mode: get data from FIFO buffer + uint8_t fiforead = (m_fifo_read + 1) & 0x3F; + if (fiforead != m_fifo_write) { - // Slave Mode: get data from FIFO buffer - uint8_t fiforead = (m_fifo_read + 1) & 0x3F; - if (fiforead != m_fifo_write) - { - m_fifo_in = m_fifo_data[fiforead]; - m_fifo_read = fiforead; - } + m_fifo_in = m_fifo_data[fiforead]; + m_fifo_read = fiforead; } - break; + } + break; } - upd775x_device::advance_state(); + upd7756_device::advance_state(); } @@ -47,7 +47,7 @@ WRITE8_MEMBER( sega_315_5641_pcm_device::port_w ) { if (m_rombase != nullptr) { - /* update the FIFO value */ + // update the FIFO value m_fifo_in = data; } else @@ -65,8 +65,8 @@ uint8_t sega_315_5641_pcm_device::get_fifo_space() void sega_315_5641_pcm_device::device_reset() { + upd7756_device::device_reset(); + m_fifo_read = 0x3F; m_fifo_write = 0x00; - - upd775x_device::device_reset(); } diff --git a/src/devices/sound/315-5641.h b/src/devices/sound/315-5641.h index 700fcaccaa2..1419e83d961 100644 --- a/src/devices/sound/315-5641.h +++ b/src/devices/sound/315-5641.h @@ -13,7 +13,7 @@ #include "upd7759.h" -class sega_315_5641_pcm_device : public upd7759_device +class sega_315_5641_pcm_device : public upd7756_device { public: sega_315_5641_pcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); @@ -27,7 +27,7 @@ protected: virtual void device_start() override; virtual void device_reset() override; - void advance_state() override; + virtual void advance_state() override; uint8_t m_fifo_data[0x40]; uint8_t m_fifo_read; // last read offset (will read in m_fifo_read+1) diff --git a/src/devices/sound/segapcm.h b/src/devices/sound/segapcm.h index fd2847a0f67..3d4004d7814 100644 --- a/src/devices/sound/segapcm.h +++ b/src/devices/sound/segapcm.h @@ -14,12 +14,6 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_SEGAPCM_ADD(tag, clock) \ - MCFG_DEVICE_ADD((tag), SEGAPCM, (clock)) - -#define MCFG_SEGAPCM_REPLACE(tag, clock) \ - MCFG_DEVICE_REPLACE((tag), SEGAPCM, (clock)) - #define MCFG_SEGAPCM_BANK(bank) \ downcast<segapcm_device &>(*device).set_bank((segapcm_device::bank)); diff --git a/src/devices/sound/snkwave.h b/src/devices/sound/snkwave.h index b05f483139d..6f07bca26af 100644 --- a/src/devices/sound/snkwave.h +++ b/src/devices/sound/snkwave.h @@ -5,15 +5,6 @@ #pragma once -//************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_SNKWAVE_ADD(_tag, _clock) \ - MCFG_DEVICE_ADD(_tag, SNKWAVE, _clock) -#define MCFG_SNKWAVE_REPLACE(_tag, _clock) \ - MCFG_DEVICE_REPLACE(_tag, SNKWAVE, _clock) - //************************************************************************** // TYPE DEFINITIONS diff --git a/src/devices/sound/upd7759.cpp b/src/devices/sound/upd7759.cpp index ad046d3382e..5c20e7c13da 100644 --- a/src/devices/sound/upd7759.cpp +++ b/src/devices/sound/upd7759.cpp @@ -174,7 +174,6 @@ upd775x_device::upd775x_device(const machine_config &mconfig, device_type type, , m_rom(nullptr) , m_romoffset(0) , m_rommask(0) - , m_drqcallback(*this) { } @@ -188,6 +187,7 @@ upd7759_device::upd7759_device(const machine_config &mconfig, const char *tag, d upd7759_device::upd7759_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : upd775x_device(mconfig, type, tag, owner, clock) + , m_drqcallback(*this) , m_timer(nullptr) { } @@ -196,7 +196,12 @@ upd7759_device::upd7759_device(const machine_config &mconfig, device_type type, DEFINE_DEVICE_TYPE(UPD7756, upd7756_device, "upd7756", "NEC uPD7756") upd7756_device::upd7756_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : upd775x_device(mconfig, UPD7756, tag, owner, clock) + : upd7756_device(mconfig, UPD7756, tag, owner, clock) +{ +} + +upd7756_device::upd7756_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : upd775x_device(mconfig, type, tag, owner, clock) { } @@ -206,58 +211,41 @@ upd7756_device::upd7756_device(const machine_config &mconfig, const char *tag, d void upd775x_device::device_start() { -} - -void upd7759_device::device_start() -{ - m_drqcallback.resolve_safe(); - - /* chip configuration */ - m_sample_offset_shift = (type() == UPD7759) ? 1 : 0; + // chip configuration + m_sample_offset_shift = 0; - /* allocate a stream channel */ + // allocate a stream channel m_channel = machine().sound().stream_alloc(*this, 0, 1, clock()/4); - /* compute the stepping rate based on the chip's clock speed */ + // compute the stepping rate based on the chip's clock speed m_step = 4 * FRAC_ONE; - /* compute the clock period */ + // compute the clock period m_clock_period = attotime::from_hz(clock()); - /* set the intial state */ + // set the intial state m_state = STATE_IDLE; - /* compute the ROM base or allocate a timer */ + // compute the ROM base or allocate a timer m_romoffset = 0; m_rom = m_rombase; - if (m_rombase != nullptr) + if (m_rombase) { - uint32_t romsize = m_rombase.bytes(); + uint32_t const romsize = m_rombase.bytes(); if (romsize >= 0x20000) - { m_rommask = 0x1ffff; - } else - { m_rommask = romsize - 1; - } - - m_drqcallback.set_callback(DEVCB_NOOP); } else { - assert(type() == UPD7759); // other chips do not support slave mode - m_timer = timer_alloc(TIMER_SLAVE_UPDATE); m_rommask = 0; } - /* assume /RESET and /START are both high */ + // assume /RESET and /START are both high m_reset = 1; m_start = 1; - /* toggle the reset line to finish the reset */ - device_reset(); - save_item(NAME(m_pos)); save_item(NAME(m_step)); @@ -285,86 +273,34 @@ void upd7759_device::device_start() save_item(NAME(m_sample)); save_item(NAME(m_romoffset)); - machine().save().register_postload(save_prepost_delegate(FUNC(upd7759_device::postload), this)); } - -void upd7756_device::device_start() +void upd7759_device::device_start() { - m_drqcallback.resolve_safe(); - - /* chip configuration */ - m_sample_offset_shift = (type() == UPD7759) ? 1 : 0; - - /* allocate a stream channel */ - m_channel = machine().sound().stream_alloc(*this, 0, 1, clock()/4); + upd775x_device::device_start(); - /* compute the stepping rate based on the chip's clock speed */ - m_step = 4 * FRAC_ONE; - - /* compute the clock period */ - m_clock_period = attotime::from_hz(clock()); + // chip configuration + m_sample_offset_shift = 1; - /* set the intial state */ - m_state = STATE_IDLE; - - /* compute the ROM base or allocate a timer */ - m_romoffset = 0; - m_rom = m_rombase; - if (m_rombase != nullptr) - { - uint32_t romsize = m_rombase.bytes(); - if (romsize >= 0x20000) - { - m_rommask = 0x1ffff; - } - else - { - m_rommask = romsize - 1; - } - - m_drqcallback.set_callback(DEVCB_NOOP); - } + // alloate a timer + if (m_rombase) + m_drqcallback.reset(); else - { - m_rommask = 0; - } + m_timer = timer_alloc(TIMER_SLAVE_UPDATE); - /* assume /RESET and /START are both high */ - m_reset = 1; - m_start = 1; + m_drqcallback.resolve_safe(); - /* toggle the reset line to finish the reset */ + // toggle the reset line to finish the reset device_reset(); +} - save_item(NAME(m_pos)); - save_item(NAME(m_step)); - - save_item(NAME(m_fifo_in)); - save_item(NAME(m_reset)); - save_item(NAME(m_start)); - save_item(NAME(m_drq)); - - save_item(NAME(m_state)); - save_item(NAME(m_clocks_left)); - save_item(NAME(m_nibbles_left)); - save_item(NAME(m_repeat_count)); - save_item(NAME(m_post_drq_state)); - save_item(NAME(m_post_drq_clocks)); - save_item(NAME(m_req_sample)); - save_item(NAME(m_last_sample)); - save_item(NAME(m_block_header)); - save_item(NAME(m_sample_rate)); - save_item(NAME(m_first_valid_header)); - save_item(NAME(m_offset)); - save_item(NAME(m_repeat_offset)); - save_item(NAME(m_adpcm_state)); - save_item(NAME(m_adpcm_data)); - save_item(NAME(m_sample)); +void upd7756_device::device_start() +{ + upd775x_device::device_start(); - save_item(NAME(m_romoffset)); - machine().save().register_postload(save_prepost_delegate(FUNC(upd7759_device::postload), this)); + // toggle the reset line to finish the reset + device_reset(); } //------------------------------------------------- @@ -373,10 +309,6 @@ void upd7756_device::device_start() void upd775x_device::device_reset() { -} - -void upd7759_device::device_reset() -{ m_pos = 0; m_fifo_in = 0; m_drq = 0; @@ -396,33 +328,15 @@ void upd7759_device::device_reset() m_adpcm_state = 0; m_adpcm_data = 0; m_sample = 0; - - /* turn off any timer */ - if (m_timer) - m_timer->adjust(attotime::never); } -void upd7756_device::device_reset() +void upd7759_device::device_reset() { - m_pos = 0; - m_fifo_in = 0; - m_drq = 0; - m_state = STATE_IDLE; - m_clocks_left = 0; - m_nibbles_left = 0; - m_repeat_count = 0; - m_post_drq_state = STATE_IDLE; - m_post_drq_clocks = 0; - m_req_sample = 0; - m_last_sample = 0; - m_block_header = 0; - m_sample_rate = 0; - m_first_valid_header = 0; - m_offset = 0; - m_repeat_offset = 0; - m_adpcm_state = 0; - m_adpcm_data = 0; - m_sample = 0; + upd775x_device::device_reset(); + + // turn off any timer + if (m_timer) + m_timer->adjust(attotime::never); } @@ -728,12 +642,10 @@ void upd7759_device::device_timer(emu_timer &timer, device_timer_id id, int para *************************************************************/ -void upd775x_device::postload() +void upd775x_device::device_post_load() { if (m_rombase) - { m_rom = m_rombase + m_romoffset; - } } /************************************************************ @@ -877,13 +789,3 @@ void upd775x_device::sound_stream_update(sound_stream &stream, stream_sample_t * m_clocks_left = clocks_left; m_pos = pos; } - -void upd7759_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - upd775x_device::sound_stream_update(stream, inputs, outputs, samples); -} - -void upd7756_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - upd775x_device::sound_stream_update(stream, inputs, outputs, samples); -} diff --git a/src/devices/sound/upd7759.h b/src/devices/sound/upd7759.h index 419365fc9e3..6c41e4b0f43 100644 --- a/src/devices/sound/upd7759.h +++ b/src/devices/sound/upd7759.h @@ -18,14 +18,11 @@ class upd775x_device : public device_t, public device_sound_interface public: enum : u32 { STANDARD_CLOCK = 640'000 }; - template <class Object> devcb_base &set_drq_callback(Object &&cb) { return m_drqcallback.set_callback(std::forward<Object>(cb)); } - void set_bank_base(offs_t base); DECLARE_WRITE_LINE_MEMBER( reset_w ); DECLARE_READ_LINE_MEMBER( busy_r ); virtual DECLARE_WRITE8_MEMBER( port_w ); - void postload(); protected: // chip states @@ -51,6 +48,7 @@ protected: // device-level overrides virtual void device_start() override; virtual void device_reset() override; + virtual void device_post_load() override; // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; @@ -100,13 +98,13 @@ protected: uint8_t * m_rom; /* pointer to ROM data or nullptr for slave mode */ uint32_t m_romoffset; /* ROM offset to make save/restore easier */ uint32_t m_rommask; /* maximum address offset */ - - devcb_write_line m_drqcallback; }; class upd7759_device : public upd775x_device { public: + template <class Object> devcb_base &set_drq_callback(Object &&cb) { return m_drqcallback.set_callback(std::forward<Object>(cb)); } + upd7759_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = STANDARD_CLOCK); DECLARE_WRITE_LINE_MEMBER( start_w ); @@ -122,8 +120,8 @@ protected: virtual void device_start() override; virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; + devcb_write_line m_drqcallback; emu_timer *m_timer; }; @@ -135,9 +133,9 @@ public: DECLARE_WRITE_LINE_MEMBER( start_w ); protected: + upd7756_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + virtual void device_start() override; - virtual void device_reset() override; - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; }; DECLARE_DEVICE_TYPE(UPD7759, upd7759_device) @@ -146,7 +144,4 @@ DECLARE_DEVICE_TYPE(UPD7756, upd7756_device) #define MCFG_UPD7759_DRQ_CALLBACK(_write) \ devcb = &downcast<upd7759_device &>(*device).set_drq_callback(DEVCB_##_write); -#define MCFG_UPD7756_DRQ_CALLBACK(_write) \ - devcb = &downcast<upd7756_device &>(*device).set_drq_callback(DEVCB_##_write); - #endif // MAME_SOUND_UPD7759_H diff --git a/src/devices/sound/vrc6.h b/src/devices/sound/vrc6.h index 7e1e72fdddf..dbcd5152c3b 100644 --- a/src/devices/sound/vrc6.h +++ b/src/devices/sound/vrc6.h @@ -13,16 +13,6 @@ #pragma once //************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_VRC6_ADD(_tag, _clock) \ - MCFG_DEVICE_ADD(_tag, VRC6, _clock) - -#define MCFG_VRC6_REPLACE(_tag, _clock) \ - MCFG_DEVICE_REPLACE(_tag, VRC6, _clock) - -//************************************************************************** // TYPE DEFINITIONS //************************************************************************** diff --git a/src/devices/sound/ym2151.h b/src/devices/sound/ym2151.h index 989607bbf62..0aba974025f 100644 --- a/src/devices/sound/ym2151.h +++ b/src/devices/sound/ym2151.h @@ -40,9 +40,6 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_YM2151_ADD(_tag, _clock) \ - MCFG_DEVICE_ADD(_tag, YM2151, _clock) - #define MCFG_YM2151_IRQ_HANDLER(_devcb) \ devcb = &downcast<ym2151_device &>(*device).set_irq_handler(DEVCB_##_devcb); #define MCFG_YM2151_PORT_WRITE_HANDLER(_devcb) \ diff --git a/src/devices/sound/ymz770.h b/src/devices/sound/ymz770.h index cd0dfe1e11d..22e20e1817b 100644 --- a/src/devices/sound/ymz770.h +++ b/src/devices/sound/ymz770.h @@ -12,22 +12,6 @@ #pragma once //************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_YMZ770_ADD(_tag, _clock) \ - MCFG_DEVICE_ADD(_tag, YMZ770, _clock) - -#define MCFG_YMZ770_REPLACE(_tag, _clock) \ - MCFG_DEVICE_REPLACE(_tag, YMZ770, _clock) - -#define MCFG_YMZ774_ADD(_tag, _clock) \ - MCFG_DEVICE_ADD(_tag, YMZ774, _clock) - -#define MCFG_YMZ774_REPLACE(_tag, _clock) \ - MCFG_DEVICE_REPLACE(_tag, YMZ774, _clock) - -//************************************************************************** // TYPE DEFINITIONS //************************************************************************** |