21static constexpr auto config1 = [] {
22 std::array<
Info, 512 / 64> result = {};
24 result[7].writeProtected =
false;
28static constexpr auto config2 = [] {
29 std::array<
Info, 512 / 64> result = {};
31 result[4].writeProtected =
false;
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)
70 getName() +
" SCC", config, getCurrentTime())
75 config, getCurrentTime())
77 , flash(rom, getSectorInfo(type),
79 AmdFlash::Addressing::BITS_11, config)
80 , romBlockDebug(*this, bank, 0x4000, 0x8000, 13)
110 for (
auto i :
xrange(4)) {
127void RomManbow2::setRom(
unsigned region,
byte block)
130 auto nrBlocks = narrow<unsigned>(flash.
size() / 0x2000);
131 bank[region] = block & narrow<byte>(nrBlocks - 1);
137 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
138 return scc->peekMem(narrow_cast<uint8_t>(address & 0xFF), time);
139 }
else if ((0x4000 <= address) && (address < 0xC000)) {
140 unsigned page = (address - 0x4000) / 0x2000;
141 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
142 return flash.
peek(addr);
150 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
151 return scc->readMem(narrow_cast<uint8_t>(address & 0xFF), time);
152 }
else if ((0x4000 <= address) && (address < 0xC000)) {
153 unsigned page = (address - 0x4000) / 0x2000;
154 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
155 return flash.
read(addr);
163 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
165 }
else if ((0x4000 <= address) && (address < 0xC000)) {
166 unsigned page = (address - 0x4000) / 0x2000;
167 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
176 if (sccEnabled && (0x9800 <= address) && (address < 0xA000)) {
178 scc->writeMem(narrow_cast<uint8_t>(address & 0xff), value, time);
182 if ((0x4000 <= address) && (address < 0xC000)) {
183 unsigned page = (address - 0x4000) / 0x2000;
184 unsigned addr = (address & 0x1FFF) + 0x2000 * bank[page];
185 flash.
write(addr, value);
187 if (scc && ((address & 0xF800) == 0x9000)) {
189 sccEnabled = ((value & 0x3F) == 0x3F);
192 if ((address & 0x1800) == 0x1000) {
201 if ((0x4000 <= address) && (address < 0xC000)) {
210 assert((port & 0xFF) == 0x12); (void)port;
211 return psg->readRegister(psgLatch, time);
216 assert((port & 0xFF) == 0x12); (void)port;
217 return psg->peekRegister(psgLatch, time);
222 if ((port & 0xFF) == 0x10) {
223 psgLatch = value & 0x0F;
225 assert((port & 0xFF) == 0x11);
226 psg->writeRegister(psgLatch, value, time);
234template<
typename Archive>
238 ar.template serializeBase<MSXDevice>(*
this);
241 ar.serialize(
"scc", *scc,
242 "sccEnabled", sccEnabled);
244 if ((ar.versionAtLeast(version, 2)) && psg) {
245 ar.serialize(
"psg", *psg,
246 "psgLatch", psgLatch);
248 ar.serialize(
"flash", flash,
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 register_IO_Out(byte port, MSXDevice *device)
Devices can register their Out ports.
void register_IO_In(byte port, MSXDevice *device)
Devices can register their In ports.
void unregister_IO_In(byte port, MSXDevice *device)
void unregister_IO_Out(byte port, MSXDevice *device)
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.
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
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)