File:  [Previous NeXT emulator] / previous / src / cpu / events_normal.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 19:25:47 2018 UTC (8 years, 3 months ago) by root
Branches: giles, MAIN
CVS tags: branch_winuae-cpu, branch_scsi, branch_mmu, branch_keyboard, branch_gilles, HEAD
Previous NeXT emulator


STATIC_INLINE void cycles_do_special (void)
{
}
STATIC_INLINE void set_cycles (int c)
{
}

STATIC_INLINE void events_schedule (void)
{
	int i;

	unsigned long int mintime = ~0L;
	for (i = 0; i < ev_max; i++) {
		if (eventtab[i].active) {
			unsigned long int eventtime = eventtab[i].evtime - currcycle;
			if (eventtime < mintime)
				mintime = eventtime;
		}
	}
	nextevent = currcycle + mintime;
}

STATIC_INLINE void do_cycles_slow (unsigned long cycles_to_add)
{
	if (is_lastline && eventtab[ev_hsync].evtime - currcycle <= cycles_to_add
		&& (long int)(read_processor_time () - vsyncmintime) < 0)
		return;

	while ((nextevent - currcycle) <= cycles_to_add) {
		int i;
		cycles_to_add -= (nextevent - currcycle);
		currcycle = nextevent;

		for (i = 0; i < ev_max; i++) {
			if (eventtab[i].active && eventtab[i].evtime == currcycle) {
				(*eventtab[i].handler)();
			}
		}
		events_schedule();
	}
	currcycle += cycles_to_add;
}

STATIC_INLINE void do_cycles_fast (void)
{
	if (is_lastline && eventtab[ev_hsync].evtime - currcycle <= 1
		&& (long int)(read_processor_time () - vsyncmintime) < 0)
		return;

	currcycle++;
	if (nextevent == currcycle) {
		int i;

		for (i = 0; i < ev_max; i++) {
			if (eventtab[i].active && eventtab[i].evtime == currcycle) {
				(*eventtab[i].handler) ();
			}
		}
		events_schedule();
	}

}

/* This is a special-case function.  Normally, all events should lie in the
future; they should only ever be active at the current cycle during
do_cycles.  However, a snapshot is saved during do_cycles, and so when
restoring it, we may have other events pending.  */
STATIC_INLINE void handle_active_events (void)
{
	int i;
	for (i = 0; i < ev_max; i++) {
		if (eventtab[i].active && eventtab[i].evtime == currcycle) {
			(*eventtab[i].handler)();
		}
	}
}

STATIC_INLINE unsigned long get_cycles (void)
{
	return currcycle;
}

extern void init_eventtab (void);

#if /* M68K_SPEED == 1 */  0
#define do_cycles do_cycles_fast
#else
#define do_cycles do_cycles_slow
#endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.