From c83232f8da3ae323e75299b2a2ca7efcba76edc8 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 11 Jun 2023 18:57:32 -0500 Subject: [PATCH] get rid of some custom tempo legacy --- src/engine/engine.cpp | 39 ++++----------------------------------- src/engine/engine.h | 2 +- src/engine/fileOps.cpp | 26 ++++++++++---------------- src/engine/song.h | 4 ---- src/gui/speed.cpp | 2 +- 5 files changed, 16 insertions(+), 57 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 9f70aef00..5afc54078 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1444,9 +1444,6 @@ void DivEngine::initSongWithDesc(const char* description, bool inBase64, bool ol // extra attributes song.subsong[0]->hz=c.getDouble("tickRate",60.0); - if (song.subsong[0]->hz!=60.0) { - song.subsong[0]->customTempo=true; - } } void DivEngine::createNew(const char* description, String sysName, bool inBase64) { @@ -2696,16 +2693,7 @@ void DivEngine::reset() { elapsedBars=0; elapsedBeats=0; nextSpeed=speeds.val[0]; - divider=60; - if (curSubSong->customTempo) { - divider=curSubSong->hz; - } else { - if (curSubSong->pal) { - divider=60; - } else { - divider=50; - } - } + divider=curSubSong->hz; globalPitch=0; for (int i=0; ireset(); @@ -2920,14 +2908,7 @@ const DivGroovePattern& DivEngine::getSpeeds() { } float DivEngine::getHz() { - if (curSubSong->customTempo) { - return curSubSong->hz; - } else if (curSubSong->pal) { - return 60.0; - } else { - return 50.0; - } - return 60.0; + return curSubSong->hz; } float DivEngine::getCurHz() { @@ -4354,23 +4335,11 @@ void DivEngine::updateSysFlags(int system, bool restart) { BUSY_END; } -void DivEngine::setSongRate(float hz, bool pal) { +void DivEngine::setSongRate(float hz) { BUSY_BEGIN; saveLock.lock(); - curSubSong->pal=!pal; curSubSong->hz=hz; - // what? - curSubSong->customTempo=true; - divider=60; - if (curSubSong->customTempo) { - divider=curSubSong->hz; - } else { - if (curSubSong->pal) { - divider=60; - } else { - divider=50; - } - } + divider=curSubSong->hz; saveLock.unlock(); BUSY_END; } diff --git a/src/engine/engine.h b/src/engine/engine.h index 2b9f59920..bae7daa91 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -954,7 +954,7 @@ class DivEngine { void updateSysFlags(int system, bool restart); // set Hz - void setSongRate(float hz, bool pal); + void setSongRate(float hz); // set remaining loops. -1 means loop forever. void setLoops(int loops); diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index d3ae54212..5a752236d 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -220,20 +220,22 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { ds.subsong[0]->hilightB=reader.readC(); } + bool customTempo=false; + ds.subsong[0]->timeBase=reader.readC(); ds.subsong[0]->speeds.len=2; ds.subsong[0]->speeds.val[0]=reader.readC(); if (ds.version>0x07) { ds.subsong[0]->speeds.val[1]=reader.readC(); - ds.subsong[0]->pal=reader.readC(); - ds.subsong[0]->hz=(ds.subsong[0]->pal)?60:50; - ds.subsong[0]->customTempo=reader.readC(); + bool pal=reader.readC(); + ds.subsong[0]->hz=pal?60:50; + customTempo=reader.readC(); } else { ds.subsong[0]->speeds.len=1; } if (ds.version>0x0a) { String hz=reader.readString(3); - if (ds.subsong[0]->customTempo) { + if (customTempo) { try { ds.subsong[0]->hz=std::stoi(hz); } catch (std::exception& e) { @@ -304,7 +306,6 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { ds.subsong[0]->hz=248; break; } - ds.subsong[0]->customTempo=true; ds.subsong[0]->timeBase=0; addWarning("Yamaha YMU759 emulation is incomplete! please migrate your song to the OPL3 system."); } @@ -1864,8 +1865,6 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { subSong->speeds.val[1]=reader.readC(); subSong->arpLen=reader.readC(); subSong->hz=reader.readF(); - subSong->pal=(subSong->hz>=53); - subSong->customTempo=true; subSong->patLen=reader.readS(); subSong->ordersLen=reader.readS(); @@ -2489,8 +2488,6 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { subSong->speeds.val[1]=reader.readC(); subSong->arpLen=reader.readC(); subSong->hz=reader.readF(); - subSong->pal=(subSong->hz>=53); - subSong->customTempo=true; subSong->patLen=reader.readS(); subSong->ordersLen=reader.readS(); @@ -3322,9 +3319,7 @@ bool DivEngine::loadMod(unsigned char* file, size_t len) { ds.subsong[0]->pat[ch].effectCols=fxCols; } - ds.subsong[0]->pal=false; ds.subsong[0]->hz=50; - ds.subsong[0]->customTempo=false; ds.systemLen=(chCount+3)/4; for(int i=0; ispeeds.val[0]=(unsigned char)reader.readC(); ds.subsong[0]->hz=((double)reader.readC())/2.5; - ds.subsong[0]->customTempo=true; unsigned char masterVol=reader.readC(); @@ -3993,8 +3987,6 @@ bool DivEngine::loadFC(unsigned char* file, size_t len) { ds.subsong[0]->ordersLen=seqLen; ds.subsong[0]->patLen=32; ds.subsong[0]->hz=50; - ds.subsong[0]->pal=true; - ds.subsong[0]->customTempo=true; ds.subsong[0]->pat[3].effectCols=3; ds.subsong[0]->speeds.val[0]=3; ds.subsong[0]->speeds.len=1; @@ -5819,12 +5811,14 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) { w->writeString(song.author,true); w->writeC(curSubSong->hilightA); w->writeC(curSubSong->hilightB); + + int intHz=curSubSong->hz; w->writeC(curSubSong->timeBase); w->writeC(curSubSong->speeds.val[0]); w->writeC((curSubSong->speeds.len>=2)?curSubSong->speeds.val[1]:curSubSong->speeds.val[0]); - w->writeC(curSubSong->pal); - w->writeC(curSubSong->customTempo); + w->writeC((intHz<=53)?1:0); + w->writeC((intHz!=60 && intHz!=50)); char customHz[4]; memset(customHz,0,4); snprintf(customHz,4,"%d",(int)curSubSong->hz); diff --git a/src/engine/song.h b/src/engine/song.h index fd2d1e07d..0a6149f8d 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -153,8 +153,6 @@ struct DivSubSong { unsigned char timeBase, arpLen; DivGroovePattern speeds; short virtualTempoN, virtualTempoD; - bool pal; - bool customTempo; float hz; int patLen, ordersLen; @@ -177,8 +175,6 @@ struct DivSubSong { arpLen(1), virtualTempoN(150), virtualTempoD(150), - pal(true), - customTempo(false), hz(60.0), patLen(64), ordersLen(1) { diff --git a/src/gui/speed.cpp b/src/gui/speed.cpp index 9cb5c72d5..5557c663e 100644 --- a/src/gui/speed.cpp +++ b/src/gui/speed.cpp @@ -56,7 +56,7 @@ void FurnaceGUI::drawSpeed(bool asChild) { if (tempoView) setHz/=2.5; if (setHz<1) setHz=1; if (setHz>999) setHz=999; - e->setSongRate(setHz,setHz<52); + e->setSongRate(setHz); } if (tempoView) { ImGui::SameLine();