NDS: fix drift
This commit is contained in:
parent
1ea872f6fb
commit
6e4458d04d
|
@ -25,10 +25,10 @@
|
|||
#define CHIP_DIVIDER 32
|
||||
|
||||
#define rRead8(a) (nds.read8(a))
|
||||
#define rWrite8(a,v) {if(!skipRegisterWrites) {nds.write8((a),(v)); regPool[(a)]=(v); if(dumpWrites) addWrite((a),(v)); }}
|
||||
#define rWrite8(a,v) {if(!skipRegisterWrites){writes.push_back(QueuedWrite((a),1,(v)));regPool[(a)]=(v);if(dumpWrites)addWrite((a),(v));}}
|
||||
#define rWrite16(a,v) { \
|
||||
if(!skipRegisterWrites) { \
|
||||
nds.write16((a)>>1,(v)); \
|
||||
writes.push_back(QueuedWrite((a),2,(v)));\
|
||||
regPool[(a)+0]=(v)&0xff; \
|
||||
regPool[(a)+1]=((v)>>8)&0xff; \
|
||||
if(dumpWrites) addWrite((a)+0,(v)&0xff); \
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#define rWrite32(a,v) { \
|
||||
if(!skipRegisterWrites) { \
|
||||
nds.write32((a)>>2,(v)); \
|
||||
writes.push_back(QueuedWrite((a),4,(v)));\
|
||||
regPool[(a)+0]=(v)&0xff; \
|
||||
regPool[(a)+1]=((v)>>8)&0xff; \
|
||||
regPool[(a)+2]=((v)>>16)&0xff; \
|
||||
|
@ -76,6 +76,19 @@ void DivPlatformNDS::acquireDirect(blip_buffer_t** bb, size_t len) {
|
|||
nds.set_bb(bb[0],bb[1]);
|
||||
nds.set_oscbuf(oscBuf);
|
||||
nds.resetTS(0);
|
||||
|
||||
while (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
if (w.size==4) {
|
||||
nds.write32(w.addr>>2,w.val);
|
||||
} else if (w.size==2) {
|
||||
nds.write16(w.addr>>1,w.val);
|
||||
} else {
|
||||
nds.write8(w.addr,w.val);
|
||||
}
|
||||
writes.pop();
|
||||
}
|
||||
|
||||
nds.tick(len);
|
||||
|
||||
for (int i=0; i<16; i++) {
|
||||
|
@ -444,6 +457,7 @@ DivDispatchOscBuffer* DivPlatformNDS::getOscBuffer(int ch) {
|
|||
void DivPlatformNDS::reset() {
|
||||
memset(regPool,0,288);
|
||||
nds.reset();
|
||||
writes.clear();
|
||||
globalVolume=0x7f;
|
||||
lastOut[0]=0;
|
||||
lastOut[1]=0;
|
||||
|
|
|
@ -52,6 +52,14 @@ class DivPlatformNDS: public DivDispatch, public nds_sound_intf {
|
|||
int lastOut[2];
|
||||
unsigned int sampleOff[256];
|
||||
bool sampleLoaded[256];
|
||||
struct QueuedWrite {
|
||||
unsigned short addr;
|
||||
unsigned char size;
|
||||
unsigned int val;
|
||||
QueuedWrite(): addr(0), size(0), val(0) {}
|
||||
QueuedWrite(unsigned short a, unsigned char s, unsigned int v): addr(a), size(s), val(v) {}
|
||||
};
|
||||
FixedQueue<QueuedWrite,2048> writes;
|
||||
|
||||
unsigned char* sampleMem;
|
||||
size_t sampleMemLen;
|
||||
|
|
|
@ -62,8 +62,6 @@ namespace nds_sound_emu
|
|||
|
||||
m_control = 0;
|
||||
m_bias = 0;
|
||||
m_loutput = 0;
|
||||
m_routput = 0;
|
||||
}
|
||||
|
||||
s32 nds_sound_t::predict() {
|
||||
|
@ -96,7 +94,6 @@ namespace nds_sound_emu
|
|||
|
||||
void nds_sound_t::tick(s32 cycle)
|
||||
{
|
||||
m_loutput = m_routput = (m_bias & 0x3ff);
|
||||
if (!enable())
|
||||
return;
|
||||
|
||||
|
@ -156,10 +153,6 @@ namespace nds_sound_emu
|
|||
// adjust master volume
|
||||
lmix = (lmix * mvol()) >> 13;
|
||||
rmix = (rmix * mvol()) >> 13;
|
||||
|
||||
// add bias and clip output
|
||||
m_loutput = clamp<s32>((lmix + (m_bias & 0x3ff)), 0, 0x3ff);
|
||||
m_routput = clamp<s32>((rmix + (m_bias & 0x3ff)), 0, 0x3ff);
|
||||
}
|
||||
|
||||
u8 nds_sound_t::read8(u32 addr)
|
||||
|
@ -321,6 +314,9 @@ namespace nds_sound_emu
|
|||
if (!m_playing && !m_ctl_hold)
|
||||
{
|
||||
m_sample = m_lfsr_out = 0;
|
||||
m_oscBuf->putSample(m_lastts,0);
|
||||
blip_add_delta(m_bb[0],m_lastts,-m_loutput);
|
||||
blip_add_delta(m_bb[1],m_lastts,-m_routput);
|
||||
m_output = m_loutput = m_routput = 0;
|
||||
}
|
||||
break;
|
||||
|
@ -368,6 +364,9 @@ namespace nds_sound_emu
|
|||
if (!m_ctl_hold)
|
||||
{
|
||||
m_sample = m_lfsr_out = 0;
|
||||
m_oscBuf->putSample(m_lastts,0);
|
||||
blip_add_delta(m_bb[0],m_lastts,-m_loutput);
|
||||
blip_add_delta(m_bb[1],m_lastts,-m_routput);
|
||||
m_output = m_loutput = m_routput = 0;
|
||||
}
|
||||
|
||||
|
@ -404,11 +403,11 @@ namespace nds_sound_emu
|
|||
m_oscBuf->putSample(i,(loutput+routput)>>1);
|
||||
}
|
||||
if (m_loutput!=loutput) {
|
||||
blip_add_delta(m_bb[0],i,m_loutput-loutput);
|
||||
blip_add_delta(m_bb[0],i,loutput-m_loutput);
|
||||
m_loutput=loutput;
|
||||
}
|
||||
if (m_routput!=routput) {
|
||||
blip_add_delta(m_bb[1],i,m_routput-routput);
|
||||
blip_add_delta(m_bb[1],i,routput-m_routput);
|
||||
m_routput=routput;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,8 +129,6 @@ namespace nds_sound_emu
|
|||
}
|
||||
, m_control(0)
|
||||
, m_bias(0)
|
||||
, m_loutput(0)
|
||||
, m_routput(0)
|
||||
, m_lastts(0)
|
||||
{
|
||||
}
|
||||
|
@ -152,9 +150,6 @@ namespace nds_sound_emu
|
|||
u8 read8(u32 addr);
|
||||
void write8(u32 addr, u8 data);
|
||||
|
||||
s32 loutput() { return m_loutput; }
|
||||
s32 routput() { return m_routput; }
|
||||
|
||||
// for debug
|
||||
s32 chan_lout(u8 ch) { return m_channel[ch].loutput(); }
|
||||
s32 chan_rout(u8 ch) { return m_channel[ch].routput(); }
|
||||
|
@ -458,8 +453,6 @@ namespace nds_sound_emu
|
|||
|
||||
u32 m_control = 0; // global control
|
||||
u32 m_bias = 0; // output bias
|
||||
s32 m_loutput = 0; // left output
|
||||
s32 m_routput = 0; // right output
|
||||
u32 m_lastts = 0; // running timestamp
|
||||
};
|
||||
}; // namespace nds_sound_emu
|
||||
|
|
|
@ -546,6 +546,7 @@ void FurnaceGUI::drawMobileControls() {
|
|||
break;
|
||||
case GUI_SCENE_CHIPS:
|
||||
ImGui::Text(_("Chips here..."));
|
||||
ImGui::Text("Built");
|
||||
break;
|
||||
case GUI_SCENE_MIXER:
|
||||
ImGui::Text(_("What the hell..."));
|
||||
|
|
Loading…
Reference in a new issue