2 Skelton for retropc emulator
4 Origin : MAME i386 core
5 Author : Takeda.Toshiya
8 [ i386/i486/Pentium/MediaGX ]
11 #include "i386_base.h"
12 #include "libcpu_i386/i386_opdef.h"
14 void I386_BASE::initialize()
16 cpucore = new I386_OPS_BASE;
17 cpucore->cpu_init_i386();
18 cpucore->set_context_pic(d_pic);
19 cpucore->set_context_progmem(d_mem);
20 cpucore->set_context_io(d_io);
21 cpucore->set_shutdown_flag(0);
24 void I386_BASE::release()
26 cpucore->i386_vtlb_free();
27 cpucore->i386_free_state();
31 void I386_BASE::reset()
33 cpucore->cpu_reset_i386();
36 int I386_BASE::run(int cycles)
38 return cpucore->cpu_execute_i386(cycles);
41 void I386_BASE::write_signal(int id, uint32_t data, uint32_t mask)
43 if(id == SIG_CPU_NMI) {
44 cpucore->i386_set_irq_line( INPUT_LINE_NMI, (data & mask) ? HOLD_LINE : CLEAR_LINE);
45 } else if(id == SIG_CPU_IRQ) {
46 cpucore->i386_set_irq_line( INPUT_LINE_IRQ, (data & mask) ? HOLD_LINE : CLEAR_LINE);
47 } else if(id == SIG_CPU_BUSREQ) {
48 cpucore->set_busreq(((data & mask) != 0));
49 } else if(id == SIG_I386_A20) {
50 cpucore->i386_set_a20_line( data & mask);
54 void I386_BASE::set_intr_line(bool line, bool pending, uint32_t bit)
56 cpucore->i386_set_irq_line(INPUT_LINE_IRQ, line ? HOLD_LINE : CLEAR_LINE);
59 void I386_BASE::set_extra_clock(int cycles)
61 cpucore->set_extra_clock(cycles);
64 int I386_BASE::get_extra_clock()
66 return cpucore->get_extra_clock();
69 uint32_t I386_BASE::get_pc()
71 return cpucore->get_prev_pc();
74 uint32_t I386_BASE::get_next_pc()
76 return cpucore->get_pc();
79 void I386_BASE::set_address_mask(uint32_t mask)
81 cpucore->set_address_mask(mask);
84 uint32_t I386_BASE::get_address_mask()
86 return cpucore->get_address_mask();
88 void I386_BASE::set_shutdown_flag(int shutdown)
90 cpucore->set_shutdown_flag(shutdown);
93 int I386_BASE::get_shutdown_flag()
95 return cpucore->get_shutdown_flag();
98 void I386_BASE::set_context_mem(DEVICE* device)
101 if(cpucore != NULL) cpucore->set_context_progmem(d_mem);
104 void I386_BASE::set_context_io(DEVICE* device)
107 if(cpucore != NULL) cpucore->set_context_io(d_io);
110 void I386_BASE::set_context_intr(DEVICE* device)
113 if(cpucore != NULL) cpucore->set_context_pic(d_pic);
117 #include "../../fileio.h"
119 #define STATE_VERSION 1
121 void I386_BASE::save_state(FILEIO* state_fio)
123 state_fio->FputUint32(STATE_VERSION);
124 state_fio->FputInt32(this_device_id);
125 cpucore->save_state(state_fio);
128 bool I386_BASE::load_state(FILEIO* state_fio)
130 if(state_fio->FgetUint32() != STATE_VERSION) {
133 if(state_fio->FgetInt32() != this_device_id) {
136 cpucore->load_state(state_fio);
139 cpucore->set_context_pic(d_pic);
140 cpucore->set_context_progmem(d_mem);
141 cpucore->set_context_io(d_io);