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()
17 cpucore = new I386_OPS_BASE;
18 cpucore->cpu_init_i386();
19 cpucore->set_context_pic(d_pic);
20 cpucore->set_context_progmem(d_mem);
21 cpucore->set_context_io(d_io);
22 cpucore->set_shutdown_flag(0);
25 void I386_BASE::release()
27 cpucore->i386_vtlb_free();
28 cpucore->i386_free_state();
32 void I386_BASE::reset()
34 cpucore->cpu_reset_i386();
37 int I386_BASE::run(int cycles)
39 return cpucore->cpu_execute_i386(cycles);
42 void I386_BASE::write_signal(int id, uint32_t data, uint32_t mask)
44 if(id == SIG_CPU_NMI) {
45 cpucore->i386_set_irq_line( INPUT_LINE_NMI, (data & mask) ? HOLD_LINE : CLEAR_LINE);
46 } else if(id == SIG_CPU_IRQ) {
47 cpucore->i386_set_irq_line( INPUT_LINE_IRQ, (data & mask) ? HOLD_LINE : CLEAR_LINE);
48 } else if(id == SIG_CPU_BUSREQ) {
49 cpucore->set_busreq(((data & mask) != 0));
50 } else if(id == SIG_I386_A20) {
51 cpucore->i386_set_a20_line( data & mask);
55 void I386_BASE::set_intr_line(bool line, bool pending, uint32_t bit)
57 cpucore->i386_set_irq_line(INPUT_LINE_IRQ, line ? HOLD_LINE : CLEAR_LINE);
60 void I386_BASE::set_extra_clock(int cycles)
62 cpucore->set_extra_clock(cycles);
65 int I386_BASE::get_extra_clock()
67 return cpucore->get_extra_clock();
70 uint32_t I386_BASE::get_pc()
72 return cpucore->get_prev_pc();
75 uint32_t I386_BASE::get_next_pc()
77 return cpucore->get_pc();
80 void I386_BASE::set_address_mask(uint32_t mask)
82 cpucore->set_address_mask(mask);
84 // TODO: how does A20M and the tlb interact
85 cpucore->vtlb_flush_dynamic();
88 uint32_t I386_BASE::get_address_mask()
90 return cpucore->get_address_mask();
92 void I386_BASE::set_shutdown_flag(int shutdown)
94 cpucore->set_shutdown_flag(shutdown);
97 int I386_BASE::get_shutdown_flag()
99 return cpucore->get_shutdown_flag();
102 void I386_BASE::set_context_mem(DEVICE* device)
105 if(cpucore != NULL) cpucore->set_context_progmem(d_mem);
108 void I386_BASE::set_context_io(DEVICE* device)
111 if(cpucore != NULL) cpucore->set_context_io(d_io);
114 void I386_BASE::set_context_intr(DEVICE* device)
117 if(cpucore != NULL) cpucore->set_context_pic(d_pic);
121 #include "../../fileio.h"
123 #define STATE_VERSION 1
125 void I386_BASE::save_state(FILEIO* state_fio)
127 state_fio->FputUint32(STATE_VERSION);
128 state_fio->FputInt32(this_device_id);
129 cpucore->save_state(state_fio);
132 bool I386_BASE::load_state(FILEIO* state_fio)
134 if(state_fio->FgetUint32() != STATE_VERSION) {
137 if(state_fio->FgetInt32() != this_device_id) {
140 cpucore->load_state(state_fio);
143 cpucore->set_context_pic(d_pic);
144 cpucore->set_context_progmem(d_mem);
145 cpucore->set_context_io(d_io);