-static int getGraphicAnimationPhase(int frames, int delay, int mode)
-{
- int phase;
-
- if (mode == ANIM_PINGPONG)
- {
- int max_anim_frames = 2 * frames - 2;
-
- phase = (FrameCounter % (delay * max_anim_frames)) / delay;
- phase = (phase < frames ? phase : max_anim_frames - phase);
- }
- else
- phase = (FrameCounter % (delay * frames)) / delay;
-
- if (mode == ANIM_REVERSE)
- phase = -phase;
-
- return phase;
-}
-
-static int getNewGraphicAnimationFrame(int graphic, int sync_frame)
-{
- int num_frames = new_graphic_info[graphic].anim_frames;
- int delay = new_graphic_info[graphic].anim_delay;
- int mode = new_graphic_info[graphic].anim_mode;
- int frame;
-
- /* animation synchronized with global frame counter, not move position */
- if (new_graphic_info[graphic].anim_global_sync || sync_frame < 0)
- sync_frame = FrameCounter;
-
- if (mode & ANIM_PINGPONG) /* use border frames once */
- {
- int max_anim_frames = 2 * num_frames - 2;
-
- frame = (sync_frame % (delay * max_anim_frames)) / delay;
- frame = (frame < num_frames ? frame : max_anim_frames - frame);
- }
- else if (mode & ANIM_PINGPONG2) /* use border frames twice */
- {
- int max_anim_frames = 2 * num_frames;
-
- frame = (sync_frame % (delay * max_anim_frames)) / delay;
- frame = (frame < num_frames ? frame : max_anim_frames - frame - 1);
- }
- else /* mode == ANIM_NORMAL || mode == ANIM_REVERSE */
- frame = (sync_frame % (delay * num_frames)) / delay;
-
- if (mode & ANIM_REVERSE) /* use reverse animation direction */
- frame = num_frames - frame - 1;
-
- return frame;
-}
-
-void DrawGraphicAnimationExt(int x, int y, int graphic,
- int frames, int delay, int mode, int mask_mode)
-{
- int phase = getGraphicAnimationPhase(frames, delay, mode);
-
- if (!(FrameCounter % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
- {
- if (mask_mode == USE_MASKING)
- DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic + phase);
- else
- DrawGraphic(SCREENX(x), SCREENY(y), graphic + phase);
- }
-}
-
-void DrawNewGraphicAnimationExt(int x, int y, int graphic, int mask_mode)
-{
- int delay = new_graphic_info[graphic].anim_delay;
-
- if (!(FrameCounter % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
- {
- int frame = getNewGraphicAnimationFrame(graphic, -1);
-
- if (mask_mode == USE_MASKING)
- DrawNewGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame);
- else
- DrawNewGraphic(SCREENX(x), SCREENY(y), graphic, frame);
- }
-}
-
-void DrawGraphicAnimation(int x, int y, int graphic,
- int frames, int delay, int mode)
-{
- DrawGraphicAnimationExt(x, y, graphic, frames, delay, mode, NO_MASKING);
-}
-
-void DrawNewGraphicAnimation(int x, int y, int graphic)
-{
- DrawNewGraphicAnimationExt(x, y, graphic, NO_MASKING);
-}
-
-void DrawGraphicAnimationThruMask(int x, int y, int graphic,
- int frames, int delay, int mode)
-{
- DrawGraphicAnimationExt(x, y, graphic, frames, delay, mode, USE_MASKING);
-}
-
-static void DrawGraphicAnimationShiftedThruMask(int sx, int sy,
- int sxx, int syy,
- int graphic,
- int frames, int delay,
- int mode)
-{
- int phase = getGraphicAnimationPhase(frames, delay, mode);
-
- DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic + phase, NO_CUTTING);
-}
-
-void getGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y)