genesis: fix delay bug

This commit is contained in:
tildearrow 2021-12-06 03:07:29 -05:00
parent 8478481466
commit 055b4f9c26

View file

@ -32,31 +32,29 @@ void DivPlatformGenesis::acquire(int& l, int& r) {
} }
} }
if (!writes.empty() && --delay<0) { os[0]=0; os[1]=0;
delay=0; for (int i=0; i<6; i++) {
QueuedWrite& w=writes.front(); if (!writes.empty() && --delay<0) {
if (w.addrOrVal) { delay=0;
OPN2_Write(&fm,0x1+((w.addr>>8)<<1),w.val); QueuedWrite& w=writes.front();
//printf("write: %x = %.2x\n",w.addr,w.val); if (w.addrOrVal) {
lastBusy=0; OPN2_Write(&fm,0x1+((w.addr>>8)<<1),w.val);
writes.pop(); //printf("write: %x = %.2x\n",w.addr,w.val);
} else { lastBusy=0;
lastBusy++; writes.pop();
if (fm.write_busy==0) { } else {
//printf("busycounter: %d\n",lastBusy); lastBusy++;
OPN2_Write(&fm,0x0+((w.addr>>8)<<1),w.addr); if (fm.write_busy==0) {
w.addrOrVal=true; //printf("busycounter: %d\n",lastBusy);
OPN2_Write(&fm,0x0+((w.addr>>8)<<1),w.addr);
w.addrOrVal=true;
}
} }
} }
OPN2_Clock(&fm,o); os[0]+=o[0]; os[1]+=o[1];
//OPN2_Write(&fm,0,0);
} }
os[0]=0; os[1]=0;
OPN2_Clock(&fm,o); os[0]+=o[0]; os[1]+=o[1];
OPN2_Clock(&fm,o); os[0]+=o[0]; os[1]+=o[1];
OPN2_Clock(&fm,o); os[0]+=o[0]; os[1]+=o[1];
OPN2_Clock(&fm,o); os[0]+=o[0]; os[1]+=o[1];
OPN2_Clock(&fm,o); os[0]+=o[0]; os[1]+=o[1];
OPN2_Clock(&fm,o); os[0]+=o[0]; os[1]+=o[1];
//OPN2_Write(&fm,0,0);
psgClocks+=223722; psgClocks+=223722;
while (psgClocks>=rate) { while (psgClocks>=rate) {
@ -70,7 +68,6 @@ void DivPlatformGenesis::acquire(int& l, int& r) {
} }
void DivPlatformGenesis::tick() { void DivPlatformGenesis::tick() {
printf("writes remain: %ld\n",writes.size());
for (int i=0; i<6; i++) { for (int i=0; i<6; i++) {
if (i==2 && extMode) continue; if (i==2 && extMode) continue;
if (chan[i].keyOn || chan[i].keyOff) { if (chan[i].keyOn || chan[i].keyOff) {