diff options
author | 2008-12-05 03:59:56 +0000 | |
---|---|---|
committer | 2008-12-05 03:59:56 +0000 | |
commit | 9c88aa96d05c4c88908a571b7581dfc16b9e7e5e (patch) | |
tree | 54f2963c1754eead960824b4a5931093fd7ded34 /src/emu/machine | |
parent | 89b03aba17097b7327d47904bbf8b5f5eca651b6 (diff) |
Made the 6526/8520 CIA implementations be devices
Diffstat (limited to 'src/emu/machine')
-rw-r--r-- | src/emu/machine/6526cia.c | 471 | ||||
-rw-r--r-- | src/emu/machine/6526cia.h | 65 |
2 files changed, 315 insertions, 221 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__ */ |