From 45eab67fd46d7f5b197d3429deefd31164b767e9 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 13 Aug 2024 04:10:03 -0500 Subject: [PATCH] prepare more stuff --- CMakeLists.txt | 1 + src/engine/engine.h | 6 ++++ src/engine/export.h | 26 +++++++++++------ src/engine/exportDef.cpp | 60 +++++++++++++++++++++++++++++++++++++++ src/gui/exportOptions.cpp | 11 +++++++ 5 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 src/engine/exportDef.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b7bc35433..464283d9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -693,6 +693,7 @@ src/engine/configEngine.cpp src/engine/dispatchContainer.cpp src/engine/engine.cpp src/engine/export.cpp +src/engine/exportDef.cpp src/engine/fileOpsIns.cpp src/engine/fileOpsSample.cpp src/engine/filter.cpp diff --git a/src/engine/engine.h b/src/engine/engine.h index a2e900c81..7f19e946b 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -518,6 +518,7 @@ class DivEngine { static DivSysDef* sysDefs[DIV_MAX_CHIP_DEFS]; static DivSystem sysFileMapFur[DIV_MAX_CHIP_DEFS]; static DivSystem sysFileMapDMF[DIV_MAX_CHIP_DEFS]; + static DivROMExportDef* romExportDefs[DIV_ROM_MAX]; DivCSPlayer* cmdStreamInt; @@ -624,6 +625,7 @@ class DivEngine { bool deinitAudioBackend(bool dueToSwitchMaster=false); void registerSystems(); + void registerROMExports(); void initSongWithDesc(const char* description, bool inBase64=true, bool oldVol=false); void exchangeIns(int one, int two); @@ -884,6 +886,9 @@ class DivEngine { // get sys definition const DivSysDef* getSystemDef(DivSystem sys); + // get ROM export definition + const DivROMExportDef* getROMExportDef(DivROMExportOptions opt); + // convert sample rate format int fileToDivRate(int frate); int divToFileRate(int drate); @@ -1466,6 +1471,7 @@ class DivEngine { memset(pitchTable,0,4096*sizeof(int)); memset(effectSlotMap,-1,4096*sizeof(short)); memset(sysDefs,0,DIV_MAX_CHIP_DEFS*sizeof(void*)); + memset(romExportDefs,0,DIV_ROM_MAX*sizeof(void*)); memset(walked,0,8192); memset(oscBuf,0,DIV_MAX_OUTPUTS*(sizeof(float*))); memset(exportChannelMask,1,DIV_MAX_CHANS*sizeof(bool)); diff --git a/src/engine/export.h b/src/engine/export.h index 9445ecfe9..4911217c8 100644 --- a/src/engine/export.h +++ b/src/engine/export.h @@ -29,6 +29,8 @@ class DivEngine; enum DivROMExportOptions { DIV_ROM_ABSTRACT=0, DIV_ROM_AMIGA_VALIDATION, + DIV_ROM_ZSM, + DIV_ROM_TIUNA, DIV_ROM_MAX }; @@ -67,24 +69,30 @@ class DivROMExport { virtual ~DivROMExport() {} }; +enum DivROMExportReqPolicy { + // exactly these chips. + DIV_REQPOL_EXACT=0, + // specified chips must be present but any amount of them is acceptable. + DIV_REQPOL_ANY, + // at least one of the specified chips. + DIV_REQPOL_LAX +}; + struct DivROMExportDef { const char* name; const char* author; const char* description; - DivSystem requisites[32]; - int requisitesLen; + std::vector requisites; bool multiOutput; + DivROMExportReqPolicy requisitePolicy; - DivROMExportDef(const char* n, const char* a, const char* d, std::initializer_list req, bool multiOut): + DivROMExportDef(const char* n, const char* a, const char* d, std::initializer_list req, bool multiOut, DivROMExportReqPolicy reqPolicy): name(n), author(a), description(d), - multiOutput(multiOut) { - requisitesLen=0; - memset(requisites,0,32*sizeof(DivSystem)); - for (DivSystem i: req) { - requisites[requisitesLen++]=i; - } + multiOutput(multiOut), + requisitePolicy(reqPolicy) { + requisites=req; } }; diff --git a/src/engine/exportDef.cpp b/src/engine/exportDef.cpp new file mode 100644 index 000000000..bdf881e65 --- /dev/null +++ b/src/engine/exportDef.cpp @@ -0,0 +1,60 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2024 tildearrow and contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "engine.h" + +DivROMExportDef* DivEngine::romExportDefs[DIV_ROM_MAX]; + +const DivROMExportDef* DivEngine::getROMExportDef(DivROMExportOptions opt) { + return romExportDefs[opt]; +} + +void DivEngine::registerROMExports() { + logD("registering ROM exports..."); + + romExportDefs[DIV_ROM_AMIGA_VALIDATION]=new DivROMExportDef( + "Amiga Validation", "tildearrow", + "a test export for ensuring Amiga emulation is accurate. do not use!", + {DIV_SYSTEM_AMIGA}, + true, DIV_REQPOL_EXACT + ); + + romExportDefs[DIV_ROM_ZSM]=new DivROMExportDef( + "Commander X16 ZSM", "ZeroByteOrg and MooingLemur", + "Commander X16 Zsound Music File.\n" + "for use with Melodius, Calliope and/or ZSMKit:\n" + "- https://github.com/mooinglemur/zsmkit (development)\n" + "- https://github.com/mooinglemur/melodius (player)\n" + "- https://github.com/ZeroByteOrg/calliope (player)\n", + { + DIV_SYSTEM_YM2151, DIV_SYSTEM_VERA + }, + true, DIV_REQPOL_LAX + ); + + romExportDefs[DIV_ROM_TIUNA]=new DivROMExportDef( + "Atari 2600 (TIunA)", "Natt Akuma", + "advanced driver with software tuning support.\n" + "see https://github.com/AYCEdemo/twin-tiuna for code.", + { + DIV_SYSTEM_TIA + }, + true, DIV_REQPOL_ANY + ); +} \ No newline at end of file diff --git a/src/gui/exportOptions.cpp b/src/gui/exportOptions.cpp index 904c88891..582ba3055 100644 --- a/src/gui/exportOptions.cpp +++ b/src/gui/exportOptions.cpp @@ -240,7 +240,18 @@ void FurnaceGUI::drawExportVGM(bool onWindow) { } void FurnaceGUI::drawExportROM(bool onWindow) { + exitDisabledTimer=1; + + if (onWindow) { + ImGui::Separator(); + if (ImGui::Button(_("Cancel"),ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup(); + ImGui::SameLine(); + } + if (ImGui::Button(_("Export"),ImVec2(200.0f*dpiScale,0))) { + openFileDialog(GUI_FILE_EXPORT_ROM); + ImGui::CloseCurrentPopup(); + } } void FurnaceGUI::drawExportZSM(bool onWindow) {