dev104 - add "is sample" flag to Sound Unit ins

This commit is contained in:
tildearrow 2022-08-06 04:04:18 -05:00
parent 0946d23883
commit 5534f55f7a
6 changed files with 42 additions and 14 deletions

View file

@ -45,8 +45,8 @@
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
#define BUSY_END isBusy.unlock(); softLocked=false;
#define DIV_VERSION "dev103"
#define DIV_ENGINE_VERSION 103
#define DIV_VERSION "dev104"
#define DIV_ENGINE_VERSION 104
// for imports
#define DIV_VERSION_MOD 0xff01

View file

@ -528,6 +528,10 @@ void DivInstrument::putInsData(SafeWriter* w) {
w->writeC(0);
}
// Sound Unit
w->writeC(su.useSample);
w->writeC(su.switchRoles);
blockEndSeek=w->tell();
w->seek(blockStartSeek,SEEK_SET);
w->writeI(blockEndSeek-blockStartSeek-4);
@ -1075,6 +1079,12 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
for (int k=0; k<23; k++) reader.readC();
}
// Sound Unit
if (version>=104) {
su.useSample=reader.readC();
su.switchRoles=reader.readC();
}
return DIV_DATA_SUCCESS;
}

View file

@ -437,6 +437,14 @@ struct DivInstrumentWaveSynth {
param4(0) {}
};
struct DivInstrumentSoundUnit {
bool useSample;
bool switchRoles;
DivInstrumentSoundUnit():
useSample(false),
switchRoles(false) {}
};
struct DivInstrument {
String name;
bool mode;
@ -450,6 +458,7 @@ struct DivInstrument {
DivInstrumentFDS fds;
DivInstrumentMultiPCM multipcm;
DivInstrumentWaveSynth ws;
DivInstrumentSoundUnit su;
/**
* save the instrument to a SafeWriter.

View file

@ -256,12 +256,12 @@ int DivPlatformSoundUnit::dispatch(DivCommand c) {
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_SU);
if (chan[c.chan].pcm && ins->type!=DIV_INS_AMIGA) {
chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA);
if (chan[c.chan].pcm && !(ins->type==DIV_INS_AMIGA || ins->su.useSample)) {
chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA || ins->su.useSample);
writeControl(c.chan);
writeControlUpper(c.chan);
}
chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA);
chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA || ins->su.useSample);
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].freqChanged=true;