ZSM export: support for looped samples, fix error dispatching ZSM sync events

This commit is contained in:
MooingLemur 2023-07-07 11:38:44 -07:00 committed by tildearrow
parent dfa663a500
commit d722cc33d4
4 changed files with 39 additions and 20 deletions

View file

@ -19,7 +19,6 @@
#include "vera.h"
#include "../engine.h"
#include "../../ta-log.h"
#include <string.h>
#include <math.h>
@ -40,14 +39,15 @@ extern "C" {
#define rWriteZSMSync(d) {if (dumpWrites) addWrite(68,(d));}
const char* regCheatSheetVERA[]={
"CHxFreq", "00+x*4",
"CHxVol", "02+x*4",
"CHxWave", "03+x*4",
"CHxFreq", "00+x*4",
"CHxVol", "02+x*4",
"CHxWave", "03+x*4",
"AUDIO_CTRL", "40",
"AUDIO_RATE", "41",
"AUDIO_DATA", "42",
"ZSM_SYNC", "44",
"AUDIO_CTRL", "40",
"AUDIO_RATE", "41",
"AUDIO_DATA", "42",
"ZSM_PCM_LOOP_POINT", "43",
"ZSM_SYNC", "44",
NULL
};
@ -230,9 +230,16 @@ void DivPlatformVERA::tick(bool sysTick) {
chan[16].freqChanged=false;
}
// For export, output the entire sample that starts on this tick
if (dumpWrites) {
DivSample* s=parent->getSample(chan[16].pcm.sample);
if (s->samples>0) {
if (s->isLoopable()) {
// Inform the export process of the loop point for this sample
addWrite(67,s->loopStart&0xff);
addWrite(67,(s->loopStart>>8)&0xff);
addWrite(67,(s->loopStart>>16)&0xff);
}
while (true) {
short tmp_l=0;
short tmp_r=0;
@ -258,8 +265,6 @@ void DivPlatformVERA::tick(bool sysTick) {
}
chan[16].pcm.pos++;
if (s->isLoopable() && chan[16].pcm.pos>=(unsigned int)s->loopEnd) {
//chan[16].pcm.pos=s->loopStart;
logI("VERA PCM export: treating looped sample as non-looped");
chan[16].pcm.sample=-1;
break;
}