OXYGENHUB
◆ main openmsx / src / MSXResetStatusRegister.cc
1.1 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "MSXResetStatusRegister.hh"
2
3
#include "serialize.hh"
4
5
namespace openmsx {
6
7
MSXResetStatusRegister::MSXResetStatusRegister(const DeviceConfig& config)
8
	: MSXDevice(config)
9
	, inverted(config.getChildDataAsBool("inverted", false))
10
{
11
	reset(EmuTime::dummy());
12
}
13
14
void MSXResetStatusRegister::reset(EmuTime /*time*/)
15
{
16
	status = inverted ? 0xFF : 0x00;
17
}
18
19
byte MSXResetStatusRegister::readIO(uint16_t port, EmuTime time)
20
{
21
	return peekIO(port, time);
22
}
23
24
byte MSXResetStatusRegister::peekIO(uint16_t /*port*/, EmuTime /*time*/) const
25
{
26
	return status;
27
}
28
29
void MSXResetStatusRegister::writeIO(uint16_t /*port*/, byte value, EmuTime /*time*/)
30
{
31
	if (inverted) {
32
		status = value | 0x7F;
33
	} else {
34
		status = (status & 0x20) | (value & 0xA0);
35
	}
36
}
37
38
template<typename Archive>
39
void MSXResetStatusRegister::serialize(Archive& ar, unsigned /*version*/)
40
{
41
	ar.template serializeBase<MSXDevice>(*this);
42
	ar.serialize("status", status);
43
}
44
INSTANTIATE_SERIALIZE_METHODS(MSXResetStatusRegister);
45
REGISTER_MSXDEVICE(MSXResetStatusRegister, "F4Device"); // TODO: find a way to handle renames of classes and keep bw compat with savestates....
46
47
} // namespace openmsx