From 707d36ab2fbedd6f28019a3bb8587a79e49eb00e Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 29 Feb 2024 15:02:24 +0100 Subject: okim6258: small cleanup --- src/devices/sound/okim6258.cpp | 76 ++++++++++++++++++------------------------ src/devices/sound/okim6258.h | 16 ++++----- src/devices/sound/okim6588.cpp | 11 ++++-- src/devices/sound/okim6588.h | 2 +- 4 files changed, 48 insertions(+), 57 deletions(-) diff --git a/src/devices/sound/okim6258.cpp b/src/devices/sound/okim6258.cpp index 349fe9ca13c..171100e2080 100644 --- a/src/devices/sound/okim6258.cpp +++ b/src/devices/sound/okim6258.cpp @@ -2,15 +2,15 @@ // copyright-holders:Barry Rodewald /********************************************************************************************** * - * OKI MSM6258 ADPCM + * OKI MSM6258 ADPCM Speech Processor * * TODO: - * 3-bit ADPCM support - * Recording? + * - 3-bit ADPCM support + * - Use okiadpcm.* helper? + * - Recording? * **********************************************************************************************/ - #include "emu.h" #include "okim6258.h" @@ -46,19 +46,19 @@ DEFINE_DEVICE_TYPE(OKIM6258, okim6258_device, "okim6258", "OKI MSM6258 ADPCM") // okim6258_device - constructor //------------------------------------------------- -okim6258_device::okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, OKIM6258, tag, owner, clock), - device_sound_interface(mconfig, *this), - m_status(0), - m_start_divider(0), - m_divider(512), - m_adpcm_type(0), - m_data_in(0), - m_nibble_shift(0), - m_stream(nullptr), - m_output_bits(0), - m_signal(0), - m_step(0) +okim6258_device::okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, OKIM6258, tag, owner, clock), + device_sound_interface(mconfig, *this), + m_status(0), + m_start_divider(0), + m_divider(512), + m_adpcm_type(0), + m_data_in(0), + m_nibble_shift(0), + m_stream(nullptr), + m_output_bits(0), + m_signal(0), + m_step(0) { } @@ -93,7 +93,7 @@ static void compute_tables() for (nib = 0; nib < 16; nib++) { diff_lookup[step*16 + nib] = nbl2bit[nib][0] * - (stepval * nbl2bit[nib][1] + + (stepval * nbl2bit[nib][1] + stepval/2 * nbl2bit[nib][2] + stepval/4 * nbl2bit[nib][3] + stepval/8); @@ -119,7 +119,13 @@ void okim6258_device::device_start() m_signal = -2; m_step = 0; - state_save_register(); + // register for savestates + save_item(NAME(m_status)); + save_item(NAME(m_divider)); + save_item(NAME(m_data_in)); + save_item(NAME(m_nibble_shift)); + save_item(NAME(m_signal)); + save_item(NAME(m_step)); } @@ -171,25 +177,6 @@ void okim6258_device::sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; private: - void state_save_register(); int16_t clock_adpcm(uint8_t nibble); uint8_t m_status; uint32_t m_start_divider; - uint32_t m_divider; /* master clock divider */ - uint8_t m_adpcm_type; /* 3/4 bit ADPCM select */ - uint8_t m_data_in; /* ADPCM data-in register */ - uint8_t m_nibble_shift; /* nibble select */ - sound_stream *m_stream; /* which stream are we playing on? */ - - uint8_t m_output_bits; /* D/A precision is 10-bits but 12-bit data can be - output serially to an external DAC */ + uint32_t m_divider; // master clock divider + uint8_t m_adpcm_type; // 3/4 bit ADPCM select + uint8_t m_data_in; // ADPCM data-in register + uint8_t m_nibble_shift; // nibble select + sound_stream *m_stream; // which stream are we playing on? + + uint8_t m_output_bits; // D/A precision is 10-bits but 12-bit data can be output serially to an external DAC int32_t m_signal; int32_t m_step; diff --git a/src/devices/sound/okim6588.cpp b/src/devices/sound/okim6588.cpp index 7704c61d315..4e28ddd1ee3 100644 --- a/src/devices/sound/okim6588.cpp +++ b/src/devices/sound/okim6588.cpp @@ -4,6 +4,8 @@ OKI MSM6588 ADPCM Recorder +It has similar functionality to MSM6258. + TODO: - it only supports MCU mode EXT playback, nothing else emulated yet - status register read (eg. BUSY flag) @@ -123,10 +125,13 @@ TIMER_CALLBACK_MEMBER(okim6588_device::set_mon) m_write_mon(param ? 1 : 0); } -s32 okim6588_device::get_adpcm_sample(u8 data) +s16 okim6588_device::get_adpcm_sample(u8 data) { - u8 mask = m_vds_bit ? 0xf : 0xe; - return m_adpcm.clock(data & mask); + // 4-bit or 3-bit input + if (m_vds_bit) + return m_adpcm.clock(data & 0xf); + else + return m_adpcm.clock((data & 0xc) | (data >> 1 & 1)); } void okim6588_device::reset_adpcm() diff --git a/src/devices/sound/okim6588.h b/src/devices/sound/okim6588.h index 7382902c3d8..28bcec029aa 100644 --- a/src/devices/sound/okim6588.h +++ b/src/devices/sound/okim6588.h @@ -78,7 +78,7 @@ private: TIMER_CALLBACK_MEMBER(clock_adpcm); TIMER_CALLBACK_MEMBER(set_mon); - s32 get_adpcm_sample(u8 data); + s16 get_adpcm_sample(u8 data); void reset_adpcm(); }; -- cgit v1.2.3