X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=7ec68260c039aa73114f50eda882f07dd1884c1b;hb=0b722fa1c111eac25b4ce7606c99369eb0144442;hp=6dc9129afa775e788a8f9bbefc36dafef01f8fd5;hpb=6ddb8d0a22cbe7e084029f53d84dd1718e3d55c8;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 6dc9129a..7ec68260 100644 --- a/src/tools.c +++ b/src/tools.c @@ -528,6 +528,22 @@ static void PrintFrameTimeDebugging() } #endif +static int unifiedRedrawMask(int mask) +{ + if (mask & REDRAW_ALL) + return REDRAW_ALL; + + if (mask & REDRAW_FIELD && mask & REDRAW_DOORS) + return REDRAW_ALL; + + return mask; +} + +static boolean equalRedrawMasks(int mask_1, int mask_2) +{ + return unifiedRedrawMask(mask_1) == unifiedRedrawMask(mask_2); +} + void BackToFront() { static int last_redraw_mask = REDRAW_NONE; @@ -550,6 +566,10 @@ void BackToFront() if (redraw_mask & REDRAW_FPS) DrawFramesPerSecond(); + // remove playfield redraw before potentially merging with doors redraw + if (DrawingDeactivated(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE)) + redraw_mask &= ~REDRAW_FIELD; + // redraw complete window if both playfield and (some) doors need redraw if (redraw_mask & REDRAW_FIELD && redraw_mask & REDRAW_DOORS) redraw_mask = REDRAW_ALL; @@ -583,14 +603,16 @@ void BackToFront() x2 = MAX(x2, DX + DXSIZE); y2 = MAX(y2, DY + DYSIZE); } - else if (redraw_mask & REDRAW_DOOR_2) + + if (redraw_mask & REDRAW_DOOR_2) { x1 = MIN(x1, VX); y1 = MIN(y1, VY); x2 = MAX(x2, VX + VXSIZE); y2 = MAX(y2, VY + VYSIZE); } - else if (redraw_mask & REDRAW_DOOR_3) + + if (redraw_mask & REDRAW_DOOR_3) { x1 = MIN(x1, EX); y1 = MIN(y1, EY); @@ -725,10 +747,6 @@ static void SetScreenStates_AfterFadingIn() gfx.fade_border_source_status = global.border_status; global.anim_status = global.anim_status_next; - - // force update of global animation status in case of rapid screen changes - redraw_mask = REDRAW_ALL; - BackToFront(); } static void SetScreenStates_BeforeFadingOut() @@ -767,10 +785,18 @@ void FadeIn(int fade_mask) FADE_SYSIZE = FULL_SYSIZE; SetScreenStates_AfterFadingIn(); + + // force update of global animation status in case of rapid screen changes + redraw_mask = REDRAW_ALL; + BackToFront(); } void FadeOut(int fade_mask) { + // update screen if areas covered by "fade_mask" and "redraw_mask" differ + if (!equalRedrawMasks(fade_mask, redraw_mask)) + BackToFront(); + SetScreenStates_BeforeFadingOut(); #if 0