void ttl74123_device::start_pulse() { attotime duration = compute_duration(); if(timer_running()) { /* retriggering, but not if we are called to quickly */ attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * m_config.m_cap * 220); if(attotime_compare(timer_timeelapsed(m_timer), delay_time) >= 0) { timer_adjust_oneshot(m_timer, duration, 0); if (LOG) logerror("74123 %s: Retriggering pulse. Duration: %f\n", tag(), attotime_to_double(duration)); } else { if (LOG) logerror("74123 %s: Retriggering failed.\n", tag()); } } else { /* starting */ timer_adjust_oneshot(m_timer, duration, 0); set_output(); if (LOG) logerror("74123 %s: Starting pulse. Duration: %f\n", tag(), attotime_to_double(duration)); } }
void timer_print_first_timer(running_machine *machine) { timer_private *global = machine->timer_data; emu_timer *t = global->activelist; printf(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s)\n", attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->func); }
static void start_pulse(const device_config *device) { ttl74123_t *chip = get_safe_token(device); attotime duration = compute_duration(chip); if (timer_running(chip)) { /* retriggering, but not if we are called to quickly */ attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * chip->intf->cap * 220); if (attotime_compare(timer_timeelapsed(chip->timer), delay_time) >= 0) { timer_adjust_oneshot(chip->timer, duration, 0); if (LOG) logerror("74123 %s: Retriggering pulse. Duration: %f\n", device->tag, attotime_to_double(duration)); } else { if (LOG) logerror("74123 %s: Retriggering failed.\n", device->tag); } } else { /* starting */ timer_adjust_oneshot(chip->timer, duration, 0); set_output(device); if (LOG) logerror("74123 %s: Starting pulse. Duration: %f\n", device->tag, attotime_to_double(duration)); } }
static void start_pulse(TTL74123_state *chip) { attotime duration = compute_duration(chip); if (timer_running(chip)) { /* retriggering, but not if we are called to quickly */ attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * chip->intf->cap * 220); if (attotime_compare(timer_timeelapsed(chip->timer), delay_time) >= 0) { timer_adjust(chip->timer, duration, 0, attotime_never); if (LOG) logerror("74123 #%d: Retriggering pulse. Duration: %f\n", chip->which, attotime_to_double(duration)); } else { if (LOG) logerror("74123 #%d: Retriggering failed.\n", chip->which); } } else { /* starting */ timer_adjust(chip->timer, duration, 0, attotime_never); set_output(chip); if (LOG) logerror("74123 #%d: Starting pulse. Duration: %f\n", chip->which, attotime_to_double(duration)); } }
static READ8_HANDLER( exidy_shriot_r ) { /* I/O is done if A2 == 0 */ if ((offset & 0x04) == 0) { switch (offset & 0x03) { case 0x00: /* port A */ return riot_porta_data; case 0x01: /* port A DDR */ return riot_porta_ddr; case 0x02: /* port B */ if (has_tms5220) { riot_portb_data &= ~0x0c; if (!tms5220_ready_r()) riot_portb_data |= 0x04; if (!tms5220_int_r()) riot_portb_data |= 0x08; } return riot_portb_data; case 0x03: /* port B DDR */ return riot_portb_ddr; } } /* interrupt flags are read if A2 == 1 and A0 == 1 */ else if (offset & 0x01) { int temp = riot_irq_flag; riot_irq_flag = 0; riot_irq_state = 0; update_irq_state(0); return temp; } /* timer count is read if A2 == 1 and A0 == 0 */ else { /* set the enable from the offset */ riot_timer_irq_enable = offset & 0x08; /* compute the timer based on the current state */ switch (riot_state) { case RIOT_IDLE: return 0x00; case RIOT_COUNT: return attotime_to_double(timer_timeleft(riot_timer)) * SH6532_CLOCK / riot_clock_divisor; case RIOT_POST_COUNT: return attotime_to_double(timer_timeleft(riot_timer)) * SH6532_CLOCK; } } logerror("Undeclared RIOT read: %x PC:%x\n",offset,activecpu_get_pc()); return 0xff; }
static READ8_DEVICE_HANDLER( r6532_porta_r ) { if (has_tms5220) { running_device *tms = devtag_get_device(device->machine, "tms"); logerror("(%f)%s:TMS5220 status read = %02X\n", attotime_to_double(timer_get_time(device->machine)), cpuexec_describe_context(device->machine), tms5220_status_r(tms, 0)); return tms5220_status_r(tms, 0); } else return 0xff; }
static MACHINE_RESET( beathead ) { /* reset the common subsystems */ atarigen_eeprom_reset(); atarigen_interrupt_reset(update_interrupts); atarijsa_reset(); /* the code is temporarily mapped at 0 at startup */ /* just copying the first 0x40 bytes is sufficient */ memcpy(ram_base, rom_base, 0x40); /* compute the timing of the HBLANK interrupt and set the first timer */ hblank_offset = attotime_to_double(video_screen_get_scan_period(machine->primary_screen)) * ((455. - 336. - 25.) / 455.); timer_set(machine, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(machine->primary_screen, 0, 0)) - hblank_offset), NULL, 0, scanline_callback); /* reset IRQs */ irq_line_state = CLEAR_LINE; irq_state[0] = irq_state[1] = irq_state[2] = 0; irq_enable[0] = irq_enable[1] = irq_enable[2] = 0; }
static WRITE8_DEVICE_HANDLER( r6532_porta_w ) { if (has_mc3417) cputag_set_input_line(device->machine, "cvsdcpu", INPUT_LINE_RESET, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE); if (has_tms5220) { running_device *tms = devtag_get_device(device->machine, "tms"); logerror("(%f)%s:TMS5220 data write = %02X\n", attotime_to_double(timer_get_time(device->machine)), cpuexec_describe_context(device->machine), riot6532_porta_out_get(riot)); tms5220_data_w(tms, 0, data); } }
static TIMER_CALLBACK( schaser_effect_555_cb ) { mw8080bw_state *state = machine->driver_data<mw8080bw_state>(); int effect = param; attotime new_time; /* Toggle 555 output */ state->schaser_effect_555_is_low = !state->schaser_effect_555_is_low; state->schaser_effect_555_time_remain = attotime_zero; state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain); if (state->schaser_effect_555_is_low) new_time = attotime_div(PERIOD_OF_555_ASTABLE(0, RES_K(20), CAP_U(1)), 2); else { if (effect) new_time = attotime_make(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]); else new_time = attotime_never; } timer_adjust_oneshot(state->schaser_effect_555_timer, new_time, effect); sn76477_enable_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion)); sn76477_one_shot_cap_voltage_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT); }
static TIMER_DEVICE_CALLBACK( scanline_callback ) { int scanline = param; /* update the video */ video_screen_update_now(timer->machine->primary_screen); /* on scanline zero, clear any halt condition */ if (scanline == 0) cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE); /* wrap around at 262 */ scanline++; if (scanline >= MAX_SCANLINES) scanline = 0; /* set the scanline IRQ */ irq_state[2] = 1; update_interrupts(timer->machine); /* set the timer for the next one */ timer_device_adjust_oneshot(timer, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0)) - hblank_offset), scanline); }
static void timer_logtimers(void) { emu_timer *t; logerror("===============\n"); logerror("TIMER LOG START\n"); logerror("===============\n"); logerror("Enqueued timers:\n"); for (t = timer_head; t; t = t->next) logerror(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s:%d[%s])\n", attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func); logerror("Free timers:\n"); for (t = timer_free_head; t; t = t->next) logerror(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s:%d[%s])\n", attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func); logerror("==============\n"); logerror("TIMER LOG STOP\n"); logerror("==============\n"); }
static void timer_logtimers(running_machine *machine) { timer_private *global = machine->timer_data; emu_timer *t; logerror("===============\n"); logerror("TIMER LOG START\n"); logerror("===============\n"); logerror("Enqueued timers:\n"); for (t = global->activelist; t; t = t->next) logerror(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s:%d[%s])\n", attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func); logerror("Free timers:\n"); for (t = global->freelist; t; t = t->next) logerror(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s:%d[%s])\n", attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func); logerror("==============\n"); logerror("TIMER LOG STOP\n"); logerror("==============\n"); }
static WRITE8_HANDLER( exidy_shriot_w ) { /* I/O is done if A2 == 0 */ if ((offset & 0x04) == 0) { switch (offset & 0x03) { case 0: /* port A */ if (has_mc3417) cpunum_set_input_line(machine, 2, INPUT_LINE_RESET, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE); riot_porta_data = (riot_porta_data & ~riot_porta_ddr) | (data & riot_porta_ddr); break; case 1: /* port A DDR */ riot_porta_ddr = data; break; case 2: /* port B */ if (has_tms5220) { if (!(data & 0x01) && (riot_portb_data & 0x01)) { riot_porta_data = tms5220_status_r(machine, 0); logerror("(%f)%04X:TMS5220 status read = %02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), riot_porta_data); } if (!(data & 0x02) && (riot_portb_data & 0x02)) { logerror("(%f)%04X:TMS5220 data write = %02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), riot_porta_data); tms5220_data_w(machine, 0, riot_porta_data); } } riot_portb_data = (riot_portb_data & ~riot_portb_ddr) | (data & riot_portb_ddr); break; case 3: /* port B DDR */ riot_portb_ddr = data; break; } } /* PA7 edge detect control if A2 == 1 and A4 == 0 */ else if ((offset & 0x10) == 0) { riot_PA7_irq_enable = offset & 0x03; } /* timer enable if A2 == 1 and A4 == 1 */ else { static const int divisors[4] = { 1, 8, 64, 1024 }; /* make sure the IRQ state is clear */ if (riot_state != RIOT_COUNT) riot_irq_flag &= ~0x80; riot_irq_state = 0; update_irq_state(0); /* set the enable from the offset */ riot_timer_irq_enable = (offset & 0x08) ? 1 : 0; /* set a new timer */ riot_clock_divisor = divisors[offset & 0x03]; timer_adjust_oneshot(riot_timer, attotime_mul(ATTOTIME_IN_HZ(SH6532_CLOCK), data * riot_clock_divisor), 0); riot_state = RIOT_COUNT; } }
UINT32 via6522_device::time_to_cycles(attotime t) { return attotime_to_double(attotime_mul(t, clock())); }
static double calc_plunger_pos(running_machine *machine) { mgolf_state *state = machine->driver_data<mgolf_state>(); return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(state->time_released)) * (attotime_to_double(state->time_released) - attotime_to_double(state->time_pushed) + 0.2); }
static double calc_plunger_pos(running_machine *machine) { return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(time_released)) * (attotime_to_double(time_released) - attotime_to_double(time_pushed) + 0.2); }
static double make_fraction(attotime a, attotime b, double timediv) { /* fraction = (a - b) / timediv */ return attotime_to_double(attotime_sub(a, b)) / timediv; }
static double calc_plunger_pos(void) { return (attotime_to_double(timer_get_time()) - attotime_to_double(time_released)) * (attotime_to_double(time_released) - attotime_to_double(time_pushed) + 0.2); }