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

@@ -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);
}