| e8555c89 Andy McCall |
1 |
#include "RomColecoMegaCart.hh" |
| 2 |
|
| 3 |
#include "CacheLine.hh" |
| 4 |
#include "MSXException.hh" |
| 5 |
#include "serialize.hh" |
| 6 |
|
| 7 |
#include "one_of.hh" |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace openmsx { |
| 13 |
|
| 14 |
RomColecoMegaCart::RomColecoMegaCart(const DeviceConfig& config, Rom&& rom_) |
| 15 |
: Rom16kBBlocks(config, std::move(rom_)) |
| 16 |
{ |
| 17 |
if (auto size = rom.size() / 1024; |
| 18 |
size != one_of(128u, 256u, 512u, 1024u)) { |
| 19 |
throw MSXException( |
| 20 |
"MegaCart only supports ROMs of 128kB, 256kB, 512kB and 1024kB " |
| 21 |
"size and not of ", size, "kB."); |
| 22 |
} |
| 23 |
reset(EmuTime::dummy()); |
| 24 |
} |
| 25 |
|
| 26 |
void RomColecoMegaCart::reset(EmuTime ) |
| 27 |
{ |
| 28 |
setUnmapped(0); |
| 29 |
setUnmapped(1); |
| 30 |
|
| 31 |
|
| 32 |
setRom(2, unsigned(-1)); |
| 33 |
setRom(3, 0); |
| 34 |
invalidateDeviceRCache(0xFFC0 & CacheLine::HIGH, CacheLine::SIZE); |
| 35 |
} |
| 36 |
|
| 37 |
byte RomColecoMegaCart::readMem(uint16_t address, EmuTime time) |
| 38 |
{ |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
if (address >= 0xFFC0) { |
| 44 |
setRom(3, address); |
| 45 |
invalidateDeviceRCache(0xFFC0 & CacheLine::HIGH, CacheLine::SIZE); |
| 46 |
} |
| 47 |
return Rom16kBBlocks::readMem(address, time); |
| 48 |
} |
| 49 |
|
| 50 |
const byte* RomColecoMegaCart::getReadCacheLine(uint16_t start) const |
| 51 |
{ |
| 52 |
if (start >= (0xFFC0 & CacheLine::HIGH)) { |
| 53 |
return nullptr; |
| 54 |
} else { |
| 55 |
return Rom16kBBlocks::getReadCacheLine(start); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
REGISTER_MSXDEVICE(RomColecoMegaCart, "RomColecoMegaCart"); |
| 60 |
|
| 61 |
} |