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 for (
auto port : {0x10, 0x11}) {
80 cpuInterface.register_IO_Out(narrow_cast<byte>(port),
this);
82 cpuInterface.register_IO_In(0x12,
this);
90 for (
auto port : {0x10, 0x11}) {
91 cpuInterface.unregister_IO_Out(narrow_cast<byte>(port),
this);
93 cpuInterface.unregister_IO_In(0x12,
this);
107 for (
auto i :
xrange(4)) {
124void RomManbow2::setRom(
unsigned region,
byte block)
127 auto nrBlocks = narrow<unsigned>(flash.
size() / 0x2000);
128 bank[region] = block & narrow<byte>(nrBlocks - 1);
134 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
135 return scc->peekMem(narrow_cast<uint8_t>(address & 0xFF), time);
136 }
else if ((0x4000 <= address) && (address < 0xC000)) {
137 unsigned page = (address - 0x4000) / 0x2000;
138 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
139 return flash.
peek(addr);
147 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
148 return scc->readMem(narrow_cast<uint8_t>(address & 0xFF), time);
149 }
else if ((0x4000 <= address) && (address < 0xC000)) {
150 unsigned page = (address - 0x4000) / 0x2000;
151 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
152 return flash.
read(addr);
160 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
162 }
else if ((0x4000 <= address) && (address < 0xC000)) {
163 unsigned page = (address - 0x4000) / 0x2000;
164 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
173 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
175 scc->writeMem(narrow_cast<uint8_t>(address & 0xff), value, time);
179 if ((0x4000 <= address) && (address < 0xC000)) {
180 unsigned page = (address - 0x4000) / 0x2000;
181 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
182 flash.
write(addr, value);
184 if (scc && ((address & 0xF800) == 0x9000)) {
186 sccEnabled = ((value & 0x3F) == 0x3F);
189 if ((address & 0x1800) == 0x1000) {
198 if ((0x4000 <= address) && (address < 0xC000)) {
207 assert((port & 0xFF) == 0x12); (void)port;
208 return psg->readRegister(psgLatch, time);
213 assert((port & 0xFF) == 0x12); (void)port;
214 return psg->peekRegister(psgLatch, time);
219 if ((port & 0xFF) == 0x10) {
220 psgLatch = value & 0x0F;
222 assert((port & 0xFF) == 0x11);
223 psg->writeRegister(psgLatch, value, time);
231template<
typename Archive>
235 ar.template serializeBase<MSXDevice>(*
this);
238 ar.serialize(
"scc", *scc,
239 "sccEnabled", sccEnabled);
241 if ((ar.versionAtLeast(version, 2)) && psg) {
242 ar.serialize(
"psg", *psg,
243 "psgLatch", psgLatch);
245 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)