-romout command line export

consolidate DivEngine::isROMExportViable function from FurnaceGUI::updateROMExportAvail to avoid copy-paste
This commit is contained in:
bbbradsmith 2024-12-13 03:44:52 -05:00 committed by tildearrow
parent addb50e384
commit 55a189444f
5 changed files with 118 additions and 51 deletions

View file

@ -769,60 +769,13 @@ void FurnaceGUI::autoDetectSystem() {
}
void FurnaceGUI::updateROMExportAvail() {
unsigned char sysReqCount[DIV_SYSTEM_MAX];
unsigned char defReqCount[DIV_SYSTEM_MAX];
memset(sysReqCount,0,DIV_SYSTEM_MAX);
for (int i=0; i<e->song.systemLen; i++) {
sysReqCount[e->song.system[i]]++;
}
memset(romExportAvail,0,sizeof(bool)*DIV_ROM_MAX);
romExportExists=false;
for (int i=0; i<DIV_ROM_MAX; i++) {
const DivROMExportDef* newDef=e->getROMExportDef((DivROMExportOptions)i);
if (newDef!=NULL) {
// check for viability
bool viable=true;
memset(defReqCount,0,DIV_SYSTEM_MAX);
for (DivSystem j: newDef->requisites) {
defReqCount[j]++;
}
switch (newDef->requisitePolicy) {
case DIV_REQPOL_EXACT:
for (int j=0; j<DIV_SYSTEM_MAX; j++) {
if (defReqCount[j]!=sysReqCount[j]) {
viable=false;
break;
}
}
break;
case DIV_REQPOL_ANY:
for (int j=0; j<DIV_SYSTEM_MAX; j++) {
if (defReqCount[j]>sysReqCount[j]) {
viable=false;
break;
}
}
break;
case DIV_REQPOL_LAX:
viable=false;
for (DivSystem j: newDef->requisites) {
if (defReqCount[j]<=sysReqCount[j]) {
viable=true;
break;
}
}
break;
}
if (viable) {
romExportAvail[i]=true;
romExportExists=true;
}
if (e->isROMExportViable((DivROMExportOptions)i)) {
romExportAvail[i]=true;
romExportExists=true;
}
}