| 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; |
| 18 |
writeIO(port, 0, time); |
| 19 |
} |
| 20 |
|
| 21 |
byte MSXCielTurbo::readIO(uint16_t , EmuTime ) |
| 22 |
{ |
| 23 |
return lastValue; |
| 24 |
} |
| 25 |
|
| 26 |
byte MSXCielTurbo::peekIO(uint16_t , EmuTime ) const |
| 27 |
{ |
| 28 |
return lastValue; |
| 29 |
} |
| 30 |
|
| 31 |
void MSXCielTurbo::writeIO(uint16_t , byte value, EmuTime ) |
| 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 ) |
| 43 |
{ |
| 44 |
ar.template serializeBase<MSXDevice>(*this); |
| 45 |
|
| 46 |
ar.serialize("value", lastValue); |
| 47 |
if constexpr (!Archive::IS_LOADER) { |
| 48 |
uint16_t port = 0; |
| 49 |
writeIO(port, lastValue, EmuTime::dummy()); |
| 50 |
} |
| 51 |
} |
| 52 |
INSTANTIATE_SERIALIZE_METHODS(MSXCielTurbo); |
| 53 |
REGISTER_MSXDEVICE(MSXCielTurbo, "CielTurbo"); |
| 54 |
|
| 55 |
} |