From a90176ac9903fcd7f1c72f8d82ef25c6f437186a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Mar 2013 09:44:58 -0700 Subject: [PATCH] Removed Nintendo DS support since nobody has volunteered to maintain it for over a year. --- CREDITS | 3 - Makefile.ds | 231 ---------- README.Platforms | 1 - README.ds | 64 --- .../project.pbxproj | 2 - include/SDL_config.h | 2 - include/SDL_config.h.cmake | 6 - include/SDL_config.h.in | 6 - include/SDL_config_nintendods.h | 129 ------ include/SDL_platform.h | 6 - include/SDL_stdinc.h | 6 +- include/SDL_test_common.h | 5 +- src/SDL.c | 2 - src/audio/SDL_audio.c | 3 - src/audio/nds/SDL_ndsaudio.c | 129 ------ src/audio/nds/SDL_ndsaudio.h | 42 -- src/events/nds/SDL_ndsgesture.c | 41 -- src/file/SDL_rwops.c | 12 - src/haptic/nds/SDL_syshaptic.c | 330 -------------- src/joystick/nds/SDL_sysjoystick.c | 209 --------- src/power/SDL_power.c | 4 - src/power/nds/SDL_syspower.c | 44 -- src/render/SDL_render.c | 3 - src/render/SDL_sysrender.h | 3 - src/render/nds/SDL_libgl2D.c | 315 ------------- src/render/nds/SDL_libgl2D.h | 154 ------- src/render/nds/SDL_ndsrender.c | 418 ------------------ src/test/SDL_test_common.c | 8 - src/thread/SDL_thread_c.h | 2 - src/thread/nds/SDL_syscond.c | 230 ---------- src/thread/nds/SDL_syscond_c.h | 25 -- src/thread/nds/SDL_sysmutex.c | 177 -------- src/thread/nds/SDL_sysmutex_c.h | 25 -- src/thread/nds/SDL_syssem.c | 229 ---------- src/thread/nds/SDL_syssem_c.h | 25 -- src/thread/nds/SDL_systhread.c | 64 --- src/thread/nds/SDL_systhread_c.h | 27 -- src/timer/nds/SDL_systimer.c | 78 ---- src/video/SDL_sysvideo.h | 3 - src/video/SDL_video.c | 3 - src/video/nds/SDL_ndsevents.c | 54 --- src/video/nds/SDL_ndsevents_c.h | 27 -- src/video/nds/SDL_ndsvideo.c | 401 ----------------- src/video/nds/SDL_ndsvideo.h | 59 --- src/video/nds/SDL_ndswindow.c | 37 -- src/video/nds/SDL_ndswindow.h | 30 -- test/nds-test-progs/Makefile | 7 - test/nds-test-progs/general/Makefile | 131 ------ test/nds-test-progs/general/source/main.c | 89 ---- test/nds-test-progs/testscale/Makefile | 147 ------ test/nds-test-progs/testsprite2/Makefile | 152 ------- .../nds-test-progs/testspriteminimal/Makefile | 147 ------ test/testspriteminimal.c | 5 - 53 files changed, 2 insertions(+), 4350 deletions(-) delete mode 100644 Makefile.ds delete mode 100644 README.ds delete mode 100644 include/SDL_config_nintendods.h delete mode 100644 src/audio/nds/SDL_ndsaudio.c delete mode 100644 src/audio/nds/SDL_ndsaudio.h delete mode 100644 src/events/nds/SDL_ndsgesture.c delete mode 100644 src/haptic/nds/SDL_syshaptic.c delete mode 100644 src/joystick/nds/SDL_sysjoystick.c delete mode 100644 src/power/nds/SDL_syspower.c delete mode 100644 src/render/nds/SDL_libgl2D.c delete mode 100644 src/render/nds/SDL_libgl2D.h delete mode 100644 src/render/nds/SDL_ndsrender.c delete mode 100644 src/thread/nds/SDL_syscond.c delete mode 100644 src/thread/nds/SDL_syscond_c.h delete mode 100644 src/thread/nds/SDL_sysmutex.c delete mode 100644 src/thread/nds/SDL_sysmutex_c.h delete mode 100644 src/thread/nds/SDL_syssem.c delete mode 100644 src/thread/nds/SDL_syssem_c.h delete mode 100644 src/thread/nds/SDL_systhread.c delete mode 100644 src/thread/nds/SDL_systhread_c.h delete mode 100644 src/timer/nds/SDL_systimer.c delete mode 100644 src/video/nds/SDL_ndsevents.c delete mode 100644 src/video/nds/SDL_ndsevents_c.h delete mode 100644 src/video/nds/SDL_ndsvideo.c delete mode 100644 src/video/nds/SDL_ndsvideo.h delete mode 100644 src/video/nds/SDL_ndswindow.c delete mode 100644 src/video/nds/SDL_ndswindow.h delete mode 100644 test/nds-test-progs/Makefile delete mode 100755 test/nds-test-progs/general/Makefile delete mode 100644 test/nds-test-progs/general/source/main.c delete mode 100644 test/nds-test-progs/testscale/Makefile delete mode 100644 test/nds-test-progs/testsprite2/Makefile delete mode 100644 test/nds-test-progs/testspriteminimal/Makefile diff --git a/CREDITS b/CREDITS index 29dd032c9..4bf1f96bf 100644 --- a/CREDITS +++ b/CREDITS @@ -19,9 +19,6 @@ Thanks to everyone who made this possible, including: * Holmes Futrell for port of SDL to the iPhone and iPod Touch during the Google Summer of Code 2008 -* Darren Alton for port of SDL to the Nintendo DS during the Google Summer - of Code 2008 - * Szymon "Wilku" Wilczek for adding support for multiple mice and tablets during the Google Summer of Code 2008 diff --git a/Makefile.ds b/Makefile.ds deleted file mode 100644 index 9a79f6f1b..000000000 --- a/Makefile.ds +++ /dev/null @@ -1,231 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -#--------------------------------------------------------------------------------- -TARGET := $(shell basename $(CURDIR)) -BUILD := src -SOURCES := src -DATA := data -INCLUDES := include - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork \ - -D__NDS__ -DENABLE_NDS -DNO_SIGNAL_H -DDISABLE_THREADS -DPACKAGE=\"SDL\" \ - -DVERSION=\"2.0\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 - -CFLAGS := -g -Wall -Os\ - -march=armv5te -mtune=arm946e-s \ - -fomit-frame-pointer -ffast-math \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -# Set to 0 to use a framer buffer, or 1 to use the GL like hardware -# renderer. Alas, both cannot be used at the same time for lack of -# display/texture memory. -USE_HW_RENDERER := 1 - -ifeq ($(USE_HW_RENDERER),1) -CFLAGS += -DUSE_HW_RENDERER -else -endif - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := \ - SDL.c \ - SDL_assert.c \ - SDL_error.c \ - SDL_fatal.c \ - SDL_hints.c \ - SDL_log.c \ - atomic/SDL_atomic.c \ - atomic/SDL_spinlock.arm.c \ - audio/SDL_audio.c \ - audio/SDL_audiocvt.c \ - audio/SDL_audiodev.c \ - audio/SDL_audiotypecvt.c \ - audio/SDL_mixer.c \ - audio/SDL_wave.c \ - audio/nds/SDL_ndsaudio.c \ - cpuinfo/SDL_cpuinfo.c \ - events/SDL_events.c \ - events/SDL_keyboard.c \ - events/SDL_mouse.c \ - events/SDL_quit.c \ - events/SDL_touch.c \ - events/SDL_windowevents.c \ - events/nds/SDL_ndsgesture.c \ - file/SDL_rwops.c \ - haptic/SDL_haptic.c \ - haptic/nds/SDL_syshaptic.c \ - joystick/SDL_joystick.c \ - joystick/nds/SDL_sysjoystick.c \ - power/SDL_power.c \ - power/nds/SDL_syspower.c \ - render/SDL_render.c \ - render/SDL_yuv_sw.c \ - render/nds/SDL_ndsrender.c \ - render/nds/SDL_libgl2D.c \ - render/software/SDL_blendfillrect.c \ - render/software/SDL_blendline.c \ - render/software/SDL_blendpoint.c \ - render/software/SDL_drawline.c \ - render/software/SDL_drawpoint.c \ - render/software/SDL_render_sw.c \ - stdlib/SDL_getenv.c \ - stdlib/SDL_iconv.c \ - stdlib/SDL_malloc.c \ - stdlib/SDL_qsort.c \ - stdlib/SDL_stdlib.c \ - stdlib/SDL_string.c \ - thread/SDL_thread.c \ - thread/nds/SDL_syscond.c \ - thread/nds/SDL_sysmutex.c \ - thread/nds/SDL_syssem.c \ - thread/nds/SDL_systhread.c \ - timer/SDL_timer.c \ - timer/nds/SDL_systimer.c \ - video/SDL_RLEaccel.c \ - video/SDL_blit.c \ - video/SDL_blit_0.c \ - video/SDL_blit_1.c \ - video/SDL_blit_A.c \ - video/SDL_blit_N.c \ - video/SDL_blit_auto.c \ - video/SDL_blit_copy.c \ - video/SDL_blit_slow.c \ - video/SDL_bmp.c \ - video/SDL_clipboard.c \ - video/SDL_fillrect.c \ - video/SDL_pixels.c \ - video/SDL_rect.c \ - video/SDL_stretch.c \ - video/SDL_surface.c \ - video/SDL_video.c \ - video/nds/SDL_ndsevents.c \ - video/nds/SDL_ndsvideo.c \ - video/nds/SDL_ndswindow.c - - -#CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -#SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -#BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) \ - -I$(PORTLIBS)/include/SDL - -.PHONY: $(BUILD) clean all - -#--------------------------------------------------------------------------------- -all: arm_only $(BUILD) install nds_test - -lib: - @[ -d $@ ] || mkdir -p $@ - -$(BUILD): lib - @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.ds -s - -install: $(BUILD) - @mkdir -p $(PORTLIBS)/include/SDL/ - @rsync -a $(OUTPUT) $(PORTLIBS)/lib/ - @rsync -a include/*.h $(PORTLIBS)/include/SDL/ - -nds_test: - $(MAKE) -C test/nds-test-progs -s - -tags: - cd $(SOURCES); etags $(CFILES) - -# This file must be compiled with the ARM instruction set, not -# thumb. Use devkitpro way of doing things. -arm_only: src/atomic/SDL_spinlock.arm.c -src/atomic/SDL_spinlock.arm.c: src/atomic/SDL_spinlock.c - @cp $< $@ - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @cd src; rm -fr $(OFILES) $(OFILES:.o=.d) lib - @rm -f $(OUTPUT) - @make -C test/nds-test-progs -s clean - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT) : $(OFILES) - -#--------------------------------------------------------------------------------- -%.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- diff --git a/README.Platforms b/README.Platforms index 80a6c3f44..19a6e429a 100644 --- a/README.Platforms +++ b/README.Platforms @@ -29,5 +29,4 @@ PSP - maintained by 527721088@qq.com Platforms that need maintainers =============================== -Nintendo DS Haiku diff --git a/README.ds b/README.ds deleted file mode 100644 index 40bf8823e..000000000 --- a/README.ds +++ /dev/null @@ -1,64 +0,0 @@ -================================================================================ -Simple DirectMedia Layer for Nintendo DS -================================================================================ - --Requirements- -* The devkitpro SDK available at http://devkitpro.org. - Read the information at http://devkitpro.org/wiki/Getting_Started/devkitARM - The necessary packages are devkitARM, libnds, libfat and default arm7. -* Optionally, use a DS emulator, such as desmume (http://desmume.org/) - to program and debug. - --Building SDL- - -After setting the devkitpro environment, cd into your SDL directory and type: - make -f Makefile.ds - -This will compile and install the library and headers into the -devkitpro's portlibs directory (../portlibs/arm/lib/ and -../portlibs/arm/include/). Additionally it will compile several tests -that you can run either on the DS or with desmume. For instance: - desmume --cflash-path=test/ test/nds-test-progs/testsprite2/testsprite2.nds - desmume --cflash-path=test/ test/nds-test-progs/testspriteminimal/testspriteminimal.nds - desmume --cflash-path=test/ test/nds-test-progs/testscale/testscale.nds - desmume test/nds-test-progs/general/general.nds - --Notes- -* The renderer code is based on the gl like engine. It's not using the sprite engine. -* The hardware renderer is using the parts of the libgl2d abstraction library that can be found at: - http://rel.phatcode.net/junk.php?id=117 - Used with the author's permission. -* The port is very basic and incomplete: - - SDL currently has to be compiled for either framebuffer mode or renderer mode. - See USE_HW_RENDERER in Makefile.ds. - - some optional renderer functions are not implemented. - - no sound - --Limitations- -* in hardware renderer mode, don't load too many textures. The internal format is - 2 bytes per pixel. And there is only 256KB reserved for the textures. For instance, - testscale won't display sample.bmp, unless it's resized to a smaller picture. -* the screen size is 256 x 384. Anything else won't work. -* there is no 8 bits/pixel mode because SDL 2.0 doesn't support palettes. - --Joystick mapping- -The Joystick presented to SDL has 2 axes and 8 buttons - - KEY | Code - A | 0 - B | 1 - X | 2 - Y | 3 - L | 4 - R | 5 - select | 6 - start | 7 - - Left-right is axe 0. - Up-down is axe 1. - --Mouse mapping- -todo - --Examples- -Due to memory limitations, to be able to successfully run the testscale example, sample.bmp must be resized to 256x105. diff --git a/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj b/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj index f786799eb..3e0eb0c80 100755 --- a/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj +++ b/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj @@ -38,7 +38,6 @@ 0097E2A812F70C4D00724AC5 /* SDL_config_iphoneos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_config_iphoneos.h; sourceTree = ""; }; 0097E2A912F70C4D00724AC5 /* SDL_config_macosx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_config_macosx.h; sourceTree = ""; }; 0097E2AA12F70C4D00724AC5 /* SDL_config_minimal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_config_minimal.h; sourceTree = ""; }; - 0097E2AB12F70C4D00724AC5 /* SDL_config_nintendods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_config_nintendods.h; sourceTree = ""; }; 0097E2AC12F70C4D00724AC5 /* SDL_config_pandora.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_config_pandora.h; sourceTree = ""; }; 0097E2AD12F70C4D00724AC5 /* SDL_config_windows.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_config_windows.h; sourceTree = ""; }; 0097E2AE12F70C4D00724AC5 /* SDL_config_wiz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_config_wiz.h; sourceTree = ""; }; @@ -142,7 +141,6 @@ 0097E2A812F70C4D00724AC5 /* SDL_config_iphoneos.h */, 0097E2A912F70C4D00724AC5 /* SDL_config_macosx.h */, 0097E2AA12F70C4D00724AC5 /* SDL_config_minimal.h */, - 0097E2AB12F70C4D00724AC5 /* SDL_config_nintendods.h */, 0097E2AC12F70C4D00724AC5 /* SDL_config_pandora.h */, 0097E2AD12F70C4D00724AC5 /* SDL_config_windows.h */, 0097E2AE12F70C4D00724AC5 /* SDL_config_wiz.h */, diff --git a/include/SDL_config.h b/include/SDL_config.h index 1ec9e406c..951a77d27 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -37,8 +37,6 @@ #include "SDL_config_iphoneos.h" #elif defined(__ANDROID__) #include "SDL_config_android.h" -#elif defined(__NINTENDODS__) -#include "SDL_config_nintendods.h" #elif defined(__PSP__) #include "SDL_config_psp.h" #else diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 5e5f6a769..c3b9bc708 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -195,7 +195,6 @@ #cmakedefine SDL_AUDIO_DRIVER_ESD_DYNAMIC @SDL_AUDIO_DRIVER_ESD_DYNAMIC@ #cmakedefine SDL_AUDIO_DRIVER_NAS @SDL_AUDIO_DRIVER_NAS@ #cmakedefine SDL_AUDIO_DRIVER_NAS_DYNAMIC @SDL_AUDIO_DRIVER_NAS_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_NDS @SDL_AUDIO_DRIVER_NDS@ #cmakedefine SDL_AUDIO_DRIVER_OSS @SDL_AUDIO_DRIVER_OSS@ #cmakedefine SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H @SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H@ #cmakedefine SDL_AUDIO_DRIVER_PAUDIO @SDL_AUDIO_DRIVER_PAUDIO@ @@ -213,7 +212,6 @@ #cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@ #cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@ #cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@ -#cmakedefine SDL_JOYSTICK_NDS @SDL_JOYSTICK_NDS@ #cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@ #cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@ #cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@ @@ -231,7 +229,6 @@ /* Enable various threading systems */ #cmakedefine SDL_THREAD_BEOS @SDL_THREAD_BEOS@ -#cmakedefine SDL_THREAD_NDS @SDL_THREAD_NDS@ #cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@ #cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@ #cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@ @@ -240,7 +237,6 @@ /* Enable various timer systems */ #cmakedefine SDL_TIMER_BEOS @SDL_TIMER_BEOS@ #cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@ -#cmakedefine SDL_TIMER_NDS @SDL_TIMER_NDS@ #cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@ #cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@ #cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@ @@ -251,7 +247,6 @@ #cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@ #cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@ #cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@ -#cmakedefine SDL_VIDEO_DRIVER_NDS @SDL_VIDEO_DRIVER_NDS@ #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ #cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@ #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@ @@ -295,7 +290,6 @@ #cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@ #cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@ #cmakedefine SDL_POWER_BEOS @SDL_POWER_BEOS@ -#cmakedefine SDL_POWER_NINTENDODS @SDL_POWER_NINTENDODS@ #cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@ /* Enable assembly routines */ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 59d102dd3..bd2be4b2f 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -198,7 +198,6 @@ #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC #undef SDL_AUDIO_DRIVER_NAS #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC -#undef SDL_AUDIO_DRIVER_NDS #undef SDL_AUDIO_DRIVER_OSS #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H #undef SDL_AUDIO_DRIVER_PAUDIO @@ -216,7 +215,6 @@ #undef SDL_JOYSTICK_DUMMY #undef SDL_JOYSTICK_IOKIT #undef SDL_JOYSTICK_LINUX -#undef SDL_JOYSTICK_NDS #undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_USBHID #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @@ -234,7 +232,6 @@ /* Enable various threading systems */ #undef SDL_THREAD_BEOS -#undef SDL_THREAD_NDS #undef SDL_THREAD_PTHREAD #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @@ -243,7 +240,6 @@ /* Enable various timer systems */ #undef SDL_TIMER_BEOS #undef SDL_TIMER_DUMMY -#undef SDL_TIMER_NDS #undef SDL_TIMER_UNIX #undef SDL_TIMER_WINDOWS @@ -253,7 +249,6 @@ #undef SDL_VIDEO_DRIVER_DIRECTFB #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC #undef SDL_VIDEO_DRIVER_DUMMY -#undef SDL_VIDEO_DRIVER_NDS #undef SDL_VIDEO_DRIVER_WINDOWS #undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC @@ -297,7 +292,6 @@ #undef SDL_POWER_WINDOWS #undef SDL_POWER_MACOSX #undef SDL_POWER_BEOS -#undef SDL_POWER_NINTENDODS #undef SDL_POWER_HARDWIRED /* Enable assembly routines */ diff --git a/include/SDL_config_nintendods.h b/include/SDL_config_nintendods.h deleted file mode 100644 index 7b5c21e7c..000000000 --- a/include/SDL_config_nintendods.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef _SDL_config_nintendods_h -#define _SDL_config_nintendods_h - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; - -/* LiF: __PTRDIFF_TYPE__ was causing errors of conflicting typedefs with the - shipping with devkitARM. copied a similar ifdef from it. */ -#ifndef __PTRDIFF_TYPE__ -typedef unsigned long uintptr_t; -#else -typedef unsigned __PTRDIFF_TYPE__ uintptr_t; -#endif -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ - -#define SIZEOF_VOIDP 4 - -/* Useful headers */ -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_CTYPE_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRDUP 1 -#define HAVE_INDEX 1 -#define HAVE_RINDEX 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRICMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 - -/* DS isn't that sophisticated */ -#define LACKS_SYS_MMAN_H 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_NDS 1 -/*#define SDL_AUDIO_DRIVER_DUMMY 1 TODO: uncomment this later*/ - -/* Enable various input drivers */ -#define SDL_JOYSTICK_NDS 1 -/*#define SDL_JOYSTICK_DUMMY 1 TODO: uncomment this later*/ - -/* DS has no dynamic linking afaik */ -#define SDL_LOADSO_DISABLED 1 - -/* Enable various threading systems */ -/*#define SDL_THREAD_NDS 1*/ -#define SDL_THREADS_DISABLED 1 - -/* Enable various timer systems */ -#define SDL_TIMER_NDS 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_NDS 1 -#ifdef USE_HW_RENDERER -#define SDL_VIDEO_RENDER_NDS 1 -#else -#define SDL_VIDEO_RENDER_NDS 0 -#endif - -/* Enable system power support */ -#define SDL_POWER_NINTENDODS 1 - -/* Enable haptic support */ -#define SDL_HAPTIC_NDS 1 - -#define SDL_BYTEORDER SDL_LIL_ENDIAN - -#endif /* _SDL_config_nintendods_h */ diff --git a/include/SDL_platform.h b/include/SDL_platform.h index 86b45bc6a..d37964dfe 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -118,12 +118,6 @@ #undef __WIN32__ #define __WIN32__ 1 #endif - -#if defined(__NDS__) -#undef __NINTENDODS__ -#define __NINTENDODS__ 1 -#endif - #if defined(__PSP__) #undef __PLAYSTATIONPORTABLE__ #define __PLAYSTATIONPORTABLE__ 1 diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index f609eb0e3..f37678957 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -178,7 +178,7 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); /** \cond */ #ifndef DOXYGEN_SHOULD_IGNORE_THIS -#if !defined(__NINTENDODS__) && !defined(__ANDROID__) +#if !defined(__ANDROID__) /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ typedef enum { @@ -190,10 +190,6 @@ SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ /** \endcond */ -#if !defined(wchar_t) && defined(__NINTENDODS__) -#define wchar_t short /* TODO: figure out why libnds doesn't have this */ -#endif - #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus diff --git a/include/SDL_test_common.h b/include/SDL_test_common.h index 411d03347..9e9122f1b 100644 --- a/include/SDL_test_common.h +++ b/include/SDL_test_common.h @@ -34,10 +34,7 @@ #include "SDL.h" -#ifdef __NDS__ -#define DEFAULT_WINDOW_WIDTH 256 -#define DEFAULT_WINDOW_HEIGHT (2*192) -#elif defined(__PSP__) +#if defined(__PSP__) #define DEFAULT_WINDOW_WIDTH 480 #define DEFAULT_WINDOW_HEIGHT 272 #else diff --git a/src/SDL.c b/src/SDL.c index a8707d7ec..aebc3fe36 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -390,8 +390,6 @@ SDL_GetPlatform() return "Mac OS X"; #elif __NETBSD__ return "NetBSD"; -#elif __NDS__ - return "Nintendo DS"; #elif __OPENBSD__ return "OpenBSD"; #elif __OS2__ diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index abe8c8b86..439e74d70 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -121,9 +121,6 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_DUMMY &DUMMYAUD_bootstrap, #endif -#if SDL_AUDIO_DRIVER_NDS - &NDSAUD_bootstrap, -#endif #if SDL_AUDIO_DRIVER_FUSIONSOUND &FUSIONSOUND_bootstrap, #endif diff --git a/src/audio/nds/SDL_ndsaudio.c b/src/audio/nds/SDL_ndsaudio.c deleted file mode 100644 index f729979ab..000000000 --- a/src/audio/nds/SDL_ndsaudio.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#if SDL_AUDIO_DRIVER_NDS - -/* Output audio to NDS */ - -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "SDL_ndsaudio.h" - -static int -NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture) -{ - SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); - int valid_datatype = 0; - - this->hidden = SDL_malloc(sizeof(*(this->hidden))); - if (!this->hidden) { - SDL_OutOfMemory(); - return 0; - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - while ((!valid_datatype) && (test_format)) { - this->spec.format = test_format; - switch (test_format) { - case AUDIO_S8: - /*case AUDIO_S16LSB: */ - valid_datatype = 1; - break; - default: - test_format = SDL_NextAudioFormat(); - break; - } - } - -#if 0 - /* set the generic sound parameters */ - setGenericSound(22050, /* sample rate */ - 127, /* volume */ - 64, /* panning/balance */ - 0); /* sound format */ -#endif - - return 1; -} - -static void -NDSAUD_PlayDevice(_THIS) -{ -#if 0 - playGenericSound(this->hidden->mixbuf, this->hidden->mixlen); - -// sound->data = this->hidden->mixbuf;/* pointer to raw audio data */ -// sound->len = this->hidden->mixlen; /* size of raw data pointed to above */ -// sound->rate = 22050; /* sample rate = 22050Hz */ -// sound->vol = 127; /* volume [0..127] for [min..max] */ -// sound->pan = 64; /* balance [0..127] for [left..right] */ -// sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */ -// playSound(sound); -#endif -} - - -static Uint8 * -NDSAUD_GetDeviceBuf(_THIS) -{ - return this->hidden->mixbuf; /* is this right? */ -} - -static void -NDSAUD_WaitDevice(_THIS) -{ - /* stub */ -} - -static void -NDSAUD_CloseDevice(_THIS) -{ - /* stub */ -} - -static int -NDSAUD_Init(SDL_AudioDriverImpl * impl) -{ - /* Set the function pointers */ - impl->OpenDevice = NDSAUD_OpenDevice; - impl->PlayDevice = NDSAUD_PlayDevice; - impl->WaitDevice = NDSAUD_WaitDevice; - impl->GetDeviceBuf = NDSAUD_GetDeviceBuf; - impl->CloseDevice = NDSAUD_CloseDevice; - - /* and the capabilities */ - impl->HasCaptureSupport = 1; - impl->OnlyHasDefaultOutputDevice = 1; - impl->OnlyHasDefaultInputDevice = 1; - - return 1; /* this audio target is available. */ -} - -AudioBootStrap NDSAUD_bootstrap = { - "nds", "SDL NDS audio driver", NDSAUD_Init, 0 /*1? */ -}; - -#endif /* SDL_AUDIO_DRIVER_NDS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/nds/SDL_ndsaudio.h b/src/audio/nds/SDL_ndsaudio.h deleted file mode 100644 index 892c62f6b..000000000 --- a/src/audio/nds/SDL_ndsaudio.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#ifndef _SDL_ndsaudio_h -#define _SDL_ndsaudio_h - -#include "../SDL_sysaudio.h" -#include - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -struct SDL_PrivateAudioData -{ - /* The file descriptor for the audio device */ - Uint8 *mixbuf; - Uint32 mixlen; - Uint32 write_delay; - Uint32 initial_calls; -}; - -#endif /* _SDL_ndsaudio_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/events/nds/SDL_ndsgesture.c b/src/events/nds/SDL_ndsgesture.c deleted file mode 100644 index 16597c73e..000000000 --- a/src/events/nds/SDL_ndsgesture.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_config.h" - -/* No supported under the NDS because of math operations. */ - -#include "SDL_events.h" -#include "../SDL_events_c.h" -#include "../SDL_gesture_c.h" - -int SDL_GestureAddTouch(SDL_Touch* touch) -{ - return 0; -} - -void SDL_GestureProcessEvent(SDL_Event* event) -{ - return; -} - -/* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 99010c3b7..0b67978d6 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -37,11 +37,6 @@ #include "../core/android/SDL_android.h" #endif -#ifdef __NDS__ -/* include libfat headers for fatInitDefault(). */ -#include -#endif /* __NDS__ */ - #ifdef __WIN32__ /* Functions to read/write Win32 API file pointers */ @@ -556,13 +551,6 @@ SDL_RWFromFP(FILE * fp, SDL_bool autoclose) { SDL_RWops *rwops = NULL; -#if 0 -/*#ifdef __NDS__*/ - /* set it up so we can use stdio file function */ - fatInitDefault(); - printf("called fatInitDefault()"); -#endif /* __NDS__ */ - rwops = SDL_AllocRW(); if (rwops != NULL) { rwops->size = stdio_size; diff --git a/src/haptic/nds/SDL_syshaptic.c b/src/haptic/nds/SDL_syshaptic.c deleted file mode 100644 index e46f178dc..000000000 --- a/src/haptic/nds/SDL_syshaptic.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#ifdef SDL_HAPTIC_NDS - -#include "SDL_haptic.h" -#include "../SDL_syshaptic.h" -#include "SDL_joystick.h" -#include -#include - -#define MAX_HAPTICS 1 -/* right now only the ezf3in1 (and maybe official rumble pak) are supported - and there can only be one of those in at a time (in GBA slot.) */ - -static SDL_Haptic *nds_haptic = NULL; - -struct haptic_hwdata -{ - enum - { NONE, OFFICIAL, EZF3IN1 } type; - int pos; -}; - - -void -NDS_EZF_OpenNorWrite() -{ - GBA_BUS[0x0FF0000] = 0xD200; - GBA_BUS[0x0000000] = 0x1500; - GBA_BUS[0x0010000] = 0xD200; - GBA_BUS[0x0020000] = 0x1500; - GBA_BUS[0x0E20000] = 0x1500; - GBA_BUS[0x0FE0000] = 0x1500; -} - -void -NDS_EZF_CloseNorWrite() -{ - GBA_BUS[0x0FF0000] = 0xD200; - GBA_BUS[0x0000000] = 0x1500; - GBA_BUS[0x0010000] = 0xD200; - GBA_BUS[0x0020000] = 0x1500; - GBA_BUS[0x0E20000] = 0xD200; - GBA_BUS[0x0FE0000] = 0x1500; -} - -void -NDS_EZF_ChipReset() -{ - GBA_BUS[0x0000] = 0x00F0; - GBA_BUS[0x1000] = 0x00F0; -} uint32 NDS_EZF_IsPresent() -{ - vuint16 id1, id2; - - NDS_EZF_OpenNorWrite(); - - GBA_BUS[0x0555] = 0x00AA; - GBA_BUS[0x02AA] = 0x0055; - GBA_BUS[0x0555] = 0x0090; - GBA_BUS[0x1555] = 0x00AA; - GBA_BUS[0x12AA] = 0x0055; - GBA_BUS[0x1555] = 0x0090; - id1 = GBA_BUS[0x0001]; - id2 = GBA_BUS[0x1001]; - if ((id1 != 0x227E) || (id2 != 0x227E)) { - NDS_EZF_CloseNorWrite(); - return 0; - } - id1 = GBA_BUS[0x000E]; - id2 = GBA_BUS[0x100E]; - - NDS_EZF_CloseNorWrite(); - if (id1 == 0x2218 && id2 == 0x2218) { - return 1; - } - return 0; -} -void -NDS_EZF_SetShake(u8 pos) -{ - u16 data = ((pos % 3) | 0x00F0); - GBA_BUS[0x0FF0000] = 0xD200; - GBA_BUS[0x0000000] = 0x1500; - GBA_BUS[0x0010000] = 0xD200; - GBA_BUS[0x0020000] = 0x1500; - GBA_BUS[0x0F10000] = data; - GBA_BUS[0x0FE0000] = 0x1500; - - GBA_BUS[0] = 0x0000; /* write any value for vibration. */ - GBA_BUS[0] = 0x0002; -} - -static int -SDL_SYS_LogicError(void) -{ - SDL_SetError("Logic error: No haptic devices available."); - return 0; -} - - -int -SDL_SYS_HapticInit(void) -{ - int ret = 0; - if (isRumbleInserted()) { - /* official rumble pak is present. */ - ret = 1; - printf("debug: haptic present: nintendo\n"); - } else if (NDS_EZF_IsPresent()) { - /* ezflash 3-in-1 pak is present. */ - ret = 1; - printf("debug: haptic present: ezf3in1\n"); - NDS_EZF_ChipReset(); - } else { - printf("debug: no haptic found\n"); - } - - return ret; -} - - -const char * -SDL_SYS_HapticName(int index) -{ - if (nds_haptic) { - switch (nds_haptic->hwdata->type) { - case OFFICIAL: - return "Nintendo DS Rumble Pak"; - case EZF3IN1: - return "EZFlash 3-in-1 Rumble"; - default: - return NULL; - } - } - return NULL; -} - - -int -SDL_SYS_HapticOpen(SDL_Haptic * haptic) -{ - if (!haptic) { - return -1; - } - - haptic->hwdata = SDL_malloc(sizeof(struct haptic_hwdata)); - if (!haptic->hwdata) { - SDL_OutOfMemory(); - return -1; - } - nds_haptic = haptic; - - haptic->supported = SDL_HAPTIC_CONSTANT; - - /* determine what is here, if anything */ - haptic->hwdata->type = NONE; - if (isRumbleInserted()) { - /* official rumble pak is present. */ - haptic->hwdata->type = OFFICIAL; - } else if (NDS_EZF_IsPresent()) { - /* ezflash 3-in-1 pak is present. */ - haptic->hwdata->type = EZF3IN1; - NDS_EZF_ChipReset(); - } else { - /* no haptic present */ - SDL_SYS_LogicError(); - return -1; - } - - return 0; -} - - -int -SDL_SYS_HapticMouse(void) -{ - return -1; -} - - -int -SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) -{ - return 0; -} - - -int -SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) -{ - /*SDL_SYS_LogicError(); */ - return -1; -} - - -int -SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) -{ - return 0; -} - - -void -SDL_SYS_HapticClose(SDL_Haptic * haptic) -{ - return; -} - - -void -SDL_SYS_HapticQuit(void) -{ - return; -} - - -int -SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, SDL_HapticEffect * base) -{ - SDL_SYS_LogicError(); - return -1; -} - - -int -SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, - struct haptic_effect *effect, - SDL_HapticEffect * data) -{ - SDL_SYS_LogicError(); - return -1; -} - - -int -SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, - Uint32 iterations) -{ - SDL_SYS_LogicError(); - return -1; -} - - -int -SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) -{ - SDL_SYS_LogicError(); - return -1; -} - - -void -SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) -{ - SDL_SYS_LogicError(); - return; -} - - -int -SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, - struct haptic_effect *effect) -{ - SDL_SYS_LogicError(); - return -1; -} - - -int -SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) -{ - SDL_SYS_LogicError(); - return -1; -} - - -int -SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) -{ - SDL_SYS_LogicError(); - return -1; -} - -int -SDL_SYS_HapticPause(SDL_Haptic * haptic) -{ - SDL_SYS_LogicError(); - return -1; -} - -int -SDL_SYS_HapticUnpause(SDL_Haptic * haptic) -{ - SDL_SYS_LogicError(); - return -1; -} - -int -SDL_SYS_HapticStopAll(SDL_Haptic * haptic) -{ - SDL_SYS_LogicError(); - return -1; -} - - - -#endif /* SDL_HAPTIC_NDS */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/nds/SDL_sysjoystick.c b/src/joystick/nds/SDL_sysjoystick.c deleted file mode 100644 index a4ac18233..000000000 --- a/src/joystick/nds/SDL_sysjoystick.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_config.h" - -#ifdef SDL_JOYSTICK_NDS - -/* This is the system specific header for the SDL joystick API */ -#include -#include /* For the definition of NULL */ - -#include "SDL_error.h" -#include "SDL_events.h" -#include "SDL_joystick.h" -#include "../SDL_sysjoystick.h" -#include "../SDL_joystick_c.h" - -#include "../../video/nds/SDL_ndsevents_c.h" - -/* Function to scan the system for joysticks. - */ -int -SDL_SYS_JoystickInit(void) -{ - return (1); -} - -int SDL_SYS_NumJoysticks() -{ - return 1; -} - -void SDL_SYS_JoystickDetect() -{ -} - -SDL_bool SDL_SYS_JoystickNeedsPolling() -{ - return SDL_FALSE; -} - -/* Function to get the device-dependent name of a joystick */ -const char * -SDL_SYS_JoystickNameForDeviceIndex(int device_index) -{ - return "NDS builtin joypad"; -} - -/* Function to perform the mapping from device index to the instance id for this index */ -SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) -{ - return device_index; -} - -/* Function to open a joystick for use. - The joystick to open is specified by the index field of the joystick. - 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 device_index) -{ - joystick->nbuttons = 8; - joystick->nhats = 0; - joystick->nballs = 0; - joystick->naxes = 2; - return 0; -} - -/* Function to determine is this joystick is attached to the system right now */ -SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) -{ - return SDL_TRUE; -} - -/* 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. - */ - void -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) -{ - u32 keysd, keysu; - int magnitude = 16384; - - /*scanKeys(); - this is done in PumpEvents, because touch uses it too */ - keysd = keysDown(); - keysu = keysUp(); - - if ((keysd & KEY_UP)) { - SDL_PrivateJoystickAxis(joystick, 1, -magnitude); - } - if ((keysd & KEY_DOWN)) { - SDL_PrivateJoystickAxis(joystick, 1, magnitude); - } - if ((keysd & KEY_LEFT)) { - SDL_PrivateJoystickAxis(joystick, 0, -magnitude); - } - if ((keysd & KEY_RIGHT)) { - SDL_PrivateJoystickAxis(joystick, 0, magnitude); - } - if ((keysu & (KEY_UP | KEY_DOWN))) { - SDL_PrivateJoystickAxis(joystick, 1, 0); - } - if ((keysu & (KEY_LEFT | KEY_RIGHT))) { - SDL_PrivateJoystickAxis(joystick, 0, 0); - } - if ((keysd & KEY_A)) { - SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED); - } - if ((keysd & KEY_B)) { - SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED); - } - if ((keysd & KEY_X)) { - SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED); - } - if ((keysd & KEY_Y)) { - SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED); - } - if ((keysd & KEY_L)) { - SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED); - } - if ((keysd & KEY_R)) { - SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED); - } - if ((keysd & KEY_SELECT)) { - SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED); - } - if ((keysd & KEY_START)) { - SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED); - } - if ((keysu & KEY_A)) { - SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED); - } - if ((keysu & KEY_B)) { - SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED); - } - if ((keysu & KEY_X)) { - SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED); - } - if ((keysu & KEY_Y)) { - SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED); - } - if ((keysu & KEY_L)) { - SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED); - } - if ((keysu & KEY_R)) { - SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED); - } - if ((keysu & KEY_SELECT)) { - SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED); - } - if ((keysu & KEY_START)) { - SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED); - } -} - -/* Function to close a joystick after use */ -void -SDL_SYS_JoystickClose(SDL_Joystick * joystick) -{ -} - -/* Function to perform any system-specific joystick related cleanup */ -void -SDL_SYS_JoystickQuit(void) -{ -} - -SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) -{ - SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now - const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); - SDL_zero( guid ); - SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); - return guid; -} - -SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) -{ - SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now - const char *name = joystick->name; - SDL_zero( guid ); - SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); - return guid; -} - -#endif /* SDL_JOYSTICK_NDS */ diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index bb920600e..b8f3ae40f 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -34,7 +34,6 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_BeOS(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_NintendoDS(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *); @@ -69,9 +68,6 @@ static SDL_GetPowerInfo_Impl implementations[] = { #ifdef SDL_POWER_MACOSX /* handles Mac OS X, Darwin. */ SDL_GetPowerInfo_MacOSX, #endif -#ifdef SDL_POWER_NINTENDODS /* handles Nintendo DS. */ - SDL_GetPowerInfo_NintendoDS, -#endif #ifdef SDL_POWER_BEOS /* handles BeOS, Zeta, with euc.jp apm driver. */ SDL_GetPowerInfo_BeOS, #endif diff --git a/src/power/nds/SDL_syspower.c b/src/power/nds/SDL_syspower.c deleted file mode 100644 index 0a1a01ce2..000000000 --- a/src/power/nds/SDL_syspower.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#ifndef SDL_POWER_DISABLED -#if SDL_POWER_NINTENDODS - -#include "SDL_power.h" - -SDL_bool -SDL_GetPowerInfo_NintendoDS(SDL_PowerState * state, int *seconds, - int *percent) -{ - /* !!! FIXME: write me. */ - - *state = SDL_POWERSTATE_UNKNOWN; - *percent = -1; - *seconds = -1; - - return SDL_TRUE; /* always the definitive answer on Nintendo DS. */ -} - -#endif /* SDL_POWER_NINTENDODS */ -#endif /* SDL_POWER_DISABLED */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index c3f86ca1a..d007186e8 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -61,9 +61,6 @@ static const SDL_RenderDriver *render_drivers[] = { #if SDL_VIDEO_RENDER_DIRECTFB &DirectFB_RenderDriver, #endif -#if SDL_VIDEO_RENDER_NDS - &NDS_RenderDriver, -#endif #if SDL_VIDEO_RENDER_PSP &PSP_RenderDriver, #endif diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index 95d3f67e0..17f506ed8 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -173,9 +173,6 @@ extern SDL_RenderDriver GLES_RenderDriver; #if SDL_VIDEO_RENDER_DIRECTFB extern SDL_RenderDriver DirectFB_RenderDriver; #endif -#if SDL_VIDEO_RENDER_NDS -extern SDL_RenderDriver NDS_RenderDriver; -#endif #if SDL_VIDEO_RENDER_PSP extern SDL_RenderDriver PSP_RenderDriver; #endif diff --git a/src/render/nds/SDL_libgl2D.c b/src/render/nds/SDL_libgl2D.c deleted file mode 100644 index 7ba9be072..000000000 --- a/src/render/nds/SDL_libgl2D.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Note: The Nintendo DS port to SDL uses excerpts from the libGL2D, - * with permission of the original author. The following is mostly his - * code/comments. - * - * - * Easy GL2D - * - * Relminator 2010 - * Richard Eric M. Lope BSN RN - * - * http://rel.betterwebber.com - * - * A very small and simple DS rendering lib using the 3d core to render 2D stuff - */ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_NDS - -#include "SDL_libgl2D.h" - -/* - * Our static global variable used for Depth values since we cannot - * disable depth testing in the DS hardware This value is incremented - * for every draw call. */ -v16 g_depth; -int gCurrentTexture; - -/* - * !!! PRIVATE !!! Set orthographic projection at 1:1 correspondence - * to screen coords glOrtho expects f32 values but if we use the - * standard f32 values, we need to rescale either every vert or the - * modelview matrix by the same amount to make it work. That's gonna - * give us lots of overflows and headaches. So we "scale down" and - * use an all integer value. - */ -void SetOrtho(void) -{ - glMatrixMode(GL_PROJECTION); // set matrixmode to projection - glLoadIdentity(); // reset - glOrthof32(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1 << 12, 1 << 12); // downscale projection matrix -} - -/* - * Initializes GL in 2D mode Also initializes GL in 3d mode so that we - * could combine 2D and 3D later Almost a direct copy from the DS - * example files - */ -void glScreen2D(void) -{ - // initialize gl - glInit(); - - // enable textures - glEnable(GL_TEXTURE_2D); - - // enable antialiasing - glEnable(GL_ANTIALIAS); - - // setup the rear plane - glClearColor(0, 0, 0, 31); // BG must be opaque for AA to work - glClearPolyID(63); // BG must have a unique polygon ID for AA to work - - glClearDepth(GL_MAX_DEPTH); - - // this should work the same as the normal gl call - glViewport(0,0,255,191); - - // any floating point gl call is being converted to fixed prior to being implemented - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(70, 256.0 / 192.0, 1, 200); - - gluLookAt( 0.0, 0.0, 1.0, //camera possition - 0.0, 0.0, 0.0, //look at - 0.0, 1.0, 0.0); //up - - glMaterialf(GL_AMBIENT, RGB15(31,31,31)); - glMaterialf(GL_DIFFUSE, RGB15(31,31,31)); - glMaterialf(GL_SPECULAR, BIT(15) | RGB15(31,31,31)); - glMaterialf(GL_EMISSION, RGB15(31,31,31)); - - // ds uses a table for shinyness..this generates a half-ass one - glMaterialShinyness(); - - // not a real gl function and will likely change - glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK); -} - -/* - * Sets up OpenGL for 2d rendering Call this before drawing any of - * GL2D's drawing or sprite functions. - */ -void glBegin2D(void) -{ - // save 3d perpective projection matrix - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - - // save 3d modelview matrix for safety - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - - // what?!! No glDisable(GL_DEPTH_TEST)?!!!!!! - glEnable(GL_BLEND); - glEnable(GL_TEXTURE_2D); - glDisable(GL_ANTIALIAS); // disable AA - glDisable(GL_OUTLINE); // disable edge-marking - - glColor(0x7FFF); // max color - - glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); // no culling - - SetOrtho(); - - glMatrixMode(GL_TEXTURE); // reset texture matrix just in case we did some funky stuff with it - glLoadIdentity(); - - glMatrixMode(GL_MODELVIEW); // reset modelview matrix. No need to scale up by << 12 - glLoadIdentity(); - - gCurrentTexture = 0; // set current texture to 0 - g_depth = 0; // set depth to 0. We need this var since we cannot disable depth testing -} - -/* - * Issue this after drawing 2d so that we don't mess the matrix stack. - * The complement of glBegin2D. - */ -void glEnd2D(void) -{ - // restore 3d matrices and set current matrix to modelview - glMatrixMode(GL_PROJECTION); - glPopMatrix(1); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(1); -} - -/* - * Draws a pixel - * Parameters: - * x,y -> First coordinate of the line - * color -> RGB15/ARGB16 color - */ -void glPutPixel(int x, int y, int color) -{ - glBindTexture(0, 0); - glColor(color); - glBegin(GL_TRIANGLES); - gxVertex3i(x, y, g_depth); - gxVertex2i(x, y); - gxVertex2i(x, y); - glEnd(); - glColor(0x7FFF); - g_depth++; - gCurrentTexture = 0; -} - -/* - * Draws a line - * Parameters: - * x1,y1 -> First coordinate of the line - * x2,y2 -> Second coordinate of the line - * color -> RGB15/ARGB16 color - */ -void glLine(int x1, int y1, int x2, int y2, int color) -{ - x2++; - y2++; - - glBindTexture(0, 0); - glColor(color); - glBegin(GL_TRIANGLES); - gxVertex3i(x1, y1, g_depth); - gxVertex2i(x2, y2); - gxVertex2i(x2, y2); - glEnd(); - glColor(0x7FFF); - g_depth++; - gCurrentTexture = 0; -} - -/* - * Draws a Filled Box - * Parameters: - * x1,y1 -> Top-left corner of the box - * x2,y2 -> Bottom-Right corner of the box - * color -> RGB15/ARGB16 color -*/ -void glBoxFilled(int x1, int y1, int x2, int y2, int color) -{ - x2++; - y2++; - - glBindTexture(0, 0); - glColor(color); - glBegin(GL_QUADS); - gxVertex3i(x1, y1, g_depth); // use 3i for first vertex so that we increment HW depth - gxVertex2i(x1, y2); // no need for 3 vertices as 2i would share last depth call - gxVertex2i(x2, y2); - gxVertex2i(x2, y1); - glEnd(); - glColor(0x7FFF); - g_depth++; - gCurrentTexture = 0; -} - -/* - * - * Create a tile. - * Very rigid and prone to human error. - * - * Parameters: - * *sprite -> pointer to a glImage - * texture_width -> width/height of the texture; - * texture_height -> valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d) - * sprite_width - * sprite_height -> width/height of the picture in the texture. - * type -> The format of the texture (see glTexImage2d) - * param -> parameters for the texture (see glTexImage2d) - */ -int glLoadTile(glImage *sprite, - int texture_width, - int texture_height, - int sprite_width, - int sprite_height, - GL_TEXTURE_TYPE_ENUM type, - int param, - int pallette_width, - const u16 *palette, - const uint8 *texture) -{ - int textureID; - - glGenTextures(1, &textureID); - glBindTexture(0, textureID); - glTexImage2D(0, 0, type, texture_width, texture_height, 0, param, texture); - glColorTableEXT(0, 0, pallette_width, 0, 0, palette); - - sprite->width = sprite_width; - sprite->height = sprite_height; - sprite->textureID = textureID; - - return textureID; -} - -/* - * I made this since the scale wrappers are either the vectorized mode - * or does not permit you to scale only the axis you want to - * scale. Needed for sprite scaling. - */ -static inline void gxScalef32(s32 x, s32 y, s32 z) -{ - MATRIX_SCALE = x; - MATRIX_SCALE = y; - MATRIX_SCALE = z; -} - -/* - * I this made for future naming conflicts. - */ -static inline void gxTranslate3f32(int32 x, int32 y, int32 z) -{ - MATRIX_TRANSLATE = x; - MATRIX_TRANSLATE = y; - MATRIX_TRANSLATE = z; -} - -/* - * Draws an axis exclusive scaled sprite - * Parameters: - * x -> x position of the sprite - * y -> y position of the sprite - * scaleX -> 20.12 FP X axis scale value (1 << 12 is normal) - * scaleY -> 20.12 FP Y axis scale value (1 << 12 is normal) - * flipmode -> mode for flipping (see GL_FLIP_MODE enum) - * *spr -> pointer to a glImage - */ -void glSpriteScaleXY(int x, int y, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr) -{ - const int x1 = 0; - const int y1 = 0; - const int x2 = spr->width; - const int y2 = spr->height; - const int u1 = ((flipmode & GL_FLIP_H) ? spr->width-1 : 0); - const int u2 = ((flipmode & GL_FLIP_H) ? 0 : spr->width-1); - const int v1 = ((flipmode & GL_FLIP_V) ? spr->height-1 : 0); - const int v2 = ((flipmode & GL_FLIP_V) ? 0 : spr->height-1); - - if (spr->textureID != gCurrentTexture) - { - glBindTexture(GL_TEXTURE_2D, spr->textureID); - gCurrentTexture = spr->textureID; - } - - glPushMatrix(); - - gxTranslate3f32(x, y, 0); - gxScalef32(scaleX, scaleY, 1 << 12); - - glBegin(GL_QUADS); - - gxTexcoord2i(u1, v1); gxVertex3i(x1, y1, g_depth); - gxTexcoord2i(u1, v2); gxVertex2i(x1, y2); - gxTexcoord2i(u2, v2); gxVertex2i(x2, y2); - gxTexcoord2i(u2, v1); gxVertex2i(x2, y1); - - glEnd(); - - glPopMatrix(1); - g_depth++; -} - -#endif /* SDL_VIDEO_RENDER_NDS */ diff --git a/src/render/nds/SDL_libgl2D.h b/src/render/nds/SDL_libgl2D.h deleted file mode 100644 index 4d56f0e89..000000000 --- a/src/render/nds/SDL_libgl2D.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Note: The Nintendo DS port to SDL uses excerpts from the libGL2D, - * with permission of the original author. The following is mostly his - * code/comments. - * - * - * Easy GL2D - * - * Relminator 2010 - * Richard Eric M. Lope BSN RN - * - * http://rel.betterwebber.com - * - * A very small and simple DS rendering lib using the 3d core to render 2D stuff - */ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_NDS - -#include - -/* LibGL extension(s) */ -static inline void gxTexcoord2i(t16 u, t16 v) -{ - GFX_TEX_COORD = (v << 20) | ((u << 4) & 0xFFFF); -} - -static inline void gxVertex3i(v16 x, v16 y, v16 z) -{ - GFX_VERTEX16 = (y << 16) | (x & 0xFFFF); - GFX_VERTEX16 = ((uint32)(uint16)z); -} - -static inline void gxVertex2i(v16 x, v16 y) -{ - GFX_VERTEX_XY = (y << 16) | (x & 0xFFFF); -} - -/* - * Enums selecting flipping mode. - * - * These enums are bits for flipping the sprites. - * You can "|" (or) GL_FLIP_V and GL_FLIP_H to flip - * both ways. - */ -typedef enum -{ - GL_FLIP_NONE = (1 << 0), /* No flipping */ - GL_FLIP_V = (1 << 1), /* Sprite is rendered vertically flipped */ - GL_FLIP_H = (1 << 2), /* Sprite is rendered horizontally flipped */ -} GL_FLIP_MODE; - -/* Struct for out GL-Based Images. */ -typedef struct -{ - int width; /* Width of the Sprite */ - int height; /* Height of the Sprite */ - int textureID; /* Texture handle (used in glDeleteTextures()) - The texture handle in VRAM (returned by glGenTextures()) - ie. This references the actual texture stored in VRAM. */ -} glImage; - -extern v16 g_depth; -extern int gCurrentTexture; - -/* - * Draws an Axis Exclusive Scaled Sprite - * Parameters: - * x X position of the sprite. - * y Y position of the sprite. - * scaleX 20.12 fixed-point X-Axis scale value (1 << 12 is normal). - * scaleY 20.12 fixed-point Y-Axis scale value (1 << 12 is normal). - * flipmode mode for flipping (see GL_FLIP_MODE enum). - * *spr pointer to a glImage. -*/ -void glSpriteScaleXY(int x, int y, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr); - -/* Initializes our Tileset (like glInitSpriteset()) but without the use of Texture Packer auto-generated files. - * Can only be used when tiles in a tilset are of the same dimensions. - * Parameters: - * *sprite Pointer to an array of glImage. - * tile_wid Width of each tile in the texture. - * tile_hei Height of each tile in the texture. - * bmp_wid Width of of the texture or tileset. - * bmp_hei height of of the texture or tileset. - * type The format of the texture (see glTexImage2d()). - * sizeX The horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d()). - * sizeY The vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d()). - * param parameters for the texture (see glTexImage2d()). - * pallette_width Length of the palette. Valid values are 4, 16, 32, 256 (if 0, then palette is removed from currently bound texture). - * *palette Pointer to the palette data to load (if NULL, then palette is removed from currently bound texture). - * *texture Pointer to the texture data to load. -*/ -int glLoadTile(glImage *sprite, - int texture_width, - int texture_height, - int sprite_width, - int sprite_height, - GL_TEXTURE_TYPE_ENUM type, - int param, - int pallette_width, - const u16 *palette, - const uint8 *texture); - -/* Initializes GL in 2D mode */ -void glScreen2D(void); - -/* - * Sets up OpenGL for 2d rendering. - * - * Call this before drawing any of GL2D's drawing or sprite functions. - */ -void glBegin2D(void); - -/* - * Issue this after drawing 2d so that we don't mess the matrix stack. - * - * The complement of glBegin2D(). - */ -void glEnd2D(void); - -/* - * Draws a Pixel - * x X position of the pixel. - * y Y position of the pixel. - * color RGB15/ARGB16 color. - */ -void glPutPixel(int x, int y, int color); - -/* - * Draws a Line - * x1,y1 Top-Left coordinate of the line. - * x2,y2 Bottom-Right coordinate of the line. - * color RGB15/ARGB16 color. - */ -void glLine(int x1, int y1, int x2, int y2, int color); - -/* - * Draws a Box - * x1,y1 Top-Left coordinate of the box. - * x2,y2 Bottom-Right coordinate of the box. - * color RGB15/ARGB16 color. -*/ -void glBox(int x1, int y1, int x2, int y2, int color); - -/* - * Draws a Filled Box - * x1,y1 Top-Left coordinate of the box. - * x2,y2 Bottom-Right coordinate of the box. - * color RGB15/ARGB16 color. - */ -void glBoxFilled(int x1, int y1, int x2, int y2, int color); - -#endif /* SDL_VIDEO_RENDER_NDS */ diff --git a/src/render/nds/SDL_ndsrender.c b/src/render/nds/SDL_ndsrender.c deleted file mode 100644 index b888f0aa8..000000000 --- a/src/render/nds/SDL_ndsrender.c +++ /dev/null @@ -1,418 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_NDS - -#include -#include -#include - -#include "SDL_libgl2D.h" - -#include "SDL_video.h" -#include "../../video/SDL_sysvideo.h" -#include "SDL_render.h" -#include "../SDL_sysrender.h" -#include "SDL_log.h" - -/* Draws a partial sprite. Based on glSprite. */ -static void glSpritePartial(const SDL_Rect * srcrect, int x, int y, int flipmode, const glImage *spr) -{ - int x1 = x; - int y1 = y; - int x2 = x + srcrect->w; - int y2 = y + srcrect->h; - - int u1 = srcrect->x + ((flipmode & GL_FLIP_H) ? spr->width-1 : 0); - int u2 = srcrect->x + ((flipmode & GL_FLIP_H) ? 0 : srcrect->h); - int v1 = srcrect->y + ((flipmode & GL_FLIP_V) ? spr->height-1 : 0); - int v2 = srcrect->y + ((flipmode & GL_FLIP_V) ? 0 : srcrect->h); - - if (spr->textureID != gCurrentTexture) { - glBindTexture(GL_TEXTURE_2D, spr->textureID); - gCurrentTexture = spr->textureID; - } - - glBegin(GL_QUADS); - - gxTexcoord2i(u1, v1); gxVertex3i(x1, y1, g_depth); - gxTexcoord2i(u1, v2); gxVertex2i(x1, y2); - gxTexcoord2i(u2, v2); gxVertex2i(x2, y2); - gxTexcoord2i(u2, v1); gxVertex2i(x2, y1); - - glEnd(); - - g_depth++; -} - -/* SDL NDS renderer implementation */ - -extern SDL_RenderDriver NDS_RenderDriver; - -typedef struct -{ - /* Whether current 3D engine is on the main or sub screen. */ - int is_sub; -} NDS_RenderData; - -typedef struct -{ - glImage image[1]; -} NDS_TextureData; - -static int NDS_UpdateViewport(SDL_Renderer *renderer) -{ - /* Nothing to do. */ - return 0; -} - -static int -NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; - int dest_y; - - if (data->is_sub) { - dest_y = dstrect->y; - } else { - dest_y = dstrect->y-SCREEN_HEIGHT; - } - - if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { - /* No scaling */ - glSpritePartial(srcrect, dstrect->x, dest_y, GL_FLIP_NONE, txdat->image); - } else { - /* Convert the scaling proportion into a 20.12 value. */ - s32 scale_w = divf32(dstrect->w << 12, texture->w << 12); - s32 scale_h = divf32(dstrect->h << 12, texture->h << 12); - - glSpriteScaleXY(dstrect->x, dest_y, scale_w, scale_h, GL_FLIP_NONE, txdat->image); - } - - return 0; -} - -static int NDS_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) -{ - NDS_TextureData *txdat = NULL; - int i; - - SDL_Log("NDS_CreateTexture: NDS_CreateTexture.\n"); - - /* Sanity checks. */ - for (i=0; iformat == NDS_RenderDriver.info.texture_formats[i]) - break; - } - if (i == NDS_RenderDriver.info.num_texture_formats) { - SDL_SetError("Unsupported texture format (%x)", texture->format); - return -1; - } - - if (texture->w > NDS_RenderDriver.info.max_texture_width) { - SDL_SetError("Texture too large (%d)", texture->w); - return -1; - } - - if (texture->h > NDS_RenderDriver.info.max_texture_height) { - SDL_SetError("Texture too tall (%d)", texture->h); - return -1; - } - - texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData)); - txdat = (NDS_TextureData *) texture->driverdata; - if (!txdat) { - SDL_OutOfMemory(); - return -1; - } - - return 0; -} - -static void -NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - NDS_TextureData *txdat = texture->driverdata; - - /* free anything else allocated for texture */ - SDL_free(txdat); -} - -/* size is no more than 512. */ -static int get_gltexture_size(unsigned int size) -{ - if (size > 256) - return TEXTURE_SIZE_512; - else if (size > 128) - return TEXTURE_SIZE_256; - else if (size > 64) - return TEXTURE_SIZE_128; - else if (size > 32) - return TEXTURE_SIZE_64; - else if (size > 16) - return TEXTURE_SIZE_32; - else if (size > 8) - return TEXTURE_SIZE_16; - else - return TEXTURE_SIZE_8; -} - -static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; - char *new_pixels = NULL; - const int gl_w = get_gltexture_size(rect->w); - const int gl_h = get_gltexture_size(rect->h); - const int w = 1 << (3+gl_w); /* Texture sizes must be a power of 2. */ - const int h = 1 << (3+gl_h); /* Texture sizes must be a power of 2. */ - - if (w != rect->w || h != rect->h) { - /* Allocate a temporary surface and copy pixels into it while - * enlarging the pitch. */ - const char *src; - char *dst; - int new_pitch = 2 * w; - int i; - - new_pixels = malloc(2 * w * h); - if (!new_pixels) - return SDL_ENOMEM; - - src = pixels; - dst = new_pixels; - for (i=0; ih; i++) { - memcpy(dst, src, pitch); - src += pitch; - dst += new_pitch; - } - } - - glLoadTile(txdat->image, - gl_w, gl_h, - rect->w, rect->h, - texture->format == SDL_PIXELFORMAT_ABGR1555 ? GL_RGBA : GL_RGB, - TEXGEN_OFF, 0, NULL, - new_pixels? new_pixels : pixels); - - if (new_pixels) - free(new_pixels); - - return 0; -} - -static int NDS_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, void **pixels, int *pitch) -{ - SDL_Log("enter %s (todo)\n", __func__); - - return 0; -} - -static void NDS_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) -{ - SDL_Log("enter %s\n", __func__); - /* stub! */ -} - -static int NDS_RenderClear(SDL_Renderer *renderer) -{ - glClearColor(renderer->r >> 3, - renderer->g >> 3, - renderer->b >> 3, - renderer->a >> 3); - - return 0; -} - -static void NDS_RenderPresent(SDL_Renderer * renderer) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - - glEnd2D(); - - glFlush(0); - - swiWaitForVBlank(); - - /* wait for capture unit to be ready */ - while(REG_DISPCAPCNT & DCAP_ENABLE); - - /* 3D engine can only work on one screen at a time. */ - data->is_sub = !data->is_sub; - if (data->is_sub) { - lcdMainOnBottom(); - vramSetBankC(VRAM_C_LCD); - vramSetBankD(VRAM_D_SUB_SPRITE); - REG_DISPCAPCNT = DCAP_BANK(2) | DCAP_ENABLE | DCAP_SIZE(3); - } else { - lcdMainOnTop(); - vramSetBankD(VRAM_D_LCD); - vramSetBankC(VRAM_C_SUB_BG); - REG_DISPCAPCNT = DCAP_BANK(3) | DCAP_ENABLE | DCAP_SIZE(3); - } - - glBegin2D(); -} - -static int NDS_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, - int count) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - int i; - int color = RGB15(renderer->r >> 3, - renderer->g >> 3, - renderer->b >> 3); - - for (i=0; i < count; i++) { - if (data->is_sub) { - glPutPixel(points[i].x, points[i].y, color); - } else { - glPutPixel(points[i].x, points[i].y - SCREEN_HEIGHT, color); - } - } - - return 0; -} - -static int NDS_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, - int count) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - int i; - int color = RGB15(renderer->r >> 3, - renderer->g >> 3, - renderer->b >> 3); - - for (i=0; i < count-1; i++) { - if (data->is_sub) { - glLine(points[i].x, points[i].y, points[i+1].x, points[i+1].y, color); - } else { - glLine(points[i].x, points[i].y - SCREEN_HEIGHT, - points[i+1].x, points[i+1].y - SCREEN_HEIGHT, color); - } - } - - return 0; -} - -static int NDS_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, - int count) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - int i; - int color = RGB15(renderer->r >> 3, - renderer->g >> 3, - renderer->b >> 3); - - for (i=0; iis_sub) { - glBoxFilled(rects[i].x, rects[i].y, - rects[i].x + rects[i].w, - rects[i].y + rects[i].h, color); - } else { - glBoxFilled(rects[i].x, rects[i].y - SCREEN_HEIGHT, - rects[i].x + rects[i].w, - rects[i].y + rects[i].h - SCREEN_HEIGHT, - color); - } - } - - return 0; -} - -static SDL_Renderer * -NDS_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - SDL_DisplayMode *displayMode = &display->current_mode; - SDL_Renderer *renderer; - NDS_RenderData *data; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (displayMode->format != SDL_PIXELFORMAT_ABGR1555) { - SDL_SetError("Unsupported pixel format (%x)", displayMode->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) { - SDL_OutOfMemory(); - return NULL; - } - - data = (NDS_RenderData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - SDL_free(renderer); - SDL_OutOfMemory(); - return NULL; - } - - renderer->info = NDS_RenderDriver.info; - renderer->info.flags = SDL_RENDERER_ACCELERATED; - - renderer->CreateTexture = NDS_CreateTexture; - renderer->UpdateTexture = NDS_UpdateTexture; - renderer->LockTexture = NDS_LockTexture; - renderer->UnlockTexture = NDS_UnlockTexture; - renderer->UpdateViewport = NDS_UpdateViewport; - renderer->RenderClear = NDS_RenderClear; - renderer->RenderDrawPoints = NDS_RenderDrawPoints; - renderer->RenderDrawLines = NDS_RenderDrawLines; - renderer->RenderFillRects = NDS_RenderFillRects; - renderer->RenderCopy = NDS_RenderCopy; - /* renderer->RenderReadPixels = NDS_RenderReadPixels; - todo ? */ - renderer->RenderPresent = NDS_RenderPresent; - renderer->DestroyTexture = NDS_DestroyTexture; - /* renderer->DestroyRenderer = NDS_DestroyRenderer; - todo ? */ - - renderer->driverdata = data; - - return renderer; -} - -SDL_RenderDriver NDS_RenderDriver = { - .CreateRenderer = NDS_CreateRenderer, - .info = { - .name = "nds", - .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC, - .num_texture_formats = 2, - .texture_formats = { [0] = SDL_PIXELFORMAT_ABGR1555, - [1] = SDL_PIXELFORMAT_BGR555, - }, - .max_texture_width = 512, - .max_texture_height = 512, - } -}; - -#endif /* SDL_VIDEO_RENDER_NDS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 9f8bff878..e050de735 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -44,11 +44,7 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags) /* Initialize some defaults */ state->argv = argv; state->flags = flags; -#ifdef __NDS__ - state->window_title = ""; -#else state->window_title = argv[0]; -#endif state->window_flags = 0; state->window_x = SDL_WINDOWPOS_UNDEFINED; state->window_y = SDL_WINDOWPOS_UNDEFINED; @@ -87,10 +83,6 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) { char **argv = state->argv; -#ifdef __NDS__ - return 0; -#endif - if (SDL_strcasecmp(argv[index], "--video") == 0) { ++index; if (!argv[index]) { diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index f1c1c1ddf..64fb77894 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -34,8 +34,6 @@ #include "pthread/SDL_systhread_c.h" #elif SDL_THREAD_WINDOWS #include "windows/SDL_systhread_c.h" -#elif SDL_THREAD_NDS -#include "nds/SDL_systhread_c.h" #elif SDL_THREAD_PSP #include "psp/SDL_systhread_c.h" #else diff --git a/src/thread/nds/SDL_syscond.c b/src/thread/nds/SDL_syscond.c deleted file mode 100644 index 6f41eaa5b..000000000 --- a/src/thread/nds/SDL_syscond.c +++ /dev/null @@ -1,230 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $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 */ -/* - This implementation borrows heavily from the BeOS condition variable - implementation, written by Christopher Tate and Owen Smith. Thanks! - */ - -#include -#include - -#include "SDL_error.h" -#include "SDL_thread.h" - -struct SDL_cond -{ - 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 *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) -{ - 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) -{ - 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); - } - - return 0; -} - -/* Restart all threads that are waiting on the condition variable */ -int -SDL_CondBroadcast(SDL_cond * cond) -{ - 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; - - 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; -} - -/* Wait on the condition variable for at most 'ms' milliseconds. - The mutex must be locked before entering this function! - The mutex is unlocked during the wait, and locked again after the wait. - -Typical use: - -Thread A: - SDL_LockMutex(lock); - while ( ! condition ) { - SDL_CondWait(cond); - } - SDL_UnlockMutex(lock); - -Thread B: - SDL_LockMutex(lock); - ... - condition = true; - ... - SDL_UnlockMutex(lock); - */ -int -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) -{ - int retval; - - 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); - - /* 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); - } - - /* 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); - - /* Lock the mutex, as is required by condition variable semantics */ - SDL_LockMutex(mutex); - - return retval; -} - -/* Wait on the condition variable forever */ -int -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) -{ - return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/nds/SDL_syscond_c.h b/src/thread/nds/SDL_syscond_c.h deleted file mode 100644 index d842d5929..000000000 --- a/src/thread/nds/SDL_syscond_c.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $Id: SDL_syscond_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $"; -#endif diff --git a/src/thread/nds/SDL_sysmutex.c b/src/thread/nds/SDL_sysmutex.c deleted file mode 100644 index ffdecc808..000000000 --- a/src/thread/nds/SDL_sysmutex.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $Id: SDL_sysmutex.c,v 1.2 2001/04/26 16:50:18 hercules Exp $"; -#endif - -/* An implementation of mutexes using semaphores */ - -#include -#include - -#include "SDL_error.h" -#include "SDL_thread.h" -#include "SDL_systhread_c.h" - - -struct SDL_mutex -{ - int recursive; - SDL_threadID owner; - SDL_sem *sem; -}; - -/* Create a mutex */ -SDL_mutex * -SDL_CreateMutex(void) -{ - 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; -} - -/* Free the mutex */ -void -SDL_DestroyMutex(SDL_mutex * mutex) -{ - if (mutex) { - if (mutex->sem) { - SDL_DestroySemaphore(mutex->sem); - } - free(mutex); - } -} - -/* Lock the mutex */ -int -SDL_LockMutex(SDL_mutex * mutex) -{ -#ifdef DISABLE_THREADS - return 0; -#else - SDL_threadID this_thread; - - 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; - } - - return 0; -#endif /* DISABLE_THREADS */ -} - -/* Try Lock the mutex */ -int -SDL_TryLockMutex(SDL_mutex * mutex) -{ -#ifdef DISABLE_THREADS - return 0; -#else - int retval = 0; - SDL_threadID this_thread; - - 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. - */ - retval = SDL_SemTryWait(mutex->sem); - if (ret == 0) { - mutex->owner = this_thread; - mutex->recursive = 0; - } - } - - return retval; -#endif /* DISABLE_THREADS */ -} - -/* Unlock the mutex */ -int -SDL_UnlockMutex(SDL_mutex * mutex) -{ -#ifdef DISABLE_THREADS - return 0; -#else - 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 (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 */ -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/nds/SDL_sysmutex_c.h b/src/thread/nds/SDL_sysmutex_c.h deleted file mode 100644 index d310519af..000000000 --- a/src/thread/nds/SDL_sysmutex_c.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $Id: SDL_sysmutex_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $"; -#endif diff --git a/src/thread/nds/SDL_syssem.c b/src/thread/nds/SDL_syssem.c deleted file mode 100644 index 788fc9223..000000000 --- a/src/thread/nds/SDL_syssem.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $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 */ - -#include - -#include "SDL_error.h" -#include "SDL_timer.h" -#include "SDL_thread.h" -#include "SDL_systhread_c.h" - - -#ifdef DISABLE_THREADS - -SDL_sem * -SDL_CreateSemaphore(Uint32 initial_value) -{ - SDL_SetError("SDL not configured with thread support"); - return (SDL_sem *) 0; -} - -void -SDL_DestroySemaphore(SDL_sem * sem) -{ - return; -} - -int -SDL_SemTryWait(SDL_sem * sem) -{ - SDL_SetError("SDL not configured with thread support"); - return -1; -} - -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) -{ - SDL_SetError("SDL not configured with thread support"); - return -1; -} - -int -SDL_SemWait(SDL_sem * sem) -{ - SDL_SetError("SDL not configured with thread support"); - return -1; -} - -Uint32 -SDL_SemValue(SDL_sem * sem) -{ - return 0; -} - -int -SDL_SemPost(SDL_sem * sem) -{ - 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; -}; - -SDL_sem * -SDL_CreateSemaphore(Uint32 initial_value) -{ - SDL_sem *sem; - - 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); - } - - return (sem); -} - -/* WARNING: - You cannot call this function when another thread is using the semaphore. -*/ -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_LockMutex(sem->count_lock); - SDL_UnlockMutex(sem->count_lock); - SDL_DestroyMutex(sem->count_lock); - free(sem); - } -} - -int -SDL_SemTryWait(SDL_sem * sem) -{ - int retval; - - 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); - - return retval; -} - -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) -{ - int retval; - - 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); - } - - 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; -} - -int -SDL_SemWait(SDL_sem * sem) -{ - return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); -} - -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; -} - -int -SDL_SemPost(SDL_sem * sem) -{ - 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); - - return 0; -} - -#endif /* DISABLE_THREADS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/nds/SDL_syssem_c.h b/src/thread/nds/SDL_syssem_c.h deleted file mode 100644 index b12f9ce6d..000000000 --- a/src/thread/nds/SDL_syssem_c.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $Id: SDL_syssem_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $"; -#endif diff --git a/src/thread/nds/SDL_systhread.c b/src/thread/nds/SDL_systhread.c deleted file mode 100644 index e94dcd774..000000000 --- a/src/thread/nds/SDL_systhread.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $Id: SDL_systhread.c,v 1.2 2001/04/26 16:50:18 hercules Exp $"; -#endif - -/* Thread management routines for SDL */ - -#include "SDL_error.h" -#include "SDL_thread.h" -#include "../SDL_systhread.h" - -int -SDL_SYS_CreateThread(SDL_Thread * thread, void *args) -{ - SDL_SetError("Threads are not supported on this platform"); - return (-1); -} - -void -SDL_SYS_SetupThread(const char *name) -{ - return; -} - -SDL_threadID -SDL_ThreadID(void) -{ - return (0); -} - -void -SDL_SYS_WaitThread(SDL_Thread * thread) -{ - return; -} - -int -SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) -{ - return (0); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/nds/SDL_systhread_c.h b/src/thread/nds/SDL_systhread_c.h deleted file mode 100644 index 8aaf10d9d..000000000 --- a/src/thread/nds/SDL_systhread_c.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* Stub until we implement threads on this platform */ -typedef int SYS_ThreadHandle; - -#ifndef DISABLE_THREADS -#define DISABLE_THREADS -#endif diff --git a/src/timer/nds/SDL_systimer.c b/src/timer/nds/SDL_systimer.c deleted file mode 100644 index a44695593..000000000 --- a/src/timer/nds/SDL_systimer.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#ifdef SDL_TIMER_NDS - -#include -#include - -#include "SDL_timer.h" - -/* Will wrap after 49 days. Shouldn't be an issue. */ -static volatile Uint32 timer_ticks; - -static void -NDS_TimerInterrupt(void) -{ - timer_ticks++; -} - -void -SDL_StartTicks(void) -{ - timer_ticks = 0; - - /* Set timer 2 to fire every ms. */ - timerStart(2, ClockDivider_1024, TIMER_FREQ_1024(1000), NDS_TimerInterrupt); -} - -Uint32 -SDL_GetTicks(void) -{ - return timer_ticks; -} - -Uint64 -SDL_GetPerformanceCounter(void) -{ - return SDL_GetTicks(); -} - -Uint64 -SDL_GetPerformanceFrequency(void) -{ - return 1000; -} - -void -SDL_Delay(Uint32 ms) -{ - Uint32 start = SDL_GetTicks(); - while (1) { - if ((SDL_GetTicks() - start) >= ms) - break; - } -} - -#endif /* SDL_TIMER_NDS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 20c90e9c8..b51c5e4cd 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -341,9 +341,6 @@ extern VideoBootStrap BWINDOW_bootstrap; #if SDL_VIDEO_DRIVER_PANDORA extern VideoBootStrap PND_bootstrap; #endif -#if SDL_VIDEO_DRIVER_NDS -extern VideoBootStrap NDS_bootstrap; -#endif #if SDL_VIDEO_DRIVER_UIKIT extern VideoBootStrap UIKIT_bootstrap; #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 4ca466384..1877a5870 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -69,9 +69,6 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_PANDORA &PND_bootstrap, #endif -#if SDL_VIDEO_DRIVER_NDS - &NDS_bootstrap, -#endif #if SDL_VIDEO_DRIVER_UIKIT &UIKIT_bootstrap, #endif diff --git a/src/video/nds/SDL_ndsevents.c b/src/video/nds/SDL_ndsevents.c deleted file mode 100644 index 97933a46a..000000000 --- a/src/video/nds/SDL_ndsevents.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_DRIVER_NDS - -#include -#include -#include - -#include "../../events/SDL_events_c.h" - -#include "SDL_ndsvideo.h" -#include "SDL_ndsevents_c.h" - -void -NDS_PumpEvents(_THIS) -{ - scanKeys(); - /* TODO: defer click-age */ - if (keysDown() & KEY_TOUCH) { - SDL_SendMouseButton(NULL, 0, SDL_PRESSED, 0); - } else if (keysUp() & KEY_TOUCH) { - SDL_SendMouseButton(NULL, 0, SDL_RELEASED, 0); - } - if (keysHeld() & KEY_TOUCH) { - touchPosition t; - - touchRead(&t); - SDL_SendMouseMotion(NULL, 0, 0, t.px, t.py); - } -} - -#endif /* SDL_VIDEO_DRIVER_NDS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nds/SDL_ndsevents_c.h b/src/video/nds/SDL_ndsevents_c.h deleted file mode 100644 index 5c222a598..000000000 --- a/src/video/nds/SDL_ndsevents_c.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#include "SDL_ndsvideo.h" - -extern void NDS_PumpEvents(_THIS); - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nds/SDL_ndsvideo.c b/src/video/nds/SDL_ndsvideo.c deleted file mode 100644 index 9fd412442..000000000 --- a/src/video/nds/SDL_ndsvideo.c +++ /dev/null @@ -1,401 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_DRIVER_NDS - -/* SDL Nintendo DS video driver implementation */ - -#include -#include -#include -#include - -#include "SDL_video.h" -#include "SDL_ndsvideo.h" -#include "SDL_ndsevents_c.h" -#include "../../render/SDL_sysrender.h" -#include "../../render/nds/SDL_libgl2D.h" -#include "SDL_log.h" - -#define NDSVID_DRIVER_NAME "nds" - -static SDL_DisplayMode display_modes[] = -{ - /* Only one screen */ - { - .format = SDL_PIXELFORMAT_ABGR1555, - .w = SCREEN_WIDTH, - .h = SCREEN_HEIGHT, - .refresh_rate = 60, - }, - - /* Aggregated display (two screens) with no gap. */ - { - .format = SDL_PIXELFORMAT_ABGR1555, - .w = SCREEN_WIDTH, - .h = 2*SCREEN_HEIGHT+SCREEN_GAP, - .refresh_rate = 60, - }, - - /* Aggregated display (two screens) with a gap. */ - { - .format = SDL_PIXELFORMAT_ABGR1555, - .w = SCREEN_WIDTH, - .h = 2*SCREEN_HEIGHT, - .refresh_rate = 60, - }, - - /* Last entry */ - { - .w = 0, - } -}; - -/* This function must not be optimized nor inlined, else the pointer - * to the message will be in the wrong register, and the emulator won't - * find the string. */ -__attribute__ ((noinline, optimize (0))) -static void NDS_DebugOutput2(const char* message) -{ -#ifdef __thumb__ - asm volatile ("swi #0xfc"); -#else - asm volatile ("swi #0xfc0000"); -#endif -} - -static void NDS_DebugOutput(void *userdata, int category, SDL_LogPriority priority, const char *message) -{ - NDS_DebugOutput2(message); -} - -/* SDL NDS driver bootstrap functions */ -static int NDS_Available(void) -{ - return 1; /* always here */ -} - -#ifndef USE_HW_RENDERER -static int NDS_CreateWindowFramebuffer(_THIS, SDL_Window *window, - Uint32 *format, void **pixels, - int *pitch) -{ - struct NDS_WindowData *wdata; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - const SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - const SDL_DisplayMode *mode = display->driverdata; - const Uint32 fmt = mode->format; - - if (fmt != SDL_PIXELFORMAT_ABGR1555) { - SDL_SetError("Unsupported pixel format (%x)", fmt); - return -1; - } - - if (!SDL_PixelFormatEnumToMasks - (fmt, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown texture format"); - return -1; - } - - wdata = SDL_calloc(1, sizeof(struct NDS_WindowData)); - if (!wdata) { - SDL_OutOfMemory(); - return -1; - } - - if (bpp == 8) { - wdata->pixels_length = (SCREEN_HEIGHT+SCREEN_GAP+SCREEN_HEIGHT)*SCREEN_WIDTH; - } else { - wdata->pixels_length = (SCREEN_HEIGHT+SCREEN_GAP+SCREEN_HEIGHT)*SCREEN_WIDTH*2; - } - wdata->pixels = SDL_calloc(1, wdata->pixels_length); - if (!wdata->pixels) { - SDL_free(wdata); - SDL_SetError("Not enough memory"); - return -1; - } - - if (bpp == 8) { - wdata->main.bg_id = bgInit(2, BgType_Bmp8, BgSize_B8_256x256, 0, 0); - wdata->sub.bg_id = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0); - - wdata->main.length = SCREEN_HEIGHT*SCREEN_WIDTH; - wdata->main.pixels = wdata->pixels; - - wdata->sub.length = SCREEN_HEIGHT*SCREEN_WIDTH; - wdata->sub.pixels = (u8 *)wdata->pixels + wdata->main.length; /* or ...+SCREEN_GAP */ - - } else { - wdata->main.bg_id = bgInit(2, BgType_Bmp16, BgSize_B16_256x256, 0, 0); - wdata->sub.bg_id = bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); - - wdata->main.length = SCREEN_HEIGHT*SCREEN_WIDTH*2; - wdata->main.pixels = wdata->pixels; - - wdata->sub.length = SCREEN_HEIGHT*SCREEN_WIDTH*2; - wdata->sub.pixels = (u8 *)wdata->pixels + wdata->main.length; /* or ...+SCREEN_GAP */ - } - - wdata->pitch = (window->w) * ((bpp+1) / 8); - wdata->bpp = bpp; - wdata->rotate = 0; - wdata->scale.x = 0x100; - wdata->scale.y = 0x100; - wdata->scroll.x = 0; - wdata->scroll.y = 0; - - wdata->main.vram_pixels = bgGetGfxPtr(wdata->main.bg_id); - wdata->sub.vram_pixels = bgGetGfxPtr(wdata->sub.bg_id); - -#if 0 - bgSetCenter(wdata->main.bg_id, 0, 0); - bgSetRotateScale(wdata->main.bg_id, wdata->rotate, wdata->scale.x, - wdata->scale.y); - bgSetScroll(wdata->main.bg_id, wdata->scroll.x, wdata->scroll.y); -#endif - -#if 0 - bgSetCenter(wdata->sub.bg_id, 0, 0); - bgSetRotateScale(wdata->sub.bg_id, wdata->rotate, wdata->scale.x, - wdata->scale.y); - bgSetScroll(wdata->sub.bg_id, wdata->scroll.x, wdata->scroll.y); -#endif - - bgUpdate(); - - *format = fmt; - *pixels = wdata->pixels; - *pitch = wdata->pitch; - - window->driverdata = wdata; - - return 0; -} - -static int NDS_UpdateWindowFramebuffer(_THIS, SDL_Window * window, - SDL_Rect * rects, int numrects) -{ - struct NDS_WindowData *wdata = window->driverdata; - - /* Copy everything. TODO: use rects/numrects. */ - DC_FlushRange(wdata->pixels, wdata->pixels_length); - - swiWaitForVBlank(); - - dmaCopy(wdata->main.pixels, wdata->main.vram_pixels, wdata->main.length); - dmaCopy(wdata->sub.pixels, wdata->sub.vram_pixels, wdata->sub.length); - - return 0; -} - -static void NDS_DestroyWindowFramebuffer(_THIS, SDL_Window *window) -{ - struct NDS_WindowData *wdata = window->driverdata; - - SDL_free(wdata->pixels); - SDL_free(wdata); -} -#endif - -#ifdef USE_HW_RENDERER -/* Set up a 2D layer construced of bitmap sprites. This holds the - * image when rendering to the top screen. From libnds example. - */ -static void initSubSprites(void) -{ - oamInit(&oamSub, SpriteMapping_Bmp_2D_256, false); - - int x = 0; - int y = 0; - - int id = 0; - - //set up a 4x3 grid of 64x64 sprites to cover the screen - for(y = 0; y < 3; y++) - for(x = 0; x < 4; x++) - { - oamSub.oamMemory[id].attribute[0] = ATTR0_BMP | ATTR0_SQUARE | (64 * y); - oamSub.oamMemory[id].attribute[1] = ATTR1_SIZE_64 | (64 * x); - oamSub.oamMemory[id].attribute[2] = ATTR2_ALPHA(1) | (8 * 32 * y) | (8 * x); - id++; - } - - swiWaitForVBlank(); - - oamUpdate(&oamSub); -} -#endif - -static int NDS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) -{ - display->driverdata = mode->driverdata; - - powerOn(POWER_ALL_2D); - -#ifdef USE_HW_RENDERER - - videoSetMode(MODE_5_3D); - videoSetModeSub(MODE_5_2D); - - /* initialize gl2d */ - glScreen2D(); - glBegin2D(); - - vramSetBankA(VRAM_A_TEXTURE); - vramSetBankB(VRAM_B_TEXTURE ); - vramSetBankC(VRAM_C_SUB_BG_0x06200000); - vramSetBankE(VRAM_E_TEX_PALETTE); - - // sub sprites hold the bottom image when 3D directed to top - initSubSprites(); - - // sub background holds the top image when 3D directed to bottom - bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); -#else - - /* Select mode 5 for both screens. Can do Extended Rotation - * Background on both (BG 2 and 3). */ - videoSetMode(MODE_5_2D); - videoSetModeSub(MODE_5_2D); - - vramSetBankA(VRAM_A_MAIN_BG_0x06000000); - vramSetBankB(VRAM_B_TEXTURE ); - vramSetBankC(VRAM_C_SUB_BG_0x06200000); - vramSetBankE(VRAM_E_TEX_PALETTE); - -#endif - - return 0; -} - -void NDS_GetDisplayModes(_THIS, SDL_VideoDisplay * display) -{ - SDL_DisplayMode *mode; - - for (mode = display_modes; mode->w; mode++) { - mode->driverdata = mode; /* point back to self */ - SDL_AddDisplayMode(display, mode); - } -} - -static int NDS_VideoInit(_THIS) -{ - SDL_VideoDisplay display; - SDL_DisplayMode mode; - - SDL_zero(mode); - - mode.format = SDL_PIXELFORMAT_UNKNOWN; // should be SDL_PIXELFORMAT_ABGR1555; - mode.w = SCREEN_WIDTH; - mode.h = 2*SCREEN_HEIGHT+SCREEN_GAP; - mode.refresh_rate = 60; - - SDL_zero(display); - - display.desktop_mode = mode; - - SDL_AddVideoDisplay(&display); - - return 0; -} - -static void NDS_VideoQuit(_THIS) -{ - videoSetMode(DISPLAY_SCREEN_OFF); - videoSetModeSub(DISPLAY_SCREEN_OFF); - vramSetBankA(VRAM_A_LCD); - vramSetBankB(VRAM_B_LCD); - vramSetBankC(VRAM_C_LCD); - vramSetBankD(VRAM_D_LCD); - vramSetBankE(VRAM_E_LCD); - vramSetBankF(VRAM_F_LCD); - vramSetBankG(VRAM_G_LCD); - vramSetBankH(VRAM_H_LCD); - vramSetBankI(VRAM_I_LCD); -} - -static void NDS_DeleteDevice(SDL_VideoDevice * device) -{ - SDL_free(device); -} - -static SDL_VideoDevice *NDS_CreateDevice(int devindex) -{ - SDL_VideoDevice *device; - - fatInitDefault(); - - /* Initialize all variables that we clean on shutdown */ - device = SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (!device) { - SDL_OutOfMemory(); - return NULL; - } - - device->driverdata = SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (!device) { - SDL_free(device); - SDL_OutOfMemory(); - return NULL; - } - - /* Set the function pointers */ - device->VideoInit = NDS_VideoInit; - device->VideoQuit = NDS_VideoQuit; - device->GetDisplayModes = NDS_GetDisplayModes; - device->SetDisplayMode = NDS_SetDisplayMode; - device->CreateWindow = NDS_CreateWindow; -#ifndef USE_HW_RENDERER - device->CreateWindowFramebuffer = NDS_CreateWindowFramebuffer; - device->UpdateWindowFramebuffer = NDS_UpdateWindowFramebuffer; - device->DestroyWindowFramebuffer = NDS_DestroyWindowFramebuffer; -#endif - device->PumpEvents = NDS_PumpEvents; - device->free = NDS_DeleteDevice; - - /* Set the debug output. Use only under an emulator. Will crash the DS. */ -#if 0 - SDL_LogSetOutputFunction(NDS_DebugOutput, NULL); -#endif - - return device; -} - -VideoBootStrap NDS_bootstrap = { - NDSVID_DRIVER_NAME, "SDL NDS video driver", - NDS_Available, NDS_CreateDevice -}; - -double SDLCALL SDL_pow(double x, double y) -{ - static int once = 1; - if (once) { - SDL_Log("SDL_pow called but not supported on this platform"); - once = 0; - } - return 0; -} - -#endif /* SDL_VIDEO_DRIVER_NDS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nds/SDL_ndsvideo.h b/src/video/nds/SDL_ndsvideo.h deleted file mode 100644 index d0795c064..000000000 --- a/src/video/nds/SDL_ndsvideo.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#ifndef _SDL_ndsvideo_h -#define _SDL_ndsvideo_h - -#include "../SDL_sysvideo.h" - -#include "SDL_ndswindow.h" - -#define SCREEN_GAP 92 /* line-equivalent gap between the 2 screens */ - -/* Per Window information. */ -struct NDS_WindowData { - struct { - int bg_id; - void *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */ - void *pixels; /* area in user frame buffer */ - int length; - } main, sub; - - int pitch, bpp; /* useful information about the texture */ - struct { - int x, y; - } scale; /* x/y stretch (24.8 fixed point) */ - - struct { - int x, y; - } scroll; /* x/y offset */ - int rotate; /* -32768 to 32767, texture rotation */ - - /* user frame buffer - todo: better way to do double buffering */ - void *pixels; - int pixels_length; -}; - - -#endif /* _SDL_ndsvideo_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nds/SDL_ndswindow.c b/src/video/nds/SDL_ndswindow.c deleted file mode 100644 index a76c08f05..000000000 --- a/src/video/nds/SDL_ndswindow.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_DRIVER_NDS - -#include "SDL_ndsvideo.h" - - -int NDS_CreateWindow(_THIS, SDL_Window * window) -{ - /* Nintendo DS windows are always fullscreen */ - window->flags |= SDL_WINDOW_FULLSCREEN; - return 0; -} - -#endif /* SDL_VIDEO_DRIVER_NDS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nds/SDL_ndswindow.h b/src/video/nds/SDL_ndswindow.h deleted file mode 100644 index 19bd49290..000000000 --- a/src/video/nds/SDL_ndswindow.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#ifndef _SDL_ndswindow_h -#define _SDL_ndswindow_h - -extern int NDS_CreateWindow(_THIS, SDL_Window * window); - -#endif /* _SDL_ndswindow_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/nds-test-progs/Makefile b/test/nds-test-progs/Makefile deleted file mode 100644 index ab7725a67..000000000 --- a/test/nds-test-progs/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -SUBDIRS:= $(shell ls | egrep -v '^(CVS)$$') - -all: - for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; - -clean: - for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; diff --git a/test/nds-test-progs/general/Makefile b/test/nds-test-progs/general/Makefile deleted file mode 100755 index 0dcaac884..000000000 --- a/test/nds-test-progs/general/Makefile +++ /dev/null @@ -1,131 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# INCLUDES is a list of directories containing extra header files -#--------------------------------------------------------------------------------- -TARGET := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -DATA := data -INCLUDES := include - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork - -# note: arm9tdmi isn't the correct CPU arch, but anything newer and LD -# *insists* it has a FPU or VFP, and it won't take no for an answer! -CFLAGS := -save-temps -g -Wall -O0\ - -mcpu=arm9tdmi -mtune=arm9tdmi \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM9 -D__NDS__ -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-exceptions -fno-rtti - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -LIBS := -lSDL -lfat -lnds9 - - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9 $(TARGET).ds.gba - - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).ds.gba : $(OUTPUT).nds -$(OUTPUT).nds : $(OUTPUT).arm9 -$(OUTPUT).arm9 : $(OUTPUT).elf -$(OUTPUT).elf : $(OFILES) - -#--------------------------------------------------------------------------------- -%.pcx.o : %.pcx -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- diff --git a/test/nds-test-progs/general/source/main.c b/test/nds-test-progs/general/source/main.c deleted file mode 100644 index 087dc4da1..000000000 --- a/test/nds-test-progs/general/source/main.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Really basic sample for the NDS. - * - * Fills a rectangle increasingly smaller of random color every time a - * button (a, b, x, y) is pressed. - * - * The behaviour whether SDL is compiled with HW support or not (see - * USE_HW_RENDERER in Makefile.ds). - * - * In framebuffer mode, the old rectangles stay because the screen has - * not been cleared. - * - * In accelerated mode, old the last rectangle is visible. - * - * No text is displayed. - */ - -#include -#if defined(NDS) || defined(__NDS__) || defined (__NDS) -#include -#include -#else -#define consoleDemoInit() -#define fatInitDefault() -#define RGB15(r,g,b) SDL_MapRGB(screen->format,((r)<<3),((g)<<3),((b)<<3)) -#endif - -int main(void) -{ - SDL_Window *window; - SDL_Renderer *renderer; - SDL_Joystick *stick; - SDL_Event event; - SDL_Rect rect = { 0, 0, 256, 192 }; - int i; - - consoleDemoInit(); - puts("Hello world! Initializing FAT..."); - - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { - puts("# error initializing SDL"); - puts(SDL_GetError()); - return 1; - } - puts("* initialized SDL"); - - if (SDL_CreateWindowAndRenderer(256, 192, SDL_RENDERER_ACCELERATED, &window, &renderer) < 0 && - SDL_CreateWindowAndRenderer(256, 192, SDL_RENDERER_SOFTWARE, &window, &renderer) < 0) { - exit(1); - } - - stick = SDL_JoystickOpen(0); - if (stick == NULL) { - puts("# error opening joystick"); - puts(SDL_GetError()); - } - puts("* opened joystick"); - - SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); - SDL_RenderFillRect(renderer, &rect); - SDL_RenderPresent(renderer); - - while (1) - while (SDL_PollEvent(&event)) - switch (event.type) { - case SDL_JOYBUTTONDOWN: - - SDL_SetRenderDrawColor(renderer, rand(), rand(), rand(), SDL_ALPHA_OPAQUE); - SDL_RenderFillRect(renderer, &rect); - SDL_RenderPresent(renderer); - 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.button, SDL_GetTicks()); - */ - break; - case SDL_QUIT: - SDL_Quit(); - return 0; - default: - break; - } - return 0; -} diff --git a/test/nds-test-progs/testscale/Makefile b/test/nds-test-progs/testscale/Makefile deleted file mode 100644 index 31a123220..000000000 --- a/test/nds-test-progs/testscale/Makefile +++ /dev/null @@ -1,147 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# INCLUDES is a list of directories containing extra header files -# DATA is a list of directories containing binary files embedded using bin2o -# GRAPHICS is a list of directories containing image files to be converted with grit -#--------------------------------------------------------------------------------- -TARGET := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include ../.. -DATA := data -GRAPHICS := gfx - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O2\ - -fomit-frame-pointer\ - -ffast-math \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM9 -D__NDS__ -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lSDL -lfat -lnds9 - - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ - $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := ../../../common.c ../../../testscale.c - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(PNGFILES:.png=.o) \ - $(BMPFILES:.bmp=.o) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) \ - -I$(PORTLIBS)/include/SDL - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds : $(OUTPUT).elf -$(OUTPUT).elf : $(OFILES) - -#--------------------------------------------------------------------------------- -%.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - $(bin2o) - -#--------------------------------------------------------------------------------- -# This rule creates assembly source files using grit -# grit takes an image file and a .grit describing how the file is to be processed -# add additional rules like this for each image extension -# you use in the graphics folders -#--------------------------------------------------------------------------------- -%.s %.h : %.bmp %.grit -#--------------------------------------------------------------------------------- - grit $< -fts -o$* - - -#--------------------------------------------------------------------------------- -%.s %.h : %.png %.grit -#--------------------------------------------------------------------------------- - grit $< -fts -o$* - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- diff --git a/test/nds-test-progs/testsprite2/Makefile b/test/nds-test-progs/testsprite2/Makefile deleted file mode 100644 index b765e6c84..000000000 --- a/test/nds-test-progs/testsprite2/Makefile +++ /dev/null @@ -1,152 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# INCLUDES is a list of directories containing extra header files -# DATA is a list of directories containing binary files embedded using bin2o -# GRAPHICS is a list of directories containing image files to be converted with grit -#--------------------------------------------------------------------------------- -TARGET := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include ../.. -DATA := data -GRAPHICS := gfx - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O2\ - -fomit-frame-pointer\ - -ffast-math \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM9 -D__NDS__ -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lSDL -lfat -lnds9 - - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ - $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := ../../../common.c ../../../testsprite2.c -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png))) -BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(PNGFILES:.png=.o) \ - $(BMPFILES:.bmp=.o) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) \ - -I$(PORTLIBS)/include/SDL - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds : $(OUTPUT).elf -$(OUTPUT).elf : $(OFILES) - -#--------------------------------------------------------------------------------- -%.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - $(bin2o) - -#--------------------------------------------------------------------------------- -# This rule creates assembly source files using grit -# grit takes an image file and a .grit describing how the file is to be processed -# add additional rules like this for each image extension -# you use in the graphics folders -#--------------------------------------------------------------------------------- -%.s %.h : %.bmp %.grit -#--------------------------------------------------------------------------------- - grit $< -fts -o$* - - -#--------------------------------------------------------------------------------- -%.s %.h : %.png %.grit -#--------------------------------------------------------------------------------- - grit $< -fts -o$* - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- diff --git a/test/nds-test-progs/testspriteminimal/Makefile b/test/nds-test-progs/testspriteminimal/Makefile deleted file mode 100644 index e54101f9e..000000000 --- a/test/nds-test-progs/testspriteminimal/Makefile +++ /dev/null @@ -1,147 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# INCLUDES is a list of directories containing extra header files -# DATA is a list of directories containing binary files embedded using bin2o -# GRAPHICS is a list of directories containing image files to be converted with grit -#--------------------------------------------------------------------------------- -TARGET := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := source -INCLUDES := include -DATA := data -GRAPHICS := gfx - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork -march=armv5te -mtune=arm946e-s - -CFLAGS := -g -Wall -O2\ - -fomit-frame-pointer\ - -ffast-math \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM9 -D__NDS__ -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project (order is important) -#--------------------------------------------------------------------------------- -LIBS := -lSDL -lfat -lnds9 - - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) $(PORTLIBS) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ - $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := ../../../testspriteminimal.c - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(PNGFILES:.png=.o) \ - $(BMPFILES:.bmp=.o) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) \ - -I$(PORTLIBS)/include/SDL - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -.PHONY: $(BUILD) clean - -#--------------------------------------------------------------------------------- -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT).nds : $(OUTPUT).elf -$(OUTPUT).elf : $(OFILES) - -#--------------------------------------------------------------------------------- -%.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - $(bin2o) - -#--------------------------------------------------------------------------------- -# This rule creates assembly source files using grit -# grit takes an image file and a .grit describing how the file is to be processed -# add additional rules like this for each image extension -# you use in the graphics folders -#--------------------------------------------------------------------------------- -%.s %.h : %.bmp %.grit -#--------------------------------------------------------------------------------- - grit $< -fts -o$* - - -#--------------------------------------------------------------------------------- -%.s %.h : %.png %.grit -#--------------------------------------------------------------------------------- - grit $< -fts -o$* - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 48e996c01..76244c282 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -17,13 +17,8 @@ #include "SDL.h" -#ifdef __NDS__ -#define WINDOW_WIDTH 256 -#define WINDOW_HEIGHT (2*192) -#else #define WINDOW_WIDTH 640 #define WINDOW_HEIGHT 480 -#endif #define NUM_SPRITES 100 #define MAX_SPEED 1