32 , ram(config, getName() +
" RAM",
"ROM Hunter Mk 2 RAM", 0x40000)
44unsigned ROMHunterMk2::getRamAddr(
unsigned addr)
const
46 unsigned page = (addr >> 13) - 2;
48 unsigned bank = bankRegs[page];
49 return (bank * 0x2000) + (addr & 0x1FFF);
55 if ((addr < 0x4000) || (0xC000 <= addr)) {
60 if (((configReg & 0b1000) == 0) && (addr < 0x8000)) {
61 return &
rom[addr & 0x1FFF];
63 return &ram[getRamAddr(addr)];
87 if ((addr < 0x4000) || (0xC000 <= addr)) {
92 unsigned ramAddr = getRamAddr(addr);
95 if ((configReg & 0b10) == 0) {
97 switch (configReg & 0b101) {
107 const byte maskedValue = value & 0xF;
108 if ((0x6000 <= addr) && (addr < 0x6800)) {
109 bankRegs[0] = narrow_cast<byte>(2 * maskedValue + 0);
110 bankRegs[1] = narrow_cast<byte>(2 * maskedValue + 1);
113 if ((0x7000 <= addr) && (addr < 0x7800)) {
114 bankRegs[2] = narrow_cast<byte>(2 * maskedValue + 0);
115 bankRegs[3] = narrow_cast<byte>(2 * maskedValue + 1);
122 if ((0x6000 <= addr) && (addr < 0x8000)) {
123 byte bank = (addr >> 11) & 0x03;
124 bankRegs[bank] = value & 0x1F;
130 if ((0x6000 <= addr) && (addr < 0xC000)) {
131 unsigned bank = (addr >> 13) - 2;
132 bankRegs[bank] = value & 0x1F;
143 if ((configReg & 0b1000) == 0) {
146 if ((addr >= 0x8000) || ((configReg & 0b10) == 0b10)) {
147 ram[ramAddr] = value;
157template<
typename Archive>
161 ar.template serializeBase<MSXDevice>(*
this);
162 ar.serialize(
"ram", ram,
163 "configReg", configReg,
164 "bankRegs", bankRegs);
#define REGISTER_MSXDEVICE(CLASS, NAME)
void invalidateDeviceRCache()
static std::array< byte, 0x10000 > unmappedRead
EmuTime::param getCurrentTime() const
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
ROMHunterMk2(const DeviceConfig &config, Rom &&rom)
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)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
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.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
void reset(EmuTime::param time) override
This method is called on reset.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
constexpr void fill(ForwardRange &&range, const T &value)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)