|
|
1.1 root 1: /*
2: * UAE - The Un*x Amiga Emulator
3: *
4: * Events
5: * These are best for low-frequency events. Having too many of them,
6: * or using them for events that occur too frequently, can cause massive
7: * slowdown.
8: *
9: * Copyright 1995-1998 Bernd Schmidt
10: */
11:
1.1.1.4 root 12: #ifndef UAE_EVENTS_H
13: #define UAE_EVENTS_H
14:
15: #include "uae/types.h"
16:
1.1 root 17: #undef EVENT_DEBUG
18:
1.1.1.4 root 19: #include "machdep/rpt.h"
1.1 root 20:
1.1.1.3 root 21: extern frame_time_t vsyncmintime, vsyncmaxtime, vsyncwaittime;
22: extern int vsynctimebase, syncbase;
1.1 root 23: extern void reset_frame_rate_hack (void);
1.1.1.3 root 24: extern unsigned long int vsync_cycles;
25: extern unsigned long start_cycles;
26: extern int event2_count;
27: extern bool event_wait;
1.1 root 28:
29: extern void compute_vsynctime (void);
30: extern void init_eventtab (void);
1.1.1.3 root 31: extern void do_cycles_ce (unsigned long cycles);
32: ////extern void do_cycles_ce_internal (unsigned long cycles);
1.1.1.5 root 33: #ifdef WINUAE_FOR_HATARI
34: extern void do_cycles_ce_hatari_blitter (unsigned long cycles);
35: #endif
1.1.1.3 root 36: #ifndef WINUAE_FOR_HATARI
37: extern void do_cycles_ce020 (unsigned long cycles);
38: ///extern void do_cycles_ce020_internal (unsigned long cycles);
39: #else
40: /* [NP] avoid conflict with do_cycles_ce020( int ) in cpu_prefetch.h */
41: extern void do_cycles_ce020_long (unsigned long cycles);
42: ///extern void do_cycles_ce020_internal_long (unsigned long cycles);
43: #endif
44: extern void events_schedule (void);
45: extern void do_cycles_slow (unsigned long cycles_to_add);
1.1 root 46:
1.1.1.3 root 47: extern int is_cycle_ce (void);
1.1 root 48:
1.1.1.3 root 49: extern unsigned long currcycle, nextevent;
50: extern int is_syncline, is_syncline_end;
1.1 root 51: typedef void (*evfunc)(void);
52: typedef void (*evfunc2)(uae_u32);
53:
54: typedef unsigned long int evt;
55:
56: struct ev
57: {
1.1.1.3 root 58: bool active;
1.1 root 59: evt evtime, oldcycles;
60: evfunc handler;
61: };
62:
63: struct ev2
64: {
1.1.1.3 root 65: bool active;
1.1 root 66: evt evtime;
67: uae_u32 data;
68: evfunc2 handler;
69: };
70:
71: enum {
1.1.1.3 root 72: ev_cia, ev_audio, ev_misc, ev_hsync,
1.1 root 73: ev_max
74: };
75:
76: enum {
77: ev2_blitter, ev2_disk, ev2_misc,
78: ev2_max = 12
79: };
80:
1.1.1.3 root 81: #define do_cycles do_cycles_slow
82:
1.1 root 83: extern struct ev eventtab[ev_max];
84: extern struct ev2 eventtab2[ev2_max];
85:
1.1.1.3 root 86: extern int hpos_offset;
87: extern int maxhpos;
1.1 root 88:
1.1.1.3 root 89: STATIC_INLINE void cycles_do_special (void)
90: {
1.1.1.4 root 91: /* Currently unused in Hatari */
1.1.1.3 root 92: }
93:
94: STATIC_INLINE void do_extra_cycles (unsigned long cycles_to_add)
95: {
1.1.1.4 root 96: /* Currently unused in Hatari */
1.1.1.3 root 97: }
98:
99: STATIC_INLINE unsigned long int get_cycles (void)
100: {
101: return currcycle;
102: }
103:
104: STATIC_INLINE void set_cycles (unsigned long int x)
105: {
106: currcycle = x;
107: eventtab[ev_hsync].oldcycles = x;
108: #ifdef EVT_DEBUG
109: if (currcycle & (CYCLE_UNIT - 1))
110: write_log (_T("%x\n"), currcycle);
1.1 root 111: #endif
1.1.1.3 root 112: }
1.1 root 113:
1.1.1.3 root 114: STATIC_INLINE int current_hpos_safe (void)
115: {
116: int hp = (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
117: return hp;
118: }
1.1 root 119:
1.1.1.3 root 120: extern int current_hpos(void);
1.1 root 121:
122: STATIC_INLINE bool cycles_in_range (unsigned long endcycles)
123: {
124: signed long c = get_cycles ();
125: return (signed long)endcycles - c > 0;
126: }
127:
1.1.1.3 root 128: extern void MISC_handler (void);
129: extern void event2_newevent_xx (int no, evt t, uae_u32 data, evfunc2 func);
1.1.1.4 root 130: extern void event2_newevent_x_replace(evt t, uae_u32 data, evfunc2 func);
1.1.1.3 root 131:
132: STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func)
133: {
134: if (((int)t) <= 0) {
135: func (data);
136: return;
137: }
138: event2_newevent_xx (no, t * CYCLE_UNIT, data, func);
139: }
140:
141: STATIC_INLINE void event2_newevent (int no, evt t, uae_u32 data)
142: {
143: event2_newevent_x (no, t, data, eventtab2[no].handler);
144: }
145: STATIC_INLINE void event2_newevent2 (evt t, uae_u32 data, evfunc2 func)
146: {
147: event2_newevent_x (-1, t, data, func);
148: }
149:
150: STATIC_INLINE void event2_remevent (int no)
151: {
152: eventtab2[no].active = 0;
153: }
154:
1.1.1.4 root 155: #endif /* UAE_EVENTS_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.