OSDN Git Service

[VM][General] Merge upstream 2016-03-01. (Pahse 1).
[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 void SYSTEM::save_state(FILEIO* state_fio)
60 {
61         state_fio->FputUint32(STATE_VERSION);
62         state_fio->FputInt32(this_device_id);
63         
64         state_fio->FputUint8(arr);
65         state_fio->FputUint8(nmistat);
66         state_fio->FputUint8(nmimask);
67 }
68
69 bool SYSTEM::load_state(FILEIO* state_fio)
70 {
71         if(state_fio->FgetUint32() != STATE_VERSION) {
72                 return false;
73         }
74         if(state_fio->FgetInt32() != this_device_id) {
75                 return false;
76         }
77         arr = state_fio->FgetUint8();
78         nmistat = state_fio->FgetUint8();
79         nmimask = state_fio->FgetUint8();
80         return true;
81 }
82