Frank Zago to sdl
authorSam Lantinga <slouken@libsdl.org>
Sat, 12 Feb 2011 11:36:56 -0800
changeset 52707aba0406c273
parent 5269 11bd1585efb5
child 5271 73f8030f0c72
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.
Makefile.ds
include/SDL_config_nintendods.h
src/SDL.c
src/atomic/nds/SDL_atomic.c
src/audio/nds/SDL_ndsaudio.c
src/audio/nds/SDL_ndsaudio.h
src/events/nds/SDL_ndsgesture.c
src/haptic/nds/SDL_syshaptic.c
src/render/SDL_render.c
src/render/SDL_sysrender.h
src/timer/nds/SDL_systimer.c
src/video/nds/SDL_ndsevents.c
src/video/nds/SDL_ndsrender.c
src/video/nds/SDL_ndsvideo.c
test/nds-test-progs/general/source/main.c
     1.1 --- a/Makefile.ds	Sat Feb 12 10:13:53 2011 -0800
     1.2 +++ b/Makefile.ds	Sat Feb 12 11:36:56 2011 -0800
     1.3 @@ -22,46 +22,58 @@
     1.4  #endif
     1.5  
     1.6  #CFLAGS=$(DEFS) -Iinclude
     1.7 -CFLAGS	=	-mthumb -mthumb-interwork \
     1.8 -		-march=armv5te -mtune=arm946e-s \
     1.9 -		-O2 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
    1.10 -		-DARM9 -D__NDS__ -I$(DEVKITPRO)/libnds/include -DENABLE_NDS -DNO_SIGNAL_H -DDISABLE_THREADS -DPACKAGE=\"SDL\" -DVERSION=\"1.3\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 \
    1.11 -		-Iinclude -Isrc -Isrc/audio -Isrc/cdrom -Isrc/endian -Isrc/events -Isrc/joystick -Isrc/thread/nds -Isrc/thread -Isrc/timer -Isrc/video
    1.12 +CFLAGS	=	-mthumb -mthumb-interwork \
    1.13 +		-march=armv5te -mtune=arm946e-s \
    1.14 +		-O2 -Wall -Wwrite-strings -Wpointer-arith  \
    1.15 +		-DARM9 -D__NDS__ -I$(DEVKITPRO)/libnds/include -DENABLE_NDS -DNO_SIGNAL_H -DDISABLE_THREADS -DPACKAGE=\"SDL\" -DVERSION=\"1.3\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 \
    1.16 +		-Iinclude -Isrc -Isrc/audio -Isrc/cdrom -Isrc/endian -Isrc/events -Isrc/joystick -Isrc/thread/nds -Isrc/thread -Isrc/timer -Isrc/video
    1.17  
    1.18  #src/audio/disk/SDL_diskaudio.c \
    1.19  #src/audio/dummy/SDL_dummyaudio.c \
    1.20  
    1.21  SRCS = \
    1.22  src/SDL.c \
    1.23 +src/SDL_assert.c \
    1.24  src/SDL_compat.c \
    1.25  src/SDL_error.c \
    1.26  src/SDL_fatal.c \
    1.27 -src/SDL_assert.c \
    1.28 -src/audio/nds/SDL_ndsaudio.c \
    1.29 +src/SDL_hints.c \
    1.30 +src/SDL_log.c \
    1.31 +src/atomic/nds/SDL_atomic.c \
    1.32 +src/atomic/SDL_atomic.c \
    1.33  src/audio/SDL_audio.c \
    1.34  src/audio/SDL_audiocvt.c \
    1.35  src/audio/SDL_audiodev.c \
    1.36  src/audio/SDL_audiotypecvt.c \
    1.37  src/audio/SDL_mixer.c \
    1.38 -src/audio/SDL_mixer_m68k.c \
    1.39  src/audio/SDL_mixer_MMX.c \
    1.40  src/audio/SDL_mixer_MMX_VC.c \
    1.41 +src/audio/SDL_mixer_m68k.c \
    1.42  src/audio/SDL_wave.c \
    1.43 -src/cdrom/dummy/SDL_syscdrom.c \
    1.44 -src/cdrom/SDL_cdrom.c \
    1.45 +src/audio/nds/SDL_ndsaudio.c \
    1.46  src/cpuinfo/SDL_cpuinfo.c \
    1.47  src/events/SDL_events.c \
    1.48  src/events/SDL_keyboard.c \
    1.49  src/events/SDL_mouse.c \
    1.50  src/events/SDL_quit.c \
    1.51 +src/events/SDL_touch.c \
    1.52  src/events/SDL_windowevents.c \
    1.53 +src/events/nds/SDL_ndsgesture.c \
    1.54  src/file/SDL_rwops.c \
    1.55 +src/haptic/SDL_haptic.c \
    1.56 +src/haptic/nds/SDL_syshaptic.c \
    1.57 +src/joystick/SDL_joystick.c \
    1.58 +src/joystick/nds/SDL_sysjoystick.c \
    1.59  src/power/SDL_power.c \
    1.60  src/power/nds/SDL_syspower.c \
    1.61 -src/haptic/SDL_haptic.c \
    1.62 -src/haptic/nds/SDL_syshaptic.c \
    1.63 -src/joystick/nds/SDL_sysjoystick.c \
    1.64 -src/joystick/SDL_joystick.c \
    1.65 +src/render/SDL_render.c \
    1.66 +src/render/SDL_yuv_sw.c \
    1.67 +src/render/software/SDL_render_sw.c \
    1.68 +src/render/software/SDL_blendpoint.c \
    1.69 +src/render/software/SDL_drawline.c \
    1.70 +src/render/software/SDL_blendline.c \
    1.71 +src/render/software/SDL_blendfillrect.c \
    1.72 +src/render/software/SDL_drawpoint.c \
    1.73  src/stdlib/SDL_getenv.c \
    1.74  src/stdlib/SDL_iconv.c \
    1.75  src/stdlib/SDL_malloc.c \
    1.76 @@ -73,37 +85,29 @@
    1.77  src/thread/nds/SDL_sysmutex.c \
    1.78  src/thread/nds/SDL_syssem.c \
    1.79  src/thread/nds/SDL_systhread.c \
    1.80 +src/timer/SDL_timer.c \
    1.81  src/timer/nds/SDL_systimer.c \
    1.82 -src/timer/SDL_timer.c \
    1.83 +src/video/SDL_RLEaccel.c \
    1.84 +src/video/SDL_blit.c \
    1.85 +src/video/SDL_blit_0.c \
    1.86 +src/video/SDL_blit_1.c \
    1.87 +src/video/SDL_blit_A.c \
    1.88 +src/video/SDL_blit_N.c \
    1.89 +src/video/SDL_blit_auto.c \
    1.90 +src/video/SDL_blit_copy.c \
    1.91 +src/video/SDL_blit_slow.c \
    1.92 +src/video/SDL_bmp.c \
    1.93 +src/video/SDL_fillrect.c \
    1.94 +src/video/SDL_pixels.c \
    1.95 +src/video/SDL_rect.c \
    1.96 +src/video/SDL_stretch.c \
    1.97 +src/video/SDL_surface.c \
    1.98 +src/video/SDL_video.c \
    1.99 +src/video/dummy/SDL_nullevents.c \
   1.100 +src/video/dummy/SDL_nullvideo.c \
   1.101  src/video/nds/SDL_ndsevents.c \
   1.102  src/video/nds/SDL_ndsrender.c \
   1.103  src/video/nds/SDL_ndsvideo.c \
   1.104 -src/video/dummy/SDL_nullevents.c \
   1.105 -src/video/dummy/SDL_nullrender.c \
   1.106 -src/video/dummy/SDL_nullvideo.c \
   1.107 -src/video/SDL_blit_0.c \
   1.108 -src/video/SDL_blit_1.c \
   1.109 -src/video/SDL_blit_A.c \
   1.110 -src/video/SDL_blit_auto.c \
   1.111 -src/video/SDL_blit.c \
   1.112 -src/video/SDL_blit_copy.c \
   1.113 -src/video/SDL_blit_N.c \
   1.114 -src/video/SDL_blit_slow.c \
   1.115 -src/video/SDL_bmp.c \
   1.116 -src/video/SDL_drawline.c \
   1.117 -src/video/SDL_drawpoint.c \
   1.118 -src/video/SDL_fillrect.c \
   1.119 -src/video/SDL_gamma.c \
   1.120 -src/video/SDL_pixels.c \
   1.121 -src/video/SDL_rect.c \
   1.122 -src/video/SDL_renderer_gl.c \
   1.123 -src/video/SDL_renderer_sw.c \
   1.124 -src/video/SDL_RLEaccel.c \
   1.125 -src/video/SDL_stretch.c \
   1.126 -src/video/SDL_surface.c \
   1.127 -src/video/SDL_video.c \
   1.128 -src/video/SDL_yuv_mmx.c \
   1.129 -src/video/SDL_yuv_sw.c \
   1.130  
   1.131  OBJS = $(SRCS:.c=.o)
   1.132  
   1.133 @@ -113,7 +117,7 @@
   1.134  test/nds-test-progs/sprite2/sprite2.nds \
   1.135  
   1.136  
   1.137 -all: $(TARGET)
   1.138 +all: $(TARGET) install nds_test
   1.139  
   1.140  $(TARGET): copy_config \
   1.141  	$(OBJS)
   1.142 @@ -126,7 +130,9 @@
   1.143  	@cp include/*.h $(DEVKITPRO)/libnds/include/SDL/
   1.144  
   1.145  nds_test:
   1.146 -	$(MAKE) -C test/nds-test-progs
   1.147 +	$(MAKE) -C test/nds-test-progs/general
   1.148 +#	$(MAKE) -C test/nds-test-progs/sprite
   1.149 +#	$(MAKE) -C test/nds-test-progs/sprite2
   1.150  
   1.151  copy_config:
   1.152  	@cp include/SDL_config.h.default include/SDL_config.h
     2.1 --- a/include/SDL_config_nintendods.h	Sat Feb 12 10:13:53 2011 -0800
     2.2 +++ b/include/SDL_config_nintendods.h	Sat Feb 12 11:36:56 2011 -0800
     2.3 @@ -46,6 +46,8 @@
     2.4  #endif
     2.5  #endif /* !_STDINT_H_ && !HAVE_STDINT_H */
     2.6  
     2.7 +#define SIZEOF_VOIDP 4
     2.8 +
     2.9  #define SDL_HAS_64BIT_TYPE	1
    2.10  
    2.11  /* Useful headers */
    2.12 @@ -113,9 +115,12 @@
    2.13  
    2.14  /* Enable various video drivers */
    2.15  #define SDL_VIDEO_DRIVER_NDS	1
    2.16 -/*#define SDL_VIDEO_DRIVER_DUMMY	1 TODO: uncomment this later*/
    2.17 +#define SDL_VIDEO_RENDER_NDS	1
    2.18  
    2.19  /* Enable system power support */
    2.20  #define SDL_POWER_NINTENDODS 1
    2.21  
    2.22 +/* Enable haptic support */
    2.23 +#define SDL_HAPTIC_NDS 1
    2.24 +
    2.25  #endif /* _SDL_config_nintendods_h */
     3.1 --- a/src/SDL.c	Sat Feb 12 10:13:53 2011 -0800
     3.2 +++ b/src/SDL.c	Sat Feb 12 11:36:56 2011 -0800
     3.3 @@ -266,6 +266,8 @@
     3.4      return "Mac OS X";
     3.5  #elif __NETBSD__
     3.6      return "NetBSD";
     3.7 +#elif __NDS__
     3.8 +    return "Nintendo DS";
     3.9  #elif __OPENBSD__
    3.10      return "OpenBSD";
    3.11  #elif __OS2__
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/atomic/nds/SDL_atomic.c	Sat Feb 12 11:36:56 2011 -0800
     4.3 @@ -0,0 +1,469 @@
     4.4 +/*
     4.5 +  SDL - Simple DirectMedia Layer
     4.6 +  Copyright (C) 1997-2010 Sam Lantinga
     4.7 +
     4.8 +  This library is free software; you can redistribute it and/or
     4.9 +  modify it under the terms of the GNU Lesser General Public
    4.10 +  License as published by the Free Software Foundation; either
    4.11 +  version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +  This library is distributed in the hope that it will be useful,
    4.14 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +  Lesser General Public License for more details.
    4.17 +
    4.18 +  You should have received a copy of the GNU Lesser General Public
    4.19 +  License along with this library; if not, write to the Free Software
    4.20 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +  Sam Lantinga
    4.23 +  slouken@libsdl.org
    4.24 +
    4.25 +  Contributed by Bob Pendleton, bob@pendleton.com
    4.26 +*/
    4.27 +
    4.28 +#include "SDL_stdinc.h"
    4.29 +#include "SDL_atomic.h"
    4.30 +
    4.31 +#include "SDL_error.h"
    4.32 +
    4.33 +/*
    4.34 +  This file provides 32, and 64 bit atomic operations. If the
    4.35 +  operations are provided by the native hardware and operating system
    4.36 +  they are used. If they are not then the operations are emulated
    4.37 +  using the SDL spin lock operations. If spin lock can not be
    4.38 +  implemented then these functions must fail.
    4.39 +*/
    4.40 +
    4.41 +/* 
    4.42 +  DUMMY VERSION.
    4.43 +
    4.44 +  This version of the code assumes there is no support for atomic
    4.45 +  operations. Therefore, every function sets the SDL error
    4.46 +  message. Oddly enough, if you only have one thread then this
    4.47 +  version actuallys works.
    4.48 +*/
    4.49 +
    4.50 +/*
    4.51 +  Native spinlock routines. Because this is the dummy implementation
    4.52 +  these will always call SDL_SetError() and do nothing.
    4.53 +*/
    4.54 +
    4.55 +void 
    4.56 +SDL_AtomicLock(SDL_SpinLock *lock)
    4.57 +{
    4.58 +   SDL_SetError("SDL_atomic.c: is not implemented on this platform");
    4.59 +}
    4.60 +
    4.61 +void 
    4.62 +SDL_AtomicUnlock(SDL_SpinLock *lock)
    4.63 +{
    4.64 +   SDL_SetError("SDL_atomic.c: is not implemented on this platform");
    4.65 +}
    4.66 +
    4.67 +/*
    4.68 +  Note that platform specific versions can be built from this version
    4.69 +  by changing the #undefs to #defines and adding platform specific
    4.70 +  code.
    4.71 +*/
    4.72 +
    4.73 +#undef  nativeTestThenSet32
    4.74 +#undef  nativeClear32
    4.75 +#undef  nativeFetchThenIncrement32
    4.76 +#undef  nativeFetchThenDecrement32
    4.77 +#undef  nativeFetchThenAdd32
    4.78 +#undef  nativeFetchThenSubtract32
    4.79 +#undef  nativeIncrementThenFetch32
    4.80 +#undef  nativeDecrementThenFetch32
    4.81 +#undef  nativeAddThenFetch32
    4.82 +#undef  nativeSubtractThenFetch32
    4.83 +
    4.84 +#undef  nativeTestThenSet64
    4.85 +#undef  nativeClear64
    4.86 +#undef  nativeFetchThenIncrement64
    4.87 +#undef  nativeFetchThenDecrement64
    4.88 +#undef  nativeFetchThenAdd64
    4.89 +#undef  nativeFetchThenSubtract64
    4.90 +#undef  nativeIncrementThenFetch64
    4.91 +#undef  nativeDecrementThenFetch64
    4.92 +#undef  nativeAddThenFetch64
    4.93 +#undef  nativeSubtractThenFetch64
    4.94 +
    4.95 +/* 
    4.96 +  If any of the operations are not provided then we must emulate some
    4.97 +  of them. That means we need a nice implementation of spin locks
    4.98 +  that avoids the "one big lock" problem. We use a vector of spin
    4.99 +  locks and pick which one to use based on the address of the operand
   4.100 +  of the function.
   4.101 +
   4.102 +  To generate the index of the lock we first shift by 3 bits to get
   4.103 +  rid on the zero bits that result from 32 and 64 bit allignment of
   4.104 +  data. We then mask off all but 5 bits and use those 5 bits as an
   4.105 +  index into the table. 
   4.106 +
   4.107 +  Picking the lock this way insures that accesses to the same data at
   4.108 +  the same time will go to the same lock. OTOH, accesses to different
   4.109 +  data have only a 1/32 chance of hitting the same lock. That should
   4.110 +  pretty much eliminate the chances of several atomic operations on
   4.111 +  different data from waiting on the same "big lock". If it isn't
   4.112 +  then the table of locks can be expanded to a new size so long as
   4.113 +  the new size is a power of two.
   4.114 +*/
   4.115 +
   4.116 +static SDL_SpinLock locks[32] = {
   4.117 +   0, 0, 0, 0, 0, 0, 0, 0,
   4.118 +   0, 0, 0, 0, 0, 0, 0, 0,
   4.119 +   0, 0, 0, 0, 0, 0, 0, 0,
   4.120 +   0, 0, 0, 0, 0, 0, 0, 0,
   4.121 +};
   4.122 +
   4.123 +static __inline__ void
   4.124 +privateWaitLock(volatile void *ptr)
   4.125 +{
   4.126 +#if SIZEOF_VOIDP == 4
   4.127 +   Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f);
   4.128 +#elif SIZEOF_VOIDP == 8
   4.129 +   Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f);
   4.130 +#endif
   4.131 +
   4.132 +   SDL_AtomicLock(&locks[index]);
   4.133 +}
   4.134 +
   4.135 +static __inline__ void
   4.136 +privateUnlock(volatile void *ptr)
   4.137 +{
   4.138 +#if SIZEOF_VOIDP == 4
   4.139 +   Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f);
   4.140 +#elif SIZEOF_VOIDP == 8
   4.141 +   Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f);
   4.142 +#endif
   4.143 +
   4.144 +   SDL_AtomicUnlock(&locks[index]);
   4.145 +}
   4.146 +
   4.147 +/* 32 bit atomic operations */
   4.148 +
   4.149 +SDL_bool
   4.150 +SDL_AtomicTestThenSet32(volatile Uint32 * ptr)
   4.151 +{
   4.152 +#ifdef nativeTestThenSet32
   4.153 +#else
   4.154 +   SDL_bool result = SDL_FALSE;
   4.155 +
   4.156 +   privateWaitLock(ptr);
   4.157 +   result = (*ptr == 0);
   4.158 +   if (result)
   4.159 +   {
   4.160 +      *ptr = 1;
   4.161 +   }
   4.162 +   privateUnlock(ptr);
   4.163 +
   4.164 +   return result;
   4.165 +#endif
   4.166 +}
   4.167 +
   4.168 +void
   4.169 +SDL_AtomicClear32(volatile Uint32 * ptr)
   4.170 +{
   4.171 +#ifdef nativeClear32
   4.172 +#else
   4.173 +   privateWaitLock(ptr);
   4.174 +   *ptr = 0;
   4.175 +   privateUnlock(ptr);
   4.176 +
   4.177 +   return;
   4.178 +#endif
   4.179 +}
   4.180 +
   4.181 +Uint32
   4.182 +SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr)
   4.183 +{
   4.184 +#ifdef nativeFetchThenIncrement32
   4.185 +#else
   4.186 +   Uint32 tmp = 0;
   4.187 +
   4.188 +   privateWaitLock(ptr);
   4.189 +   tmp = *ptr;
   4.190 +   (*ptr)+= 1;
   4.191 +   privateUnlock(ptr);
   4.192 +
   4.193 +   return tmp;
   4.194 +#endif
   4.195 +}
   4.196 +
   4.197 +Uint32
   4.198 +SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr)
   4.199 +{
   4.200 +#ifdef nativeFetchThenDecrement32
   4.201 +#else
   4.202 +   Uint32 tmp = 0;
   4.203 +
   4.204 +   privateWaitLock(ptr);
   4.205 +   tmp = *ptr;
   4.206 +   (*ptr) -= 1;
   4.207 +   privateUnlock(ptr);
   4.208 +
   4.209 +   return tmp;
   4.210 +#endif
   4.211 +}
   4.212 +
   4.213 +Uint32
   4.214 +SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value)
   4.215 +{
   4.216 +#ifdef nativeFetchThenAdd32
   4.217 +#else
   4.218 +   Uint32 tmp = 0;
   4.219 +
   4.220 +   privateWaitLock(ptr);
   4.221 +   tmp = *ptr;
   4.222 +   (*ptr)+= value;
   4.223 +   privateUnlock(ptr);
   4.224 +
   4.225 +   return tmp;
   4.226 +#endif
   4.227 +}
   4.228 +
   4.229 +Uint32
   4.230 +SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value)
   4.231 +{
   4.232 +#ifdef nativeFetchThenSubtract32
   4.233 +#else
   4.234 +   Uint32 tmp = 0;
   4.235 +
   4.236 +   privateWaitLock(ptr);
   4.237 +   tmp = *ptr;
   4.238 +   (*ptr)-= value;
   4.239 +   privateUnlock(ptr);
   4.240 +
   4.241 +   return tmp;
   4.242 +#endif
   4.243 +}
   4.244 +
   4.245 +Uint32
   4.246 +SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr)
   4.247 +{
   4.248 +#ifdef nativeIncrementThenFetch32
   4.249 +#else
   4.250 +   Uint32 tmp = 0;
   4.251 +
   4.252 +   privateWaitLock(ptr);
   4.253 +   (*ptr)+= 1;
   4.254 +   tmp = *ptr;
   4.255 +   privateUnlock(ptr);
   4.256 +
   4.257 +   return tmp;
   4.258 +#endif
   4.259 +}
   4.260 +
   4.261 +Uint32
   4.262 +SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr)
   4.263 +{
   4.264 +#ifdef nativeDecrementThenFetch32
   4.265 +#else
   4.266 +   Uint32 tmp = 0;
   4.267 +
   4.268 +   privateWaitLock(ptr);
   4.269 +   (*ptr)-= 1;
   4.270 +   tmp = *ptr;
   4.271 +   privateUnlock(ptr);
   4.272 +
   4.273 +   return tmp;
   4.274 +#endif
   4.275 +}
   4.276 +
   4.277 +Uint32
   4.278 +SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value)
   4.279 +{
   4.280 +#ifdef nativeAddThenFetch32
   4.281 +#else
   4.282 +   Uint32 tmp = 0;
   4.283 +
   4.284 +   privateWaitLock(ptr);
   4.285 +   (*ptr)+= value;
   4.286 +   tmp = *ptr;
   4.287 +   privateUnlock(ptr);
   4.288 +
   4.289 +   return tmp;
   4.290 +#endif
   4.291 +}
   4.292 +
   4.293 +Uint32
   4.294 +SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value)
   4.295 +{
   4.296 +#ifdef nativeSubtractThenFetch32
   4.297 +#else
   4.298 +   Uint32 tmp = 0;
   4.299 +
   4.300 +   privateWaitLock(ptr);
   4.301 +   (*ptr)-= value;
   4.302 +   tmp = *ptr;
   4.303 +   privateUnlock(ptr);
   4.304 +
   4.305 +   return tmp;
   4.306 +#endif
   4.307 +}
   4.308 +
   4.309 +/* 64 bit atomic operations */
   4.310 +#ifdef SDL_HAS_64BIT_TYPE
   4.311 +
   4.312 +SDL_bool
   4.313 +SDL_AtomicTestThenSet64(volatile Uint64 * ptr)
   4.314 +{
   4.315 +#ifdef nativeTestThenSet64
   4.316 +#else
   4.317 +   SDL_bool result = SDL_FALSE;
   4.318 +
   4.319 +   privateWaitLock(ptr);
   4.320 +   result = (*ptr == 0);
   4.321 +   if (result)
   4.322 +   {
   4.323 +      *ptr = 1;
   4.324 +   }
   4.325 +   privateUnlock(ptr);
   4.326 +
   4.327 +   return result;
   4.328 +#endif
   4.329 +}
   4.330 +
   4.331 +void
   4.332 +SDL_AtomicClear64(volatile Uint64 * ptr)
   4.333 +{
   4.334 +#ifdef nativeClear64
   4.335 +#else
   4.336 +   privateWaitLock(ptr);
   4.337 +   *ptr = 0;
   4.338 +   privateUnlock(ptr);
   4.339 +
   4.340 +   return;
   4.341 +#endif
   4.342 +}
   4.343 +
   4.344 +Uint64
   4.345 +SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr)
   4.346 +{
   4.347 +#ifdef nativeFetchThenIncrement64
   4.348 +#else
   4.349 +   Uint64 tmp = 0;
   4.350 +
   4.351 +   privateWaitLock(ptr);
   4.352 +   tmp = *ptr;
   4.353 +   (*ptr)+= 1;
   4.354 +   privateUnlock(ptr);
   4.355 +
   4.356 +   return tmp;
   4.357 +#endif
   4.358 +}
   4.359 +
   4.360 +Uint64
   4.361 +SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr)
   4.362 +{
   4.363 +#ifdef nativeFetchThenDecrement64
   4.364 +#else
   4.365 +   Uint64 tmp = 0;
   4.366 +
   4.367 +   privateWaitLock(ptr);
   4.368 +   tmp = *ptr;
   4.369 +   (*ptr) -= 1;
   4.370 +   privateUnlock(ptr);
   4.371 +
   4.372 +   return tmp;
   4.373 +#endif
   4.374 +}
   4.375 +
   4.376 +Uint64
   4.377 +SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value)
   4.378 +{
   4.379 +#ifdef nativeFetchThenAdd64
   4.380 +#else
   4.381 +   Uint64 tmp = 0;
   4.382 +
   4.383 +   privateWaitLock(ptr);
   4.384 +   tmp = *ptr;
   4.385 +   (*ptr)+= value;
   4.386 +   privateUnlock(ptr);
   4.387 +
   4.388 +   return tmp;
   4.389 +#endif
   4.390 +}
   4.391 +
   4.392 +Uint64
   4.393 +SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value)
   4.394 +{
   4.395 +#ifdef nativeFetchThenSubtract64
   4.396 +#else
   4.397 +   Uint64 tmp = 0;
   4.398 +
   4.399 +   privateWaitLock(ptr);
   4.400 +   tmp = *ptr;
   4.401 +   (*ptr)-= value;
   4.402 +   privateUnlock(ptr);
   4.403 +
   4.404 +   return tmp;
   4.405 +#endif
   4.406 +}
   4.407 +
   4.408 +Uint64
   4.409 +SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr)
   4.410 +{
   4.411 +#ifdef nativeIncrementThenFetch64
   4.412 +#else
   4.413 +   Uint64 tmp = 0;
   4.414 +
   4.415 +   privateWaitLock(ptr);
   4.416 +   (*ptr)+= 1;
   4.417 +   tmp = *ptr;
   4.418 +   privateUnlock(ptr);
   4.419 +
   4.420 +   return tmp;
   4.421 +#endif
   4.422 +}
   4.423 +
   4.424 +Uint64
   4.425 +SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr)
   4.426 +{
   4.427 +#ifdef nativeDecrementThenFetch64
   4.428 +#else
   4.429 +   Uint64 tmp = 0;
   4.430 +
   4.431 +   privateWaitLock(ptr);
   4.432 +   (*ptr)-= 1;
   4.433 +   tmp = *ptr;
   4.434 +   privateUnlock(ptr);
   4.435 +
   4.436 +   return tmp;
   4.437 +#endif
   4.438 +}
   4.439 +
   4.440 +Uint64
   4.441 +SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value)
   4.442 +{
   4.443 +#ifdef nativeAddThenFetch64
   4.444 +#else
   4.445 +   Uint64 tmp = 0;
   4.446 +
   4.447 +   privateWaitLock(ptr);
   4.448 +   (*ptr)+= value;
   4.449 +   tmp = *ptr;
   4.450 +   privateUnlock(ptr);
   4.451 +
   4.452 +   return tmp;
   4.453 +#endif
   4.454 +}
   4.455 +
   4.456 +Uint64
   4.457 +SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value)
   4.458 +{
   4.459 +#ifdef nativeSubtractThenFetch64
   4.460 +#else
   4.461 +   Uint64 tmp = 0;
   4.462 +
   4.463 +   privateWaitLock(ptr);
   4.464 +   (*ptr)-= value;
   4.465 +   tmp = *ptr;
   4.466 +   privateUnlock(ptr);
   4.467 +
   4.468 +   return tmp;
   4.469 +#endif
   4.470 +}
   4.471 +#endif
   4.472 +
     5.1 --- a/src/audio/nds/SDL_ndsaudio.c	Sat Feb 12 10:13:53 2011 -0800
     5.2 +++ b/src/audio/nds/SDL_ndsaudio.c	Sat Feb 12 11:36:56 2011 -0800
     5.3 @@ -57,11 +57,13 @@
     5.4          }
     5.5      }
     5.6  
     5.7 +#if 0
     5.8      /* set the generic sound parameters */
     5.9      setGenericSound(22050,      /* sample rate */
    5.10                      127,        /* volume */
    5.11                      64,         /* panning/balance */
    5.12                      0);         /* sound format */
    5.13 +#endif
    5.14  
    5.15      return 1;
    5.16  }
    5.17 @@ -69,13 +71,9 @@
    5.18  static void
    5.19  NDSAUD_PlayDevice(_THIS)
    5.20  {
    5.21 -    TransferSoundData *sound = SDL_malloc(sizeof(TransferSoundData));
    5.22 -    if (!sound) {
    5.23 -        SDL_OutOfMemory();
    5.24 -    }
    5.25 +#if 0
    5.26 +    playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
    5.27  
    5.28 -    playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
    5.29 -#if 0
    5.30  //    sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
    5.31  //    sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
    5.32  //    sound->rate = 22050; /* sample rate = 22050Hz */
     6.1 --- a/src/audio/nds/SDL_ndsaudio.h	Sat Feb 12 10:13:53 2011 -0800
     6.2 +++ b/src/audio/nds/SDL_ndsaudio.h	Sat Feb 12 11:36:56 2011 -0800
     6.3 @@ -32,7 +32,6 @@
     6.4  
     6.5  struct SDL_PrivateAudioData
     6.6  {
     6.7 -    TransferSoundData *sound;
     6.8      /* The file descriptor for the audio device */
     6.9      Uint8 *mixbuf;
    6.10      Uint32 mixlen;
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/events/nds/SDL_ndsgesture.c	Sat Feb 12 11:36:56 2011 -0800
     7.3 @@ -0,0 +1,41 @@
     7.4 +/*
     7.5 +    SDL - Simple DirectMedia Layer
     7.6 +    Copyright (C) 1997-2010 Sam Lantinga
     7.7 +
     7.8 +    This library is free software; you can redistribute it and/or
     7.9 +    modify it under the terms of the GNU Lesser General Public
    7.10 +    License as published by the Free Software Foundation; either
    7.11 +    version 2.1 of the License, or (at your option) any later version.
    7.12 +
    7.13 +    This library is distributed in the hope that it will be useful,
    7.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.16 +    Lesser General Public License for more details.
    7.17 +
    7.18 +    You should have received a copy of the GNU Lesser General Public
    7.19 +    License along with this library; if not, write to the Free Software    Founation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    7.20 +
    7.21 +    Sam Lantinga
    7.22 +    slouken@libsdl.org
    7.23 +*/
    7.24 +
    7.25 +#include "SDL_config.h"
    7.26 +
    7.27 +/* No supported under the NDS because of math operations. */
    7.28 +
    7.29 +#include "SDL_events.h"
    7.30 +#include "SDL_events_c.h"
    7.31 +#include "SDL_gesture_c.h"
    7.32 +
    7.33 +int SDL_GestureAddTouch(SDL_Touch* touch)
    7.34 +{  
    7.35 +	return 0;
    7.36 +}
    7.37 +
    7.38 +void SDL_GestureProcessEvent(SDL_Event* event)
    7.39 +{
    7.40 +	return;
    7.41 +}
    7.42 +
    7.43 +/* vi: set ts=4 sw=4 expandtab: */
    7.44 +  
     8.1 --- a/src/haptic/nds/SDL_syshaptic.c	Sat Feb 12 10:13:53 2011 -0800
     8.2 +++ b/src/haptic/nds/SDL_syshaptic.c	Sat Feb 12 11:36:56 2011 -0800
     8.3 @@ -26,21 +26,21 @@
     8.4  #include "SDL_haptic.h"
     8.5  #include "../SDL_syshaptic.h"
     8.6  #include "SDL_joystick.h"
     8.7 +#include <nds/memory.h>
     8.8  #include <nds/arm9/rumble.h>
     8.9 -#include <nds/memory.h>
    8.10  
    8.11  #define MAX_HAPTICS  1
    8.12  /* right now only the ezf3in1 (and maybe official rumble pak) are supported
    8.13     and there can only be one of those in at a time (in GBA slot.) */
    8.14  
    8.15 -SDL_Haptic *nds_haptic = NULL;
    8.16 +static SDL_Haptic *nds_haptic = NULL;
    8.17  
    8.18 -typedef struct
    8.19 +struct haptic_hwdata
    8.20  {
    8.21      enum
    8.22      { NONE, OFFICIAL, EZF3IN1 } type;
    8.23      int pos;
    8.24 -} NDS_HapticData;
    8.25 +};
    8.26  
    8.27  
    8.28  void
    8.29 @@ -165,7 +165,7 @@
    8.30          return -1;
    8.31      }
    8.32  
    8.33 -    haptic->hwdata = SDL_malloc(sizeof(NDS_HapticData));
    8.34 +    haptic->hwdata = SDL_malloc(sizeof(struct haptic_hwdata));
    8.35      if (!haptic->hwdata) {
    8.36          SDL_OutOfMemory();
    8.37          return -1;
     9.1 --- a/src/render/SDL_render.c	Sat Feb 12 10:13:53 2011 -0800
     9.2 +++ b/src/render/SDL_render.c	Sat Feb 12 11:36:56 2011 -0800
     9.3 @@ -61,6 +61,9 @@
     9.4  #if SDL_VIDEO_RENDER_DIRECTFB
     9.5      &DirectFB_RenderDriver,
     9.6  #endif
     9.7 +#if SDL_VIDEO_RENDER_NDS
     9.8 +	&NDS_RenderDriver,
     9.9 +#endif
    9.10      &SW_RenderDriver
    9.11  #endif /* !SDL_RENDER_DISABLED */
    9.12  };
    10.1 --- a/src/render/SDL_sysrender.h	Sat Feb 12 10:13:53 2011 -0800
    10.2 +++ b/src/render/SDL_sysrender.h	Sat Feb 12 11:36:56 2011 -0800
    10.3 @@ -136,6 +136,9 @@
    10.4  #if SDL_VIDEO_RENDER_DIRECTFB
    10.5  extern SDL_RenderDriver DirectFB_RenderDriver;
    10.6  #endif
    10.7 +#ifdef SDL_VIDEO_RENDER_NDS
    10.8 +extern SDL_RenderDriver NDS_RenderDriver;
    10.9 +#endif
   10.10  extern SDL_RenderDriver SW_RenderDriver;
   10.11  
   10.12  #endif /* !SDL_RENDER_DISABLED */
    11.1 --- a/src/timer/nds/SDL_systimer.c	Sat Feb 12 10:13:53 2011 -0800
    11.2 +++ b/src/timer/nds/SDL_systimer.c	Sat Feb 12 11:36:56 2011 -0800
    11.3 @@ -28,7 +28,7 @@
    11.4  
    11.5  #include "SDL_timer.h"
    11.6  
    11.7 -
    11.8 +/* Will wrap afetr 49 days. Shouldn't be an issue. */
    11.9  static volatile Uint32 timer_ticks;
   11.10  
   11.11  static void
   11.12 @@ -42,10 +42,8 @@
   11.13  {
   11.14      timer_ticks = 0;
   11.15  
   11.16 -    TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
   11.17 -    TIMER_DATA(3) = TIMER_FREQ_1024(1000);
   11.18 -    irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
   11.19 -    irqEnable(IRQ_TIMER3);
   11.20 +	/* Set timer 2 to fire every ms. */
   11.21 +	timerStart(2, ClockDivider_1024, TIMER_FREQ_1024(1000), NDS_TimerInterrupt);
   11.22  }
   11.23  
   11.24  Uint32
   11.25 @@ -58,7 +56,7 @@
   11.26  SDL_Delay(Uint32 ms)
   11.27  {
   11.28      Uint32 start = SDL_GetTicks();
   11.29 -    while (timer_alive) {
   11.30 +    while (1) {
   11.31          if ((SDL_GetTicks() - start) >= ms)
   11.32              break;
   11.33      }
    12.1 --- a/src/video/nds/SDL_ndsevents.c	Sat Feb 12 10:13:53 2011 -0800
    12.2 +++ b/src/video/nds/SDL_ndsevents.c	Sat Feb 12 11:36:56 2011 -0800
    12.3 @@ -45,8 +45,7 @@
    12.4      }
    12.5      if (keysHeld() & KEY_TOUCH) {
    12.6          touchPosition t = touchReadXY();
    12.7 -        SDL_SendMouseMotion(0, 0, t.px, t.py, 1);       /* last arg is pressure,
    12.8 -                                                           hardcoded 1 for now */
    12.9 +        SDL_SendMouseMotion(0, 0, t.px, t.py);
   12.10      }
   12.11  }
   12.12  
    13.1 --- a/src/video/nds/SDL_ndsrender.c	Sat Feb 12 10:13:53 2011 -0800
    13.2 +++ b/src/video/nds/SDL_ndsrender.c	Sat Feb 12 11:36:56 2011 -0800
    13.3 @@ -31,8 +31,8 @@
    13.4  
    13.5  #include "SDL_video.h"
    13.6  #include "../SDL_sysvideo.h"
    13.7 -#include "../SDL_yuv_sw_c.h"
    13.8 -#include "../SDL_renderer_sw.h"
    13.9 +#include "SDL_render.h"
   13.10 +#include "../../render/SDL_sysrender.h"
   13.11  
   13.12  /* SDL NDS renderer implementation */
   13.13  
   13.14 @@ -40,9 +40,11 @@
   13.15  static int NDS_ActivateRenderer(SDL_Renderer * renderer);
   13.16  static int NDS_DisplayModeChanged(SDL_Renderer * renderer);
   13.17  static int NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
   13.18 +#if 0
   13.19  static int NDS_QueryTexturePixels(SDL_Renderer * renderer,
   13.20                                    SDL_Texture * texture, void **pixels,
   13.21                                    int *pitch);
   13.22 +#endif
   13.23  static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   13.24                               const SDL_Rect * rect, const void *pixels,
   13.25                               int pitch);
   13.26 @@ -50,8 +52,8 @@
   13.27                             const SDL_Rect * rect, int markDirty,
   13.28                             void **pixels, int *pitch);
   13.29  static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
   13.30 -static int NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
   13.31 -                          Uint8 b, Uint8 a, const SDL_Rect * rect);
   13.32 +static int NDS_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
   13.33 +							   int count);
   13.34  static int NDS_RenderCopy(SDL_Renderer * renderer,
   13.35                            SDL_Texture * texture,
   13.36                            const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   13.37 @@ -149,7 +151,7 @@
   13.38      }
   13.39      SDL_zerop(data);
   13.40  
   13.41 -    renderer->RenderFill = NDS_RenderFill;
   13.42 +    renderer->RenderFillRects = NDS_RenderFillRects;
   13.43      renderer->RenderCopy = NDS_RenderCopy;
   13.44      renderer->RenderPresent = NDS_RenderPresent;
   13.45      renderer->DestroyRenderer = NDS_DestroyRenderer;
   13.46 @@ -158,7 +160,7 @@
   13.47      renderer->window = window;
   13.48      renderer->driverdata = data;
   13.49      renderer->CreateTexture = NDS_CreateTexture;
   13.50 -    renderer->QueryTexturePixels = NDS_QueryTexturePixels;
   13.51 +//  renderer->QueryTexturePixels = NDS_QueryTexturePixels;
   13.52      renderer->UpdateTexture = NDS_UpdateTexture;
   13.53      renderer->LockTexture = NDS_LockTexture;
   13.54      renderer->UnlockTexture = NDS_UnlockTexture;
   13.55 @@ -341,7 +343,7 @@
   13.56  		bgUpdate(bg3);
   13.57  */
   13.58              txdat->type = NDSTX_BG;
   13.59 -            txdat->pitch = (texture->w) * (bpp / 8);
   13.60 +            txdat->pitch = (texture->w) * ((bpp+1) / 8);
   13.61              txdat->bpp = bpp;
   13.62              txdat->rotate = 0;
   13.63              txdat->scale.x = 0x100;
   13.64 @@ -354,7 +356,7 @@
   13.65              bgSetRotateScale(txdat->hw_index, txdat->rotate, txdat->scale.x,
   13.66                               txdat->scale.y);
   13.67              bgSetScroll(txdat->hw_index, txdat->scroll.x, txdat->scroll.y);
   13.68 -            bgUpdate(txdat->hw_index);
   13.69 +            bgUpdate();
   13.70  
   13.71              data->bg_taken[whichbg] = 1;
   13.72              /*txdat->size = txdat->dim.pitch * texture->h; */
   13.73 @@ -372,6 +374,7 @@
   13.74      return 0;
   13.75  }
   13.76  
   13.77 +#if 0
   13.78  static int
   13.79  NDS_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
   13.80                         void **pixels, int *pitch)
   13.81 @@ -381,6 +384,7 @@
   13.82      *pitch = txdat->pitch;
   13.83      return 0;
   13.84  }
   13.85 +#endif
   13.86  
   13.87  static int
   13.88  NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   13.89 @@ -433,16 +437,13 @@
   13.90  }
   13.91  
   13.92  static int
   13.93 -NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
   13.94 -               Uint8 a, const SDL_Rect * rect)
   13.95 +NDS_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
   13.96 +					int count)
   13.97  {
   13.98      NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
   13.99 -    SDL_Rect real_rect = *rect;
  13.100 -    u16 color;
  13.101 -    int i, j;
  13.102  
  13.103      printf("NDS_RenderFill: stub\n");
  13.104 -    color = RGB8(r, g, b);      /* macro in libnds that makes an ARGB1555 pixel */
  13.105 +
  13.106      /* TODO: make a single-color sprite and stretch it.
  13.107         calculate the "HDX" width modifier of the sprite by:
  13.108         let S be the actual sprite's width (like, 32 pixels for example)
    14.1 --- a/src/video/nds/SDL_ndsvideo.c	Sat Feb 12 10:13:53 2011 -0800
    14.2 +++ b/src/video/nds/SDL_ndsvideo.c	Sat Feb 12 11:36:56 2011 -0800
    14.3 @@ -38,6 +38,8 @@
    14.4  #include "../SDL_sysvideo.h"
    14.5  #include "../SDL_pixels_c.h"
    14.6  #include "../../events/SDL_events_c.h"
    14.7 +#include "SDL_render.h"
    14.8 +#include "../../render/SDL_sysrender.h"
    14.9  
   14.10  #include "SDL_ndsvideo.h"
   14.11  #include "SDL_ndsevents_c.h"
   14.12 @@ -47,7 +49,8 @@
   14.13  
   14.14  /* Initialization/Query functions */
   14.15  static int NDS_VideoInit(_THIS);
   14.16 -static int NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
   14.17 +static int NDS_SetDisplayMode(_THIS, SDL_VideoDisplay *display,
   14.18 +							  SDL_DisplayMode *mode);
   14.19  static void NDS_VideoQuit(_THIS);
   14.20  
   14.21  
   14.22 @@ -73,10 +76,7 @@
   14.23      device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   14.24      if (!device) {
   14.25          SDL_OutOfMemory();
   14.26 -        if (device) {
   14.27 -            SDL_free(device);
   14.28 -        }
   14.29 -        return (0);
   14.30 +        return NULL;
   14.31      }
   14.32  
   14.33      /* Set the function pointers */
   14.34 @@ -101,7 +101,6 @@
   14.35  NDS_VideoInit(_THIS)
   14.36  {
   14.37      SDL_DisplayMode mode;
   14.38 -    int i;
   14.39  
   14.40      /* simple 256x192x16x60 for now */
   14.41      mode.w = 256;
   14.42 @@ -113,21 +112,19 @@
   14.43      if (SDL_AddBasicVideoDisplay(&mode) < 0) {
   14.44          return -1;
   14.45      }
   14.46 -    SDL_AddRenderDriver(&_this->displays[0], &NDS_RenderDriver);
   14.47  
   14.48      SDL_zero(mode);
   14.49 -    SDL_AddDisplayMode(0, &mode);
   14.50 +	SDL_AddDisplayMode(&_this->displays[0], &mode);
   14.51  
   14.52 -    powerON(POWER_ALL_2D);
   14.53 -    irqInit();
   14.54 +    powerOn(POWER_ALL_2D);
   14.55      irqEnable(IRQ_VBLANK);
   14.56 -    NDS_SetDisplayMode(_this, &mode);
   14.57 +    NDS_SetDisplayMode(_this, &_this->displays[0], &mode);
   14.58  
   14.59      return 0;
   14.60  }
   14.61  
   14.62  static int
   14.63 -NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   14.64 +NDS_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   14.65  {
   14.66      /* right now this function is just hard-coded for 256x192 ABGR1555 */
   14.67      videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_BG_EXT_PALETTE | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_1D_BMP | DISPLAY_SPR_1D_BMP_SIZE_256 |      /* (try 128 if 256 is trouble.) */
   14.68 @@ -141,7 +138,7 @@
   14.69      vramSetBankC(VRAM_C_SUB_BG_0x06200000);
   14.70      vramSetBankD(VRAM_D_MAIN_BG_0x06040000);    /* not a typo. vram d can't sub */
   14.71      vramSetBankE(VRAM_E_MAIN_SPRITE);
   14.72 -    vramSetBankF(VRAM_F_OBJ_EXT_PALETTE);
   14.73 +    vramSetBankF(VRAM_F_SPRITE_EXT_PALETTE);
   14.74      vramSetBankG(VRAM_G_BG_EXT_PALETTE);
   14.75      vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
   14.76      vramSetBankI(VRAM_I_SUB_SPRITE);
    15.1 --- a/test/nds-test-progs/general/source/main.c	Sat Feb 12 10:13:53 2011 -0800
    15.2 +++ b/test/nds-test-progs/general/source/main.c	Sat Feb 12 11:36:56 2011 -0800
    15.3 @@ -82,7 +82,7 @@
    15.4                      rect.h -= 6;
    15.5                  }
    15.6                  printf("button %d pressed at %d ticks\n",
    15.7 -                       event.jbutton.which, SDL_GetTicks());
    15.8 +                       event.jbutton.button, SDL_GetTicks());
    15.9                  break;
   15.10              case SDL_QUIT:
   15.11                  SDL_Quit();