openMSX
MSXCielTurbo.cc
Go to the documentation of this file.
1 #include "MSXCielTurbo.hh"
2 #include "MSXCPU.hh"
3 #include "LedStatus.hh"
4 #include "serialize.hh"
5 
6 namespace openmsx {
7 
8 MSXCielTurbo::MSXCielTurbo(const DeviceConfig& config)
9  : MSXDevice(config)
10 {
11  reset(EmuTime::dummy());
12 }
13 
14 void MSXCielTurbo::reset(EmuTime::param time)
15 {
16  word port = 0; // dummy
17  writeIO(port, 0, time);
18 }
19 
20 byte MSXCielTurbo::readIO(word /*port*/, EmuTime::param /*time*/)
21 {
22  return lastValue;
23 }
24 
25 byte MSXCielTurbo::peekIO(word /*port*/, EmuTime::param /*time*/) const
26 {
27  return lastValue;
28 }
29 
30 void MSXCielTurbo::writeIO(word /*port*/, byte value, EmuTime::param /*time*/)
31 {
32  lastValue = value;
33  bool enabled = (value & 0x80) != 0;
34  unsigned freq = 3579545;
35  if (enabled) freq *= 2;
36  getCPU().setZ80Freq(freq);
37  getLedStatus().setLed(LedStatus::TURBO, enabled);
38 }
39 
40 template<typename Archive>
41 void MSXCielTurbo::serialize(Archive& ar, unsigned /*version*/)
42 {
43  ar.template serializeBase<MSXDevice>(*this);
44 
45  ar.serialize("value", lastValue);
46  if (!ar.isLoader()) {
47  word port = 0; // dummy
48  writeIO(port, lastValue, EmuTime::dummy());
49  }
50 }
52 REGISTER_MSXDEVICE(MSXCielTurbo, "CielTurbo");
53 
54 } // namespace openmsx
bool getEnum() const noexcept
Definition: EnumSetting.hh:96
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MSXCielTurbo.cc:20
void serialize(Archive &ar, unsigned version)
Definition: MSXCielTurbo.cc:41
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition: MSXDevice.hh:307
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXCielTurbo.cc:14
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX...
Definition: MSXDevice.hh:31
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXCielTurbo.cc:25
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
Definition: MSXCielTurbo.cc:30
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981