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 setRom(2, bank);
36 } else if ((0x6000 <= address) && (address < 0x8000)) {
37 ram[address & 0x1FFF] = value;
38 }
39}
40
41byte RomMitsubishiMLTS2::readMem(word address, EmuTime::param time)
42{
43 return peekMem(address, time);
44}
45
46byte RomMitsubishiMLTS2::peekMem(word address, EmuTime::param time) const
47{
48 // TODO What are these 4 registers? Are there any more?
49 // Is there any mirroring going on?
50 // Is the bank select register readable? (0x7fc0)
51 if (address == 0x7f00) {
52 return 0xff; // TODO
53 } else if (address == 0x7f01) {
54 return 0xff; // TODO
55 } else if (address == 0x7f02) {
56 return 0xff; // TODO
57 } else if (address == 0x7f03) {
58 return 0xff; // TODO
59 } else if ((0x6000 <= address) && (address < 0x8000)) {
60 return ram[address & 0x1FFF];
61 } else {
62 return Rom8kBBlocks::peekMem(address, time);
63 }
64}
65
67{
68 if (address == (0x7FC0 & CacheLine::HIGH)) return nullptr;
69 if ((0x6000 <= address) && (address < 0x8000)) {
70 return &ram[address & 0x1FFF];
71 }
72 return Rom8kBBlocks::getReadCacheLine(address);
73}
74
76{
77 if (address == (0x7FC0 & CacheLine::HIGH)) return nullptr;
78 if ((0x6000 <= address) && (address < 0x8000)) {
79 return &ram[address & 0x1FFF];
80 }
81 return unmappedWrite.data();
82}
83
84template<typename Archive>
85void RomMitsubishiMLTS2::serialize(Archive& ar, unsigned /*version*/)
86{
87 ar.template serializeBase<Rom8kBBlocks>(*this);
88}
91
92} // 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)