UINT8 z80pio_d_r(int which, int ch) { z80pio *pio = pios + which; switch (pio->mode[ch]) { case PIO_MODE0: /* mode 0 output */ return pio->out[ch]; case PIO_MODE1: /* mode 1 input */ set_rdy(pio, ch, 1); /* ready = H */ update_irq_state(pio, ch); return pio->in[ch]; case PIO_MODE2: /* mode 2 i/o */ if (ch) logerror("PIO-B mode 2 \n"); set_rdy(pio, 1, 1); /* brdy = H */ update_irq_state(pio, ch); return pio->in[ch]; case PIO_MODE3: /* mode 3 bit */ return (pio->in[ch] & pio->dir[ch]) | (pio->out[ch] & ~pio->dir[ch]); } logerror("PIO-%c data read,bad mode\n",'A'+ch ); return 0; }
void z80pio_p_w(int which, UINT8 ch, UINT8 data) { z80pio *pio = pios + which; pio->in[ch] = data; switch (pio->mode[ch]) { case PIO_MODE0: logerror("PIO-%c OUTPUT mode and data write\n",'A'+ch ); break; case PIO_MODE2: /* only port A */ ch = 1; /* handshake and IRQ is use portB */ case PIO_MODE1: set_rdy(pio, ch, 0); update_irq_state(pio, ch); break; case PIO_MODE3: /* irq check */ update_irq_state(pio, ch); break; } }
void luxor_55_21056_device::abcbus_out(UINT8 data) { if (m_cs) { m_out = data; if (STAT_DIR && !m_rdy) set_rdy(!m_rdy); } }
void luxor_55_21056_device::device_reset() { m_maincpu->reset(); m_cs = false; m_stat = 0; m_sasi_data = 0; set_rdy(m_rdy); }
UINT8 luxor_55_21056_device::abcbus_inp() { UINT8 data = 0xff; if (m_cs && !STAT_DIR) { data = m_inp; if (m_rdy) set_rdy(!m_rdy); } return data; }
static void z80pio_update_strobe(const device_config *device, int ch, int state) { z80pio_t *z80pio = get_safe_token( device ); switch (z80pio->mode[ch]) { /* output mode: a positive edge is used by peripheral to acknowledge the receipt of data */ case PIO_MODE0: { /* ensure valid */ state = state & 0x01; /* strobe changed state? */ if ((z80pio->strobe[ch] ^ state) != 0) { /* yes */ if (state != 0) { /* positive edge */ VPRINTF(("PIO-%c positive strobe\n",'A' + ch)); /* ready is now inactive */ set_rdy(device, ch, 0); /* int enabled? */ if (z80pio->enable[ch] & PIO_INT_ENABLE) { /* trigger an int request */ z80pio->int_state[ch] |= Z80_DAISY_INT; } } } /* store strobe state */ z80pio->strobe[ch] = state; /* check interrupt */ interrupt_check(device); } break; /* input mode: strobe is used by peripheral to load data from the peripheral into port a input register, data loaded into pio when signal is active */ default: break; } }
static DEVICE_RESET( z80pio ) { z80pio_t *z80pio = get_safe_token( device ); int i; for (i = 0; i < 2; i++) { z80pio->mask[i] = 0xff; /* mask all on */ z80pio->enable[i] = 0x00; /* disable */ z80pio->mode[i] = 0x01; /* mode input */ z80pio->dir[i] = 0x01; /* dir input */ set_rdy(device, i, 0); /* RDY = low */ z80pio->out[i] = 0x00; /* outdata = 0 */ z80pio->int_state[i] = 0; z80pio->strobe[i] = 0; } interrupt_check(device); }
void z80pio_reset(int which) { z80pio *pio = pios + which; int i; for (i = 0; i < 2; i++) { pio->mask[i] = 0xff; /* mask all on */ pio->enable[i] = 0x00; /* disable */ pio->mode[i] = 0x01; /* mode input */ pio->dir[i] = 0x01; /* dir input */ set_rdy(pio, i, 0); /* RDY = low */ pio->out[i] = 0x00; /* outdata = 0 */ pio->int_state[i] = 0; pio->strobe[i] = 0; } interrupt_check(which); }
int z80pio_p_r(int which, UINT8 ch) { z80pio *pio = pios + which; switch (pio->mode[ch]) { case PIO_MODE2: /* port A only */ case PIO_MODE0: set_rdy(pio, ch, 0); update_irq_state(pio, ch); break; case PIO_MODE1: logerror("PIO-%c INPUT mode and data read\n",'A'+ch ); break; case PIO_MODE3: return (pio->in[ch] & pio->dir[ch]) | (pio->out[ch] & ~pio->dir[ch]); } return pio->out[ch]; }
void z80pio_d_w(int which, int ch, UINT8 data) { z80pio *pio = pios + which; pio->out[ch] = data; /* latch out data */ switch (pio->mode[ch]) { case PIO_MODE0: /* mode 0 output */ case PIO_MODE2: /* mode 2 i/o */ set_rdy(pio, ch, 1); /* ready = H */ update_irq_state(pio, ch); return; case PIO_MODE1: /* mode 1 input */ case PIO_MODE3: /* mode 0 bit */ return; default: logerror("PIO-%c data write,bad mode\n",'A'+ch ); } }