+ int step_factor = step_delay / max_step_delay;
+ int kx = k / step_factor + 1;
+ int ky = k / step_factor + 1;
+
+#if 0
+ // if (k == 0)
+ printf("::: kx == %d, ky == %d\n", kx, ky);
+#endif
+
+ if (pos->step_xoffset < 0)
+ {
+ src_xx = 0;
+ dst_xx = pos->x + ABS(kx * pos->step_xoffset);
+ width = g->width;
+
+ if (dst_xx + width > door_rect->width)
+ width = door_rect->width - dst_xx;
+ }
+ else
+ {
+ src_xx = 0;
+ dst_xx = pos->x - kx * pos->step_xoffset;
+
+ if (dst_xx < 0)
+ {
+ src_xx = ABS(dst_xx);
+ dst_xx = 0;
+ }
+
+ width = g->width - src_xx;
+ }
+
+ if (pos->step_yoffset < 0)
+ {
+ src_yy = 0;
+ dst_yy = pos->y + ABS(ky * pos->step_yoffset);
+ height = g->height;
+
+ if (dst_yy + height > door_rect->height)
+ height = door_rect->height - dst_yy;
+ }
+ else
+ {
+ src_yy = 0;
+ dst_yy = pos->y - ky * pos->step_yoffset;
+
+ if (dst_yy < 0)
+ {
+ src_yy = ABS(dst_yy);
+ dst_yy = 0;
+ }
+
+ height = g->height - src_yy;
+ }
+
+#if 0
+ if (width < 0 || height < 0)
+ door_part_done[nr] = TRUE;
+#endif
+ }
+ else // DOOR_CLOSE
+ {
+ int step_factor = step_delay / max_step_delay;
+ int num_steps = (num_xsteps[nr] && num_ysteps[nr] ?
+ MIN(num_xsteps[nr], num_ysteps[nr]) :
+ num_xsteps[nr] ? num_xsteps[nr] :
+ num_ysteps[nr]);
+#if 1
+ int kx = num_steps - k / step_factor - 1;
+ int ky = num_steps - k / step_factor - 1;
+#else
+ int kx = num_xsteps[nr] - k;
+ int ky = num_ysteps[nr] - k;
+#endif
+