|
|
1.1 root 1: /* Let's see whether hiding this away somewhere where the compiler can't
2: see it will cure it of its silly urge to mis-optimize the comparison */
3: extern long int diff32(frame_time_t x, frame_time_t y);
4: extern int pissoff_value;
5:
6: STATIC_INLINE void events_schedule (void)
7: {
8: int i;
9:
10: unsigned long int mintime = ~0L;
11: for (i = 0; i < ev_max; i++) {
12: if (eventtab[i].active) {
13: unsigned long int eventtime = eventtab[i].evtime - currcycle;
14: #ifdef EVENT_DEBUG
15: if (eventtime == 0) {
16: write_log ("event %d bug\n",i);
17: }
18: #endif
19: if (eventtime < mintime)
20: mintime = eventtime;
21: }
22: }
23: nextevent = currcycle + mintime;
24: }
25:
26: extern signed long pissoff;
27:
28: STATIC_INLINE void cycles_do_special (void)
29: {
30: #ifdef JIT
31: if (currprefs.cachesize) {
32: if (pissoff >= 0)
33: pissoff = -1;
34: } else
35: #endif
36: {
37: pissoff = 0;
38: }
39: }
40:
41: STATIC_INLINE void do_extra_cycles (unsigned long cycles_to_add)
42: {
43: pissoff -= cycles_to_add;
44: }
45:
46: STATIC_INLINE unsigned long int get_cycles (void)
47: {
48: return currcycle;
49: }
50:
51: STATIC_INLINE void set_cycles (unsigned long int x)
52: {
53: currcycle = x;
54: #ifdef EVT_DEBUG
55: if (currcycle & (CYCLE_UNIT - 1))
56: write_log (L"%x\n", currcycle);
57: #endif
58: }
59:
60: STATIC_INLINE void do_cycles_slow (unsigned long cycles_to_add)
61: {
62: if ((pissoff -= cycles_to_add) >= 0)
63: return;
64:
65: cycles_to_add = -pissoff;
66: pissoff = 0;
67:
68: if (is_lastline && eventtab[ev_hsync].evtime - currcycle <= cycles_to_add) {
69: int rpt = read_processor_time ();
70: int v = rpt - vsyncmintime;
71: if (v > (int)syncbase || v < -((int)syncbase))
72: vsyncmintime = rpt;
73: if (v < 0) {
74: pissoff = pissoff_value * CYCLE_UNIT;
75: return;
76: }
77: }
78: while ((nextevent - currcycle) <= cycles_to_add) {
79: int i;
80: cycles_to_add -= (nextevent - currcycle);
81: currcycle = nextevent;
82:
83: for (i = 0; i < ev_max; i++) {
84: if (eventtab[i].active && eventtab[i].evtime == currcycle) {
85: (*eventtab[i].handler)();
86: }
87: }
88: events_schedule ();
89: }
90: currcycle += cycles_to_add;
91: #ifdef EVT_DEBUG
92: if (currcycle & (CYCLE_UNIT - 1))
93: write_log (L"%x\n", currcycle);
94: #endif
95: }
96:
97: #define do_cycles do_cycles_slow
98: #define countdown pissoff
99:
100: /* This is a special-case function. Normally, all events should lie in the
101: future; they should only ever be active at the current cycle during
102: do_cycles. However, a snapshot is saved during do_cycles, and so when
103: restoring it, we may have other events pending. */
104:
105: STATIC_INLINE void handle_active_events (void)
106: {
107: int i;
108: for (i = 0; i < ev_max; i++) {
109: if (eventtab[i].active && eventtab[i].evtime == currcycle) {
110: (*eventtab[i].handler)();
111: }
112: }
113: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.