openMSX
RomMatraInk.cc
Go to the documentation of this file.
1#include "RomMatraInk.hh"
2#include "ranges.hh"
3#include "serialize.hh"
4#include <array>
5
6namespace openmsx {
7
8static constexpr auto sectorInfo = [] {
9 // 2 * 64kB, fully writeable
10 using Info = AmdFlash::SectorInfo;
11 std::array<Info, 2> result = {};
12 ranges::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
25void RomMatraInk::reset(EmuTime::param /*time*/)
26{
27 flash.reset();
28}
29
30byte RomMatraInk::peekMem(word address, EmuTime::param /*time*/) const
31{
32 return flash.peek(address);
33}
34
35byte RomMatraInk::readMem(word address, EmuTime::param /*time*/)
36{
37 return flash.read(address);
38}
39
40void RomMatraInk::writeMem(word address, byte value, EmuTime::param /*time*/)
41{
42 flash.write(address + 0x10000, value);
43}
44
45const byte* RomMatraInk::getReadCacheLine(word address) const
46{
47 return flash.getReadCacheLine(address);
48}
49
50byte* RomMatraInk::getWriteCacheLine(word /*address*/) const
51{
52 return nullptr;
53}
54
55template<typename Archive>
56void 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
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:354
void write(size_t address, uint8_t value)
Definition AmdFlash.cc:265
const uint8_t * getReadCacheLine(size_t address) const
Definition AmdFlash.cc:254
uint8_t peek(size_t address) const
Definition AmdFlash.cc:212
uint8_t read(size_t address) const
Definition AmdFlash.cc:248
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
void serialize(Archive &ar, unsigned version)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
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.
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
void reset(EmuTime::param time) override
This method is called on reset.
RomMatraInk(const DeviceConfig &config, Rom &&rom)
This file implemented 3 utility functions:
Definition Autofire.cc:9
AmdFlash::SectorInfo Info
Definition RomManbow2.cc:18
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
constexpr void fill(ForwardRange &&range, const T &value)
Definition ranges.hh:305
STL namespace.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)