2 Skelton for retropc emulator
5 Author : Takeda.Toshiya
16 /* ----------------------------------------------------------------------------
18 ---------------------------------------------------------------------------- */
24 /*****************************************************************************/
25 /* src/emu/devcpu.h */
27 // CPU interface functions
28 #define READ8_HANDLER(name) UINT8 name(h6280_Regs *cpustate, offs_t offset)
29 #define WRITE8_HANDLER(name) void name(h6280_Regs *cpustate, offs_t offset, UINT8 data)
31 #include "mame/emu/cpu/h6280/h6280.h"
32 //#include "mame/emu/cpu/h6280/h6280.c"
34 //#include "mame/emu/cpu/h6280/6280dasm.c"
38 void HUC6280::initialize()
40 HUC6280_BASE::initialize();
43 h6280_Regs *cpustate = (h6280_Regs *)opaque;
45 cpustate->debugger = d_debugger;
46 cpustate->program_stored = d_mem;
47 cpustate->io_stored = d_io;
49 d_debugger->set_context_mem(d_mem);
50 d_debugger->set_context_io(d_io);
54 void HUC6280::release()
61 HUC6280_BASE::reset();
63 h6280_Regs *cpustate = (h6280_Regs *)opaque;
65 cpustate->debugger = d_debugger;
66 cpustate->program_stored = d_mem;
67 cpustate->io_stored = d_io;
71 int HUC6280::run(int clock)
73 h6280_Regs *cpustate = (h6280_Regs *)opaque;
83 // run only one opcode
84 return run_one_opecode();
88 int first_icount = icount;
90 // run cpu while given clocks
91 while(icount > 0 && !busreq) {
92 icount -= run_one_opecode();
94 // if busreq is raised, spin cpu while remained clock
95 if(icount > 0 && busreq) {
97 total_icount += icount;
101 return first_icount - icount;
105 int HUC6280::run_one_opecode()
107 h6280_Regs *cpustate = (h6280_Regs *)opaque;
109 d_debugger->add_cpu_trace(cpustate->pc.w.l);
111 int passed_icount = HUC6280_BASE::run_one_opecode();
113 total_icount += passed_icount;
115 return passed_icount;
118 #define STATE_VERSION 5
120 void HUC6280::save_state(FILEIO* state_fio)
122 state_fio->FputUint32(STATE_VERSION);
123 state_fio->FputInt32(this_device_id);
126 save_state_registers(state_fio);
128 state_fio->FputUint64(total_icount);
130 state_fio->FputInt32(icount);
131 state_fio->FputBool(busreq);
134 bool HUC6280::load_state(FILEIO* state_fio)
136 if(state_fio->FgetUint32() != STATE_VERSION) {
139 if(state_fio->FgetInt32() != this_device_id) {
143 total_icount = prev_total_icount = state_fio->FgetUint64();
145 load_state_registers(state_fio);
146 icount = state_fio->FgetInt32();
147 busreq = state_fio->FgetBool();
150 h6280_Regs *cpustate = (h6280_Regs *)opaque;
151 cpustate->program = d_mem;
155 cpustate->debugger = d_debugger;
156 cpustate->program_stored = d_mem;
157 cpustate->io_stored = d_io;