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 & 0x10) >> 2) | // transform bit-pattern
35 ((value & 0x04) >> 1) | // ...a.b.c
36 ((value & 0x01) >> 0); // into 00000abc
37 std::cerr << "Setting MLTS2 mapper page 1 to bank " << int(bank) << '\n';
38 setRom(2, bank);
39 } else if ((0x6000 <= address) && (address < 0x8000)) {
40 ram[address & 0x1FFF] = value;
41 }
42}
43
44byte RomMitsubishiMLTS2::readMem(word address, EmuTime::param time)
45{
46 return peekMem(address, time);
47}
48
49byte RomMitsubishiMLTS2::peekMem(word address, EmuTime::param time) const
50{
51 // TODO What are these 4 registers? Are there any more?
52 // Is there any mirroring going on?
53 // Is the bank select register readable? (0x7fc0)
54 if (address == 0x7f00) {
55 return 0xff; // TODO
56 } else if (address == 0x7f01) {
57 return 0xff; // TODO
58 } else if (address == 0x7f02) {
59 return 0xff; // TODO
60 } else if (address == 0x7f03) {
61 return 0xff; // TODO
62 } else if ((0x6000 <= address) && (address < 0x8000)) {
63 return ram[address & 0x1FFF];
64 } else {
65 return Rom8kBBlocks::peekMem(address, time);
66 }
67}
68
70{
71 if (address == (0x7FC0 & CacheLine::HIGH)) return nullptr;
72 if ((0x6000 <= address) && (address < 0x8000)) {
73 return &ram[address & 0x1FFF];
74 }
75 return Rom8kBBlocks::getReadCacheLine(address);
76}
77
79{
80 if (address == (0x7FC0 & CacheLine::HIGH)) return nullptr;
81 if ((0x6000 <= address) && (address < 0x8000)) {
82 return const_cast<byte*>(&ram[address & 0x1FFF]);
83 }
84 return unmappedWrite;
85}
86
87template<typename Archive>
88void RomMitsubishiMLTS2::serialize(Archive& ar, unsigned /*version*/)
89{
90 ar.template serializeBase<Rom8kBBlocks>(*this);
91}
94
95} // namespace openmsx
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:302
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition: RomBlocks.cc:60
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:105
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) const 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
std::string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:727
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
STL namespace.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:1009