static void control_b_w(const device_config *device, UINT8 data) { pia6821_state *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); }
void pia6821_device::control_b_w(UINT8 data) { int temp; // bit 7 and 6 are read only data &= 0x3f; LOG(("PIA #%s: control B write = %02X\n", tag(), data)); // update the control register m_ctl_b = data; if (C2_SET_MODE(m_ctl_b)) { // set/reset mode - bit value determines the new output temp = C2_SET(m_ctl_b); } else { // strobe mode - output is always high unless strobed temp = TRUE; } set_out_cb2(temp); // update externals update_interrupts(); }
void pia_write(int which, int offset, int data) { pia6821 *p = pia + which; /* adjust offset for 16-bit and ordering */ offset &= 3; if (p->addr & PIA_ALTERNATE_ORDERING) offset = swizzle_address[offset]; switch (offset) { /******************* port A output/DDR write *******************/ case PIA_DDRA: /* write output register */ if (OUTPUT_SELECTED(p->ctl_a)) { LOG(("%04x: PIA%d port A write = %02X\n", activecpu_get_previouspc(), which, data)); /* update the output value */ p->out_a = data;/* & p->ddr_a; */ /* NS990130 - don't mask now, DDR could change later */ /* send it to the output function */ if (p->intf->out_a_func && p->ddr_a) p->intf->out_a_func(0, p->out_a & p->ddr_a); /* NS990130 */ } /* write DDR register */ else { LOG(("%04x: PIA%d DDR A write = %02X\n", activecpu_get_previouspc(), which, data)); if (p->ddr_a != data) { /* NS990130 - if DDR changed, call the callback again */ p->ddr_a = data; /* send it to the output function */ if (p->intf->out_a_func && p->ddr_a) p->intf->out_a_func(0, p->out_a & p->ddr_a); } } break; /******************* port B output/DDR write *******************/ case PIA_DDRB: /* write output register */ if (OUTPUT_SELECTED(p->ctl_b)) { LOG(("%04x: PIA%d port B write = %02X\n", activecpu_get_previouspc(), which, data)); /* update the output value */ p->out_b = data;/* & p->ddr_b */ /* NS990130 - don't mask now, DDR could change later */ /* send it to the output function */ if (p->intf->out_b_func && p->ddr_b) p->intf->out_b_func(0, p->out_b & p->ddr_b); /* NS990130 */ /* CB2 is configured as output and in write strobe mode */ if (C2_OUTPUT(p->ctl_b) && C2_STROBE_MODE(p->ctl_b)) { /* this will cause a transition low; call the output function if we're currently high */ if (p->out_cb2) if (p->intf->out_cb2_func) p->intf->out_cb2_func(0, 0); p->out_cb2 = 0; /* if the CB2 strobe is cleared by the E, reset it right away */ if (STROBE_E_RESET(p->ctl_b)) { if (p->intf->out_cb2_func) p->intf->out_cb2_func(0, 1); p->out_cb2 = 1; } } } /* write DDR register */ else { LOG(("%04x: PIA%d DDR B write = %02X\n", activecpu_get_previouspc(), which, data)); if (p->ddr_b != data) { /* NS990130 - if DDR changed, call the callback again */ p->ddr_b = data; /* send it to the output function */ if (p->intf->out_b_func && p->ddr_b) p->intf->out_b_func(0, p->out_b & p->ddr_b); } } break; /******************* port A control write *******************/ case PIA_CTLA: /* Bit 7 and 6 read only - PD 16/01/00 */ data &= 0x3f; LOG(("%04x: PIA%d control A write = %02X\n", activecpu_get_previouspc(), which, data)); /* CA2 is configured as output */ if (C2_OUTPUT(data)) { int temp; if (C2_SET_MODE(data)) { /* set/reset mode--bit value determines the new output */ temp = SET_C2(data) ? 1 : 0; } else { /* strobe mode--output is always high unless strobed. */ temp = 1; } /* if we're going from input to output mode, or we're already in output mode and this change creates a transition, call the CA2 output function */ if (C2_INPUT(p->ctl_a) || (C2_OUTPUT(p->ctl_a) && (p->out_ca2 ^ temp))) if (p->intf->out_ca2_func) p->intf->out_ca2_func(0, temp); /* set the new value */ p->out_ca2 = temp; } /* update the control register */ p->ctl_a = data; /* update externals */ update_6821_interrupts(p); break; /******************* port B control write *******************/ case PIA_CTLB: /* Bit 7 and 6 read only - PD 16/01/00 */ data &= 0x3f; LOG(("%04x: PIA%d control B write = %02X\n", activecpu_get_previouspc(), which, data)); /* CB2 is configured as output */ if (C2_OUTPUT(data)) { int temp; if (C2_SET_MODE(data)) { /* set/reset mode--bit value determines the new output */ temp = SET_C2(data) ? 1 : 0; } else { /* strobe mode--output is always high unless strobed. */ temp = 1; } /* if we're going from input to output mode, or we're already in output mode and this change creates a transition, call the CB2 output function */ if (C2_INPUT(p->ctl_b) || (C2_OUTPUT(p->ctl_b) && (p->out_cb2 ^ temp))) if (p->intf->out_cb2_func) p->intf->out_cb2_func(0, temp); /* set the new value */ p->out_cb2 = temp; } /* update the control register */ p->ctl_b = data; /* update externals */ update_6821_interrupts(p); break; } }