From bc4c8acd87fcc69814d14ec90e05205870612c4e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 23 Sep 2022 19:34:44 -0500 Subject: [PATCH] AY PCM still doesn't work so I am leaving a note --- src/engine/platform/ay.cpp | 13 +++++++------ src/engine/platform/ay8930.cpp | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index ad2bbc65..851ef46b 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -89,26 +89,27 @@ void DivPlatformAY8910::acquire(short* bufL, short* bufR, size_t start, size_t l ayBuf[i]=new short[ayBufLen]; } } + // TODO: try to fit this into the actual loop // PCM part for (int i=0; i<3; i++) { if (chan[i].psgMode.dac && chan[i].dac.sample!=-1) { chan[i].dac.period+=chan[i].dac.rate; bool end=false; bool changed=false; - int prev_out = chan[i].dac.out; + int prevOut=chan[i].dac.out; while (chan[i].dac.period>rate && !end) { DivSample* s=parent->getSample(chan[i].dac.sample); if (s->samples<=0) { chan[i].dac.sample=-1; - rWrite(0x08+i,0); + immWrite(0x08+i,0); end=true; break; } // Partially unsigned char dacData=(((unsigned char)s->data8[chan[i].dac.pos]^0x80)>>4); chan[i].dac.out=MAX(0,MIN(15,(dacData*chan[i].outVol)/15)); - if (prev_out!=chan[i].dac.out) { - prev_out=chan[i].dac.out; + if (prevOut!=chan[i].dac.out) { + prevOut=chan[i].dac.out; changed=true; } chan[i].dac.pos++; @@ -116,7 +117,7 @@ void DivPlatformAY8910::acquire(short* bufL, short* bufR, size_t start, size_t l chan[i].dac.pos=s->loopStart; } else if (chan[i].dac.pos>=(int)s->samples) { chan[i].dac.sample=-1; - rWrite(0x08+i,0); + immWrite(0x08+i,0); end=true; break; } @@ -124,7 +125,7 @@ void DivPlatformAY8910::acquire(short* bufL, short* bufR, size_t start, size_t l } if (changed && !end) { if (!isMuted[i]) { - rWrite(0x08+i,chan[i].dac.out); + immWrite(0x08+i,chan[i].dac.out); } } } diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index 913be11b..fbc9b327 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -85,6 +85,7 @@ void DivPlatformAY8930::acquire(short* bufL, short* bufR, size_t start, size_t l ayBuf[i]=new short[ayBufLen]; } } + // TODO: try to fit this into the actual loop // PCM part for (int i=0; i<3; i++) { if (chan[i].psgMode.dac && chan[i].dac.sample!=-1) { @@ -96,7 +97,7 @@ void DivPlatformAY8930::acquire(short* bufL, short* bufR, size_t start, size_t l DivSample* s=parent->getSample(chan[i].dac.sample); if (s->samples<=0) { chan[i].dac.sample=-1; - rWrite(0x08+i,0); + immWrite(0x08+i,0); end=true; break; } @@ -112,7 +113,7 @@ void DivPlatformAY8930::acquire(short* bufL, short* bufR, size_t start, size_t l chan[i].dac.pos=s->loopStart; } else if (chan[i].dac.pos>=(int)s->samples) { chan[i].dac.sample=-1; - rWrite(0x08+i,0); + immWrite(0x08+i,0); end=true; break; } @@ -120,7 +121,7 @@ void DivPlatformAY8930::acquire(short* bufL, short* bufR, size_t start, size_t l } if (changed && !end) { if (!isMuted[i]) { - rWrite(0x08+i,chan[i].dac.out); + immWrite(0x08+i,chan[i].dac.out); } } }