From: Holger Schemel Date: Sun, 8 Oct 2023 22:11:13 +0000 (+0200) Subject: moved code to set global animation to CE position to separate function X-Git-Tag: 4.3.7.0~7 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d3bcf9a438f1d60468d934026eb66b2215628e63;p=rocksndiamonds.git moved code to set global animation to CE position to separate function --- diff --git a/src/anim.c b/src/anim.c index 808f7c8b..3dd9a143 100644 --- a/src/anim.c +++ b/src/anim.c @@ -1344,6 +1344,28 @@ static boolean clickConsumed(struct GlobalAnimPartControlInfo *part) return ((part->control_info.style & STYLE_PASSTHROUGH) ? FALSE : TRUE); } +static void SetGlobalAnimPartTileXY(struct GlobalAnimPartControlInfo *part) +{ + // calculate playfield position (with scrolling) for related CE tile + // (do not use FX/FY, which are incorrect during envelope requests) + int FX0 = 2 * TILEX_VAR; // same as FX during DRAW_TO_FIELDBUFFER + int FY0 = 2 * TILEY_VAR; // same as FY during DRAW_TO_FIELDBUFFER + int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos); + int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos); + int sx = FX0 + SCREENX(part->tile_x) * TILEX_VAR; + int sy = FY0 + SCREENY(part->tile_y) * TILEY_VAR; + int cx = SX - REAL_SX; + int cy = SY - REAL_SY; + int x = sx - fx + cx; + int y = sy - fy + cy; + + part->tile_xoffset += part->step_xoffset; + part->tile_yoffset += part->step_yoffset; + + part->x = x + part->tile_xoffset; + part->y = y + part->tile_yoffset; +} + static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part, boolean *click_consumed, boolean *any_event_action, @@ -1775,24 +1797,7 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, if (c->position == POS_CE) { - // calculate playfield position (with scrolling) for related CE tile - // (do not use FX/FY, which are incorrect during envelope requests) - int FX0 = 2 * TILEX_VAR; // same as FX during DRAW_TO_FIELDBUFFER - int FY0 = 2 * TILEY_VAR; // same as FY during DRAW_TO_FIELDBUFFER - int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos); - int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos); - int sx = FX0 + SCREENX(part->tile_x) * TILEX_VAR; - int sy = FY0 + SCREENY(part->tile_y) * TILEY_VAR; - int cx = SX - REAL_SX; - int cy = SY - REAL_SY; - int x = sx - fx + cx; - int y = sy - fy + cy; - - part->tile_xoffset += part->step_xoffset; - part->tile_yoffset += part->step_yoffset; - - part->x = x + part->tile_xoffset; - part->y = y + part->tile_yoffset; + SetGlobalAnimPartTileXY(part); } else {