--- uae/src/include/events.h 2018/04/24 16:58:54 1.1.1.9 +++ uae/src/include/events.h 2018/04/24 17:14:54 1.1.1.12 @@ -15,6 +15,8 @@ extern frame_time_t vsynctime, vsyncmint extern void reset_frame_rate_hack (void); extern int rpt_available; +extern void compute_vsynctime (void); + extern unsigned long currcycle, nextevent, is_lastline; extern unsigned long sample_evtime; typedef void (*evfunc)(void); @@ -55,16 +57,16 @@ STATIC_INLINE void do_cycles_slow (unsig return; while ((nextevent - currcycle) <= cycles_to_add) { - int i; - cycles_to_add -= (nextevent - currcycle); - currcycle = nextevent; + int i; + cycles_to_add -= (nextevent - currcycle); + currcycle = nextevent; - for (i = 0; i < ev_max; i++) { + for (i = 0; i < ev_max; i++) { if (eventtab[i].active && eventtab[i].evtime == currcycle) { (*eventtab[i].handler)(); } } - events_schedule(); + events_schedule(); } currcycle += cycles_to_add; } @@ -89,11 +91,27 @@ STATIC_INLINE void do_cycles_fast (void) } +/* 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