38static constexpr auto sectorInfo = [] {
40 using Info = AmdFlash::SectorInfo;
41 std::array<Info, 8 + 127> result = {};
42 std::fill(result.begin(), result.begin() + 8,
Info{ 8 * 1024, false});
43 std::fill(result.begin() + 8, result.end(),
Info{64 * 1024, false});
50 , flash(rom, sectorInfo, 0x207E,
51 AmdFlash::Addressing::BITS_12, config)
52 , scc(
"KUC SCC", config, getCurrentTime(),
SCC::SCC_Compatible)
53 , dac(
"KUC DAC",
"Konami Ultimate Collection DAC", config)
77unsigned KonamiUltimateCollection::getFlashAddr(
unsigned addr)
const
79 unsigned page8kB = (addr >> 13) - 2;
80 if (page8kB >= 4)
return unsigned(-1);
82 byte bank = bankRegs[page8kB] + offsetReg;
83 return ((mapperReg & 0xC0) << (21 - 6)) | (bank << 13) | (addr & 0x1FFF);
86bool KonamiUltimateCollection::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 (isMapperRegisterEnabled()) {
163 if (addr == 0x7FFF) {
165 }
else if (addr == 0x7FFE) {
173 if (isBank0Disabled() && (addr < 0x6000) && ((addr & 0x0010) == 0)) {
177 if (areBankRegsEnabled()) {
179 if (isKonamiSCCmode()) {
181 if ((addr & 0x1800) == 0x1000) {
185 bankRegs[page8kB] = value;
190 if (isBank0Disabled() && (addr < 0x6000)) {
195 if (!((addr < 0x5000) || ((0x5800 <= addr) && (addr < 0x6000)))) {
197 bankRegs[page8kB] = value;
204 if ((addr & 0xFFFE) == 0xBFFE) {
213 if ((flashAddr !=
unsigned(-1)) && isFlashRomWriteEnabled()) {
214 flash.
write(flashAddr, value);
220 return ((0x4000 <= addr) && (addr < 0xC000))
225template<
typename Archive>
229 ar.template serializeBase<MSXDevice>(*
this);
231 ar.serialize(
"flash", flash,
234 "mapperReg", mapperReg,
235 "offsetReg", offsetReg,
237 "bankRegs", bankRegs);
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 reset(EmuTime::param time)
void writeDAC(uint8_t value, EmuTime::param time)
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
KonamiUltimateCollection(const DeviceConfig &config, Rom &&rom)
void reset(EmuTime::param time) override
This method is called on reset.
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
void serialize(Archive &ar, unsigned version)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
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.
void invalidateDeviceRCache()
static std::array< byte, 0x10000 > unmappedRead
static std::array< byte, 0x10000 > unmappedWrite
void invalidateDeviceRWCache()
Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is lo...
EmuTime::param getCurrentTime() const
void setChipMode(ChipMode 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:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
AmdFlash::SectorInfo Info
uint16_t word
16 bit unsigned integer
constexpr void fill(ForwardRange &&range, const T &value)
constexpr void iota(ForwardIt first, ForwardIt last, T value)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)