OSDN Git Service

[VM][TK80BS][PC2001][PC8201][PC98HA] Apply new state framework to VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / tk80bs / membus.cpp
1 /*
2         NEC TK-80BS (COMPO BS/80) Emulator 'eTK-80BS'
3         NEC TK-80 Emulator 'eTK-80'
4         NEC TK-85 Emulator 'eTK-85'
5
6         Author : Takeda.Toshiya
7         Date   : 2017.01.13-
8
9         [ memory bus ]
10 */
11
12 #include "membus.h"
13 #include "../i8080.h"
14
15 void MEMBUS::reset()
16 {
17 #if defined(_TK85)
18         pc7 = count = 0;
19 #endif
20         MEMORY::reset();
21 }
22
23 uint32_t MEMBUS::fetch_op(uint32_t addr, int *wait)
24 {
25 #if defined(_TK80BS) || defined(_TK80)
26         if(d_cpu->read_signal(SIG_I8080_INTE) != 0) {
27                 if(config.dipswitch & 1) {
28                         d_cpu->write_signal(SIG_I8080_INTR, 1, 1);
29                 }
30         }
31 #elif defined(_TK85)
32         if(pc7 != 0 && ++count == 4) {
33                 if(config.dipswitch & 1) {
34                         d_cpu->write_signal(SIG_I8085_RST7, 1, 1);
35                 }
36         }
37 #endif
38         return MEMORY::fetch_op(addr, wait);
39 }
40
41 #if defined(_TK85)
42 void MEMBUS::write_signal(int id, uint32_t data, uint32_t mask)
43 {
44         if(id == SIG_MEMBUS_PC7) {
45                 if((pc7 = data & mask) == 0) {
46                         count = 0;
47                 }
48         }
49 }
50 #endif
51
52 #define STATE_VERSION   1
53
54 #include "../../statesub.h"
55
56 void MEMBUS::decl_state()
57 {
58         enter_decl_state(STATE_VERSION);
59
60 #if defined(_TK85)
61         DECL_STATE_ENTRY_UINT32(pc7);
62         DECL_STATE_ENTRY_UINT32(count);
63 #endif
64         MEMORY::decl_state();
65         
66         leave_decl_state();
67 }
68
69 void MEMBUS::save_state(FILEIO* state_fio)
70 {
71 //      state_fio->FputUint32(STATE_VERSION);
72 //      state_fio->FputInt32(this_device_id);
73         
74 //#if defined(_TK85)
75 //      state_fio->FputUint32(pc7);
76 //      state_fio->FputUint32(count);
77 //#endif
78         MEMORY::save_state(state_fio);
79 }
80
81 bool MEMBUS::load_state(FILEIO* state_fio)
82 {
83 //      if(state_fio->FgetUint32() != STATE_VERSION) {
84 //              return false;
85 //      }
86 //      if(state_fio->FgetInt32() != this_device_id) {
87 //              return false;
88 //      }
89 //#if defined(_TK85)
90 //      pc7 = state_fio->FgetUint32();
91 //      count = state_fio->FgetUint32();
92 //#endif
93         return MEMORY::load_state(state_fio);
94 }