+#if 1
+ /* adjust graphics with 2nd tile for movement according to direction
+ (do this before correcting '-1' values to minimize calculations) */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ for (act = 0; act < NUM_ACTIONS; act++)
+ {
+ for (dir = 0; dir < NUM_DIRECTIONS; dir++)
+ {
+ int graphic = element_info[i].direction_graphic[act][dir];
+ int move_dir = (act == ACTION_FALLING ? MV_BIT_DOWN : dir);
+
+ if (act == ACTION_FALLING) /* special case */
+ graphic = element_info[i].graphic[act];
+
+ if (graphic != -1 &&
+ graphic_info[graphic].double_movement &&
+ graphic_info[graphic].swap_double_tiles != 0)
+ {
+ struct GraphicInfo *g = &graphic_info[graphic];
+ int src_x_front = g->src_x;
+ int src_y_front = g->src_y;
+ int src_x_back = g->src_x + g->offset2_x;
+ int src_y_back = g->src_y + g->offset2_y;
+ boolean frames_are_ordered_diagonally = (g->offset_x != 0 &&
+ g->offset_y != 0);
+ boolean front_is_left_or_upper = (src_x_front < src_x_back ||
+ src_y_front < src_y_back);
+#if 0
+ boolean second_tile_is_back =
+ ((move_dir == MV_BIT_LEFT && front_is_left_or_upper) ||
+ (move_dir == MV_BIT_UP && front_is_left_or_upper));
+ boolean second_tile_is_front =
+ ((move_dir == MV_BIT_RIGHT && front_is_left_or_upper) ||
+ (move_dir == MV_BIT_DOWN && front_is_left_or_upper));
+ boolean second_tile_should_be_front =
+ (g->second_tile_is_start == 0);
+ boolean second_tile_should_be_back =
+ (g->second_tile_is_start == 1);
+#endif
+ boolean swap_movement_tiles_always = (g->swap_double_tiles == 1);
+ boolean swap_movement_tiles_autodetected =
+ (!frames_are_ordered_diagonally &&
+ ((move_dir == MV_BIT_LEFT && !front_is_left_or_upper) ||
+ (move_dir == MV_BIT_UP && !front_is_left_or_upper) ||
+ (move_dir == MV_BIT_RIGHT && front_is_left_or_upper) ||
+ (move_dir == MV_BIT_DOWN && front_is_left_or_upper)));
+ Bitmap *dummy;
+
+#if 0
+ printf("::: CHECKING element %d ('%s'), '%s', dir %d [(%d -> %d, %d), %d => %d]\n",
+ i, element_info[i].token_name,
+ element_action_info[act].suffix, move_dir,
+ g->swap_double_tiles,
+ swap_movement_tiles_never,
+ swap_movement_tiles_always,
+ swap_movement_tiles_autodetected,
+ swap_movement_tiles);
+#endif
+
+ /* swap frontside and backside graphic tile coordinates, if needed */
+ if (swap_movement_tiles_always || swap_movement_tiles_autodetected)
+ {
+ /* get current (wrong) backside tile coordinates */
+ getGraphicSourceExt(graphic, 0, &dummy, &src_x_back, &src_y_back,
+ TRUE);
+
+ /* set frontside tile coordinates to backside tile coordinates */
+ g->src_x = src_x_back;
+ g->src_y = src_y_back;
+
+ /* invert tile offset to point to new backside tile coordinates */
+ g->offset2_x *= -1;
+ g->offset2_y *= -1;
+
+ /* do not swap front and backside tiles again after correction */
+ g->swap_double_tiles = 0;
+
+#if 0
+ printf(" CORRECTED\n");
+#endif
+ }
+ }
+ }
+ }
+ }
+#endif
+