commit
b9c199bce3
16 changed files with 104 additions and 61 deletions
|
@ -60,7 +60,6 @@ namespace
|
|||
}
|
||||
else
|
||||
{
|
||||
mySaveOnExit = false;
|
||||
LogFileOutput("Registry: configuration file '%s' not found\n", filename.c_str());
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +68,14 @@ namespace
|
|||
{
|
||||
if (mySaveOnExit)
|
||||
{
|
||||
boost::property_tree::ini_parser::write_ini(myFilename, myINI);
|
||||
try
|
||||
{
|
||||
boost::property_tree::ini_parser::write_ini(myFilename, myINI);
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
LogFileOutput("Registry: cannot save settings to '%s': %s\n", myFilename.c_str(), e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +110,7 @@ namespace common2
|
|||
}
|
||||
}
|
||||
|
||||
void InitializeFileRegistry(const EmulatorOptions & options)
|
||||
std::shared_ptr<Registry> CreateFileRegistry(const EmulatorOptions & options)
|
||||
{
|
||||
const std::string homeDir = getHomeDir();
|
||||
|
||||
|
@ -125,7 +131,7 @@ namespace common2
|
|||
std::shared_ptr<Configuration> config(new Configuration(filename, saveOnExit));
|
||||
config->addExtraOptions(options.registryOptions);
|
||||
|
||||
Registry::instance = config;
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class Registry;
|
||||
|
||||
namespace common2
|
||||
{
|
||||
|
@ -8,6 +11,6 @@ namespace common2
|
|||
struct EmulatorOptions;
|
||||
|
||||
std::string GetConfigFile(const std::string & filename);
|
||||
void InitializeFileRegistry(const EmulatorOptions & options);
|
||||
std::shared_ptr<Registry> CreateFileRegistry(const EmulatorOptions & options);
|
||||
|
||||
}
|
||||
|
|
|
@ -123,9 +123,9 @@ namespace common2
|
|||
HD_Destroy();
|
||||
PrintDestroy();
|
||||
CpuDestroy();
|
||||
DebugDestroy();
|
||||
|
||||
GetCardMgr().GetDisk2CardMgr().Destroy();
|
||||
LogDone();
|
||||
RiffFinishWriteFile();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,11 +54,13 @@ namespace ra2
|
|||
|
||||
unsigned Game::ourInputDevices[MAX_PADS] = {RETRO_DEVICE_NONE};
|
||||
|
||||
Game::Game(const std::shared_ptr<RetroFrame> & frame)
|
||||
: myFrame(frame), mySpeed(true), myButtonStates(RETRO_DEVICE_ID_JOYPAD_R3 + 1)
|
||||
Game::Game()
|
||||
: myLogger(true)
|
||||
, myFrame(new ra2::RetroFrame())
|
||||
, mySpeed(true)
|
||||
, myButtonStates(RETRO_DEVICE_ID_JOYPAD_R3 + 1)
|
||||
{
|
||||
LogInit();
|
||||
InitialiseRetroRegistry();
|
||||
Registry::instance = CreateRetroRegistry();
|
||||
SetFrame(myFrame);
|
||||
myFrame->Initialize();
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "frontends/common2/speed.h"
|
||||
#include "frontends/libretro/environment.h"
|
||||
|
||||
#include "linux/context.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -14,7 +16,7 @@ namespace ra2
|
|||
class Game
|
||||
{
|
||||
public:
|
||||
Game(const std::shared_ptr<RetroFrame> & frame);
|
||||
Game();
|
||||
~Game();
|
||||
|
||||
bool loadGame(const std::string & path);
|
||||
|
@ -33,6 +35,7 @@ namespace ra2
|
|||
static retro_usec_t ourFrameTime;
|
||||
|
||||
private:
|
||||
const Logger myLogger;
|
||||
const std::shared_ptr<RetroFrame> myFrame;
|
||||
|
||||
common2::Speed mySpeed; // fixed speed
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "frontends/libretro/environment.h"
|
||||
#include "frontends/libretro/rdirectsound.h"
|
||||
#include "frontends/libretro/retroregistry.h"
|
||||
#include "frontends/libretro/retroframe.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -180,8 +179,7 @@ bool retro_load_game(const retro_game_info *info)
|
|||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<ra2::RetroFrame> frame(new ra2::RetroFrame());
|
||||
std::unique_ptr<ra2::Game> game(new ra2::Game(frame));
|
||||
std::unique_ptr<ra2::Game> game(new ra2::Game());
|
||||
|
||||
const std::string snapshotEnding = ".aws.yaml";
|
||||
const std::string gamePath = info->path;
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace ra2
|
|||
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, retroVariables.data());
|
||||
}
|
||||
|
||||
void InitialiseRetroRegistry()
|
||||
std::shared_ptr<Registry> CreateRetroRegistry()
|
||||
{
|
||||
const auto registry = std::make_shared<common2::PTreeRegistry>();
|
||||
|
||||
|
@ -158,7 +158,7 @@ namespace ra2
|
|||
}
|
||||
}
|
||||
|
||||
Registry::instance = registry;
|
||||
return registry;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Registry;
|
||||
|
||||
namespace ra2
|
||||
{
|
||||
|
||||
void SetupRetroVariables();
|
||||
void InitialiseRetroRegistry();
|
||||
std::shared_ptr<Registry> CreateRetroRegistry();
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "frontends/common2/utils.h"
|
||||
#include "frontends/ncurses/world.h"
|
||||
#include "frontends/ncurses/nframe.h"
|
||||
#include "frontends/ncurses/evdevpaddle.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -132,7 +133,6 @@ namespace
|
|||
|
||||
void EnterMessageLoop(const common2::EmulatorOptions & options, const std::shared_ptr<na2::NFrame> & frame)
|
||||
{
|
||||
LogFileTimeUntilFirstKeyReadReset();
|
||||
while (ContinueExecution(options, frame))
|
||||
{
|
||||
}
|
||||
|
@ -146,16 +146,14 @@ namespace
|
|||
if (!run)
|
||||
return 1;
|
||||
|
||||
if (options.log)
|
||||
{
|
||||
LogInit();
|
||||
}
|
||||
|
||||
InitializeFileRegistry(options);
|
||||
const Logger logger(options.log);
|
||||
const std::shared_ptr<Registry> registry = CreateFileRegistry(options);
|
||||
g_nMemoryClearType = options.memclear;
|
||||
|
||||
std::shared_ptr<na2::NFrame> frame(new na2::NFrame(options.paddleDeviceName));
|
||||
Initialisation init(frame);
|
||||
const std::shared_ptr<na2::EvDevPaddle> paddle(new na2::EvDevPaddle(options.paddleDeviceName));
|
||||
|
||||
const std::shared_ptr<na2::NFrame> frame(new na2::NFrame(paddle));
|
||||
const Initialisation init(registry, frame, paddle);
|
||||
|
||||
na2::SetCtrlCHandler(options.headless);
|
||||
applyOptions(options);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "frontends/ncurses/colors.h"
|
||||
#include "frontends/ncurses/asciiart.h"
|
||||
#include "frontends/ncurses/evdevpaddle.h"
|
||||
|
||||
#include "Interface.h"
|
||||
#include "Memory.h"
|
||||
#include "Log.h"
|
||||
|
@ -39,8 +38,8 @@ namespace na2
|
|||
std::shared_ptr<GraphicsColors> colors;
|
||||
};
|
||||
|
||||
NFrame::NFrame(const std::string & paddleDevice)
|
||||
: myPaddleDevice(paddleDevice)
|
||||
NFrame::NFrame(const std::shared_ptr<EvDevPaddle> & paddle)
|
||||
: myPaddle(paddle)
|
||||
, myRows(-1)
|
||||
, myColumns(-1)
|
||||
{
|
||||
|
@ -54,8 +53,6 @@ namespace na2
|
|||
myTextFlashCounter = 0;
|
||||
myTextFlashState = 0;
|
||||
myAsciiArt.reset(new ASCIIArt());
|
||||
myPaddle.reset(new EvDevPaddle(myPaddleDevice));
|
||||
Paddle::instance = myPaddle;
|
||||
}
|
||||
|
||||
void NFrame::Destroy()
|
||||
|
@ -67,9 +64,6 @@ namespace na2
|
|||
myStatus.reset();
|
||||
myAsciiArt.reset();
|
||||
|
||||
myPaddle.reset();
|
||||
Paddle::instance.reset();
|
||||
|
||||
myNCurses.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace na2
|
|||
class NFrame : public common2::CommonFrame
|
||||
{
|
||||
public:
|
||||
NFrame(const std::string & paddleDevice);
|
||||
NFrame(const std::shared_ptr<EvDevPaddle> & paddle);
|
||||
|
||||
WINDOW * GetWindow();
|
||||
WINDOW * GetStatus();
|
||||
|
@ -35,7 +35,8 @@ namespace na2
|
|||
|
||||
private:
|
||||
|
||||
const std::string myPaddleDevice;
|
||||
const std::shared_ptr<EvDevPaddle> myPaddle;
|
||||
|
||||
int myRows;
|
||||
int myColumns;
|
||||
int myTextFlashCounter;
|
||||
|
@ -44,7 +45,6 @@ namespace na2
|
|||
std::shared_ptr<WINDOW> myFrame;
|
||||
std::shared_ptr<WINDOW> myStatus;
|
||||
std::shared_ptr<ASCIIArt> myAsciiArt;
|
||||
std::shared_ptr<EvDevPaddle> myPaddle;
|
||||
std::shared_ptr<NCurses> myNCurses;
|
||||
|
||||
LPBYTE myTextBank1; // Aux
|
||||
|
|
|
@ -90,18 +90,11 @@ void run_sdl(int argc, const char * argv [])
|
|||
if (!run)
|
||||
return;
|
||||
|
||||
InitializeFileRegistry(options);
|
||||
|
||||
if (options.log)
|
||||
{
|
||||
LogInit();
|
||||
}
|
||||
|
||||
const Logger logger(options.log);
|
||||
const std::shared_ptr<Registry> registry = CreateFileRegistry(options);
|
||||
g_nMemoryClearType = options.memclear;
|
||||
Paddle::instance.reset(new sa2::Gamepad(0));
|
||||
|
||||
std::shared_ptr<sa2::SDLFrame> frame;
|
||||
|
||||
if (options.imgui)
|
||||
{
|
||||
frame.reset(new sa2::SDLImGuiFrame(options));
|
||||
|
@ -111,13 +104,14 @@ void run_sdl(int argc, const char * argv [])
|
|||
frame.reset(new sa2::SDLRendererFrame(options));
|
||||
}
|
||||
|
||||
std::shared_ptr<Paddle> paddle(new sa2::Gamepad(0));
|
||||
const Initialisation init(registry, frame, paddle);
|
||||
|
||||
if (SDL_GL_SetSwapInterval(options.glSwapInterval))
|
||||
{
|
||||
throw std::runtime_error(SDL_GetError());
|
||||
}
|
||||
|
||||
Initialisation init(frame);
|
||||
|
||||
applyOptions(options);
|
||||
|
||||
const int fps = getRefreshRate();
|
||||
|
@ -230,8 +224,6 @@ int main(int argc, const char * argv [])
|
|||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
|
||||
// this must happen BEFORE the SDL_Quit() as otherwise we have a double free (of the game controller).
|
||||
Paddle::instance.reset();
|
||||
SDL_Quit();
|
||||
|
||||
return exit;
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#include "linux/context.h"
|
||||
#include "linux/linuxframe.h"
|
||||
#include "linux/registry.h"
|
||||
#include "linux/paddle.h"
|
||||
#include "linux/duplicates/PropertySheet.h"
|
||||
|
||||
#include "Interface.h"
|
||||
#include "linux/duplicates/PropertySheet.h"
|
||||
#include "linux/linuxframe.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -33,9 +36,16 @@ Video& GetVideo()
|
|||
return sg_Video;
|
||||
}
|
||||
|
||||
Initialisation::Initialisation(const std::shared_ptr<FrameBase> & frame)
|
||||
Initialisation::Initialisation(
|
||||
const std::shared_ptr<Registry> & registry,
|
||||
const std::shared_ptr<FrameBase> & frame,
|
||||
const std::shared_ptr<Paddle> & paddle
|
||||
)
|
||||
{
|
||||
Registry::instance = registry;
|
||||
SetFrame(frame);
|
||||
Paddle::instance = paddle;
|
||||
|
||||
frame->Initialize();
|
||||
}
|
||||
|
||||
|
@ -43,4 +53,20 @@ Initialisation::~Initialisation()
|
|||
{
|
||||
GetFrame().Destroy();
|
||||
SetFrame(std::shared_ptr<FrameBase>());
|
||||
|
||||
Paddle::instance.reset();
|
||||
Registry::instance.reset();
|
||||
}
|
||||
|
||||
Logger::Logger(const bool log)
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
LogInit();
|
||||
}
|
||||
}
|
||||
|
||||
Logger::~Logger()
|
||||
{
|
||||
LogDone();
|
||||
}
|
||||
|
|
|
@ -3,12 +3,27 @@
|
|||
#include <memory>
|
||||
|
||||
class FrameBase;
|
||||
class Paddle;
|
||||
class Registry;
|
||||
|
||||
void SetFrame(const std::shared_ptr<FrameBase> & frame);
|
||||
|
||||
// RAII around Frame Registry and Paddle
|
||||
class Initialisation
|
||||
{
|
||||
public:
|
||||
Initialisation(const std::shared_ptr<FrameBase> & frame);
|
||||
Initialisation(
|
||||
const std::shared_ptr<Registry> & registry,
|
||||
const std::shared_ptr<FrameBase> & frame,
|
||||
const std::shared_ptr<Paddle> & paddle
|
||||
);
|
||||
~Initialisation();
|
||||
};
|
||||
|
||||
// RAII around LogInit / LogDone.
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
Logger(const bool log);
|
||||
~Logger();
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "linux/linuxframe.h"
|
||||
#include "Interface.h"
|
||||
#include "Log.h"
|
||||
#include "Core.h"
|
||||
|
||||
void LinuxFrame::FrameDrawDiskLEDS()
|
||||
{
|
||||
|
@ -54,6 +55,7 @@ void LinuxFrame::Initialize()
|
|||
const size_t numberOfBytes = sizeof(bgra_t) * numberOfPixels;
|
||||
myFramebuffer.resize(numberOfBytes);
|
||||
video.Initialize(myFramebuffer.data());
|
||||
LogFileTimeUntilFirstKeyReadReset();
|
||||
}
|
||||
|
||||
void LinuxFrame::Destroy()
|
||||
|
|
|
@ -22,10 +22,10 @@ DWORD timeGetTime()
|
|||
/// Returns the number of ticks since an undefined time (usually system startup).
|
||||
DWORD GetTickCount()
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
const uint64_t ticks = (uint64_t)(ts.tv_nsec / 1000000) + ((uint64_t)ts.tv_sec * 1000ull);
|
||||
return ticks;
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
const uint64_t ticks = (uint64_t)(ts.tv_nsec / 1000000) + ((uint64_t)ts.tv_sec * 1000ull);
|
||||
return ticks;
|
||||
}
|
||||
|
||||
void GetLocalTime(SYSTEMTIME *t)
|
||||
|
@ -48,18 +48,18 @@ void GetLocalTime(SYSTEMTIME *t)
|
|||
t->wYear = local->tm_year;
|
||||
}
|
||||
|
||||
int GetDateFormat(LCID Locale, DWORD dwFlags, CONST SYSTEMTIME *lpDate, LPCSTR lpFormat, LPSTR lpDateStr, int cchDate)
|
||||
int GetDateFormat(LCID /* Locale */, DWORD /* dwFlags */, CONST SYSTEMTIME * /* lpDate */, LPCSTR /* lpFormat */, LPSTR lpDateStr, int cchDate)
|
||||
{
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm tm = *std::localtime(&t);
|
||||
std::ostringstream ss;
|
||||
ss << std::put_time(&tm, "%D");
|
||||
ss << std::put_time(&tm, "%F");
|
||||
const std::string str = ss.str();
|
||||
strncpy(lpDateStr, str.c_str(), cchDate);
|
||||
return cchDate; // not 100% sure, but it is never used
|
||||
}
|
||||
|
||||
int GetTimeFormat(LCID Locale, DWORD dwFlags, CONST SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpTimeStr, int cchTime)
|
||||
int GetTimeFormat(LCID /* Locale */, DWORD /* dwFlags */, CONST SYSTEMTIME * /* lpTime */, LPCSTR /* lpFormat */, LPSTR lpTimeStr, int cchTime)
|
||||
{
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm tm = *std::localtime(&t);
|
||||
|
|
Loading…
Add table
Reference in a new issue