OSDN Git Service

[VM][COMMON_VM] Include IO:: class to common_vm.
[csp-qt/common_source_project-fm7.git] / source / src / vm / v30.cpp
1 /*
2         Skelton for retropc emulator
3
4         Origin : MAME i286 core
5         Author : Kyuma.Ohta <whatisthis.sowhat _at_ gmail.com>
6         Date  : 2019.06.27-
7         History: 2019.06.27 Split from i286.cpp.
8
9         [ NEC V30 ]
10 */
11
12 #include "v30.h"
13 #include "debugger.h"
14 #include "i80x86_commondefs.h"
15
16 /* ----------------------------------------------------------------------------
17         MAME i86
18 ---------------------------------------------------------------------------- */
19
20 // Note:
21 // API of bios_int_i86() / bios_caii_i86() has changed.
22 // regs[8] regs[9] are added.These entries set redirect-address by PSEUDO-BIOS.
23 // If need, will add more entries for cycle#.
24 // - 20181126 K.O
25
26 #define cpu_state i8086_state
27 #include "mame/emu/cpu/i86/v30.c"
28 #include "mame/emu/cpu/nec/necdasm.c"
29
30
31 void V30::initialize()
32 {
33         DEVICE::initialize();
34         n_cpu_type = N_CPU_TYPE_V30;
35         _HAS_i80286 = false;
36         _HAS_v30 = true;
37         opaque = CPU_INIT_CALL( v30 );
38         
39         cpu_state *cpustate = (cpu_state *)opaque;
40         cpustate->pic = d_pic;
41         cpustate->program = d_mem;
42         cpustate->io = d_io;
43 //#ifdef I86_PSEUDO_BIOS
44         cpustate->bios = d_bios;
45 //#endif
46 //#ifdef SINGLE_MODE_DMA
47         cpustate->dma = d_dma;
48 //#endif
49         cpustate->emu = emu;
50         cpustate->debugger = d_debugger;
51         cpustate->program_stored = d_mem;
52         cpustate->io_stored = d_io;
53         
54         if(d_debugger != NULL) {
55                 d_debugger->set_context_mem(d_mem);
56                 d_debugger->set_context_io(d_io);
57         }
58 }
59
60 void V30::release()
61 {
62         free(opaque);
63 }
64 void V30::reset()
65 {
66         cpu_state *cpustate = (cpu_state *)opaque;
67         int busreq = cpustate->busreq;
68         int haltreq = cpustate->haltreq;
69
70         CPU_RESET_CALL( v30 );
71         
72         cpustate->pic = d_pic;
73         cpustate->program = d_mem;
74         cpustate->io = d_io;
75 //#ifdef I86_PSEUDO_BIOS
76         cpustate->bios = d_bios;
77 //#endif
78 //#ifdef SINGLE_MODE_DMA
79         cpustate->dma = d_dma;
80 //#endif
81 //#ifdef USE_DEBUGGER
82         cpustate->emu = emu;
83         cpustate->debugger = d_debugger;
84         cpustate->program_stored = d_mem;
85         cpustate->io_stored = d_io;
86 //#endif
87         cpustate->busreq = busreq;
88         cpustate->haltreq = haltreq;
89 }
90
91 int V30::run(int icount)
92 {
93         cpu_state *cpustate = (cpu_state *)opaque;
94         int ret = 0;
95         ret = CPU_EXECUTE_CALL( v30 );
96         return ret;
97 }
98 // Belows are common to V30:: .
99 //uint32_t V30::read_signal(int id)
100 //void V30::write_signal(int id, uint32_t data, uint32_t mask)
101 //void V30::set_intr_line(bool line, bool pending, uint32_t bit)
102 //void V30::set_extra_clock(int icount)
103 //int V30::get_extra_clock()
104 //uint32_t V30::get_pc()
105 //uint32_t V30::get_next_pc()
106 //uint32_t V30::translate_address(int segment, uint32_t offset)
107 //void V30::write_debug_data8(uint32_t addr, uint32_t data)
108 //uint32_t V30::read_debug_data8(uint32_t addr)
109 //void V30::write_debug_data16(uint32_t addr, uint32_t data)
110 //uint32_t V30::read_debug_data16(uint32_t addr)
111 //void V30::write_debug_io8(uint32_t addr, uint32_t data)
112 //uint32_t V30::read_debug_io8(uint32_t addr) {
113 //void V30::write_debug_io16(uint32_t addr, uint32_t data)
114 //uint32_t V30::read_debug_io16(uint32_t addr) {
115 //bool V30::write_debug_reg(const _TCHAR *reg, uint32_t data)
116 //uint32_t V30::read_debug_reg(const _TCHAR *reg)
117 //bool V30::get_debug_regs_info(_TCHAR *buffer, size_t buffer_len)
118 int V30::debug_dasm_with_userdata(uint32_t pc, _TCHAR *buffer, size_t buffer_len, uint32_t userdata)
119 {
120         cpu_state *cpustate = (cpu_state *)opaque;
121         UINT64 eip = pc - cpustate->base[CS];
122         UINT8 ops[16];
123         for(int i = 0; i < 16; i++) {
124                 int wait;
125                 ops[i] = d_mem->read_data8w(pc + i, &wait);
126         }
127         UINT8 *oprom = ops;
128         
129         return CPU_DISASSEMBLE_CALL(nec_generic) & DASMFLAG_LENGTHMASK;
130 }
131