From 5d0b6e197f11004753484ad383d66fe0c3588857 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 20 Jul 2013 12:22:01 +0200 Subject: Correction uint32_t -> Uint32. Debut conversion paint_terrain, ya du taff... --- src/graphic.c | 61 +++++++++++++++++++++++++------------------------- src/include/data_ini.h | 14 ++++++------ src/parser.c | 4 ++-- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/graphic.c b/src/graphic.c index 1a3fa1f..934e87b 100644 --- a/src/graphic.c +++ b/src/graphic.c @@ -84,51 +84,52 @@ void my_SDL_init_or_die(char title[], SDL_Rect win_pos, Uint32 init_flags, Uint3 //FIXME : to be implmented int paint_terrain(gameIni_t *gIni, gameRess_t *gRess) { - int res, res2, i, modifier; - int x,y,xmin,xmax,ymin,ymax,y2,xdst,ydst; - Uint32 dstPixel, dstStencil, rmask, gmask, bmask, amask; - SDL_Surface *tile; -/* Is necessary ? -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - rmask = 0xff000000; - gmask = 0x00ff0000; - bmask = 0x0000ff00; - amask = 0x000000ff; -#else - rmask = 0x000000ff; - gmask = 0x0000ff00; - bmask = 0x00ff0000; - amask = 0xff000000; -#endif -*/ - rmask = gmask = bmask = amask = 0; // Use default masks - gRess->terrain=SDL_CreateRGBSurface(0, LEVEL_WIDTH, LEVEL_HEIGHT, 32, rmask, gmask, bmask, amask); - gRess->stencil=SDL_CreateRGBSurface(0, LEVEL_WIDTH, LEVEL_HEIGHT, 32, rmask, gmask, bmask, amask); + int res, res2, bpp; +// int i, modifier; +// int x,y,xmin,xmax,ymin,ymax,y2,xdst,ydst; +// Uint32 dstPixel, dstStencil; + Uint32 format, cc_nothing, rmask, gmask, bmask, amask; +// SDL_Surface *tile; + + format=SDL_PIXELFORMAT_ARGB8888; + cc_nothing=0xFF000000; /* Make it portable (big endian) */ + + res=SDL_PixelFormatEnumToMasks(format, &bpp, &rmask, &gmask, &bmask, &amask); + MPL_CHECK( + res==SDL_TRUE, + { return 1; }, + SDL_LOG_PRIORITY_CRITICAL, + "paintTerrain(), SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB8888, ...) failed" + ); + gRess->terrain=SDL_CreateRGBSurface(0, LEVEL_WIDTH, LEVEL_HEIGHT, bpp, rmask, gmask, bmask, amask); + gRess->stencil=SDL_CreateRGBSurface(0, LEVEL_WIDTH, LEVEL_HEIGHT, bpp, rmask, gmask, bmask, amask); MPL_CHECK( gRess->terrain && gRess->stencil, - { return 1; }, + { return 2; }, SDL_LOG_PRIORITY_CRITICAL, "paintTerrain(), SDL_CreateRGBSurface() failed" ); + /* Fill the entire surfaces with default color */ res=SDL_FillRect(gRess->terrain, NULL, gIni->style.bgColor); - res2=SDL_FillRect(gRess->stencil, NULL, ccc_nothing); + res2=SDL_FillRect(gRess->stencil, NULL, cc_nothing); MPL_CHECK( res==0 && res2==0, - { return 2; }, + { return 3; }, SDL_LOG_PRIORITY_CRITICAL, "paintTerrain(), SDL_FillRect() failed" ); - SDL_LockSurface(gRess->terrain); +#if 0 + SDL_LockSurface(gRess->terrain); /*XXX Only if RLE encoded. To be removed ? */ SDL_LockSurface(gRess->stencil); for(i=0 ; i < gIni->level.terrainCount ; i++) { int tid=gIni->level.terrains[i].id; MPL_CHECK( tid > 0 && tid < MAX_TILES_COUNT, - { return 3; }, + { return 4; }, SDL_LOG_PRIORITY_CRITICAL, "paintTerrain(), gIni->level.terrains[%].id == %i and it's out of range", i, tid ); @@ -136,7 +137,7 @@ int paint_terrain(gameIni_t *gIni, gameRess_t *gRess) { tile=gRess->tiles[tid]; MPL_CHECK( tile, - { return 4; }, + { return 5; }, SDL_LOG_PRIORITY_CRITICAL, "paintTerrain(), tile %i was not loaded", tid ); @@ -184,14 +185,14 @@ int paint_terrain(gameIni_t *gIni, gameRess_t *gRess) { // Always paint pixel, except in one case: // If we are in NO_OVERRIDE mode and there is already a terrain on the current (source) pixel if ( !( (modifier & 8) == 8 && - getPixel(gRess->stencil, xdst, ydst) == ccc_terrain ) ) { + getPixel(gRess->stencil, xdst, ydst) == cc_terrain ) ) { // If we have REMOVE modifier, dstPixel will be rolled back to bgColor, else, it will be identical to the source pixel. We have to update stencil consistenly. if ( (modifier & 2) == 2 ) { dstPixel=gIni->style.bgColor; - dstStencil=ccc_nothing; + dstStencil=cc_nothing; } else { dstPixel=getPixel8BitPalette(tile, x, y2); - dstStencil=ccc_terrain; + dstStencil=cc_terrain; } putPixel(gRess->terrain,xdst,ydst,dstPixel); putPixel(gRess->stencil,xdst,ydst,dstStencil); @@ -203,7 +204,7 @@ int paint_terrain(gameIni_t *gIni, gameRess_t *gRess) { } SDL_UnlockSurface(gRess->stencil); SDL_UnlockSurface(gRess->terrain); - +#endif return 0; } diff --git a/src/include/data_ini.h b/src/include/data_ini.h index c2c4c11..381943a 100644 --- a/src/include/data_ini.h +++ b/src/include/data_ini.h @@ -54,14 +54,14 @@ struct levelPackIni { //////////////////////// STYLE INI FILES //////////////////////// struct styleIni { - uint32_t bgColor, debrisColor; - int tiles, particleColorCount; - uint32_t particleColor[MAX_PARTICLE_COLORS]; + Uint32 bgColor, debrisColor; + int tiles, particleColorCount; + Uint32 particleColor[MAX_PARTICLE_COLORS]; int objectCount; - int frames[MAX_OBJECTS_COUNT]; - int anim[MAX_OBJECTS_COUNT]; - int type[MAX_OBJECTS_COUNT]; - int sound[MAX_OBJECTS_COUNT]; + int frames[MAX_OBJECTS_COUNT]; + int anim[MAX_OBJECTS_COUNT]; + int type[MAX_OBJECTS_COUNT]; + int sound[MAX_OBJECTS_COUNT]; }; /*////////////////////// MISC/LEMMING.INI FILE //////////////////////// diff --git a/src/parser.c b/src/parser.c index d34197d..027d1fc 100644 --- a/src/parser.c +++ b/src/parser.c @@ -113,12 +113,12 @@ int loadIni(enum ini_type type, const char *filepath, gameIni_t *ini) { return res; } -uint32_t hextext2rgb(const char str[]) { +Uint32 hextext2rgb(const char str[]) { int res; unsigned int val; res=SDL_sscanf(str,"0x%x",&val); // Default value to opaque white. Should be visible on screen if problem with that - return (res!=1)?0xffffffff:(uint32_t)val; + return (res!=1)?0xffffffff:(Uint32)val; } int callback_ini_style(const mTCHAR *section, const mTCHAR *key, const mTCHAR *value, const void *userData) { -- cgit v1.2.3