From 8644d25ee08c670a7ba53790710529d7c51b3f46 Mon Sep 17 00:00:00 2001 From: Sergio Martin Date: Tue, 9 Jan 2024 20:59:59 +0100 Subject: [PATCH] Some progress with emulator and player instances --- core/abstract_file.cpp | 17 +++++++++++++++++ core/abstract_file.h | 19 +++++++++++++++++++ player/player.cpp | 22 +++++++++++++++++++--- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/core/abstract_file.cpp b/core/abstract_file.cpp index fc42202..417cf8f 100644 --- a/core/abstract_file.cpp +++ b/core/abstract_file.cpp @@ -77,6 +77,23 @@ const char *Mem_Writer::write( const void* p, long s ) return 0; } +// Dry_Writer for determining size + +Dry_Writer::Dry_Writer() +{ + size_ = 0; +} + +Dry_Writer::~Dry_Writer() +{ +} + +const char *Dry_Writer::write( const void* p, long s ) +{ + size_ += s; + return 0; +} + // Auto_File_Reader const char* Auto_File_Reader::open() diff --git a/core/abstract_file.h b/core/abstract_file.h index 3806db6..663d829 100644 --- a/core/abstract_file.h +++ b/core/abstract_file.h @@ -48,6 +48,25 @@ public: ~Mem_Writer(); }; +// Dry writer to get the state size +class Dry_Writer : public Data_Writer { + long size_; +public: + // Keep all written data in expanding block of memory + Dry_Writer(); + + const char *write( const void*, long ); + + // Pointer to beginning of written data + char* data() { return NULL; } + + // Number of bytes written + long size() const { return size_; } + + ~Dry_Writer(); +}; + + // Auto_File to use in place of Data_Reader&/Data_Writer&, allowing a normal // file path to be used in addition to a Data_Reader/Data_Writer. diff --git a/player/player.cpp b/player/player.cpp index 3c07d13..9a3fe68 100644 --- a/player/player.cpp +++ b/player/player.cpp @@ -1,6 +1,7 @@ #include #include "argparse.hpp" #include "utils.hpp" +#include "core/emuInstance.hpp" int main(int argc, char *argv[]) { @@ -8,11 +9,11 @@ int main(int argc, char *argv[]) argparse::ArgumentParser program("player", "1.0"); program.add_argument("romFile") - .help("path to the rom file to run.") + .help("Path to the rom file to run.") .required(); - program.add_argument("solutionFile") - .help("path to the solution sequence file (.sol) to reproduce.") + program.add_argument("sequenceFile") + .help("Path to the input sequence file (.sol) to reproduce.") .required(); program.add_argument("stateFile") @@ -32,5 +33,20 @@ int main(int argc, char *argv[]) // Try to parse arguments try { program.parse_args(argc, argv); } catch (const std::runtime_error &err) { EXIT_WITH_ERROR("%s\n%s", err.what(), program.help().str().c_str()); } + + // Getting ROM file path + std::string romFilePath = program.get("romFile"); + + // Getting sequence file path + std::string sequenceFile = program.get("sequenceFile"); + + // If initial state file is specified, load it + std::string sequenceFile = program.get("stateFile"); + + // Getting reproduce flag + bool isReproduce = program.get("--reproduce"); + + // Getting reproduce flag + bool disableRender = program.get("--disableRender"); }