From: Holger Schemel Date: Tue, 7 Mar 2017 20:16:53 +0000 (+0100) Subject: added functions for masked drawing of sized elements X-Git-Tag: 4.1.0.0~175 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=787be88219f3631b0bb044c16e3cdea4e8351aee;p=rocksndiamonds.git added functions for masked drawing of sized elements --- diff --git a/src/tools.c b/src/tools.c index a51f2f69..bfaad2ac 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1635,6 +1635,14 @@ void DrawSizedGraphic(int x, int y, int graphic, int frame, int tilesize) MarkTileDirty(x / tilesize, y / tilesize); } +void DrawSizedGraphicThruMask(int x, int y, int graphic, int frame, + int tilesize) +{ + DrawSizedGraphicThruMaskExt(drawto, SX + x * tilesize, SY + y * tilesize, + graphic, frame, tilesize); + MarkTileDirty(x / tilesize, y / tilesize); +} + void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int frame, int tilesize) { @@ -1645,6 +1653,16 @@ void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int frame, BlitBitmap(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y); } +void DrawSizedGraphicThruMaskExt(DrawBuffer *d, int x, int y, int graphic, + int frame, int tilesize) +{ + Bitmap *src_bitmap; + int src_x, src_y; + + getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y); + BlitBitmapMasked(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y); +} + void DrawMiniGraphic(int x, int y, int graphic) { DrawMiniGraphicExt(drawto, SX + x * MINI_TILEX,SY + y * MINI_TILEY, graphic); @@ -2456,8 +2474,8 @@ void DrawLevelField(int x, int y) } } -void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, - int (*el2img_function)(int)) +static void DrawSizedWallExt_MM(int dst_x, int dst_y, int element, int tilesize, + int (*el2img_function)(int), boolean masked) { int element_base = map_mm_wall_element(element); int element_bits = (IS_DF_WALL(element) ? @@ -2477,29 +2495,58 @@ void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, int dst_draw_y = dst_y + (i / 2) * tilesize_draw; if (element_bits & (1 << i)) - BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize_draw, tilesize_draw, - dst_draw_x, dst_draw_y); + { + if (masked) + BlitBitmapMasked(src_bitmap, drawto, src_x, src_y, + tilesize_draw, tilesize_draw, dst_draw_x, dst_draw_y); + else + BlitBitmap(src_bitmap, drawto, src_x, src_y, + tilesize_draw, tilesize_draw, dst_draw_x, dst_draw_y); + } else - ClearRectangle(drawto, dst_draw_x, dst_draw_y, - tilesize_draw, tilesize_draw); + { + if (!masked) + ClearRectangle(drawto, dst_draw_x, dst_draw_y, + tilesize_draw, tilesize_draw); + } } } -void DrawSizedElement(int x, int y, int element, int tilesize) +void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, + int (*el2img_function)(int)) +{ + DrawSizedWallExt_MM(dst_x, dst_y, element, tilesize, el2img_function, FALSE); +} + +void DrawSizedElementExt(int x, int y, int element, int tilesize, + boolean masked) { if (IS_MM_WALL(element)) { - DrawSizedWall_MM(SX + x * tilesize, SY + y * tilesize, - element, tilesize, el2edimg); + DrawSizedWallExt_MM(SX + x * tilesize, SY + y * tilesize, + element, tilesize, el2edimg, masked); } else { int graphic = el2edimg(element); - DrawSizedGraphic(x, y, graphic, 0, tilesize); + if (masked) + DrawSizedGraphicThruMask(x, y, graphic, 0, tilesize); + else + DrawSizedGraphic(x, y, graphic, 0, tilesize); } } +void DrawSizedElement(int x, int y, int element, int tilesize) +{ + DrawSizedElementExt(x, y, element, tilesize, FALSE); +} + +void DrawSizedElementThruMask(int x, int y, int element, int tilesize) +{ + DrawSizedElementExt(x, y, element, tilesize, TRUE); +} + void DrawMiniElement(int x, int y, int element) { int graphic; diff --git a/src/tools.h b/src/tools.h index 6deb4057..4f26f72e 100644 --- a/src/tools.h +++ b/src/tools.h @@ -157,6 +157,8 @@ void DrawFixedGraphicThruMaskExt(DrawBuffer *, int, int, int, int); void DrawSizedGraphic(int, int, int, int, int); void DrawSizedGraphicExt(DrawBuffer *, int, int, int, int, int); +void DrawSizedGraphicThruMask(int, int, int, int, int); +void DrawSizedGraphicThruMaskExt(DrawBuffer *, int, int, int, int, int); void DrawMiniGraphic(int, int, int); void DrawMiniGraphicExt(DrawBuffer *, int, int, int); @@ -177,6 +179,7 @@ void DrawScreenField(int, int); void DrawLevelField(int, int); void DrawSizedElement(int, int, int, int); +void DrawSizedElementThruMask(int, int, int, int); void DrawSizedElementOrWall(int, int, int, int, int); void DrawMiniElement(int, int, int);