Mercurial > sdl-ios-xcode
annotate src/timer/nds/SDL_systimer.c @ 4093:7ea10b80eda3 SDL-1.2
Fixed bugs #471 and #480
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 21 Aug 2007 06:52:33 +0000 |
parents | 8582c6a5ca16 |
children | a1b03ba2fcd0 |
rev | line source |
---|---|
3976
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_thread.h" |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "SDL_timer.h" |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL_error.h" |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include "../SDL_timer_c.h" |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include <nds.h> |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #define timers2ms(tlow,thigh)(tlow | (thigh<<16)) >> 5 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 void SDL_StartTicks(void) |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 { |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 TIMER0_DATA=0; |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 TIMER1_DATA=0; |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 TIMER0_CR=TIMER_ENABLE|TIMER_DIV_1024; |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 TIMER1_CR=TIMER_ENABLE|TIMER_CASCADE; |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 } |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 Uint32 SDL_GetTicks(void) |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 { |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 return timers2ms(TIMER0_DATA, TIMER1_DATA); |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 } |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 void SDL_Delay(Uint32 ms) |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 { |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 Uint32 now; |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 now=timers2ms(TIMER0_DATA, TIMER1_DATA); |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 while((Uint32)timers2ms(TIMER0_DATA, TIMER1_DATA)<now+ms); |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 } |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 /* This is only called if the event thread is not running */ |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 int SDL_SYS_TimerInit(void) |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 { |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 return 0; |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 } |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 void SDL_SYS_TimerQuit(void) |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 { |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 } |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 int SDL_SYS_StartTimer(void) |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 { |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 SDL_SetError("Timers not implemented on NDS"); |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 return -1; |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 } |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 void SDL_SYS_StopTimer(void) |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 { |
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 } |