OSDN Git Service

[General] Convert sourcecode's CRLF format: DOS(WINDOWS) to Unix, to apply patches...
[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 #include "../fileio.h"
12
13 void OR::write_signal(int id, uint32 data, uint32 mask)
14 {
15         if(data & mask) {
16                 bits_in |= id;
17         } else {
18                 bits_in &= ~id;
19         }
20         bool next = (bits_in != 0);
21         if(prev != next || first) {
22                 write_signals(&outputs, next ? 0xffffffff : 0);
23                 prev = next;
24                 first = false;
25         }
26 }
27
28 #define STATE_VERSION   1
29
30 void OR::save_state(FILEIO* state_fio)
31 {
32         state_fio->FputUint32(STATE_VERSION);
33         state_fio->FputInt32(this_device_id);
34         
35         state_fio->FputUint32(bits_in);
36         state_fio->FputBool(prev);
37         state_fio->FputBool(first);
38 }
39
40 bool OR::load_state(FILEIO* state_fio)
41 {
42         if(state_fio->FgetUint32() != STATE_VERSION) {
43                 return false;
44         }
45         if(state_fio->FgetInt32() != this_device_id) {
46                 return false;
47         }
48         bits_in = state_fio->FgetUint32();
49         prev = state_fio->FgetBool();
50         first = state_fio->FgetBool();
51         return true;
52 }
53