2020-01-10 03:31:12 +00:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/log.h"
|
2019-10-04 03:54:09 +00:00
|
|
|
#include "core/system.h"
|
2019-11-03 14:39:48 +00:00
|
|
|
#include "sdl_host_interface.h"
|
2019-09-09 07:01:26 +00:00
|
|
|
#include <SDL.h>
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
static int Run(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
// init sdl
|
2019-12-15 13:24:34 +00:00
|
|
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) < 0)
|
2019-09-09 07:01:26 +00:00
|
|
|
{
|
|
|
|
Panic("SDL initialization failed");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-09-14 10:28:47 +00:00
|
|
|
// parameters
|
|
|
|
const char* filename = nullptr;
|
2019-09-22 15:28:00 +00:00
|
|
|
const char* exp1_filename = nullptr;
|
2020-01-10 03:31:12 +00:00
|
|
|
std::string state_filename;
|
2019-09-14 10:28:47 +00:00
|
|
|
for (int i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
#define CHECK_ARG(str) !std::strcmp(argv[i], str)
|
|
|
|
#define CHECK_ARG_PARAM(str) (!std::strcmp(argv[i], str) && ((i + 1) < argc))
|
|
|
|
|
|
|
|
if (CHECK_ARG_PARAM("-state"))
|
2019-11-03 14:39:48 +00:00
|
|
|
state_filename = SDLHostInterface::GetSaveStateFilename(std::strtoul(argv[++i], nullptr, 10));
|
2019-09-22 15:28:00 +00:00
|
|
|
else if (CHECK_ARG_PARAM("-exp1"))
|
|
|
|
exp1_filename = argv[++i];
|
2019-09-14 10:28:47 +00:00
|
|
|
else
|
|
|
|
filename = argv[i];
|
|
|
|
|
|
|
|
#undef CHECK_ARG
|
|
|
|
#undef CHECK_ARG_PARAM
|
|
|
|
}
|
|
|
|
|
2019-10-20 14:38:04 +00:00
|
|
|
// create display and host interface
|
2020-01-10 03:31:12 +00:00
|
|
|
std::unique_ptr<SDLHostInterface> host_interface =
|
|
|
|
SDLHostInterface::Create(filename, exp1_filename, state_filename.empty() ? nullptr : state_filename.c_str());
|
2019-10-20 14:38:04 +00:00
|
|
|
if (!host_interface)
|
2019-09-09 07:01:26 +00:00
|
|
|
{
|
2019-10-20 14:38:04 +00:00
|
|
|
Panic("Failed to create host interface");
|
|
|
|
SDL_Quit();
|
|
|
|
return -1;
|
2019-10-20 10:37:21 +00:00
|
|
|
}
|
2019-09-30 04:22:30 +00:00
|
|
|
|
2019-09-09 07:01:26 +00:00
|
|
|
// run
|
|
|
|
host_interface->Run();
|
|
|
|
|
|
|
|
// done
|
|
|
|
host_interface.reset();
|
|
|
|
SDL_Quit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SDL requires the entry point declared without c++ decoration
|
|
|
|
#undef main
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
// set log flags
|
2020-01-11 03:29:22 +00:00
|
|
|
#ifndef _DEBUG
|
2019-10-05 05:15:00 +00:00
|
|
|
const LOGLEVEL level = LOGLEVEL_INFO;
|
|
|
|
// const LOGLEVEL level = LOGLEVEL_DEV;
|
|
|
|
// const LOGLEVEL level = LOGLEVEL_PROFILE;
|
2020-01-10 03:31:12 +00:00
|
|
|
Log::SetConsoleOutputParams(true, nullptr, level);
|
|
|
|
Log::SetFilterLevel(level);
|
2019-09-09 07:01:26 +00:00
|
|
|
#else
|
2020-01-10 03:31:12 +00:00
|
|
|
Log::SetConsoleOutputParams(true, nullptr, LOGLEVEL_DEBUG);
|
|
|
|
// Log::SetConsoleOutputParams(true, "GPU GPU_HW_OpenGL SPU Pad DigitalController", LOGLEVEL_DEBUG);
|
|
|
|
// Log::SetConsoleOutputParams(true, "GPU GPU_HW_OpenGL Pad DigitalController MemoryCard InterruptController SPU
|
2019-12-15 13:24:34 +00:00
|
|
|
// MDEC", LOGLEVEL_DEBUG); g_pLog->SetFilterLevel(LOGLEVEL_TRACE);
|
2020-01-10 03:31:12 +00:00
|
|
|
Log::SetFilterLevel(LOGLEVEL_DEBUG);
|
|
|
|
// Log::SetFilterLevel(LOGLEVEL_DEV);
|
2019-09-09 07:01:26 +00:00
|
|
|
#endif
|
|
|
|
|
2019-09-14 10:28:47 +00:00
|
|
|
// return NoGUITest();
|
2019-09-12 14:18:13 +00:00
|
|
|
return Run(argc, argv);
|
2019-09-09 07:01:26 +00:00
|
|
|
}
|