Temporarily removing sprite and sprite2 at Frank's request
authorSam Lantinga <slouken@libsdl.org>
Sat, 26 Mar 2011 21:27:23 -0700
changeset 551689ad52a52876
parent 5515 0fcf231a6e74
child 5517 aa339c0dca2d
Temporarily removing sprite and sprite2 at Frank's request
test/nds-test-progs/sprite/Makefile
test/nds-test-progs/sprite/source/common.c
test/nds-test-progs/sprite/source/common.h
test/nds-test-progs/sprite/source/testsprite.c
test/nds-test-progs/sprite2/Makefile
test/nds-test-progs/sprite2/icon.bmp
test/nds-test-progs/sprite2/source/common.c
test/nds-test-progs/sprite2/source/common.h
test/nds-test-progs/sprite2/source/testsprite2.c
     1.1 --- a/test/nds-test-progs/sprite/Makefile	Sat Mar 26 21:26:05 2011 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,132 +0,0 @@
     1.4 -#---------------------------------------------------------------------------------
     1.5 -.SUFFIXES:
     1.6 -#---------------------------------------------------------------------------------
     1.7 -
     1.8 -ifeq ($(strip $(DEVKITARM)),)
     1.9 -$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
    1.10 -endif
    1.11 -
    1.12 -include $(DEVKITARM)/ds_rules
    1.13 -
    1.14 -#---------------------------------------------------------------------------------
    1.15 -# TARGET is the name of the output
    1.16 -# BUILD is the directory where object files & intermediate files will be placed
    1.17 -# SOURCES is a list of directories containing source code
    1.18 -# INCLUDES is a list of directories containing extra header files
    1.19 -#---------------------------------------------------------------------------------
    1.20 -TARGET		:=	$(shell basename $(CURDIR))
    1.21 -BUILD		:=	build
    1.22 -SOURCES		:=	source
    1.23 -DATA		:=	data  
    1.24 -INCLUDES	:=	include
    1.25 -
    1.26 -#---------------------------------------------------------------------------------
    1.27 -# options for code generation
    1.28 -#---------------------------------------------------------------------------------
    1.29 -ARCH	:=	-mthumb -mthumb-interwork
    1.30 -
    1.31 -# note: arm9tdmi isn't the correct CPU arch, but anything newer and LD
    1.32 -# *insists* it has a FPU or VFP, and it won't take no for an answer!
    1.33 -CFLAGS	:=	-save-temps -g -Wall -O0\
    1.34 - 			-mcpu=arm9tdmi -mtune=arm9tdmi \
    1.35 -			$(ARCH)
    1.36 -
    1.37 -CFLAGS	+=	$(INCLUDE) -DARM9 -D__NDS__
    1.38 -CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions -fno-exceptions -fno-rtti
    1.39 -
    1.40 -ASFLAGS	:=	-g $(ARCH)
    1.41 -LDFLAGS	=	-specs=ds_arm9.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*.map)
    1.42 -
    1.43 -#---------------------------------------------------------------------------------
    1.44 -# any extra libraries we wish to link with the project
    1.45 -#---------------------------------------------------------------------------------
    1.46 -LIBS	:= -lSDL -lfat -lnds9
    1.47 - 
    1.48 - 
    1.49 -#---------------------------------------------------------------------------------
    1.50 -# list of directories containing libraries, this must be the top level containing
    1.51 -# include and lib
    1.52 -#---------------------------------------------------------------------------------
    1.53 -LIBDIRS	:=	$(LIBNDS)
    1.54 - 
    1.55 -#---------------------------------------------------------------------------------
    1.56 -# no real need to edit anything past this point unless you need to add additional
    1.57 -# rules for different file extensions
    1.58 -#---------------------------------------------------------------------------------
    1.59 -ifneq ($(BUILD),$(notdir $(CURDIR)))
    1.60 -#---------------------------------------------------------------------------------
    1.61 - 
    1.62 -export OUTPUT	:=	$(CURDIR)/$(TARGET)
    1.63 - 
    1.64 -export VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
    1.65 -					$(foreach dir,$(DATA),$(CURDIR)/$(dir))
    1.66 -
    1.67 -export DEPSDIR	:=	$(CURDIR)/$(BUILD)
    1.68 -
    1.69 -CFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
    1.70 -CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
    1.71 -SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
    1.72 -BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
    1.73 - 
    1.74 -#---------------------------------------------------------------------------------
    1.75 -# use CXX for linking C++ projects, CC for standard C
    1.76 -#---------------------------------------------------------------------------------
    1.77 -ifeq ($(strip $(CPPFILES)),)
    1.78 -#---------------------------------------------------------------------------------
    1.79 -	export LD	:=	$(CC)
    1.80 -#---------------------------------------------------------------------------------
    1.81 -else
    1.82 -#---------------------------------------------------------------------------------
    1.83 -	export LD	:=	$(CXX)
    1.84 -#---------------------------------------------------------------------------------
    1.85 -endif
    1.86 -#---------------------------------------------------------------------------------
    1.87 -
    1.88 -export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
    1.89 -					$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
    1.90 - 
    1.91 -export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
    1.92 -					$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
    1.93 -					$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
    1.94 -					-I$(CURDIR)/$(BUILD)
    1.95 - 
    1.96 -export LIBPATHS	:=	$(foreach dir,$(LIBDIRS),-L$(dir)/lib)
    1.97 - 
    1.98 -.PHONY: $(BUILD) clean
    1.99 - 
   1.100 -#---------------------------------------------------------------------------------
   1.101 -$(BUILD):
   1.102 -	@[ -d $@ ] || mkdir -p $@
   1.103 -	@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
   1.104 - 
   1.105 -#---------------------------------------------------------------------------------
   1.106 -clean:
   1.107 -	@echo clean ...
   1.108 -	@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9 $(TARGET).ds.gba 
   1.109 - 
   1.110 - 
   1.111 -#---------------------------------------------------------------------------------
   1.112 -else
   1.113 - 
   1.114 -DEPENDS	:=	$(OFILES:.o=.d)
   1.115 - 
   1.116 -#---------------------------------------------------------------------------------
   1.117 -# main targets
   1.118 -#---------------------------------------------------------------------------------
   1.119 -$(OUTPUT).ds.gba	: 	$(OUTPUT).nds
   1.120 -$(OUTPUT).nds	: 	$(OUTPUT).arm9
   1.121 -$(OUTPUT).arm9	:	$(OUTPUT).elf
   1.122 -$(OUTPUT).elf	:	$(OFILES)
   1.123 - 
   1.124 -#---------------------------------------------------------------------------------
   1.125 -%.pcx.o	:	%.pcx
   1.126 -#---------------------------------------------------------------------------------
   1.127 -	@echo $(notdir $<)
   1.128 -	@$(bin2o)
   1.129 - 
   1.130 - 
   1.131 --include $(DEPENDS)
   1.132 - 
   1.133 -#---------------------------------------------------------------------------------------
   1.134 -endif
   1.135 -#---------------------------------------------------------------------------------------
     2.1 --- a/test/nds-test-progs/sprite/source/common.c	Sat Mar 26 21:26:05 2011 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,965 +0,0 @@
     2.4 -
     2.5 -/* A simple test program framework */
     2.6 -
     2.7 -#include <stdio.h>
     2.8 -
     2.9 -#include "common.h"
    2.10 -
    2.11 -#define VIDEO_USAGE \
    2.12 -"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display %d] [--fullscreen | --windows N] [--title title] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]"
    2.13 -
    2.14 -#define AUDIO_USAGE \
    2.15 -"[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
    2.16 -
    2.17 -CommonState *
    2.18 -CommonCreateState(char **argv, Uint32 flags)
    2.19 -{
    2.20 -    CommonState *state = SDL_calloc(1, sizeof(*state));
    2.21 -    if (!state) {
    2.22 -        SDL_OutOfMemory();
    2.23 -        return NULL;
    2.24 -    }
    2.25 -
    2.26 -    /* Initialize some defaults */
    2.27 -    state->argv = argv;
    2.28 -    state->flags = flags;
    2.29 -    state->window_title = argv[0];
    2.30 -    state->window_flags = SDL_WINDOW_SHOWN;
    2.31 -    state->window_x = SDL_WINDOWPOS_UNDEFINED;
    2.32 -    state->window_y = SDL_WINDOWPOS_UNDEFINED;
    2.33 -    state->window_w = 256;
    2.34 -    state->window_h = 192;
    2.35 -    state->num_windows = 1;
    2.36 -    state->audiospec.freq = 22050;
    2.37 -    state->audiospec.format = AUDIO_S16;
    2.38 -    state->audiospec.channels = 2;
    2.39 -    state->audiospec.samples = 2048;
    2.40 -    return state;
    2.41 -}
    2.42 -
    2.43 -int
    2.44 -CommonArg(CommonState * state, int index)
    2.45 -{
    2.46 -    char **argv = state->argv;
    2.47 -
    2.48 -    if (SDL_strcasecmp(argv[index], "--video") == 0) {
    2.49 -        ++index;
    2.50 -        if (!argv[index]) {
    2.51 -            return -1;
    2.52 -        }
    2.53 -        state->videodriver = argv[index];
    2.54 -        return 2;
    2.55 -    }
    2.56 -    if (SDL_strcasecmp(argv[index], "--renderer") == 0) {
    2.57 -        ++index;
    2.58 -        if (!argv[index]) {
    2.59 -            return -1;
    2.60 -        }
    2.61 -        state->renderdriver = argv[index];
    2.62 -        return 2;
    2.63 -    }
    2.64 -    if (SDL_strcasecmp(argv[index], "--info") == 0) {
    2.65 -        ++index;
    2.66 -        if (!argv[index]) {
    2.67 -            return -1;
    2.68 -        }
    2.69 -        if (SDL_strcasecmp(argv[index], "all") == 0) {
    2.70 -            state->verbose |=
    2.71 -                (VERBOSE_VIDEO | VERBOSE_MODES | VERBOSE_RENDER |
    2.72 -                 VERBOSE_EVENT);
    2.73 -            return 2;
    2.74 -        }
    2.75 -        if (SDL_strcasecmp(argv[index], "video") == 0) {
    2.76 -            state->verbose |= VERBOSE_VIDEO;
    2.77 -            return 2;
    2.78 -        }
    2.79 -        if (SDL_strcasecmp(argv[index], "modes") == 0) {
    2.80 -            state->verbose |= VERBOSE_MODES;
    2.81 -            return 2;
    2.82 -        }
    2.83 -        if (SDL_strcasecmp(argv[index], "render") == 0) {
    2.84 -            state->verbose |= VERBOSE_RENDER;
    2.85 -            return 2;
    2.86 -        }
    2.87 -        if (SDL_strcasecmp(argv[index], "event") == 0) {
    2.88 -            state->verbose |= VERBOSE_EVENT;
    2.89 -            return 2;
    2.90 -        }
    2.91 -        return -1;
    2.92 -    }
    2.93 -    if (SDL_strcasecmp(argv[index], "--display") == 0) {
    2.94 -        ++index;
    2.95 -        if (!argv[index]) {
    2.96 -            return -1;
    2.97 -        }
    2.98 -        state->display = SDL_atoi(argv[index]);
    2.99 -        return 2;
   2.100 -    }
   2.101 -    if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) {
   2.102 -        state->window_flags |= SDL_WINDOW_FULLSCREEN;
   2.103 -        state->num_windows = 1;
   2.104 -        return 1;
   2.105 -    }
   2.106 -    if (SDL_strcasecmp(argv[index], "--windows") == 0) {
   2.107 -        ++index;
   2.108 -        if (!argv[index] || !SDL_isdigit(*argv[index])) {
   2.109 -            return -1;
   2.110 -        }
   2.111 -        if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) {
   2.112 -            state->num_windows = SDL_atoi(argv[index]);
   2.113 -        }
   2.114 -        return 2;
   2.115 -    }
   2.116 -    if (SDL_strcasecmp(argv[index], "--title") == 0) {
   2.117 -        ++index;
   2.118 -        if (!argv[index]) {
   2.119 -            return -1;
   2.120 -        }
   2.121 -        state->window_title = argv[index];
   2.122 -        return 2;
   2.123 -    }
   2.124 -    if (SDL_strcasecmp(argv[index], "--center") == 0) {
   2.125 -        state->window_x = SDL_WINDOWPOS_CENTERED;
   2.126 -        state->window_y = SDL_WINDOWPOS_CENTERED;
   2.127 -        return 1;
   2.128 -    }
   2.129 -    if (SDL_strcasecmp(argv[index], "--position") == 0) {
   2.130 -        char *x, *y;
   2.131 -        ++index;
   2.132 -        if (!argv[index]) {
   2.133 -            return -1;
   2.134 -        }
   2.135 -        x = argv[index];
   2.136 -        y = argv[index];
   2.137 -        while (*y && *y != ',') {
   2.138 -            ++y;
   2.139 -        }
   2.140 -        if (!*y) {
   2.141 -            return -1;
   2.142 -        }
   2.143 -        *y++ = '\0';
   2.144 -        state->window_x = SDL_atoi(x);
   2.145 -        state->window_y = SDL_atoi(y);
   2.146 -        return 2;
   2.147 -    }
   2.148 -    if (SDL_strcasecmp(argv[index], "--geometry") == 0) {
   2.149 -        char *w, *h;
   2.150 -        ++index;
   2.151 -        if (!argv[index]) {
   2.152 -            return -1;
   2.153 -        }
   2.154 -        w = argv[index];
   2.155 -        h = argv[index];
   2.156 -        while (*h && *h != 'x') {
   2.157 -            ++h;
   2.158 -        }
   2.159 -        if (!*h) {
   2.160 -            return -1;
   2.161 -        }
   2.162 -        *h++ = '\0';
   2.163 -        state->window_w = SDL_atoi(w);
   2.164 -        state->window_h = SDL_atoi(h);
   2.165 -        return 2;
   2.166 -    }
   2.167 -    if (SDL_strcasecmp(argv[index], "--depth") == 0) {
   2.168 -        ++index;
   2.169 -        if (!argv[index]) {
   2.170 -            return -1;
   2.171 -        }
   2.172 -        state->depth = SDL_atoi(argv[index]);
   2.173 -        return 2;
   2.174 -    }
   2.175 -    if (SDL_strcasecmp(argv[index], "--refresh") == 0) {
   2.176 -        ++index;
   2.177 -        if (!argv[index]) {
   2.178 -            return -1;
   2.179 -        }
   2.180 -        state->refresh_rate = SDL_atoi(argv[index]);
   2.181 -        return 2;
   2.182 -    }
   2.183 -    if (SDL_strcasecmp(argv[index], "--vsync") == 0) {
   2.184 -        state->render_flags |= SDL_RENDERER_PRESENTVSYNC;
   2.185 -        return 1;
   2.186 -    }
   2.187 -    if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
   2.188 -        state->window_flags |= SDL_WINDOW_BORDERLESS;
   2.189 -        return 1;
   2.190 -    }
   2.191 -    if (SDL_strcasecmp(argv[index], "--resize") == 0) {
   2.192 -        state->window_flags |= SDL_WINDOW_RESIZABLE;
   2.193 -        return 1;
   2.194 -    }
   2.195 -    if (SDL_strcasecmp(argv[index], "--minimize") == 0) {
   2.196 -        state->window_flags |= SDL_WINDOW_MINIMIZED;
   2.197 -        return 1;
   2.198 -    }
   2.199 -    if (SDL_strcasecmp(argv[index], "--maximize") == 0) {
   2.200 -        state->window_flags |= SDL_WINDOW_MAXIMIZED;
   2.201 -        return 1;
   2.202 -    }
   2.203 -    if (SDL_strcasecmp(argv[index], "--grab") == 0) {
   2.204 -        state->window_flags |= SDL_WINDOW_INPUT_GRABBED;
   2.205 -        return 1;
   2.206 -    }
   2.207 -    if (SDL_strcasecmp(argv[index], "--rate") == 0) {
   2.208 -        ++index;
   2.209 -        if (!argv[index]) {
   2.210 -            return -1;
   2.211 -        }
   2.212 -        state->audiospec.freq = SDL_atoi(argv[index]);
   2.213 -        return 2;
   2.214 -    }
   2.215 -    if (SDL_strcasecmp(argv[index], "--format") == 0) {
   2.216 -        ++index;
   2.217 -        if (!argv[index]) {
   2.218 -            return -1;
   2.219 -        }
   2.220 -        if (SDL_strcasecmp(argv[index], "U8") == 0) {
   2.221 -            state->audiospec.format = AUDIO_U8;
   2.222 -            return 2;
   2.223 -        }
   2.224 -        if (SDL_strcasecmp(argv[index], "S8") == 0) {
   2.225 -            state->audiospec.format = AUDIO_S8;
   2.226 -            return 2;
   2.227 -        }
   2.228 -        if (SDL_strcasecmp(argv[index], "U16") == 0) {
   2.229 -            state->audiospec.format = AUDIO_U16;
   2.230 -            return 2;
   2.231 -        }
   2.232 -        if (SDL_strcasecmp(argv[index], "U16LE") == 0) {
   2.233 -            state->audiospec.format = AUDIO_U16LSB;
   2.234 -            return 2;
   2.235 -        }
   2.236 -        if (SDL_strcasecmp(argv[index], "U16BE") == 0) {
   2.237 -            state->audiospec.format = AUDIO_U16MSB;
   2.238 -            return 2;
   2.239 -        }
   2.240 -        if (SDL_strcasecmp(argv[index], "S16") == 0) {
   2.241 -            state->audiospec.format = AUDIO_S16;
   2.242 -            return 2;
   2.243 -        }
   2.244 -        if (SDL_strcasecmp(argv[index], "S16LE") == 0) {
   2.245 -            state->audiospec.format = AUDIO_S16LSB;
   2.246 -            return 2;
   2.247 -        }
   2.248 -        if (SDL_strcasecmp(argv[index], "S16BE") == 0) {
   2.249 -            state->audiospec.format = AUDIO_S16MSB;
   2.250 -            return 2;
   2.251 -        }
   2.252 -        return -1;
   2.253 -    }
   2.254 -    if (SDL_strcasecmp(argv[index], "--channels") == 0) {
   2.255 -        ++index;
   2.256 -        if (!argv[index]) {
   2.257 -            return -1;
   2.258 -        }
   2.259 -        state->audiospec.channels = (Uint8) SDL_atoi(argv[index]);
   2.260 -        return 2;
   2.261 -    }
   2.262 -    if (SDL_strcasecmp(argv[index], "--samples") == 0) {
   2.263 -        ++index;
   2.264 -        if (!argv[index]) {
   2.265 -            return -1;
   2.266 -        }
   2.267 -        state->audiospec.samples = (Uint16) SDL_atoi(argv[index]);
   2.268 -        return 2;
   2.269 -    }
   2.270 -    if ((SDL_strcasecmp(argv[index], "-h") == 0)
   2.271 -        || (SDL_strcasecmp(argv[index], "--help") == 0)) {
   2.272 -        /* Print the usage message */
   2.273 -        return -1;
   2.274 -    }
   2.275 -    return 0;
   2.276 -}
   2.277 -
   2.278 -const char *
   2.279 -CommonUsage(CommonState * state)
   2.280 -{
   2.281 -    switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
   2.282 -    case SDL_INIT_VIDEO:
   2.283 -        return VIDEO_USAGE;
   2.284 -    case SDL_INIT_AUDIO:
   2.285 -        return AUDIO_USAGE;
   2.286 -    case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
   2.287 -        return VIDEO_USAGE " " AUDIO_USAGE;
   2.288 -    default:
   2.289 -        return "";
   2.290 -    }
   2.291 -}
   2.292 -
   2.293 -static void
   2.294 -PrintRendererFlag(Uint32 flag)
   2.295 -{
   2.296 -    switch (flag) {
   2.297 -    case SDL_RENDERER_SINGLEBUFFER:
   2.298 -        fprintf(stderr, "SingleBuffer");
   2.299 -        break;
   2.300 -    case SDL_RENDERER_PRESENTCOPY:
   2.301 -        fprintf(stderr, "PresentCopy");
   2.302 -        break;
   2.303 -    case SDL_RENDERER_PRESENTFLIP2:
   2.304 -        fprintf(stderr, "PresentFlip2");
   2.305 -        break;
   2.306 -    case SDL_RENDERER_PRESENTFLIP3:
   2.307 -        fprintf(stderr, "PresentFlip3");
   2.308 -        break;
   2.309 -    case SDL_RENDERER_PRESENTDISCARD:
   2.310 -        fprintf(stderr, "PresentDiscard");
   2.311 -        break;
   2.312 -    case SDL_RENDERER_PRESENTVSYNC:
   2.313 -        fprintf(stderr, "PresentVSync");
   2.314 -        break;
   2.315 -    case SDL_RENDERER_ACCELERATED:
   2.316 -        fprintf(stderr, "Accelerated");
   2.317 -        break;
   2.318 -    default:
   2.319 -        fprintf(stderr, "0x%8.8x", flag);
   2.320 -        break;
   2.321 -    }
   2.322 -}
   2.323 -
   2.324 -static void
   2.325 -PrintBlendMode(Uint32 flag)
   2.326 -{
   2.327 -    switch (flag) {
   2.328 -    case SDL_BLENDMODE_NONE:
   2.329 -        fprintf(stderr, "None");
   2.330 -        break;
   2.331 -    case SDL_BLENDMODE_MASK:
   2.332 -        fprintf(stderr, "Mask");
   2.333 -        break;
   2.334 -    case SDL_BLENDMODE_BLEND:
   2.335 -        fprintf(stderr, "Blend");
   2.336 -        break;
   2.337 -    case SDL_BLENDMODE_ADD:
   2.338 -        fprintf(stderr, "Add");
   2.339 -        break;
   2.340 -    case SDL_BLENDMODE_MOD:
   2.341 -        fprintf(stderr, "Mod");
   2.342 -        break;
   2.343 -    default:
   2.344 -        fprintf(stderr, "0x%8.8x", flag);
   2.345 -        break;
   2.346 -    }
   2.347 -}
   2.348 -
   2.349 -static void
   2.350 -PrintScaleMode(Uint32 flag)
   2.351 -{
   2.352 -    switch (flag) {
   2.353 -    case SDL_TEXTURESCALEMODE_NONE:
   2.354 -        fprintf(stderr, "None");
   2.355 -        break;
   2.356 -    case SDL_TEXTURESCALEMODE_FAST:
   2.357 -        fprintf(stderr, "Fast");
   2.358 -        break;
   2.359 -    case SDL_TEXTURESCALEMODE_SLOW:
   2.360 -        fprintf(stderr, "Slow");
   2.361 -        break;
   2.362 -    case SDL_TEXTURESCALEMODE_BEST:
   2.363 -        fprintf(stderr, "Best");
   2.364 -        break;
   2.365 -    default:
   2.366 -        fprintf(stderr, "0x%8.8x", flag);
   2.367 -        break;
   2.368 -    }
   2.369 -}
   2.370 -
   2.371 -static void
   2.372 -PrintPixelFormat(Uint32 format)
   2.373 -{
   2.374 -    switch (format) {
   2.375 -    case SDL_PIXELFORMAT_UNKNOWN:
   2.376 -        fprintf(stderr, "Unknwon");
   2.377 -        break;
   2.378 -    case SDL_PIXELFORMAT_INDEX1LSB:
   2.379 -        fprintf(stderr, "Index1LSB");
   2.380 -        break;
   2.381 -    case SDL_PIXELFORMAT_INDEX1MSB:
   2.382 -        fprintf(stderr, "Index1MSB");
   2.383 -        break;
   2.384 -    case SDL_PIXELFORMAT_INDEX4LSB:
   2.385 -        fprintf(stderr, "Index4LSB");
   2.386 -        break;
   2.387 -    case SDL_PIXELFORMAT_INDEX4MSB:
   2.388 -        fprintf(stderr, "Index4MSB");
   2.389 -        break;
   2.390 -    case SDL_PIXELFORMAT_INDEX8:
   2.391 -        fprintf(stderr, "Index8");
   2.392 -        break;
   2.393 -    case SDL_PIXELFORMAT_RGB332:
   2.394 -        fprintf(stderr, "RGB332");
   2.395 -        break;
   2.396 -    case SDL_PIXELFORMAT_RGB444:
   2.397 -        fprintf(stderr, "RGB444");
   2.398 -        break;
   2.399 -    case SDL_PIXELFORMAT_RGB555:
   2.400 -        fprintf(stderr, "RGB555");
   2.401 -        break;
   2.402 -    case SDL_PIXELFORMAT_ARGB4444:
   2.403 -        fprintf(stderr, "ARGB4444");
   2.404 -        break;
   2.405 -    case SDL_PIXELFORMAT_ARGB1555:
   2.406 -        fprintf(stderr, "ARGB1555");
   2.407 -        break;
   2.408 -    case SDL_PIXELFORMAT_RGB565:
   2.409 -        fprintf(stderr, "RGB565");
   2.410 -        break;
   2.411 -    case SDL_PIXELFORMAT_RGB24:
   2.412 -        fprintf(stderr, "RGB24");
   2.413 -        break;
   2.414 -    case SDL_PIXELFORMAT_BGR24:
   2.415 -        fprintf(stderr, "BGR24");
   2.416 -        break;
   2.417 -    case SDL_PIXELFORMAT_RGB888:
   2.418 -        fprintf(stderr, "RGB888");
   2.419 -        break;
   2.420 -    case SDL_PIXELFORMAT_BGR888:
   2.421 -        fprintf(stderr, "BGR888");
   2.422 -        break;
   2.423 -    case SDL_PIXELFORMAT_ARGB8888:
   2.424 -        fprintf(stderr, "ARGB8888");
   2.425 -        break;
   2.426 -    case SDL_PIXELFORMAT_RGBA8888:
   2.427 -        fprintf(stderr, "RGBA8888");
   2.428 -        break;
   2.429 -    case SDL_PIXELFORMAT_ABGR8888:
   2.430 -        fprintf(stderr, "ABGR8888");
   2.431 -        break;
   2.432 -    case SDL_PIXELFORMAT_BGRA8888:
   2.433 -        fprintf(stderr, "BGRA8888");
   2.434 -        break;
   2.435 -    case SDL_PIXELFORMAT_ARGB2101010:
   2.436 -        fprintf(stderr, "ARGB2101010");
   2.437 -        break;
   2.438 -    case SDL_PIXELFORMAT_YV12:
   2.439 -        fprintf(stderr, "YV12");
   2.440 -        break;
   2.441 -    case SDL_PIXELFORMAT_IYUV:
   2.442 -        fprintf(stderr, "IYUV");
   2.443 -        break;
   2.444 -    case SDL_PIXELFORMAT_YUY2:
   2.445 -        fprintf(stderr, "YUY2");
   2.446 -        break;
   2.447 -    case SDL_PIXELFORMAT_UYVY:
   2.448 -        fprintf(stderr, "UYVY");
   2.449 -        break;
   2.450 -    case SDL_PIXELFORMAT_YVYU:
   2.451 -        fprintf(stderr, "YVYU");
   2.452 -        break;
   2.453 -    case SDL_PIXELFORMAT_ABGR1555:
   2.454 -        fprintf(stderr, "ABGR1555");
   2.455 -        break;
   2.456 -    case SDL_PIXELFORMAT_BGR555:
   2.457 -        fprintf(stderr, "BGR555");
   2.458 -        break;
   2.459 -    default:
   2.460 -        fprintf(stderr, "0x%8.8x", format);
   2.461 -        break;
   2.462 -    }
   2.463 -}
   2.464 -
   2.465 -static void
   2.466 -PrintRenderer(SDL_RendererInfo * info)
   2.467 -{
   2.468 -    int i, count;
   2.469 -
   2.470 -    fprintf(stderr, "  Renderer %s:\n", info->name);
   2.471 -
   2.472 -    fprintf(stderr, "    Flags: 0x%8.8X", info->flags);
   2.473 -    fprintf(stderr, " (");
   2.474 -    count = 0;
   2.475 -    for (i = 0; i < sizeof(info->flags) * 8; ++i) {
   2.476 -        Uint32 flag = (1 << i);
   2.477 -        if (info->flags & flag) {
   2.478 -            if (count > 0) {
   2.479 -                fprintf(stderr, " | ");
   2.480 -            }
   2.481 -            PrintRendererFlag(flag);
   2.482 -            ++count;
   2.483 -        }
   2.484 -    }
   2.485 -    fprintf(stderr, ")\n");
   2.486 -
   2.487 -    fprintf(stderr, "    Blend: 0x%8.8X", info->blend_modes);
   2.488 -    fprintf(stderr, " (");
   2.489 -    count = 0;
   2.490 -    for (i = 0; i < sizeof(info->blend_modes) * 8; ++i) {
   2.491 -        Uint32 flag = (1 << i);
   2.492 -        if (info->blend_modes & flag) {
   2.493 -            if (count > 0) {
   2.494 -                fprintf(stderr, " | ");
   2.495 -            }
   2.496 -            PrintBlendMode(flag);
   2.497 -            ++count;
   2.498 -        }
   2.499 -    }
   2.500 -    fprintf(stderr, ")\n");
   2.501 -
   2.502 -    fprintf(stderr, "    Scale: 0x%8.8X", info->scale_modes);
   2.503 -    fprintf(stderr, " (");
   2.504 -    count = 0;
   2.505 -    for (i = 0; i < sizeof(info->scale_modes) * 8; ++i) {
   2.506 -        Uint32 flag = (1 << i);
   2.507 -        if (info->scale_modes & flag) {
   2.508 -            if (count > 0) {
   2.509 -                fprintf(stderr, " | ");
   2.510 -            }
   2.511 -            PrintScaleMode(flag);
   2.512 -            ++count;
   2.513 -        }
   2.514 -    }
   2.515 -    fprintf(stderr, ")\n");
   2.516 -
   2.517 -    fprintf(stderr, "    Texture formats (%d): ", info->num_texture_formats);
   2.518 -    for (i = 0; i < (int) info->num_texture_formats; ++i) {
   2.519 -        if (i > 0) {
   2.520 -            fprintf(stderr, ", ");
   2.521 -        }
   2.522 -        PrintPixelFormat(info->texture_formats[i]);
   2.523 -    }
   2.524 -    fprintf(stderr, "\n");
   2.525 -
   2.526 -    if (info->max_texture_width || info->max_texture_height) {
   2.527 -        fprintf(stderr, "    Max Texture Size: %dx%d\n",
   2.528 -                info->max_texture_width, info->max_texture_height);
   2.529 -    }
   2.530 -}
   2.531 -
   2.532 -SDL_bool
   2.533 -CommonInit(CommonState * state)
   2.534 -{
   2.535 -    int i, j, m, n;
   2.536 -    SDL_DisplayMode fullscreen_mode;
   2.537 -
   2.538 -    if (state->flags & SDL_INIT_VIDEO) {
   2.539 -        if (state->verbose & VERBOSE_VIDEO) {
   2.540 -            n = SDL_GetNumVideoDrivers();
   2.541 -            if (n == 0) {
   2.542 -                fprintf(stderr, "No built-in video drivers\n");
   2.543 -            } else {
   2.544 -                fprintf(stderr, "Built-in video drivers:");
   2.545 -                for (i = 0; i < n; ++i) {
   2.546 -                    if (i > 0) {
   2.547 -                        fprintf(stderr, ",");
   2.548 -                    }
   2.549 -                    fprintf(stderr, " %s", SDL_GetVideoDriver(i));
   2.550 -                }
   2.551 -                fprintf(stderr, "\n");
   2.552 -            }
   2.553 -        }
   2.554 -        if (SDL_VideoInit(state->videodriver, 0) < 0) {
   2.555 -            fprintf(stderr, "Couldn't initialize video driver: %s\n",
   2.556 -                    SDL_GetError());
   2.557 -            return SDL_FALSE;
   2.558 -        }
   2.559 -        if (state->verbose & VERBOSE_VIDEO) {
   2.560 -            fprintf(stderr, "Video driver: %s\n",
   2.561 -                    SDL_GetCurrentVideoDriver());
   2.562 -        }
   2.563 -
   2.564 -        if (state->verbose & VERBOSE_MODES) {
   2.565 -            SDL_DisplayMode mode;
   2.566 -            int bpp;
   2.567 -            Uint32 Rmask, Gmask, Bmask, Amask;
   2.568 -
   2.569 -            n = SDL_GetNumVideoDisplays();
   2.570 -            fprintf(stderr, "Number of displays: %d\n", n);
   2.571 -            for (i = 0; i < n; ++i) {
   2.572 -                fprintf(stderr, "Display %d:\n", i);
   2.573 -                SDL_SelectVideoDisplay(i);
   2.574 -
   2.575 -                SDL_GetDesktopDisplayMode(&mode);
   2.576 -                SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask,
   2.577 -                                           &Bmask, &Amask);
   2.578 -                fprintf(stderr,
   2.579 -                        "  Current mode: %dx%d@%dHz, %d bits-per-pixel\n",
   2.580 -                        mode.w, mode.h, mode.refresh_rate, bpp);
   2.581 -                if (Rmask || Gmask || Bmask) {
   2.582 -                    fprintf(stderr, "      Red Mask = 0x%.8x\n", Rmask);
   2.583 -                    fprintf(stderr, "      Green Mask = 0x%.8x\n", Gmask);
   2.584 -                    fprintf(stderr, "      Blue Mask = 0x%.8x\n", Bmask);
   2.585 -                    if (Amask)
   2.586 -                        fprintf(stderr, "      Alpha Mask = 0x%.8x\n", Amask);
   2.587 -                }
   2.588 -
   2.589 -                /* Print available fullscreen video modes */
   2.590 -                m = SDL_GetNumDisplayModes();
   2.591 -                if (m == 0) {
   2.592 -                    fprintf(stderr, "No available fullscreen video modes\n");
   2.593 -                } else {
   2.594 -                    fprintf(stderr, "  Fullscreen video modes:\n");
   2.595 -                    for (j = 0; j < m; ++j) {
   2.596 -                        SDL_GetDisplayMode(j, &mode);
   2.597 -                        SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
   2.598 -                                                   &Gmask, &Bmask, &Amask);
   2.599 -                        fprintf(stderr,
   2.600 -                                "    Mode %d: %dx%d@%dHz, %d bits-per-pixel\n",
   2.601 -                                j, mode.w, mode.h, mode.refresh_rate, bpp);
   2.602 -                        if (Rmask || Gmask || Bmask) {
   2.603 -                            fprintf(stderr, "        Red Mask = 0x%.8x\n",
   2.604 -                                    Rmask);
   2.605 -                            fprintf(stderr, "        Green Mask = 0x%.8x\n",
   2.606 -                                    Gmask);
   2.607 -                            fprintf(stderr, "        Blue Mask = 0x%.8x\n",
   2.608 -                                    Bmask);
   2.609 -                            if (Amask)
   2.610 -                                fprintf(stderr,
   2.611 -                                        "        Alpha Mask = 0x%.8x\n",
   2.612 -                                        Amask);
   2.613 -                        }
   2.614 -                    }
   2.615 -                }
   2.616 -            }
   2.617 -        }
   2.618 -
   2.619 -        SDL_SelectVideoDisplay(state->display);
   2.620 -        if (state->verbose & VERBOSE_RENDER) {
   2.621 -            SDL_RendererInfo info;
   2.622 -
   2.623 -            n = SDL_GetNumRenderDrivers();
   2.624 -            if (n == 0) {
   2.625 -                fprintf(stderr, "No built-in render drivers\n");
   2.626 -            } else {
   2.627 -                fprintf(stderr, "Built-in render drivers:\n");
   2.628 -                for (i = 0; i < n; ++i) {
   2.629 -                    SDL_GetRenderDriverInfo(i, &info);
   2.630 -                    PrintRenderer(&info);
   2.631 -                }
   2.632 -            }
   2.633 -        }
   2.634 -
   2.635 -        switch (state->depth) {
   2.636 -        case 8:
   2.637 -            fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
   2.638 -            break;
   2.639 -        case 15:
   2.640 -            fullscreen_mode.format = SDL_PIXELFORMAT_BGR555;
   2.641 -            break;
   2.642 -        case 16:
   2.643 -        default:
   2.644 -            fullscreen_mode.format = SDL_PIXELFORMAT_ABGR1555;
   2.645 -            break;
   2.646 -/* NDS       default:
   2.647 -            fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
   2.648 -            break;*/
   2.649 -        }
   2.650 -        fullscreen_mode.w = state->window_w;
   2.651 -        fullscreen_mode.h = state->window_h;
   2.652 -        fullscreen_mode.refresh_rate = state->refresh_rate;
   2.653 -        SDL_SetFullscreenDisplayMode(&fullscreen_mode);
   2.654 -
   2.655 -        state->windows =
   2.656 -            (SDL_WindowID *) SDL_malloc(state->num_windows *
   2.657 -                                        sizeof(*state->windows));
   2.658 -        if (!state->windows) {
   2.659 -            fprintf(stderr, "Out of memory!\n");
   2.660 -            return SDL_FALSE;
   2.661 -        }
   2.662 -        for (i = 0; i < state->num_windows; ++i) {
   2.663 -            char title[1024];
   2.664 -
   2.665 -            if (state->num_windows > 1) {
   2.666 -                SDL_snprintf(title, SDL_arraysize(title), "%s %d",
   2.667 -                             state->window_title, i + 1);
   2.668 -            } else {
   2.669 -                SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
   2.670 -            }
   2.671 -            state->windows[i] =
   2.672 -                SDL_CreateWindow(title, state->window_x, state->window_y,
   2.673 -                                 state->window_w, state->window_h,
   2.674 -                                 state->window_flags);
   2.675 -            if (!state->windows[i]) {
   2.676 -                fprintf(stderr, "Couldn't create window: %s\n",
   2.677 -                        SDL_GetError());
   2.678 -                return SDL_FALSE;
   2.679 -            }
   2.680 -
   2.681 -            if (!state->skip_renderer
   2.682 -                && (state->renderdriver
   2.683 -                    || !(state->window_flags & SDL_WINDOW_OPENGL))) {
   2.684 -                m = -1;
   2.685 -                if (state->renderdriver) {
   2.686 -                    SDL_RendererInfo info;
   2.687 -                    n = SDL_GetNumRenderDrivers();
   2.688 -                    for (j = 0; j < n; ++j) {
   2.689 -                        SDL_GetRenderDriverInfo(j, &info);
   2.690 -                        if (SDL_strcasecmp(info.name, state->renderdriver) ==
   2.691 -                            0) {
   2.692 -                            m = j;
   2.693 -                            break;
   2.694 -                        }
   2.695 -                    }
   2.696 -                    if (m == n) {
   2.697 -                        fprintf(stderr,
   2.698 -                                "Couldn't find render driver named %s",
   2.699 -                                state->renderdriver);
   2.700 -                        return SDL_FALSE;
   2.701 -                    }
   2.702 -                }
   2.703 -                if (SDL_CreateRenderer
   2.704 -                    (state->windows[i], m, state->render_flags) < 0) {
   2.705 -                    fprintf(stderr, "Couldn't create renderer: %s\n",
   2.706 -                            SDL_GetError());
   2.707 -                    return SDL_FALSE;
   2.708 -                }
   2.709 -                if (state->verbose & VERBOSE_RENDER) {
   2.710 -                    SDL_RendererInfo info;
   2.711 -
   2.712 -                    fprintf(stderr, "Current renderer:\n");
   2.713 -                    SDL_GetRendererInfo(&info);
   2.714 -                    PrintRenderer(&info);
   2.715 -                }
   2.716 -            }
   2.717 -        }
   2.718 -        SDL_SelectRenderer(state->windows[0]);
   2.719 -    }
   2.720 -
   2.721 -    if (state->flags & SDL_INIT_AUDIO) {
   2.722 -        if (state->verbose & VERBOSE_AUDIO) {
   2.723 -            n = SDL_GetNumAudioDrivers();
   2.724 -            if (n == 0) {
   2.725 -                fprintf(stderr, "No built-in audio drivers\n");
   2.726 -            } else {
   2.727 -                fprintf(stderr, "Built-in audio drivers:");
   2.728 -                for (i = 0; i < n; ++i) {
   2.729 -                    if (i > 0) {
   2.730 -                        fprintf(stderr, ",");
   2.731 -                    }
   2.732 -                    fprintf(stderr, " %s", SDL_GetAudioDriver(i));
   2.733 -                }
   2.734 -                fprintf(stderr, "\n");
   2.735 -            }
   2.736 -        }
   2.737 -        if (SDL_AudioInit(state->audiodriver) < 0) {
   2.738 -            fprintf(stderr, "Couldn't initialize audio driver: %s\n",
   2.739 -                    SDL_GetError());
   2.740 -            return SDL_FALSE;
   2.741 -        }
   2.742 -        if (state->verbose & VERBOSE_VIDEO) {
   2.743 -            fprintf(stderr, "Audio driver: %s\n",
   2.744 -                    SDL_GetCurrentAudioDriver());
   2.745 -        }
   2.746 -
   2.747 -        if (SDL_OpenAudio(&state->audiospec, NULL) < 0) {
   2.748 -            fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
   2.749 -            return SDL_FALSE;
   2.750 -        }
   2.751 -    }
   2.752 -
   2.753 -    return SDL_TRUE;
   2.754 -}
   2.755 -
   2.756 -static void
   2.757 -PrintEvent(SDL_Event * event)
   2.758 -{
   2.759 -    fprintf(stderr, "SDL EVENT: ");
   2.760 -    switch (event->type) {
   2.761 -    case SDL_WINDOWEVENT:
   2.762 -        switch (event->window.event) {
   2.763 -        case SDL_WINDOWEVENT_SHOWN:
   2.764 -            fprintf(stderr, "Window %d shown", event->window.windowID);
   2.765 -            break;
   2.766 -        case SDL_WINDOWEVENT_HIDDEN:
   2.767 -            fprintf(stderr, "Window %d hidden", event->window.windowID);
   2.768 -            break;
   2.769 -        case SDL_WINDOWEVENT_EXPOSED:
   2.770 -            fprintf(stderr, "Window %d exposed", event->window.windowID);
   2.771 -            break;
   2.772 -        case SDL_WINDOWEVENT_MOVED:
   2.773 -            fprintf(stderr, "Window %d moved to %d,%d",
   2.774 -                    event->window.windowID, event->window.data1,
   2.775 -                    event->window.data2);
   2.776 -            break;
   2.777 -        case SDL_WINDOWEVENT_RESIZED:
   2.778 -            fprintf(stderr, "Window %d resized to %dx%d",
   2.779 -                    event->window.windowID, event->window.data1,
   2.780 -                    event->window.data2);
   2.781 -            break;
   2.782 -        case SDL_WINDOWEVENT_MINIMIZED:
   2.783 -            fprintf(stderr, "Window %d minimized", event->window.windowID);
   2.784 -            break;
   2.785 -        case SDL_WINDOWEVENT_MAXIMIZED:
   2.786 -            fprintf(stderr, "Window %d maximized", event->window.windowID);
   2.787 -            break;
   2.788 -        case SDL_WINDOWEVENT_RESTORED:
   2.789 -            fprintf(stderr, "Window %d restored", event->window.windowID);
   2.790 -            break;
   2.791 -        case SDL_WINDOWEVENT_ENTER:
   2.792 -            fprintf(stderr, "Mouse entered window %d",
   2.793 -                    event->window.windowID);
   2.794 -            break;
   2.795 -        case SDL_WINDOWEVENT_LEAVE:
   2.796 -            fprintf(stderr, "Mouse left window %d", event->window.windowID);
   2.797 -            break;
   2.798 -        case SDL_WINDOWEVENT_FOCUS_GAINED:
   2.799 -            fprintf(stderr, "Window %d gained keyboard focus",
   2.800 -                    event->window.windowID);
   2.801 -            break;
   2.802 -        case SDL_WINDOWEVENT_FOCUS_LOST:
   2.803 -            fprintf(stderr, "Window %d lost keyboard focus",
   2.804 -                    event->window.windowID);
   2.805 -            break;
   2.806 -        case SDL_WINDOWEVENT_CLOSE:
   2.807 -            fprintf(stderr, "Window %d closed", event->window.windowID);
   2.808 -            break;
   2.809 -        default:
   2.810 -            fprintf(stderr, "Window %d got unknown event %d",
   2.811 -                    event->window.windowID, event->window.event);
   2.812 -            break;
   2.813 -        }
   2.814 -        break;
   2.815 -    case SDL_KEYDOWN:
   2.816 -        fprintf(stderr,
   2.817 -                "Keyboard %d: key pressed  in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
   2.818 -                event->key.which, event->key.windowID,
   2.819 -                event->key.keysym.scancode,
   2.820 -                SDL_GetScancodeName(event->key.keysym.scancode),
   2.821 -                event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
   2.822 -        break;
   2.823 -    case SDL_KEYUP:
   2.824 -        fprintf(stderr,
   2.825 -                "Keyboard %d: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
   2.826 -                event->key.which, event->key.windowID,
   2.827 -                event->key.keysym.scancode,
   2.828 -                SDL_GetScancodeName(event->key.keysym.scancode),
   2.829 -                event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
   2.830 -        break;
   2.831 -    case SDL_TEXTINPUT:
   2.832 -        fprintf(stderr, "Keyboard %d: text input \"%s\" in window %d",
   2.833 -                event->text.which, event->text.text, event->text.windowID);
   2.834 -        break;
   2.835 -    case SDL_MOUSEMOTION:
   2.836 -        fprintf(stderr, "Mouse %d: moved to %d,%d (%d,%d) in window %d",
   2.837 -                event->motion.which, event->motion.x, event->motion.y,
   2.838 -                event->motion.xrel, event->motion.yrel,
   2.839 -                event->motion.windowID);
   2.840 -        break;
   2.841 -    case SDL_MOUSEBUTTONDOWN:
   2.842 -        fprintf(stderr, "Mouse %d: button %d pressed at %d,%d in window %d",
   2.843 -                event->button.which, event->button.button, event->button.x,
   2.844 -                event->button.y, event->button.windowID);
   2.845 -        break;
   2.846 -    case SDL_MOUSEBUTTONUP:
   2.847 -        fprintf(stderr, "Mouse %d: button %d released at %d,%d in window %d",
   2.848 -                event->button.which, event->button.button, event->button.x,
   2.849 -                event->button.y, event->button.windowID);
   2.850 -        break;
   2.851 -    case SDL_MOUSEWHEEL:
   2.852 -        fprintf(stderr,
   2.853 -                "Mouse %d: wheel scrolled %d in x and %d in y in window %d",
   2.854 -                event->wheel.which, event->wheel.x, event->wheel.y,
   2.855 -                event->wheel.windowID);
   2.856 -        break;
   2.857 -    case SDL_JOYBALLMOTION:
   2.858 -        fprintf(stderr, "Joystick %d: ball %d moved by %d,%d",
   2.859 -                event->jball.which, event->jball.ball, event->jball.xrel,
   2.860 -                event->jball.yrel);
   2.861 -        break;
   2.862 -    case SDL_JOYHATMOTION:
   2.863 -        fprintf(stderr, "Joystick %d: hat %d moved to ", event->jhat.which,
   2.864 -                event->jhat.hat);
   2.865 -        switch (event->jhat.value) {
   2.866 -        case SDL_HAT_CENTERED:
   2.867 -            fprintf(stderr, "CENTER");
   2.868 -            break;
   2.869 -        case SDL_HAT_UP:
   2.870 -            fprintf(stderr, "UP");
   2.871 -            break;
   2.872 -        case SDL_HAT_RIGHTUP:
   2.873 -            fprintf(stderr, "RIGHTUP");
   2.874 -            break;
   2.875 -        case SDL_HAT_RIGHT:
   2.876 -            fprintf(stderr, "RIGHT");
   2.877 -            break;
   2.878 -        case SDL_HAT_RIGHTDOWN:
   2.879 -            fprintf(stderr, "RIGHTDOWN");
   2.880 -            break;
   2.881 -        case SDL_HAT_DOWN:
   2.882 -            fprintf(stderr, "DOWN");
   2.883 -            break;
   2.884 -        case SDL_HAT_LEFTDOWN:
   2.885 -            fprintf(stderr, "LEFTDOWN");
   2.886 -            break;
   2.887 -        case SDL_HAT_LEFT:
   2.888 -            fprintf(stderr, "LEFT");
   2.889 -            break;
   2.890 -        case SDL_HAT_LEFTUP:
   2.891 -            fprintf(stderr, "LEFTUP");
   2.892 -            break;
   2.893 -        default:
   2.894 -            fprintf(stderr, "UNKNOWN");
   2.895 -            break;
   2.896 -        }
   2.897 -        break;
   2.898 -    case SDL_JOYBUTTONDOWN:
   2.899 -        fprintf(stderr, "Joystick %d: button %d pressed",
   2.900 -                event->jbutton.which, event->jbutton.button);
   2.901 -        break;
   2.902 -    case SDL_JOYBUTTONUP:
   2.903 -        fprintf(stderr, "Joystick %d: button %d released",
   2.904 -                event->jbutton.which, event->jbutton.button);
   2.905 -        break;
   2.906 -    case SDL_QUIT:
   2.907 -        fprintf(stderr, "Quit requested");
   2.908 -        break;
   2.909 -    case SDL_USEREVENT:
   2.910 -        fprintf(stderr, "User event %d", event->user.code);
   2.911 -        break;
   2.912 -    default:
   2.913 -        fprintf(stderr, "Unknown event %d", event->type);
   2.914 -        break;
   2.915 -    }
   2.916 -    fprintf(stderr, "\n");
   2.917 -}
   2.918 -
   2.919 -void
   2.920 -CommonEvent(CommonState * state, SDL_Event * event, int *done)
   2.921 -{
   2.922 -    if (state->verbose & VERBOSE_EVENT) {
   2.923 -        PrintEvent(event);
   2.924 -    }
   2.925 -
   2.926 -    switch (event->type) {
   2.927 -    case SDL_WINDOWEVENT:
   2.928 -        switch (event->window.event) {
   2.929 -        case SDL_WINDOWEVENT_CLOSE:
   2.930 -            *done = 1;
   2.931 -            break;
   2.932 -        }
   2.933 -        break;
   2.934 -    case SDL_KEYDOWN:
   2.935 -        switch (event->key.keysym.sym) {
   2.936 -            /* Add hotkeys here */
   2.937 -        case SDLK_g:
   2.938 -            if (event->key.keysym.mod & KMOD_CTRL) {
   2.939 -                /* Ctrl-G toggle grab */
   2.940 -            }
   2.941 -            break;
   2.942 -        case SDLK_ESCAPE:
   2.943 -            *done = 1;
   2.944 -            break;
   2.945 -        default:
   2.946 -            break;
   2.947 -        }
   2.948 -        break;
   2.949 -    case SDL_QUIT:
   2.950 -        *done = 1;
   2.951 -        break;
   2.952 -    }
   2.953 -}
   2.954 -
   2.955 -void
   2.956 -CommonQuit(CommonState * state)
   2.957 -{
   2.958 -    if (state->flags & SDL_INIT_VIDEO) {
   2.959 -        SDL_VideoQuit();
   2.960 -    }
   2.961 -    if (state->flags & SDL_INIT_AUDIO) {
   2.962 -        SDL_AudioQuit();
   2.963 -    }
   2.964 -    if (state->windows) {
   2.965 -        SDL_free(state->windows);
   2.966 -    }
   2.967 -    SDL_free(state);
   2.968 -}
     3.1 --- a/test/nds-test-progs/sprite/source/common.h	Sat Mar 26 21:26:05 2011 -0700
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,48 +0,0 @@
     3.4 -
     3.5 -/* A simple test program framework */
     3.6 -
     3.7 -#include <SDL/SDL.h>
     3.8 -
     3.9 -#define VERBOSE_VIDEO   0x00000001
    3.10 -#define VERBOSE_MODES   0x00000002
    3.11 -#define VERBOSE_RENDER  0x00000004
    3.12 -#define VERBOSE_EVENT   0x00000008
    3.13 -#define VERBOSE_AUDIO   0x00000010
    3.14 -
    3.15 -typedef struct
    3.16 -{
    3.17 -    /* SDL init flags */
    3.18 -    char **argv;
    3.19 -    Uint32 flags;
    3.20 -    Uint32 verbose;
    3.21 -
    3.22 -    /* Video info */
    3.23 -    const char *videodriver;
    3.24 -    int display;
    3.25 -    const char *window_title;
    3.26 -    Uint32 window_flags;
    3.27 -    int window_x;
    3.28 -    int window_y;
    3.29 -    int window_w;
    3.30 -    int window_h;
    3.31 -    int depth;
    3.32 -    int refresh_rate;
    3.33 -    int num_windows;
    3.34 -    SDL_WindowID *windows;
    3.35 -
    3.36 -    /* Renderer info */
    3.37 -    const char *renderdriver;
    3.38 -    Uint32 render_flags;
    3.39 -    SDL_bool skip_renderer;
    3.40 -
    3.41 -    /* Audio info */
    3.42 -    const char *audiodriver;
    3.43 -    SDL_AudioSpec audiospec;
    3.44 -} CommonState;
    3.45 -
    3.46 -extern CommonState *CommonCreateState(char **argv, Uint32 flags);
    3.47 -extern int CommonArg(CommonState * state, int index);
    3.48 -extern const char *CommonUsage(CommonState * state);
    3.49 -extern SDL_bool CommonInit(CommonState * state);
    3.50 -extern void CommonEvent(CommonState * state, SDL_Event * event, int *done);
    3.51 -extern void CommonQuit(CommonState * state);
     4.1 --- a/test/nds-test-progs/sprite/source/testsprite.c	Sat Mar 26 21:26:05 2011 -0700
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,316 +0,0 @@
     4.4 -/* Simple program:  Move N sprites around on the screen as fast as possible */
     4.5 -
     4.6 -#include <stdlib.h>
     4.7 -#include <stdio.h>
     4.8 -#include <time.h>
     4.9 -#include <math.h>
    4.10 -#include <fat.h>
    4.11 -#include <SDL/SDL.h>
    4.12 -
    4.13 -#define NUM_SPRITES	10
    4.14 -#define MAX_SPEED 	1
    4.15 -
    4.16 -SDL_Surface *sprite;
    4.17 -int numsprites;
    4.18 -SDL_Rect *sprite_rects;
    4.19 -SDL_Rect *positions;
    4.20 -SDL_Rect *velocities;
    4.21 -int sprites_visible;
    4.22 -int debug_flip;
    4.23 -Uint16 sprite_w, sprite_h;
    4.24 -
    4.25 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    4.26 -static void
    4.27 -quit(int rc)
    4.28 -{
    4.29 -    SDL_Quit();
    4.30 -    exit(rc);
    4.31 -}
    4.32 -
    4.33 -int
    4.34 -LoadSprite(char *file)
    4.35 -{
    4.36 -    SDL_Surface *temp;
    4.37 -
    4.38 -    /* Load the sprite image */
    4.39 -    sprite = SDL_LoadBMP(file);
    4.40 -    if (sprite == NULL) {
    4.41 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
    4.42 -        return (-1);
    4.43 -    }
    4.44 -
    4.45 -    /* Set transparent pixel as the pixel at (0,0) */
    4.46 -    if (sprite->format->palette) {
    4.47 -        SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY | SDL_RLEACCEL),
    4.48 -                        *(Uint8 *) sprite->pixels);
    4.49 -    }
    4.50 -
    4.51 -    /* Convert sprite to video format */
    4.52 -    temp = SDL_DisplayFormat(sprite);
    4.53 -    SDL_FreeSurface(sprite);
    4.54 -    if (temp == NULL) {
    4.55 -        fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError());
    4.56 -        return (-1);
    4.57 -    }
    4.58 -    sprite = temp;
    4.59 -
    4.60 -    /* We're ready to roll. :) */
    4.61 -    return (0);
    4.62 -}
    4.63 -
    4.64 -void
    4.65 -MoveSprites(SDL_Surface * screen, Uint32 background)
    4.66 -{
    4.67 -    int i, nupdates;
    4.68 -    SDL_Rect area, *position, *velocity;
    4.69 -
    4.70 -    nupdates = 0;
    4.71 -    /* Erase all the sprites if necessary */
    4.72 -    if (sprites_visible) {
    4.73 -        SDL_FillRect(screen, NULL, background);
    4.74 -    }
    4.75 -
    4.76 -    /* Move the sprite, bounce at the wall, and draw */
    4.77 -    for (i = 0; i < numsprites; ++i) {
    4.78 -        position = &positions[i];
    4.79 -        velocity = &velocities[i];
    4.80 -        position->x += velocity->x;
    4.81 -        if ((position->x < 0) || (position->x >= (screen->w - sprite_w))) {
    4.82 -            velocity->x = -velocity->x;
    4.83 -            position->x += velocity->x;
    4.84 -        }
    4.85 -        position->y += velocity->y;
    4.86 -        if ((position->y < 0) || (position->y >= (screen->h - sprite_w))) {
    4.87 -            velocity->y = -velocity->y;
    4.88 -            position->y += velocity->y;
    4.89 -        }
    4.90 -
    4.91 -        /* Blit the sprite onto the screen */
    4.92 -        area = *position;
    4.93 -        SDL_BlitSurface(sprite, NULL, screen, &area);
    4.94 -        sprite_rects[nupdates++] = area;
    4.95 -    }
    4.96 -
    4.97 -    if (debug_flip) {
    4.98 -        if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
    4.99 -            static int t = 0;
   4.100 -
   4.101 -            Uint32 color = SDL_MapRGB(screen->format, 255, 0, 0);
   4.102 -            SDL_Rect r;
   4.103 -            r.x = t;
   4.104 -/* (sin((float) t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w - 20); */
   4.105 -            r.y = 0;
   4.106 -            r.w = 20;
   4.107 -            r.h = screen->h;
   4.108 -
   4.109 -            SDL_FillRect(screen, &r, color);
   4.110 -            t += 2;
   4.111 -        }
   4.112 -    }
   4.113 -
   4.114 -    /* Update the screen! */
   4.115 -    if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
   4.116 -        SDL_Flip(screen);
   4.117 -    } else {
   4.118 -        SDL_UpdateRects(screen, nupdates, sprite_rects);
   4.119 -    }
   4.120 -    sprites_visible = 1;
   4.121 -}
   4.122 -
   4.123 -/* This is a way of telling whether or not to use hardware surfaces */
   4.124 -Uint32
   4.125 -FastestFlags(Uint32 flags, int width, int height, int bpp)
   4.126 -{
   4.127 -    const SDL_VideoInfo *info;
   4.128 -
   4.129 -    /* Hardware acceleration is only used in fullscreen mode */
   4.130 -    flags |= SDL_FULLSCREEN;
   4.131 -
   4.132 -    /* Check for various video capabilities */
   4.133 -    info = SDL_GetVideoInfo();
   4.134 -    if (info->blit_hw_CC && info->blit_fill) {
   4.135 -        /* We use accelerated colorkeying and color filling */
   4.136 -        flags |= SDL_HWSURFACE;
   4.137 -    }
   4.138 -    /* If we have enough video memory, and will use accelerated
   4.139 -       blits directly to it, then use page flipping.
   4.140 -     */
   4.141 -    if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
   4.142 -        /* Direct hardware blitting without double-buffering
   4.143 -           causes really bad flickering.
   4.144 -         */
   4.145 -        if (info->video_mem * 1024 > (height * width * bpp / 8)) {
   4.146 -            flags |= SDL_DOUBLEBUF;
   4.147 -        } else {
   4.148 -            flags &= ~SDL_HWSURFACE;
   4.149 -        }
   4.150 -    }
   4.151 -
   4.152 -    /* Return the flags */
   4.153 -    return (flags);
   4.154 -}
   4.155 -
   4.156 -int
   4.157 -main(int argc, char *argv[])
   4.158 -{
   4.159 -    SDL_Surface *screen;
   4.160 -    Uint8 *mem;
   4.161 -    int width, height;
   4.162 -    Uint8 video_bpp;
   4.163 -    Uint32 videoflags;
   4.164 -    Uint32 background;
   4.165 -    int i, done;
   4.166 -    SDL_Event event;
   4.167 -    Uint32 then, now, frames;
   4.168 -
   4.169 -    consoleDemoInit();
   4.170 -    puts("Hello world!  Initializing FAT...");
   4.171 -    fatInitDefault();
   4.172 -    /* Initialize SDL */
   4.173 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   4.174 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   4.175 -        return (1);
   4.176 -    }
   4.177 -    puts("* initialized SDL");
   4.178 -
   4.179 -    numsprites = NUM_SPRITES;
   4.180 -    videoflags = SDL_SWSURFACE /*| SDL_ANYFORMAT */ ;
   4.181 -    width = 256;
   4.182 -    height = 192;
   4.183 -    video_bpp = 15;
   4.184 -    debug_flip = 0;
   4.185 -    while (argc > 1) {
   4.186 -        --argc;
   4.187 -        if (strcmp(argv[argc - 1], "-width") == 0) {
   4.188 -            width = atoi(argv[argc]);
   4.189 -            --argc;
   4.190 -        } else if (strcmp(argv[argc - 1], "-height") == 0) {
   4.191 -            height = atoi(argv[argc]);
   4.192 -            --argc;
   4.193 -        } else if (strcmp(argv[argc - 1], "-bpp") == 0) {
   4.194 -            video_bpp = atoi(argv[argc]);
   4.195 -            videoflags &= ~SDL_ANYFORMAT;
   4.196 -            --argc;
   4.197 -        } else if (strcmp(argv[argc], "-fast") == 0) {
   4.198 -            videoflags = FastestFlags(videoflags, width, height, video_bpp);
   4.199 -        } else if (strcmp(argv[argc], "-hw") == 0) {
   4.200 -            videoflags ^= SDL_HWSURFACE;
   4.201 -        } else if (strcmp(argv[argc], "-flip") == 0) {
   4.202 -            videoflags ^= SDL_DOUBLEBUF;
   4.203 -        } else if (strcmp(argv[argc], "-debugflip") == 0) {
   4.204 -            debug_flip ^= 1;
   4.205 -        } else if (strcmp(argv[argc], "-fullscreen") == 0) {
   4.206 -            videoflags ^= SDL_FULLSCREEN;
   4.207 -        } else if (isdigit(argv[argc][0])) {
   4.208 -            numsprites = atoi(argv[argc]);
   4.209 -        } else {
   4.210 -            fprintf(stderr,
   4.211 -                    "Usage: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen] [numsprites]\n",
   4.212 -                    argv[0]);
   4.213 -            quit(1);
   4.214 -        }
   4.215 -    }
   4.216 -
   4.217 -    /* Set video mode */
   4.218 -    screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
   4.219 -    if (!screen) {
   4.220 -        fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
   4.221 -                width, height, SDL_GetError());
   4.222 -        quit(2);
   4.223 -    }
   4.224 -    screen->flags &= ~SDL_PREALLOC;
   4.225 -    puts("* set video mode");
   4.226 -
   4.227 -    /* Load the sprite */
   4.228 -    if (LoadSprite("icon.bmp") < 0) {
   4.229 -        quit(1);
   4.230 -    }
   4.231 -    puts("* loaded sprite");
   4.232 -
   4.233 -    /* Allocate memory for the sprite info */
   4.234 -    mem = (Uint8 *) malloc(4 * sizeof(SDL_Rect) * numsprites);
   4.235 -    if (mem == NULL) {
   4.236 -        SDL_FreeSurface(sprite);
   4.237 -        fprintf(stderr, "Out of memory!\n");
   4.238 -        quit(2);
   4.239 -    }
   4.240 -    sprite_rects = (SDL_Rect *) mem;
   4.241 -    positions = sprite_rects;
   4.242 -    sprite_rects += numsprites;
   4.243 -    velocities = sprite_rects;
   4.244 -    sprite_rects += numsprites;
   4.245 -    sprite_w = sprite->w;
   4.246 -    sprite_h = sprite->h;
   4.247 -    srand(time(NULL));
   4.248 -    for (i = 0; i < numsprites; ++i) {
   4.249 -        positions[i].x = rand() % (screen->w - sprite_w);
   4.250 -        positions[i].y = rand() % (screen->h - sprite_h);
   4.251 -        positions[i].w = sprite->w;
   4.252 -        positions[i].h = sprite->h;
   4.253 -        velocities[i].x = 0;
   4.254 -        velocities[i].y = 0;
   4.255 -        while (!velocities[i].x && !velocities[i].y) {
   4.256 -            velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
   4.257 -            velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
   4.258 -        }
   4.259 -    }
   4.260 -    background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
   4.261 -
   4.262 -    /* Print out information about our surfaces */
   4.263 -    printf("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel);
   4.264 -    if ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
   4.265 -        printf("Screen is in video memory\n");
   4.266 -    } else {
   4.267 -        printf("Screen is in system memory\n");
   4.268 -    }
   4.269 -    if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
   4.270 -        printf("Screen has double-buffering enabled\n");
   4.271 -    }
   4.272 -    if ((sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
   4.273 -        printf("Sprite is in video memory\n");
   4.274 -    } else {
   4.275 -        printf("Sprite is in system memory\n");
   4.276 -    }
   4.277 -    /* Run a sample blit to trigger blit acceleration */
   4.278 -    {
   4.279 -        SDL_Rect dst;
   4.280 -        dst.x = 0;
   4.281 -        dst.y = 0;
   4.282 -        dst.w = sprite->w;
   4.283 -        dst.h = sprite->h;
   4.284 -        SDL_BlitSurface(sprite, NULL, screen, &dst);
   4.285 -        SDL_FillRect(screen, &dst, background);
   4.286 -    }
   4.287 -    if ((sprite->flags & SDL_HWACCEL) == SDL_HWACCEL) {
   4.288 -        printf("Sprite blit uses hardware acceleration\n");
   4.289 -    }
   4.290 -    if ((sprite->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
   4.291 -        printf("Sprite blit uses RLE acceleration\n");
   4.292 -    }
   4.293 -
   4.294 -    /* Loop, blitting sprites and waiting for a keystroke */
   4.295 -    frames = 0;
   4.296 -    then = SDL_GetTicks();
   4.297 -    done = 0;
   4.298 -    sprites_visible = 0;
   4.299 -    puts("hello!");
   4.300 -    while (!done) {
   4.301 -        /* Check for events */
   4.302 -        ++frames;
   4.303 -        printf(".");
   4.304 -        swiWaitForVBlank();
   4.305 -        MoveSprites(screen, background);
   4.306 -    }
   4.307 -    puts("goodbye!");
   4.308 -    SDL_FreeSurface(sprite);
   4.309 -    free(mem);
   4.310 -
   4.311 -    /* Print out some timing information */
   4.312 -    now = SDL_GetTicks();
   4.313 -    if (now > then) {
   4.314 -        printf("%2.2f frames per second\n",
   4.315 -               ((double) frames * 1000) / (now - then));
   4.316 -    }
   4.317 -    SDL_Quit();
   4.318 -    return (0);
   4.319 -}
     5.1 --- a/test/nds-test-progs/sprite2/Makefile	Sat Mar 26 21:26:05 2011 -0700
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,132 +0,0 @@
     5.4 -#---------------------------------------------------------------------------------
     5.5 -.SUFFIXES:
     5.6 -#---------------------------------------------------------------------------------
     5.7 -
     5.8 -ifeq ($(strip $(DEVKITARM)),)
     5.9 -$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
    5.10 -endif
    5.11 -
    5.12 -include $(DEVKITARM)/ds_rules
    5.13 -
    5.14 -#---------------------------------------------------------------------------------
    5.15 -# TARGET is the name of the output
    5.16 -# BUILD is the directory where object files & intermediate files will be placed
    5.17 -# SOURCES is a list of directories containing source code
    5.18 -# INCLUDES is a list of directories containing extra header files
    5.19 -#---------------------------------------------------------------------------------
    5.20 -TARGET		:=	$(shell basename $(CURDIR))
    5.21 -BUILD		:=	build
    5.22 -SOURCES		:=	source
    5.23 -DATA		:=	data  
    5.24 -INCLUDES	:=	include
    5.25 -
    5.26 -#---------------------------------------------------------------------------------
    5.27 -# options for code generation
    5.28 -#---------------------------------------------------------------------------------
    5.29 -ARCH	:=	-mthumb -mthumb-interwork
    5.30 -
    5.31 -# note: arm9tdmi isn't the correct CPU arch, but anything newer and LD
    5.32 -# *insists* it has a FPU or VFP, and it won't take no for an answer!
    5.33 -CFLAGS	:=	-save-temps -g -Wall -O0\
    5.34 - 			-mcpu=arm9tdmi -mtune=arm9tdmi \
    5.35 -			$(ARCH)
    5.36 -
    5.37 -CFLAGS	+=	$(INCLUDE) -DARM9 -D__NDS__
    5.38 -CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions -fno-exceptions -fno-rtti
    5.39 -
    5.40 -ASFLAGS	:=	-g $(ARCH)
    5.41 -LDFLAGS	=	-specs=ds_arm9.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*.map)
    5.42 -
    5.43 -#---------------------------------------------------------------------------------
    5.44 -# any extra libraries we wish to link with the project
    5.45 -#---------------------------------------------------------------------------------
    5.46 -LIBS	:= -lSDL -lfat -lnds9
    5.47 - 
    5.48 - 
    5.49 -#---------------------------------------------------------------------------------
    5.50 -# list of directories containing libraries, this must be the top level containing
    5.51 -# include and lib
    5.52 -#---------------------------------------------------------------------------------
    5.53 -LIBDIRS	:=	$(LIBNDS)
    5.54 - 
    5.55 -#---------------------------------------------------------------------------------
    5.56 -# no real need to edit anything past this point unless you need to add additional
    5.57 -# rules for different file extensions
    5.58 -#---------------------------------------------------------------------------------
    5.59 -ifneq ($(BUILD),$(notdir $(CURDIR)))
    5.60 -#---------------------------------------------------------------------------------
    5.61 - 
    5.62 -export OUTPUT	:=	$(CURDIR)/$(TARGET)
    5.63 - 
    5.64 -export VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
    5.65 -					$(foreach dir,$(DATA),$(CURDIR)/$(dir))
    5.66 -
    5.67 -export DEPSDIR	:=	$(CURDIR)/$(BUILD)
    5.68 -
    5.69 -CFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
    5.70 -CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
    5.71 -SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
    5.72 -BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
    5.73 - 
    5.74 -#---------------------------------------------------------------------------------
    5.75 -# use CXX for linking C++ projects, CC for standard C
    5.76 -#---------------------------------------------------------------------------------
    5.77 -ifeq ($(strip $(CPPFILES)),)
    5.78 -#---------------------------------------------------------------------------------
    5.79 -	export LD	:=	$(CC)
    5.80 -#---------------------------------------------------------------------------------
    5.81 -else
    5.82 -#---------------------------------------------------------------------------------
    5.83 -	export LD	:=	$(CXX)
    5.84 -#---------------------------------------------------------------------------------
    5.85 -endif
    5.86 -#---------------------------------------------------------------------------------
    5.87 -
    5.88 -export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
    5.89 -					$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
    5.90 - 
    5.91 -export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
    5.92 -					$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
    5.93 -					$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
    5.94 -					-I$(CURDIR)/$(BUILD)
    5.95 - 
    5.96 -export LIBPATHS	:=	$(foreach dir,$(LIBDIRS),-L$(dir)/lib)
    5.97 - 
    5.98 -.PHONY: $(BUILD) clean
    5.99 - 
   5.100 -#---------------------------------------------------------------------------------
   5.101 -$(BUILD):
   5.102 -	@[ -d $@ ] || mkdir -p $@
   5.103 -	@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
   5.104 - 
   5.105 -#---------------------------------------------------------------------------------
   5.106 -clean:
   5.107 -	@echo clean ...
   5.108 -	@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9 $(TARGET).ds.gba 
   5.109 - 
   5.110 - 
   5.111 -#---------------------------------------------------------------------------------
   5.112 -else
   5.113 - 
   5.114 -DEPENDS	:=	$(OFILES:.o=.d)
   5.115 - 
   5.116 -#---------------------------------------------------------------------------------
   5.117 -# main targets
   5.118 -#---------------------------------------------------------------------------------
   5.119 -$(OUTPUT).ds.gba	: 	$(OUTPUT).nds
   5.120 -$(OUTPUT).nds	: 	$(OUTPUT).arm9
   5.121 -$(OUTPUT).arm9	:	$(OUTPUT).elf
   5.122 -$(OUTPUT).elf	:	$(OFILES)
   5.123 - 
   5.124 -#---------------------------------------------------------------------------------
   5.125 -%.bin.o	:	%.bin
   5.126 -#---------------------------------------------------------------------------------
   5.127 -	@echo $(notdir $<)
   5.128 -	@$(bin2o)
   5.129 - 
   5.130 - 
   5.131 --include $(DEPENDS)
   5.132 - 
   5.133 -#---------------------------------------------------------------------------------------
   5.134 -endif
   5.135 -#---------------------------------------------------------------------------------------
     6.1 Binary file test/nds-test-progs/sprite2/icon.bmp has changed
     7.1 --- a/test/nds-test-progs/sprite2/source/common.c	Sat Mar 26 21:26:05 2011 -0700
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,965 +0,0 @@
     7.4 -
     7.5 -/* A simple test program framework */
     7.6 -
     7.7 -#include <stdio.h>
     7.8 -
     7.9 -#include "common.h"
    7.10 -
    7.11 -#define VIDEO_USAGE \
    7.12 -"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display %d] [--fullscreen | --windows N] [--title title] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]"
    7.13 -
    7.14 -#define AUDIO_USAGE \
    7.15 -"[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
    7.16 -
    7.17 -CommonState *
    7.18 -CommonCreateState(char **argv, Uint32 flags)
    7.19 -{
    7.20 -    CommonState *state = SDL_calloc(1, sizeof(*state));
    7.21 -    if (!state) {
    7.22 -        SDL_OutOfMemory();
    7.23 -        return NULL;
    7.24 -    }
    7.25 -
    7.26 -    /* Initialize some defaults */
    7.27 -    state->argv = argv;
    7.28 -    state->flags = flags;
    7.29 -    state->window_title = argv[0];
    7.30 -    state->window_flags = SDL_WINDOW_SHOWN;
    7.31 -    state->window_x = SDL_WINDOWPOS_UNDEFINED;
    7.32 -    state->window_y = SDL_WINDOWPOS_UNDEFINED;
    7.33 -    state->window_w = 256;
    7.34 -    state->window_h = 192;
    7.35 -    state->num_windows = 1;
    7.36 -    state->audiospec.freq = 22050;
    7.37 -    state->audiospec.format = AUDIO_S16;
    7.38 -    state->audiospec.channels = 2;
    7.39 -    state->audiospec.samples = 2048;
    7.40 -    return state;
    7.41 -}
    7.42 -
    7.43 -int
    7.44 -CommonArg(CommonState * state, int index)
    7.45 -{
    7.46 -    char **argv = state->argv;
    7.47 -
    7.48 -    if (SDL_strcasecmp(argv[index], "--video") == 0) {
    7.49 -        ++index;
    7.50 -        if (!argv[index]) {
    7.51 -            return -1;
    7.52 -        }
    7.53 -        state->videodriver = argv[index];
    7.54 -        return 2;
    7.55 -    }
    7.56 -    if (SDL_strcasecmp(argv[index], "--renderer") == 0) {
    7.57 -        ++index;
    7.58 -        if (!argv[index]) {
    7.59 -            return -1;
    7.60 -        }
    7.61 -        state->renderdriver = argv[index];
    7.62 -        return 2;
    7.63 -    }
    7.64 -    if (SDL_strcasecmp(argv[index], "--info") == 0) {
    7.65 -        ++index;
    7.66 -        if (!argv[index]) {
    7.67 -            return -1;
    7.68 -        }
    7.69 -        if (SDL_strcasecmp(argv[index], "all") == 0) {
    7.70 -            state->verbose |=
    7.71 -                (VERBOSE_VIDEO | VERBOSE_MODES | VERBOSE_RENDER |
    7.72 -                 VERBOSE_EVENT);
    7.73 -            return 2;
    7.74 -        }
    7.75 -        if (SDL_strcasecmp(argv[index], "video") == 0) {
    7.76 -            state->verbose |= VERBOSE_VIDEO;
    7.77 -            return 2;
    7.78 -        }
    7.79 -        if (SDL_strcasecmp(argv[index], "modes") == 0) {
    7.80 -            state->verbose |= VERBOSE_MODES;
    7.81 -            return 2;
    7.82 -        }
    7.83 -        if (SDL_strcasecmp(argv[index], "render") == 0) {
    7.84 -            state->verbose |= VERBOSE_RENDER;
    7.85 -            return 2;
    7.86 -        }
    7.87 -        if (SDL_strcasecmp(argv[index], "event") == 0) {
    7.88 -            state->verbose |= VERBOSE_EVENT;
    7.89 -            return 2;
    7.90 -        }
    7.91 -        return -1;
    7.92 -    }
    7.93 -    if (SDL_strcasecmp(argv[index], "--display") == 0) {
    7.94 -        ++index;
    7.95 -        if (!argv[index]) {
    7.96 -            return -1;
    7.97 -        }
    7.98 -        state->display = SDL_atoi(argv[index]);
    7.99 -        return 2;
   7.100 -    }
   7.101 -    if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) {
   7.102 -        state->window_flags |= SDL_WINDOW_FULLSCREEN;
   7.103 -        state->num_windows = 1;
   7.104 -        return 1;
   7.105 -    }
   7.106 -    if (SDL_strcasecmp(argv[index], "--windows") == 0) {
   7.107 -        ++index;
   7.108 -        if (!argv[index] || !SDL_isdigit(*argv[index])) {
   7.109 -            return -1;
   7.110 -        }
   7.111 -        if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) {
   7.112 -            state->num_windows = SDL_atoi(argv[index]);
   7.113 -        }
   7.114 -        return 2;
   7.115 -    }
   7.116 -    if (SDL_strcasecmp(argv[index], "--title") == 0) {
   7.117 -        ++index;
   7.118 -        if (!argv[index]) {
   7.119 -            return -1;
   7.120 -        }
   7.121 -        state->window_title = argv[index];
   7.122 -        return 2;
   7.123 -    }
   7.124 -    if (SDL_strcasecmp(argv[index], "--center") == 0) {
   7.125 -        state->window_x = SDL_WINDOWPOS_CENTERED;
   7.126 -        state->window_y = SDL_WINDOWPOS_CENTERED;
   7.127 -        return 1;
   7.128 -    }
   7.129 -    if (SDL_strcasecmp(argv[index], "--position") == 0) {
   7.130 -        char *x, *y;
   7.131 -        ++index;
   7.132 -        if (!argv[index]) {
   7.133 -            return -1;
   7.134 -        }
   7.135 -        x = argv[index];
   7.136 -        y = argv[index];
   7.137 -        while (*y && *y != ',') {
   7.138 -            ++y;
   7.139 -        }
   7.140 -        if (!*y) {
   7.141 -            return -1;
   7.142 -        }
   7.143 -        *y++ = '\0';
   7.144 -        state->window_x = SDL_atoi(x);
   7.145 -        state->window_y = SDL_atoi(y);
   7.146 -        return 2;
   7.147 -    }
   7.148 -    if (SDL_strcasecmp(argv[index], "--geometry") == 0) {
   7.149 -        char *w, *h;
   7.150 -        ++index;
   7.151 -        if (!argv[index]) {
   7.152 -            return -1;
   7.153 -        }
   7.154 -        w = argv[index];
   7.155 -        h = argv[index];
   7.156 -        while (*h && *h != 'x') {
   7.157 -            ++h;
   7.158 -        }
   7.159 -        if (!*h) {
   7.160 -            return -1;
   7.161 -        }
   7.162 -        *h++ = '\0';
   7.163 -        state->window_w = SDL_atoi(w);
   7.164 -        state->window_h = SDL_atoi(h);
   7.165 -        return 2;
   7.166 -    }
   7.167 -    if (SDL_strcasecmp(argv[index], "--depth") == 0) {
   7.168 -        ++index;
   7.169 -        if (!argv[index]) {
   7.170 -            return -1;
   7.171 -        }
   7.172 -        state->depth = SDL_atoi(argv[index]);
   7.173 -        return 2;
   7.174 -    }
   7.175 -    if (SDL_strcasecmp(argv[index], "--refresh") == 0) {
   7.176 -        ++index;
   7.177 -        if (!argv[index]) {
   7.178 -            return -1;
   7.179 -        }
   7.180 -        state->refresh_rate = SDL_atoi(argv[index]);
   7.181 -        return 2;
   7.182 -    }
   7.183 -    if (SDL_strcasecmp(argv[index], "--vsync") == 0) {
   7.184 -        state->render_flags |= SDL_RENDERER_PRESENTVSYNC;
   7.185 -        return 1;
   7.186 -    }
   7.187 -    if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
   7.188 -        state->window_flags |= SDL_WINDOW_BORDERLESS;
   7.189 -        return 1;
   7.190 -    }
   7.191 -    if (SDL_strcasecmp(argv[index], "--resize") == 0) {
   7.192 -        state->window_flags |= SDL_WINDOW_RESIZABLE;
   7.193 -        return 1;
   7.194 -    }
   7.195 -    if (SDL_strcasecmp(argv[index], "--minimize") == 0) {
   7.196 -        state->window_flags |= SDL_WINDOW_MINIMIZED;
   7.197 -        return 1;
   7.198 -    }
   7.199 -    if (SDL_strcasecmp(argv[index], "--maximize") == 0) {
   7.200 -        state->window_flags |= SDL_WINDOW_MAXIMIZED;
   7.201 -        return 1;
   7.202 -    }
   7.203 -    if (SDL_strcasecmp(argv[index], "--grab") == 0) {
   7.204 -        state->window_flags |= SDL_WINDOW_INPUT_GRABBED;
   7.205 -        return 1;
   7.206 -    }
   7.207 -    if (SDL_strcasecmp(argv[index], "--rate") == 0) {
   7.208 -        ++index;
   7.209 -        if (!argv[index]) {
   7.210 -            return -1;
   7.211 -        }
   7.212 -        state->audiospec.freq = SDL_atoi(argv[index]);
   7.213 -        return 2;
   7.214 -    }
   7.215 -    if (SDL_strcasecmp(argv[index], "--format") == 0) {
   7.216 -        ++index;
   7.217 -        if (!argv[index]) {
   7.218 -            return -1;
   7.219 -        }
   7.220 -        if (SDL_strcasecmp(argv[index], "U8") == 0) {
   7.221 -            state->audiospec.format = AUDIO_U8;
   7.222 -            return 2;
   7.223 -        }
   7.224 -        if (SDL_strcasecmp(argv[index], "S8") == 0) {
   7.225 -            state->audiospec.format = AUDIO_S8;
   7.226 -            return 2;
   7.227 -        }
   7.228 -        if (SDL_strcasecmp(argv[index], "U16") == 0) {
   7.229 -            state->audiospec.format = AUDIO_U16;
   7.230 -            return 2;
   7.231 -        }
   7.232 -        if (SDL_strcasecmp(argv[index], "U16LE") == 0) {
   7.233 -            state->audiospec.format = AUDIO_U16LSB;
   7.234 -            return 2;
   7.235 -        }
   7.236 -        if (SDL_strcasecmp(argv[index], "U16BE") == 0) {
   7.237 -            state->audiospec.format = AUDIO_U16MSB;
   7.238 -            return 2;
   7.239 -        }
   7.240 -        if (SDL_strcasecmp(argv[index], "S16") == 0) {
   7.241 -            state->audiospec.format = AUDIO_S16;
   7.242 -            return 2;
   7.243 -        }
   7.244 -        if (SDL_strcasecmp(argv[index], "S16LE") == 0) {
   7.245 -            state->audiospec.format = AUDIO_S16LSB;
   7.246 -            return 2;
   7.247 -        }
   7.248 -        if (SDL_strcasecmp(argv[index], "S16BE") == 0) {
   7.249 -            state->audiospec.format = AUDIO_S16MSB;
   7.250 -            return 2;
   7.251 -        }
   7.252 -        return -1;
   7.253 -    }
   7.254 -    if (SDL_strcasecmp(argv[index], "--channels") == 0) {
   7.255 -        ++index;
   7.256 -        if (!argv[index]) {
   7.257 -            return -1;
   7.258 -        }
   7.259 -        state->audiospec.channels = (Uint8) SDL_atoi(argv[index]);
   7.260 -        return 2;
   7.261 -    }
   7.262 -    if (SDL_strcasecmp(argv[index], "--samples") == 0) {
   7.263 -        ++index;
   7.264 -        if (!argv[index]) {
   7.265 -            return -1;
   7.266 -        }
   7.267 -        state->audiospec.samples = (Uint16) SDL_atoi(argv[index]);
   7.268 -        return 2;
   7.269 -    }
   7.270 -    if ((SDL_strcasecmp(argv[index], "-h") == 0)
   7.271 -        || (SDL_strcasecmp(argv[index], "--help") == 0)) {
   7.272 -        /* Print the usage message */
   7.273 -        return -1;
   7.274 -    }
   7.275 -    return 0;
   7.276 -}
   7.277 -
   7.278 -const char *
   7.279 -CommonUsage(CommonState * state)
   7.280 -{
   7.281 -    switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
   7.282 -    case SDL_INIT_VIDEO:
   7.283 -        return VIDEO_USAGE;
   7.284 -    case SDL_INIT_AUDIO:
   7.285 -        return AUDIO_USAGE;
   7.286 -    case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
   7.287 -        return VIDEO_USAGE " " AUDIO_USAGE;
   7.288 -    default:
   7.289 -        return "";
   7.290 -    }
   7.291 -}
   7.292 -
   7.293 -static void
   7.294 -PrintRendererFlag(Uint32 flag)
   7.295 -{
   7.296 -    switch (flag) {
   7.297 -    case SDL_RENDERER_SINGLEBUFFER:
   7.298 -        fprintf(stderr, "SingleBuffer");
   7.299 -        break;
   7.300 -    case SDL_RENDERER_PRESENTCOPY:
   7.301 -        fprintf(stderr, "PresentCopy");
   7.302 -        break;
   7.303 -    case SDL_RENDERER_PRESENTFLIP2:
   7.304 -        fprintf(stderr, "PresentFlip2");
   7.305 -        break;
   7.306 -    case SDL_RENDERER_PRESENTFLIP3:
   7.307 -        fprintf(stderr, "PresentFlip3");
   7.308 -        break;
   7.309 -    case SDL_RENDERER_PRESENTDISCARD:
   7.310 -        fprintf(stderr, "PresentDiscard");
   7.311 -        break;
   7.312 -    case SDL_RENDERER_PRESENTVSYNC:
   7.313 -        fprintf(stderr, "PresentVSync");
   7.314 -        break;
   7.315 -    case SDL_RENDERER_ACCELERATED:
   7.316 -        fprintf(stderr, "Accelerated");
   7.317 -        break;
   7.318 -    default:
   7.319 -        fprintf(stderr, "0x%8.8x", flag);
   7.320 -        break;
   7.321 -    }
   7.322 -}
   7.323 -
   7.324 -static void
   7.325 -PrintBlendMode(Uint32 flag)
   7.326 -{
   7.327 -    switch (flag) {
   7.328 -    case SDL_BLENDMODE_NONE:
   7.329 -        fprintf(stderr, "None");
   7.330 -        break;
   7.331 -    case SDL_BLENDMODE_MASK:
   7.332 -        fprintf(stderr, "Mask");
   7.333 -        break;
   7.334 -    case SDL_BLENDMODE_BLEND:
   7.335 -        fprintf(stderr, "Blend");
   7.336 -        break;
   7.337 -    case SDL_BLENDMODE_ADD:
   7.338 -        fprintf(stderr, "Add");
   7.339 -        break;
   7.340 -    case SDL_BLENDMODE_MOD:
   7.341 -        fprintf(stderr, "Mod");
   7.342 -        break;
   7.343 -    default:
   7.344 -        fprintf(stderr, "0x%8.8x", flag);
   7.345 -        break;
   7.346 -    }
   7.347 -}
   7.348 -
   7.349 -static void
   7.350 -PrintScaleMode(Uint32 flag)
   7.351 -{
   7.352 -    switch (flag) {
   7.353 -    case SDL_TEXTURESCALEMODE_NONE:
   7.354 -        fprintf(stderr, "None");
   7.355 -        break;
   7.356 -    case SDL_TEXTURESCALEMODE_FAST:
   7.357 -        fprintf(stderr, "Fast");
   7.358 -        break;
   7.359 -    case SDL_TEXTURESCALEMODE_SLOW:
   7.360 -        fprintf(stderr, "Slow");
   7.361 -        break;
   7.362 -    case SDL_TEXTURESCALEMODE_BEST:
   7.363 -        fprintf(stderr, "Best");
   7.364 -        break;
   7.365 -    default:
   7.366 -        fprintf(stderr, "0x%8.8x", flag);
   7.367 -        break;
   7.368 -    }
   7.369 -}
   7.370 -
   7.371 -static void
   7.372 -PrintPixelFormat(Uint32 format)
   7.373 -{
   7.374 -    switch (format) {
   7.375 -    case SDL_PIXELFORMAT_UNKNOWN:
   7.376 -        fprintf(stderr, "Unknwon");
   7.377 -        break;
   7.378 -    case SDL_PIXELFORMAT_INDEX1LSB:
   7.379 -        fprintf(stderr, "Index1LSB");
   7.380 -        break;
   7.381 -    case SDL_PIXELFORMAT_INDEX1MSB:
   7.382 -        fprintf(stderr, "Index1MSB");
   7.383 -        break;
   7.384 -    case SDL_PIXELFORMAT_INDEX4LSB:
   7.385 -        fprintf(stderr, "Index4LSB");
   7.386 -        break;
   7.387 -    case SDL_PIXELFORMAT_INDEX4MSB:
   7.388 -        fprintf(stderr, "Index4MSB");
   7.389 -        break;
   7.390 -    case SDL_PIXELFORMAT_INDEX8:
   7.391 -        fprintf(stderr, "Index8");
   7.392 -        break;
   7.393 -    case SDL_PIXELFORMAT_RGB332:
   7.394 -        fprintf(stderr, "RGB332");
   7.395 -        break;
   7.396 -    case SDL_PIXELFORMAT_RGB444:
   7.397 -        fprintf(stderr, "RGB444");
   7.398 -        break;
   7.399 -    case SDL_PIXELFORMAT_RGB555:
   7.400 -        fprintf(stderr, "RGB555");
   7.401 -        break;
   7.402 -    case SDL_PIXELFORMAT_ARGB4444:
   7.403 -        fprintf(stderr, "ARGB4444");
   7.404 -        break;
   7.405 -    case SDL_PIXELFORMAT_ARGB1555:
   7.406 -        fprintf(stderr, "ARGB1555");
   7.407 -        break;
   7.408 -    case SDL_PIXELFORMAT_RGB565:
   7.409 -        fprintf(stderr, "RGB565");
   7.410 -        break;
   7.411 -    case SDL_PIXELFORMAT_RGB24:
   7.412 -        fprintf(stderr, "RGB24");
   7.413 -        break;
   7.414 -    case SDL_PIXELFORMAT_BGR24:
   7.415 -        fprintf(stderr, "BGR24");
   7.416 -        break;
   7.417 -    case SDL_PIXELFORMAT_RGB888:
   7.418 -        fprintf(stderr, "RGB888");
   7.419 -        break;
   7.420 -    case SDL_PIXELFORMAT_BGR888:
   7.421 -        fprintf(stderr, "BGR888");
   7.422 -        break;
   7.423 -    case SDL_PIXELFORMAT_ARGB8888:
   7.424 -        fprintf(stderr, "ARGB8888");
   7.425 -        break;
   7.426 -    case SDL_PIXELFORMAT_RGBA8888:
   7.427 -        fprintf(stderr, "RGBA8888");
   7.428 -        break;
   7.429 -    case SDL_PIXELFORMAT_ABGR8888:
   7.430 -        fprintf(stderr, "ABGR8888");
   7.431 -        break;
   7.432 -    case SDL_PIXELFORMAT_BGRA8888:
   7.433 -        fprintf(stderr, "BGRA8888");
   7.434 -        break;
   7.435 -    case SDL_PIXELFORMAT_ARGB2101010:
   7.436 -        fprintf(stderr, "ARGB2101010");
   7.437 -        break;
   7.438 -    case SDL_PIXELFORMAT_YV12:
   7.439 -        fprintf(stderr, "YV12");
   7.440 -        break;
   7.441 -    case SDL_PIXELFORMAT_IYUV:
   7.442 -        fprintf(stderr, "IYUV");
   7.443 -        break;
   7.444 -    case SDL_PIXELFORMAT_YUY2:
   7.445 -        fprintf(stderr, "YUY2");
   7.446 -        break;
   7.447 -    case SDL_PIXELFORMAT_UYVY:
   7.448 -        fprintf(stderr, "UYVY");
   7.449 -        break;
   7.450 -    case SDL_PIXELFORMAT_YVYU:
   7.451 -        fprintf(stderr, "YVYU");
   7.452 -        break;
   7.453 -    case SDL_PIXELFORMAT_ABGR1555:
   7.454 -        fprintf(stderr, "ABGR1555");
   7.455 -        break;
   7.456 -    case SDL_PIXELFORMAT_BGR555:
   7.457 -        fprintf(stderr, "BGR555");
   7.458 -        break;
   7.459 -    default:
   7.460 -        fprintf(stderr, "0x%8.8x", format);
   7.461 -        break;
   7.462 -    }
   7.463 -}
   7.464 -
   7.465 -static void
   7.466 -PrintRenderer(SDL_RendererInfo * info)
   7.467 -{
   7.468 -    int i, count;
   7.469 -
   7.470 -    fprintf(stderr, "  Renderer %s:\n", info->name);
   7.471 -
   7.472 -    fprintf(stderr, "    Flags: 0x%8.8X", info->flags);
   7.473 -    fprintf(stderr, " (");
   7.474 -    count = 0;
   7.475 -    for (i = 0; i < sizeof(info->flags) * 8; ++i) {
   7.476 -        Uint32 flag = (1 << i);
   7.477 -        if (info->flags & flag) {
   7.478 -            if (count > 0) {
   7.479 -                fprintf(stderr, " | ");
   7.480 -            }
   7.481 -            PrintRendererFlag(flag);
   7.482 -            ++count;
   7.483 -        }
   7.484 -    }
   7.485 -    fprintf(stderr, ")\n");
   7.486 -
   7.487 -    fprintf(stderr, "    Blend: 0x%8.8X", info->blend_modes);
   7.488 -    fprintf(stderr, " (");
   7.489 -    count = 0;
   7.490 -    for (i = 0; i < sizeof(info->blend_modes) * 8; ++i) {
   7.491 -        Uint32 flag = (1 << i);
   7.492 -        if (info->blend_modes & flag) {
   7.493 -            if (count > 0) {
   7.494 -                fprintf(stderr, " | ");
   7.495 -            }
   7.496 -            PrintBlendMode(flag);
   7.497 -            ++count;
   7.498 -        }
   7.499 -    }
   7.500 -    fprintf(stderr, ")\n");
   7.501 -
   7.502 -    fprintf(stderr, "    Scale: 0x%8.8X", info->scale_modes);
   7.503 -    fprintf(stderr, " (");
   7.504 -    count = 0;
   7.505 -    for (i = 0; i < sizeof(info->scale_modes) * 8; ++i) {
   7.506 -        Uint32 flag = (1 << i);
   7.507 -        if (info->scale_modes & flag) {
   7.508 -            if (count > 0) {
   7.509 -                fprintf(stderr, " | ");
   7.510 -            }
   7.511 -            PrintScaleMode(flag);
   7.512 -            ++count;
   7.513 -        }
   7.514 -    }
   7.515 -    fprintf(stderr, ")\n");
   7.516 -
   7.517 -    fprintf(stderr, "    Texture formats (%d): ", info->num_texture_formats);
   7.518 -    for (i = 0; i < (int) info->num_texture_formats; ++i) {
   7.519 -        if (i > 0) {
   7.520 -            fprintf(stderr, ", ");
   7.521 -        }
   7.522 -        PrintPixelFormat(info->texture_formats[i]);
   7.523 -    }
   7.524 -    fprintf(stderr, "\n");
   7.525 -
   7.526 -    if (info->max_texture_width || info->max_texture_height) {
   7.527 -        fprintf(stderr, "    Max Texture Size: %dx%d\n",
   7.528 -                info->max_texture_width, info->max_texture_height);
   7.529 -    }
   7.530 -}
   7.531 -
   7.532 -SDL_bool
   7.533 -CommonInit(CommonState * state)
   7.534 -{
   7.535 -    int i, j, m, n;
   7.536 -    SDL_DisplayMode fullscreen_mode;
   7.537 -
   7.538 -    if (state->flags & SDL_INIT_VIDEO) {
   7.539 -        if (state->verbose & VERBOSE_VIDEO) {
   7.540 -            n = SDL_GetNumVideoDrivers();
   7.541 -            if (n == 0) {
   7.542 -                fprintf(stderr, "No built-in video drivers\n");
   7.543 -            } else {
   7.544 -                fprintf(stderr, "Built-in video drivers:");
   7.545 -                for (i = 0; i < n; ++i) {
   7.546 -                    if (i > 0) {
   7.547 -                        fprintf(stderr, ",");
   7.548 -                    }
   7.549 -                    fprintf(stderr, " %s", SDL_GetVideoDriver(i));
   7.550 -                }
   7.551 -                fprintf(stderr, "\n");
   7.552 -            }
   7.553 -        }
   7.554 -        if (SDL_VideoInit(state->videodriver, 0) < 0) {
   7.555 -            fprintf(stderr, "Couldn't initialize video driver: %s\n",
   7.556 -                    SDL_GetError());
   7.557 -            return SDL_FALSE;
   7.558 -        }
   7.559 -        if (state->verbose & VERBOSE_VIDEO) {
   7.560 -            fprintf(stderr, "Video driver: %s\n",
   7.561 -                    SDL_GetCurrentVideoDriver());
   7.562 -        }
   7.563 -
   7.564 -        if (state->verbose & VERBOSE_MODES) {
   7.565 -            SDL_DisplayMode mode;
   7.566 -            int bpp;
   7.567 -            Uint32 Rmask, Gmask, Bmask, Amask;
   7.568 -
   7.569 -            n = SDL_GetNumVideoDisplays();
   7.570 -            fprintf(stderr, "Number of displays: %d\n", n);
   7.571 -            for (i = 0; i < n; ++i) {
   7.572 -                fprintf(stderr, "Display %d:\n", i);
   7.573 -                SDL_SelectVideoDisplay(i);
   7.574 -
   7.575 -                SDL_GetDesktopDisplayMode(&mode);
   7.576 -                SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask,
   7.577 -                                           &Bmask, &Amask);
   7.578 -                fprintf(stderr,
   7.579 -                        "  Current mode: %dx%d@%dHz, %d bits-per-pixel\n",
   7.580 -                        mode.w, mode.h, mode.refresh_rate, bpp);
   7.581 -                if (Rmask || Gmask || Bmask) {
   7.582 -                    fprintf(stderr, "      Red Mask = 0x%.8x\n", Rmask);
   7.583 -                    fprintf(stderr, "      Green Mask = 0x%.8x\n", Gmask);
   7.584 -                    fprintf(stderr, "      Blue Mask = 0x%.8x\n", Bmask);
   7.585 -                    if (Amask)
   7.586 -                        fprintf(stderr, "      Alpha Mask = 0x%.8x\n", Amask);
   7.587 -                }
   7.588 -
   7.589 -                /* Print available fullscreen video modes */
   7.590 -                m = SDL_GetNumDisplayModes();
   7.591 -                if (m == 0) {
   7.592 -                    fprintf(stderr, "No available fullscreen video modes\n");
   7.593 -                } else {
   7.594 -                    fprintf(stderr, "  Fullscreen video modes:\n");
   7.595 -                    for (j = 0; j < m; ++j) {
   7.596 -                        SDL_GetDisplayMode(j, &mode);
   7.597 -                        SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
   7.598 -                                                   &Gmask, &Bmask, &Amask);
   7.599 -                        fprintf(stderr,
   7.600 -                                "    Mode %d: %dx%d@%dHz, %d bits-per-pixel\n",
   7.601 -                                j, mode.w, mode.h, mode.refresh_rate, bpp);
   7.602 -                        if (Rmask || Gmask || Bmask) {
   7.603 -                            fprintf(stderr, "        Red Mask = 0x%.8x\n",
   7.604 -                                    Rmask);
   7.605 -                            fprintf(stderr, "        Green Mask = 0x%.8x\n",
   7.606 -                                    Gmask);
   7.607 -                            fprintf(stderr, "        Blue Mask = 0x%.8x\n",
   7.608 -                                    Bmask);
   7.609 -                            if (Amask)
   7.610 -                                fprintf(stderr,
   7.611 -                                        "        Alpha Mask = 0x%.8x\n",
   7.612 -                                        Amask);
   7.613 -                        }
   7.614 -                    }
   7.615 -                }
   7.616 -            }
   7.617 -        }
   7.618 -
   7.619 -        SDL_SelectVideoDisplay(state->display);
   7.620 -        if (state->verbose & VERBOSE_RENDER) {
   7.621 -            SDL_RendererInfo info;
   7.622 -
   7.623 -            n = SDL_GetNumRenderDrivers();
   7.624 -            if (n == 0) {
   7.625 -                fprintf(stderr, "No built-in render drivers\n");
   7.626 -            } else {
   7.627 -                fprintf(stderr, "Built-in render drivers:\n");
   7.628 -                for (i = 0; i < n; ++i) {
   7.629 -                    SDL_GetRenderDriverInfo(i, &info);
   7.630 -                    PrintRenderer(&info);
   7.631 -                }
   7.632 -            }
   7.633 -        }
   7.634 -
   7.635 -        switch (state->depth) {
   7.636 -        case 8:
   7.637 -            fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
   7.638 -            break;
   7.639 -        case 15:
   7.640 -            fullscreen_mode.format = SDL_PIXELFORMAT_BGR555;
   7.641 -            break;
   7.642 -        case 16:
   7.643 -        default:
   7.644 -            fullscreen_mode.format = SDL_PIXELFORMAT_ABGR1555;
   7.645 -            break;
   7.646 -/* NDS       default:
   7.647 -            fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
   7.648 -            break;*/
   7.649 -        }
   7.650 -        fullscreen_mode.w = state->window_w;
   7.651 -        fullscreen_mode.h = state->window_h;
   7.652 -        fullscreen_mode.refresh_rate = state->refresh_rate;
   7.653 -        SDL_SetFullscreenDisplayMode(&fullscreen_mode);
   7.654 -
   7.655 -        state->windows =
   7.656 -            (SDL_WindowID *) SDL_malloc(state->num_windows *
   7.657 -                                        sizeof(*state->windows));
   7.658 -        if (!state->windows) {
   7.659 -            fprintf(stderr, "Out of memory!\n");
   7.660 -            return SDL_FALSE;
   7.661 -        }
   7.662 -        for (i = 0; i < state->num_windows; ++i) {
   7.663 -            char title[1024];
   7.664 -
   7.665 -            if (state->num_windows > 1) {
   7.666 -                SDL_snprintf(title, SDL_arraysize(title), "%s %d",
   7.667 -                             state->window_title, i + 1);
   7.668 -            } else {
   7.669 -                SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
   7.670 -            }
   7.671 -            state->windows[i] =
   7.672 -                SDL_CreateWindow(title, state->window_x, state->window_y,
   7.673 -                                 state->window_w, state->window_h,
   7.674 -                                 state->window_flags);
   7.675 -            if (!state->windows[i]) {
   7.676 -                fprintf(stderr, "Couldn't create window: %s\n",
   7.677 -                        SDL_GetError());
   7.678 -                return SDL_FALSE;
   7.679 -            }
   7.680 -
   7.681 -            if (!state->skip_renderer
   7.682 -                && (state->renderdriver
   7.683 -                    || !(state->window_flags & SDL_WINDOW_OPENGL))) {
   7.684 -                m = -1;
   7.685 -                if (state->renderdriver) {
   7.686 -                    SDL_RendererInfo info;
   7.687 -                    n = SDL_GetNumRenderDrivers();
   7.688 -                    for (j = 0; j < n; ++j) {
   7.689 -                        SDL_GetRenderDriverInfo(j, &info);
   7.690 -                        if (SDL_strcasecmp(info.name, state->renderdriver) ==
   7.691 -                            0) {
   7.692 -                            m = j;
   7.693 -                            break;
   7.694 -                        }
   7.695 -                    }
   7.696 -                    if (m == n) {
   7.697 -                        fprintf(stderr,
   7.698 -                                "Couldn't find render driver named %s",
   7.699 -                                state->renderdriver);
   7.700 -                        return SDL_FALSE;
   7.701 -                    }
   7.702 -                }
   7.703 -                if (SDL_CreateRenderer
   7.704 -                    (state->windows[i], m, state->render_flags) < 0) {
   7.705 -                    fprintf(stderr, "Couldn't create renderer: %s\n",
   7.706 -                            SDL_GetError());
   7.707 -                    return SDL_FALSE;
   7.708 -                }
   7.709 -                if (state->verbose & VERBOSE_RENDER) {
   7.710 -                    SDL_RendererInfo info;
   7.711 -
   7.712 -                    fprintf(stderr, "Current renderer:\n");
   7.713 -                    SDL_GetRendererInfo(&info);
   7.714 -                    PrintRenderer(&info);
   7.715 -                }
   7.716 -            }
   7.717 -        }
   7.718 -        SDL_SelectRenderer(state->windows[0]);
   7.719 -    }
   7.720 -
   7.721 -    if (state->flags & SDL_INIT_AUDIO) {
   7.722 -        if (state->verbose & VERBOSE_AUDIO) {
   7.723 -            n = SDL_GetNumAudioDrivers();
   7.724 -            if (n == 0) {
   7.725 -                fprintf(stderr, "No built-in audio drivers\n");
   7.726 -            } else {
   7.727 -                fprintf(stderr, "Built-in audio drivers:");
   7.728 -                for (i = 0; i < n; ++i) {
   7.729 -                    if (i > 0) {
   7.730 -                        fprintf(stderr, ",");
   7.731 -                    }
   7.732 -                    fprintf(stderr, " %s", SDL_GetAudioDriver(i));
   7.733 -                }
   7.734 -                fprintf(stderr, "\n");
   7.735 -            }
   7.736 -        }
   7.737 -        if (SDL_AudioInit(state->audiodriver) < 0) {
   7.738 -            fprintf(stderr, "Couldn't initialize audio driver: %s\n",
   7.739 -                    SDL_GetError());
   7.740 -            return SDL_FALSE;
   7.741 -        }
   7.742 -        if (state->verbose & VERBOSE_VIDEO) {
   7.743 -            fprintf(stderr, "Audio driver: %s\n",
   7.744 -                    SDL_GetCurrentAudioDriver());
   7.745 -        }
   7.746 -
   7.747 -        if (SDL_OpenAudio(&state->audiospec, NULL) < 0) {
   7.748 -            fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
   7.749 -            return SDL_FALSE;
   7.750 -        }
   7.751 -    }
   7.752 -
   7.753 -    return SDL_TRUE;
   7.754 -}
   7.755 -
   7.756 -static void
   7.757 -PrintEvent(SDL_Event * event)
   7.758 -{
   7.759 -    fprintf(stderr, "SDL EVENT: ");
   7.760 -    switch (event->type) {
   7.761 -    case SDL_WINDOWEVENT:
   7.762 -        switch (event->window.event) {
   7.763 -        case SDL_WINDOWEVENT_SHOWN:
   7.764 -            fprintf(stderr, "Window %d shown", event->window.windowID);
   7.765 -            break;
   7.766 -        case SDL_WINDOWEVENT_HIDDEN:
   7.767 -            fprintf(stderr, "Window %d hidden", event->window.windowID);
   7.768 -            break;
   7.769 -        case SDL_WINDOWEVENT_EXPOSED:
   7.770 -            fprintf(stderr, "Window %d exposed", event->window.windowID);
   7.771 -            break;
   7.772 -        case SDL_WINDOWEVENT_MOVED:
   7.773 -            fprintf(stderr, "Window %d moved to %d,%d",
   7.774 -                    event->window.windowID, event->window.data1,
   7.775 -                    event->window.data2);
   7.776 -            break;
   7.777 -        case SDL_WINDOWEVENT_RESIZED:
   7.778 -            fprintf(stderr, "Window %d resized to %dx%d",
   7.779 -                    event->window.windowID, event->window.data1,
   7.780 -                    event->window.data2);
   7.781 -            break;
   7.782 -        case SDL_WINDOWEVENT_MINIMIZED:
   7.783 -            fprintf(stderr, "Window %d minimized", event->window.windowID);
   7.784 -            break;
   7.785 -        case SDL_WINDOWEVENT_MAXIMIZED:
   7.786 -            fprintf(stderr, "Window %d maximized", event->window.windowID);
   7.787 -            break;
   7.788 -        case SDL_WINDOWEVENT_RESTORED:
   7.789 -            fprintf(stderr, "Window %d restored", event->window.windowID);
   7.790 -            break;
   7.791 -        case SDL_WINDOWEVENT_ENTER:
   7.792 -            fprintf(stderr, "Mouse entered window %d",
   7.793 -                    event->window.windowID);
   7.794 -            break;
   7.795 -        case SDL_WINDOWEVENT_LEAVE:
   7.796 -            fprintf(stderr, "Mouse left window %d", event->window.windowID);
   7.797 -            break;
   7.798 -        case SDL_WINDOWEVENT_FOCUS_GAINED:
   7.799 -            fprintf(stderr, "Window %d gained keyboard focus",
   7.800 -                    event->window.windowID);
   7.801 -            break;
   7.802 -        case SDL_WINDOWEVENT_FOCUS_LOST:
   7.803 -            fprintf(stderr, "Window %d lost keyboard focus",
   7.804 -                    event->window.windowID);
   7.805 -            break;
   7.806 -        case SDL_WINDOWEVENT_CLOSE:
   7.807 -            fprintf(stderr, "Window %d closed", event->window.windowID);
   7.808 -            break;
   7.809 -        default:
   7.810 -            fprintf(stderr, "Window %d got unknown event %d",
   7.811 -                    event->window.windowID, event->window.event);
   7.812 -            break;
   7.813 -        }
   7.814 -        break;
   7.815 -    case SDL_KEYDOWN:
   7.816 -        fprintf(stderr,
   7.817 -                "Keyboard %d: key pressed  in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
   7.818 -                event->key.which, event->key.windowID,
   7.819 -                event->key.keysym.scancode,
   7.820 -                SDL_GetScancodeName(event->key.keysym.scancode),
   7.821 -                event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
   7.822 -        break;
   7.823 -    case SDL_KEYUP:
   7.824 -        fprintf(stderr,
   7.825 -                "Keyboard %d: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
   7.826 -                event->key.which, event->key.windowID,
   7.827 -                event->key.keysym.scancode,
   7.828 -                SDL_GetScancodeName(event->key.keysym.scancode),
   7.829 -                event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
   7.830 -        break;
   7.831 -    case SDL_TEXTINPUT:
   7.832 -        fprintf(stderr, "Keyboard %d: text input \"%s\" in window %d",
   7.833 -                event->text.which, event->text.text, event->text.windowID);
   7.834 -        break;
   7.835 -    case SDL_MOUSEMOTION:
   7.836 -        fprintf(stderr, "Mouse %d: moved to %d,%d (%d,%d) in window %d",
   7.837 -                event->motion.which, event->motion.x, event->motion.y,
   7.838 -                event->motion.xrel, event->motion.yrel,
   7.839 -                event->motion.windowID);
   7.840 -        break;
   7.841 -    case SDL_MOUSEBUTTONDOWN:
   7.842 -        fprintf(stderr, "Mouse %d: button %d pressed at %d,%d in window %d",
   7.843 -                event->button.which, event->button.button, event->button.x,
   7.844 -                event->button.y, event->button.windowID);
   7.845 -        break;
   7.846 -    case SDL_MOUSEBUTTONUP:
   7.847 -        fprintf(stderr, "Mouse %d: button %d released at %d,%d in window %d",
   7.848 -                event->button.which, event->button.button, event->button.x,
   7.849 -                event->button.y, event->button.windowID);
   7.850 -        break;
   7.851 -    case SDL_MOUSEWHEEL:
   7.852 -        fprintf(stderr,
   7.853 -                "Mouse %d: wheel scrolled %d in x and %d in y in window %d",
   7.854 -                event->wheel.which, event->wheel.x, event->wheel.y,
   7.855 -                event->wheel.windowID);
   7.856 -        break;
   7.857 -    case SDL_JOYBALLMOTION:
   7.858 -        fprintf(stderr, "Joystick %d: ball %d moved by %d,%d",
   7.859 -                event->jball.which, event->jball.ball, event->jball.xrel,
   7.860 -                event->jball.yrel);
   7.861 -        break;
   7.862 -    case SDL_JOYHATMOTION:
   7.863 -        fprintf(stderr, "Joystick %d: hat %d moved to ", event->jhat.which,
   7.864 -                event->jhat.hat);
   7.865 -        switch (event->jhat.value) {
   7.866 -        case SDL_HAT_CENTERED:
   7.867 -            fprintf(stderr, "CENTER");
   7.868 -            break;
   7.869 -        case SDL_HAT_UP:
   7.870 -            fprintf(stderr, "UP");
   7.871 -            break;
   7.872 -        case SDL_HAT_RIGHTUP:
   7.873 -            fprintf(stderr, "RIGHTUP");
   7.874 -            break;
   7.875 -        case SDL_HAT_RIGHT:
   7.876 -            fprintf(stderr, "RIGHT");
   7.877 -            break;
   7.878 -        case SDL_HAT_RIGHTDOWN:
   7.879 -            fprintf(stderr, "RIGHTDOWN");
   7.880 -            break;
   7.881 -        case SDL_HAT_DOWN:
   7.882 -            fprintf(stderr, "DOWN");
   7.883 -            break;
   7.884 -        case SDL_HAT_LEFTDOWN:
   7.885 -            fprintf(stderr, "LEFTDOWN");
   7.886 -            break;
   7.887 -        case SDL_HAT_LEFT:
   7.888 -            fprintf(stderr, "LEFT");
   7.889 -            break;
   7.890 -        case SDL_HAT_LEFTUP:
   7.891 -            fprintf(stderr, "LEFTUP");
   7.892 -            break;
   7.893 -        default:
   7.894 -            fprintf(stderr, "UNKNOWN");
   7.895 -            break;
   7.896 -        }
   7.897 -        break;
   7.898 -    case SDL_JOYBUTTONDOWN:
   7.899 -        fprintf(stderr, "Joystick %d: button %d pressed",
   7.900 -                event->jbutton.which, event->jbutton.button);
   7.901 -        break;
   7.902 -    case SDL_JOYBUTTONUP:
   7.903 -        fprintf(stderr, "Joystick %d: button %d released",
   7.904 -                event->jbutton.which, event->jbutton.button);
   7.905 -        break;
   7.906 -    case SDL_QUIT:
   7.907 -        fprintf(stderr, "Quit requested");
   7.908 -        break;
   7.909 -    case SDL_USEREVENT:
   7.910 -        fprintf(stderr, "User event %d", event->user.code);
   7.911 -        break;
   7.912 -    default:
   7.913 -        fprintf(stderr, "Unknown event %d", event->type);
   7.914 -        break;
   7.915 -    }
   7.916 -    fprintf(stderr, "\n");
   7.917 -}
   7.918 -
   7.919 -void
   7.920 -CommonEvent(CommonState * state, SDL_Event * event, int *done)
   7.921 -{
   7.922 -    if (state->verbose & VERBOSE_EVENT) {
   7.923 -        PrintEvent(event);
   7.924 -    }
   7.925 -
   7.926 -    switch (event->type) {
   7.927 -    case SDL_WINDOWEVENT:
   7.928 -        switch (event->window.event) {
   7.929 -        case SDL_WINDOWEVENT_CLOSE:
   7.930 -            *done = 1;
   7.931 -            break;
   7.932 -        }
   7.933 -        break;
   7.934 -    case SDL_KEYDOWN:
   7.935 -        switch (event->key.keysym.sym) {
   7.936 -            /* Add hotkeys here */
   7.937 -        case SDLK_g:
   7.938 -            if (event->key.keysym.mod & KMOD_CTRL) {
   7.939 -                /* Ctrl-G toggle grab */
   7.940 -            }
   7.941 -            break;
   7.942 -        case SDLK_ESCAPE:
   7.943 -            *done = 1;
   7.944 -            break;
   7.945 -        default:
   7.946 -            break;
   7.947 -        }
   7.948 -        break;
   7.949 -    case SDL_QUIT:
   7.950 -        *done = 1;
   7.951 -        break;
   7.952 -    }
   7.953 -}
   7.954 -
   7.955 -void
   7.956 -CommonQuit(CommonState * state)
   7.957 -{
   7.958 -    if (state->flags & SDL_INIT_VIDEO) {
   7.959 -        SDL_VideoQuit();
   7.960 -    }
   7.961 -    if (state->flags & SDL_INIT_AUDIO) {
   7.962 -        SDL_AudioQuit();
   7.963 -    }
   7.964 -    if (state->windows) {
   7.965 -        SDL_free(state->windows);
   7.966 -    }
   7.967 -    SDL_free(state);
   7.968 -}
     8.1 --- a/test/nds-test-progs/sprite2/source/common.h	Sat Mar 26 21:26:05 2011 -0700
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,48 +0,0 @@
     8.4 -
     8.5 -/* A simple test program framework */
     8.6 -
     8.7 -#include <SDL/SDL.h>
     8.8 -
     8.9 -#define VERBOSE_VIDEO   0x00000001
    8.10 -#define VERBOSE_MODES   0x00000002
    8.11 -#define VERBOSE_RENDER  0x00000004
    8.12 -#define VERBOSE_EVENT   0x00000008
    8.13 -#define VERBOSE_AUDIO   0x00000010
    8.14 -
    8.15 -typedef struct
    8.16 -{
    8.17 -    /* SDL init flags */
    8.18 -    char **argv;
    8.19 -    Uint32 flags;
    8.20 -    Uint32 verbose;
    8.21 -
    8.22 -    /* Video info */
    8.23 -    const char *videodriver;
    8.24 -    int display;
    8.25 -    const char *window_title;
    8.26 -    Uint32 window_flags;
    8.27 -    int window_x;
    8.28 -    int window_y;
    8.29 -    int window_w;
    8.30 -    int window_h;
    8.31 -    int depth;
    8.32 -    int refresh_rate;
    8.33 -    int num_windows;
    8.34 -    SDL_WindowID *windows;
    8.35 -
    8.36 -    /* Renderer info */
    8.37 -    const char *renderdriver;
    8.38 -    Uint32 render_flags;
    8.39 -    SDL_bool skip_renderer;
    8.40 -
    8.41 -    /* Audio info */
    8.42 -    const char *audiodriver;
    8.43 -    SDL_AudioSpec audiospec;
    8.44 -} CommonState;
    8.45 -
    8.46 -extern CommonState *CommonCreateState(char **argv, Uint32 flags);
    8.47 -extern int CommonArg(CommonState * state, int index);
    8.48 -extern const char *CommonUsage(CommonState * state);
    8.49 -extern SDL_bool CommonInit(CommonState * state);
    8.50 -extern void CommonEvent(CommonState * state, SDL_Event * event, int *done);
    8.51 -extern void CommonQuit(CommonState * state);
     9.1 --- a/test/nds-test-progs/sprite2/source/testsprite2.c	Sat Mar 26 21:26:05 2011 -0700
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,270 +0,0 @@
     9.4 -/* Simple program:  Move N sprites around on the screen as fast as possible */
     9.5 -
     9.6 -#include <stdlib.h>
     9.7 -#include <stdio.h>
     9.8 -#include <time.h>
     9.9 -#include <nds.h>
    9.10 -#include <fat.h>
    9.11 -#include "common.h"
    9.12 -
    9.13 -#define NUM_SPRITES	10
    9.14 -#define MAX_SPEED 	1
    9.15 -
    9.16 -static CommonState *state;
    9.17 -static int num_sprites;
    9.18 -static SDL_TextureID *sprites;
    9.19 -static SDL_bool cycle_color;
    9.20 -static SDL_bool cycle_alpha;
    9.21 -static int cycle_direction = 1;
    9.22 -static int current_alpha = 0;
    9.23 -static int current_color = 0;
    9.24 -static SDL_Rect *positions;
    9.25 -static SDL_Rect *velocities;
    9.26 -static int sprite_w, sprite_h;
    9.27 -static SDL_BlendMode blendMode = SDL_BLENDMODE_MASK;
    9.28 -static SDL_TextureScaleMode scaleMode = SDL_TEXTURESCALEMODE_NONE;
    9.29 -
    9.30 -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    9.31 -static void
    9.32 -quit(int rc)
    9.33 -{
    9.34 -    if (sprites) {
    9.35 -        SDL_free(sprites);
    9.36 -    }
    9.37 -    if (positions) {
    9.38 -        SDL_free(positions);
    9.39 -    }
    9.40 -    if (velocities) {
    9.41 -        SDL_free(velocities);
    9.42 -    }
    9.43 -    CommonQuit(state);
    9.44 -    exit(rc);
    9.45 -}
    9.46 -
    9.47 -int
    9.48 -LoadSprite(char *file)
    9.49 -{
    9.50 -    int i;
    9.51 -    SDL_Surface *temp;
    9.52 -
    9.53 -    /* Load the sprite image */
    9.54 -    temp = SDL_LoadBMP(file);
    9.55 -    if (temp == NULL) {
    9.56 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
    9.57 -        return (-1);
    9.58 -    }
    9.59 -    sprite_w = temp->w;
    9.60 -    sprite_h = temp->h;
    9.61 -
    9.62 -    /* Set transparent pixel as the pixel at (0,0) */
    9.63 -    if (temp->format->palette) {
    9.64 -        SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint8 *) temp->pixels);
    9.65 -    }
    9.66 -
    9.67 -    /* Create textures from the image */
    9.68 -    for (i = 0; i < state->num_windows; ++i) {
    9.69 -        SDL_SelectRenderer(state->windows[i]);
    9.70 -        sprites[i] = SDL_CreateTextureFromSurface(0, temp);
    9.71 -        if (!sprites[i]) {
    9.72 -            fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
    9.73 -            SDL_FreeSurface(temp);
    9.74 -            return (-1);
    9.75 -        }
    9.76 -        SDL_SetTextureBlendMode(sprites[i], blendMode);
    9.77 -        SDL_SetTextureScaleMode(sprites[i], scaleMode);
    9.78 -    }
    9.79 -    SDL_FreeSurface(temp);
    9.80 -
    9.81 -    /* We're ready to roll. :) */
    9.82 -    return (0);
    9.83 -}
    9.84 -
    9.85 -int
    9.86 -LoadSprite2(const u8 * ptr, int size)
    9.87 -{
    9.88 -    int i;
    9.89 -    SDL_Rect r = { 0, 0, 32, 32 };
    9.90 -    for (i = 0; i < state->num_windows; ++i) {
    9.91 -        SDL_SelectRenderer(state->windows[i]);
    9.92 -        sprites[i] = SDL_CreateTexture(SDL_PIXELFORMAT_ABGR1555,
    9.93 -                                       SDL_TEXTUREACCESS_STATIC, r.w, r.h);
    9.94 -        if (!sprites[i]) {
    9.95 -            fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
    9.96 -            return -1;
    9.97 -        }
    9.98 -        SDL_UpdateTexture(sprites[i], &r, ptr, r.w * 2);
    9.99 -        SDL_SetTextureBlendMode(sprites[i], blendMode);
   9.100 -        SDL_SetTextureScaleMode(sprites[i], scaleMode);
   9.101 -    }
   9.102 -    return 0;
   9.103 -}
   9.104 -
   9.105 -void
   9.106 -MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
   9.107 -{
   9.108 -    int i, n;
   9.109 -    int window_w, window_h;
   9.110 -    SDL_Rect area, *position, *velocity;
   9.111 -
   9.112 -    SDL_SelectRenderer(window);
   9.113 -
   9.114 -    /* Query the sizes */
   9.115 -    SDL_GetWindowSize(window, &window_w, &window_h);
   9.116 -
   9.117 -    /* Cycle the color and alpha, if desired */
   9.118 -    if (cycle_color) {
   9.119 -        current_color += cycle_direction;
   9.120 -        if (current_color < 0) {
   9.121 -            current_color = 0;
   9.122 -            cycle_direction = -cycle_direction;
   9.123 -        }
   9.124 -        if (current_color > 255) {
   9.125 -            current_color = 255;
   9.126 -            cycle_direction = -cycle_direction;
   9.127 -        }
   9.128 -        SDL_SetTextureColorMod(sprite, 255, (Uint8) current_color,
   9.129 -                               (Uint8) current_color);
   9.130 -    }
   9.131 -    if (cycle_alpha) {
   9.132 -        current_alpha += cycle_direction;
   9.133 -        if (current_alpha < 0) {
   9.134 -            current_alpha = 0;
   9.135 -            cycle_direction = -cycle_direction;
   9.136 -        }
   9.137 -        if (current_alpha > 255) {
   9.138 -            current_alpha = 255;
   9.139 -            cycle_direction = -cycle_direction;
   9.140 -        }
   9.141 -        SDL_SetTextureAlphaMod(sprite, (Uint8) current_alpha);
   9.142 -    }
   9.143 -
   9.144 -    /* Move the sprite, bounce at the wall, and draw */
   9.145 -    n = 0;
   9.146 -    SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
   9.147 -    for (i = 0; i < num_sprites; ++i) {
   9.148 -        position = &positions[i];
   9.149 -        velocity = &velocities[i];
   9.150 -        position->x += velocity->x;
   9.151 -        if ((position->x < 0) || (position->x >= (window_w - sprite_w))) {
   9.152 -            velocity->x = -velocity->x;
   9.153 -            position->x += velocity->x;
   9.154 -        }
   9.155 -        position->y += velocity->y;
   9.156 -        if ((position->y < 0) || (position->y >= (window_h - sprite_w))) {
   9.157 -            velocity->y = -velocity->y;
   9.158 -            position->y += velocity->y;
   9.159 -        }
   9.160 -
   9.161 -        /* Blit the sprite onto the screen */
   9.162 -        SDL_RenderCopy(sprite, NULL, position);
   9.163 -    }
   9.164 -
   9.165 -    /* Update the screen! */
   9.166 -    SDL_RenderPresent();
   9.167 -}
   9.168 -
   9.169 -int
   9.170 -main(int argc, char *argv[])
   9.171 -{
   9.172 -    int i, done;
   9.173 -    SDL_Event event;
   9.174 -    Uint32 then, now, frames;
   9.175 -
   9.176 -    consoleDemoInit();
   9.177 -    puts("Hello world!  Initializing FAT...");
   9.178 -    fatInitDefault();
   9.179 -
   9.180 -    /* Initialize parameters */
   9.181 -    num_sprites = NUM_SPRITES;
   9.182 -
   9.183 -    /* Initialize test framework */
   9.184 -    state = CommonCreateState(argv, SDL_INIT_VIDEO);
   9.185 -    if (!state) {
   9.186 -        return 1;
   9.187 -    }
   9.188 -
   9.189 -    if (!CommonInit(state)) {
   9.190 -        quit(2);
   9.191 -    }
   9.192 -
   9.193 -    /* Create the windows, initialize the renderers, and load the textures */
   9.194 -    sprites =
   9.195 -        (SDL_TextureID *) SDL_malloc(state->num_windows * sizeof(*sprites));
   9.196 -    if (!sprites) {
   9.197 -        fprintf(stderr, "Out of memory!\n");
   9.198 -        quit(2);
   9.199 -    }
   9.200 -    for (i = 0; i < state->num_windows; ++i) {
   9.201 -        SDL_SelectRenderer(state->windows[i]);
   9.202 -        SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
   9.203 -    }
   9.204 -    if (LoadSprite("icon.bmp") < 0) {
   9.205 -        printf("\nerrored.\n");
   9.206 -        while (1);
   9.207 -        quit(2);
   9.208 -    }
   9.209 -
   9.210 -    /* Allocate memory for the sprite info */
   9.211 -    positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
   9.212 -    velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
   9.213 -    if (!positions || !velocities) {
   9.214 -        fprintf(stderr, "Out of memory!\n");
   9.215 -        quit(2);
   9.216 -    }
   9.217 -    srand(time(NULL));
   9.218 -    if (scaleMode != SDL_TEXTURESCALEMODE_NONE) {
   9.219 -        sprite_w += sprite_w / 2;
   9.220 -        sprite_h += sprite_h / 2;
   9.221 -    }
   9.222 -    for (i = 0; i < num_sprites; ++i) {
   9.223 -        positions[i].x = rand() % (state->window_w - sprite_w);
   9.224 -        positions[i].y = rand() % (state->window_h - sprite_h);
   9.225 -        positions[i].w = sprite_w;
   9.226 -        positions[i].h = sprite_h;
   9.227 -        velocities[i].x = 0;
   9.228 -        velocities[i].y = 0;
   9.229 -        while (!velocities[i].x && !velocities[i].y) {
   9.230 -            velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
   9.231 -            velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
   9.232 -        }
   9.233 -    }
   9.234 -
   9.235 -    /* Main render loop */
   9.236 -    frames = 0;
   9.237 -    then = SDL_GetTicks();
   9.238 -    done = 0;
   9.239 -    while (!done) {
   9.240 -        /* Check for events */
   9.241 -        ++frames;
   9.242 -        while (SDL_PollEvent(&event)) {
   9.243 -            CommonEvent(state, &event, &done);
   9.244 -            switch (event.type) {
   9.245 -            case SDL_WINDOWEVENT:
   9.246 -                switch (event.window.event) {
   9.247 -                case SDL_WINDOWEVENT_EXPOSED:
   9.248 -                    SDL_SelectRenderer(event.window.windowID);
   9.249 -                    SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
   9.250 -                    break;
   9.251 -                }
   9.252 -                break;
   9.253 -            default:
   9.254 -                break;
   9.255 -            }
   9.256 -        }
   9.257 -        for (i = 0; i < state->num_windows; ++i) {
   9.258 -            MoveSprites(state->windows[i], sprites[i]);
   9.259 -        }
   9.260 -    }
   9.261 -
   9.262 -    /* Print out some timing information */
   9.263 -    now = SDL_GetTicks();
   9.264 -    if (now > then) {
   9.265 -        printf("%2.2f frames per second\n",
   9.266 -               ((double) frames * 1000) / (now - then));
   9.267 -    }
   9.268 -
   9.269 -    quit(0);
   9.270 -    return 0;
   9.271 -}
   9.272 -
   9.273 -/* vi: set ts=4 sw=4 expandtab: */