Changed 6526cia to use devcb

This commit is contained in:
Nathan Woods 2009-02-04 13:37:15 +00:00
parent ee5806bc2e
commit f9d6855b54
7 changed files with 63 additions and 84 deletions

View File

@ -58,15 +58,15 @@ struct _cia_port
UINT8 latch;
UINT8 in;
UINT8 out;
UINT8 (*read)(const device_config *);
void (*write)(const device_config *, UINT8);
devcb_resolved_read8 read;
devcb_resolved_write8 write;
UINT8 mask_value; /* in READ operation the value can be forced by a extern electric circuit */
};
struct _cia_state
{
const device_config *device;
void (*irq_func)(const device_config *device, int state);
devcb_resolved_write_line irq_func;
cia_port port[2];
cia_timer timer[2];
@ -140,13 +140,13 @@ static DEVICE_START( cia )
/* clear out CIA structure, and copy the interface */
memset(cia, 0, sizeof(*cia));
cia->device = device;
cia->irq_func = intf->irq_func;
devcb_resolve_write_line(&cia->irq_func, &intf->irq_func, device);
/* setup ports */
for (p = 0; p < (sizeof(cia->port) / sizeof(cia->port[0])); p++)
{
cia->port[p].read = intf->port[p].read;
cia->port[p].write = intf->port[p].write;
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;
}
@ -292,8 +292,7 @@ static void cia_update_interrupts(const device_config *device)
if (cia->irq != new_irq)
{
cia->irq = new_irq;
if (cia->irq_func)
(*cia->irq_func)(device, cia->irq);
devcb_call_write_line(&cia->irq_func, cia->irq);
}
}
@ -627,7 +626,7 @@ READ8_DEVICE_HANDLER( cia_r )
case CIA_PRA:
case CIA_PRB:
port = &cia->port[offset & 1];
data = port->read ? (*port->read)(device) : 0;
data = devcb_call_read8(&port->read, 0);
data = ((data & ~port->ddr) | (port->latch & port->ddr)) & port->mask_value;
port->in = data;
@ -742,8 +741,7 @@ WRITE8_DEVICE_HANDLER( cia_w )
port = &cia->port[offset & 1];
port->latch = data;
port->out = (data & port->ddr) | (port->in & ~port->ddr);
if (port->write != NULL)
(*port->write)(device, port->out);
devcb_call_write8(&port->write, 0, port->out);
break;
/* port A/B direction */

View File

@ -10,6 +10,8 @@
#ifndef __6526CIA_H__
#define __6526CIA_H__
#include "devcb.h"
/***************************************************************************
MACROS
@ -42,14 +44,13 @@
typedef struct _cia6526_interface cia6526_interface;
struct _cia6526_interface
{
void (*irq_func)(const device_config *device, int state);
devcb_write_line irq_func;
int tod_clock;
struct
{
UINT8 (*read)(const device_config *);
void (*write)(const device_config *, UINT8);
devcb_read8 read;
devcb_write8 write;
} port[2];
};

View File

@ -196,7 +196,7 @@ static CUSTOM_INPUT( lightgun_holster_r )
*
*************************************/
static void alg_cia_0_porta_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( alg_cia_0_porta_w )
{
/* switch banks as appropriate */
memory_set_bank(device->machine, 1, data & 1);
@ -212,34 +212,34 @@ static void alg_cia_0_porta_w(const device_config *device, UINT8 data)
}
static UINT8 alg_cia_0_porta_r(const device_config *device)
static READ8_DEVICE_HANDLER( alg_cia_0_porta_r )
{
return input_port_read(device->machine, "FIRE") | 0x3f;
}
static UINT8 alg_cia_0_portb_r(const device_config *device)
static READ8_DEVICE_HANDLER( alg_cia_0_portb_r )
{
logerror("%s:alg_cia_0_portb_r\n", cpuexec_describe_context(device->machine));
return 0xff;
}
static void alg_cia_0_portb_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( alg_cia_0_portb_w )
{
/* parallel port */
logerror("%s:alg_cia_0_portb_w(%02x)\n", cpuexec_describe_context(device->machine), data);
}
static UINT8 alg_cia_1_porta_r(const device_config *device)
static READ8_DEVICE_HANDLER( alg_cia_1_porta_r )
{
logerror("%s:alg_cia_1_porta_r\n", cpuexec_describe_context(device->machine));
return 0xff;
}
static void alg_cia_1_porta_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( alg_cia_1_porta_w )
{
logerror("%s:alg_cia_1_porta_w(%02x)\n", cpuexec_describe_context(device->machine), data);
}
@ -390,21 +390,21 @@ static const custom_sound_interface amiga_custom_interface =
static const cia6526_interface cia_0_intf =
{
amiga_cia_0_irq, /* irq_func */
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
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 */
{ DEVCB_HANDLER(alg_cia_0_porta_r), 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 =
{
amiga_cia_1_irq, /* irq_func */
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
0, /* tod_clock */
{
{ alg_cia_1_porta_r, alg_cia_1_porta_w, }, /* port A */
{ NULL, NULL } /* port B */
{ DEVCB_HANDLER(alg_cia_1_porta_r), DEVCB_HANDLER(alg_cia_1_porta_w), }, /* port A */
{ DEVCB_NULL, DEVCB_NULL } /* port B */
}
};

View File

@ -93,12 +93,7 @@ static WRITE16_HANDLER( arcadia_multibios_change_game )
*
*************************************/
static UINT8 arcadia_cia_0_porta_r(const device_config *device)
{
return input_port_read(device->machine, "CIA0PORTA");
}
static void arcadia_cia_0_porta_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( arcadia_cia_0_porta_w )
{
/* switch banks as appropriate */
memory_set_bank(device->machine, 1, data & 1);
@ -133,12 +128,7 @@ static void arcadia_cia_0_porta_w(const device_config *device, UINT8 data)
*
*************************************/
static UINT8 arcadia_cia_0_portb_r(const device_config *device)
{
return input_port_read(device->machine, "CIA0PORTB");
}
static void arcadia_cia_0_portb_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( arcadia_cia_0_portb_w )
{
/* writing a 0 in the low bit clears one of the coins */
if ((data & 1) == 0)
@ -283,21 +273,21 @@ static const custom_sound_interface amiga_custom_interface =
static const cia6526_interface cia_0_intf =
{
amiga_cia_0_irq, /* irq_func */
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
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 */
{ DEVCB_INPUT_PORT("CIA0PORTA"), 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 =
{
amiga_cia_1_irq, /* irq_func */
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
0, /* tod_clock */
{
{ NULL, NULL }, /* port A */
{ NULL, NULL } /* port B */
{ DEVCB_NULL, DEVCB_NULL }, /* port A */
{ DEVCB_NULL, DEVCB_NULL } /* port B */
}
};

View File

@ -86,12 +86,7 @@ static WRITE32_HANDLER( aga_overlay_w )
*
*************************************/
static UINT8 cd32_cia_0_porta_r(const device_config *device)
{
return input_port_read(device->machine, "CIA0PORTA");
}
static void cd32_cia_0_porta_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( cd32_cia_0_porta_w )
{
/* bit 1 = cd audio mute */
sndti_set_output_gain(SOUND_CDDA, 0, 0, ( data & 1 ) ? 0.0 : 1.0 );
@ -115,14 +110,14 @@ static void cd32_cia_0_porta_w(const device_config *device, UINT8 data)
*
*************************************/
static UINT8 cd32_cia_0_portb_r(const device_config *device)
static READ8_DEVICE_HANDLER( cd32_cia_0_portb_r )
{
/* parallel port */
logerror("%s:CIA0_portb_r\n", cpuexec_describe_context(device->machine));
return 0xff;
}
static void cd32_cia_0_portb_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( cd32_cia_0_portb_w )
{
/* parallel port */
logerror("%s:CIA0_portb_w(%02x)\n", cpuexec_describe_context(device->machine), data);
@ -224,21 +219,21 @@ static const custom_sound_interface amiga_custom_interface =
static const cia6526_interface cia_0_intf =
{
amiga_cia_0_irq, /* irq_func */
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
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 */
{ DEVCB_INPUT_PORT("CIA0PORTA"), 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 =
{
amiga_cia_1_irq, /* irq_func */
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
0, /* tod_clock */
{
{ NULL, NULL }, /* port A */
{ NULL, NULL } /* port B */
{ DEVCB_NULL, DEVCB_NULL }, /* port A */
{ DEVCB_NULL, DEVCB_NULL } /* port B */
}
};

View File

@ -30,12 +30,7 @@
*
*************************************/
static UINT8 mquake_cia_0_porta_r(const device_config *device)
{
return input_port_read(device->machine, "CIA0PORTA");
}
static void mquake_cia_0_porta_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( mquake_cia_0_porta_w )
{
/* switch banks as appropriate */
memory_set_bank(device->machine, 1, data & 1);
@ -67,14 +62,14 @@ static void mquake_cia_0_porta_w(const device_config *device, UINT8 data)
*
*************************************/
static UINT8 mquake_cia_0_portb_r(const device_config *device)
static READ8_DEVICE_HANDLER( mquake_cia_0_portb_r )
{
/* parallel port */
logerror("%s:CIA0_portb_r\n", cpuexec_describe_context(device->machine));
return 0xff;
}
static void mquake_cia_0_portb_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( mquake_cia_0_portb_w )
{
/* parallel port */
logerror("%s:CIA0_portb_w(%02x)\n", cpuexec_describe_context(device->machine), data);
@ -351,21 +346,21 @@ static MACHINE_RESET(mquake)
static const cia6526_interface cia_0_intf =
{
amiga_cia_0_irq, /* irq_func */
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
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 */
{ DEVCB_INPUT_PORT("CIA0PORTA"), 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 =
{
amiga_cia_1_irq, /* irq_func */
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
0, /* tod_clock */
{
{ NULL, NULL }, /* port A */
{ NULL, NULL } /* port B */
{ DEVCB_NULL, DEVCB_NULL }, /* port A */
{ DEVCB_NULL, DEVCB_NULL } /* port B */
}
};

View File

@ -81,7 +81,7 @@ static void upscope_reset(running_machine *machine)
*
*************************************/
static void upscope_cia_0_porta_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( upscope_cia_0_porta_w )
{
/* switch banks as appropriate */
memory_set_bank(device->machine, 1, data & 1);
@ -113,12 +113,12 @@ static void upscope_cia_0_porta_w(const device_config *device, UINT8 data)
*
*************************************/
static void upscope_cia_0_portb_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( upscope_cia_0_portb_w )
{
parallel_data = data;
}
static UINT8 upscope_cia_0_portb_r(const device_config *device)
static READ8_DEVICE_HANDLER( upscope_cia_0_portb_r )
{
return nvram_data_latch;
}
@ -140,12 +140,12 @@ static UINT8 upscope_cia_0_portb_r(const device_config *device)
*
*************************************/
static UINT8 upscope_cia_1_porta_r(const device_config *device)
static READ8_DEVICE_HANDLER( upscope_cia_1_porta_r )
{
return 0xf8 | (prev_cia1_porta & 0x07);
}
static void upscope_cia_1_porta_w(const device_config *device, UINT8 data)
static WRITE8_DEVICE_HANDLER( upscope_cia_1_porta_w )
{
/* on a low transition of POUT, we latch stuff for the NVRAM */
if ((prev_cia1_porta & 2) && !(data & 2))
@ -289,21 +289,21 @@ static const custom_sound_interface amiga_custom_interface =
static const cia6526_interface cia_0_intf =
{
amiga_cia_0_irq, /* irq_func */
DEVCB_LINE(amiga_cia_0_irq), /* irq_func */
0, /* tod_clock */
{
{ NULL, upscope_cia_0_porta_w }, /* port A */
{ upscope_cia_0_portb_r, upscope_cia_0_portb_w } /* port B */
{ DEVCB_NULL, 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 =
{
amiga_cia_1_irq, /* irq_func */
DEVCB_LINE(amiga_cia_1_irq), /* irq_func */
0, /* tod_clock */
{
{ upscope_cia_1_porta_r, upscope_cia_1_porta_w, }, /* port A */
{ NULL, NULL } /* port B */
{ DEVCB_HANDLER(upscope_cia_1_porta_r), DEVCB_HANDLER(upscope_cia_1_porta_w), }, /* port A */
{ DEVCB_NULL, DEVCB_NULL } /* port B */
}
};