openMSX
RomMSXtra.cc
Go to the documentation of this file.
1 #include "RomMSXtra.hh"
2 #include "serialize.hh"
3 
4 namespace openmsx {
5 
6 RomMSXtra::RomMSXtra(const DeviceConfig& config, Rom&& rom_)
7  : MSXRom(config, std::move(rom_))
8  , ram(config, getName() + " RAM", "MSXtra RAM", 0x0800)
9 {
10  for (int i = 0; i < 0x800; ++i) {
11  ram[i] = (i & 1) ? 0x5a : 0xa5;
12  }
13 }
14 
15 byte RomMSXtra::readMem(word address, EmuTime::param /*time*/)
16 {
17  if ((0x4000 <= address) && (address < 0x6000)) {
18  return rom[address & 0x1fff];
19  } else if ((0x6000 <= address) && (address < 0x8000)) {
20  return ram[address & 0x07ff];
21  } else {
22  return 0xff;
23  }
24 }
25 
26 const byte* RomMSXtra::getReadCacheLine(word address) const
27 {
28  if ((0x4000 <= address) && (address < 0x6000)) {
29  return &rom[address & 0x1fff];
30  } else if ((0x6000 <= address) && (address < 0x8000)) {
31  return &ram[address & 0x07ff];
32  } else {
33  return unmappedRead;
34  }
35 }
36 
37 // default peekMem() implementation is OK
38 
39 void RomMSXtra::writeMem(word address, byte value, EmuTime::param /*time*/)
40 {
41  if ((0x6000 <= address) && (address < 0x8000)) {
42  ram[address & 0x07ff] = value;
43  }
44 }
45 
46 byte* RomMSXtra::getWriteCacheLine(word address) const
47 {
48  if ((0x6000 <= address) && (address < 0x8000)) {
49  return const_cast<byte*>(&ram[address & 0x07ff]);
50  } else {
51  return unmappedWrite;
52  }
53 }
54 
55 template<typename Archive>
56 void RomMSXtra::serialize(Archive& ar, unsigned /*version*/)
57 {
58  // skip MSXRom base class
59  ar.template serializeBase<MSXDevice>(*this);
60  ar.serialize("ram", ram);
61 }
63 REGISTER_MSXDEVICE(RomMSXtra, "RomMSXtra");
64 
65 } // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition: MSXDevice.hh:307
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981