From 5abed77f4575375756d228a2afc749589a25c87a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 10 Sep 2014 22:35:21 +0200 Subject: [PATCH] fixed some bugs and added some speed when scaling in-game tile size --- ChangeLog | 4 + src/conftime.h | 2 +- src/init.c | 11 ++ src/libgame/sdl.c | 291 ++++++++++++++++++++++++++++++++++++++++++- src/libgame/sdl.h | 7 ++ src/libgame/system.c | 42 ++++++- src/tools.c | 52 ++++---- 7 files changed, 377 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee3945eb..3711c4ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-09-10 + * fixed some drawing bugs when scaling graphics due to "game.tile_size" + * added some performance improvements when handling SDL surface scaling + 2014-09-04 * added custom graphics property "game.tile_size" to define in-game tile size (this defines the tile size actually displayed on the playfield); diff --git a/src/conftime.h b/src/conftime.h index da246efe..6e813d9b 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-09-04 23:52" +#define COMPILE_DATE_STRING "2014-09-10 22:28" diff --git a/src/init.c b/src/init.c index dfe8d77f..8e02ffe2 100644 --- a/src/init.c +++ b/src/init.c @@ -202,6 +202,8 @@ inline void InitElementSmallImagesScaledUp(int graphic) void InitElementSmallImages() { + print_timestamp_init("InitElementSmallImages"); + static int special_graphics[] = { IMG_EDITOR_ELEMENT_BORDER, @@ -214,21 +216,30 @@ void InitElementSmallImages() int num_property_mappings = getImageListPropertyMappingSize(); int i; + print_timestamp_time("getImageListPropertyMapping/Size"); + + print_timestamp_init("InitElementSmallImagesScaledUp (1)"); /* initialize normal images from static configuration */ for (i = 0; element_to_graphic[i].element > -1; i++) InitElementSmallImagesScaledUp(element_to_graphic[i].graphic); + print_timestamp_done("InitElementSmallImagesScaledUp (1)"); /* initialize special images from static configuration */ for (i = 0; element_to_special_graphic[i].element > -1; i++) InitElementSmallImagesScaledUp(element_to_special_graphic[i].graphic); + print_timestamp_time("InitElementSmallImagesScaledUp (2)"); /* initialize images from dynamic configuration (may be elements or other) */ for (i = 0; i < num_property_mappings; i++) InitElementSmallImagesScaledUp(property_mapping[i].artwork_index); + print_timestamp_time("InitElementSmallImagesScaledUp (3)"); /* initialize special images from above list (non-element images) */ for (i = 0; special_graphics[i] > -1; i++) InitElementSmallImagesScaledUp(special_graphics[i]); + print_timestamp_time("InitElementSmallImagesScaledUp (4)"); + + print_timestamp_done("InitElementSmallImages"); } void InitScaledImages() diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index b6fd5b40..bf875a6d 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -177,14 +177,113 @@ static void SDLSetWindowIcon(char *basename) } #if defined(TARGET_SDL2) + +static boolean equalSDLPixelFormat(SDL_PixelFormat *format1, + SDL_PixelFormat *format2) +{ + return (format1->format == format2->format && + format1->BitsPerPixel == format2->BitsPerPixel && + format1->BytesPerPixel == format2->BytesPerPixel && + format1->Rmask == format2->Rmask && + format1->Gmask == format2->Gmask && + format1->Bmask == format2->Bmask && + format1->Amask == format2->Amask); +} + +boolean SDLSetNativeSurface(SDL_Surface **surface) +{ + SDL_Surface *new_surface; + + if (surface == NULL || + *surface == NULL || + backbuffer == NULL || + backbuffer->surface == NULL) + return FALSE; + + // if pixel format already optimized for destination surface, do nothing + if (equalSDLPixelFormat((*surface)->format, backbuffer->surface->format)) + return FALSE; + + new_surface = SDL_ConvertSurface(*surface, backbuffer->surface->format, 0); + + SDL_FreeSurface(*surface); + + *surface = new_surface; + + return TRUE; +} + +SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface) +{ + if (surface == NULL || + backbuffer == NULL || + backbuffer->surface == NULL) + return NULL; + + return SDL_ConvertSurface(surface, backbuffer->surface->format, 0); +} + SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface) { - if (backbuffer == NULL || + if (surface == NULL || + backbuffer == NULL || backbuffer->surface == NULL) return NULL; +#if 0 + boolean same_pixel_format = + equalSDLPixelFormat(surface->format, backbuffer->surface->format); + + printf("::: SDL_DisplayFormat: %08x -> %08x [%08x, %08x, %08x -> %08x, %08x, %08x] [%d, %d -> %d, %d] => %s\n", + surface->format->format, + backbuffer->surface->format->format, + surface->format->Rmask, + surface->format->Gmask, + surface->format->Bmask, + backbuffer->surface->format->Rmask, + backbuffer->surface->format->Gmask, + backbuffer->surface->format->Bmask, + surface->format->BitsPerPixel, + surface->format->BytesPerPixel, + backbuffer->surface->format->BitsPerPixel, + backbuffer->surface->format->BytesPerPixel, + (same_pixel_format ? "SAME" : "DIFF")); +#endif + return SDL_ConvertSurface(surface, backbuffer->surface->format, 0); } + +#else + +boolean SDLSetNativeSurface(SDL_Surface **surface) +{ + SDL_Surface *new_surface; + + if (surface == NULL) + return FALSE; + + new_surface = SDL_DisplayFormat(*surface); + + if (new_surface == NULL) + Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); + + SDL_FreeSurface(*surface); + + *surface = new_surface; + + return TRUE; +} + +SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface) +{ + SDL_Surface *new_surface = SDL_DisplayFormat(surface); + + if (new_surface == NULL) + Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); + + return new_surface; +} + #endif void SDLInitVideoDisplay(void) @@ -540,6 +639,11 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer, if (sdl_texture != NULL) { +#if 1 + // use SDL default values for RGB masks and no alpha channel + new_surface = SDL_CreateRGBSurface(0, width, height, 32, 0,0,0, 0); +#else + #if 1 // (do not use alpha channel) new_surface = SDL_CreateRGBSurface(0, width, height, 32, @@ -554,6 +658,8 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer, 0x0000FF00, 0x000000FF, 0xFF000000); +#endif + #endif if (new_surface == NULL) @@ -950,9 +1056,22 @@ void SDLRedrawWindow() } #endif -void SDLCreateBitmapContent(Bitmap *new_bitmap, int width, int height, +void SDLCreateBitmapContent(Bitmap *bitmap, int width, int height, int depth) { +#if 1 + SDL_Surface *surface = + SDL_CreateRGBSurface(SURFACE_FLAGS, width, height, depth, 0,0,0, 0); + + if (surface == NULL) + Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError()); + + SDLSetNativeSurface(&surface); + + bitmap->surface = surface; + +#else + SDL_Surface *surface_tmp, *surface_native; if ((surface_tmp = SDL_CreateRGBSurface(SURFACE_FLAGS, width, height, depth, @@ -966,6 +1085,7 @@ void SDLCreateBitmapContent(Bitmap *new_bitmap, int width, int height, SDL_FreeSurface(surface_tmp); new_bitmap->surface = surface_native; +#endif } void SDLFreeBitmapPointers(Bitmap *bitmap) @@ -2058,6 +2178,80 @@ int zoomSurfaceRGBA_scaleDownBy2(SDL_Surface *src, SDL_Surface *dst) return 0; } +#if 1 + +int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst) +{ + int x, y, *sax, *say, *csax, *csay; + float sx, sy; + tColorRGBA *sp, *csp, *csp0, *dp; + int dgap; + + /* use specialized zoom function when scaling down to exactly half size */ + if (src->w == 2 * dst->w && + src->h == 2 * dst->h) + return zoomSurfaceRGBA_scaleDownBy2(src, dst); + +#if 0 + printf("::: zoomSurfaceRGBA: %d, %d -> %d, %d\n", + src->w, src->h, dst->w, dst->h); +#endif + + /* variable setup */ + sx = (float) src->w / (float) dst->w; + sy = (float) src->h / (float) dst->h; + + /* allocate memory for row increments */ + csax = sax = (int *)checked_malloc((dst->w + 1) * sizeof(Uint32)); + csay = say = (int *)checked_malloc((dst->h + 1) * sizeof(Uint32)); + + /* precalculate row increments */ + for (x = 0; x <= dst->w; x++) + *csax++ = (int)(sx * x); + + for (y = 0; y <= dst->h; y++) + *csay++ = (int)(sy * y); + + /* pointer setup */ + sp = csp = csp0 = (tColorRGBA *) src->pixels; + dp = (tColorRGBA *) dst->pixels; + dgap = dst->pitch - dst->w * 4; + + csay = say; + for (y = 0; y < dst->h; y++) + { + sp = csp; + csax = sax; + + for (x = 0; x < dst->w; x++) + { + /* draw */ + *dp = *sp; + + /* advance source pointers */ + csax++; + sp = csp + *csax; + + /* advance destination pointer */ + dp++; + } + + /* advance source pointer */ + csay++; + csp = (tColorRGBA *) ((Uint8 *) csp0 + *csay * src->pitch); + + /* advance destination pointers */ + dp = (tColorRGBA *) ((Uint8 *) dp + dgap); + } + + free(sax); + free(say); + + return 0; +} + +#else + int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst) { int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy; @@ -2142,6 +2336,8 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst) return 0; } +#endif + /* ----------------------------------------------------------------------------- 8 bit zoomer @@ -2272,7 +2468,7 @@ SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height) else { /* new source surface is 32 bit with a defined RGB ordering */ - zoom_src = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32, + zoom_src = SDL_CreateRGBSurface(SURFACE_FLAGS, src->w, src->h, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0); SDL_BlitSurface(src, NULL, zoom_src, NULL); is_32bit = TRUE; @@ -2283,7 +2479,7 @@ SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height) if (is_32bit) { /* target surface is 32 bit with source RGBA/ABGR ordering */ - zoom_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dst_width, dst_height, 32, + zoom_dst = SDL_CreateRGBSurface(SURFACE_FLAGS, dst_width, dst_height, 32, zoom_src->format->Rmask, zoom_src->format->Gmask, zoom_src->format->Bmask, 0); @@ -2291,7 +2487,7 @@ SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height) else { /* target surface is 8 bit */ - zoom_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dst_width, dst_height, 8, + zoom_dst = SDL_CreateRGBSurface(SURFACE_FLAGS, dst_width, dst_height, 8, 0, 0, 0, 0); } @@ -2327,25 +2523,92 @@ SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height) return zoom_dst; } +#if 1 + +Bitmap *SDLZoomBitmap(Bitmap *src_bitmap, int dst_width, int dst_height) +{ +#if 1 + + Bitmap *dst_bitmap = CreateBitmapStruct(); + SDL_Surface **dst_surface = &dst_bitmap->surface; + + dst_width = MAX(1, dst_width); /* prevent zero bitmap width */ + dst_height = MAX(1, dst_height); /* prevent zero bitmap height */ + + dst_bitmap->width = dst_width; + dst_bitmap->height = dst_height; + + /* create zoomed temporary surface from source surface */ + *dst_surface = zoomSurface(src_bitmap->surface, dst_width, dst_height); + + /* create native format destination surface from zoomed temporary surface */ + SDLSetNativeSurface(dst_surface); + + return dst_bitmap; + +#else + + Bitmap *dst_bitmap = CreateBitmapStruct(); + SDL_Surface *sdl_surface_tmp; + + dst_width = MAX(1, dst_width); /* prevent zero bitmap width */ + dst_height = MAX(1, dst_height); /* prevent zero bitmap height */ + + dst_bitmap->width = dst_width; + dst_bitmap->height = dst_height; + + print_timestamp_init("SDLZoomBitmap"); + + /* create zoomed temporary surface from source surface */ + sdl_surface_tmp = zoomSurface(src_bitmap->surface, dst_width, dst_height); + print_timestamp_time("zoomSurface"); + + /* create native format destination surface from zoomed temporary surface */ + dst_bitmap->surface = SDL_DisplayFormat(sdl_surface_tmp); + print_timestamp_time("SDL_DisplayFormat"); + + /* free temporary surface */ + SDL_FreeSurface(sdl_surface_tmp); + print_timestamp_time("SDL_FreeSurface"); + + print_timestamp_done("SDLZoomBitmap"); + + return dst_bitmap; + +#endif +} + +#else + void SDLZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap) { SDL_Surface *sdl_surface_tmp; int dst_width = dst_bitmap->width; int dst_height = dst_bitmap->height; + print_timestamp_init("SDLZoomBitmap"); + /* throw away old destination surface */ SDL_FreeSurface(dst_bitmap->surface); + print_timestamp_time("SDL_FreeSurface"); /* create zoomed temporary surface from source surface */ sdl_surface_tmp = zoomSurface(src_bitmap->surface, dst_width, dst_height); + print_timestamp_time("zoomSurface"); /* create native format destination surface from zoomed temporary surface */ dst_bitmap->surface = SDL_DisplayFormat(sdl_surface_tmp); + print_timestamp_time("SDL_DisplayFormat"); /* free temporary surface */ SDL_FreeSurface(sdl_surface_tmp); + print_timestamp_time("SDL_FreeSurface"); + + print_timestamp_done("SDLZoomBitmap"); } +#endif + /* ========================================================================= */ /* load image to bitmap */ @@ -2373,12 +2636,21 @@ Bitmap *SDLLoadImage(char *filename) UPDATE_BUSY_STATE(); /* create native non-transparent surface for current image */ +#if 1 + if ((new_bitmap->surface = SDLGetNativeSurface(sdl_image_tmp)) == NULL) + { + SetError("SDL_DisplayFormat(): %s", SDL_GetError()); + + return NULL; + } +#else if ((new_bitmap->surface = SDL_DisplayFormat(sdl_image_tmp)) == NULL) { SetError("SDL_DisplayFormat(): %s", SDL_GetError()); return NULL; } +#endif print_timestamp_time("SDL_DisplayFormat (opaque)"); @@ -2387,12 +2659,21 @@ Bitmap *SDLLoadImage(char *filename) /* create native transparent surface for current image */ SDL_SetColorKey(sdl_image_tmp, SET_TRANSPARENT_PIXEL, SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00)); +#if 1 + if ((new_bitmap->surface_masked = SDLGetNativeSurface(sdl_image_tmp)) == NULL) + { + SetError("SDL_DisplayFormat(): %s", SDL_GetError()); + + return NULL; + } +#else if ((new_bitmap->surface_masked = SDL_DisplayFormat(sdl_image_tmp)) == NULL) { SetError("SDL_DisplayFormat(): %s", SDL_GetError()); return NULL; } +#endif print_timestamp_time("SDL_DisplayFormat (masked)"); diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index fe4bf7da..ef2cfd25 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -436,6 +436,9 @@ struct MouseCursorInfo /* SDL function definitions */ +boolean SDLSetNativeSurface(SDL_Surface **); +SDL_Surface *SDLGetNativeSurface(SDL_Surface *); + #if defined(TARGET_SDL2) SDL_Surface *SDL_DisplayFormat(SDL_Surface *); void SDLSetWindowScaling(int); @@ -464,7 +467,11 @@ void SDLPutPixel(Bitmap *, int, int, Pixel); void SDLInvertArea(Bitmap *, int, int, int, int, Uint32); void SDLCopyInverseMasked(Bitmap *, Bitmap *, int, int, int, int, int, int); +#if 1 +Bitmap *SDLZoomBitmap(Bitmap *, int, int); +#else void SDLZoomBitmap(Bitmap *, Bitmap *); +#endif Bitmap *SDLLoadImage(char *); diff --git a/src/libgame/system.c b/src/libgame/system.c index 78a32348..615d9d33 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -1115,9 +1115,32 @@ void ReloadCustomImage(Bitmap *bitmap, char *basename) Bitmap *ZoomBitmap(Bitmap *src_bitmap, int zoom_width, int zoom_height) { +#if 0 + // !!! TEST ONLY !!! + Bitmap *dst_bitmap = CreateBitmap(zoom_width, zoom_height, DEFAULT_DEPTH); + print_timestamp_time("CreateBitmap"); + + SDL_Rect src_rect, dst_rect; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.w = src_bitmap->width - 0; + src_rect.h = src_bitmap->height; + + dst_rect.x = 0; + dst_rect.y = 0; + dst_rect.w = dst_bitmap->width; + dst_rect.h = dst_bitmap->height; - SDLZoomBitmap(src_bitmap, dst_bitmap); + SDL_BlitScaled(src_bitmap->surface, &src_rect, + dst_bitmap->surface, &dst_rect); + print_timestamp_time("SDL_BlitScaled"); + +#else + + Bitmap *dst_bitmap = SDLZoomBitmap(src_bitmap, zoom_width, zoom_height); +#endif return dst_bitmap; } @@ -1148,6 +1171,8 @@ static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor, int old_width, old_height; int new_width, new_height; + print_timestamp_init("CreateScaledBitmaps"); + old_width = old_bitmap->width; old_height = old_bitmap->height; @@ -1199,7 +1224,15 @@ static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor, else if (width_0 == width_final) tmp_bitmap_0 = tmp_bitmap_final; else + { +#if 0 + if (old_width != width_0) + printf("::: %d, %d -> %d, %d\n", + old_width, old_height, width_0, height_0); +#endif + tmp_bitmap_0 = ZoomBitmap(old_bitmap, width_0, height_0); + } UPDATE_BUSY_STATE(); } @@ -1464,8 +1497,13 @@ static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor, SDL_SetColorKey(old_surface, SET_TRANSPARENT_PIXEL, SDL_MapRGB(old_surface->format, 0x00, 0x00, 0x00)); +#if 1 + if ((old_bitmap->surface_masked = SDLGetNativeSurface(old_surface)) == NULL) + Error(ERR_EXIT, "SDL_DisplayFormat() failed"); +#else if ((old_bitmap->surface_masked = SDL_DisplayFormat(old_surface)) == NULL) Error(ERR_EXIT, "SDL_DisplayFormat() failed"); +#endif SDL_SetColorKey(old_surface, UNSET_TRANSPARENT_PIXEL, 0); } @@ -1474,6 +1512,8 @@ static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor, UPDATE_BUSY_STATE(); FreeBitmap(new_bitmap); /* this actually frees the _old_ bitmap now */ + + print_timestamp_done("CreateScaledBitmaps"); } void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor, diff --git a/src/tools.c b/src/tools.c index 968ddc7a..6e1ffddc 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2234,8 +2234,8 @@ static void DrawLevelFieldCrumbledInnerCorners(int x, int y, int dx, int dy, #if NEW_TILESIZE width = crumbled_border_size * TILESIZE_VAR / TILESIZE; height = crumbled_border_size * TILESIZE_VAR / TILESIZE; - cx = (dx > 0 ? TILEX - crumbled_border_size : 0) * TILESIZE_VAR / TILESIZE; - cy = (dy > 0 ? TILEY - crumbled_border_size : 0) * TILESIZE_VAR / TILESIZE; + cx = (dx > 0 ? TILESIZE_VAR - width : 0); + cy = (dy > 0 ? TILESIZE_VAR - height : 0); BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy, width, height, FX + sx * TILEX_VAR + cx, FY + sy * TILEY_VAR + cy); @@ -2258,6 +2258,8 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, int width, height, bx, by, cx, cy; int sx = SCREENX(x), sy = SCREENY(y); int crumbled_border_size = graphic_info[graphic].border_size; + int crumbled_border_size_var = crumbled_border_size * TILESIZE_VAR / TILESIZE; + int crumbled_border_pos_var = TILESIZE_VAR - crumbled_border_size_var; int i; getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); @@ -2265,10 +2267,10 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, /* draw simple, sloppy, non-corner-accurate crumbled border */ #if 1 - width = (dir == 1 || dir == 2 ? crumbled_border_size : TILEX); - height = (dir == 0 || dir == 3 ? crumbled_border_size : TILEY); - cx = (dir == 2 ? TILEX - crumbled_border_size : 0); - cy = (dir == 3 ? TILEY - crumbled_border_size : 0); + width = (dir == 1 || dir == 2 ? crumbled_border_size_var : TILESIZE_VAR); + height = (dir == 0 || dir == 3 ? crumbled_border_size_var : TILESIZE_VAR); + cx = (dir == 2 ? crumbled_border_pos_var : 0); + cy = (dir == 3 ? crumbled_border_pos_var : 0); #else if (dir == 1 || dir == 2) /* left or right crumbled border */ { @@ -2288,12 +2290,12 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, #if NEW_TILESIZE BlitBitmap(src_bitmap, drawto_field, - src_x + cx * TILESIZE_VAR / TILESIZE, - src_y + cy * TILESIZE_VAR / TILESIZE, - width * TILESIZE_VAR / TILESIZE, - height * TILESIZE_VAR / TILESIZE, - FX + sx * TILEX_VAR + cx * TILESIZE_VAR / TILESIZE, - FY + sy * TILEY_VAR + cy * TILESIZE_VAR / TILESIZE); + src_x + cx, + src_y + cy, + width, + height, + FX + sx * TILEX_VAR + cx, + FY + sy * TILEY_VAR + cy); #else BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy, width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); @@ -2307,7 +2309,7 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, /* correct corners of crumbled border, if needed */ #if 1 - for (i = -1; i <= 1; i+=2) + for (i = -1; i <= 1; i += 2) { int xx = x + (dir == 0 || dir == 3 ? i : 0); int yy = y + (dir == 1 || dir == 2 ? i : 0); @@ -2321,13 +2323,13 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, { /* no crumbled corner, but continued crumbled border */ - int c1 = (dir == 2 || dir == 3 ? TILESIZE - crumbled_border_size : 0); - int c2 = (i == 1 ? TILESIZE - crumbled_border_size : 0); - int b1 = (i == 1 ? crumbled_border_size : - TILESIZE - 2 * crumbled_border_size); + int c1 = (dir == 2 || dir == 3 ? crumbled_border_pos_var : 0); + int c2 = (i == 1 ? crumbled_border_pos_var : 0); + int b1 = (i == 1 ? crumbled_border_size_var : + TILESIZE_VAR - 2 * crumbled_border_size_var); - width = crumbled_border_size; - height = crumbled_border_size; + width = crumbled_border_size_var; + height = crumbled_border_size_var; if (dir == 1 || dir == 2) { @@ -2346,12 +2348,12 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, #if NEW_TILESIZE BlitBitmap(src_bitmap, drawto_field, - src_x + bx * TILESIZE_VAR / TILESIZE, - src_y + by * TILESIZE_VAR / TILESIZE, - width * TILESIZE_VAR / TILESIZE, - height * TILESIZE_VAR / TILESIZE, - FX + sx * TILEX_VAR + cx * TILESIZE_VAR / TILESIZE, - FY + sy * TILEY_VAR + cy * TILESIZE_VAR / TILESIZE); + src_x + bx, + src_y + by, + width, + height, + FX + sx * TILEX_VAR + cx, + FY + sy * TILEY_VAR + cy); #else BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by, width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); -- 2.34.1