comparison src/timer/mint/SDL_systimer.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents 92947e3a18db
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
49 #include "SDL_vbltimer_s.h" 49 #include "SDL_vbltimer_s.h"
50 50
51 /* The first ticks value of the application */ 51 /* The first ticks value of the application */
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 SDL_StartTicks(void) 56 void
57 SDL_StartTicks (void)
57 { 58 {
58 void *oldpile; 59 void *oldpile;
59 unsigned long dummy; 60 unsigned long dummy;
60 61
61 /* Set first ticks value */ 62 /* Set first ticks value */
62 oldpile=(void *)Super(0); 63 oldpile = (void *) Super (0);
63 start=*((volatile long *)_hz_200); 64 start = *((volatile long *) _hz_200);
64 Super(oldpile); 65 Super (oldpile);
65 66
66 start *= 5; /* One _hz_200 tic is 5ms */ 67 start *= 5; /* One _hz_200 tic is 5ms */
67 68
68 mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); 69 mint_present = (Getcookie (C_MiNT, &dummy) == C_FOUND);
69 } 70 }
70 71
71 Uint32 SDL_GetTicks (void) 72 Uint32
73 SDL_GetTicks (void)
72 { 74 {
73 Uint32 now; 75 Uint32 now;
74 void *oldpile=NULL; 76 void *oldpile = NULL;
75 77
76 /* Check if we are in supervisor mode 78 /* Check if we are in supervisor mode
77 (this is the case when called from SDL_ThreadedTimerCheck, 79 (this is the case when called from SDL_ThreadedTimerCheck,
78 which is called from RunTimer, running in the vbl vector) 80 which is called from RunTimer, running in the vbl vector)
79 */ 81 */
80 if (!supervisor) { 82 if (!supervisor) {
81 oldpile=(void *)Super(0); 83 oldpile = (void *) Super (0);
82 } 84 }
83 85
84 now=*((volatile long *)_hz_200); 86 now = *((volatile long *) _hz_200);
85 87
86 if (!supervisor) { 88 if (!supervisor) {
87 Super(oldpile); 89 Super (oldpile);
88 } 90 }
89 91
90 return((now*5)-start); 92 return ((now * 5) - start);
91 } 93 }
92 94
93 void SDL_Delay (Uint32 ms) 95 void
96 SDL_Delay (Uint32 ms)
94 { 97 {
95 Uint32 now; 98 Uint32 now;
96 99
97 now = SDL_GetTicks(); 100 now = SDL_GetTicks ();
98 while ((SDL_GetTicks()-now)<ms){ 101 while ((SDL_GetTicks () - now) < ms) {
99 if (mint_present) { 102 if (mint_present) {
100 Syield(); 103 Syield ();
101 } 104 }
102 } 105 }
103 } 106 }
104 107
105 /* Data to handle a single periodic alarm */ 108 /* Data to handle a single periodic alarm */
106 static SDL_bool timer_installed=SDL_FALSE; 109 static SDL_bool timer_installed = SDL_FALSE;
107 110
108 static void RunTimer(void) 111 static void
112 RunTimer (void)
109 { 113 {
110 supervisor=SDL_TRUE; 114 supervisor = SDL_TRUE;
111 SDL_ThreadedTimerCheck(); 115 SDL_ThreadedTimerCheck ();
112 supervisor=SDL_FALSE; 116 supervisor = SDL_FALSE;
113 } 117 }
114 118
115 /* This is only called if the event thread is not running */ 119 /* This is only called if the event thread is not running */
116 int SDL_SYS_TimerInit(void) 120 int
121 SDL_SYS_TimerInit (void)
117 { 122 {
118 void *oldpile; 123 void *oldpile;
119 124
120 supervisor=SDL_FALSE; 125 supervisor = SDL_FALSE;
121 126
122 /* Install RunTimer in vbl vector */ 127 /* Install RunTimer in vbl vector */
123 oldpile=(void *)Super(0); 128 oldpile = (void *) Super (0);
124 timer_installed = !SDL_AtariVblInstall(RunTimer); 129 timer_installed = !SDL_AtariVblInstall (RunTimer);
125 Super(oldpile); 130 Super (oldpile);
126 131
127 if (!timer_installed) { 132 if (!timer_installed) {
128 return(-1); 133 return (-1);
129 } 134 }
130 return(SDL_SetTimerThreaded(0)); 135 return (SDL_SetTimerThreaded (0));
131 } 136 }
132 137
133 void SDL_SYS_TimerQuit(void) 138 void
139 SDL_SYS_TimerQuit (void)
134 { 140 {
135 void *oldpile; 141 void *oldpile;
136 142
137 if (timer_installed) { 143 if (timer_installed) {
138 /* Uninstall RunTimer vbl vector */ 144 /* Uninstall RunTimer vbl vector */
139 oldpile=(void *)Super(0); 145 oldpile = (void *) Super (0);
140 SDL_AtariVblUninstall(RunTimer); 146 SDL_AtariVblUninstall (RunTimer);
141 Super(oldpile); 147 Super (oldpile);
142 timer_installed = SDL_FALSE; 148 timer_installed = SDL_FALSE;
143 } 149 }
144 } 150 }
145 151
146 int SDL_SYS_StartTimer(void) 152 int
153 SDL_SYS_StartTimer (void)
147 { 154 {
148 SDL_SetError("Internal logic error: MiNT uses vbl timer"); 155 SDL_SetError ("Internal logic error: MiNT uses vbl timer");
149 return(-1); 156 return (-1);
150 } 157 }
151 158
152 void SDL_SYS_StopTimer(void) 159 void
160 SDL_SYS_StopTimer (void)
153 { 161 {
154 return; 162 return;
155 } 163 }
156 164
157 #endif /* SDL_TIMER_MINT */ 165 #endif /* SDL_TIMER_MINT */
166 /* vi: set ts=4 sw=4 expandtab: */