34 , flash(rom, AmdFlashChip::M29W640GB, {}, config)
39 powerUp(getCurrentTime());
40 auto& cpuInterface = getCPUInterface();
41 for (
auto port : {0x10, 0x11, 0x13}) {
42 cpuInterface.register_IO_Out(narrow_cast<byte>(port),
this);
49 for (
auto port : {0x10, 0x11, 0x13}) {
50 cpuInterface.unregister_IO_Out(narrow_cast<byte>(port),
this);
62 flashRomWriteEnabled =
false;
76unsigned ReproCartridgeV1::getFlashAddr(
unsigned addr)
const
78 unsigned page8kB = (addr >> 13) - 2;
79 if (page8kB >= 4)
return unsigned(-1);
81 byte bank = bankRegs[page8kB];
82 return (mainBankReg << 21) | (bank << 13) | (addr & 0x1FFF);
86bool ReproCartridgeV1::isSCCAccess(
word addr)
const
88 if (sccMode & 0x10)
return false;
100 return (bankRegs[3] & 0x80) && (0xB800 <= addr) && (addr < 0xBFFE);
103 return ((bankRegs[2] & 0x3F) == 0x3F) && (0x9800 <= addr) && (addr < 0x9FFE);
109 if (isSCCAccess(addr)) {
110 return scc.
readMem(narrow_cast<uint8_t>(addr & 0xFF), time);
113 unsigned flashAddr = getFlashAddr(addr);
114 return (flashAddr !=
unsigned(-1))
115 ? flash.
read(flashAddr)
121 if (isSCCAccess(addr)) {
122 return scc.
peekMem(narrow_cast<uint8_t>(addr & 0xFF), time);
125 unsigned flashAddr = getFlashAddr(addr);
126 return (flashAddr !=
unsigned(-1))
127 ? flash.
peek(flashAddr)
133 if (isSCCAccess(addr))
return nullptr;
135 unsigned flashAddr = getFlashAddr(addr);
136 return (flashAddr !=
unsigned(-1))
143 unsigned page8kB = (addr >> 13) - 2;
144 if (page8kB >= 4)
return;
153 if (isSCCAccess(addr)) {
154 scc.
writeMem(narrow_cast<uint8_t>(addr & 0xFF), value, time);
159 unsigned flashAddr = getFlashAddr(addr);
162 if (addr == 0x7FFF) {
163 flashRomWriteEnabled = (value == 0x50);
167 if (!flashRomWriteEnabled) {
169 if ((addr & 0x1800) == 0x1000) {
172 bankRegs[page8kB] = value;
177 if ((addr & 0xFFFE) == 0xBFFE) {
185 if (flashAddr !=
unsigned(-1)) {
186 flash.
write(flashAddr, value);
193 return ((0x4000 <= addr) && (addr < 0xC000))
203 psgLatch = value & 0x0F;
209 mainBankReg = value & 3;
216template<
typename Archive>
220 ar.template serializeBase<MSXDevice>(*
this);
222 ar.serialize(
"flash", flash,
225 "psgLatch", psgLatch,
226 "flashRomWriteEnabled", flashRomWriteEnabled,
227 "mainBankReg", mainBankReg,
229 "bankRegs", bankRegs);
#define REGISTER_MSXDEVICE(CLASS, NAME)
void reset(EmuTime::param time)
void writeRegister(unsigned reg, uint8_t value, EmuTime::param time)
void write(size_t address, uint8_t value)
const uint8_t * getReadCacheLine(size_t address) const
uint8_t read(size_t address)
uint8_t peek(size_t address) const
static DummyAY8910Periphery & instance()
void invalidateDeviceRCache()
static std::array< byte, 0x10000 > unmappedRead
static std::array< byte, 0x10000 > unmappedWrite
MSXCPUInterface & getCPUInterface() const
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.
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
ReproCartridgeV1(const DeviceConfig &config, Rom &&rom)
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
~ReproCartridgeV1() override
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
void serialize(Archive &ar, unsigned version)
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.
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.
void setMode(Mode newMode)
void powerUp(EmuTime::param time)
uint8_t readMem(uint8_t address, EmuTime::param time)
void reset(EmuTime::param time)
uint8_t peekMem(uint8_t address, EmuTime::param time) const
void writeMem(uint8_t address, uint8_t value, EmuTime::param time)
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
constexpr void iota(ForwardIt first, ForwardIt last, T value)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)