openMSX
RomColecoMegaCart.cc
Go to the documentation of this file.
2#include "serialize.hh"
3#include "MSXException.hh"
4#include "CacheLine.hh"
5#include "one_of.hh"
6
7// information source:
8// https://github.com/openMSX/openMSX/files/2118720/MegaCart.FAQ.V1-2.pdf
9
10namespace openmsx {
11
13 : Rom16kBBlocks(config, std::move(rom_))
14{
15 auto size = rom.size() / 1024;
16 if (size != one_of(128u, 256u, 512u, 1024u)) {
17 throw MSXException(
18 "MegaCart only supports ROMs of 128kB, 256kB, 512kB and 1024kB "
19 "size and not of ", size, "kB.");
20 }
21 reset(EmuTime::dummy());
22}
23
24void RomColecoMegaCart::reset(EmuTime::param /*time*/)
25{
26 setUnmapped(0);
27 setUnmapped(1);
28 // The first 16K of the cartridge (CV 8000h-BFFFh) is fixed and will
29 // always contain the highest/last 16K segment of the EPROM.
30 setRom(2, unsigned(-1)); // select last block
31 setRom(3, 0);
33}
34
35byte RomColecoMegaCart::readMem(word address, EmuTime::param time)
36{
37 // The last 64 locations will switch banks (FFC0-FFFF). If you have
38 // fewer than 64 banks, then the strobe addresses simply repeat where
39 // they end. If you have 16 banks, then bank 0 can be strobed at FFC0,
40 // FFD0, FFE0, or FFF0.
41 if (address >= 0xFFC0) {
42 setRom(3, address); // mirroring is handled in superclass
44 }
45 return Rom16kBBlocks::readMem(address, time);
46}
47
49{
50 if (start >= (0xFFC0 & CacheLine::HIGH)) {
51 return nullptr;
52 } else {
54 }
55}
56
58
59} // namespace openmsx
Definition: one_of.hh:7
void invalidateDeviceRCache()
Definition: MSXDevice.hh:211
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: RomBlocks.cc:65
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:103
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: RomBlocks.cc:71
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:91
void reset(EmuTime::param time) override
This method is called on reset.
RomColecoMegaCart(const DeviceConfig &config, Rom &&rom)
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
auto size() const
Definition: Rom.hh:36
constexpr unsigned HIGH
Definition: CacheLine.hh:10
constexpr unsigned SIZE
Definition: CacheLine.hh:7
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
STL namespace.
size_t size(std::string_view utf8)