From 6b2c010afaee5fb1b240bf8e88ef9d91ef92108f Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 1 Jul 2024 05:17:12 -0500 Subject: [PATCH] S3M import: Armani can take a shower again --- src/engine/platform/es5506.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/engine/platform/es5506.cpp b/src/engine/platform/es5506.cpp index a8103a546..d07ef65e9 100644 --- a/src/engine/platform/es5506.cpp +++ b/src/engine/platform/es5506.cpp @@ -1315,7 +1315,7 @@ void DivPlatformES5506::renderSamples(int sysID) { memCompo=DivMemoryComposition(); memCompo.name="Sample Memory"; - size_t memPos=129; // add silent at begin and end of each bank for reverse playback and add 1 for loop + size_t memPos=128; // add silent at begin and end of each bank for reverse playback and add 1 for loop for (int i=0; isong.sampleLen; i++) { DivSample* s=parent->song.sample[i]; if (!s->renderOn[0][sysID]) { @@ -1340,8 +1340,13 @@ void DivPlatformES5506::renderSamples(int sysID) { logW("out of ES5506 memory for sample %d!",i); } else { memcpy(sampleMem+(memPos/sizeof(short)),s->data16,length); + // inject loop sample + if (s->loop && s->loopEnd>=0 && s->loopEnd<=(int)s->samples && s->loopStart>=0 && s->loopStart<(int)s->samples) { + sampleMem[(memPos/sizeof(short))+s->loopEnd]=s->data16[s->loopStart]; + if (s->loopEnd>=(int)s->samples) length+=2; + } } - sampleOffES5506[i]=memPos-1; + sampleOffES5506[i]=memPos; sampleLoaded[i]=true; memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+length)); memPos+=length;