gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

virusTestConsole.cpp (2039B)


      1 #include <iostream>
      2 
      3 #include "baseLib/filesystem.h"
      4 
      5 #include "virusConsoleLib/consoleApp.h"
      6 
      7 #include "dsp56kEmu/jitunittests.h"
      8 #include "dsp56kEmu/interpreterunittests.h"
      9 
     10 constexpr bool g_createDebugger = false;
     11 constexpr bool g_dumpAssembly = false;
     12 
     13 using namespace dsp56k;
     14 using namespace virusLib;
     15 using namespace synthLib;
     16 
     17 int main(int _argc, char* _argv[])
     18 {
     19 	if constexpr(true)
     20 	{
     21 		try
     22 		{
     23 			puts("Running Unit Tests...");
     24 //			InterpreterUnitTests tests;
     25 			JitUnittests jitTests;
     26 			puts("Unit Tests finished.");
     27 		}
     28 		catch(const std::string& _err)
     29 		{
     30 			std::cout << "Unit test failed: " << _err << std::endl;
     31 			ConsoleApp::waitReturn();
     32 			return -1;
     33 		}
     34 	}
     35 	
     36 	std::unique_ptr<ConsoleApp> app;
     37 	app.reset(new ConsoleApp({}, DeviceModel::TI2));
     38 
     39 	if(!app->isValid())
     40 	{
     41 		std::cout << "ROM file couldn't be loaded. Make sure that the ROM file is valid" << std::endl;
     42 		ConsoleApp::waitReturn();
     43 		return -1;
     44 	}
     45 
     46 	if(_argc > 1)
     47 	{
     48 		const std::string name = _argv[1];
     49 		if(baseLib::filesystem::hasExtension(name, ".mid") || baseLib::filesystem::hasExtension(name, ".bin"))
     50 		{
     51 			if(!app->loadDemo(name))
     52 			{
     53 				std::cout << "Failed to load demo from '" << name << "', make sure that the file contains a demo" << std::endl;
     54 				ConsoleApp::waitReturn();
     55 				return -1;
     56 			}
     57 		}
     58 		else if(name == "demo")
     59 		{
     60 			if(!app->loadInternalDemo())
     61 			{
     62 				std::cout << "Failed to load internal demo, the ROM might not contain any demo song" << std::endl;
     63 				ConsoleApp::waitReturn();
     64 				return -1;
     65 			}
     66 		}
     67 		else if(!app->loadSingle(name))
     68 		{
     69 			std::cout << "Failed to find preset '" << _argv[1] << "', make sure to use a ROM that contains it" << std::endl;
     70 			ConsoleApp::waitReturn();
     71 			return -1;
     72 		}
     73 	}
     74 	else
     75 	{
     76 		if(!app->loadInternalDemo())
     77 			app->loadSingle(0, 0);
     78 	}
     79 
     80 	const std::string audioFilename = app->getSingleNameAsFilename();
     81 
     82 	app->run(audioFilename, 0, 64, g_createDebugger, g_dumpAssembly);
     83 
     84 	std::cout << "Program ended. Press key to exit." << std::endl;
     85 	ConsoleApp::waitReturn();
     86 
     87 	return 0;
     88 }