diff options
| -rw-r--r-- | .gitattributes | 2 | ||||
| -rw-r--r-- | src/emu/emu.mak | 1 | ||||
| -rw-r--r-- | src/emu/machine/6821new.c | 1327 | ||||
| -rw-r--r-- | src/emu/machine/6821new.h | 130 | ||||
| -rw-r--r-- | src/mame/drivers/williams.c | 184 | ||||
| -rw-r--r-- | src/mame/includes/williams.h | 3 | ||||
| -rw-r--r-- | src/mame/machine/williams.c | 274 |
7 files changed, 1760 insertions, 161 deletions
diff --git a/.gitattributes b/.gitattributes index 9646aafc8b3..4dc04206dad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -560,6 +560,8 @@ src/emu/machine/6526cia.c svneol=native#text/plain src/emu/machine/6526cia.h svneol=native#text/plain src/emu/machine/6532riot.c svneol=native#text/plain src/emu/machine/6532riot.h svneol=native#text/plain +src/emu/machine/6821new.c svneol=native#text/plain +src/emu/machine/6821new.h svneol=native#text/plain src/emu/machine/6821pia.c svneol=native#text/plain src/emu/machine/6821pia.h svneol=native#text/plain src/emu/machine/6840ptm.c svneol=native#text/plain diff --git a/src/emu/emu.mak b/src/emu/emu.mak index df398533d1c..970670bc9b0 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -111,6 +111,7 @@ EMUMACHINEOBJS = \ $(EMUMACHINE)/6522via.o \ $(EMUMACHINE)/6526cia.o \ $(EMUMACHINE)/6821pia.o \ + $(EMUMACHINE)/6821new.o \ $(EMUMACHINE)/6840ptm.o \ $(EMUMACHINE)/6850acia.o \ $(EMUMACHINE)/68681.o \ diff --git a/src/emu/machine/6821new.c b/src/emu/machine/6821new.c new file mode 100644 index 00000000000..4273e83230d --- /dev/null +++ b/src/emu/machine/6821new.c @@ -0,0 +1,1327 @@ +/********************************************************************** + + Motorola 6821 PIA interface and emulation + +**********************************************************************/ + +#include "6821new.h" + + +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +typedef struct _pia6821 pia6821; +struct _pia6821 +{ + UINT8 in_a; + UINT8 in_ca1; + UINT8 in_ca2; + UINT8 out_a; + UINT8 out_ca2; + UINT8 port_a_z_mask; + UINT8 ddr_a; + UINT8 ctl_a; + UINT8 irq_a1; + UINT8 irq_a2; + UINT8 irq_a_state; + + UINT8 in_b; + UINT8 in_cb1; + UINT8 in_cb2; + UINT8 out_b; + UINT8 out_cb2; + UINT8 last_out_cb2_z; + UINT8 ddr_b; + UINT8 ctl_b; + UINT8 irq_b1; + UINT8 irq_b2; + UINT8 irq_b_state; + + /* variables that indicate if access a line externally - + used to for logging purposes ONLY */ + UINT8 in_a_pushed; + UINT8 out_a_needs_pulled; + UINT8 in_ca1_pushed; + UINT8 in_ca2_pushed; + UINT8 out_ca2_needs_pulled; + UINT8 in_b_pushed; + UINT8 out_b_needs_pulled; + UINT8 in_cb1_pushed; + UINT8 in_cb2_pushed; + UINT8 out_cb2_needs_pulled; + UINT8 logged_port_a_not_connected; + UINT8 logged_port_b_not_connected; + UINT8 logged_ca1_not_connected; + UINT8 logged_ca2_not_connected; + UINT8 logged_cb1_not_connected; + UINT8 logged_cb2_not_connected; +}; + + +/*************************************************************************** + MACROS +***************************************************************************/ + +#define VERBOSE 0 + +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +#define PIA_IRQ1 (0x80) +#define PIA_IRQ2 (0x40) + +#define IRQ1_ENABLED(c) ( (((c) >> 0) & 0x01)) +#define C1_LOW_TO_HIGH(c) ( (((c) >> 1) & 0x01)) +#define C1_HIGH_TO_LOW(c) (!(((c) >> 1) & 0x01)) +#define OUTPUT_SELECTED(c) ( (((c) >> 2) & 0x01)) +#define IRQ2_ENABLED(c) ( (((c) >> 3) & 0x01)) +#define STROBE_E_RESET(c) ( (((c) >> 3) & 0x01)) +#define STROBE_C1_RESET(c) (!(((c) >> 3) & 0x01)) +#define C2_SET(c) ( (((c) >> 3) & 0x01)) +#define C2_LOW_TO_HIGH(c) ( (((c) >> 4) & 0x01)) +#define C2_HIGH_TO_LOW(c) (!(((c) >> 4) & 0x01)) +#define C2_SET_MODE(c) ( (((c) >> 4) & 0x01)) +#define C2_STROBE_MODE(c) (!(((c) >> 4) & 0x01)) +#define C2_OUTPUT(c) ( (((c) >> 5) & 0x01)) +#define C2_INPUT(c) (!(((c) >> 5) & 0x01)) + + +/*************************************************************************** + PROTOTYPES +***************************************************************************/ +/*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ + +INLINE pia6821 *get_token(const device_config *device) +{ + assert(device != NULL); + assert((device->type == PIA6821) || (device->type == PIA6822)); + return (pia6821 *) device->token; +} + + +INLINE const pia6821_interface *get_interface(const device_config *device) +{ + assert(device != NULL); + assert((device->type == PIA6821) || (device->type == PIA6822)); + return (const pia6821_interface *) device->static_config; +} + + +/*************************************************************************** + IMPLEMENTATION +***************************************************************************/ + +/*------------------------------------------------- + DEVICE_START( pia ) +-------------------------------------------------*/ + +static DEVICE_START( pia ) +{ + pia6821 *p = get_token(device); + memset(p, 0, sizeof(*p)); + + state_save_register_device_item(device, 0, p->in_a); + state_save_register_device_item(device, 0, p->in_ca1); + state_save_register_device_item(device, 0, p->in_ca2); + state_save_register_device_item(device, 0, p->out_a); + state_save_register_device_item(device, 0, p->out_ca2); + state_save_register_device_item(device, 0, p->port_a_z_mask); + state_save_register_device_item(device, 0, p->ddr_a); + state_save_register_device_item(device, 0, p->ctl_a); + state_save_register_device_item(device, 0, p->irq_a1); + state_save_register_device_item(device, 0, p->irq_a2); + state_save_register_device_item(device, 0, p->irq_a_state); + state_save_register_device_item(device, 0, p->in_b); + state_save_register_device_item(device, 0, p->in_cb1); + state_save_register_device_item(device, 0, p->in_cb2); + state_save_register_device_item(device, 0, p->out_b); + state_save_register_device_item(device, 0, p->out_cb2); + state_save_register_device_item(device, 0, p->last_out_cb2_z); + state_save_register_device_item(device, 0, p->ddr_b); + state_save_register_device_item(device, 0, p->ctl_b); + state_save_register_device_item(device, 0, p->irq_b1); + state_save_register_device_item(device, 0, p->irq_b2); + state_save_register_device_item(device, 0, p->irq_b_state); + state_save_register_device_item(device, 0, p->in_a_pushed); + state_save_register_device_item(device, 0, p->out_a_needs_pulled); + state_save_register_device_item(device, 0, p->in_ca1_pushed); + state_save_register_device_item(device, 0, p->in_ca2_pushed); + state_save_register_device_item(device, 0, p->out_ca2_needs_pulled); + state_save_register_device_item(device, 0, p->in_b_pushed); + state_save_register_device_item(device, 0, p->out_b_needs_pulled); + state_save_register_device_item(device, 0, p->in_cb1_pushed); + state_save_register_device_item(device, 0, p->in_cb2_pushed); + state_save_register_device_item(device, 0, p->out_cb2_needs_pulled); + + return DEVICE_START_OK; +} + + +/*------------------------------------------------- + DEVICE_RESET( pia ) +-------------------------------------------------*/ + +static DEVICE_RESET( pia ) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + + memset(p, 0, sizeof(*p)); + + /* + * set default read values. + * + * ports A,CA1,CA2 default to 1 + * ports B,CB1,CB2 are three-state and undefined (set to 0) + */ + p->in_a = 0xff; + p->in_ca1 = TRUE; + p->in_ca2 = TRUE; + + /* clear the IRQs */ + if (intf->irq_a_func) (*intf->irq_a_func)(device, FALSE); + if (intf->irq_b_func) (*intf->irq_b_func)(device, FALSE); +} + + +/*------------------------------------------------- + update_interrupts +-------------------------------------------------*/ + +static void update_interrupts(const device_config *device) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + int new_state; + + /* start with IRQ A */ + new_state = (p->irq_a1 && IRQ1_ENABLED(p->ctl_a)) || (p->irq_a2 && IRQ2_ENABLED(p->ctl_a)); + + if (new_state != p->irq_a_state) + { + p->irq_a_state = new_state; + + if (intf->irq_a_func) + (*intf->irq_a_func)(device, p->irq_a_state); + } + + /* then do IRQ B */ + new_state = (p->irq_b1 && IRQ1_ENABLED(p->ctl_b)) || (p->irq_b2 && IRQ2_ENABLED(p->ctl_b)); + + if (new_state != p->irq_b_state) + { + p->irq_b_state = new_state; + + if (intf->irq_b_func) + (*intf->irq_b_func)(device, p->irq_b_state); + } +} + + +/*------------------------------------------------- + get_in_a_value +-------------------------------------------------*/ + +static UINT8 get_in_a_value(const device_config *device) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + UINT8 port_a_data = 0; + UINT8 ret; + + /* update the input */ + if (intf->in_a_func) + port_a_data = (*intf->in_a_func)(device, 0); + else + { + if (p->in_a_pushed) + port_a_data = p->in_a; + else + { + /* mark all pins disconnected */ + p->port_a_z_mask = 0xff; + + if (!p->logged_port_a_not_connected && (p->ddr_a != 0xff)) + { + logerror("PIA #%s: Warning! No port A read handler. Assuming pins 0x%02X not connected\n", device->tag, p->ddr_a ^ 0xff); + p->logged_port_a_not_connected = TRUE; + } + } + } + + /* - connected pins are always read + - disconnected pins read the output buffer in output mode + - disconnected pins are HI in input mode */ + ret = (~p->port_a_z_mask & port_a_data) | + ( p->port_a_z_mask & p->ddr_a & p->out_a) | + ( p->port_a_z_mask & ~p->ddr_a); + + return ret; +} + + +/*------------------------------------------------- + get_in_b_value +-------------------------------------------------*/ + +static UINT8 get_in_b_value(const device_config *device) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + UINT8 ret; + + if (p->ddr_b == 0xff) + /* all output, just return buffer */ + ret = p->out_b; + else + { + UINT8 port_b_data; + + /* update the input */ + if (intf->in_b_func) + port_b_data = (*intf->in_b_func)(device, 0); + else + { + if (p->in_b_pushed) + port_b_data = p->in_b; + else + { + if (!p->logged_port_b_not_connected && (p->ddr_b != 0xff)) + { + logerror("PIA #%s: Error! No port B read handler. Three-state pins 0x%02X are undefined\n", device->tag, p->ddr_b ^ 0xff); + p->logged_port_b_not_connected = TRUE; + } + + /* undefined -- need to return something */ + port_b_data = 0x00; + } + } + + /* the DDR determines if the pin or the output buffer is read */ + ret = (p->out_b & p->ddr_b) | (port_b_data & ~p->ddr_b); + } + + return ret; +} + + +/*------------------------------------------------- + get_out_a_value +-------------------------------------------------*/ + +static UINT8 get_out_a_value(const device_config *device) +{ + pia6821 *p = get_token(device); + UINT8 ret; + + if (p->ddr_a == 0xff) + /* all output */ + ret = p->out_a; + else + /* input pins don't change */ + ret = (p->out_a & p->ddr_a) | (get_in_a_value(device) & ~p->ddr_a); + + return ret; +} + + +/*------------------------------------------------- + get_out_b_value +-------------------------------------------------*/ + +static UINT8 get_out_b_value(const device_config *device) +{ + pia6821 *p = get_token(device); + + /* input pins are high-impedance - we just send them as zeros for backwards compatibility */ + return p->out_b & p->ddr_b; +} + + +/*------------------------------------------------- + set_out_ca2 +-------------------------------------------------*/ + +static void set_out_ca2(const device_config *device, int data) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + + if (data != p->out_ca2) + { + p->out_ca2 = data; + + /* send to output function */ + if (intf->out_ca2_func) + (*intf->out_ca2_func)(device, 0, p->out_ca2); + else + { + if (p->out_ca2_needs_pulled) + logerror("PIA #%s: Warning! No port CA2 write handler. Previous value has been lost!\n", device->tag); + + p->out_ca2_needs_pulled = TRUE; + } + } +} + + +/*------------------------------------------------- + set_out_cb2 +-------------------------------------------------*/ + +static void set_out_cb2(const device_config *device, int data) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + + int z = pianew_get_output_cb2_z(device); + + if ((data != p->out_cb2) || (z != p->last_out_cb2_z)) + { + p->out_cb2 = data; + p->last_out_cb2_z = z; + + /* send to output function */ + if (intf->out_cb2_func) + (*intf->out_cb2_func)(device, 0, p->out_cb2); + else + { + if (p->out_cb2_needs_pulled) + logerror("PIA #%s: Warning! No port CB2 write handler. Previous value has been lost!\n", device->tag); + + p->out_cb2_needs_pulled = TRUE; + } + } +} + + +/*------------------------------------------------- + port_a_r +-------------------------------------------------*/ + +static UINT8 port_a_r(const device_config *device) +{ + pia6821 *p = get_token(device); + + UINT8 ret = get_in_a_value(device); + + /* IRQ flags implicitly cleared by a read */ + p->irq_a1 = FALSE; + p->irq_a2 = FALSE; + update_interrupts(device); + + /* CA2 is configured as output and in read strobe mode */ + if (C2_OUTPUT(p->ctl_a) && C2_STROBE_MODE(p->ctl_a)) + { + /* this will cause a transition low */ + set_out_ca2(device, FALSE); + + /* if the CA2 strobe is cleared by the E, reset it right away */ + if (STROBE_E_RESET(p->ctl_a)) + set_out_ca2(device, TRUE); + } + + LOG(("PIA #%s: port A read = %02X\n", device->tag, ret)); + + return ret; +} + + +/*------------------------------------------------- + ddr_a_r +-------------------------------------------------*/ + +static UINT8 ddr_a_r(const device_config *device) +{ + pia6821 *p = get_token(device); + + UINT8 ret = p->ddr_a; + + LOG(("PIA #%s: DDR A read = %02X\n", device->tag, ret)); + + return ret; +} + + +/*------------------------------------------------- + port_b_r +-------------------------------------------------*/ + +static UINT8 port_b_r(const device_config *device) +{ + pia6821 *p = get_token(device); + + UINT8 ret = get_in_b_value(device); + + /* This read will implicitly clear the IRQ B1 flag. If CB2 is in write-strobe + mode with CB1 restore, and a CB1 active transition set the flag, + clearing it will cause CB2 to go high again. Note that this is different + from what happens with port A. */ + if (p->irq_b1 && C2_STROBE_MODE(p->ctl_b) && STROBE_C1_RESET(p->ctl_b)) + set_out_cb2(device, TRUE); + + /* IRQ flags implicitly cleared by a read */ + p->irq_b1 = FALSE; + p->irq_b2 = FALSE; + update_interrupts(device); + + LOG(("PIA #%s: port B read = %02X\n", device->tag, ret)); + + return ret; +} + + +/*------------------------------------------------- + ddr_b_r +-------------------------------------------------*/ + +static UINT8 ddr_b_r(const device_config *device) +{ + pia6821 *p = get_token(device); + + UINT8 ret = p->ddr_b; + + LOG(("PIA #%s: DDR B read = %02X\n", device->tag, ret)); + + return ret; +} + + +/*------------------------------------------------- + control_a_r +-------------------------------------------------*/ + +static UINT8 control_a_r(const device_config *device) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + UINT8 ret; + + /* update CA1 & CA2 if callback exists, these in turn may update IRQ's */ + if (intf->in_ca1_func) + pia_ca1_w(device, 0, (*intf->in_ca1_func)(device, 0)); + else if (!p->logged_ca1_not_connected && (!p->in_ca1_pushed)) + { + logerror("PIA #%s: Warning! No CA1 read handler. Assuming pin not connected\n", device->tag); + p->logged_ca1_not_connected = TRUE; + } + + if (intf->in_ca2_func) + pia_ca2_w(device, 0, (*intf->in_ca2_func)(device, 0)); + else if ( !p->logged_ca2_not_connected && C2_INPUT(p->ctl_a) && !p->in_ca2_pushed) + { + logerror("PIA #%s: Warning! No CA2 read handler. Assuming pin not connected\n", device->tag); + p->logged_ca2_not_connected = TRUE; + } + + /* read control register */ + ret = p->ctl_a; + + /* set the IRQ flags if we have pending IRQs */ + if (p->irq_a1) + ret |= PIA_IRQ1; + + if (p->irq_a2 && C2_INPUT(p->ctl_a)) + ret |= PIA_IRQ2; + + LOG(("PIA #%s: control A read = %02X\n", device->tag, ret)); + + return ret; +} + + +/*------------------------------------------------- + control_b_r +-------------------------------------------------*/ + +static UINT8 control_b_r(const device_config *device) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + UINT8 ret; + + /* update CB1 & CB2 if callback exists, these in turn may update IRQ's */ + if (intf->in_cb1_func) + pia_cb1_w(device, 0, (*intf->in_cb1_func)(device, 0)); + else if (!p->logged_cb1_not_connected && !p->in_cb1_pushed) + { + logerror("PIA #%s: Error! no CB1 read handler. Three-state pin is undefined\n", device->tag); + p->logged_cb1_not_connected = TRUE; + } + + if (intf->in_cb2_func) + pia_cb2_w(device, 0, (*intf->in_cb2_func)(device, 0)); + else if (!p->logged_cb2_not_connected && C2_INPUT(p->ctl_b) && !p->in_cb2_pushed) + { + logerror("PIA #%s: Error! No CB2 read handler. Three-state pin is undefined\n", device->tag); + p->logged_cb2_not_connected = TRUE; + } + + /* read control register */ + ret = p->ctl_b; + + /* set the IRQ flags if we have pending IRQs */ + if (p->irq_b1) + ret |= PIA_IRQ1; + + if (p->irq_b2 && C2_INPUT(p->ctl_b)) + ret |= PIA_IRQ2; + + LOG(("PIA #%s: control B read = %02X\n", device->tag, ret)); + + return ret; +} + + +/*------------------------------------------------- + pia_r +-------------------------------------------------*/ + +READ8_DEVICE_HANDLER(pia_r) +{ + pia6821 *p = get_token(device); + UINT8 ret; + + switch (offset & 0x03) + { + default: /* impossible */ + case 0x00: + if (OUTPUT_SELECTED(p->ctl_a)) + ret = port_a_r(device); + else + ret = ddr_a_r(device); + break; + + case 0x01: + ret = control_a_r(device); + break; + + case 0x02: + if (OUTPUT_SELECTED(p->ctl_b)) + ret = port_b_r(device); + else + ret = ddr_b_r(device); + break; + + case 0x03: + ret = control_b_r(device); + break; + } + + return ret; +} + + +/*------------------------------------------------- + pia_alt_r +-------------------------------------------------*/ + +READ8_DEVICE_HANDLER(pia_alt_r) +{ + return pia_r(device, ((offset << 1) & 0x02) | ((offset >> 1) & 0x01)); +} + + +/*------------------------------------------------- + pianew_get_port_b_z_mask +-------------------------------------------------*/ + +UINT8 pianew_get_port_b_z_mask(const device_config *device) +{ + pia6821 *p = get_token(device); + return ~p->ddr_b; +} + + +/*------------------------------------------------- + send_to_out_a_func +-------------------------------------------------*/ + +static void send_to_out_a_func(const device_config *device, const char* message) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + + /* input pins are pulled high */ + UINT8 data = get_out_a_value(device); + + LOG(("PIA #%s: %s = %02X\n", device->tag, message, data)); + + if (intf->out_a_func) + (*intf->out_a_func)(device, 0, data); + else + { + if (p->out_a_needs_pulled) + logerror("PIA #%s: Warning! No port A write handler. Previous value has been lost!\n", device->tag); + + p->out_a_needs_pulled = TRUE; + } +} + + +/*------------------------------------------------- + send_to_out_b_func +-------------------------------------------------*/ + +static void send_to_out_b_func(const device_config *device, const char* message) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + + /* input pins are high-impedance - we just send them as zeros for backwards compatibility */ + UINT8 data = get_out_b_value(device); + + LOG(("PIA #%s: %s = %02X\n", device->tag, message, data)); + + if (intf->out_b_func) + (*intf->out_b_func)(device, 0, data); + else + { + if (p->out_b_needs_pulled) + logerror("PIA #%s: Warning! No port B write handler. Previous value has been lost!\n", device->tag); + + p->out_b_needs_pulled = TRUE; + } +} + + +/*------------------------------------------------- + port_a_w +-------------------------------------------------*/ + +static void port_a_w(const device_config *device, UINT8 data) +{ + pia6821 *p = get_token(device); + + /* buffer the output value */ + p->out_a = data; + + send_to_out_a_func(device, "port A write"); +} + + +/*------------------------------------------------- + ddr_a_w +-------------------------------------------------*/ + +static void ddr_a_w(const device_config *device, UINT8 data) +{ + pia6821 *p = get_token(device); + + if (data == 0x00) + LOG(("PIA #%s: DDR A write = %02X (input mode)\n", device->tag, data)); + else if (data == 0xff) + LOG(("PIA #%s: DDR A write = %02X (output mode)\n", device->tag, data)); + else + LOG(("PIA #%s: DDR A write = %02X (mixed mode)\n", device->tag, data)); + + if (p->ddr_a != data) + { + /* DDR changed, call the callback again */ + p->ddr_a = data; + p->logged_port_a_not_connected = FALSE; + send_to_out_a_func(device, "port A write due to DDR change"); + } +} + + +/*------------------------------------------------- + port_b_w +-------------------------------------------------*/ + +static void port_b_w(const device_config *device, UINT8 data) +{ + pia6821 *p = get_token(device); + + /* buffer the output value */ + p->out_b = data; + + send_to_out_b_func(device, "port B write"); + + /* CB2 in write strobe mode */ + if (C2_STROBE_MODE(p->ctl_b)) + { + /* this will cause a transition low */ + set_out_cb2(device, FALSE); + + /* if the CB2 strobe is cleared by the E, reset it right away */ + if (STROBE_E_RESET(p->ctl_b)) + set_out_cb2(device, TRUE); + } +} + + +/*------------------------------------------------- + ddr_b_w +-------------------------------------------------*/ + +static void ddr_b_w(const device_config *device, UINT8 data) +{ + pia6821 *p = get_token(device); + + if (data == 0x00) + LOG(("PIA #%s: DDR B write = %02X (input mode)\n", device->tag, data)); + else if (data == 0xff) + LOG(("PIA #%s: DDR B write = %02X (output mode)\n", device->tag, data)); + else + LOG(("PIA #%s: DDR B write = %02X (mixed mode)\n", device->tag, data)); + + if (p->ddr_b != data) + { + /* DDR changed, call the callback again */ + p->ddr_b = data; + p->logged_port_b_not_connected = FALSE; + send_to_out_b_func(device, "port B write due to DDR change"); + } +} + + +/*------------------------------------------------- + control_a_w +-------------------------------------------------*/ + +static void control_a_w(const device_config *device, UINT8 data) +{ + pia6821 *p = get_token(device); + + /* bit 7 and 6 are read only */ + data &= 0x3f; + + LOG(("PIA #%s: control A write = %02X\n", device->tag, data)); + + /* update the control register */ + p->ctl_a = data; + + /* CA2 is configured as output */ + if (C2_OUTPUT(p->ctl_a)) + { + int temp; + + if (C2_SET_MODE(p->ctl_a)) + /* set/reset mode - bit value determines the new output */ + temp = C2_SET(p->ctl_a); + else + /* strobe mode - output is always high unless strobed */ + temp = TRUE; + + set_out_ca2(device, temp); + } + + /* update externals */ + update_interrupts(device); +} + + +/*------------------------------------------------- + control_b_w +-------------------------------------------------*/ + +static void control_b_w(const device_config *device, UINT8 data) +{ + pia6821 *p = get_token(device); + int temp; + + /* bit 7 and 6 are read only */ + data &= 0x3f; + + LOG(("PIA #%s: control B write = %02X\n", device->tag, data)); + + /* update the control register */ + p->ctl_b = data; + + if (C2_SET_MODE(p->ctl_b)) + /* set/reset mode - bit value determines the new output */ + temp = C2_SET(p->ctl_b); + else + /* strobe mode - output is always high unless strobed */ + temp = TRUE; + + set_out_cb2(device, temp); + + /* update externals */ + update_interrupts(device); +} + + +/*------------------------------------------------- + pia_w +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER(pia_w) +{ + pia6821 *p = get_token(device); + + switch (offset & 0x03) + { + default: /* impossible */ + case 0x00: + if (OUTPUT_SELECTED(p->ctl_a)) + port_a_w(device, data); + else + ddr_a_w(device, data); + break; + + case 0x01: + control_a_w(device, data); + break; + + case 0x02: + if (OUTPUT_SELECTED(p->ctl_b)) + port_b_w(device, data); + else + ddr_b_w(device, data); + break; + + case 0x03: + control_b_w(device, data); + break; + } +} + + +/*------------------------------------------------- + pia_alt_w +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER(pia_alt_w) +{ + pia_w(device, ((offset << 1) & 0x02) | ((offset >> 1) & 0x01), data); +} + + +/*------------------------------------------------- + pianew_set_port_a_z_mask +-------------------------------------------------*/ + +void pianew_set_port_a_z_mask(const device_config *device, UINT8 data) +{ + pia6821 *p = get_token(device); + + p->port_a_z_mask = data; +} + + +/*------------------------------------------------- + pia_porta_r +-------------------------------------------------*/ + +READ8_DEVICE_HANDLER(pia_porta_r) +{ + pia6821 *p = get_token(device); + + return p->in_a; +} + + +/*------------------------------------------------- + pianew_set_input_a +-------------------------------------------------*/ + +void pianew_set_input_a(const device_config *device, UINT8 data, UINT8 z_mask) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + + assert_always(intf->in_a_func == NULL, "pia_porta_w() called when in_a_func implemented"); + + LOG(("PIA #%s: set input port A = %02X\n", device->tag, data)); + + p->in_a = data; + p->port_a_z_mask = z_mask; + p->in_a_pushed = TRUE; +} + + +/*------------------------------------------------- + pia_porta_w +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER(pia_porta_w) +{ + pianew_set_input_a(device, data, 0); +} + + +/*------------------------------------------------- + pianew_get_output_a +-------------------------------------------------*/ + +UINT8 pianew_get_output_a(const device_config *device) +{ + pia6821 *p = get_token(device); + + p->out_a_needs_pulled = FALSE; + + return get_out_a_value(device); +} + + +/*------------------------------------------------- + pia_ca1_r +-------------------------------------------------*/ + +READ8_DEVICE_HANDLER(pia_ca1_r) +{ + pia6821 *p = get_token(device); + + return p->in_ca1; +} + + +/*------------------------------------------------- + pia_ca1_w +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER(pia_ca1_w) +{ + pia6821 *p = get_token(device); + + /* limit the data to 0 or 1 */ + data = data ? TRUE : FALSE; + + LOG(("PIA #%s: set input CA1 = %d\n", device->tag, data)); + + /* the new state has caused a transition */ + if ((p->in_ca1 != data) && + ((data && C1_LOW_TO_HIGH(p->ctl_a)) || (!data && C1_HIGH_TO_LOW(p->ctl_a)))) + { + LOG(("PIA #%s: CA1 triggering\n", device->tag)); + + /* mark the IRQ */ + p->irq_a1 = TRUE; + + /* update externals */ + update_interrupts(device); + + /* CA2 is configured as output and in read strobe mode and cleared by a CA1 transition */ + if (C2_OUTPUT(p->ctl_a) && C2_STROBE_MODE(p->ctl_a) && STROBE_C1_RESET(p->ctl_a)) + set_out_ca2(device, TRUE); + } + + /* set the new value for CA1 */ + p->in_ca1 = data; + p->in_ca1_pushed = TRUE; +} + + +/*------------------------------------------------- + pia_ca2_r +-------------------------------------------------*/ + +READ8_DEVICE_HANDLER(pia_ca2_r) +{ + pia6821 *p = get_token(device); + + return p->in_ca2; +} + + +/*------------------------------------------------- + pia_ca2_w +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER(pia_ca2_w) +{ + pia6821 *p = get_token(device); + + /* limit the data to 0 or 1 */ + data = data ? 1 : 0; + + LOG(("PIA #%s: set input CA2 = %d\n", device->tag, data)); + + /* if input mode and the new state has caused a transition */ + if (C2_INPUT(p->ctl_a) && + (p->in_ca2 != data) && + ((data && C2_LOW_TO_HIGH(p->ctl_a)) || (!data && C2_HIGH_TO_LOW(p->ctl_a)))) + { + LOG(("PIA #%s: CA2 triggering\n", device->tag)); + + /* mark the IRQ */ + p->irq_a2 = TRUE; + + /* update externals */ + update_interrupts(device); + } + + /* set the new value for CA2 */ + p->in_ca2 = data; + p->in_ca2_pushed = TRUE; +} + + +/*------------------------------------------------- + pianew_get_output_ca2 +-------------------------------------------------*/ + +int pianew_get_output_ca2(const device_config *device) +{ + pia6821 *p = get_token(device); + + p->out_ca2_needs_pulled = FALSE; + + return p->out_ca2; +} + + +/*------------------------------------------------- + pianew_get_output_ca2_z - version of + pianew_get_output_ca2, which takes account of internal + pullup resistor +-------------------------------------------------*/ + +int pianew_get_output_ca2_z(const device_config *device) +{ + pia6821 *p = get_token(device); + + p->out_ca2_needs_pulled = FALSE; + + // If it's an output, output the bit, if it's an input, it's + // pulled up + return p->out_ca2 | + C2_INPUT(p->ctl_a); +} + + +/*------------------------------------------------- + pia_portb_r +-------------------------------------------------*/ + +READ8_DEVICE_HANDLER(pia_portb_r) +{ + pia6821 *p = get_token(device); + + return p->in_b; +} + + +/*------------------------------------------------- + pia_portb_w +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER(pia_portb_w) +{ + pia6821 *p = get_token(device); + const pia6821_interface *intf = get_interface(device); + + assert_always(intf->in_b_func == NULL, "pia_set_input_b() called when in_b_func implemented"); + + LOG(("PIA #%s: set input port B = %02X\n", device->tag, data)); + + p->in_b = data; + p->in_b_pushed = TRUE; +} + + +/*------------------------------------------------- + pianew_get_output_b +-------------------------------------------------*/ + +UINT8 pianew_get_output_b(const device_config *device) +{ + pia6821 *p = get_token(device); + + p->out_b_needs_pulled = FALSE; + + return get_out_b_value(device); +} + + +/*------------------------------------------------- + pia_cb1_r +-------------------------------------------------*/ + +READ8_DEVICE_HANDLER(pia_cb1_r) +{ + pia6821 *p = get_token(device); + + return p->in_cb1; +} + + +/*------------------------------------------------- + pia_cb1_w +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER(pia_cb1_w) +{ + pia6821 *p = get_token(device); + + /* limit the data to 0 or 1 */ + data = data ? 1 : 0; + + LOG(("PIA #%s: set input CB1 = %d\n", device->tag, data)); + + /* the new state has caused a transition */ + if ((p->in_cb1 != data) && + ((data && C1_LOW_TO_HIGH(p->ctl_b)) || (!data && C1_HIGH_TO_LOW(p->ctl_b)))) + { + LOG(("PIA #%s: CB1 triggering\n", device->tag)); + + /* mark the IRQ */ + p->irq_b1 = 1; + + /* update externals */ + update_interrupts(device); + + /* If CB2 is configured as a write-strobe output which is reset by a CB1 + transition, this reset will only happen when a read from port B implicitly + clears the IRQ B1 flag. So we handle the CB2 reset there. Note that this + is different from what happens with port A. */ + } + + /* set the new value for CB1 */ + p->in_cb1 = data; + p->in_cb1_pushed = TRUE; +} + + +/*------------------------------------------------- + pia_cb2_r +-------------------------------------------------*/ + +READ8_DEVICE_HANDLER(pia_cb2_r) +{ + pia6821 *p = get_token(device); + + return p->in_cb2; +} + + +/*------------------------------------------------- + pia_cb2_w +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER(pia_cb2_w) +{ + pia6821 *p = get_token(device); + + /* limit the data to 0 or 1 */ + data = data ? 1 : 0; + + LOG(("PIA #%s: set input CB2 = %d\n", device->tag, data)); + + /* if input mode and the new state has caused a transition */ + if (C2_INPUT(p->ctl_b) && + (p->in_cb2 != data) && + ((data && C2_LOW_TO_HIGH(p->ctl_b)) || (!data && C2_HIGH_TO_LOW(p->ctl_b)))) + { + LOG(("PIA #%s: CB2 triggering\n", device->tag)); + + /* mark the IRQ */ + p->irq_b2 = 1; + + /* update externals */ + update_interrupts(device); + } + + /* set the new value for CA2 */ + p->in_cb2 = data; + p->in_cb2_pushed = TRUE; +} + + +/*------------------------------------------------- + pianew_get_output_cb2 +-------------------------------------------------*/ + +int pianew_get_output_cb2(const device_config *device) +{ + pia6821 *p = get_token(device); + + p->out_cb2_needs_pulled = FALSE; + + return p->out_cb2; +} + + +/*------------------------------------------------- + pianew_get_output_cb2_z +-------------------------------------------------*/ + +int pianew_get_output_cb2_z(const device_config *device) +{ + pia6821 *p = get_token(device); + + return !C2_OUTPUT(p->ctl_b); +} + + +/*------------------------------------------------- + pianew_get_irq_a +-------------------------------------------------*/ + +int pianew_get_irq_a(const device_config *device) +{ + pia6821 *p = get_token(device); + + return p->irq_a_state; +} + + +/*------------------------------------------------- + pianew_get_irq_b +-------------------------------------------------*/ + +int pianew_get_irq_b(const device_config *device) +{ + pia6821 *p = get_token(device); + + return p->irq_b_state; +} + + +/*------------------------------------------------- + DEVICE_SET_INFO( pia ) +-------------------------------------------------*/ + +static DEVICE_SET_INFO( pia ) +{ + switch(state) + { + } +} + + +/*------------------------------------------------- + DEVICE_GET_INFO( pia6821 ) +-------------------------------------------------*/ + +DEVICE_GET_INFO(pia6821) +{ + switch (state) + { + /* --- the following bits of info are returned as 64-bit signed integers --- */ + case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(pia6821); 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(pia); break; + case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(pia); break; + case DEVINFO_FCT_STOP: /* Nothing */ break; + case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(pia); break; + + /* --- the following bits of info are returned as NULL-terminated strings --- */ + case DEVINFO_STR_NAME: strcpy(info->s, "6821 PIA"); break; + case DEVINFO_STR_FAMILY: strcpy(info->s, "6821 PIA"); break; + case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; + case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; + case DEVINFO_STR_CREDITS: /* Nothing */ break; + } +} + + +/*------------------------------------------------- + DEVICE_GET_INFO( pia6822 ) +-------------------------------------------------*/ + +DEVICE_GET_INFO(pia6822) +{ + switch (state) + { + case DEVINFO_STR_NAME: strcpy(info->s, "6822 PIA"); break; + default: DEVICE_GET_INFO_CALL(pia6821); break; + } +} diff --git a/src/emu/machine/6821new.h b/src/emu/machine/6821new.h new file mode 100644 index 00000000000..5e8ab4b38d8 --- /dev/null +++ b/src/emu/machine/6821new.h @@ -0,0 +1,130 @@ +/********************************************************************** + + Motorola 6821 PIA interface and emulation + + Notes: + * pia_get_port_b_z_mask() gives the caller the bitmask + that show which bits are high-impendance when + reading port B, thus neither 0 or 1. + pia_get_output_cb2_z() returns the same + information for the CB2 pin + * pia_set_port_a_z_mask allows the input callback to + indicate which port A bits are disconnected. + For these bit, the read operation will return the + output buffer's contents + * the 'alt' interface functions are used when the A0 and A1 + address bits are swapped + * all 'int' data or return values are Boolean + +**********************************************************************/ + +#ifndef __6821NEW_H__ +#define __6821NEW_H__ + +#include "driver.h" + + +/*************************************************************************** + CONSTANTS +***************************************************************************/ + +#define PIA6821 DEVICE_GET_INFO_NAME(pia6821) +#define PIA6822 DEVICE_GET_INFO_NAME(pia6822) + + +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +/*------------- PIA interface structure -----------------*/ + +typedef struct _pia6821_interface pia6821_interface; +struct _pia6821_interface +{ + read8_device_func in_a_func; + read8_device_func in_b_func; + read8_device_func in_ca1_func; + read8_device_func in_cb1_func; + read8_device_func in_ca2_func; + read8_device_func in_cb2_func; + write8_device_func out_a_func; + write8_device_func out_b_func; + write8_device_func out_ca2_func; + write8_device_func out_cb2_func; + void (*irq_a_func)(const device_config *device, int state); + void (*irq_b_func)(const device_config *device, int state); +}; + + +/*************************************************************************** + PROTOTYPES +***************************************************************************/ + +DEVICE_GET_INFO(pia6821); +DEVICE_GET_INFO(pia6822); + +READ8_DEVICE_HANDLER(pia_r); +WRITE8_DEVICE_HANDLER(pia_w); + +READ8_DEVICE_HANDLER(pia_alt_r); +WRITE8_DEVICE_HANDLER(pia_alt_w); + +UINT8 pianew_get_port_b_z_mask(const device_config *device); /* see first note */ +void pianew_set_port_a_z_mask(const device_config *device, UINT8 data); /* see second note */ + +READ8_DEVICE_HANDLER(pia_porta_r); +WRITE8_DEVICE_HANDLER(pia_porta_w); +void pianew_set_input_a(const device_config *device, UINT8 data, UINT8 z_mask); +UINT8 pianew_get_output_a(const device_config *device); + +READ8_DEVICE_HANDLER(pia_ca1_r); +WRITE8_DEVICE_HANDLER(pia_ca1_w); + +READ8_DEVICE_HANDLER(pia_ca2_r); +WRITE8_DEVICE_HANDLER(pia_ca2_w); +int pianew_get_output_ca2(const device_config *device); +int pianew_get_output_ca2_z(const device_config *device); + +READ8_DEVICE_HANDLER(pia_portb_r); +WRITE8_DEVICE_HANDLER(pia_portb_w); +UINT8 pianew_get_output_b(const device_config *device); + +READ8_DEVICE_HANDLER(pia_cb1_r); +WRITE8_DEVICE_HANDLER(pia_cb1_w); + +READ8_DEVICE_HANDLER(pia_cb2_r); +WRITE8_DEVICE_HANDLER(pia_cb2_w); +int pianew_get_output_cb2(const device_config *device); +int pianew_get_output_cb2_z(const device_config *device); + +int pianew_get_irq_a(const device_config *device); +int pianew_get_irq_b(const device_config *device); + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MDRV_PIA6821_ADD(_tag, _intrf) \ + MDRV_DEVICE_ADD(_tag, PIA6821, 0) \ + MDRV_DEVICE_CONFIG(_intrf) + +#define MDRV_PIA6821_MODIFY(_tag, _intrf) \ + MDRV_DEVICE_MODIFY(_tag, PIA6821) \ + MDRV_DEVICE_CONFIG(_intrf) + +#define MDRV_PIA6821_REMOVE(_tag) \ + MDRV_DEVICE_REMOVE(_tag, PIA6821) + +#define MDRV_PIA6822_ADD(_tag, _intrf) \ + MDRV_DEVICE_ADD(_tag, PIA6822, 0) \ + MDRV_DEVICE_CONFIG(_intrf) + +#define MDRV_PIA6822_MODIFY(_tag, _intrf) \ + MDRV_DEVICE_MODIFY(_tag, PIA6822) \ + MDRV_DEVICE_CONFIG(_intrf) + +#define MDRV_PIA6822_REMOVE(_tag) \ + MDRV_DEVICE_REMOVE(_tag, PIA6821) + +#endif /* __6821NEW_H__ */ diff --git a/src/mame/drivers/williams.c b/src/mame/drivers/williams.c index eb3f3a731ad..829758e20bc 100644 --- a/src/mame/drivers/williams.c +++ b/src/mame/drivers/williams.c @@ -494,7 +494,7 @@ #include "driver.h" #include "cpu/m6809/m6809.h" #include "cpu/m6800/m6800.h" -#include "machine/6821pia.h" +#include "machine/6821new.h" #include "audio/williams.h" #include "williams.h" #include "sound/dac.h" @@ -522,14 +522,17 @@ ADDRESS_MAP_END void defender_install_io_space(const address_space *space) { + const device_config *pia_0 = devtag_get_device(space->machine, PIA6821, "pia_0"); + const device_config *pia_1 = devtag_get_device(space->machine, PIA6821, "pia_1"); + /* this routine dynamically installs the memory mapped above from c000-cfff */ - memory_install_write8_handler (space, 0xc000, 0xc00f, 0, 0x03e0, SMH_BANK4); - memory_install_write8_handler (space, 0xc010, 0xc01f, 0, 0x03e0, defender_video_control_w); - memory_install_write8_handler (space, 0xc3ff, 0xc3ff, 0, 0, williams_watchdog_reset_w); - memory_install_readwrite8_handler (space, 0xc400, 0xc4ff, 0, 0x0300, SMH_BANK3, williams_cmos_w); - memory_install_read8_handler (space, 0xc800, 0xcbff, 0, 0x03e0, williams_video_counter_r); - memory_install_readwrite8_handler (space, 0xcc00, 0xcc03, 0, 0x03e0, pia_1_r, pia_1_w); - memory_install_readwrite8_handler (space, 0xcc04, 0xcc07, 0, 0x03e0, pia_0_r, pia_0_w); + memory_install_write8_handler (space, 0xc000, 0xc00f, 0, 0x03e0, SMH_BANK4); + memory_install_write8_handler (space, 0xc010, 0xc01f, 0, 0x03e0, defender_video_control_w); + memory_install_write8_handler (space, 0xc3ff, 0xc3ff, 0, 0, williams_watchdog_reset_w); + memory_install_readwrite8_handler(space, 0xc400, 0xc4ff, 0, 0x0300, SMH_BANK3, williams_cmos_w); + memory_install_read8_handler (space, 0xc800, 0xcbff, 0, 0x03e0, williams_video_counter_r); + memory_install_readwrite8_device_handler(space, pia_1, 0xcc00, 0xcc03, 0, 0x03e0, pia_r, pia_w); + memory_install_readwrite8_device_handler(space, pia_0, 0xcc04, 0xcc07, 0, 0x03e0, pia_r, pia_w); memory_set_bankptr(space->machine, 3, generic_nvram); memory_set_bankptr(space->machine, 4, paletteram); } @@ -546,8 +549,8 @@ static ADDRESS_MAP_START( williams_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x8fff) AM_READWRITE(SMH_BANK1, SMH_RAM) AM_BASE(&williams_videoram) AM_RANGE(0x9000, 0xbfff) AM_RAM AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x03f0) AM_WRITE(SMH_RAM) AM_BASE(&paletteram) - AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_READWRITE(pia_0_r, pia_0_w) - AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_READWRITE(pia_1_r, pia_1_w) + AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w) + AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w) AM_RANGE(0xc900, 0xc9ff) AM_WRITE(williams_vram_select_w) AM_RANGE(0xca00, 0xca07) AM_MIRROR(0x00f8) AM_WRITE(williams_blitter_w) AM_RANGE(0xcb00, 0xcbff) AM_READ(williams_video_counter_r) @@ -561,8 +564,8 @@ static ADDRESS_MAP_START( williams_extra_ram_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x8fff) AM_READWRITE(SMH_BANK1, SMH_RAM) AM_BASE(&williams_videoram) AM_RANGE(0x9000, 0xbfff) AM_RAM AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x03f0) AM_WRITE(SMH_RAM) AM_BASE(&paletteram) - AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_READWRITE(pia_0_r, pia_0_w) - AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_READWRITE(pia_1_r, pia_1_w) + AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w) + AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w) AM_RANGE(0xc900, 0xc9ff) AM_WRITE(sinistar_vram_select_w) AM_RANGE(0xca00, 0xca07) AM_MIRROR(0x00f8) AM_WRITE(williams_blitter_w) AM_RANGE(0xcb00, 0xcbff) AM_READ(williams_video_counter_r) @@ -587,8 +590,8 @@ static ADDRESS_MAP_START( blaster_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xbc00, 0xbcff) AM_WRITE(SMH_RAM) AM_BASE(&blaster_scanline_control) AM_RANGE(0x9000, 0xbfff) AM_RAM AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x03f0) AM_WRITE(SMH_RAM) AM_BASE(&paletteram) - AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_READWRITE(pia_0_r, pia_0_w) - AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_READWRITE(pia_1_r, pia_1_w) + AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w) + AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w) AM_RANGE(0xc900, 0xc93f) AM_WRITE(blaster_vram_select_w) AM_RANGE(0xc940, 0xc97f) AM_WRITE(blaster_remap_select_w) AM_RANGE(0xc980, 0xc9bf) AM_WRITE(blaster_bank_select_w) @@ -615,8 +618,8 @@ static ADDRESS_MAP_START( williams2_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xc800, 0xc87f) AM_WRITE(williams2_bank_select_w) AM_RANGE(0xc880, 0xc887) AM_MIRROR(0x0078) AM_WRITE(williams_blitter_w) AM_RANGE(0xc900, 0xc97f) AM_WRITE(williams2_watchdog_reset_w) - AM_RANGE(0xc980, 0xc983) AM_MIRROR(0x0070) AM_READWRITE(pia_1_r, pia_1_w) - AM_RANGE(0xc984, 0xc987) AM_MIRROR(0x0070) AM_READWRITE(pia_0_r, pia_0_w) + AM_RANGE(0xc980, 0xc983) AM_MIRROR(0x0070) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w) + AM_RANGE(0xc984, 0xc987) AM_MIRROR(0x0070) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w) AM_RANGE(0xc98c, 0xc98f) AM_MIRROR(0x0070) AM_WRITE(williams2_7segment_w) AM_RANGE(0xcb00, 0xcb1f) AM_WRITE(williams2_fg_select_w) AM_RANGE(0xcb20, 0xcb3f) AM_WRITE(williams2_bg_select_w) @@ -637,8 +640,8 @@ static ADDRESS_MAP_START( williams2_extra_ram_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xc800, 0xc87f) AM_WRITE(williams2_bank_select_w) AM_RANGE(0xc880, 0xc887) AM_MIRROR(0x0078) AM_WRITE(williams_blitter_w) AM_RANGE(0xc900, 0xc97f) AM_WRITE(williams2_watchdog_reset_w) - AM_RANGE(0xc980, 0xc983) AM_MIRROR(0x0070) AM_READWRITE(pia_1_r, pia_1_w) - AM_RANGE(0xc984, 0xc987) AM_MIRROR(0x0070) AM_READWRITE(pia_0_r, pia_0_w) + AM_RANGE(0xc980, 0xc983) AM_MIRROR(0x0070) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w) + AM_RANGE(0xc984, 0xc987) AM_MIRROR(0x0070) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w) AM_RANGE(0xc98c, 0xc98f) AM_MIRROR(0x0070) AM_WRITE(williams2_7segment_w) AM_RANGE(0xcb00, 0xcb1f) AM_WRITE(williams2_fg_select_w) AM_RANGE(0xcb20, 0xcb3f) AM_WRITE(williams2_bg_select_w) @@ -662,7 +665,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( defender_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x007f) AM_RAM /* internal RAM */ - AM_RANGE(0x0400, 0x0403) AM_MIRROR(0x8000) AM_READWRITE(pia_2_r, pia_2_w) + AM_RANGE(0x0400, 0x0403) AM_MIRROR(0x8000) AM_DEVREADWRITE(PIA6821, "pia_2", pia_r, pia_w) AM_RANGE(0xb000, 0xffff) AM_ROM /* most games start at $F000, Sinistar starts at $B000 */ ADDRESS_MAP_END @@ -670,7 +673,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x007f) AM_RAM /* internal RAM */ AM_RANGE(0x0080, 0x00ff) AM_RAM /* MC6810 RAM */ - AM_RANGE(0x0400, 0x0403) AM_MIRROR(0x8000) AM_READWRITE(pia_2_r, pia_2_w) + AM_RANGE(0x0400, 0x0403) AM_MIRROR(0x8000) AM_DEVREADWRITE(PIA6821, "pia_2", pia_r, pia_w) AM_RANGE(0xb000, 0xffff) AM_ROM /* most games start at $F000, Sinistar starts at $B000 */ ADDRESS_MAP_END @@ -685,7 +688,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( williams2_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x007f) AM_RAM /* internal RAM */ AM_RANGE(0x0080, 0x00ff) AM_RAM /* MC6810 RAM */ - AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x1ffc) AM_READWRITE(pia_2_r, pia_2_w) + AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x1ffc) AM_DEVREADWRITE(PIA6821, "pia_2", pia_r, pia_w) AM_RANGE(0xe000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -1445,6 +1448,11 @@ static MACHINE_DRIVER_START( defender ) MDRV_SOUND_ADD("dac", DAC, 0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) + + /* pia */ + MDRV_PIA6821_ADD("pia_0", williams_pia_0_intf) + MDRV_PIA6821_ADD("pia_1", williams_pia_1_intf) + MDRV_PIA6821_ADD("pia_2", williams_snd_pia_intf) MACHINE_DRIVER_END @@ -1473,6 +1481,16 @@ static MACHINE_DRIVER_START( williams ) MACHINE_DRIVER_END +static MACHINE_DRIVER_START( williams_muxed ) + + /* basic machine hardware */ + MDRV_IMPORT_FROM(williams) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_0", williams_muxed_pia_0_intf) +MACHINE_DRIVER_END + + static MACHINE_DRIVER_START( williams_extra_ram ) /* basic machine hardware */ @@ -1483,6 +1501,26 @@ static MACHINE_DRIVER_START( williams_extra_ram ) MACHINE_DRIVER_END +static MACHINE_DRIVER_START( spdball ) + + /* basic machine hardware */ + MDRV_IMPORT_FROM(williams) + + /* pia */ + MDRV_PIA6821_ADD("pia_3", spdball_pia_3_intf) +MACHINE_DRIVER_END + + +static MACHINE_DRIVER_START( lottofun ) + + /* basic machine hardware */ + MDRV_IMPORT_FROM(williams) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_0", lottofun_pia_0_intf) +MACHINE_DRIVER_END + + static MACHINE_DRIVER_START( alienar ) /* basic machine hardware */ @@ -1494,6 +1532,9 @@ static MACHINE_DRIVER_START( alienar ) MDRV_MACHINE_RESET(williams) MDRV_SCREEN_MODIFY("main") MDRV_SCREEN_VISIBLE_AREA(6, 298-1, 7, 247-1) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_0", williams_muxed_pia_0_intf) MACHINE_DRIVER_END @@ -1505,6 +1546,10 @@ static MACHINE_DRIVER_START( sinistar ) /* sound hardware */ MDRV_SOUND_ADD("cvsd", HC55516, 0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_0", williams_49way_pia_0_intf) + MDRV_PIA6821_MODIFY("pia_2", sinistar_snd_pia_intf) MACHINE_DRIVER_END @@ -1520,6 +1565,10 @@ static MACHINE_DRIVER_START( playball ) /* sound hardware */ MDRV_SOUND_ADD("cvsd", HC55516, 0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_1", playball_pia_1_intf) + MDRV_PIA6821_MODIFY("pia_2", sinistar_snd_pia_intf) MACHINE_DRIVER_END @@ -1536,6 +1585,19 @@ static MACHINE_DRIVER_START( blaster ) /* video hardware */ MDRV_VIDEO_START(blaster) MDRV_VIDEO_UPDATE(blaster) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_0", williams_49way_pia_0_intf) +MACHINE_DRIVER_END + + +static MACHINE_DRIVER_START( blastkit ) + + /* basic machine hardware */ + MDRV_IMPORT_FROM(blaster) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_0", williams_49way_muxed_pia_0_intf) MACHINE_DRIVER_END @@ -1568,6 +1630,11 @@ static MACHINE_DRIVER_START( williams2 ) MDRV_SOUND_ADD("wmsdac", DAC, 0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) + + /* pia */ + MDRV_PIA6821_ADD("pia_0", williams2_muxed_pia_0_intf) + MDRV_PIA6821_ADD("pia_1", williams2_pia_1_intf) + MDRV_PIA6821_ADD("pia_2", williams2_snd_pia_intf) MACHINE_DRIVER_END @@ -1581,6 +1648,29 @@ static MACHINE_DRIVER_START( williams2_extra_ram ) MACHINE_DRIVER_END +static MACHINE_DRIVER_START( mysticm ) + + /* basic machine hardware */ + MDRV_IMPORT_FROM(williams2_extra_ram) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_0", mysticm_pia_0_intf) + MDRV_PIA6821_MODIFY("pia_1", mysticm_pia_1_intf) +MACHINE_DRIVER_END + + +static MACHINE_DRIVER_START( tshoot ) + + /* basic machine hardware */ + MDRV_IMPORT_FROM(williams2) + + /* pia */ + MDRV_PIA6821_MODIFY("pia_0", tshoot_pia_0_intf) + MDRV_PIA6821_MODIFY("pia_1", tshoot_pia_1_intf) + MDRV_PIA6821_MODIFY("pia_2", tshoot_snd_pia_intf) +MACHINE_DRIVER_END + + static MACHINE_DRIVER_START( joust2 ) /* basic machine hardware */ @@ -1593,6 +1683,10 @@ static MACHINE_DRIVER_START( joust2 ) /* sound hardware */ MDRV_SOUND_REMOVE("wmsdac") + + /* pia */ + MDRV_PIA6821_MODIFY("pia_1", joust2_pia_1_intf) + MDRV_PIA6821_ADD("pia_3", joust2_pia_3_intf) MACHINE_DRIVER_END @@ -2600,11 +2694,6 @@ ROM_END #define CONFIGURE_TILEMAP(x) \ williams2_tilemap_config = x -#define CONFIGURE_PIAS(a,b,c) \ - pia_config(machine, 0, &a);\ - pia_config(machine, 1, &b);\ - pia_config(machine, 2, &c) - /************************************* @@ -2616,7 +2705,6 @@ ROM_END static DRIVER_INIT( defender ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000); - CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); } @@ -2626,7 +2714,6 @@ static DRIVER_INIT( defndjeu ) int i; CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000); - CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); /* apply simple decryption by swapping bits 0 and 7 */ for (i = 0xd000; i < 0x19000; i++) @@ -2637,7 +2724,6 @@ static DRIVER_INIT( defndjeu ) static DRIVER_INIT( mayday ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000); - CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); /* install a handler to catch protection checks */ mayday_protection = memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa190, 0xa191, 0, 0, mayday_protection_r); @@ -2654,28 +2740,24 @@ static DRIVER_INIT( mayday ) static DRIVER_INIT( stargate ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000); - CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); } static DRIVER_INIT( robotron ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000); - CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); } static DRIVER_INIT( joust ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000); - CONFIGURE_PIAS(williams_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); } static DRIVER_INIT( bubbles ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000); - CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); /* bubbles has a full 8-bit-wide CMOS */ memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xcc00, 0xcfff, 0, 0, bubbles_cmos_w); @@ -2685,46 +2767,41 @@ static DRIVER_INIT( bubbles ) static DRIVER_INIT( splat ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0xc000); - CONFIGURE_PIAS(williams_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); } static DRIVER_INIT( sinistar ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0x7400); - CONFIGURE_PIAS(williams_49way_pia_0_intf, williams_pia_1_intf, sinistar_snd_pia_intf); } static DRIVER_INIT( playball ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000); - CONFIGURE_PIAS(williams_pia_0_intf, playball_pia_1_intf, sinistar_snd_pia_intf); } static DRIVER_INIT( blaster ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9700); - CONFIGURE_PIAS(williams_49way_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); } static DRIVER_INIT( blastkit ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9700); - CONFIGURE_PIAS(williams_49way_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); } static DRIVER_INIT( spdball ) { + const device_config *pia_3 = devtag_get_device(machine, PIA6821, "pia_3"); + CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000); - CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); /* add a third PIA */ - pia_config(machine, 3, &spdball_pia_3_intf); - memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc808, 0xc80b, 0, 0, pia_3_r, pia_3_w); + memory_install_readwrite8_device_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), pia_3, 0xc808, 0xc80b, 0, 0, pia_r, pia_w); /* install extra input handlers */ memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc800, 0xc800, 0, 0, input_port_read_handler8(machine->portconfig, "AN0")); @@ -2737,7 +2814,6 @@ static DRIVER_INIT( spdball ) static DRIVER_INIT( alienar ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000); - CONFIGURE_PIAS(williams_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xcbff, 0xcbff, 0, 0, SMH_NOP); } @@ -2745,7 +2821,6 @@ static DRIVER_INIT( alienar ) static DRIVER_INIT( alienaru ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000); - CONFIGURE_PIAS(williams_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xcbff, 0xcbff, 0, 0, SMH_NOP); } @@ -2753,7 +2828,6 @@ static DRIVER_INIT( alienaru ) static DRIVER_INIT( lottofun ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000); - CONFIGURE_PIAS(lottofun_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf); } @@ -2768,7 +2842,6 @@ static DRIVER_INIT( mysticm ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9000); CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_MYSTICM); - CONFIGURE_PIAS(mysticm_pia_0_intf, mysticm_pia_1_intf, williams2_snd_pia_intf); } @@ -2776,7 +2849,6 @@ static DRIVER_INIT( tshoot ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9000); CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_TSHOOT); - CONFIGURE_PIAS(tshoot_pia_0_intf, tshoot_pia_1_intf, tshoot_snd_pia_intf); } @@ -2784,7 +2856,6 @@ static DRIVER_INIT( inferno ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9000); CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_TSHOOT); - CONFIGURE_PIAS(williams2_muxed_pia_0_intf, williams2_pia_1_intf, williams2_snd_pia_intf); } @@ -2792,7 +2863,6 @@ static DRIVER_INIT( joust2 ) { CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9000); CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_JOUST2); - CONFIGURE_PIAS(williams2_muxed_pia_0_intf, joust2_pia_1_intf, williams2_snd_pia_intf); } @@ -2827,27 +2897,27 @@ GAME( 1982, jin, 0, jin, jin, defender, ROT90, GAME( 1981, stargate, 0, williams, stargate, stargate, ROT0, "Williams", "Stargate", GAME_SUPPORTS_SAVE ) GAME( 1982, robotron, 0, williams, robotron, robotron, ROT0, "Williams", "Robotron (Solid Blue label)", GAME_SUPPORTS_SAVE ) GAME( 1982, robotryo, robotron, williams, robotron, robotron, ROT0, "Williams", "Robotron (Yellow/Orange label)", GAME_SUPPORTS_SAVE ) -GAME( 1982, joust, 0, williams, joust, joust, ROT0, "Williams", "Joust (White/Green label)", GAME_SUPPORTS_SAVE ) -GAME( 1982, joustr, joust, williams, joust, joust, ROT0, "Williams", "Joust (Solid Red label)", GAME_SUPPORTS_SAVE ) -GAME( 1982, joustwr, joust, williams, joust, joust, ROT0, "Williams", "Joust (White/Red label)", GAME_SUPPORTS_SAVE ) +GAME( 1982, joust, 0, williams_muxed, joust, joust, ROT0, "Williams", "Joust (White/Green label)", GAME_SUPPORTS_SAVE ) +GAME( 1982, joustr, joust, williams_muxed, joust, joust, ROT0, "Williams", "Joust (Solid Red label)", GAME_SUPPORTS_SAVE ) +GAME( 1982, joustwr, joust, williams_muxed, joust, joust, ROT0, "Williams", "Joust (White/Red label)", GAME_SUPPORTS_SAVE ) GAME( 1982, bubbles, 0, williams, bubbles, bubbles, ROT0, "Williams", "Bubbles", GAME_SUPPORTS_SAVE ) GAME( 1982, bubblesr, bubbles, williams, bubbles, bubbles, ROT0, "Williams", "Bubbles (Solid Red label)", GAME_SUPPORTS_SAVE ) GAME( 1982, bubblesp, bubbles, williams, bubbles, bubbles, ROT0, "Williams", "Bubbles (prototype version)", GAME_SUPPORTS_SAVE ) -GAME( 1982, splat, 0, williams, splat, splat, ROT0, "Williams", "Splat!", GAME_SUPPORTS_SAVE ) +GAME( 1982, splat, 0, williams_muxed, splat, splat, ROT0, "Williams", "Splat!", GAME_SUPPORTS_SAVE ) GAME( 1982, sinistar, 0, sinistar, sinistar, sinistar, ROT270, "Williams", "Sinistar (revision 3)", GAME_SUPPORTS_SAVE ) GAME( 1982, sinista1, sinistar, sinistar, sinistar, sinistar, ROT270, "Williams", "Sinistar (prototype version)", GAME_SUPPORTS_SAVE ) GAME( 1982, sinista2, sinistar, sinistar, sinistar, sinistar, ROT270, "Williams", "Sinistar (revision 2)", GAME_SUPPORTS_SAVE ) GAME( 1983, playball, 0, playball, playball, playball, ROT270, "Williams", "PlayBall! (prototype)", GAME_SUPPORTS_SAVE ) GAME( 1983, blaster, 0, blaster, blaster, blaster, ROT0, "Williams", "Blaster", GAME_SUPPORTS_SAVE ) GAME( 1983, blast30, blaster, blaster, blaster, blaster, ROT0, "Williams", "Blaster (early 30 wave version)", GAME_SUPPORTS_SAVE ) -GAME( 1983, blastkit, blaster, blaster, blastkit, blastkit, ROT0, "Williams", "Blaster (kit)", GAME_SUPPORTS_SAVE ) -GAME( 1985, spdball, 0, williams, spdball, spdball, ROT0, "Williams", "Speed Ball (prototype)", GAME_SUPPORTS_SAVE ) +GAME( 1983, blastkit, blaster, blastkit, blastkit, blastkit, ROT0, "Williams", "Blaster (kit)", GAME_SUPPORTS_SAVE ) +GAME( 1985, spdball, 0, spdball, spdball, spdball, ROT0, "Williams", "Speed Ball (prototype)", GAME_SUPPORTS_SAVE ) GAME( 1985, alienar, 0, alienar, alienar, alienar, ROT0, "Duncan Brown", "Alien Arena", GAME_SUPPORTS_SAVE ) GAME( 1985, alienaru, alienar, alienar, alienar, alienaru, ROT0, "Duncan Brown", "Alien Arena (Stargate Upgrade)", GAME_SUPPORTS_SAVE ) -GAME( 1987, lottofun, 0, williams, lottofun, lottofun, ROT0, "H.A.R. Management", "Lotto Fun", GAME_SUPPORTS_SAVE ) +GAME( 1987, lottofun, 0, lottofun, lottofun, lottofun, ROT0, "H.A.R. Management", "Lotto Fun", GAME_SUPPORTS_SAVE ) /* 2nd Generation Williams hardware with tilemaps */ -GAME( 1983, mysticm, 0, williams2_extra_ram, mysticm, mysticm, ROT0, "Williams", "Mystic Marathon", GAME_SUPPORTS_SAVE ) -GAME( 1984, tshoot, 0, williams2, tshoot, tshoot, ROT0, "Williams", "Turkey Shoot", GAME_SUPPORTS_SAVE ) +GAME( 1983, mysticm, 0, mysticm, mysticm, mysticm, ROT0, "Williams", "Mystic Marathon", GAME_SUPPORTS_SAVE ) +GAME( 1984, tshoot, 0, tshoot, tshoot, tshoot, ROT0, "Williams", "Turkey Shoot", GAME_SUPPORTS_SAVE ) GAME( 1984, inferno, 0, williams2_extra_ram, inferno, inferno, ROT0, "Williams", "Inferno", GAME_SUPPORTS_SAVE ) GAME( 1986, joust2, 0, joust2, joust2, joust2, ROT270, "Williams", "Joust 2 - Survival of the Fittest (set 1)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/williams.h b/src/mame/includes/williams.h index 063162f364a..a2fd810e043 100644 --- a/src/mame/includes/williams.h +++ b/src/mame/includes/williams.h @@ -5,7 +5,7 @@ **************************************************************************/ -#include "machine/6821pia.h" +#include "machine/6821new.h" /*----------- defined in drivers/williams.c -----------*/ @@ -40,6 +40,7 @@ extern const pia6821_interface tshoot_pia_0_intf; extern const pia6821_interface tshoot_pia_1_intf; extern const pia6821_interface tshoot_snd_pia_intf; extern const pia6821_interface joust2_pia_1_intf; +extern const pia6821_interface joust2_pia_3_intf; /* initialization */ MACHINE_RESET( defender ); diff --git a/src/mame/machine/williams.c b/src/mame/machine/williams.c index 3a02d2d7f17..b99dfc59af8 100644 --- a/src/mame/machine/williams.c +++ b/src/mame/machine/williams.c @@ -8,7 +8,7 @@ #include "audio/williams.h" #include "cpu/m6800/m6800.h" #include "cpu/m6809/m6809.h" -#include "machine/6821pia.h" +#include "machine/6821new.h" #include "machine/ticket.h" #include "williams.h" #include "sound/dac.h" @@ -31,39 +31,93 @@ static UINT8 vram_bank; static UINT16 joust2_current_sound_data; /* older-Williams routines */ -static void williams_main_irq(running_machine *machine, int state); -static void williams_main_firq(running_machine *machine, int state); -static void williams_snd_irq(running_machine *machine, int state); -static WRITE8_HANDLER( williams_snd_cmd_w ); -static WRITE8_HANDLER( playball_snd_cmd_w ); +static void williams_main_irq(const device_config *device, int state); +static void williams_main_firq(const device_config *device, int state); +static void williams_snd_irq(const device_config *device, int state); +static WRITE8_DEVICE_HANDLER( williams_snd_cmd_w ); +static WRITE8_DEVICE_HANDLER( playball_snd_cmd_w ); /* input port mapping */ static UINT8 port_select; -static WRITE8_HANDLER( williams_port_select_w ); -static READ8_HANDLER( williams_input_port_49way_0_5_r ); -static READ8_HANDLER( williams_49way_port_0_r ); +static WRITE8_DEVICE_HANDLER( williams_port_select_w ); +static READ8_DEVICE_HANDLER( williams_input_port_49way_0_5_r ); +static READ8_DEVICE_HANDLER( williams_49way_port_0_r ); /* newer-Williams routines */ -static WRITE8_HANDLER( williams2_snd_cmd_w ); -static void mysticm_main_irq(running_machine *machine, int state); -static void tshoot_main_irq(running_machine *machine, int state); +static WRITE8_DEVICE_HANDLER( williams2_snd_cmd_w ); +static void mysticm_main_irq(const device_config *device, int state); +static void tshoot_main_irq(const device_config *device, int state); /* Lotto Fun-specific code */ -static READ8_HANDLER( lottofun_input_port_0_r ); +static READ8_DEVICE_HANDLER( lottofun_input_port_0_r ); /* Turkey Shoot-specific code */ -static READ8_HANDLER( tshoot_input_port_0_3_r ); -static WRITE8_HANDLER( tshoot_lamp_w ); -static WRITE8_HANDLER( tshoot_maxvol_w ); +static READ8_DEVICE_HANDLER( tshoot_input_port_0_3_r ); +static WRITE8_DEVICE_HANDLER( tshoot_lamp_w ); +static WRITE8_DEVICE_HANDLER( tshoot_maxvol_w ); /* Joust 2-specific code */ -static WRITE8_HANDLER( joust2_snd_cmd_w ); -static WRITE8_HANDLER( joust2_pia_3_cb1_w ); +static WRITE8_DEVICE_HANDLER( joust2_snd_cmd_w ); +static WRITE8_DEVICE_HANDLER( joust2_pia_3_cb1_w ); /************************************* * + * Trampoline functions + * + *************************************/ + +static READ8_DEVICE_HANDLER( input_port_0_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 0)); } +static READ8_DEVICE_HANDLER( input_port_1_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 1)); } +static READ8_DEVICE_HANDLER( input_port_2_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 2)); } +static READ8_DEVICE_HANDLER( input_port_3_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 3)); } +static READ8_DEVICE_HANDLER( input_port_4_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 4)); } + +static WRITE8_DEVICE_HANDLER( williams_dac_data_w ) +{ + const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + dac_0_data_w(space, offset, data); +} + +static WRITE8_DEVICE_HANDLER( williams_ticket_dispenser_w ) +{ + const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + ticket_dispenser_w(space, offset, data); +} + +static WRITE8_DEVICE_HANDLER( williams_hc55516_0_digit_w ) +{ + const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + hc55516_0_digit_w(space, offset, data); +} + +static WRITE8_DEVICE_HANDLER( williams_hc55516_0_clock_w ) +{ + const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + hc55516_0_clock_w(space, offset, data); +} + +static WRITE8_DEVICE_HANDLER( pia_1_portb_w ) +{ + const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1"); + pia_portb_w(pia_1, offset, data); +} + +static WRITE8_DEVICE_HANDLER( pia_1_cb1_w ) +{ + const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1"); + pia_cb1_w(pia_1, offset, data); +} + +static WRITE8_DEVICE_HANDLER( pia_2_ca1_w ) +{ + const device_config *pia_2 = devtag_get_device(device->machine, PIA6821, "pia_2"); + pia_ca1_w(pia_2, offset, data); +} + +/************************************* + * * Generic old-Williams PIA interfaces * *************************************/ @@ -71,7 +125,7 @@ static WRITE8_HANDLER( joust2_pia_3_cb1_w ); /* Generic PIA 0, maps to input ports 0 and 1 */ const pia6821_interface williams_pia_0_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, input_port_1_r, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_device_r, input_port_1_device_r, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, 0, 0, 0, /*irqs : A/B */ 0, 0 }; @@ -81,7 +135,7 @@ const pia6821_interface williams_pia_0_intf = /* muxing done in williams_mux_r */ const pia6821_interface williams_muxed_pia_0_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, input_port_1_r, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_device_r, input_port_1_device_r, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, 0, 0, williams_port_select_w, /*irqs : A/B */ 0, 0 }; @@ -89,7 +143,7 @@ const pia6821_interface williams_muxed_pia_0_intf = /* Generic 49-way joystick PIA 0 for Sinistar/Blaster */ const pia6821_interface williams_49way_pia_0_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ williams_49way_port_0_r, input_port_1_r, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ williams_49way_port_0_r, input_port_1_device_r, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, 0, 0, 0, /*irqs : A/B */ 0, 0 }; @@ -97,7 +151,7 @@ const pia6821_interface williams_49way_pia_0_intf = /* Muxing 49-way joystick PIA 0 for Blaster kit */ const pia6821_interface williams_49way_muxed_pia_0_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ williams_input_port_49way_0_5_r, input_port_1_r, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ williams_input_port_49way_0_5_r, input_port_1_device_r, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, 0, 0, williams_port_select_w, /*irqs : A/B */ 0, 0 }; @@ -105,7 +159,7 @@ const pia6821_interface williams_49way_muxed_pia_0_intf = /* Generic PIA 1, maps to input port 2, sound command out, and IRQs */ const pia6821_interface williams_pia_1_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, williams_snd_cmd_w, 0, 0, /*irqs : A/B */ williams_main_irq, williams_main_irq }; @@ -114,7 +168,7 @@ const pia6821_interface williams_pia_1_intf = const pia6821_interface williams_snd_pia_intf = { /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0, - /*outputs: A/B,CA/B2 */ dac_0_data_w, 0, 0, 0, + /*outputs: A/B,CA/B2 */ williams_dac_data_w, 0, 0, 0, /*irqs : A/B */ williams_snd_irq, williams_snd_irq }; @@ -129,8 +183,8 @@ const pia6821_interface williams_snd_pia_intf = /* Special PIA 0 for Lotto Fun, to handle the controls and ticket dispenser */ const pia6821_interface lottofun_pia_0_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ lottofun_input_port_0_r, input_port_1_r, 0, 0, 0, 0, - /*outputs: A/B,CA/B2 */ 0, ticket_dispenser_w, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ lottofun_input_port_0_r, input_port_1_device_r, 0, 0, 0, 0, + /*outputs: A/B,CA/B2 */ 0, williams_ticket_dispenser_w, 0, 0, /*irqs : A/B */ 0, 0 }; @@ -138,14 +192,14 @@ const pia6821_interface lottofun_pia_0_intf = const pia6821_interface sinistar_snd_pia_intf = { /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0, - /*outputs: A/B,CA/B2 */ dac_0_data_w, 0, hc55516_0_digit_w, hc55516_0_clock_w, + /*outputs: A/B,CA/B2 */ williams_dac_data_w, 0, williams_hc55516_0_digit_w, williams_hc55516_0_clock_w, /*irqs : A/B */ williams_snd_irq, williams_snd_irq }; /* Special PIA 1 for PlayBall, doesn't set the high bits on sound commands */ const pia6821_interface playball_pia_1_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, playball_snd_cmd_w, 0, 0, /*irqs : A/B */ williams_main_irq, williams_main_irq }; @@ -153,7 +207,7 @@ const pia6821_interface playball_pia_1_intf = /* extra PIA 3 for Speed Ball */ const pia6821_interface spdball_pia_3_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_3_r, input_port_4_r, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_3_device_r, input_port_4_device_r, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, 0, 0, 0, /*irqs : A/B */ 0, 0 }; @@ -169,7 +223,7 @@ const pia6821_interface spdball_pia_3_intf = /* Generic muxing PIA 0, maps to input ports 0/3 and 1; port select is CA2 */ const pia6821_interface williams2_muxed_pia_0_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, input_port_1_r, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_device_r, input_port_1_device_r, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, 0, williams_port_select_w, 0, /*irqs : A/B */ 0, 0 }; @@ -177,7 +231,7 @@ const pia6821_interface williams2_muxed_pia_0_intf = /* Generic PIA 1, maps to input port 2, sound command out, and IRQs */ const pia6821_interface williams2_pia_1_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, williams2_snd_cmd_w, 0, pia_2_ca1_w, /*irqs : A/B */ williams_main_irq, williams_main_irq }; @@ -186,7 +240,7 @@ const pia6821_interface williams2_pia_1_intf = const pia6821_interface williams2_snd_pia_intf = { /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0, - /*outputs: A/B,CA/B2 */ pia_1_portb_w, dac_0_data_w, pia_1_cb1_w, 0, + /*outputs: A/B,CA/B2 */ pia_1_portb_w, williams_dac_data_w, pia_1_cb1_w, 0, /*irqs : A/B */ williams_snd_irq, williams_snd_irq }; @@ -201,7 +255,7 @@ const pia6821_interface williams2_snd_pia_intf = /* Mystic Marathon PIA 0 */ const pia6821_interface mysticm_pia_0_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, input_port_1_r, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_device_r, input_port_1_device_r, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, 0, 0, 0, /*irqs : A/B */ williams_main_firq, mysticm_main_irq }; @@ -209,7 +263,7 @@ const pia6821_interface mysticm_pia_0_intf = /* Mystic Marathon PIA 1 */ const pia6821_interface mysticm_pia_1_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, williams2_snd_cmd_w, 0, pia_2_ca1_w, /*irqs : A/B */ mysticm_main_irq, mysticm_main_irq }; @@ -217,7 +271,7 @@ const pia6821_interface mysticm_pia_1_intf = /* Turkey Shoot PIA 0 */ const pia6821_interface tshoot_pia_0_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ tshoot_input_port_0_3_r, input_port_1_r, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ tshoot_input_port_0_3_r, input_port_1_device_r, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, tshoot_lamp_w, williams_port_select_w, 0, /*irqs : A/B */ tshoot_main_irq, tshoot_main_irq }; @@ -225,7 +279,7 @@ const pia6821_interface tshoot_pia_0_intf = /* Turkey Shoot PIA 1 */ const pia6821_interface tshoot_pia_1_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, williams2_snd_cmd_w, 0, pia_2_ca1_w, /*irqs : A/B */ tshoot_main_irq, tshoot_main_irq }; @@ -234,18 +288,23 @@ const pia6821_interface tshoot_pia_1_intf = const pia6821_interface tshoot_snd_pia_intf = { /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0, - /*outputs: A/B,CA/B2 */ pia_1_portb_w, dac_0_data_w, pia_1_cb1_w, tshoot_maxvol_w, + /*outputs: A/B,CA/B2 */ pia_1_portb_w, williams_dac_data_w, pia_1_cb1_w, tshoot_maxvol_w, /*irqs : A/B */ williams_snd_irq, williams_snd_irq }; /* Joust 2 PIA 1 */ const pia6821_interface joust2_pia_1_intf = { - /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0, + /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0, /*outputs: A/B,CA/B2 */ 0, joust2_snd_cmd_w, joust2_pia_3_cb1_w, pia_2_ca1_w, /*irqs : A/B */ williams_main_irq, williams_main_irq }; +/* Joust 2 PIA 3 */ +const pia6821_interface joust2_pia_3_intf = +{ + 0, +}; /************************************* @@ -256,11 +315,11 @@ const pia6821_interface joust2_pia_1_intf = static TIMER_CALLBACK( williams_va11_callback ) { - const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); + const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1"); int scanline = param; /* the IRQ signal comes into CB1, and is set to VA11 */ - pia_1_cb1_w(space, 0, scanline & 0x20); + pia_cb1_w(pia_1, 0, scanline & 0x20); /* set a timer for the next update */ scanline += 0x20; @@ -271,19 +330,19 @@ static TIMER_CALLBACK( williams_va11_callback ) static TIMER_CALLBACK( williams_count240_off_callback ) { - const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); + const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1"); /* the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13 */ - pia_1_ca1_w(space, 0, 0); + pia_ca1_w(pia_1, 0, 0); } static TIMER_CALLBACK( williams_count240_callback ) { - const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); + const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1"); /* the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13 */ - pia_1_ca1_w(space, 0, 1); + pia_ca1_w(pia_1, 0, 1); /* set a timer to turn it off once the scanline counter resets */ timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, williams_count240_off_callback); @@ -293,28 +352,30 @@ static TIMER_CALLBACK( williams_count240_callback ) } -static void williams_main_irq(running_machine *machine, int state) +static void williams_main_irq(const device_config *device, int state) { - int combined_state = pia_get_irq_a(1) | pia_get_irq_b(1); + const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1"); + int combined_state = pianew_get_irq_a(pia_1) | pianew_get_irq_b(pia_1); /* IRQ to the main CPU */ - cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(device->machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); } -static void williams_main_firq(running_machine *machine, int state) +static void williams_main_firq(const device_config *device, int state) { /* FIRQ to the main CPU */ - cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(device->machine->cpu[0], M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); } -static void williams_snd_irq(running_machine *machine, int state) +static void williams_snd_irq(const device_config *device, int state) { - int combined_state = pia_get_irq_a(2) | pia_get_irq_b(2); + const device_config *pia_2 = devtag_get_device(device->machine, PIA6821, "pia_2"); + int combined_state = pianew_get_irq_a(pia_2) | pianew_get_irq_b(pia_2); /* IRQ to the sound CPU */ - cpu_set_input_line(machine->cpu[1], M6800_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(device->machine->cpu[1], M6800_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); } @@ -325,21 +386,25 @@ static void williams_snd_irq(running_machine *machine, int state) * *************************************/ -static void mysticm_main_irq(running_machine *machine, int state) +static void mysticm_main_irq(const device_config *device, int state) { - int combined_state = pia_get_irq_b(0) | pia_get_irq_a(1) | pia_get_irq_b(1); + const device_config *pia_0 = devtag_get_device(device->machine, PIA6821, "pia_0"); + const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1"); + int combined_state = pianew_get_irq_b(pia_0) | pianew_get_irq_a(pia_1) | pianew_get_irq_b(pia_1); /* IRQ to the main CPU */ - cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(device->machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); } -static void tshoot_main_irq(running_machine *machine, int state) +static void tshoot_main_irq(const device_config *device, int state) { - int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0) | pia_get_irq_a(1) | pia_get_irq_b(1); + const device_config *pia_0 = devtag_get_device(device->machine, PIA6821, "pia_0"); + const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1"); + int combined_state = pianew_get_irq_a(pia_0) | pianew_get_irq_b(pia_0) | pianew_get_irq_a(pia_1) | pianew_get_irq_b(pia_1); /* IRQ to the main CPU */ - cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(device->machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); } @@ -352,9 +417,6 @@ static void tshoot_main_irq(running_machine *machine, int state) static MACHINE_RESET( williams_common ) { - /* reset the PIAs */ - pia_reset(); - /* reset the ticket dispenser (Lotto Fun) */ ticket_dispenser_init(machine, 70, TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_HIGH); @@ -389,12 +451,13 @@ MACHINE_RESET( williams ) static TIMER_CALLBACK( williams2_va11_callback ) { - const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); + const device_config *pia_0 = devtag_get_device(machine, PIA6821, "pia_0"); + const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1"); int scanline = param; /* the IRQ signal comes into CB1, and is set to VA11 */ - pia_0_cb1_w(space, 0, scanline & 0x20); - pia_1_ca1_w(space, 0, scanline & 0x20); + pia_cb1_w(pia_0, 0, scanline & 0x20); + pia_ca1_w(pia_1, 0, scanline & 0x20); /* set a timer for the next update */ scanline += 0x20; @@ -405,19 +468,19 @@ static TIMER_CALLBACK( williams2_va11_callback ) static TIMER_CALLBACK( williams2_endscreen_off_callback ) { - const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); + const device_config *pia_0 = devtag_get_device(machine, PIA6821, "pia_0"); /* the /ENDSCREEN signal comes into CA1 */ - pia_0_ca1_w(space, 0, 1); + pia_ca1_w(pia_0, 0, 1); } static TIMER_CALLBACK( williams2_endscreen_callback ) { - const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); + const device_config *pia_0 = devtag_get_device(machine, PIA6821, "pia_0"); /* the /ENDSCREEN signal comes into CA1 */ - pia_0_ca1_w(space, 0, 0); + pia_ca1_w(pia_0, 0, 0); /* set a timer to turn it off once the scanline counter resets */ timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 8, 0), NULL, 0, williams2_endscreen_off_callback); @@ -445,9 +508,6 @@ MACHINE_RESET( williams2 ) { const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); - /* reset the PIAs */ - pia_reset(); - /* configure memory banks */ memory_configure_bank(machine, 1, 0, 1, williams_videoram, 0); memory_configure_bank(machine, 1, 1, 4, memory_region(machine, "main") + 0x10000, 0x10000); @@ -529,32 +589,34 @@ WRITE8_HANDLER( williams2_bank_select_w ) static TIMER_CALLBACK( williams_deferred_snd_cmd_w ) { - const address_space *space = ptr; - pia_2_portb_w(space, 0, param); - pia_2_cb1_w(space, 0, (param == 0xff) ? 0 : 1); + const device_config *pia_2 = devtag_get_device(machine, PIA6821, "pia_2"); + + pia_portb_w(pia_2, 0, param); + pia_cb1_w(pia_2, 0, (param == 0xff) ? 0 : 1); } -WRITE8_HANDLER( williams_snd_cmd_w ) +WRITE8_DEVICE_HANDLER( williams_snd_cmd_w ) { /* the high two bits are set externally, and should be 1 */ - timer_call_after_resynch(space->machine, (void *)space, data | 0xc0, williams_deferred_snd_cmd_w); + timer_call_after_resynch(device->machine, NULL, data | 0xc0, williams_deferred_snd_cmd_w); } -WRITE8_HANDLER( playball_snd_cmd_w ) +WRITE8_DEVICE_HANDLER( playball_snd_cmd_w ) { - timer_call_after_resynch(space->machine, (void *)space, data, williams_deferred_snd_cmd_w); + timer_call_after_resynch(device->machine, NULL, data, williams_deferred_snd_cmd_w); } static TIMER_CALLBACK( williams2_deferred_snd_cmd_w ) { - const address_space *space = ptr; - pia_2_porta_w(space, 0, param); + const device_config *pia_2 = devtag_get_device(machine, PIA6821, "pia_2"); + + pia_porta_w(pia_2, 0, param); } -static WRITE8_HANDLER( williams2_snd_cmd_w ) +static WRITE8_DEVICE_HANDLER( williams2_snd_cmd_w ) { - timer_call_after_resynch(space->machine, (void *)space, data, williams2_deferred_snd_cmd_w); + timer_call_after_resynch(device->machine, NULL, data, williams2_deferred_snd_cmd_w); } @@ -565,7 +627,7 @@ static WRITE8_HANDLER( williams2_snd_cmd_w ) * *************************************/ -WRITE8_HANDLER( williams_port_select_w ) +WRITE8_DEVICE_HANDLER( williams_port_select_w ) { port_select = data; } @@ -605,19 +667,19 @@ CUSTOM_INPUT( williams_mux_r ) * 1000 = right/down full */ -READ8_HANDLER( williams_49way_port_0_r ) +READ8_DEVICE_HANDLER( williams_49way_port_0_r ) { static const UINT8 translate49[7] = { 0x0, 0x4, 0x6, 0x7, 0xb, 0x9, 0x8 }; - return (translate49[input_port_read(space->machine, "49WAYX") >> 4] << 4) | translate49[input_port_read(space->machine, "49WAYY") >> 4]; + return (translate49[input_port_read(device->machine, "49WAYX") >> 4] << 4) | translate49[input_port_read(device->machine, "49WAYY") >> 4]; } -READ8_HANDLER( williams_input_port_49way_0_5_r ) +READ8_DEVICE_HANDLER( williams_input_port_49way_0_5_r ) { if (port_select) - return williams_49way_port_0_r(space,0); + return williams_49way_port_0_r(device, 0); else - return input_port_read(space->machine, "IN3"); + return input_port_read(device->machine, "IN3"); } @@ -866,10 +928,12 @@ WRITE8_HANDLER( blaster_bank_select_w ) * *************************************/ -static READ8_HANDLER( lottofun_input_port_0_r ) +static READ8_DEVICE_HANDLER( lottofun_input_port_0_r ) { + const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + /* merge in the ticket dispenser status */ - return input_port_read(space->machine, "IN0") | ticket_dispenser_r(space,offset); + return input_port_read(device->machine, "IN0") | ticket_dispenser_r(space,offset); } @@ -880,10 +944,10 @@ static READ8_HANDLER( lottofun_input_port_0_r ) * *************************************/ -static READ8_HANDLER( tshoot_input_port_0_3_r ) +static READ8_DEVICE_HANDLER( tshoot_input_port_0_3_r ) { /* merge in the gun inputs with the standard data */ - int data = input_port_read(space->machine, "IN0"); + int data = input_port_read(device->machine, "IN0"); int gun = (data & 0x3f) ^ ((data & 0x3f) >> 1); return (data & 0xc0) | gun; @@ -891,14 +955,14 @@ static READ8_HANDLER( tshoot_input_port_0_3_r ) } -static WRITE8_HANDLER( tshoot_maxvol_w ) +static WRITE8_DEVICE_HANDLER( tshoot_maxvol_w ) { /* something to do with the sound volume */ - logerror("tshoot maxvol = %d (pc:%x)\n", data, cpu_get_pc(space->cpu)); + logerror("tshoot maxvol = %d (%s)\n", data, cpuexec_describe_context(device->machine)); } -static WRITE8_HANDLER( tshoot_lamp_w ) +static WRITE8_DEVICE_HANDLER( tshoot_lamp_w ) { /* set the grenade lamp */ set_led_status(0,data & 0x04); @@ -939,30 +1003,34 @@ MACHINE_START( joust2 ) MACHINE_RESET( joust2 ) { + const device_config *pia_3 = devtag_get_device(machine, PIA6821, "pia_3"); + /* standard init */ MACHINE_RESET_CALL(williams2); - pia_set_input_ca1(3, 1); + pia_ca1_w(pia_3, 0, 1); state_save_register_global(machine, joust2_current_sound_data); } static TIMER_CALLBACK( joust2_deferred_snd_cmd_w ) { - const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); - pia_2_porta_w(space, 0, param & 0xff); + const device_config *pia_2 = devtag_get_device(machine, PIA6821, "pia_2"); + pia_porta_w(pia_2, 0, param & 0xff); } -static WRITE8_HANDLER( joust2_pia_3_cb1_w ) +static WRITE8_DEVICE_HANDLER( joust2_pia_3_cb1_w ) { + const device_config *pia_3 = devtag_get_device(device->machine, PIA6821, "pia_3"); + joust2_current_sound_data = (joust2_current_sound_data & ~0x100) | ((data << 8) & 0x100); - pia_3_cb1_w(space, offset, data); + pia_cb1_w(pia_3, offset, data); } -static WRITE8_HANDLER( joust2_snd_cmd_w ) +static WRITE8_DEVICE_HANDLER( joust2_snd_cmd_w ) { joust2_current_sound_data = (joust2_current_sound_data & ~0xff) | (data & 0xff); - williams_cvsd_data_w(space->machine, joust2_current_sound_data); - timer_call_after_resynch(space->machine, NULL, joust2_current_sound_data, joust2_deferred_snd_cmd_w); + williams_cvsd_data_w(device->machine, joust2_current_sound_data); + timer_call_after_resynch(device->machine, NULL, joust2_current_sound_data, joust2_deferred_snd_cmd_w); } |
