libretro: add abiity to load snapshot file.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
05321679f8
commit
2e654a0fcc
3 changed files with 38 additions and 5 deletions
|
@ -293,8 +293,14 @@ void Game::drawVideoBuffer()
|
|||
video_cb(myVideoBuffer.data() + myOffset, myBorderlessWidth, myBorderlessHeight, myPitch);
|
||||
}
|
||||
|
||||
bool Game::loadGame(const char * path)
|
||||
bool Game::loadGame(const std::string & path)
|
||||
{
|
||||
const bool ok = DoDiskInsert(SLOT6, DRIVE_1, path);
|
||||
const bool ok = DoDiskInsert(SLOT6, DRIVE_1, path.c_str());
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool Game::loadSnapshot(const std::string & path)
|
||||
{
|
||||
setSnapshotFilename(path, true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,17 @@
|
|||
#include "frontends/common2/speed.h"
|
||||
#include "frontends/libretro/environment.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
Game();
|
||||
~Game();
|
||||
|
||||
bool loadGame(const char * path);
|
||||
bool loadGame(const std::string & path);
|
||||
bool loadSnapshot(const std::string & path);
|
||||
|
||||
void executeOneFrame();
|
||||
void processInputEvents();
|
||||
|
|
|
@ -17,7 +17,18 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
|
||||
std::unique_ptr<Game> game;
|
||||
|
||||
bool endsWith(const std::string & value, const std::string & ending)
|
||||
{
|
||||
if (ending.size() > value.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void retro_init(void)
|
||||
|
@ -77,7 +88,7 @@ void retro_get_system_info(retro_system_info *info)
|
|||
info->library_name = "AppleWin";
|
||||
info->library_version = version.c_str();
|
||||
info->need_fullpath = true;
|
||||
info->valid_extensions = "bin|do|dsk|nib|po|gz|woz|zip|2mg|2img|iie|apl|hdv";
|
||||
info->valid_extensions = "bin|do|dsk|nib|po|gz|woz|zip|2mg|2img|iie|apl|hdv|yaml";
|
||||
}
|
||||
|
||||
|
||||
|
@ -182,7 +193,19 @@ bool retro_load_game(const retro_game_info *info)
|
|||
try
|
||||
{
|
||||
game.reset(new Game);
|
||||
const bool ok = game->loadGame(info->path);
|
||||
|
||||
const std::string snapshotEnding = ".aws.yaml";
|
||||
const std::string gamePath = info->path;
|
||||
|
||||
bool ok;
|
||||
if (endsWith(gamePath, snapshotEnding))
|
||||
{
|
||||
ok = game->loadSnapshot(gamePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = game->loadGame(gamePath);
|
||||
}
|
||||
|
||||
log_cb(RETRO_LOG_INFO, "Game path: %s:%d\n", info->path, ok);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue