21static constexpr auto config1 = [] {
22 std::array<
Info, 512 / 64> result = {};
28static constexpr auto config2 = [] {
29 std::array<
Info, 512 / 64> result = {};
32 result[5].writeProtected =
false;
36static constexpr auto config3 = [] {
37 std::array<
Info, 512 / 64> result = {};
42static constexpr auto config4 = [] {
43 std::array<
Info, 2048 / 64> result = {};
47[[nodiscard]]
static constexpr std::span<const Info> getSectorInfo(
RomType type)
69 getName() +
" SCC", config, getCurrentTime())
74 config, getCurrentTime())
76 , flash(rom, getSectorInfo(type),
78 AmdFlash::Addressing::BITS_11, config)
79 , romBlockDebug(*this, bank, 0x4000, 0x8000, 13)
85 for (
auto port : {0x10, 0x11}) {
86 cpuInterface.register_IO_Out(narrow_cast<byte>(port),
this);
88 cpuInterface.register_IO_In(0x12,
this);
96 for (
auto port : {0x10, 0x11}) {
97 cpuInterface.unregister_IO_Out(narrow_cast<byte>(port),
this);
99 cpuInterface.unregister_IO_In(0x12,
this);
113 for (
auto i :
xrange(4)) {
130void RomManbow2::setRom(
unsigned region,
byte block)
133 auto nrBlocks = narrow<unsigned>(flash.
size() / 0x2000);
134 bank[region] = block & narrow<byte>(nrBlocks - 1);
140 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
141 return scc->peekMem(narrow_cast<uint8_t>(address & 0xFF), time);
142 }
else if ((0x4000 <= address) && (address < 0xC000)) {
143 unsigned page = (address - 0x4000) / 0x2000;
144 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
145 return flash.
peek(addr);
153 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
154 return scc->readMem(narrow_cast<uint8_t>(address & 0xFF), time);
155 }
else if ((0x4000 <= address) && (address < 0xC000)) {
156 unsigned page = (address - 0x4000) / 0x2000;
157 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
158 return flash.
read(addr);
166 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
168 }
else if ((0x4000 <= address) && (address < 0xC000)) {
169 unsigned page = (address - 0x4000) / 0x2000;
170 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
179 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
181 scc->writeMem(narrow_cast<uint8_t>(address & 0xff), value, time);
185 if ((0x4000 <= address) && (address < 0xC000)) {
186 unsigned page = (address - 0x4000) / 0x2000;
187 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
188 flash.
write(addr, value);
190 if (scc && ((address & 0xF800) == 0x9000)) {
192 sccEnabled = ((value & 0x3F) == 0x3F);
195 if ((address & 0x1800) == 0x1000) {
204 if ((0x4000 <= address) && (address < 0xC000)) {
213 assert((port & 0xFF) == 0x12); (void)port;
214 return psg->readRegister(psgLatch, time);
219 assert((port & 0xFF) == 0x12); (void)port;
220 return psg->peekRegister(psgLatch, time);
225 if ((port & 0xFF) == 0x10) {
226 psgLatch = value & 0x0F;
228 assert((port & 0xFF) == 0x11);
229 psg->writeRegister(psgLatch, value, time);
237template<
typename Archive>
241 ar.template serializeBase<MSXDevice>(*
this);
244 ar.serialize(
"scc", *scc,
245 "sccEnabled", sccEnabled);
247 if ((ar.versionAtLeast(version, 2)) && psg) {
248 ar.serialize(
"psg", *psg,
249 "psgLatch", psgLatch);
251 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 peek(size_t address) const
uint8_t read(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.
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)
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
This file implemented 3 utility functions:
AmdFlash::SectorInfo Info
uint16_t word
16 bit unsigned integer
@ ROM_RBSC_FLASH_KONAMI_SCC
constexpr void fill(ForwardRange &&range, const T &value)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)