comparison src/timer/nds/SDL_systimer.c @ 5275:7aba0406c273

Frank Zago to sdl The following patch fixes some of the bitrot for the Nintendo DS port. The support is still basic at the moment, but it allows to run the "general" test under the current head of tree (parent: 5269:11bd1585efb5 tip). Most of the patch is mine, but I integrated a couple changes that John Magnotti posted on Feb 1st.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 12 Feb 2011 11:36:56 -0800
parents b530ef003506
children
comparison
equal deleted inserted replaced
5274:11bd1585efb5 5275:7aba0406c273
26 #include <nds.h> 26 #include <nds.h>
27 #include <nds/timers.h> 27 #include <nds/timers.h>
28 28
29 #include "SDL_timer.h" 29 #include "SDL_timer.h"
30 30
31 31 /* Will wrap afetr 49 days. Shouldn't be an issue. */
32 static volatile Uint32 timer_ticks; 32 static volatile Uint32 timer_ticks;
33 33
34 static void 34 static void
35 NDS_TimerInterrupt(void) 35 NDS_TimerInterrupt(void)
36 { 36 {
40 void 40 void
41 SDL_StartTicks(void) 41 SDL_StartTicks(void)
42 { 42 {
43 timer_ticks = 0; 43 timer_ticks = 0;
44 44
45 TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ; 45 /* Set timer 2 to fire every ms. */
46 TIMER_DATA(3) = TIMER_FREQ_1024(1000); 46 timerStart(2, ClockDivider_1024, TIMER_FREQ_1024(1000), NDS_TimerInterrupt);
47 irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
48 irqEnable(IRQ_TIMER3);
49 } 47 }
50 48
51 Uint32 49 Uint32
52 SDL_GetTicks(void) 50 SDL_GetTicks(void)
53 { 51 {
56 54
57 void 55 void
58 SDL_Delay(Uint32 ms) 56 SDL_Delay(Uint32 ms)
59 { 57 {
60 Uint32 start = SDL_GetTicks(); 58 Uint32 start = SDL_GetTicks();
61 while (timer_alive) { 59 while (1) {
62 if ((SDL_GetTicks() - start) >= ms) 60 if ((SDL_GetTicks() - start) >= ms)
63 break; 61 break;
64 } 62 }
65 } 63 }
66 64