36 sram = std::make_unique<SRAM>(
getName() +
" SRAM", size, config);
37 reset(EmuTime::dummy());
44 for (
auto i :
xrange(2, 6)) {
55 auto bank = narrow<byte>(address /
BANK_SIZE);
56 if ((1 << bank) & sramEnabled) {
68 auto bank = narrow<byte>(address /
BANK_SIZE);
69 if ((1 << bank) & sramEnabled) {
73 return &(*sram)[addr];
81 if ((0x6000 <= address) && (address < 0x8000)) {
83 byte region = ((address >> 11) & 3) + 2;
84 if (value & sramEnableBit) {
86 sramEnabled |= (1 << region) & sramPages;
87 sramBlock[region] = value & mask;
91 sramEnabled &=
byte(~(1 << region));
97 auto bank = narrow<byte>(address /
BANK_SIZE);
98 if ((1 << bank) & sramEnabled) {
100 auto addr = (sramBlock[bank] *
BANK_SIZE)
102 sram->write(addr, value);
109 if ((0x6000 <= address) && (address < 0x8000)) {
112 }
else if ((1 << (address /
BANK_SIZE)) & sramEnabled) {
120template<
typename Archive>
123 ar.template serializeBase<Rom8kBBlocks>(*
this);
124 ar.serialize(
"sramEnabled", sramEnabled,
125 "sramBlock", sramBlock);
#define REGISTER_MSXDEVICE(CLASS, NAME)
void invalidateDeviceRCache()
void invalidateDeviceWCache()
virtual const std::string & getName() const
Returns a human-readable name for this device.
static std::array< byte, 0x10000 > unmappedWrite
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
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.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
void serialize(Archive &ar, unsigned version)
void reset(EmuTime::param time) override
This method is called on reset.
RomAscii8_8(const DeviceConfig &config, Rom &&rom, SubType subType)
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void setBank(unsigned region, const byte *adr, byte block)
Sets the memory visible for reading in a certain region.
void setUnmapped(unsigned region)
Select 'unmapped' memory for this region.
std::unique_ptr< SRAM > sram
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
static constexpr unsigned BANK_MASK
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
static constexpr unsigned BANK_SIZE
This file implemented 3 utility functions:
uint8_t byte
8 bit unsigned integer
uint16_t word
16 bit unsigned integer
constexpr To narrow_cast(From &&from) noexcept
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)