Getting memory pointer is a const now

This commit is contained in:
Sergio Martin 2024-01-29 19:47:52 +01:00
parent beaa6bfd25
commit 9209d17d48
6 changed files with 11 additions and 10 deletions

View File

@ -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;

@ -1 +1 @@
Subproject commit c41d8eff29132553e374abc15108c552b6d4a942
Subproject commit e35054dc19c94fcac9b8cfd2fbf5b33f8e1dfbde

View File

@ -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
{

View File

@ -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

View File

@ -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); }

View File

@ -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());
}