+ XFreeGC(display, copy_clipmask_gc);
+
+#endif /* TARGET_X11_NATIVE */
+#endif /* TARGET_X11 */
+}
+
+void FreeTileClipmasks()
+{
+#if defined(TARGET_X11)
+ int i;
+
+ for(i=0; i<NUM_TILES; i++)
+ {
+ if (tile_clipmask[i] != None)
+ {
+ XFreePixmap(display, tile_clipmask[i]);
+ tile_clipmask[i] = None;
+ }
+ }
+
+ if (tile_clip_gc)
+ XFreeGC(display, tile_clip_gc);
+ tile_clip_gc = None;
+
+ for(i=0; i<NUM_BITMAPS; i++)
+ {
+ if (pix[i]->stored_clip_gc)
+ {
+ XFreeGC(display, pix[i]->stored_clip_gc);
+ pix[i]->stored_clip_gc = None;
+ }
+ }
+#endif /* TARGET_X11 */
+}
+
+void InitGfx()
+{
+ int i;
+
+ /* initialize some global variables */
+ global.frames_per_second = 0;
+ global.fps_slowdown = FALSE;
+ global.fps_slowdown_factor = 1;
+
+ /* initialize screen properties */
+ InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
+ REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
+ InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
+ InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
+ InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
+
+ /* create additional image buffers for double-buffering */
+ pix[PIX_DB_DOOR] = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
+ pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
+
+ pix[PIX_SMALLFONT] = LoadCustomImage(image_filename[PIX_SMALLFONT]);
+
+ InitFontInfo(NULL, NULL, pix[PIX_SMALLFONT]);
+
+ DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
+ DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
+#if defined(PLATFORM_MSDOS)
+ DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE);
+ rest(200);
+#endif
+ DrawInitText("Loading graphics:",120,FC_GREEN);
+
+ for(i=0; i<NUM_PICTURES; i++)
+ {
+ if (i != PIX_SMALLFONT)
+ {
+ DrawInitText(image_filename[i], 150, FC_YELLOW);
+
+ pix[i] = LoadCustomImage(image_filename[i]);
+ }
+ }
+
+ InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]);
+
+ InitTileClipmasks();