18[[nodiscard]]
static const AmdFlash::ValidatedChip& getFlashChip(
RomType type)
26 return AmdFlashChip::AM29F040;
28 return AmdFlashChip::AM29F016;
34[[nodiscard]]
static std::span<const bool> getWriteProtectSectors(
RomType type)
41 static constexpr std::array<const bool, 8> writeProtectSectors =
42 {
true,
true,
true,
true,
true,
true,
true,
false};
43 return writeProtectSectors;
47 static constexpr std::array<const bool, 8> writeProtectSectors =
48 {
true,
true,
true,
true,
false,
false,
true,
true};
49 return writeProtectSectors;
65 getName() +
" SCC", config, getCurrentTime())
70 config, getCurrentTime())
72 , flash(rom, getFlashChip(type), getWriteProtectSectors(type), config)
73 , romBlockDebug(*this, bank, 0x4000, 0x8000, 13)
79 cpuInterface.register_IO_Out_range(0x10, 2,
this);
80 cpuInterface.register_IO_In(0x12,
this);
88 cpuInterface.unregister_IO_Out_range(0x10, 2,
this);
89 cpuInterface.unregister_IO_In(0x12,
this);
103 for (
auto i :
xrange(4)) {
120void RomManbow2::setRom(
unsigned region,
byte block)
123 auto nrBlocks = narrow<unsigned>(flash.
size() / 0x2000);
124 bank[region] = block & narrow<byte>(nrBlocks - 1);
130 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
131 return scc->peekMem(narrow_cast<uint8_t>(address & 0xFF), time);
132 }
else if ((0x4000 <= address) && (address < 0xC000)) {
133 unsigned page = (address - 0x4000) / 0x2000;
134 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
135 return flash.
peek(addr);
143 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
144 return scc->readMem(narrow_cast<uint8_t>(address & 0xFF), time);
145 }
else if ((0x4000 <= address) && (address < 0xC000)) {
146 unsigned page = (address - 0x4000) / 0x2000;
147 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
148 return flash.
read(addr);
156 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
158 }
else if ((0x4000 <= address) && (address < 0xC000)) {
159 unsigned page = (address - 0x4000) / 0x2000;
160 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
169 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
171 scc->writeMem(narrow_cast<uint8_t>(address & 0xff), value, time);
175 if ((0x4000 <= address) && (address < 0xC000)) {
176 unsigned page = (address - 0x4000) / 0x2000;
177 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
178 flash.
write(addr, value);
180 if (scc && ((address & 0xF800) == 0x9000)) {
182 sccEnabled = ((value & 0x3F) == 0x3F);
185 if ((address & 0x1800) == 0x1000) {
194 if ((0x4000 <= address) && (address < 0xC000)) {
203 assert((port & 0xFF) == 0x12); (void)port;
204 return psg->readRegister(psgLatch, time);
209 assert((port & 0xFF) == 0x12); (void)port;
210 return psg->peekRegister(psgLatch, time);
215 if ((port & 0xFF) == 0x10) {
216 psgLatch = value & 0x0F;
218 assert((port & 0xFF) == 0x11);
219 psg->writeRegister(psgLatch, value, time);
227template<
typename Archive>
231 ar.template serializeBase<MSXDevice>(*
this);
234 ar.serialize(
"scc", *scc,
235 "sccEnabled", sccEnabled);
237 if ((ar.versionAtLeast(version, 2)) && psg) {
238 ar.serialize(
"psg", *psg,
239 "psgLatch", psgLatch);
241 ar.serialize(
"flash", flash,
#define REGISTER_MSXDEVICE(CLASS, NAME)
This class implements the AY-3-8910 sound chip.
void write(size_t address, uint8_t value)
const uint8_t * getReadCacheLine(size_t address) const
uint8_t read(size_t address)
power_of_two< size_t > size() const
uint8_t peek(size_t address) const
void invalidateDeviceRCache()
static std::array< byte, 0x10000 > unmappedRead
static std::array< byte, 0x10000 > unmappedWrite
EmuTime::param getCurrentTime() const
MSXCPUInterface & getCPUInterface() const
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
RomManbow2(const DeviceConfig &config, Rom &&rom, RomType type)
void reset(EmuTime::param time) override
This method is called on reset.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
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.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void serialize(Archive &ar, unsigned version)
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)