X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=e33344dd6b23cd1a64bd06a2f84d4d8924836fc0;hp=55f00ac327732c1f816e588c53f6179ccb6105b9;hb=3ea7bc006da99f1b13d817285820023b30ce2e38;hpb=a8cbd6caea4467607417ffe93ca70122b6862ff2 diff --git a/src/tools.c b/src/tools.c index 55f00ac3..e33344dd 100644 --- a/src/tools.c +++ b/src/tools.c @@ -208,18 +208,19 @@ int correctLevelPosY_EM(int ly) return ly; } -static int getFieldbufferOffsetX_RND(void) +int getFieldbufferOffsetX_RND(int dir, int pos) { int full_lev_fieldx = lev_fieldx + (BorderElement != EL_EMPTY ? 2 : 0); - int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); + int dx = (dir & MV_HORIZONTAL ? pos : 0); int dx_var = dx * TILESIZE_VAR / TILESIZE; int fx = FX; if (EVEN(SCR_FIELDX)) { - int ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; + int sbx_right = SBX_Right + (BorderElement != EL_EMPTY ? 1 : 0); + int ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) + if (ffx < sbx_right * TILEX_VAR + TILEX_VAR / 2) fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; else fx += (dx_var > 0 ? TILEX_VAR : 0); @@ -240,18 +241,19 @@ static int getFieldbufferOffsetX_RND(void) return fx; } -static int getFieldbufferOffsetY_RND(void) +int getFieldbufferOffsetY_RND(int dir, int pos) { int full_lev_fieldy = lev_fieldy + (BorderElement != EL_EMPTY ? 2 : 0); - int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); + int dy = (dir & MV_VERTICAL ? pos : 0); int dy_var = dy * TILESIZE_VAR / TILESIZE; int fy = FY; if (EVEN(SCR_FIELDY)) { + int sby_lower = SBY_Lower + (BorderElement != EL_EMPTY ? 1 : 0); int ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var; - if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR) + if (ffy < sby_lower * TILEY_VAR + TILEY_VAR / 2) fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR; else fy += (dy_var > 0 ? TILEY_VAR : 0); @@ -274,7 +276,7 @@ static int getFieldbufferOffsetY_RND(void) static int getLevelFromScreenX_RND(int sx) { - int fx = getFieldbufferOffsetX_RND(); + int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos); int dx = fx - FX; int px = sx - SX; int lx = LEVELX((px + dx) / TILESIZE_VAR); @@ -284,7 +286,7 @@ static int getLevelFromScreenX_RND(int sx) static int getLevelFromScreenY_RND(int sy) { - int fy = getFieldbufferOffsetY_RND(); + int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos); int dy = fy - FY; int py = sy - SY; int ly = LEVELY((py + dy) / TILESIZE_VAR); @@ -689,12 +691,17 @@ void DrawTileCursor(int draw_target) dst_x, dst_y); } +void BlitScreenToBitmapExt_RND(Bitmap *target_bitmap, int fx, int fy) +{ + BlitBitmap(drawto_field, target_bitmap, fx, fy, SXSIZE, SYSIZE, SX, SY); +} + void BlitScreenToBitmap_RND(Bitmap *target_bitmap) { - int fx = getFieldbufferOffsetX_RND(); - int fy = getFieldbufferOffsetY_RND(); + int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos); + int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos); - BlitBitmap(drawto_field, target_bitmap, fx, fy, SXSIZE, SYSIZE, SX, SY); + BlitScreenToBitmapExt_RND(target_bitmap, fx, fy); } void BlitScreenToBitmap(Bitmap *target_bitmap) @@ -1057,7 +1064,8 @@ void FadeIn(int fade_mask) void FadeOut(int fade_mask) { // update screen if areas covered by "fade_mask" and "redraw_mask" differ - if (!equalRedrawMasks(fade_mask, redraw_mask)) + if (!equalRedrawMasks(fade_mask, redraw_mask) && + fade_type_skip != FADE_MODE_SKIP_FADE_OUT) BackToFront(); SetScreenStates_BeforeFadingOut();