OXYGENHUB
◆ main openmsx / src / memory / FraelSwitchableROM.cc
1.9 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "FraelSwitchableROM.hh"
2
3
#include "serialize.hh"
4
5
/*
6
 * Information as reverse engineered by FRS:
7
 *
8
 * Curiously, the machine works without the boot-logo+firmware ROM, because the
9
 * MainBIOS checks for its presence. If it's not there, it just skips the logo and
10
 * the menu. Maybe they were planning a cheaper version without that ROM.
11
 *
12
 * The boot-logo+firmware ROM is selected by the bit7 of the I/O port 90h. This is
13
 * the same port that has the strobe bit (bit-1) in normal MSX computers. Besides
14
 * the extra bit, the rest of the printer port seems to be pretty ordinary.
15
 *
16
 * Bit7=0: Select Frael MainBIOS ROM on slot-0
17
 * Bit7=1: Select the boot-logo+firmware ROM on slot-0
18
 */
19
20
namespace openmsx {
21
22
FraelSwitchableROM::FraelSwitchableROM(DeviceConfig& config)
23
	: MSXDevice(config)
24
	, basicBiosRom(getName() + " BASIC/BIOS", "rom", config, "basicbios")
25
	, firmwareRom (getName() + " firmware"  , "rom", config, "firmware" )
26
{
27
	reset(EmuTime::dummy());
28
}
29
30
void FraelSwitchableROM::writeIO(uint16_t /*port*/, byte value, EmuTime /*time*/)
31
{
32
	bool newValue = value & 0x80;
33
	if (newValue != firmwareSelected) {
34
		firmwareSelected = newValue;
35
		invalidateDeviceRCache();
36
	}
37
}
38
39
void FraelSwitchableROM::reset(EmuTime /*time*/)
40
{
41
	firmwareSelected = false;
42
	invalidateDeviceRCache();
43
}
44
45
byte FraelSwitchableROM::readMem(uint16_t address, EmuTime /*time*/)
46
{
47
	return *getReadCacheLine(address);
48
}
49
50
const byte* FraelSwitchableROM::getReadCacheLine(uint16_t start) const
51
{
52
	return firmwareSelected ? &firmwareRom[start & (firmwareRom.size() - 1)] :
53
		&basicBiosRom[start & (basicBiosRom.size() - 1)];
54
}
55
56
template<typename Archive>
57
void FraelSwitchableROM::serialize(Archive& ar, unsigned /*version*/)
58
{
59
	ar.template serializeBase<MSXDevice>(*this);
60
	ar.serialize("firmwareSelected", firmwareSelected);
61
}
62
INSTANTIATE_SERIALIZE_METHODS(FraelSwitchableROM);
63
REGISTER_MSXDEVICE(FraelSwitchableROM, "FraelSwitchableROM");
64
65
} // namespace openmsx