+ 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)
+{
+ 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_anim_status == global.anim_status)
+ return FALSE;
+
+ part->last_anim_status = global.anim_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"))
+ {
+ viewport_x = 0;
+ viewport_y = 0;
+ viewport_width = WIN_XSIZE;
+ viewport_height = WIN_YSIZE;
+
+ part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_2;
+ }
+ else if (part->control_info.class == get_hash_from_key("door_1"))
+ {
+ viewport_x = DX;
+ viewport_y = DY;
+ viewport_width = DXSIZE;
+ viewport_height = DYSIZE;
+ }
+ else if (part->control_info.class == get_hash_from_key("door_2"))
+ {
+ viewport_x = VX;
+ viewport_y = VY;
+ viewport_width = VXSIZE;
+ viewport_height = VYSIZE;
+ }
+ else // default: "playfield"
+ {
+ viewport_x = REAL_SX;
+ viewport_y = REAL_SY;
+ viewport_width = FULL_SXSIZE;
+ viewport_height = FULL_SYSIZE;
+ }
+
+ if (viewport_x != part->viewport_x ||
+ viewport_y != part->viewport_y ||
+ viewport_width != part->viewport_width ||
+ viewport_height != part->viewport_height)
+ {
+ part->viewport_x = viewport_x;
+ part->viewport_y = viewport_y;
+ part->viewport_width = viewport_width;
+ part->viewport_height = viewport_height;
+
+ changed = TRUE;
+ }
+
+ return changed;
+}
+
+int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, int state)
+{
+ struct GraphicInfo *g = &part->graphic_info;
+ struct GraphicInfo *c = &part->control_info;
+ boolean viewport_changed = SetGlobalAnimPart_Viewport(part);
+
+ if (viewport_changed)
+ state |= ANIM_STATE_RESTART;
+
+ if (state & ANIM_STATE_RESTART)