33 static std::unique_ptr<SRAM> createSRAM(
34 const DeviceConfig& config,
const std::string& name)
36 unsigned sramSize = config.getChildDataAsInt(
"sramsize", 256);
37 if (sramSize != 1024 && sramSize != 512 && sramSize != 256 && sramSize != 128) {
39 "SRAM size for " << name <<
40 " should be 128, 256, 512 or 1024kB and not " <<
44 return make_unique<SRAM>(name +
" SRAM", sramSize, config);
49 , sram(createSRAM(config,
getName()))
51 *this, mapped, 0x4000, 0x8000, 13))
52 , blockMask((sram->getSize() / 8192) - 1)
63 for (
int i = 0; i < 4; ++i) {
71 if ((0x4000 <= address) && (address < 0xC000)) {
72 unsigned page = (address / 8192) - 2;
73 word addr = address & 0x1FFF;
74 result = (*sram)[8192 * mapped[page] + addr];
83 if ((0x4000 <= address) && (address < 0xC000)) {
84 unsigned page = (address / 8192) - 2;
86 return &(*sram)[8192 * mapped[page] + address];
94 if ((0x6000 <= address) && (address < 0x8000)) {
95 byte region = ((address >> 11) & 3);
96 setSRAM(region, value);
97 }
else if ((0x4000 <= address) && (address < 0xC000)) {
98 unsigned page = (address / 8192) - 2;
100 if (isWriteable[page]) {
101 sram->write(8192 * mapped[page] + address, value);
108 if ((0x6000 <= address) && (address < 0x8000)) {
110 }
else if ((0x4000 <= address) && (address < 0xC000)) {
111 unsigned page = (address / 8192) - 2;
112 if (isWriteable[page]) {
119 void ESE_RAM::setSRAM(
unsigned region,
byte block)
123 isWriteable[region] = (block & 0x80) != 0;
124 mapped[region] = block & blockMask;
127 template<
typename Archive>
130 ar.template serializeBase<MSXDevice>(*this);
131 ar.serialize(
"SRAM", *sram);
132 ar.serialize(
"isWriteable", isWriteable);
133 ar.serialize(
"mapped", mapped);