Compilation fixes for SDL 1.3/2.0, Alien Blaster compiles but does not start

This commit is contained in:
pelya
2012-05-23 19:23:32 +03:00
parent 0c1ee22ffa
commit 04a4375565
16 changed files with 206 additions and 19 deletions

View File

@@ -26,7 +26,7 @@ echo "If you will supply empty string as answer the previous value will be used"
if [ -z "$LibSdlVersion" -o -z "$AUTO" ]; then
echo
echo -n "libSDL version to use (1.2 or 1.3) ($LibSdlVersion): "
echo -n "libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2) ($LibSdlVersion): "
read var
if [ -n "$var" ] ; then
LibSdlVersion="$var"

View File

@@ -14,6 +14,7 @@ SwVideoMode=n
SdlVideoResize=y
SdlVideoResizeKeepAspect=n
CompatibilityHacks=
CompatibilityHacksStaticInit=n
AppUsesMouse=n
AppNeedsTwoButtonMouse=n
ShowMouseCursor=n
@@ -35,6 +36,7 @@ MultiABI=n
AppVersionCode=110014
AppVersionName="1.1.0.14"
ResetSdlConfigForThisVersion=n
DeleteFilesOnUpgrade="%"
CompiledLibraries="sdl_mixer sdl_image"
CustomBuildScript=n
AppCflags='-O3'

View File

@@ -22,6 +22,10 @@ struct SdlCompat_AcceleratedSurface
SDL_PixelFormat * format;
};
enum { SDL_SRCALPHA = 8, SDL_SRCCOLORKEY = 16 }; // Some dummy non-zero values
typedef SDL_Keycode SDLKey;
extern SDL_Renderer * SDL_global_renderer;
static inline SdlCompat_AcceleratedSurface * SdlCompat_CreateAcceleratedSurface(SDL_Surface * surface)
@@ -29,6 +33,8 @@ static inline SdlCompat_AcceleratedSurface * SdlCompat_CreateAcceleratedSurface(
SdlCompat_AcceleratedSurface * ret = new SdlCompat_AcceleratedSurface();
// Allocate accelerated surface even if that means loss of color quality
Uint32 format;
Uint32 colorkey;
Uint8 alpha;
ret->w = surface->w;
ret->h = surface->h;
@@ -36,7 +42,7 @@ static inline SdlCompat_AcceleratedSurface * SdlCompat_CreateAcceleratedSurface(
memcpy(ret->format, surface->format, sizeof(SDL_PixelFormat));
format = SDL_PIXELFORMAT_RGB565;
if( surface->flags & SDL_SRCCOLORKEY )
if( SDL_GetColorKey(surface, &colorkey) == 0 )
{
format = SDL_PIXELFORMAT_RGBA4444;
}
@@ -52,13 +58,8 @@ static inline SdlCompat_AcceleratedSurface * SdlCompat_CreateAcceleratedSurface(
SDL_SetTextureBlendMode( ret->t, SDL_BLENDMODE_BLEND );
//SDL_SetTextureAlphaMod( ret->t, SDL_ALPHA_OPAQUE );
SDL_SetTextureAlphaMod( ret->t, 128 );
if( surface->flags & SDL_SRCALPHA )
{
Uint8 alpha = 128;
if( SDL_GetSurfaceAlphaMod( surface, &alpha ) < 0 )
alpha = 128;
if( SDL_GetSurfaceAlphaMod(surface, &alpha) == 0 )
SDL_SetTextureAlphaMod( ret->t, alpha );
}
return ret;
};
@@ -90,7 +91,7 @@ static inline int SDL_Flip(SdlCompat_AcceleratedSurface * unused)
static inline int SDL_SetAlpha(SdlCompat_AcceleratedSurface * surface, Uint32 flag, Uint8 alpha)
{
if( ! (flag & SDL_SRCALPHA) )
if( ! flag )
alpha = SDL_ALPHA_OPAQUE;
return SDL_SetTextureAlphaMod(surface->t, alpha);
};

View File

@@ -21,6 +21,7 @@
#define INPUT_H
#include "SDL.h"
#include "SdlForwardCompat.h"
class Input;

View File

@@ -130,6 +130,7 @@ int Mixer::loadSample(string fileName, int volume) {
if ( 0 <= volume && volume < 128 ) {
Mix_VolumeChunk( mixChunks[ mixChunks.size() - 1 ], volume );
}
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", (string( "Loading sound " ) + fn1 + " done").c_str() );
return mixChunks.size() - 1;
}
return fn2snd[ fileName ];
@@ -180,7 +181,7 @@ int Mixer::loadMusic( string fn ) {
if (enabled) {
if (fn2mus.find(fn) == fn2mus.end()) {
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", (string( "Loading sound " ) + fn).c_str() );
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", (string( "Loading music " ) + fn).c_str() );
string fn1 = fn;
// Check if file exist
@@ -213,6 +214,7 @@ int Mixer::loadMusic( string fn ) {
musics.push_back(newSound);
fn2mus[ fn ] = musics.size() - 1;
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", (string( "Loading music " ) + fn1 + " done").c_str() );
return musics.size() - 1;
}
return fn2mus[ fn ];

View File

@@ -80,19 +80,19 @@ SDL_Surface *SurfaceDB::loadSurfaceInternal( string fn, bool alpha ) {
if (!inputFile) {
cout << "ERROR: file " << fn1 << " does not exist!" << endl;
#ifdef ANDROID
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", (string( "Cannot load image " ) + fn1).c_str() );
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", (string( "Cannot load image " ) + fn1 + " - file does not exist").c_str() );
#endif
exit(1);
}
}
fclose(inputFile);
SDL_Surface *newSurface = isPNG ? IMG_Load( fn1.c_str() ) : SDL_LoadBMP( fn1.c_str() );
SDL_Surface *newSurface = IMG_Load( fn1.c_str() );
if( newSurface == NULL )
{
cout << "ERROR: Cannot load image " << fn1 << endl;
#ifdef ANDROID
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", (string( "Cannot load image " ) + fn1).c_str() );
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", (string( "Cannot load image " ) + fn1 + " - file is in invalid format").c_str() );
#endif
exit(1);
}

View File

@@ -1 +0,0 @@
../../sdl-1.3/include/SDL_screenkeyboard.h

View File

@@ -0,0 +1,108 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_screenkeyboard_h
#define _SDL_screenkeyboard_h
#include "SDL_stdinc.h"
#include "SDL_video.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_keyboard.h"
#include "SDL_keycode.h"
#include "SDL_scancode.h"
#else
#include "SDL_keysym.h"
#endif
/* On-screen keyboard exposed to the application, it's available on Android platform only */
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/* Button IDs */
enum {
SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD = 0, /* Joystick/D-Pad button */
SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, /* Main (usually Fire) button */
SDL_ANDROID_SCREENKEYBOARD_BUTTON_1,
SDL_ANDROID_SCREENKEYBOARD_BUTTON_2,
SDL_ANDROID_SCREENKEYBOARD_BUTTON_3,
SDL_ANDROID_SCREENKEYBOARD_BUTTON_4,
SDL_ANDROID_SCREENKEYBOARD_BUTTON_5,
SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, /* Button to show screen keyboard */
SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM
};
/* All functions return 0 on failure and 1 on success, contrary to other SDL API */
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos);
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos);
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonKey(int buttonId,
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_Keycode
#else
SDLKey
#endif
key);
/* Returns SDLK_UNKNOWN on failure */
extern DECLSPEC
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_Keycode
#else
SDLKey
#endif
SDLCALL SDL_ANDROID_GetScreenKeyboardButtonKey(int buttonId);
/* Buttons 0 and 1 may have auto-fire state */
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardAutoFireButtonsAmount(int nbuttons);
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardAutoFireButtonsAmount();
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardShown(int shown);
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardShown();
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardSize();
/* Show Android on-screen keyboard, and pass entered text back to application as SDL keypress events,
previousText is UTF-8 encoded, it may be NULL, only 256 first bytes will be used, and this call will not block */
extern DECLSPEC int SDLCALL SDL_ANDROID_ToggleScreenKeyboardTextInput(const char * previousText);
/* Show Android on-screen keyboard, and pass entered text back to application in a buffer,
using buffer contents as previous text (UTF-8 encoded), the buffer may be of any size -
this call will block until user typed all text. */
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardTextInput(char * textBuf, int textBufSize);
/* Whether user redefined on-screen keyboard layout via SDL menu, app should not enforce it's own layout in that case */
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardRedefinedByUser();
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif

View File

@@ -1 +0,0 @@
../../../../sdl-1.3/include/SDL_scalemode.h

View File

@@ -0,0 +1,69 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* \file SDL_scalemode.h
*
* Header file declaring the SDL_ScaleMode enumeration
*/
#ifndef _SDL_scalemode_h
#define _SDL_scalemode_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/**
* \brief The texture scale mode used in SDL_RenderCopy().
*/
typedef enum
{
SDL_SCALEMODE_NONE = 0x00000000, /**< No scaling, rectangles must
match dimensions */
SDL_SCALEMODE_FAST = 0x00000001, /**< Point sampling or
equivalent algorithm */
SDL_SCALEMODE_SLOW = 0x00000002, /**< Linear filtering or
equivalent algorithm */
SDL_SCALEMODE_BEST = 0x00000004 /**< Bicubic filtering or
equivalent algorithm */
} SDL_ScaleMode;
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_video_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -29,6 +29,7 @@
#include <OpenGLES/ES1/gl.h>
#include <OpenGLES/ES1/glext.h>
#else
#define GL_GLEXT_PROTOTYPES 1
#include <GLES/gl.h>
#include <GLES/glext.h>
#endif

View File

@@ -29,6 +29,7 @@
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#else
#define GL_GLEXT_PROTOTYPES 1
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif

View File

@@ -0,0 +1 @@
../../sdl-1.2/include/SDL_screenkeyboard.h

View File

@@ -32,7 +32,7 @@
#endif /* __APPLE__ */
#ifdef ANDROID
#include "../core/android/SDL_android.h"
/* #include "../core/android/SDL_android.h" */
#endif
#ifdef __NDS__
@@ -445,7 +445,8 @@ SDL_RWFromFile(const char *file, const char *mode)
SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
return NULL;
}
#if defined(ANDROID)
#if defined(ANDROID) && 0
rwops = SDL_AllocRW();
if (!rwops)
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */

View File

@@ -38,7 +38,7 @@
#include "../../events/SDL_mouse_c.h"
#include "SDL_keycode.h"
#include "SDL_scancode.h"
#include "SDL_compat.h"
//#include "SDL_compat.h"
#else
#include "SDL_keysym.h"
#include "../../events/SDL_events_c.h"
@@ -61,6 +61,9 @@
#define SDL_KEY2(X) SDL_SCANCODE_ ## X
#define SDL_KEY(X) SDL_KEY2(X)
typedef SDL_Scancode SDL_scancode;
typedef SDL_Keycode SDLKey;
typedef SDL_Keysym SDL_keysym;
#else