示例#1
0
static void mcr68_common_init(void)
{
	int i;

	/* reset the 6840's */
	m6840_counter_periods[0] = ATTOTIME_IN_HZ(30);			/* clocked by /VBLANK */
	m6840_counter_periods[1] = attotime_never;					/* grounded */
	m6840_counter_periods[2] = ATTOTIME_IN_HZ(512 * 30);	/* clocked by /HSYNC */

	m6840_status = 0x00;
	m6840_status_read_since_int = 0x00;
	m6840_msb_buffer = m6840_lsb_buffer = 0;
	for (i = 0; i < 3; i++)
	{
		struct counter_state *m6840 = &m6840_state[i];

		m6840->control = 0x00;
		m6840->latch = 0xffff;
		m6840->count = 0xffff;
		timer_enable(m6840->timer, FALSE);
		m6840->timer_active = 0;
		m6840->period = m6840_counter_periods[i];
	}

	/* initialize the clock */
	m6840_internal_counter_period = ATTOTIME_IN_HZ(cpunum_get_clock(0) / 10);

	/* reset cocktail flip */
	mcr_cocktail_flip = 0;

	/* initialize the sound */
	mcr_sound_reset();
}
示例#2
0
文件: ds2404.c 项目: nitrologic/emu
void DS2404_init(running_machine *machine, int ref_year, int ref_month, int ref_day)
{
	struct tm ref_tm;
	time_t ref_time;
	time_t current_time;
	emu_timer *timer;

	memset( &ref_tm, 0, sizeof( ref_tm ) );
	ref_tm.tm_year = ref_year - 1900;
	ref_tm.tm_mon = ref_month - 1;
	ref_tm.tm_mday = ref_day;

	ref_time = mktime( &ref_tm );

	time( &current_time );
	current_time -= ref_time;

	ds2404.rtc[ 0 ] = 0x0;
	ds2404.rtc[ 1 ] = ( current_time >> 0 ) & 0xff;
	ds2404.rtc[ 2 ] = ( current_time >> 8 ) & 0xff;
	ds2404.rtc[ 3 ] = ( current_time >> 16 ) & 0xff;
	ds2404.rtc[ 4 ] = ( current_time >> 24 ) & 0xff;

	timer = timer_alloc( machine, DS2404_tick , NULL);
	timer_adjust_periodic( timer, ATTOTIME_IN_HZ( 256 ), 0, ATTOTIME_IN_HZ( 256 ) );
}
示例#3
0
void microtouch_init(running_machine *machine, microtouch_tx_func tx_cb, microtouch_touch_func touch_cb)
{
	memset(&microtouch, 0, sizeof(microtouch));

	microtouch.last_touch_state = -1;
	microtouch.tx_callback = tx_cb;
	microtouch.touch_callback = touch_cb;

	microtouch.timer = timer_alloc(machine, microtouch_timer_callback, NULL);
	timer_adjust_periodic(microtouch.timer, ATTOTIME_IN_HZ(167*5), 0, ATTOTIME_IN_HZ(167*5));

	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.reset_done);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.format_tablet);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.mode_inactive);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.mode_stream);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.last_touch_state);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.last_x);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.last_y);
	state_save_register_item_array(machine, "microtouch", NULL, 0, microtouch.rx_buffer);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.rx_buffer_ptr);
	state_save_register_item_array(machine, "microtouch", NULL, 0, microtouch.tx_buffer);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.tx_buffer_num);
	state_save_register_item(machine, "microtouch", NULL, 0, microtouch.tx_buffer_ptr);

};
示例#4
0
void z80dart_device::device_start()
{
	// resolve callbacks
	devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this);

	m_channel[Z80DART_CH_A].start(this, Z80DART_CH_A, m_config.m_in_rxda_func, m_config.m_out_txda_func, m_config.m_out_dtra_func, m_config.m_out_rtsa_func, m_config.m_out_wrdya_func);
	m_channel[Z80DART_CH_B].start(this, Z80DART_CH_B, m_config.m_in_rxdb_func, m_config.m_out_txdb_func, m_config.m_out_dtrb_func, m_config.m_out_rtsb_func, m_config.m_out_wrdyb_func);

	if (m_config.m_rx_clock_a != 0)
	{
		// allocate channel A receive timer
		m_rxca_timer = timer_alloc(&m_machine, dart_channel::static_rxca_tick, (void *)&m_channel[Z80DART_CH_A]);
		timer_adjust_periodic(m_rxca_timer, attotime_zero, 0, ATTOTIME_IN_HZ(m_config.m_rx_clock_a));
	}

	if (m_config.m_tx_clock_a != 0)
	{
		// allocate channel A transmit timer
		m_txca_timer = timer_alloc(&m_machine, dart_channel::static_txca_tick, (void *)&m_channel[Z80DART_CH_A]);
		timer_adjust_periodic(m_txca_timer, attotime_zero, 0, ATTOTIME_IN_HZ(m_config.m_tx_clock_a));
	}

	if (m_config.m_rx_tx_clock_b != 0)
	{
		// allocate channel B receive/transmit timer
		m_rxtxcb_timer = timer_alloc(&m_machine, dart_channel::static_rxtxcb_tick, (void *)&m_channel[Z80DART_CH_B]);
		timer_adjust_periodic(m_rxtxcb_timer, attotime_zero, 0, ATTOTIME_IN_HZ(m_config.m_rx_tx_clock_b));
	}

	state_save_register_device_item_array(this, 0, m_int_state);
}
示例#5
0
static WRITE8_HANDLER( polyplay_start_timer2 )
{
	if (data == 0x03)
		timer_adjust(polyplay_timer, attotime_never, 0, attotime_never);

	if (data == 0xb5)
		timer_adjust(polyplay_timer, ATTOTIME_IN_HZ(40), 0, ATTOTIME_IN_HZ(40));
}
示例#6
0
文件: cdp1852.c 项目: nitrologic/emu
static DEVICE_START( cdp1852 )
{
	cdp1852_t *cdp1852 = get_safe_token(device);
	const cdp1852_interface *intf = get_interface(device);

	/* resolve callbacks */
	devcb_resolve_read8(&cdp1852->in_data_func, &intf->in_data_func, device);
	devcb_resolve_write8(&cdp1852->out_data_func, &intf->out_data_func, device);
	devcb_resolve_write_line(&cdp1852->out_sr_func, &intf->out_sr_func, device);

	/* set initial values */
	cdp1852->mode = (cdp1852_mode)intf->mode;

	if (device->clock > 0)
	{
		/* create the scan timer */
		cdp1852->scan_timer = timer_alloc(device->machine, cdp1852_scan_tick, (void *)device);
		timer_adjust_periodic(cdp1852->scan_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock));
	}

	/* register for state saving */
	state_save_register_device_item(device, 0, cdp1852->new_data);
	state_save_register_device_item(device, 0, cdp1852->data);
	state_save_register_device_item(device, 0, cdp1852->next_data);
	state_save_register_device_item(device, 0, cdp1852->sr);
	state_save_register_device_item(device, 0, cdp1852->next_sr);
}
示例#7
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;
	}
}
示例#8
0
文件: z80dma.c 项目: johkelly/MAME_hi
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);
}
示例#9
0
static void dma8257_update_status(const device_config *device)
{
	dma8257_t *dma8257 = get_safe_token(device);
	UINT16 pending_transfer;
	attotime next;

	/* no transfer is active right now; is there a transfer pending right now? */
	pending_transfer = dma8257->drq & (dma8257->mode & 0x0F);

	if (pending_transfer)
	{
		next = ATTOTIME_IN_HZ(device->clock / 4 );
		timer_adjust_periodic(dma8257->timer,
			attotime_zero,
			0,
			/* 1 byte transferred in 4 clock cycles */
			next);
	}
	else
	{
		/* no transfers active right now */
		timer_reset(dma8257->timer, attotime_never);
	}

	/* set the halt line */
	if (dma8257->intf && dma8257->intf->cputag != NULL)
	{
		cputag_set_input_line(device->machine, dma8257->intf->cputag, INPUT_LINE_HALT,
			pending_transfer ? ASSERT_LINE : CLEAR_LINE);
	}

}
示例#10
0
static CPU_INIT( sc61860 )
{
	sc61860_state *cpustate = get_safe_token(device);
	cpustate->config = (sc61860_cpu_core *) device->static_config;
	timer_pulse(device->machine, ATTOTIME_IN_HZ(500), cpustate, 0, sc61860_2ms_tick);
	cpustate->device = device;
	cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
}
示例#11
0
static WRITE8_HANDLER( sound_nmi_rate_w )
{
    /* rate is controlled by the value written here */
    /* this value is latched into up-counters, which are clocked at the */
    /* input clock / 256 */
    attotime nmi_rate = attotime_mul(ATTOTIME_IN_HZ(4000000), 4096 * (256 - data));
    timer_adjust(sound_nmi_timer, nmi_rate, 0, nmi_rate);
}
示例#12
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);
}
示例#13
0
void sega_usb_reset(UINT8 t1_clock_mask)
{
	/* halt the USB CPU at reset time */
	cpunum_set_input_line(Machine, usb.cpunum, INPUT_LINE_RESET, ASSERT_LINE);

	/* start the clock timer */
	timer_pulse(attotime_mul(ATTOTIME_IN_HZ(USB_2MHZ_CLOCK), 256), NULL, 0, increment_t1_clock);
	usb.t1_clock_mask = t1_clock_mask;
}
示例#14
0
文件: neogeo.c 项目: nitrologic/emu
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);
	}
}
示例#15
0
文件: archimds.c 项目: nitrologic/emu
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);
	}
}
示例#16
0
文件: gottlieb.c 项目: nitrologic/emu
static TIMER_CALLBACK( nmi_callback )
{
	/* assert the NMI if it is not disabled */
	nmi_state = 1;
	nmi_state_update(machine);

	/* set a timer to turn it off again on hte next SOUND_CLOCK/16 */
	timer_set(machine, ATTOTIME_IN_HZ(SOUND2_CLOCK/16), NULL, 0, nmi_clear);

	/* adjust the NMI timer for the next time */
	nmi_timer_adjust();
}
示例#17
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);
	}
}
示例#18
0
static void timer_handler(void *param,int c,int count,int clock)
{
	struct ym2203_info *info = param;
	if( count == 0 )
	{	/* Reset FM Timer */
		timer_enable(info->timer[c], 0);
	}
	else
	{	/* Start FM Timer */
		attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count);
		if (!timer_enable(info->timer[c], 1))
			timer_adjust_oneshot(info->timer[c], period, 0);
	}
}
示例#19
0
void kbdc8042_init(running_machine *machine, const struct kbdc8042_interface *intf)
{
	poll_delay = 10;
	memset(&kbdc8042, 0, sizeof(kbdc8042));
	kbdc8042.type = intf->type;
	kbdc8042.set_gate_a20 = intf->set_gate_a20;
	kbdc8042.keyboard_interrupt = intf->keyboard_interrupt;
	kbdc8042.get_out2 = intf->get_out2;

	/* ibmat bios wants 0x20 set! (keyboard locked when not set) 0x80 */
	kbdc8042.inport = 0xa0;
	at_8042_set_outport(machine, 0xfe, 1);

	timer_pulse(machine, ATTOTIME_IN_HZ(60), NULL, 0, kbdc8042_time);
}
示例#20
0
	AM_RANGE(0x00, 0x3f) AM_RAM
ADDRESS_MAP_END

/****************************************************************************
 * Initialize emulation
 ****************************************************************************/
static void cop410_init(int index, int clock, const void *config, int (*irqcallback)(int))
{
	int i;

	memset(&R, 0, sizeof(R));
	R.G_mask = 0x0F;
	R.D_mask = 0x0F;

	cop410_serial_timer = timer_alloc(cop410_serial_tick, NULL);
	timer_adjust_periodic(cop410_serial_timer, attotime_zero, index, ATTOTIME_IN_HZ(clock));

	for (i=0; i<256; i++) InstLen[i]=1;

	InstLen[0x60] = InstLen[0x61] = InstLen[0x68] = InstLen[0x69] = InstLen[0x33] = InstLen[0x23] = 2;

	for (i=0; i<256; i++) LBIops[i] = 0;
	for (i=0x08; i<0x10; i++) LBIops[i] = 1;
	for (i=0x18; i<0x20; i++) LBIops[i] = 1;
	for (i=0x28; i<0x30; i++) LBIops[i] = 1;
	for (i=0x38; i<0x40; i++) LBIops[i] = 1;

	state_save_register_item("cop410", index, PC);
	state_save_register_item("cop410", index, R.PREVPC);
	state_save_register_item("cop410", index, A);
	state_save_register_item("cop410", index, B);
	state_save_register_item("cop410", index, C);
	state_save_register_item("cop410", index, EN);
	state_save_register_item("cop410", index, G);
	state_save_register_item("cop410", index, Q);
	state_save_register_item("cop410", index, SA);
	state_save_register_item("cop410", index, SB);
	state_save_register_item("cop410", index, SIO);
	state_save_register_item("cop410", index, SKL);
	state_save_register_item("cop410", index, skip);
	state_save_register_item("cop410", index, skipLBI);
	state_save_register_item("cop410", index, R.G_mask);
	state_save_register_item("cop410", index, R.D_mask);
	state_save_register_item("cop410", index, R.last_si);
}
示例#21
0
static void sslam_play(const device_config *device, int track, int data)
{
	int status = okim6295_r(device,0);

	if (data < 0x80) {
		if (track) {
			if (sslam_track != data) {
				sslam_track  = data;
				sslam_bar = 1;
				if (status & 0x08)
					okim6295_w(device,0,0x40);
				okim6295_w(device,0,(0x80 | data));
				okim6295_w(device,0,0x81);
				timer_adjust_periodic(music_timer, ATTOTIME_IN_MSEC(4), 0, ATTOTIME_IN_HZ(250));	/* 250Hz for smooth sequencing */
			}
		}
		else {
			if ((status & 0x01) == 0) {
				okim6295_w(device,0,(0x80 | data));
				okim6295_w(device,0,0x11);
			}
			else if ((status & 0x02) == 0) {
				okim6295_w(device,0,(0x80 | data));
				okim6295_w(device,0,0x21);
			}
			else if ((status & 0x04) == 0) {
				okim6295_w(device,0,(0x80 | data));
				okim6295_w(device,0,0x41);
			}
		}
	}
	else {		/* use above 0x80 to turn off channels */
		if (track) {
			timer_enable(music_timer,0);
			sslam_track = 0;
			sslam_melody = 0;
			sslam_bar = 0;
		}
		data &= 0x7f;
		okim6295_w(device,0,data);
	}
}
示例#22
0
文件: 68681.c 项目: johkelly/MAME_hi
static void duart68681_write_TX(duart68681_state* duart68681, int ch, UINT8 data)
{
	attotime period;

	duart68681->channel[ch].tx_data = data;

	// tx_ready will stay on in local loopback mode
	if ((duart68681->channel[ch].MR2 & 0xc0) != 0x80) {
		duart68681->channel[ch].tx_ready = 0;
		duart68681->channel[ch].SR &= ~STATUS_TRANSMITTER_READY;
	}

	if (ch == 0)
		duart68681->ISR &= ~INT_TXRDYA;
	else
		duart68681->ISR &= ~INT_TXRDYB;

	duart68681_update_interrupts(duart68681);

	period = ATTOTIME_IN_HZ(duart68681->channel[ch].baud_rate / 10 );
	timer_adjust_oneshot(duart68681->channel[ch].tx_timer, period, ch);

	// if local loopback is on, write the transmitted data as if a byte had been recieved
	if ((duart68681->channel[ch].MR2&0xC0) == 0x80)
	{
		if ( duart68681->channel[ch].rx_fifo_num >= RX_FIFO_SIZE )
		{
			LOG(( "68681: FIFO overflow\n" ));
			duart68681->channel[ch].SR |= STATUS_OVERRUN_ERROR;
			return;
		}
		duart68681->channel[ch].rx_fifo[duart68681->channel[ch].rx_fifo_write_ptr++] = data;
		if ( duart68681->channel[ch].rx_fifo_write_ptr == RX_FIFO_SIZE )
		{
			duart68681->channel[ch].rx_fifo_write_ptr = 0;
		}
		duart68681->channel[ch].rx_fifo_num++;
		duart68681_update_interrupts(duart68681);
	}
};
示例#23
0
static TIMER_CALLBACK( riot_interrupt )
{
	/* if we're doing the initial interval counting... */
	if (riot_state == RIOT_COUNT)
	{
		/* generate the IRQ */
		riot_irq_flag |= 0x80;
		riot_irq_state = riot_timer_irq_enable;
		update_irq_state(0);

		/* now start counting clock cycles down */
		riot_state = RIOT_POST_COUNT;
		timer_adjust_oneshot(riot_timer, attotime_mul(ATTOTIME_IN_HZ(SH6532_CLOCK), 0xff), 0);
	}

	/* if not, we are done counting down */
	else
	{
		riot_state = RIOT_IDLE;
		timer_adjust_oneshot(riot_timer, attotime_never, 0);
	}
}
示例#24
0
				else
				{
					// transparent disable
					nbmj8891_videoram1[(dy2 * width) + dx1] = color1;
					update_pixel1(dx1, dy2);
					nbmj8891_videoram1[(dy2 * width) + dx2] = color2;
					update_pixel1(dx2, dy2);
				}
			}

			nb1413m3_busyctr++;
		}
	}

	nb1413m3_busyflag = 0;
	timer_set(attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), NULL, 0, blitter_timer_callback);
}

/******************************************************************************


******************************************************************************/
VIDEO_START( nbmj8891_1layer )
{
	UINT8 *CLUT = memory_region(REGION_USER1);
	int i;
	int width = video_screen_get_width(machine->primary_screen);
	int height = video_screen_get_height(machine->primary_screen);

	nbmj8891_tmpbitmap0 = video_screen_auto_bitmap_alloc(machine->primary_screen);
	nbmj8891_videoram0 = auto_malloc(width * height * sizeof(char));
示例#25
0
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;
	}
}
示例#26
0
attotime via6522_device::cycles_to_time(int c)
{
	return attotime_mul(ATTOTIME_IN_HZ(clock()), c);
}
示例#27
0
static void cchasm_refresh (void)
{

	int pc = 0;
    int done = 0;
    int opcode, data;
    int currentx = 0, currenty = 0;
    int scalex = 0, scaley = 0;
    int color = 0;
    int total_length = 1;   /* length of all lines drawn in a frame */
    int move = 0;

	vector_clear_list();

	while (!done)
	{
        data = cchasm_ram[pc];
   		opcode = data >> 12;
        data &= 0xfff;
        if ((opcode > COLOR) && (data & 0x800))
          data |= 0xfffff000;

		pc++;

		switch (opcode)
		{
        case HALT:
            done=1;
            break;
        case JUMP:
            pc = data - 0xb00;
            logerror("JUMP to %x\n", data);
            break;
        case COLOR:
            color = VECTOR_COLOR444(data ^ 0xfff);
            break;
        case SCALEY:
            scaley = data << 5;
            break;
        case POSY:
            move = 1;
            currenty = ycenter + (data << 16);
            break;
        case SCALEX:
            scalex = data << 5;
            break;
        case POSX:
            move = 1;
            currentx = xcenter - (data << 16);
            break;
        case LENGTH:
            if (move)
            {
                vector_add_point (currentx, currenty, 0, 0);
                move = 0;
            }

            currentx -= data * scalex;
            currenty += data * scaley;

            total_length += abs(data);

            if (color)
                vector_add_point (currentx, currenty, color, 0xff);
            else
                move = 1;
            break;
        default:
            logerror("Unknown refresh proc opcode %x with data %x at pc = %x\n", opcode, data, pc-2);
            done = 1;
            break;
		}
	}
    /* Refresh processor runs with 6 MHz */
    timer_set (attotime_mul(ATTOTIME_IN_HZ(6000000), total_length), NULL, 0, cchasm_refresh_end);
}
示例#28
0
INLINE attotime compute_time_per_character(z80sio *sio, int which)
{
	/* fix me -- should compute properly and include data, stop, parity bits */
	return attotime_mul(ATTOTIME_IN_HZ(9600), 10);
}
示例#29
0
文件: gottlieb.c 项目: nitrologic/emu
INLINE void nmi_timer_adjust(void)
{
	/* adjust timer to go off in the future based on the current rate */
	timer_adjust_oneshot(nmi_timer, attotime_mul(ATTOTIME_IN_HZ(SOUND2_CLOCK/16), 256 * (256 - nmi_rate)), 0);
}
示例#30
0
				}
			}
		}
	}
	mc146818->updated = 1;  /* clock has been updated */
	mc146818->last_refresh = timer_get_time(machine);
}



void mc146818_init(running_machine *machine, MC146818_TYPE type)
{
	mc146818 = auto_alloc_clear(machine, struct mc146818_chip);
	mc146818->type = type;
	mc146818->last_refresh = timer_get_time(machine);
    timer_pulse(machine, ATTOTIME_IN_HZ(1), NULL, 0, mc146818_timer);
	mc146818_set_base_datetime(machine);
}



void mc146818_load(running_machine *machine)
{
	mame_file *file;

	file = nvram_fopen(machine, OPEN_FLAG_READ);
	if (file)
	{
		mc146818_load_stream(file);
		mame_fclose(file);
	}