port TIunA to export framework, part 4

index option
This commit is contained in:
tildearrow 2024-08-13 18:42:11 -05:00
parent b7631542c6
commit 34517754ad
2 changed files with 30 additions and 32 deletions

View file

@ -183,16 +183,15 @@ static void writeCmd(std::vector<TiunaBytes>& cmds, TiunaCmd& cmd, unsigned char
void DivExportTiuna::run() {
int loopOrder, loopOrderRow, loopEnd;
int tiaIdx;
int tick=0;
SafeWriter* w;
std::map<int,TiunaCmd> allCmds[2];
// config
int* sysToExport=NULL;
String baseLabel=conf.getString("baseLabel","song");
int firstBankSize=conf.getInt("firstBankSize",3072);
int otherBankSize=conf.getInt("otherBankSize",4096-48);
int tiaIdx=conf.getInt("sysToExport",-1);
e->stop();
e->repeatPattern=false;
@ -210,23 +209,29 @@ void DivExportTiuna::run() {
w=new SafeWriter;
w->init();
tiaIdx=-1;
for (int i=0; i<e->song.systemLen; i++) {
if (sysToExport!=NULL && !sysToExport[i]) continue;
if (e->song.system[i]==DIV_SYSTEM_TIA) {
tiaIdx=i;
e->disCont[i].dispatch->toggleRegisterDump(true);
break;
if (tiaIdx<0 || tiaIdx>=e->song.systemLen) {
tiaIdx=-1;
for (int i=0; i<e->song.systemLen; i++) {
if (e->song.system[i]==DIV_SYSTEM_TIA) {
tiaIdx=i;
break;
}
}
}
if (tiaIdx<0) {
logAppend("ERROR: selected TIA system not found");
if (tiaIdx<0) {
logAppend("ERROR: selected TIA system not found");
failed=true;
running=false;
return;
}
} else if (e->song.system[tiaIdx]!=DIV_SYSTEM_TIA) {
logAppend("ERROR: selected chip is not a TIA!");
failed=true;
running=false;
return;
}
e->disCont[tiaIdx].dispatch->toggleRegisterDump(true);
// write patterns
// bool writeLoop=false;
logAppend("recording sequence...");

View file

@ -281,6 +281,7 @@ void FurnaceGUI::drawExportROM(bool onWindow) {
String asmBaseLabel=romConfig.getString("baseLabel","song");
int firstBankSize=romConfig.getInt("firstBankSize",3072);
int otherBankSize=romConfig.getInt("otherBankSize",4096-48);
int sysToExport=romConfig.getInt("sysToExport",-1);
// TODO; validate label
if (ImGui::InputText(_("base song label name"),&asmBaseLabel)) {
@ -297,30 +298,22 @@ void FurnaceGUI::drawExportROM(bool onWindow) {
altered=true;
}
ImGui::Text(_("chips to export:"));
int selected=0;
ImGui::Text(_("chip to export:"));
for (int i=0; i<e->song.systemLen; i++) {
DivSystem sys=e->song.system[i];
bool isTIA=sys==DIV_SYSTEM_TIA;
ImGui::BeginDisabled((!isTIA) || (selected>=1));
if (ImGui::Checkbox(fmt::sprintf("%d. %s##_SYSV%d",i+1,getSystemName(e->song.system[i]),i).c_str(),&willExport[i])) {
bool isTIA=(sys==DIV_SYSTEM_TIA);
ImGui::BeginDisabled(!isTIA);
if (ImGui::RadioButton(fmt::sprintf("%d. %s##_SYSV%d",i+1,getSystemName(e->song.system[i]),i).c_str(),sysToExport==i)) {
sysToExport=i;
altered=true;
}
ImGui::EndDisabled();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
if (!isTIA) {
ImGui::SetTooltip(_("this chip is not supported by the file format!"));
} else if (selected>=1) {
ImGui::SetTooltip(_("only one Atari TIA is supported!"));
}
}
if (isTIA && willExport[i]) selected++;
if (altered) {
romConfig.set("baseLabel",asmBaseLabel);
romConfig.set("firstBankSize",firstBankSize);
romConfig.set("otherBankSize",otherBankSize);
}
}
if (altered) {
romConfig.set("baseLabel",asmBaseLabel);
romConfig.set("firstBankSize",firstBankSize);
romConfig.set("otherBankSize",otherBankSize);
romConfig.set("sysToExport",sysToExport);
}
break;
}