OXYGENHUB
◆ main openmsx / src / memory / RomRetroHard31in1.cc
1.1 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
// Retrohard 31-in-1 cartridge
2
//
3
//  31 in 1 cartridges use Port &H94 for mapping 32kB games at their respective
4
//  offsets into 0x4000-0xBFFF
5
6
#include "RomRetroHard31in1.hh"
7
#include "MSXCPUInterface.hh"
8
#include "serialize.hh"
9
#include "unreachable.hh"
10
11
namespace openmsx {
12
13
RomRetroHard31in1::RomRetroHard31in1(const DeviceConfig& config, Rom&& rom_)
14
	: Rom16kBBlocks(config, std::move(rom_))
15
{
16
	reset(EmuTime::dummy());
17
	getCPUInterface().register_IO_Out(0x94, this);
18
}
19
20
RomRetroHard31in1::~RomRetroHard31in1()
21
{
22
	getCPUInterface().unregister_IO_Out(0x94, this);
23
}
24
25
void RomRetroHard31in1::reset(EmuTime time)
26
{
27
	writeIO(0x94, 0, time);
28
}
29
30
void RomRetroHard31in1::writeIO(uint16_t /*port*/, byte value, EmuTime /*time*/)
31
{
32
	byte page = 2 * (value & 0x1F);
33
	// note: we use a mirrored configuration here on purpose.
34
	// Without this, H.E.R.O. doesn't work from the dump I got.
35
	setRom(0, page + 1);
36
	setRom(1, page + 0);
37
	setRom(2, page + 1);
38
	setRom(3, page + 0);
39
}
40
41
byte* RomRetroHard31in1::getWriteCacheLine(uint16_t /*address*/)
42
{
43
	return unmappedWrite.data();
44
}
45
46
REGISTER_MSXDEVICE(RomRetroHard31in1, "RomRetroHard31in1");
47
48
} // namespace openmsx