openMSX
RomMatraCompilation.cc
Go to the documentation of this file.
1 #include "RomMatraCompilation.hh"
2 #include "one_of.hh"
3 #include "serialize.hh"
4 
5 // This is basically a generic 8kB mapper (Konami like, but without fixed page
6 // at 0x4000), with an extra offset register accessible at 0xBA00.
7 // The software only writes to 0x5000, 0x6000, 0x8000, 0xA000 to switch mapper
8 // page. I took these as unique switching addresses, as some of the compilation
9 // software would write to others, causing crashes.
10 // It seems that a write of 1 (and probably 0, but the software doesn't do
11 // that) to the offset register should be ignored and will disable the mapper
12 // switch addresses. Values of 2 or larger written there must be lowered by 2
13 // to get the actual offset to use.
14 
15 namespace openmsx {
16 
18  : Rom8kBBlocks(config, std::move(rom_))
19 {
20  reset(EmuTime::dummy());
21 }
22 
23 void RomMatraCompilation::reset(EmuTime::param /*time*/)
24 {
25  setUnmapped(0);
26  setUnmapped(1);
27  for (int i = 2; i < 6; i++) {
28  setRom(i, i - 2);
29  }
30  setUnmapped(6);
31  setUnmapped(7);
32 
33  blockOffset = 2;
34 }
35 
36 void RomMatraCompilation::writeMem(word address, byte value, EmuTime::param /*time*/)
37 {
38  if (address == 0xBA00) {
39  // write of block offset
40  blockOffset = value;
41  // retro-actively select the blocks for this offset
42  if (blockOffset >= 2) {
43  for (int i = 2; i < 6; i++) {
44  setRom(i, blockNr[i] + blockOffset - 2);
45  }
46  }
47  } else if ((blockOffset >= 2) &&
48  (address == one_of(0x5000, 0x6000, 0x8000, 0xA000))) {
49  setRom(address >> 13, value + blockOffset - 2);
50  }
51 }
52 
54 {
55  if ((0x5000 <= address) && (address < 0xC000)) {
56  return nullptr;
57  } else {
58  return unmappedWrite;
59  }
60 }
61 
62 template<typename Archive>
63 void RomMatraCompilation::serialize(Archive& ar, unsigned /*version*/)
64 {
65  ar.template serializeBase<Rom8kBBlocks>(*this);
66 
67  ar.serialize("blockOffset", blockOffset);
68 }
70 REGISTER_MSXDEVICE(RomMatraCompilation, "RomMatraCompilation");
71 
72 } // namespace openmsx
one_of.hh
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::MSXDevice::unmappedWrite
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:301
openmsx::RomMatraCompilation::serialize
void serialize(Archive &ar, unsigned version)
Definition: RomMatraCompilation.cc:63
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
openmsx::RomBlocks::setRom
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:104
one_of
Definition: one_of.hh:7
openmsx::RomBlocks::setUnmapped
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:91
openmsx::RomBlocks
Definition: RomBlocks.hh:14
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
openmsx::RomMatraCompilation::getWriteCacheLine
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: RomMatraCompilation.cc:53
openmsx::Rom
Definition: Rom.hh:21
RomMatraCompilation.hh
openmsx::RomMatraCompilation
Definition: RomMatraCompilation.hh:9
openmsx::RomMatraCompilation::writeMem
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.
Definition: RomMatraCompilation.cc:36
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::RomMatraCompilation::RomMatraCompilation
RomMatraCompilation(const DeviceConfig &config, Rom &&rom)
Definition: RomMatraCompilation.cc:17
openmsx::RomMatraCompilation::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomMatraCompilation.cc:23
openmsx::RomBlocks::blockNr
byte blockNr[NUM_BANKS]
Definition: RomBlocks.hh:84
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5