2 Skelton for retropc emulator
5 Author : Takeda.Toshiya
16 /* ----------------------------------------------------------------------------
18 ---------------------------------------------------------------------------- */
24 /*****************************************************************************/
25 /* src/emu/devcpu.h */
27 // CPU interface functions
28 #define CPU_INIT_NAME(name) cpu_init_##name
29 #define CPU_INIT(name) void* CPU_INIT_NAME(name)()
30 #define CPU_INIT_CALL(name) CPU_INIT_NAME(name)()
32 #define CPU_RESET_NAME(name) cpu_reset_##name
33 #define CPU_RESET(name) void CPU_RESET_NAME(name)(h6280_Regs *cpustate)
34 #define CPU_RESET_CALL(name) CPU_RESET_NAME(name)(cpustate)
36 #define CPU_EXECUTE_NAME(name) cpu_execute_##name
37 #define CPU_EXECUTE(name) int CPU_EXECUTE_NAME(name)(h6280_Regs *cpustate, int ICount)
38 #define CPU_EXECUTE_CALL(name) CPU_EXECUTE_NAME(name)(cpustate, icount)
40 #define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name
41 #define CPU_DISASSEMBLE(name) int CPU_DISASSEMBLE_NAME(name)(_TCHAR *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
42 #define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(buffer, pc, oprom, oprom)
44 #define READ8_HANDLER(name) UINT8 name(h6280_Regs *cpustate, offs_t offset)
45 #define WRITE8_HANDLER(name) void name(h6280_Regs *cpustate, offs_t offset, UINT8 data)
47 /*****************************************************************************/
48 /* src/emu/didisasm.h */
50 // Disassembler constants
51 const UINT32 DASMFLAG_SUPPORTED = 0x80000000; // are disassembly flags supported?
52 const UINT32 DASMFLAG_STEP_OUT = 0x40000000; // this instruction should be the end of a step out sequence
53 const UINT32 DASMFLAG_STEP_OVER = 0x20000000; // this instruction should be stepped over by setting a breakpoint afterwards
54 const UINT32 DASMFLAG_OVERINSTMASK = 0x18000000; // number of extra instructions to skip when stepping over
55 const UINT32 DASMFLAG_OVERINSTSHIFT = 27; // bits to shift after masking to get the value
56 const UINT32 DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain the actual length
58 /*****************************************************************************/
59 /* src/emu/diexec.h */
64 CLEAR_LINE = 0, // clear (a fired or held) line
65 ASSERT_LINE, // assert an interrupt immediately
66 HOLD_LINE, // hold interrupt line until acknowledged
67 PULSE_LINE // pulse interrupt line instantaneously (only for NMI, RESET)
80 #include "mame/emu/cpu/h6280/h6280.c"
82 #include "mame/emu/cpu/h6280/6280dasm.c"
87 void HUC6280::initialize()
89 opaque = CPU_INIT_CALL(h6280);
91 h6280_Regs *cpustate = (h6280_Regs *)opaque;
92 cpustate->program = d_mem;
96 cpustate->debugger = d_debugger;
97 cpustate->program_stored = d_mem;
98 cpustate->io_stored = d_io;
100 d_debugger->set_context_mem(d_mem);
101 d_debugger->set_context_io(d_io);
105 void HUC6280::release()
110 void HUC6280::reset()
112 h6280_Regs *cpustate = (h6280_Regs *)opaque;
114 CPU_RESET_CALL(h6280);
116 cpustate->program = d_mem;
120 cpustate->debugger = d_debugger;
121 cpustate->program_stored = d_mem;
122 cpustate->io_stored = d_io;
126 int HUC6280::run(int icount)
128 h6280_Regs *cpustate = (h6280_Regs *)opaque;
129 return CPU_EXECUTE_CALL(h6280);
132 void HUC6280::write_signal(int id, uint32 data, uint32 mask)
134 h6280_Regs *cpustate = (h6280_Regs *)opaque;
135 set_irq_line(cpustate, id, data);
138 uint32 HUC6280::get_pc()
140 h6280_Regs *cpustate = (h6280_Regs *)opaque;
141 return cpustate->ppc.w.l;
144 uint32 HUC6280::get_next_pc()
146 h6280_Regs *cpustate = (h6280_Regs *)opaque;
147 return cpustate->pc.w.l;
150 uint8 HUC6280::irq_status_r(uint16 offset)
152 h6280_Regs *cpustate = (h6280_Regs *)opaque;
153 return h6280_irq_status_r(cpustate, offset);
156 void HUC6280::irq_status_w(uint16 offset, uint8 data)
158 h6280_Regs *cpustate = (h6280_Regs *)opaque;
159 h6280_irq_status_w(cpustate, offset, data);
162 uint8 HUC6280::timer_r(uint16 offset)
164 h6280_Regs *cpustate = (h6280_Regs *)opaque;
165 return h6280_timer_r(cpustate, offset);
168 void HUC6280::timer_w(uint16 offset, uint8 data)
170 h6280_Regs *cpustate = (h6280_Regs *)opaque;
171 h6280_timer_w(cpustate, offset, data);
175 void HUC6280::write_debug_data8(uint32 addr, uint32 data)
178 d_mem->write_data8w(addr, data, &wait);
181 uint32 HUC6280::read_debug_data8(uint32 addr)
184 return d_mem->read_data8w(addr, &wait);
187 void HUC6280::write_debug_io8(uint32 addr, uint32 data)
190 d_io->write_io8w(addr, data, &wait);
193 uint32 HUC6280::read_debug_io8(uint32 addr) {
195 return d_io->read_io8w(addr, &wait);
198 bool HUC6280::write_debug_reg(const _TCHAR *reg, uint32 data)
200 h6280_Regs *cpustate = (h6280_Regs *)opaque;
201 if(_tcsicmp(reg, _T("PC")) == 0) {
202 cpustate->pc.w.l = data;
203 } if(_tcsicmp(reg, _T("SP")) == 0) {
204 cpustate->sp.w.l = data;
205 } if(_tcsicmp(reg, _T("ZP")) == 0) {
206 cpustate->zp.w.l = data;
207 } if(_tcsicmp(reg, _T("EA")) == 0) {
208 cpustate->ea.w.l = data;
209 } if(_tcsicmp(reg, _T("A")) == 0) {
211 } if(_tcsicmp(reg, _T("X")) == 0) {
213 } if(_tcsicmp(reg, _T("Y")) == 0) {
215 } if(_tcsicmp(reg, _T("P")) == 0) {
223 void HUC6280::get_debug_regs_info(_TCHAR *buffer, size_t buffer_len)
225 h6280_Regs *cpustate = (h6280_Regs *)opaque;
226 my_stprintf_s(buffer, buffer_len,
227 _T("PC = 0000 SP = %04X ZP = %04X EA = %04X A = %02X X = %02X Y = %02X P = %02X"),
228 cpustate->pc.w.l, cpustate->sp.w.l, cpustate->zp.w.l, cpustate->ea.w.l, cpustate->a, cpustate->x, cpustate->y, cpustate->p);
233 int HUC6280::debug_dasm(uint32 pc, _TCHAR *buffer, size_t buffer_len)
236 uint8 *opram = oprom;
238 for(int i = 0; i < 8; i++) {
240 oprom[i] = d_mem->read_data8w(pc + i, &wait);
242 return CPU_DISASSEMBLE_CALL(h6280) & DASMFLAG_LENGTHMASK;
246 #define STATE_VERSION 2
248 void HUC6280::save_state(FILEIO* state_fio)
250 state_fio->FputUint32(STATE_VERSION);
251 state_fio->FputInt32(this_device_id);
253 state_fio->Fwrite(opaque, sizeof(h6280_Regs), 1);
257 bool HUC6280::load_state(FILEIO* state_fio)
259 if(state_fio->FgetUint32() != STATE_VERSION) {
262 if(state_fio->FgetInt32() != this_device_id) {
265 state_fio->Fread(opaque, sizeof(h6280_Regs), 1);
268 h6280_Regs *cpustate = (h6280_Regs *)opaque;
269 cpustate->program = d_mem;
273 cpustate->debugger = d_debugger;
274 cpustate->program_stored = d_mem;
275 cpustate->io_stored = d_io;