diff options
Diffstat (limited to 'src/devices/sound/msm5205.cpp')
-rw-r--r-- | src/devices/sound/msm5205.cpp | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/src/devices/sound/msm5205.cpp b/src/devices/sound/msm5205.cpp index 89858f040e0..c44f4760a87 100644 --- a/src/devices/sound/msm5205.cpp +++ b/src/devices/sound/msm5205.cpp @@ -71,7 +71,8 @@ msm5205_device::msm5205_device(const machine_config &mconfig, device_type type, m_s1(false), m_s2(false), m_bitwidth(4), - m_vclk_cb(*this) + m_vck_cb(*this), + m_vck_legacy_cb(*this) { } @@ -99,18 +100,19 @@ void msm5205_device::set_prescaler_selector(device_t &device, int select) void msm5205_device::device_start() { - m_vclk_cb.resolve(); + m_vck_cb.resolve_safe(); + m_vck_legacy_cb.resolve(); /* compute the difference tables */ compute_tables(); /* stream system initialize */ m_stream = machine().sound().stream_alloc(*this, 0, 1, clock()); - m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(msm5205_device::vclk_callback), this)); + m_timer = timer_alloc(TIMER_VCK); /* register for save states */ save_item(NAME(m_data)); - save_item(NAME(m_vclk)); + save_item(NAME(m_vck)); save_item(NAME(m_reset)); save_item(NAME(m_s1)); save_item(NAME(m_s2)); @@ -127,7 +129,7 @@ void msm5205_device::device_reset() { /* initialize work */ m_data = 0; - m_vclk = 0; + m_vck = 0; m_reset = 0; m_signal = 0; m_step = 0; @@ -176,15 +178,32 @@ void msm5205_device::compute_tables() } } + +//------------------------------------------------- +// device_timer - called whenever a device timer +// fires +//------------------------------------------------- + +void msm5205_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + assert(id == TIMER_VCK); + + m_vck = !m_vck; + m_vck_cb(m_vck); + + if (!m_vck) + update_adpcm(); +} + // timer callback at VCK low edge on MSM5205 (at rising edge on MSM6585) -TIMER_CALLBACK_MEMBER( msm5205_device::vclk_callback ) +void msm5205_device::update_adpcm() { int val; int new_signal; // callback user handler and latch next data - if (!m_vclk_cb.isnull()) - m_vclk_cb(1); + if (!m_vck_legacy_cb.isnull()) + m_vck_legacy_cb(1); // reset check at last hiedge of VCK if (m_reset) @@ -228,11 +247,11 @@ WRITE_LINE_MEMBER(msm5205_device::vclk_w) logerror("Error: vclk_w() called but VCK selected master mode\n"); else { - if (m_vclk != state) + if (m_vck != state) { - m_vclk = state; + m_vck = state; if (!state) - vclk_callback(this, 0); + update_adpcm(); } } } @@ -333,11 +352,16 @@ void msm5205_device::device_clock_changed() int prescaler = get_prescaler(); if (prescaler != 0) { - attotime period = clocks_to_attotime(prescaler); - m_timer->adjust(period, 0, period); + logerror("/%d prescaler selected\n", prescaler); + + attotime half_period = clocks_to_attotime(prescaler / 2); + m_timer->adjust(half_period, 0, half_period); } else + { + logerror("VCK slave mode selected\n"); m_timer->adjust(attotime::never); + } } @@ -365,6 +389,23 @@ void msm5205_device::sound_stream_update(sound_stream &stream, stream_sample_t * //------------------------------------------------- +// device_timer - called whenever a device timer +// fires +//------------------------------------------------- + +void msm6585_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + assert(id == TIMER_VCK); + + m_vck = !m_vck; + m_vck_cb(m_vck); + + if (m_vck) + update_adpcm(); +} + + +//------------------------------------------------- // sound_stream_update - handle a stream update //------------------------------------------------- |