OXYGENHUB
◆ main openmsx / src / MSXCielTurbo.cc
1.2 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "MSXCielTurbo.hh"
2
3
#include "LedStatus.hh"
4
#include "MSXCPU.hh"
5
#include "serialize.hh"
6
7
namespace openmsx {
8
9
MSXCielTurbo::MSXCielTurbo(const DeviceConfig& config)
10
	: MSXDevice(config)
11
{
12
	reset(EmuTime::dummy());
13
}
14
15
void MSXCielTurbo::reset(EmuTime time)
16
{
17
	uint16_t port = 0; // dummy
18
	writeIO(port, 0, time);
19
}
20
21
byte MSXCielTurbo::readIO(uint16_t /*port*/, EmuTime /*time*/)
22
{
23
	return lastValue;
24
}
25
26
byte MSXCielTurbo::peekIO(uint16_t /*port*/, EmuTime /*time*/) const
27
{
28
	return lastValue;
29
}
30
31
void MSXCielTurbo::writeIO(uint16_t /*port*/, byte value, EmuTime /*time*/)
32
{
33
	lastValue = value;
34
	bool enabled = (value & 0x80) != 0;
35
	unsigned freq = 3579545;
36
	if (enabled) freq *= 2;
37
	getCPU().setZ80Freq(freq);
38
	getLedStatus().setLed(LedStatus::TURBO, enabled);
39
}
40
41
template<typename Archive>
42
void MSXCielTurbo::serialize(Archive& ar, unsigned /*version*/)
43
{
44
	ar.template serializeBase<MSXDevice>(*this);
45
46
	ar.serialize("value", lastValue);
47
	if constexpr (!Archive::IS_LOADER) {
48
		uint16_t port = 0; // dummy
49
		writeIO(port, lastValue, EmuTime::dummy());
50
	}
51
}
52
INSTANTIATE_SERIALIZE_METHODS(MSXCielTurbo);
53
REGISTER_MSXDEVICE(MSXCielTurbo, "CielTurbo");
54
55
} // namespace openmsx