diff --git a/configure b/configure index be222696a..c6c7c2859 100755 --- a/configure +++ b/configure @@ -21,6 +21,7 @@ _build_joystick=yes _build_cheats=yes _build_png=yes _build_zip=yes +_build_sqlite=no _build_static=no _build_profile=no _build_debug=no @@ -201,6 +202,8 @@ Optional Features: --disable-png --enable-zip enable/disable ZIP file support [enabled] --disable-zip + --enable-sqlite enable SQLite for storing settings and preferences [disabled] + --disable-sqlite --enable-windowed enable/disable windowed rendering modes [enabled] --disable-windowed --enable-shared build shared binary [enabled] @@ -215,6 +218,7 @@ Optional Libraries: --with-sdl-prefix=DIR Prefix where the sdl2-config script is installed (optional) --with-libpng-prefix=DIR Prefix where libpng is installed (optional) --with-zlib-prefix=DIR Prefix where zlib is installed (optional) + --with-sqlite-prefix=DIR PREFIX where sqlite is installed (optional) Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a @@ -243,6 +247,8 @@ for ac_option in $@; do --disable-png) _build_png=no ;; --enable-zip) _build_zip=yes ;; --disable-zip) _build_zip=no ;; + --enable-sqlite) _build_sqlite=yes ;; + --disable-sqlite) _build_sqlite=no ;; --enable-windowed) _build_windowed=yes ;; --disable-windowed) _build_windowed=no ;; --enable-shared) _build_static=no ;; @@ -265,6 +271,11 @@ for ac_option in $@; do _prefix=`echo $ac_option | cut -d '=' -f 2` ZLIB_CFLAGS="-I$_prefix/include" ZLIB_LIBS="-L$_prefix/lib" + ;; + --with-sqlite-prefix=*) + _prefix=`echo $ac_option | cut -d '=' -f 2` + SQLITE_CFLAGS="-I$_prefix/include" + SQLITE_LIBS="-L$_prefix/lib" ;; --host=*) _host=`echo $ac_option | cut -d '=' -f 2` @@ -640,6 +651,30 @@ else _build_png=no fi +# +# Check for SQLite +# +echocheck "SQLite" +if test "$_build_sqlite" = yes ; then + _sqlite=no + cat > $TMPC << EOF +#include +#include +int main(void) { printf("%s\n", SQLITE_VERSION); } +EOF + cc_check $LDFLAGS $CXXFLAGS $SQLITE_CFLAGS $SQLITE_LIBS -lsqlite3 && _sqlite=yes + + if test "$_sqlite" = yes ; then + echo "$_sqlite" + else + echo "disabled" + _build_sqlite=no + fi +else + echo "disabled" + _build_sqlite=no +fi + # # figure out installation directories # @@ -699,6 +734,14 @@ else echo fi +if test "$_build_sqlite" = yes ; then + echo_n " SQLite enabled" + echo +else + echo_n " SQLite disabled" + echo +fi + if test "$_build_windowed" = "yes" ; then echo_n " Windowed rendering modes enabled" echo @@ -752,6 +795,7 @@ YACC="$SRC/yacc" CHEAT="$SRC/cheat" LIBPNG="$SRC/libpng" ZLIB="$SRC/zlib" +SQLITE="$SRC/common/repository/sqlite" INCLUDES="-I$CORE -I$COMMON -I$TV -I$GUI -I$TIA -I$TIA_FRAME_MANAGER" @@ -828,6 +872,13 @@ if test "$_build_png" = yes ; then fi fi +if test "$_build_sqlite" = yes; then + DEFINES="$DEFINES -DSQLITE_SUPPORT" + MODULES="$MODULES $SQLITE" + INCLUDES="$INCLUDES -I$SQLITE" + LIBS="$LIBS -lsqlite3" +fi + if test "$_build_zip" = yes ; then DEFINES="$DEFINES -DZIP_SUPPORT" if test "$_zlib" = yes ; then diff --git a/src/common/FSNodeZIP.cxx b/src/common/FSNodeZIP.cxx index 46215eac7..f88714841 100644 --- a/src/common/FSNodeZIP.cxx +++ b/src/common/FSNodeZIP.cxx @@ -184,7 +184,7 @@ bool FilesystemNodeZIP::getChildren(AbstractFSList& myList, ListMode mode, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 FilesystemNodeZIP::read(BytePtr& image) const +uInt32 FilesystemNodeZIP::read(ByteBuffer& image) const { switch(_error) { diff --git a/src/common/FSNodeZIP.hxx b/src/common/FSNodeZIP.hxx index 2057c94ff..c76cca1c1 100644 --- a/src/common/FSNodeZIP.hxx +++ b/src/common/FSNodeZIP.hxx @@ -65,7 +65,7 @@ class FilesystemNodeZIP : public AbstractFSNode bool getChildren(AbstractFSList& list, ListMode mode, bool hidden) const override; AbstractFSNodePtr getParent() const override; - uInt32 read(BytePtr& image) const override; + uInt32 read(ByteBuffer& image) const override; private: FilesystemNodeZIP(const string& zipfile, const string& virtualpath, diff --git a/src/common/MediaFactory.hxx b/src/common/MediaFactory.hxx index 4d205b59b..88ef4ed80 100644 --- a/src/common/MediaFactory.hxx +++ b/src/common/MediaFactory.hxx @@ -32,22 +32,18 @@ #include "SettingsR77.hxx" #include "OSystemR77.hxx" #else - #include "SettingsUNIX.hxx" #include "OSystemUNIX.hxx" #endif #elif defined(BSPF_WINDOWS) #include "SerialPortWINDOWS.hxx" - #include "SettingsWINDOWS.hxx" #include "OSystemWINDOWS.hxx" #elif defined(BSPF_MACOS) #include "SerialPortMACOS.hxx" - #include "SettingsMACOS.hxx" #include "OSystemMACOS.hxx" extern "C" { int stellaMain(int argc, char* argv[]); } #elif defined(__LIB_RETRO__) - #include "SettingsLIBRETRO.hxx" #include "OSystemLIBRETRO.hxx" #else #error Unsupported platform! @@ -112,20 +108,10 @@ class MediaFactory static unique_ptr createSettings() { - #if defined(BSPF_UNIX) - #if defined(RETRON77) - return make_unique(); - #else - return make_unique(); - #endif - #elif defined(BSPF_WINDOWS) - return make_unique(); - #elif defined(BSPF_MACOS) - return make_unique(); - #elif defined(__LIB_RETRO__) - return make_unique(); + #ifdef RETRON77 + return make_unique(); #else - #error Unsupported platform for Settings! + return make_unique(); #endif } diff --git a/src/common/PNGLibrary.hxx b/src/common/PNGLibrary.hxx index 2c319ba1f..ee61d302a 100644 --- a/src/common/PNGLibrary.hxx +++ b/src/common/PNGLibrary.hxx @@ -137,7 +137,7 @@ class PNGLibrary // The following data remains between invocations of allocateStorage, // and is only changed when absolutely necessary. struct ReadInfoType { - BytePtr buffer; + ByteBuffer buffer; unique_ptr row_pointers; png_uint_32 width, height, pitch; uInt32 buffer_size, row_size; diff --git a/src/common/ZipHandler.cxx b/src/common/ZipHandler.cxx index b7c303055..91ccbcda6 100644 --- a/src/common/ZipHandler.cxx +++ b/src/common/ZipHandler.cxx @@ -105,7 +105,7 @@ const string& ZipHandler::next() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt64 ZipHandler::decompress(BytePtr& image) +uInt64 ZipHandler::decompress(ByteBuffer& image) { if(myZip && myZip->myHeader.uncompressedLength > 0) { @@ -269,7 +269,7 @@ void ZipHandler::ZipFile::close() void ZipHandler::ZipFile::readEcd() { uInt64 buflen = 1024; - BytePtr buffer; + ByteBuffer buffer; // We may need multiple tries while(buflen < 65536) @@ -323,7 +323,7 @@ void ZipHandler::ZipFile::readEcd() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool ZipHandler::ZipFile::readStream(BytePtr& out, uInt64 offset, +bool ZipHandler::ZipFile::readStream(ByteBuffer& out, uInt64 offset, uInt64 length, uInt64& actual) { try @@ -367,7 +367,7 @@ const ZipHandler::ZipHeader* const ZipHandler::ZipFile::nextFile() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ZipHandler::ZipFile::decompress(BytePtr& out, uInt64 length) +void ZipHandler::ZipFile::decompress(ByteBuffer& out, uInt64 length) { // If we don't have enough buffer, error if(length < myHeader.uncompressedLength) @@ -434,7 +434,7 @@ uInt64 ZipHandler::ZipFile::getCompressedDataOffset() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ZipHandler::ZipFile::decompressDataType0( - uInt64 offset, BytePtr& out, uInt64 length) + uInt64 offset, ByteBuffer& out, uInt64 length) { // The data is uncompressed; just read it uInt64 read_length = 0; @@ -447,7 +447,7 @@ void ZipHandler::ZipFile::decompressDataType0( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ZipHandler::ZipFile::decompressDataType8( - uInt64 offset, BytePtr& out, uInt64 length) + uInt64 offset, ByteBuffer& out, uInt64 length) { uInt64 input_remaining = myHeader.compressedLength; diff --git a/src/common/ZipHandler.hxx b/src/common/ZipHandler.hxx index 137682076..5f3081908 100644 --- a/src/common/ZipHandler.hxx +++ b/src/common/ZipHandler.hxx @@ -47,7 +47,7 @@ class ZipHandler // Decompress the currently selected file and return its length // An exception will be thrown on any errors - uInt64 decompress(BytePtr& image); + uInt64 decompress(ByteBuffer& image); // Answer the number of ROM files (with a valid extension) found uInt16 romFiles() const { return myZip ? myZip->myRomfiles : 0; } @@ -112,11 +112,11 @@ class ZipHandler ZipEcd myEcd; // end of central directory - BytePtr myCd; // central directory raw data + ByteBuffer myCd; // central directory raw data uInt64 myCdPos; // position in central directory ZipHeader myHeader; // current file header - BytePtr myBuffer; // buffer for decompression + ByteBuffer myBuffer; // buffer for decompression /** Constructor */ explicit ZipFile(const string& filename); @@ -134,22 +134,22 @@ class ZipHandler void readEcd(); /** Read data from stream */ - bool readStream(BytePtr& out, uInt64 offset, uInt64 length, uInt64& actual); + bool readStream(ByteBuffer& out, uInt64 offset, uInt64 length, uInt64& actual); /** Return the next entry in the ZIP file */ const ZipHeader* const nextFile(); /** Decompress the most recently found file in the ZIP into target buffer */ - void decompress(BytePtr& out, uInt64 length); + void decompress(ByteBuffer& out, uInt64 length); /** Return the offset of the compressed data */ uInt64 getCompressedDataOffset(); /** Decompress type 0 data (which is uncompressed) */ - void decompressDataType0(uInt64 offset, BytePtr& out, uInt64 length); + void decompressDataType0(uInt64 offset, ByteBuffer& out, uInt64 length); /** Decompress type 8 data (which is deflated) */ - void decompressDataType8(uInt64 offset, BytePtr& out, uInt64 length); + void decompressDataType8(uInt64 offset, ByteBuffer& out, uInt64 length); }; using ZipFilePtr = unique_ptr; diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index ef5e57f17..f123fa9e6 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -83,7 +83,7 @@ using BoolArray = std::vector; using ByteArray = std::vector; using ShortArray = std::vector; using StringList = std::vector; -using BytePtr = std::unique_ptr; +using ByteBuffer = std::unique_ptr; static const string EmptyString(""); diff --git a/src/common/module.mk b/src/common/module.mk index 530dda57a..6d48a20f5 100644 --- a/src/common/module.mk +++ b/src/common/module.mk @@ -21,7 +21,8 @@ MODULE_OBJS := \ src/common/AudioSettings.o \ src/common/FpsMeter.o \ src/common/ThreadDebugging.o \ - src/common/StaggeredLogger.o + src/common/StaggeredLogger.o \ + src/common/repository/KeyValueRepositoryConfigfile.o MODULE_DIRS += \ src/common diff --git a/src/windows/SettingsWINDOWS.cxx b/src/common/repository/KeyValueRepository.hxx similarity index 65% rename from src/windows/SettingsWINDOWS.cxx rename to src/common/repository/KeyValueRepository.hxx index ec7ac237b..c8c8540e5 100644 --- a/src/windows/SettingsWINDOWS.cxx +++ b/src/common/repository/KeyValueRepository.hxx @@ -15,10 +15,23 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "SettingsWINDOWS.hxx" +#ifndef KEY_VALUE_REPOSITORY_HXX +#define KEY_VALUE_REPOSITORY_HXX -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SettingsWINDOWS::SettingsWINDOWS() - : Settings() +#include + +#include "Variant.hxx" +#include "bspf.hxx" + +class KeyValueRepository { -} + public: + + virtual ~KeyValueRepository() = default; + + virtual std::map load() = 0; + + virtual void save(const std::map& values) = 0; +}; + +#endif // KEY_VALUE_REPOSITORY_HXX diff --git a/src/common/repository/KeyValueRepositoryConfigfile.cxx b/src/common/repository/KeyValueRepositoryConfigfile.cxx new file mode 100644 index 000000000..c265b2a76 --- /dev/null +++ b/src/common/repository/KeyValueRepositoryConfigfile.cxx @@ -0,0 +1,107 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include "KeyValueRepositoryConfigfile.hxx" + +namespace { + string trim(const string& str) + { + string::size_type first = str.find_first_not_of(' '); + return (first == string::npos) ? EmptyString : + str.substr(first, str.find_last_not_of(' ')-first+1); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +KeyValueRepositoryConfigfile::KeyValueRepositoryConfigfile(const string& filename) + : myFilename(filename) +{} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +std::map KeyValueRepositoryConfigfile::load() +{ + std::map values; + + string line, key, value; + string::size_type equalPos, garbage; + + ifstream in(myFilename); + if(!in || !in.is_open()) { + // FIXME - make logger available everywhere + cout << "ERROR: Couldn't load from settings file " << myFilename << endl; + + return values; + } + + while(getline(in, line)) + { + // Strip all whitespace and tabs from the line + while((garbage = line.find("\t")) != string::npos) + line.erase(garbage, 1); + + // Ignore commented and empty lines + if((line.length() == 0) || (line[0] == ';')) + continue; + + // Search for the equal sign and discard the line if its not found + if((equalPos = line.find("=")) == string::npos) + continue; + + // Split the line into key/value pairs and trim any whitespace + key = trim(line.substr(0, equalPos)); + value = trim(line.substr(equalPos + 1, line.length() - key.length() - 1)); + + // Skip absent key + if(key.length() == 0) + continue; + + values[key] = value; + } + + return values; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void KeyValueRepositoryConfigfile::save(const std::map& values) +{ +ofstream out(myFilename); + if(!out || !out.is_open()) { + // FIXME - make logger available everywhere + cout << "ERROR: Couldn't save to settings file " << myFilename << endl; + + return; + } + + out << "; Stella configuration file" << endl + << ";" << endl + << "; Lines starting with ';' are comments and are ignored." << endl + << "; Spaces and tabs are ignored." << endl + << ";" << endl + << "; Format MUST be as follows:" << endl + << "; command = value" << endl + << ";" << endl + << "; Commands are the same as those specified on the commandline," << endl + << "; without the '-' character." << endl + << ";" << endl + << "; Values are the same as those allowed on the commandline." << endl + << "; Boolean values are specified as 1 (or true) and 0 (or false)" << endl + << ";" << endl; + + // Write out each of the key and value pairs + for(const auto& pair: values) + out << pair.first << " = " << pair.second << endl; +} diff --git a/src/macos/Preferences.h b/src/common/repository/KeyValueRepositoryConfigfile.hxx similarity index 58% rename from src/macos/Preferences.h rename to src/common/repository/KeyValueRepositoryConfigfile.hxx index 144bc0880..e6b07b299 100644 --- a/src/macos/Preferences.h +++ b/src/common/repository/KeyValueRepositoryConfigfile.hxx @@ -15,23 +15,24 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#import +#ifndef KEY_VALUE_REPOSITORY_CONFIGFILE_HXX +#define KEY_VALUE_REPOSITORY_CONFIGFILE_HXX -void prefsSetString(const char* key, const char* value); -void prefsGetString(const char* key, char* value, int size); -void prefsSave(void); +#include "KeyValueRepository.hxx" -/** - Preferences class and support functions for the macOS - SDL2 port of Stella. +class KeyValueRepositoryConfigfile : public KeyValueRepository +{ + public: - @author Mark Grebe -*/ -@interface Preferences : NSObject + KeyValueRepositoryConfigfile(const string& filename); -+ (Preferences *)sharedInstance; -- (void)setString:(const char *)key : (const char *)value; -- (void)getString:(const char *)key : (char *)value : (int)size; -- (void)save; + virtual std::map load(); -@end + virtual void save(const std::map& values); + + private: + + const string& myFilename; +}; + +#endif // KEY_VALUE_REPOSITORY_CONFIGFILE_HXX diff --git a/src/unix/SettingsUNIX.cxx b/src/common/repository/KeyValueRepositoryNoop.hxx similarity index 64% rename from src/unix/SettingsUNIX.cxx rename to src/common/repository/KeyValueRepositoryNoop.hxx index 91e589e68..b4d2dc137 100644 --- a/src/unix/SettingsUNIX.cxx +++ b/src/common/repository/KeyValueRepositoryNoop.hxx @@ -15,10 +15,20 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "SettingsUNIX.hxx" +#ifndef KEY_VALUE_REPOSITORY_NOOP_HXX +#define KEY_VALUE_REPOSITORY_NOOP_HXX -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SettingsUNIX::SettingsUNIX() - : Settings() +#include "KeyValueRepository.hxx" + +class KeyValueRepositoryNoop : public KeyValueRepository { -} + public: + + virtual std::map load() { + return std::map(); + } + + virtual void save(const std::map& values) {} +}; + +#endif // KEY_VALUE_REPOSITORY_NOOP_HXX diff --git a/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx new file mode 100644 index 000000000..fba0e7f0f --- /dev/null +++ b/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx @@ -0,0 +1,168 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include +#include + +#include "KeyValueRepositorySqlite.hxx" +#include "bspf.hxx" + +#ifdef BSPF_WINDOWS + #define SEPARATOR "\" +#else + #define SEPARATOR "/" +#endif + +namespace { + struct SqliteError { + SqliteError(const string _message) : message(_message) {} + + const string message; + }; + + class Statement { + public: + + Statement(sqlite3* handle, string sql) : myStmt(nullptr) + { + if (sqlite3_prepare_v2(handle, sql.c_str(), -1, &myStmt, nullptr) != SQLITE_OK) + throw SqliteError(sqlite3_errmsg(handle)); + } + + ~Statement() + { + if (myStmt) sqlite3_finalize(myStmt); + } + + operator sqlite3_stmt*() const { return myStmt; } + + private: + + sqlite3_stmt* myStmt; + + private: + + Statement() = delete; + Statement(const Statement&) = delete; + Statement(Statement&&) = delete; + Statement& operator=(const Statement&) = delete; + Statement& operator=(Statement&&) = delete; + }; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +KeyValueRepositorySqlite::KeyValueRepositorySqlite( + const string& databaseDirectory, + const string& databaseName +) : myDatabaseFile(databaseDirectory + SEPARATOR + databaseName + ".sqlite3"), + myIsFailed(false), + myDbHandle(nullptr) +{} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +KeyValueRepositorySqlite::~KeyValueRepositorySqlite() +{ + if (myDbHandle) sqlite3_close(myDbHandle); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +std::map KeyValueRepositorySqlite::load() +{ + std::map values; + if (myIsFailed) return values; + + try { + initializeDb(); + Statement stmt(myDbHandle, "SELECT `key`, `VALUE` FROM `values`"); + + while (sqlite3_step(stmt) == SQLITE_ROW) + values[reinterpret_cast(sqlite3_column_text(stmt, 0))] = + reinterpret_cast(sqlite3_column_text(stmt, 1)); + } + catch (SqliteError err) { + cout << "failed to load from sqlite DB " << myDatabaseFile << ": " << err.message << endl; + } + + return values; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void KeyValueRepositorySqlite::save(const std::map& values) +{ + if (myIsFailed) return; + + try { + initializeDb(); + Statement stmt(myDbHandle, "INSERT OR REPLACE INTO `values` VALUES (?, ?)"); + + if (sqlite3_exec(myDbHandle, "BEGIN TRANSACTION", nullptr, nullptr, nullptr) != SQLITE_OK) + throw SqliteError(sqlite3_errmsg(myDbHandle)); + + for (const auto& pair: values) { + sqlite3_bind_text(stmt, 1, pair.first.c_str(), -1, SQLITE_STATIC); + sqlite3_bind_text(stmt, 2, pair.second.toCString(), -1, SQLITE_STATIC); + sqlite3_step(stmt); + + if (sqlite3_reset(stmt) != SQLITE_OK) throw SqliteError(sqlite3_errmsg(myDbHandle)); + } + + if (sqlite3_exec(myDbHandle, "COMMIT", nullptr, nullptr, nullptr) != SQLITE_OK) + throw SqliteError(sqlite3_errmsg(myDbHandle)); + } + catch (SqliteError err) { + cout << "failed to write to sqlite DB " << myDatabaseFile << ": " << err.message << endl; + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void KeyValueRepositorySqlite::initializeDb() +{ + if (myIsFailed || myDbHandle) return; + + bool dbInitialized = false; + + for (int tries = 1; tries < 3 && !dbInitialized; tries++) { + dbInitialized = (sqlite3_open(myDatabaseFile.c_str(), &myDbHandle) == SQLITE_OK); + + dbInitialized = dbInitialized && (sqlite3_exec( + myDbHandle, + "CREATE TABLE IF NOT EXISTS `values` (`key` TEXT PRIMARY KEY, `value` TEXT) WITHOUT ROWID", + nullptr, nullptr, nullptr + ) == SQLITE_OK); + + if (!dbInitialized && tries == 1) { + cout << "sqlite DB " << myDatabaseFile << " seems to be corrupt, removing and retrying..." << endl; + + remove(myDatabaseFile.c_str()); + } + } + + myIsFailed = !dbInitialized; + + if (myIsFailed) { + if (myDbHandle) { + string emsg = sqlite3_errmsg(myDbHandle); + + sqlite3_close(myDbHandle); + myDbHandle = nullptr; + + throw SqliteError(emsg); + } + + throw SqliteError("unable to initialize sqlite DB " + myDatabaseFile); + }; +} diff --git a/src/windows/SettingsWINDOWS.hxx b/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx similarity index 54% rename from src/windows/SettingsWINDOWS.hxx rename to src/common/repository/sqlite/KeyValueRepositorySqlite.hxx index fd998c491..2ab4e2a19 100644 --- a/src/windows/SettingsWINDOWS.hxx +++ b/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx @@ -15,28 +15,37 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#ifndef SETTINGS_WINDOWS_HXX -#define SETTINGS_WINDOWS_HXX +#ifndef KEY_VALUE_REPOSITORY_SQLITE_HXX +#define KEY_VALUE_REPOSITORY_SQLITE_HXX -class OSystem; +#include -#include "Settings.hxx" +#include "repository/KeyValueRepository.hxx" -class SettingsWINDOWS : public Settings +class KeyValueRepositorySqlite : public KeyValueRepository { public: - /** - Create a new UNIX settings object - */ - explicit SettingsWINDOWS(); - virtual ~SettingsWINDOWS() = default; + + KeyValueRepositorySqlite(const string& databaseDirectory, const string& databaseName); + + ~KeyValueRepositorySqlite(); + + virtual std::map load(); + + virtual void save(const std::map& values); private: - // Following constructors and assignment operators not supported - SettingsWINDOWS(const SettingsWINDOWS&) = delete; - SettingsWINDOWS(SettingsWINDOWS&&) = delete; - SettingsWINDOWS& operator=(const SettingsWINDOWS&) = delete; - SettingsWINDOWS& operator=(SettingsWINDOWS&&) = delete; + + void initializeDb(); + + private: + + string myDatabaseFile; + + bool myIsFailed; + + sqlite3* myDbHandle; + }; -#endif +#endif // KEY_VALUE_REPOSITORY_SQLITE_HXX diff --git a/src/common/repository/sqlite/module.mk b/src/common/repository/sqlite/module.mk new file mode 100644 index 000000000..d23fcb37c --- /dev/null +++ b/src/common/repository/sqlite/module.mk @@ -0,0 +1,10 @@ +MODULE := src/common/repository/sqlite + +MODULE_OBJS := \ + src/common/repository/sqlite/KeyValueRepositorySqlite.o + +MODULE_DIRS += \ + src/common/repository/sqlite + +# Include common rules +include $(srcdir)/common.rules diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 41773bae3..d40ef8ab2 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -302,7 +302,7 @@ class Cartridge : public Device // The array containing information about every byte of ROM indicating // whether it is used as code. - BytePtr myCodeAccessBase; + ByteBuffer myCodeAccessBase; private: // The startup bank to use (where to look for the reset vector address) diff --git a/src/emucore/Cart0840.cxx b/src/emucore/Cart0840.cxx index fd4743e46..af6c0d703 100644 --- a/src/emucore/Cart0840.cxx +++ b/src/emucore/Cart0840.cxx @@ -19,7 +19,7 @@ #include "Cart0840.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cartridge0840::Cartridge0840(const BytePtr& image, uInt32 size, +Cartridge0840::Cartridge0840(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/Cart0840.hxx b/src/emucore/Cart0840.hxx index 2fb591c64..eef306fba 100644 --- a/src/emucore/Cart0840.hxx +++ b/src/emucore/Cart0840.hxx @@ -45,7 +45,7 @@ class Cartridge0840 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - Cartridge0840(const BytePtr& image, uInt32 size, const string& md5, + Cartridge0840(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~Cartridge0840() = default; diff --git a/src/emucore/Cart2K.cxx b/src/emucore/Cart2K.cxx index c316548b5..8b1b7b3f4 100644 --- a/src/emucore/Cart2K.cxx +++ b/src/emucore/Cart2K.cxx @@ -19,7 +19,7 @@ #include "Cart2K.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cartridge2K::Cartridge2K(const BytePtr& image, uInt32 size, +Cartridge2K::Cartridge2K(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5) { diff --git a/src/emucore/Cart2K.hxx b/src/emucore/Cart2K.hxx index ddca38048..e603d83bc 100644 --- a/src/emucore/Cart2K.hxx +++ b/src/emucore/Cart2K.hxx @@ -48,7 +48,7 @@ class Cartridge2K : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - Cartridge2K(const BytePtr& image, uInt32 size, const string& md5, + Cartridge2K(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~Cartridge2K() = default; @@ -127,7 +127,7 @@ class Cartridge2K : public Cartridge private: // Pointer to a dynamically allocated ROM image of the cartridge - BytePtr myImage; + ByteBuffer myImage; // Size of the ROM image uInt32 mySize; diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index c5637752f..80778a501 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -20,7 +20,7 @@ #include "Cart3E.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cartridge3E::Cartridge3E(const BytePtr& image, uInt32 size, +Cartridge3E::Cartridge3E(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size), diff --git a/src/emucore/Cart3E.hxx b/src/emucore/Cart3E.hxx index 383e3f06c..6ec025013 100644 --- a/src/emucore/Cart3E.hxx +++ b/src/emucore/Cart3E.hxx @@ -74,7 +74,7 @@ class Cartridge3E : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - Cartridge3E(const BytePtr& image, uInt32 size, const string& md5, + Cartridge3E(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~Cartridge3E() = default; @@ -180,7 +180,7 @@ class Cartridge3E : public Cartridge private: // Pointer to a dynamically allocated ROM image of the cartridge - BytePtr myImage; + ByteBuffer myImage; // RAM contents. For now every ROM gets all 32K of potential RAM uInt8 myRAM[32 * 1024]; diff --git a/src/emucore/Cart3EPlus.cxx b/src/emucore/Cart3EPlus.cxx index dd8a8d719..a40c1e3ea 100644 --- a/src/emucore/Cart3EPlus.cxx +++ b/src/emucore/Cart3EPlus.cxx @@ -20,7 +20,7 @@ #include "Cart3EPlus.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cartridge3EPlus::Cartridge3EPlus(const BytePtr& image, uInt32 size, +Cartridge3EPlus::Cartridge3EPlus(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size) diff --git a/src/emucore/Cart3EPlus.hxx b/src/emucore/Cart3EPlus.hxx index e064401e0..5de961d2a 100644 --- a/src/emucore/Cart3EPlus.hxx +++ b/src/emucore/Cart3EPlus.hxx @@ -54,7 +54,7 @@ class Cartridge3EPlus: public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - Cartridge3EPlus(const BytePtr& image, uInt32 size, const string& md5, + Cartridge3EPlus(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~Cartridge3EPlus() = default; @@ -178,7 +178,7 @@ class Cartridge3EPlus: public Cartridge static constexpr uInt16 RAM_WRITE_OFFSET = 0x200; - BytePtr myImage; // Pointer to a dynamically allocated ROM image of the cartridge + ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge uInt32 mySize; // Size of the ROM image uInt8 myRAM[RAM_TOTAL_SIZE]; diff --git a/src/emucore/Cart3F.cxx b/src/emucore/Cart3F.cxx index 832cd52a1..10fef4677 100644 --- a/src/emucore/Cart3F.cxx +++ b/src/emucore/Cart3F.cxx @@ -20,7 +20,7 @@ #include "Cart3F.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cartridge3F::Cartridge3F(const BytePtr& image, uInt32 size, +Cartridge3F::Cartridge3F(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size), diff --git a/src/emucore/Cart3F.hxx b/src/emucore/Cart3F.hxx index 8e63ec577..8982de2ac 100644 --- a/src/emucore/Cart3F.hxx +++ b/src/emucore/Cart3F.hxx @@ -51,7 +51,7 @@ class Cartridge3F : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - Cartridge3F(const BytePtr& image, uInt32 size, const string& md5, + Cartridge3F(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~Cartridge3F() = default; @@ -157,7 +157,7 @@ class Cartridge3F : public Cartridge private: // Pointer to a dynamically allocated ROM image of the cartridge - BytePtr myImage; + ByteBuffer myImage; // Size of the ROM image uInt32 mySize; diff --git a/src/emucore/Cart4A50.cxx b/src/emucore/Cart4A50.cxx index a512b1ca2..68b109e2d 100644 --- a/src/emucore/Cart4A50.cxx +++ b/src/emucore/Cart4A50.cxx @@ -21,7 +21,7 @@ #include "Cart4A50.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cartridge4A50::Cartridge4A50(const BytePtr& image, uInt32 size, +Cartridge4A50::Cartridge4A50(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size), diff --git a/src/emucore/Cart4A50.hxx b/src/emucore/Cart4A50.hxx index cf400859c..2bf24823b 100644 --- a/src/emucore/Cart4A50.hxx +++ b/src/emucore/Cart4A50.hxx @@ -65,7 +65,7 @@ class Cartridge4A50 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - Cartridge4A50(const BytePtr& image, uInt32 size, const string& md5, + Cartridge4A50(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~Cartridge4A50() = default; diff --git a/src/emucore/Cart4K.cxx b/src/emucore/Cart4K.cxx index 55f874933..1940214a0 100644 --- a/src/emucore/Cart4K.cxx +++ b/src/emucore/Cart4K.cxx @@ -19,7 +19,7 @@ #include "Cart4K.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cartridge4K::Cartridge4K(const BytePtr& image, uInt32 size, +Cartridge4K::Cartridge4K(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5) { diff --git a/src/emucore/Cart4K.hxx b/src/emucore/Cart4K.hxx index f8ad3c6fa..f876b650f 100644 --- a/src/emucore/Cart4K.hxx +++ b/src/emucore/Cart4K.hxx @@ -45,7 +45,7 @@ class Cartridge4K : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - Cartridge4K(const BytePtr& image, uInt32 size, const string& md5, + Cartridge4K(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~Cartridge4K() = default; diff --git a/src/emucore/Cart4KSC.cxx b/src/emucore/Cart4KSC.cxx index 57db6f24a..330c7dcdb 100644 --- a/src/emucore/Cart4KSC.cxx +++ b/src/emucore/Cart4KSC.cxx @@ -19,7 +19,7 @@ #include "Cart4KSC.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cartridge4KSC::Cartridge4KSC(const BytePtr& image, uInt32 size, +Cartridge4KSC::Cartridge4KSC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5) { diff --git a/src/emucore/Cart4KSC.hxx b/src/emucore/Cart4KSC.hxx index 9f2177e39..f2823cdc9 100644 --- a/src/emucore/Cart4KSC.hxx +++ b/src/emucore/Cart4KSC.hxx @@ -44,7 +44,7 @@ class Cartridge4KSC : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - Cartridge4KSC(const BytePtr& image, uInt32 size, const string& md5, + Cartridge4KSC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~Cartridge4KSC() = default; diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index 00cbf53aa..548bc7f85 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -20,7 +20,7 @@ #include "CartAR.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeAR::CartridgeAR(const BytePtr& image, uInt32 size, +CartridgeAR::CartridgeAR(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(std::max(size, 8448u)), diff --git a/src/emucore/CartAR.hxx b/src/emucore/CartAR.hxx index c2100c080..f78536a22 100644 --- a/src/emucore/CartAR.hxx +++ b/src/emucore/CartAR.hxx @@ -52,7 +52,7 @@ class CartridgeAR : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeAR(const BytePtr& image, uInt32 size, const string& md5, + CartridgeAR(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeAR() = default; @@ -197,7 +197,7 @@ class CartridgeAR : public Cartridge uInt32 mySize; // All of the 8448 byte loads associated with the game - BytePtr myLoadImages; + ByteBuffer myLoadImages; // Indicates how many 8448 loads there are uInt8 myNumberOfLoadImages; diff --git a/src/emucore/CartBF.cxx b/src/emucore/CartBF.cxx index b3e2e8d8a..85974c3f9 100644 --- a/src/emucore/CartBF.cxx +++ b/src/emucore/CartBF.cxx @@ -19,7 +19,7 @@ #include "CartBF.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeBF::CartridgeBF(const BytePtr& image, uInt32 size, +CartridgeBF::CartridgeBF(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartBF.hxx b/src/emucore/CartBF.hxx index c6e71927a..59853b68a 100644 --- a/src/emucore/CartBF.hxx +++ b/src/emucore/CartBF.hxx @@ -46,7 +46,7 @@ class CartridgeBF : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeBF(const BytePtr& image, uInt32 size, const string& md5, + CartridgeBF(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeBF() = default; diff --git a/src/emucore/CartBFSC.cxx b/src/emucore/CartBFSC.cxx index c1b50c608..d7edea29b 100644 --- a/src/emucore/CartBFSC.cxx +++ b/src/emucore/CartBFSC.cxx @@ -19,7 +19,7 @@ #include "CartBFSC.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeBFSC::CartridgeBFSC(const BytePtr& image, uInt32 size, +CartridgeBFSC::CartridgeBFSC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartBFSC.hxx b/src/emucore/CartBFSC.hxx index c9ba66746..34d701d82 100644 --- a/src/emucore/CartBFSC.hxx +++ b/src/emucore/CartBFSC.hxx @@ -46,7 +46,7 @@ class CartridgeBFSC : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeBFSC(const BytePtr& image, uInt32 size, const string& md5, + CartridgeBFSC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeBFSC() = default; diff --git a/src/emucore/CartBUS.cxx b/src/emucore/CartBUS.cxx index 520c94360..84057ddd7 100644 --- a/src/emucore/CartBUS.cxx +++ b/src/emucore/CartBUS.cxx @@ -41,7 +41,7 @@ #define DIGITAL_AUDIO_ON ((myMode & 0xF0) == 0) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeBUS::CartridgeBUS(const BytePtr& image, uInt32 size, +CartridgeBUS::CartridgeBUS(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myAudioCycles(0), diff --git a/src/emucore/CartBUS.hxx b/src/emucore/CartBUS.hxx index b75d05c30..e4cc7b634 100644 --- a/src/emucore/CartBUS.hxx +++ b/src/emucore/CartBUS.hxx @@ -54,7 +54,7 @@ class CartridgeBUS : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeBUS(const BytePtr& image, uInt32 size, const string& md5, + CartridgeBUS(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeBUS() = default; diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index 80211c742..756d4ddd1 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -57,7 +57,7 @@ namespace { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeCDF::CartridgeCDF(const BytePtr& image, uInt32 size, +CartridgeCDF::CartridgeCDF(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myAudioCycles(0), diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index 5248bb5d3..340097b83 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -62,7 +62,7 @@ class CartridgeCDF : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeCDF(const BytePtr& image, uInt32 size, const string& md5, + CartridgeCDF(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeCDF() = default; diff --git a/src/emucore/CartCM.cxx b/src/emucore/CartCM.cxx index 29db21f84..b0c93623d 100644 --- a/src/emucore/CartCM.cxx +++ b/src/emucore/CartCM.cxx @@ -21,7 +21,7 @@ #include "CartCM.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeCM::CartridgeCM(const BytePtr& image, uInt32 size, +CartridgeCM::CartridgeCM(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySWCHA(0xFF), // portA is all 1's diff --git a/src/emucore/CartCM.hxx b/src/emucore/CartCM.hxx index 64d8a8530..de57c2e40 100644 --- a/src/emucore/CartCM.hxx +++ b/src/emucore/CartCM.hxx @@ -120,7 +120,7 @@ class CartridgeCM : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeCM(const BytePtr& image, uInt32 size, const string& md5, + CartridgeCM(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeCM() = default; diff --git a/src/emucore/CartCTY.cxx b/src/emucore/CartCTY.cxx index 01f27c4f0..d0d00b3e5 100644 --- a/src/emucore/CartCTY.cxx +++ b/src/emucore/CartCTY.cxx @@ -22,7 +22,7 @@ #include "CartCTY.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeCTY::CartridgeCTY(const BytePtr& image, uInt32 size, +CartridgeCTY::CartridgeCTY(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myOperationType(0), diff --git a/src/emucore/CartCTY.hxx b/src/emucore/CartCTY.hxx index 3ce07910c..32f229f14 100644 --- a/src/emucore/CartCTY.hxx +++ b/src/emucore/CartCTY.hxx @@ -118,7 +118,7 @@ class CartridgeCTY : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the settings object */ - CartridgeCTY(const BytePtr& image, uInt32 size, const string& md5, + CartridgeCTY(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeCTY() = default; diff --git a/src/emucore/CartCV.cxx b/src/emucore/CartCV.cxx index 665055b48..0153b1aaf 100644 --- a/src/emucore/CartCV.cxx +++ b/src/emucore/CartCV.cxx @@ -19,7 +19,7 @@ #include "CartCV.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeCV::CartridgeCV(const BytePtr& image, uInt32 size, +CartridgeCV::CartridgeCV(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size) diff --git a/src/emucore/CartCV.hxx b/src/emucore/CartCV.hxx index c393f1865..c22c8f4fa 100644 --- a/src/emucore/CartCV.hxx +++ b/src/emucore/CartCV.hxx @@ -48,7 +48,7 @@ class CartridgeCV : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeCV(const BytePtr& image, uInt32 size, const string& md5, + CartridgeCV(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeCV() = default; @@ -138,7 +138,7 @@ class CartridgeCV : public Cartridge private: // Pointer to the initial RAM data from the cart // This doesn't always exist, so we don't pre-allocate it - BytePtr myInitialRAM; + ByteBuffer myInitialRAM; // Initial size of the cart data uInt32 mySize; diff --git a/src/emucore/CartCVPlus.cxx b/src/emucore/CartCVPlus.cxx index 89eeb24d4..495322dac 100644 --- a/src/emucore/CartCVPlus.cxx +++ b/src/emucore/CartCVPlus.cxx @@ -20,7 +20,7 @@ #include "CartCVPlus.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeCVPlus::CartridgeCVPlus(const BytePtr& image, uInt32 size, +CartridgeCVPlus::CartridgeCVPlus(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size), diff --git a/src/emucore/CartCVPlus.hxx b/src/emucore/CartCVPlus.hxx index a9e787e2b..eddda563e 100644 --- a/src/emucore/CartCVPlus.hxx +++ b/src/emucore/CartCVPlus.hxx @@ -57,7 +57,7 @@ class CartridgeCVPlus : public Cartridge @param size The size of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeCVPlus(const BytePtr& image, uInt32 size, const string& md5, + CartridgeCVPlus(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeCVPlus() = default; @@ -163,7 +163,7 @@ class CartridgeCVPlus : public Cartridge private: // Pointer to a dynamically allocated ROM image of the cartridge - BytePtr myImage; + ByteBuffer myImage; // The 1024 bytes of RAM uInt8 myRAM[1024]; diff --git a/src/emucore/CartDASH.cxx b/src/emucore/CartDASH.cxx index f00e0d8d5..7472b4d58 100644 --- a/src/emucore/CartDASH.cxx +++ b/src/emucore/CartDASH.cxx @@ -20,7 +20,7 @@ #include "CartDASH.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeDASH::CartridgeDASH(const BytePtr& image, uInt32 size, +CartridgeDASH::CartridgeDASH(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size) diff --git a/src/emucore/CartDASH.hxx b/src/emucore/CartDASH.hxx index 4b0a4a6c4..7c109e32b 100644 --- a/src/emucore/CartDASH.hxx +++ b/src/emucore/CartDASH.hxx @@ -136,7 +136,7 @@ class CartridgeDASH: public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeDASH(const BytePtr& image, uInt32 size, const string& md5, + CartridgeDASH(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeDASH() = default; @@ -261,7 +261,7 @@ class CartridgeDASH: public Cartridge static constexpr uInt16 RAM_WRITE_OFFSET = 0x800; - BytePtr myImage; // Pointer to a dynamically allocated ROM image of the cartridge + ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge uInt32 mySize; // Size of the ROM image uInt8 myRAM[RAM_TOTAL_SIZE]; diff --git a/src/emucore/CartDF.cxx b/src/emucore/CartDF.cxx index ab18ee73b..60e9635de 100644 --- a/src/emucore/CartDF.cxx +++ b/src/emucore/CartDF.cxx @@ -19,7 +19,7 @@ #include "CartDF.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeDF::CartridgeDF(const BytePtr& image, uInt32 size, +CartridgeDF::CartridgeDF(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartDF.hxx b/src/emucore/CartDF.hxx index da9a8b974..9a8a6182a 100644 --- a/src/emucore/CartDF.hxx +++ b/src/emucore/CartDF.hxx @@ -46,7 +46,7 @@ class CartridgeDF : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeDF(const BytePtr& image, uInt32 size, const string& md5, + CartridgeDF(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeDF() = default; diff --git a/src/emucore/CartDFSC.cxx b/src/emucore/CartDFSC.cxx index 950ced070..f65f97b11 100644 --- a/src/emucore/CartDFSC.cxx +++ b/src/emucore/CartDFSC.cxx @@ -19,7 +19,7 @@ #include "CartDFSC.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeDFSC::CartridgeDFSC(const BytePtr& image, uInt32 size, +CartridgeDFSC::CartridgeDFSC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartDFSC.hxx b/src/emucore/CartDFSC.hxx index 1a682df48..8ffe7e955 100644 --- a/src/emucore/CartDFSC.hxx +++ b/src/emucore/CartDFSC.hxx @@ -46,7 +46,7 @@ class CartridgeDFSC : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeDFSC(const BytePtr& image, uInt32 size, const string& md5, + CartridgeDFSC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeDFSC() = default; diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index ba8b3e189..c7c92740e 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -19,7 +19,7 @@ #include "CartDPC.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeDPC::CartridgeDPC(const BytePtr& image, uInt32 size, +CartridgeDPC::CartridgeDPC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size), diff --git a/src/emucore/CartDPC.hxx b/src/emucore/CartDPC.hxx index 399c8b00b..45fe0ecca 100644 --- a/src/emucore/CartDPC.hxx +++ b/src/emucore/CartDPC.hxx @@ -50,7 +50,7 @@ class CartridgeDPC : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeDPC(const BytePtr& image, uInt32 size, const string& md5, + CartridgeDPC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeDPC() = default; diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index eecdc8af9..7fbdc7e14 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -26,7 +26,7 @@ #include "exception/FatalEmulationError.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeDPCPlus::CartridgeDPCPlus(const BytePtr& image, uInt32 size, +CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(std::min(size, 32768u)), diff --git a/src/emucore/CartDPCPlus.hxx b/src/emucore/CartDPCPlus.hxx index 8594382da..fd02eca2b 100644 --- a/src/emucore/CartDPCPlus.hxx +++ b/src/emucore/CartDPCPlus.hxx @@ -56,7 +56,7 @@ class CartridgeDPCPlus : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeDPCPlus(const BytePtr& image, uInt32 size, const string& md5, + CartridgeDPCPlus(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeDPCPlus() = default; diff --git a/src/emucore/CartDetector.cxx b/src/emucore/CartDetector.cxx index 7cc04ffed..67467dc65 100644 --- a/src/emucore/CartDetector.cxx +++ b/src/emucore/CartDetector.cxx @@ -66,7 +66,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unique_ptr CartDetector::create(const FilesystemNode& file, - const BytePtr& image, uInt32 size, string& md5, + const ByteBuffer& image, uInt32 size, string& md5, const string& propertiesType, Settings& settings) { unique_ptr cartridge; @@ -210,13 +210,13 @@ unique_ptr CartDetector::create(const FilesystemNode& file, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unique_ptr -CartDetector::createFromMultiCart(const BytePtr& image, uInt32& size, +CartDetector::createFromMultiCart(const ByteBuffer& image, uInt32& size, uInt32 numroms, string& md5, Bankswitch::Type type, string& id, Settings& settings) { // Get a piece of the larger image uInt32 i = settings.getInt("romloadcount"); size /= numroms; - BytePtr slice = make_unique(size); + ByteBuffer slice = make_unique(size); memcpy(slice.get(), image.get()+i*size, size); // We need a new md5 and name @@ -238,7 +238,7 @@ CartDetector::createFromMultiCart(const BytePtr& image, uInt32& size, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unique_ptr -CartDetector::createFromImage(const BytePtr& image, uInt32 size, Bankswitch::Type type, +CartDetector::createFromImage(const ByteBuffer& image, uInt32 size, Bankswitch::Type type, const string& md5, Settings& settings) { // We should know the cart's type by now so let's create it @@ -334,7 +334,7 @@ CartDetector::createFromImage(const BytePtr& image, uInt32 size, Bankswitch::Typ } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Bankswitch::Type CartDetector::autodetectType(const BytePtr& image, uInt32 size) +Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, uInt32 size) { // Guess type based on size Bankswitch::Type type = Bankswitch::Type::_AUTO; @@ -551,7 +551,7 @@ bool CartDetector::searchForBytes(const uInt8* image, uInt32 imagesize, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablySC(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablySC(const ByteBuffer& image, uInt32 size) { // We assume a Superchip cart repeats the first 128 bytes for the second // 128 bytes in the RAM area, which is the first 256 bytes of each 4K bank @@ -568,7 +568,7 @@ bool CartDetector::isProbablySC(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyARM(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyARM(const ByteBuffer& image, uInt32 size) { // ARM code contains the following 'loader' patterns in the first 1K // Thanks to Thomas Jentzsch of AtariAge for this advice @@ -583,7 +583,7 @@ bool CartDetector::isProbablyARM(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbably0840(const BytePtr& image, uInt32 size) +bool CartDetector::isProbably0840(const ByteBuffer& image, uInt32 size) { // 0840 cart bankswitching is triggered by accessing addresses 0x0800 // or 0x0840 at least twice @@ -608,7 +608,7 @@ bool CartDetector::isProbably0840(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbably3E(const BytePtr& image, uInt32 size) +bool CartDetector::isProbably3E(const ByteBuffer& image, uInt32 size) { // 3E cart bankswitching is triggered by storing the bank number // in address 3E using 'STA $3E', commonly followed by an @@ -618,7 +618,7 @@ bool CartDetector::isProbably3E(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbably3EPlus(const BytePtr& image, uInt32 size) +bool CartDetector::isProbably3EPlus(const ByteBuffer& image, uInt32 size) { // 3E+ cart is identified key 'TJ3E' in the ROM uInt8 tj3e[] = { 'T', 'J', '3', 'E' }; @@ -626,7 +626,7 @@ bool CartDetector::isProbably3EPlus(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbably3F(const BytePtr& image, uInt32 size) +bool CartDetector::isProbably3F(const ByteBuffer& image, uInt32 size) { // 3F cart bankswitching is triggered by storing the bank number // in address 3F using 'STA $3F' @@ -637,7 +637,7 @@ bool CartDetector::isProbably3F(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbably4A50(const BytePtr& image, uInt32 size) +bool CartDetector::isProbably4A50(const ByteBuffer& image, uInt32 size) { // 4A50 carts store address $4A50 at the NMI vector, which // in this scheme is always in the last page of ROM at @@ -655,7 +655,7 @@ bool CartDetector::isProbably4A50(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbably4KSC(const BytePtr& image, uInt32 size) +bool CartDetector::isProbably4KSC(const ByteBuffer& image, uInt32 size) { // We check if the first 256 bytes are identical *and* if there's // an "SC" signature for one of our larger SC types at 1FFA. @@ -672,7 +672,7 @@ bool CartDetector::isProbably4KSC(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyBF(const BytePtr& image, uInt32 size, +bool CartDetector::isProbablyBF(const ByteBuffer& image, uInt32 size, Bankswitch::Type& type) { // BF carts store strings 'BFBF' and 'BFSC' starting at address $FFF8 @@ -694,7 +694,7 @@ bool CartDetector::isProbablyBF(const BytePtr& image, uInt32 size, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyBUS(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyBUS(const ByteBuffer& image, uInt32 size) { // BUS ARM code has 2 occurrences of the string BUS // Note: all Harmony/Melody custom drivers also contain the value @@ -704,7 +704,7 @@ bool CartDetector::isProbablyBUS(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyCDF(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyCDF(const ByteBuffer& image, uInt32 size) { // CDF ARM code has 3 occurrences of the string CDF // Note: all Harmony/Melody custom drivers also contain the value @@ -714,14 +714,14 @@ bool CartDetector::isProbablyCDF(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyCTY(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyCTY(const ByteBuffer& image, uInt32 size) { uInt8 lenin[] = { 'L', 'E', 'N', 'I', 'N' }; return searchForBytes(image.get(), size, lenin, 5, 1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyCV(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyCV(const ByteBuffer& image, uInt32 size) { // CV RAM access occurs at addresses $f3ff and $f400 // These signatures are attributed to the MESS project @@ -736,7 +736,7 @@ bool CartDetector::isProbablyCV(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyCVPlus(const BytePtr& image, uInt32) +bool CartDetector::isProbablyCVPlus(const ByteBuffer& image, uInt32) { // CV+ cart is identified key 'commavidplus' @ $04 in the ROM // We inspect only this area to speed up the search @@ -746,7 +746,7 @@ bool CartDetector::isProbablyCVPlus(const BytePtr& image, uInt32) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyDASH(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyDASH(const ByteBuffer& image, uInt32 size) { // DASH cart is identified key 'TJAD' in the ROM uInt8 tjad[] = { 'T', 'J', 'A', 'D' }; @@ -754,7 +754,7 @@ bool CartDetector::isProbablyDASH(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyDF(const BytePtr& image, uInt32 size, +bool CartDetector::isProbablyDF(const ByteBuffer& image, uInt32 size, Bankswitch::Type& type) { @@ -777,7 +777,7 @@ bool CartDetector::isProbablyDF(const BytePtr& image, uInt32 size, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyDPCplus(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyDPCplus(const ByteBuffer& image, uInt32 size) { // DPC+ ARM code has 2 occurrences of the string DPC+ // Note: all Harmony/Melody custom drivers also contain the value @@ -787,7 +787,7 @@ bool CartDetector::isProbablyDPCplus(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyE0(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyE0(const ByteBuffer& image, uInt32 size) { // E0 cart bankswitching is triggered by accessing addresses // $FE0 to $FF9 using absolute non-indexed addressing @@ -813,7 +813,7 @@ bool CartDetector::isProbablyE0(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyE7(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyE7(const ByteBuffer& image, uInt32 size) { // E7 cart bankswitching is triggered by accessing addresses // $FE0 to $FE6 using absolute non-indexed addressing @@ -838,7 +838,7 @@ bool CartDetector::isProbablyE7(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyE78K(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyE78K(const ByteBuffer& image, uInt32 size) { // E78K cart bankswitching is triggered by accessing addresses // $FE4 to $FE6 using absolute non-indexed addressing @@ -857,7 +857,7 @@ bool CartDetector::isProbablyE78K(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyEF(const BytePtr& image, uInt32 size, +bool CartDetector::isProbablyEF(const ByteBuffer& image, uInt32 size, Bankswitch::Type& type) { // Newer EF carts store strings 'EFEF' and 'EFSC' starting at address $FFF8 @@ -906,7 +906,7 @@ bool CartDetector::isProbablyEF(const BytePtr& image, uInt32 size, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyFA2(const BytePtr& image, uInt32) +bool CartDetector::isProbablyFA2(const ByteBuffer& image, uInt32) { // This currently tests only the 32K version of FA2; the 24 and 28K // versions are easy, in that they're the only possibility with those @@ -921,7 +921,7 @@ bool CartDetector::isProbablyFA2(const BytePtr& image, uInt32) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyFE(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyFE(const ByteBuffer& image, uInt32 size) { // FE bankswitching is very weird, but always seems to include a // 'JSR $xxxx' @@ -940,7 +940,7 @@ bool CartDetector::isProbablyFE(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyMDM(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyMDM(const ByteBuffer& image, uInt32 size) { // MDM cart is identified key 'MDMC' in the first 8K of ROM uInt8 mdmc[] = { 'M', 'D', 'M', 'C' }; @@ -948,7 +948,7 @@ bool CartDetector::isProbablyMDM(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablySB(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablySB(const ByteBuffer& image, uInt32 size) { // SB cart bankswitching switches banks by accessing address 0x0800 uInt8 signature[2][3] = { @@ -962,7 +962,7 @@ bool CartDetector::isProbablySB(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyUA(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyUA(const ByteBuffer& image, uInt32 size) { // UA cart bankswitching switches to bank 1 by accessing address 0x240 // using 'STA $240' or 'LDA $240' @@ -979,7 +979,7 @@ bool CartDetector::isProbablyUA(const BytePtr& image, uInt32 size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartDetector::isProbablyX07(const BytePtr& image, uInt32 size) +bool CartDetector::isProbablyX07(const ByteBuffer& image, uInt32 size) { // X07 bankswitching switches to bank 0, 1, 2, etc by accessing address 0x08xd uInt8 signature[6][3] = { diff --git a/src/emucore/CartDetector.hxx b/src/emucore/CartDetector.hxx index d3213ae2a..2c2c3bd90 100644 --- a/src/emucore/CartDetector.hxx +++ b/src/emucore/CartDetector.hxx @@ -46,7 +46,7 @@ class CartDetector @return Pointer to the new cartridge object allocated on the heap */ static unique_ptr create(const FilesystemNode& file, - const BytePtr& image, uInt32 size, string& md5, + const ByteBuffer& image, uInt32 size, string& md5, const string& dtype, Settings& settings); private: @@ -65,7 +65,7 @@ class CartDetector @return Pointer to the new cartridge object allocated on the heap */ static unique_ptr - createFromMultiCart(const BytePtr& image, uInt32& size, + createFromMultiCart(const ByteBuffer& image, uInt32& size, uInt32 numroms, string& md5, Bankswitch::Type type, string& id, Settings& settings); @@ -81,7 +81,7 @@ class CartDetector @return Pointer to the new cartridge object allocated on the heap */ static unique_ptr - createFromImage(const BytePtr& image, uInt32 size, Bankswitch::Type type, + createFromImage(const ByteBuffer& image, uInt32 size, Bankswitch::Type type, const string& md5, Settings& settings); /** @@ -92,7 +92,7 @@ class CartDetector @return The "best guess" for the cartridge type */ - static Bankswitch::Type autodetectType(const BytePtr& image, uInt32 size); + static Bankswitch::Type autodetectType(const ByteBuffer& image, uInt32 size); /** Search the image for the specified byte signature @@ -113,142 +113,142 @@ class CartDetector Returns true if the image is probably a SuperChip (128 bytes RAM) Note: should be called only on ROMs with size multiple of 4K */ - static bool isProbablySC(const BytePtr& image, uInt32 size); + static bool isProbablySC(const ByteBuffer& image, uInt32 size); /** Returns true if the image probably contains ARM code in the first 1K */ - static bool isProbablyARM(const BytePtr& image, uInt32 size); + static bool isProbablyARM(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a 0840 bankswitching cartridge */ - static bool isProbably0840(const BytePtr& image, uInt32 size); + static bool isProbably0840(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a 3E bankswitching cartridge */ - static bool isProbably3E(const BytePtr& image, uInt32 size); + static bool isProbably3E(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a 3E+ bankswitching cartridge */ - static bool isProbably3EPlus(const BytePtr& image, uInt32 size); + static bool isProbably3EPlus(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a 3F bankswitching cartridge */ - static bool isProbably3F(const BytePtr& image, uInt32 size); + static bool isProbably3F(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a 4A50 bankswitching cartridge */ - static bool isProbably4A50(const BytePtr& image, uInt32 size); + static bool isProbably4A50(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a 4K SuperChip (128 bytes RAM) */ - static bool isProbably4KSC(const BytePtr& image, uInt32 size); + static bool isProbably4KSC(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a BF/BFSC bankswitching cartridge */ - static bool isProbablyBF(const BytePtr& image, uInt32 size, Bankswitch::Type& type); + static bool isProbablyBF(const ByteBuffer& image, uInt32 size, Bankswitch::Type& type); /** Returns true if the image is probably a BUS bankswitching cartridge */ - static bool isProbablyBUS(const BytePtr& image, uInt32 size); + static bool isProbablyBUS(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a CDF bankswitching cartridge */ - static bool isProbablyCDF(const BytePtr& image, uInt32 size); + static bool isProbablyCDF(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a CTY bankswitching cartridge */ - static bool isProbablyCTY(const BytePtr& image, uInt32 size); + static bool isProbablyCTY(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a CV bankswitching cartridge */ - static bool isProbablyCV(const BytePtr& image, uInt32 size); + static bool isProbablyCV(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a CV+ bankswitching cartridge */ - static bool isProbablyCVPlus(const BytePtr& image, uInt32 size); + static bool isProbablyCVPlus(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a DASH bankswitching cartridge */ - static bool isProbablyDASH(const BytePtr& image, uInt32 size); + static bool isProbablyDASH(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a DF/DFSC bankswitching cartridge */ - static bool isProbablyDF(const BytePtr& image, uInt32 size, Bankswitch::Type& type); + static bool isProbablyDF(const ByteBuffer& image, uInt32 size, Bankswitch::Type& type); /** Returns true if the image is probably a DPC+ bankswitching cartridge */ - static bool isProbablyDPCplus(const BytePtr& image, uInt32 size); + static bool isProbablyDPCplus(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a E0 bankswitching cartridge */ - static bool isProbablyE0(const BytePtr& image, uInt32 size); + static bool isProbablyE0(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a E7 bankswitching cartridge */ - static bool isProbablyE7(const BytePtr& image, uInt32 size); + static bool isProbablyE7(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a E78K bankswitching cartridge */ - static bool isProbablyE78K(const BytePtr& image, uInt32 size); + static bool isProbablyE78K(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably an EF/EFSC bankswitching cartridge */ - static bool isProbablyEF(const BytePtr& image, uInt32 size, Bankswitch::Type& type); + static bool isProbablyEF(const ByteBuffer& image, uInt32 size, Bankswitch::Type& type); /** Returns true if the image is probably an F6 bankswitching cartridge */ - //static bool isProbablyF6(const BytePtr& image, uInt32 size); + //static bool isProbablyF6(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably an FA2 bankswitching cartridge */ - static bool isProbablyFA2(const BytePtr& image, uInt32 size); + static bool isProbablyFA2(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably an FE bankswitching cartridge */ - static bool isProbablyFE(const BytePtr& image, uInt32 size); + static bool isProbablyFE(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a MDM bankswitching cartridge */ - static bool isProbablyMDM(const BytePtr& image, uInt32 size); + static bool isProbablyMDM(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a SB bankswitching cartridge */ - static bool isProbablySB(const BytePtr& image, uInt32 size); + static bool isProbablySB(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably a UA bankswitching cartridge */ - static bool isProbablyUA(const BytePtr& image, uInt32 size); + static bool isProbablyUA(const ByteBuffer& image, uInt32 size); /** Returns true if the image is probably an X07 bankswitching cartridge */ - static bool isProbablyX07(const BytePtr& image, uInt32 size); + static bool isProbablyX07(const ByteBuffer& image, uInt32 size); private: // Following constructors and assignment operators not supported diff --git a/src/emucore/CartE0.cxx b/src/emucore/CartE0.cxx index 9107a4c1c..0f337a0f5 100644 --- a/src/emucore/CartE0.cxx +++ b/src/emucore/CartE0.cxx @@ -19,7 +19,7 @@ #include "CartE0.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeE0::CartridgeE0(const BytePtr& image, uInt32 size, +CartridgeE0::CartridgeE0(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5) { diff --git a/src/emucore/CartE0.hxx b/src/emucore/CartE0.hxx index b2367d76b..c5b6cbde8 100644 --- a/src/emucore/CartE0.hxx +++ b/src/emucore/CartE0.hxx @@ -54,7 +54,7 @@ class CartridgeE0 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeE0(const BytePtr& image, uInt32 size, const string& md5, + CartridgeE0(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeE0() = default; diff --git a/src/emucore/CartE7.cxx b/src/emucore/CartE7.cxx index 4c7f9efee..87a3b7a98 100644 --- a/src/emucore/CartE7.cxx +++ b/src/emucore/CartE7.cxx @@ -19,7 +19,7 @@ #include "CartE7.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeE7::CartridgeE7(const BytePtr& image, uInt32 size, +CartridgeE7::CartridgeE7(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : CartridgeMNetwork(image, size, md5, settings) { diff --git a/src/emucore/CartE7.hxx b/src/emucore/CartE7.hxx index 0eca2dff0..6b1c36973 100644 --- a/src/emucore/CartE7.hxx +++ b/src/emucore/CartE7.hxx @@ -43,7 +43,7 @@ class CartridgeE7 : public CartridgeMNetwork @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeE7(const BytePtr& image, uInt32 size, const string& md5, + CartridgeE7(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeE7() = default; diff --git a/src/emucore/CartE78K.cxx b/src/emucore/CartE78K.cxx index 9cb0f62ad..04f7b2c82 100644 --- a/src/emucore/CartE78K.cxx +++ b/src/emucore/CartE78K.cxx @@ -19,7 +19,7 @@ #include "CartE78K.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeE78K::CartridgeE78K(const BytePtr& image, uInt32 size, +CartridgeE78K::CartridgeE78K(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : CartridgeMNetwork(image, size, md5, settings) { diff --git a/src/emucore/CartE78K.hxx b/src/emucore/CartE78K.hxx index d3a374704..91fe1b785 100644 --- a/src/emucore/CartE78K.hxx +++ b/src/emucore/CartE78K.hxx @@ -41,7 +41,7 @@ class CartridgeE78K : public CartridgeMNetwork @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeE78K(const BytePtr& image, uInt32 size, const string& md5, + CartridgeE78K(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeE78K() = default; diff --git a/src/emucore/CartEF.cxx b/src/emucore/CartEF.cxx index cc2cd1533..594701774 100644 --- a/src/emucore/CartEF.cxx +++ b/src/emucore/CartEF.cxx @@ -19,7 +19,7 @@ #include "CartEF.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeEF::CartridgeEF(const BytePtr& image, uInt32 size, +CartridgeEF::CartridgeEF(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartEF.hxx b/src/emucore/CartEF.hxx index b65d2374c..8bee49b90 100644 --- a/src/emucore/CartEF.hxx +++ b/src/emucore/CartEF.hxx @@ -46,7 +46,7 @@ class CartridgeEF : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeEF(const BytePtr& image, uInt32 size, const string& md5, + CartridgeEF(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeEF() = default; diff --git a/src/emucore/CartEFSC.cxx b/src/emucore/CartEFSC.cxx index 0aa99eaa9..86c10a4af 100644 --- a/src/emucore/CartEFSC.cxx +++ b/src/emucore/CartEFSC.cxx @@ -19,7 +19,7 @@ #include "CartEFSC.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeEFSC::CartridgeEFSC(const BytePtr& image, uInt32 size, +CartridgeEFSC::CartridgeEFSC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartEFSC.hxx b/src/emucore/CartEFSC.hxx index 5d655354f..d948e54ff 100644 --- a/src/emucore/CartEFSC.hxx +++ b/src/emucore/CartEFSC.hxx @@ -47,7 +47,7 @@ class CartridgeEFSC : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeEFSC(const BytePtr& image, uInt32 size, const string& md5, + CartridgeEFSC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeEFSC() = default; diff --git a/src/emucore/CartF0.cxx b/src/emucore/CartF0.cxx index a48f3005a..b6d178a06 100644 --- a/src/emucore/CartF0.cxx +++ b/src/emucore/CartF0.cxx @@ -19,7 +19,7 @@ #include "CartF0.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeF0::CartridgeF0(const BytePtr& image, uInt32 size, +CartridgeF0::CartridgeF0(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartF0.hxx b/src/emucore/CartF0.hxx index ae6fcf719..ad9b6aa30 100644 --- a/src/emucore/CartF0.hxx +++ b/src/emucore/CartF0.hxx @@ -46,7 +46,7 @@ class CartridgeF0 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeF0(const BytePtr& image, uInt32 size, const string& md5, + CartridgeF0(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeF0() = default; diff --git a/src/emucore/CartF4.cxx b/src/emucore/CartF4.cxx index cded5dda1..47d5dee96 100644 --- a/src/emucore/CartF4.cxx +++ b/src/emucore/CartF4.cxx @@ -20,7 +20,7 @@ #include "CartF4.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeF4::CartridgeF4(const BytePtr& image, uInt32 size, +CartridgeF4::CartridgeF4(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartF4.hxx b/src/emucore/CartF4.hxx index ab9af5c64..3685320c6 100644 --- a/src/emucore/CartF4.hxx +++ b/src/emucore/CartF4.hxx @@ -45,7 +45,7 @@ class CartridgeF4 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeF4(const BytePtr& image, uInt32 size, const string& md5, + CartridgeF4(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeF4() = default; diff --git a/src/emucore/CartF4SC.cxx b/src/emucore/CartF4SC.cxx index 3d407d237..148d61d7d 100644 --- a/src/emucore/CartF4SC.cxx +++ b/src/emucore/CartF4SC.cxx @@ -19,7 +19,7 @@ #include "CartF4SC.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeF4SC::CartridgeF4SC(const BytePtr& image, uInt32 size, +CartridgeF4SC::CartridgeF4SC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartF4SC.hxx b/src/emucore/CartF4SC.hxx index 5af53fcac..bc37769e2 100644 --- a/src/emucore/CartF4SC.hxx +++ b/src/emucore/CartF4SC.hxx @@ -46,7 +46,7 @@ class CartridgeF4SC : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeF4SC(const BytePtr& image, uInt32 size, const string& md5, + CartridgeF4SC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeF4SC() = default; diff --git a/src/emucore/CartF6.cxx b/src/emucore/CartF6.cxx index 3fecd3e9b..fc804ead4 100644 --- a/src/emucore/CartF6.cxx +++ b/src/emucore/CartF6.cxx @@ -19,7 +19,7 @@ #include "CartF6.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeF6::CartridgeF6(const BytePtr& image, uInt32 size, +CartridgeF6::CartridgeF6(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartF6.hxx b/src/emucore/CartF6.hxx index 423524b1d..16791909e 100644 --- a/src/emucore/CartF6.hxx +++ b/src/emucore/CartF6.hxx @@ -45,7 +45,7 @@ class CartridgeF6 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeF6(const BytePtr& image, uInt32 size, const string& md5, + CartridgeF6(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeF6() = default; diff --git a/src/emucore/CartF6SC.cxx b/src/emucore/CartF6SC.cxx index c40f0d726..3ad8ad790 100644 --- a/src/emucore/CartF6SC.cxx +++ b/src/emucore/CartF6SC.cxx @@ -19,7 +19,7 @@ #include "CartF6SC.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeF6SC::CartridgeF6SC(const BytePtr& image, uInt32 size, +CartridgeF6SC::CartridgeF6SC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartF6SC.hxx b/src/emucore/CartF6SC.hxx index 87cb3642d..0a50dc451 100644 --- a/src/emucore/CartF6SC.hxx +++ b/src/emucore/CartF6SC.hxx @@ -46,7 +46,7 @@ class CartridgeF6SC : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeF6SC(const BytePtr& image, uInt32 size, const string& md5, + CartridgeF6SC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeF6SC() = default; diff --git a/src/emucore/CartF8.cxx b/src/emucore/CartF8.cxx index 0dadfd061..63e504848 100644 --- a/src/emucore/CartF8.cxx +++ b/src/emucore/CartF8.cxx @@ -19,7 +19,7 @@ #include "CartF8.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeF8::CartridgeF8(const BytePtr& image, uInt32 size, +CartridgeF8::CartridgeF8(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartF8.hxx b/src/emucore/CartF8.hxx index 710f5088a..9e83db236 100644 --- a/src/emucore/CartF8.hxx +++ b/src/emucore/CartF8.hxx @@ -45,7 +45,7 @@ class CartridgeF8 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeF8(const BytePtr& image, uInt32 size, const string& md5, + CartridgeF8(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeF8() = default; diff --git a/src/emucore/CartF8SC.cxx b/src/emucore/CartF8SC.cxx index 763503ad5..41da41178 100644 --- a/src/emucore/CartF8SC.cxx +++ b/src/emucore/CartF8SC.cxx @@ -19,7 +19,7 @@ #include "CartF8SC.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeF8SC::CartridgeF8SC(const BytePtr& image, uInt32 size, +CartridgeF8SC::CartridgeF8SC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartF8SC.hxx b/src/emucore/CartF8SC.hxx index 4e33cc2e5..3907b2b43 100644 --- a/src/emucore/CartF8SC.hxx +++ b/src/emucore/CartF8SC.hxx @@ -46,7 +46,7 @@ class CartridgeF8SC : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeF8SC(const BytePtr& image, uInt32 size, const string& md5, + CartridgeF8SC(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeF8SC() = default; diff --git a/src/emucore/CartFA.cxx b/src/emucore/CartFA.cxx index 0b2966fb5..140277a93 100644 --- a/src/emucore/CartFA.cxx +++ b/src/emucore/CartFA.cxx @@ -19,7 +19,7 @@ #include "CartFA.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeFA::CartridgeFA(const BytePtr& image, uInt32 size, +CartridgeFA::CartridgeFA(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartFA.hxx b/src/emucore/CartFA.hxx index 615bd469c..5bcb1cf3f 100644 --- a/src/emucore/CartFA.hxx +++ b/src/emucore/CartFA.hxx @@ -46,7 +46,7 @@ class CartridgeFA : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeFA(const BytePtr& image, uInt32 size, const string& md5, + CartridgeFA(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeFA() = default; diff --git a/src/emucore/CartFA2.cxx b/src/emucore/CartFA2.cxx index 5bb667faa..038d72a07 100644 --- a/src/emucore/CartFA2.cxx +++ b/src/emucore/CartFA2.cxx @@ -22,7 +22,7 @@ #include "CartFA2.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeFA2::CartridgeFA2(const BytePtr& image, uInt32 size, +CartridgeFA2::CartridgeFA2(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(28 * 1024), diff --git a/src/emucore/CartFA2.hxx b/src/emucore/CartFA2.hxx index 779acd795..acc201d1e 100644 --- a/src/emucore/CartFA2.hxx +++ b/src/emucore/CartFA2.hxx @@ -58,7 +58,7 @@ class CartridgeFA2 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the settings object */ - CartridgeFA2(const BytePtr& image, uInt32 size, const string& md5, + CartridgeFA2(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeFA2() = default; diff --git a/src/emucore/CartFE.cxx b/src/emucore/CartFE.cxx index 83ad0fb9f..5c99e4ab9 100644 --- a/src/emucore/CartFE.cxx +++ b/src/emucore/CartFE.cxx @@ -20,7 +20,7 @@ #include "CartFE.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeFE::CartridgeFE(const BytePtr& image, uInt32 size, +CartridgeFE::CartridgeFE(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0), diff --git a/src/emucore/CartFE.hxx b/src/emucore/CartFE.hxx index c63f94e9b..6158c4cfb 100644 --- a/src/emucore/CartFE.hxx +++ b/src/emucore/CartFE.hxx @@ -88,7 +88,7 @@ class CartridgeFE : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeFE(const BytePtr& image, uInt32 size, const string& md5, + CartridgeFE(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeFE() = default; diff --git a/src/emucore/CartMDM.cxx b/src/emucore/CartMDM.cxx index 5e0f6287b..ade4407cb 100644 --- a/src/emucore/CartMDM.cxx +++ b/src/emucore/CartMDM.cxx @@ -19,7 +19,7 @@ #include "CartMDM.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeMDM::CartridgeMDM(const BytePtr& image, uInt32 size, +CartridgeMDM::CartridgeMDM(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size), diff --git a/src/emucore/CartMDM.hxx b/src/emucore/CartMDM.hxx index 91906ff55..abeaee3a2 100644 --- a/src/emucore/CartMDM.hxx +++ b/src/emucore/CartMDM.hxx @@ -57,7 +57,7 @@ class CartridgeMDM : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeMDM(const BytePtr& image, uInt32 size, const string& md5, + CartridgeMDM(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeMDM() = default; @@ -163,7 +163,7 @@ class CartridgeMDM : public Cartridge private: // Pointer to a dynamically allocated ROM image of the cartridge - BytePtr myImage; + ByteBuffer myImage; // Size of the ROM image uInt32 mySize; diff --git a/src/emucore/CartMNetwork.cxx b/src/emucore/CartMNetwork.cxx index 0696c695f..7c29f3924 100644 --- a/src/emucore/CartMNetwork.cxx +++ b/src/emucore/CartMNetwork.cxx @@ -19,7 +19,7 @@ #include "CartMNetwork.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeMNetwork::CartridgeMNetwork(const BytePtr& image, uInt32 size, +CartridgeMNetwork::CartridgeMNetwork(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size), @@ -29,7 +29,7 @@ CartridgeMNetwork::CartridgeMNetwork(const BytePtr& image, uInt32 size, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeMNetwork::initialize(const BytePtr& image, uInt32 size) +void CartridgeMNetwork::initialize(const ByteBuffer& image, uInt32 size) { // Allocate array for the ROM image myImage = make_unique(size); diff --git a/src/emucore/CartMNetwork.hxx b/src/emucore/CartMNetwork.hxx index 59c2de98c..c8441be24 100644 --- a/src/emucore/CartMNetwork.hxx +++ b/src/emucore/CartMNetwork.hxx @@ -73,7 +73,7 @@ class CartridgeMNetwork : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeMNetwork(const BytePtr& image, uInt32 size, const string& md5, + CartridgeMNetwork(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeMNetwork() = default; @@ -162,7 +162,7 @@ class CartridgeMNetwork : public Cartridge /** Class initialization */ - void initialize(const BytePtr& image, uInt32 size); + void initialize(const ByteBuffer& image, uInt32 size); /** Install pages for the specified 256 byte bank of RAM @@ -195,7 +195,7 @@ class CartridgeMNetwork : public Cartridge private: // Pointer to a dynamically allocated ROM image of the cartridge - BytePtr myImage; + ByteBuffer myImage; // The 16K ROM image of the cartridge (works for E78K too) //uInt8 myImage[BANK_SIZE * 8]; diff --git a/src/emucore/CartSB.cxx b/src/emucore/CartSB.cxx index e6e9aafed..bd1cc8568 100644 --- a/src/emucore/CartSB.cxx +++ b/src/emucore/CartSB.cxx @@ -19,7 +19,7 @@ #include "CartSB.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeSB::CartridgeSB(const BytePtr& image, uInt32 size, +CartridgeSB::CartridgeSB(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(size), diff --git a/src/emucore/CartSB.hxx b/src/emucore/CartSB.hxx index 0f53c59b5..c29559b7f 100644 --- a/src/emucore/CartSB.hxx +++ b/src/emucore/CartSB.hxx @@ -46,7 +46,7 @@ class CartridgeSB : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeSB(const BytePtr& image, uInt32 size, const string& md5, + CartridgeSB(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeSB() = default; @@ -152,7 +152,7 @@ class CartridgeSB : public Cartridge private: // The 128-256K ROM image and size of the cartridge - BytePtr myImage; + ByteBuffer myImage; uInt32 mySize; // Indicates the offset into the ROM image (aligns to current bank) diff --git a/src/emucore/CartUA.cxx b/src/emucore/CartUA.cxx index bd57f4d92..ec6923edb 100644 --- a/src/emucore/CartUA.cxx +++ b/src/emucore/CartUA.cxx @@ -19,7 +19,7 @@ #include "CartUA.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeUA::CartridgeUA(const BytePtr& image, uInt32 size, +CartridgeUA::CartridgeUA(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myBankOffset(0) diff --git a/src/emucore/CartUA.hxx b/src/emucore/CartUA.hxx index aaab82390..d1d85e0cc 100644 --- a/src/emucore/CartUA.hxx +++ b/src/emucore/CartUA.hxx @@ -45,7 +45,7 @@ class CartridgeUA : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeUA(const BytePtr& image, uInt32 size, const string& md5, + CartridgeUA(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeUA() = default; diff --git a/src/emucore/CartWD.cxx b/src/emucore/CartWD.cxx index 66f638f1a..1391ac0d9 100644 --- a/src/emucore/CartWD.cxx +++ b/src/emucore/CartWD.cxx @@ -21,7 +21,7 @@ #include "CartWD.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeWD::CartridgeWD(const BytePtr& image, uInt32 size, +CartridgeWD::CartridgeWD(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), mySize(std::min(8195u, size)), diff --git a/src/emucore/CartWD.hxx b/src/emucore/CartWD.hxx index 061ad5ac1..fee93ce30 100644 --- a/src/emucore/CartWD.hxx +++ b/src/emucore/CartWD.hxx @@ -74,7 +74,7 @@ class CartridgeWD : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeWD(const BytePtr& image, uInt32 size, const string& md5, + CartridgeWD(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeWD() = default; diff --git a/src/emucore/CartX07.cxx b/src/emucore/CartX07.cxx index 9a0b3aff8..fe2104e3f 100644 --- a/src/emucore/CartX07.cxx +++ b/src/emucore/CartX07.cxx @@ -21,7 +21,7 @@ #include "CartX07.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeX07::CartridgeX07(const BytePtr& image, uInt32 size, +CartridgeX07::CartridgeX07(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings) : Cartridge(settings, md5), myCurrentBank(0) diff --git a/src/emucore/CartX07.hxx b/src/emucore/CartX07.hxx index 8c9e4babe..81959a79b 100644 --- a/src/emucore/CartX07.hxx +++ b/src/emucore/CartX07.hxx @@ -55,7 +55,7 @@ class CartridgeX07 : public Cartridge @param md5 The md5sum of the ROM image @param settings A reference to the various settings (read-only) */ - CartridgeX07(const BytePtr& image, uInt32 size, const string& md5, + CartridgeX07(const ByteBuffer& image, uInt32 size, const string& md5, const Settings& settings); virtual ~CartridgeX07() = default; diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index 244add8bd..77654edbe 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -159,7 +159,7 @@ bool FilesystemNode::rename(const string& newfile) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 FilesystemNode::read(BytePtr& image) const +uInt32 FilesystemNode::read(ByteBuffer& image) const { uInt32 size = 0; diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index c880cd4d8..408bed559 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -243,7 +243,7 @@ class FilesystemNode * This method can throw exceptions, and should be used inside * a try-catch block. */ - uInt32 read(BytePtr& buffer) const; + uInt32 read(ByteBuffer& buffer) const; /** * The following methods are almost exactly the same as the various @@ -391,7 +391,7 @@ class AbstractFSNode * This method can throw exceptions, and should be used inside * a try-catch block. */ - virtual uInt32 read(BytePtr& buffer) const { return 0; } + virtual uInt32 read(ByteBuffer& buffer) const { return 0; } /** * The parent node of this directory. diff --git a/src/emucore/M6532.hxx b/src/emucore/M6532.hxx index 81d9ee8a7..f6330cba4 100644 --- a/src/emucore/M6532.hxx +++ b/src/emucore/M6532.hxx @@ -123,14 +123,12 @@ class M6532 : public Device */ void updateEmulation(); - #ifdef __LIB_RETRO__ /** Get a pointer to the RAM contents. @return Pointer to RAM array. */ - uInt8* getRAM() { return myRAM; } - #endif + const uInt8* getRAM() const { return myRAM; } private: @@ -221,11 +219,11 @@ class M6532 : public Device #ifdef DEBUGGER_SUPPORT // The arrays containing information about every byte of RIOT // indicating whether and how (RW) it is used. - BytePtr myRAMAccessBase; - BytePtr myStackAccessBase; - BytePtr myIOAccessBase; + ByteBuffer myRAMAccessBase; + ByteBuffer myStackAccessBase; + ByteBuffer myIOAccessBase; // The array used to skip the first ZP access tracking - BytePtr myZPAccessDelay; + ByteBuffer myZPAccessDelay; static constexpr uInt16 RAM_SIZE = 0x80, RAM_MASK = RAM_SIZE - 1, diff --git a/src/emucore/MD5.cxx b/src/emucore/MD5.cxx index 43c92a676..dbdf1c654 100644 --- a/src/emucore/MD5.cxx +++ b/src/emucore/MD5.cxx @@ -307,7 +307,7 @@ static void Decode(uInt32* output, const uInt8* input, uInt32 len) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string hash(const BytePtr& buffer, uInt32 length) +string hash(const ByteBuffer& buffer, uInt32 length) { return hash(buffer.get(), length); } @@ -336,7 +336,7 @@ string hash(const uInt8* buffer, uInt32 length) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string hash(const FilesystemNode& node) { - BytePtr image; + ByteBuffer image; uInt32 size = 0; try { diff --git a/src/emucore/MD5.hxx b/src/emucore/MD5.hxx index 760da598f..199ae6da4 100644 --- a/src/emucore/MD5.hxx +++ b/src/emucore/MD5.hxx @@ -32,7 +32,7 @@ namespace MD5 { @param length The length of the message @return The message-digest */ -string hash(const BytePtr& buffer, uInt32 length); +string hash(const ByteBuffer& buffer, uInt32 length); string hash(const uInt8* buffer, uInt32 length); /** diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 24d2895d0..a8201ffbb 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -30,6 +30,10 @@ #include "CheatManager.hxx" #endif +#ifdef SQLITE_SUPPORT + #include "KeyValueRepositorySqlite.hxx" +#endif + #include "FSNode.hxx" #include "MD5.hxx" #include "Cart.hxx" @@ -55,6 +59,9 @@ #include "DispatchResult.hxx" #include "EmulationWorker.hxx" #include "AudioSettings.hxx" +#include "repository/KeyValueRepositoryNoop.hxx" +#include "repository/KeyValueRepositoryConfigfile.hxx" + #include "OSystem.hxx" @@ -115,9 +122,13 @@ bool OSystem::create() << " Features: " << myFeatures << endl << " " << myBuildInfo << endl << endl << "Base directory: '" - << FilesystemNode(myBaseDir).getShortPath() << "'" << endl + << FilesystemNode(myBaseDir).getShortPath() << "'" << endl; + + if (!myConfigFile.empty()) buf << "Configuration file: '" - << FilesystemNode(myConfigFile).getShortPath() << "'" << endl + << FilesystemNode(myConfigFile).getShortPath() << "'" << endl; + + buf << "User game properties: '" << FilesystemNode(myPropertiesFile).getShortPath() << "'" << endl; logMessage(buf.str(), 1); @@ -182,7 +193,7 @@ void OSystem::loadConfig(const Settings::Options& options) if(!node.isDirectory()) node.makeDir(); myBaseDir = node.getPath(); - myConfigFile = FilesystemNode(myConfigFile).getPath(); + if (!myConfigFile.empty()) myConfigFile = FilesystemNode(myConfigFile).getPath(); FilesystemNode save(myDefaultSaveDir); if(!save.isDirectory()) @@ -194,8 +205,10 @@ void OSystem::loadConfig(const Settings::Options& options) load.makeDir(); myDefaultLoadDir = load.getShortPath(); + mySettings->setRepository(createSettingsRepository()); + logMessage("Loading config options ...", 2); - mySettings->load(configFile(), options); + mySettings->load(options); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -209,7 +222,7 @@ void OSystem::saveConfig() } logMessage("Saving config options ...", 2); - mySettings->save(configFile()); + mySettings->save(); if(myPropSet && myPropSet->save(myPropertiesFile)) logMessage("Saving properties set ...", 2); @@ -473,7 +486,7 @@ unique_ptr OSystem::openConsole(const FilesystemNode& romfile, string& unique_ptr console; // Open the cartridge image and read it in - BytePtr image; + ByteBuffer image; uInt32 size = 0; if((image = openROM(romfile, md5, size)) != nullptr) { @@ -552,14 +565,14 @@ void OSystem::closeConsole() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -BytePtr OSystem::openROM(const FilesystemNode& rom, string& md5, uInt32& size) +ByteBuffer OSystem::openROM(const FilesystemNode& rom, string& md5, uInt32& size) { // This method has a documented side-effect: // It not only loads a ROM and creates an array with its contents, // but also adds a properties entry if the one for the ROM doesn't // contain a valid name - BytePtr image; + ByteBuffer image; if((size = rom.read(image)) == 0) return nullptr; @@ -734,6 +747,19 @@ void OSystem::mainLoop() #endif } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +shared_ptr OSystem::createSettingsRepository() +{ + #ifdef SQLITE_SUPPORT + return make_shared(myBaseDir, "settings"); + #else + if (myConfigFile.empty()) + return make_shared(); + + return make_shared(myConfigFile); + #endif +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string OSystem::ourOverrideBaseDir = ""; bool OSystem::ourOverrideBaseDirWithApp = false; diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index 8c8f0dbc0..0f288c453 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -50,6 +50,7 @@ class AudioSettings; #include "FpsMeter.hxx" #include "Settings.hxx" #include "bspf.hxx" +#include "repository/KeyValueRepository.hxx" /** This class provides an interface for accessing operating system specific @@ -256,13 +257,6 @@ class OSystem */ const string& cheatFile() const { return myCheatFile; } - /** - This method should be called to get the full path of the config file. - - @return String representing the full path of the config filename. - */ - const string& configFile() const { return myConfigFile; } - /** This method should be called to get the full path of the (optional) palette file. @@ -298,7 +292,7 @@ class OSystem @return Unique pointer to the array */ - BytePtr openROM(const FilesystemNode& rom, string& md5, uInt32& size); + ByteBuffer openROM(const FilesystemNode& rom, string& md5, uInt32& size); /** Creates a new game console from the specified romfile, and correctly @@ -423,6 +417,9 @@ class OSystem virtual void stateChanged(EventHandlerState state) { } protected: + + virtual shared_ptr createSettingsRepository(); + ////////////////////////////////////////////////////////////////////// // The following methods are system-specific and *must* be // implemented in derived classes. diff --git a/src/emucore/ProfilingRunner.cxx b/src/emucore/ProfilingRunner.cxx index 8764d1bcd..a0e8ce7ca 100644 --- a/src/emucore/ProfilingRunner.cxx +++ b/src/emucore/ProfilingRunner.cxx @@ -102,7 +102,7 @@ bool ProfilingRunner::runOne(const ProfilingRun run) return false; } - BytePtr image; + ByteBuffer image; uInt32 size = imageFile.read(image); if (size == 0) { cout << "ERROR: unable to read " << run.romFile << endl; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index dcfed0474..8b6851fb8 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -26,10 +26,13 @@ #endif #include "Settings.hxx" +#include "repository/KeyValueRepositoryNoop.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Settings::Settings() { + myRespository = make_shared(); + // Video-related options setPermanent("video", ""); setPermanent("speed", "1.0"); @@ -191,16 +194,17 @@ Settings::Settings() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Settings::load(const string& cfgfile, const Options& options) +void Settings::setRepository(shared_ptr repository) { - // First load from the platform-specific config file - // Different ports may override this functionality - if(!loadConfigFile(cfgfile)) - { - // FIXME - make logger available everywhere - // myOSystem.logMessage("ERROR: Couldn't load settings file", 0); - cout << "ERROR: Couldn't load settings file" << endl; - } + myRespository = repository; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Settings::load(const Options& options) +{ + Options fromFile = myRespository->load(); + for (const auto& opt: fromFile) + setValue(opt.first, opt.second); // Apply commandline options, which override those from settings file for(const auto& opt: options) @@ -212,14 +216,9 @@ void Settings::load(const string& cfgfile, const Options& options) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Settings::save(const string& cfgfile) const +void Settings::save() { - if(!saveConfigFile(cfgfile)) - { - // FIXME - make logger available everywhere - // myOSystem.logMessage("ERROR: Couldn't save settings file", 0); - cout << "ERROR: Couldn't save settings file" << endl; - } + myRespository->save(myPermanentSettings); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -600,73 +599,6 @@ void Settings::setValue(const string& key, const Variant& value) myTemporarySettings[key] = value; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Settings::loadConfigFile(const string& cfgfile) -{ - string line, key, value; - string::size_type equalPos, garbage; - - ifstream in(cfgfile); - if(!in || !in.is_open()) - return false; - - while(getline(in, line)) - { - // Strip all whitespace and tabs from the line - while((garbage = line.find("\t")) != string::npos) - line.erase(garbage, 1); - - // Ignore commented and empty lines - if((line.length() == 0) || (line[0] == ';')) - continue; - - // Search for the equal sign and discard the line if its not found - if((equalPos = line.find("=")) == string::npos) - continue; - - // Split the line into key/value pairs and trim any whitespace - key = trim(line.substr(0, equalPos)); - value = trim(line.substr(equalPos + 1, line.length() - key.length() - 1)); - - // Skip absent key - if(key.length() == 0) - continue; - - // Only settings which have been previously set are valid - setValue(key, value); - } - return true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Settings::saveConfigFile(const string& cfgfile) const -{ - ofstream out(cfgfile); - if(!out || !out.is_open()) - return false; - - out << "; Stella configuration file" << endl - << ";" << endl - << "; Lines starting with ';' are comments and are ignored." << endl - << "; Spaces and tabs are ignored." << endl - << ";" << endl - << "; Format MUST be as follows:" << endl - << "; command = value" << endl - << ";" << endl - << "; Commands are the same as those specified on the commandline," << endl - << "; without the '-' character." << endl - << ";" << endl - << "; Values are the same as those allowed on the commandline." << endl - << "; Boolean values are specified as 1 (or true) and 0 (or false)" << endl - << ";" << endl; - - // Write out each of the key and value pairs - for(const auto& s: myPermanentSettings) - out << s.first << " = " << s.second << endl; - - return true; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Settings::setPermanent(const string& key, const Variant& value) { diff --git a/src/emucore/Settings.hxx b/src/emucore/Settings.hxx index bb62634a9..fecea763a 100644 --- a/src/emucore/Settings.hxx +++ b/src/emucore/Settings.hxx @@ -22,6 +22,7 @@ #include "Variant.hxx" #include "bspf.hxx" +#include "repository/KeyValueRepository.hxx" /** This class provides an interface for accessing all configurable options, @@ -56,21 +57,22 @@ class Settings */ void usage() const; + void setRepository(shared_ptr repository); + /** This method is called to load settings from the settings file, and apply commandline options specified by the given parameter. - @param cfgfile The full path to the configuration file @param options A list of options that overrides ones in the settings file */ - void load(const string& cfgfile, const Options& options); + void load(const Options& options); /** This method is called to save the current settings to the settings file. */ - void save(const string& cfgfile) const; + void save(); /** Get the value assigned to the specified key. @@ -110,28 +112,6 @@ class Settings void setPermanent(const string& key, const Variant& value); void setTemporary(const string& key, const Variant& value); - /** - This method will be called to load the settings from the - platform-specific settings file. Since different ports can have - different behaviour here, we mark it as virtual so derived - classes can override as needed. - - @param cfgfile The full path to the configuration file - @return False on any error, else true - */ - virtual bool loadConfigFile(const string& cfgfile); - - /** - This method will be called to save the current settings to the - platform-specific settings file. Since different ports can have - different behaviour here, we mark it as virtual so derived - classes can override as needed. - - @param cfgfile The full path to the configuration file - @return False on any error, else true - */ - virtual bool saveConfigFile(const string& cfgfile) const; - // Trim leading and following whitespace from a string static string trim(const string& str) { @@ -162,6 +142,8 @@ class Settings // program exit. Options myTemporarySettings; + shared_ptr myRespository; + private: // Following constructors and assignment operators not supported Settings(const Settings&) = delete; diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index 722a47f33..1a1c15818 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -889,10 +889,10 @@ class TIA : public Device #ifdef DEBUGGER_SUPPORT // The arrays containing information about every byte of TIA // indicating whether and how (RW) it is used. - BytePtr myAccessBase; + ByteBuffer myAccessBase; // The array used to skip the first two TIA access trackings - BytePtr myAccessDelay; + ByteBuffer myAccessDelay; #endif // DEBUGGER_SUPPORT static constexpr uInt16 diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index ec481d5e3..db0e1f6cf 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -419,7 +419,7 @@ void GameInfoDialog::loadControllerProperties(const Properties& props) { bool swapPorts = props.get(PropType::Console_SwapPorts) == "YES"; bool autoDetect = false; - BytePtr image; + ByteBuffer image; string md5 = props.get(PropType::Cart_MD5); uInt32 size = 0; const FilesystemNode& node = FilesystemNode(instance().launcher().selectedRom()); diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 0248b9b2a..6f2a6a1a8 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -137,7 +137,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node) string right = myProperties.get(PropType::Controller_Right); try { - BytePtr image; + ByteBuffer image; string md5 = myProperties.get(PropType::Cart_MD5); uInt32 size = 0; diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index f42f2d1ea..88dedd1e6 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -387,7 +387,7 @@ void StellaSettingsDialog::loadControllerProperties(const Properties& props) if (enable) { bool autoDetect = false; - BytePtr image; + ByteBuffer image; string md5 = props.get(PropType::Cart_MD5); uInt32 size = 0; const FilesystemNode& node = FilesystemNode(instance().launcher().selectedRom()); diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 89c46189b..3f766a4bf 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -33,7 +33,7 @@ Widget::Widget(GuiObject* boss, const GUI::Font& font, : GuiObject(boss->instance(), boss->parent(), boss->dialog(), x, y, w, h), _boss(boss), _font(font), - _id(-1), + _id(0), _flags(0), _hasFocus(false), _bgcolor(kWidColor), diff --git a/src/libretro/FSNodeLIBRETRO.cxx b/src/libretro/FSNodeLIBRETRO.cxx index 90a2dc979..b12305337 100644 --- a/src/libretro/FSNodeLIBRETRO.cxx +++ b/src/libretro/FSNodeLIBRETRO.cxx @@ -84,7 +84,7 @@ AbstractFSNodePtr FilesystemNodeLIBRETRO::getParent() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 FilesystemNodeLIBRETRO::read(BytePtr& image) const +uInt32 FilesystemNodeLIBRETRO::read(ByteBuffer& image) const { image = make_unique(512 * 1024); diff --git a/src/libretro/FSNodeLIBRETRO.hxx b/src/libretro/FSNodeLIBRETRO.hxx index 33182b608..b2790d767 100644 --- a/src/libretro/FSNodeLIBRETRO.hxx +++ b/src/libretro/FSNodeLIBRETRO.hxx @@ -50,7 +50,7 @@ class FilesystemNodeLIBRETRO : public AbstractFSNode bool getChildren(AbstractFSList& list, ListMode mode, bool hidden) const override; AbstractFSNodePtr getParent() const override; - uInt32 read(BytePtr& image) const override; + uInt32 read(ByteBuffer& image) const override; protected: string _displayName; diff --git a/src/libretro/Makefile.common b/src/libretro/Makefile.common index 69937ad58..0b6b4db3a 100644 --- a/src/libretro/Makefile.common +++ b/src/libretro/Makefile.common @@ -12,7 +12,6 @@ SOURCES_CXX := \ $(CORE_DIR)/libretro/FBSurfaceLIBRETRO.cxx \ $(CORE_DIR)/libretro/FrameBufferLIBRETRO.cxx \ $(CORE_DIR)/libretro/OSystemLIBRETRO.cxx \ - $(CORE_DIR)/libretro/SettingsLIBRETRO.cxx \ $(CORE_DIR)/libretro/SoundLIBRETRO.cxx \ $(CORE_DIR)/libretro/StellaLIBRETRO.cxx \ $(CORE_DIR)/common/AudioQueue.cxx \ @@ -28,6 +27,7 @@ SOURCES_CXX := \ $(CORE_DIR)/common/StaggeredLogger.cxx \ $(CORE_DIR)/common/StateManager.cxx \ $(CORE_DIR)/common/TimerManager.cxx \ + $(CORE_DIR)/common/repository/KeyValueRepositoryConfigfile.cxx \ $(CORE_DIR)/common/tv_filters/AtariNTSC.cxx \ $(CORE_DIR)/common/tv_filters/NTSCFilter.cxx \ $(CORE_DIR)/common/ZipHandler.cxx \ diff --git a/src/libretro/OSystemLIBRETRO.cxx b/src/libretro/OSystemLIBRETRO.cxx index 4b5e2c84f..e63de6e96 100644 --- a/src/libretro/OSystemLIBRETRO.cxx +++ b/src/libretro/OSystemLIBRETRO.cxx @@ -24,7 +24,6 @@ void OSystemLIBRETRO::getBaseDirAndConfig(string& basedir, string& cfgfile, bool useappdir, const string& usedir) { basedir = "."; - cfgfile = "."; #if 0 // Check to see if basedir overrides are active diff --git a/src/libretro/SettingsLIBRETRO.hxx b/src/libretro/SettingsLIBRETRO.hxx deleted file mode 100644 index 5e6bdc156..000000000 --- a/src/libretro/SettingsLIBRETRO.hxx +++ /dev/null @@ -1,42 +0,0 @@ -//============================================================================ -// -// SSSS tt lll lll -// SS SS tt ll ll -// SS tttttt eeee ll ll aaaa -// SSSS tt ee ee ll ll aa -// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" -// SS SS tt ee ll ll aa aa -// SSSS ttt eeeee llll llll aaaaa -// -// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony -// and the Stella Team -// -// See the file "License.txt" for information on usage and redistribution of -// this file, and for a DISCLAIMER OF ALL WARRANTIES. -//============================================================================ - -#ifndef SETTINGS_LIBRETRO_HXX -#define SETTINGS_LIBRETRO_HXX - -class OSystem; - -#include "Settings.hxx" - -class SettingsLIBRETRO : public Settings -{ - public: - /** - Create a new LIBRETRO settings object - */ - explicit SettingsLIBRETRO(); - virtual ~SettingsLIBRETRO() = default; - - private: - // Following constructors and assignment operators not supported - SettingsLIBRETRO(const SettingsLIBRETRO&) = delete; - SettingsLIBRETRO(SettingsLIBRETRO&&) = delete; - SettingsLIBRETRO& operator=(const SettingsLIBRETRO&) = delete; - SettingsLIBRETRO& operator=(SettingsLIBRETRO&&) = delete; -}; - -#endif diff --git a/src/libretro/Stella.vcxproj b/src/libretro/Stella.vcxproj index e7d6edce8..1dd82a8b6 100644 --- a/src/libretro/Stella.vcxproj +++ b/src/libretro/Stella.vcxproj @@ -141,7 +141,6 @@ - @@ -158,6 +157,7 @@ + diff --git a/src/libretro/StellaLIBRETRO.cxx b/src/libretro/StellaLIBRETRO.cxx index 54f6129d1..6dfb4d36f 100644 --- a/src/libretro/StellaLIBRETRO.cxx +++ b/src/libretro/StellaLIBRETRO.cxx @@ -158,6 +158,10 @@ void StellaLIBRETRO::destroy() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StellaLIBRETRO::runFrame() { + // write ram updates + for(int lcv = 0; lcv <= 127; lcv++) + myOSystem->console().system().m6532().poke(lcv | 0x80, system_ram[lcv]); + // poll input right at vsync updateInput(); @@ -167,7 +171,8 @@ void StellaLIBRETRO::runFrame() // drain generated audio updateAudio(); - // give user time to respond + // refresh ram copy + memcpy(system_ram, myOSystem->console().system().m6532().getRAM(), 128); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libretro/StellaLIBRETRO.hxx b/src/libretro/StellaLIBRETRO.hxx index 9eb4a0369..c57a18344 100644 --- a/src/libretro/StellaLIBRETRO.hxx +++ b/src/libretro/StellaLIBRETRO.hxx @@ -62,7 +62,7 @@ class StellaLIBRETRO uInt32 getROMSize() { return rom_size; } uInt32 getROMMax() { return 512 * 1024; } - uInt8* getRAM() { return myOSystem->console().system().m6532().getRAM(); } + uInt8* getRAM() { return system_ram; } uInt32 getRAMSize() { return 128; } size_t getStateSize(); @@ -151,7 +151,9 @@ class StellaLIBRETRO uInt32 audio_samples; // (31440 rate / 50 Hz) * 16-bit stereo * 1.25x padding - static const uInt32 audio_buffer_max = (31440 / 50 * 4 * 5) / 4; + const uInt32 audio_buffer_max = (31440 / 50 * 4 * 5) / 4; + + uInt8 system_ram[128]; private: string video_palette; diff --git a/src/libretro/libretro.cxx b/src/libretro/libretro.cxx index 779fb430b..6e78d8012 100644 --- a/src/libretro/libretro.cxx +++ b/src/libretro/libretro.cxx @@ -308,7 +308,7 @@ static void update_variables(bool init = false) setting_phosphor_blend = value; } } - + RETRO_GET("stella_paddle_joypad_sensitivity") { int value = 0; @@ -354,7 +354,7 @@ static bool reset_system() // reset libretro window, apply post-boot settings update_variables(false); - + return true; } diff --git a/src/macos/OSystemMACOS.cxx b/src/macos/OSystemMACOS.cxx index 92bc1e83a..5df230234 100644 --- a/src/macos/OSystemMACOS.cxx +++ b/src/macos/OSystemMACOS.cxx @@ -17,6 +17,7 @@ #include "FSNode.hxx" #include "OSystemMACOS.hxx" +#include "SettingsRepositoryMACOS.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void OSystemMACOS::getBaseDirAndConfig(string& basedir, string& cfgfile, @@ -24,7 +25,6 @@ void OSystemMACOS::getBaseDirAndConfig(string& basedir, string& cfgfile, bool useappdir, const string& usedir) { basedir = "~/Library/Application Support/Stella/"; - cfgfile = "~/Library/Application Support/Stella/stellarc"; // FIXME - actually use this #if 0 // Check to see if basedir overrides are active @@ -40,3 +40,9 @@ void OSystemMACOS::getBaseDirAndConfig(string& basedir, string& cfgfile, FilesystemNode desktop("~/Desktop/"); savedir = loaddir = desktop.isDirectory() ? desktop.getShortPath() : "~/"; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +shared_ptr OSystemMACOS::createSettingsRepository() +{ + return make_shared(); +} diff --git a/src/macos/OSystemMACOS.hxx b/src/macos/OSystemMACOS.hxx index c500a3c50..7426dfc41 100644 --- a/src/macos/OSystemMACOS.hxx +++ b/src/macos/OSystemMACOS.hxx @@ -54,6 +54,10 @@ class OSystemMACOS : public OSystem string& savedir, string& loaddir, bool useappdir, const string& usedir) override; +protected: + + virtual shared_ptr createSettingsRepository() override; + private: // Following constructors and assignment operators not supported OSystemMACOS(const OSystemMACOS&) = delete; diff --git a/src/macos/Preferences.m b/src/macos/Preferences.m deleted file mode 100644 index 69e2dee63..000000000 --- a/src/macos/Preferences.m +++ /dev/null @@ -1,95 +0,0 @@ -//============================================================================ -// -// SSSS tt lll lll -// SS SS tt ll ll -// SS tttttt eeee ll ll aaaa -// SSSS tt ee ee ll ll aa -// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" -// SS SS tt ee ll ll aa aa -// SSSS ttt eeeee llll llll aaaaa -// -// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony -// and the Stella Team -// -// See the file "License.txt" for information on usage and redistribution of -// this file, and for a DISCLAIMER OF ALL WARRANTIES. -//============================================================================ - -#import - -#import "Preferences.h" - -void prefsSetString(const char* key, const char* value) -{ - [[Preferences sharedInstance] setString:key:value]; -} - -void prefsGetString(const char* key, char* value, int size) -{ - [[Preferences sharedInstance] getString:key:value:size]; -} - -void prefsSave(void) -{ - [[Preferences sharedInstance] save]; -} - -@implementation Preferences -{ - NSUserDefaults *defaults; /* Defaults pointer */ -} - -static Preferences *sharedInstance = nil; - -+ (Preferences *)sharedInstance -{ - return sharedInstance ? sharedInstance : [[self alloc] init]; -} - -- (id)init -{ - if (self = [super init]) { - defaults = [NSUserDefaults standardUserDefaults]; - sharedInstance = self; - } - return(self); -} - -- (void)dealloc -{ - if (self == sharedInstance) { - sharedInstance = nil; - } - -} - -- (void)setString:(const char *)key : (const char *)value -{ - @autoreleasepool { - NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; - NSString* theValue = [NSString stringWithCString:value encoding:NSUTF8StringEncoding]; - - [defaults setObject:theValue forKey:theKey]; - } -} - -- (void)getString:(const char *)key : (char *)value : (int)size -{ - @autoreleasepool { - NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; - NSString* theValue = [defaults objectForKey:theKey]; - if (theValue != nil) - strncpy(value, [theValue cStringUsingEncoding: NSUTF8StringEncoding], size); - else - value[0] = 0; - } -} - -- (void)save -{ - @autoreleasepool { - [defaults synchronize]; - } -} - -@end diff --git a/src/macos/SDLMain.m b/src/macos/SDLMain.m index 220f03197..f7e405c18 100644 --- a/src/macos/SDLMain.m +++ b/src/macos/SDLMain.m @@ -5,7 +5,6 @@ #import "SDL.h" #import "SDLMain.h" -#import "Preferences.h" #define SDL_main stellaMain extern int stellaMain(int argc, char* argv[]); @@ -158,8 +157,6 @@ static int IsFinderLaunch(const int argc, char **argv) // Main entry point to executable - should *not* be SDL_main! int main (int argc, char* argv[]) { - static Preferences *myPrefs; - // Copy the arguments into a global variable // This is passed if we are launched by double-clicking if (IsFinderLaunch(argc, argv)) @@ -179,8 +176,6 @@ int main (int argc, char* argv[]) gFinderLaunch = NO; } - myPrefs = [Preferences sharedInstance]; - NSApplicationMain (argc, (const char**)argv); return 0; diff --git a/src/macos/SettingsMACOS.cxx b/src/macos/SettingsMACOS.cxx deleted file mode 100644 index b8134e32b..000000000 --- a/src/macos/SettingsMACOS.cxx +++ /dev/null @@ -1,63 +0,0 @@ -//============================================================================ -// -// SSSS tt lll lll -// SS SS tt ll ll -// SS tttttt eeee ll ll aaaa -// SSSS tt ee ee ll ll aa -// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" -// SS SS tt ee ll ll aa aa -// SSSS ttt eeeee llll llll aaaaa -// -// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony -// and the Stella Team -// -// See the file "License.txt" for information on usage and redistribution of -// this file, and for a DISCLAIMER OF ALL WARRANTIES. -//============================================================================ - -// TODO - Fix this code so that we don't need access to getPermanentSettings() -// The code should parse the plist file and call setValue on each -// option; it shouldn't need to query the base class for which options -// are valid. - -#include "SettingsMACOS.hxx" - -extern "C" { - void prefsSetString(const char* key, const char* value); - void prefsGetString(const char* key, char* value, int size); - void prefsSave(void); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SettingsMACOS::SettingsMACOS() - : Settings() -{ -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool SettingsMACOS::loadConfigFile(const string&) -{ - string key, value; - char cvalue[4096]; - - // Read key/value pairs from the plist file - for(const auto& s: getPermanentSettings()) - { - prefsGetString(s.first.c_str(), cvalue, 4090); - if(cvalue[0] != 0) - setValue(s.first, cvalue); - } - return true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool SettingsMACOS::saveConfigFile(const string&) const -{ - // Write out each of the key and value pairs - for(const auto& s: getPermanentSettings()) - prefsSetString(s.first.c_str(), s.second.toCString()); - - prefsSave(); - - return true; -} diff --git a/src/macos/SettingsMACOS.hxx b/src/macos/SettingsMACOS.hxx deleted file mode 100644 index a963c4254..000000000 --- a/src/macos/SettingsMACOS.hxx +++ /dev/null @@ -1,58 +0,0 @@ -//============================================================================ -// -// SSSS tt lll lll -// SS SS tt ll ll -// SS tttttt eeee ll ll aaaa -// SSSS tt ee ee ll ll aa -// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" -// SS SS tt ee ll ll aa aa -// SSSS ttt eeeee llll llll aaaaa -// -// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony -// and the Stella Team -// -// See the file "License.txt" for information on usage and redistribution of -// this file, and for a DISCLAIMER OF ALL WARRANTIES. -//============================================================================ - -#ifndef SETTINGS_MACOS_HXX -#define SETTINGS_MACOS_HXX - -#include "Settings.hxx" - -/** - This class defines macOS system-specific settings. - - @author Mark Grebe, Stephen Anthony -*/ -class SettingsMACOS : public Settings -{ - public: - /** - Create a new UNIX settings object - */ - explicit SettingsMACOS(); - virtual ~SettingsMACOS() = default; - - public: - /** - This method should be called to load the current settings from the - standard Mac preferences. - */ - bool loadConfigFile(const string&) override; - - /** - This method should be called to save the current settings to the - standard Mac preferences. - */ - bool saveConfigFile(const string&) const override; - - private: - // Following constructors and assignment operators not supported - SettingsMACOS(const SettingsMACOS&) = delete; - SettingsMACOS(SettingsMACOS&&) = delete; - SettingsMACOS& operator=(const SettingsMACOS&) = delete; - SettingsMACOS& operator=(SettingsMACOS&&) = delete; -}; - -#endif diff --git a/src/libretro/SettingsLIBRETRO.cxx b/src/macos/SettingsRepositoryMACOS.hxx similarity index 67% rename from src/libretro/SettingsLIBRETRO.cxx rename to src/macos/SettingsRepositoryMACOS.hxx index 73122d51c..ff26b6c87 100644 --- a/src/libretro/SettingsLIBRETRO.cxx +++ b/src/macos/SettingsRepositoryMACOS.hxx @@ -15,10 +15,17 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "SettingsLIBRETRO.hxx" +#ifndef SETTINGS_REPOSITORY_MACOS_HXX +#define SETTINGS_REPOSITORY_MACOS_HXX -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SettingsLIBRETRO::SettingsLIBRETRO() - : Settings() +#include "repository/KeyValueRepository.hxx" + +class SettingsRepositoryMACOS : public KeyValueRepository { -} +public: + virtual std::map load(); + + virtual void save(const std::map& values); +}; + +#endif // SETTINGS_REPOSITORY_MACOS_HXX diff --git a/src/macos/SettingsRepositoryMACOS.mm b/src/macos/SettingsRepositoryMACOS.mm new file mode 100644 index 000000000..4cff1aeea --- /dev/null +++ b/src/macos/SettingsRepositoryMACOS.mm @@ -0,0 +1,53 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#import + +#include "SettingsRepositoryMACOS.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +std::map SettingsRepositoryMACOS::load() +{ + std::map values; + + @autoreleasepool { + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + NSArray* keys = [[defaults dictionaryRepresentation] allKeys]; + + for (NSString* key in keys) { + NSString* value = [defaults stringForKey:key]; + if (value != nil) + values[[key UTF8String]] = string([value UTF8String]); + } + } + + return values; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void SettingsRepositoryMACOS::save(const std::map& values) +{ + @autoreleasepool { + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + + for (const auto& pair: values) + [defaults + setObject:[NSString stringWithUTF8String:pair.second.toCString()] + forKey:[NSString stringWithUTF8String:pair.first.c_str()] + ]; + } +} diff --git a/src/macos/stella.xcodeproj/project.pbxproj b/src/macos/stella.xcodeproj/project.pbxproj index eef10c01f..6c0d755b1 100644 --- a/src/macos/stella.xcodeproj/project.pbxproj +++ b/src/macos/stella.xcodeproj/project.pbxproj @@ -67,7 +67,6 @@ 2D91741909BA90380026E9FF /* CartUA.hxx in Headers */ = {isa = PBXBuildFile; fileRef = 2DDBEB7108457B7D00812C11 /* CartUA.hxx */; }; 2D91741A09BA90380026E9FF /* FSNode.hxx in Headers */ = {isa = PBXBuildFile; fileRef = 2DDBEB7308457B7D00812C11 /* FSNode.hxx */; }; 2D91741B09BA90380026E9FF /* OSystem.hxx in Headers */ = {isa = PBXBuildFile; fileRef = 2DDBEB7508457B7D00812C11 /* OSystem.hxx */; }; - 2D91741D09BA90380026E9FF /* Preferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DDBEBE3084582C400812C11 /* Preferences.h */; }; 2D91741F09BA90380026E9FF /* AboutBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D1A6CD4085135F9007CDBA8 /* AboutBox.h */; }; 2D91742009BA90380026E9FF /* ConsoleFont.hxx in Headers */ = {isa = PBXBuildFile; fileRef = 2D9217FA0857CC88001D664B /* ConsoleFont.hxx */; }; 2D91742109BA90380026E9FF /* Font.hxx in Headers */ = {isa = PBXBuildFile; fileRef = 2D9217FC0857CC88001D664B /* Font.hxx */; }; @@ -166,7 +165,6 @@ 2D9174BE09BA90380026E9FF /* CartUA.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 2DDBEB7008457B7D00812C11 /* CartUA.cxx */; }; 2D9174BF09BA90380026E9FF /* FSNode.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 2DDBEB7208457B7D00812C11 /* FSNode.cxx */; }; 2D9174C009BA90380026E9FF /* OSystem.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 2DDBEB7408457B7D00812C11 /* OSystem.cxx */; }; - 2D9174C209BA90380026E9FF /* Preferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 2DDBEBE4084582C400812C11 /* Preferences.m */; }; 2D9174C409BA90380026E9FF /* AboutBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D1A6CD5085135F9007CDBA8 /* AboutBox.m */; }; 2D9174C509BA90380026E9FF /* Font.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 2D9217FB0857CC88001D664B /* Font.cxx */; }; 2D9174C609BA90380026E9FF /* Debugger.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 2D659E2D085D3DD6005D96C8 /* Debugger.cxx */; }; @@ -235,8 +233,6 @@ DC21E5C021CA903E007D0E1A /* OSystemMACOS.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC21E5BA21CA903E007D0E1A /* OSystemMACOS.hxx */; }; DC21E5C121CA903E007D0E1A /* SerialPortMACOS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC21E5BB21CA903E007D0E1A /* SerialPortMACOS.cxx */; }; DC21E5C221CA903E007D0E1A /* SerialPortMACOS.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC21E5BC21CA903E007D0E1A /* SerialPortMACOS.hxx */; }; - DC21E5C321CA903E007D0E1A /* SettingsMACOS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC21E5BD21CA903E007D0E1A /* SettingsMACOS.cxx */; }; - DC21E5C421CA903E007D0E1A /* SettingsMACOS.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC21E5BE21CA903E007D0E1A /* SettingsMACOS.hxx */; }; DC2410E32274BDA8007A4CBF /* MinUICommandDialog.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC2410E12274BDA7007A4CBF /* MinUICommandDialog.hxx */; }; DC2410E42274BDA8007A4CBF /* MinUICommandDialog.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC2410E22274BDA8007A4CBF /* MinUICommandDialog.cxx */; }; DC2874071F8F2278004BF21A /* TrapArray.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC2874061F8F2278004BF21A /* TrapArray.hxx */; }; @@ -649,6 +645,12 @@ E034A5EF209FB25D00C89E9E /* EmulationTiming.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E034A5ED209FB25C00C89E9E /* EmulationTiming.hxx */; }; E0406FB61F81A85400A82AE0 /* AbstractFrameManager.cxx in Sources */ = {isa = PBXBuildFile; fileRef = E0DFDD781F81A358000F3505 /* AbstractFrameManager.cxx */; }; E0406FB81F81A85400A82AE0 /* FrameManager.cxx in Sources */ = {isa = PBXBuildFile; fileRef = E0DFDD7B1F81A358000F3505 /* FrameManager.cxx */; }; + E06508BE2272447200B341AC /* KeyValueRepositoryNoop.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E06508B82272447200B341AC /* KeyValueRepositoryNoop.hxx */; }; + E06508BF2272447200B341AC /* KeyValueRepository.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E06508B92272447200B341AC /* KeyValueRepository.hxx */; }; + E06508C02272447200B341AC /* KeyValueRepositoryConfigfile.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E06508BA2272447200B341AC /* KeyValueRepositoryConfigfile.hxx */; }; + E06508C12272447200B341AC /* KeyValueRepositoryConfigfile.cxx in Sources */ = {isa = PBXBuildFile; fileRef = E06508BB2272447200B341AC /* KeyValueRepositoryConfigfile.cxx */; }; + E06508CA2272493200B341AC /* SettingsRepositoryMACOS.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E06508C82272493200B341AC /* SettingsRepositoryMACOS.hxx */; }; + E06508CB2272493200B341AC /* SettingsRepositoryMACOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = E06508C92272493200B341AC /* SettingsRepositoryMACOS.mm */; }; E0893AF2211B9842008B170D /* HighPass.cxx in Sources */ = {isa = PBXBuildFile; fileRef = E0893AF0211B9841008B170D /* HighPass.cxx */; }; E0893AF3211B9842008B170D /* HighPass.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E0893AF1211B9841008B170D /* HighPass.hxx */; }; E09F413B201E901D004A3391 /* AudioQueue.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E09F4139201E901C004A3391 /* AudioQueue.hxx */; }; @@ -846,8 +848,6 @@ 2DDBEB7308457B7D00812C11 /* FSNode.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = FSNode.hxx; sourceTree = ""; }; 2DDBEB7408457B7D00812C11 /* OSystem.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = OSystem.cxx; sourceTree = ""; }; 2DDBEB7508457B7D00812C11 /* OSystem.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = OSystem.hxx; sourceTree = ""; }; - 2DDBEBE3084582C400812C11 /* Preferences.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Preferences.h; sourceTree = SOURCE_ROOT; }; - 2DDBEBE4084582C400812C11 /* Preferences.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = Preferences.m; sourceTree = SOURCE_ROOT; }; 2DE2DF100627AE07006BEC99 /* Booster.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Booster.cxx; sourceTree = ""; }; 2DE2DF110627AE07006BEC99 /* Booster.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = Booster.hxx; sourceTree = ""; }; 2DE2DF120627AE07006BEC99 /* Cart.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cart.cxx; sourceTree = ""; }; @@ -947,8 +947,6 @@ DC21E5BA21CA903E007D0E1A /* OSystemMACOS.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = OSystemMACOS.hxx; sourceTree = SOURCE_ROOT; }; DC21E5BB21CA903E007D0E1A /* SerialPortMACOS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerialPortMACOS.cxx; sourceTree = SOURCE_ROOT; }; DC21E5BC21CA903E007D0E1A /* SerialPortMACOS.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SerialPortMACOS.hxx; sourceTree = SOURCE_ROOT; }; - DC21E5BD21CA903E007D0E1A /* SettingsMACOS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingsMACOS.cxx; sourceTree = SOURCE_ROOT; }; - DC21E5BE21CA903E007D0E1A /* SettingsMACOS.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SettingsMACOS.hxx; sourceTree = SOURCE_ROOT; }; DC2410E12274BDA7007A4CBF /* MinUICommandDialog.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MinUICommandDialog.hxx; sourceTree = ""; }; DC2410E22274BDA8007A4CBF /* MinUICommandDialog.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MinUICommandDialog.cxx; sourceTree = ""; }; DC2874061F8F2278004BF21A /* TrapArray.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TrapArray.hxx; sourceTree = ""; }; @@ -1361,6 +1359,12 @@ E0306E0B1F93E916003DDD52 /* JitterEmulation.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JitterEmulation.hxx; sourceTree = ""; }; E034A5EC209FB25C00C89E9E /* EmulationTiming.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmulationTiming.cxx; sourceTree = ""; }; E034A5ED209FB25C00C89E9E /* EmulationTiming.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EmulationTiming.hxx; sourceTree = ""; }; + E06508B82272447200B341AC /* KeyValueRepositoryNoop.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KeyValueRepositoryNoop.hxx; sourceTree = ""; }; + E06508B92272447200B341AC /* KeyValueRepository.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KeyValueRepository.hxx; sourceTree = ""; }; + E06508BA2272447200B341AC /* KeyValueRepositoryConfigfile.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KeyValueRepositoryConfigfile.hxx; sourceTree = ""; }; + E06508BB2272447200B341AC /* KeyValueRepositoryConfigfile.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyValueRepositoryConfigfile.cxx; sourceTree = ""; }; + E06508C82272493200B341AC /* SettingsRepositoryMACOS.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SettingsRepositoryMACOS.hxx; sourceTree = ""; }; + E06508C92272493200B341AC /* SettingsRepositoryMACOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SettingsRepositoryMACOS.mm; sourceTree = ""; }; E07C2326226393BD00B78631 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; E0893AF0211B9841008B170D /* HighPass.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HighPass.cxx; path = audio/HighPass.cxx; sourceTree = ""; }; E0893AF1211B9841008B170D /* HighPass.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = HighPass.hxx; path = audio/HighPass.hxx; sourceTree = ""; }; @@ -1405,10 +1409,10 @@ children = ( 2D1A6CD4085135F9007CDBA8 /* AboutBox.h */, 2D1A6CD5085135F9007CDBA8 /* AboutBox.m */, - 2DDBEBE3084582C400812C11 /* Preferences.h */, - 2DDBEBE4084582C400812C11 /* Preferences.m */, F5A47A9D01A0482F01D3D55B /* SDLMain.h */, F5A47A9E01A0483001D3D55B /* SDLMain.m */, + E06508C82272493200B341AC /* SettingsRepositoryMACOS.hxx */, + E06508C92272493200B341AC /* SettingsRepositoryMACOS.mm */, ); name = Classes; sourceTree = ""; @@ -1690,6 +1694,7 @@ DC1BC6652066B4390076F74A /* PKeyboardHandler.hxx */, DCD6FC9111C28C6F005DA767 /* PNGLibrary.cxx */, DCD6FC9211C28C6F005DA767 /* PNGLibrary.hxx */, + E06508B72272447200B341AC /* repository */, DCDDEAC01F5DBF0400C67366 /* RewindManager.cxx */, DCDDEAC11F5DBF0400C67366 /* RewindManager.hxx */, DCA078331F8C1B04008EFEE5 /* SDL_lib.hxx */, @@ -1725,8 +1730,6 @@ DC21E5BA21CA903E007D0E1A /* OSystemMACOS.hxx */, DC21E5BB21CA903E007D0E1A /* SerialPortMACOS.cxx */, DC21E5BC21CA903E007D0E1A /* SerialPortMACOS.hxx */, - DC21E5BD21CA903E007D0E1A /* SettingsMACOS.cxx */, - DC21E5BE21CA903E007D0E1A /* SettingsMACOS.hxx */, ); path = macos; sourceTree = ""; @@ -2232,6 +2235,17 @@ path = tia; sourceTree = ""; }; + E06508B72272447200B341AC /* repository */ = { + isa = PBXGroup; + children = ( + E06508B92272447200B341AC /* KeyValueRepository.hxx */, + E06508BB2272447200B341AC /* KeyValueRepositoryConfigfile.cxx */, + E06508BA2272447200B341AC /* KeyValueRepositoryConfigfile.hxx */, + E06508B82272447200B341AC /* KeyValueRepositoryNoop.hxx */, + ); + path = repository; + sourceTree = ""; + }; E0DFDD731F81A358000F3505 /* frame-manager */ = { isa = PBXGroup; children = ( @@ -2301,6 +2315,7 @@ 2D9173E809BA90380026E9FF /* MD5.hxx in Headers */, 2D9173EA09BA90380026E9FF /* Paddles.hxx in Headers */, 2D9173EB09BA90380026E9FF /* Props.hxx in Headers */, + E06508CA2272493200B341AC /* SettingsRepositoryMACOS.hxx in Headers */, DC5ACB5C1FBFCE8E00A213FD /* DeveloperDialog.hxx in Headers */, 2D9173EC09BA90380026E9FF /* PropsSet.hxx in Headers */, 2D9173ED09BA90380026E9FF /* Random.hxx in Headers */, @@ -2349,7 +2364,6 @@ DCE8B1871E7E03B300189864 /* FrameLayout.hxx in Headers */, 2D91741A09BA90380026E9FF /* FSNode.hxx in Headers */, 2D91741B09BA90380026E9FF /* OSystem.hxx in Headers */, - 2D91741D09BA90380026E9FF /* Preferences.h in Headers */, DC6A18F919B3E65500DEB242 /* CartMDMWidget.hxx in Headers */, 2D91741F09BA90380026E9FF /* AboutBox.h in Headers */, 2D91742009BA90380026E9FF /* ConsoleFont.hxx in Headers */, @@ -2456,7 +2470,9 @@ DCBDDE9F1D6A5F2F009DF1E9 /* Cart3EPlus.hxx in Headers */, DCF467BD0F9399F500B25D7A /* Version.hxx in Headers */, DC2B85E81EF5EF2300379EB9 /* AtariNTSC.hxx in Headers */, + E06508BE2272447200B341AC /* KeyValueRepositoryNoop.hxx in Headers */, DCF467C30F939A1400B25D7A /* CartEF.hxx in Headers */, + E06508C02272447200B341AC /* KeyValueRepositoryConfigfile.hxx in Headers */, DC68F8901FA64C5300F4A2CC /* TIAConstants.hxx in Headers */, DCA82C721FEB4E780059340F /* TimeMachine.hxx in Headers */, DCF467C50F939A1400B25D7A /* CartEFSC.hxx in Headers */, @@ -2533,7 +2549,6 @@ DC71C399221623D9005DE92F /* ControllerDetector.hxx in Headers */, DCAAE5DD1715887B0080BB82 /* CartDebugWidget.hxx in Headers */, DC6DC921205DB879004A5FC3 /* PJoystickHandler.hxx in Headers */, - DC21E5C421CA903E007D0E1A /* SettingsMACOS.hxx in Headers */, DCAAE5DF1715887B0080BB82 /* CartEFSCWidget.hxx in Headers */, DCAAE5E11715887B0080BB82 /* CartEFWidget.hxx in Headers */, DCDFF08220B781B0001227C0 /* DispatchResult.hxx in Headers */, @@ -2549,6 +2564,7 @@ DCAAE5F11715887B0080BB82 /* CartFAWidget.hxx in Headers */, DCAAE5F31715887B0080BB82 /* CartUAWidget.hxx in Headers */, DC676A421729A0B000E4E73D /* Cart3EWidget.hxx in Headers */, + E06508BF2272447200B341AC /* KeyValueRepository.hxx in Headers */, DC676A441729A0B000E4E73D /* Cart4A50Widget.hxx in Headers */, CFE3F6141E84A9CE00A8204E /* CartBUS.hxx in Headers */, DC676A461729A0B000E4E73D /* CartARWidget.hxx in Headers */, @@ -2782,7 +2798,6 @@ 2D9174BF09BA90380026E9FF /* FSNode.cxx in Sources */, DCF3A6FE1DFC75E3008A8AF3 /* TIA.cxx in Sources */, 2D9174C009BA90380026E9FF /* OSystem.cxx in Sources */, - 2D9174C209BA90380026E9FF /* Preferences.m in Sources */, DC53B6AE1F3622DA00AA6BFB /* PointingDevice.cxx in Sources */, 2D9174C409BA90380026E9FF /* AboutBox.m in Sources */, DC96162C1F817830008A2206 /* AmigaMouseWidget.cxx in Sources */, @@ -2795,6 +2810,7 @@ 2D9174CD09BA90380026E9FF /* YaccParser.cxx in Sources */, DC6A18F819B3E65500DEB242 /* CartMDMWidget.cxx in Sources */, DC62E6491960E87B007AEF05 /* SaveKeyWidget.cxx in Sources */, + E06508CB2272493200B341AC /* SettingsRepositoryMACOS.mm in Sources */, 2D9174CE09BA90380026E9FF /* Cart3E.cxx in Sources */, 2D9174CF09BA90380026E9FF /* CpuDebug.cxx in Sources */, 2D9174F109BA90380026E9FF /* InputTextDialog.cxx in Sources */, @@ -2804,6 +2820,7 @@ 2D9174F209BA90380026E9FF /* CheckListWidget.cxx in Sources */, 2D9174F309BA90380026E9FF /* StringListWidget.cxx in Sources */, 2D9174F409BA90380026E9FF /* CommandDialog.cxx in Sources */, + E06508C12272447200B341AC /* KeyValueRepositoryConfigfile.cxx in Sources */, DC2B85E71EF5EF2300379EB9 /* AtariNTSC.cxx in Sources */, 2D9174F509BA90380026E9FF /* CommandMenu.cxx in Sources */, 2D9174F709BA90380026E9FF /* CpuWidget.cxx in Sources */, @@ -2887,7 +2904,6 @@ DC6B2BA611037FF200F199A7 /* DiStella.cxx in Sources */, CFE3F6151E84A9CE00A8204E /* CartCDF.cxx in Sources */, DCA82C711FEB4E780059340F /* TimeMachine.cxx in Sources */, - DC21E5C321CA903E007D0E1A /* SettingsMACOS.cxx in Sources */, DCD3F7C511340AAF00DBA3AE /* Genesis.cxx in Sources */, DCAD60A81152F8BD00BC4184 /* CartDPCPlus.cxx in Sources */, DC5ACB5B1FBFCE8E00A213FD /* DeveloperDialog.cxx in Sources */, diff --git a/src/unix/SettingsUNIX.hxx b/src/unix/SettingsUNIX.hxx deleted file mode 100644 index 71acbb101..000000000 --- a/src/unix/SettingsUNIX.hxx +++ /dev/null @@ -1,45 +0,0 @@ -//============================================================================ -// -// SSSS tt lll lll -// SS SS tt ll ll -// SS tttttt eeee ll ll aaaa -// SSSS tt ee ee ll ll aa -// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" -// SS SS tt ee ll ll aa aa -// SSSS ttt eeeee llll llll aaaaa -// -// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony -// and the Stella Team -// -// See the file "License.txt" for information on usage and redistribution of -// this file, and for a DISCLAIMER OF ALL WARRANTIES. -//============================================================================ - -#ifndef SETTINGS_UNIX_HXX -#define SETTINGS_UNIX_HXX - -#include "Settings.hxx" - -/** - This class defines UNIX-like OS's (Linux) system specific settings. - - @author Stephen Anthony -*/ -class SettingsUNIX : public Settings -{ - public: - /** - Create a new UNIX settings object - */ - explicit SettingsUNIX(); - virtual ~SettingsUNIX() = default; - - private: - // Following constructors and assignment operators not supported - SettingsUNIX(const SettingsUNIX&) = delete; - SettingsUNIX(SettingsUNIX&&) = delete; - SettingsUNIX& operator=(const SettingsUNIX&) = delete; - SettingsUNIX& operator=(SettingsUNIX&&) = delete; -}; - -#endif diff --git a/src/unix/module.mk b/src/unix/module.mk index 052b37a8c..b01b04ffc 100644 --- a/src/unix/module.mk +++ b/src/unix/module.mk @@ -3,11 +3,10 @@ MODULE := src/unix MODULE_OBJS := \ src/unix/FSNodePOSIX.o \ src/unix/OSystemUNIX.o \ - src/unix/SerialPortUNIX.o \ - src/unix/SettingsUNIX.o + src/unix/SerialPortUNIX.o MODULE_DIRS += \ src/unix -# Include common rules +# Include common rules include $(srcdir)/common.rules diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index 39a8f8db1..85efc36f2 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -381,6 +381,7 @@ + @@ -512,7 +513,6 @@ - @@ -1076,6 +1076,9 @@ + + + @@ -1237,7 +1240,6 @@ - diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index 632cfb678..93adee9d2 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -64,6 +64,12 @@ {fb5429b5-4ffb-4574-a98d-54ba865e4199} + + {6960ed3f-a5e0-4af6-af20-e9308167ae63} + + + {1aab46fa-ee39-415d-9e41-d5ad3ee14ce7} + @@ -81,9 +87,6 @@ Source Files - - Source Files - Source Files @@ -963,6 +966,9 @@ Source Files\gui + + Source Files\repository + @@ -983,9 +989,6 @@ Header Files - - Header Files - Header Files @@ -1970,6 +1973,15 @@ Header Files\gui + + Header Files\repository + + + Header Files\repository + + + Header Files\repository +