Genesis: better DAC write algorithm

only write DAC if there aren't too many queued writes
This commit is contained in:
tildearrow 2022-03-27 01:47:27 -05:00
parent 1c98748a88
commit 5dac609d92
2 changed files with 7 additions and 3 deletions

View file

@ -92,8 +92,10 @@ void DivPlatformGenesis::acquire_nuked(short* bufL, short* bufR, size_t start, s
DivSample* s=parent->getSample(dacSample); DivSample* s=parent->getSample(dacSample);
if (s->samples>0) { if (s->samples>0) {
if (!isMuted[5]) { if (!isMuted[5]) {
if (writes.size()<16) {
urgentWrite(0x2a,(unsigned char)s->data8[dacPos]+0x80); urgentWrite(0x2a,(unsigned char)s->data8[dacPos]+0x80);
} }
}
if (++dacPos>=s->samples) { if (++dacPos>=s->samples) {
if (s->loopStart>=0 && s->loopStart<(int)s->samples) { if (s->loopStart>=0 && s->loopStart<(int)s->samples) {
dacPos=s->loopStart; dacPos=s->loopStart;
@ -159,8 +161,10 @@ void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, si
DivSample* s=parent->getSample(dacSample); DivSample* s=parent->getSample(dacSample);
if (s->samples>0) { if (s->samples>0) {
if (!isMuted[5]) { if (!isMuted[5]) {
if (writes.size()<16) {
urgentWrite(0x2a,(unsigned char)s->data8[dacPos]+0x80); urgentWrite(0x2a,(unsigned char)s->data8[dacPos]+0x80);
} }
}
if (++dacPos>=s->samples) { if (++dacPos>=s->samples) {
if (s->loopStart>=0 && s->loopStart<(int)s->samples) { if (s->loopStart>=0 && s->loopStart<(int)s->samples) {
dacPos=s->loopStart; dacPos=s->loopStart;

View file

@ -44,6 +44,6 @@ static int orderedOps[4]={
#define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;} #define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;}
#define immWrite(a,v) if (!skipRegisterWrites) {writes.push_back(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define immWrite(a,v) if (!skipRegisterWrites) {writes.push_back(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} }
#define urgentWrite(a,v) if (!skipRegisterWrites) {if (writes.empty() || writes.front().addrOrVal) {writes.push_back(QueuedWrite(a,v));} else {writes.push_front(QueuedWrite(a,v));}; if (dumpWrites) {addWrite(a,v);} } #define urgentWrite(a,v) if (!skipRegisterWrites) {if (writes.empty() || writes.size()>16 || writes.front().addrOrVal) {writes.push_back(QueuedWrite(a,v));} else {writes.push_front(QueuedWrite(a,v));}; if (dumpWrites) {addWrite(a,v);} }
#include "fmshared_OPN.h" #include "fmshared_OPN.h"