okim6258: small cleanup

This commit is contained in:
hap 2024-02-29 15:02:24 +01:00
parent f1bb8a02ff
commit 707d36ab2f
4 changed files with 47 additions and 56 deletions

View File

@ -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,8 +46,8 @@ 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),
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),
@ -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<read
}
}
/**********************************************************************************************
state save support for MAME
***********************************************************************************************/
void okim6258_device::state_save_register()
{
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));
}
int16_t okim6258_device::clock_adpcm(uint8_t nibble)
{
int32_t max = (1 << (m_output_bits - 1)) - 1;
@ -217,7 +204,7 @@ int16_t okim6258_device::clock_adpcm(uint8_t nibble)
/**********************************************************************************************
okim6258::set_divider -- set the master clock divider
set_divider -- set the master clock divider
***********************************************************************************************/
@ -230,7 +217,7 @@ void okim6258_device::set_divider(int val)
/**********************************************************************************************
okim6258::set_clock -- set the master clock
set_clock -- set the master clock
***********************************************************************************************/
@ -242,7 +229,7 @@ void okim6258_device::device_clock_changed()
/**********************************************************************************************
okim6258::get_vclk -- get the VCLK/sampling frequency
get_vclk -- get the VCLK/sampling frequency
***********************************************************************************************/
@ -254,7 +241,7 @@ int okim6258_device::get_vclk()
/**********************************************************************************************
okim6258_status_r -- read the status port of an OKIM6258-compatible chip
status_r -- read the status port of an OKIM6258-compatible chip
***********************************************************************************************/
@ -268,9 +255,10 @@ uint8_t okim6258_device::status_r()
/**********************************************************************************************
okim6258_data_w -- write to the control port of an OKIM6258-compatible chip
data_w -- write to the control port of an OKIM6258-compatible chip
***********************************************************************************************/
void okim6258_device::data_w(uint8_t data)
{
/* update the stream */
@ -283,7 +271,7 @@ void okim6258_device::data_w(uint8_t data)
/**********************************************************************************************
okim6258_ctrl_w -- write to the control port of an OKIM6258-compatible chip
ctrl_w -- write to the control port of an OKIM6258-compatible chip
***********************************************************************************************/

View File

@ -50,20 +50,18 @@ protected:
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &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? */
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 */
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;

View File

@ -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()

View File

@ -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();
};