OSDN Git Service

[VM][Qt] Add SANYOPHC-20, PHC-25 and SEIKO MAP-1010 .
[csp-qt/common_source_project-fm7.git] / source / src / vm / or.cpp
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2008.06.10-
6
7         [ or gate ]
8 */
9
10 #include "or.h"
11
12 void OR::write_signal(int id, uint32 data, uint32 mask)
13 {
14         if(data & mask) {
15                 bits_in |= id;
16         } else {
17                 bits_in &= ~id;
18         }
19         bool next = (bits_in != 0);
20         if(prev != next || first) {
21                 write_signals(&outputs, next ? 0xffffffff : 0);
22                 prev = next;
23                 first = false;
24         }
25 }
26
27 #define STATE_VERSION   1
28
29 void OR::save_state(FILEIO* state_fio)
30 {
31         state_fio->FputUint32(STATE_VERSION);
32         state_fio->FputInt32(this_device_id);
33         
34         state_fio->FputUint32(bits_in);
35         state_fio->FputBool(prev);
36         state_fio->FputBool(first);
37 }
38
39 bool OR::load_state(FILEIO* state_fio)
40 {
41         if(state_fio->FgetUint32() != STATE_VERSION) {
42                 return false;
43         }
44         if(state_fio->FgetInt32() != this_device_id) {
45                 return false;
46         }
47         bits_in = state_fio->FgetUint32();
48         prev = state_fio->FgetBool();
49         first = state_fio->FgetBool();
50         return true;
51 }
52