From 26dd96003f732e3dbd4629d2469c9bfd2e5e9b5d Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Thu, 26 Feb 2009 09:07:02 +0000 Subject: [PATCH] From: Duke [mailto:startaq@gmail.com] Sent: Wednesday, February 25, 2009 5:20 AM To: submit@mamedev.org Subject: CIA update Hello, this patch adds support for the /PC output pin to the CIA emulation. From the datasheet "/PC will go low for one cycle following a read or write of PORT B.". This is needed for centronics printer emulation on the MESS side, but I imagine it would simplify/correct the emulation in some MAME amiga drivers as well (mquake.c for example). --Dirk --- src/emu/machine/6526cia.c | 24 ++++++++++++++++++++++++ src/emu/machine/6526cia.h | 2 ++ src/mame/drivers/alg.c | 2 ++ src/mame/drivers/arcadia.c | 2 ++ src/mame/drivers/cubocd32.c | 2 ++ src/mame/drivers/mquake.c | 2 ++ src/mame/drivers/upscope.c | 2 ++ 7 files changed, 36 insertions(+) diff --git a/src/emu/machine/6526cia.c b/src/emu/machine/6526cia.c index 7b75d5eccfc..685eba1c042 100644 --- a/src/emu/machine/6526cia.c +++ b/src/emu/machine/6526cia.c @@ -67,6 +67,7 @@ struct _cia_state { const device_config *device; devcb_resolved_write_line irq_func; + devcb_resolved_write_line pc_func; cia_port port[2]; cia_timer timer[2]; @@ -141,6 +142,7 @@ static DEVICE_START( cia ) 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); /* setup ports */ for (p = 0; p < (sizeof(cia->port) / sizeof(cia->port[0])); p++) @@ -272,6 +274,20 @@ static DEVICE_VALIDITY_CHECK( cia ) } +/*------------------------------------------------- + cia_update_pc - pulse /pc output +-------------------------------------------------*/ + +static void cia_update_pc(const device_config *device) +{ + cia_state *cia = get_token(device); + + /* this should really be one cycle long */ + devcb_call_write_line(&cia->pc_func, 0); + devcb_call_write_line(&cia->pc_func, 1); +} + + /*------------------------------------------------- cia_update_interrupts -------------------------------------------------*/ @@ -651,6 +667,9 @@ READ8_DEVICE_HANDLER( cia_r ) else data &= ~0x80; } + + /* pulse /PC following the read */ + cia_update_pc(device); } break; @@ -742,6 +761,11 @@ WRITE8_DEVICE_HANDLER( cia_w ) port->latch = data; port->out = (data & port->ddr) | (port->in & ~port->ddr); devcb_call_write8(&port->write, 0, port->out); + + /* pulse /PC following the write */ + if (offset == CIA_PRB) + cia_update_pc(device); + break; /* port A/B direction */ diff --git a/src/emu/machine/6526cia.h b/src/emu/machine/6526cia.h index 1c835da2be2..f8cea3d34aa 100644 --- a/src/emu/machine/6526cia.h +++ b/src/emu/machine/6526cia.h @@ -45,6 +45,8 @@ typedef struct _cia6526_interface cia6526_interface; struct _cia6526_interface { devcb_write_line irq_func; + devcb_write_line pc_func; + int tod_clock; struct diff --git a/src/mame/drivers/alg.c b/src/mame/drivers/alg.c index 69ee5b71ce1..a9e3860d682 100644 --- a/src/mame/drivers/alg.c +++ b/src/mame/drivers/alg.c @@ -378,6 +378,7 @@ INPUT_PORTS_END static const cia6526_interface cia_0_intf = { DEVCB_LINE(amiga_cia_0_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_HANDLER(alg_cia_0_porta_r), DEVCB_HANDLER(alg_cia_0_porta_w) }, /* port A */ @@ -388,6 +389,7 @@ static const cia6526_interface cia_0_intf = static const cia6526_interface cia_1_intf = { DEVCB_LINE(amiga_cia_1_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_HANDLER(alg_cia_1_porta_r), DEVCB_HANDLER(alg_cia_1_porta_w), }, /* port A */ diff --git a/src/mame/drivers/arcadia.c b/src/mame/drivers/arcadia.c index 5dbffde3534..a2ee9687e6c 100644 --- a/src/mame/drivers/arcadia.c +++ b/src/mame/drivers/arcadia.c @@ -260,6 +260,7 @@ INPUT_PORTS_END static const cia6526_interface cia_0_intf = { DEVCB_LINE(amiga_cia_0_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(arcadia_cia_0_porta_w) }, /* port A */ @@ -270,6 +271,7 @@ static const cia6526_interface cia_0_intf = static const cia6526_interface cia_1_intf = { DEVCB_LINE(amiga_cia_1_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_NULL, DEVCB_NULL }, /* port A */ diff --git a/src/mame/drivers/cubocd32.c b/src/mame/drivers/cubocd32.c index c2896055854..a7f95ec30bc 100644 --- a/src/mame/drivers/cubocd32.c +++ b/src/mame/drivers/cubocd32.c @@ -212,6 +212,7 @@ INPUT_PORTS_END static const cia6526_interface cia_0_intf = { DEVCB_LINE(amiga_cia_0_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(cd32_cia_0_porta_w) }, /* port A */ @@ -222,6 +223,7 @@ static const cia6526_interface cia_0_intf = static const cia6526_interface cia_1_intf = { DEVCB_LINE(amiga_cia_1_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_NULL, DEVCB_NULL }, /* port A */ diff --git a/src/mame/drivers/mquake.c b/src/mame/drivers/mquake.c index 9bdcf734da9..a0da3d376ce 100644 --- a/src/mame/drivers/mquake.c +++ b/src/mame/drivers/mquake.c @@ -333,6 +333,7 @@ static MACHINE_RESET(mquake) static const cia6526_interface cia_0_intf = { DEVCB_LINE(amiga_cia_0_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(mquake_cia_0_porta_w) }, /* port A */ @@ -343,6 +344,7 @@ static const cia6526_interface cia_0_intf = static const cia6526_interface cia_1_intf = { DEVCB_LINE(amiga_cia_1_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_NULL, DEVCB_NULL }, /* port A */ diff --git a/src/mame/drivers/upscope.c b/src/mame/drivers/upscope.c index 26c40c9d692..b118c7bcbf9 100644 --- a/src/mame/drivers/upscope.c +++ b/src/mame/drivers/upscope.c @@ -277,6 +277,7 @@ INPUT_PORTS_END static const cia6526_interface cia_0_intf = { DEVCB_LINE(amiga_cia_0_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_NULL, DEVCB_HANDLER(upscope_cia_0_porta_w) }, /* port A */ @@ -287,6 +288,7 @@ static const cia6526_interface cia_0_intf = static const cia6526_interface cia_1_intf = { DEVCB_LINE(amiga_cia_1_irq), /* irq_func */ + DEVCB_NULL, /* pc_func */ 0, /* tod_clock */ { { DEVCB_HANDLER(upscope_cia_1_porta_r), DEVCB_HANDLER(upscope_cia_1_porta_w), }, /* port A */