OXYGENHUB
◆ main openmsx / src / memory / RomMSXWrite.cc
1.1 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
// Japanese MSX Write (1)
2
// Identical to ASCII 16kB cartridges, but with 2 extra switch addresses:
3
// 0x6FFF and 0x7FFF
4
5
#include "RomMSXWrite.hh"
6
#include "CacheLine.hh"
7
#include "one_of.hh"
8
#include "serialize.hh"
9
10
namespace openmsx {
11
12
RomMSXWrite::RomMSXWrite(const DeviceConfig& config, Rom&& rom_)
13
	: Rom16kBBlocks(config, std::move(rom_))
14
{
15
	reset(EmuTime::dummy());
16
}
17
18
void RomMSXWrite::reset(EmuTime /*time*/)
19
{
20
	setUnmapped(0);
21
	setRom(1, 0);
22
	setRom(2, 0);
23
	setUnmapped(3);
24
}
25
26
void RomMSXWrite::writeMem(uint16_t address, byte value, EmuTime /*time*/)
27
{
28
	if (((0x6000 <= address) && (address < 0x7800) && !(address & 0x0800)) ||
29
	    (address == one_of(0x6FFF, 0x7FFF))) {
30
		byte region = ((address >> 12) & 1) + 1;
31
		setRom(region, value);
32
	}
33
}
34
35
byte* RomMSXWrite::getWriteCacheLine(uint16_t address)
36
{
37
	if (((0x6000 <= address) && (address < 0x7800) && !(address & 0x0800)) ||
38
	    (address == one_of(0x6FFF & CacheLine::HIGH, 0x7FFF & CacheLine::HIGH))) {
39
		return nullptr;
40
	} else {
41
		return unmappedWrite.data();
42
	}
43
}
44
45
REGISTER_MSXDEVICE(RomMSXWrite, "RomMSXWrite");
46
47
} // namespace openmsx