|
|
1.1 root 1:
2: STATIC_INLINE void cycles_do_special (void)
3: {
4: }
5: STATIC_INLINE void set_cycles (int c)
6: {
7: }
8:
9: STATIC_INLINE void events_schedule (void)
10: {
11: int i;
12:
13: unsigned long int mintime = ~0L;
14: for (i = 0; i < ev_max; i++) {
15: if (eventtab[i].active) {
16: unsigned long int eventtime = eventtab[i].evtime - currcycle;
17: if (eventtime < mintime)
18: mintime = eventtime;
19: }
20: }
21: nextevent = currcycle + mintime;
22: }
23:
24: STATIC_INLINE void do_cycles_slow (unsigned long cycles_to_add)
25: {
1.1.1.2 ! root 26: /* Laurent: not needed, as hatari has it's own events management.
1.1 root 27: if (is_lastline && eventtab[ev_hsync].evtime - currcycle <= cycles_to_add
28: && (long int)(read_processor_time () - vsyncmintime) < 0)
29: return;
30:
31: while ((nextevent - currcycle) <= cycles_to_add) {
32: int i;
33: cycles_to_add -= (nextevent - currcycle);
34: currcycle = nextevent;
35:
36: for (i = 0; i < ev_max; i++) {
37: if (eventtab[i].active && eventtab[i].evtime == currcycle) {
38: (*eventtab[i].handler)();
39: }
40: }
41: events_schedule();
42: }
1.1.1.2 ! root 43: */
1.1 root 44: currcycle += cycles_to_add;
45: }
46:
47: STATIC_INLINE void do_cycles_fast (void)
48: {
49: if (is_lastline && eventtab[ev_hsync].evtime - currcycle <= 1
50: && (long int)(read_processor_time () - vsyncmintime) < 0)
51: return;
52:
53: currcycle++;
54: if (nextevent == currcycle) {
55: int i;
56:
57: for (i = 0; i < ev_max; i++) {
58: if (eventtab[i].active && eventtab[i].evtime == currcycle) {
59: (*eventtab[i].handler) ();
60: }
61: }
62: events_schedule();
63: }
64:
65: }
66:
67: /* This is a special-case function. Normally, all events should lie in the
68: future; they should only ever be active at the current cycle during
69: do_cycles. However, a snapshot is saved during do_cycles, and so when
70: restoring it, we may have other events pending. */
71: STATIC_INLINE void handle_active_events (void)
72: {
73: int i;
74: for (i = 0; i < ev_max; i++) {
75: if (eventtab[i].active && eventtab[i].evtime == currcycle) {
76: (*eventtab[i].handler)();
77: }
78: }
79: }
80:
81: STATIC_INLINE unsigned long get_cycles (void)
82: {
83: return currcycle;
84: }
85:
86: extern void init_eventtab (void);
87:
88: #if /* M68K_SPEED == 1 */ 0
89: #define do_cycles do_cycles_fast
90: #else
91: #define do_cycles do_cycles_slow
92: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.