Mercurial > sdl-ios-xcode
comparison src/timer/mint/SDL_systimer.c @ 1045:63b8e93a3a52
Release CPU when waiting
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Fri, 01 Apr 2005 15:19:26 +0000 |
parents | b8d311d90021 |
children | c9b51268668f |
comparison
equal
deleted
inserted
replaced
1044:d36ea7925763 | 1045:63b8e93a3a52 |
---|---|
37 #include <signal.h> | 37 #include <signal.h> |
38 #include <unistd.h> | 38 #include <unistd.h> |
39 #include <string.h> | 39 #include <string.h> |
40 #include <errno.h> | 40 #include <errno.h> |
41 | 41 |
42 #include <mint/cookie.h> | |
43 #include <mint/sysvars.h> | |
42 #include <mint/osbind.h> | 44 #include <mint/osbind.h> |
43 #include <mint/sysvars.h> | 45 #include <mint/mintbind.h> |
44 | 46 |
45 #include "SDL_error.h" | 47 #include "SDL_error.h" |
46 #include "SDL_timer.h" | 48 #include "SDL_timer.h" |
47 #include "SDL_timer_c.h" | 49 #include "SDL_timer_c.h" |
48 #include "SDL_thread.h" | 50 #include "SDL_thread.h" |
50 #include "mint/SDL_vbltimer_s.h" | 52 #include "mint/SDL_vbltimer_s.h" |
51 | 53 |
52 /* The first ticks value of the application */ | 54 /* The first ticks value of the application */ |
53 static Uint32 start; | 55 static Uint32 start; |
54 static SDL_bool supervisor; | 56 static SDL_bool supervisor; |
57 static int mint_present; /* can we use Syield() ? */ | |
55 | 58 |
56 void SDL_StartTicks(void) | 59 void SDL_StartTicks(void) |
57 { | 60 { |
58 void *oldpile; | 61 void *oldpile; |
62 unsigned long dummy; | |
59 | 63 |
60 /* Set first ticks value */ | 64 /* Set first ticks value */ |
61 oldpile=(void *)Super(0); | 65 oldpile=(void *)Super(0); |
62 start=*((volatile long *)_hz_200); | 66 start=*((volatile long *)_hz_200); |
63 Super(oldpile); | 67 Super(oldpile); |
64 | 68 |
65 start *= 5; /* One _hz_200 tic is 5ms */ | 69 start *= 5; /* One _hz_200 tic is 5ms */ |
70 | |
71 mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); | |
66 } | 72 } |
67 | 73 |
68 Uint32 SDL_GetTicks (void) | 74 Uint32 SDL_GetTicks (void) |
69 { | 75 { |
70 Uint32 now; | 76 Uint32 now; |
71 void *oldpile; | 77 void *oldpile=NULL; |
72 | 78 |
73 /* Check if we are in supervisor mode | 79 /* Check if we are in supervisor mode |
74 (this is the case when called from SDL_ThreadedTimerCheck, | 80 (this is the case when called from SDL_ThreadedTimerCheck, |
75 which is called from RunTimer, running in the vbl vector) | 81 which is called from RunTimer, running in the vbl vector) |
76 */ | 82 */ |
91 { | 97 { |
92 Uint32 now; | 98 Uint32 now; |
93 | 99 |
94 now = SDL_GetTicks(); | 100 now = SDL_GetTicks(); |
95 while ((SDL_GetTicks()-now)<ms){ | 101 while ((SDL_GetTicks()-now)<ms){ |
102 if (mint_present) { | |
103 Syield(); | |
104 } | |
96 } | 105 } |
97 } | 106 } |
98 | 107 |
99 /* Data to handle a single periodic alarm */ | 108 /* Data to handle a single periodic alarm */ |
100 static SDL_bool timer_installed=SDL_FALSE; | 109 static SDL_bool timer_installed=SDL_FALSE; |