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.
// if notPrimary is true then the song will not be altered
SafeWriter* saveFur(bool notPrimary=false, bool newPatternFormat=true);
// build a ROM file (TODO).
// specify system to build ROM for.
std::vector<DivROMExportOutput> buildROM(DivROMExportOptions sys);
// return a ROM exporter.
DivROMExport* buildROM(DivROMExportOptions sys);
// dump to VGM.
// set trailingTicks to:
// - 0 to add one tick of trailing

View file

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

View file

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

View file

@ -20,7 +20,34 @@
#include "../export.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?");
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) {}
};
std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
std::vector<DivROMExportOutput> ret;
void DivExportAmigaValidation::run() {
std::vector<WaveEntry> waves;
std::vector<SampleBookEntry> sampleBook;
unsigned int wavesDataPtr=0;
@ -266,12 +265,16 @@ std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
}
// finish
ret.reserve(5);
ret.push_back(DivROMExportOutput("sbook.bin",sbook));
ret.push_back(DivROMExportOutput("wbook.bin",wbook));
ret.push_back(DivROMExportOutput("sample.bin",sample));
ret.push_back(DivROMExportOutput("wave.bin",wave));
ret.push_back(DivROMExportOutput("seq.bin",seq));
return ret;
output.reserve(5);
output.push_back(DivROMExportOutput("sbook.bin",sbook));
output.push_back(DivROMExportOutput("wbook.bin",wbook));
output.push_back(DivROMExportOutput("sample.bin",sample));
output.push_back(DivROMExportOutput("wave.bin",wave));
output.push_back(DivROMExportOutput("seq.bin",seq));
}
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"
class DivExportAmigaValidation: public DivROMExport {
DivEngine* e;
std::thread* exportThread;
void run();
public:
std::vector<DivROMExportOutput> go(DivEngine* e);
bool go(DivEngine* e);
~DivExportAmigaValidation() {}
};

View file

@ -619,41 +619,6 @@ void FurnaceGUI::drawMobileControls() {
if (ImGui::Button(_("Switch to Desktop Mode"))) {
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;
}
}

View file

@ -329,21 +329,31 @@ void FurnaceGUI::drawExportAmigaVal(bool onWindow) {
ImGui::SameLine();
}
if (ImGui::Button(_("Bake Data"),ImVec2(200.0f*dpiScale,0))) {
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);
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[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR;
}
for (DivROMExportOutput& i: ex->getResult()) {
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)ex->getResult().size()));
}
i.data->finish();
delete i.data;
} else {
showError("error!");
}
showError(fmt::sprintf(_("Done! Baked %d files."),(int)out.size()));
delete ex;
ImGui::CloseCurrentPopup();
}
}