Exemplo n.º 1
0
void mame_schedule_soft_reset(void)
{
	mame_timer_adjust(soft_reset_timer, time_zero, 0, time_zero);

	/* we can't be paused since the timer needs to fire */
	mame_pause(FALSE);
}
Exemplo n.º 2
0
INLINE void schedule_next_irq(int curscanline)
{
	/* IRQ is clocked by /32V, so every 64 scanlines */
	curscanline = (curscanline + 64) & 255;

	/* next one at the start of this scanline */
	mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, curscanline, 0), curscanline, time_zero);
}
Exemplo n.º 3
0
void mame_schedule_soft_reset(running_machine *machine)
{
	mame_private *mame = machine->mame_data;

	mame_timer_adjust(mame->soft_reset_timer, time_zero, 0, time_zero);

	/* we can't be paused since the timer needs to fire */
	mame_pause(machine, FALSE);
}
Exemplo n.º 4
0
INLINE void schedule_next_irq(int curscanline)
{
	/* scan for a rising edge on the IRQCK signal */
	for (curscanline++; ; curscanline = (curscanline + 1) & 0xff)
		if ((syncprom[(curscanline - 1) & 0xff] & 8) == 0 && (syncprom[curscanline] & 8) != 0)
			break;

	/* next one at the start of this scanline */
	mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, curscanline, 0), curscanline, time_zero);
}
Exemplo n.º 5
0
void _mame_timer_pulse(mame_time period, int param, void (*callback)(int), const char *file, int line)
{
	mame_timer *timer = _mame_timer_alloc(callback, file, line);

	/* fail if we can't allocate */
	if (!timer)
		return;

	/* adjust to our liking */
	mame_timer_adjust(timer, period, param, period);
}
Exemplo n.º 6
0
INLINE void schedule_next_irq(int curv)
{
	/* IRQ = /32V, clocked by /16V ^ flip */
	/* When not flipped, clocks on 0, 64, 128, 192 */
	/* When flipped, clocks on 16, 80, 144, 208 */
	if (flipscreen)
		curv = ((curv - 32) & 0xff) | 0x10;
	else
		curv = ((curv + 32) & 0xff) & ~0x10;

	/* next one at the start of this scanline */
	mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, v_to_scanline(curv), 0), curv, time_zero);
}
Exemplo n.º 7
0
void mame_timer_reset(mame_timer *which, mame_time duration)
{
	/* error if this is an inactive timer */
	if (which->tag == -1)
	{
		printf("mame_timer_reset: resetting an inactive timer!\n");
		logerror("mame_timer_reset: resetting an inactive timer!\n");
		return;
	}

	/* adjust the timer */
	mame_timer_adjust(which, duration, which->callback_param, which->period);
}
Exemplo n.º 8
0
void _mame_timer_set(mame_time duration, int param, void (*callback)(int), const char *file, int line)
{
	mame_timer *timer = _mame_timer_alloc(callback, file, line);

	/* fail if we can't allocate */
	if (!timer)
		return;

	/* mark the timer temporary */
	timer->temporary = 1;

	/* adjust to our liking */
	mame_timer_adjust(timer, duration, param, time_zero);
}
Exemplo n.º 9
0
static void dma8237_update_status(int which)
{
	UINT16 pending_transfer;
	int channel;
	unsigned int new_eop;

	if ((dma[which].status & 0xF0) == 0)
	{
		/* no transfer is active right now; is there a transfer pending right now? */
		pending_transfer = dma[which].drq & ~dma[which].mask;

		if (pending_transfer)
		{
			/* we do have a transfer in progress */
			for (channel = 3; (pending_transfer & (1 << channel)) == 0; channel--)
				;

			dma[which].status |= 0x10 << channel;
			dma[which].status &= ~(0x01 << channel);

			mame_timer_adjust(dma[which].timer,
				time_zero,
				which * 4 + channel,
				double_to_mame_time(dma[which].intf->bus_speed));
		}
		else
		{
			/* no transfers active right now */
			mame_timer_reset(dma[which].timer, time_never);
		}

		/* set the halt line */
		if (dma[which].intf && dma[which].intf->cpunum >= 0)
		{
			cpunum_set_input_line(dma[which].intf->cpunum, INPUT_LINE_HALT,
				pending_transfer ? ASSERT_LINE : CLEAR_LINE);
		}

		/* set the eop line, if it has changed */
		new_eop = (dma[which].status & 0x0F) == 0x0F ? 1 : 0;
		if (dma[which].eop != new_eop)
		{
			dma[which].eop = new_eop;
			if (dma[which].intf->out_eop_func)
				dma[which].intf->out_eop_func(new_eop ? ASSERT_LINE : CLEAR_LINE);
		}
	}
}
Exemplo n.º 10
0
static void internal_post_key(unicode_char_t ch)
{
	struct KeyBuffer *keybuf;

	keybuf = get_buffer();

	/* need to start up the timer? */
	if (keybuf->begin_pos == keybuf->end_pos)
	{
		mame_timer_adjust(inputx_timer, choose_delay(ch), 0, time_zero);
		keybuf->status_keydown = 0;
	}

	keybuf->buffer[keybuf->end_pos++] = ch;
	keybuf->end_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]);
}
Exemplo n.º 11
0
static void inputx_timerproc(int dummy)
{
	struct KeyBuffer *keybuf;
	mame_time delay;

	keybuf = get_buffer();

	if (queue_chars)
	{
		/* the driver has a queue_chars handler */
		while((keybuf->begin_pos != keybuf->end_pos) && queue_chars(&keybuf->buffer[keybuf->begin_pos], 1))
		{
			keybuf->begin_pos++;
			keybuf->begin_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]);

			if (current_rate.seconds || current_rate.subseconds)
				break;
		}
	}
	else
	{
		/* the driver does not have a queue_chars handler */
		if (keybuf->status_keydown)
		{
			keybuf->status_keydown = FALSE;
			keybuf->begin_pos++;
			keybuf->begin_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]);
		}
		else
		{
			keybuf->status_keydown = TRUE;
		}
	}

	/* need to make sure timerproc is called again if buffer not empty */
	if (keybuf->begin_pos != keybuf->end_pos)
	{
		delay = choose_delay(keybuf->buffer[keybuf->begin_pos]);
		mame_timer_adjust(inputx_timer, delay, 0, time_zero);
	}
}
Exemplo n.º 12
0
static void cliff_irq_callback(int param)
{
	phillips_code = 0;

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

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

	/* if we have a valid code, trigger an IRQ */
	if ( phillips_code & 0x800000 )
		cpunum_set_input_line(0, 0, ASSERT_LINE);

	mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, param, 0), param, time_zero);
}
Exemplo n.º 13
0
static void prepare_msb_flip(int which)
{
	mame_timer_adjust(dma[which].msbflip_timer, time_zero, which, time_zero);
}
Exemplo n.º 14
0
void sound_frame_update(void)
{
	int sample, spknum;

	VPRINTF(("sound_frame_update\n"));

	profiler_mark(PROFILER_SOUND);

	/* reset the mixing streams */
	memset(leftmix, 0, samples_this_frame * sizeof(*leftmix));
	memset(rightmix, 0, samples_this_frame * sizeof(*rightmix));

	/* if we're not paused, keep the sounds going */
	if (!mame_is_paused(Machine))
	{
		/* force all the speaker streams to generate the proper number of samples */
		for (spknum = 0; spknum < totalspeakers; spknum++)
		{
			speaker_info *spk = &speaker[spknum];
			stream_sample_t *stream_buf;

			/* get the output buffer */
			if (spk->mixer_stream)
			{
				stream_buf = stream_consume_output(spk->mixer_stream, 0, samples_this_frame);

#ifdef MAME_DEBUG
				/* debug version: keep track of the maximum sample */
				for (sample = 0; sample < samples_this_frame; sample++)
				{
					if (stream_buf[sample] > spk->max_sample)
						spk->max_sample = stream_buf[sample];
					else if (-stream_buf[sample] > spk->max_sample)
						spk->max_sample = -stream_buf[sample];
					if (stream_buf[sample] > 32767 || stream_buf[sample] < -32768)
						spk->clipped_samples++;
					spk->total_samples++;
				}
#endif

				/* mix if sound is enabled */
				if (global_sound_enabled && !nosound_mode)
				{
					/* if the speaker is centered, send to both left and right */
					if (spk->speaker->x == 0)
						for (sample = 0; sample < samples_this_frame; sample++)
						{
							leftmix[sample] += stream_buf[sample];
							rightmix[sample] += stream_buf[sample];
						}

					/* if the speaker is to the left, send only to the left */
					else if (spk->speaker->x < 0)
						for (sample = 0; sample < samples_this_frame; sample++)
							leftmix[sample] += stream_buf[sample];

					/* if the speaker is to the right, send only to the right */
					else
						for (sample = 0; sample < samples_this_frame; sample++)
							rightmix[sample] += stream_buf[sample];
				}
			}
		}
	}

	/* now downmix the final result */
	for (sample = 0; sample < samples_this_frame; sample++)
	{
		INT32 samp;

		/* clamp the left side */
		samp = leftmix[sample];
		if (samp < -32768)
			samp = -32768;
		else if (samp > 32767)
			samp = 32767;
		finalmix[sample*2+0] = samp;

		/* clamp the right side */
		samp = rightmix[sample];
		if (samp < -32768)
			samp = -32768;
		else if (samp > 32767)
			samp = 32767;
		finalmix[sample*2+1] = samp;
	}

	if (wavfile && !mame_is_paused(Machine))
		wav_add_data_16(wavfile, finalmix, samples_this_frame * 2);

	/* play the result */
	samples_this_frame = osd_update_audio_stream(finalmix);

	/* update the streamer */
	streams_frame_update();

	/* reset the timer to resync for this frame */
	mame_timer_adjust(sound_update_timer, time_never, 0, time_never);

	profiler_mark(PROFILER_END);
}
Exemplo n.º 15
0
void timekeeper_init( int chip, int type, UINT8 *data )
{
	mame_timer *timer;
	mame_time duration;
	mame_system_time systime;
	struct timekeeper_chip *c;

	if( chip >= MAX_TIMEKEEPER_CHIPS )
	{
		logerror( "timekeeper_init( %d ) invalid chip\n", chip );
		return;
	}
	c = &timekeeper[ chip ];

	c->type = type;

	switch( c->type )
	{
	case TIMEKEEPER_M48T02:
		c->offset_control = 0x7f8;
		c->offset_seconds = 0x7f9;
		c->offset_minutes = 0x7fa;
		c->offset_hours = 0x7fb;
		c->offset_day = 0x7fc;
		c->offset_date = 0x7fd;
		c->offset_month = 0x7fe;
		c->offset_year = 0x7ff;
		c->offset_century = -1;
		c->offset_flags = -1;
		c->size = 0x800;
		break;
	case TIMEKEEPER_M48T58:
		c->offset_control = 0x1ff8;
		c->offset_seconds = 0x1ff9;
		c->offset_minutes = 0x1ffa;
		c->offset_hours = 0x1ffb;
		c->offset_day = 0x1ffc;
		c->offset_date = 0x1ffd;
		c->offset_month = 0x1ffe;
		c->offset_year = 0x1fff;
		c->offset_century = -1;
		c->offset_flags = -1;
		c->size = 0x2000;
		break;
	case TIMEKEEPER_MK48T08:
		c->offset_control = 0x1ff8;
		c->offset_seconds = 0x1ff9;
		c->offset_minutes = 0x1ffa;
		c->offset_hours = 0x1ffb;
		c->offset_day = 0x1ffc;
		c->offset_date = 0x1ffd;
		c->offset_month = 0x1ffe;
		c->offset_year = 0x1fff;
		c->offset_century = 0x1ff1;
		c->offset_flags = 0x1ff0;
		c->size = 0x2000;
		break;
	}

	if( data == NULL )
	{
		data = auto_malloc( c->size );
		memset( data, 0xff, c->size );
	}
	c->data = data;

	mame_get_base_datetime(Machine, &systime);

	c->control = 0;
	c->seconds = make_bcd( systime.local_time.second );
	c->minutes = make_bcd( systime.local_time.minute );
	c->hours = make_bcd( systime.local_time.hour );
	c->day = make_bcd( systime.local_time.weekday + 1 );
	c->date = make_bcd( systime.local_time.mday );
	c->month = make_bcd( systime.local_time.month + 1 );
	c->year = make_bcd( systime.local_time.year % 100 );
	c->century = make_bcd( systime.local_time.year / 100 );

	state_save_register_item( "timekeeper", chip, c->control );
	state_save_register_item( "timekeeper", chip, c->seconds );
	state_save_register_item( "timekeeper", chip, c->minutes );
	state_save_register_item( "timekeeper", chip, c->hours );
	state_save_register_item( "timekeeper", chip, c->day );
	state_save_register_item( "timekeeper", chip, c->date );
	state_save_register_item( "timekeeper", chip, c->month );
	state_save_register_item( "timekeeper", chip, c->year );
	state_save_register_item( "timekeeper", chip, c->century );
	state_save_register_item_pointer( "timekeeper", chip, c->data, c->size );

	timer = mame_timer_alloc( timekeeper_tick );
	duration = make_mame_time( 1, 0 );
	mame_timer_adjust( timer, duration, chip, duration );
}
Exemplo n.º 16
0
static MACHINE_RESET( cliffhgr )
{
	port_bank = 0;
	phillips_code = 0;
	mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, 17, 0), 17, time_zero);
}