summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author mooglyguy <therealmogminer@gmail.com>2020-02-14 22:41:06 +0100
committer mooglyguy <therealmogminer@gmail.com>2020-02-14 22:41:40 +0100
commit7ea0a6a964420c67cb490caa4f0feb0f5c584145 (patch)
tree37f1fe3295b853edb853a4542dca0117563ae5e4
parentbd5252fa62583cc48c78dd33341902ad0180ed97 (diff)
-spg2xx_audio: Added logging of ADPCM36 samples, nw
-rw-r--r--src/devices/machine/spg2xx_audio.cpp48
-rw-r--r--src/devices/machine/spg2xx_audio.h1
2 files changed, 48 insertions, 1 deletions
diff --git a/src/devices/machine/spg2xx_audio.cpp b/src/devices/machine/spg2xx_audio.cpp
index 668d5d36856..cea33bf5ac7 100644
--- a/src/devices/machine/spg2xx_audio.cpp
+++ b/src/devices/machine/spg2xx_audio.cpp
@@ -41,7 +41,11 @@ DEFINE_DEVICE_TYPE(SUNPLUS_GCM394_AUDIO, sunplus_gcm394_audio_device, "gcm394_au
#include "logmacro.h"
#define SPG_DEBUG_AUDIO (0)
+#define SPG_LOG_ADPCM36 (1)
+#if SPG_LOG_ADPCM36
+static FILE *adpcm_file[16] = {};
+#endif
spg2xx_audio_device::spg2xx_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
@@ -139,6 +143,18 @@ void spg2xx_audio_device::device_reset()
}
}
+void spg2xx_audio_device::device_stop()
+{
+#if SPG_LOG_ADPCM36
+ for (int i = 0; i < 16; i++)
+ {
+ if (adpcm_file[i])
+ {
+ fclose(adpcm_file[i]);
+ }
+ }
+#endif
+}
void spg2xx_audio_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
@@ -449,6 +465,9 @@ WRITE16_MEMBER(spg2xx_audio_device::audio_ctrl_w)
const uint16_t changed = m_audio_ctrl_regs[AUDIO_CHANNEL_ENABLE] ^ data;
for (uint32_t channel_bit = 0; channel_bit < 16; channel_bit++)
{
+ if (channel_bit == 0)
+ continue;
+
const uint16_t mask = 1 << channel_bit;
if (!(changed & mask))
continue;
@@ -981,6 +1000,13 @@ inline void spg2xx_audio_device::stop_channel(const uint32_t channel)
m_audio_ctrl_regs[AUDIO_CHANNEL_TONE_RELEASE] &= ~(1 << channel);
m_audio_ctrl_regs[AUDIO_ENV_RAMP_DOWN] &= ~(1 << channel);
m_channel_irq[channel]->adjust(attotime::never);
+#if SPG_LOG_ADPCM36
+ if (get_adpcm36_bit(channel))
+ {
+ fclose(adpcm_file[channel]);
+ adpcm_file[channel] = nullptr;
+ }
+#endif
}
bool spg2xx_audio_device::advance_channel(const uint32_t channel)
@@ -1048,7 +1074,27 @@ bool spg2xx_audio_device::fetch_sample(const uint32_t channel)
const uint16_t tone_mode = get_tone_mode(channel);
uint16_t raw_sample = tone_mode ? read_space(m_sample_addr[channel]) : m_audio_regs[wave_data_reg];
- LOGMASKED(LOG_SAMPLES, "Channel %d: Raw sample %04x\n", channel, raw_sample);
+#if SPG_LOG_ADPCM36
+ if (get_adpcm36_bit(channel))
+ {
+ static int adpcm_file_counts[16] = {};
+
+ if (adpcm_file[channel] == nullptr)
+ {
+ char file_buf[256];
+ snprintf(file_buf, 256, "adpcm36_chan%d_%d.bin", channel, adpcm_file_counts[channel]);
+ adpcm_file[channel] = fopen(file_buf, "wb");
+ }
+ static int blah[16] = {};
+ if ((blah[channel] & 3) == 0)
+ {
+ LOGMASKED(LOG_SAMPLES, "Channel %d: Raw sample %04x\n", channel, raw_sample);
+ fwrite(&raw_sample, sizeof(uint16_t), 1, adpcm_file[channel]);
+ }
+ blah[channel]++;
+ blah[channel] &= 3;
+ }
+#endif
if (get_adpcm_bit(channel))
{
diff --git a/src/devices/machine/spg2xx_audio.h b/src/devices/machine/spg2xx_audio.h
index 05c68282a14..9a59d3fa3e0 100644
--- a/src/devices/machine/spg2xx_audio.h
+++ b/src/devices/machine/spg2xx_audio.h
@@ -329,6 +329,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
+ virtual void device_stop() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
uint16_t read_space(offs_t offset);