OSDN Git Service

[VM][COMMON_VM] Include IO:: class to common_vm.
[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 bool LS393::process_state(FILEIO* state_fio, bool loading)
33 {
34         if(!state_fio->StateCheckUint32(STATE_VERSION)) {
35                 return false;
36         }
37         if(!state_fio->StateCheckInt32(this_device_id)) {
38                 return false;
39         }
40         state_fio->StateValue(count);
41         state_fio->StateValue(prev_in);
42         return true;
43 }
44