Duckstation/src/duckstation-sdl/main.cpp

84 lines
2.2 KiB
C++
Raw Normal View History

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"
#include "sdl_host_interface.h"
#include "frontend-common/sdl_initializer.h"
2019-09-09 07:01:26 +00:00
#include <SDL.h>
#include <cstdio>
static int Run(int argc, char* argv[])
{
2019-09-14 10:28:47 +00:00
// parameters
std::optional<s32> state_index;
const char* boot_filename = nullptr;
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"))
state_index = std::atoi(argv[++i]);
if (CHECK_ARG_PARAM("-resume"))
state_index = -1;
2019-09-14 10:28:47 +00:00
else
boot_filename = argv[i];
2019-09-14 10:28:47 +00:00
#undef CHECK_ARG
#undef CHECK_ARG_PARAM
}
// create display and host interface
std::unique_ptr<SDLHostInterface> host_interface = SDLHostInterface::Create();
if (!host_interface)
2019-09-09 07:01:26 +00:00
{
Panic("Failed to create host interface");
SDL_Quit();
return -1;
}
// boot/load state
if (boot_filename)
{
if (host_interface->BootSystemFromFile(boot_filename) && state_index.has_value())
host_interface->LoadState(false, state_index.value());
}
else if (state_index.has_value())
{
host_interface->LoadState(true, state_index.value());
}
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
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
FrontendCommon::EnsureSDLInitialized();
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
}