diff options
-rw-r--r-- | src/devices/sound/segapcm.cpp | 37 | ||||
-rw-r--r-- | src/devices/sound/segapcm.h | 4 | ||||
-rw-r--r-- | src/mame/drivers/vgmplay.cpp | 3 |
3 files changed, 24 insertions, 20 deletions
diff --git a/src/devices/sound/segapcm.cpp b/src/devices/sound/segapcm.cpp index 86fdedfb206..919726a26c4 100644 --- a/src/devices/sound/segapcm.cpp +++ b/src/devices/sound/segapcm.cpp @@ -7,6 +7,7 @@ #include "emu.h" #include "segapcm.h" +#include <algorithm> // device type definition DEFINE_DEVICE_TYPE(SEGAPCM, segapcm_device, "segapcm", "Sega PCM") @@ -17,14 +18,13 @@ DEFINE_DEVICE_TYPE(SEGAPCM, segapcm_device, "segapcm", "Sega PCM") //------------------------------------------------- segapcm_device::segapcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, SEGAPCM, tag, owner, clock), - device_sound_interface(mconfig, *this), - device_rom_interface(mconfig, *this, 21), - m_ram(nullptr), - m_bank(0), - m_bankshift(0), - m_bankmask(0), - m_stream(nullptr) + : device_t(mconfig, SEGAPCM, tag, owner, clock) + , device_sound_interface(mconfig, *this) + , device_rom_interface(mconfig, *this, 21) + , m_ram(nullptr) + , m_bankshift(12) + , m_bankmask(0x70) + , m_stream(nullptr) { } @@ -35,18 +35,9 @@ segapcm_device::segapcm_device(const machine_config &mconfig, const char *tag, d void segapcm_device::device_start() { - int mask; - m_ram = std::make_unique<uint8_t[]>(0x800); - memset(m_ram.get(), 0xff, 0x800); - - m_bankshift = (uint8_t) m_bank; - mask = m_bank >> 16; - if (!mask) - mask = BANK_MASK7 >> 16; - - m_bankmask = mask & (0x1fffff >> m_bankshift); + std::fill(&m_ram[0], &m_ram[0x800], 0xff); m_stream = stream_alloc(0, 2, clock() / 128); @@ -55,6 +46,16 @@ void segapcm_device::device_start() } +//------------------------------------------------- +// device_clock_changed - called if the clock +// changes +//------------------------------------------------- + +void segapcm_device::device_clock_changed() +{ + m_stream->set_sample_rate(clock() / 128); +} + //------------------------------------------------- // rom_bank_updated - the rom bank has changed diff --git a/src/devices/sound/segapcm.h b/src/devices/sound/segapcm.h index 14825754023..fd2847a0f67 100644 --- a/src/devices/sound/segapcm.h +++ b/src/devices/sound/segapcm.h @@ -46,7 +46,7 @@ public: segapcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // configuration - void set_bank(int bank) { m_bank = bank; } + void set_bank(int bank) { m_bankshift = (bank & 0xf); m_bankmask = (0x70|((bank >> 16) & 0xfc)); } DECLARE_WRITE8_MEMBER( sega_pcm_w ); DECLARE_READ8_MEMBER( sega_pcm_r ); @@ -54,6 +54,7 @@ public: protected: // device-level overrides virtual void device_start() override; + virtual void device_clock_changed() override; // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; @@ -64,7 +65,6 @@ protected: private: std::unique_ptr<uint8_t[]> m_ram; uint8_t m_low[16]; - int m_bank; int m_bankshift; int m_bankmask; sound_stream* m_stream; diff --git a/src/mame/drivers/vgmplay.cpp b/src/mame/drivers/vgmplay.cpp index 335a395f196..4befce870df 100644 --- a/src/mame/drivers/vgmplay.cpp +++ b/src/mame/drivers/vgmplay.cpp @@ -1197,6 +1197,9 @@ void vgmplay_state::machine_start() if(version >= 0x151 && r32(0x38)) m_segapcm->set_unscaled_clock(r32(0x38)); + if(version >= 0x151 && r32(0x3c)) + m_segapcm->set_bank(r32(0x3c)); + if (data_start > 0x40) { if(version >= 0x151 && r32(0x40)) |