--- hatari/src/cpu/events.h 2019/04/09 08:51:56 1.1.1.2 +++ hatari/src/cpu/events.h 2019/04/09 08:55:30 1.1.1.3 @@ -1,3 +1,6 @@ +#ifndef EVENTS_H +#define EVENTS_H + /* * UAE - The Un*x Amiga Emulator * @@ -9,28 +12,38 @@ * Copyright 1995-1998 Bernd Schmidt */ -#ifndef HATARI_EVENT_H -#define HATARI_EVENT_H - #undef EVENT_DEBUG -#define do_cycles do_cycles_slow +#include "rpt.h" +extern frame_time_t vsyncmintime, vsyncmaxtime, vsyncwaittime; +extern int vsynctimebase, syncbase; extern void reset_frame_rate_hack (void); -extern int rpt_available; +extern unsigned long int vsync_cycles; +extern unsigned long start_cycles; +extern int event2_count; +extern bool event_wait; extern void compute_vsynctime (void); extern void init_eventtab (void); -extern void do_cycles_ce (long cycles); -extern void do_cycles_ce020 (int clocks); -extern void do_cycles_ce020_mem (int clocks); -extern void do_cycles_ce000 (int clocks); -extern int is_cycle_ce (void); -extern int current_hpos (void); +extern void do_cycles_ce (unsigned long cycles); +////extern void do_cycles_ce_internal (unsigned long cycles); +#ifndef WINUAE_FOR_HATARI +extern void do_cycles_ce020 (unsigned long cycles); +///extern void do_cycles_ce020_internal (unsigned long cycles); +#else +/* [NP] avoid conflict with do_cycles_ce020( int ) in cpu_prefetch.h */ +extern void do_cycles_ce020_long (unsigned long cycles); +///extern void do_cycles_ce020_internal_long (unsigned long cycles); +#endif +extern void events_schedule (void); +extern void do_cycles_slow (unsigned long cycles_to_add); +extern void do_cycles_fast (unsigned long cycles_to_add); -static void events_schedule (void); +extern int is_cycle_ce (void); -extern unsigned long currcycle, nextevent, is_lastline; +extern unsigned long currcycle, nextevent; +extern int is_syncline, is_syncline_end; typedef void (*evfunc)(void); typedef void (*evfunc2)(uae_u32); @@ -38,21 +51,21 @@ typedef unsigned long int evt; struct ev { - int active; + bool active; evt evtime, oldcycles; evfunc handler; }; struct ev2 { - int active; + bool active; evt evtime; uae_u32 data; evfunc2 handler; }; enum { - ev_hsync, ev_audio, ev_cia, ev_misc, + ev_cia, ev_audio, ev_misc, ev_hsync, ev_max }; @@ -61,26 +74,60 @@ enum { ev2_max = 12 }; +extern int pissoff_value; +extern signed long pissoff; + +#define countdown pissoff +#define do_cycles do_cycles_slow + extern struct ev eventtab[ev_max]; extern struct ev2 eventtab2[ev2_max]; -extern void event2_newevent (int, evt, uae_u32); -extern void event2_newevent2 (evt, uae_u32, evfunc2); -extern void event2_remevent (int); +extern volatile bool vblank_found_chipset; +extern volatile bool vblank_found_rtg; +extern int hpos_offset; +extern int maxhpos; -/*#if 0 +STATIC_INLINE void cycles_do_special (void) +{ #ifdef JIT -#include "events_jit.h" -#else -#include "events_normal.h" + if (currprefs.cachesize) { + if (pissoff >= 0) + pissoff = -1; + } else #endif -#else -#include "events_jit.h" + { + pissoff = 0; + } +} + +STATIC_INLINE void do_extra_cycles (unsigned long cycles_to_add) +{ + pissoff -= cycles_to_add; +} + +STATIC_INLINE unsigned long int get_cycles (void) +{ + return currcycle; +} + +STATIC_INLINE void set_cycles (unsigned long int x) +{ + currcycle = x; + eventtab[ev_hsync].oldcycles = x; +#ifdef EVT_DEBUG + if (currcycle & (CYCLE_UNIT - 1)) + write_log (_T("%x\n"), currcycle); #endif -*/ +} -#include "events_normal.h" +STATIC_INLINE int current_hpos_safe (void) +{ + int hp = (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT; + return hp; +} +extern int current_hpos(void); STATIC_INLINE bool cycles_in_range (unsigned long endcycles) { @@ -88,4 +135,31 @@ STATIC_INLINE bool cycles_in_range (unsi return (signed long)endcycles - c > 0; } -#endif //HATARI_EVENT_H +extern void MISC_handler (void); +extern void event2_newevent_xx (int no, evt t, uae_u32 data, evfunc2 func); + +STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func) +{ + if (((int)t) <= 0) { + func (data); + return; + } + event2_newevent_xx (no, t * CYCLE_UNIT, data, func); +} + +STATIC_INLINE void event2_newevent (int no, evt t, uae_u32 data) +{ + event2_newevent_x (no, t, data, eventtab2[no].handler); +} +STATIC_INLINE void event2_newevent2 (evt t, uae_u32 data, evfunc2 func) +{ + event2_newevent_x (-1, t, data, func); +} + +STATIC_INLINE void event2_remevent (int no) +{ + eventtab2[no].active = 0; +} + + +#endif