+ if (draw_masked)
+ {
+ /* draw the player to current location */
+ dst_x = x1;
+ dst_y = y1;
+ SetClipOrigin(g->bitmap, g->bitmap->stored_clip_gc,
+ dst_x - src_x, dst_y - src_y);
+ BlitBitmapMasked(g->bitmap, screenBitmap,
+ src_x, src_y, TILEX, TILEY, dst_x, dst_y);
+
+ /* draw the player to opposite wrap-around column */
+ dst_x = x1 - MAX_BUF_XSIZE * TILEX;
+ dst_y = y1;
+ SetClipOrigin(g->bitmap, g->bitmap->stored_clip_gc,
+ dst_x - src_x, dst_y - src_y);
+ BlitBitmapMasked(g->bitmap, screenBitmap,
+ g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
+
+ /* draw the player to opposite wrap-around row */
+ dst_x = x1;
+ dst_y = y1 - MAX_BUF_YSIZE * TILEY;
+ SetClipOrigin(g->bitmap, g->bitmap->stored_clip_gc,
+ dst_x - src_x, dst_y - src_y);
+ BlitBitmapMasked(g->bitmap, screenBitmap,
+ g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
+ }
+ else
+ {
+ /* draw the player to current location */
+ dst_x = x1;
+ dst_y = y1;
+ BlitBitmap(g->bitmap, screenBitmap,
+ g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
+
+ /* draw the player to opposite wrap-around column */
+ dst_x = x1 - MAX_BUF_XSIZE * TILEX;
+ dst_y = y1;
+ BlitBitmap(g->bitmap, screenBitmap,
+ g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
+
+ /* draw the player to opposite wrap-around row */
+ dst_x = x1;
+ dst_y = y1 - MAX_BUF_YSIZE * TILEY;
+ BlitBitmap(g->bitmap, screenBitmap,
+ g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
+ }
+}
+
+/* draw differences between game tiles and screen tiles
+ *
+ * implicitly handles scrolling and restoring background under the sprites
+ */
+
+static void animscreen(void)
+{
+ int x, y, i;
+ int left = screen_x / TILEX;
+ int top = screen_y / TILEY;
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+
+ if (!game.use_native_emc_graphics_engine)
+ for (y = 2; y < EM_MAX_CAVE_HEIGHT - 2; y++)
+ for (x = 2; x < EM_MAX_CAVE_WIDTH - 2; x++)
+ SetGfxAnimation_EM(&graphic_info_em_object[Draw[y][x]][frame],
+ Draw[y][x], 7 - frame, x - 2, y - 2);
+
+ for (y = top; y < top + MAX_BUF_YSIZE; y++)
+ {
+ for (x = left; x < left + MAX_BUF_XSIZE; x++)
+ {
+ int sx = x % MAX_BUF_XSIZE;
+ int sy = y % MAX_BUF_YSIZE;
+ int tile = Draw[y][x];
+ struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
+ int obj = g->unique_identifier;
+ int crm = 0;
+ boolean redraw_screen_tile = FALSE;
+
+ /* re-calculate crumbled state of this tile */
+ if (g->has_crumbled_graphics)
+ {
+ for (i = 0; i < 4; i++)
+ {
+ int xx = x + xy[i][0];
+ int yy = y + xy[i][1];
+ int tile_next;