From 6663fc274d17b1d1c053253b591120a2c3a2b4b9 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 13 Mar 2023 04:20:54 -0500 Subject: [PATCH] prepare to add ROM export framework --- CMakeLists.txt | 3 ++ src/asm/68k/amigatest/README.md | 4 +- src/engine/engine.h | 3 +- src/engine/export.h | 63 +++++++++++++++++++++++++++ src/engine/export/abstract.cpp | 26 +++++++++++ src/engine/export/amigaValidation.cpp | 0 src/engine/export/amigaValidation.h | 0 src/engine/platform/amiga.cpp | 4 ++ src/gui/gui.cpp | 44 ++++++++++++++----- 9 files changed, 132 insertions(+), 15 deletions(-) create mode 100644 src/engine/export.h create mode 100644 src/engine/export/abstract.cpp create mode 100644 src/engine/export/amigaValidation.cpp create mode 100644 src/engine/export/amigaValidation.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 906bacff..fa8f92c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -488,6 +488,7 @@ src/engine/waveSynth.cpp src/engine/vgmOps.cpp src/engine/zsmOps.cpp src/engine/zsm.cpp + src/engine/platform/abstract.cpp src/engine/platform/genesis.cpp src/engine/platform/genesisext.cpp @@ -550,6 +551,8 @@ src/engine/platform/sm8521.cpp src/engine/platform/pv1000.cpp src/engine/platform/pcmdac.cpp src/engine/platform/dummy.cpp + +src/engine/export/abstract.cpp ) if (USE_SNDFILE) diff --git a/src/asm/68k/amigatest/README.md b/src/asm/68k/amigatest/README.md index fe941ea5..7cb5b0cd 100644 --- a/src/asm/68k/amigatest/README.md +++ b/src/asm/68k/amigatest/README.md @@ -9,12 +9,12 @@ do not assume this is the actual ROM export! it is nothing more than a register enable the setting in Furnace to unlock the export option by adding this to furnace.cfg: ``` -iCannotWait=true +iCannotWait=1 ``` go to file > export Amiga validation data... -put sample.bin and seq.bin in this directory. +put sample.bin, seq.bin and wave.bin in this directory. compile with vasm: diff --git a/src/engine/engine.h b/src/engine/engine.h index 0ff399bf..7cbc1bd0 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -23,6 +23,7 @@ #include "instrument.h" #include "song.h" #include "dispatch.h" +#include "export.h" #include "dataErrors.h" #include "safeWriter.h" #include "../audio/taAudio.h" @@ -531,7 +532,7 @@ class DivEngine { SafeWriter* saveFur(bool notPrimary=false); // build a ROM file (TODO). // specify system to build ROM for. - SafeWriter* buildROM(int sys); + std::vector buildROM(int sys); // dump to VGM. // set trailingTicks to: // - 0 to add one tick of trailing diff --git a/src/engine/export.h b/src/engine/export.h new file mode 100644 index 00000000..82ba790d --- /dev/null +++ b/src/engine/export.h @@ -0,0 +1,63 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2023 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. + */ + +#ifndef _EXPORT_H +#define _EXPORT_H + +#include "song.h" +#include + +class DivEngine; + +enum DivROMExportOptions { + DIV_ROM_ABSTRACT=0, + DIV_ROM_AMIGA_VALIDATION, + + DIV_ROM_MAX +}; + +struct DivROMExportOutput { + String name; + SafeWriter* data; + + DivROMExportOutput(String n, SafeWriter* d): + name(n), + data(d) {} + DivROMExportOutput(): + name(""), + data(NULL) {} +}; + +class DivROMExport { + const char* name; + const char* author; + const char* description; + DivSystem requisites[32]; + int requisitesLen; + bool multiOutput; + + public: + virtual std::vector go(DivEngine* e); + DivROMExport(const char* n, const char* auth, const char* desc): + name(n), + author(auth), + description(desc) {} +}; + +#endif diff --git a/src/engine/export/abstract.cpp b/src/engine/export/abstract.cpp new file mode 100644 index 00000000..e60e5b0f --- /dev/null +++ b/src/engine/export/abstract.cpp @@ -0,0 +1,26 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2023 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 "../export.h" +#include "../../ta-log.h" + +std::vector go(DivEngine* e) { + logW("what's this? the null ROM export?"); + return std::vector(); +} \ No newline at end of file diff --git a/src/engine/export/amigaValidation.cpp b/src/engine/export/amigaValidation.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/engine/export/amigaValidation.h b/src/engine/export/amigaValidation.h new file mode 100644 index 00000000..e69de29b diff --git a/src/engine/platform/amiga.cpp b/src/engine/platform/amiga.cpp index a83921ad..2a5e9729 100644 --- a/src/engine/platform/amiga.cpp +++ b/src/engine/platform/amiga.cpp @@ -213,6 +213,10 @@ void DivPlatformAmiga::rWrite(unsigned short addr, unsigned short val) { //logV("%.3x = %.4x",addr,val); regPool[addr>>1]=val; + if (!skipRegisterWrites && dumpWrites) { + addWrite(addr,val); + } + switch (addr&0x1fe) { case 0x96: { // DMACON if (val&32768) { diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2c96ceeb..010e9f16 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3668,18 +3668,38 @@ bool FurnaceGUI::loop() { } if (numZSMCompat > 0) { if (ImGui::BeginMenu("export ZSM...")) { - ImGui::Text("Commander X16 Zsound Music File"); - if (ImGui::InputInt("Tick Rate (Hz)",&zsmExportTickRate,1,2)) { - if (zsmExportTickRate<1) zsmExportTickRate=1; - if (zsmExportTickRate>44100) zsmExportTickRate=44100; - } - ImGui::Checkbox("loop",&zsmExportLoop); - ImGui::SameLine(); - if (ImGui::Button("Begin Export")) { - openFileDialog(GUI_FILE_EXPORT_ZSM); - ImGui::CloseCurrentPopup(); - } - ImGui::EndMenu(); + ImGui::Text("Commander X16 Zsound Music File"); + if (ImGui::InputInt("Tick Rate (Hz)",&zsmExportTickRate,1,2)) { + if (zsmExportTickRate<1) zsmExportTickRate=1; + if (zsmExportTickRate>44100) zsmExportTickRate=44100; + } + ImGui::Checkbox("loop",&zsmExportLoop); + ImGui::SameLine(); + if (ImGui::Button("Begin Export")) { + openFileDialog(GUI_FILE_EXPORT_ZSM); + ImGui::CloseCurrentPopup(); + } + ImGui::EndMenu(); + } + } + int numAmiga=0; + for (int i=0; isong.systemLen; i++) { + if (e->song.system[i]==DIV_SYSTEM_AMIGA) numAmiga++; + } + if (numAmiga && settings.iCannotWait) { + if (ImGui::BeginMenu("export Amiga validation data...")) { + 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::Text("Directory"); + ImGui::SameLine(); + ImGui::InputText("##AVDPath",&workingDirROMExport); + if (ImGui::Button("Bake Data")) { + ImGui::CloseCurrentPopup(); + } + ImGui::EndMenu(); } } if (ImGui::BeginMenu("export command stream...")) {