32size_t ESE_RAM::getSramSize()
const
35 if (sramSize !=
one_of(1024u, 512u, 256u, 128u)) {
38 " should be 128, 256, 512 or 1024kB and not ",
41 return sramSize * 1024;
46 , sram(getName() +
" SRAM", getSramSize(), config)
47 , romBlockDebug(*this, mapped, 0x4000, 0x8000, 13)
48 , blockMask(
narrow<
byte>((sram.size() / 0x2000) - 1))
50 reset(EmuTime::dummy());
62 if ((0x4000 <= address) && (address < 0xC000)) {
63 unsigned page = (address / 8192) - 2;
64 word addr = address & 0x1FFF;
65 return sram[8192 * mapped[page] + addr];
73 if ((0x4000 <= address) && (address < 0xC000)) {
74 unsigned page = (address / 8192) - 2;
76 return &sram[8192 * mapped[page] + address];
84 if ((0x6000 <= address) && (address < 0x8000)) {
85 byte region = ((address >> 11) & 3);
86 setSRAM(region, value);
87 }
else if ((0x4000 <= address) && (address < 0xC000)) {
88 unsigned page = (address / 8192) - 2;
90 if (isWriteable[page]) {
91 sram.
write(8192 * mapped[page] + address, value);
98 if ((0x6000 <= address) && (address < 0x8000)) {
100 }
else if ((0x4000 <= address) && (address < 0xC000)) {
101 unsigned page = (address / 8192) - 2;
102 if (isWriteable[page]) {
109void ESE_RAM::setSRAM(
unsigned region,
byte block)
113 isWriteable[region] = (block & 0x80) != 0;
114 mapped[region] = block & blockMask;
117template<
typename Archive>
120 ar.template serializeBase<MSXDevice>(*
this);
121 ar.serialize(
"SRAM", sram,
122 "isWriteable", isWriteable,
#define REGISTER_MSXDEVICE(CLASS, NAME)
void serialize(Archive &ar, unsigned version)
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
void reset(EmuTime::param time) override
This method is called on reset.
ESE_RAM(const DeviceConfig &config)
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
static std::array< byte, 0x10000 > unmappedRead
virtual const std::string & getName() const
Returns a human-readable name for this device.
static std::array< byte, 0x10000 > unmappedWrite
void invalidateDeviceRWCache()
Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is lo...
const XMLElement & getDeviceConfig() const
Get the configuration section for this device.
void write(size_t addr, byte value)
int getChildDataAsInt(std::string_view childName, int defaultValue) const
This file implemented 3 utility functions:
uint8_t byte
8 bit unsigned integer
uint16_t word
16 bit unsigned integer
constexpr To narrow(From from) noexcept
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)