--- uae/src/include/events.h 2018/04/24 16:38:39 1.1 +++ uae/src/include/events.h 2018/04/24 16:40:27 1.1.1.3 @@ -2,18 +2,15 @@ * UAE - The Un*x Amiga Emulator * * Events - * - * (c) 1995 Bernd Schmidt + * + * Note that this file must be included after sound.h and sounddep/sound.h, + * since DONT_WANT_SOUND can get overridden in those. + * + * Copyright 1995, 1996, 1997 Bernd Schmidt */ -/* This is tunable. 4 gives good results. */ -#ifdef LINUX_SOUND_SLOW_MACHINE -#define cycles_per_instruction 8 -#else -#define cycles_per_instruction 4 -#endif - -extern unsigned long int cycles, nextevent; +extern unsigned long int cycles, nextevent, is_lastline; +extern unsigned long int sample_evtime; typedef void (*evfunc)(void); struct ev @@ -23,7 +20,7 @@ struct ev evfunc handler; }; -enum { +enum { ev_hsync, ev_copper, ev_cia, ev_blitter, ev_diskblk, ev_diskindex, #ifndef DONT_WANT_SOUND @@ -38,13 +35,13 @@ extern struct ev eventtab[ev_max]; static __inline__ void events_schedule(void) { int i; - + unsigned long int mintime = ~0L; for(i = 0; i < ev_max; i++) { - if (eventtab[i].active) { + if (eventtab[i].active) { unsigned long int eventtime = eventtab[i].evtime - cycles; if (eventtime < mintime) - mintime = eventtime; + mintime = eventtime; } } nextevent = cycles + mintime; @@ -52,12 +49,18 @@ static __inline__ void events_schedule(v static __inline__ void do_cycles_slow(void) { - if ((nextevent - cycles) <= cycles_per_instruction) { - int j; - for(j = 0; j < cycles_per_instruction; j++) { + unsigned long cycles_to_add = currprefs.m68k_speed; + +#ifdef FRAME_RATE_HACK + if (is_lastline && eventtab[ev_hsync].evtime-cycles <= cycles_to_add + && (long int)(read_processor_time () - vsyncmintime) < 0) + return; +#endif + if ((nextevent - cycles) <= cycles_to_add) { + for (; cycles_to_add != 0; cycles_to_add--) { if (++cycles == nextevent) { int i; - + for(i = 0; i < ev_max; i++) { if (eventtab[i].active && eventtab[i].evtime == cycles) { (*eventtab[i].handler)(); @@ -66,17 +69,21 @@ static __inline__ void do_cycles_slow(vo events_schedule(); } } - } else { - cycles += cycles_per_instruction; } + cycles += cycles_to_add; } static __inline__ void do_cycles_fast(void) { +#ifdef FRAME_RATE_HACK + if (is_lastline && eventtab[ev_hsync].evtime-cycles <= 1 + && (long int)(read_processor_time () - vsyncmintime) < 0) + return; +#endif cycles++; if (nextevent == cycles) { int i; - + for(i = 0; i < ev_max; i++) { if (eventtab[i].active && eventtab[i].evtime == cycles) { (*eventtab[i].handler)(); @@ -87,7 +94,7 @@ static __inline__ void do_cycles_fast(vo } -#ifdef FASTER_CPU +#if /* M68K_SPEED == 1 */ 0 #define do_cycles do_cycles_fast #else #define do_cycles do_cycles_slow