OXYGENHUB
◆ main openmsx / src / memory / RomMitsubishiMLTS2.cc
2.4 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "RomMitsubishiMLTS2.hh"
2
3
#include "CacheLine.hh"
4
#include "serialize.hh"
5
6
namespace openmsx {
7
8
RomMitsubishiMLTS2::RomMitsubishiMLTS2(const DeviceConfig& config, Rom&& rom_)
9
	: Rom8kBBlocks(config, std::move(rom_))
10
	, ram(config, getName() + " RAM", "ML-TS2 RAM", 0x2000)
11
{
12
	reset(EmuTime::dummy());
13
}
14
15
void RomMitsubishiMLTS2::reset(EmuTime /*time*/)
16
{
17
	setRom(2, 0);
18
}
19
20
void RomMitsubishiMLTS2::writeMem(uint16_t address, byte value, EmuTime /*time*/)
21
{
22
	// TODO What are these 4 registers? Are there any more?
23
	//      Is there any mirroring going on?
24
	if        (address == 0x7f00) {
25
		// TODO
26
	} else if (address == 0x7f01) {
27
		// TODO
28
	} else if (address == 0x7f02) {
29
		// TODO
30
	} else if (address == 0x7f03) {
31
		// TODO
32
	} else if (address == 0x7FC0) {
33
		byte bank = value & 0b111;
34
		setRom(2, bank);
35
	} else if ((0x6000 <= address) && (address < 0x8000)) {
36
		ram[address & 0x1FFF] = value;
37
	}
38
}
39
40
byte RomMitsubishiMLTS2::readMem(uint16_t address, EmuTime time)
41
{
42
	return peekMem(address, time);
43
}
44
45
byte RomMitsubishiMLTS2::peekMem(uint16_t address, EmuTime time) const
46
{
47
	// TODO What are these 4 registers? Are there any more?
48
	//      Is there any mirroring going on?
49
	//      Is the bank select register readable? (0x7fc0)
50
	if        (address == 0x7f00) {
51
		return 0xff; // TODO
52
	} else if (address == 0x7f01) {
53
		return 0xff; // TODO
54
	} else if (address == 0x7f02) {
55
		return 0xff; // TODO
56
	} else if (address == 0x7f03) {
57
		return 0xff; // TODO
58
	} else if ((0x6000 <= address) && (address < 0x8000)) {
59
		return ram[address & 0x1FFF];
60
	} else {
61
		return Rom8kBBlocks::peekMem(address, time);
62
	}
63
}
64
65
const byte* RomMitsubishiMLTS2::getReadCacheLine(uint16_t address) const
66
{
67
	if (address == (0x7FC0 & CacheLine::HIGH)) return nullptr;
68
	if ((0x6000 <= address) && (address < 0x8000)) {
69
		return &ram[address & 0x1FFF];
70
	}
71
	return Rom8kBBlocks::getReadCacheLine(address);
72
}
73
74
byte* RomMitsubishiMLTS2::getWriteCacheLine(uint16_t address)
75
{
76
	if (address == (0x7FC0 & CacheLine::HIGH)) return nullptr;
77
	if ((0x6000 <= address) && (address < 0x8000)) {
78
		return &ram[address & 0x1FFF];
79
	}
80
	return unmappedWrite.data();
81
}
82
83
template<typename Archive>
84
void RomMitsubishiMLTS2::serialize(Archive& ar, unsigned /*version*/)
85
{
86
	ar.template serializeBase<Rom8kBBlocks>(*this);
87
}
88
INSTANTIATE_SERIALIZE_METHODS(RomMitsubishiMLTS2);
89
REGISTER_MSXDEVICE(RomMitsubishiMLTS2, "RomMitsubishiMLTS2");
90
91
} // namespace openmsx