openMSX
RomMatraInk.cc
Go to the documentation of this file.
1 #include "RomMatraInk.hh"
2 #include "cstd.hh"
3 #include "serialize.hh"
4 #include <array>
5 
6 namespace openmsx {
7 
8 static constexpr auto sectorInfo = [] {
9  // 2 * 64kB, fully writeable
10  using Info = AmdFlash::SectorInfo;
11  std::array<Info, 2> result = {};
12  cstd::fill(result, Info{64 * 1024, false});
13  return result;
14 }();
15 
17  : MSXRom(config, std::move(rom_))
18  , flash(rom, sectorInfo, 0x01A4,
19  AmdFlash::Addressing::BITS_11, config,
20  AmdFlash::Load::DONT)
21 {
22  reset(EmuTime::dummy());
23 }
24 
25 void RomMatraInk::reset(EmuTime::param /*time*/)
26 {
27  flash.reset();
28 }
29 
30 byte RomMatraInk::peekMem(word address, EmuTime::param /*time*/) const
31 {
32  return flash.peek(address);
33 }
34 
35 byte RomMatraInk::readMem(word address, EmuTime::param /*time*/)
36 {
37  return flash.read(address);
38 }
39 
40 void RomMatraInk::writeMem(word address, byte value, EmuTime::param /*time*/)
41 {
42  flash.write(address + 0x10000, value);
43 }
44 
45 const byte* RomMatraInk::getReadCacheLine(word address) const
46 {
47  return flash.getReadCacheLine(address);
48 }
49 
50 byte* RomMatraInk::getWriteCacheLine(word /*address*/) const
51 {
52  return nullptr;
53 }
54 
55 template<typename Archive>
56 void RomMatraInk::serialize(Archive& ar, unsigned /*version*/)
57 {
58  // skip MSXRom base class
59  ar.template serializeBase<MSXDevice>(*this);
60 
61  ar.serialize("flash", flash);
62 }
65 
66 } // namespace openmsx
void write(unsigned address, byte value)
Definition: AmdFlash.cc:268
byte peek(unsigned address) const
Definition: AmdFlash.cc:215
byte read(unsigned address) const
Definition: AmdFlash.cc:251
const byte * getReadCacheLine(unsigned address) const
Definition: AmdFlash.cc:257
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: RomMatraInk.cc:45
void serialize(Archive &ar, unsigned version)
Definition: RomMatraInk.cc:56
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition: RomMatraInk.cc:30
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: RomMatraInk.cc:40
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: RomMatraInk.cc:50
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: RomMatraInk.cc:35
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomMatraInk.cc:25
RomMatraInk(const DeviceConfig &config, Rom &&rom)
Definition: RomMatraInk.cc:16
constexpr void fill(ForwardIt first, ForwardIt last, const T &value)
Definition: cstd.hh:111
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
AmdFlash::SectorInfo Info
Definition: RomManbow2.cc:17
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:983