Timers work now. gsoc2008_nds
authorDarren Alton <dalton@stevens.edu>
Mon, 18 Aug 2008 07:29:52 +0000
branchgsoc2008_nds
changeset 26960b395a60deff
parent 2695 c04a266c277a
child 2697 c9121b04cffa
Timers work now.
Makefile.ds
include/SDL_config_nintendods.h
src/timer/nds/SDL_systimer.c
src/video/nds/SDL_ndsrender.c
test/nds-test-progs/general/source/main.c
     1.1 --- a/Makefile.ds	Sun Aug 17 09:50:28 2008 +0000
     1.2 +++ b/Makefile.ds	Mon Aug 18 07:29:52 2008 +0000
     1.3 @@ -67,7 +67,7 @@
     1.4  src/thread/nds/SDL_sysmutex.c \
     1.5  src/thread/nds/SDL_syssem.c \
     1.6  src/thread/nds/SDL_systhread.c \
     1.7 -src/timer/dummy/SDL_systimer.c \
     1.8 +src/timer/nds/SDL_systimer.c \
     1.9  src/timer/SDL_timer.c \
    1.10  src/video/nds/SDL_ndsevents.c \
    1.11  src/video/nds/SDL_ndsrender.c \
     2.1 --- a/include/SDL_config_nintendods.h	Sun Aug 17 09:50:28 2008 +0000
     2.2 +++ b/include/SDL_config_nintendods.h	Mon Aug 18 07:29:52 2008 +0000
     2.3 @@ -110,7 +110,7 @@
     2.4  #define SDL_THREADS_DISABLED	1
     2.5  
     2.6  /* Enable various timer systems */
     2.7 -#define SDL_TIMERS_DISABLED	1
     2.8 +#define SDL_TIMER_NDS	1
     2.9  
    2.10  /* Enable various video drivers */
    2.11  #define SDL_VIDEO_DRIVER_NDS	1
     3.1 --- a/src/timer/nds/SDL_systimer.c	Sun Aug 17 09:50:28 2008 +0000
     3.2 +++ b/src/timer/nds/SDL_systimer.c	Mon Aug 18 07:29:52 2008 +0000
     3.3 @@ -28,7 +28,10 @@
     3.4  
     3.5  #include "SDL_timer.h"
     3.6  #include "../SDL_timer_c.h"
     3.7 +#include "../SDL_systimer.h"
     3.8  
     3.9 +/* Data to handle a single periodic alarm */
    3.10 +static int timer_alive = 0;
    3.11  static Uint32 timer_ticks;
    3.12  
    3.13  void
    3.14 @@ -57,10 +60,6 @@
    3.15      }
    3.16  }
    3.17  
    3.18 -/* Data to handle a single periodic alarm */
    3.19 -static int timer_alive = 0;
    3.20 -static int timer_ticks = 0;
    3.21 -
    3.22  static int
    3.23  RunTimer(void *unused)
    3.24  {
    3.25 @@ -72,8 +71,8 @@
    3.26      return (0);
    3.27  }
    3.28  
    3.29 -void NDS_TimerInterrupt() {
    3.30 -    printf("timer irq\n");
    3.31 +void NDS_TimerInterrupt(void) {
    3.32 +	timer_ticks++;
    3.33  }
    3.34  
    3.35  /* This is only called if the event thread is not running */
    3.36 @@ -82,9 +81,10 @@
    3.37  {
    3.38      timer_alive = 1;
    3.39      timer_ticks = 0;
    3.40 -    TIMER_CR(0) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
    3.41 -    TIMER_DATA(0) = TIMER_FREQ_1024(1000);
    3.42 -    irqSet(IRQ_TIMER1, NDS_TimerInterrupt);
    3.43 +    TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
    3.44 +    TIMER_DATA(3) = TIMER_FREQ_1024(1000);
    3.45 +    irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
    3.46 +    irqEnable(IRQ_TIMER3);
    3.47      return 0;
    3.48  }
    3.49  
    3.50 @@ -92,22 +92,23 @@
    3.51  SDL_SYS_TimerQuit(void)
    3.52  {
    3.53      if (timer_alive) {
    3.54 -        TIMER_CR(0) = 0;
    3.55 +        TIMER_CR(3) = 0;
    3.56      }
    3.57      timer_alive = 0;
    3.58 +    irqDisable(IRQ_TIMER3);
    3.59  }
    3.60  
    3.61  int
    3.62  SDL_SYS_StartTimer(void)
    3.63  {
    3.64 -    TIMER_CR(0) |= TIMER_ENABLE;
    3.65 +    TIMER_CR(3) |= TIMER_ENABLE;
    3.66      return 0;
    3.67  }
    3.68  
    3.69  void
    3.70  SDL_SYS_StopTimer(void)
    3.71  {
    3.72 -    TIMER_CR(0) &= ~TIMER_ENABLE;
    3.73 +    TIMER_CR(3) &= ~TIMER_ENABLE;
    3.74      return;
    3.75  }
    3.76  
     4.1 --- a/src/video/nds/SDL_ndsrender.c	Sun Aug 17 09:50:28 2008 +0000
     4.2 +++ b/src/video/nds/SDL_ndsrender.c	Mon Aug 18 07:29:52 2008 +0000
     4.3 @@ -656,8 +656,7 @@
     4.4                       SDL_Color * colors, int firstcolor, int ncolors)
     4.5  {
     4.6      NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
     4.7 -    TRACE("+NDS_GetTexturePalette\n");
     4.8 -    TRACE("-NDS_GetTexturePalette\n");
     4.9 +    TRACE("!NDS_GetTexturePalette\n");
    4.10      return 0;
    4.11  }
    4.12  
     5.1 --- a/test/nds-test-progs/general/source/main.c	Sun Aug 17 09:50:28 2008 +0000
     5.2 +++ b/test/nds-test-progs/general/source/main.c	Mon Aug 18 07:29:52 2008 +0000
     5.3 @@ -32,7 +32,7 @@
     5.4  	SDL_Surface *screen;
     5.5  	SDL_Joystick *stick;
     5.6  	SDL_Event event;
     5.7 -	SDL_Rect rect = {8,8,240,176};
     5.8 +	SDL_Rect rect = {0,0,256,192};
     5.9  	int i;
    5.10  
    5.11  	consoleDemoInit(); puts("Hello world!  Initializing FAT...");
    5.12 @@ -68,23 +68,14 @@
    5.13  	while(SDL_PollEvent(&event))
    5.14  	switch(event.type) {
    5.15  		case SDL_JOYBUTTONDOWN:
    5.16 -		switch(event.jbutton.which) {
    5.17 -			case 0:
    5.18 -			SDL_FillRect(screen, &rect, RGB15(31,0,0)|0x8000);
    5.19 -			break;
    5.20 -			case 1:
    5.21 -			SDL_FillRect(screen, &rect, RGB15(0,31,0)|0x8000);
    5.22 -			break;
    5.23 -			case 2:
    5.24 -			SDL_FillRect(screen, &rect, RGB15(0,0,31)|0x8000);
    5.25 -			break;
    5.26 -			case 3:
    5.27 -			SDL_FillRect(screen, &rect, RGB15(0,0,0)|0x8000);
    5.28 -			break;
    5.29 -			default: break;
    5.30 -		}
    5.31 -		printf("joy_%d, at %d\n", event.jbutton.which, SDL_GetTicks());
    5.32 -		SDL_Flip(screen);
    5.33 +			SDL_FillRect(screen, &rect, (u16)rand()|0x8000);
    5.34 +			SDL_Flip(screen);
    5.35 +			if(rect.w > 8) {
    5.36 +				rect.x += 4; rect.y += 3;
    5.37 +				rect.w -= 8; rect.h -= 6;
    5.38 +			}
    5.39 +			printf("button %d pressed at %d ticks\n",
    5.40 +			       event.jbutton.which, SDL_GetTicks());
    5.41  		break;
    5.42  		case SDL_QUIT: SDL_Quit(); return 0;
    5.43  		default: break;