comparison src/timer/mint/SDL_systimer.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
52 static Uint32 start; 52 static Uint32 start;
53 static SDL_bool supervisor; 53 static SDL_bool supervisor;
54 static int mint_present; /* can we use Syield() ? */ 54 static int mint_present; /* can we use Syield() ? */
55 55
56 void 56 void
57 SDL_StartTicks (void) 57 SDL_StartTicks(void)
58 { 58 {
59 void *oldpile; 59 void *oldpile;
60 unsigned long dummy; 60 unsigned long dummy;
61 61
62 /* Set first ticks value */ 62 /* Set first ticks value */
63 oldpile = (void *) Super (0); 63 oldpile = (void *) Super(0);
64 start = *((volatile long *) _hz_200); 64 start = *((volatile long *) _hz_200);
65 Super (oldpile); 65 Super(oldpile);
66 66
67 start *= 5; /* One _hz_200 tic is 5ms */ 67 start *= 5; /* One _hz_200 tic is 5ms */
68 68
69 mint_present = (Getcookie (C_MiNT, &dummy) == C_FOUND); 69 mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
70 } 70 }
71 71
72 Uint32 72 Uint32
73 SDL_GetTicks (void) 73 SDL_GetTicks(void)
74 { 74 {
75 Uint32 now; 75 Uint32 now;
76 void *oldpile = NULL; 76 void *oldpile = NULL;
77 77
78 /* Check if we are in supervisor mode 78 /* Check if we are in supervisor mode
79 (this is the case when called from SDL_ThreadedTimerCheck, 79 (this is the case when called from SDL_ThreadedTimerCheck,
80 which is called from RunTimer, running in the vbl vector) 80 which is called from RunTimer, running in the vbl vector)
81 */ 81 */
82 if (!supervisor) { 82 if (!supervisor) {
83 oldpile = (void *) Super (0); 83 oldpile = (void *) Super(0);
84 } 84 }
85 85
86 now = *((volatile long *) _hz_200); 86 now = *((volatile long *) _hz_200);
87 87
88 if (!supervisor) { 88 if (!supervisor) {
89 Super (oldpile); 89 Super(oldpile);
90 } 90 }
91 91
92 return ((now * 5) - start); 92 return ((now * 5) - start);
93 } 93 }
94 94
95 void 95 void
96 SDL_Delay (Uint32 ms) 96 SDL_Delay(Uint32 ms)
97 { 97 {
98 Uint32 now; 98 Uint32 now;
99 99
100 now = SDL_GetTicks (); 100 now = SDL_GetTicks();
101 while ((SDL_GetTicks () - now) < ms) { 101 while ((SDL_GetTicks() - now) < ms) {
102 if (mint_present) { 102 if (mint_present) {
103 Syield (); 103 Syield();
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 /* Data to handle a single periodic alarm */ 108 /* Data to handle a single periodic alarm */
109 static SDL_bool timer_installed = SDL_FALSE; 109 static SDL_bool timer_installed = SDL_FALSE;
110 110
111 static void 111 static void
112 RunTimer (void) 112 RunTimer(void)
113 { 113 {
114 supervisor = SDL_TRUE; 114 supervisor = SDL_TRUE;
115 SDL_ThreadedTimerCheck (); 115 SDL_ThreadedTimerCheck();
116 supervisor = SDL_FALSE; 116 supervisor = SDL_FALSE;
117 } 117 }
118 118
119 /* This is only called if the event thread is not running */ 119 /* This is only called if the event thread is not running */
120 int 120 int
121 SDL_SYS_TimerInit (void) 121 SDL_SYS_TimerInit(void)
122 { 122 {
123 void *oldpile; 123 void *oldpile;
124 124
125 supervisor = SDL_FALSE; 125 supervisor = SDL_FALSE;
126 126
127 /* Install RunTimer in vbl vector */ 127 /* Install RunTimer in vbl vector */
128 oldpile = (void *) Super (0); 128 oldpile = (void *) Super(0);
129 timer_installed = !SDL_AtariVblInstall (RunTimer); 129 timer_installed = !SDL_AtariVblInstall(RunTimer);
130 Super (oldpile); 130 Super(oldpile);
131 131
132 if (!timer_installed) { 132 if (!timer_installed) {
133 return (-1); 133 return (-1);
134 } 134 }
135 return (SDL_SetTimerThreaded (0)); 135 return (SDL_SetTimerThreaded(0));
136 } 136 }
137 137
138 void 138 void
139 SDL_SYS_TimerQuit (void) 139 SDL_SYS_TimerQuit(void)
140 { 140 {
141 void *oldpile; 141 void *oldpile;
142 142
143 if (timer_installed) { 143 if (timer_installed) {
144 /* Uninstall RunTimer vbl vector */ 144 /* Uninstall RunTimer vbl vector */
145 oldpile = (void *) Super (0); 145 oldpile = (void *) Super(0);
146 SDL_AtariVblUninstall (RunTimer); 146 SDL_AtariVblUninstall(RunTimer);
147 Super (oldpile); 147 Super(oldpile);
148 timer_installed = SDL_FALSE; 148 timer_installed = SDL_FALSE;
149 } 149 }
150 } 150 }
151 151
152 int 152 int
153 SDL_SYS_StartTimer (void) 153 SDL_SYS_StartTimer(void)
154 { 154 {
155 SDL_SetError ("Internal logic error: MiNT uses vbl timer"); 155 SDL_SetError("Internal logic error: MiNT uses vbl timer");
156 return (-1); 156 return (-1);
157 } 157 }
158 158
159 void 159 void
160 SDL_SYS_StopTimer (void) 160 SDL_SYS_StopTimer(void)
161 { 161 {
162 return; 162 return;
163 } 163 }
164 164
165 #endif /* SDL_TIMER_MINT */ 165 #endif /* SDL_TIMER_MINT */