clean up and add psp power driver

change the licence
This commit is contained in:
lex 2013-03-17 19:25:12 +08:00
parent fb7ffb67ef
commit f43d59e6f5
32 changed files with 1143 additions and 1663 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
################# #################
*.o *.o
*.a
*.bat *.bat
*.PBP *.PBP
*.elf *.elf

View File

@ -26,7 +26,7 @@ OBJS= src/SDL.o \
src/events/SDL_windowevents.o \ src/events/SDL_windowevents.o \
src/file/SDL_rwops.o \ src/file/SDL_rwops.o \
src/haptic/SDL_haptic.o \ src/haptic/SDL_haptic.o \
src/haptic/psp/SDL_syshaptic.o \ src/haptic/dummy/SDL_syshaptic.o \
src/joystick/SDL_joystick.o \ src/joystick/SDL_joystick.o \
src/joystick/SDL_gamecontroller.o \ src/joystick/SDL_gamecontroller.o \
src/joystick/psp/SDL_sysjoystick.o \ src/joystick/psp/SDL_sysjoystick.o \
@ -35,7 +35,6 @@ OBJS= src/SDL.o \
src/render/SDL_render.o \ src/render/SDL_render.o \
src/render/SDL_yuv_sw.o \ src/render/SDL_yuv_sw.o \
src/render/psp/SDL_render_psp.o \ src/render/psp/SDL_render_psp.o \
src/render/psp/SDL_pspvram.o \
src/render/software/SDL_blendfillrect.o \ src/render/software/SDL_blendfillrect.o \
src/render/software/SDL_blendline.o \ src/render/software/SDL_blendline.o \
src/render/software/SDL_blendpoint.o \ src/render/software/SDL_blendpoint.o \

View File

@ -2,9 +2,8 @@ SDL port for the Sony PSP contributed by
Captian Lex Captian Lex
Credit to Credit to
Marcus R. Brown <mrbrown@ocgnet.org> Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP
Jim Paris <jim@jtan.com> Geecko for his PSP GU lib "Glib2d"
Matthew H <matthewh@webone.com.au>
Building Building
-------- --------
@ -14,4 +13,5 @@ To build for the PSP, make sure psp-config is in the path and run:
To Do To Do
------ ------
PSP Screen Keyboard

View File

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -24,27 +24,6 @@
#include "SDL_platform.h" #include "SDL_platform.h"
/**
* \file SDL_config_minimal.h
*
* This is the minimal configuration that can be used to build SDL.
*/
/*
#if !defined(_STDINT_H_) && !defined(_STDINT_H) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
typedef unsigned int size_t;
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
typedef unsigned long uintptr_t;
#endif if (stdint.h isn't available) */
#ifdef __GNUC__ #ifdef __GNUC__
@ -134,28 +113,24 @@ typedef unsigned long uintptr_t;
#define SDL_TIMERS_PSP 1 #define SDL_TIMERS_PSP 1
/* Enable the stub joystick driver (src/joystick/psp/\*.c) */ /* Enable the stub joystick driver (src/joystick/psp/\*.c) */
#define SDL_JOYSTICK_PSP 1 #define SDL_JOYSTICK_PSP 1
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ /* Enable the stub audio driver (src/audio/psp/\*.c) */
#define SDL_AUDIO_DRIVER_PSP 1 #define SDL_AUDIO_DRIVER_PSP 1
/* Enable the dummy video driver (src/video/dummy/\*.c) */ /* PSP video dirver */
//#define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_PSP 1
/* PSP Vedio dirver */ /* PSP render dirver */
#define SDL_VIDEO_DRIVER_PSP 1 #define SDL_VIDEO_RENDER_PSP 1
#define SDL_POWER_PSP 1
/* Render with opengl */ /* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1
//#define SDL_VIDEO_RENDER_OGL_ES 1 /* PSP can't load shared object (src/loadso/dummy/\*.c) */
#define SDL_VIDEO_RENDER_PSP 1 #define SDL_LOADSO_DISABLED 1
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_PSP 1
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED 1
#endif /* _SDL_config_minimal_h */ #endif /* _SDL_config_minimal_h */

View File

@ -1,151 +1,155 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL_platform.h * \file SDL_platform.h
* *
* Try to get a standard set of platform defines. * Try to get a standard set of platform defines.
*/ */
#ifndef _SDL_platform_h #ifndef _SDL_platform_h
#define _SDL_platform_h #define _SDL_platform_h
#if defined(_AIX) #if defined(_AIX)
#undef __AIX__ #undef __AIX__
#define __AIX__ 1 #define __AIX__ 1
#endif #endif
#if defined(__BEOS__) #if defined(__BEOS__)
#undef __BEOS__ #undef __BEOS__
#define __BEOS__ 1 #define __BEOS__ 1
#endif #endif
#if defined(__HAIKU__) #if defined(__HAIKU__)
#undef __HAIKU__ #undef __HAIKU__
#define __HAIKU__ 1 #define __HAIKU__ 1
#endif #endif
#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
#undef __BSDI__ #undef __BSDI__
#define __BSDI__ 1 #define __BSDI__ 1
#endif #endif
#if defined(_arch_dreamcast) #if defined(_arch_dreamcast)
#undef __DREAMCAST__ #undef __DREAMCAST__
#define __DREAMCAST__ 1 #define __DREAMCAST__ 1
#endif #endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#undef __FREEBSD__ #undef __FREEBSD__
#define __FREEBSD__ 1 #define __FREEBSD__ 1
#endif #endif
#if defined(hpux) || defined(__hpux) || defined(__hpux__) #if defined(hpux) || defined(__hpux) || defined(__hpux__)
#undef __HPUX__ #undef __HPUX__
#define __HPUX__ 1 #define __HPUX__ 1
#endif #endif
#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
#undef __IRIX__ #undef __IRIX__
#define __IRIX__ 1 #define __IRIX__ 1
#endif #endif
#if defined(linux) || defined(__linux) || defined(__linux__) #if defined(linux) || defined(__linux) || defined(__linux__)
#undef __LINUX__ #undef __LINUX__
#define __LINUX__ 1 #define __LINUX__ 1
#endif #endif
#if defined(ANDROID) #if defined(ANDROID)
#undef __ANDROID__ #undef __ANDROID__
#undef __LINUX__ /*do we need to do this?*/ #undef __LINUX__ /*do we need to do this?*/
#define __ANDROID__ 1 #define __ANDROID__ 1
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)
/* lets us know what version of Mac OS X we're compiling on */ /* lets us know what version of Mac OS X we're compiling on */
#include "AvailabilityMacros.h" #include "AvailabilityMacros.h"
#include "TargetConditionals.h" #include "TargetConditionals.h"
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
/* if compiling for iPhone */ /* if compiling for iPhone */
#undef __IPHONEOS__ #undef __IPHONEOS__
#define __IPHONEOS__ 1 #define __IPHONEOS__ 1
#undef __MACOSX__ #undef __MACOSX__
#else #else
/* if not compiling for iPhone */ /* if not compiling for iPhone */
#undef __MACOSX__ #undef __MACOSX__
#define __MACOSX__ 1 #define __MACOSX__ 1
#endif /* TARGET_OS_IPHONE */ #endif /* TARGET_OS_IPHONE */
#endif /* defined(__APPLE__) */ #endif /* defined(__APPLE__) */
#if defined(__NetBSD__) #if defined(__NetBSD__)
#undef __NETBSD__ #undef __NETBSD__
#define __NETBSD__ 1 #define __NETBSD__ 1
#endif #endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
#undef __OPENBSD__ #undef __OPENBSD__
#define __OPENBSD__ 1 #define __OPENBSD__ 1
#endif #endif
#if defined(__OS2__) #if defined(__OS2__)
#undef __OS2__ #undef __OS2__
#define __OS2__ 1 #define __OS2__ 1
#endif #endif
#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
#undef __OSF__ #undef __OSF__
#define __OSF__ 1 #define __OSF__ 1
#endif #endif
#if defined(__QNXNTO__) #if defined(__QNXNTO__)
#undef __QNXNTO__ #undef __QNXNTO__
#define __QNXNTO__ 1 #define __QNXNTO__ 1
#endif #endif
#if defined(riscos) || defined(__riscos) || defined(__riscos__) #if defined(riscos) || defined(__riscos) || defined(__riscos__)
#undef __RISCOS__ #undef __RISCOS__
#define __RISCOS__ 1 #define __RISCOS__ 1
#endif #endif
#if defined(__SVR4) #if defined(__SVR4)
#undef __SOLARIS__ #undef __SOLARIS__
#define __SOLARIS__ 1 #define __SOLARIS__ 1
#endif #endif
#if defined(WIN32) || defined(_WIN32) #if defined(WIN32) || defined(_WIN32)
#undef __WIN32__ #undef __WIN32__
#define __WIN32__ 1 #define __WIN32__ 1
#endif #endif
#if defined(__NDS__) #if defined(__NDS__)
#undef __NINTENDODS__ #undef __NINTENDODS__
#define __NINTENDODS__ 1 #define __NINTENDODS__ 1
#endif #endif
#if defined(__PSP__)
#include "begin_code.h" #undef __PLAYSTATIONPORTABLE__
/* Set up for C function definitions, even when using C++ */ #define __PLAYSTATIONPORTABLE__ 1
#ifdef __cplusplus #endif
/* *INDENT-OFF* */
extern "C" { #include "begin_code.h"
/* *INDENT-ON* */ /* Set up for C function definitions, even when using C++ */
#endif #ifdef __cplusplus
/* *INDENT-OFF* */
/** extern "C" {
* \brief Gets the name of the platform. /* *INDENT-ON* */
*/ #endif
extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);
/**
/* Ends C function definitions when using C++ */ * \brief Gets the name of the platform.
#ifdef __cplusplus */
/* *INDENT-OFF* */ extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);
}
/* *INDENT-ON* */ /* Ends C function definitions when using C++ */
#endif #ifdef __cplusplus
#include "close_code.h" /* *INDENT-OFF* */
}
#endif /* _SDL_platform_h */ /* *INDENT-ON* */
#endif
/* vi: set ts=4 sw=4 expandtab: */ #include "close_code.h"
#endif /* _SDL_platform_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,186 +1,189 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL_test_common.h * \file SDL_test_common.h
* *
* Include file for SDL test framework. * Include file for SDL test framework.
* *
* This code is a part of the SDL2_test library, not the main SDL library. * This code is a part of the SDL2_test library, not the main SDL library.
*/ */
/* Ported from original test\common.h file. */ /* Ported from original test\common.h file. */
#ifndef _SDL_test_common_h #ifndef _SDL_test_common_h
#define _SDL_test_common_h #define _SDL_test_common_h
#include "SDL.h" #include "SDL.h"
#ifdef __NDS__ #ifdef __NDS__
#define DEFAULT_WINDOW_WIDTH 256 #define DEFAULT_WINDOW_WIDTH 256
#define DEFAULT_WINDOW_HEIGHT (2*192) #define DEFAULT_WINDOW_HEIGHT (2*192)
#else #elif defined(__PSP__)
#define DEFAULT_WINDOW_WIDTH 640 #define DEFAULT_WINDOW_WIDTH 480
#define DEFAULT_WINDOW_HEIGHT 480 #define DEFAULT_WINDOW_HEIGHT 272
#endif #else
#define DEFAULT_WINDOW_WIDTH 640
#define VERBOSE_VIDEO 0x00000001 #define DEFAULT_WINDOW_HEIGHT 480
#define VERBOSE_MODES 0x00000002 #endif
#define VERBOSE_RENDER 0x00000004
#define VERBOSE_EVENT 0x00000008 #define VERBOSE_VIDEO 0x00000001
#define VERBOSE_AUDIO 0x00000010 #define VERBOSE_MODES 0x00000002
#define VERBOSE_RENDER 0x00000004
typedef struct #define VERBOSE_EVENT 0x00000008
{ #define VERBOSE_AUDIO 0x00000010
/* SDL init flags */
char **argv; typedef struct
Uint32 flags; {
Uint32 verbose; /* SDL init flags */
char **argv;
/* Video info */ Uint32 flags;
const char *videodriver; Uint32 verbose;
int display;
const char *window_title; /* Video info */
const char *window_icon; const char *videodriver;
Uint32 window_flags; int display;
int window_x; const char *window_title;
int window_y; const char *window_icon;
int window_w; Uint32 window_flags;
int window_h; int window_x;
int window_minW; int window_y;
int window_minH; int window_w;
int window_maxW; int window_h;
int window_maxH; int window_minW;
int depth; int window_minH;
int refresh_rate; int window_maxW;
int num_windows; int window_maxH;
SDL_Window **windows; int depth;
int refresh_rate;
/* Renderer info */ int num_windows;
const char *renderdriver; SDL_Window **windows;
Uint32 render_flags;
SDL_bool skip_renderer; /* Renderer info */
SDL_Renderer **renderers; const char *renderdriver;
Uint32 render_flags;
/* Audio info */ SDL_bool skip_renderer;
const char *audiodriver; SDL_Renderer **renderers;
SDL_AudioSpec audiospec;
/* Audio info */
/* GL settings */ const char *audiodriver;
int gl_red_size; SDL_AudioSpec audiospec;
int gl_green_size;
int gl_blue_size; /* GL settings */
int gl_alpha_size; int gl_red_size;
int gl_buffer_size; int gl_green_size;
int gl_depth_size; int gl_blue_size;
int gl_stencil_size; int gl_alpha_size;
int gl_double_buffer; int gl_buffer_size;
int gl_accum_red_size; int gl_depth_size;
int gl_accum_green_size; int gl_stencil_size;
int gl_accum_blue_size; int gl_double_buffer;
int gl_accum_alpha_size; int gl_accum_red_size;
int gl_stereo; int gl_accum_green_size;
int gl_multisamplebuffers; int gl_accum_blue_size;
int gl_multisamplesamples; int gl_accum_alpha_size;
int gl_retained_backing; int gl_stereo;
int gl_accelerated; int gl_multisamplebuffers;
int gl_major_version; int gl_multisamplesamples;
int gl_minor_version; int gl_retained_backing;
} SDLTest_CommonState; int gl_accelerated;
int gl_major_version;
#include "begin_code.h" int gl_minor_version;
/* Set up for C function definitions, even when using C++ */ } SDLTest_CommonState;
#ifdef __cplusplus
/* *INDENT-OFF* */ #include "begin_code.h"
extern "C" { /* Set up for C function definitions, even when using C++ */
/* *INDENT-ON* */ #ifdef __cplusplus
#endif /* *INDENT-OFF* */
extern "C" {
/* Function prototypes */ /* *INDENT-ON* */
#endif
/**
* \brief Parse command line parameters and create common state. /* Function prototypes */
*
* \param argv Array of command line parameters /**
* \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) * \brief Parse command line parameters and create common state.
* *
* \returns Returns a newly allocated common state object. * \param argv Array of command line parameters
*/ * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); *
* \returns Returns a newly allocated common state object.
/** */
* \brief Process one common argument. SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
*
* \param state The common state describing the test window to create. /**
* \param index The index of the argument to process in argv[]. * \brief Process one common argument.
* *
* \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. * \param state The common state describing the test window to create.
*/ * \param index The index of the argument to process in argv[].
int SDLTest_CommonArg(SDLTest_CommonState * state, int index); *
* \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error.
/** */
* \brief Returns common usage information int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
*
* \param state The common state describing the test window to create. /**
* * \brief Returns common usage information
* \returns String with usage information *
*/ * \param state The common state describing the test window to create.
const char *SDLTest_CommonUsage(SDLTest_CommonState * state); *
* \returns String with usage information
/** */
* \brief Open test window. const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
*
* \param state The common state describing the test window to create. /**
* * \brief Open test window.
* \returns True if initialization succeeded, false otherwise *
*/ * \param state The common state describing the test window to create.
SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); *
* \returns True if initialization succeeded, false otherwise
/** */
* \brief Common event handler for test windows. SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
*
* \param state The common state used to create test window. /**
* \param event The event to handle. * \brief Common event handler for test windows.
* \param done Flag indicating we are done. *
* * \param state The common state used to create test window.
*/ * \param event The event to handle.
void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done); * \param done Flag indicating we are done.
*
/** */
* \brief Close test window. void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
*
* \param state The common state used to create test window. /**
* * \brief Close test window.
*/ *
void SDLTest_CommonQuit(SDLTest_CommonState * state); * \param state The common state used to create test window.
*
*/
/* Ends C function definitions when using C++ */ void SDLTest_CommonQuit(SDLTest_CommonState * state);
#ifdef __cplusplus
/* *INDENT-OFF* */
} /* Ends C function definitions when using C++ */
/* *INDENT-ON* */ #ifdef __cplusplus
#endif /* *INDENT-OFF* */
#include "close_code.h" }
/* *INDENT-ON* */
#endif /* _SDL_test_common_h */ #endif
#include "close_code.h"
/* vi: set ts=4 sw=4 expandtab: */
#endif /* _SDL_test_common_h */
/* vi: set ts=4 sw=4 expandtab: */

BIN
libSDL2.a

Binary file not shown.

880
src/SDL.c
View File

@ -1,439 +1,441 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "SDL_config.h" #include "SDL_config.h"
/* Initialization code for SDL */ /* Initialization code for SDL */
#include "SDL.h" #include "SDL.h"
#include "SDL_bits.h" #include "SDL_bits.h"
#include "SDL_revision.h" #include "SDL_revision.h"
#include "SDL_fatal.h" #include "SDL_fatal.h"
#include "SDL_assert_c.h" #include "SDL_assert_c.h"
#include "haptic/SDL_haptic_c.h" #include "haptic/SDL_haptic_c.h"
#include "joystick/SDL_joystick_c.h" #include "joystick/SDL_joystick_c.h"
/* Initialization/Cleanup routines */ /* Initialization/Cleanup routines */
#if !SDL_TIMERS_DISABLED #if !SDL_TIMERS_DISABLED
extern void SDL_StartTicks(void); extern void SDL_StartTicks(void);
extern int SDL_TimerInit(void); extern int SDL_TimerInit(void);
extern void SDL_TimerQuit(void); extern void SDL_TimerQuit(void);
#endif #endif
#if defined(__WIN32__) #if defined(__WIN32__)
extern int SDL_HelperWindowCreate(void); extern int SDL_HelperWindowCreate(void);
extern int SDL_HelperWindowDestroy(void); extern int SDL_HelperWindowDestroy(void);
#endif #endif
/* The initialized subsystems */ /* The initialized subsystems */
static Uint32 ticks_started = 0; static Uint32 ticks_started = 0;
static SDL_bool SDL_bInMainQuit = SDL_FALSE; static SDL_bool SDL_bInMainQuit = SDL_FALSE;
static Uint8 SDL_SubsystemRefCount[ 32 ]; static Uint8 SDL_SubsystemRefCount[ 32 ];
/* Private helper to increment a subsystem's ref counter. */ /* Private helper to increment a subsystem's ref counter. */
static void static void
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem) SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
{ {
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255); SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
++SDL_SubsystemRefCount[subsystem_index]; ++SDL_SubsystemRefCount[subsystem_index];
} }
/* Private helper to decrement a subsystem's ref counter. */ /* Private helper to decrement a subsystem's ref counter. */
static void static void
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem) SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
{ {
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if (SDL_SubsystemRefCount[subsystem_index] > 0) { if (SDL_SubsystemRefCount[subsystem_index] > 0) {
--SDL_SubsystemRefCount[subsystem_index]; --SDL_SubsystemRefCount[subsystem_index];
} }
} }
/* Private helper to check if a system needs init. */ /* Private helper to check if a system needs init. */
static SDL_bool static SDL_bool
SDL_PrivateShouldInitSubsystem(Uint32 subsystem) SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{ {
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255); SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
return (SDL_SubsystemRefCount[subsystem_index] == 0); return (SDL_SubsystemRefCount[subsystem_index] == 0);
} }
/* Private helper to check if a system needs to be quit. */ /* Private helper to check if a system needs to be quit. */
static SDL_bool static SDL_bool
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) { SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if (SDL_SubsystemRefCount[subsystem_index] == 0) { if (SDL_SubsystemRefCount[subsystem_index] == 0) {
return SDL_FALSE; return SDL_FALSE;
} }
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount /* If we're in SDL_Quit, we shut down every subsystem, even if refcount
* isn't zero. * isn't zero.
*/ */
return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit; return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit;
} }
int int
SDL_InitSubSystem(Uint32 flags) SDL_InitSubSystem(Uint32 flags)
{ {
#if !SDL_TIMERS_DISABLED #if !SDL_TIMERS_DISABLED
if (!ticks_started) { if (!ticks_started) {
SDL_StartTicks(); SDL_StartTicks();
ticks_started = 1; ticks_started = 1;
} }
#endif #endif
/* Initialize the timer subsystem */ /* Initialize the timer subsystem */
if ((flags & SDL_INIT_TIMER) ){ if ((flags & SDL_INIT_TIMER) ){
#if !SDL_TIMERS_DISABLED #if !SDL_TIMERS_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) { if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
if (SDL_TimerInit() < 0) { if (SDL_TimerInit() < 0) {
return (-1); return (-1);
} }
} }
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER); SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
#else #else
SDL_SetError("SDL not built with timer support"); SDL_SetError("SDL not built with timer support");
return (-1); return (-1);
#endif #endif
} }
/* Initialize the video/event subsystem */ /* Initialize the video/event subsystem */
if ((flags & SDL_INIT_VIDEO) ){ if ((flags & SDL_INIT_VIDEO) ){
#if !SDL_VIDEO_DISABLED #if !SDL_VIDEO_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) { if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
if (SDL_VideoInit(NULL) < 0) { if (SDL_VideoInit(NULL) < 0) {
return (-1); return (-1);
} }
} }
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO); SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
#else #else
SDL_SetError("SDL not built with video support"); SDL_SetError("SDL not built with video support");
return (-1); return (-1);
#endif #endif
} }
/* Initialize the audio subsystem */ /* Initialize the audio subsystem */
if ((flags & SDL_INIT_AUDIO) ){ if ((flags & SDL_INIT_AUDIO) ){
#if !SDL_AUDIO_DISABLED #if !SDL_AUDIO_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) { if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
if (SDL_AudioInit(NULL) < 0) { if (SDL_AudioInit(NULL) < 0) {
return (-1); return (-1);
} }
} }
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO); SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
#else #else
SDL_SetError("SDL not built with audio support"); SDL_SetError("SDL not built with audio support");
return (-1); return (-1);
#endif #endif
} }
if ((flags & SDL_INIT_GAMECONTROLLER)) { if ((flags & SDL_INIT_GAMECONTROLLER)) {
// Game controller implies Joystick. // Game controller implies Joystick.
flags |= SDL_INIT_JOYSTICK; flags |= SDL_INIT_JOYSTICK;
} }
/* Initialize the joystick subsystem */ /* Initialize the joystick subsystem */
if ((flags & SDL_INIT_JOYSTICK) ){ if ((flags & SDL_INIT_JOYSTICK) ){
#if !SDL_JOYSTICK_DISABLED #if !SDL_JOYSTICK_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) { if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
if (SDL_JoystickInit() < 0) { if (SDL_JoystickInit() < 0) {
return (-1); return (-1);
} }
} }
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK); SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
#else #else
SDL_SetError("SDL not built with joystick support"); SDL_SetError("SDL not built with joystick support");
return (-1); return (-1);
#endif #endif
} }
if ((flags & SDL_INIT_GAMECONTROLLER) ){ if ((flags & SDL_INIT_GAMECONTROLLER) ){
#if !SDL_JOYSTICK_DISABLED #if !SDL_JOYSTICK_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) { if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
if (SDL_GameControllerInit() < 0) { if (SDL_GameControllerInit() < 0) {
return (-1); return (-1);
} }
} }
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER); SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
#else #else
SDL_SetError("SDL not built with joystick support"); SDL_SetError("SDL not built with joystick support");
return (-1); return (-1);
#endif #endif
} }
/* Initialize the haptic subsystem */ /* Initialize the haptic subsystem */
if ((flags & SDL_INIT_HAPTIC) ){ if ((flags & SDL_INIT_HAPTIC) ){
#if !SDL_HAPTIC_DISABLED #if !SDL_HAPTIC_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) { if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
if (SDL_HapticInit() < 0) { if (SDL_HapticInit() < 0) {
return (-1); return (-1);
} }
} }
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC); SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
#else #else
SDL_SetError("SDL not built with haptic (force feedback) support"); SDL_SetError("SDL not built with haptic (force feedback) support");
return (-1); return (-1);
#endif #endif
} }
return (0); return (0);
} }
int int
SDL_Init(Uint32 flags) SDL_Init(Uint32 flags)
{ {
if (SDL_AssertionsInit() < 0) { if (SDL_AssertionsInit() < 0) {
return -1; return -1;
} }
/* Clear the error message */ /* Clear the error message */
SDL_ClearError(); SDL_ClearError();
#if defined(__WIN32__) #if defined(__WIN32__)
if (SDL_HelperWindowCreate() < 0) { if (SDL_HelperWindowCreate() < 0) {
return -1; return -1;
} }
#endif #endif
/* Initialize the desired subsystems */ /* Initialize the desired subsystems */
if (SDL_InitSubSystem(flags) < 0) { if (SDL_InitSubSystem(flags) < 0) {
return (-1); return (-1);
} }
/* Everything is initialized */ /* Everything is initialized */
if (!(flags & SDL_INIT_NOPARACHUTE)) { if (!(flags & SDL_INIT_NOPARACHUTE)) {
SDL_InstallParachute(); SDL_InstallParachute();
} }
return (0); return (0);
} }
void void
SDL_QuitSubSystem(Uint32 flags) SDL_QuitSubSystem(Uint32 flags)
{ {
/* Shut down requested initialized subsystems */ /* Shut down requested initialized subsystems */
#if !SDL_JOYSTICK_DISABLED #if !SDL_JOYSTICK_DISABLED
if ((flags & SDL_INIT_GAMECONTROLLER)) { if ((flags & SDL_INIT_GAMECONTROLLER)) {
// Game controller implies Joystick. // Game controller implies Joystick.
flags |= SDL_INIT_JOYSTICK; flags |= SDL_INIT_JOYSTICK;
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
SDL_GameControllerQuit(); SDL_GameControllerQuit();
} }
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER); SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
} }
if ((flags & SDL_INIT_JOYSTICK)) { if ((flags & SDL_INIT_JOYSTICK)) {
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
SDL_JoystickQuit(); SDL_JoystickQuit();
} }
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK); SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
} }
#endif #endif
#if !SDL_HAPTIC_DISABLED #if !SDL_HAPTIC_DISABLED
if ((flags & SDL_INIT_HAPTIC)) { if ((flags & SDL_INIT_HAPTIC)) {
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
SDL_HapticQuit(); SDL_HapticQuit();
} }
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC); SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
} }
#endif #endif
#if !SDL_AUDIO_DISABLED #if !SDL_AUDIO_DISABLED
if ((flags & SDL_INIT_AUDIO)) { if ((flags & SDL_INIT_AUDIO)) {
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
SDL_AudioQuit(); SDL_AudioQuit();
} }
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO); SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
} }
#endif #endif
#if !SDL_VIDEO_DISABLED #if !SDL_VIDEO_DISABLED
if ((flags & SDL_INIT_VIDEO)) { if ((flags & SDL_INIT_VIDEO)) {
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
SDL_VideoQuit(); SDL_VideoQuit();
} }
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO); SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
} }
#endif #endif
#if !SDL_TIMERS_DISABLED #if !SDL_TIMERS_DISABLED
if ((flags & SDL_INIT_TIMER)) { if ((flags & SDL_INIT_TIMER)) {
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
SDL_TimerQuit(); SDL_TimerQuit();
} }
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER); SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
} }
#endif #endif
} }
Uint32 Uint32
SDL_WasInit(Uint32 flags) SDL_WasInit(Uint32 flags)
{ {
int i; int i;
int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount); int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
Uint32 initialized = 0; Uint32 initialized = 0;
if (!flags) { if (!flags) {
flags = SDL_INIT_EVERYTHING; flags = SDL_INIT_EVERYTHING;
} }
num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1); num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
/* Iterate over each bit in flags, and check the matching subsystem. */ /* Iterate over each bit in flags, and check the matching subsystem. */
for (i = 0; i < num_subsystems; ++i) { for (i = 0; i < num_subsystems; ++i) {
if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) { if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
initialized |= (1 << i); initialized |= (1 << i);
} }
flags >>= 1; flags >>= 1;
} }
return initialized; return initialized;
} }
void void
SDL_Quit(void) SDL_Quit(void)
{ {
SDL_bInMainQuit = SDL_TRUE; SDL_bInMainQuit = SDL_TRUE;
/* Quit all subsystems */ /* Quit all subsystems */
#if defined(__WIN32__) #if defined(__WIN32__)
SDL_HelperWindowDestroy(); SDL_HelperWindowDestroy();
#endif #endif
SDL_QuitSubSystem(SDL_INIT_EVERYTHING); SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
/* Uninstall any parachute signal handlers */ /* Uninstall any parachute signal handlers */
SDL_UninstallParachute(); SDL_UninstallParachute();
SDL_ClearHints(); SDL_ClearHints();
SDL_AssertionsQuit(); SDL_AssertionsQuit();
SDL_LogResetPriorities(); SDL_LogResetPriorities();
/* Now that every subsystem has been quit, we reset the subsystem refcount /* Now that every subsystem has been quit, we reset the subsystem refcount
* and the list of initialized subsystems. * and the list of initialized subsystems.
*/ */
SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) ); SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
SDL_bInMainQuit = SDL_FALSE; SDL_bInMainQuit = SDL_FALSE;
} }
/* Get the library version number */ /* Get the library version number */
void void
SDL_GetVersion(SDL_version * ver) SDL_GetVersion(SDL_version * ver)
{ {
SDL_VERSION(ver); SDL_VERSION(ver);
} }
/* Get the library source revision */ /* Get the library source revision */
const char * const char *
SDL_GetRevision(void) SDL_GetRevision(void)
{ {
return SDL_REVISION; return SDL_REVISION;
} }
/* Get the library source revision number */ /* Get the library source revision number */
int int
SDL_GetRevisionNumber(void) SDL_GetRevisionNumber(void)
{ {
return SDL_REVISION_NUMBER; return SDL_REVISION_NUMBER;
} }
/* Get the name of the platform */ /* Get the name of the platform */
const char * const char *
SDL_GetPlatform() SDL_GetPlatform()
{ {
#if __AIX__ #if __AIX__
return "AIX"; return "AIX";
#elif __ANDROID__ #elif __ANDROID__
return "Android"; return "Android";
#elif __HAIKU__ #elif __HAIKU__
/* Haiku must appear here before BeOS, since it also defines __BEOS__ */ /* Haiku must appear here before BeOS, since it also defines __BEOS__ */
return "Haiku"; return "Haiku";
#elif __BEOS__ #elif __BEOS__
return "BeOS"; return "BeOS";
#elif __BSDI__ #elif __BSDI__
return "BSDI"; return "BSDI";
#elif __DREAMCAST__ #elif __DREAMCAST__
return "Dreamcast"; return "Dreamcast";
#elif __FREEBSD__ #elif __FREEBSD__
return "FreeBSD"; return "FreeBSD";
#elif __HPUX__ #elif __HPUX__
return "HP-UX"; return "HP-UX";
#elif __IRIX__ #elif __IRIX__
return "Irix"; return "Irix";
#elif __LINUX__ #elif __LINUX__
return "Linux"; return "Linux";
#elif __MINT__ #elif __MINT__
return "Atari MiNT"; return "Atari MiNT";
#elif __MACOS__ #elif __MACOS__
return "MacOS Classic"; return "MacOS Classic";
#elif __MACOSX__ #elif __MACOSX__
return "Mac OS X"; return "Mac OS X";
#elif __NETBSD__ #elif __NETBSD__
return "NetBSD"; return "NetBSD";
#elif __NDS__ #elif __NDS__
return "Nintendo DS"; return "Nintendo DS";
#elif __OPENBSD__ #elif __OPENBSD__
return "OpenBSD"; return "OpenBSD";
#elif __OS2__ #elif __OS2__
return "OS/2"; return "OS/2";
#elif __OSF__ #elif __OSF__
return "OSF/1"; return "OSF/1";
#elif __QNXNTO__ #elif __QNXNTO__
return "QNX Neutrino"; return "QNX Neutrino";
#elif __RISCOS__ #elif __RISCOS__
return "RISC OS"; return "RISC OS";
#elif __SOLARIS__ #elif __SOLARIS__
return "Solaris"; return "Solaris";
#elif __WIN32__ #elif __WIN32__
return "Windows"; return "Windows";
#elif __IPHONEOS__ #elif __IPHONEOS__
return "iPhone OS"; return "iPhone OS";
#else #elif __PSP__
return "Unknown (see SDL_platform.h)"; return "PlayStation Portable";
#endif #else
} return "Unknown (see SDL_platform.h)";
#endif
#if defined(__WIN32__) }
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL)) #if defined(__WIN32__)
/* Need to include DllMain() on Watcom C for some reason.. */
#include "core/windows/SDL_windows.h" #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
/* Need to include DllMain() on Watcom C for some reason.. */
BOOL APIENTRY #include "core/windows/SDL_windows.h"
_DllMainCRTStartup(HANDLE hModule,
DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY
{ _DllMainCRTStartup(HANDLE hModule,
switch (ul_reason_for_call) { DWORD ul_reason_for_call, LPVOID lpReserved)
case DLL_PROCESS_ATTACH: {
case DLL_THREAD_ATTACH: switch (ul_reason_for_call) {
case DLL_THREAD_DETACH: case DLL_PROCESS_ATTACH:
case DLL_PROCESS_DETACH: case DLL_THREAD_ATTACH:
break; case DLL_THREAD_DETACH:
} case DLL_PROCESS_DETACH:
return TRUE; break;
} }
#endif /* building DLL with Watcom C */ return TRUE;
}
#endif /* __WIN32__ */ #endif /* building DLL with Watcom C */
/* vi: set sts=4 ts=4 sw=4 expandtab: */ #endif /* __WIN32__ */
/* vi: set sts=4 ts=4 sw=4 expandtab: */

View File

@ -1,26 +1,24 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,26 +1,24 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _SDL_pspaudio_h #ifndef _SDL_pspaudio_h
#define _SDL_pspaudio_h #define _SDL_pspaudio_h

View File

@ -1,194 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#if defined(SDL_HAPTIC_PSP) || defined(SDL_HAPTIC_DISABLED)
#include "SDL_haptic.h"
#include "../SDL_syshaptic.h"
static int
SDL_SYS_LogicError(void)
{
SDL_SetError("Logic error: No haptic devices available.");
return 0;
}
int
SDL_SYS_HapticInit(void)
{
return 0;
}
const char *
SDL_SYS_HapticName(int index)
{
SDL_SYS_LogicError();
return NULL;
}
int
SDL_SYS_HapticOpen(SDL_Haptic * haptic)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticMouse(void)
{
return -1;
}
int
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
{
return 0;
}
int
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
return 0;
}
void
SDL_SYS_HapticClose(SDL_Haptic * haptic)
{
return;
}
void
SDL_SYS_HapticQuit(void)
{
return;
}
int
SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
struct haptic_effect *effect, SDL_HapticEffect * base)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
struct haptic_effect *effect,
SDL_HapticEffect * data)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
Uint32 iterations)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
{
SDL_SYS_LogicError();
return -1;
}
void
SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
{
SDL_SYS_LogicError();
return;
}
int
SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
struct haptic_effect *effect)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticPause(SDL_Haptic * haptic)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
{
SDL_SYS_LogicError();
return -1;
}
int
SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
{
SDL_SYS_LogicError();
return -1;
}
#endif /* SDL_HAPTIC_PSP || SDL_HAPTIC_DISABLED */

View File

@ -1,23 +1,22 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@devolution.com misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
/* This is the system specific header for the SDL joystick API */ /* This is the system specific header for the SDL joystick API */

View File

@ -1,81 +1,80 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
Permission is granted to anyone to use this software for any purpose,
This library is distributed in the hope that it will be useful, including commercial applications, and to alter it and redistribute it
but WITHOUT ANY WARRANTY; without even the implied warranty of freely, subject to the following restrictions:
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
You should have received a copy of the GNU Library General Public in a product, an acknowledgment in the product documentation would be
License along with this library; if not, write to the Free appreciated but is not required.
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
Sam Lantinga 3. This notice may not be removed or altered from any source distribution.
slouken@libsdl.org */
*/
#include "SDL_main.h"
#include "SDL_main.h" #include <pspkernel.h>
#include <pspkernel.h> #include <pspdebug.h>
#include <pspdebug.h> #include <pspsdk.h>
#include <pspsdk.h> #include <pspthreadman.h>
#include <pspthreadman.h> #include <stdlib.h>
#include <stdlib.h> #include <stdio.h>
#include <stdio.h>
/* If application's main() is redefined as SDL_main, and libSDLmain is
/* If application's main() is redefined as SDL_main, and libSDLmain is linked, then this file will create the standard exit callback,
linked, then this file will create the standard exit callback, define the PSP_MODULE_INFO macro, and exit back to the browser when
define the PSP_MODULE_INFO macro, and exit back to the browser when the program is finished.
the program is finished.
You can still override other parameters in your own code if you
You can still override other parameters in your own code if you desire, such as PSP_HEAP_SIZE_KB, PSP_MAIN_THREAD_ATTR,
desire, such as PSP_HEAP_SIZE_KB, PSP_MAIN_THREAD_ATTR, PSP_MAIN_THREAD_STACK_SIZE, etc.
PSP_MAIN_THREAD_STACK_SIZE, etc. */
*/
extern int SDL_main(int argc, char *argv[]);
extern int SDL_main(int argc, char *argv[]);
PSP_MODULE_INFO("SDL App", 0, 1, 1);
PSP_MODULE_INFO("SDL App", 0, 1, 1);
int sdl_psp_exit_callback(int arg1, int arg2, void *common)
int sdl_psp_exit_callback(int arg1, int arg2, void *common) {
{ exit(0);
exit(0); return 0;
return 0; }
}
int sdl_psp_callback_thread(SceSize args, void *argp)
int sdl_psp_callback_thread(SceSize args, void *argp) {
{ int cbid;
int cbid; cbid = sceKernelCreateCallback("Exit Callback",
cbid = sceKernelCreateCallback("Exit Callback", sdl_psp_exit_callback, NULL);
sdl_psp_exit_callback, NULL); sceKernelRegisterExitCallback(cbid);
sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB();
sceKernelSleepThreadCB(); return 0;
return 0; }
}
int sdl_psp_setup_callbacks(void)
int sdl_psp_setup_callbacks(void) {
{ int thid = 0;
int thid = 0; thid = sceKernelCreateThread("update_thread",
thid = sceKernelCreateThread("update_thread", sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0);
sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0); if(thid >= 0)
if(thid >= 0) sceKernelStartThread(thid, 0, 0);
sceKernelStartThread(thid, 0, 0); return thid;
return thid; }
}
int main(int argc, char *argv[])
int main(int argc, char *argv[]) {
{ pspDebugScreenInit();
pspDebugScreenInit(); sdl_psp_setup_callbacks();
sdl_psp_setup_callbacks();
/* Register sceKernelExitGame() to be called when we exit */
/* Register sceKernelExitGame() to be called when we exit */ atexit(sceKernelExitGame);
atexit(sceKernelExitGame);
(void)SDL_main(argc, argv);
(void)SDL_main(argc, argv); return 0;
return 0; }
}

View File

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -18,23 +18,47 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#ifndef SDL_POWER_DISABLED #ifndef SDL_POWER_DISABLED
#if SDL_POWER_PSP #if SDL_POWER_PSP
#include "SDL_power.h" #include "SDL_power.h"
#include <psppower.h>
SDL_bool SDL_bool
SDL_GetPowerInfo_PSP(SDL_PowerState * state, int *seconds, SDL_GetPowerInfo_PSP(SDL_PowerState * state, int *seconds,
int *percent) int *percent)
{ {
/* !!! FIXME: write me. */ int battery = scePowerIsBatteryExist();
int plugged = scePowerIsPowerOnline();
int charging = scePowerIsBatteryCharging();
*state = SDL_POWERSTATE_UNKNOWN; *state = SDL_POWERSTATE_UNKNOWN;
*percent = -1; *seconds = -1;
*seconds = -1; *percent = -1;
if (!battery) {
*state = SDL_POWERSTATE_NO_BATTERY;
*seconds = -1;
*percent = -1;
} else if (charging) {
*state = SDL_POWERSTATE_CHARGING;
*percent = scePowerGetBatteryLifePercent();
*seconds = scePowerGetBatteryLifeTime()*60;
} else if (plugged) {
*state = SDL_POWERSTATE_CHARGED;
*percent = scePowerGetBatteryLifePercent();
*seconds = scePowerGetBatteryLifeTime()*60;
} else {
*state = SDL_POWERSTATE_ON_BATTERY;
*percent = scePowerGetBatteryLifePercent();
*seconds = scePowerGetBatteryLifeTime()*60;
}
return SDL_TRUE; /* always the definitive answer on PSP. */ return SDL_TRUE; /* always the definitive answer on PSP. */
} }

View File

@ -1,241 +0,0 @@
/*
* This file is part of "Phoenix Game Engine".
*
* Copyright (C) 2008 Phoenix Game Engine
* Copyright (C) 2008 InsertWittyName <tias_dp@hotmail.com>
* Copyright (C) 2008 MK2k <pge@mk2k.net>
*
* Phoenix Game Engine is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Phoenix Game Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Phoenix Game Engine. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "SDL_pspvram.h"
// Configure the memory to be managed
#define __MEM_SIZE 0x00200000
#define __MEM_START 0x04000000
// Configure the block size the memory gets subdivided into (page size)
// __MEM_SIZE/__BLOCK_SIZE may not exceed 2^15 = 32768
// The block size also defines the alignment of allocations
// Larger block sizes perform better, because the blocktable is smaller and therefore fits better into cache
// however the overhead is also bigger and more memory is wasted
#define __BLOCK_SIZE 512
#define __MEM_BLOCKS (__MEM_SIZE/__BLOCK_SIZE)
#define __BLOCKS(x) ((x+__BLOCK_SIZE-1)/__BLOCK_SIZE)
#define __BLOCKSIZE(x) ((x+__BLOCK_SIZE-1)&~(__BLOCK_SIZE-1))
// A MEMORY BLOCK ENTRY IS MADE UP LIKE THAT:
// bit: 31 32 30 - 15 14-0
// free block prev size
//
// bit 31: free bit, indicating if block is allocated or not
// bit 30: blocked bit, indicating if block is part of a larger block (0) - used for error resilience
// bit 30-15: block index of previous block
// bit 14- 0: size of current block
//
// This management can handle a max amount of 2^15 = 32768 blocks, which resolves to 32MB at blocksize of 1024 bytes
//
#define __BLOCK_GET_SIZE(x) ((x & 0x7FFF))
#define __BLOCK_GET_PREV(x) ((x >> 15) & 0x7FFF)
#define __BLOCK_GET_FREE(x) ((x >> 31))
#define __BLOCK_GET_BLOCK(x) ((x >> 30) & 0x1)
#define __BLOCK_SET_SIZE(x,y) x=((x & ~0x7FFF) | ((y) & 0x7FFF))
#define __BLOCK_ADD_SIZE(x,y) x=((x & ~0x7FFF) | (((x & 0x7FFF)+((y) & 0x7FFF)) & 0x7FFF))
#define __BLOCK_SET_PREV(x,y) x=((x & ~0x3FFF8000) | (((y) & 0x7FFF)<<15))
#define __BLOCK_SET_FREE(x,y) x=((x & 0x7FFFFFFF) | (((y) & 0x1)<<31))
#define __BLOCK_SET_BLOCK(x,y) x=((x & 0xBFFFFFFF) | (((y) & 0x1)<<30))
#define __BLOCK_MAKE(s,p,f,n) (((f & 0x1)<<31) | ((n & 0x1)<<30) | (((p) & 0x7FFF)<<15) | ((s) & 0x7FFF))
#define __BLOCK_GET_FREEBLOCK(x) ((x>>30) & 0x3) // returns 11b if block is a starting block and free, 10b if block is a starting block and allocated, 0xb if it is a non-starting block (don't change)
#define __BLOCK0 ((__MEM_BLOCKS) | (1<<31) | (1<<30))
static long __mem_blocks[__MEM_BLOCKS] = { 0 };
static long __largest_update = 0;
static long __largest_block = __MEM_BLOCKS;
static long __mem_free = __MEM_BLOCKS;
inline void* VramRelativePointer(void *ptr)
{
return (void*)((unsigned long)ptr & ~__MEM_START);
}
inline void* VramAbsolutePointer(void *ptr)
{
return (void*)((unsigned long)ptr | __MEM_START);
}
static void __find_largest_block()
{
long i = 0;
__largest_block = 0;
while (i < __MEM_BLOCKS)
{
long csize = __BLOCK_GET_SIZE(__mem_blocks[i]);
if (__BLOCK_GET_FREEBLOCK(__mem_blocks[i]) == 3 && csize > __largest_block)
__largest_block = csize;
i += csize;
}
__largest_update = 0;
}
void* VramAlloc(unsigned long size)
{
// Initialize memory block, if not yet done
if (__mem_blocks[0]==0) __mem_blocks[0] = __BLOCK0;
long i = 0;
long j = 0;
long bsize = __BLOCKS(size);
if (__largest_update == 0 && __largest_block < bsize)
{
return(0);
}
// Find smallest block that still fits the requested size
long bestblock = -1;
long bestblock_prev = 0;
long bestblock_size = __MEM_BLOCKS + 1;
while (i < __MEM_BLOCKS)
{
long csize = __BLOCK_GET_SIZE(__mem_blocks[i]);
if (__BLOCK_GET_FREEBLOCK(__mem_blocks[i]) == 3 && csize >= bsize)
{
if (csize < bestblock_size)
{
bestblock = i;
bestblock_prev = j;
bestblock_size = csize;
}
if (csize == bsize)
break;
}
j = i;
i += csize;
}
if (bestblock < 0)
{
return(0);
}
i = bestblock;
j = bestblock_prev;
long csize = bestblock_size;
__mem_blocks[i] = __BLOCK_MAKE(bsize, j, 0, 1);
long next = i + bsize;
if (csize > bsize && next < __MEM_BLOCKS)
{
__mem_blocks[next] = __BLOCK_MAKE(csize-bsize, i, 1, 1);
long nextnext = i + csize;
if (nextnext < __MEM_BLOCKS)
{
__BLOCK_SET_PREV(__mem_blocks[nextnext], next);
}
}
__mem_free -= bsize;
if (__largest_block == csize) // if we just allocated from one of the largest blocks
{
if ((csize-bsize) > (__mem_free>>1))
__largest_block = (csize - bsize); // there can't be another largest block
else
__largest_update = 1;
}
return ((void*)(__MEM_START + (i * __BLOCK_SIZE)));
}
void VramFree(void* ptr)
{
if (ptr == 0) return;
long block = ((long)ptr - __MEM_START)/__BLOCK_SIZE;
if (block < 0 || block > __MEM_BLOCKS)
{
return;
}
long csize = __BLOCK_GET_SIZE(__mem_blocks[block]);
if (__BLOCK_GET_FREEBLOCK(__mem_blocks[block]) != 1 || csize == 0)
{
return;
}
// Mark block as free
__BLOCK_SET_FREE(__mem_blocks[block], 1);
__mem_free += csize;
long next = block+csize;
// Merge with previous block if possible
long prev = __BLOCK_GET_PREV(__mem_blocks[block]);
if (prev < block)
{
if (__BLOCK_GET_FREEBLOCK(__mem_blocks[prev]) == 3)
{
__BLOCK_ADD_SIZE(__mem_blocks[prev], csize);
__BLOCK_SET_BLOCK(__mem_blocks[block], 0); // mark current block as inter block
if (next < __MEM_BLOCKS)
__BLOCK_SET_PREV(__mem_blocks[next], prev);
block = prev;
}
}
// Merge with next block if possible
if (next < __MEM_BLOCKS)
{
if (__BLOCK_GET_FREEBLOCK(__mem_blocks[next]) == 3)
{
__BLOCK_ADD_SIZE(__mem_blocks[block], __BLOCK_GET_SIZE(__mem_blocks[next]));
__BLOCK_SET_BLOCK(__mem_blocks[next], 0); // mark next block as inter block
long nextnext = next + __BLOCK_GET_SIZE(__mem_blocks[next]);
if (nextnext < __MEM_BLOCKS)
__BLOCK_SET_PREV(__mem_blocks[nextnext], block);
}
}
// Update if a new largest block emerged
if (__largest_block < __BLOCK_GET_SIZE(__mem_blocks[block]))
{
__largest_block = __BLOCK_GET_SIZE(__mem_blocks[block]);
__largest_update = 0; // No update necessary any more, because update only necessary when largest has shrinked at most
}
}
unsigned long VramAvailable()
{
return __mem_free * __BLOCK_SIZE;
}
unsigned long VramLargestBlock()
{
if (__largest_update) __find_largest_block();
return __largest_block * __BLOCK_SIZE;
}

View File

@ -1,94 +0,0 @@
/*
* pgeVram.h: Header for VRAM memory management
*
* This file is part of "Phoenix Game Engine".
*
* Copyright (C) 2008 Phoenix Game Engine
* Copyright (C) 2008 InsertWittyName <tias_dp@hotmail.com>
* Copyright (C) 2008 MK2k <pge@mk2k.net>
*
* Phoenix Game Engine is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Phoenix Game Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Phoenix Game Engine. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __SDL_PSPVRAM_H__
#define __SDL_PSPVRAM_H__
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup pgeVram VRAM Library
* @{
*/
/**
* Make a pointer relative to VRAM base
*
* @note A relative NULL pointer is NOT illegal!
*
* @param ptr - Pointer to make relative
*
* @returns relative pointer matching ptr
*/
void* VramRelativePointer(void *ptr);
/**
* Make a pointer absolute (usable by CPU).
*
* @note A relative NULL pointer is NOT illegal!
*
* @param ptr - Pointer to make absolute
*
* @returns absolute pointer matching ptr
*/
void* VramAbsolutePointer(void *ptr);
/**
* Allocate memory from VRAM.
*
* @param size - Number of bytes to allocate
*
* @returns Absolute pointer on success, NULL on failure
*/
void* VramAlloc(unsigned long size);
/**
* Free allocated memory from VRAM.
*
* @param ptr - Previously allocated pointer
*/
void VramFree(void* ptr);
/**
* Return remaining unallocated VRAM.
*
* @returns Size of remaining VRAM in bytes
*/
unsigned long VramAvailable();
/**
* Return largest free memory block in VRAM.
*
* @returns Size of largest free block in bytes
*/
unsigned long VramLargestBlock();
/** @} */
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // __PGEVRAM_H__

View File

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@ -1,27 +1,24 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
/* Semaphore functions for the PSP. */ /* Semaphore functions for the PSP. */
#include <stdio.h> #include <stdio.h>

View File

@ -1,27 +1,25 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
/* PSP thread management routines for SDL */ /* PSP thread management routines for SDL */
#include <stdio.h> #include <stdio.h>

View File

@ -1,26 +1,24 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#include <pspkerneltypes.h> #include <pspkerneltypes.h>
typedef SceUID SYS_ThreadHandle; typedef SceUID SYS_ThreadHandle;

View File

@ -1,27 +1,24 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_error.h" #include "SDL_error.h"

View File

@ -1,26 +1,24 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
/* Being a null driver, there's no event stream. We just define stubs for /* Being a null driver, there's no event stream. We just define stubs for
most of the API. */ most of the API. */

View File

@ -1,26 +1,24 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#include "SDL_pspvideo.h" #include "SDL_pspvideo.h"
/* Variables and functions exported by SDL_sysevents.c to other parts /* Variables and functions exported by SDL_sysevents.c to other parts

View File

@ -1,23 +1,22 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,23 +1,22 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _SDL_pspgl_c_h #ifndef _SDL_pspgl_c_h

View File

@ -1,27 +1,25 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#include <stdio.h> #include <stdio.h>
#include "SDL_error.h" #include "SDL_error.h"

View File

@ -1,26 +1,24 @@
/* /*
SDL - Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or This software is provided 'as-is', without any express or implied
modify it under the terms of the GNU Library General Public warranty. In no event will the authors be held liable for any damages
License as published by the Free Software Foundation; either arising from the use of this software.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, Permission is granted to anyone to use this software for any purpose,
but WITHOUT ANY WARRANTY; without even the implied warranty of including commercial applications, and to alter it and redistribute it
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU freely, subject to the following restrictions:
Library General Public License for more details.
You should have received a copy of the GNU Library General Public 1. The origin of this software must not be misrepresented; you must not
License along with this library; if not, write to the Free claim that you wrote the original software. If you use this software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
Sam Lantinga 2. Altered source versions must be plainly marked as such, and must not be
slouken@libsdl.org misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/ */
#include "SDL_pspvideo.h" #include "SDL_pspvideo.h"
/* Functions to be exported */ /* Functions to be exported */

View File

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -18,6 +18,7 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#if SDL_VIDEO_DRIVER_PSP #if SDL_VIDEO_DRIVER_PSP
@ -135,6 +136,11 @@ PSP_Create()
device->GL_GetSwapInterval = PSP_GL_GetSwapInterval; device->GL_GetSwapInterval = PSP_GL_GetSwapInterval;
device->GL_SwapWindow = PSP_GL_SwapWindow; device->GL_SwapWindow = PSP_GL_SwapWindow;
device->GL_DeleteContext = PSP_GL_DeleteContext; device->GL_DeleteContext = PSP_GL_DeleteContext;
device->SDL_HasScreenKeyboardSupport = PSP_SDL_HasScreenKeyboardSupport;
device->SDL_ShowScreenKeyboard = PSP_SDL_ShowScreenKeyboard;
device->SDL_HideScreenKeyboard = PSP_SDL_HideScreenKeyboard;
device->SDL_IsScreenKeyboardShown = PSP_SDL_IsScreenKeyboardShown;
device->PumpEvents = PSP_PumpEvents; device->PumpEvents = PSP_PumpEvents;
return device; return device;
@ -276,7 +282,7 @@ PSP_RestoreWindow(_THIS, SDL_Window * window)
{ {
} }
void void
PSP_SetWindowGrab(_THIS, SDL_Window * window) PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
{ {
} }
@ -306,7 +312,23 @@ PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
} }
/* TO Write Me*/
SDL_bool PSP_SDL_HasScreenKeyboardSupport(_THIS)
{
return SDL_TRUE;
}
void PSP_SDL_ShowScreenKeyboard(_THIS, SDL_Window *window)
{
}
void PSP_SDL_HideScreenKeyboard(_THIS, SDL_Window *window)
{
}
SDL_bool PSP_SDL_IsScreenKeyboardShown(_THIS, SDL_Window *window)
{
return SDL_FALSE;
}
#endif /* SDL_VIDEO_DRIVER_PANDORA */
#endif /* SDL_VIDEO_DRIVER_PSP */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -73,7 +73,7 @@ void PSP_RaiseWindow(_THIS, SDL_Window * window);
void PSP_MaximizeWindow(_THIS, SDL_Window * window); void PSP_MaximizeWindow(_THIS, SDL_Window * window);
void PSP_MinimizeWindow(_THIS, SDL_Window * window); void PSP_MinimizeWindow(_THIS, SDL_Window * window);
void PSP_RestoreWindow(_THIS, SDL_Window * window); void PSP_RestoreWindow(_THIS, SDL_Window * window);
void PSP_SetWindowGrab(_THIS, SDL_Window * window); void PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
void PSP_DestroyWindow(_THIS, SDL_Window * window); void PSP_DestroyWindow(_THIS, SDL_Window * window);
/* Window manager function */ /* Window manager function */
@ -91,7 +91,12 @@ int PSP_GL_GetSwapInterval(_THIS);
void PSP_GL_SwapWindow(_THIS, SDL_Window * window); void PSP_GL_SwapWindow(_THIS, SDL_Window * window);
void PSP_GL_DeleteContext(_THIS, SDL_GLContext context); void PSP_GL_DeleteContext(_THIS, SDL_GLContext context);
/*PSP on screen keyboard */
SDL_bool PSP_SDL_HasScreenKeyboardSupport(_THIS);
void PSP_SDL_ShowScreenKeyboard(_THIS, SDL_Window *window);
void PSP_SDL_HideScreenKeyboard(_THIS, SDL_Window *window);
SDL_bool PSP_SDL_IsScreenKeyboardShown(_THIS, SDL_Window *window);
#endif /* __SDL_PANDORA_H__ */ #endif /* __SDL_PANDORA_H__ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */