diff --git a/src/gfx.c b/src/gfx.c index 7ed9805..2b6cb5c 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -220,14 +220,12 @@ makegray_image (SDL_Surface * org) gmask = 0x00ff0000; bmask = 0x0000ff00; amask = 0x000000ff; - -#else /* */ +#else rmask = 0x00ff0000; gmask = 0x0000ff00; bmask = 0x000000ff; amask = 0xff000000; - -#endif /* */ +#endif dest = SDL_CreateRGBSurface (SDL_SWSURFACE, org->w, org->h, 32, rmask, gmask, bmask, amask); if (dest == NULL) { fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ()); @@ -271,31 +269,16 @@ makegray_image (SDL_Surface * org) }; SDL_Surface * -gfx_quater_image (SDL_Surface * org1,SDL_Surface * org2,SDL_Surface * org3,SDL_Surface * org4) +gfx_quater_image (SDL_Surface * org1, SDL_Surface * org2, SDL_Surface * org3, SDL_Surface * org4) { - Uint32 rmask, - gmask, - bmask, - amask; - Uint32 pixel; + Uint32 pixel; SDL_Surface *dest; int y, x; - -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - rmask = 0xff000000; - gmask = 0x00ff0000; - bmask = 0x0000ff00; - amask = 0x000000ff; - -#else /* */ - rmask = 0x00ff0000; - gmask = 0x0000ff00; - bmask = 0x000000ff; - amask = 0xff000000; -#endif /* */ - dest = SDL_CreateRGBSurface (SDL_SWSURFACE, org1->w, org1->h, 32, rmask, gmask, bmask, amask); + dest = SDL_CreateRGBSurface (SDL_HWSURFACE, org1->w, org1->h, org1->format->BitsPerPixel, + org1->format->Rmask, org1->format->Gmask, + org1->format->Bmask, org1->format->Amask); if (dest == NULL) { fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ()); return NULL; @@ -339,34 +322,36 @@ gfx_quater_image (SDL_Surface * org1,SDL_Surface * org2,SDL_Surface * org3,SDL_S } return NULL; } - for (x = 0; x < org1->w/2; x++) - for (y = 0; y < org1->h/2; y++) { + for (x = 0; x < org1->w / 2; x++) + for (y = 0; y < org1->h / 2; y++) { pixel = getpixel (org1, x, y); putpixel (dest, x, y, pixel); } - for (x = org1->w/2; x < org1->w; x++) - for (y = 0; y < org1->h/2; y++) { + for (x = org1->w / 2; x < org1->w; x++) + for (y = 0; y < org1->h / 2; y++) { pixel = getpixel (org2, x, y); putpixel (dest, x, y, pixel); } - for (x = 0; x < org1->w/2; x++) - for (y = org1->h/2; y < org1->h; y++) { + for (x = 0; x < org1->w / 2; x++) + for (y = org1->h / 2; y < org1->h; y++) { pixel = getpixel (org3, x, y); putpixel (dest, x, y, pixel); } - for (x = org1->w/2; x < org1->w; x++) - for (y = org1->h/2; y < org1->h; y++) { + for (x = org1->w / 2; x < org1->w; x++) + for (y = org1->h / 2; y < org1->h; y++) { pixel = getpixel (org4, x, y); putpixel (dest, x, y, pixel); } - if (SDL_MUSTLOCK (org1)) SDL_UnlockSurface (org1); - if (SDL_MUSTLOCK (org2)) SDL_UnlockSurface (org2); - if (SDL_MUSTLOCK (org3)) SDL_UnlockSurface (org3); - if (SDL_MUSTLOCK (org4)) SDL_UnlockSurface (org4); - - - if (SDL_MUSTLOCK (dest)) { + if (SDL_MUSTLOCK (org1)) + SDL_UnlockSurface (org1); + if (SDL_MUSTLOCK (org2)) + SDL_UnlockSurface (org2); + if (SDL_MUSTLOCK (org3)) + SDL_UnlockSurface (org3); + if (SDL_MUSTLOCK (org4)) + SDL_UnlockSurface (org4); + if (SDL_MUSTLOCK (dest)) { SDL_UnlockSurface (dest); } return dest; @@ -889,25 +874,28 @@ gfx_load_tileset (char *tilesetname) sprintf (filename, "%s/tileset/%s/fieldshoe.bmp", bman.datapath, tileset); break; } - if (i==FT_mixed) { - tmpimage=gfx_quater_image(gfx.field[FT_bomb].image,gfx.field[FT_fire].image,gfx.field[FT_death].image,gfx.field[FT_shoe].image); - gfx.field[i].image = SDL_DisplayFormat (tmpimage); - } - else { - tmpimage = SDL_LoadBMP (filename); - if (tmpimage == NULL) { - printf ("Can't load image: %s\n", SDL_GetError ()); - exit (1); + if (i == FT_mixed) { + tmpimage = + gfx_quater_image (gfx.field[FT_bomb].image, gfx.field[FT_fire].image, + gfx.field[FT_death].image, gfx.field[FT_shoe].image); + gfx.field[i].image = SDL_DisplayFormat (tmpimage); } - gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE; - tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, - gfx.field[i].frames * gfx.block.y); - SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 255, 255)); - gfx.field[i].image = SDL_DisplayFormat (tmpimage1); - SDL_FreeSurface (tmpimage); - SDL_FreeSurface (tmpimage1); - } - } + else { + tmpimage = SDL_LoadBMP (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE; + tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, + gfx.field[i].frames * gfx.block.y); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, + SDL_MapRGB (tmpimage1->format, 255, 255, 255)); + gfx.field[i].image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage); + SDL_FreeSurface (tmpimage1); + } + } UpdateRects_nr = 0; };