+ ply->joy_spin = !ply->joy_spin;
+
+ if (ply->joy_snap == 0) /* player wants to move */
+ {
+ boolean moved = FALSE;
+
+ if (ply->last_move_dir & MV_HORIZONTAL)
+ {
+ if (!(moved = player_digfield(ply, 0, dy)))
+ moved = player_digfield(ply, dx, 0);
+ }
+ else
+ {
+ if (!(moved = player_digfield(ply, dx, 0)))
+ moved = player_digfield(ply, 0, dy);
+ }
+
+ if (moved)
+ {
+ if (oldx != ply->x)
+ ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT);
+ else if (oldy != ply->y)
+ ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN);
+ }
+ }
+ else /* player wants to snap */
+ {
+ player_digfield(ply, dx, dy);
+ }
+}
+
+static boolean player_digfield(struct PLAYER *ply, int dx, int dy)
+{
+ int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2);
+ unsigned int oldx = ply->x;
+ unsigned int oldy = ply->y;
+ register unsigned int x = oldx + dx;
+ register unsigned int y = oldy + dy;
+ boolean result = TRUE;
+
+ if (!dx && !dy) /* no direction specified */
+ return FALSE;
+
+ if (dx && dy && ply->joy_snap) /* more than one direction specified */
+ return FALSE;