From f839b0771cb001d659d50a9659cb43298db41d68 Mon Sep 17 00:00:00 2001 From: cam900 Date: Sat, 22 Oct 2022 16:28:37 +0900 Subject: [PATCH] Sync vgsound_emu with master --- extern/vgsound_emu-modified/CHANGELOG.md | 4 +++ .../vgsound_emu/src/es550x/es5504.cpp | 8 +++--- .../vgsound_emu/src/es550x/es5505.cpp | 15 ++++++----- .../vgsound_emu/src/es550x/es5505.hpp | 25 ++++++++++++++----- .../vgsound_emu/src/es550x/es5506.cpp | 15 ++++++----- .../vgsound_emu/src/es550x/es5506.hpp | 22 ++++++++-------- 6 files changed, 57 insertions(+), 32 deletions(-) diff --git a/extern/vgsound_emu-modified/CHANGELOG.md b/extern/vgsound_emu-modified/CHANGELOG.md index 46957e509..22950258c 100644 --- a/extern/vgsound_emu-modified/CHANGELOG.md +++ b/extern/vgsound_emu-modified/CHANGELOG.md @@ -2,6 +2,10 @@ ## Important changes +### V 2.1.3 (2022-10-22) + +Fix ES5504, ES5505, ES5506 per-voice preview functions + ### V 2.1.2 (2022-10-21) Split utilities and core framework header diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5504.cpp b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5504.cpp index b31a13b20..a7ee9e322 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5504.cpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5504.cpp @@ -11,8 +11,6 @@ // Internal functions void es5504_core::tick() { - m_voice_update = false; - m_voice_end = false; // /CAS, E if (m_clkin.falling_edge()) // falling edge triggers /CAS, E clock { @@ -77,8 +75,6 @@ void es5504_core::tick() // less cycle accurate, but less CPU heavy routine void es5504_core::tick_perf() { - m_voice_update = false; - m_voice_end = false; // update // falling edge m_e.edge().set(false); @@ -121,6 +117,10 @@ void es5504_core::voice_tick() m_voice_end = true; m_voice_cycle = 0; } + else + { + m_voice_end = false; + } m_voice_fetch = 0; } diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.cpp b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.cpp index 6172a8665..292b1a8a3 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.cpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.cpp @@ -11,8 +11,6 @@ // Internal functions void es5505_core::tick() { - m_voice_update = false; - m_voice_end = false; // CLKIN if (m_clkin.tick()) { @@ -149,8 +147,6 @@ void es5505_core::tick() // less cycle accurate, but less CPU heavy routine void es5505_core::tick_perf() { - m_voice_update = false; - m_voice_end = false; // output for (int c = 0; c < 4; c++) { @@ -207,6 +203,10 @@ void es5505_core::voice_tick() elem.ch().reset(); } } + else + { + m_voice_end = false; + } m_voice_fetch = 0; } } @@ -230,8 +230,11 @@ void es5505_core::voice_t::tick(u8 voice) if (m_alu.busy()) { // Send to output - m_ch.set_left(volume_calc(m_lvol, sign_ext(m_filter.o4_1(), 16))); - m_ch.set_right(volume_calc(m_rvol, sign_ext(m_filter.o4_1(), 16))); + m_output[0] = volume_calc(m_lvol, sign_ext(m_filter.o4_1(), 16)); + m_output[1] = volume_calc(m_rvol, sign_ext(m_filter.o4_1(), 16)); + + m_ch.set_left(m_output[0]); + m_ch.set_right(m_output[1]); // ALU execute if (m_alu.tick()) diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.hpp b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.hpp index 52a3b5f36..cfd6f88c4 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.hpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5505.hpp @@ -105,6 +105,8 @@ class es5505_core : public es550x_shared_core , m_lvol(0) , m_rvol(0) , m_ch(output_t()) + , m_mute(false) + , m_output{0} { } @@ -125,14 +127,23 @@ class es5505_core : public es550x_shared_core output_t &ch() { return m_ch; } + // for debug/preview only + inline void set_mute(bool mute) { m_mute = mute; } + + inline s32 left_out() { return m_mute ? 0 : m_output[0]; } + + inline s32 right_out() { return m_mute ? 0 : m_output[1]; } + private: s32 volume_calc(u8 volume, s32 in); // registers es5505_core &m_host; - u8 m_lvol = 0; // Left volume - u8 m_rvol = 0; // Right volume - output_t m_ch; // channel output + u8 m_lvol = 0; // Left volume + u8 m_rvol = 0; // Right volume + output_t m_ch; // channel output + bool m_mute = false; // mute flag (for debug purpose) + std::array m_output; // output preview (for debug purpose) }; class sermode_t : public vgsound_emu_core @@ -270,10 +281,12 @@ class es5505_core : public es550x_shared_core return ret; } - // per-voice outputs - inline s32 voice_lout(u8 voice) { return (voice < 32) ? m_voice[voice].ch().left() : 0; } + inline void set_mute(u8 ch, bool mute) { m_voice[ch & 0x1f].set_mute(mute); } - inline s32 voice_rout(u8 voice) { return (voice < 32) ? m_voice[voice].ch().right() : 0; } + // per-voice outputs + inline s32 voice_lout(u8 voice) { return (voice < 32) ? m_voice[voice].left_out() : 0; } + + inline s32 voice_rout(u8 voice) { return (voice < 32) ? m_voice[voice].right_out() : 0; } protected: virtual inline u8 max_voices() override { return 32; } diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.cpp b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.cpp index 83e43cac9..454e067bb 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.cpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.cpp @@ -11,8 +11,6 @@ // Internal functions void es5506_core::tick() { - m_voice_update = false; - m_voice_end = false; // CLKIN if (m_clkin.tick()) { @@ -192,8 +190,6 @@ void es5506_core::tick() // less cycle accurate, but less CPU heavy routine void es5506_core::tick_perf() { - m_voice_update = false; - m_voice_end = false; // output if (((!m_mode.lrclk_en()) && (!m_mode.bclk_en()) && (!m_mode.wclk_en())) && (m_w_st < m_w_end)) { @@ -268,6 +264,10 @@ void es5506_core::voice_tick() elem.ch().reset(); } } + else + { + m_voice_end = false; + } m_voice_fetch = 0; } } @@ -295,8 +295,11 @@ void es5506_core::voice_t::tick(u8 voice) if (m_alu.busy()) { // Send to output - m_ch.set_left(volume_calc(m_lvol, sign_ext(m_filter.o4_1(), 16))); - m_ch.set_right(volume_calc(m_rvol, sign_ext(m_filter.o4_1(), 16))); + m_output[0] = volume_calc(m_lvol, sign_ext(m_filter.o4_1(), 16)); + m_output[1] = volume_calc(m_rvol, sign_ext(m_filter.o4_1(), 16)); + + m_ch.set_left(m_output[0]); + m_ch.set_right(m_output[1]); // ALU execute if (m_alu.tick()) diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.hpp b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.hpp index b59a96dcf..f5b54d4f1 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.hpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es5506.hpp @@ -147,6 +147,7 @@ class es5506_core : public es550x_shared_core , m_filtcount(0) , m_ch(output_t()) , m_mute(false) + , m_output{0} { } @@ -186,9 +187,9 @@ class es5506_core : public es550x_shared_core // for debug/preview only inline void set_mute(bool mute) { m_mute = mute; } - inline s32 left_out() { return m_mute ? 0 : m_ch.left(); } + inline s32 left_out() { return m_mute ? 0 : m_output[0]; } - inline s32 right_out() { return m_mute ? 0 : m_ch.right(); } + inline s32 right_out() { return m_mute ? 0 : m_output[1]; } private: // accessors, getters, setters @@ -202,14 +203,15 @@ class es5506_core : public es550x_shared_core s32 m_lvol = 0; // Left volume s32 m_rvol = 0; // Right volume // Envelope - s32 m_lvramp = 0; // Left volume ramp - s32 m_rvramp = 0; // Righr volume ramp - s16 m_ecount = 0; // Envelope counter - filter_ramp_t m_k2ramp; // Filter coefficient 2 Ramp - filter_ramp_t m_k1ramp; // Filter coefficient 1 Ramp - u8 m_filtcount = 0; // Internal counter for slow mode - output_t m_ch; // channel output - bool m_mute = false; // mute flag (for debug purpose) + s32 m_lvramp = 0; // Left volume ramp + s32 m_rvramp = 0; // Righr volume ramp + s16 m_ecount = 0; // Envelope counter + filter_ramp_t m_k2ramp; // Filter coefficient 2 Ramp + filter_ramp_t m_k1ramp; // Filter coefficient 1 Ramp + u8 m_filtcount = 0; // Internal counter for slow mode + output_t m_ch; // channel output + bool m_mute = false; // mute flag (for debug purpose) + std::array m_output; // output preview (for debug purpose) }; // 5 bit mode