From: Holger Schemel Date: Tue, 22 Mar 2016 08:55:28 +0000 (+0100) Subject: changed drawing of global borders to more generic approach X-Git-Tag: 4.0.0.0-rc1~37 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=cd6f67fb2096aecb1d43e8684eead6a6232ef768;p=rocksndiamonds.git changed drawing of global borders to more generic approach --- diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 2fd019ce..6b38ce15 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -95,7 +95,7 @@ static void UpdateScreen(SDL_Rect *rect) // copy global masked border to render target buffer, if defined if (gfx.draw_global_border_function != NULL) - gfx.draw_global_border_function(REDRAW_ALL); + gfx.draw_global_border_function(DRAW_BORDER_TO_SCREEN); // copy global animations to render target buffer, if defined (above border) if (gfx.draw_global_anim_function != NULL) @@ -140,7 +140,7 @@ static void UpdateScreen(SDL_Rect *rect) // copy global masked border to render target buffer, if defined if (gfx.draw_global_border_function != NULL) - gfx.draw_global_border_function(REDRAW_ALL); + gfx.draw_global_border_function(DRAW_BORDER_TO_SCREEN); // copy global animations to render target buffer, if defined (above border) if (gfx.draw_global_anim_function != NULL) diff --git a/src/libgame/system.h b/src/libgame/system.h index dd5b1bf1..c4882637 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -169,6 +169,10 @@ #define DRAW_GLOBAL_ANIM_STAGE_1 1 #define DRAW_GLOBAL_ANIM_STAGE_2 2 +/* values for drawing target for global border */ +#define DRAW_BORDER_TO_BACKBUFFER 0 +#define DRAW_BORDER_TO_SCREEN 1 + /* values for move directions and special "button" key bitmasks */ #define MV_NONE 0 #define MV_LEFT (1 << MV_BIT_LEFT) diff --git a/src/tools.c b/src/tools.c index 552eef2f..b3938f5b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -289,65 +289,67 @@ void RedrawPlayfield() } static void DrawMaskedBorderExt_Rect(int x, int y, int width, int height, - boolean blit_to_screen) + int draw_target) { Bitmap *bitmap = getGlobalBorderBitmapFromGameStatus(); if (x == -1 && y == -1) return; - if (blit_to_screen) + if (draw_target == DRAW_BORDER_TO_SCREEN) BlitToScreenMasked(bitmap, x, y, width, height, x, y); else BlitBitmapMasked(bitmap, backbuffer, x, y, width, height, x, y); } -static void DrawMaskedBorderExt_FIELD(boolean blit_to_screen) +static void DrawMaskedBorderExt_FIELD(int draw_target) { if (global.border_status >= GAME_MODE_TITLE && global.border_status <= GAME_MODE_PLAYING && border.draw_masked[global.border_status]) DrawMaskedBorderExt_Rect(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, - blit_to_screen); + draw_target); } -static void DrawMaskedBorderExt_DOOR_1(boolean blit_to_screen) +static void DrawMaskedBorderExt_DOOR_1(int draw_target) { - // only draw border over closed doors when drawing to backbuffer - if (!blit_to_screen && (GetDoorState() & DOOR_OPEN_1)) + // when drawing to backbuffer, never draw border over open doors + if (draw_target == DRAW_BORDER_TO_BACKBUFFER && + (GetDoorState() & DOOR_OPEN_1)) return; if (border.draw_masked[GFX_SPECIAL_ARG_DOOR] && (global.border_status != GAME_MODE_EDITOR || border.draw_masked[GFX_SPECIAL_ARG_EDITOR])) - DrawMaskedBorderExt_Rect(DX, DY, DXSIZE, DYSIZE, blit_to_screen); + DrawMaskedBorderExt_Rect(DX, DY, DXSIZE, DYSIZE, draw_target); } -static void DrawMaskedBorderExt_DOOR_2(boolean blit_to_screen) +static void DrawMaskedBorderExt_DOOR_2(int draw_target) { - // only draw border over closed doors when drawing to backbuffer - if (!blit_to_screen && (GetDoorState() & DOOR_OPEN_2)) + // when drawing to backbuffer, never draw border over open doors + if (draw_target == DRAW_BORDER_TO_BACKBUFFER && + (GetDoorState() & DOOR_OPEN_2)) return; if (border.draw_masked[GFX_SPECIAL_ARG_DOOR] && global.border_status != GAME_MODE_EDITOR) - DrawMaskedBorderExt_Rect(VX, VY, VXSIZE, VYSIZE, blit_to_screen); + DrawMaskedBorderExt_Rect(VX, VY, VXSIZE, VYSIZE, draw_target); } -static void DrawMaskedBorderExt_DOOR_3(boolean blit_to_screen) +static void DrawMaskedBorderExt_DOOR_3(int draw_target) { /* currently not available */ } -static void DrawMaskedBorderExt_ALL(boolean blit_to_screen) +static void DrawMaskedBorderExt_ALL(int draw_target) { - DrawMaskedBorderExt_FIELD(blit_to_screen); - DrawMaskedBorderExt_DOOR_1(blit_to_screen); - DrawMaskedBorderExt_DOOR_2(blit_to_screen); - DrawMaskedBorderExt_DOOR_3(blit_to_screen); + DrawMaskedBorderExt_FIELD(draw_target); + DrawMaskedBorderExt_DOOR_1(draw_target); + DrawMaskedBorderExt_DOOR_2(draw_target); + DrawMaskedBorderExt_DOOR_3(draw_target); } -static void DrawMaskedBorderExt(int redraw_mask, boolean blit_to_screen) +static void DrawMaskedBorderExt(int redraw_mask, int draw_target) { /* never draw masked screen borders on borderless screens */ if (game_status == GAME_MODE_LOADING || @@ -355,33 +357,33 @@ static void DrawMaskedBorderExt(int redraw_mask, boolean blit_to_screen) return; if (redraw_mask & REDRAW_ALL) - DrawMaskedBorderExt_ALL(blit_to_screen); + DrawMaskedBorderExt_ALL(draw_target); else { if (redraw_mask & REDRAW_FIELD) - DrawMaskedBorderExt_FIELD(blit_to_screen); + DrawMaskedBorderExt_FIELD(draw_target); if (redraw_mask & REDRAW_DOOR_1) - DrawMaskedBorderExt_DOOR_1(blit_to_screen); + DrawMaskedBorderExt_DOOR_1(draw_target); if (redraw_mask & REDRAW_DOOR_2) - DrawMaskedBorderExt_DOOR_2(blit_to_screen); + DrawMaskedBorderExt_DOOR_2(draw_target); if (redraw_mask & REDRAW_DOOR_3) - DrawMaskedBorderExt_DOOR_3(blit_to_screen); + DrawMaskedBorderExt_DOOR_3(draw_target); } } void DrawMaskedBorder_FIELD() { - DrawMaskedBorderExt_FIELD(FALSE); + DrawMaskedBorderExt_FIELD(DRAW_BORDER_TO_BACKBUFFER); } void DrawMaskedBorder(int redraw_mask) { - DrawMaskedBorderExt(redraw_mask, FALSE); + DrawMaskedBorderExt(redraw_mask, DRAW_BORDER_TO_BACKBUFFER); } -void DrawMaskedBorderToScreen(int redraw_mask) +void DrawMaskedBorderToScreen(int draw_target) { - DrawMaskedBorderExt(redraw_mask, TRUE); + DrawMaskedBorderExt(REDRAW_ALL, draw_target); } void BlitScreenToBitmap_RND(Bitmap *target_bitmap)