changeset 2671:c3e7c0698cbb gsoc2008_nds

some changes to the dummy driver for debug purposes that should be reverted. most importantly, commenting out a check for an env. var.
author Darren Alton <dalton@stevens.edu>
date Thu, 12 Jun 2008 02:38:49 +0000
parents 6e4669f4db49
children 74ac057679d5
files include/SDL_config_nintendods.h include/SDL_stdinc.h src/joystick/nds/SDL_sysjoystick.c src/thread/nds/SDL_syscond.c src/thread/nds/SDL_syscond_c.h src/thread/nds/SDL_sysmutex.c src/thread/nds/SDL_sysmutex_c.h src/thread/nds/SDL_syssem.c src/thread/nds/SDL_syssem_c.h src/thread/nds/SDL_systhread.c src/video/dummy/SDL_nullrender.c src/video/dummy/SDL_nullvideo.c src/video/nds/SDL_ndsrender.c src/video/nds/SDL_ndsvideo.c
diffstat 14 files changed, 635 insertions(+), 504 deletions(-) [+]
line wrap: on
line diff
--- a/include/SDL_config_nintendods.h	Tue Jun 10 06:57:57 2008 +0000
+++ b/include/SDL_config_nintendods.h	Thu Jun 12 02:38:49 2008 +0000
@@ -111,7 +111,6 @@
 #define SDL_TIMERS_DISABLED	1
 
 /* Enable various video drivers */
-#define SDL_VIDEO_DRIVER_NDS	1
+#define SDL_VIDEO_DRIVER_DUMMY	1
 
 #endif /* _SDL_config_nintendods_h */
-
--- a/include/SDL_stdinc.h	Tue Jun 10 06:57:57 2008 +0000
+++ b/include/SDL_stdinc.h	Thu Jun 12 02:38:49 2008 +0000
@@ -147,9 +147,9 @@
 SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
 SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
 SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
-#ifndef __NINTENDODS__ /* TODO: figure out why the following happens:
-include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
-include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
+#ifndef __NINTENDODS__          /* TODO: figure out why the following happens:
+                                   include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
+                                   include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
 SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
 SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
 #endif
@@ -166,7 +166,7 @@
 #endif
 
 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
-#ifndef __NINTENDODS__  /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
+#ifndef __NINTENDODS__          /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
 typedef enum
 {
     DUMMY_ENUM_VALUE
@@ -432,7 +432,7 @@
 #define SDL_wcslen      wcslen
 #else
 #if !defined(wchar_t) && defined(__NINTENDODS__)
-#define wchar_t short /* TODO: figure out why libnds doesn't have this */
+#define wchar_t short           /* TODO: figure out why libnds doesn't have this */
 #endif
 extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
 #endif
--- a/src/joystick/nds/SDL_sysjoystick.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/joystick/nds/SDL_sysjoystick.c	Thu Jun 12 02:38:49 2008 +0000
@@ -22,13 +22,13 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: SDL_sysjoystick.c,v 1.2 2001/04/26 16:50:17 hercules Exp $";
+    "@(#) $Id: SDL_sysjoystick.c,v 1.2 2001/04/26 16:50:17 hercules Exp $";
 #endif
 
 /* This is the system specific header for the SDL joystick API */
 #include <nds.h>
 //#include <nds/registers_alt.h>
-#include <stdio.h>		/* For the definition of NULL */
+#include <stdio.h>              /* For the definition of NULL */
 
 #include "SDL_error.h"
 #include "SDL_joystick.h"
@@ -42,21 +42,23 @@
  * joysticks.  Joystick 0 should be the system default joystick.
  * It should return 0, or -1 on an unrecoverable fatal error.
  */
-int SDL_SYS_JoystickInit(void)
+int
+SDL_SYS_JoystickInit(void)
 {
-	SDL_numjoysticks = 1;
-    //keysInit();
-
-	return(1);
+    SDL_numjoysticks = 1;
+    
+        //keysInit();
+        return (1);
 }
 
 /* Function to get the device-dependent name of a joystick */
-const char *SDL_SYS_JoystickName(int index)
+const char *
+SDL_SYS_JoystickName(int index)
 {
-	if(!index)
-		return "NDS builtin joypad";
-	SDL_SetError("No joystick available with that index");
-	return (NULL);
+    if (!index)
+        return "NDS builtin joypad";
+    SDL_SetError("No joystick available with that index");
+    return (NULL);
 }
 
 /* Function to open a joystick for use.
@@ -64,91 +66,175 @@
    This should fill the nbuttons and naxes fields of the joystick structure.
    It returns 0, or -1 if there is an error.
  */
-int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
+int
+SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
 {
-	joystick->nbuttons=8;
-	joystick->nhats=0;
-	joystick->nballs=0;
-	joystick->naxes=2;
-	return 0;
+    joystick->nbuttons = 8;
+    joystick->nhats = 0;
+    joystick->nballs = 0;
+    joystick->naxes = 2;
+    return 0;
 }
+
 
-
 /* Function to update the state of a joystick - called as a device poll.
  * This function shouldn't update the joystick structure directly,
  * but instead should call SDL_PrivateJoystick*() to deliver events
  * and update joystick device state.
  */
-
-int prevbutton=0;
-int prevkey=0;
+int prevbutton = 0;
+int prevkey = 0;
 
-int dc=NULL;int ldc=0;
-u32 keysd,keysu=NULL;
-void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
-{
-    //dc=keysd;
-	//if (dc != NULL)
-	//{
-		//fprintf(stderr,"heartbeat= %d\n",REG_VCOUNT); 
-		//swiWaitForVBlank();
-		//scanKeys();
-		//keysd = keysDown(); 
-		//keysu = keysUp();
-		//ldc=keysd;
-		 
-	//}
-	/*if (prevkey !=NULL && prevbutton !=NULL)
-	{
-		scanKeys();
-	}
-	*/
-	
-	//scanKeys();
-		keysd = keysDown(); 
-		keysu = keysUp();
-		
-	
-	short ax=0,v=0,h=0;
-	if((keysd&KEY_UP)) {ax=1;v=-10;SDL_PrivateJoystickAxis(joystick,ax,v);prevkey=KEY_UP;}//fprintf(stderr,"KEY_UP\n");}
-	if((keysd&KEY_DOWN)) {ax=1;v=10;SDL_PrivateJoystickAxis(joystick,ax,v);prevkey=KEY_DOWN;}//fprintf(stderr,"KEY_DOWN\n");}
-	if((keysd&KEY_LEFT)) {ax=0;h=-10;SDL_PrivateJoystickAxis(joystick,ax,h);prevkey=KEY_LEFT;}//fprintf(stderr,"KEY_LEFT\n");}
-	if((keysd&KEY_RIGHT)) {ax=0;h=10;SDL_PrivateJoystickAxis(joystick,ax,h);prevkey=KEY_RIGHT;}//fprintf(stderr,"KEY_RIGHT\n");}
-
-	if((keysu&KEY_UP)) {ax=1;v=0;SDL_PrivateJoystickAxis(joystick,ax,v);prevkey=NULL;}//fprintf(stderr,"KEY_UP\n");}
-	if((keysu&KEY_DOWN)) {ax=1;v=0;SDL_PrivateJoystickAxis(joystick,ax,v);prevkey=NULL;}//fprintf(stderr,"KEY_DOWN\n");}
-	if((keysu&KEY_LEFT)) {ax=0;h=0;SDL_PrivateJoystickAxis(joystick,ax,h);prevkey=NULL;}//fprintf(stderr,"KEY_LEFT\n");}
-	if((keysu&KEY_RIGHT)) {ax=0;h=0;SDL_PrivateJoystickAxis(joystick,ax,h);prevkey=NULL;}//fprintf(stderr,"KEY_RIGHT\n");}
-
-	if((keysd&KEY_A))		{SDL_PrivateJoystickButton(joystick,0,SDL_PRESSED);prevbutton=KEY_A;}
-	if((keysd&KEY_B))		{SDL_PrivateJoystickButton(joystick,1,SDL_PRESSED);prevbutton=KEY_B;}
-	if((keysd&KEY_X))		{SDL_PrivateJoystickButton(joystick,2,SDL_PRESSED);prevbutton=KEY_X;}
-	if((keysd&KEY_Y))		{SDL_PrivateJoystickButton(joystick,3,SDL_PRESSED);prevbutton=KEY_Y;}
-	if((keysd&KEY_SELECT))	{SDL_PrivateJoystickButton(joystick,6,SDL_PRESSED);prevbutton=KEY_SELECT;}
-	if((keysd&KEY_START))	{SDL_PrivateJoystickButton(joystick,7,SDL_PRESSED);prevbutton=KEY_START;}
-	if((keysd&KEY_L))		{SDL_PrivateJoystickButton(joystick,4,SDL_PRESSED);prevbutton=KEY_L;}
-	if((keysd&KEY_R))		{SDL_PrivateJoystickButton(joystick,5,SDL_PRESSED);prevbutton=KEY_R;}
-
-	if((keysu&KEY_A))		{SDL_PrivateJoystickButton(joystick,0,SDL_RELEASED);prevbutton=NULL;}
-	if((keysu&KEY_B))		{SDL_PrivateJoystickButton(joystick,1,SDL_RELEASED);prevbutton=NULL;}
-	if((keysu&KEY_X))		{SDL_PrivateJoystickButton(joystick,2,SDL_RELEASED);prevbutton=NULL;}
-	if((keysu&KEY_Y))		{SDL_PrivateJoystickButton(joystick,3,SDL_RELEASED);prevbutton=NULL;}
-	if((keysu&KEY_SELECT))  {SDL_PrivateJoystickButton(joystick,6,SDL_RELEASED);prevbutton=NULL;}
-	if((keysu&KEY_START))	{SDL_PrivateJoystickButton(joystick,7,SDL_RELEASED);prevbutton=NULL;}
-	if((keysu&KEY_L))		{SDL_PrivateJoystickButton(joystick,4,SDL_RELEASED);prevbutton=NULL;}
-	if((keysu&KEY_R))		{SDL_PrivateJoystickButton(joystick,5,SDL_RELEASED);prevbutton=NULL;}
-
-
-
-}
+int dc = NULL;
+int ldc = 0;
+u32 keysd, keysu = NULL;
+void
+SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
+{
+    
+        //dc=keysd;
+        //if (dc != NULL)
+        //{
+        //fprintf(stderr,"heartbeat= %d\n",REG_VCOUNT); 
+        //swiWaitForVBlank();
+        //scanKeys();
+        //keysd = keysDown(); 
+        //keysu = keysUp();
+        //ldc=keysd;
+        
+        //}
+        /*if (prevkey !=NULL && prevbutton !=NULL)
+           {
+           scanKeys();
+           }
+         */ 
+        
+        //scanKeys();
+        keysd = keysDown();
+    
keysu = keysUp();
+    

short ax = 0, v = 0, h = 0;
+    if ((keysd & KEY_UP)) {
+        ax = 1;
+        v = -10;
+        SDL_PrivateJoystickAxis(joystick, ax, v);
+        prevkey = KEY_UP;
+    }                           //fprintf(stderr,"KEY_UP\n");}
+    if ((keysd & KEY_DOWN)) {
+        ax = 1;
+        v = 10;
+        SDL_PrivateJoystickAxis(joystick, ax, v);
+        prevkey = KEY_DOWN;
+    }                           //fprintf(stderr,"KEY_DOWN\n");}
+    if ((keysd & KEY_LEFT)) {
+        ax = 0;
+        h = -10;
+        SDL_PrivateJoystickAxis(joystick, ax, h);
+        prevkey = KEY_LEFT;
+    }                           //fprintf(stderr,"KEY_LEFT\n");}
+    if ((keysd & KEY_RIGHT)) {
+        ax = 0;
+        h = 10;
+        SDL_PrivateJoystickAxis(joystick, ax, h);
+        prevkey = KEY_RIGHT;
+    }                           //fprintf(stderr,"KEY_RIGHT\n");}
+    
if ((keysu & KEY_UP)) {
+        ax = 1;
+        v = 0;
+        SDL_PrivateJoystickAxis(joystick, ax, v);
+        prevkey = NULL;
+    }                           //fprintf(stderr,"KEY_UP\n");}
+    if ((keysu & KEY_DOWN)) {
+        ax = 1;
+        v = 0;
+        SDL_PrivateJoystickAxis(joystick, ax, v);
+        prevkey = NULL;
+    }                           //fprintf(stderr,"KEY_DOWN\n");}
+    if ((keysu & KEY_LEFT)) {
+        ax = 0;
+        h = 0;
+        SDL_PrivateJoystickAxis(joystick, ax, h);
+        prevkey = NULL;
+    }                           //fprintf(stderr,"KEY_LEFT\n");}
+    if ((keysu & KEY_RIGHT)) {
+        ax = 0;
+        h = 0;
+        SDL_PrivateJoystickAxis(joystick, ax, h);
+        prevkey = NULL;
+    }                           //fprintf(stderr,"KEY_RIGHT\n");}
+    
if ((keysd & KEY_A)) {
+        SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
+        prevbutton = KEY_A;
+    }
+    
if ((keysd & KEY_B)) {
+        SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED);
+        prevbutton = KEY_B;
+    }
+    
if ((keysd & KEY_X)) {
+        SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED);
+        prevbutton = KEY_X;
+    }
+    
if ((keysd & KEY_Y)) {
+        SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED);
+        prevbutton = KEY_Y;
+    }
+    
if ((keysd & KEY_SELECT)) {
+        SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED);
+        prevbutton = KEY_SELECT;
+    }
+    
if ((keysd & KEY_START)) {
+        SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED);
+        prevbutton = KEY_START;
+    }
+    
if ((keysd & KEY_L)) {
+        SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED);
+        prevbutton = KEY_L;
+    }
+    
if ((keysd & KEY_R)) {
+        SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED);
+        prevbutton = KEY_R;
+    }
+    

if ((keysu & KEY_A)) {
+        SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
+        prevbutton = NULL;
+    }
+    
if ((keysu & KEY_B)) {
+        SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED);
+        prevbutton = NULL;
+    }
+    
if ((keysu & KEY_X)) {
+        SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED);
+        prevbutton = NULL;
+    }
+    
if ((keysu & KEY_Y)) {
+        SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED);
+        prevbutton = NULL;
+    }
+    
if ((keysu & KEY_SELECT)) {
+        SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED);
+        prevbutton = NULL;
+    }
+    
if ((keysu & KEY_START)) {
+        SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED);
+        prevbutton = NULL;
+    }
+    
if ((keysu & KEY_L)) {
+        SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED);
+        prevbutton = NULL;
+    }
+    
if ((keysu & KEY_R)) {
+        SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED);
+        prevbutton = NULL;
+    }
+

}
 
 /* Function to close a joystick after use */
-void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
+void
+SDL_SYS_JoystickClose(SDL_Joystick * joystick)
 {
 }
 
 /* Function to perform any system-specific joystick related cleanup */
-void SDL_SYS_JoystickQuit(void)
+void
+SDL_SYS_JoystickQuit(void)
 {
 }
-
--- a/src/thread/nds/SDL_syscond.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/thread/nds/SDL_syscond.c	Thu Jun 12 02:38:49 2008 +0000
@@ -22,7 +22,7 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: SDL_syscond.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
+    "@(#) $Id: SDL_syscond.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
 #endif
 
 /* An implementation of condition variables using semaphores and mutexes */
@@ -39,107 +39,111 @@
 
 struct SDL_cond
 {
-	SDL_mutex *lock;
-	int waiting;
-	int signals;
-	SDL_sem *wait_sem;
-	SDL_sem *wait_done;
+    SDL_mutex *lock;
+    int waiting;
+    int signals;
+    SDL_sem *wait_sem;
+    SDL_sem *wait_done;
 };
 
 /* Create a condition variable */
-SDL_cond * SDL_CreateCond(void)
+SDL_cond *
+SDL_CreateCond(void)
 {
-	SDL_cond *cond;
+    SDL_cond *cond;
 
-	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
-	if ( cond ) {
-		cond->lock = SDL_CreateMutex();
-		cond->wait_sem = SDL_CreateSemaphore(0);
-		cond->wait_done = SDL_CreateSemaphore(0);
-		cond->waiting = cond->signals = 0;
-		if ( ! cond->lock || ! cond->wait_sem || ! cond->wait_done ) {
-			SDL_DestroyCond(cond);
-			cond = NULL;
-		}
-	} else {
-		SDL_OutOfMemory();
-	}
-	return(cond);
+    cond = (SDL_cond *) malloc(sizeof(SDL_cond));
+    if (cond) {
+        cond->lock = SDL_CreateMutex();
+        cond->wait_sem = SDL_CreateSemaphore(0);
+        cond->wait_done = SDL_CreateSemaphore(0);
+        cond->waiting = cond->signals = 0;
+        if (!cond->lock || !cond->wait_sem || !cond->wait_done) {
+            SDL_DestroyCond(cond);
+            cond = NULL;
+        }
+    } else {
+        SDL_OutOfMemory();
+    }
+    return (cond);
 }
 
 /* Destroy a condition variable */
-void SDL_DestroyCond(SDL_cond *cond)
+void
+SDL_DestroyCond(SDL_cond * cond)
 {
-	if ( cond ) {
-		if ( cond->wait_sem ) {
-			SDL_DestroySemaphore(cond->wait_sem);
-		}
-		if ( cond->wait_done ) {
-			SDL_DestroySemaphore(cond->wait_done);
-		}
-		if ( cond->lock ) {
-			SDL_DestroyMutex(cond->lock);
-		}
-		free(cond);
-	}
+    if (cond) {
+        if (cond->wait_sem) {
+            SDL_DestroySemaphore(cond->wait_sem);
+        }
+        if (cond->wait_done) {
+            SDL_DestroySemaphore(cond->wait_done);
+        }
+        if (cond->lock) {
+            SDL_DestroyMutex(cond->lock);
+        }
+        free(cond);
+    }
 }
 
 /* Restart one of the threads that are waiting on the condition variable */
-int SDL_CondSignal(SDL_cond *cond)
+int
+SDL_CondSignal(SDL_cond * cond)
 {
-	if ( ! cond ) {
-		SDL_SetError("Passed a NULL condition variable");
-		return -1;
-	}
+    if (!cond) {
+        SDL_SetError("Passed a NULL condition variable");
+        return -1;
+    }
 
-	/* If there are waiting threads not already signalled, then
-	   signal the condition and wait for the thread to respond.
-	*/
-	SDL_LockMutex(cond->lock);
-	if ( cond->waiting > cond->signals ) {
-		++cond->signals;
-		SDL_SemPost(cond->wait_sem);
-		SDL_UnlockMutex(cond->lock);
-		SDL_SemWait(cond->wait_done);
-	} else {
-		SDL_UnlockMutex(cond->lock);
-	}
+    /* If there are waiting threads not already signalled, then
+       signal the condition and wait for the thread to respond.
+     */
+    SDL_LockMutex(cond->lock);
+    if (cond->waiting > cond->signals) {
+        ++cond->signals;
+        SDL_SemPost(cond->wait_sem);
+        SDL_UnlockMutex(cond->lock);
+        SDL_SemWait(cond->wait_done);
+    } else {
+        SDL_UnlockMutex(cond->lock);
+    }
 
-	return 0;
+    return 0;
 }
 
 /* Restart all threads that are waiting on the condition variable */
-int SDL_CondBroadcast(SDL_cond *cond)
+int
+SDL_CondBroadcast(SDL_cond * cond)
 {
-	if ( ! cond ) {
-		SDL_SetError("Passed a NULL condition variable");
-		return -1;
-	}
+    if (!cond) {
+        SDL_SetError("Passed a NULL condition variable");
+        return -1;
+    }
 
-	/* If there are waiting threads not already signalled, then
-	   signal the condition and wait for the thread to respond.
-	*/
-	SDL_LockMutex(cond->lock);
-	if ( cond->waiting > cond->signals ) {
-		int i, num_waiting;
+    /* If there are waiting threads not already signalled, then
+       signal the condition and wait for the thread to respond.
+     */
+    SDL_LockMutex(cond->lock);
+    if (cond->waiting > cond->signals) {
+        int i, num_waiting;
 
-		num_waiting = (cond->waiting - cond->signals);
-		cond->signals = cond->waiting;
-		for ( i=0; i<num_waiting; ++i ) {
-			SDL_SemPost(cond->wait_sem);
-		}
-		/* Now all released threads are blocked here, waiting for us.
-		   Collect them all (and win fabulous prizes!) :-)
-		 */
-		SDL_UnlockMutex(cond->lock);
-		for ( i=0; i<num_waiting; ++i ) {
-			SDL_SemWait(cond->wait_done);
-		}
-	} else {
-		SDL_UnlockMutex(cond->lock);
-	}
+        num_waiting = (cond->waiting - cond->signals);
+        cond->signals = cond->waiting;
+        for (i = 0; i < num_waiting; ++i) {
+            SDL_SemPost(cond->wait_sem);
+        }
+        /* Now all released threads are blocked here, waiting for us.
+           Collect them all (and win fabulous prizes!) :-)
+         */
+        SDL_UnlockMutex(cond->lock);
+        for (i = 0; i < num_waiting; ++i) {
+            SDL_SemWait(cond->wait_done);
+        }
+    } else {
+        SDL_UnlockMutex(cond->lock);
+    }
 
-	return 0;
+    return 0;
 }
 
 /* Wait on the condition variable for at most 'ms' milliseconds.
@@ -162,62 +166,64 @@
 	...
 	SDL_UnlockMutex(lock);
  */
-int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
+int
+SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
 {
-	int retval;
+    int retval;
 
-	if ( ! cond ) {
-		SDL_SetError("Passed a NULL condition variable");
-		return -1;
-	}
+    if (!cond) {
+        SDL_SetError("Passed a NULL condition variable");
+        return -1;
+    }
 
-	/* Obtain the protection mutex, and increment the number of waiters.
-	   This allows the signal mechanism to only perform a signal if there
-	   are waiting threads.
-	 */
-	SDL_LockMutex(cond->lock);
-	++cond->waiting;
-	SDL_UnlockMutex(cond->lock);
+    /* Obtain the protection mutex, and increment the number of waiters.
+       This allows the signal mechanism to only perform a signal if there
+       are waiting threads.
+     */
+    SDL_LockMutex(cond->lock);
+    ++cond->waiting;
+    SDL_UnlockMutex(cond->lock);
 
-	/* Unlock the mutex, as is required by condition variable semantics */
-	SDL_UnlockMutex(mutex);
+    /* Unlock the mutex, as is required by condition variable semantics */
+    SDL_UnlockMutex(mutex);
 
-	/* Wait for a signal */
-	if ( ms == SDL_MUTEX_MAXWAIT ) {
-		retval = SDL_SemWait(cond->wait_sem);
-	} else {
-		retval = SDL_SemWaitTimeout(cond->wait_sem, ms);
-	}
+    /* Wait for a signal */
+    if (ms == SDL_MUTEX_MAXWAIT) {
+        retval = SDL_SemWait(cond->wait_sem);
+    } else {
+        retval = SDL_SemWaitTimeout(cond->wait_sem, ms);
+    }
 
-	/* Let the signaler know we have completed the wait, otherwise
-           the signaler can race ahead and get the condition semaphore
-           if we are stopped between the mutex unlock and semaphore wait,
-           giving a deadlock.  See the following URL for details:
-        http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html
-	*/
-	SDL_LockMutex(cond->lock);
-	if ( cond->signals > 0 ) {
-		/* If we timed out, we need to eat a condition signal */
-		if ( retval > 0 ) {
-			SDL_SemWait(cond->wait_sem);
-		}
-		/* We always notify the signal thread that we are done */
-		SDL_SemPost(cond->wait_done);
+    /* Let the signaler know we have completed the wait, otherwise
+       the signaler can race ahead and get the condition semaphore
+       if we are stopped between the mutex unlock and semaphore wait,
+       giving a deadlock.  See the following URL for details:
+       http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html
+     */
+    SDL_LockMutex(cond->lock);
+    if (cond->signals > 0) {
+        /* If we timed out, we need to eat a condition signal */
+        if (retval > 0) {
+            SDL_SemWait(cond->wait_sem);
+        }
+        /* We always notify the signal thread that we are done */
+        SDL_SemPost(cond->wait_done);
 
-		/* Signal handshake complete */
-		--cond->signals;
-	}
-	--cond->waiting;
-	SDL_UnlockMutex(cond->lock);
+        /* Signal handshake complete */
+        --cond->signals;
+    }
+    --cond->waiting;
+    SDL_UnlockMutex(cond->lock);
 
-	/* Lock the mutex, as is required by condition variable semantics */
-	SDL_LockMutex(mutex);
+    /* Lock the mutex, as is required by condition variable semantics */
+    SDL_LockMutex(mutex);
 
-	return retval;
+    return retval;
 }
 
 /* Wait on the condition variable forever */
-int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
+int
+SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
 {
-	return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
+    return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
 }
--- a/src/thread/nds/SDL_syscond_c.h	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/thread/nds/SDL_syscond_c.h	Thu Jun 12 02:38:49 2008 +0000
@@ -22,6 +22,5 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: SDL_syscond_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
+    "@(#) $Id: SDL_syscond_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
 #endif
-
--- a/src/thread/nds/SDL_sysmutex.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/thread/nds/SDL_sysmutex.c	Thu Jun 12 02:38:49 2008 +0000
@@ -22,7 +22,7 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: SDL_sysmutex.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
+    "@(#) $Id: SDL_sysmutex.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
 #endif
 
 /* An implementation of mutexes using semaphores */
@@ -35,103 +35,108 @@
 #include "SDL_systhread_c.h"
 
 
-struct SDL_mutex {
-	int recursive;
-	Uint32 owner;
-	SDL_sem *sem;
+struct SDL_mutex
+{
+    int recursive;
+    Uint32 owner;
+    SDL_sem *sem;
 };
 
 /* Create a mutex */
-SDL_mutex *SDL_CreateMutex(void)
+SDL_mutex *
+SDL_CreateMutex(void)
 {
-	SDL_mutex *mutex;
+    SDL_mutex *mutex;
 
-	/* Allocate mutex memory */
-	mutex = (SDL_mutex *)malloc(sizeof(*mutex));
-	if ( mutex ) {
-		/* Create the mutex semaphore, with initial value 1 */
-		mutex->sem = SDL_CreateSemaphore(1);
-		mutex->recursive = 0;
-		mutex->owner = 0;
-		if ( ! mutex->sem ) {
-			free(mutex);
-			mutex = NULL;
-		}
-	} else {
-		SDL_OutOfMemory();
-	}
-	return mutex;
+    /* Allocate mutex memory */
+    mutex = (SDL_mutex *) malloc(sizeof(*mutex));
+    if (mutex) {
+        /* Create the mutex semaphore, with initial value 1 */
+        mutex->sem = SDL_CreateSemaphore(1);
+        mutex->recursive = 0;
+        mutex->owner = 0;
+        if (!mutex->sem) {
+            free(mutex);
+            mutex = NULL;
+        }
+    } else {
+        SDL_OutOfMemory();
+    }
+    return mutex;
 }
 
 /* Free the mutex */
-void SDL_DestroyMutex(SDL_mutex *mutex)
+void
+SDL_DestroyMutex(SDL_mutex * mutex)
 {
-	if ( mutex ) {
-		if ( mutex->sem ) {
-			SDL_DestroySemaphore(mutex->sem);
-		}
-		free(mutex);
-	}
+    if (mutex) {
+        if (mutex->sem) {
+            SDL_DestroySemaphore(mutex->sem);
+        }
+        free(mutex);
+    }
 }
 
 /* Lock the semaphore */
-int SDL_mutexP(SDL_mutex *mutex)
+int
+SDL_mutexP(SDL_mutex * mutex)
 {
 #ifdef DISABLE_THREADS
-	return 0;
+    return 0;
 #else
-	Uint32 this_thread;
+    Uint32 this_thread;
 
-	if ( mutex == NULL ) {
-		SDL_SetError("Passed a NULL mutex");
-		return -1;
-	}
+    if (mutex == NULL) {
+        SDL_SetError("Passed a NULL mutex");
+        return -1;
+    }
 
-	this_thread = SDL_ThreadID();
-	if ( mutex->owner == this_thread ) {
-		++mutex->recursive;
-	} else {
-		/* The order of operations is important.
-		   We set the locking thread id after we obtain the lock
-		   so unlocks from other threads will fail.
-		*/
-		SDL_SemWait(mutex->sem);
-		mutex->owner = this_thread;
-		mutex->recursive = 0;
-	}
+    this_thread = SDL_ThreadID();
+    if (mutex->owner == this_thread) {
+        ++mutex->recursive;
+    } else {
+        /* The order of operations is important.
+           We set the locking thread id after we obtain the lock
+           so unlocks from other threads will fail.
+         */
+        SDL_SemWait(mutex->sem);
+        mutex->owner = this_thread;
+        mutex->recursive = 0;
+    }
 
-	return 0;
+    return 0;
 #endif /* DISABLE_THREADS */
 }
 
 /* Unlock the mutex */
-int SDL_mutexV(SDL_mutex *mutex)
+int
+SDL_mutexV(SDL_mutex * mutex)
 {
 #ifdef DISABLE_THREADS
-	return 0;
+    return 0;
 #else
-	if ( mutex == NULL ) {
-		SDL_SetError("Passed a NULL mutex");
-		return -1;
-	}
+    if (mutex == NULL) {
+        SDL_SetError("Passed a NULL mutex");
+        return -1;
+    }
 
-	/* If we don't own the mutex, we can't unlock it */
-	if ( SDL_ThreadID() != mutex->owner ) {
-		SDL_SetError("mutex not owned by this thread");
-		return -1;
-	}
+    /* If we don't own the mutex, we can't unlock it */
+    if (SDL_ThreadID() != mutex->owner) {
+        SDL_SetError("mutex not owned by this thread");
+        return -1;
+    }
 
-	if ( mutex->recursive ) {
-		--mutex->recursive;
-	} else {
-		/* The order of operations is important.
-		   First reset the owner so another thread doesn't lock
-		   the mutex and set the ownership before we reset it,
-		   then release the lock semaphore.
-		 */
-		mutex->owner = 0;
-		SDL_SemPost(mutex->sem);
-	}
-	return 0;
+    if (mutex->recursive) {
+        --mutex->recursive;
+    } else {
+        /* The order of operations is important.
+           First reset the owner so another thread doesn't lock
+           the mutex and set the ownership before we reset it,
+           then release the lock semaphore.
+         */
+        mutex->owner = 0;
+        SDL_SemPost(mutex->sem);
+    }
+    return 0;
 #endif /* DISABLE_THREADS */
 }
--- a/src/thread/nds/SDL_sysmutex_c.h	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/thread/nds/SDL_sysmutex_c.h	Thu Jun 12 02:38:49 2008 +0000
@@ -22,6 +22,5 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: SDL_sysmutex_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
+    "@(#) $Id: SDL_sysmutex_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
 #endif
-
--- a/src/thread/nds/SDL_syssem.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/thread/nds/SDL_syssem.c	Thu Jun 12 02:38:49 2008 +0000
@@ -22,7 +22,7 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: SDL_syssem.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
+    "@(#) $Id: SDL_syssem.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
 #endif
 
 /* An implementation of semaphores using mutexes and condition variables */
@@ -37,178 +37,192 @@
 
 #ifdef DISABLE_THREADS
 
-SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+SDL_sem *
+SDL_CreateSemaphore(Uint32 initial_value)
 {
-	SDL_SetError("SDL not configured with thread support");
-	return (SDL_sem *)0;
+    SDL_SetError("SDL not configured with thread support");
+    return (SDL_sem *) 0;
 }
 
-void SDL_DestroySemaphore(SDL_sem *sem)
+void
+SDL_DestroySemaphore(SDL_sem * sem)
 {
-	return;
+    return;
 }
 
-int SDL_SemTryWait(SDL_sem *sem)
+int
+SDL_SemTryWait(SDL_sem * sem)
 {
-	SDL_SetError("SDL not configured with thread support");
-	return -1;
+    SDL_SetError("SDL not configured with thread support");
+    return -1;
 }
 
-int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+int
+SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
 {
-	SDL_SetError("SDL not configured with thread support");
-	return -1;
+    SDL_SetError("SDL not configured with thread support");
+    return -1;
 }
 
-int SDL_SemWait(SDL_sem *sem)
+int
+SDL_SemWait(SDL_sem * sem)
 {
-	SDL_SetError("SDL not configured with thread support");
-	return -1;
+    SDL_SetError("SDL not configured with thread support");
+    return -1;
 }
 
-Uint32 SDL_SemValue(SDL_sem *sem)
+Uint32
+SDL_SemValue(SDL_sem * sem)
 {
-	return 0;
+    return 0;
 }
 
-int SDL_SemPost(SDL_sem *sem)
+int
+SDL_SemPost(SDL_sem * sem)
 {
-	SDL_SetError("SDL not configured with thread support");
-	return -1;
+    SDL_SetError("SDL not configured with thread support");
+    return -1;
 }
 
 #else
 
 struct SDL_semaphore
 {
-	Uint32 count;
-	Uint32 waiters_count;
-	SDL_mutex *count_lock;
-	SDL_cond *count_nonzero;
+    Uint32 count;
+    Uint32 waiters_count;
+    SDL_mutex *count_lock;
+    SDL_cond *count_nonzero;
 };
 
-SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+SDL_sem *
+SDL_CreateSemaphore(Uint32 initial_value)
 {
-	SDL_sem *sem;
+    SDL_sem *sem;
 
-	sem = (SDL_sem *)malloc(sizeof(*sem));
-	if ( ! sem ) {
-		SDL_OutOfMemory();
-		return(0);
-	}
-	sem->count = initial_value;
-	sem->waiters_count = 0;
+    sem = (SDL_sem *) malloc(sizeof(*sem));
+    if (!sem) {
+        SDL_OutOfMemory();
+        return (0);
+    }
+    sem->count = initial_value;
+    sem->waiters_count = 0;
 
-	sem->count_lock = SDL_CreateMutex();
-	sem->count_nonzero = SDL_CreateCond();
-	if ( ! sem->count_lock || ! sem->count_nonzero ) {
-		SDL_DestroySemaphore(sem);
-		return(0);
-	}
+    sem->count_lock = SDL_CreateMutex();
+    sem->count_nonzero = SDL_CreateCond();
+    if (!sem->count_lock || !sem->count_nonzero) {
+        SDL_DestroySemaphore(sem);
+        return (0);
+    }
 
-	return(sem);
+    return (sem);
 }
 
 /* WARNING:
    You cannot call this function when another thread is using the semaphore.
 */
-void SDL_DestroySemaphore(SDL_sem *sem)
+void
+SDL_DestroySemaphore(SDL_sem * sem)
 {
-	if ( sem ) {
-		sem->count = 0xFFFFFFFF;
-		while ( sem->waiters_count > 0) {
-			SDL_CondSignal(sem->count_nonzero);
-			SDL_Delay(10);
-		}
-		SDL_DestroyCond(sem->count_nonzero);
-		SDL_mutexP(sem->count_lock);
-		SDL_mutexV(sem->count_lock);
-		SDL_DestroyMutex(sem->count_lock);
-		free(sem);
-	}
+    if (sem) {
+        sem->count = 0xFFFFFFFF;
+        while (sem->waiters_count > 0) {
+            SDL_CondSignal(sem->count_nonzero);
+            SDL_Delay(10);
+        }
+        SDL_DestroyCond(sem->count_nonzero);
+        SDL_mutexP(sem->count_lock);
+        SDL_mutexV(sem->count_lock);
+        SDL_DestroyMutex(sem->count_lock);
+        free(sem);
+    }
 }
 
-int SDL_SemTryWait(SDL_sem *sem)
+int
+SDL_SemTryWait(SDL_sem * sem)
 {
-	int retval;
+    int retval;
 
-	if ( ! sem ) {
-		SDL_SetError("Passed a NULL semaphore");
-		return -1;
-	}
+    if (!sem) {
+        SDL_SetError("Passed a NULL semaphore");
+        return -1;
+    }
 
-	retval = SDL_MUTEX_TIMEDOUT;
-	SDL_LockMutex(sem->count_lock);
-	if ( sem->count > 0 ) {
-		--sem->count;
-		retval = 0;
-	}
-	SDL_UnlockMutex(sem->count_lock);
+    retval = SDL_MUTEX_TIMEDOUT;
+    SDL_LockMutex(sem->count_lock);
+    if (sem->count > 0) {
+        --sem->count;
+        retval = 0;
+    }
+    SDL_UnlockMutex(sem->count_lock);
 
-	return retval;
+    return retval;
 }
 
-int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+int
+SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
 {
-	int retval;
+    int retval;
 
-	if ( ! sem ) {
-		SDL_SetError("Passed a NULL semaphore");
-		return -1;
-	}
+    if (!sem) {
+        SDL_SetError("Passed a NULL semaphore");
+        return -1;
+    }
 
-	/* A timeout of 0 is an easy case */
-	if ( timeout == 0 ) {
-		return SDL_SemTryWait(sem);
-	}
+    /* A timeout of 0 is an easy case */
+    if (timeout == 0) {
+        return SDL_SemTryWait(sem);
+    }
 
-	SDL_LockMutex(sem->count_lock);
-	++sem->waiters_count;
-	retval = 0;
-	while ( (sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT) ) {
-		retval = SDL_CondWaitTimeout(sem->count_nonzero,
-		                             sem->count_lock, timeout);
-	}
-	--sem->waiters_count;
-	--sem->count;
-	SDL_UnlockMutex(sem->count_lock);
+    SDL_LockMutex(sem->count_lock);
+    ++sem->waiters_count;
+    retval = 0;
+    while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) {
+        retval = SDL_CondWaitTimeout(sem->count_nonzero,
+                                     sem->count_lock, timeout);
+    }
+    --sem->waiters_count;
+    --sem->count;
+    SDL_UnlockMutex(sem->count_lock);
 
-	return retval;
+    return retval;
 }
 
-int SDL_SemWait(SDL_sem *sem)
+int
+SDL_SemWait(SDL_sem * sem)
 {
-	return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
+    return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
 }
 
-Uint32 SDL_SemValue(SDL_sem *sem)
+Uint32
+SDL_SemValue(SDL_sem * sem)
 {
-	Uint32 value;
-	
-	value = 0;
-	if ( sem ) {
-		SDL_LockMutex(sem->count_lock);
-		value = sem->count;
-		SDL_UnlockMutex(sem->count_lock);
-	}
-	return value;
+    Uint32 value;
+
+    value = 0;
+    if (sem) {
+        SDL_LockMutex(sem->count_lock);
+        value = sem->count;
+        SDL_UnlockMutex(sem->count_lock);
+    }
+    return value;
 }
 
-int SDL_SemPost(SDL_sem *sem)
+int
+SDL_SemPost(SDL_sem * sem)
 {
-	if ( ! sem ) {
-		SDL_SetError("Passed a NULL semaphore");
-		return -1;
-	}
+    if (!sem) {
+        SDL_SetError("Passed a NULL semaphore");
+        return -1;
+    }
 
-	SDL_LockMutex(sem->count_lock);
-	if ( sem->waiters_count > 0 ) {
-		SDL_CondSignal(sem->count_nonzero);
-	}
-	++sem->count;
-	SDL_UnlockMutex(sem->count_lock);
+    SDL_LockMutex(sem->count_lock);
+    if (sem->waiters_count > 0) {
+        SDL_CondSignal(sem->count_nonzero);
+    }
+    ++sem->count;
+    SDL_UnlockMutex(sem->count_lock);
 
-	return 0;
+    return 0;
 }
 
 #endif /* DISABLE_THREADS */
--- a/src/thread/nds/SDL_syssem_c.h	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/thread/nds/SDL_syssem_c.h	Thu Jun 12 02:38:49 2008 +0000
@@ -22,6 +22,5 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: SDL_syssem_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
+    "@(#) $Id: SDL_syssem_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
 #endif
-
--- a/src/thread/nds/SDL_systhread.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/thread/nds/SDL_systhread.c	Thu Jun 12 02:38:49 2008 +0000
@@ -22,7 +22,7 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: SDL_systhread.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
+    "@(#) $Id: SDL_systhread.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
 #endif
 
 /* Thread management routines for SDL */
@@ -31,29 +31,33 @@
 #include "SDL_thread.h"
 #include "SDL_systhread.h"
 
-int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+int
+SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
 {
-	SDL_SetError("Threads are not supported on this platform");
-	return(-1);
+    SDL_SetError("Threads are not supported on this platform");
+    return (-1);
 }
 
-void SDL_SYS_SetupThread(void)
+void
+SDL_SYS_SetupThread(void)
 {
-	return;
+    return;
 }
 
-Uint32 SDL_ThreadID(void)
+Uint32
+SDL_ThreadID(void)
 {
-	return(0);
+    return (0);
 }
 
-void SDL_SYS_WaitThread(SDL_Thread *thread)
+void
+SDL_SYS_WaitThread(SDL_Thread * thread)
 {
-	return;
+    return;
 }
 
-void SDL_SYS_KillThread(SDL_Thread *thread)
+void
+SDL_SYS_KillThread(SDL_Thread * thread)
 {
-	return;
+    return;
 }
-
--- a/src/video/dummy/SDL_nullrender.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/video/dummy/SDL_nullrender.c	Thu Jun 12 02:38:49 2008 +0000
@@ -174,12 +174,18 @@
         (SDL_DUMMY_RenderData *) renderer->driverdata;
 
     /* Send the data to the display */
-    if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
+    /*if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) */  {
         char file[128];
         SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
                      renderer->window, ++frame_number);
         SDL_SaveBMP(data->screens[data->current_screen], file);
     }
+    /*{
+        int i;
+        for (i = 0; i < 256 * 192; ++i)
+            ((Uint16 *)0x6800000)[i]
+                = ((Uint16 *)(data->screens[data->current_screen]->pixels))[i];
+    }*/
 
     /* Update the flipping chain, if any */
     if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
--- a/src/video/dummy/SDL_nullvideo.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/video/dummy/SDL_nullvideo.c	Thu Jun 12 02:38:49 2008 +0000
@@ -63,7 +63,7 @@
         return (1);
     }
 
-    return (0);
+    return (1);
 }
 
 static void
--- a/src/video/nds/SDL_ndsrender.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/video/nds/SDL_ndsrender.c	Thu Jun 12 02:38:49 2008 +0000
@@ -35,20 +35,20 @@
 /* SDL surface based renderer implementation */
 
 static SDL_Renderer *SDL_NDS_CreateRenderer(SDL_Window * window,
-                                              Uint32 flags);
+                                            Uint32 flags);
 static int SDL_NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
-                                Uint8 b, Uint8 a, const SDL_Rect * rect);
+                              Uint8 b, Uint8 a, const SDL_Rect * rect);
 static int SDL_NDS_RenderCopy(SDL_Renderer * renderer,
-                                SDL_Texture * texture,
-                                const SDL_Rect * srcrect,
-                                const SDL_Rect * dstrect);
+                              SDL_Texture * texture,
+                              const SDL_Rect * srcrect,
+                              const SDL_Rect * dstrect);
 static void SDL_NDS_RenderPresent(SDL_Renderer * renderer);
 static void SDL_NDS_DestroyRenderer(SDL_Renderer * renderer);
 
 
 SDL_RenderDriver SDL_NDS_RenderDriver = {
     SDL_NDS_CreateRenderer,
-    { "nds",  SDL_RENDERER_PRESENTCOPY }
+    {"nds", SDL_RENDERER_PRESENTCOPY}
 /*   (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
       SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
       SDL_RENDERER_PRESENTDISCARD),*/
@@ -73,14 +73,15 @@
     Uint32 Rmask = 0x7C00, Gmask = 0x03E0, Bmask = 0x001F, Amask = 0x8000;
 
     printf("SDL_NDS_CreateRenderer(window, 0x%x)\n", flags);
-    printf(" window: (%d,%d), %dx%d\n", window->x, window->y, window->w, window->h);
+    printf(" window: (%d,%d), %dx%d\n", window->x, window->y, window->w,
+           window->h);
 
     /* hard coded this to ARGB1555 for now
-    if (!SDL_PixelFormatEnumToMasks
-        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-        SDL_SetError("Unknown display format");
-        return NULL;
-    }*/
+       if (!SDL_PixelFormatEnumToMasks
+       (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
+       SDL_SetError("Unknown display format");
+       return NULL;
+       } */
 
     renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
@@ -118,7 +119,8 @@
     }
     for (i = 0; i < n; ++i) {
         data->screens[i] =
-            SDL_CreateRGBSurface(0, 256, 192, bpp, Rmask, Gmask, Bmask, Amask);
+            SDL_CreateRGBSurface(0, 256, 192, bpp, Rmask, Gmask, Bmask,
+                                 Amask);
         if (!data->screens[i]) {
             SDL_NDS_DestroyRenderer(renderer);
             return NULL;
@@ -131,17 +133,11 @@
 #if 0
 #define blarg (data->screens[0])
     printf("hello?\n");
-    if(!data || !(data->screens) || !blarg) {
+    if (!data || !(data->screens) || !blarg) {
         printf("they're null.\n");
     } else {
         printf("not null.\n");
-        printf("%d\n%d\n%d\n%d\n%x\n%x\n%x\n%x\n",
-        blarg->w, blarg->h, blarg->pitch,
-        blarg->format->BitsPerPixel,
-        blarg->format->Rmask,
-        blarg->format->Gmask,
-        blarg->format->Bmask,
-        (u32)(blarg->pixels)); /* ARGH WHY DOESN'T THIS PRINT AT ALL? */
+        printf("%d\n%d\n%d\n%d\n%x\n%x\n%x\n%x\n", blarg->w, blarg->h, blarg->pitch, blarg->format->BitsPerPixel, blarg->format->Rmask, blarg->format->Gmask, blarg->format->Bmask, (u32) (blarg->pixels));     /* ARGH WHY DOESN'T THIS PRINT AT ALL? */
         printf("hurr\n");
     }
 #undef blarg
@@ -151,7 +147,7 @@
 
 static int
 SDL_NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
-                     Uint8 a, const SDL_Rect * rect)
+                   Uint8 a, const SDL_Rect * rect)
 {
     SDL_NDS_RenderData *data = (SDL_NDS_RenderData *) renderer->driverdata;
     SDL_Surface *target = data->screens[data->current_screen];
@@ -164,26 +160,29 @@
 }
 
 /* this is mainly for testing stuff to put a surface where I can see it */
-void sdlds_surf2vram(SDL_Surface *s) {
+void
+sdlds_surf2vram(SDL_Surface * s)
+{
     int i;
-    for(i = 0; i < 256*192; ++i) {
-        ((u16*)VRAM_A)[i] = ((u16*)(s->pixels))[i];
+    for (i = 0; i < 256 * 192; ++i) {
+        ((u16 *) VRAM_A)[i] = ((u16 *) (s->pixels))[i];
     }
 }
 
 static int
 SDL_NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+                   const SDL_Rect * srcrect, const SDL_Rect * dstrect)
 {
-    SDL_NDS_RenderData *data =
-        (SDL_NDS_RenderData *) renderer->driverdata;
+    SDL_NDS_RenderData *data = (SDL_NDS_RenderData *) renderer->driverdata;
     SDL_Window *window = SDL_GetWindowFromID(renderer->window);
     SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
     printf("SDL_NDS_RenderCopy(renderer, texture, srcrect, dstrect)\n");
     printf(" renderer: %s\n", renderer->info.name);
     printf(" texture: %dx%d\n", texture->w, texture->h);
-    printf(" srcrect: (%d,%d), %dx%d\n", srcrect->x, srcrect->y, srcrect->w, srcrect->h);
-    printf(" dstrect: (%d,%d), %dx%d\n", dstrect->x, dstrect->y, dstrect->w, dstrect->h);
+    printf(" srcrect: (%d,%d), %dx%d\n", srcrect->x, srcrect->y, srcrect->w,
+           srcrect->h);
+    printf(" dstrect: (%d,%d), %dx%d\n", dstrect->x, dstrect->y, dstrect->w,
+           dstrect->h);
 
     if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
         SDL_Surface *target = data->screens[data->current_screen];
@@ -201,37 +200,38 @@
         SDL_Rect real_dstrect = *dstrect;
         printf("Rmask %x Gmask %x Bmask %x Amask %x\n"
                "width %d, height %d, pitch %d\nbpp %d, pixels %x\n",
-            surface->format->Rmask, surface->format->Gmask,
-            surface->format->Bmask, surface->format->Amask,
-            surface->w, surface->h, surface->pitch,
-            surface->format->BitsPerPixel, (u32)(surface->pixels));
+               surface->format->Rmask, surface->format->Gmask,
+               surface->format->Bmask, surface->format->Amask,
+               surface->w, surface->h, surface->pitch,
+               surface->format->BitsPerPixel, (u32) (surface->pixels));
         sdlds_surf2vram(surface);
         return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
     }
 #if 0
 /* previous attempt to copy it directly to vram */
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        int sx = srcrect->x, sy = srcrect->y, sw = srcrect->w, sh = srcrect->h;
-        int dx = dstrect->x, dy = dstrect->y, dw = dstrect->w, dh = dstrect->h;
-        int si,sj, di,dj;
-        /*printf("DEBUG: still alive!\n");*/
-        for(sj=0, dj=0; sj<sh && dj<dh; ++sj, ++dj) {
-            for(si=0, di=0; si<sw && di<dw; ++si, ++di) {
-                ((uint16*)VRAM_A)[(dj+dy)*256 + di+dx]
-                 = ((Uint16*)surface->pixels)[(sj+sy)*(surface->w) + si+sx];
-            }
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    int sx = srcrect->x, sy = srcrect->y, sw = srcrect->w, sh = srcrect->h;
+    int dx = dstrect->x, dy = dstrect->y, dw = dstrect->w, dh = dstrect->h;
+    int si, sj, di, dj;
+    /*printf("DEBUG: still alive!\n"); */
+    for (sj = 0, dj = 0; sj < sh && dj < dh; ++sj, ++dj) {
+        for (si = 0, di = 0; si < sw && di < dw; ++si, ++di) {
+            ((uint16 *) VRAM_A)[(dj + dy) * 256 + di + dx]
+                = ((Uint16 *) surface->pixels)[(sj + sy) * (surface->w) + si +
+                                               sx];
         }
-        /*printf("DEBUG: still alive!\n");*/
     }
-    return 0;
+    /*printf("DEBUG: still alive!\n"); */
+}
+
+return 0;
 #endif
 }
 
 static void
 SDL_NDS_RenderPresent(SDL_Renderer * renderer)
 {
-    SDL_NDS_RenderData *data =
-        (SDL_NDS_RenderData *) renderer->driverdata;
+    SDL_NDS_RenderData *data = (SDL_NDS_RenderData *) renderer->driverdata;
 
     printf("SDL_NDS_RenderPresent(renderer)\n");
     printf(" renderer: %s\n", renderer->info.name);
@@ -240,18 +240,25 @@
 #if 0
 /*testing to see if rectangles drawn get copied right*/
     {
-    SDL_Rect ra;
-  	ra.x=0; ra.y=0; ra.w=256; ra.h=192;
-	SDL_FillRect(data->screens[data->current_screen], &ra, 0x250);
-	ra.x=32; ra.y=32; ra.w=192; ra.h=128;
-	SDL_FillRect(data->screens[data->current_screen], &ra,
-	    SDL_MapRGBA(data->screens[data->current_screen]->format,
-	    255,255,255,255));
-	}
+        SDL_Rect ra;
+        ra.x = 0;
+        ra.y = 0;
+        ra.w = 256;
+        ra.h = 192;
+        
SDL_FillRect(data->screens[data->current_screen], &ra, 0x250);
+        ra.x = 32;
+        ra.y = 32;
+        ra.w = 192;
+        ra.h = 128;
+        
SDL_FillRect(data->screens[data->current_screen], &ra,
+                      SDL_MapRGBA(data->screens[data->current_screen]->format,
+                                  255, 255, 255, 255));
+    }
 /*okay so this works but why not when I do it in the main()?
   for some reason the screen I get from screen=SDL_SetVideoMode(...)
   doesn't get copied to renderer->driverdata? */
-    for(i = 0; i < 30; ++i) swiWaitForVBlank(); /* delay for debug purpose */
+    for (i = 0; i < 30; ++i)
+        swiWaitForVBlank();     /* delay for debug purpose */
 #endif
     sdlds_surf2vram(data->screens[data->current_screen]);
 
--- a/src/video/nds/SDL_ndsvideo.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/video/nds/SDL_ndsvideo.c	Thu Jun 12 02:38:49 2008 +0000
@@ -63,7 +63,7 @@
 NDS_Available(void)
 {
     const char *envr = SDL_getenv("SDL_VIDEODRIVER");
-	printf("NDS_Available()\n");
+    printf("NDS_Available()\n");
     return (1);
 }
 
@@ -77,7 +77,7 @@
 NDS_CreateDevice(int devindex)
 {
     SDL_VideoDevice *device;
-	printf("NDS_CreateDevice(%d)\n", devindex);
+    printf("NDS_CreateDevice(%d)\n", devindex);
 
     /* Initialize all variables that we clean on shutdown */
     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
@@ -95,7 +95,7 @@
     device->SetDisplayMode = NDS_SetDisplayMode;
     device->PumpEvents = NDS_PumpEvents;
 
-    device->num_displays = 2; /* DS = dual screens */
+    device->num_displays = 2;   /* DS = dual screens */
 
     device->free = NDS_DeleteDevice;
 
@@ -114,7 +114,8 @@
     int i;
 
     /* simple 256x192x16x60 for now */
-    mode.w = 256;  mode.h = 192;
+    mode.w = 256;
+    mode.h = 192;
     mode.format = SDL_PIXELFORMAT_ARGB1555;
     mode.refresh_rate = 60;
     mode.driverdata = NULL;
@@ -125,43 +126,49 @@
     SDL_zero(mode);
     SDL_AddDisplayMode(0, &mode);
 
-	/* hackish stuff to get things up and running for now, and for a console */
-	powerON(POWER_ALL);
-	videoSetMode(MODE_FB0);
-	videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub */
-	vramSetBankA(VRAM_A_LCD);
-	vramSetBankC(VRAM_C_SUB_BG);
-	irqInit();
-	irqEnable(IRQ_VBLANK);
+    /* hackish stuff to get things up and running for now, and for a console */
+    powerON(POWER_ALL);
+    videoSetMode(MODE_FB0);
+    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);    /* debug text on sub */
+    
    vramSetBankA(VRAM_A_LCD);
+    vramSetBankC(VRAM_C_SUB_BG);
+    
    irqInit();
+    irqEnable(IRQ_VBLANK);
     /* set up console for debug text 'n stuff */
-    SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31);
-	consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31),
-	                   (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
-    for(i = 0; i < 256*192; ++i) {
-		((u16*)VRAM_A)[i] = i;
-	}
-	for(i = 0; i < 60; ++i) swiWaitForVBlank();
-    /*NDS_SetDisplayMode(_this, &mode);*/
+    SUB_BG0_CR = BG_MAP_BASE(31);
+    BG_PALETTE_SUB[255] = RGB15(31, 31, 31);
+    consoleInitDefault((u16 *) SCREEN_BASE_BLOCK_SUB(31),
+                       (u16 *) CHAR_BASE_BLOCK_SUB(0), 16);
+    for (i = 0; i < 256 * 192; ++i) {
+        ((u16 *) VRAM_A)[i] = i;
+    }
+    for (i = 0; i < 60; ++i)
+        swiWaitForVBlank();
+    
+    /*NDS_SetDisplayMode(_this, &mode); */
     return 0;
 }
 
 static int
 NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
 {
-	/* right now this function is just hard-coded for 256x192 ARGB1555 */
+    /* right now this function is just hard-coded for 256x192 ARGB1555 */
 #if 0
-	videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); /* display on main core */
-    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub */
+    videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);       /* display on main core */
+    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);    /* debug text on sub */
     vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_LCD,
                      VRAM_C_SUB_BG, VRAM_D_LCD);
 
     /* maps well to the 256x192 screen anyway.  note: need VRAM_B for bigger */
     BG3_CR = BG_BMP16_256x256;
     /* affine transformation matrix.  nothing too fancy here */
-	BG3_XDX = 0x100;    BG3_XDY = 0;
-	BG3_YDX = 0;        BG3_YDY = 0x100;
-	/* x/y position */
-	BG3_CX = 0;         BG3_CY = 0;
+    BG3_XDX = 0x100;
+    BG3_XDY = 0;
+    BG3_YDX = 0;
+    BG3_YDY = 0x100;
+    /* x/y position */
+    BG3_CX = 0;
+    BG3_CY = 0;
 #endif
     return 0;
 }