OXYGENHUB
◆ main openmsx / src / memory / RomAscii8kB.cc
1.7 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
// ASCII 8kB cartridges
2
//
3
// this type is used in many japanese-only cartridges.
4
// example of cartridges: Valis(Fantasm Soldier), Dragon Slayer, Outrun,
5
//                        Ashguine 2, ...
6
// The address to change banks:
7
//  bank 1: 0x6000 - 0x67ff (0x6000 used)
8
//  bank 2: 0x6800 - 0x6fff (0x6800 used)
9
//  bank 3: 0x7000 - 0x77ff (0x7000 used)
10
//  bank 4: 0x7800 - 0x7fff (0x7800 used)
11
//
12
// With 'reversedRegs' the same four registers exist, but they are wired to the
13
// memory regions in the opposite order:
14
//  0x4000 - 0x5fff: selected by 0x7800 - 0x7fff
15
//  0x6000 - 0x7fff: selected by 0x7000 - 0x77ff
16
//  0x8000 - 0x9fff: selected by 0x6800 - 0x6fff
17
//  0xa000 - 0xbfff: selected by 0x6000 - 0x67ff
18
// Used by the retail cartridge of XeGrader.
19
20
#include "RomAscii8kB.hh"
21
#include "serialize.hh"
22
#include "xrange.hh"
23
24
namespace openmsx {
25
26
RomAscii8kB::RomAscii8kB(const DeviceConfig& config, Rom&& rom_,
27
                         bool reversedRegs_)
28
	: Rom8kBBlocks(config, std::move(rom_))
29
	, reversedRegs(reversedRegs_)
30
{
31
	RomAscii8kB::reset(EmuTime::dummy());
32
}
33
34
void RomAscii8kB::reset(EmuTime /*time*/)
35
{
36
	setUnmapped(0);
37
	setUnmapped(1);
38
	for (auto i : xrange(2, 6)) {
39
		setRom(i, 0);
40
	}
41
	setUnmapped(6);
42
	setUnmapped(7);
43
}
44
45
void RomAscii8kB::writeMem(uint16_t address, byte value, EmuTime /*time*/)
46
{
47
	if ((0x6000 <= address) && (address < 0x8000)) {
48
		auto reg = (address >> 11) & 3;
49
		byte region = reversedRegs ? byte(5 - reg) : byte(reg + 2);
50
		setRom(region, value);
51
	}
52
}
53
54
byte* RomAscii8kB::getWriteCacheLine(uint16_t address)
55
{
56
	if ((0x6000 <= address) && (address < 0x8000)) {
57
		return nullptr;
58
	} else {
59
		return unmappedWrite.data();
60
	}
61
}
62
63
REGISTER_MSXDEVICE(RomAscii8kB, "RomAscii8kB");
64
65
} // namespace openmsx