diff --git a/source/logger.hpp b/source/logger.hpp index 3c19646..1ad1098 100644 --- a/source/logger.hpp +++ b/source/logger.hpp @@ -5,14 +5,19 @@ #include // If we use NCurses, we need to use the appropriate printing function -#ifdef NCURSES - #include - #define LOG printw -#else - #define LOG printf +#ifndef LOG + #ifdef NCURSES + #include + #define LOG printw + #else + #define LOG printf + #endif +#endif + +#ifndef EXIT_WITH_ERROR + #define EXIT_WITH_ERROR(...) exitWithError(__FILE__, __LINE__, __VA_ARGS__) #endif -#define EXIT_WITH_ERROR(...) exitWithError(__FILE__, __LINE__, __VA_ARGS__) inline void exitWithError [[noreturn]] (const char *fileName, const int lineNumber, const char *format, ...) { char *outstr = 0; diff --git a/source/nesInstanceBase.hpp b/source/nesInstanceBase.hpp index 5daad89..2f9a06f 100644 --- a/source/nesInstanceBase.hpp +++ b/source/nesInstanceBase.hpp @@ -3,10 +3,6 @@ #include "logger.hpp" #include "controller.hpp" -#define _LOW_MEM_SIZE 0x800 -#define _HIGH_MEM_SIZE 0x2000 -#define _NAMETABLES_MEM_SIZE 0x1000 - // Size of image generated in graphics buffer static const uint16_t image_width = 256; static const uint16_t image_height = 240; @@ -95,7 +91,8 @@ class NESInstanceBase // Virtual functions - virtual uint8_t *getLowMem() = 0; + virtual uint8_t *getLowMem() const = 0; + virtual size_t getLowMemSize() const = 0; virtual void serializeState(uint8_t *state) const = 0; virtual void deserializeState(const uint8_t *state) = 0; diff --git a/source/quickNES/core b/source/quickNES/core index c41d8ef..e35054d 160000 --- a/source/quickNES/core +++ b/source/quickNES/core @@ -1 +1 @@ -Subproject commit c41d8eff29132553e374abc15108c552b6d4a942 +Subproject commit e35054dc19c94fcac9b8cfd2fbf5b33f8e1dfbde diff --git a/source/quickNES/nesInstance.hpp b/source/quickNES/nesInstance.hpp index 6a26d49..0c900e6 100644 --- a/source/quickNES/nesInstance.hpp +++ b/source/quickNES/nesInstance.hpp @@ -23,7 +23,8 @@ class NESInstance final : public NESInstanceBase register_mapper_70(); } - uint8_t *getLowMem() override { return _nes.low_mem(); }; + uint8_t *getLowMem() const override { return _nes.low_mem(); }; + size_t getLowMemSize() const override { return 0x800; }; void serializeState(uint8_t *state) const override { diff --git a/source/quickerNES/core/emu.hpp b/source/quickerNES/core/emu.hpp index 3ed140a..eb79718 100644 --- a/source/quickerNES/core/emu.hpp +++ b/source/quickerNES/core/emu.hpp @@ -204,7 +204,9 @@ class Emu { low_mem_size = 0x800 }; - uint8_t *low_mem() { return emu.low_mem; } + + uint8_t *get_low_mem() const { return (uint8_t*)emu.low_mem; } + size_t get_low_mem_size() const { return low_mem_size; } // Optional 8K memory enum diff --git a/source/quickerNES/nesInstance.hpp b/source/quickerNES/nesInstance.hpp index bfc72d4..4b1e618 100644 --- a/source/quickerNES/nesInstance.hpp +++ b/source/quickerNES/nesInstance.hpp @@ -9,7 +9,8 @@ class NESInstance final : public NESInstanceBase { public: - uint8_t *getLowMem() override { return _nes.low_mem(); }; + uint8_t *getLowMem() const override { return _nes.get_low_mem(); }; + size_t getLowMemSize() const override { return _nes.get_low_mem_size(); }; void serializeState(uint8_t *state) const override { _nes.serializeState(state); } void deserializeState(const uint8_t *state) override { _nes.deserializeState(state); } diff --git a/source/utils.hpp b/source/utils.hpp index c9f3319..97903ad 100644 --- a/source/utils.hpp +++ b/source/utils.hpp @@ -169,5 +169,5 @@ inline hash_t calculateMetroHash(uint8_t *data, size_t size) inline hash_t calculateStateHash(NESInstance* nes) { - return calculateMetroHash(nes->getLowMem(), _LOW_MEM_SIZE); + return calculateMetroHash(nes->getLowMem(), nes->getLowMemSize()); } \ No newline at end of file