OXYGENHUB
◆ main openmsx / src / memory / RomKorean128in1.cc
1.5 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
// Korean 128-in-1 cartridge for Sega/MSX, see
2
// https://www.smspower.org/forums/17902-DumpingKorean128128In1CartridgeLikelyPirateMissingOriginalLabel
3
//
4
// Reverse engineered by bsittler.
5
//
6
//    ... the unusual MSX mapper this dump normally would require, where writing
7
//    byte Y to address 0x6000 would map 0x4000-0x5FFF to Y, 0x6000-0x7FFF to Y
8
//    XOR 1, 0x8000-0x9FFF to Y XOR 2, and 0xA000-0xBFFF to Y XOR 3.
9
//
10
// Those are 8KB page numbers, naturally. And yes, it really is XOR and not
11
// addition - sometimes two games share a page and map it differently in a way
12
// that only works when the operation is XOR.
13
14
15
#include "RomKorean128in1.hh"
16
#include "CacheLine.hh"
17
#include "serialize.hh"
18
#include "xrange.hh"
19
20
namespace openmsx {
21
22
RomKorean128in1::RomKorean128in1(const DeviceConfig& config, Rom&& rom_)
23
	: Rom8kBBlocks(config, std::move(rom_))
24
{
25
	reset(EmuTime::dummy());
26
}
27
28
void RomKorean128in1::reset(EmuTime /*time*/)
29
{
30
	setUnmapped(0);
31
	setUnmapped(1);
32
	// TODO: initial mapping not known (?)
33
	for (auto i : xrange(2, 6)) {
34
		setRom(i, i - 2);
35
	}
36
	setUnmapped(6);
37
	setUnmapped(7);
38
}
39
40
void RomKorean128in1::writeMem(uint16_t address, byte value, EmuTime /*time*/)
41
{
42
	if (address == 0x6000) {
43
		for (auto i : xrange(2, 6)) {
44
			setRom(i, value ^ (i - 2));
45
		}
46
	}
47
}
48
49
byte* RomKorean128in1::getWriteCacheLine(uint16_t address)
50
{
51
	if (address == (0x6000 & CacheLine::HIGH)) {
52
		return nullptr;
53
	} else {
54
		return unmappedWrite.data();
55
	}
56
}
57
58
REGISTER_MSXDEVICE(RomKorean128in1, "RomKorean128in1");
59
60
} // namespace openmsx