OSDN Git Service

[VM][WIP] Pre-process to apply new state framework.Still not buildable.
[csp-qt/common_source_project-fm7.git] / source / src / vm / fmr30 / system.cpp
1 /*
2         FUJITSU FMR-30 Emulator 'eFMR-30'
3
4         Author : Takeda.Toshiya
5         Date   : 2008.12.31 -
6
7         [ system ]
8 */
9
10 #include "system.h"
11
12 void SYSTEM::initialize()
13 {
14         arr = nmistat = 0;
15         nmimask = 0xf0;
16 }
17
18 void SYSTEM::write_io8(uint32_t addr, uint32_t data)
19 {
20         switch(addr & 0xffff) {
21         case 0x46:
22                 nmistat &= ~data;
23                 break;
24         case 0x47:
25                 nmimask = data;
26                 break;
27         case 0xff00:
28                 arr = data;
29                 break;
30         }
31 }
32
33 uint32_t SYSTEM::read_io8(uint32_t addr)
34 {
35         switch(addr & 0xffff) {
36         case 0x18:
37                 // modem:       no
38                 // scsi:        yes
39                 // fd23:        3.5inch
40                 // ext-ram:     yes (1mb)
41                 // co-pro       no
42                 return 0x24;
43         case 0x20:
44         case 0x21:
45                 // isrr high/low
46                 return 0;
47         case 0x46:
48                 return nmistat;
49         case 0x47:
50                 return nmimask;
51         case 0xff00:
52                 return arr;
53         }
54         return 0xff;
55 }
56
57 #define STATE_VERSION   1
58
59 #include "../../statesub.h"
60
61 void SYSTEM::decl_state()
62 {
63         enter_decl_state(STATE_VERSION);
64         
65         DECL_STATE_ENTRY_UINT8(arr);
66         DECL_STATE_ENTRY_UINT8(nmistat);
67         DECL_STATE_ENTRY_UINT8(nmimask);
68
69         leave_decl_state();
70 }
71
72 void SYSTEM::save_state(FILEIO* state_fio)
73 {
74         if(state_entry != NULL) {
75                 state_entry->save_state(state_fio);
76         }
77
78 //      state_fio->FputUint32(STATE_VERSION);
79 //      state_fio->FputInt32(this_device_id);
80         
81 //      state_fio->FputUint8(arr);
82 //      state_fio->FputUint8(nmistat);
83 //      state_fio->FputUint8(nmimask);
84 }
85
86 bool SYSTEM::load_state(FILEIO* state_fio)
87 {
88         bool mb = false;
89         if(state_entry != NULL) {
90                 mb = state_entry->load_state(state_fio);
91         }
92         if(!mb) {
93                 return false;
94         }
95
96 //      if(state_fio->FgetUint32() != STATE_VERSION) {
97 //              return false;
98 //      }
99 //      if(state_fio->FgetInt32() != this_device_id) {
100 //              return false;
101 //      }
102 //      arr = state_fio->FgetUint8();
103 //      nmistat = state_fio->FgetUint8();
104 //      nmimask = state_fio->FgetUint8();
105         return true;
106 }
107
108 bool SYSTEM::process_state(FILEIO* state_fio, bool loading)
109 {
110         if(!state_fio->StateCheckUint32(STATE_VERSION)) {
111                 return false;
112         }
113         if(!state_fio->StateCheckInt32(this_device_id)) {
114                 return false;
115         }
116         state_fio->StateUint8(arr);
117         state_fio->StateUint8(nmistat);
118         state_fio->StateUint8(nmimask);
119         return true;
120 }