42 "Rom for HALNOTE mapper must be exactly 1MB in size.");
44 sram = std::make_unique<SRAM>(
getName() +
" SRAM", 0x4000, config);
45 reset(EmuTime::dummy());
50 subBanks[0] = subBanks[1] = 0;
52 subMapperEnabled =
false;
56 for (
auto i :
xrange(2, 6)) {
65 if (subMapperEnabled && (0x7000 <= address) && (address < 0x8000)) {
67 int subBank = address < 0x7800 ? 0 : 1;
68 return &
rom[0x80000 + subBanks[subBank] * 0x800 + (address & 0x7FF)];
82 if (address < 0x4000) {
85 sram->write(address, value);
87 }
else if (address < 0xC000) {
88 if (address ==
one_of(0x77FF, 0x7FFF)) {
90 int subBank = address < 0x7800 ? 0 : 1;
91 if (subBanks[subBank] != value) {
92 subBanks[subBank] = value;
93 if (subMapperEnabled) {
95 0x7000 + subBank * 0x800, 0x800);
98 }
else if ((address & 0x1FFF) == 0x0FFF) {
100 auto bank = address >> 13;
104 bool newSramEnabled = (value & 0x80) != 0;
105 if (newSramEnabled != sramEnabled) {
106 sramEnabled = newSramEnabled;
117 }
else if (bank == 3) {
119 subMapperEnabled = (value & 0x80) != 0;
120 if (subMapperEnabled) {
130 if (address < 0x4000) {
135 }
else if (address < 0xC000) {
149template<
typename Archive>
152 ar.template serializeBase<Rom8kBBlocks>(*
this);
153 ar.serialize(
"subBanks", subBanks,
154 "sramEnabled", sramEnabled,
155 "subMapperEnabled", subMapperEnabled);
#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
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
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.
void reset(EmuTime::param time) override
This method is called on reset.
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
RomHalnote(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 writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
void serialize(Archive &ar, unsigned version)
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)