summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2008-12-05 03:59:56 +0000
committer Nathan Woods <npwoods@mess.org>2008-12-05 03:59:56 +0000
commit9c88aa96d05c4c88908a571b7581dfc16b9e7e5e (patch)
tree54f2963c1754eead960824b4a5931093fd7ded34 /src
parent89b03aba17097b7327d47904bbf8b5f5eca651b6 (diff)
Made the 6526/8520 CIA implementations be devices
Diffstat (limited to 'src')
-rw-r--r--src/emu/machine/6526cia.c471
-rw-r--r--src/emu/machine/6526cia.h65
-rw-r--r--src/mame/drivers/alg.c33
-rw-r--r--src/mame/drivers/arcadia.c33
-rw-r--r--src/mame/drivers/cubocd32.c34
-rw-r--r--src/mame/drivers/mquake.c33
-rw-r--r--src/mame/drivers/upscope.c33
-rw-r--r--src/mame/includes/amiga.h13
-rw-r--r--src/mame/machine/amiga.c71
9 files changed, 488 insertions, 298 deletions
diff --git a/src/emu/machine/6526cia.c b/src/emu/machine/6526cia.c
index 4358888a144..6a4657b72ee 100644
--- a/src/emu/machine/6526cia.c
+++ b/src/emu/machine/6526cia.c
@@ -2,7 +2,7 @@
MOS 6526/8520 CIA interface and emulation
- This function emulates all the functionality of up to 2 MOS6526 or
+ This function emulates all the functionality MOS6526 or
MOS8520 complex interface adapters.
**********************************************************************/
@@ -11,12 +11,9 @@
#include "6526cia.h"
-
-/*************************************
- *
- * Constants
- *
- *************************************/
+/***************************************************************************
+ CONSTANTS
+***************************************************************************/
/* CIA registers */
#define CIA_PRA 0
@@ -37,12 +34,9 @@
#define CIA_CRB 15
-
-/*************************************
- *
- * Type definitions
- *
- *************************************/
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
typedef struct _cia_timer cia_timer;
typedef struct _cia_port cia_port;
@@ -71,9 +65,8 @@ struct _cia_port
struct _cia_state
{
- int active;
- cia_type_t type;
- void (*irq_func)(running_machine *machine, int state);
+ const device_config *device;
+ void (*irq_func)(const device_config *device, int state);
int clock;
cia_port port[2];
@@ -101,64 +94,54 @@ struct _cia_state
};
-
-/*************************************
- *
- * Globals
- *
- *************************************/
-
-static cia_state cia_array[2];
-
-
-
-/*************************************
- *
- * Prototypes
- *
- *************************************/
+/***************************************************************************
+ PROTOTYPES
+***************************************************************************/
static TIMER_CALLBACK( cia_timer_proc );
-static void cia_timer_underflow(running_machine *machine, cia_state *cia, int timer);
+static void cia_timer_underflow(const device_config *device, int timer);
static TIMER_CALLBACK( cia_clock_tod_callback );
-/*************************************
- *
- * Prototypes
- *
- *************************************/
-
-
/***************************************************************************
+ INLINE FUNCTIONS
+***************************************************************************/
- Setup and reset
+INLINE cia_state *get_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert((device->type == CIA6526) || (device->type == CIA8520));
+ return (cia_state *) device->token;
+}
-***************************************************************************/
-static void cia_exit(running_machine *machine)
+INLINE const cia6526_interface *get_interface(const device_config *device)
{
- memset(cia_array, 0, sizeof(*cia_array));
+ assert(device != NULL);
+ assert((device->type == CIA6526) || (device->type == CIA8520));
+ return (cia6526_interface *) device->static_config;
}
+/***************************************************************************
+ IMPLEMENTATION
+***************************************************************************/
+
+/*-------------------------------------------------
+ DEVICE_START( cia )
+-------------------------------------------------*/
-void cia_config(running_machine *machine, int which, const cia6526_interface *intf)
+static DEVICE_START( cia )
{
int t, p;
- cia_state *cia = &cia_array[which];
-
- /* sanity checks */
- assert_always(mame_get_phase(machine) == MAME_PHASE_INIT, "Can only call cia_config at init time!");
- assert_always((which >= 0) && (which < (sizeof(cia_array) / sizeof(cia_array[0]))),
- "cia_config called on an invalid CIA!");
+ cia_state *cia = get_token(device);
+ const cia6526_interface *intf = get_interface(device);
/* clear out CIA structure, and copy the interface */
memset(cia, 0, sizeof(*cia));
- cia->active = TRUE;
- cia->type = intf->type;
- cia->clock = (intf->clock != 0) ? intf->clock : cpu_get_clock(machine->cpu[0]);
+ cia->device = device;
+ cia->clock = (intf->clock != 0) ? intf->clock : cpu_get_clock(device->machine->cpu[0]);
cia->irq_func = intf->irq_func;
/* setup ports */
@@ -173,117 +156,115 @@ void cia_config(running_machine *machine, int which, const cia6526_interface *in
for (t = 0; t < (sizeof(cia->timer) / sizeof(cia->timer[0])); t++)
{
cia_timer *timer = &cia->timer[t];
- timer->timer = timer_alloc(machine, cia_timer_proc, timer);
+ timer->timer = timer_alloc(device->machine, cia_timer_proc, timer);
timer->cia = cia;
timer->irq = 0x01 << t;
}
/* setup TOD timer, if appropriate */
- if (intf->tod_clock)
- timer_pulse(machine, ATTOTIME_IN_HZ(intf->tod_clock), NULL, which, cia_clock_tod_callback);
-
- /* special case; for the first CIA, set up an exit handler to clear things out */
- if (which == 0)
- add_exit_callback(machine, cia_exit);
+ if (intf->tod_clock != 0)
+ timer_pulse(device->machine, ATTOTIME_IN_HZ(intf->tod_clock), (void *) device, 0, cia_clock_tod_callback);
/* state save support */
- state_save_register_item("6526cia", NULL, which, cia->port[0].ddr);
- state_save_register_item("6526cia", NULL, which, cia->port[0].latch);
- state_save_register_item("6526cia", NULL, which, cia->port[0].in);
- state_save_register_item("6526cia", NULL, which, cia->port[0].out);
- state_save_register_item("6526cia", NULL, which, cia->port[0].mask_value);
- state_save_register_item("6526cia", NULL, which, cia->port[1].ddr);
- state_save_register_item("6526cia", NULL, which, cia->port[1].latch);
- state_save_register_item("6526cia", NULL, which, cia->port[1].in);
- state_save_register_item("6526cia", NULL, which, cia->port[1].out);
- state_save_register_item("6526cia", NULL, which, cia->port[1].mask_value);
- state_save_register_item("6526cia", NULL, which, cia->timer[0].latch);
- state_save_register_item("6526cia", NULL, which, cia->timer[0].count);
- state_save_register_item("6526cia", NULL, which, cia->timer[0].mode);
- state_save_register_item("6526cia", NULL, which, cia->timer[0].irq);
- state_save_register_item("6526cia", NULL, which, cia->timer[1].latch);
- state_save_register_item("6526cia", NULL, which, cia->timer[1].count);
- state_save_register_item("6526cia", NULL, which, cia->timer[1].mode);
- state_save_register_item("6526cia", NULL, which, cia->timer[1].irq);
- state_save_register_item("6526cia", NULL, which, cia->tod);
- state_save_register_item("6526cia", NULL, which, cia->tod_latch);
- state_save_register_item("6526cia", NULL, which, cia->tod_latched);
- state_save_register_item("6526cia", NULL, which, cia->tod_running);
- state_save_register_item("6526cia", NULL, which, cia->alarm);
- state_save_register_item("6526cia", NULL, which, cia->icr);
- state_save_register_item("6526cia", NULL, which, cia->ics);
- state_save_register_item("6526cia", NULL, which, cia->irq);
- state_save_register_item("6526cia", NULL, which, cia->loaded);
- state_save_register_item("6526cia", NULL, which, cia->sdr);
- state_save_register_item("6526cia", NULL, which, cia->sp);
- state_save_register_item("6526cia", NULL, which, cia->cnt);
- state_save_register_item("6526cia", NULL, which, cia->shift);
- state_save_register_item("6526cia", NULL, which, cia->serial);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[0].ddr);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[0].latch);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[0].in);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[0].out);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[0].mask_value);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[1].ddr);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[1].latch);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[1].in);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[1].out);
+ state_save_register_item("6526cia", device->tag, 0, cia->port[1].mask_value);
+ state_save_register_item("6526cia", device->tag, 0, cia->timer[0].latch);
+ state_save_register_item("6526cia", device->tag, 0, cia->timer[0].count);
+ state_save_register_item("6526cia", device->tag, 0, cia->timer[0].mode);
+ state_save_register_item("6526cia", device->tag, 0, cia->timer[0].irq);
+ state_save_register_item("6526cia", device->tag, 0, cia->timer[1].latch);
+ state_save_register_item("6526cia", device->tag, 0, cia->timer[1].count);
+ state_save_register_item("6526cia", device->tag, 0, cia->timer[1].mode);
+ state_save_register_item("6526cia", device->tag, 0, cia->timer[1].irq);
+ state_save_register_item("6526cia", device->tag, 0, cia->tod);
+ state_save_register_item("6526cia", device->tag, 0, cia->tod_latch);
+ state_save_register_item("6526cia", device->tag, 0, cia->tod_latched);
+ state_save_register_item("6526cia", device->tag, 0, cia->tod_running);
+ state_save_register_item("6526cia", device->tag, 0, cia->alarm);
+ state_save_register_item("6526cia", device->tag, 0, cia->icr);
+ state_save_register_item("6526cia", device->tag, 0, cia->ics);
+ state_save_register_item("6526cia", device->tag, 0, cia->irq);
+ state_save_register_item("6526cia", device->tag, 0, cia->loaded);
+ state_save_register_item("6526cia", device->tag, 0, cia->sdr);
+ state_save_register_item("6526cia", device->tag, 0, cia->sp);
+ state_save_register_item("6526cia", device->tag, 0, cia->cnt);
+ state_save_register_item("6526cia", device->tag, 0, cia->shift);
+ state_save_register_item("6526cia", device->tag, 0, cia->serial);
+ return DEVICE_START_OK;
}
-void cia_set_port_mask_value(int which, int port, int data)
+
+/*-------------------------------------------------
+ cia_set_port_mask_value
+-------------------------------------------------*/
+
+void cia_set_port_mask_value(const device_config *device, int port, int data)
{
- cia_state *cia = &cia_array[which];
+ cia_state *cia = get_token(device);
cia->port[port].mask_value = data;
}
-void cia_reset(void)
-{
- int i, t;
- /* loop over and set up initial values */
- for (i = 0; i < (sizeof(cia_array) / sizeof(cia_array[0])); i++)
- {
- cia_state *cia = &cia_array[i];
+/*-------------------------------------------------
+ DEVICE_RESET( cia )
+-------------------------------------------------*/
- if (cia->active)
- {
- /* clear things out */
- cia->port[0].latch = 0x00;
- cia->port[0].in = 0x00;
- cia->port[0].out = 0x00;
- cia->port[0].mask_value = 0xff;
- cia->port[1].latch = 0x00;
- cia->port[1].in = 0x00;
- cia->port[1].out = 0x00;
- cia->port[1].mask_value = 0xff;
- cia->tod = 0;
- cia->tod_latch = 0;
- cia->alarm = 0;
- cia->icr = 0x00;
- cia->ics = 0x00;
- cia->irq = 0;
-
- /* initialize data direction registers */
- cia->port[0].ddr = (i == 0) ? 0x03 : 0xff;
- cia->port[1].ddr = (i == 0) ? 0x00 : 0xff;
-
- /* TOD running by default */
- cia->tod_running = TRUE;
-
- /* initialize timers */
- for (t = 0; t < 2; t++)
- {
- cia_timer *timer = &cia->timer[t];
+static DEVICE_RESET( cia )
+{
+ int t;
+ cia_state *cia = get_token(device);
+
+ /* clear things out */
+ cia->port[0].latch = 0x00;
+ cia->port[0].in = 0x00;
+ cia->port[0].out = 0x00;
+ cia->port[0].mask_value = 0xff;
+ cia->port[1].latch = 0x00;
+ cia->port[1].in = 0x00;
+ cia->port[1].out = 0x00;
+ cia->port[1].mask_value = 0xff;
+ cia->tod = 0;
+ cia->tod_latch = 0;
+ cia->alarm = 0;
+ cia->icr = 0x00;
+ cia->ics = 0x00;
+ cia->irq = 0;
+
+ /* initialize data direction registers */
+ cia->port[0].ddr = !strcmp(device->tag, "cia_0") ? 0x03 : 0xff;
+ cia->port[1].ddr = !strcmp(device->tag, "cia_0") ? 0x00 : 0xff;
+
+ /* TOD running by default */
+ cia->tod_running = TRUE;
+
+ /* initialize timers */
+ for (t = 0; t < 2; t++)
+ {
+ cia_timer *timer = &cia->timer[t];
- timer->latch = 0xffff;
- timer->count = 0x0000;
- timer->mode = 0x00;
- }
- }
+ timer->latch = 0xffff;
+ timer->count = 0x0000;
+ timer->mode = 0x00;
}
}
-/***************************************************************************
-
- CIA runtime
+/*-------------------------------------------------
+ cia_update_interrupts
+-------------------------------------------------*/
-***************************************************************************/
-
-static void cia_update_interrupts(running_machine *machine, cia_state *cia)
+static void cia_update_interrupts(const device_config *device)
{
UINT8 new_irq;
+ cia_state *cia = get_token(device);
/* always update the high bit of ICS */
if (cia->ics & 0x7f)
@@ -297,11 +278,15 @@ static void cia_update_interrupts(running_machine *machine, cia_state *cia)
{
cia->irq = new_irq;
if (cia->irq_func)
- cia->irq_func(machine, cia->irq);
+ (*cia->irq_func)(device, cia->irq);
}
}
+/*-------------------------------------------------
+ is_timer_active
+-------------------------------------------------*/
+
static int is_timer_active(emu_timer *timer)
{
attotime t = timer_firetime(timer);
@@ -309,7 +294,11 @@ static int is_timer_active(emu_timer *timer)
}
-/* updates the count and emu_timer for a given CIA timer */
+/*-------------------------------------------------
+ cia_timer_update - updates the count and
+ emu_timer for a given CIA timer
+-------------------------------------------------*/
+
static void cia_timer_update(cia_timer *timer, INT32 new_count)
{
int which = timer - timer->cia->timer;
@@ -343,24 +332,36 @@ static void cia_timer_update(cia_timer *timer, INT32 new_count)
}
-static void cia_timer_bump(running_machine *machine, cia_state *cia, int timer)
+/*-------------------------------------------------
+ cia_timer_bump
+-------------------------------------------------*/
+
+static void cia_timer_bump(const device_config *device, int timer)
{
+ cia_state *cia = get_token(device);
+
cia_timer_update(&cia->timer[timer], -1);
if (cia->timer[timer].count == 0x00)
- cia_timer_underflow(machine, cia, timer);
+ cia_timer_underflow(device, timer);
else
cia_timer_update(&cia->timer[timer], cia->timer[timer].count - 1);
}
-static void cia_timer_underflow(running_machine *machine, cia_state *cia, int timer)
+/*-------------------------------------------------
+ cia_timer_underflow
+-------------------------------------------------*/
+
+static void cia_timer_underflow(const device_config *device, int timer)
{
+ cia_state *cia = get_token(device);
+
assert((timer == 0) || (timer == 1));
/* set the status and update interrupts */
cia->ics |= cia->timer[timer].irq;
- cia_update_interrupts(machine, cia);
+ cia_update_interrupts(device);
/* if one-shot mode, turn it off */
if (cia->timer[timer].mode & 0x08)
@@ -376,7 +377,7 @@ static void cia_timer_underflow(running_machine *machine, cia_state *cia, int ti
if ((cia->timer[1].mode & 0x41) == 0x41)
{
if (cia->cnt || !(cia->timer[1].mode & 0x20))
- cia_timer_bump(machine, cia, 1);
+ cia_timer_bump(device, 1);
}
/* also the serial line */
@@ -402,7 +403,7 @@ static void cia_timer_underflow(running_machine *machine, cia_state *cia, int ti
if (cia->shift == 8)
{
cia->ics |= 0x08;
- cia_update_interrupts(machine, cia);
+ cia_update_interrupts(device);
}
}
}
@@ -411,15 +412,23 @@ static void cia_timer_underflow(running_machine *machine, cia_state *cia, int ti
}
+/*-------------------------------------------------
+ TIMER_CALLBACK( cia_timer_proc )
+-------------------------------------------------*/
+
static TIMER_CALLBACK( cia_timer_proc )
{
cia_timer *timer = ptr;
cia_state *cia = timer->cia;
- cia_timer_underflow(machine, cia, timer - cia->timer);
+ cia_timer_underflow(cia->device, timer - cia->timer);
}
+/*-------------------------------------------------
+ bcd_increment
+-------------------------------------------------*/
+
static UINT8 bcd_increment(UINT8 value)
{
value++;
@@ -429,6 +438,10 @@ static UINT8 bcd_increment(UINT8 value)
}
+/*-------------------------------------------------
+ cia6526_increment
+-------------------------------------------------*/
+
static void cia6526_increment(cia_state *cia)
{
/* break down TOD value into components */
@@ -471,74 +484,92 @@ static void cia6526_increment(cia_state *cia)
}
-/* Update TOD on CIA A */
-void cia_clock_tod(running_machine *machine, int which)
+/*-------------------------------------------------
+ cia_clock_tod - Update TOD on CIA A
+-------------------------------------------------*/
+
+void cia_clock_tod(const device_config *device)
{
cia_state *cia;
- cia = &cia_array[which];
+ cia = get_token(device);
if (cia->tod_running)
{
- switch(cia->type)
+ if (device->type == CIA6526)
+ {
+ /* The 6526 split the value into hours, minutes, seconds and
+ * subseconds */
+ cia6526_increment(cia);
+ }
+ else if (device->type == CIA8520)
{
- case CIA6526:
- /* The 6526 split the value into hours, minutes, seconds and
- * subseconds */
- cia6526_increment(cia);
- break;
-
- case CIA8520:
- /* the 8520 has a straight 24-bit counter */
- cia->tod++;
- cia->tod &= 0xffffff;
- break;
+ /* the 8520 has a straight 24-bit counter */
+ cia->tod++;
+ cia->tod &= 0xffffff;
}
if (cia->tod == cia->alarm)
{
cia->ics |= 0x04;
- cia_update_interrupts(machine, cia);
+ cia_update_interrupts(device);
}
}
}
+/*-------------------------------------------------
+ cia_clock_tod_callback
+-------------------------------------------------*/
+
static TIMER_CALLBACK( cia_clock_tod_callback )
{
- cia_clock_tod(machine, param);
+ const device_config *device = ptr;
+ cia_clock_tod(device);
}
-void cia_issue_index(running_machine *machine, int which)
+/*-------------------------------------------------
+ cia_issue_index
+-------------------------------------------------*/
+
+void cia_issue_index(const device_config *device)
{
- cia_state *cia = &cia_array[which];
+ cia_state *cia = get_token(device);
cia->ics |= 0x10;
- cia_update_interrupts(machine, cia);
+ cia_update_interrupts(device);
}
-void cia_set_input_sp(int which, int data)
+/*-------------------------------------------------
+ cia_set_input_sp
+-------------------------------------------------*/
+
+void cia_set_input_sp(const device_config *device, int data)
{
- cia_state *cia = &cia_array[which];
+ cia_state *cia = get_token(device);
cia->sp = data;
}
-void cia_set_input_cnt(running_machine *machine, int which, int data)
+/*-------------------------------------------------
+ cia_set_input_cnt
+-------------------------------------------------*/
+
+void cia_set_input_cnt(const device_config *device, int data)
{
- cia_state *cia = &cia_array[which];
+ cia_state *cia = get_token(device);
/* is this a rising edge? */
if (!cia->cnt && data)
{
/* does timer #0 bump on CNT? */
if ((cia->timer[0].mode & 0x21) == 0x21)
- cia_timer_bump(machine, cia, 0);
+ cia_timer_bump(device, 0);
/* does timer #1 bump on CNT? */
if ((cia->timer[1].mode & 0x61) == 0x21)
- cia_timer_bump(machine, cia, 1);
+ cia_timer_bump(device, 1);
/* if the serial port is set to output, the CNT will shift the port */
if (!(cia->timer[0].mode & 0x40))
@@ -553,7 +584,7 @@ void cia_set_input_cnt(running_machine *machine, int which, int data)
cia->serial = 0;
cia->shift = 0;
cia->ics |= 0x08;
- cia_update_interrupts(machine, cia);
+ cia_update_interrupts(device);
}
}
}
@@ -561,14 +592,18 @@ void cia_set_input_cnt(running_machine *machine, int which, int data)
}
-UINT8 cia_read(running_machine *machine, int which, offs_t offset)
+/*-------------------------------------------------
+ cia_r
+-------------------------------------------------*/
+
+READ8_DEVICE_HANDLER( cia_r )
{
cia_timer *timer;
cia_state *cia;
cia_port *port;
UINT8 data = 0x00;
- cia = &cia_array[which];
+ cia = get_token(device);
offset &= 0x0F;
switch(offset)
@@ -656,7 +691,7 @@ UINT8 cia_read(running_machine *machine, int which, offs_t offset)
case CIA_ICR:
data = cia->ics;
cia->ics = 0; /* clear on read */
- cia_update_interrupts(machine, cia);
+ cia_update_interrupts(device);
break;
/* timer A/B mode */
@@ -670,15 +705,18 @@ UINT8 cia_read(running_machine *machine, int which, offs_t offset)
}
+/*-------------------------------------------------
+ cia_w
+-------------------------------------------------*/
-void cia_write(running_machine *machine, int which, offs_t offset, UINT8 data)
+WRITE8_DEVICE_HANDLER( cia_w )
{
cia_timer *timer;
cia_state *cia;
cia_port *port;
int shift;
- cia = &cia_array[which];
+ cia = get_token(device);
offset &= 0x0F;
switch(offset)
@@ -760,7 +798,7 @@ void cia_write(running_machine *machine, int which, offs_t offset, UINT8 data)
cia->icr |= data & 0x7f;
else
cia->icr &= ~(data & 0x7f);
- cia_update_interrupts(machine, cia);
+ cia_update_interrupts(device);
break;
/* timer A/B modes */
@@ -780,12 +818,63 @@ void cia_write(running_machine *machine, int which, offs_t offset, UINT8 data)
-UINT8 cia_get_output_a(int which) { return cia_array[which].port[0].out; }
-UINT8 cia_get_output_b(int which) { return cia_array[which].port[1].out; }
-int cia_get_irq(int which) { return cia_array[which].irq; }
+UINT8 cia_get_output_a(const device_config *device) { return get_token(device)->port[0].out; }
+UINT8 cia_get_output_b(const device_config *device) { return get_token(device)->port[1].out; }
+int cia_get_irq(const device_config *device) { return get_token(device)->irq; }
+
-READ8_HANDLER( cia_0_r ) { return cia_read(space->machine, 0, offset); }
-READ8_HANDLER( cia_1_r ) { return cia_read(space->machine, 1, offset); }
+/*-------------------------------------------------
+ DEVICE_SET_INFO( cia6526 )
+-------------------------------------------------*/
-WRITE8_HANDLER( cia_0_w ) { cia_write(space->machine, 0, offset, data); }
-WRITE8_HANDLER( cia_1_w ) { cia_write(space->machine, 1, offset, data); }
+static DEVICE_SET_INFO( cia6526 )
+{
+ switch (state)
+ {
+ /* no parameters to set */
+ }
+}
+
+
+/*-------------------------------------------------
+ DEVICE_GET_INFO( cia6526 )
+-------------------------------------------------*/
+
+DEVICE_GET_INFO(cia6526)
+{
+ switch (state)
+ {
+ /* --- the following bits of info are returned as 64-bit signed integers --- */
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cia_state); break;
+ case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
+ case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break;
+
+ /* --- the following bits of info are returned as pointers to data or functions --- */
+ case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(cia6526); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cia); break;
+ case DEVINFO_FCT_STOP: /* Nothing */ break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(cia); break;
+
+ /* --- the following bits of info are returned as NULL-terminated strings --- */
+ case DEVINFO_STR_NAME: info->s = "6526 CIA"; break;
+ case DEVINFO_STR_FAMILY: info->s = "6526 CIA"; break;
+ case DEVINFO_STR_VERSION: info->s = "1.0"; break;
+ case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break;
+ case DEVINFO_STR_CREDITS: /* Nothing */ break;
+ }
+}
+
+
+/*-------------------------------------------------
+ DEVICE_GET_INFO( cia8520 )
+-------------------------------------------------*/
+
+DEVICE_GET_INFO(cia8520)
+{
+ switch (state)
+ {
+ /* --- the following bits of info are returned as NULL-terminated strings --- */
+ case DEVINFO_STR_NAME: info->s = "8520 CIA"; break;
+ default: DEVICE_GET_INFO_CALL(cia6526); break;
+ }
+}
diff --git a/src/emu/machine/6526cia.h b/src/emu/machine/6526cia.h
index 1f4da8dc873..ef2bd0babb0 100644
--- a/src/emu/machine/6526cia.h
+++ b/src/emu/machine/6526cia.h
@@ -7,20 +7,26 @@
**********************************************************************/
-#ifndef _6526CIA_H_
-#define _6526CIA_H_
+#ifndef __6526CIA_H__
+#define __6526CIA_H__
-typedef enum
-{
- CIA6526,
- CIA8520
-} cia_type_t;
+
+/***************************************************************************
+ MACROS
+***************************************************************************/
+
+#define CIA6526 DEVICE_GET_INFO_NAME(cia6526)
+#define CIA8520 DEVICE_GET_INFO_NAME(cia8520)
+
+
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
typedef struct _cia6526_interface cia6526_interface;
struct _cia6526_interface
{
- cia_type_t type;
- void (*irq_func)(running_machine *machine, int state);
+ void (*irq_func)(const device_config *device, int state);
int clock;
int tod_clock;
@@ -31,29 +37,28 @@ struct _cia6526_interface
} port[2];
};
-/* configuration and reset */
-void cia_config(running_machine *machine, int which, const cia6526_interface *intf);
-void cia_reset(void);
-void cia_set_port_mask_value(int which, int port, int data);
-/* reading and writing */
-UINT8 cia_read(running_machine *machine, int which, offs_t offset);
-void cia_write(running_machine *machine, int which, offs_t offset, UINT8 data);
-void cia_clock_tod(running_machine *machine, int which);
-void cia_issue_index(running_machine *machine, int which);
-void cia_set_input_cnt(running_machine *machine, int which, int data);
-void cia_set_input_sp(int which, int data);
+/***************************************************************************
+ FUNCTION PROTOTYPES
+***************************************************************************/
-/* accessors */
-UINT8 cia_get_output_a(int which);
-UINT8 cia_get_output_b(int which);
-int cia_get_irq(int which);
+DEVICE_GET_INFO(cia6526);
+DEVICE_GET_INFO(cia8520);
-/* standard handlers */
-READ8_HANDLER( cia_0_r );
-READ8_HANDLER( cia_1_r );
+/* configuration */
+void cia_set_port_mask_value(const device_config *device, int port, int data);
-WRITE8_HANDLER( cia_0_w );
-WRITE8_HANDLER( cia_1_w );
+/* reading and writing */
+READ8_DEVICE_HANDLER( cia_r );
+WRITE8_DEVICE_HANDLER( cia_w );
+void cia_clock_tod(const device_config *device);
+void cia_issue_index(const device_config *device);
+void cia_set_input_cnt(const device_config *device, int data);
+void cia_set_input_sp(const device_config *device, int data);
+
+/* accessors */
+UINT8 cia_get_output_a(const device_config *device);
+UINT8 cia_get_output_b(const device_config *device);
+int cia_get_irq(const device_config *device);
-#endif /* _6526CIA_H_ */
+#endif /* __6526CIA_H__ */
diff --git a/src/mame/drivers/alg.c b/src/mame/drivers/alg.c
index b9be3e5253e..d0370c34e1f 100644
--- a/src/mame/drivers/alg.c
+++ b/src/mame/drivers/alg.c
@@ -25,6 +25,7 @@
#include "deprecat.h"
#include "includes/amiga.h"
#include "machine/laserdsc.h"
+#include "machine/6526cia.h"
static const device_config *laserdisc;
@@ -387,6 +388,28 @@ static const custom_sound_interface amiga_custom_interface =
*
*************************************/
+static const cia6526_interface cia_0_intf =
+{
+ amiga_cia_0_irq, /* irq_func */
+ AMIGA_68000_NTSC_CLOCK / 10, /* clock */
+ 0, /* tod_clock */
+ {
+ { alg_cia_0_porta_r, alg_cia_0_porta_w }, /* port A */
+ { alg_cia_0_portb_r, alg_cia_0_portb_w } /* port B */
+ }
+};
+
+static const cia6526_interface cia_1_intf =
+{
+ amiga_cia_1_irq, /* irq_func */
+ 0, /* clock */
+ 0, /* tod_clock */
+ {
+ { alg_cia_1_porta_r, alg_cia_1_porta_w, }, /* port A */
+ { NULL, NULL } /* port B */
+ }
+};
+
static MACHINE_DRIVER_START( alg_r1 )
/* basic machine hardware */
@@ -426,6 +449,12 @@ static MACHINE_DRIVER_START( alg_r1 )
MDRV_SOUND_CONFIG(laserdisc_custom_interface)
MDRV_SOUND_ROUTE(0, "left", 1.0)
MDRV_SOUND_ROUTE(1, "right", 1.0)
+
+ /* cia */
+ MDRV_DEVICE_ADD("cia_0", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_0_intf)
+ MDRV_DEVICE_ADD("cia_1", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_1_intf)
MACHINE_DRIVER_END
@@ -644,10 +673,6 @@ static void alg_init(running_machine *machine)
static const amiga_machine_interface alg_intf =
{
ANGUS_CHIP_RAM_MASK,
- alg_cia_0_porta_r, alg_cia_0_portb_r,
- alg_cia_0_porta_w, alg_cia_0_portb_w,
- alg_cia_1_porta_r, NULL,
- alg_cia_1_porta_w, NULL,
NULL, NULL, alg_potgo_w,
NULL, NULL, serial_w,
diff --git a/src/mame/drivers/arcadia.c b/src/mame/drivers/arcadia.c
index 4114e3129d6..e7849bfe27c 100644
--- a/src/mame/drivers/arcadia.c
+++ b/src/mame/drivers/arcadia.c
@@ -51,6 +51,7 @@
#include "deprecat.h"
#include "sound/custom.h"
#include "includes/amiga.h"
+#include "machine/6526cia.h"
@@ -280,6 +281,28 @@ static const custom_sound_interface amiga_custom_interface =
*
*************************************/
+static const cia6526_interface cia_0_intf =
+{
+ amiga_cia_0_irq, /* irq_func */
+ AMIGA_68000_NTSC_CLOCK, /* clock */
+ 0, /* tod_clock */
+ {
+ { arcadia_cia_0_porta_r, arcadia_cia_0_porta_w }, /* port A */
+ { arcadia_cia_0_portb_r, arcadia_cia_0_portb_w } /* port B */
+ }
+};
+
+static const cia6526_interface cia_1_intf =
+{
+ amiga_cia_1_irq, /* irq_func */
+ AMIGA_68000_NTSC_CLOCK / 10, /* clock */
+ 0, /* tod_clock */
+ {
+ { NULL, NULL }, /* port A */
+ { NULL, NULL } /* port B */
+ }
+};
+
static MACHINE_DRIVER_START( arcadia )
/* basic machine hardware */
@@ -313,6 +336,12 @@ static MACHINE_DRIVER_START( arcadia )
MDRV_SOUND_ROUTE(1, "right", 0.50)
MDRV_SOUND_ROUTE(2, "right", 0.50)
MDRV_SOUND_ROUTE(3, "left", 0.50)
+
+ /* cia */
+ MDRV_DEVICE_ADD("cia_0", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_0_intf)
+ MDRV_DEVICE_ADD("cia_1", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_1_intf)
MACHINE_DRIVER_END
@@ -654,10 +683,6 @@ static void arcadia_init(running_machine *machine)
static const amiga_machine_interface arcadia_intf =
{
ANGUS_CHIP_RAM_MASK,
- arcadia_cia_0_porta_r, arcadia_cia_0_portb_r,
- arcadia_cia_0_porta_w, arcadia_cia_0_portb_w,
- NULL, NULL,
- NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, arcadia_reset_coins,
diff --git a/src/mame/drivers/cubocd32.c b/src/mame/drivers/cubocd32.c
index cc972d709b9..d0278ceabc9 100644
--- a/src/mame/drivers/cubocd32.c
+++ b/src/mame/drivers/cubocd32.c
@@ -49,6 +49,7 @@
#include "sound/custom.h"
#include "includes/amiga.h"
#include "includes/cubocd32.h"
+#include "machine/6526cia.h"
static WRITE32_HANDLER( aga_overlay_w )
{
@@ -219,6 +220,29 @@ static const custom_sound_interface amiga_custom_interface =
};
+
+static const cia6526_interface cia_0_intf =
+{
+ amiga_cia_0_irq, /* irq_func */
+ AMIGA_68EC020_PAL_CLOCK / 10, /* clock */
+ 0, /* tod_clock */
+ {
+ { cd32_cia_0_porta_r, cd32_cia_0_porta_w }, /* port A */
+ { cd32_cia_0_portb_r, cd32_cia_0_portb_w } /* port B */
+ }
+};
+
+static const cia6526_interface cia_1_intf =
+{
+ amiga_cia_1_irq, /* irq_func */
+ AMIGA_68EC020_PAL_CLOCK / 10, /* clock */
+ 0, /* tod_clock */
+ {
+ { NULL, NULL }, /* port A */
+ { NULL, NULL } /* port B */
+ }
+};
+
static MACHINE_DRIVER_START( cd32 )
/* basic machine hardware */
@@ -257,6 +281,12 @@ static MACHINE_DRIVER_START( cd32 )
MDRV_SOUND_ADD( "cdda", CDDA, 0 )
MDRV_SOUND_ROUTE( 0, "left", 0.50 )
MDRV_SOUND_ROUTE( 1, "right", 0.50 )
+
+ /* cia */
+ MDRV_DEVICE_ADD("cia_0", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_0_intf)
+ MDRV_DEVICE_ADD("cia_1", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_1_intf)
MACHINE_DRIVER_END
@@ -322,10 +352,6 @@ static DRIVER_INIT( cd32 )
static const amiga_machine_interface cubocd32_intf =
{
AGA_CHIP_RAM_MASK,
- cd32_cia_0_porta_r, cd32_cia_0_portb_r,
- cd32_cia_0_porta_w, cd32_cia_0_portb_w,
- NULL, NULL,
- NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL,
diff --git a/src/mame/drivers/mquake.c b/src/mame/drivers/mquake.c
index 1fc1c3b7d46..2a6d6a40382 100644
--- a/src/mame/drivers/mquake.c
+++ b/src/mame/drivers/mquake.c
@@ -11,6 +11,7 @@
#include "deprecat.h"
#include "includes/amiga.h"
#include "sound/es5503.h"
+#include "machine/6526cia.h"
@@ -348,6 +349,28 @@ static MACHINE_RESET(mquake)
*
*************************************/
+static const cia6526_interface cia_0_intf =
+{
+ amiga_cia_0_irq, /* irq_func */
+ AMIGA_68000_NTSC_CLOCK / 10, /* clock */
+ 0, /* tod_clock */
+ {
+ { mquake_cia_0_porta_r, mquake_cia_0_porta_w }, /* port A */
+ { mquake_cia_0_portb_r, mquake_cia_0_portb_w } /* port B */
+ }
+};
+
+static const cia6526_interface cia_1_intf =
+{
+ amiga_cia_1_irq, /* irq_func */
+ AMIGA_68000_NTSC_CLOCK / 10, /* clock */
+ 0, /* tod_clock */
+ {
+ { NULL, NULL }, /* port A */
+ { NULL, NULL } /* port B */
+ }
+};
+
static MACHINE_DRIVER_START( mquake )
/* basic machine hardware */
@@ -389,6 +412,12 @@ static MACHINE_DRIVER_START( mquake )
MDRV_SOUND_ROUTE(0, "right", 0.50)
MDRV_SOUND_ROUTE(1, "left", 0.50)
MDRV_SOUND_ROUTE(1, "right", 0.50)
+
+ /* cia */
+ MDRV_DEVICE_ADD("cia_0", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_0_intf)
+ MDRV_DEVICE_ADD("cia_1", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_1_intf)
MACHINE_DRIVER_END
@@ -438,10 +467,6 @@ static DRIVER_INIT(mquake)
static const amiga_machine_interface mquake_intf =
{
ANGUS_CHIP_RAM_MASK,
- mquake_cia_0_porta_r, mquake_cia_0_portb_r,
- mquake_cia_0_porta_w, mquake_cia_0_portb_w,
- NULL, NULL,
- NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL,
diff --git a/src/mame/drivers/upscope.c b/src/mame/drivers/upscope.c
index 66ff94ad051..c41b8962486 100644
--- a/src/mame/drivers/upscope.c
+++ b/src/mame/drivers/upscope.c
@@ -26,6 +26,7 @@
#include "driver.h"
#include "deprecat.h"
#include "includes/amiga.h"
+#include "machine/6526cia.h"
@@ -286,6 +287,28 @@ static const custom_sound_interface amiga_custom_interface =
*
*************************************/
+static const cia6526_interface cia_0_intf =
+{
+ amiga_cia_0_irq, /* irq_func */
+ AMIGA_68000_NTSC_CLOCK / 10, /* clock */
+ 0, /* tod_clock */
+ {
+ { NULL, upscope_cia_0_porta_w }, /* port A */
+ { upscope_cia_0_portb_r, upscope_cia_0_portb_w } /* port B */
+ }
+};
+
+static const cia6526_interface cia_1_intf =
+{
+ amiga_cia_1_irq, /* irq_func */
+ AMIGA_68000_NTSC_CLOCK / 10, /* clock */
+ 0, /* tod_clock */
+ {
+ { upscope_cia_1_porta_r, upscope_cia_1_porta_w, }, /* port A */
+ { NULL, NULL } /* port B */
+ }
+};
+
static MACHINE_DRIVER_START( upscope )
/* basic machine hardware */
@@ -320,6 +343,12 @@ static MACHINE_DRIVER_START( upscope )
MDRV_SOUND_ROUTE(1, "left", 0.50)
MDRV_SOUND_ROUTE(2, "left", 0.50)
MDRV_SOUND_ROUTE(3, "right", 0.50)
+
+ /* cia */
+ MDRV_DEVICE_ADD("cia_0", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_0_intf)
+ MDRV_DEVICE_ADD("cia_1", CIA8520)
+ MDRV_DEVICE_CONFIG(cia_1_intf)
MACHINE_DRIVER_END
@@ -365,10 +394,6 @@ static DRIVER_INIT( upscope )
static const amiga_machine_interface upscope_intf =
{
ANGUS_CHIP_RAM_MASK,
- NULL, upscope_cia_0_portb_r,
- upscope_cia_0_porta_w, upscope_cia_0_portb_w,
- upscope_cia_1_porta_r, NULL,
- upscope_cia_1_porta_w, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, upscope_reset,
diff --git a/src/mame/includes/amiga.h b/src/mame/includes/amiga.h
index 2154340db7c..97f8b323a6d 100644
--- a/src/mame/includes/amiga.h
+++ b/src/mame/includes/amiga.h
@@ -309,16 +309,6 @@ struct _amiga_machine_interface
{
UINT32 chip_ram_mask;
- UINT8 (*cia_0_portA_r)(void);
- UINT8 (*cia_0_portB_r)(void);
- void (*cia_0_portA_w)(UINT8 data);
- void (*cia_0_portB_w)(UINT8 data);
-
- UINT8 (*cia_1_portA_r)(void);
- UINT8 (*cia_1_portB_r)(void);
- void (*cia_1_portA_w)(UINT8 data);
- void (*cia_1_portB_w)(UINT8 data);
-
UINT16 (*joy0dat_r)(void);
UINT16 (*joy1dat_r)(void);
void (*potgo_w)(UINT16 data);
@@ -393,6 +383,9 @@ void amiga_add_autoconfig(const amiga_autoconfig_device *device);
READ16_HANDLER( amiga_autoconfig_r );
WRITE16_HANDLER( amiga_autoconfig_w );
+void amiga_cia_0_irq(const device_config *device, int state);
+void amiga_cia_1_irq(const device_config *device, int state);
+
const amiga_machine_interface *amiga_get_interface(void);
diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c
index 704ffb43292..7a321421ad3 100644
--- a/src/mame/machine/amiga.c
+++ b/src/mame/machine/amiga.c
@@ -33,9 +33,6 @@
*
*************************************/
-/* 715909 Hz for NTSC, 709379 for PAL */
-#define O2_CLOCK (cpu_get_clock(machine->cpu[0]) / 10)
-
/* How many CPU cycles we delay until we fire a pending interrupt */
#define AMIGA_IRQ_DELAY_CYCLES 24
@@ -175,8 +172,6 @@ const char *const amiga_custom_names[0x100] =
static void custom_reset(void);
static void autoconfig_reset(void);
-static void amiga_cia_0_irq(running_machine *machine, int state);
-static void amiga_cia_1_irq(running_machine *machine, int state);
static TIMER_CALLBACK( amiga_irq_proc );
static TIMER_CALLBACK( amiga_blitter_proc );
static TIMER_CALLBACK( scanline_callback );
@@ -260,8 +255,6 @@ static void amiga_chip_ram32_w(offs_t offset, UINT16 data)
void amiga_machine_config(running_machine *machine, const amiga_machine_interface *intf)
{
- cia6526_interface cia_intf[2];
-
amiga_intf = intf;
/* setup chipmem handlers */
@@ -276,28 +269,6 @@ void amiga_machine_config(running_machine *machine, const amiga_machine_interfac
amiga_chip_ram_w = amiga_chip_ram16_w;
}
- /* set up CIA interfaces */
- memset(&cia_intf, 0, sizeof(cia_intf));
- cia_intf[0].type = CIA8520;
- cia_intf[0].clock = O2_CLOCK;
- cia_intf[0].tod_clock = 0;
- cia_intf[0].irq_func = amiga_cia_0_irq;
- cia_intf[0].port[0].read = intf->cia_0_portA_r;
- cia_intf[0].port[0].write = intf->cia_0_portA_w;
- cia_intf[0].port[1].read = intf->cia_0_portB_r;
- cia_intf[0].port[1].write = intf->cia_0_portB_w;
- cia_config(machine, 0, &cia_intf[0]);
-
- cia_intf[1].type = CIA8520;
- cia_intf[1].clock = O2_CLOCK;
- cia_intf[1].tod_clock = 0;
- cia_intf[1].irq_func = amiga_cia_1_irq;
- cia_intf[1].port[0].read = intf->cia_1_portA_r;
- cia_intf[1].port[0].write = intf->cia_1_portA_w;
- cia_intf[1].port[1].read = intf->cia_1_portB_r;
- cia_intf[1].port[1].write = intf->cia_1_portB_w;
- cia_config(machine, 1, &cia_intf[1]);
-
/* setup the timers */
amiga_irq_timer = timer_alloc(machine, amiga_irq_proc, NULL);
amiga_blitter_timer = timer_alloc(machine, amiga_blitter_proc, NULL);
@@ -311,7 +282,6 @@ static void amiga_m68k_reset(const device_config *device)
logerror("Executed RESET at PC=%06x\n", cpu_get_pc(space->cpu));
/* Initialize the various chips */
- cia_reset();
custom_reset();
autoconfig_reset();
@@ -355,6 +325,8 @@ MACHINE_RESET( amiga )
static TIMER_CALLBACK( scanline_callback )
{
int scanline = param;
+ const device_config *cia_0 = device_list_find_by_tag(machine->config->devicelist, CIA8520, "cia_0");
+ const device_config *cia_1 = device_list_find_by_tag(machine->config->devicelist, CIA8520, "cia_1");
/* on the first scanline, we do some extra bookkeeping */
if (scanline == 0)
@@ -363,7 +335,7 @@ static TIMER_CALLBACK( scanline_callback )
amiga_custom_w(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), REG_INTREQ, 0x8000 | INTENA_VERTB, 0xffff);
/* clock the first CIA TOD */
- cia_clock_tod(machine, 0);
+ cia_clock_tod(cia_0);
/* call the system-specific callback */
if (amiga_intf->scanline0_callback != NULL)
@@ -371,7 +343,7 @@ static TIMER_CALLBACK( scanline_callback )
}
/* on every scanline, clock the second CIA TOD */
- cia_clock_tod(machine, 1);
+ cia_clock_tod(cia_1);
/* render up to this scanline */
if (!video_screen_update_partial(machine->primary_screen, scanline))
@@ -1047,24 +1019,25 @@ static void blitter_setup(void)
READ16_HANDLER( amiga_cia_r )
{
UINT8 data;
- int shift, which;
+ int shift;
+ const device_config *cia;
/* offsets 0000-07ff reference CIA B, and are accessed via the MSB */
if ((offset & 0x0800) == 0)
{
- which = 1;
+ cia = device_list_find_by_tag(space->machine->config->devicelist, CIA8520, "cia_1");
shift = 8;
}
/* offsets 0800-0fff reference CIA A, and are accessed via the LSB */
else
{
- which = 0;
+ cia = device_list_find_by_tag(space->machine->config->devicelist, CIA8520, "cia_0");
shift = 0;
}
/* handle the reads */
- data = cia_read(space->machine, which, offset >> 7);
+ data = cia_r(cia, offset >> 7);
if (LOG_CIA)
logerror("%06x:cia_%c_read(%03x) = %04x & %04x\n", safe_cpu_get_pc(space->cpu), 'A' + ((~offset & 0x0800) >> 11), offset * 2, data << shift, mem_mask);
@@ -1082,7 +1055,7 @@ READ16_HANDLER( amiga_cia_r )
WRITE16_HANDLER( amiga_cia_w )
{
- int which;
+ const device_config *cia;
if (LOG_CIA)
logerror("%06x:cia_%c_write(%03x) = %04x & %04x\n", safe_cpu_get_pc(space->cpu), 'A' + ((~offset & 0x0800) >> 11), offset * 2, data, mem_mask);
@@ -1092,7 +1065,7 @@ WRITE16_HANDLER( amiga_cia_w )
{
if (!ACCESSING_BITS_8_15)
return;
- which = 1;
+ cia = device_list_find_by_tag(space->machine->config->devicelist, CIA8520, "cia_1");
data >>= 8;
}
@@ -1101,12 +1074,12 @@ WRITE16_HANDLER( amiga_cia_w )
{
if (!ACCESSING_BITS_0_7)
return;
- which = 0;
+ cia = device_list_find_by_tag(space->machine->config->devicelist, CIA8520, "cia_0");
data &= 0xff;
}
/* handle the writes */
- cia_write(space->machine, which, offset >> 7, (UINT8) data);
+ cia_w(cia, offset >> 7, (UINT8) data);
}
@@ -1117,15 +1090,15 @@ WRITE16_HANDLER( amiga_cia_w )
*
*************************************/
-static void amiga_cia_0_irq(running_machine *machine, int state)
+void amiga_cia_0_irq(const device_config *device, int state)
{
- amiga_custom_w(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_PORTS, 0xffff);
+ amiga_custom_w(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_PORTS, 0xffff);
}
-static void amiga_cia_1_irq(running_machine *machine, int state)
+void amiga_cia_1_irq(const device_config *device, int state)
{
- amiga_custom_w(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_EXTER, 0xffff);
+ amiga_custom_w(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_EXTER, 0xffff);
}
@@ -1276,6 +1249,8 @@ static TIMER_CALLBACK( finish_serial_write )
WRITE16_HANDLER( amiga_custom_w )
{
+ const device_config *cia_0;
+ const device_config *cia_1;
UINT16 temp;
offset &= 0xff;
@@ -1422,12 +1397,14 @@ WRITE16_HANDLER( amiga_custom_w )
CUSTOM_REG(REG_SERDATR) &= ~0x8000;
data = (data & 0x8000) ? (CUSTOM_REG(offset) | (data & 0x7fff)) : (CUSTOM_REG(offset) & ~(data & 0x7fff));
- if ( cia_get_irq( 0 ) ) data |= INTENA_PORTS;
- if ( cia_get_irq( 1 ) ) data |= INTENA_EXTER;
+ cia_0 = device_list_find_by_tag(space->machine->config->devicelist, CIA8520, "cia_0");
+ cia_1 = device_list_find_by_tag(space->machine->config->devicelist, CIA8520, "cia_1");
+ if ( cia_get_irq( cia_0 ) ) data |= INTENA_PORTS;
+ if ( cia_get_irq( cia_1 ) ) data |= INTENA_EXTER;
CUSTOM_REG(offset) = data;
if ( temp & 0x8000 ) /* if we're generating irq's, delay a bit */
- timer_adjust_oneshot( amiga_irq_timer, cpu_clocks_to_attotime( Machine->activecpu, AMIGA_IRQ_DELAY_CYCLES ), 0);
+ timer_adjust_oneshot( amiga_irq_timer, cpu_clocks_to_attotime( space->machine->cpu[0], AMIGA_IRQ_DELAY_CYCLES ), 0);
else /* if we're clearing irq's, process right away */
update_irqs(space->machine);
break;