| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
#include "RomKonami.hh" |
| 13 |
|
| 14 |
#include "MSXCliComm.hh" |
| 15 |
#include "MSXMotherBoard.hh" |
| 16 |
#include "serialize.hh" |
| 17 |
|
| 18 |
#include "xrange.hh" |
| 19 |
|
| 20 |
namespace openmsx { |
| 21 |
|
| 22 |
RomKonami::RomKonami(const DeviceConfig& config, Rom&& rom_) |
| 23 |
: Rom8kBBlocks(config, std::move(rom_)) |
| 24 |
{ |
| 25 |
|
| 26 |
setBlockMask(31); |
| 27 |
|
| 28 |
|
| 29 |
if (rom.size() > 256 * 1024) { |
| 30 |
getMotherBoard().getMSXCliComm().printWarning( |
| 31 |
"The size of this ROM image is larger than 256kB, " |
| 32 |
"which is not supported on real Konami mapper chips!"); |
| 33 |
} |
| 34 |
reset(EmuTime::dummy()); |
| 35 |
} |
| 36 |
|
| 37 |
void RomKonami::bankSwitch(unsigned page, unsigned block) |
| 38 |
{ |
| 39 |
setRom(page, block); |
| 40 |
|
| 41 |
|
| 42 |
if (page == 2 || page == 3) { |
| 43 |
|
| 44 |
setRom(page - 2, block); |
| 45 |
} else if (page == 4 || page == 5) { |
| 46 |
|
| 47 |
setRom(page + 2, block); |
| 48 |
} else { |
| 49 |
assert(false); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
void RomKonami::reset(EmuTime ) |
| 54 |
{ |
| 55 |
for (auto i : xrange(2, 6)) { |
| 56 |
bankSwitch(i, i - 2); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
void RomKonami::writeMem(uint16_t address, byte value, EmuTime ) |
| 61 |
{ |
| 62 |
|
| 63 |
if (0x6000 <= address && address < 0xC000) { |
| 64 |
bankSwitch(address >> 13, value); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
byte* RomKonami::getWriteCacheLine(uint16_t address) |
| 69 |
{ |
| 70 |
return (0x6000 <= address && address < 0xC000) ? nullptr : unmappedWrite.data(); |
| 71 |
} |
| 72 |
|
| 73 |
template<typename Archive> |
| 74 |
void RomKonami::serialize(Archive& ar, unsigned ) |
| 75 |
{ |
| 76 |
ar.template serializeBase<Rom8kBBlocks>(*this); |
| 77 |
} |
| 78 |
INSTANTIATE_SERIALIZE_METHODS(RomKonami); |
| 79 |
REGISTER_MSXDEVICE(RomKonami, "RomKonami"); |
| 80 |
|
| 81 |
} |