+ struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
+ int anim_nr;
+
+ if (mode_nr != GFX_SPECIAL_ARG_DEFAULT &&
+ mode_nr != game_status)
+ continue;
+
+ for (anim_nr = 0; anim_nr < ctrl->num_anims; anim_nr++)
+ {
+ struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
+ struct GraphicInfo *c = &anim->control_info;
+ int part_first, part_last;
+ int part_nr;
+
+ if (!(anim->state & ANIM_STATE_RUNNING))
+ continue;
+
+ part_first = part_last = anim->active_part_nr;
+
+ if (c->anim_mode & ANIM_ALL || anim->num_parts == 0)
+ {
+ int num_parts = anim->num_parts + (anim->has_base ? 1 : 0);
+
+ part_first = 0;
+ part_last = num_parts - 1;
+ }
+
+ for (part_nr = part_first; part_nr <= part_last; part_nr++)
+ {
+ struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
+ struct GraphicInfo *g = &part->graphic_info;
+ Bitmap *src_bitmap;
+ int src_x, src_y;
+ int width = g->width;
+ int height = g->height;
+ int dst_x = part->x;
+ int dst_y = part->y;
+ int cut_x = 0;
+ int cut_y = 0;
+ int sync_frame;
+ int frame;
+
+ if (!(part->state & ANIM_STATE_RUNNING))
+ continue;
+
+ if (part->drawing_stage != drawing_stage)
+ continue;
+
+ if (part->x < 0)
+ {
+ dst_x = 0;
+ width += part->x;
+ cut_x = -part->x;
+ }
+ else if (part->x > part->viewport_width - g->width)
+ width -= (part->x - (part->viewport_width - g->width));
+
+ if (part->y < 0)
+ {
+ dst_y = 0;
+ height += part->y;
+ cut_y = -part->y;
+ }
+ else if (part->y > part->viewport_height - g->height)
+ height -= (part->y - (part->viewport_height - g->height));
+
+ dst_x += part->viewport_x;
+ dst_y += part->viewport_y;
+
+ sync_frame = anim_sync_frame - part->initial_anim_sync_frame;
+ frame = getAnimationFrame(g->anim_frames, g->anim_delay,
+ g->anim_mode, g->anim_start_frame,
+ sync_frame);
+
+ getFixedGraphicSource(part->graphic, frame, &src_bitmap,
+ &src_x, &src_y);
+
+ src_x += cut_x;
+ src_y += cut_y;
+
+ BlitToScreenMasked(src_bitmap, src_x, src_y, width, height,
+ dst_x, dst_y);
+ }
+ }
+ }
+}
+
+void DrawGlobalAnim(int drawing_stage)
+{
+ if (!do_animations || !setup.toons)
+ return;
+
+ DrawGlobalAnimExt(drawing_stage);
+}
+
+boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part)
+{
+ int viewport_x;
+ int viewport_y;
+ int viewport_width;
+ int viewport_height;
+ boolean changed = FALSE;
+
+ if (part->last_game_status == game_status)
+ return FALSE;
+
+ part->last_game_status = game_status;
+
+ part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_1;
+
+ if (part->control_info.class == get_hash_from_key("window") ||
+ part->control_info.class == get_hash_from_key("border"))