summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/okiadpcm.cpp
diff options
context:
space:
mode:
author cam900 <dbtlrchl@naver.com>2020-06-11 22:52:31 +0900
committer cam900 <dbtlrchl@naver.com>2020-06-11 22:52:31 +0900
commita5579831cae73eb13c01b10d74666ee41a217887 (patch)
tree95ef5342246f035213ddefbf140400443af77676 /src/devices/sound/okiadpcm.cpp
parentd3a7b0ddc1272c2e0e2417a4c6906d6f7c23bd88 (diff)
okiadpcm.cpp: Add looped sample support, Allow reading current output without decoding
Fix initial values, Fix descriptions qs1000.cpp: Add save state related to loop support (disabled currently)
Diffstat (limited to 'src/devices/sound/okiadpcm.cpp')
-rw-r--r--src/devices/sound/okiadpcm.cpp80
1 files changed, 71 insertions, 9 deletions
diff --git a/src/devices/sound/okiadpcm.cpp b/src/devices/sound/okiadpcm.cpp
index 160ddc3519b..4b565042288 100644
--- a/src/devices/sound/okiadpcm.cpp
+++ b/src/devices/sound/okiadpcm.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Andrew Gardner,Aaron Giles
/***************************************************************************
- okiadpcm.h
+ okiadpcm.cpp
OKI ADPCM emulation.
@@ -39,14 +39,15 @@ int oki_adpcm_state::s_diff_lookup[49*16];
void oki_adpcm_state::reset()
{
// reset the signal/step
- m_signal = -2;
- m_step = 0;
+ m_signal = m_loop_signal = 0;
+ m_step = m_loop_step = 0;
+ m_saved = false;
}
//-------------------------------------------------
-// device_clock_changed - called if the clock
-// changes
+// clock - decode single nibble and update
+// ADPCM output
//-------------------------------------------------
int16_t oki_adpcm_state::clock(uint8_t nibble)
@@ -73,6 +74,36 @@ int16_t oki_adpcm_state::clock(uint8_t nibble)
//-------------------------------------------------
+// save - save current ADPCM state to buffer
+//-------------------------------------------------
+
+void oki_adpcm_state::save()
+{
+ if (!m_saved)
+ {
+ m_loop_signal = m_signal;
+ m_loop_step = m_step;
+ m_saved = true;
+ }
+}
+
+
+//-------------------------------------------------
+// restore - restore previous ADPCM state
+// from buffer
+//-------------------------------------------------
+
+void oki_adpcm_state::restore()
+{
+ if (m_saved)
+ {
+ m_signal = m_loop_signal;
+ m_step = m_loop_step;
+ }
+}
+
+
+//-------------------------------------------------
// compute_tables - precompute tables for faster
// sound generation
//-------------------------------------------------
@@ -128,14 +159,15 @@ int oki_adpcm2_state::s_diff_lookup[49*16];
void oki_adpcm2_state::reset()
{
// reset the signal/step
- m_signal = -2;
- m_step = 0;
+ m_signal = m_loop_signal = -2;
+ m_step = m_loop_step = 0;
+ m_saved = false;
}
//-------------------------------------------------
-// device_clock_changed - called if the clock
-// changes
+// clock - decode single nibble and update
+// ADPCM output
//-------------------------------------------------
int16_t oki_adpcm2_state::clock(uint8_t nibble)
@@ -162,6 +194,36 @@ int16_t oki_adpcm2_state::clock(uint8_t nibble)
//-------------------------------------------------
+// save - save current ADPCM state to buffer
+//-------------------------------------------------
+
+void oki_adpcm2_state::save()
+{
+ if (!m_saved)
+ {
+ m_loop_signal = m_signal;
+ m_loop_step = m_step;
+ m_saved = true;
+ }
+}
+
+
+//-------------------------------------------------
+// restore - restore previous ADPCM state
+// from buffer
+//-------------------------------------------------
+
+void oki_adpcm2_state::restore()
+{
+ if (m_saved)
+ {
+ m_signal = m_loop_signal;
+ m_step = m_loop_step;
+ }
+}
+
+
+//-------------------------------------------------
// compute_tables - precompute tables for faster
// sound generation
//-------------------------------------------------