apvr eatavel eao rso jyrsovrs

to-do:
- make an "exporting ROM" dialog with progress and all
- move TIunA export to the ROM export framework
- perhaps do the same with ZSM in the future?
This commit is contained in:
tildearrow 2024-08-10 19:25:01 -05:00
parent 48523add00
commit a4aa408912
8 changed files with 80 additions and 72 deletions

View file

@ -697,9 +697,8 @@ class DivEngine {
// save as .fur. // save as .fur.
// if notPrimary is true then the song will not be altered // if notPrimary is true then the song will not be altered
SafeWriter* saveFur(bool notPrimary=false, bool newPatternFormat=true); SafeWriter* saveFur(bool notPrimary=false, bool newPatternFormat=true);
// build a ROM file (TODO). // return a ROM exporter.
// specify system to build ROM for. DivROMExport* buildROM(DivROMExportOptions sys);
std::vector<DivROMExportOutput> buildROM(DivROMExportOptions sys);
// dump to VGM. // dump to VGM.
// set trailingTicks to: // set trailingTicks to:
// - 0 to add one tick of trailing // - 0 to add one tick of trailing

View file

@ -21,7 +21,7 @@
#include "export/amigaValidation.h" #include "export/amigaValidation.h"
std::vector<DivROMExportOutput> DivEngine::buildROM(DivROMExportOptions sys) { DivROMExport* DivEngine::buildROM(DivROMExportOptions sys) {
DivROMExport* exporter=NULL; DivROMExport* exporter=NULL;
switch (sys) { switch (sys) {
case DIV_ROM_AMIGA_VALIDATION: case DIV_ROM_AMIGA_VALIDATION:
@ -31,7 +31,5 @@ std::vector<DivROMExportOutput> DivEngine::buildROM(DivROMExportOptions sys) {
exporter=new DivROMExport; exporter=new DivROMExport;
break; break;
} }
std::vector<DivROMExportOutput> ret=exporter->go(this); return exporter;
delete exporter;
return ret;
} }

View file

@ -51,13 +51,16 @@ struct DivROMExportProgress {
}; };
class DivROMExport { class DivROMExport {
protected:
std::vector<String> exportLog; std::vector<String> exportLog;
std::vector<DivROMExportOutput> output;
std::mutex logLock; std::mutex logLock;
void logAppend(String what); void logAppend(String what);
public: public:
virtual bool go(DivEngine* eng); virtual bool go(DivEngine* eng);
virtual void abort(); virtual void abort();
virtual std::vector<DivROMExportOutput> getResult(); virtual void wait();
std::vector<DivROMExportOutput>& getResult();
virtual bool hasFailed(); virtual bool hasFailed();
virtual DivROMExportProgress getProgress(); virtual DivROMExportProgress getProgress();
virtual ~DivROMExport() {} virtual ~DivROMExport() {}

View file

@ -20,7 +20,34 @@
#include "../export.h" #include "../export.h"
#include "../../ta-log.h" #include "../../ta-log.h"
std::vector<DivROMExportOutput> DivROMExport::go(DivEngine* e) { bool DivROMExport::go(DivEngine* eng) {
logW("what's this? the null ROM export?"); logW("what's this? the null ROM export?");
return std::vector<DivROMExportOutput>(); return false;
}
void DivROMExport::abort() {
}
std::vector<DivROMExportOutput>& DivROMExport::getResult() {
return output;
}
bool DivROMExport::hasFailed() {
return true;
}
DivROMExportProgress DivROMExport::getProgress() {
DivROMExportProgress ret;
ret.name="Test";
ret.amount=0.0f;
return ret;
}
void DivROMExport::logAppend(String what) {
logLock.lock();
exportLog.push_back(what);
logLock.unlock();
}
void DivROMExport::wait() {
} }

View file

@ -40,8 +40,7 @@ struct SampleBookEntry {
len(0) {} len(0) {}
}; };
std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) { void DivExportAmigaValidation::run() {
std::vector<DivROMExportOutput> ret;
std::vector<WaveEntry> waves; std::vector<WaveEntry> waves;
std::vector<SampleBookEntry> sampleBook; std::vector<SampleBookEntry> sampleBook;
unsigned int wavesDataPtr=0; unsigned int wavesDataPtr=0;
@ -266,12 +265,16 @@ std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
} }
// finish // finish
ret.reserve(5); output.reserve(5);
ret.push_back(DivROMExportOutput("sbook.bin",sbook)); output.push_back(DivROMExportOutput("sbook.bin",sbook));
ret.push_back(DivROMExportOutput("wbook.bin",wbook)); output.push_back(DivROMExportOutput("wbook.bin",wbook));
ret.push_back(DivROMExportOutput("sample.bin",sample)); output.push_back(DivROMExportOutput("sample.bin",sample));
ret.push_back(DivROMExportOutput("wave.bin",wave)); output.push_back(DivROMExportOutput("wave.bin",wave));
ret.push_back(DivROMExportOutput("seq.bin",seq)); output.push_back(DivROMExportOutput("seq.bin",seq));
}
return ret;
bool DivExportAmigaValidation::go(DivEngine* eng) {
e=eng;
exportThread=new std::thread(&DivExportAmigaValidation::run,this);
return true;
} }

View file

@ -20,7 +20,10 @@
#include "../export.h" #include "../export.h"
class DivExportAmigaValidation: public DivROMExport { class DivExportAmigaValidation: public DivROMExport {
DivEngine* e;
std::thread* exportThread;
void run();
public: public:
std::vector<DivROMExportOutput> go(DivEngine* e); bool go(DivEngine* e);
~DivExportAmigaValidation() {} ~DivExportAmigaValidation() {}
}; };

View file

@ -619,41 +619,6 @@ void FurnaceGUI::drawMobileControls() {
if (ImGui::Button(_("Switch to Desktop Mode"))) { if (ImGui::Button(_("Switch to Desktop Mode"))) {
toggleMobileUI(!mobileUI); toggleMobileUI(!mobileUI);
} }
int numAmiga=0;
for (int i=0; i<e->song.systemLen; i++) {
if (e->song.system[i]==DIV_SYSTEM_AMIGA) numAmiga++;
}
if (numAmiga) {
ImGui::Text(_(
"this is NOT ROM export! only use for making sure the\n"
"Furnace Amiga emulator is working properly by\n"
"comparing it with real Amiga output."
));
ImGui::AlignTextToFramePadding();
ImGui::Text(_("Directory"));
ImGui::SameLine();
ImGui::InputText("##AVDPath",&workingDirROMExport);
if (ImGui::Button(_("Bake Data"))) {
std::vector<DivROMExportOutput> out=e->buildROM(DIV_ROM_AMIGA_VALIDATION);
if (workingDirROMExport.size()>0) {
if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR;
}
for (DivROMExportOutput& i: out) {
String path=workingDirROMExport+i.name;
FILE* outFile=ps_fopen(path.c_str(),"wb");
if (outFile!=NULL) {
fwrite(i.data->getFinalBuf(),1,i.data->size(),outFile);
fclose(outFile);
}
i.data->finish();
delete i.data;
}
showError(fmt::sprintf(_("Done! Baked %d files."),(int)out.size()));
}
}
break; break;
} }
} }

View file

@ -329,11 +329,16 @@ void FurnaceGUI::drawExportAmigaVal(bool onWindow) {
ImGui::SameLine(); ImGui::SameLine();
} }
if (ImGui::Button(_("Bake Data"),ImVec2(200.0f*dpiScale,0))) { if (ImGui::Button(_("Bake Data"),ImVec2(200.0f*dpiScale,0))) {
std::vector<DivROMExportOutput> out=e->buildROM(DIV_ROM_AMIGA_VALIDATION); DivROMExport* ex=e->buildROM(DIV_ROM_AMIGA_VALIDATION);
if (ex->go(e)) {
ex->wait();
if (ex->hasFailed()) {
showError("error!");
} else {
if (workingDirROMExport.size()>0) { if (workingDirROMExport.size()>0) {
if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR; if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR;
} }
for (DivROMExportOutput& i: out) { for (DivROMExportOutput& i: ex->getResult()) {
String path=workingDirROMExport+i.name; String path=workingDirROMExport+i.name;
FILE* outFile=ps_fopen(path.c_str(),"wb"); FILE* outFile=ps_fopen(path.c_str(),"wb");
if (outFile!=NULL) { if (outFile!=NULL) {
@ -343,7 +348,12 @@ void FurnaceGUI::drawExportAmigaVal(bool onWindow) {
i.data->finish(); i.data->finish();
delete i.data; delete i.data;
} }
showError(fmt::sprintf(_("Done! Baked %d files."),(int)out.size())); showError(fmt::sprintf(_("Done! Baked %d files."),(int)ex->getResult().size()));
}
} else {
showError("error!");
}
delete ex;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
} }