From 055b4f9c26d5ced8d5744f33045ce85c94d0a7b4 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 6 Dec 2021 03:07:29 -0500 Subject: [PATCH] genesis: fix delay bug --- src/engine/platform/genesis.cpp | 43 +++++++++++++++------------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index aba3aa12..7bbad5c2 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -32,31 +32,29 @@ void DivPlatformGenesis::acquire(int& l, int& r) { } } - if (!writes.empty() && --delay<0) { - delay=0; - QueuedWrite& w=writes.front(); - if (w.addrOrVal) { - OPN2_Write(&fm,0x1+((w.addr>>8)<<1),w.val); - //printf("write: %x = %.2x\n",w.addr,w.val); - lastBusy=0; - writes.pop(); - } else { - lastBusy++; - if (fm.write_busy==0) { - //printf("busycounter: %d\n",lastBusy); - OPN2_Write(&fm,0x0+((w.addr>>8)<<1),w.addr); - w.addrOrVal=true; + os[0]=0; os[1]=0; + for (int i=0; i<6; i++) { + if (!writes.empty() && --delay<0) { + delay=0; + QueuedWrite& w=writes.front(); + if (w.addrOrVal) { + OPN2_Write(&fm,0x1+((w.addr>>8)<<1),w.val); + //printf("write: %x = %.2x\n",w.addr,w.val); + lastBusy=0; + writes.pop(); + } else { + lastBusy++; + if (fm.write_busy==0) { + //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; while (psgClocks>=rate) { @@ -70,7 +68,6 @@ void DivPlatformGenesis::acquire(int& l, int& r) { } void DivPlatformGenesis::tick() { - printf("writes remain: %ld\n",writes.size()); for (int i=0; i<6; i++) { if (i==2 && extMode) continue; if (chan[i].keyOn || chan[i].keyOff) {