Implement sample playback

Fix register viewer
Minor optimize
This commit is contained in:
cam900 2023-04-02 14:55:10 +09:00
parent 09726e6290
commit dee28d218e
4 changed files with 51 additions and 31 deletions

View File

@ -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

View File

@ -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<s32, 2> 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<voice_t, 4> m_voice;
voice_t m_voice[4];
k053260_intf &m_intf; // common memory interface
std::array<u8, 2> m_host2snd;
std::array<u8, 2> 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<u8, 64> m_reg; // register pool
std::array<s32, 2> m_out; // stereo output
u8 m_reg[64]; // register pool
s32 m_out[2]; // stereo output
};
#endif

View File

@ -22,20 +22,32 @@
#include "../../ta-log.h"
#include <math.h>
#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<getSampleMemCapacity())) {
address&=0x1fffff;
return sampleMem[address];
}
return 0;
}
void DivPlatformK053260::acquire(short** buf, size_t len) {
for (int i=0; i<len; i++) {
k053260.tick(TICK_DIVIDER);
@ -387,14 +405,15 @@ void DivPlatformK053260::setFlags(const DivConfig& flags) {
}
void DivPlatformK053260::poke(unsigned int addr, unsigned short val) {
rWrite(addr&0x0f,val);
rWrite(addr&0x3f,val);
}
void DivPlatformK053260::poke(std::vector<DivRegWrite>& 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;
}

View File

@ -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);