openMSX
RomMitsubishiMLTS2.cc
Go to the documentation of this file.
2#include "CacheLine.hh"
3#include "serialize.hh"
4
5#include <iostream>
6
7namespace openmsx {
8
10 : Rom8kBBlocks(config, std::move(rom_))
11 , ram(config, getName() + " RAM", "ML-TS2 RAM", 0x2000)
12{
13 reset(EmuTime::dummy());
14}
15
16void RomMitsubishiMLTS2::reset(EmuTime::param /*time*/)
17{
18 setRom(2, 0);
19}
20
21void RomMitsubishiMLTS2::writeMem(word address, byte value, EmuTime::param /*time*/)
22{
23 // TODO What are these 4 registers? Are there any more?
24 // Is there any mirroring going on?
25 if (address == 0x7f00) {
26 // TODO
27 } else if (address == 0x7f01) {
28 // TODO
29 } else if (address == 0x7f02) {
30 // TODO
31 } else if (address == 0x7f03) {
32 // TODO
33 } else if (address == 0x7FC0) {
34 byte bank = value & 0b111;
35 std::cerr << "Setting MLTS2 mapper page 1 to bank " << int(bank) << '\n';
36 setRom(2, bank);
37 } else if ((0x6000 <= address) && (address < 0x8000)) {
38 ram[address & 0x1FFF] = value;
39 }
40}
41
42byte RomMitsubishiMLTS2::readMem(word address, EmuTime::param time)
43{
44 return peekMem(address, time);
45}
46
47byte RomMitsubishiMLTS2::peekMem(word address, EmuTime::param time) const
48{
49 // TODO What are these 4 registers? Are there any more?
50 // Is there any mirroring going on?
51 // Is the bank select register readable? (0x7fc0)
52 if (address == 0x7f00) {
53 return 0xff; // TODO
54 } else if (address == 0x7f01) {
55 return 0xff; // TODO
56 } else if (address == 0x7f02) {
57 return 0xff; // TODO
58 } else if (address == 0x7f03) {
59 return 0xff; // TODO
60 } else if ((0x6000 <= address) && (address < 0x8000)) {
61 return ram[address & 0x1FFF];
62 } else {
63 return Rom8kBBlocks::peekMem(address, time);
64 }
65}
66
68{
69 if (address == (0x7FC0 & CacheLine::HIGH)) return nullptr;
70 if ((0x6000 <= address) && (address < 0x8000)) {
71 return &ram[address & 0x1FFF];
72 }
73 return Rom8kBBlocks::getReadCacheLine(address);
74}
75
77{
78 if (address == (0x7FC0 & CacheLine::HIGH)) return nullptr;
79 if ((0x6000 <= address) && (address < 0x8000)) {
80 return &ram[address & 0x1FFF];
81 }
82 return unmappedWrite.data();
83}
84
85template<typename Archive>
86void RomMitsubishiMLTS2::serialize(Archive& ar, unsigned /*version*/)
87{
88 ar.template serializeBase<Rom8kBBlocks>(*this);
89}
92
93} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
static std::array< byte, 0x10000 > unmappedWrite
Definition MSXDevice.hh:307
auto data()
Definition Ram.hh:45
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition RomBlocks.cc:60
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition RomBlocks.cc:104
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:72
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.
RomMitsubishiMLTS2(const DeviceConfig &config, Rom &&rom)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
void reset(EmuTime::param time) override
This method is called on reset.
void serialize(Archive &ar, unsigned version)
constexpr unsigned HIGH
Definition CacheLine.hh:10
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
STL namespace.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)