OXYGENHUB
◆ main openmsx / src / memory / RomNamco.cc
1.3 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#include "RomNamco.hh"
2
3
#include "MSXException.hh"
4
5
#include "xrange.hh"
6
7
namespace openmsx {
8
9
RomNamco::RomNamco(const DeviceConfig& config, Rom&& rom_)
10
	: Rom8kBBlocks(config, std::move(rom_))
11
{
12
	// Namco's MSX arcade ports (Galaga, Dig Dug, Bosconian, King &
13
	// Balloon) use a 16kB ROM chip on a cartridge that ties the chip's A13
14
	// line to the MSX A15 line and leaves the MSX A13/A14 lines
15
	// unconnected. So MSX A15 selects which 8kB half of the chip is
16
	// visible, and that half is mirrored across the whole 32kB region:
17
	//   0x0000-0x7FFF -> first  8kB block
18
	//   0x8000-0xFFFF -> second 8kB block
19
	// As a regular cartridge this is active in pages 1+2, giving:
20
	//   0x4000-0x7FFF -> block 0 (mirrored at 0x6000-0x7FFF)
21
	//   0x8000-0xBFFF -> block 1 (mirrored at 0xA000-0xBFFF)
22
	//
23
	// Note: dumping such a cartridge through the MSX address space yields a
24
	// 32kB image with each 8kB block doubled ([b0,b0,b1,b1]). Those (more
25
	// common) overdumps already load correctly as the plain 'Mirrored'
26
	// type; this mapper exists for the trimmed 16kB originals.
27
	if (rom.size() != 0x4000) {
28
		throw MSXException(rom.getName(),
29
			": Namco ROM must be exactly 16kB.");
30
	}
31
	for (auto page : xrange(8)) {
32
		setRom(page, (page < 4) ? 0 : 1);
33
	}
34
}
35
36
REGISTER_MSXDEVICE(RomNamco, "RomNamco");
37
38
} // namespace openmsx