#include #include #include #include "ta-log.h" #include "engine/engine.h" #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include #else #include #endif #ifdef HAVE_GUI #include "gui/gui.h" #endif DivEngine e; #ifdef HAVE_GUI FurnaceGUI g; #endif String outName; #ifdef HAVE_GUI bool consoleMode=false; #else bool consoleMode=true; #endif std::vector params; bool pHelp(String) { printf("usage: furnace [params] [filename]\n" "you may specify the following parameters:\n"); for (auto& i: params) { if (i.value) { printf(" -%s %s: %s\n",i.name.c_str(),i.valName.c_str(),i.desc.c_str()); } else { printf(" -%s: %s\n",i.name.c_str(),i.desc.c_str()); } } return false; } bool pAudio(String val) { if (val=="jack") { e.setAudio(DIV_AUDIO_JACK); } else if (val=="sdl") { e.setAudio(DIV_AUDIO_SDL); } else { logE("invalid value for audio engine! valid values are: jack, sdl.\n"); return false; } return true; } bool pView(String val) { if (val=="pattern") { e.setView(DIV_STATUS_PATTERN); } else if (val=="commands") { e.setView(DIV_STATUS_COMMANDS); } else if (val=="nothing") { e.setView(DIV_STATUS_NOTHING); } else { logE("invalid value for view type! valid values are: pattern, commands, nothing.\n"); return false; } return true; } bool pConsole(String val) { consoleMode=true; return true; } bool pLogLevel(String val) { if (val=="debug") { logLevel=LOGLEVEL_DEBUG; } else if (val=="info") { logLevel=LOGLEVEL_INFO; } else if (val=="warning") { logLevel=LOGLEVEL_WARN; } else if (val=="error") { logLevel=LOGLEVEL_ERROR; } else { logE("invalid value for loglevel! valid values are: debug, info, warning, error.\n"); return false; } return true; } bool pVersion(String) { printf("Furnace version " DIV_VERSION ".\n\n"); printf("developed by tildearrow. copyright (C) 2021.\n"); printf("licensed under the GNU General Public License version 2\n"); printf(".\n\n"); printf("this is free software with ABSOLUTELY NO WARRANTY.\n"); printf("pass the -warranty parameter for more information.\n\n"); printf("DISCLAIMER: this program is not affiliated with Delek in any form.\n"); printf("\n"); printf("furnace is powered by:\n"); printf("- libsndfile by Erik de Castro Lopo and rest of libsndfile team (LGPLv2.1)\n"); printf("- SDL2 by Sam Lantinga (zlib license)\n"); printf("- zlib by Jean-loup Gailly and Mark Adler (zlib license)\n"); printf("- Dear ImGui by Omar Cornut (MIT)\n"); printf("- Nuked-OPM by Nuke.YKT (LGPLv2.1)\n"); printf("- Nuked-OPN2 by Nuke.YKT (LGPLv2.1)\n"); printf("- ymfm by Aaron Giles (BSD 3-clause)\n"); printf("- MAME SN76496 emulation core by Nicola Salmoria (BSD 3-clause)\n"); printf("- MAME AY-3-8910 emulation core by Couriersud (BSD 3-clause)\n"); printf("- SameBoy by Lior Halphon (MIT)\n"); printf("- Mednafen PCE by Mednafen Team (GPLv2)\n"); printf("- puNES by FHorse (GPLv2)\n"); printf("- reSID by Dag Lem (GPLv2)\n"); printf("- Stella by Stella Team (GPLv2)\n"); return false; } bool pWarranty(String) { printf("This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU General Public License\n" "as published by the Free Software Foundation; either version 2\n" "of the License, or (at your option) any later version.\n\n" "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n\n" "You should have received a copy of the GNU General Public License\n" "along with this program; if not, write to the Free Software\n" "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n"); return false; } bool pLoops(String val) { try { int count=std::stoi(val); if (count<0) { e.setLoops(-1); } else { e.setLoops(count+1); } } catch (std::exception& e) { logE("loop count shall be a number.\n"); return false; } return true; } bool pOutput(String val) { outName=val; return true; } bool needsValue(String param) { for (size_t i=0; i","output audio to file")); params.push_back(TAParam("L","loglevel",true,pLogLevel,"debug|info|warning|error","set the log level (info by default)")); params.push_back(TAParam("v","view",true,pView,"pattern|commands|nothing","set visualization (pattern by default)")); params.push_back(TAParam("c","console",false,pConsole,"","enable console mode")); params.push_back(TAParam("l","loops",true,pLoops,"","set number of loops (-1 means loop forever)")); params.push_back(TAParam("V","version",false,pVersion,"","view information about Furnace.")); params.push_back(TAParam("W","warranty",false,pWarranty,"","view warranty disclaimer.")); } int main(int argc, char** argv) { outName=""; initParams(); // parse arguments String arg, val, fileName; size_t eqSplit, argStart; for (int i=1; i