OSDN Git Service

[VM] Remove compiler warinings.
[csp-qt/common_source_project-fm7.git] / source / src / vm / ls393.cpp
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2008.04.11-
6
7         [ 74LS393 ]
8 */
9
10 #include "ls393.h"
11
12 void LS393::write_signal(int id, uint32_t data, uint32_t mask)
13 {
14         bool signal = ((data & mask) != 0);
15         if(prev_in && !signal) {
16                 uint32_t prev_count = count++;
17                 for(int i = 0; i < 8; i++) {
18                         if(outputs[i].count) {
19                                 int bit = 1 << i;
20                                 if((prev_count & bit) != (count & bit)) {
21                                         uint32_t val = (count & bit) ? 0xffffffff : 0;
22                                         write_signals(&outputs[i], val);
23                                 }
24                         }
25                 }
26         }
27         prev_in = signal;
28 }
29
30 #define STATE_VERSION   1
31
32 void LS393::save_state(FILEIO* state_fio)
33 {
34         state_fio->FputUint32(STATE_VERSION);
35         state_fio->FputInt32(this_device_id);
36         
37         state_fio->FputUint32(count);
38         state_fio->FputBool(prev_in);
39 }
40
41 bool LS393::load_state(FILEIO* state_fio)
42 {
43         if(state_fio->FgetUint32() != STATE_VERSION) {
44                 return false;
45         }
46         if(state_fio->FgetInt32() != this_device_id) {
47                 return false;
48         }
49         count = state_fio->FgetUint32();
50         prev_in = state_fio->FgetBool();
51         return true;
52 }
53