Пример #1
0
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));
	}
}
Пример #2
0
static DEVICE_RESET(duart68681)
{
	duart68681_state *duart68681 = get_safe_token(device);
	emu_timer *save0, *save1;

	duart68681->ACR = 0;  /* Interrupt Vector Register */
	duart68681->IVR = 0x0f;  /* Interrupt Vector Register */
	duart68681->IMR = 0;  /* Interrupt Mask Register */
	duart68681->ISR = 0;  /* Interrupt Status Register */
	duart68681->OPCR = 0; /* Output Port Conf. Register */
	duart68681->OPR = 0;  /* Output Port Register */
	duart68681->CTR.d = 0;  /* Counter/Timer Preset Value */
	duart68681->IP_last_state = 0;  /* last state of IP bits */
	// "reset clears internal registers (SRA, SRB, IMR, ISR, OPR, OPCR) puts OP0-7 in the high state, stops the counter/timer, and puts channels a/b in the inactive state"
	save0 = duart68681->channel[0].tx_timer;
	save1 = duart68681->channel[1].tx_timer;
	memset(duart68681->channel, 0, sizeof(duart68681->channel));
	duart68681->channel[0].tx_timer = save0;
	duart68681->channel[1].tx_timer = save1;

	if (duart68681->duart_config->output_port_write)
		duart68681->duart_config->output_port_write(duart68681->device, duart68681->OPR ^ 0xff);

	// reset timers
	timer_adjust_oneshot(duart68681->channel[0].tx_timer, attotime_never, 0);
	timer_adjust_oneshot(duart68681->channel[1].tx_timer, attotime_never, 1);
}
Пример #3
0
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);
            }
		}
	}
Пример #4
0
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));
	}
}
Пример #5
0
static TIMER_CALLBACK( vidc_vblank )
{
	archimedes_request_irq_a(machine, ARCHIMEDES_IRQA_VBL);

	// set up for next vbl
	timer_adjust_oneshot(vbl_timer, video_screen_get_time_until_pos(machine->primary_screen, vidc_regs[0xb4], 0), 0);
}
Пример #6
0
void spacefev_start_red_cannon( running_machine *machine )
{
	n8080_state *state = (n8080_state *)machine->driver_data;

	state->spacefev_red_cannon = 1;
	timer_adjust_oneshot(state->cannon_timer, ATTOTIME_IN_USEC(550 * 68 * 10), 0);
}
Пример #7
0
static TIMER_CALLBACK( spacefev_stop_red_cannon )
{
	n8080_state *state = (n8080_state *)machine->driver_data;

	state->spacefev_red_cannon = 0;
	timer_adjust_oneshot(state->cannon_timer, attotime_never, 0);
}
Пример #8
0
void timer_device::device_reset()
{
	// type based configuration
	switch (m_config.m_type)
	{
		case timer_device_config::TIMER_TYPE_GENERIC:
		case timer_device_config::TIMER_TYPE_PERIODIC:
		{
			// convert the period into attotime
			attotime period = attotime_never;
			if (m_config.m_period > 0)
			{
				period = UINT64_ATTOTIME_TO_ATTOTIME(m_config.m_period);

				// convert the start_delay into attotime
				attotime start_delay = attotime_zero;
				if (m_config.m_start_delay > 0)
					start_delay = UINT64_ATTOTIME_TO_ATTOTIME(m_config.m_start_delay);

				// allocate and start the backing timer
				timer_adjust_periodic(m_timer, start_delay, m_config.m_param, period);
			}
			break;
		}

		case timer_device_config::TIMER_TYPE_SCANLINE:
			if (m_screen == NULL)
				fatalerror("timer '%s': unable to find screen '%s'\n", tag(), m_config.m_screen);

			// set the timer to to fire immediately
			m_first_time = true;
			timer_adjust_oneshot(m_timer, attotime_zero, m_config.m_param);
			break;
	}
}
Пример #9
0
static void msm5205_playmode(msm5205_state *voice,int select)
{
	static const int prescaler_table[4] = {96,48,64,0};
	int prescaler = prescaler_table[select & 3];
	int bitwidth = (select & 4) ? 4 : 3;


	if( voice->prescaler != prescaler )
	{
		stream_update(voice->stream);

		voice->prescaler = prescaler;
		/* timer set */
		if( prescaler )
		{
			attotime period = attotime_mul(ATTOTIME_IN_HZ(voice->clock), prescaler);
			timer_adjust_periodic(voice->timer, period, 0, period);
		}
		else
			timer_adjust_oneshot(voice->timer, attotime_never, 0);
	}

	if( voice->bitwidth != bitwidth )
	{
		stream_update(voice->stream);

		voice->bitwidth = bitwidth;
	}
}
Пример #10
0
static TIMER_CALLBACK( cursor_callback )
{
	if (lockon_main_inten)
		cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, 0xff);

	timer_adjust_oneshot(cursor_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0);
}
Пример #11
0
static TIMER_CALLBACK( pr8210_bit_callback )
{
	attotime duration = ATTOTIME_IN_MSEC(30);
	const device_config *laserdisc = ptr;
	UINT8 bitsleft = param >> 16;
	UINT8 data = param;

	/* if we have bits, process */
	if (bitsleft != 0)
	{
		/* assert the line and set a timer for deassertion */
	   	laserdisc_line_w(laserdisc, LASERDISC_LINE_CONTROL, ASSERT_LINE);
		timer_set(machine, ATTOTIME_IN_USEC(250), ptr, 0, pr8210_bit_off_callback);

		/* space 0 bits apart by 1msec, and 1 bits by 2msec */
		duration = attotime_mul(ATTOTIME_IN_MSEC(1), (data & 0x80) ? 2 : 1);
		data <<= 1;
		bitsleft--;
	}

	/* if we're out of bits, queue up the next command */
	else if (bitsleft == 0 && pr8210_command_buffer_in != pr8210_command_buffer_out)
	{
		data = pr8210_command_buffer[pr8210_command_buffer_out++ % ARRAY_LENGTH(pr8210_command_buffer)];
		bitsleft = 12;
	}
	timer_adjust_oneshot(pr8210_bit_timer, duration, (bitsleft << 16) | data);
}
Пример #12
0
static TIMER_CALLBACK( cliff_irq_callback )
{
	phillips_code = 0;

	switch (param)
	{
		case 17:
			phillips_code = laserdisc_get_field_code(laserdisc, LASERDISC_CODE_LINE17, TRUE);
			param = 18;
			break;

		case 18:
			phillips_code = laserdisc_get_field_code(laserdisc, LASERDISC_CODE_LINE18, TRUE);
			param = 17;
			break;
	}

	/* if we have a valid code, trigger an IRQ */
	if (phillips_code & 0x800000)
	{
//      printf("%2d:code = %06X\n", param, phillips_code);
		cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE);
	}

	timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(param * 2), param);
}
Пример #13
0
INLINE void schedule_next_irq(running_machine *machine, int curscanline)
{
    /* IRQ is clocked by /32V, so every 64 scanlines */
    curscanline = (curscanline + 64) & 255;

    /* next one at the start of this scanline */
    timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, curscanline, 0), curscanline);
}
Пример #14
0
static void f3853_timer_start(running_device *device, UINT8 value)
{
	f3853_t	*f3853 = get_safe_token( device );

	attotime period = (value != 0xff) ? attotime_mul(ATTOTIME_IN_HZ(device->clock), f3853_value_to_cycle[value]*31) : attotime_never;

	timer_adjust_oneshot(f3853->timer, period, 0);
}
Пример #15
0
static MACHINE_RESET( atetris )
{
	/* reset the slapstic */
	slapstic_reset();
	current_bank = slapstic_bank() & 1;
	reset_bank();

	/* start interrupts going (32V clocked by 16V) */
	timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 48, 0), 48);
}
Пример #16
0
static void adjust_display_position_interrupt_timer(running_machine *machine)
{
	if ((display_counter + 1) != 0)
	{
		attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), display_counter + 1);
		if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer  current y: %02x  current x: %02x   target y: %x  target x: %x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen), (display_counter + 1) / NEOGEO_HTOTAL, (display_counter + 1) % NEOGEO_HTOTAL);

		timer_adjust_oneshot(display_position_interrupt_timer, period, 0);
	}
}
Пример #17
0
INLINE void schedule_next_irq(running_machine *machine, int curscanline)
{
	cloud9_state *state = (cloud9_state *)machine->driver_data;

	/* IRQ is clocked by /32V, so every 64 scanlines */
	curscanline = (curscanline + 64) & 255;

	/* next one at the start of this scanline */
	timer_adjust_oneshot(state->irq_timer, machine->primary_screen->time_until_pos(curscanline), curscanline);
}
Пример #18
0
static TIMER_CALLBACK( ds2401_reset )
{
	int which = param;
	struct ds2401_chip *c = &ds2401[ which ];

	verboselog( machine, 1, "ds2401_reset(%d)\n", which );

	c->state = STATE_RESET;
	timer_adjust_oneshot( c->timer, attotime_never, which );
}
Пример #19
0
void running_machine::schedule_soft_reset()
{
	timer_adjust_oneshot(m_soft_reset_timer, attotime_zero, 0);

	// we can't be paused since the timer needs to fire
	resume();

	// if we're executing, abort out immediately
	m_scheduler.eat_all_cycles();
}
Пример #20
0
INLINE void count_states(int states)
{
	attotime state_time = attotime_make(0, attotime_to_attoseconds(MICRO_STATE_CLOCK_PERIOD) * states);

	if (!micro.timer)
	{
		timer_adjust_oneshot(micro.timer, attotime_never, 0);
		micro.timer_active = 1;
		micro.endtime = state_time;
	}
	else if (attotime_compare(timer_timeelapsed(micro.timer), micro.endtime) > 0)
	{
		timer_adjust_oneshot(micro.timer, attotime_never, 0);
		micro.timer_active = 1;
		micro.endtime = state_time;
	}
	else
		micro.endtime = attotime_add(micro.endtime, state_time);
}
Пример #21
0
static WRITE32_HANDLER( namcofl_paletteram_w )
{
	COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]);

	if ((offset == 0x1808/4) && ACCESSING_BITS_16_31)
	{
		UINT16 v = space->machine->generic.paletteram.u32[offset] >> 16;
		UINT16 triggerscanline=(((v>>8)&0xff)|((v&0xff)<<8))-(32+1);

		timer_adjust_oneshot(raster_interrupt_timer, space->machine->primary_screen->time_until_pos(triggerscanline), 0);
	}
Пример #22
0
static TIMER_CALLBACK( tms34061_interrupt )
{
    /* set timer for next frame */
    timer_adjust_oneshot(tms34061.timer, video_screen_get_frame_period(tms34061.screen), 0);

    /* set the interrupt bit in the status reg */
    tms34061.regs[TMS34061_STATUS] |= 1;

    /* update the interrupt state */
    update_interrupts();
}
Пример #23
0
static TIMER_CALLBACK( display_position_vblank_callback )
{
	if (display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_VBLANK)
	{
		if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_VBLANK ");
		adjust_display_position_interrupt_timer(machine);
	}

	/* set timer for next screen */
	timer_adjust_oneshot(display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
}
Пример #24
0
static void a310_set_timer(int tmr)
{
	double freq;

	if(ioc_timercnt[tmr] != 0) // FIXME: dmdtouch does a divide by zero?
	{
		freq = 2000000.0 / (double)ioc_timercnt[tmr];
	//  logerror("IOC: starting timer %d, %d ticks, freq %f Hz\n", tmr, ioc_timercnt[tmr], freq);
		timer_adjust_oneshot(timer[tmr], ATTOTIME_IN_HZ(freq), tmr);
	}
}
Пример #25
0
static MACHINE_RESET( magmax )
{
	timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64);

#if 0
	{
		int i;
		for (i=0; i<9; i++)
			logerror("SOUND Chan#%i name=%s\n", i, mixer_get_name(i) );
	}
#endif
}
Пример #26
0
void running_machine::schedule_soft_reset()
{
    retro_log(RETRO_LOG_INFO, "[MAME 2010] schedule_soft_reset for current MAME machine.\n");
    
	timer_adjust_oneshot(m_soft_reset_timer, attotime_zero, 0);

	/* we can't be paused since the timer needs to fire */
	resume();

	/* if we're executing, abort out immediately */
	m_scheduler.eat_all_cycles();
}
Пример #27
0
static void adjust_display_position_interrupt_timer( running_machine *machine )
{
	neogeo_state *state = (neogeo_state *)machine->driver_data;

	if ((state->display_counter + 1) != 0)
	{
		attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), state->display_counter + 1);
		if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer  current y: %02x  current x: %02x   target y: %x  target x: %x\n", machine->primary_screen->vpos(), machine->primary_screen->hpos(), (state->display_counter + 1) / NEOGEO_HTOTAL, (state->display_counter + 1) % NEOGEO_HTOTAL);

		timer_adjust_oneshot(state->display_position_interrupt_timer, period, 0);
	}
}
Пример #28
0
/* TimerHandler from fm.c */
static void TimerHandler(void *param,int c,attotime period)
{
	ym3526_state *info = (ym3526_state *)param;
	if( attotime_compare(period, attotime_zero) == 0 )
	{	/* Reset FM Timer */
		timer_enable(info->timer[c], 0);
	}
	else
	{	/* Start FM Timer */
		timer_adjust_oneshot(info->timer[c], period, 0);
	}
}
Пример #29
0
void ds2401_write( running_machine *machine, int which, int data )
{
	struct ds2401_chip *c = &ds2401[ which ];

	verboselog( machine, 1, "ds2401_write( %d, %d )\n", which, data );

	if( data == 0 && c->rx != 0 )
	{
		switch( c->state )
		{
		case STATE_IDLE:
			break;
		case STATE_COMMAND:
			verboselog( machine, 2, "ds2401_write(%d) state_command\n", which );
			timer_adjust_oneshot( c->timer, c->t_samp, which );
			break;
		case STATE_READROM:
			if( c->bit == 0 )
			{
				c->shift = c->data[ 7 - c->byte ];
				verboselog( machine, 1, "ds2401_write(%d) <- data %02x\n", which, c->shift );
			}
			c->tx = c->shift & 1;
			c->shift >>= 1;
			c->bit++;
			if( c->bit == 8 )
			{
				c->bit = 0;
				c->byte++;
			}
			verboselog( machine, 2, "ds2401_write(%d) state_readrom %d\n", which, c->tx );
			timer_adjust_oneshot( c->timer, c->t_rdv, which );
			break;
		default:
			verboselog( machine, 0, "ds2401_write(%d) state not handled: %d\n", which, c->state );
			break;
		}
		timer_adjust_oneshot( c->reset_timer, c->t_rstl, which );
	}
	else if( data == 1 && c->rx == 0 )
Пример #30
0
static TIMER_CALLBACK( interrupt_gen )
{
	int scanline = param;

	/* assert/deassert the interrupt */
	cputag_set_input_line(machine, "maincpu", 0, (scanline & 32) ? ASSERT_LINE : CLEAR_LINE);

	/* set the next timer */
	scanline += 32;
	if (scanline >= 256)
		scanline -= 256;
	timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
}