OXYGENHUB
◆ main openmsx / src / memory / RomWonderKid.cc
1.9 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#include "RomWonderKid.hh"
2
3
// Mapper reverse engineered by Omar Cornut.
4
// Based on the Wonder Kid game for Game Gear, that is fully MSX compatible.
5
//
6
// Only 1 register works and reacts to the whole $8000..BFFF address range
7
//
8
// reg $0000 mem $0000..$3fff -- return page 0
9
// reg $0001 mem $0000..$3fff -- "
10
//
11
// reg $4000 mem $4000..$7fff -- return page 0
12
// reg $7fff mem $4000..$7fff -- "
13
//
14
// reg $7fff mem $8000..$bfff --
15
// reg $8000 mem $8000..$bfff ok
16
// reg $8001 mem $8000..$bfff ok
17
// reg $BFFF mem $8000..$bfff ok
18
// reg $C000 mem $8000..$bfff --
19
//
20
//
21
// Restating more simply: Actual Wonder Kid mapper only has a single register
22
// which is mirrored across all of 0x8000-0xbfff, and writing to any of the
23
// mirrors remaps all of 0x8000-0xbfff. Writing in 0x0000-0x7fff, and
24
// 0xc000-... has no effect.
25
// 0x0000-0x3fff always shows page 0, as does 0x4000-0x7fff
26
// The mapper does not respond to reads in 0xc000-0xffff
27
28
namespace openmsx {
29
30
RomWonderKid::RomWonderKid(const DeviceConfig& config, Rom&& rom_)
31
	: Rom16kBBlocks(config, std::move(rom_))
32
{
33
	reset(EmuTime::dummy());
34
}
35
36
void RomWonderKid::reset(EmuTime /*time*/)
37
{
38
	setRom(0, 0); // fixed
39
	setRom(1, 0); // fixed
40
	setRom(2, 2); // actually confirmed by Omar
41
	setUnmapped(3);
42
}
43
44
byte RomWonderKid::peekMem(uint16_t address, EmuTime time) const
45
{
46
	if (address < 0xC000) {
47
		return Rom16kBBlocks::peekMem(address, time);
48
	}
49
	return 0xff;
50
}
51
52
byte RomWonderKid::readMem(uint16_t address, EmuTime time)
53
{
54
	return peekMem(address, time);
55
}
56
57
void RomWonderKid::writeMem(uint16_t address, byte value, EmuTime /*time*/)
58
{
59
	if ((0x8000 <= address) && (address < 0xC000)) {
60
		setRom(2, value);
61
	}
62
}
63
64
byte* RomWonderKid::getWriteCacheLine(uint16_t address)
65
{
66
	if ((0x8000 <= address) && (address < 0xC000)) {
67
		return nullptr;
68
	} else {
69
		return unmappedWrite.data();
70
	}
71
}
72
73
REGISTER_MSXDEVICE(RomWonderKid, "RomWonderKid");
74
75
} // namespace openmsx