From 658b1a47f8f8f2707dffac7aaad926d007c70879 Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 21 Jul 2020 19:41:44 -0400 Subject: [PATCH] okim9810: Modernize logging --- src/devices/sound/okim9810.cpp | 85 ++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/src/devices/sound/okim9810.cpp b/src/devices/sound/okim9810.cpp index c9ae6e29c4a..78717fd9ae9 100644 --- a/src/devices/sound/okim9810.cpp +++ b/src/devices/sound/okim9810.cpp @@ -16,6 +16,9 @@ #include "emu.h" #include "okim9810.h" +#define VERBOSE 0 +#include "logmacro.h" + //************************************************************************** // GLOBAL VARIABLES @@ -135,26 +138,28 @@ void okim9810_device::device_start() { okim_voice *voice = &m_voice[i]; + // can't use STRUCT_MEMBER on nested structs save_item(NAME(voice->m_adpcm.m_signal), i); save_item(NAME(voice->m_adpcm.m_step), i); save_item(NAME(voice->m_adpcm2.m_signal), i); save_item(NAME(voice->m_adpcm2.m_step), i); - save_item(NAME(voice->m_playbackAlgo), i); - save_item(NAME(voice->m_looping), i); - save_item(NAME(voice->m_startFlags), i); - save_item(NAME(voice->m_endFlags), i); - save_item(NAME(voice->m_base_offset), i); - save_item(NAME(voice->m_count), i); - save_item(NAME(voice->m_samplingFreq), i); - save_item(NAME(voice->m_playing), i); - save_item(NAME(voice->m_sample), i); - save_item(NAME(voice->m_channel_volume), i); - save_item(NAME(voice->m_pan_volume_left), i); - save_item(NAME(voice->m_pan_volume_right), i); - save_item(NAME(voice->m_startSample), i); - save_item(NAME(voice->m_endSample), i); - save_item(NAME(voice->m_interpSampleNum), i); } + + save_item(STRUCT_MEMBER(m_voice, m_playbackAlgo)); + save_item(STRUCT_MEMBER(m_voice, m_looping)); + save_item(STRUCT_MEMBER(m_voice, m_startFlags)); + save_item(STRUCT_MEMBER(m_voice, m_endFlags)); + save_item(STRUCT_MEMBER(m_voice, m_base_offset)); + save_item(STRUCT_MEMBER(m_voice, m_count)); + save_item(STRUCT_MEMBER(m_voice, m_samplingFreq)); + save_item(STRUCT_MEMBER(m_voice, m_playing)); + save_item(STRUCT_MEMBER(m_voice, m_sample)); + save_item(STRUCT_MEMBER(m_voice, m_channel_volume)); + save_item(STRUCT_MEMBER(m_voice, m_pan_volume_left)); + save_item(STRUCT_MEMBER(m_voice, m_pan_volume_right)); + save_item(STRUCT_MEMBER(m_voice, m_startSample)); + save_item(STRUCT_MEMBER(m_voice, m_endSample)); + save_item(STRUCT_MEMBER(m_voice, m_interpSampleNum)); } @@ -263,14 +268,14 @@ void okim9810_device::write_command(uint8_t data) { case 0x00: // START { - osd_printf_debug("START channel mask %02x\n", m_TMP_register); + LOG("START channel mask %02x\n", m_TMP_register); uint8_t channelMask = 0x01; for (int i = 0; i < OKIM9810_VOICES; i++, channelMask <<= 1) { if (channelMask & m_TMP_register) { m_voice[i].m_playing = true; - osd_printf_debug("\t\tPlaying channel %d: encoder type %d @ %dhz (volume = %d %d). From %08x for %d samples (looping=%d).\n", + LOG("\t\tPlaying channel %d: encoder type %d @ %dhz (volume = %d %d). From %08x for %d samples (looping=%d).\n", i, m_voice[i].m_playbackAlgo, m_voice[i].m_samplingFreq, @@ -285,52 +290,52 @@ void okim9810_device::write_command(uint8_t data) } case 0x01: // STOP { - osd_printf_debug("STOP channel mask %02x\n", m_TMP_register); + LOG("STOP channel mask %02x\n", m_TMP_register); uint8_t channelMask = 0x01; for (int i = 0; i < OKIM9810_VOICES; i++, channelMask <<= 1) { if (channelMask & m_TMP_register) { m_voice[i].m_playing = false; - osd_printf_debug("\tChannel %d stopping.\n", i); + LOG("\tChannel %d stopping.\n", i); } } break; } case 0x02: // LOOP { - osd_printf_debug("LOOP channel mask %02x\n", m_TMP_register); + LOG("LOOP channel mask %02x\n", m_TMP_register); uint8_t channelMask = 0x01; for (int i = 0; i < OKIM9810_VOICES; i++, channelMask <<= 1) { if (channelMask & m_TMP_register) { m_voice[i].m_looping = true; - osd_printf_debug("\tChannel %d looping.\n", i); + LOG("\tChannel %d looping.\n", i); } else { m_voice[i].m_looping = false; - osd_printf_debug("\tChannel %d done looping.\n", i); + LOG("\tChannel %d done looping.\n", i); } } break; } case 0x03: // OPT (options) { - osd_printf_debug("OPT complex data %02x\n", m_TMP_register); + LOG("OPT complex data %02x\n", m_TMP_register); m_global_volume = (m_TMP_register & 0x18) >> 3; m_filter_type = (m_TMP_register & 0x06) >> 1; m_output_level = (m_TMP_register & 0x01); - osd_printf_debug("\tOPT setting main volume scale to Vdd/%d\n", m_global_volume+1); - osd_printf_debug("\tOPT setting output filter type to %d\n", m_filter_type); - osd_printf_debug("\tOPT setting output amp level to %d\n", m_output_level); + LOG("\tOPT setting main volume scale to Vdd/%d\n", m_global_volume+1); + LOG("\tOPT setting output filter type to %d\n", m_filter_type); + LOG("\tOPT setting output amp level to %d\n", m_output_level); break; } case 0x04: // MUON (silence) { - osd_printf_warning("MUON channel %d length %02x\n", channel, m_TMP_register); - osd_printf_warning("MSM9810: UNIMPLEMENTED COMMAND!\n"); + logerror("MUON channel %d length %02x\n", channel, m_TMP_register); + logerror("MSM9810: UNIMPLEMENTED COMMAND!\n"); break; } @@ -379,10 +384,10 @@ void okim9810_device::write_command(uint8_t data) m_voice[channel].m_playbackAlgo == ADPCM2_PLAYBACK) m_voice[channel].m_count *= 2; else if (m_voice[channel].m_playbackAlgo == NONLINEAR8_PLAYBACK) - osd_printf_warning("MSM9810: UNIMPLEMENTED PLAYBACK METHOD %d\n", m_voice[channel].m_playbackAlgo); + logerror("MSM9810: UNIMPLEMENTED PLAYBACK METHOD %d\n", m_voice[channel].m_playbackAlgo); - osd_printf_debug("FADR channel %d phrase offset %02x => ", channel, m_TMP_register); - osd_printf_debug("startFlags(%02x) startAddr(%06x) endFlags(%02x) endAddr(%06x) bytes(%d)\n", startFlags, startAddr, endFlags, endAddr, endAddr-startAddr); + LOG("FADR channel %d phrase offset %02x => ", channel, m_TMP_register); + LOG("startFlags(%02x) startAddr(%06x) endFlags(%02x) endAddr(%06x) bytes(%d)\n", startFlags, startAddr, endFlags, endAddr, endAddr-startAddr); break; } @@ -407,20 +412,20 @@ void okim9810_device::write_command(uint8_t data) m_voice[channel].m_playbackAlgo == ADPCM2_PLAYBACK) m_voice[channel].m_count *= 2; else if (m_voice[channel].m_playbackAlgo == NONLINEAR8_PLAYBACK) - osd_printf_warning("MSM9810: UNIMPLEMENTED PLAYBACK METHOD %d\n", m_voice[channel].m_playbackAlgo); + logerror("MSM9810: UNIMPLEMENTED PLAYBACK METHOD %d\n", m_voice[channel].m_playbackAlgo); - osd_printf_debug("startFlags(%02x) startAddr(%06x) endAddr(%06x) bytes(%d)\n", startFlags, startAddr, endAddr, endAddr-startAddr); + LOG("startFlags(%02x) startAddr(%06x) endAddr(%06x) bytes(%d)\n", startFlags, startAddr, endAddr, endAddr-startAddr); } else { - osd_printf_warning("MSM9810: UNKNOWN COMMAND!\n"); + logerror("MSM9810: UNKNOWN COMMAND!\n"); } break; } case 0x07: // CVOL (channel volume) { - osd_printf_debug("CVOL channel %d data %02x\n", channel, m_TMP_register); - osd_printf_debug("\tChannel %d -> volume index %d.\n", channel, m_TMP_register & 0x0f); + LOG("CVOL channel %d data %02x\n", channel, m_TMP_register); + LOG("\tChannel %d -> volume index %d.\n", channel, m_TMP_register & 0x0f); m_voice[channel].m_channel_volume = m_TMP_register & 0x0f; break; @@ -429,15 +434,15 @@ void okim9810_device::write_command(uint8_t data) { const uint8_t leftVolIndex = (m_TMP_register & 0xf0) >> 4; const uint8_t rightVolIndex = m_TMP_register & 0x0f; - osd_printf_debug("PAN channel %d left index: %02x right index: %02x (%02x)\n", channel, leftVolIndex, rightVolIndex, m_TMP_register); - osd_printf_debug("\tChannel %d left -> %d right -> %d\n", channel, leftVolIndex, rightVolIndex); + LOG("PAN channel %d left index: %02x right index: %02x (%02x)\n", channel, leftVolIndex, rightVolIndex, m_TMP_register); + LOG("\tChannel %d left -> %d right -> %d\n", channel, leftVolIndex, rightVolIndex); m_voice[channel].m_pan_volume_left = leftVolIndex; m_voice[channel].m_pan_volume_right = rightVolIndex; break; } default: { - osd_printf_warning("MSM9810: UNKNOWN COMMAND!\n"); + logerror("MSM9810: UNKNOWN COMMAND!\n"); break; } } @@ -488,7 +493,7 @@ void okim9810_device::write_tmp_register(uint8_t data) default: break; } - osd_printf_debug("DADR direct offset %02x = %02x => ", m_dadr, m_TMP_register); + LOG("DADR direct offset %02x = %02x => ", m_dadr, m_TMP_register); m_dadr++; } }