changeset 2696:0b395a60deff gsoc2008_nds

Timers work now.
author Darren Alton <dalton@stevens.edu>
date Mon, 18 Aug 2008 07:29:52 +0000
parents c04a266c277a
children c9121b04cffa
files 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
diffstat 5 files changed, 25 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.ds	Sun Aug 17 09:50:28 2008 +0000
+++ b/Makefile.ds	Mon Aug 18 07:29:52 2008 +0000
@@ -67,7 +67,7 @@
 src/thread/nds/SDL_sysmutex.c \
 src/thread/nds/SDL_syssem.c \
 src/thread/nds/SDL_systhread.c \
-src/timer/dummy/SDL_systimer.c \
+src/timer/nds/SDL_systimer.c \
 src/timer/SDL_timer.c \
 src/video/nds/SDL_ndsevents.c \
 src/video/nds/SDL_ndsrender.c \
--- a/include/SDL_config_nintendods.h	Sun Aug 17 09:50:28 2008 +0000
+++ b/include/SDL_config_nintendods.h	Mon Aug 18 07:29:52 2008 +0000
@@ -110,7 +110,7 @@
 #define SDL_THREADS_DISABLED	1
 
 /* Enable various timer systems */
-#define SDL_TIMERS_DISABLED	1
+#define SDL_TIMER_NDS	1
 
 /* Enable various video drivers */
 #define SDL_VIDEO_DRIVER_NDS	1
--- a/src/timer/nds/SDL_systimer.c	Sun Aug 17 09:50:28 2008 +0000
+++ b/src/timer/nds/SDL_systimer.c	Mon Aug 18 07:29:52 2008 +0000
@@ -28,7 +28,10 @@
 
 #include "SDL_timer.h"
 #include "../SDL_timer_c.h"
+#include "../SDL_systimer.h"
 
+/* Data to handle a single periodic alarm */
+static int timer_alive = 0;
 static Uint32 timer_ticks;
 
 void
@@ -57,10 +60,6 @@
     }
 }
 
-/* Data to handle a single periodic alarm */
-static int timer_alive = 0;
-static int timer_ticks = 0;
-
 static int
 RunTimer(void *unused)
 {
@@ -72,8 +71,8 @@
     return (0);
 }
 
-void NDS_TimerInterrupt() {
-    printf("timer irq\n");
+void NDS_TimerInterrupt(void) {
+	timer_ticks++;
 }
 
 /* This is only called if the event thread is not running */
@@ -82,9 +81,10 @@
 {
     timer_alive = 1;
     timer_ticks = 0;
-    TIMER_CR(0) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
-    TIMER_DATA(0) = TIMER_FREQ_1024(1000);
-    irqSet(IRQ_TIMER1, NDS_TimerInterrupt);
+    TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
+    TIMER_DATA(3) = TIMER_FREQ_1024(1000);
+    irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
+    irqEnable(IRQ_TIMER3);
     return 0;
 }
 
@@ -92,22 +92,23 @@
 SDL_SYS_TimerQuit(void)
 {
     if (timer_alive) {
-        TIMER_CR(0) = 0;
+        TIMER_CR(3) = 0;
     }
     timer_alive = 0;
+    irqDisable(IRQ_TIMER3);
 }
 
 int
 SDL_SYS_StartTimer(void)
 {
-    TIMER_CR(0) |= TIMER_ENABLE;
+    TIMER_CR(3) |= TIMER_ENABLE;
     return 0;
 }
 
 void
 SDL_SYS_StopTimer(void)
 {
-    TIMER_CR(0) &= ~TIMER_ENABLE;
+    TIMER_CR(3) &= ~TIMER_ENABLE;
     return;
 }
 
--- a/src/video/nds/SDL_ndsrender.c	Sun Aug 17 09:50:28 2008 +0000
+++ b/src/video/nds/SDL_ndsrender.c	Mon Aug 18 07:29:52 2008 +0000
@@ -656,8 +656,7 @@
                      SDL_Color * colors, int firstcolor, int ncolors)
 {
     NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
-    TRACE("+NDS_GetTexturePalette\n");
-    TRACE("-NDS_GetTexturePalette\n");
+    TRACE("!NDS_GetTexturePalette\n");
     return 0;
 }
 
--- a/test/nds-test-progs/general/source/main.c	Sun Aug 17 09:50:28 2008 +0000
+++ b/test/nds-test-progs/general/source/main.c	Mon Aug 18 07:29:52 2008 +0000
@@ -32,7 +32,7 @@
 	SDL_Surface *screen;
 	SDL_Joystick *stick;
 	SDL_Event event;
-	SDL_Rect rect = {8,8,240,176};
+	SDL_Rect rect = {0,0,256,192};
 	int i;
 
 	consoleDemoInit(); puts("Hello world!  Initializing FAT...");
@@ -68,23 +68,14 @@
 	while(SDL_PollEvent(&event))
 	switch(event.type) {
 		case SDL_JOYBUTTONDOWN:
-		switch(event.jbutton.which) {
-			case 0:
-			SDL_FillRect(screen, &rect, RGB15(31,0,0)|0x8000);
-			break;
-			case 1:
-			SDL_FillRect(screen, &rect, RGB15(0,31,0)|0x8000);
-			break;
-			case 2:
-			SDL_FillRect(screen, &rect, RGB15(0,0,31)|0x8000);
-			break;
-			case 3:
-			SDL_FillRect(screen, &rect, RGB15(0,0,0)|0x8000);
-			break;
-			default: break;
-		}
-		printf("joy_%d, at %d\n", event.jbutton.which, SDL_GetTicks());
-		SDL_Flip(screen);
+			SDL_FillRect(screen, &rect, (u16)rand()|0x8000);
+			SDL_Flip(screen);
+			if(rect.w > 8) {
+				rect.x += 4; rect.y += 3;
+				rect.w -= 8; rect.h -= 6;
+			}
+			printf("button %d pressed at %d ticks\n",
+			       event.jbutton.which, SDL_GetTicks());
 		break;
 		case SDL_QUIT: SDL_Quit(); return 0;
 		default: break;