void via6522_device::shift() { if (SO_O2_CONTROL(m_acr) || SO_T2_CONTROL(m_acr)) { m_out_cb2 = (m_sr >> 7) & 1; m_sr = (m_sr << 1) | m_out_cb2; devcb_call_write_line(&m_out_cb2_func, m_out_cb2); m_in_cb1=1; /* this should be one cycle wide */ devcb_call_write_line(&m_out_cb1_func, 0); devcb_call_write_line(&m_out_cb1_func, 1); m_shift_counter = (m_shift_counter + 1) % 8; if (m_shift_counter) { if (SO_O2_CONTROL(m_acr)) { timer_adjust_oneshot(m_shift_timer, cycles_to_time(2), 0); } else { timer_adjust_oneshot(m_shift_timer, cycles_to_time((m_t2ll + 2)*2), 0); } } else { if (!(m_ifr & INT_SR)) { set_int(INT_SR); } } }
static TIMER_CALLBACK( cdp1861_int_tick ) { device_t *device = (device_t *)ptr; cdp1861_t *cdp1861 = get_safe_token(device); int scanline = cdp1861->screen->vpos(); if (scanline == CDP1861_SCANLINE_INT_START) { if (cdp1861->disp) { devcb_call_write_line(&cdp1861->out_int_func, ASSERT_LINE); } cdp1861->int_timer->adjust(cdp1861->screen->time_until_pos( CDP1861_SCANLINE_INT_END, 0)); } else { if (cdp1861->disp) { devcb_call_write_line(&cdp1861->out_int_func, CLEAR_LINE); } cdp1861->int_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_INT_START, 0)); } }
static TIMER_CALLBACK( pic8259_timerproc ) { device_t *device = (device_t *)ptr; pic8259_t *pic8259 = get_safe_token(device); int irq; UINT8 mask; /* check the various IRQs */ for (irq = 0; irq < IRQ_COUNT; irq++) { mask = 1 << irq; /* is this IRQ in service? */ if (pic8259->isr & mask) { if (LOG_GENERAL) logerror("pic8259_timerproc(): PIC IRQ #%d still in service\n", irq); break; } /* is this IRQ pending and enabled? */ if ((pic8259->state == STATE_READY) && (pic8259->irr & mask) && !(pic8259->imr & mask)) { if (LOG_GENERAL) logerror("pic8259_timerproc(): PIC triggering IRQ #%d\n", irq); if (!BIT(pic8259->ocw3, 2)) devcb_call_write_line(&pic8259->out_int_func, 1); return; } } if (!BIT(pic8259->ocw3, 2)) devcb_call_write_line(&pic8259->out_int_func, 0); }
static TIMER_CALLBACK( cdp1861_efx_tick ) { device_t *device = (device_t *)ptr; cdp1861_t *cdp1861 = get_safe_token(device); int scanline = cdp1861->screen->vpos(); switch (scanline) { case CDP1861_SCANLINE_EFX_TOP_START: devcb_call_write_line(&cdp1861->out_efx_func, ASSERT_LINE); cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_END, 0)); break; case CDP1861_SCANLINE_EFX_TOP_END: devcb_call_write_line(&cdp1861->out_efx_func, CLEAR_LINE); cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_BOTTOM_START, 0)); break; case CDP1861_SCANLINE_EFX_BOTTOM_START: devcb_call_write_line(&cdp1861->out_efx_func, ASSERT_LINE); cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_BOTTOM_END, 0)); break; case CDP1861_SCANLINE_EFX_BOTTOM_END: devcb_call_write_line(&cdp1861->out_efx_func, CLEAR_LINE); cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_START, 0)); break; } }
static DEVICE_RESET( pia6821 ) { pia6821_state *p = get_token(device); /* * 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; p->out_a = 0; p->out_ca2 = 0; p->port_a_z_mask = 0; p->ddr_a = 0; p->ctl_a = 0; p->irq_a1 = 0; p->irq_a2 = 0; p->irq_a_state = 0; p->in_b = 0; p->in_cb1 = 0; p->in_cb2 = 0; p->out_b = 0; p->out_cb2 = 0; p->last_out_cb2_z = 0; p->ddr_b = 0; p->ctl_b = 0; p->irq_b1 = 0; p->irq_b2 = 0; p->irq_b_state = 0; p->in_a_pushed = 0; p->out_a_needs_pulled = 0; p->in_ca1_pushed = 0; p->in_ca2_pushed = 0; p->out_ca2_needs_pulled = 0; p->in_b_pushed = 0; p->out_b_needs_pulled = 0; p->in_cb1_pushed = 0; p->in_cb2_pushed = 0; p->out_cb2_needs_pulled = 0; p->logged_port_a_not_connected = 0; p->logged_port_b_not_connected = 0; p->logged_ca1_not_connected = 0; p->logged_ca2_not_connected = 0; p->logged_cb1_not_connected = 0; p->logged_cb2_not_connected = 0; /* clear the IRQs */ devcb_call_write_line(&p->irq_a_func, FALSE); devcb_call_write_line(&p->irq_b_func, FALSE); }
static DEVICE_RESET( cdp1861 ) { cdp1861_t *cdp1861 = get_safe_token(device); cdp1861->int_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_INT_START, 0)); cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_START, 0)); cdp1861->dma_timer->adjust(cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_START)); cdp1861->disp = 0; cdp1861->dmaout = 0; devcb_call_write_line(&cdp1861->out_int_func, CLEAR_LINE); devcb_call_write_line(&cdp1861->out_dmao_func, CLEAR_LINE); devcb_call_write_line(&cdp1861->out_efx_func, CLEAR_LINE); }
static DEVICE_RESET( e05a03 ) { e05a03_state *e05a03 = get_safe_token(device); e05a03->printhead = 0x00; e05a03->pf_motor = 0x00; e05a03->cr_motor = 0x0f; devcb_call_write_line(&e05a03->out_pe_func, 0); devcb_call_write_line(&e05a03->out_pe_lp_func, 1); e05a03->busy_software = 1; e05a03->nlqlp = 1; e05a03->cndlp = 1; }
void acia6850_device::device_reset() { int cts = devcb_call_read_line(&m_in_cts_func); int dcd = devcb_call_read_line(&m_in_dcd_func); m_status = (cts << 3) | (dcd << 2) | ACIA6850_STATUS_TDRE; m_tdr = 0; m_rdr = 0; m_tx_shift = 0; m_rx_shift = 0; m_tx_counter = 0; m_rx_counter = 0; TXD(1); m_overrun = 0; m_status_read = 0; m_brk = 0; m_rx_state = START; m_tx_state = START; m_irq = 0; devcb_call_write_line(&m_out_irq_func, 1); if (m_first_reset) { m_first_reset = 0; RTS(1); } else { RTS(m_rts); } }
static WRITE_LINE_DEVICE_HANDLER( pcode_ready ) { // Caution: The device pointer passed to this function is the calling // device. That is, if we want *this* device, we need to take the owner. ti99_pcoden_state *pcode = get_safe_token(device->owner()); devcb_call_write_line( &pcode->lines.ready, state ); }
INLINE void interrupt_check(const device_config *device) { z80pio_t *z80pio = get_safe_token( device ); /* if we have a callback, update it with the current state */ devcb_call_write_line(&z80pio->intr, (z80pio_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); }
void z80dma_device::update_status() { UINT16 pending_transfer; attotime next; // no transfer is active right now; is there a transfer pending right now? pending_transfer = is_ready() & m_dma_enabled; if (pending_transfer) { m_is_read = true; m_cur_cycle = (PORTA_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN); next = ATTOTIME_IN_HZ(clock()); timer_adjust_periodic(m_timer, attotime_zero, 0, // 1 byte transferred in 4 clock cycles next); } else { if (m_is_read) { // no transfers active right now timer_reset(m_timer, attotime_never); } } // set the busreq line devcb_call_write_line(&m_out_busreq_func, pending_transfer ? ASSERT_LINE : CLEAR_LINE); }
inline void abc99_device::key_down(int state) { if (m_keydown != state) { devcb_call_write_line(&m_out_keydown_func, state); m_keydown = state; } }
static void set_sr_line(cdp1852_t *cdp1852, int level) { if (cdp1852->sr != level) { cdp1852->sr = level; devcb_call_write_line(&cdp1852->out_sr_func, cdp1852->sr); } }
INLINE void set_rdy(const device_config *device, int ch, int state) { z80pio_t *z80pio = get_safe_token( device ); /* set state */ z80pio->rdy[ch] = state; /* call callback with state */ devcb_call_write_line(&z80pio->rdyr[ch], z80pio->rdy[ch]); }
INLINE void update_irqstate(running_device *device) { riot6532_state *riot = get_safe_token(device); int state = (riot->irqstate & riot->irqenable); if (riot->irq_func.write != NULL) devcb_call_write_line(&riot->irq_func, (state != 0) ? ASSERT_LINE : CLEAR_LINE); else logerror("%s:6532RIOT chip #%d: no irq callback function\n", cpuexec_describe_context(device->machine), riot->index); }
inline void abc99_device::serial_output() { int so = m_so_z2 & m_so_z5; if (m_so != so) { m_so = so; devcb_call_write_line(&m_out_txd_func, m_so); } }
static void ttl7474_update(ttl7474_state *state) { if (!state->preset && state->clear) /* line 1 in truth table */ { state->output = 1; state->output_comp = 0; } else if (state->preset && !state->clear) /* line 2 in truth table */ { state->output = 0; state->output_comp = 1; } else if (!state->preset && !state->clear) /* line 3 in truth table */ { state->output = 1; state->output_comp = 1; } else if (!state->last_clock && state->clock) /* line 4 in truth table */ { state->output = state->d; state->output_comp = !state->d; } state->last_clock = state->clock; /* call callback if any of the outputs changed */ if (state->output != state->last_output) { state->last_output = state->output; if (state->output_cb.write != NULL) devcb_call_write_line(&state->output_cb, state->output); } /* call callback if any of the outputs changed */ if (state->output_comp != state->last_output_comp) { state->last_output_comp = state->output_comp; if (state->comp_output_cb.write != NULL) devcb_call_write_line(&state->comp_output_cb, state->output_comp); } }
void acia6850_device::check_interrupts() { int irq = (m_tx_int && (m_status & ACIA6850_STATUS_TDRE) && (~m_status & ACIA6850_STATUS_CTS)) || ((m_ctrl & 0x80) && ((m_status & (ACIA6850_STATUS_RDRF|ACIA6850_STATUS_DCD)) || m_overrun)); if (irq != m_irq) { m_irq = irq; if (irq) { m_status |= ACIA6850_STATUS_IRQ; devcb_call_write_line(&m_out_irq_func, 0); } else { m_status &= ~ACIA6850_STATUS_IRQ; devcb_call_write_line(&m_out_irq_func, 1); } } }
void ttl7474_device::update() { if (!m_preset && m_clear) /* line 1 in truth table */ { m_output = 1; m_output_comp = 0; } else if (m_preset && !m_clear) /* line 2 in truth table */ { m_output = 0; m_output_comp = 1; } else if (!m_preset && !m_clear) /* line 3 in truth table */ { m_output = 1; m_output_comp = 1; } else if (!m_last_clock && m_clk) /* line 4 in truth table */ { m_output = m_d; m_output_comp = !m_d; } m_last_clock = m_clk; /* call callback if any of the outputs changed */ if (m_output != m_last_output) { m_last_output = m_output; devcb_call_write_line(&m_output_cb, m_output); } /* call callback if any of the outputs changed */ if (m_output_comp != m_last_output_comp) { m_last_output_comp = m_output_comp; devcb_call_write_line(&m_comp_output_cb, m_output_comp); } }
void riot6532_device::update_irqstate() { int state = (m_irqstate & m_irqenable); if (m_irq_func.write != NULL) { devcb_call_write_line(&m_irq_func, (state != 0) ? ASSERT_LINE : CLEAR_LINE); } else { logerror("%s:6532RIOT chip #%d: no irq callback function\n", m_machine.describe_context(), m_index); } }
static void update_interrupts(const device_config *device) { pia6821_state *p = get_token(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; devcb_call_write_line(&p->irq_a_func, 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; devcb_call_write_line(&p->irq_b_func, p->irq_b_state); } }
void via6522_device::set_int(int data) { m_ifr |= data; if (TRACE_VIA) { logerror("%s:6522VIA chip %s: IFR = %02X\n", cpuexec_describe_context(&m_machine), tag(), m_ifr); } if (m_ier & m_ifr) { m_ifr |= INT_ANY; devcb_call_write_line(&m_irq_func, ASSERT_LINE); } }
void zx8301_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { case TIMER_VSYNC: //m_vsync = !m_vsync; devcb_call_write_line(&m_out_vsync_func, m_vsync); break; case TIMER_FLASH: m_flash = !m_flash; break; } }
static TIMER_CALLBACK( cdp1861_dma_tick ) { device_t *device = (device_t *)ptr; cdp1861_t *cdp1861 = get_safe_token(device); int scanline = cdp1861->screen->vpos(); if (cdp1861->dmaout) { if (cdp1861->disp) { if (scanline >= CDP1861_SCANLINE_DISPLAY_START && scanline < CDP1861_SCANLINE_DISPLAY_END) { devcb_call_write_line(&cdp1861->out_dmao_func, CLEAR_LINE); } } cdp1861->dma_timer->adjust(cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_WAIT)); cdp1861->dmaout = 0; } else { if (cdp1861->disp) { if (scanline >= CDP1861_SCANLINE_DISPLAY_START && scanline < CDP1861_SCANLINE_DISPLAY_END) { devcb_call_write_line(&cdp1861->out_dmao_func, ASSERT_LINE); } } cdp1861->dma_timer->adjust(cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_ACTIVE)); cdp1861->dmaout = 1; } }
void via6522_device::clear_int(int data) { m_ifr = (m_ifr & ~data) & 0x7f; if (TRACE_VIA) { logerror("%s:6522VIA chip %s: IFR = %02X\n", cpuexec_describe_context(&m_machine), tag(), m_ifr); } if (m_ifr & m_ier) { m_ifr |= INT_ANY; } else { devcb_call_write_line(&m_irq_func, CLEAR_LINE); } }
static void set_out_ca2(const device_config *device, int data) { pia6821_state *p = get_token(device); if (data != p->out_ca2) { p->out_ca2 = data; /* send to output function */ if (p->out_ca2_func.write) devcb_call_write_line(&p->out_ca2_func, 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; } } }
void z80dma_device::interrupt_check() { devcb_call_write_line(&m_out_int_func, m_ip ? ASSERT_LINE : CLEAR_LINE); }
inline void i8155_device::timer_output() { devcb_call_write_line(&m_out_to_func, m_to); if (LOG) logerror("8155 '%s' Timer Output: %u\n", tag(), m_to); }
void z80dart_device::check_interrupts() { int state = (z80daisy_irq_state() & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE; devcb_call_write_line(&m_out_int_func, state); }
inline void abc99_device::serial_clock() { devcb_call_write_line(&m_out_clock_func, 1); devcb_call_write_line(&m_out_clock_func, 0); }