summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Curt Coder <curtcoder@mail.com>2009-07-16 12:19:43 +0000
committer Curt Coder <curtcoder@mail.com>2009-07-16 12:19:43 +0000
commit9956b7002f6147b7ffecfe0d773cfb37f147cb21 (patch)
tree67c287c89e0c607af48e1cbae2b7a25bb09d66f2
parentc54ff15107489729e6cb8c11cf5ad1dbcbd173fe (diff)
CDP1802:
- refactored the Q and DMA callbacks to use devcb
-rw-r--r--src/emu/cpu/cdp1802/cdp1802.c33
-rw-r--r--src/emu/cpu/cdp1802/cdp1802.h16
-rw-r--r--src/mame/drivers/cidelsa.c18
3 files changed, 26 insertions, 41 deletions
diff --git a/src/emu/cpu/cdp1802/cdp1802.c b/src/emu/cpu/cdp1802/cdp1802.c
index b3af98dab90..a26fe710b19 100644
--- a/src/emu/cpu/cdp1802/cdp1802.c
+++ b/src/emu/cpu/cdp1802/cdp1802.c
@@ -29,6 +29,10 @@ struct _cdp1802_state
const address_space *program;
const address_space *io;
+ devcb_resolved_write_line out_q_func;
+ devcb_resolved_read8 in_dma_func;
+ devcb_resolved_write8 out_dma_func;
+
/* registers */
UINT8 d; /* data register (accumulator) */
int df; /* data flag (ALU carry) */
@@ -549,19 +553,13 @@ static void cdp1802_run(const device_config *device)
case 0xa:
Q = 0;
- if (cpustate->intf->q_w)
- {
- cpustate->intf->q_w(device, Q);
- }
+ devcb_call_write_line(&cpustate->out_q_func, Q);
break;
case 0xb:
Q = 1;
- if (cpustate->intf->q_w)
- {
- cpustate->intf->q_w(device, Q);
- }
+ devcb_call_write_line(&cpustate->out_q_func, Q);
break;
case 0xc:
@@ -791,10 +789,7 @@ static void cdp1802_run(const device_config *device)
case CDP1802_STATE_2_DMA_IN:
- if (cpustate->intf->dma_r)
- {
- RAM_W(R[0], cpustate->intf->dma_r(device, R[0]));
- }
+ RAM_W(R[0], devcb_call_read8(&cpustate->in_dma_func, R[0]));
R[0] = R[0] + 1;
@@ -824,10 +819,7 @@ static void cdp1802_run(const device_config *device)
case CDP1802_STATE_2_DMA_OUT:
- if (cpustate->intf->dma_w)
- {
- cpustate->intf->dma_w(device, R[0], RAM_R(R[0]));
- }
+ devcb_call_write8(&cpustate->out_dma_func, R[0], RAM_R(R[0]));
R[0] = R[0] + 1;
@@ -954,19 +946,21 @@ static CPU_INIT( cdp1802 )
cpustate->intf = (cdp1802_interface *) device->static_config;
- /* set up the state table */
+ /* resolve callbacks */
+ devcb_resolve_write_line(&cpustate->out_q_func, &cpustate->intf->out_q_func, device);
+ devcb_resolve_read8(&cpustate->in_dma_func, &cpustate->intf->in_dma_func, device);
+ devcb_resolve_write8(&cpustate->out_dma_func, &cpustate->intf->out_dma_func, device);
+ /* set up the state table */
cpustate->state_table = state_table_template;
cpustate->state_table.baseptr = cpustate;
cpustate->state_table.subtypemask = 1;
/* find address spaces */
-
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
/* set initial values */
-
cpustate->p = mame_rand(device->machine) & 0x0f;
cpustate->x = mame_rand(device->machine) & 0x0f;
cpustate->d = mame_rand(device->machine);
@@ -987,7 +981,6 @@ static CPU_INIT( cdp1802 )
cpustate->dmaout = CLEAR_LINE;
/* register for state saving */
-
state_save_register_device_item(device, 0, cpustate->p);
state_save_register_device_item(device, 0, cpustate->x);
state_save_register_device_item(device, 0, cpustate->d);
diff --git a/src/emu/cpu/cdp1802/cdp1802.h b/src/emu/cpu/cdp1802/cdp1802.h
index 98b888dd585..c1bd3a6300a 100644
--- a/src/emu/cpu/cdp1802/cdp1802.h
+++ b/src/emu/cpu/cdp1802/cdp1802.h
@@ -18,6 +18,7 @@
*/
#include "cpuintrf.h"
+#include "devcb.h"
enum
{
@@ -70,15 +71,6 @@ typedef UINT8 (*cdp1802_ef_read_func)(const device_config *device);
typedef void (*cdp1802_sc_write_func)(const device_config *device, cdp1802_state_code state);
#define CDP1802_SC_WRITE(name) void name(const device_config *device, cdp1802_state_code state)
-typedef void (*cdp1802_q_write_func)(const device_config *device, int level);
-#define CDP1802_Q_WRITE(name) void name(const device_config *device, int level)
-
-typedef UINT8 (*cdp1802_dma_read_func)(const device_config *device, UINT16 ma);
-#define CDP1802_DMA_READ(name) UINT8 name(const device_config *device, UINT16 ma)
-
-typedef void (*cdp1802_dma_write_func)(const device_config *device, UINT16 ma, UINT8 data);
-#define CDP1802_DMA_WRITE(name) void name(const device_config *device, UINT16 ma, UINT8 data)
-
/* interface */
typedef struct _cdp1802_interface cdp1802_interface;
struct _cdp1802_interface
@@ -93,13 +85,13 @@ struct _cdp1802_interface
cdp1802_sc_write_func sc_w;
/* if specified, this gets called for every change of the Q pin (pin 4) */
- cdp1802_q_write_func q_w;
+ devcb_write_line out_q_func;
/* if specified, this gets called for every DMA read */
- cdp1802_dma_read_func dma_r;
+ devcb_read8 in_dma_func;
/* if specified, this gets called for every DMA write */
- cdp1802_dma_write_func dma_w;
+ devcb_write8 out_dma_func;
};
#define CDP1802_INTERFACE(name) const cdp1802_interface (name) =
diff --git a/src/mame/drivers/cidelsa.c b/src/mame/drivers/cidelsa.c
index bb2369ca6b2..bbc6c3ba119 100644
--- a/src/mame/drivers/cidelsa.c
+++ b/src/mame/drivers/cidelsa.c
@@ -27,21 +27,21 @@ static CDP1802_EF_READ( cidelsa_ef_r )
return input_port_read(device->machine, "EF");
}
-static CDP1802_Q_WRITE( cidelsa_q_w )
+static WRITE_LINE_DEVICE_HANDLER( cidelsa_q_w )
{
- cidelsa_state *state = (cidelsa_state *)device->machine->driver_data;
+ cidelsa_state *driver_state = (cidelsa_state *)device->machine->driver_data;
- state->cdp1802_q = level;
+ driver_state->cdp1802_q = state;
}
static CDP1802_INTERFACE( cidelsa_cdp1802_config )
{
- cidelsa_mode_r, // MODE
- cidelsa_ef_r, // EF
- NULL, // SC
- cidelsa_q_w, // Q
- NULL, // DMA read
- NULL // DMA write
+ cidelsa_mode_r, // MODE
+ cidelsa_ef_r, // EF
+ NULL, // SC
+ DEVCB_LINE(cidelsa_q_w), // Q
+ DEVCB_NULL, // DMA read
+ DEVCB_NULL // DMA write
};
/* Sound Interface */