OSDN Git Service

4212ea5a8b9e645f38dda0922401203b948c1ca4
[csp-qt/common_source_project-fm7.git] / source / src / vm / msx / rtcif.cpp
1 /*
2         ASCII MSX2 Emulator 'yaMSX2'
3
4         Author : umaiboux
5         Date   : 2014.12.xx-
6
7         modified by Takeda.Toshiya
8
9         [ rtc i/f ]
10 */
11
12 #include "rtcif.h"
13
14 void RTCIF::write_io8(uint32_t addr, uint32_t data)
15 {
16         switch(addr & 1) {
17         case 0:
18                 adrs = data & 0x0f;
19                 break;
20         case 1:
21                 d_rtc->write_io8(adrs, data & 0x0f);
22                 break;
23         }
24 }
25
26 uint32_t RTCIF::read_io8(uint32_t addr)
27 {
28         return d_rtc->read_io8(adrs);
29 }
30
31 #define STATE_VERSION   1
32
33 #include "../../statesub.h"
34
35 void RTCIF::decl_state()
36 {
37         enter_decl_state(STATE_VERSION);
38
39         DECL_STATE_ENTRY_UINT8(adrs);
40         
41         leave_decl_state();
42 }
43
44 void RTCIF::save_state(FILEIO* state_fio)
45 {
46         if(state_entry != NULL) {
47                 state_entry->save_state(state_fio);
48         }
49 //      state_fio->FputUint32(STATE_VERSION);
50 //      state_fio->FputInt32(this_device_id);
51         
52 //      state_fio->FputUint8(adrs);
53 }
54
55 bool RTCIF::load_state(FILEIO* state_fio)
56 {
57         bool mb = false;
58         if(state_entry != NULL) {
59                 mb = state_entry->load_state(state_fio);
60         }
61         if(!mb) {
62                 return false;
63         }
64 //      if(state_fio->FgetUint32() != STATE_VERSION) {
65 //              return false;
66 //      }
67 //      if(state_fio->FgetInt32() != this_device_id) {
68 //              return false;
69 //      }
70 //      adrs = state_fio->FgetUint8();
71         return true;
72 }
73