mirror of
https://github.com/holub/mame
synced 2025-05-24 23:05:32 +03:00
Refactored the CIA 6526 interface, adding SP/CNT callbacks.
This commit is contained in:
parent
c6c534dbb6
commit
2244f9274d
@ -10,7 +10,6 @@
|
|||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "6526cia.h"
|
#include "6526cia.h"
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
CONSTANTS
|
CONSTANTS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -33,7 +32,6 @@
|
|||||||
#define CIA_CRA 14
|
#define CIA_CRA 14
|
||||||
#define CIA_CRB 15
|
#define CIA_CRB 15
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
TYPE DEFINITIONS
|
TYPE DEFINITIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -66,8 +64,10 @@ struct _cia_port
|
|||||||
struct _cia_state
|
struct _cia_state
|
||||||
{
|
{
|
||||||
running_device *device;
|
running_device *device;
|
||||||
devcb_resolved_write_line irq_func;
|
devcb_resolved_write_line out_irq_func;
|
||||||
devcb_resolved_write_line pc_func;
|
devcb_resolved_write_line out_pc_func;
|
||||||
|
devcb_resolved_write_line out_cnt_func;
|
||||||
|
devcb_resolved_write_line out_sp_func;
|
||||||
|
|
||||||
cia_port port[2];
|
cia_port port[2];
|
||||||
cia_timer timer[2];
|
cia_timer timer[2];
|
||||||
@ -94,7 +94,6 @@ struct _cia_state
|
|||||||
UINT8 serial;
|
UINT8 serial;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
PROTOTYPES
|
PROTOTYPES
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -103,8 +102,6 @@ static TIMER_CALLBACK( cia_timer_proc );
|
|||||||
static void cia_timer_underflow(running_device *device, int timer);
|
static void cia_timer_underflow(running_device *device, int timer);
|
||||||
static TIMER_CALLBACK( cia_clock_tod_callback );
|
static TIMER_CALLBACK( cia_clock_tod_callback );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
INLINE FUNCTIONS
|
INLINE FUNCTIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -112,98 +109,21 @@ static TIMER_CALLBACK( cia_clock_tod_callback );
|
|||||||
INLINE cia_state *get_token(running_device *device)
|
INLINE cia_state *get_token(running_device *device)
|
||||||
{
|
{
|
||||||
assert(device != NULL);
|
assert(device != NULL);
|
||||||
assert((device->type == CIA6526R1) || (device->type == CIA6526R2) || (device->type == CIA8520));
|
assert((device->type == MOS6526R1) || (device->type == MOS6526R2) || (device->type == MOS8520));
|
||||||
return (cia_state *) device->token;
|
return (cia_state *) device->token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE const mos6526_interface *get_interface(running_device *device)
|
||||||
INLINE const cia6526_interface *get_interface(running_device *device)
|
|
||||||
{
|
{
|
||||||
assert(device != NULL);
|
assert(device != NULL);
|
||||||
assert((device->type == CIA6526R1) || (device->type == CIA6526R2) || (device->type == CIA8520));
|
assert((device->type == MOS6526R1) || (device->type == MOS6526R2) || (device->type == MOS8520));
|
||||||
return (cia6526_interface *) device->baseconfig().static_config;
|
return (mos6526_interface *) device->baseconfig().static_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
IMPLEMENTATION
|
IMPLEMENTATION
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/*-------------------------------------------------
|
|
||||||
DEVICE_START( cia )
|
|
||||||
-------------------------------------------------*/
|
|
||||||
|
|
||||||
static DEVICE_START( cia )
|
|
||||||
{
|
|
||||||
int t, p;
|
|
||||||
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->device = device;
|
|
||||||
devcb_resolve_write_line(&cia->irq_func, &intf->irq_func, device);
|
|
||||||
devcb_resolve_write_line(&cia->pc_func, &intf->pc_func, device);
|
|
||||||
cia->flag = 1;
|
|
||||||
|
|
||||||
/* setup ports */
|
|
||||||
for (p = 0; p < (sizeof(cia->port) / sizeof(cia->port[0])); p++)
|
|
||||||
{
|
|
||||||
devcb_resolve_read8(&cia->port[p].read, &intf->port[p].read, device);
|
|
||||||
devcb_resolve_write8(&cia->port[p].write, &intf->port[p].write, device);
|
|
||||||
cia->port[p].mask_value = 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup timers */
|
|
||||||
for (t = 0; t < (sizeof(cia->timer) / sizeof(cia->timer[0])); t++)
|
|
||||||
{
|
|
||||||
cia_timer *timer = &cia->timer[t];
|
|
||||||
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 != 0)
|
|
||||||
timer_pulse(device->machine, ATTOTIME_IN_HZ(intf->tod_clock), (void *) device, 0, cia_clock_tod_callback);
|
|
||||||
|
|
||||||
/* state save support */
|
|
||||||
state_save_register_device_item(device, 0, cia->port[0].ddr);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[0].latch);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[0].in);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[0].out);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[0].mask_value);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[1].ddr);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[1].latch);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[1].in);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[1].out);
|
|
||||||
state_save_register_device_item(device, 0, cia->port[1].mask_value);
|
|
||||||
state_save_register_device_item(device, 0, cia->timer[0].latch);
|
|
||||||
state_save_register_device_item(device, 0, cia->timer[0].count);
|
|
||||||
state_save_register_device_item(device, 0, cia->timer[0].mode);
|
|
||||||
state_save_register_device_item(device, 0, cia->timer[0].irq);
|
|
||||||
state_save_register_device_item(device, 0, cia->timer[1].latch);
|
|
||||||
state_save_register_device_item(device, 0, cia->timer[1].count);
|
|
||||||
state_save_register_device_item(device, 0, cia->timer[1].mode);
|
|
||||||
state_save_register_device_item(device, 0, cia->timer[1].irq);
|
|
||||||
state_save_register_device_item(device, 0, cia->tod);
|
|
||||||
state_save_register_device_item(device, 0, cia->tod_latch);
|
|
||||||
state_save_register_device_item(device, 0, cia->tod_latched);
|
|
||||||
state_save_register_device_item(device, 0, cia->tod_running);
|
|
||||||
state_save_register_device_item(device, 0, cia->alarm);
|
|
||||||
state_save_register_device_item(device, 0, cia->icr);
|
|
||||||
state_save_register_device_item(device, 0, cia->ics);
|
|
||||||
state_save_register_device_item(device, 0, cia->irq);
|
|
||||||
state_save_register_device_item(device, 0, cia->flag);
|
|
||||||
state_save_register_device_item(device, 0, cia->loaded);
|
|
||||||
state_save_register_device_item(device, 0, cia->sdr);
|
|
||||||
state_save_register_device_item(device, 0, cia->sp);
|
|
||||||
state_save_register_device_item(device, 0, cia->cnt);
|
|
||||||
state_save_register_device_item(device, 0, cia->shift);
|
|
||||||
state_save_register_device_item(device, 0, cia->serial);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_set_port_mask_value
|
cia_set_port_mask_value
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -214,7 +134,6 @@ void cia_set_port_mask_value(running_device *device, int port, int data)
|
|||||||
cia->port[port].mask_value = data;
|
cia->port[port].mask_value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
DEVICE_RESET( cia )
|
DEVICE_RESET( cia )
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -258,7 +177,6 @@ static DEVICE_RESET( cia )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
DEVICE_VALIDITY_CHECK( cia )
|
DEVICE_VALIDITY_CHECK( cia )
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -276,7 +194,6 @@ static DEVICE_VALIDITY_CHECK( cia )
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_update_pc - pulse /pc output
|
cia_update_pc - pulse /pc output
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -286,11 +203,10 @@ static void cia_update_pc(running_device *device)
|
|||||||
cia_state *cia = get_token(device);
|
cia_state *cia = get_token(device);
|
||||||
|
|
||||||
/* this should really be one cycle long */
|
/* this should really be one cycle long */
|
||||||
devcb_call_write_line(&cia->pc_func, 0);
|
devcb_call_write_line(&cia->out_pc_func, 0);
|
||||||
devcb_call_write_line(&cia->pc_func, 1);
|
devcb_call_write_line(&cia->out_pc_func, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_update_interrupts
|
cia_update_interrupts
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -311,11 +227,10 @@ static void cia_update_interrupts(running_device *device)
|
|||||||
if (cia->irq != new_irq)
|
if (cia->irq != new_irq)
|
||||||
{
|
{
|
||||||
cia->irq = new_irq;
|
cia->irq = new_irq;
|
||||||
devcb_call_write_line(&cia->irq_func, cia->irq);
|
devcb_call_write_line(&cia->out_irq_func, cia->irq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
is_timer_active
|
is_timer_active
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -326,7 +241,6 @@ static int is_timer_active(emu_timer *timer)
|
|||||||
return attotime_compare(t, attotime_never) != 0;
|
return attotime_compare(t, attotime_never) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_timer_update - updates the count and
|
cia_timer_update - updates the count and
|
||||||
emu_timer for a given CIA timer
|
emu_timer for a given CIA timer
|
||||||
@ -400,7 +314,6 @@ static void cia_timer_bump(running_device *device, int timer)
|
|||||||
cia_timer_update(&cia->timer[timer], cia->timer[timer].count - 1);
|
cia_timer_update(&cia->timer[timer], cia->timer[timer].count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_timer_underflow
|
cia_timer_underflow
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -448,10 +361,16 @@ static void cia_timer_underflow(running_device *device, int timer)
|
|||||||
cia->shift++;
|
cia->shift++;
|
||||||
cia->serial <<= 1;
|
cia->serial <<= 1;
|
||||||
cia->cnt = 0;
|
cia->cnt = 0;
|
||||||
|
|
||||||
|
devcb_call_write_line(&cia->out_cnt_func, cia->cnt);
|
||||||
|
devcb_call_write_line(&cia->out_sp_func, cia->sp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cia->cnt = 1;
|
cia->cnt = 1;
|
||||||
|
|
||||||
|
devcb_call_write_line(&cia->out_cnt_func, cia->cnt);
|
||||||
|
|
||||||
if (cia->shift == 8)
|
if (cia->shift == 8)
|
||||||
{
|
{
|
||||||
cia->ics |= 0x08;
|
cia->ics |= 0x08;
|
||||||
@ -463,7 +382,6 @@ static void cia_timer_underflow(running_device *device, int timer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
TIMER_CALLBACK( cia_timer_proc )
|
TIMER_CALLBACK( cia_timer_proc )
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -476,7 +394,6 @@ static TIMER_CALLBACK( cia_timer_proc )
|
|||||||
cia_timer_underflow(cia->device, timer - cia->timer);
|
cia_timer_underflow(cia->device, timer - cia->timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
bcd_increment
|
bcd_increment
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -489,7 +406,6 @@ static UINT8 bcd_increment(UINT8 value)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia6526_increment
|
cia6526_increment
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -535,12 +451,11 @@ static void cia6526_increment(cia_state *cia)
|
|||||||
| (((UINT32) hour) << 24);
|
| (((UINT32) hour) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_clock_tod - Update TOD on CIA A
|
cia_clock_tod - Update TOD on CIA A
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
void cia_clock_tod(running_device *device)
|
static void cia_clock_tod(running_device *device)
|
||||||
{
|
{
|
||||||
cia_state *cia;
|
cia_state *cia;
|
||||||
|
|
||||||
@ -548,13 +463,13 @@ void cia_clock_tod(running_device *device)
|
|||||||
|
|
||||||
if (cia->tod_running)
|
if (cia->tod_running)
|
||||||
{
|
{
|
||||||
if ((device->type == CIA6526R1) || (device->type == CIA6526R2))
|
if ((device->type == MOS6526R1) || (device->type == MOS6526R2))
|
||||||
{
|
{
|
||||||
/* The 6526 split the value into hours, minutes, seconds and
|
/* The 6526 split the value into hours, minutes, seconds and
|
||||||
* subseconds */
|
* subseconds */
|
||||||
cia6526_increment(cia);
|
cia6526_increment(cia);
|
||||||
}
|
}
|
||||||
else if (device->type == CIA8520)
|
else if (device->type == MOS8520)
|
||||||
{
|
{
|
||||||
/* the 8520 has a straight 24-bit counter */
|
/* the 8520 has a straight 24-bit counter */
|
||||||
cia->tod++;
|
cia->tod++;
|
||||||
@ -569,7 +484,6 @@ void cia_clock_tod(running_device *device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_clock_tod_callback
|
cia_clock_tod_callback
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -580,35 +494,32 @@ static TIMER_CALLBACK( cia_clock_tod_callback )
|
|||||||
cia_clock_tod(device);
|
cia_clock_tod(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_issue_index
|
cia_issue_index
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
void cia_issue_index(running_device *device)
|
static void cia_issue_index(running_device *device)
|
||||||
{
|
{
|
||||||
cia_state *cia = get_token(device);
|
cia_state *cia = get_token(device);
|
||||||
cia->ics |= 0x10;
|
cia->ics |= 0x10;
|
||||||
cia_update_interrupts(device);
|
cia_update_interrupts(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_set_input_sp
|
cia_set_input_sp
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
void cia_set_input_sp(running_device *device, int data)
|
static void cia_set_input_sp(running_device *device, int data)
|
||||||
{
|
{
|
||||||
cia_state *cia = get_token(device);
|
cia_state *cia = get_token(device);
|
||||||
cia->sp = data;
|
cia->sp = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_set_input_cnt
|
cia_set_input_cnt
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
void cia_set_input_cnt(running_device *device, int data)
|
static void cia_set_input_cnt(running_device *device, int data)
|
||||||
{
|
{
|
||||||
cia_state *cia = get_token(device);
|
cia_state *cia = get_token(device);
|
||||||
|
|
||||||
@ -643,16 +554,47 @@ void cia_set_input_cnt(running_device *device, int data)
|
|||||||
cia->cnt = data ? 1 : 0;
|
cia->cnt = data ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
READ8_DEVICE_HANDLER( mos6526_pa_r )
|
||||||
|
{
|
||||||
|
return (get_token(device)->port[0].latch | ~get_token(device)->port[0].ddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
READ8_DEVICE_HANDLER( mos6526_pb_r )
|
||||||
|
{
|
||||||
|
return (get_token(device)->port[1].latch | ~get_token(device)->port[1].ddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
READ_LINE_DEVICE_HANDLER( mos6526_irq_r )
|
||||||
|
{
|
||||||
|
cia_state *cia = get_token(device);
|
||||||
|
|
||||||
|
return cia->irq;
|
||||||
|
}
|
||||||
|
|
||||||
WRITE_LINE_DEVICE_HANDLER( mos6526_tod_w )
|
WRITE_LINE_DEVICE_HANDLER( mos6526_tod_w )
|
||||||
{
|
{
|
||||||
if (state) cia_clock_tod(device);
|
if (state) cia_clock_tod(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
READ_LINE_DEVICE_HANDLER( mos6526_cnt_r )
|
||||||
|
{
|
||||||
|
cia_state *cia = get_token(device);
|
||||||
|
|
||||||
|
return cia->cnt;
|
||||||
|
}
|
||||||
|
|
||||||
WRITE_LINE_DEVICE_HANDLER( mos6526_cnt_w )
|
WRITE_LINE_DEVICE_HANDLER( mos6526_cnt_w )
|
||||||
{
|
{
|
||||||
cia_set_input_cnt(device, state);
|
cia_set_input_cnt(device, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
READ_LINE_DEVICE_HANDLER( mos6526_sp_r )
|
||||||
|
{
|
||||||
|
cia_state *cia = get_token(device);
|
||||||
|
|
||||||
|
return cia->sp;
|
||||||
|
}
|
||||||
|
|
||||||
WRITE_LINE_DEVICE_HANDLER( mos6526_sp_w )
|
WRITE_LINE_DEVICE_HANDLER( mos6526_sp_w )
|
||||||
{
|
{
|
||||||
cia_set_input_sp(device, state);
|
cia_set_input_sp(device, state);
|
||||||
@ -671,10 +613,10 @@ WRITE_LINE_DEVICE_HANDLER( mos6526_flag_w )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_r
|
mos6526_r
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
READ8_DEVICE_HANDLER( cia_r )
|
READ8_DEVICE_HANDLER( mos6526_r )
|
||||||
{
|
{
|
||||||
cia_timer *timer;
|
cia_timer *timer;
|
||||||
cia_state *cia;
|
cia_state *cia;
|
||||||
@ -748,7 +690,7 @@ READ8_DEVICE_HANDLER( cia_r )
|
|||||||
case CIA_TOD1:
|
case CIA_TOD1:
|
||||||
case CIA_TOD2:
|
case CIA_TOD2:
|
||||||
case CIA_TOD3:
|
case CIA_TOD3:
|
||||||
if (device->type == CIA8520)
|
if (device->type == MOS8520)
|
||||||
{
|
{
|
||||||
if (offset == CIA_TOD2)
|
if (offset == CIA_TOD2)
|
||||||
{
|
{
|
||||||
@ -796,12 +738,11 @@ READ8_DEVICE_HANDLER( cia_r )
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
cia_w
|
mos6526_w
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
WRITE8_DEVICE_HANDLER( cia_w )
|
WRITE8_DEVICE_HANDLER( mos6526_w )
|
||||||
{
|
{
|
||||||
cia_timer *timer;
|
cia_timer *timer;
|
||||||
cia_state *cia;
|
cia_state *cia;
|
||||||
@ -875,7 +816,7 @@ WRITE8_DEVICE_HANDLER( cia_w )
|
|||||||
else
|
else
|
||||||
cia->tod = (cia->tod & ~(0xff << shift)) | (data << shift);
|
cia->tod = (cia->tod & ~(0xff << shift)) | (data << shift);
|
||||||
|
|
||||||
if (device->type == CIA8520)
|
if (device->type == MOS8520)
|
||||||
{
|
{
|
||||||
if (offset == CIA_TOD2)
|
if (offset == CIA_TOD2)
|
||||||
cia->tod_running = FALSE;
|
cia->tod_running = FALSE;
|
||||||
@ -920,12 +861,84 @@ WRITE8_DEVICE_HANDLER( cia_w )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------
|
||||||
|
DEVICE_START( cia )
|
||||||
|
-------------------------------------------------*/
|
||||||
|
|
||||||
|
static DEVICE_START( cia )
|
||||||
|
{
|
||||||
|
int t, p;
|
||||||
|
cia_state *cia = get_token(device);
|
||||||
|
const mos6526_interface *intf = get_interface(device);
|
||||||
|
|
||||||
UINT8 cia_get_output_a(running_device *device) { return (get_token(device)->port[0].latch | ~get_token(device)->port[0].ddr); }
|
/* clear out CIA structure, and copy the interface */
|
||||||
UINT8 cia_get_output_b(running_device *device) { return (get_token(device)->port[1].latch | ~get_token(device)->port[1].ddr); }
|
memset(cia, 0, sizeof(*cia));
|
||||||
int cia_get_irq(running_device *device) { return get_token(device)->irq; }
|
cia->device = device;
|
||||||
|
devcb_resolve_write_line(&cia->out_irq_func, &intf->out_irq_func, device);
|
||||||
|
devcb_resolve_write_line(&cia->out_pc_func, &intf->out_pc_func, device);
|
||||||
|
devcb_resolve_write_line(&cia->out_cnt_func, &intf->out_cnt_func, device);
|
||||||
|
devcb_resolve_write_line(&cia->out_sp_func, &intf->out_sp_func, device);
|
||||||
|
cia->flag = 1;
|
||||||
|
|
||||||
|
/* setup ports */
|
||||||
|
devcb_resolve_read8(&cia->port[0].read, &intf->in_pa_func, device);
|
||||||
|
devcb_resolve_write8(&cia->port[0].write, &intf->out_pa_func, device);
|
||||||
|
devcb_resolve_read8(&cia->port[1].read, &intf->in_pb_func, device);
|
||||||
|
devcb_resolve_write8(&cia->port[1].write, &intf->out_pb_func, device);
|
||||||
|
|
||||||
|
for (p = 0; p < (sizeof(cia->port) / sizeof(cia->port[0])); p++)
|
||||||
|
{
|
||||||
|
cia->port[p].mask_value = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* setup timers */
|
||||||
|
for (t = 0; t < (sizeof(cia->timer) / sizeof(cia->timer[0])); t++)
|
||||||
|
{
|
||||||
|
cia_timer *timer = &cia->timer[t];
|
||||||
|
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 != 0)
|
||||||
|
timer_pulse(device->machine, ATTOTIME_IN_HZ(intf->tod_clock), (void *) device, 0, cia_clock_tod_callback);
|
||||||
|
|
||||||
|
/* state save support */
|
||||||
|
state_save_register_device_item(device, 0, cia->port[0].ddr);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[0].latch);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[0].in);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[0].out);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[0].mask_value);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[1].ddr);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[1].latch);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[1].in);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[1].out);
|
||||||
|
state_save_register_device_item(device, 0, cia->port[1].mask_value);
|
||||||
|
state_save_register_device_item(device, 0, cia->timer[0].latch);
|
||||||
|
state_save_register_device_item(device, 0, cia->timer[0].count);
|
||||||
|
state_save_register_device_item(device, 0, cia->timer[0].mode);
|
||||||
|
state_save_register_device_item(device, 0, cia->timer[0].irq);
|
||||||
|
state_save_register_device_item(device, 0, cia->timer[1].latch);
|
||||||
|
state_save_register_device_item(device, 0, cia->timer[1].count);
|
||||||
|
state_save_register_device_item(device, 0, cia->timer[1].mode);
|
||||||
|
state_save_register_device_item(device, 0, cia->timer[1].irq);
|
||||||
|
state_save_register_device_item(device, 0, cia->tod);
|
||||||
|
state_save_register_device_item(device, 0, cia->tod_latch);
|
||||||
|
state_save_register_device_item(device, 0, cia->tod_latched);
|
||||||
|
state_save_register_device_item(device, 0, cia->tod_running);
|
||||||
|
state_save_register_device_item(device, 0, cia->alarm);
|
||||||
|
state_save_register_device_item(device, 0, cia->icr);
|
||||||
|
state_save_register_device_item(device, 0, cia->ics);
|
||||||
|
state_save_register_device_item(device, 0, cia->irq);
|
||||||
|
state_save_register_device_item(device, 0, cia->flag);
|
||||||
|
state_save_register_device_item(device, 0, cia->loaded);
|
||||||
|
state_save_register_device_item(device, 0, cia->sdr);
|
||||||
|
state_save_register_device_item(device, 0, cia->sp);
|
||||||
|
state_save_register_device_item(device, 0, cia->cnt);
|
||||||
|
state_save_register_device_item(device, 0, cia->shift);
|
||||||
|
state_save_register_device_item(device, 0, cia->serial);
|
||||||
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
DEVICE_GET_INFO( cia6526r1 )
|
DEVICE_GET_INFO( cia6526r1 )
|
||||||
@ -947,15 +960,14 @@ DEVICE_GET_INFO(cia6526r1)
|
|||||||
case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVICE_VALIDITY_CHECK_NAME(cia); break;
|
case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVICE_VALIDITY_CHECK_NAME(cia); break;
|
||||||
|
|
||||||
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
||||||
case DEVINFO_STR_NAME: strcpy(info->s, "6526 CIA rev1"); break;
|
case DEVINFO_STR_NAME: strcpy(info->s, "MOS6526 rev1"); break;
|
||||||
case DEVINFO_STR_FAMILY: strcpy(info->s, "6526 CIA"); break;
|
case DEVINFO_STR_FAMILY: strcpy(info->s, "MOS6526"); break;
|
||||||
case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
|
case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
|
||||||
case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
||||||
case DEVINFO_STR_CREDITS: /* Nothing */ break;
|
case DEVINFO_STR_CREDITS: /* Nothing */ break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
DEVICE_GET_INFO( cia8520 )
|
DEVICE_GET_INFO( cia8520 )
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -965,12 +977,11 @@ DEVICE_GET_INFO(cia6526r2)
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
||||||
case DEVINFO_STR_NAME: strcpy(info->s, "6526 CIA rev2"); break;
|
case DEVINFO_STR_NAME: strcpy(info->s, "MOS6526 rev2"); break;
|
||||||
default: DEVICE_GET_INFO_CALL(cia6526r1); break;
|
default: DEVICE_GET_INFO_CALL(cia6526r1); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
DEVICE_GET_INFO( cia8520 )
|
DEVICE_GET_INFO( cia8520 )
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
@ -980,9 +991,7 @@ DEVICE_GET_INFO(cia8520)
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
||||||
case DEVINFO_STR_NAME: strcpy(info->s, "8520 CIA"); break;
|
case DEVINFO_STR_NAME: strcpy(info->s, "MOS8520"); break;
|
||||||
default: DEVICE_GET_INFO_CALL(cia6526r1); break;
|
default: DEVICE_GET_INFO_CALL(cia6526r1); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,54 +1,86 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
||||||
MOS 6526/8520 CIA interface and emulation
|
MOS 6526/8520 Complex Interface Adapter emulation
|
||||||
|
|
||||||
This function emulates all the functionality of up to 2 MOS6526 or
|
Copyright MESS Team.
|
||||||
MOS8520 complex interface adapters.
|
Visit http://mamedev.org for licensing and usage restrictions.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
_____ _____
|
||||||
|
Vss 1 |* \_/ | 40 CNT
|
||||||
|
PA0 2 | | 39 SP
|
||||||
|
PA1 3 | | 38 RS0
|
||||||
|
PA2 4 | | 37 RS1
|
||||||
|
PA3 5 | | 36 RS2
|
||||||
|
PA4 6 | | 35 RS3
|
||||||
|
PA5 7 | | 34 _RES
|
||||||
|
PA6 8 | | 33 DB0
|
||||||
|
PA7 9 | | 32 DB1
|
||||||
|
PB0 10 | MOS6526 | 31 DB2
|
||||||
|
PB1 11 | MOS8520 | 30 DB3
|
||||||
|
PB2 12 | | 29 DB4
|
||||||
|
PB3 13 | | 28 DB5
|
||||||
|
PB4 14 | | 27 DB6
|
||||||
|
PB5 15 | | 26 DB7
|
||||||
|
PB6 16 | | 25 phi2
|
||||||
|
PB7 17 | | 24 _FLAG
|
||||||
|
_PC 18 | | 23 _CS
|
||||||
|
TOD 19 | | 22 R/W
|
||||||
|
Vcc 20 |_____________| 21 _IRQ
|
||||||
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#ifndef __6526CIA_H__
|
#ifndef __6526CIA_H__
|
||||||
#define __6526CIA_H__
|
#define __6526CIA_H__
|
||||||
|
|
||||||
|
#include "devcb.h"
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
MACROS
|
MACROS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#define CIA6526R1 DEVICE_GET_INFO_NAME(cia6526r1)
|
#define MOS6526R1 DEVICE_GET_INFO_NAME(cia6526r1)
|
||||||
#define CIA6526R2 DEVICE_GET_INFO_NAME(cia6526r1)
|
#define MOS6526R2 DEVICE_GET_INFO_NAME(cia6526r1)
|
||||||
#define CIA8520 DEVICE_GET_INFO_NAME(cia8520)
|
#define MOS8520 DEVICE_GET_INFO_NAME(cia8520)
|
||||||
|
|
||||||
#define MDRV_CIA6526_ADD(_tag, _variant, _clock, _config) \
|
#define MDRV_MOS6526R1_ADD(_tag, _clock, _config) \
|
||||||
MDRV_DEVICE_ADD(_tag, _variant, _clock) \
|
MDRV_DEVICE_ADD(_tag, MOS6526R1, _clock) \
|
||||||
MDRV_DEVICE_CONFIG(_config)
|
MDRV_DEVICE_CONFIG(_config)
|
||||||
|
|
||||||
#define MDRV_CIA8520_ADD(_tag, _clock, _config) \
|
#define MDRV_MOS6526R2_ADD(_tag, _clock, _config) \
|
||||||
MDRV_DEVICE_ADD(_tag, CIA8520, _clock) \
|
MDRV_DEVICE_ADD(_tag, MOS6526R2, _clock) \
|
||||||
MDRV_DEVICE_CONFIG(_config)
|
MDRV_DEVICE_CONFIG(_config)
|
||||||
|
|
||||||
|
#define MDRV_MOS8520_ADD(_tag, _clock, _config) \
|
||||||
|
MDRV_DEVICE_ADD(_tag, MOS8520, _clock) \
|
||||||
|
MDRV_DEVICE_CONFIG(_config)
|
||||||
|
|
||||||
|
#define MOS6526_INTERFACE(name) \
|
||||||
|
const mos6526_interface (name)=
|
||||||
|
|
||||||
|
#define MOS8520_INTERFACE(name) \
|
||||||
|
const mos6526_interface (name)=
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
TYPE DEFINITIONS
|
TYPE DEFINITIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
typedef struct _cia6526_interface cia6526_interface;
|
typedef struct _mos6526_interface mos6526_interface;
|
||||||
struct _cia6526_interface
|
struct _mos6526_interface
|
||||||
{
|
{
|
||||||
devcb_write_line irq_func;
|
|
||||||
devcb_write_line pc_func;
|
|
||||||
|
|
||||||
int tod_clock;
|
int tod_clock;
|
||||||
|
|
||||||
struct
|
devcb_write_line out_irq_func;
|
||||||
{
|
devcb_write_line out_pc_func;
|
||||||
devcb_read8 read;
|
devcb_write_line out_cnt_func;
|
||||||
devcb_write8 write;
|
devcb_write_line out_sp_func;
|
||||||
} port[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
devcb_read8 in_pa_func;
|
||||||
|
devcb_write8 out_pa_func;
|
||||||
|
|
||||||
|
devcb_read8 in_pb_func;
|
||||||
|
devcb_write8 out_pb_func;
|
||||||
|
};
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
FUNCTION PROTOTYPES
|
FUNCTION PROTOTYPES
|
||||||
@ -58,25 +90,32 @@ DEVICE_GET_INFO(cia6526r1);
|
|||||||
DEVICE_GET_INFO(cia6526r2);
|
DEVICE_GET_INFO(cia6526r2);
|
||||||
DEVICE_GET_INFO(cia8520);
|
DEVICE_GET_INFO(cia8520);
|
||||||
|
|
||||||
/* configuration */
|
/* register access */
|
||||||
void cia_set_port_mask_value(running_device *device, int port, int data);
|
READ8_DEVICE_HANDLER( mos6526_r );
|
||||||
|
WRITE8_DEVICE_HANDLER( mos6526_w );
|
||||||
|
|
||||||
/* reading and writing */
|
/* port access */
|
||||||
READ8_DEVICE_HANDLER( cia_r );
|
READ8_DEVICE_HANDLER( mos6526_pa_r );
|
||||||
WRITE8_DEVICE_HANDLER( cia_w );
|
READ8_DEVICE_HANDLER( mos6526_pb_r );
|
||||||
void cia_clock_tod(running_device *device);
|
|
||||||
void cia_issue_index(running_device *device);
|
|
||||||
void cia_set_input_cnt(running_device *device, int data);
|
|
||||||
void cia_set_input_sp(running_device *device, int data);
|
|
||||||
|
|
||||||
|
/* interrupt request */
|
||||||
|
READ_LINE_DEVICE_HANDLER( mos6526_irq_r );
|
||||||
|
|
||||||
|
/* time of day clock */
|
||||||
WRITE_LINE_DEVICE_HANDLER( mos6526_tod_w );
|
WRITE_LINE_DEVICE_HANDLER( mos6526_tod_w );
|
||||||
|
|
||||||
|
/* serial counter */
|
||||||
|
READ_LINE_DEVICE_HANDLER( mos6526_cnt_r );
|
||||||
WRITE_LINE_DEVICE_HANDLER( mos6526_cnt_w );
|
WRITE_LINE_DEVICE_HANDLER( mos6526_cnt_w );
|
||||||
|
|
||||||
|
/* serial port */
|
||||||
|
READ_LINE_DEVICE_HANDLER( mos6526_sp_r );
|
||||||
WRITE_LINE_DEVICE_HANDLER( mos6526_sp_w );
|
WRITE_LINE_DEVICE_HANDLER( mos6526_sp_w );
|
||||||
|
|
||||||
|
/* flag */
|
||||||
WRITE_LINE_DEVICE_HANDLER( mos6526_flag_w );
|
WRITE_LINE_DEVICE_HANDLER( mos6526_flag_w );
|
||||||
|
|
||||||
/* accessors */
|
/* port mask */
|
||||||
UINT8 cia_get_output_a(running_device *device);
|
void cia_set_port_mask_value(const device_config *device, int port, int data);
|
||||||
UINT8 cia_get_output_b(running_device *device);
|
|
||||||
int cia_get_irq(running_device *device);
|
|
||||||
|
|
||||||
#endif /* __6526CIA_H__ */
|
#endif /* __6526CIA_H__ */
|
||||||
|
@ -377,26 +377,30 @@ INPUT_PORTS_END
|
|||||||
*
|
*
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
static const cia6526_interface cia_0_intf =
|
static const mos6526_interface cia_0_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_HANDLER(alg_cia_0_porta_r), DEVCB_HANDLER(alg_cia_0_porta_w) }, /* port A */
|
DEVCB_HANDLER(alg_cia_0_porta_r),
|
||||||
{ DEVCB_HANDLER(alg_cia_0_portb_r), DEVCB_HANDLER(alg_cia_0_portb_w) } /* port B */
|
DEVCB_HANDLER(alg_cia_0_porta_w), /* port A */
|
||||||
}
|
DEVCB_HANDLER(alg_cia_0_portb_r),
|
||||||
|
DEVCB_HANDLER(alg_cia_0_portb_w) /* port B */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const cia6526_interface cia_1_intf =
|
static const mos6526_interface cia_1_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_HANDLER(alg_cia_1_porta_r), DEVCB_HANDLER(alg_cia_1_porta_w), }, /* port A */
|
DEVCB_HANDLER(alg_cia_1_porta_r),
|
||||||
{ DEVCB_NULL, DEVCB_NULL } /* port B */
|
DEVCB_HANDLER(alg_cia_1_porta_w), /* port A */
|
||||||
}
|
DEVCB_NULL,
|
||||||
|
DEVCB_NULL /* port B */
|
||||||
};
|
};
|
||||||
|
|
||||||
static MACHINE_DRIVER_START( alg_r1 )
|
static MACHINE_DRIVER_START( alg_r1 )
|
||||||
@ -438,8 +442,8 @@ static MACHINE_DRIVER_START( alg_r1 )
|
|||||||
MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
|
MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
|
||||||
|
|
||||||
/* cia */
|
/* cia */
|
||||||
MDRV_CIA8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_intf)
|
MDRV_MOS8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_intf)
|
||||||
MDRV_CIA8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK / 10, cia_1_intf)
|
MDRV_MOS8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK / 10, cia_1_intf)
|
||||||
MACHINE_DRIVER_END
|
MACHINE_DRIVER_END
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,26 +260,30 @@ INPUT_PORTS_END
|
|||||||
*
|
*
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
static const cia6526_interface cia_0_intf =
|
static const mos6526_interface cia_0_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(arcadia_cia_0_porta_w) }, /* port A */
|
DEVCB_INPUT_PORT("CIA0PORTA"),
|
||||||
{ DEVCB_INPUT_PORT("CIA0PORTB"), DEVCB_HANDLER(arcadia_cia_0_portb_w) } /* port B */
|
DEVCB_HANDLER(arcadia_cia_0_porta_w), /* port A */
|
||||||
}
|
DEVCB_INPUT_PORT("CIA0PORTB"),
|
||||||
|
DEVCB_HANDLER(arcadia_cia_0_portb_w) /* port B */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const cia6526_interface cia_1_intf =
|
static const mos6526_interface cia_1_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_NULL, DEVCB_NULL }, /* port A */
|
DEVCB_NULL,
|
||||||
{ DEVCB_NULL, DEVCB_NULL } /* port B */
|
DEVCB_NULL,
|
||||||
}
|
DEVCB_NULL,
|
||||||
|
DEVCB_NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static MACHINE_DRIVER_START( arcadia )
|
static MACHINE_DRIVER_START( arcadia )
|
||||||
@ -316,8 +320,8 @@ static MACHINE_DRIVER_START( arcadia )
|
|||||||
MDRV_SOUND_ROUTE(3, "lspeaker", 0.50)
|
MDRV_SOUND_ROUTE(3, "lspeaker", 0.50)
|
||||||
|
|
||||||
/* cia */
|
/* cia */
|
||||||
MDRV_CIA8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_intf)
|
MDRV_MOS8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_intf)
|
||||||
MDRV_CIA8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK / 10, cia_1_intf)
|
MDRV_MOS8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK / 10, cia_1_intf)
|
||||||
MACHINE_DRIVER_END
|
MACHINE_DRIVER_END
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ static WRITE8_DEVICE_HANDLER( cd32_cia_0_porta_w )
|
|||||||
/* bit 2 = Power Led on Amiga */
|
/* bit 2 = Power Led on Amiga */
|
||||||
set_led_status(device->machine, 0, (data & 2) ? 0 : 1);
|
set_led_status(device->machine, 0, (data & 2) ? 0 : 1);
|
||||||
|
|
||||||
handle_cd32_joystick_cia(data, cia_r(device, 2));
|
handle_cd32_joystick_cia(data, mos6526_r(device, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
@ -1016,26 +1016,30 @@ INPUT_PORTS_END
|
|||||||
*
|
*
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
static const cia6526_interface cia_0_intf =
|
static const mos6526_interface cia_0_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(cd32_cia_0_porta_w) }, /* port A */
|
DEVCB_INPUT_PORT("CIA0PORTA"),
|
||||||
{ DEVCB_HANDLER(cd32_cia_0_portb_r), DEVCB_HANDLER(cd32_cia_0_portb_w) } /* port B */
|
DEVCB_HANDLER(cd32_cia_0_porta_w), /* port A */
|
||||||
}
|
DEVCB_HANDLER(cd32_cia_0_portb_r),
|
||||||
|
DEVCB_HANDLER(cd32_cia_0_portb_w) /* port B */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const cia6526_interface cia_1_intf =
|
static const mos6526_interface cia_1_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_NULL, DEVCB_NULL }, /* port A */
|
DEVCB_NULL,
|
||||||
{ DEVCB_NULL, DEVCB_NULL } /* port B */
|
DEVCB_NULL,
|
||||||
}
|
DEVCB_NULL,
|
||||||
|
DEVCB_NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static MACHINE_DRIVER_START( cd32 )
|
static MACHINE_DRIVER_START( cd32 )
|
||||||
@ -1074,8 +1078,8 @@ static MACHINE_DRIVER_START( cd32 )
|
|||||||
MDRV_SOUND_ROUTE( 1, "rspeaker", 0.50 )
|
MDRV_SOUND_ROUTE( 1, "rspeaker", 0.50 )
|
||||||
|
|
||||||
/* cia */
|
/* cia */
|
||||||
MDRV_CIA8520_ADD("cia_0", AMIGA_68EC020_PAL_CLOCK / 10, cia_0_intf)
|
MDRV_MOS8520_ADD("cia_0", AMIGA_68EC020_PAL_CLOCK / 10, cia_0_intf)
|
||||||
MDRV_CIA8520_ADD("cia_1", AMIGA_68EC020_PAL_CLOCK / 10, cia_1_intf)
|
MDRV_MOS8520_ADD("cia_1", AMIGA_68EC020_PAL_CLOCK / 10, cia_1_intf)
|
||||||
MACHINE_DRIVER_END
|
MACHINE_DRIVER_END
|
||||||
|
|
||||||
#define ROM_LOAD16_WORD_BIOS(bios,name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_BIOS(bios+1))
|
#define ROM_LOAD16_WORD_BIOS(bios,name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_BIOS(bios+1))
|
||||||
|
@ -330,26 +330,30 @@ static MACHINE_RESET(mquake)
|
|||||||
*
|
*
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
static const cia6526_interface cia_0_intf =
|
static const mos6526_interface cia_0_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(mquake_cia_0_porta_w) }, /* port A */
|
DEVCB_INPUT_PORT("CIA0PORTA"),
|
||||||
{ DEVCB_HANDLER(mquake_cia_0_portb_r), DEVCB_HANDLER(mquake_cia_0_portb_w) } /* port B */
|
DEVCB_HANDLER(mquake_cia_0_porta_w), /* port A */
|
||||||
}
|
DEVCB_HANDLER(mquake_cia_0_portb_r),
|
||||||
|
DEVCB_HANDLER(mquake_cia_0_portb_w) /* port B */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const cia6526_interface cia_1_intf =
|
static const mos6526_interface cia_1_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_NULL, DEVCB_NULL }, /* port A */
|
DEVCB_NULL,
|
||||||
{ DEVCB_NULL, DEVCB_NULL } /* port B */
|
DEVCB_NULL,
|
||||||
}
|
DEVCB_NULL,
|
||||||
|
DEVCB_NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static MACHINE_DRIVER_START( mquake )
|
static MACHINE_DRIVER_START( mquake )
|
||||||
@ -394,8 +398,8 @@ static MACHINE_DRIVER_START( mquake )
|
|||||||
MDRV_SOUND_ROUTE(1, "rspeaker", 0.50)
|
MDRV_SOUND_ROUTE(1, "rspeaker", 0.50)
|
||||||
|
|
||||||
/* cia */
|
/* cia */
|
||||||
MDRV_CIA8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_intf)
|
MDRV_MOS8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_intf)
|
||||||
MDRV_CIA8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK / 10, cia_1_intf)
|
MDRV_MOS8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK / 10, cia_1_intf)
|
||||||
MACHINE_DRIVER_END
|
MACHINE_DRIVER_END
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,26 +274,30 @@ INPUT_PORTS_END
|
|||||||
*
|
*
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
static const cia6526_interface cia_0_intf =
|
static const mos6526_interface cia_0_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_NULL, DEVCB_HANDLER(upscope_cia_0_porta_w) }, /* port A */
|
DEVCB_NULL,
|
||||||
{ DEVCB_HANDLER(upscope_cia_0_portb_r), DEVCB_HANDLER(upscope_cia_0_portb_w) } /* port B */
|
DEVCB_HANDLER(upscope_cia_0_porta_w), /* port A */
|
||||||
}
|
DEVCB_HANDLER(upscope_cia_0_portb_r),
|
||||||
|
DEVCB_HANDLER(upscope_cia_0_portb_w) /* port B */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const cia6526_interface cia_1_intf =
|
static const mos6526_interface cia_1_intf =
|
||||||
{
|
{
|
||||||
|
0, /* tod_clock */
|
||||||
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
|
||||||
DEVCB_NULL, /* pc_func */
|
DEVCB_NULL, /* pc_func */
|
||||||
0, /* tod_clock */
|
DEVCB_NULL,
|
||||||
{
|
DEVCB_NULL,
|
||||||
{ DEVCB_HANDLER(upscope_cia_1_porta_r), DEVCB_HANDLER(upscope_cia_1_porta_w), }, /* port A */
|
DEVCB_HANDLER(upscope_cia_1_porta_r),
|
||||||
{ DEVCB_NULL, DEVCB_NULL } /* port B */
|
DEVCB_HANDLER(upscope_cia_1_porta_w), /* port A */
|
||||||
}
|
DEVCB_NULL,
|
||||||
|
DEVCB_NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static MACHINE_DRIVER_START( upscope )
|
static MACHINE_DRIVER_START( upscope )
|
||||||
@ -331,8 +335,8 @@ static MACHINE_DRIVER_START( upscope )
|
|||||||
MDRV_SOUND_ROUTE(3, "rspeaker", 0.50)
|
MDRV_SOUND_ROUTE(3, "rspeaker", 0.50)
|
||||||
|
|
||||||
/* cia */
|
/* cia */
|
||||||
MDRV_CIA8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_intf)
|
MDRV_MOS8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_intf)
|
||||||
MDRV_CIA8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK / 10, cia_1_intf)
|
MDRV_MOS8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK / 10, cia_1_intf)
|
||||||
MACHINE_DRIVER_END
|
MACHINE_DRIVER_END
|
||||||
|
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ static TIMER_CALLBACK( scanline_callback )
|
|||||||
amiga_custom_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), REG_INTREQ, 0x8000 | INTENA_VERTB, 0xffff);
|
amiga_custom_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), REG_INTREQ, 0x8000 | INTENA_VERTB, 0xffff);
|
||||||
|
|
||||||
/* clock the first CIA TOD */
|
/* clock the first CIA TOD */
|
||||||
cia_clock_tod(cia_0);
|
mos6526_tod_w(cia_0, 1);
|
||||||
|
|
||||||
/* call the system-specific callback */
|
/* call the system-specific callback */
|
||||||
if (amiga_intf->scanline0_callback != NULL)
|
if (amiga_intf->scanline0_callback != NULL)
|
||||||
@ -359,7 +359,7 @@ static TIMER_CALLBACK( scanline_callback )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* on every scanline, clock the second CIA TOD */
|
/* on every scanline, clock the second CIA TOD */
|
||||||
cia_clock_tod(cia_1);
|
mos6526_tod_w(cia_1, 1);
|
||||||
|
|
||||||
/* render up to this scanline */
|
/* render up to this scanline */
|
||||||
if (!video_screen_update_partial(machine->primary_screen, scanline))
|
if (!video_screen_update_partial(machine->primary_screen, scanline))
|
||||||
@ -1058,7 +1058,7 @@ READ16_HANDLER( amiga_cia_r )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* handle the reads */
|
/* handle the reads */
|
||||||
data = cia_r(cia, offset >> 7);
|
data = mos6526_r(cia, offset >> 7);
|
||||||
|
|
||||||
if (LOG_CIA)
|
if (LOG_CIA)
|
||||||
logerror("%06x:cia_%c_read(%03x) = %04x & %04x\n", cpu_get_pc(space->cpu), 'A' + ((~offset & 0x0800) >> 11), offset * 2, data << shift, mem_mask);
|
logerror("%06x:cia_%c_read(%03x) = %04x & %04x\n", cpu_get_pc(space->cpu), 'A' + ((~offset & 0x0800) >> 11), offset * 2, data << shift, mem_mask);
|
||||||
@ -1100,7 +1100,7 @@ WRITE16_HANDLER( amiga_cia_w )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* handle the writes */
|
/* handle the writes */
|
||||||
cia_w(cia, offset >> 7, (UINT8) data);
|
mos6526_w(cia, offset >> 7, (UINT8) data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1446,8 +1446,8 @@ WRITE16_HANDLER( amiga_custom_w )
|
|||||||
data = (data & 0x8000) ? (CUSTOM_REG(offset) | (data & 0x7fff)) : (CUSTOM_REG(offset) & ~(data & 0x7fff));
|
data = (data & 0x8000) ? (CUSTOM_REG(offset) | (data & 0x7fff)) : (CUSTOM_REG(offset) & ~(data & 0x7fff));
|
||||||
cia_0 = devtag_get_device(space->machine, "cia_0");
|
cia_0 = devtag_get_device(space->machine, "cia_0");
|
||||||
cia_1 = devtag_get_device(space->machine, "cia_1");
|
cia_1 = devtag_get_device(space->machine, "cia_1");
|
||||||
if ( cia_get_irq( cia_0 ) ) data |= INTENA_PORTS;
|
if ( mos6526_irq_r( cia_0 ) ) data |= INTENA_PORTS;
|
||||||
if ( cia_get_irq( cia_1 ) ) data |= INTENA_EXTER;
|
if ( mos6526_irq_r( cia_1 ) ) data |= INTENA_EXTER;
|
||||||
CUSTOM_REG(offset) = data;
|
CUSTOM_REG(offset) = data;
|
||||||
|
|
||||||
if ( temp & 0x8000 ) /* if we're generating irq's, delay a bit */
|
if ( temp & 0x8000 ) /* if we're generating irq's, delay a bit */
|
||||||
|
Loading…
Reference in New Issue
Block a user