openMSX
MSXRTC.cc
Go to the documentation of this file.
1#include "MSXRTC.hh"
2#include "serialize.hh"
3#include "unreachable.hh"
4
5namespace openmsx {
6
8 : MSXDevice(config)
9 , sram(getName() + " SRAM", 4 * 13, config)
10 , rp5c01(getCommandController(), sram, getCurrentTime(), getName())
11{
13}
14
15void MSXRTC::reset(EmuTime::param time)
16{
17 // TODO verify on real hardware .. how?
18 // - registerLatch set to zero or some other value?
19 // - only on power-up or also on reset?
20 registerLatch = 0;
21 rp5c01.reset(time);
22}
23
24byte MSXRTC::readIO(word /*port*/, EmuTime::param time)
25{
26 return rp5c01.readPort(registerLatch, time) | 0xF0;
27}
28
29byte MSXRTC::peekIO(word /*port*/, EmuTime::param /*time*/) const
30{
31 return rp5c01.peekPort(registerLatch) | 0xF0;
32}
33
34void MSXRTC::writeIO(word port, byte value, EmuTime::param time)
35{
36 switch (port & 0x01) {
37 case 0:
38 registerLatch = value & 0x0F;
39 break;
40 case 1:
41 rp5c01.writePort(registerLatch, value & 0x0F, time);
42 break;
43 default:
45 }
46}
47
48template<typename Archive>
49void MSXRTC::serialize(Archive& ar, unsigned /*version*/)
50{
51 ar.template serializeBase<MSXDevice>(*this);
52 ar.serialize("sram", sram,
53 "rp5c01", rp5c01,
54 "registerLatch", registerLatch);
55}
58
59} // namespace openmsx
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:34
EmuTime::param getCurrentTime() const
Definition: MSXDevice.cc:125
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXRTC.cc:15
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXRTC.cc:29
MSXRTC(const DeviceConfig &config)
Definition: MSXRTC.cc:7
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MSXRTC.cc:24
void serialize(Archive &ar, unsigned version)
Definition: MSXRTC.cc:49
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: MSXRTC.cc:34
nibble readPort(nibble port, EmuTime::param time)
Definition: RP5C01.cc:68
void reset(EmuTime::param time)
Definition: RP5C01.cc:60
nibble peekPort(nibble port) const
Definition: RP5C01.cc:85
void writePort(nibble port, nibble value, EmuTime::param time)
Definition: RP5C01.cc:102
std::string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:730
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:1021
#define UNREACHABLE
Definition: unreachable.hh:38