OSDN Git Service

6b3f65acab448f7a48917cdd9c8dcb6cac004a1d
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc98ha / calendar.cpp
1 /*
2         NEC PC-98LT Emulator 'ePC-98LT'
3         NEC PC-98HA Emulator 'eHANDY98'
4
5         Author : Takeda.Toshiya
6         Date   : 2008.08.14 -
7
8         [ calendar ]
9 */
10
11 #include "calendar.h"
12 #ifndef _PC98HA
13 #include "../upd1990a.h"
14 #endif
15
16 void CALENDAR::initialize()
17 {
18 #ifdef _PC98HA
19         ch = 0;
20 #endif
21 }
22
23 void CALENDAR::write_io8(uint32_t addr, uint32_t data)
24 {
25         switch(addr & 0xffff) {
26 #ifdef _PC98HA
27         case 0x22:
28                 ch = data & 0x0f;
29                 break;
30         case 0x23:
31                 d_rtc->write_io8(ch, data & 0x0f);
32                 break;
33 #else
34         case 0x20:
35                 d_rtc->write_signal(SIG_UPD1990A_CMD, data, 0x07);
36                 d_rtc->write_signal(SIG_UPD1990A_DIN, data, 0x20);
37                 d_rtc->write_signal(SIG_UPD1990A_STB, data, 0x08);
38                 d_rtc->write_signal(SIG_UPD1990A_CLK, data, 0x10);
39                 break;
40 #endif
41         }
42 }
43
44 uint32_t CALENDAR::read_io8(uint32_t addr)
45 {
46 #ifdef _PC98HA
47         switch(addr & 0xffff) {
48         case 0x23:
49                 return d_rtc->read_io8(ch) & 0x0f;
50         }
51 #endif
52         return 0xff;
53 }
54
55 #ifdef _PC98HA
56 #define STATE_VERSION   1
57
58 bool CALENDAR::process_state(FILEIO* state_fio, bool loading)
59 {
60         if(!state_fio->StateCheckUint32(STATE_VERSION)) {
61                 return false;
62         }
63         if(!state_fio->StateCheckInt32(this_device_id)) {
64                 return false;
65         }
66         state_fio->StateUint8(ch);
67         return true;
68 }
69 #endif
70