OXYGENHUB
◆ main openmsx / src / memory / RomHarryFox.cc
1.1 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
// This mapper is used for the game "Harry Fox Yki no Maoh"
2
3
/** Thanks to enen for testing this on a real cartridge:
4
 *
5
 * Writing to 0x6xxx, 0 or 1, will switch bank 0 or 2 into 0x4000-0x7fff
6
 * Writing to 0x7xxx, 0 or 1, will switch bank 1 or 3 into 0x8000-0xbfff
7
 * 0x0000-0x3fff and 0xc000-0xffff are unmapped (read as 0xff)
8
 */
9
10
#include "RomHarryFox.hh"
11
#include "serialize.hh"
12
13
namespace openmsx {
14
15
RomHarryFox::RomHarryFox(const DeviceConfig& config, Rom&& rom_)
16
	: Rom16kBBlocks(config, std::move(rom_))
17
{
18
	reset(EmuTime::dummy());
19
}
20
21
void RomHarryFox::reset(EmuTime /*time*/)
22
{
23
	setUnmapped(0);
24
	setRom(1, 0);
25
	setRom(2, 1);
26
	setUnmapped(3);
27
}
28
29
void RomHarryFox::writeMem(uint16_t address, byte value, EmuTime /*time*/)
30
{
31
	if        ((0x6000 <= address) && (address < 0x7000)) {
32
		setRom(1, 2 * (value & 1) + 0);
33
	} else if ((0x7000 <= address) && (address < 0x8000)) {
34
		setRom(2, 2 * (value & 1) + 1);
35
	}
36
}
37
38
byte* RomHarryFox::getWriteCacheLine(uint16_t address)
39
{
40
	if ((0x6000 <= address) && (address < 0x8000)) {
41
		return nullptr;
42
	} else {
43
		return unmappedWrite.data();
44
	}
45
}
46
47
REGISTER_MSXDEVICE(RomHarryFox, "RomHarryFox");
48
49
} // namespace openmsx