dev96 - add virtual tempo

This commit is contained in:
tildearrow 2022-05-18 00:05:25 -05:00
parent f1ca53561f
commit cfa05143ab
10 changed files with 90 additions and 21 deletions

View file

@ -1068,6 +1068,7 @@ void DivEngine::playSub(bool preserveDrift, int goalRow) {
endOfSong=false;
} else {
ticks=1;
tempoAccum=0;
totalTicks=0;
totalSeconds=0;
totalTicksR=0;
@ -2669,6 +2670,7 @@ void DivEngine::quitDispatch() {
speedAB=false;
endOfSong=false;
ticks=0;
tempoAccum=0;
curRow=0;
curOrder=0;
nextSpeed=3;

View file

@ -45,8 +45,8 @@
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
#define BUSY_END isBusy.unlock(); softLocked=false;
#define DIV_VERSION "dev95"
#define DIV_ENGINE_VERSION 95
#define DIV_VERSION "dev96"
#define DIV_ENGINE_VERSION 96
// for imports
#define DIV_VERSION_MOD 0xff01
@ -312,6 +312,7 @@ class DivEngine {
int changeOrd, changePos, totalSeconds, totalTicks, totalTicksR, totalCmds, lastCmds, cmdsPerSecond, globalPitch;
unsigned char extValue;
unsigned char speed1, speed2;
short tempoAccum;
DivStatusView view;
DivHaltPositions haltOn;
DivChannelState chan[DIV_MAX_CHANS];
@ -942,6 +943,7 @@ class DivEngine {
extValue(0),
speed1(3),
speed2(3),
tempoAccum(0),
view(DIV_STATUS_NOTHING),
haltOn(DIV_HALT_NONE),
audioEngine(DIV_AUDIO_NULL),

View file

@ -1404,11 +1404,19 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
} else {
reader.readC();
}
for (int i=0; i<18; i++) {
for (int i=0; i<14; i++) {
reader.readC();
}
}
// first song virtual tempo
if (ds.version>=96) {
subSong->virtualTempoN=reader.readS();
subSong->virtualTempoD=reader.readS();
} else {
reader.readI();
}
// subsongs
if (ds.version>=95) {
subSong->name=reader.readString();
@ -1457,7 +1465,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
subSong->hilightA=reader.readC();
subSong->hilightB=reader.readC();
reader.readI(); // reserved
if (ds.version>=96) {
subSong->virtualTempoN=reader.readS();
subSong->virtualTempoD=reader.readS();
} else {
reader.readI();
}
subSong->name=reader.readString();
subSong->notes=reader.readString();
@ -2858,9 +2871,13 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
w->writeC(song.snDutyReset);
w->writeC(song.pitchMacroIsLinear);
w->writeC(song.pitchSlideSpeed);
for (int i=0; i<18; i++) {
for (int i=0; i<14; i++) {
w->writeC(0);
}
// first subsong virtual tempo
w->writeS(subSong->virtualTempoN);
w->writeS(subSong->virtualTempoD);
// subsong list
w->writeString(subSong->name,false);
@ -2891,7 +2908,8 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
w->writeS(subSong->ordersLen);
w->writeC(subSong->hilightA);
w->writeC(subSong->hilightB);
w->writeI(0); // reserved
w->writeS(subSong->virtualTempoN);
w->writeS(subSong->virtualTempoD);
w->writeString(subSong->name,false);
w->writeString(subSong->notes,false);
@ -3171,6 +3189,14 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
addWarning("only the currently selected subsong will be saved");
}
if (curSubSong->virtualTempoD!=curSubSong->virtualTempoN) {
addWarning(".dmf format does not support virtual tempo");
}
if (song.tuning<439.99 && song.tuning>440.01) {
addWarning(".dmf format does not support tuning");
}
if (sys==DIV_SYSTEM_C64_6581 || sys==DIV_SYSTEM_C64_8580) {
addWarning("absolute duty/cutoff macro not available in .dmf!");
addWarning("duty precision will be lost");

View file

@ -900,16 +900,23 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
if (!freelance) {
if (--subticks<=0) {
subticks=tickMult;
if (stepPlay!=1) if (--ticks<=0) {
ret=endOfSong;
if (endOfSong) {
if (song.loopModality!=2) {
playSub(true);
if (stepPlay!=1) {
tempoAccum+=curSubSong->virtualTempoN;
while (tempoAccum>=curSubSong->virtualTempoD) {
tempoAccum-=curSubSong->virtualTempoD;
if (--ticks<=0) {
ret=endOfSong;
if (endOfSong) {
if (song.loopModality!=2) {
playSub(true);
}
}
endOfSong=false;
if (stepPlay==2) stepPlay=1;
nextRow();
break;
}
}
endOfSong=false;
if (stepPlay==2) stepPlay=1;
nextRow();
}
// process stuff
for (int i=0; i<chans; i++) {

View file

@ -114,6 +114,7 @@ struct DivSubSong {
String name, notes;
unsigned char hilightA, hilightB;
unsigned char timeBase, speed1, speed2, arpLen;
short virtualTempoN, virtualTempoD;
bool pal;
bool customTempo;
float hz;
@ -136,6 +137,8 @@ struct DivSubSong {
speed1(6),
speed2(6),
arpLen(1),
virtualTempoN(150),
virtualTempoD(150),
pal(true),
customTempo(false),
hz(60.0),