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;
106 int HUC6280::run_one_opecode()
108 h6280_Regs *cpustate = (h6280_Regs *)opaque;
110 d_debugger->add_cpu_trace(cpustate->pc.w.l);
112 int passed_icount = HUC6280_BASE::run_one_opecode();
114 total_icount += passed_icount;
116 return passed_icount;
119 #define STATE_VERSION 5
121 bool HUC6280::process_state(FILEIO* state_fio, bool loading)
123 h6280_Regs *cpustate = (h6280_Regs *)opaque;
125 if(!state_fio->StateCheckUint32(STATE_VERSION)) {
128 if(!state_fio->StateCheckInt32(this_device_id)) {
131 state_fio->StateValue(cpustate->ICount);
132 state_fio->StateValue(cpustate->ppc);
133 state_fio->StateValue(cpustate->pc);
134 state_fio->StateValue(cpustate->sp);
135 state_fio->StateValue(cpustate->zp);
136 state_fio->StateValue(cpustate->ea);
137 state_fio->StateValue(cpustate->a);
138 state_fio->StateValue(cpustate->x);
139 state_fio->StateValue(cpustate->y);
140 state_fio->StateValue(cpustate->p);
141 state_fio->StateArray(cpustate->mmr, sizeof(cpustate->mmr), 1);
142 state_fio->StateValue(cpustate->irq_mask);
143 state_fio->StateValue(cpustate->timer_status);
144 state_fio->StateValue(cpustate->timer_ack);
145 state_fio->StateValue(cpustate->clocks_per_cycle);
146 state_fio->StateValue(cpustate->timer_value);
147 state_fio->StateValue(cpustate->timer_load);
148 state_fio->StateValue(cpustate->nmi_state);
149 state_fio->StateArray(cpustate->irq_state, sizeof(cpustate->irq_state), 1);
150 state_fio->StateValue(cpustate->irq_pending);
152 state_fio->StateValue(cpustate->NZ);
155 state_fio->StateValue(total_icount);
157 state_fio->StateValue(icount);
158 state_fio->StateValue(busreq);
162 prev_total_icount = total_icount;