openMSX
RP5C01.hh
Go to the documentation of this file.
1 // This class implements the RP5C01 chip (RTC)
2 //
3 // * For techncal details on RP5C01 see
4 // http://w3.qahwah.net/joost/openMSX/RP5C01.pdf
5 
6 #ifndef RP5C01_HH
7 #define RP5C01_HH
8 
9 #include "Clock.hh"
10 #include "EnumSetting.hh"
11 #include "openmsx.hh"
12 #include <string>
13 
14 namespace openmsx {
15 
16 class CommandController;
17 class SRAM;
18 
19 class RP5C01
20 {
21 public:
23 
24  RP5C01(CommandController& commandController, SRAM& regs,
25  EmuTime::param time, const std::string& name);
26 
27  void reset(EmuTime::param time);
28  nibble readPort(nibble port, EmuTime::param time);
29  nibble peekPort(nibble port) const;
30  void writePort(nibble port, nibble value, EmuTime::param time);
31 
32  template<typename Archive>
33  void serialize(Archive& ar, unsigned version);
34 
35 private:
36  void initializeTime();
37  void updateTimeRegs(EmuTime::param time);
38  void regs2Time();
39  void time2Regs();
40  void resetAlarm();
41 
42  static const unsigned FREQ = 16384;
43 
44  SRAM& regs;
45  EnumSetting<RTCMode> modeSetting;
46 
47  Clock<FREQ> reference;
48  unsigned fraction;
49  unsigned seconds, minutes, hours;
50  unsigned dayWeek, years, leapYear;
51  int days, months; // these two can be -1
52 
53  nibble modeReg, testReg, resetReg;
54 };
55 
56 } // namespace openmsx
57 
58 #endif
void serialize(Archive &ar, unsigned version)
Definition: RP5C01.cc:256
SRAM
Definition: SRAM.cc:150
nibble peekPort(nibble port) const
Definition: RP5C01.cc:82
RP5C01(CommandController &commandController, SRAM &regs, EmuTime::param time, const std::string &name)
Definition: RP5C01.cc:40
void writePort(nibble port, nibble value, EmuTime::param time)
Definition: RP5C01.cc:99
void reset(EmuTime::param time)
Definition: RP5C01.cc:57
nibble readPort(nibble port, EmuTime::param time)
Definition: RP5C01.cc:65
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
uint8_t nibble
4 bit integer
Definition: openmsx.hh:23