From 4ee17d35cdfce8661286d97b8f3c7b0615c0d66f Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 20 Jan 2022 02:46:28 -0500 Subject: [PATCH] implement sample loop on the rest of systems --- src/engine/platform/arcade.cpp | 14 ++++++++++++-- src/engine/platform/genesis.cpp | 6 +++++- src/engine/platform/nes.cpp | 6 +++++- src/engine/platform/pce.cpp | 6 +++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index ec3e0ac2f..e9d9b6505 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -70,7 +70,12 @@ void DivPlatformArcade::acquire_nuked(short* bufL, short* bufR, size_t start, si } chan[i].pcm.pos+=chan[i].pcm.freq; if (chan[i].pcm.pos>=(s->rendLength<<8)) { - chan[i].pcm.sample=-1; + if (s->loopStart>=0 && s->loopStart<=(int)s->rendLength) { + // Sega PCM limitation + chan[i].pcm.pos=(s->loopStart&(~0xff))<<8; + } else { + chan[i].pcm.sample=-1; + } } } } @@ -127,7 +132,12 @@ void DivPlatformArcade::acquire_ymfm(short* bufL, short* bufR, size_t start, siz } chan[i].pcm.pos+=chan[i].pcm.freq; if (chan[i].pcm.pos>=(s->rendLength<<8)) { - chan[i].pcm.sample=-1; + if (s->loopStart>=0 && s->loopStart<=(int)s->rendLength) { + // Sega PCM limitation + chan[i].pcm.pos=(s->loopStart&(~0xff))<<8; + } else { + chan[i].pcm.sample=-1; + } } } } diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index c341de955..d59260f1d 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -26,7 +26,11 @@ void DivPlatformGenesis::acquire(short* bufL, short* bufR, size_t start, size_t } } if (dacPos>=s->rendLength) { - dacSample=-1; + if (s->loopStart>=0 && s->loopStart<=(int)s->rendLength) { + dacPos=s->loopStart; + } else { + dacSample=-1; + } } dacPeriod+=dacRate; } diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index 48157df56..50c81fa0a 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -23,7 +23,11 @@ void DivPlatformNES::acquire(short* bufL, short* bufR, size_t start, size_t len) } } if (dacPos>=s->rendLength) { - dacSample=-1; + if (s->loopStart>=0 && s->loopStart<=(int)s->rendLength) { + dacPos=s->loopStart; + } else { + dacSample=-1; + } } dacPeriod-=rate; } diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index cc6121368..e2719905f 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -32,7 +32,11 @@ void DivPlatformPCE::acquire(short* bufL, short* bufR, size_t start, size_t len) chWrite(i,0x06,(((unsigned short)s->rendData[chan[i].dacPos++]+0x8000)>>11)); } if (chan[i].dacPos>=s->rendLength) { - chan[i].dacSample=-1; + if (s->loopStart>=0 && s->loopStart<=(int)s->rendLength) { + chan[i].dacPos=s->loopStart; + } else { + chan[i].dacSample=-1; + } } chan[i].dacPeriod+=chan[i].dacRate; }