summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/cpu/m68000
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2014-04-22 14:18:30 +0000
committer Miodrag Milanovic <mmicko@gmail.com>2014-04-22 14:18:30 +0000
commita822b1241684d5917d5099adff393aa17c45e077 (patch)
treedfb059df1d283a3586cfc04a57be0cf7ee3b3905 /src/emu/cpu/m68000
parentc0d35f1990f278c21f0e34577084c672f82ba566 (diff)
m68000 callbacks to delegates (nw)
Diffstat (limited to 'src/emu/cpu/m68000')
-rw-r--r--src/emu/cpu/m68000/m68000.h47
-rw-r--r--src/emu/cpu/m68000/m68k_in.c20
-rw-r--r--src/emu/cpu/m68000/m68kcpu.c59
3 files changed, 48 insertions, 78 deletions
diff --git a/src/emu/cpu/m68000/m68000.h b/src/emu/cpu/m68000/m68000.h
index 0756d5cc6b3..5e3ab5e0803 100644
--- a/src/emu/cpu/m68000/m68000.h
+++ b/src/emu/cpu/m68000/m68000.h
@@ -111,26 +111,11 @@ enum
M68K_GENPCBASE = STATE_GENPCBASE
};
-typedef void (*m68k_bkpt_ack_func)(device_t *device, UINT32 data);
-typedef void (*m68k_reset_func)(device_t *device);
-typedef void (*m68k_cmpild_func)(device_t *device, UINT32 data, UINT8 reg);
-typedef void (*m68k_rte_func)(device_t *device);
-typedef int (*m68k_tas_func)(device_t *device);
-
-
-
-
-
unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type);
class m68000_base_device;
-
-typedef int (*instruction_hook_t)(m68000_base_device *device, offs_t curpc);
-
-
-
extern const device_type M68K;
class m68000_base_device : public cpu_device
@@ -183,8 +168,15 @@ public:
void define_state(void);
-
-
+ void set_reset_callback(write_line_delegate callback);
+ void set_cmpild_callback(write32_delegate callback);
+ void set_rte_callback(write_line_delegate callback);
+ void set_tas_callback(read_line_delegate callback);
+ UINT16 get_fc();
+ void set_encrypted_opcode_range(offs_t start, offs_t end);
+ void set_hmmu_enable(int enable);
+ void set_instruction_hook(read32_delegate ihook);
+ void set_buserror_details(UINT32 fault_addr, UINT8 rw, UINT8 fc);
public:
@@ -261,11 +253,11 @@ public:
/* Callbacks to host */
device_irq_acknowledge_callback int_ack_callback; /* Interrupt Acknowledge */
- m68k_bkpt_ack_func bkpt_ack_callback; /* Breakpoint Acknowledge */
- m68k_reset_func reset_instr_callback; /* Called when a RESET instruction is encountered */
- m68k_cmpild_func cmpild_instr_callback; /* Called when a CMPI.L #v, Dn instruction is encountered */
- m68k_rte_func rte_instr_callback; /* Called when a RTE instruction is encountered */
- m68k_tas_func tas_instr_callback; /* Called when a TAS instruction is encountered, allows / disallows writeback */
+ write32_delegate bkpt_ack_callback; /* Breakpoint Acknowledge */
+ write_line_delegate reset_instr_callback; /* Called when a RESET instruction is encountered */
+ write32_delegate cmpild_instr_callback; /* Called when a CMPI.L #v, Dn instruction is encountered */
+ write_line_delegate rte_instr_callback; /* Called when a RTE instruction is encountered */
+ read_line_delegate tas_instr_callback; /* Called when a TAS instruction is encountered, allows / disallows writeback */
address_space *program;
@@ -373,7 +365,7 @@ public:
/* external instruction hook (does not depend on debug mode) */
- instruction_hook_t instruction_hook;
+ read32_delegate instruction_hook;
@@ -790,14 +782,5 @@ extern const device_type SCC68070;
extern const device_type FSCPU32;
extern const device_type MCF5206E;
-extern void m68k_set_reset_callback(m68000_base_device *device, m68k_reset_func callback);
-extern void m68k_set_cmpild_callback(m68000_base_device *device, m68k_cmpild_func callback);
-extern void m68k_set_rte_callback(m68000_base_device *device, m68k_rte_func callback);
-extern void m68k_set_tas_callback(m68000_base_device *device, m68k_tas_func callback);
-extern UINT16 m68k_get_fc(m68000_base_device *device);
-extern void m68k_set_encrypted_opcode_range(m68000_base_device *device, offs_t start, offs_t end);
-extern void m68k_set_hmmu_enable(m68000_base_device *device, int enable);
-extern void m68k_set_instruction_hook(m68000_base_device *device, instruction_hook_t ihook);
-extern void m68k_set_buserror_details(m68000_base_device *device, UINT32 fault_addr, UINT8 rw, UINT8 fc);
#endif /* __M68000_H__ */
diff --git a/src/emu/cpu/m68000/m68k_in.c b/src/emu/cpu/m68000/m68k_in.c
index 3d22038b2e6..a5809607138 100644
--- a/src/emu/cpu/m68000/m68k_in.c
+++ b/src/emu/cpu/m68000/m68k_in.c
@@ -3158,8 +3158,8 @@ M68KMAKE_OP(bkpt, 0, ., .)
{
if(CPU_TYPE_IS_010_PLUS((mc68kcpu)->cpu_type))
{
- if ((mc68kcpu)->bkpt_ack_callback != NULL)
- (*(mc68kcpu)->bkpt_ack_callback)((mc68kcpu), CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type) ? (mc68kcpu)->ir & 7 : 0);
+ if (!(mc68kcpu)->bkpt_ack_callback.isnull())
+ ((mc68kcpu)->bkpt_ack_callback)((*mc68kcpu->program), 0, CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type) ? (mc68kcpu)->ir & 7 : 0, 0xffffffff);
}
m68ki_exception_illegal(mc68kcpu);
}
@@ -4281,8 +4281,8 @@ M68KMAKE_OP(cmpi, 32, ., d)
UINT32 dst = DY(mc68kcpu);
UINT32 res = dst - src;
- if ((mc68kcpu)->cmpild_instr_callback != NULL)
- (*(mc68kcpu)->cmpild_instr_callback)((mc68kcpu), src, (mc68kcpu)->ir & 7);
+ if (!(mc68kcpu)->cmpild_instr_callback.isnull())
+ ((mc68kcpu)->cmpild_instr_callback)(*(mc68kcpu)->program, (mc68kcpu)->ir & 7, src, 0xffffffff);
(mc68kcpu)->n_flag = NFLAG_32(res);
(mc68kcpu)->not_z_flag = MASK_OUT_ABOVE_32(res);
@@ -8282,8 +8282,8 @@ M68KMAKE_OP(reset, 0, ., .)
{
if((mc68kcpu)->s_flag)
{
- if ((mc68kcpu)->reset_instr_callback != NULL)
- (*(mc68kcpu)->reset_instr_callback)((mc68kcpu));
+ if (!(mc68kcpu)->reset_instr_callback.isnull())
+ ((mc68kcpu)->reset_instr_callback)(1);
(mc68kcpu)->remaining_cycles -= (mc68kcpu)->cyc_reset;
return;
}
@@ -8988,8 +8988,8 @@ M68KMAKE_OP(rte, 32, ., .)
UINT32 new_pc;
UINT32 format_word;
- if ((mc68kcpu)->rte_instr_callback != NULL)
- (*(mc68kcpu)->rte_instr_callback)((mc68kcpu));
+ if (!(mc68kcpu)->rte_instr_callback.isnull())
+ ((mc68kcpu)->rte_instr_callback)(1);
m68ki_trace_t0(mc68kcpu); /* auto-disable (see m68kcpu.h) */
if(CPU_TYPE_IS_000((mc68kcpu)->cpu_type))
@@ -10026,8 +10026,8 @@ M68KMAKE_OP(tas, 8, ., .)
disabled in order to function properly. Some Amiga software may also rely
on this, but only when accessing specific addresses so additional functionality
will be needed. */
- if ((mc68kcpu)->tas_instr_callback != NULL)
- allow_writeback = (*(mc68kcpu)->tas_instr_callback)((mc68kcpu));
+ if (!(mc68kcpu)->tas_instr_callback.isnull())
+ allow_writeback = ((mc68kcpu)->tas_instr_callback)();
if (allow_writeback)
m68ki_write_8((mc68kcpu), ea, dst | 0x80);
diff --git a/src/emu/cpu/m68000/m68kcpu.c b/src/emu/cpu/m68000/m68kcpu.c
index e78f2682a50..4b0d7258dd4 100644
--- a/src/emu/cpu/m68000/m68kcpu.c
+++ b/src/emu/cpu/m68000/m68kcpu.c
@@ -840,8 +840,8 @@ inline void m68000_base_device::cpu_execute(void)
debugger_instruction_hook(this, REG_PC(this));
/* call external instruction hook (independent of debug mode) */
- if (instruction_hook != NULL)
- instruction_hook(this, REG_PC(this));
+ if (!instruction_hook.isnull())
+ instruction_hook(*program, REG_PC(this), 0xffffffff);
/* Record previous program counter */
REG_PPC(this) = REG_PC(this);
@@ -1085,11 +1085,6 @@ void m68000_base_device::reset_cpu(void)
// clear instruction cache
m68ki_ic_clear(this);
}
-
- // disable instruction hook
- instruction_hook = NULL;
-
-
}
@@ -1239,20 +1234,20 @@ void m68000_base_device::state_string_export(const device_state_entry &entry, as
/* global access */
-void m68k_set_encrypted_opcode_range(m68000_base_device *device, offs_t start, offs_t end)
+void m68000_base_device::set_encrypted_opcode_range(offs_t start, offs_t end)
{
- device->encrypted_start = start;
- device->encrypted_end = end;
+ encrypted_start = start;
+ encrypted_end = end;
}
-void m68k_set_hmmu_enable(m68000_base_device *device, int enable)
+void m68000_base_device::set_hmmu_enable(int enable)
{
- device->hmmu_enabled = enable;
+ hmmu_enabled = enable;
}
-void m68k_set_instruction_hook(m68000_base_device *device, instruction_hook_t ihook)
+void m68000_base_device::set_instruction_hook(read32_delegate ihook)
{
- device->instruction_hook = ihook;
+ instruction_hook = ihook;
}
/****************************************************************************
@@ -1676,39 +1671,39 @@ void m68000_base_device::init32hmmu(address_space &space)
write32 = m68k_write32_delegate(FUNC(m68000_base_device::writelong_d32_hmmu), this);
}
-void m68k_set_reset_callback(m68000_base_device *device, m68k_reset_func callback)
+void m68000_base_device::set_reset_callback(write_line_delegate callback)
{
- device->reset_instr_callback = callback;
+ reset_instr_callback = callback;
}
// fault_addr = address to indicate fault at
// rw = 0 for read, 1 for write
// fc = 3-bit function code of access (usually you'd just put what m68k_get_fc() returns here)
-void m68k_set_buserror_details(m68000_base_device *device, UINT32 fault_addr, UINT8 rw, UINT8 fc)
+void m68000_base_device::set_buserror_details(UINT32 fault_addr, UINT8 rw, UINT8 fc)
{
- device->aerr_address = fault_addr;
- device->aerr_write_mode = rw;
- device->aerr_fc = fc;
+ aerr_address = fault_addr;
+ aerr_write_mode = rw;
+ aerr_fc = fc;
}
-void m68k_set_cmpild_callback(m68000_base_device *device, m68k_cmpild_func callback)
+void m68000_base_device::set_cmpild_callback(write32_delegate callback)
{
- device->cmpild_instr_callback = callback;
+ cmpild_instr_callback = callback;
}
-void m68k_set_rte_callback(m68000_base_device *device, m68k_rte_func callback)
+void m68000_base_device::set_rte_callback(write_line_delegate callback)
{
- device->rte_instr_callback = callback;
+ rte_instr_callback = callback;
}
-void m68k_set_tas_callback(m68000_base_device *device, m68k_tas_func callback)
+void m68000_base_device::set_tas_callback(read_line_delegate callback)
{
- device->tas_instr_callback = callback;
+ tas_instr_callback = callback;
}
-UINT16 m68k_get_fc(m68000_base_device *device)
+UINT16 m68000_base_device::get_fc()
{
- return device->mmu_tmp_fc;
+ return mmu_tmp_fc;
}
/****************************************************************************
@@ -2417,12 +2412,6 @@ void m68000_base_device::clear_all()
cyc_exception = 0;
int_ack_callback = 0;
- bkpt_ack_callback = 0;
- reset_instr_callback = 0;
- cmpild_instr_callback = 0;
- rte_instr_callback = 0;
- tas_instr_callback = 0;
-
program = 0;
opcode_xor = 0;
@@ -2477,8 +2466,6 @@ void m68000_base_device::clear_all()
ic_data[i] = 0;
internal = 0;
-
- instruction_hook = 0;
}