From fa4f0ece38139c777e47b26ec695af094ee8f566 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 31 Jul 2024 04:24:28 -0500 Subject: [PATCH 1/5] NON-WORKING....... --- src/gui/gui.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2e9284967..53c23acc4 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5160,6 +5160,27 @@ bool FurnaceGUI::loop() { } break; case GUI_FILE_INS_SAVE_ALL: + for (int i=0; isong.insLen; i++) { + String nextPath=copyOfName; + nextPath+=DIR_SEPARATOR_STR; + nextPath+=fmt::sprintf("%.2X_",i); + for (char i: e->song.ins[i]->name) { + switch (i) { + // there chars are reserved + case '/': case '<': case '>': case ':': case '"': case '\\': case '|': case '?': case '*': + nextPath+='_'; + break; + default: + nextPath+=i; + break; + } + } + nextPath+=".fui"; + if (!e->song.ins[i]->save(nextPath.c_str(),&e->song,settings.writeInsNames)) { + + } + } + break; case GUI_FILE_WAVE_SAVE_ALL: case GUI_FILE_SAMPLE_SAVE_ALL: showError("Placeholder."); From f7553ede78ab2214b9e4998251bd2ad4327d9af0 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 31 Jul 2024 22:53:03 -0500 Subject: [PATCH 2/5] would this fix the issue? --- src/gui/gui.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 53c23acc4..48ffc95f0 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5164,18 +5164,19 @@ bool FurnaceGUI::loop() { String nextPath=copyOfName; nextPath+=DIR_SEPARATOR_STR; nextPath+=fmt::sprintf("%.2X_",i); - for (char i: e->song.ins[i]->name) { - switch (i) { - // there chars are reserved + for (char j: e->song.ins[i]->name) { + switch (j) { + // these chars are reserved case '/': case '<': case '>': case ':': case '"': case '\\': case '|': case '?': case '*': nextPath+='_'; break; default: - nextPath+=i; + nextPath+=j; break; } } nextPath+=".fui"; + logV("%s",nextPath); if (!e->song.ins[i]->save(nextPath.c_str(),&e->song,settings.writeInsNames)) { } From 0fd72afeb455b7e828c87765c2f6cb6a8cc6b651 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 1 Aug 2024 01:19:29 -0500 Subject: [PATCH 3/5] here we go --- src/gui/fileDialog.cpp | 2 +- src/gui/gui.cpp | 58 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/gui/fileDialog.cpp b/src/gui/fileDialog.cpp index cfebb2015..38afb3274 100644 --- a/src/gui/fileDialog.cpp +++ b/src/gui/fileDialog.cpp @@ -486,7 +486,7 @@ std::vector& FurnaceGUIFileDialog::getFileName() { return fileName; } else { fileName.clear(); - if (dialogType==1) { + if (dialogType!=0) { fileName.push_back(ImGuiFileDialog::Instance()->GetFilePathName()); } else { for (auto& i: ImGuiFileDialog::Instance()->GetSelection()) { diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 48ffc95f0..3ba5e2705 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5159,7 +5159,8 @@ bool FurnaceGUI::loop() { } } break; - case GUI_FILE_INS_SAVE_ALL: + case GUI_FILE_INS_SAVE_ALL: { + String errors; for (int i=0; isong.insLen; i++) { String nextPath=copyOfName; nextPath+=DIR_SEPARATOR_STR; @@ -5178,14 +5179,61 @@ bool FurnaceGUI::loop() { nextPath+=".fui"; logV("%s",nextPath); if (!e->song.ins[i]->save(nextPath.c_str(),&e->song,settings.writeInsNames)) { - + errors+=fmt::sprintf("%s: could not save!\n",e->song.ins[i]->name); } } + + if (!errors.empty()) { + showError(errors); + } break; - case GUI_FILE_WAVE_SAVE_ALL: - case GUI_FILE_SAMPLE_SAVE_ALL: - showError("Placeholder."); + } + case GUI_FILE_WAVE_SAVE_ALL: { + String errors; + for (int i=0; isong.waveLen; i++) { + String nextPath=copyOfName; + nextPath+=DIR_SEPARATOR_STR; + nextPath+=fmt::sprintf("%.2X.fuw",i); + logV("%s",nextPath); + if (!e->song.wave[i]->save(nextPath.c_str())) { + errors+=fmt::sprintf("%d: could not save!\n",i); + } + } + + if (!errors.empty()) { + showError(errors); + } break; + } + case GUI_FILE_SAMPLE_SAVE_ALL: { + String errors; + for (int i=0; isong.sampleLen; i++) { + String nextPath=copyOfName; + nextPath+=DIR_SEPARATOR_STR; + nextPath+=fmt::sprintf("%.2X_",i); + for (char j: e->song.sample[i]->name) { + switch (j) { + // these chars are reserved + case '/': case '<': case '>': case ':': case '"': case '\\': case '|': case '?': case '*': + nextPath+='_'; + break; + default: + nextPath+=j; + break; + } + } + nextPath+=".wav"; + logV("%s",nextPath); + if (!e->song.sample[i]->save(nextPath.c_str())) { + errors+=fmt::sprintf("%s: could not save!\n",e->song.sample[i]->name); + } + } + + if (!errors.empty()) { + showError(errors); + } + break; + } case GUI_FILE_WAVE_SAVE: if (curWave>=0 && curWave<(int)e->song.wave.size()) { if (e->song.wave[curWave]->save(copyOfName.c_str())) { From f50911ea4949cbbfcf596392fadfb24b1df28d2b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 2 Aug 2024 02:21:44 -0500 Subject: [PATCH 4/5] FDS: prepare for auto mod --- src/engine/dispatch.h | 2 ++ src/engine/platform/fds.cpp | 6 ++++++ src/engine/platform/fds.h | 3 +++ src/engine/playback.cpp | 4 +++- src/engine/sysDef.cpp | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index aa355f488..e077d8f4d 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -263,6 +263,8 @@ enum DivDispatchCmds { DIV_CMD_BIFURCATOR_STATE_LOAD, DIV_CMD_BIFURCATOR_PARAMETER, + DIV_CMD_FDS_MOD_AUTO, + DIV_CMD_MAX }; diff --git a/src/engine/platform/fds.cpp b/src/engine/platform/fds.cpp index 6d6a3c768..8cc729038 100644 --- a/src/engine/platform/fds.cpp +++ b/src/engine/platform/fds.cpp @@ -342,6 +342,12 @@ int DivPlatformFDS::dispatch(DivCommand c) { rWrite(0x4087,chan[c.chan].modFreq>>8); break; } + case DIV_CMD_FDS_MOD_AUTO: + chan[c.chan].autoModNum=c.value>>4; + chan[c.chan].autoModDen=c.value&15; + chan[c.chan].freqChanged=true; + chan[c.chan].modOn=(chan[c.chan].autoModNum || chan[c.chan].autoModDen); + break; case DIV_CMD_NOTE_PORTA: { int destFreq=NOTE_FREQUENCY(c.value2); bool return2=false; diff --git a/src/engine/platform/fds.h b/src/engine/platform/fds.h index 49b52d063..57c8ff0bc 100644 --- a/src/engine/platform/fds.h +++ b/src/engine/platform/fds.h @@ -29,6 +29,7 @@ class DivPlatformFDS: public DivDispatch { struct Channel: public SharedChannel { int prevFreq, modFreq; unsigned char duty, sweep, modDepth, modPos; + unsigned char autoModNum, autoModDen; bool sweepChanged, modOn; signed short wave; signed char modTable[32]; @@ -40,6 +41,8 @@ class DivPlatformFDS: public DivDispatch { sweep(8), modDepth(0), modPos(0), + autoModNum(0), + autoModDen(0), sweepChanged(false), modOn(false), wave(-1) { diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index b7b8098b6..c61415abd 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -261,7 +261,9 @@ const char* cmdName[]={ "MINMOD_ECHO", "BIFURCATOR_STATE_LOAD", - "BIFURCATOR_PARAMETER" + "BIFURCATOR_PARAMETER", + + "FDS_MOD_AUTO" }; static_assert((sizeof(cmdName)/sizeof(void*))==DIV_CMD_MAX,"update cmdName!"); diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index 20e8461d5..093369fc2 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1053,6 +1053,7 @@ void DivEngine::registerSystems() { {0x13, {DIV_CMD_FDS_MOD_LOW, _("13xx: Set modulation speed low byte")}}, {0x14, {DIV_CMD_FDS_MOD_POS, _("14xx: Set modulator position")}}, {0x15, {DIV_CMD_FDS_MOD_WAVE, _("15xx: Set modulator table to waveform")}}, + {0x16, {DIV_CMD_FDS_MOD_AUTO, _("16xy: Automatic modulation speed (x: numerator; y: denominator)")}}, } ); From 4e7d566791efd7ffbd0771b06414c72053ef5932 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 2 Aug 2024 02:47:55 -0500 Subject: [PATCH 5/5] FDS: implement auto-mod I don't like it. improvements welcome. --- src/engine/platform/fds.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/platform/fds.cpp b/src/engine/platform/fds.cpp index 8cc729038..1e42738af 100644 --- a/src/engine/platform/fds.cpp +++ b/src/engine/platform/fds.cpp @@ -200,6 +200,15 @@ void DivPlatformFDS::tick(bool sysTick) { } rWrite(0x4082,chan[i].freq&0xff); rWrite(0x4083,(chan[i].freq>>8)&15); + + if (chan[i].autoModNum>0 && chan[i].autoModDen>0) { + chan[i].modFreq=(chan[i].freq*chan[i].autoModNum)/chan[i].autoModDen; + if (chan[i].modFreq>4095) chan[i].modFreq=4095; + if (chan[i].modFreq<0) chan[i].modFreq=0; + rWrite(0x4086,chan[i].modFreq&0xff); + rWrite(0x4087,chan[i].modFreq>>8); + } + if (chan[i].keyOn) chan[i].keyOn=false; if (chan[i].keyOff) chan[i].keyOff=false; chan[i].freqChanged=false; @@ -346,7 +355,8 @@ int DivPlatformFDS::dispatch(DivCommand c) { chan[c.chan].autoModNum=c.value>>4; chan[c.chan].autoModDen=c.value&15; chan[c.chan].freqChanged=true; - chan[c.chan].modOn=(chan[c.chan].autoModNum || chan[c.chan].autoModDen); + chan[c.chan].modOn=(chan[c.chan].autoModNum && chan[c.chan].autoModDen); + rWrite(0x4084,(chan[c.chan].modOn<<7)|0x40|chan[c.chan].modDepth); break; case DIV_CMD_NOTE_PORTA: { int destFreq=NOTE_FREQUENCY(c.value2);