diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.cpp b/extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.cpp index 9c8d9434b..990c1fc36 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.cpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.cpp @@ -244,7 +244,7 @@ void k053260_core::voice_t::keyon() m_bitpos = 4; m_data = 0; m_output = 0; - std::fill(m_out.begin(), m_out.end(), 0); + std::fill_n(m_out, 2, 0); } // key off trigger @@ -260,13 +260,13 @@ void k053260_core::reset() //m_intf.write_int(0); - std::fill(m_host2snd.begin(), m_host2snd.end(), 0); - std::fill(m_snd2host.begin(), m_snd2host.end(), 0); + std::fill_n(m_host2snd, 2, 0); + std::fill_n(m_snd2host, 2, 0); m_ctrl.reset(); //m_dac.reset(); - std::fill(m_reg.begin(), m_reg.end(), 0); - std::fill(m_out.begin(), m_out.end(), 0); + std::fill_n(m_reg, 64, 0); + std::fill_n(m_out, 2, 0); } // reset voice diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.hpp b/extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.hpp index feaffeac5..bfb7ea002 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.hpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/k053260/k053260.hpp @@ -70,7 +70,7 @@ class k053260_core : public vgsound_emu_core , m_data(0) , m_output(0) { - m_out.fill(0); + std::fill_n(m_out, 2, 0); } // internal state @@ -124,7 +124,7 @@ class k053260_core : public vgsound_emu_core u8 m_bitpos = 4; // bit position for ADPCM decoding u8 m_data = 0; // current data s8 m_output = 0; // ADPCM buffer - std::array m_out; // current output + s32 m_out[2]; // current output }; class ctrl_t @@ -232,10 +232,10 @@ class k053260_core : public vgsound_emu_core //, m_ym3012(ym3012_t()) //, m_dac(dac_t()) { - m_host2snd.fill(0); - m_snd2host.fill(0); - m_reg.fill(0); - m_out.fill(0); + std::fill_n(m_host2snd, 2, 0); + std::fill_n(m_snd2host, 2, 0); + std::fill_n(m_reg, 64, 0); + std::fill_n(m_out, 2, 0); } // communications @@ -267,19 +267,19 @@ class k053260_core : public vgsound_emu_core inline s32 adpcm_lut(const u8 nibble) { return m_adpcm_lut[nibble]; } private: - std::array m_voice; + voice_t m_voice[4]; k053260_intf &m_intf; // common memory interface - std::array m_host2snd; - std::array m_snd2host; + u8 m_host2snd[2]; + u8 m_snd2host[2]; ctrl_t m_ctrl; // chip control //ym3012_t m_ym3012; // YM3012 output //dac_t m_dac; // YM3012 interface - std::array m_reg; // register pool - std::array m_out; // stereo output + u8 m_reg[64]; // register pool + s32 m_out[2]; // stereo output }; #endif diff --git a/src/engine/platform/k053260.cpp b/src/engine/platform/k053260.cpp index 47e7636d1..f42a532dc 100644 --- a/src/engine/platform/k053260.cpp +++ b/src/engine/platform/k053260.cpp @@ -22,20 +22,32 @@ #include "../../ta-log.h" #include -#define rWrite(a,v) {if(!skipRegisterWrites) {k053260.write(a,v); regPool[a]=v; if(dumpWrites) addWrite(a,v);}} +#define rWrite(a,v) {if(!skipRegisterWrites && a<0x30) {k053260.write(a,v); regPool[a]=v; if(dumpWrites) addWrite(a,v);}} -#define CHIP_DIVIDER 64 -#define TICK_DIVIDER 4 +#define CHIP_DIVIDER 16 +#define TICK_DIVIDER 64 // for match to YM3012 output rate const char* regCheatSheetK053260[]={ - "FreqL", "0", - "FreqH", "1", - "LengthL", "2", - "LengthH", "3", - "StartL", "4", - "StartM", "5", - "StartH", "6", - "Volume", "7", + "MainToSub0", "00", + "MainToSub1", "01", + "SubToMain0", "02", + "SubToMain1", "03", + "CHx_FreqL", "08+x*8", + "CHx_FreqH", "09+x*8", + "CHx_LengthL", "0A+x*8", + "CHx_LengthH", "0B+x*8", + "CHx_StartL", "0C+x*8", + "CHx_StartM", "0D+x*8", + "CHx_StartH", "0E+x*8", + "CHx_Volume", "0F+x*8", + "KeyOn", "28", + "Status", "29", + "LoopFormat", "2A", + "Test", "2B", + "CH01_Pan", "2C", + "CH23_Pan", "2D", + "ROMReadback", "2E", + "Control", "2F", NULL }; @@ -49,8 +61,14 @@ inline void DivPlatformK053260::chWrite(unsigned char ch, unsigned int addr, uns } } -// TODO: this code is weird -// make sure newDispatch didn't break it up +u8 DivPlatformK053260::read_sample(u32 address) { + if ((sampleMem!=NULL) && (address& wlist) { - for (DivRegWrite& i: wlist) rWrite(i.addr&0x0f,i.val); + for (DivRegWrite& i: wlist) rWrite(i.addr&0x3f,i.val); } unsigned char* DivPlatformK053260::getRegisterPool() { + regPool[0x29]=k053260.read(0x29); // dynamically updated return regPool; } diff --git a/src/engine/platform/k053260.h b/src/engine/platform/k053260.h index c449206f6..3b21cb4dc 100644 --- a/src/engine/platform/k053260.h +++ b/src/engine/platform/k053260.h @@ -58,6 +58,7 @@ class DivPlatformK053260: public DivDispatch, public k053260_intf { friend void putDispatchChan(void*,int,int); public: + virtual u8 read_sample(u32 address) override; void acquire(short** buf, size_t len); int dispatch(DivCommand c); void* getChanState(int chan);