+void blitscreen(void)
+{
+ BlitScreenToBitmap_EM(window);
+}
+
+static void DrawLevelField_EM(int x, int y, int sx, int sy,
+ boolean draw_masked)
+{
+ int tile = Draw[y][x];
+ struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
+ int src_x = g->src_x + g->src_offset_x;
+ int src_y = g->src_y + g->src_offset_y;
+ int dst_x = sx * TILEX + g->dst_offset_x;
+ int dst_y = sy * TILEY + g->dst_offset_y;
+ int width = g->width;
+ int height = g->height;
+
+ if (draw_masked)
+ {
+ if (width > 0 && height > 0)
+ {
+ SetClipOrigin(g->bitmap, g->bitmap->stored_clip_gc,
+ dst_x - src_x, dst_y - src_y);
+ BlitBitmapMasked(g->bitmap, screenBitmap,
+ src_x, src_y, width, height, dst_x, dst_y);
+ }
+ }
+ else
+ {
+ if ((width != TILEX || height != TILEY) && !g->preserve_background)
+ ClearRectangle(screenBitmap, sx * TILEX, sy * TILEY, TILEX, TILEY);
+
+ if (width > 0 && height > 0)
+ BlitBitmap(g->bitmap, screenBitmap,
+ src_x, src_y, width, height, dst_x, dst_y);
+ }
+}
+
+static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy,
+ int crm, boolean draw_masked)
+{
+ int tile = Draw[y][x];
+ struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
+ unsigned int i;
+
+ if (crm == 0) /* no crumbled edges for this tile */
+ return;
+
+ for (i = 0; i < 4; i++)
+ {
+ if (crm & (1 << i))
+ {
+ int width, height, cx, cy;
+
+ if (i == 1 || i == 2)
+ {
+ width = g->crumbled_border_size;
+ height = TILEY;
+ cx = (i == 2 ? TILEX - g->crumbled_border_size : 0);
+ cy = 0;
+ }
+ else
+ {
+ width = TILEX;
+ height = g->crumbled_border_size;
+ cx = 0;
+ cy = (i == 3 ? TILEY - g->crumbled_border_size : 0);
+ }
+
+ if (width > 0 && height > 0)
+ {
+ int src_x = g->crumbled_src_x + cx;
+ int src_y = g->crumbled_src_y + cy;
+ int dst_x = sx * TILEX + cx;
+ int dst_y = sy * TILEY + cy;
+
+ if (draw_masked)
+ {
+ SetClipOrigin(g->crumbled_bitmap, g->crumbled_bitmap->stored_clip_gc,
+ dst_x - src_x, dst_y - src_y);
+ BlitBitmapMasked(g->crumbled_bitmap, screenBitmap,
+ src_x, src_y, width, height, dst_x, dst_y);
+ }
+ else
+ BlitBitmap(g->crumbled_bitmap, screenBitmap,
+ src_x, src_y, width, height, dst_x, dst_y);
+ }
+ }
+ }
+}
+
+static void DrawLevelPlayer_EM(int x1, int y1, int player_nr, int anim,
+ boolean draw_masked)
+{
+ struct GraphicInfo_EM *g = &graphic_info_em_player[player_nr][anim][frame];
+
+ int src_x = g->src_x, src_y = g->src_y;
+ int dst_x, dst_y;
+
+ 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);
+ }
+}