OSDN Git Service

[VM][FMTOWNS][MEMORY] Fix setup around memory banks by I/O 0404h and 0480h.
[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 namespace TK80 {
16
17 void MEMBUS::reset()
18 {
19 #if defined(_TK85)
20         pc7 = count = 0;
21 #endif
22         MEMORY::reset();
23 }
24
25 uint32_t MEMBUS::fetch_op(uint32_t addr, int *wait)
26 {
27 #if defined(_TK80BS) || defined(_TK80)
28         if(d_cpu->read_signal(SIG_I8080_INTE) != 0) {
29                 if(config.dipswitch & 1) {
30                         d_cpu->write_signal(SIG_I8080_INTR, 1, 1);
31                 }
32         }
33 #elif defined(_TK85)
34         if(pc7 != 0 && ++count == 4) {
35                 if(config.dipswitch & 1) {
36                         d_cpu->write_signal(SIG_I8085_RST7, 1, 1);
37                 }
38         }
39 #endif
40         return MEMORY::read_data8w(addr, wait);
41 }
42
43 #if defined(_TK85)
44 void MEMBUS::write_signal(int id, uint32_t data, uint32_t mask)
45 {
46         if(id == SIG_MEMBUS_PC7) {
47                 if((pc7 = data & mask) == 0) {
48                         count = 0;
49                 }
50         }
51 }
52 #endif
53
54 #define STATE_VERSION   1
55
56 bool MEMBUS::process_state(FILEIO* state_fio, bool loading)
57 {
58         if(!state_fio->StateCheckUint32(STATE_VERSION)) {
59                 return false;
60         }
61         if(!state_fio->StateCheckInt32(this_device_id)) {
62                 return false;
63         }
64 #if defined(_TK85)
65         state_fio->StateValue(pc7);
66         state_fio->StateValue(count);
67 #endif
68         return MEMORY::process_state(state_fio, loading);
69 }
70
71 }