rnd-20000720-1-src
authorHolger Schemel <info@artsoft.org>
Thu, 20 Jul 2000 22:49:49 +0000 (00:49 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:34:40 +0000 (10:34 +0200)
21 files changed:
src/Makefile
src/buttons.c
src/buttons.h
src/cartoons.c
src/editor.c
src/events.c
src/events.h
src/game.c
src/init.c
src/main.c
src/main.h
src/misc.c
src/misc.h
src/screens.c
src/sdl.c
src/sdl.h
src/system.c [new file with mode: 0644]
src/system.h [new file with mode: 0644]
src/tape.c
src/tools.c
src/tools.h

index 044e136ddff7e86355652ad288bee9477a1de087..ef2154bac1779cc72c3fb11dd9a74cea2041eab3 100644 (file)
@@ -90,6 +90,7 @@ SRCS =        main.c          \
        network.c       \
        netserv.c       \
        msdos.c         \
+       system.c        \
        sdl.c
 
 OBJS = main.o          \
@@ -112,6 +113,7 @@ OBJS =      main.o          \
        network.o       \
        netserv.o       \
        msdos.o         \
+       system.o        \
        sdl.o
 
 all:   $(PROGNAME)
index 4844f2fe86ae4eff829f110524a1ebbb47ef1223..9f9a78df6e4cc7f7dd440b0f8783947286bf34c0 100644 (file)
@@ -138,13 +138,13 @@ void DrawVideoDisplay(unsigned long state, unsigned long value)
   {
     int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
 
-    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-             cx + VIDEO_REC_LABEL_XPOS,
-             cy + VIDEO_REC_LABEL_YPOS,
-             VIDEO_PBEND_LABEL_XSIZE,
-             VIDEO_PBEND_LABEL_YSIZE,
-             VX + VIDEO_REC_LABEL_XPOS,
-             VY + VIDEO_REC_LABEL_YPOS);
+    BlitBitmap(pix[PIX_DOOR], drawto,
+              cx + VIDEO_REC_LABEL_XPOS,
+              cy + VIDEO_REC_LABEL_YPOS,
+              VIDEO_PBEND_LABEL_XSIZE,
+              VIDEO_PBEND_LABEL_YSIZE,
+              VX + VIDEO_REC_LABEL_XPOS,
+              VY + VIDEO_REC_LABEL_YPOS);
   }
 
   for(i=0;i<10;i++)
@@ -159,21 +159,21 @@ void DrawVideoDisplay(unsigned long state, unsigned long value)
        cx = DOOR_GFX_PAGEX3;   /* i gerade => STATE_OFF / PRESS_ON */
 
       if (video_pos[pos][part_label][0] && value != VIDEO_DISPLAY_SYMBOL_ONLY)
-       XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-                 cx + video_pos[pos][part_label][xpos],
-                 cy + video_pos[pos][part_label][ypos],
-                 video_pos[pos][part_label][xsize],
-                 video_pos[pos][part_label][ysize],
-                 VX + video_pos[pos][part_label][xpos],
-                 VY + video_pos[pos][part_label][ypos]);
+       BlitBitmap(pix[PIX_DOOR], drawto,
+                  cx + video_pos[pos][part_label][xpos],
+                  cy + video_pos[pos][part_label][ypos],
+                  video_pos[pos][part_label][xsize],
+                  video_pos[pos][part_label][ysize],
+                  VX + video_pos[pos][part_label][xpos],
+                  VY + video_pos[pos][part_label][ypos]);
       if (video_pos[pos][part_symbol][0] && value != VIDEO_DISPLAY_LABEL_ONLY)
-       XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-                 cx + video_pos[pos][part_symbol][xpos],
-                 cy + video_pos[pos][part_symbol][ypos],
-                 video_pos[pos][part_symbol][xsize],
-                 video_pos[pos][part_symbol][ysize],
-                 VX + video_pos[pos][part_symbol][xpos],
-                 VY + video_pos[pos][part_symbol][ypos]);
+       BlitBitmap(pix[PIX_DOOR], drawto,
+                  cx + video_pos[pos][part_symbol][xpos],
+                  cy + video_pos[pos][part_symbol][ypos],
+                  video_pos[pos][part_symbol][xsize],
+                  video_pos[pos][part_symbol][ysize],
+                  VX + video_pos[pos][part_symbol][xpos],
+                  VY + video_pos[pos][part_symbol][ypos]);
     }
   }
 
@@ -181,26 +181,26 @@ void DrawVideoDisplay(unsigned long state, unsigned long value)
   {
     int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
 
-    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-             cx + VIDEO_PLAY_SYMBOL_XPOS,
-             cy + VIDEO_PLAY_SYMBOL_YPOS,
-             VIDEO_PLAY_SYMBOL_XSIZE - 2,
-             VIDEO_PLAY_SYMBOL_YSIZE,
-             VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
-             VY + VIDEO_PLAY_SYMBOL_YPOS);
+    BlitBitmap(pix[PIX_DOOR], drawto,
+              cx + VIDEO_PLAY_SYMBOL_XPOS,
+              cy + VIDEO_PLAY_SYMBOL_YPOS,
+              VIDEO_PLAY_SYMBOL_XSIZE - 2,
+              VIDEO_PLAY_SYMBOL_YSIZE,
+              VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
+              VY + VIDEO_PLAY_SYMBOL_YPOS);
   }
 
   if (state & VIDEO_STATE_PBEND_ON)
   {
     int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
 
-    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-             cx + VIDEO_PBEND_LABEL_XPOS,
-             cy + VIDEO_PBEND_LABEL_YPOS,
-             VIDEO_PBEND_LABEL_XSIZE,
-             VIDEO_PBEND_LABEL_YSIZE,
-             VX + VIDEO_REC_LABEL_XPOS,
-             VY + VIDEO_REC_LABEL_YPOS);
+    BlitBitmap(pix[PIX_DOOR], drawto,
+              cx + VIDEO_PBEND_LABEL_XPOS,
+              cy + VIDEO_PBEND_LABEL_YPOS,
+              VIDEO_PBEND_LABEL_XSIZE,
+              VIDEO_PBEND_LABEL_YSIZE,
+              VX + VIDEO_REC_LABEL_XPOS,
+              VY + VIDEO_REC_LABEL_YPOS);
   }
 
   if (state & VIDEO_STATE_DATE_ON)
@@ -238,13 +238,13 @@ void DrawVideoDisplay(unsigned long state, unsigned long value)
 
 void DrawCompleteVideoDisplay()
 {
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           DOOR_GFX_PAGEX3,DOOR_GFX_PAGEY2, VXSIZE,VYSIZE, VX,VY);
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           DOOR_GFX_PAGEX4+VIDEO_CONTROL_XPOS,
-           DOOR_GFX_PAGEY2+VIDEO_CONTROL_YPOS,
-           VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
-           VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
+  BlitBitmap(pix[PIX_DOOR], drawto,
+            DOOR_GFX_PAGEX3,DOOR_GFX_PAGEY2, VXSIZE,VYSIZE, VX,VY);
+  BlitBitmap(pix[PIX_DOOR], drawto,
+            DOOR_GFX_PAGEX4+VIDEO_CONTROL_XPOS,
+            DOOR_GFX_PAGEY2+VIDEO_CONTROL_YPOS,
+            VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
+            VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
 
   DrawVideoDisplay(VIDEO_ALL_OFF,0);
   if (tape.date && tape.length)
@@ -253,8 +253,8 @@ void DrawCompleteVideoDisplay()
     DrawVideoDisplay(VIDEO_STATE_TIME_ON,tape.length_seconds);
   }
 
-  XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc,
-           VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
+  BlitBitmap(drawto, pix[PIX_DB_DOOR],
+            VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
 }
 
 
@@ -345,14 +345,14 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
     case GD_TYPE_NORMAL_BUTTON:
     case GD_TYPE_CHECK_BUTTON:
     case GD_TYPE_RADIO_BUTTON:
-      XCopyArea(display, gd->pixmap, drawto, gc,
-               gd->x, gd->y, gi->width, gi->height, gi->x, gi->y);
-      if (gi->deco.design.pixmap)
-       XCopyArea(display, gi->deco.design.pixmap, drawto, gc,
-                 gi->deco.design.x, gi->deco.design.y,
-                 gi->deco.width, gi->deco.height,
-                 gi->x + gi->deco.x + (pressed ? gi->deco.xshift : 0),
-                 gi->y + gi->deco.y + (pressed ? gi->deco.yshift : 0));
+      BlitBitmap(gd->bitmap, drawto,
+                gd->x, gd->y, gi->width, gi->height, gi->x, gi->y);
+      if (gi->deco.design.bitmap)
+       BlitBitmap(gi->deco.design.bitmap, drawto,
+                  gi->deco.design.x, gi->deco.design.y,
+                  gi->deco.width, gi->deco.height,
+                  gi->x + gi->deco.x + (pressed ? gi->deco.xshift : 0),
+                  gi->y + gi->deco.y + (pressed ? gi->deco.yshift : 0));
       break;
 
     case GD_TYPE_TEXTINPUT_ALPHANUMERIC:
@@ -369,19 +369,19 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
        strcat(text, " ");
 
        /* left part of gadget */
-       XCopyArea(display, gd->pixmap, drawto, gc,
-                 gd->x, gd->y, border, gi->height, gi->x, gi->y);
+       BlitBitmap(gd->bitmap, drawto,
+                  gd->x, gd->y, border, gi->height, gi->x, gi->y);
 
        /* middle part of gadget */
        for (i=0; i<=gi->text.size; i++)
-         XCopyArea(display, gd->pixmap, drawto, gc,
-                   gd->x + border, gd->y, font_width, gi->height,
-                   gi->x + border + i * font_width, gi->y);
+         BlitBitmap(gd->bitmap, drawto,
+                    gd->x + border, gd->y, font_width, gi->height,
+                    gi->x + border + i * font_width, gi->y);
 
        /* right part of gadget */
-       XCopyArea(display, gd->pixmap, drawto, gc,
-                 gd->x + gi->border.width - border, gd->y,
-                 border, gi->height, gi->x + gi->width - border, gi->y);
+       BlitBitmap(gd->bitmap, drawto,
+                  gd->x + gi->border.width - border, gd->y,
+                  border, gi->height, gi->x + gi->width - border, gi->y);
 
        /* gadget text value */
        DrawText(gi->x + border, gi->y + border, text, FS_SMALL, font_type);
@@ -411,34 +411,33 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
        int step_size_remain = size_body - num_steps * design_body;
 
        /* clear scrollbar area */
-       XFillRectangle(display, backbuffer, gc,
-                      gi->x, gi->y, gi->width, gi->height);
+       ClearRectangle(backbuffer, gi->x, gi->y, gi->width, gi->height);
 
        /* upper part of gadget */
-       XCopyArea(display, gd->pixmap, drawto, gc,
-                 gd->x, gd->y,
-                 gi->width, gi->border.size,
-                 xpos, ypos);
+       BlitBitmap(gd->bitmap, drawto,
+                  gd->x, gd->y,
+                  gi->width, gi->border.size,
+                  xpos, ypos);
 
        /* middle part of gadget */
        for (i=0; i<num_steps; i++)
-         XCopyArea(display, gd->pixmap, drawto, gc,
-                   gd->x, gd->y + gi->border.size,
-                   gi->width, design_body,
-                   xpos, ypos + gi->border.size + i * design_body);
+         BlitBitmap(gd->bitmap, drawto,
+                    gd->x, gd->y + gi->border.size,
+                    gi->width, design_body,
+                    xpos, ypos + gi->border.size + i * design_body);
 
        /* remaining middle part of gadget */
        if (step_size_remain > 0)
-         XCopyArea(display, gd->pixmap, drawto, gc,
-                   gd->x,  gd->y + gi->border.size,
-                   gi->width, step_size_remain,
-                   xpos, ypos + gi->border.size + num_steps * design_body);
+         BlitBitmap(gd->bitmap, drawto,
+                    gd->x,  gd->y + gi->border.size,
+                    gi->width, step_size_remain,
+                    xpos, ypos + gi->border.size + num_steps * design_body);
 
        /* lower part of gadget */
-       XCopyArea(display, gd->pixmap, drawto, gc,
-                 gd->x, gd->y + design_full - gi->border.size,
-                 gi->width, gi->border.size,
-                 xpos, ypos + size_full - gi->border.size);
+       BlitBitmap(gd->bitmap, drawto,
+                  gd->x, gd->y + design_full - gi->border.size,
+                  gi->width, gi->border.size,
+                  xpos, ypos + size_full - gi->border.size);
       }
       break;
 
@@ -455,34 +454,33 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
        int step_size_remain = size_body - num_steps * design_body;
 
        /* clear scrollbar area */
-       XFillRectangle(display, backbuffer, gc,
-                      gi->x, gi->y, gi->width, gi->height);
+       ClearRectangle(backbuffer, gi->x, gi->y, gi->width, gi->height);
 
        /* left part of gadget */
-       XCopyArea(display, gd->pixmap, drawto, gc,
-                 gd->x, gd->y,
-                 gi->border.size, gi->height,
-                 xpos, ypos);
+       BlitBitmap(gd->bitmap, drawto,
+                  gd->x, gd->y,
+                  gi->border.size, gi->height,
+                  xpos, ypos);
 
        /* middle part of gadget */
        for (i=0; i<num_steps; i++)
-         XCopyArea(display, gd->pixmap, drawto, gc,
-                   gd->x + gi->border.size, gd->y,
-                   design_body, gi->height,
-                   xpos + gi->border.size + i * design_body, ypos);
+         BlitBitmap(gd->bitmap, drawto,
+                    gd->x + gi->border.size, gd->y,
+                    design_body, gi->height,
+                    xpos + gi->border.size + i * design_body, ypos);
 
        /* remaining middle part of gadget */
        if (step_size_remain > 0)
-         XCopyArea(display, gd->pixmap, drawto, gc,
-                   gd->x + gi->border.size, gd->y,
-                   step_size_remain, gi->height,
-                   xpos + gi->border.size + num_steps * design_body, ypos);
+         BlitBitmap(gd->bitmap, drawto,
+                    gd->x + gi->border.size, gd->y,
+                    step_size_remain, gi->height,
+                    xpos + gi->border.size + num_steps * design_body, ypos);
 
        /* right part of gadget */
-       XCopyArea(display, gd->pixmap, drawto, gc,
-                 gd->x + design_full - gi->border.size, gd->y,
-                 gi->border.size, gi->height,
-                 xpos + size_full - gi->border.size, ypos);
+       BlitBitmap(gd->bitmap, drawto,
+                  gd->x + design_full - gi->border.size, gd->y,
+                  gi->border.size, gi->height,
+                  xpos + size_full - gi->border.size, ypos);
       }
       break;
 
@@ -491,8 +489,8 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
   }
 
   if (direct)
-    XCopyArea(display, drawto, window, gc,
-             gi->x, gi->y, gi->width, gi->height, gi->x, gi->y);
+    BlitBitmap(drawto, window,
+              gi->x, gi->y, gi->width, gi->height, gi->x, gi->y);
   else
     redraw_mask |= (gi->x < SX + SXSIZE ? REDRAW_FIELD :
                    gi->y < DY + DYSIZE ? REDRAW_DOOR_1 :
@@ -608,25 +606,25 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap)
        break;
 
       case GDI_DESIGN_UNPRESSED:
-       gi->design[GD_BUTTON_UNPRESSED].pixmap = va_arg(ap, Pixmap);
+       gi->design[GD_BUTTON_UNPRESSED].bitmap = va_arg(ap, Bitmap);
        gi->design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int);
        gi->design[GD_BUTTON_UNPRESSED].y = va_arg(ap, int);
        break;
 
       case GDI_DESIGN_PRESSED:
-       gi->design[GD_BUTTON_PRESSED].pixmap = va_arg(ap, Pixmap);
+       gi->design[GD_BUTTON_PRESSED].bitmap = va_arg(ap, Bitmap);
        gi->design[GD_BUTTON_PRESSED].x = va_arg(ap, int);
        gi->design[GD_BUTTON_PRESSED].y = va_arg(ap, int);
        break;
 
       case GDI_ALT_DESIGN_UNPRESSED:
-       gi->alt_design[GD_BUTTON_UNPRESSED].pixmap= va_arg(ap, Pixmap);
+       gi->alt_design[GD_BUTTON_UNPRESSED].bitmap= va_arg(ap, Bitmap);
        gi->alt_design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int);
        gi->alt_design[GD_BUTTON_UNPRESSED].y = va_arg(ap, int);
        break;
 
       case GDI_ALT_DESIGN_PRESSED:
-       gi->alt_design[GD_BUTTON_PRESSED].pixmap = va_arg(ap, Pixmap);
+       gi->alt_design[GD_BUTTON_PRESSED].bitmap = va_arg(ap, Bitmap);
        gi->alt_design[GD_BUTTON_PRESSED].x = va_arg(ap, int);
        gi->alt_design[GD_BUTTON_PRESSED].y = va_arg(ap, int);
        break;
@@ -640,7 +638,7 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap)
        break;
 
       case GDI_DECORATION_DESIGN:
-       gi->deco.design.pixmap = va_arg(ap, Pixmap);
+       gi->deco.design.bitmap = va_arg(ap, Bitmap);
        gi->deco.design.x = va_arg(ap, int);
        gi->deco.design.y = va_arg(ap, int);
        break;
@@ -731,9 +729,9 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap)
 
   /* check if gadget complete */
   if (gi->type != GD_TYPE_DRAWING_AREA &&
-      (!gi->design[GD_BUTTON_UNPRESSED].pixmap ||
-       !gi->design[GD_BUTTON_PRESSED].pixmap))
-    Error(ERR_EXIT, "gadget incomplete (missing Pixmap)");
+      (!gi->design[GD_BUTTON_UNPRESSED].bitmap ||
+       !gi->design[GD_BUTTON_PRESSED].bitmap))
+    Error(ERR_EXIT, "gadget incomplete (missing Bitmap)");
 
   /* adjust gadget values in relation to other gadget values */
 
index f3d93c89e94584437d936ecd9d9379a20e779273..85b38b533047d4524881b991c917347bb4262c8f 100644 (file)
@@ -167,8 +167,8 @@ struct GadgetBorder
 
 struct GadgetDesign
 {
-  Pixmap pixmap;                       /* Pixmap with gadget surface */
-  int x, y;                            /* position of rectangle in Pixmap */
+  Bitmap bitmap;                       /* Bitmap with gadget surface */
+  int x, y;                            /* position of rectangle in Bitmap */
 };
 
 struct GadgetDecoration
index 07394acdb9538591a3cfb0a7c801b42398b7cd23..3290331e5a74fcc1a46705cbc2829365e8f1d42a 100644 (file)
@@ -18,7 +18,7 @@
 
 static void HandleAnimation(int);
 static boolean AnimateToon(int, boolean);
-static void DrawAnim(Pixmap, GC, int, int, int, int, int, int, int, int);
+static void DrawAnim(Bitmap, GC, int, int, int, int, int, int, int, int);
 
 struct AnimInfo
 {
@@ -145,9 +145,7 @@ void HandleAnimation(int mode)
         fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
         fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
 
-       XCopyArea(display,fieldbuffer,backbuffer,gc,
-                 fx,fy, SXSIZE,SYSIZE,
-                 SX,SY);
+       BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY);
       }
 
       return;
@@ -398,8 +396,9 @@ boolean AnimateToon(int toon_nr, boolean restart)
     },
   };
   struct AnimInfo *anim = &toon[toon_nr];
-  Pixmap anim_pixmap = (toon_nr < 6 ? pix[PIX_TOONS] : pix[PIX_HEROES]);
-  GC anim_clip_gc = (toon_nr < 6 ? clip_gc[PIX_TOONS] : clip_gc[PIX_HEROES]);
+  int anim_bitmap_nr = (toon_nr < 6 ? PIX_TOONS : PIX_HEROES);
+  Bitmap anim_bitmap = pix_masked[anim_bitmap_nr];
+  GC anim_clip_gc = clip_gc[anim_bitmap_nr];
 
   if (restart)
   {
@@ -465,7 +464,7 @@ boolean AnimateToon(int toon_nr, boolean restart)
     if ((game_status == HELPSCREEN ||
         (game_status == MAINMENU && redraw_mask & REDRAW_MICROLEVEL))
        && !restart)
-      DrawAnim(anim_pixmap, anim_clip_gc,
+      DrawAnim(anim_bitmap, anim_clip_gc,
               src_x + cut_x, src_y + cut_y, width, height,
               REAL_SX + dest_x, REAL_SY + dest_y, pad_x, pad_y);
 
@@ -509,7 +508,7 @@ boolean AnimateToon(int toon_nr, boolean restart)
   else if (pos_y>FULL_SYSIZE-anim->height)
     height -= (pos_y - (FULL_SYSIZE-anim->height));
 
-  DrawAnim(anim_pixmap,anim_clip_gc,
+  DrawAnim(anim_bitmap,anim_clip_gc,
           src_x+cut_x,src_y+cut_y, width,height,
           REAL_SX+dest_x,REAL_SY+dest_y, pad_x,pad_y);
 
@@ -531,7 +530,7 @@ boolean AnimateToon(int toon_nr, boolean restart)
   return(FALSE);
 }
 
-void DrawAnim(Pixmap toon_pixmap, GC toon_clip_gc,
+void DrawAnim(Bitmap toon_bitmap, GC toon_clip_gc,
              int src_x, int src_y, int width, int height,
              int dest_x, int dest_y, int pad_x, int pad_y)
 {
@@ -539,27 +538,26 @@ void DrawAnim(Pixmap toon_pixmap, GC toon_clip_gc,
 
 #if 1
   /* special method to avoid flickering interference with BackToFront() */
-  XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc,dest_x-pad_x,dest_y-pad_y,
-           width+2*pad_x,height+2*pad_y, buf_x,buf_y);
-  XSetClipOrigin(display,toon_clip_gc,dest_x-src_x,dest_y-src_y);
-  XCopyArea(display,toon_pixmap,backbuffer,toon_clip_gc,
-           src_x,src_y, width,height, dest_x,dest_y);
-  XCopyArea(display,backbuffer,window,gc, dest_x-pad_x,dest_y-pad_y,
-           width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y);
+  BlitBitmap(backbuffer, pix[PIX_DB_DOOR], dest_x-pad_x, dest_y-pad_y,
+            width+2*pad_x, height+2*pad_y, buf_x, buf_y);
+  SetClipOrigin(toon_clip_gc, dest_x-src_x, dest_y-src_y);
+  BlitBitmapMasked(toon_bitmap, backbuffer,
+                  src_x, src_y, width, height, dest_x, dest_y);
+  BlitBitmap(backbuffer, window, dest_x-pad_x, dest_y-pad_y,
+            width+2*pad_x, height+2*pad_y, dest_x-pad_x, dest_y-pad_y);
   BackToFront();
-  XCopyArea(display,pix[PIX_DB_DOOR],backbuffer,gc, buf_x,buf_y,
-           width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y);
+  BlitBitmap(pix[PIX_DB_DOOR], backbuffer, buf_x, buf_y,
+           width+2*pad_x, height+2*pad_y, dest_x-pad_x, dest_y-pad_y);
 #else
   /* normal method, causing flickering interference with BackToFront() */
-  XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc,dest_x-pad_x,dest_y-pad_y,
-           width+2*pad_x,height+2*pad_y, buf_x,buf_y);
-  XSetClipOrigin(display,toon_clip_gc,
-                buf_x-src_x+pad_x,buf_y-src_y+pad_y);
-  XCopyArea(display,toon_pixmap,pix[PIX_DB_DOOR],toon_clip_gc,
-           src_x,src_y, width,height, buf_x+pad_x,buf_y+pad_y);
-  XCopyArea(display,pix[PIX_DB_DOOR],window,gc, buf_x,buf_y,
-           width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y);
+  BlitBitmap(backbuffer, pix[PIX_DB_DOOR], dest_x-pad_x, dest_y-pad_y,
+            width+2*pad_x, height+2*pad_y, buf_x, buf_y);
+  SetClipOrigin(toon_clip_gc, buf_x-src_x+pad_x, buf_y-src_y+pad_y);
+  BlitBitmapMasked(toon_bitmap, pix[PIX_DB_DOOR],
+                  src_x, src_y, width, height, buf_x+pad_x, buf_y+pad_y);
+  BlitBitmap(pix[PIX_DB_DOOR], window, buf_x, buf_y,
+            width+2*pad_x, height+2*pad_y, dest_x-pad_x, dest_y-pad_y);
 #endif
 
-  XFlush(display);
+  FlushDisplay();
 }
index 91e10699148bb92ef47d048fe84fa2f129c7347a..618c272f9971f798162640b3913d03fd89a7ade4 100644 (file)
@@ -1267,13 +1267,13 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll)
   int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
   int dy = (scroll == ED_SCROLL_UP   ? -1 : scroll == ED_SCROLL_DOWN  ? 1 : 0);
 
-  XCopyArea(display, drawto, drawto, gc,
-           SX + (dx == -1 ? MINI_TILEX : 0),
-           SY + (dy == -1 ? MINI_TILEY : 0),
-           (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
-           (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
-           SX + (dx == +1 ? MINI_TILEX : 0),
-           SY + (dy == +1 ? MINI_TILEY : 0));
+  BlitBitmap(drawto, drawto,
+            SX + (dx == -1 ? MINI_TILEX : 0),
+            SY + (dy == -1 ? MINI_TILEY : 0),
+            (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
+            (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
+            SX + (dx == +1 ? MINI_TILEX : 0),
+            SY + (dy == +1 ? MINI_TILEY : 0));
   if (dx)
   {
     x = (dx == 1 ? 0 : ed_fieldx - 1);
@@ -1293,7 +1293,7 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll)
 
 static void CreateControlButtons()
 {
-  Pixmap gd_pixmap = pix[PIX_DOOR];
+  Bitmap gd_bitmap = pix[PIX_DOOR];
   struct GadgetInfo *gi;
   unsigned long event_mask;
   int i;
@@ -1377,10 +1377,10 @@ static void CreateControlButtons()
                      GDI_STATE, GD_BUTTON_UNPRESSED,
                      GDI_RADIO_NR, radio_button_nr,
                      GDI_CHECKED, checked,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y1,
-                     GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y2,
-                     GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
+                     GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
+                     GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleControlButtons,
                      GDI_END);
@@ -1436,8 +1436,8 @@ static void CreateControlButtons()
                      GDI_HEIGHT, height,
                      GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleControlButtons,
                      GDI_END);
@@ -1451,7 +1451,7 @@ static void CreateControlButtons()
   /* create buttons for element list */
   for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
   {
-    Pixmap deco_pixmap;
+    Bitmap deco_bitmap;
     int deco_x, deco_y, deco_xpos, deco_ypos;
     int gd_xoffset, gd_yoffset;
     int gd_x1, gd_x2, gd_y;
@@ -1469,7 +1469,7 @@ static void CreateControlButtons()
     gd_y  = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
 
     getMiniGraphicSource(el2gfx(editor_element[i]),
-                        &deco_pixmap, &deco_x, &deco_y);
+                        &deco_bitmap, &deco_x, &deco_y);
     deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2;
     deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2;
 
@@ -1482,9 +1482,9 @@ static void CreateControlButtons()
                      GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
                      GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
-                     GDI_DECORATION_DESIGN, deco_pixmap, deco_x, deco_y,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
+                     GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
                      GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
                      GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
                      GDI_DECORATION_SHIFTING, 1, 1,
@@ -1511,7 +1511,7 @@ static void CreateCounterButtons()
 
     for (j=0; j<2; j++)
     {
-      Pixmap gd_pixmap = pix[PIX_DOOR];
+      Bitmap gd_bitmap = pix[PIX_DOOR];
       struct GadgetInfo *gi;
       int id = (j == 0 ?
                counterbutton_info[i].gadget_id_down :
@@ -1564,8 +1564,8 @@ static void CreateCounterButtons()
                        GDI_HEIGHT, y_size,
                        GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
                        GDI_STATE, GD_BUTTON_UNPRESSED,
-                       GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
-                       GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
+                       GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
+                       GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
                        GDI_EVENT_MASK, event_mask,
                        GDI_CALLBACK_ACTION, HandleCounterButtons,
                        GDI_END);
@@ -1612,8 +1612,8 @@ static void CreateCounterButtons()
                          GDI_NUMBER_MAX, counterbutton_info[i].max_value,
                          GDI_TEXT_SIZE, 3,
                          GDI_TEXT_FONT, font_type,
-                         GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y,
-                         GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y,
+                         GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
+                         GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
                          GDI_BORDER_SIZE, ED_BORDER_SIZE,
                          GDI_TEXTINPUT_DESIGN_WIDTH, gd_width,
                          GDI_EVENT_MASK, event_mask,
@@ -1731,7 +1731,7 @@ static void CreateTextInputGadgets()
 
   for (i=0; i<ED_NUM_TEXTINPUT; i++)
   {
-    Pixmap gd_pixmap = pix[PIX_DOOR];
+    Bitmap gd_bitmap = pix[PIX_DOOR];
     int gd_x, gd_y;
     struct GadgetInfo *gi;
     unsigned long event_mask;
@@ -1755,8 +1755,8 @@ static void CreateTextInputGadgets()
                      GDI_TEXT_VALUE, textinput_info[i].value,
                      GDI_TEXT_SIZE, textinput_info[i].size,
                      GDI_TEXT_FONT, FC_YELLOW,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
                      GDI_BORDER_SIZE, ED_BORDER_SIZE,
                      GDI_TEXTINPUT_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
                      GDI_EVENT_MASK, event_mask,
@@ -1777,7 +1777,7 @@ static void CreateScrollbarGadgets()
   for (i=0; i<ED_NUM_SCROLLBARS; i++)
   {
     int id = scrollbar_info[i].gadget_id;
-    Pixmap gd_pixmap = pix[PIX_DOOR];
+    Bitmap gd_bitmap = pix[PIX_DOOR];
     int gd_x1, gd_x2, gd_y1, gd_y2;
     struct GadgetInfo *gi;
     int items_max, items_visible, item_position;
@@ -1825,8 +1825,8 @@ static void CreateScrollbarGadgets()
                      GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
                      GDI_SCROLLBAR_ITEM_POSITION, item_position,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
                      GDI_BORDER_SIZE, ED_BORDER_SIZE,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleControlButtons,
@@ -1841,7 +1841,7 @@ static void CreateScrollbarGadgets()
 
 static void CreateCheckbuttonGadgets()
 {
-  Pixmap gd_pixmap = pix[PIX_DOOR];
+  Bitmap gd_bitmap = pix[PIX_DOOR];
   struct GadgetInfo *gi;
   unsigned long event_mask;
   int gd_x1, gd_x2, gd_x3, gd_x4, gd_y;
@@ -1873,10 +1873,10 @@ static void CreateCheckbuttonGadgets()
                      GDI_TYPE, GD_TYPE_RADIO_BUTTON,
                      GDI_RADIO_NR, radiobutton_info[i].radio_button_nr,
                      GDI_CHECKED, checked,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
-                     GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x3, gd_y,
-                     GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x4, gd_y,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
+                     GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
+                     GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleRadiobuttons,
                      GDI_END);
@@ -1905,10 +1905,10 @@ static void CreateCheckbuttonGadgets()
                      GDI_HEIGHT, ED_CHECKBUTTON_YSIZE,
                      GDI_TYPE, GD_TYPE_CHECK_BUTTON,
                      GDI_CHECKED, *checkbutton_info[i].value,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
-                     GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x3, gd_y,
-                     GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x4, gd_y,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
+                     GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y,
+                     GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleCheckbuttons,
                      GDI_END);
@@ -2109,8 +2109,8 @@ void DrawLevelEd()
   }
 
   /* copy default editor door content to main double buffer */
-  XCopyArea(display, pix[PIX_DOOR], drawto, gc,
-           DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
+  BlitBitmap(pix[PIX_DOOR], drawto,
+            DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
 
   /* draw mouse button brush elements */
   DrawMiniGraphicExt(drawto, gc,
@@ -2127,18 +2127,16 @@ void DrawLevelEd()
   DrawSpecialEditorDoor();
 
   /* draw new control window */
-  XCopyArea(display, pix[PIX_DOOR], drawto, gc,
-           DOOR_GFX_PAGEX8, 236,
-           EXSIZE, EYSIZE,
-           EX, EY);
+  BlitBitmap(pix[PIX_DOOR], drawto,
+            DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
 
   redraw_mask |= REDRAW_ALL;
 
   MapControlButtons();
 
   /* copy actual editor door content to door double buffer for OpenDoor() */
-  XCopyArea(display, drawto, pix[PIX_DB_DOOR], gc,
-           DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+  BlitBitmap(drawto, pix[PIX_DB_DOOR],
+            DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
 
   DrawEditModeWindow();
 
@@ -2343,14 +2341,14 @@ static void DrawRandomPlacementBackgroundArea()
     for (x=0; x<2; x++)
       DrawMiniElement(area_x + x, area_y + y, EL_ERDREICH);
 
-  XFillRectangle(display, drawto, gc,
+  ClearRectangle(drawto,
                 area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
                 MINI_TILEX + 2, MINI_TILEY + 2);
 
   /* copy border to the right location */
-  XCopyArea(display, drawto, drawto, gc,
-           area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
-           area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
+  BlitBitmap(drawto, drawto,
+            area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
+            area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
 
   DrawMiniElement(area_x, area_y, ElementContent[0][0][0]);
 
@@ -2465,14 +2463,14 @@ static void DrawAmoebaContentArea()
     for (x=0; x<2; x++)
       DrawMiniElement(area_x + x, area_y + y, EL_ERDREICH);
 
-  XFillRectangle(display, drawto, gc,
+  ClearRectangle(drawto,
                 area_sx + MINI_TILEX/2 - 1, area_sy + MINI_TILEY/2 - 1,
                 MINI_TILEX + 2, MINI_TILEY + 2);
 
   /* copy border to the right location */
-  XCopyArea(display, drawto, drawto, gc,
-           area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
-           area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
+  BlitBitmap(drawto, drawto,
+            area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY,
+            area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
 
   DrawText(area_sx + TILEX, area_sy + 1, "Content of amoeba",
           FS_SMALL, font_color);
@@ -2511,7 +2509,7 @@ static void DrawElementContentAreas()
   MapCounterButtons(counter_id);
 
   /* delete content areas in case of reducing number of them */
-  XFillRectangle(display, backbuffer, gc,
+  ClearRectangle(backbuffer,
                 SX, area_sy - MINI_TILEX,
                 SXSIZE, 12 * MINI_TILEY);
 
@@ -2523,16 +2521,16 @@ static void DrawElementContentAreas()
        DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
                        EL_ERDREICH);
 
-    XFillRectangle(display, drawto, gc,
+    ClearRectangle(drawto,
                   area_sx + 5 * (i % 4) * MINI_TILEX + MINI_TILEX/2 - 1,
                   area_sy + 6 * (i / 4) * MINI_TILEY + MINI_TILEY/2 - 1,
                   3 * MINI_TILEX + 2, 3 * MINI_TILEY + 2);
   }
 
   /* copy border to the right location */
-  XCopyArea(display, drawto, drawto, gc,
-           area_sx, area_sy, (5 * 4 + 1) * MINI_TILEX, 11 * MINI_TILEY,
-           area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
+  BlitBitmap(drawto, drawto,
+            area_sx, area_sy, (5 * 4 + 1) * MINI_TILEX, 11 * MINI_TILEY,
+            area_sx - MINI_TILEX/2, area_sy - MINI_TILEY/2);
 
   DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 0 * MINI_TILEY + 1,
           "Content", FS_SMALL, font_color);
@@ -2642,28 +2640,28 @@ static void DrawPropertiesWindow()
     for (x=0; x<3; x++)
       DrawMiniElement(xstart + x , ystart + y, EL_ERDREICH);
 
-  XFillRectangle(display, drawto, gc,
+  ClearRectangle(drawto,
                 SX + xstart * MINI_TILEX + MINI_TILEX/2 - 1,
                 SY + ystart * MINI_TILEY + MINI_TILEY/2 - 1,
                 TILEX + 2, TILEY + 2);
 
   /* copy border to the right location */
-  XCopyArea(display, drawto, drawto, gc,
-           SX + xstart * MINI_TILEX,
-           SY + ystart * MINI_TILEY,
-           2 * TILEX, 2 * TILEY,
-           SX + xstart * MINI_TILEX - MINI_TILEX/2,
-           SY + ystart * MINI_TILEY - MINI_TILEY/2);
+  BlitBitmap(drawto, drawto,
+            SX + xstart * MINI_TILEX,
+            SY + ystart * MINI_TILEY,
+            2 * TILEX, 2 * TILEY,
+            SX + xstart * MINI_TILEX - MINI_TILEX/2,
+            SY + ystart * MINI_TILEY - MINI_TILEY/2);
 
   DrawGraphic(xstart/2, ystart/2, el2gfx(properties_element));
 
   /* copy the whole stuff to the definitive location */
-  XCopyArea(display, drawto, drawto, gc,
-           SX + xstart * MINI_TILEX - MINI_TILEX/2,
-           SY + ystart * MINI_TILEY - MINI_TILEY,
-           2 * TILEX, 2 * TILEY,
-           SX + xstart * MINI_TILEX - MINI_TILEX/2,
-           SY + ystart * MINI_TILEY - MINI_TILEY/2);
+  BlitBitmap(drawto, drawto,
+            SX + xstart * MINI_TILEX - MINI_TILEX/2,
+            SY + ystart * MINI_TILEY - MINI_TILEY,
+            2 * TILEX, 2 * TILEY,
+            SX + xstart * MINI_TILEX - MINI_TILEX/2,
+            SY + ystart * MINI_TILEY - MINI_TILEY/2);
 
   DrawTextF((xstart + 3) * MINI_TILEX, (ystart + 1) * MINI_TILEY,
            font_color, element_info[properties_element]);
@@ -2715,26 +2713,6 @@ static void DrawPropertiesWindow()
   }
 }
 
-static void swap_numbers(int *i1, int *i2)
-{
-  int help = *i1;
-
-  *i1 = *i2;
-  *i2 = help;
-}
-
-static void swap_number_pairs(int *x1, int *y1, int *x2, int *y2)
-{
-  int help_x = *x1;
-  int help_y = *y1;
-
-  *x1 = *x2;
-  *x2 = help_x;
-
-  *y1 = *y2;
-  *y2 = help_y;
-}
-
 static void DrawLineElement(int sx, int sy, int element, boolean change_level)
 {
   int lx = sx + level_xpos;
@@ -2914,14 +2892,10 @@ static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
   to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
   to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
 
-  XSetForeground(display, gc, WhitePixel(display, screen));
-
-  XDrawLine(display, drawto, gc, from_sx, from_sy, to_sx, from_sy);
-  XDrawLine(display, drawto, gc, to_sx, from_sy, to_sx, to_sy);
-  XDrawLine(display, drawto, gc, to_sx, to_sy, from_sx, to_sy);
-  XDrawLine(display, drawto, gc, from_sx, to_sy, from_sx, from_sy);
-
-  XSetForeground(display, gc, BlackPixel(display, screen));
+  DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
+  DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
+  DrawSimpleWhiteLine(drawto, to_sx, to_sy, from_sx, to_sy);
+  DrawSimpleWhiteLine(drawto, from_sx, to_sy, from_sx, from_sy);
 
   if (from_x == to_x && from_y == to_y)
     MarkTileDirty(from_x/2, from_y/2);
@@ -3782,7 +3756,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
        int element = editor_element[element_shift + i];
 
        UnmapGadget(gi);
-       getMiniGraphicSource(el2gfx(element), &gd->pixmap, &gd->x, &gd->y);
+       getMiniGraphicSource(el2gfx(element), &gd->bitmap, &gd->x, &gd->y);
        ModifyGadget(gi, GDI_INFO_TEXT, element_info[element], GDI_END);
        MapGadget(gi);
       }
@@ -3944,9 +3918,9 @@ static void HandleControlButtons(struct GadgetInfo *gi)
       else
       {
        CloseDoor(DOOR_CLOSE_1);
-       XCopyArea(display, pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], gc,
-                 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
-                 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+       BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR],
+                  DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
+                  DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
        OpenDoor(DOOR_OPEN_1);
       }
       break;
@@ -4048,7 +4022,7 @@ void HandleLevelEditorKeyInput(KeySym key)
 
 void ClearEditorGadgetInfoText()
 {
-  XFillRectangle(display, drawto, gc,
+  ClearRectangle(drawto,
                 INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE);
   redraw_mask |= REDRAW_FIELD;
 }
index 1866e7ae79d00373ecab208209ad6cd5765c596b..32e0013bf823f441e069281cfe2401ac3172b5c9 100644 (file)
@@ -32,26 +32,26 @@ void EventLoop(void)
 {
   while(1)
   {
-    if (XPending(display))     /* got event from X server */
+    if (PendingEvent())                /* got event */
     {
-      XEvent event;
+      Event event;
 
-      XNextEvent(display, &event);
+      NextEvent(&event);
 
       switch(event.type)
       {
-       case ButtonPress:
-       case ButtonRelease:
-         HandleButtonEvent((XButtonEvent *) &event);
+       case EVENT_BUTTONPRESS:
+       case EVENT_BUTTONRELEASE:
+         HandleButtonEvent((ButtonEvent *) &event);
          break;
 
-       case MotionNotify:
-         HandleMotionEvent((XMotionEvent *) &event);
+       case EVENT_MOTIONNOTIFY:
+         HandleMotionEvent((MotionEvent *) &event);
          break;
 
-       case KeyPress:
-       case KeyRelease:
-         HandleKeyEvent((XKeyEvent *) &event);
+       case EVENT_KEYPRESS:
+       case EVENT_KEYRELEASE:
+         HandleKeyEvent((KeyEvent *) &event);
          break;
 
        default:
@@ -67,8 +67,8 @@ void EventLoop(void)
 
     if (game_status != PLAYING)
     {
-      XSync(display, FALSE);
-      if (!XPending(display))  /* delay only if no pending events */
+      SyncDisplay();
+      if (!PendingEvent())     /* delay only if no pending events */
        Delay(10);
     }
 
@@ -80,25 +80,25 @@ void EventLoop(void)
   }
 }
 
-void HandleOtherEvents(XEvent *event)
+void HandleOtherEvents(Event *event)
 {
   switch(event->type)
   {
-    case Expose:
-      HandleExposeEvent((XExposeEvent *) event);
+    case EVENT_EXPOSE:
+      HandleExposeEvent((ExposeEvent *) event);
       break;
 
-    case UnmapNotify:
+    case EVENT_UNMAPNOTIFY:
       SleepWhileUnmapped();
       break;
 
-    case FocusIn:
-    case FocusOut:
-      HandleFocusEvent((XFocusChangeEvent *) event);
+    case EVENT_FOCUSIN:
+    case EVENT_FOCUSOUT:
+      HandleFocusEvent((FocusChangeEvent *) event);
       break;
 
-    case ClientMessage:
-      HandleClientMessageEvent((XClientMessageEvent *) event);
+    case EVENT_CLIENTMESSAGE:
+      HandleClientMessageEvent((ClientMessageEvent *) event);
       break;
 
     default:
@@ -108,19 +108,19 @@ void HandleOtherEvents(XEvent *event)
 
 void ClearEventQueue()
 {
-  while(XPending(display))
+  while (PendingEvent())
   {
-    XEvent event;
+    Event event;
 
-    XNextEvent(display, &event);
+    NextEvent(&event);
 
     switch(event.type)
     {
-      case ButtonRelease:
+      case EVENT_BUTTONRELEASE:
        button_status = MB_RELEASED;
        break;
 
-      case KeyRelease:
+      case EVENT_KEYRELEASE:
        key_joystick_mapping = 0;
        break;
 
@@ -135,29 +135,29 @@ void SleepWhileUnmapped()
 {
   boolean window_unmapped = TRUE;
 
-  XAutoRepeatOn(display);
+  KeyboardAutoRepeatOn();
 
   while(window_unmapped)
   {
-    XEvent event;
+    Event event;
 
-    XNextEvent(display, &event);
+    NextEvent(&event);
 
     switch(event.type)
     {
-      case ButtonRelease:
+      case EVENT_BUTTONRELEASE:
        button_status = MB_RELEASED;
        break;
 
-      case KeyRelease:
+      case EVENT_KEYRELEASE:
        key_joystick_mapping = 0;
        break;
 
-      case MapNotify:
+      case EVENT_MAPNOTIFY:
        window_unmapped = FALSE;
        break;
 
-      case UnmapNotify:
+      case EVENT_UNMAPNOTIFY:
        /* this is only to surely prevent the 'should not happen' case
         * of recursively looping between 'SleepWhileUnmapped()' and
         * 'HandleOtherEvents()' which usually calls this funtion.
@@ -171,10 +171,10 @@ void SleepWhileUnmapped()
   }
 
   if (game_status == PLAYING)
-    XAutoRepeatOff(display);
+    KeyboardAutoRepeatOff();
 }
 
-void HandleExposeEvent(XExposeEvent *event)
+void HandleExposeEvent(ExposeEvent *event)
 {
   int x = event->x, y = event->y;
   int width = event->width, height = event->height;
@@ -203,21 +203,19 @@ void HandleExposeEvent(XExposeEvent *event)
     fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
     fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
 
-    XCopyArea(display,fieldbuffer,backbuffer,gc,
-             fx,fy, SXSIZE,SYSIZE,
-             SX,SY);
+    BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY);
   }
 
-  XCopyArea(display,drawto,window,gc, x,y, width,height, x,y);
+  BlitBitmap(drawto, window, x,y, width,height, x,y);
 
-  XFlush(display);
+  FlushDisplay();
 }
 
-void HandleButtonEvent(XButtonEvent *event)
+void HandleButtonEvent(ButtonEvent *event)
 {
   motion_status = FALSE;
 
-  if (event->type == ButtonPress)
+  if (event->type == EVENT_BUTTONPRESS)
     button_status = event->button;
   else
     button_status = MB_RELEASED;
@@ -225,16 +223,12 @@ void HandleButtonEvent(XButtonEvent *event)
   HandleButton(event->x, event->y, button_status);
 }
 
-void HandleMotionEvent(XMotionEvent *event)
+void HandleMotionEvent(MotionEvent *event)
 {
-  Window root, child;
-  int root_x, root_y;
   int win_x, win_y;
-  unsigned int mask;
 
-  if (!XQueryPointer(display, window, &root, &child, &root_x, &root_y,
-                    &win_x, &win_y, &mask))
-    return;
+  if (!QueryPointer(window, &win_x, &win_y))
+    return;    /* window and pointer are on different screens */
 
   if (!button_status && game_status != LEVELED)
     return;
@@ -244,9 +238,9 @@ void HandleMotionEvent(XMotionEvent *event)
   HandleButton(win_x, win_y, button_status);
 }
 
-void HandleKeyEvent(XKeyEvent *event)
+void HandleKeyEvent(KeyEvent *event)
 {
-  int key_status = (event->type == KeyPress ? KEY_PRESSED : KEY_RELEASED);
+  int key_status = (event->type==EVENT_KEYPRESS ? KEY_PRESSED : KEY_RELEASED);
   KeySym key;
 
   if (game_status == PLAYING)
@@ -269,15 +263,15 @@ void HandleKeyEvent(XKeyEvent *event)
   HandleKey(key, key_status);
 }
 
-void HandleFocusEvent(XFocusChangeEvent *event)
+void HandleFocusEvent(FocusChangeEvent *event)
 {
   static int old_joystick_status = -1;
 
-  if (event->type == FocusOut)
+  if (event->type == EVENT_FOCUSOUT)
   {
     int i;
 
-    XAutoRepeatOn(display);
+    KeyboardAutoRepeatOn();
     old_joystick_status = joystick_status;
     joystick_status = JOYSTICK_OFF;
 
@@ -286,7 +280,7 @@ void HandleFocusEvent(XFocusChangeEvent *event)
     for (i=0; i<MAX_PLAYERS; i++)
       stored_player[i].action = 0;
   }
-  else if (event->type == FocusIn)
+  else if (event->type == EVENT_FOCUSIN)
   {
     /* When there are two Rocks'n'Diamonds windows which overlap and
        the player moves the pointer from one game window to the other,
@@ -307,20 +301,24 @@ void HandleFocusEvent(XFocusChangeEvent *event)
     if (game_status == PLAYING)
     {
       Delay(100);
-      XAutoRepeatOff(display);
+      KeyboardAutoRepeatOff();
     }
     if (old_joystick_status != -1)
       joystick_status = old_joystick_status;
   }
 }
 
-void HandleClientMessageEvent(XClientMessageEvent *event)
+void HandleClientMessageEvent(ClientMessageEvent *event)
 {
+#ifdef USE_SDL_LIBRARY
+  CloseAllAndExit(0);  /* the only possible message here is SDL_QUIT */
+#else
 #ifndef MSDOS
   if ((event->window == window) &&
       (event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE)))
     CloseAllAndExit(0);
 #endif
+#endif
 }
 
 void HandleButton(int mx, int my, int button)
index a7980e5a0912991376cc13efda8fd263642ccd48..bf3276e2d89ed3aaa74217dccc4e2713d98b8349 100644 (file)
 #include "main.h"
 
 void EventLoop(void);
-void HandleOtherEvents(XEvent *);
+void HandleOtherEvents(Event *);
 void ClearEventQueue(void);
 void SleepWhileUnmapped(void);
 
-void HandleExposeEvent(XExposeEvent *);
-void HandleButtonEvent(XButtonEvent *);
-void HandleMotionEvent(XMotionEvent *);
-void HandleKeyEvent(XKeyEvent *);
-void HandleFocusEvent(XFocusChangeEvent *);
-void HandleClientMessageEvent(XClientMessageEvent *event);
+void HandleExposeEvent(ExposeEvent *);
+void HandleButtonEvent(ButtonEvent *);
+void HandleMotionEvent(MotionEvent *);
+void HandleKeyEvent(KeyEvent *);
+void HandleFocusEvent(FocusChangeEvent *);
+void HandleClientMessageEvent(ClientMessageEvent *event);
 
 void HandleNoXEvent(void);
 
index 14e6445da7ccb717999e5b7574d8d85b443f1418..7c6cf1599ad4df135e9f140fce33aecc87a025d8 100644 (file)
@@ -715,14 +715,13 @@ void InitGame()
     CloseAllOpenTimegates();
 
   if (setup.soft_scrolling)
-    XCopyArea(display, fieldbuffer, backbuffer, gc,
-             FX, FY, SXSIZE, SYSIZE, SX, SY);
+    BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY);
 
   redraw_mask |= REDRAW_FROM_BACKBUFFER;
 
   /* copy default game door content to main double buffer */
-  XCopyArea(display, pix[PIX_DOOR], drawto, gc,
-           DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
+  BlitBitmap(pix[PIX_DOOR], drawto,
+            DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
 
   if (level_nr < 100)
     DrawText(DX + XX_LEVEL, DY + YY_LEVEL,
@@ -731,10 +730,10 @@ void InitGame()
   {
     DrawTextExt(drawto, gc, DX + XX_EMERALDS, DY + YY_EMERALDS,
                int2str(level_nr, 3), FS_SMALL, FC_SPECIAL3);
-    XCopyArea(display, drawto, drawto, gc,
-             DX + XX_EMERALDS, DY + YY_EMERALDS + 1,
-             FONT5_XSIZE * 3, FONT5_YSIZE - 1,
-             DX + XX_LEVEL - 1, DY + YY_LEVEL + 1);
+    BlitBitmap(drawto, drawto,
+              DX + XX_EMERALDS, DY + YY_EMERALDS + 1,
+              FONT5_XSIZE * 3, FONT5_YSIZE - 1,
+              DX + XX_LEVEL - 1, DY + YY_LEVEL + 1);
   }
 
   DrawText(DX + XX_EMERALDS, DY + YY_EMERALDS,
@@ -754,15 +753,15 @@ void InitGame()
   MapTapeButtons();
 
   /* copy actual game door content to door double buffer for OpenDoor() */
-  XCopyArea(display, drawto, pix[PIX_DB_DOOR], gc,
-           DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+  BlitBitmap(drawto, pix[PIX_DB_DOOR],
+            DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
 
   OpenDoor(DOOR_OPEN_ALL);
 
   if (setup.sound_music)
     PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
 
-  XAutoRepeatOff(display);
+  KeyboardAutoRepeatOff();
 
   if (options.verbose)
   {
@@ -3793,8 +3792,8 @@ void EdelsteinFunkeln(int x, int y)
          dest_x = FX + SCREENX(x)*TILEX;
          dest_y = FY + SCREENY(y)*TILEY;
 
-         XCopyArea(display, drawto_field, window, gc,
-                   dest_x, dest_y, TILEX, TILEY, dest_x, dest_y);
+         BlitBitmap(drawto_field, window,
+                    dest_x, dest_y, TILEX, TILEY, dest_x, dest_y);
          SetDrawtoField(DRAW_DIRECT);
        }
       }
@@ -4607,13 +4606,13 @@ void ScrollLevel(int dx, int dy)
   int softscroll_offset = (setup.soft_scrolling ? TILEX : 0);
   int x, y;
 
-  XCopyArea(display, drawto_field, drawto_field, gc,
-           FX + TILEX*(dx == -1) - softscroll_offset,
-           FY + TILEY*(dy == -1) - softscroll_offset,
-           SXSIZE - TILEX*(dx!=0) + 2*softscroll_offset,
-           SYSIZE - TILEY*(dy!=0) + 2*softscroll_offset,
-           FX + TILEX*(dx == 1) - softscroll_offset,
-           FY + TILEY*(dy == 1) - softscroll_offset);
+  BlitBitmap(drawto_field, drawto_field,
+            FX + TILEX*(dx == -1) - softscroll_offset,
+            FY + TILEY*(dy == -1) - softscroll_offset,
+            SXSIZE - TILEX*(dx!=0) + 2*softscroll_offset,
+            SYSIZE - TILEY*(dy!=0) + 2*softscroll_offset,
+            FX + TILEX*(dx == 1) - softscroll_offset,
+            FY + TILEY*(dy == 1) - softscroll_offset);
 
   if (dx)
   {
@@ -6065,7 +6064,7 @@ void CreateGameButtons()
 
   for (i=0; i<NUM_GAME_BUTTONS; i++)
   {
-    Pixmap gd_pixmap = pix[PIX_DOOR];
+    Bitmap gd_bitmap = pix[PIX_DOOR];
     struct GadgetInfo *gi;
     int button_type;
     boolean checked;
@@ -6110,10 +6109,10 @@ void CreateGameButtons()
                      GDI_TYPE, button_type,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
                      GDI_CHECKED, checked,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y1,
-                     GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y2,
-                     GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
+                     GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
+                     GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleGameButtons,
                      GDI_END);
index f77bd79ef23bb37dcf915ef4fe78e2b0cee4a249..ab51dd9fef4ce8c6ffc1ddacf9df2da289f99fc4 100644 (file)
@@ -81,14 +81,13 @@ void OpenAll(int argc, char *argv[])
 
 #ifndef USE_SDL_LIBRARY
   XMapWindow(display, window);
-  XFlush(display);
+  FlushDisplay();
 #endif
 
   InitGfx();
   InitElementProperties();     /* initializes IS_CHAR() for el2gfx() */
 
   InitLevelAndPlayerInfo();
-  return;
   InitGadgets();               /* needs to know number of level series */
 
   DrawMainMenu();
@@ -360,17 +359,14 @@ void InitWindow(int argc, char *argv[])
 {
 #ifdef USE_SDL_LIBRARY
   /* open SDL video output device (window or fullscreen mode) */
-  if ((sdl_window = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH,
-                                    SDL_HWSURFACE))
+  if ((window = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH,
+                                SDL_HWSURFACE))
       == NULL)
     Error(ERR_EXIT, "SDL_SetVideoMode() failed: %s\n", SDL_GetError());
 
   /* set window and icon title */
   SDL_WM_SetCaption(WINDOW_TITLE_STRING, WINDOW_TITLE_STRING);
 
-  /* select event types: initially no mouse motion events */
-  SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
-
 #else /* !USE_SDL_LIBRARY */
 
   unsigned int border_width = 4;
@@ -481,7 +477,7 @@ void InitWindow(int argc, char *argv[])
   XSelectInput(display, window, window_event_mask);
 #endif
 
-  /* create GC for drawing with window depth */
+  /* create GC for drawing with window depth and background color (black) */
   gc_values.graphics_exposures = False;
   gc_values.foreground = pen_bg;
   gc_values.background = pen_bg;
@@ -641,7 +637,7 @@ void InitGfx()
       == NULL)
     Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
 
-  if ((sdl_pix[PIX_DB_BACK] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+  if ((pix[PIX_DB_BACK] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
     Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
 
   SDL_FreeSurface(sdl_image_tmp);
@@ -653,7 +649,7 @@ void InitGfx()
       == NULL)
     Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
 
-  if ((sdl_pix[PIX_DB_DOOR] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+  if ((pix[PIX_DB_DOOR] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
     Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
 
   SDL_FreeSurface(sdl_image_tmp);
@@ -665,14 +661,14 @@ void InitGfx()
       == NULL)
     Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
 
-  if ((sdl_pix[PIX_DB_FIELD] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+  if ((pix[PIX_DB_FIELD] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
     Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
 
   SDL_FreeSurface(sdl_image_tmp);
 
   /* initialize surface array to 'NULL' */
   for(i=0; i<NUM_TILES; i++)
-    sdl_tile_masked[i] = NULL;
+    tile_masked[i] = NULL;
 
   /* create only those masked surfaces we really need */
   for(i=0; tile_needs_clipping[i].start>=0; i++)
@@ -680,33 +676,31 @@ void InitGfx()
     for(j=0; j<tile_needs_clipping[i].count; j++)
     {
       int tile = tile_needs_clipping[i].start + j;
-#if 0
       int graphic = tile;
       int src_x, src_y;
-      int pixmap_nr;
-      Pixmap src_pixmap;
+      int bitmap_nr;
+      Bitmap src_bitmap;
 
-      getGraphicSource(graphic, &pixmap_nr, &src_x, &src_y);
-      src_pixmap = clipmask[pixmap_nr];
+      getGraphicSource(graphic, &bitmap_nr, &src_x, &src_y);
+      src_bitmap = pix_masked[bitmap_nr];
 
-      tile_clipmask[tile] = XCreatePixmap(display, window, TILEX,TILEY, 1);
+      /* create surface for masked tile graphic */
+      if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, TILEX, TILEY,
+                                               WIN_SDL_DEPTH, 0, 0, 0, 0))
+         == NULL)
+       Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
 
-      XCopyArea(display,src_pixmap,tile_clipmask[tile],copy_clipmask_gc,
-               src_x,src_y, TILEX,TILEY, 0,0);
-#endif
-    }
-  }
+      /* create native transparent surface for current image */
+      SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
+                     SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
+      if ((tile_masked[tile] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+       Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
 
-  sdl_drawto = sdl_backbuffer = sdl_pix[PIX_DB_BACK];
-  sdl_fieldbuffer = sdl_pix[PIX_DB_FIELD];
-  SetDrawtoField(DRAW_BACKBUFFER);
+      SDL_FreeSurface(sdl_image_tmp);
 
-  SDLCopyArea(sdl_pix[PIX_BACK], sdl_backbuffer,
-             0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
-  SDLFillRectangle(sdl_pix[PIX_DB_BACK],
-                  REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, 0x000000);
-  SDLFillRectangle(sdl_pix[PIX_DB_DOOR],
-                  0,0, 3*DXSIZE,DYSIZE+VYSIZE, 0x000000);
+      BlitBitmap(src_bitmap, tile_masked[tile], src_x,src_y, TILEX,TILEY, 0,0);
+    }
+  }
 
 #else /* !USE_SDL_LIBRARY */
 
@@ -758,7 +752,7 @@ void InitGfx()
   if (!pix[PIX_DB_BACK] || !pix[PIX_DB_DOOR])
     Error(ERR_EXIT, "cannot create additional pixmaps");
 
-  for(i=0; i<NUM_PIXMAPS; i++)
+  for(i=0; i<NUM_BITMAPS; i++)
   {
     if (clipmask[i])
     {
@@ -769,17 +763,15 @@ void InitGfx()
     }
   }
 
+#endif /* !USE_SDL_LIBRARY */
+
   drawto = backbuffer = pix[PIX_DB_BACK];
   fieldbuffer = pix[PIX_DB_FIELD];
   SetDrawtoField(DRAW_BACKBUFFER);
 
-  XCopyArea(display, pix[PIX_BACK], backbuffer, gc,
-           0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
-  XFillRectangle(display, pix[PIX_DB_BACK], gc,
-                REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
-  XFillRectangle(display, pix[PIX_DB_DOOR], gc,
-                0,0, 3*DXSIZE,DYSIZE+VYSIZE);
-#endif /* !USE_SDL_LIBRARY */
+  BlitBitmap(pix[PIX_BACK], backbuffer, 0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
+  ClearRectangle(pix[PIX_DB_BACK], REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
+  ClearRectangle(pix[PIX_DB_DOOR], 0,0, 3*DXSIZE,DYSIZE+VYSIZE);
 
   for(i=0; i<MAX_BUF_XSIZE; i++)
     for(j=0; j<MAX_BUF_YSIZE; j++)
@@ -833,13 +825,13 @@ void LoadGfx(int pos, struct PictureFileInfo *pic)
       Error(ERR_EXIT, "IMG_Load() failed: %s\n", SDL_GetError());
 
     /* create native non-transparent surface for current image */
-    if ((sdl_pix[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+    if ((pix[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
       Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
 
     /* create native transparent surface for current image */
     SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
                    SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
-    if ((sdl_pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+    if ((pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
       Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
 
     /* free temporary surface */
@@ -903,6 +895,11 @@ void LoadGfx(int pos, struct PictureFileInfo *pic)
 
     if (!pix[pos])
       Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename);
+
+    /* setting pix_masked[] to pix[] allows BlitBitmapMasked() to always
+       use pix_masked[], although they are the same when not using SDL */
+    pix_masked[pos] = pix[pos];
+
 #endif /* !USE_SDL_LIBRARY */
   }
 
@@ -2119,7 +2116,7 @@ void CloseAllAndExit(int exit_value)
     FreeSounds(NUM_SOUNDS);
   }
 
-  for(i=0; i<NUM_PIXMAPS; i++)
+  for(i=0; i<NUM_BITMAPS; i++)
   {
     if (pix[i])
     {
@@ -2131,22 +2128,36 @@ void CloseAllAndExit(int exit_value)
        XpmFreeAttributes(&xpm_att[i]);
       }
 #endif
+
+#ifdef USE_SDL_LIBRARY
+      SDL_FreeSurface(pix[i]);
+#else
       XFreePixmap(display,pix[i]);
+#endif
     }
+
+#ifdef USE_SDL_LIBRARY
+      SDL_FreeSurface(pix_masked[i]);
+#else
     if (clipmask[i])
       XFreePixmap(display,clipmask[i]);
     if (clip_gc[i])
       XFreeGC(display, clip_gc[i]);
+#endif
   }
 
+#ifdef USE_SDL_LIBRARY
+  KeyboardAutoRepeatOn();
+#else
   if (gc)
     XFreeGC(display, gc);
 
   if (display)
   {
-    XAutoRepeatOn(display);
+    KeyboardAutoRepeatOn();
     XCloseDisplay(display);
   }
+#endif
 
 #ifdef MSDOS
   dumpErrorFile();
index 2c0b95c3a11fd742f92da0b0adc462e483845560..86b7eb179e4668d08a7a03590c041cbd36455783 100644 (file)
 Display        *display;
 Visual        *visual;
 int            screen;
-Window         window;
-GC             gc, clip_gc[NUM_PIXMAPS], tile_clip_gc;
-Pixmap         pix[NUM_PIXMAPS];
-Pixmap         clipmask[NUM_PIXMAPS], tile_clipmask[NUM_TILES];
+DrawWindow     window;
+GC             gc, clip_gc[NUM_BITMAPS], tile_clip_gc;
+Bitmap         pix[NUM_BITMAPS];
+Bitmap         pix_masked[NUM_BITMAPS], tile_masked[NUM_TILES];
+Pixmap         clipmask[NUM_BITMAPS], tile_clipmask[NUM_TILES];
 
 #ifdef USE_XPM_LIBRARY
 XpmAttributes  xpm_att[NUM_PICTURES];
 #endif
 
-Drawable        drawto, drawto_field, backbuffer, fieldbuffer;
+DrawBuffer     drawto, drawto_field, backbuffer, fieldbuffer;
 Colormap       cmap;
 
-#ifdef USE_SDL_LIBRARY
-SDL_Surface    *sdl_window;
-SDL_Surface    *sdl_drawto, *sdl_drawto_field;
-SDL_Surface    *sdl_backbuffer, *sdl_fieldbuffer;
-SDL_Surface    *sdl_pix[NUM_PIXMAPS];
-SDL_Surface    *sdl_pix_masked[NUM_PIXMAPS], *sdl_tile_masked[NUM_TILES];
-#endif
-
 int            sound_pipe[2];
 int            sound_device;
 char          *sound_device_name = SOUND_DEVICE;
@@ -586,7 +579,7 @@ void TEST_SDL_BLIT_RECT(int x, int y)
 {
   SDL_Rect rect_src, rect_dst;
 
-  SDLCopyArea(sdl_pix_masked[PIX_HEROES], sdl_window,
+  SDLCopyArea(pix_masked[PIX_HEROES], window,
              8 * TILEX, 8 * TILEY, TILEX, TILEY, x, y);
   return;
 
@@ -680,59 +673,73 @@ void TEST_SDL_INIT_DISPLAY()
 
 void TEST_SDL_EVENT_LOOP()
 {
-  SDL_Event event;
   int quit_loop = 0;
 
   SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
 
+  /*
   while (!quit_loop && SDL_WaitEvent(&event) >=0)
+  */
+
+  while (!quit_loop)
   {
-    /* hier werden die Ereignisse behandelt */
-    switch(event.type)
+    SDL_Event event;
+
+    if (SDL_PollEvent(&event))
     {
-      case SDL_QUIT:
+      /* hier werden die Ereignisse behandelt */
+      switch(event.type)
       {
-       quit_loop = 1;
-       break;
-      }
+        case SDL_QUIT:
+       {
+         quit_loop = 1;
+         break;
+       }
 
-      case SDL_MOUSEBUTTONDOWN:
-      {
-       int x = event.button.x;
-       int y = event.button.y;
+        case SDL_MOUSEBUTTONDOWN:
+       {
+         int x = event.button.x;
+         int y = event.button.y;
 
-       SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
+         SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
 
-       TEST_SDL_BLIT_RECT(x, y);
+         TEST_SDL_BLIT_RECT(x, y);
 
-       printf("SDL_MOUSEBUTTONDOWN(%d, %d)\n", x, y);
-       break;
-      }
+         printf("SDL_MOUSEBUTTONDOWN(%d, %d)\n", x, y);
+         break;
+       }
 
-      case SDL_MOUSEBUTTONUP:
-      {
-       int x = event.button.x;
-       int y = event.button.y;
+        case SDL_MOUSEBUTTONUP:
+       {
+         int x = event.button.x;
+         int y = event.button.y;
 
-       SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
+         SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
 
-       printf("SDL_MOUSEBUTTONUP(%d, %d)\n", x, y);
-       break;
-      }
+         printf("SDL_MOUSEBUTTONUP(%d, %d)\n", x, y);
+         break;
+       }
 
-      case SDL_MOUSEMOTION:
-      {
-       int x = event.motion.x;
-       int y = event.motion.y;
+        case SDL_MOUSEMOTION:
+       {
+         int x = event.motion.x;
+         int y = event.motion.y;
 
-       TEST_SDL_BLIT_RECT(x, y);
+         TEST_SDL_BLIT_RECT(x, y);
 
-       printf("SDL_MOUSEMOTION(%d, %d)\n", x, y);
-       break;
+         printf("SDL_MOUSEMOTION(%d, %d)\n", x, y);
+         break;
+       }
+
+        default:
+         break;
       }
+    }
 
-      default:
-       break;
+    if (!SDL_PollEvent(NULL))  /* delay only if no pending events */
+    {
+      printf("waiting...\n");
+      Delay(100);
     }
   }
 
@@ -759,10 +766,12 @@ int main(int argc, char *argv[])
   GetOptions(argv);
   OpenAll(argc,argv);
 
+#if 0
 #ifdef USE_SDL_LIBRARY
   TEST_SDL_BLIT_RECT((WIN_XSIZE - TILEX)/2, (WIN_YSIZE - TILEY)/2);
   TEST_SDL_EVENT_LOOP();
   exit(0);
+#endif
 #endif
 
   EventLoop();
index 4c1d57d52a1191f1a44d679211a4fbfa1c06f6fa..adf82efa6c4c0789728569f4fbf7abcd85b9ab04 100644 (file)
 #define XK_MISCELLANY
 #define XK_LATIN1
 
+/*
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
 #include <X11/Xos.h>
 #include <X11/Intrinsic.h>
 #include <X11/keysymdef.h>
+*/
 
 #ifdef   XPM_INCLUDE_FILE
 #define  USE_XPM_LIBRARY
 #include "msdos.h"
 #endif  /* MSDOS */
 
-#ifdef USE_SDL_LIBRARY
-#include "sdl.h"
-#endif
-
 #ifdef DEBUG
 #define DEBUG_TIMING   0
 #endif
@@ -51,6 +49,8 @@
 typedef unsigned char boolean;
 typedef unsigned char byte;
 
+#include "system.h"
+
 #ifndef FALSE
 #define FALSE          0
 #define TRUE           (!FALSE)
@@ -205,7 +205,7 @@ typedef unsigned char byte;
 #define PLAYER_PROTECTED(x,y)  (SHIELD_ON(PLAYERINFO(x, y)) ||         \
                                 PROTECTED_FIELD(x, y))
 
-/* Pixmaps with graphic file */
+/* Bitmaps with graphic file */
 #define PIX_BACK               0
 #define PIX_DOOR               1
 #define PIX_HEROES             2
@@ -216,13 +216,13 @@ typedef unsigned char byte;
 #define        PIX_BIGFONT             7
 #define PIX_SMALLFONT          8
 #define PIX_MEDIUMFONT         9
-/* Pixmaps without graphic file */
+/* Bitmaps without graphic file */
 #define PIX_DB_BACK            10
 #define PIX_DB_DOOR            11
 #define PIX_DB_FIELD           12
 
 #define NUM_PICTURES           10
-#define NUM_PIXMAPS            13
+#define NUM_BITMAPS            13
 
 /* boundaries of arrays etc. */
 #define MAX_PLAYER_NAME_LEN    10
@@ -466,26 +466,19 @@ struct GlobalInfo
 extern Display        *display;
 extern Visual         *visual;
 extern int             screen;
-extern Window                  window;
+extern DrawWindow      window;
 extern GC              gc, clip_gc[], tile_clip_gc;
-extern Pixmap          pix[];
+extern Bitmap          pix[];
+extern Bitmap          pix_masked[], tile_masked[];
 extern Pixmap          clipmask[], tile_clipmask[];
 
 #ifdef USE_XPM_LIBRARY
 extern XpmAttributes   xpm_att[];
 #endif
 
-extern Drawable        drawto, drawto_field, backbuffer, fieldbuffer;
+extern DrawBuffer      drawto, drawto_field, backbuffer, fieldbuffer;
 extern Colormap                cmap;
 
-#ifdef USE_SDL_LIBRARY
-extern SDL_Surface    *sdl_window;
-extern SDL_Surface    *sdl_drawto, *sdl_drawto_field;
-extern SDL_Surface    *sdl_backbuffer, *sdl_fieldbuffer;
-extern SDL_Surface    *sdl_pix[];
-extern SDL_Surface    *sdl_pix_masked[], *sdl_tile_masked[];
-#endif
-
 extern int             sound_pipe[2];
 extern int             sound_device;
 extern char           *sound_device_name;
@@ -1723,7 +1716,7 @@ extern char               *element_info[];
                                 REDRAW_MICROLEVEL)
 #define REDRAWTILES_THRESHOLD  (SCR_FIELDX * SCR_FIELDY / 2)
 
-/* areas in pixmap PIX_DOOR */
+/* areas in bitmap PIX_DOOR */
 /* meaning in PIX_DB_DOOR: (3 PAGEs)
    PAGEX1: 1. buffer for DOOR_1
    PAGEX2: 2. buffer for DOOR_1
index c32aa55515b13650e2ba97a7f21cdfd85c38def3..e1badb59fd82a338d8ff30ff9836b400313f1342 100644 (file)
@@ -1273,6 +1273,26 @@ void sortLevelDirInfo(struct LevelDirInfo **node_first,
   }
 }
 
+inline void swap_numbers(int *i1, int *i2)
+{
+  int help = *i1;
+
+  *i1 = *i2;
+  *i2 = help;
+}
+
+inline void swap_number_pairs(int *x1, int *y1, int *x2, int *y2)
+{
+  int help_x = *x1;
+  int help_y = *y1;
+
+  *x1 = *x2;
+  *x2 = help_x;
+
+  *y1 = *y2;
+  *y2 = help_y;
+}
+
 
 /* ------------------------------------------------------------------------- */
 /* the following is only for debugging purpose and normally not used         */
index d274922504752aff628b8b3c77cc48abb00e834d..5aa6c15ccda29cee8884f647fe2d765354e0f72b 100644 (file)
@@ -92,6 +92,9 @@ void dumpLevelDirInfo(struct LevelDirInfo *, int);
 void sortLevelDirInfo(struct LevelDirInfo **,
                      int (*compare_function)(const void *, const void *));
 
+inline void swap_numbers(int *, int *);
+inline void swap_number_pairs(int *, int *, int *, int *);
+
 void debug_print_timestamp(int, char *);
 
 #endif /* MISC_H */
index f2335cac639ab23a52c3e2e5e3854f5f2aba8649..8fb300aa2030eb40fddb2a1ed8978119b0331e4d 100644 (file)
@@ -75,7 +75,7 @@ void DrawMainMenu()
 
   UnmapAllGadgets();
   FadeSounds();
-  XAutoRepeatOn(display);
+  KeyboardAutoRepeatOn();
 
   /* needed if last screen was the playing screen, invoked from level editor */
   if (level_editor_test_game)
@@ -274,7 +274,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
 
     /* needed because DrawMicroLevel() takes some time */
     BackToFront();
-    XSync(display, FALSE);
+    SyncDisplay();
     DelayReached(&level_delay, 0);     /* reset delay counter */
   }
   else if (x == 1 && y >= 3 && y <= 10)
@@ -927,7 +927,7 @@ static void drawChooseLevelList(int first_entry, int num_page_entries)
   int max_buffer_len = (SCR_FIELDX - 2) * 2;
   int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
 
-  XFillRectangle(display, backbuffer, gc, SX, SY, SXSIZE - 32, SYSIZE);
+  ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
   redraw_mask |= REDRAW_FIELD;
 
   DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
@@ -969,7 +969,7 @@ static void drawChooseLevelInfo(int leveldir_pos)
   node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
   node = getLevelDirInfoFromPos(node_first, leveldir_pos);
 
-  XFillRectangle(display, drawto, gc, SX + 32, SY + 32, SXSIZE - 64, 32);
+  ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
 
   if (node->parent_link)
     DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
@@ -1890,18 +1890,18 @@ void CustomizeKeyboard(int player_nr)
 
   while(!finished)
   {
-    if (XPending(display))     /* got event from X server */
+    if (PendingEvent())                /* got event */
     {
-      XEvent event;
+      Event event;
 
-      XNextEvent(display, &event);
+      NextEvent(&event);
 
       switch(event.type)
       {
-        case KeyPress:
+        case EVENT_KEYPRESS:
          {
-           KeySym key = XLookupKeysym((XKeyEvent *)&event,
-                                      ((XKeyEvent *)&event)->state);
+           KeySym key = XLookupKeysym((KeyEvent *)&event,
+                                      ((KeyEvent *)&event)->state);
 
            if (key == XK_Escape || (key == XK_Return && step_nr == 6))
            {
@@ -1953,7 +1953,7 @@ void CustomizeKeyboard(int player_nr)
          }
          break;
 
-        case KeyRelease:
+        case EVENT_KEYRELEASE:
          key_joystick_mapping = 0;
          break;
 
@@ -2056,17 +2056,17 @@ void CalibrateJoystick(int player_nr)
 
   while(result < 0)
   {
-    if (XPending(display))     /* got event from X server */
+    if (PendingEvent())                /* got event */
     {
-      XEvent event;
+      Event event;
 
-      XNextEvent(display, &event);
+      NextEvent(&event);
 
       switch(event.type)
       {
-       case KeyPress:
-         switch(XLookupKeysym((XKeyEvent *)&event,
-                              ((XKeyEvent *)&event)->state))
+       case EVENT_KEYPRESS:
+         switch(XLookupKeysym((KeyEvent *)&event,
+                              ((KeyEvent *)&event)->state))
          {
            case XK_Return:
              if (check_remaining == 0)
@@ -2082,7 +2082,7 @@ void CalibrateJoystick(int player_nr)
          }
          break;
 
-       case KeyRelease:
+       case EVENT_KEYRELEASE:
          key_joystick_mapping = 0;
          break;
 
@@ -2300,7 +2300,7 @@ static struct
 
 static void CreateScreenScrollbuttons()
 {
-  Pixmap gd_pixmap = pix[PIX_MORE];
+  Bitmap gd_bitmap = pix[PIX_MORE];
   struct GadgetInfo *gi;
   unsigned long event_mask;
   int i;
@@ -2334,8 +2334,8 @@ static void CreateScreenScrollbuttons()
                      GDI_HEIGHT, height,
                      GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleScreenGadgets,
                      GDI_END);
@@ -2354,7 +2354,7 @@ static void CreateScreenScrollbars()
   for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
   {
     int id = scrollbar_info[i].gadget_id;
-    Pixmap gd_pixmap = pix[PIX_MORE];
+    Bitmap gd_bitmap = pix[PIX_MORE];
     int gd_x1, gd_x2, gd_y1, gd_y2;
     struct GadgetInfo *gi;
     int items_max, items_visible, item_position;
@@ -2395,8 +2395,8 @@ static void CreateScreenScrollbars()
                      GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
                      GDI_SCROLLBAR_ITEM_POSITION, item_position,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
                      GDI_BORDER_SIZE, SC_BORDER_SIZE,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleScreenGadgets,
index d8100125d9f0e5ad92e85d773f936d9bfa8ec24a..3f1930136e0e4c8033766490842bb973cb45f9cf 100644 (file)
--- a/src/sdl.c
+++ b/src/sdl.c
@@ -15,6 +15,7 @@
 #ifdef USE_SDL_LIBRARY
 
 #include "main.h"
+#include "misc.h"
 
 inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface,
                        int src_x, int src_y,
@@ -54,4 +55,27 @@ inline void SDLFillRectangle(SDL_Surface *surface, int x, int y,
                SDL_MapRGB(surface->format, color_r, color_g, color_b));
 }
 
+inline void SDLDrawSimpleLine(SDL_Surface *surface, int from_x, int from_y,
+                             int to_x, int to_y, unsigned int color)
+{
+  SDL_Rect rect;
+  unsigned int color_r = (color >> 2) && 0xff;
+  unsigned int color_g = (color >> 1) && 0xff;
+  unsigned int color_b = (color >> 0) && 0xff;
+
+  if (from_x > to_x)
+    swap_numbers(&from_x, &to_x);
+
+  if (from_y > to_y)
+    swap_numbers(&from_y, &to_y);
+
+  rect.x = from_x;
+  rect.y = from_y;
+  rect.w = (to_x - from_x + 1);
+  rect.h = (to_y - from_y + 1);
+
+  SDL_FillRect(surface, &rect,
+               SDL_MapRGB(surface->format, color_r, color_g, color_b));
+}
+
 #endif /* USE_SDL_LIBRARY */
index 9bfcff3b59c0442f2a148c1cf82264b930d546c6..dfe39e50f1590931a8aa13068a1b55de0080fa88 100644 (file)
--- a/src/sdl.h
+++ b/src/sdl.h
 *  sdl.h                                                   *
 ***********************************************************/
 
-#include <SDL/SDL.h>
-#include <IMG.h>
+#ifndef SDL_H
+#define SDL_H
+
+#include "SDL.h"
+#include "IMG.h"
 
 inline void SDLCopyArea(SDL_Surface *, SDL_Surface *,
                        int, int, int, int, int, int);
-inline void SDLFillRectangle(SDL_Surface *, int, int,
-                            int, int, unsigned int);
+inline void SDLFillRectangle(SDL_Surface *, int, int, int, int, unsigned int);
+inline void SDLDrawSimpleLine(SDL_Surface *, int, int, int, int, unsigned int);
+
+#endif /* SDL_H */
diff --git a/src/system.c b/src/system.c
new file mode 100644 (file)
index 0000000..71b248e
--- /dev/null
@@ -0,0 +1,160 @@
+/***********************************************************
+*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
+*----------------------------------------------------------*
+*  Â©1995 Artsoft Development                               *
+*        Holger Schemel                                    *
+*        33659 Bielefeld-Senne                             *
+*        Telefon: (0521) 493245                            *
+*        eMail: aeglos@valinor.owl.de                      *
+*               aeglos@uni-paderborn.de                    *
+*               q99492@pbhrzx.uni-paderborn.de             *
+*----------------------------------------------------------*
+*  system.c                                                *
+***********************************************************/
+
+#include "main.h"
+
+#ifdef USE_SDL_LIBRARY
+#include "sdl.h"
+#endif
+
+inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height)
+{
+#ifdef USE_SDL_LIBRARY
+  SDLFillRectangle(bitmap, x, y, width, height, 0x000000);
+#else
+  XFillRectangle(display, bitmap, gc, x, y, width, height);
+#endif
+}
+
+inline void BlitBitmap(Bitmap src_bitmap, Bitmap dst_bitmap,
+                      int src_x, int src_y,
+                      int width, int height,
+                      int dst_x, int dst_y)
+{
+#ifdef USE_SDL_LIBRARY
+  SDLCopyArea(src_bitmap, dst_bitmap,
+             src_x, src_y, width, height, dst_x, dst_y);
+#else
+  XCopyArea(display, src_bitmap, dst_bitmap, gc,
+           src_x, src_y, width, height, dst_x, dst_y);
+#endif
+}
+
+#ifndef USE_SDL_LIBRARY
+static GC last_clip_gc = 0;    /* needed for XCopyArea() through clip mask */
+#endif
+
+inline void SetClipMask(GC clip_gc, Pixmap clip_pixmap)
+{
+#ifndef USE_SDL_LIBRARY
+  XSetClipMask(display, clip_gc, clip_pixmap);
+  last_clip_gc = clip_gc;
+#endif
+}
+
+inline void SetClipOrigin(GC clip_gc, int clip_x, int clip_y)
+{
+#ifndef USE_SDL_LIBRARY
+  XSetClipOrigin(display, clip_gc, clip_x, clip_y);
+  last_clip_gc = clip_gc;
+#endif
+}
+
+inline void BlitBitmapMasked(Bitmap src_bitmap, Bitmap dst_bitmap,
+                            int src_x, int src_y,
+                            int width, int height,
+                            int dst_x, int dst_y)
+{
+#ifdef USE_SDL_LIBRARY
+  SDLCopyArea(src_bitmap, dst_bitmap,
+             src_x, src_y, width, height, dst_x, dst_y);
+#else
+  XCopyArea(display, src_bitmap, dst_bitmap, last_clip_gc,
+           src_x, src_y, width, height, dst_x, dst_y);
+#endif
+}
+
+inline void DrawSimpleWhiteLine(Bitmap bitmap, int from_x, int from_y,
+                               int to_x, int to_y)
+{
+#ifdef USE_SDL_LIBRARY
+  SDLDrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, 0xffffff);
+#else
+  XSetForeground(display, gc, WhitePixel(display, screen));
+  XDrawLine(display, bitmap, gc, from_x, from_y, to_x, to_y);
+  XSetForeground(display, gc, BlackPixel(display, screen));
+#endif
+}
+
+/* execute all pending screen drawing operations */
+inline void FlushDisplay()
+{
+#ifndef USE_SDL_LIBRARY
+  XFlush(display);
+#endif
+}
+
+/* execute and wait for all pending screen drawing operations */
+inline void SyncDisplay()
+{
+#ifndef USE_SDL_LIBRARY
+  XSync(display, FALSE);
+#endif
+}
+
+inline void KeyboardAutoRepeatOn()
+{
+#ifndef USE_SDL_LIBRARY
+  XAutoRepeatOn(display);
+#endif
+}
+
+inline void KeyboardAutoRepeatOff()
+{
+#ifndef USE_SDL_LIBRARY
+  XAutoRepeatOff(display);
+#endif
+}
+
+inline boolean QueryPointer(DrawWindow window, int *win_x, int *win_y)
+{
+#ifdef USE_SDL_LIBRARY
+  SDL_GetMouseState(win_x, win_y);
+  return TRUE;
+#else
+  DrawWindow root, child;
+  int root_x, root_y;
+  unsigned int mask;
+
+  /* if XQueryPointer() returns False, the pointer
+     is not on the same screen as the specified window */
+  return XQueryPointer(display, window, &root, &child, &root_x, &root_y,
+                      win_x, win_y, &mask);
+#endif
+}
+
+inline boolean PendingEvent()
+{
+#ifdef USE_SDL_LIBRARY
+  return (SDL_PollEvent(NULL) ? TRUE : FALSE);
+#else
+  return (XPending(display) ? TRUE : FALSE);
+#endif
+}
+
+inline void NextEvent(Event *event)
+{
+#ifdef USE_SDL_LIBRARY
+  SDL_WaitEvent(event);
+#else
+  XNextEvent(display, event);
+#endif
+}
+
+inline void dummy()
+{
+#ifdef USE_SDL_LIBRARY
+#else
+#endif
+}
diff --git a/src/system.h b/src/system.h
new file mode 100644 (file)
index 0000000..35351e3
--- /dev/null
@@ -0,0 +1,103 @@
+/***********************************************************
+*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
+*----------------------------------------------------------*
+*  Â©1995 Artsoft Development                               *
+*        Holger Schemel                                    *
+*        33659 Bielefeld-Senne                             *
+*        Telefon: (0521) 493245                            *
+*        eMail: aeglos@valinor.owl.de                      *
+*               aeglos@uni-paderborn.de                    *
+*               q99492@pbhrzx.uni-paderborn.de             *
+*----------------------------------------------------------*
+*  system.h                                                *
+***********************************************************/
+
+#ifndef SYSTEM_H
+#define SYSTEM_H
+
+#ifndef MSDOS
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include <X11/Intrinsic.h>
+#include <X11/keysymdef.h>
+#endif
+
+#ifdef USE_SDL_LIBRARY
+#include "sdl.h"
+#endif
+
+#ifdef USE_SDL_LIBRARY
+typedef SDL_Surface *Bitmap;
+typedef SDL_Surface *DrawWindow;
+typedef SDL_Surface *DrawBuffer;
+#else
+typedef Pixmap Bitmap;
+typedef Window DrawWindow;
+typedef Drawable DrawBuffer;
+#endif
+
+#ifdef USE_SDL_LIBRARY
+
+typedef SDL_Event              Event;
+typedef SDL_MouseButtonEvent   ButtonEvent;
+typedef SDL_MouseMotionEvent   MotionEvent;
+typedef XKeyEvent              KeyEvent;
+typedef XExposeEvent           ExposeEvent;
+typedef XFocusChangeEvent      FocusChangeEvent;
+typedef XClientMessageEvent    ClientMessageEvent;
+
+#define EVENT_BUTTONPRESS      SDL_MOUSEBUTTONDOWN
+#define EVENT_BUTTONRELEASE    SDL_MOUSEBUTTONUP
+#define EVENT_MOTIONNOTIFY     SDL_MOUSEMOTION
+#define EVENT_KEYPRESS         SDL_KEYDOWN
+#define EVENT_KEYRELEASE       SDL_KEYUP
+#define EVENT_EXPOSE           SDL_USEREVENT + 0
+#define EVENT_FOCUSIN          SDL_USEREVENT + 1
+#define EVENT_FOCUSOUT         SDL_USEREVENT + 2
+#define EVENT_CLIENTMESSAGE    SDL_QUIT
+#define EVENT_MAPNOTIFY                SDL_USEREVENT + 4
+#define EVENT_UNMAPNOTIFY      SDL_USEREVENT + 5
+
+#else
+
+typedef XEvent                 Event;
+typedef XButtonEvent           ButtonEvent;
+typedef XMotionEvent           MotionEvent;
+typedef XKeyEvent              KeyEvent;
+typedef XExposeEvent           ExposeEvent;
+typedef XFocusChangeEvent      FocusChangeEvent;
+typedef XClientMessageEvent    ClientMessageEvent;
+
+#define EVENT_BUTTONPRESS      ButtonPress
+#define EVENT_BUTTONRELEASE    ButtonRelease
+#define EVENT_MOTIONNOTIFY     MotionNotify
+#define EVENT_KEYPRESS         KeyPress
+#define EVENT_KEYRELEASE       KeyRelease
+#define EVENT_EXPOSE           Expose
+#define EVENT_FOCUSIN          FocusIn
+#define EVENT_FOCUSOUT         FocusOut
+#define EVENT_CLIENTMESSAGE    ClientMessage
+#define EVENT_MAPNOTIFY                MapNotify
+#define EVENT_UNMAPNOTIFY      UnmapNotify
+
+#endif
+
+inline void ClearRectangle(Bitmap, int, int, int, int);
+inline void BlitBitmap(Bitmap, Bitmap, int, int, int, int, int, int);
+inline void SetClipMask(GC, Pixmap);
+inline void SetClipOrigin(GC, int, int);
+inline void BlitBitmapMasked(Bitmap, Bitmap, int, int, int, int, int, int);
+inline void DrawSimpleWhiteLine(Bitmap, int, int, int, int);
+
+inline void FlushDisplay();
+inline void SyncDisplay();
+inline void KeyboardAutoRepeatOn();
+inline void KeyboardAutoRepeatOff();
+inline boolean QueryPointer(DrawWindow, int *, int *);
+
+inline boolean PendingEvent();
+inline void NextEvent(Event *event);
+
+#endif /* SYSTEM_H */
index 15a8dc2098973ee82bf3654264fac7f5e4a7657d..f778c71583ff1bedb21cafdb12419046518506ac 100644 (file)
@@ -328,7 +328,7 @@ void CreateTapeButtons()
 
   for (i=0; i<NUM_TAPE_BUTTONS; i++)
   {
-    Pixmap gd_pixmap = pix[PIX_DOOR];
+    Bitmap gd_bitmap = pix[PIX_DOOR];
     struct GadgetInfo *gi;
     int gd_xoffset, gd_yoffset;
     int gd_x1, gd_x2, gd_y;
@@ -348,8 +348,8 @@ void CreateTapeButtons()
                      GDI_HEIGHT, TAPE_BUTTON_YSIZE,
                      GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
                      GDI_EVENT_MASK, GD_EVENT_RELEASED,
                      GDI_CALLBACK_ACTION, HandleTapeButtons,
                      GDI_END);
index 0c9cd1766e69264bcacc83ed69a7f278ac7d9e96..51ba20555a210ed3419bc2f6c98972b48dbb92bd 100644 (file)
@@ -85,7 +85,7 @@ void SetDrawtoField(int mode)
 void BackToFront()
 {
   int x,y;
-  Drawable buffer = (drawto_field == window ? backbuffer : drawto_field);
+  DrawBuffer buffer = (drawto_field == window ? backbuffer : drawto_field);
 
   if (setup.direct_draw && game_status == PLAYING)
     redraw_mask &= ~REDRAW_MAIN;
@@ -104,13 +104,11 @@ void BackToFront()
      this could mean that we have to wait for the graphics to complete,
      although we could go on doing calculations for the next frame */
 
-  XSync(display, FALSE);
+  SyncDisplay();
 
   if (redraw_mask & REDRAW_ALL)
   {
-    XCopyArea(display, backbuffer, window, gc,
-             0, 0, WIN_XSIZE, WIN_YSIZE,
-             0, 0);
+    BlitBitmap(backbuffer, window, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
     redraw_mask = 0;
   }
 
@@ -118,9 +116,8 @@ void BackToFront()
   {
     if (game_status != PLAYING || redraw_mask & REDRAW_FROM_BACKBUFFER)
     {
-      XCopyArea(display, backbuffer, window, gc,
-               REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
-               REAL_SX, REAL_SY);
+      BlitBitmap(backbuffer, window,
+                REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, REAL_SX, REAL_SY);
     }
     else
     {
@@ -137,7 +134,7 @@ void BackToFront()
          ABS(ScreenMovPos) == ScrollStepSize ||
          redraw_tiles > REDRAWTILES_THRESHOLD)
       {
-       XCopyArea(display, buffer, window, gc, fx, fy, SXSIZE, SYSIZE, SX, SY);
+       BlitBitmap(buffer, window, fx, fy, SXSIZE, SYSIZE, SX, SY);
 
 #ifdef DEBUG
 #if 0
@@ -160,49 +157,43 @@ void BackToFront()
   if (redraw_mask & REDRAW_DOORS)
   {
     if (redraw_mask & REDRAW_DOOR_1)
-      XCopyArea(display, backbuffer, window, gc,
-               DX, DY, DXSIZE, DYSIZE,
-               DX, DY);
+      BlitBitmap(backbuffer, window, DX, DY, DXSIZE, DYSIZE, DX, DY);
     if (redraw_mask & REDRAW_DOOR_2)
     {
       if ((redraw_mask & REDRAW_DOOR_2) == REDRAW_DOOR_2)
-       XCopyArea(display,backbuffer,window,gc,
-                 VX,VY, VXSIZE,VYSIZE,
-                 VX,VY);
+       BlitBitmap(backbuffer, window, VX,VY, VXSIZE,VYSIZE, VX,VY);
       else
       {
        if (redraw_mask & REDRAW_VIDEO_1)
-         XCopyArea(display,backbuffer,window,gc,
-                   VX+VIDEO_DISPLAY1_XPOS,VY+VIDEO_DISPLAY1_YPOS,
-                   VIDEO_DISPLAY_XSIZE,VIDEO_DISPLAY_YSIZE,
-                   VX+VIDEO_DISPLAY1_XPOS,VY+VIDEO_DISPLAY1_YPOS);
+         BlitBitmap(backbuffer, window,
+                    VX+VIDEO_DISPLAY1_XPOS,VY+VIDEO_DISPLAY1_YPOS,
+                    VIDEO_DISPLAY_XSIZE,VIDEO_DISPLAY_YSIZE,
+                    VX+VIDEO_DISPLAY1_XPOS,VY+VIDEO_DISPLAY1_YPOS);
        if (redraw_mask & REDRAW_VIDEO_2)
-         XCopyArea(display,backbuffer,window,gc,
-                   VX+VIDEO_DISPLAY2_XPOS,VY+VIDEO_DISPLAY2_YPOS,
-                   VIDEO_DISPLAY_XSIZE,VIDEO_DISPLAY_YSIZE,
-                   VX+VIDEO_DISPLAY2_XPOS,VY+VIDEO_DISPLAY2_YPOS);
+         BlitBitmap(backbuffer, window,
+                    VX+VIDEO_DISPLAY2_XPOS,VY+VIDEO_DISPLAY2_YPOS,
+                    VIDEO_DISPLAY_XSIZE,VIDEO_DISPLAY_YSIZE,
+                    VX+VIDEO_DISPLAY2_XPOS,VY+VIDEO_DISPLAY2_YPOS);
        if (redraw_mask & REDRAW_VIDEO_3)
-         XCopyArea(display,backbuffer,window,gc,
-                   VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS,
-                   VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
-                   VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
+         BlitBitmap(backbuffer, window,
+                    VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS,
+                    VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
+                    VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
       }
     }
     if (redraw_mask & REDRAW_DOOR_3)
-      XCopyArea(display, backbuffer, window, gc,
-               EX, EY, EXSIZE, EYSIZE,
-               EX, EY);
+      BlitBitmap(backbuffer, window, EX, EY, EXSIZE, EYSIZE, EX, EY);
     redraw_mask &= ~REDRAW_DOORS;
   }
 
   if (redraw_mask & REDRAW_MICROLEVEL)
   {
-    XCopyArea(display,backbuffer,window,gc,
-             MICROLEV_XPOS, MICROLEV_YPOS, MICROLEV_XSIZE, MICROLEV_YSIZE,
-             MICROLEV_XPOS, MICROLEV_YPOS);
-    XCopyArea(display,backbuffer,window,gc,
-             SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE,
-             SX, MICROLABEL_YPOS);
+    BlitBitmap(backbuffer, window,
+              MICROLEV_XPOS, MICROLEV_YPOS, MICROLEV_XSIZE, MICROLEV_YSIZE,
+              MICROLEV_XPOS, MICROLEV_YPOS);
+    BlitBitmap(backbuffer, window,
+              SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE,
+              SX, MICROLABEL_YPOS);
     redraw_mask &= ~REDRAW_MICROLEVEL;
   }
 
@@ -211,12 +202,12 @@ void BackToFront()
     for(x=0; x<SCR_FIELDX; x++)
       for(y=0; y<SCR_FIELDY; y++)
        if (redraw[redraw_x1 + x][redraw_y1 + y])
-         XCopyArea(display, buffer, window, gc,
-                   FX + x * TILEX, FX + y * TILEY, TILEX, TILEY,
-                   SX + x * TILEX, SY + y * TILEY);
+         BlitBitmap(buffer, window,
+                    FX + x * TILEX, FX + y * TILEY, TILEX, TILEY,
+                    SX + x * TILEX, SY + y * TILEY);
   }
 
-  XFlush(display);
+  FlushDisplay();
 
   for(x=0; x<MAX_BUF_XSIZE; x++)
     for(y=0; y<MAX_BUF_YSIZE; y++)
@@ -227,80 +218,82 @@ void BackToFront()
 
 void FadeToFront()
 {
-/*
+#if 0
   long fading_delay = 300;
 
   if (setup.fading && (redraw_mask & REDRAW_FIELD))
   {
-*/
+#endif
 
-/*
+#if 0
     int x,y;
 
-    XFillRectangle(display,window,gc,
-                  REAL_SX,REAL_SY,FULL_SXSIZE,FULL_SYSIZE);
-    XFlush(display);
+    ClearRectangle(window, REAL_SX,REAL_SY,FULL_SXSIZE,FULL_SYSIZE);
+    FlushDisplay();
 
     for(i=0;i<2*FULL_SYSIZE;i++)
     {
       for(y=0;y<FULL_SYSIZE;y++)
       {
-       XCopyArea(display,backbuffer,window,gc,
-                 REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
+       BlitBitmap(backbuffer, window,
+                  REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
       }
-      XFlush(display);
+      FlushDisplay();
       Delay(10);
     }
-*/
+#endif
 
-/*
+#if 0
     for(i=1;i<FULL_SYSIZE;i+=2)
-      XCopyArea(display,backbuffer,window,gc,
-               REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
-    XFlush(display);
+      BlitBitmap(backbuffer, window,
+                REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
+    FlushDisplay();
     Delay(fading_delay);
-*/
+#endif
 
-/*
-    XSetClipOrigin(display,clip_gc[PIX_FADEMASK],0,0);
-    XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
-             REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
-    XFlush(display);
+#if 0
+    SetClipOrigin(clip_gc[PIX_FADEMASK], 0, 0);
+    BlitBitmapMasked(backbuffer, window,
+                    REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE,
+                    REAL_SX,REAL_SY);
+    FlushDisplay();
     Delay(fading_delay);
 
-    XSetClipOrigin(display,clip_gc[PIX_FADEMASK],-1,-1);
-    XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
-             REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
-    XFlush(display);
+    SetClipOrigin(clip_gc[PIX_FADEMASK], -1, -1);
+    BlitBitmapMasked(backbuffer, window,
+                    REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE,
+                    REAL_SX,REAL_SY);
+    FlushDisplay();
     Delay(fading_delay);
 
-    XSetClipOrigin(display,clip_gc[PIX_FADEMASK],0,-1);
-    XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
-             REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
-    XFlush(display);
+    SetClipOrigin(clip_gc[PIX_FADEMASK], 0, -1);
+    BlitBitmapMasked(backbuffer, window,
+                    REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE,
+                    REAL_SX,REAL_SY);
+    FlushDisplay();
     Delay(fading_delay);
 
-    XSetClipOrigin(display,clip_gc[PIX_FADEMASK],-1,0);
-    XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
-             REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
-    XFlush(display);
+    SetClipOrigin(clip_gc[PIX_FADEMASK], -1, 0);
+    BlitBitmapMasked(backbuffer, window,
+                    REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE,
+                    REAL_SX,REAL_SY);
+    FlushDisplay();
     Delay(fading_delay);
 
     redraw_mask &= ~REDRAW_MAIN;
   }
-*/
+#endif
 
   BackToFront();
 }
 
 void ClearWindow()
 {
-  XFillRectangle(display, backbuffer, gc,
-                REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
+  ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
 
   if (setup.soft_scrolling && game_status == PLAYING)
   {
-    XFillRectangle(display, fieldbuffer, gc, 0, 0, FXSIZE, FYSIZE);
+    ClearRectangle(fieldbuffer, 0, 0, FXSIZE, FYSIZE);
     SetDrawtoField(DRAW_BUFFERED);
   }
   else
@@ -308,8 +301,7 @@ void ClearWindow()
 
   if (setup.direct_draw && game_status == PLAYING)
   {
-    XFillRectangle(display, window, gc,
-                  REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
+    ClearRectangle(window, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
     SetDrawtoField(DRAW_DIRECT);
   }
 
@@ -339,20 +331,20 @@ int getFontHeight(int font_size, int font_type)
 void DrawInitText(char *text, int ypos, int color)
 {
 #ifdef USE_SDL_LIBRARY
-  if (sdl_window && sdl_pix[PIX_SMALLFONT])
+  if (window && pix[PIX_SMALLFONT])
   {
-    SDLFillRectangle(sdl_window, 0, ypos, WIN_XSIZE, FONT2_YSIZE, 0x000000);
+    ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
     DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2,
-               ypos,text,FS_SMALL,color);
-    SDL_Flip(sdl_window);
+               ypos, text, FS_SMALL, color);
+    SDL_Flip(window);
   }
 #else
   if (display && window && pix[PIX_SMALLFONT])
   {
-    XFillRectangle(display, window, gc, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
+    ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
     DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2,
-               ypos,text,FS_SMALL,color);
-    XFlush(display);
+               ypos, text, FS_SMALL, color);
+    FlushDisplay();
   }
 #endif
 }
@@ -393,11 +385,11 @@ void DrawText(int x, int y, char *text, int font_size, int font_type)
     redraw_mask |= REDRAW_DOOR_1;
 }
 
-void DrawTextExt(Drawable d, GC gc, int x, int y,
+void DrawTextExt(DrawBuffer d, GC gc, int x, int y,
                 char *text, int font_size, int font_type)
 {
   int font_width, font_height, font_start;
-  int font_pixmap;
+  int font_bitmap;
   boolean print_inverse = FALSE;
 
   if (font_size != FS_SMALL && font_size != FS_BIG && font_size != FS_MEDIUM)
@@ -408,7 +400,7 @@ void DrawTextExt(Drawable d, GC gc, int x, int y,
   font_width = getFontWidth(font_size, font_type);
   font_height = getFontHeight(font_size, font_type);
 
-  font_pixmap = (font_size == FS_BIG ? PIX_BIGFONT :
+  font_bitmap = (font_size == FS_BIG ? PIX_BIGFONT :
                 font_size == FS_MEDIUM ? PIX_MEDIUMFONT :
                 PIX_SMALLFONT);
   font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE :
@@ -446,26 +438,18 @@ void DrawTextExt(Drawable d, GC gc, int x, int y,
 
       if (print_inverse)
       {
-       XCopyArea(display, pix[font_pixmap], d, gc,
-                 FONT_CHARS_PER_LINE * font_width,
-                 3 * font_height + font_start,
-                 font_width, font_height, x, y);
-
-       XSetClipOrigin(display, clip_gc[font_pixmap],
-                      dest_x - src_x, dest_y - src_y);
-       XCopyArea(display, pix[font_pixmap], d, clip_gc[font_pixmap],
-                 0, 0, font_width, font_height, dest_x, dest_y);
+       BlitBitmap(pix[font_bitmap], d,
+                  FONT_CHARS_PER_LINE * font_width,
+                  3 * font_height + font_start,
+                  font_width, font_height, x, y);
+
+       SetClipOrigin(clip_gc[font_bitmap], dest_x - src_x, dest_y - src_y);
+       BlitBitmapMasked(pix_masked[font_bitmap], d,
+                        0, 0, font_width, font_height, dest_x, dest_y);
       }
       else
-      {
-#ifdef USE_SDL_LIBRARY
-       SDLCopyArea(sdl_pix[font_pixmap], sdl_window,
-                   src_x, src_y, font_width, font_height, dest_x, dest_y);
-#else
-       XCopyArea(display, pix[font_pixmap], d, gc,
-                 src_x, src_y, font_width, font_height, dest_x, dest_y);
-#endif
-      }
+       BlitBitmap(pix[font_bitmap], d,
+                  src_x, src_y, font_width, font_height, dest_x, dest_y);
     }
 
     x += font_width;
@@ -728,8 +712,8 @@ void DrawPlayer(struct PlayerInfo *player)
     int x_size = TILEX * (1 + ABS(jx - last_jx));
     int y_size = TILEY * (1 + ABS(jy - last_jy));
 
-    XCopyArea(display, drawto_field, window, gc,
-             dest_x, dest_y, x_size, y_size, dest_x, dest_y);
+    BlitBitmap(drawto_field, window,
+              dest_x, dest_y, x_size, y_size, dest_x, dest_y);
     SetDrawtoField(DRAW_DIRECT);
   }
 
@@ -792,54 +776,54 @@ static void DrawGraphicAnimationShiftedThruMask(int sx, int sy,
   DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic + phase, NO_CUTTING);
 }
 
-void getGraphicSource(int graphic, int *pixmap_nr, int *x, int *y)
+void getGraphicSource(int graphic, int *bitmap_nr, int *x, int *y)
 {
   if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
   {
     graphic -= GFX_START_ROCKSSCREEN;
-    *pixmap_nr = PIX_BACK;
+    *bitmap_nr = PIX_BACK;
     *x = SX + (graphic % GFX_PER_LINE) * TILEX;
     *y = SY + (graphic / GFX_PER_LINE) * TILEY;
   }
   else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
   {
     graphic -= GFX_START_ROCKSHEROES;
-    *pixmap_nr = PIX_HEROES;
+    *bitmap_nr = PIX_HEROES;
     *x = (graphic % HEROES_PER_LINE) * TILEX;
     *y = (graphic / HEROES_PER_LINE) * TILEY;
   }
   else if (graphic >= GFX_START_ROCKSSP && graphic <= GFX_END_ROCKSSP)
   {
     graphic -= GFX_START_ROCKSSP;
-    *pixmap_nr = PIX_SP;
+    *bitmap_nr = PIX_SP;
     *x = (graphic % SP_PER_LINE) * TILEX;
     *y = (graphic / SP_PER_LINE) * TILEY;
   }
   else if (graphic >= GFX_START_ROCKSDC && graphic <= GFX_END_ROCKSDC)
   {
     graphic -= GFX_START_ROCKSDC;
-    *pixmap_nr = PIX_DC;
+    *bitmap_nr = PIX_DC;
     *x = (graphic % DC_PER_LINE) * TILEX;
     *y = (graphic / DC_PER_LINE) * TILEY;
   }
   else if (graphic >= GFX_START_ROCKSMORE && graphic <= GFX_END_ROCKSMORE)
   {
     graphic -= GFX_START_ROCKSMORE;
-    *pixmap_nr = PIX_MORE;
+    *bitmap_nr = PIX_MORE;
     *x = (graphic % MORE_PER_LINE) * TILEX;
     *y = (graphic / MORE_PER_LINE) * TILEY;
   }
   else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT)
   {
     graphic -= GFX_START_ROCKSFONT;
-    *pixmap_nr = PIX_BIGFONT;
+    *bitmap_nr = PIX_BIGFONT;
     *x = (graphic % FONT_CHARS_PER_LINE) * TILEX;
     *y = ((graphic / FONT_CHARS_PER_LINE) * TILEY +
          FC_SPECIAL1 * FONT_LINES_PER_FONT * TILEY);
   }
   else
   {
-    *pixmap_nr = PIX_SP;
+    *bitmap_nr = PIX_SP;
     *x = 0;
     *y = 0;
   }
@@ -860,14 +844,13 @@ void DrawGraphic(int x, int y, int graphic)
   MarkTileDirty(x,y);
 }
 
-void DrawGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
+void DrawGraphicExt(DrawBuffer d, GC gc, int x, int y, int graphic)
 {
-  int pixmap_nr;
+  int bitmap_nr;
   int src_x, src_y;
 
-  getGraphicSource(graphic, &pixmap_nr, &src_x, &src_y);
-  XCopyArea(display, pix[pixmap_nr], d, gc,
-           src_x, src_y, TILEX, TILEY, x, y);
+  getGraphicSource(graphic, &bitmap_nr, &src_x, &src_y);
+  BlitBitmap(pix[bitmap_nr], d, src_x, src_y, TILEX, TILEY, x, y);
 }
 
 void DrawGraphicThruMask(int x, int y, int graphic)
@@ -885,37 +868,39 @@ void DrawGraphicThruMask(int x, int y, int graphic)
   MarkTileDirty(x,y);
 }
 
-void DrawGraphicThruMaskExt(Drawable d, int dest_x, int dest_y, int graphic)
+void DrawGraphicThruMaskExt(DrawBuffer d, int dest_x, int dest_y, int graphic)
 {
   int tile = graphic;
-  int pixmap_nr;
+  int bitmap_nr;
   int src_x, src_y;
-  Pixmap src_pixmap;
+  Bitmap src_bitmap;
   GC drawing_gc;
 
   if (graphic == GFX_LEERRAUM)
     return;
 
-  getGraphicSource(graphic, &pixmap_nr, &src_x, &src_y);
-  src_pixmap = pix[pixmap_nr];
-  drawing_gc = clip_gc[pixmap_nr];
+  getGraphicSource(graphic, &bitmap_nr, &src_x, &src_y);
+  src_bitmap = pix_masked[bitmap_nr];
+  drawing_gc = clip_gc[bitmap_nr];
 
   if (tile_clipmask[tile] != None)
   {
-    XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]);
-    XSetClipOrigin(display, tile_clip_gc, dest_x, dest_y);
-    XCopyArea(display, src_pixmap, d, tile_clip_gc,
-             src_x, src_y, TILEX, TILEY, dest_x, dest_y);
+    SetClipMask(tile_clip_gc, tile_clipmask[tile]);
+    SetClipOrigin(tile_clip_gc, dest_x, dest_y);
+    BlitBitmapMasked(src_bitmap, d,
+                    src_x, src_y, TILEX, TILEY, dest_x, dest_y);
   }
   else
   {
 #if DEBUG
+#ifndef USE_SDL_LIBRARY
     printf("DrawGraphicThruMask(): tile '%d' needs clipping!\n", tile);
+#endif
 #endif
 
-    XSetClipOrigin(display, drawing_gc, dest_x-src_x, dest_y-src_y);
-    XCopyArea(display, src_pixmap, d, drawing_gc,
-             src_x, src_y, TILEX, TILEY, dest_x, dest_y);
+    SetClipOrigin(drawing_gc, dest_x-src_x, dest_y-src_y);
+    BlitBitmapMasked(src_bitmap, d,
+                    src_x, src_y, TILEX, TILEY, dest_x, dest_y);
   }
 }
 
@@ -925,12 +910,12 @@ void DrawMiniGraphic(int x, int y, int graphic)
   MarkTileDirty(x/2, y/2);
 }
 
-void getMiniGraphicSource(int graphic, Pixmap *pixmap, int *x, int *y)
+void getMiniGraphicSource(int graphic, Bitmap *bitmap, int *x, int *y)
 {
   if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
   {
     graphic -= GFX_START_ROCKSSCREEN;
-    *pixmap = pix[PIX_BACK];
+    *bitmap = pix[PIX_BACK];
     *x = MINI_GFX_STARTX + (graphic % MINI_GFX_PER_LINE) * MINI_TILEX;
     *y = MINI_GFX_STARTY + (graphic / MINI_GFX_PER_LINE) * MINI_TILEY;
   }
@@ -938,48 +923,47 @@ void getMiniGraphicSource(int graphic, Pixmap *pixmap, int *x, int *y)
   {
     graphic -= GFX_START_ROCKSSP;
     graphic -= ((graphic / SP_PER_LINE) * SP_PER_LINE) / 2;
-    *pixmap = pix[PIX_SP];
+    *bitmap = pix[PIX_SP];
     *x = MINI_SP_STARTX + (graphic % MINI_SP_PER_LINE) * MINI_TILEX;
     *y = MINI_SP_STARTY + (graphic / MINI_SP_PER_LINE) * MINI_TILEY;
   }
   else if (graphic >= GFX_START_ROCKSDC && graphic <= GFX_END_ROCKSDC)
   {
     graphic -= GFX_START_ROCKSDC;
-    *pixmap = pix[PIX_DC];
+    *bitmap = pix[PIX_DC];
     *x = MINI_DC_STARTX + (graphic % MINI_DC_PER_LINE) * MINI_TILEX;
     *y = MINI_DC_STARTY + (graphic / MINI_DC_PER_LINE) * MINI_TILEY;
   }
   else if (graphic >= GFX_START_ROCKSMORE && graphic <= GFX_END_ROCKSMORE)
   {
     graphic -= GFX_START_ROCKSMORE;
-    *pixmap = pix[PIX_MORE];
+    *bitmap = pix[PIX_MORE];
     *x = MINI_MORE_STARTX + (graphic % MINI_MORE_PER_LINE) * MINI_TILEX;
     *y = MINI_MORE_STARTY + (graphic / MINI_MORE_PER_LINE) * MINI_TILEY;
   }
   else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT)
   {
     graphic -= GFX_START_ROCKSFONT;
-    *pixmap = pix[PIX_SMALLFONT];
+    *bitmap = pix[PIX_SMALLFONT];
     *x = (graphic % FONT_CHARS_PER_LINE) * FONT4_XSIZE;
     *y = ((graphic / FONT_CHARS_PER_LINE) * FONT4_YSIZE +
              FC_SPECIAL2 * FONT2_YSIZE * FONT_LINES_PER_FONT);
   }
   else
   {
-    *pixmap = pix[PIX_SP];
+    *bitmap = pix[PIX_SP];
     *x = MINI_SP_STARTX;
     *y = MINI_SP_STARTY;
   }
 }
 
-void DrawMiniGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
+void DrawMiniGraphicExt(DrawBuffer d, GC gc, int x, int y, int graphic)
 {
-  Pixmap pixmap;
+  Bitmap bitmap;
   int src_x, src_y;
 
-  getMiniGraphicSource(graphic, &pixmap, &src_x, &src_y);
-  XCopyArea(display, pixmap, d, gc,
-           src_x, src_y, MINI_TILEX, MINI_TILEY, x, y);
+  getMiniGraphicSource(graphic, &bitmap, &src_x, &src_y);
+  BlitBitmap(bitmap, d, src_x, src_y, MINI_TILEX, MINI_TILEY, x, y);
 }
 
 void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic,
@@ -989,8 +973,7 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic,
   int cx = 0, cy = 0;
   int src_x, src_y, dest_x, dest_y;
   int tile = graphic;
-  int pixmap_nr;
-  Pixmap src_pixmap;
+  int bitmap_nr;
   GC drawing_gc;
 
   if (graphic < 0)
@@ -1063,9 +1046,8 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic,
       MarkTileDirty(x, y + SIGN(dy));
   }
 
-  getGraphicSource(graphic, &pixmap_nr, &src_x, &src_y);
-  src_pixmap = pix[pixmap_nr];
-  drawing_gc = clip_gc[pixmap_nr];
+  getGraphicSource(graphic, &bitmap_nr, &src_x, &src_y);
+  drawing_gc = clip_gc[bitmap_nr];
 
   src_x += cx;
   src_y += cy;
@@ -1086,25 +1068,27 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic,
   {
     if (tile_clipmask[tile] != None)
     {
-      XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]);
-      XSetClipOrigin(display, tile_clip_gc, dest_x, dest_y);
-      XCopyArea(display, src_pixmap, drawto_field, tile_clip_gc,
-               src_x, src_y, TILEX, TILEY, dest_x, dest_y);
+      SetClipMask(tile_clip_gc, tile_clipmask[tile]);
+      SetClipOrigin(tile_clip_gc, dest_x, dest_y);
+      BlitBitmapMasked(pix_masked[bitmap_nr], drawto_field,
+                      src_x, src_y, TILEX, TILEY, dest_x, dest_y);
     }
     else
     {
 #if DEBUG
+#ifndef        USE_SDL_LIBRARY
       printf("DrawGraphicShifted(): tile '%d' needs clipping!\n", tile);
+#endif
 #endif
 
-      XSetClipOrigin(display, drawing_gc, dest_x - src_x, dest_y - src_y);
-      XCopyArea(display, src_pixmap, drawto_field, drawing_gc,
-               src_x, src_y, width, height, dest_x, dest_y);
+      SetClipOrigin(drawing_gc, dest_x - src_x, dest_y - src_y);
+      BlitBitmapMasked(pix_masked[bitmap_nr], drawto_field,
+                      src_x, src_y, width, height, dest_x, dest_y);
     }
   }
   else
-    XCopyArea(display, src_pixmap, drawto_field, gc,
-             src_x, src_y, width, height, dest_x, dest_y);
+    BlitBitmap(pix[bitmap_nr], drawto_field,
+              src_x, src_y, width, height, dest_x, dest_y);
 
   MarkTileDirty(x,y);
 }
@@ -1354,10 +1338,10 @@ void ErdreichAnbroeckeln(int x, int y)
        cy = (i == 3 ? TILEY - snip : 0);
       }
 
-      XCopyArea(display, pix[PIX_BACK], drawto_field, gc,
-               SX + (graphic % GFX_PER_LINE) * TILEX + cx,
-               SY + (graphic / GFX_PER_LINE) * TILEY + cy,
-               width, height, FX + x * TILEX + cx, FY + y * TILEY + cy);
+      BlitBitmap(pix[PIX_BACK], drawto_field,
+                SX + (graphic % GFX_PER_LINE) * TILEX + cx,
+                SY + (graphic / GFX_PER_LINE) * TILEY + cy,
+                width, height, FX + x * TILEX + cx, FY + y * TILEY + cy);
     }
 
     MarkTileDirty(x, y);
@@ -1398,10 +1382,10 @@ void ErdreichAnbroeckeln(int x, int y)
        cy = (i==0 ? TILEY-snip : 0);
       }
 
-      XCopyArea(display, pix[PIX_BACK], drawto_field, gc,
-               SX + (graphic % GFX_PER_LINE) * TILEX + cx,
-               SY + (graphic / GFX_PER_LINE) * TILEY + cy,
-               width, height, FX + xx * TILEX + cx, FY + yy * TILEY + cy);
+      BlitBitmap(pix[PIX_BACK], drawto_field,
+                SX + (graphic % GFX_PER_LINE) * TILEX + cx,
+                SY + (graphic / GFX_PER_LINE) * TILEY + cy,
+                width, height, FX + xx * TILEX + cx, FY + yy * TILEY + cy);
 
       MarkTileDirty(xx, yy);
     }
@@ -1582,32 +1566,32 @@ void DrawMicroElement(int xpos, int ypos, int element)
   {
     graphic -= GFX_START_ROCKSSP;
     graphic -= ((graphic / SP_PER_LINE) * SP_PER_LINE) / 2;
-    XCopyArea(display, pix[PIX_SP], drawto, gc,
-             MICRO_SP_STARTX + (graphic % MICRO_SP_PER_LINE) * MICRO_TILEX,
-             MICRO_SP_STARTY + (graphic / MICRO_SP_PER_LINE) * MICRO_TILEY,
-             MICRO_TILEX, MICRO_TILEY, xpos, ypos);
+    BlitBitmap(pix[PIX_SP], drawto,
+              MICRO_SP_STARTX + (graphic % MICRO_SP_PER_LINE) * MICRO_TILEX,
+              MICRO_SP_STARTY + (graphic / MICRO_SP_PER_LINE) * MICRO_TILEY,
+              MICRO_TILEX, MICRO_TILEY, xpos, ypos);
   }
   else if (graphic >= GFX_START_ROCKSDC && graphic <= GFX_END_ROCKSDC)
   {
     graphic -= GFX_START_ROCKSDC;
-    XCopyArea(display, pix[PIX_DC], drawto, gc,
-             MICRO_DC_STARTX + (graphic % MICRO_DC_PER_LINE) * MICRO_TILEX,
-             MICRO_DC_STARTY + (graphic / MICRO_DC_PER_LINE) * MICRO_TILEY,
-             MICRO_TILEX, MICRO_TILEY, xpos, ypos);
+    BlitBitmap(pix[PIX_DC], drawto,
+              MICRO_DC_STARTX + (graphic % MICRO_DC_PER_LINE) * MICRO_TILEX,
+              MICRO_DC_STARTY + (graphic / MICRO_DC_PER_LINE) * MICRO_TILEY,
+              MICRO_TILEX, MICRO_TILEY, xpos, ypos);
   }
   else if (graphic >= GFX_START_ROCKSMORE && graphic <= GFX_END_ROCKSMORE)
   {
     graphic -= GFX_START_ROCKSMORE;
-    XCopyArea(display, pix[PIX_MORE], drawto, gc,
-             MICRO_MORE_STARTX + (graphic % MICRO_MORE_PER_LINE) *MICRO_TILEX,
-             MICRO_MORE_STARTY + (graphic / MICRO_MORE_PER_LINE) *MICRO_TILEY,
-             MICRO_TILEX, MICRO_TILEY, xpos, ypos);
+    BlitBitmap(pix[PIX_MORE], drawto,
+              MICRO_MORE_STARTX + (graphic % MICRO_MORE_PER_LINE)*MICRO_TILEX,
+              MICRO_MORE_STARTY + (graphic / MICRO_MORE_PER_LINE)*MICRO_TILEY,
+              MICRO_TILEX, MICRO_TILEY, xpos, ypos);
   }
   else
-    XCopyArea(display, pix[PIX_BACK], drawto, gc,
-             MICRO_GFX_STARTX + (graphic % MICRO_GFX_PER_LINE) * MICRO_TILEX,
-             MICRO_GFX_STARTY + (graphic / MICRO_GFX_PER_LINE) * MICRO_TILEY,
-             MICRO_TILEX, MICRO_TILEY, xpos, ypos);
+    BlitBitmap(pix[PIX_BACK], drawto,
+              MICRO_GFX_STARTX + (graphic % MICRO_GFX_PER_LINE) * MICRO_TILEX,
+              MICRO_GFX_STARTY + (graphic / MICRO_GFX_PER_LINE) * MICRO_TILEY,
+              MICRO_TILEX, MICRO_TILEY, xpos, ypos);
 }
 
 void DrawLevel()
@@ -1638,8 +1622,7 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y)
 {
   int x, y;
 
-  XFillRectangle(display, drawto, gc,
-                xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE);
+  ClearRectangle(drawto, xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE);
 
   if (lev_fieldx < STD_LEV_FIELDX)
     xpos += (STD_LEV_FIELDX - lev_fieldx) / 2 * MICRO_TILEX;
@@ -1680,8 +1663,7 @@ static void DrawMicroLevelLabelExt(int mode)
 {
   char label_text[MAX_MICROLABEL_SIZE + 1];
 
-  XFillRectangle(display, drawto,gc,
-                SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE);
+  ClearRectangle(drawto, SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE);
 
   strncpy(label_text, (mode == MICROLABEL_LEVEL_NAME ? level.name :
                       mode == MICROLABEL_CREATED_BY ? "created by" :
@@ -1826,12 +1808,12 @@ boolean Request(char *text, unsigned int req_state)
   CloseDoor(DOOR_CLOSE_1);
 
   /* save old door content */
-  XCopyArea(display, pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], gc,
-           DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE,
-           DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1);
+  BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR],
+            DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE,
+            DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1);
 
   /* clear door drawing field */
-  XFillRectangle(display, drawto, gc, DX, DY, DXSIZE, DYSIZE);
+  ClearRectangle(drawto, DX, DY, DXSIZE, DYSIZE);
 
   /* write text for request */
   for(ty=0; ty<13; ty++)
@@ -1880,9 +1862,9 @@ boolean Request(char *text, unsigned int req_state)
   }
 
   /* copy request gadgets to door backbuffer */
-  XCopyArea(display, drawto, pix[PIX_DB_DOOR], gc,
-           DX, DY, DXSIZE, DYSIZE,
-           DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+  BlitBitmap(drawto, pix[PIX_DB_DOOR],
+            DX, DY, DXSIZE, DYSIZE,
+            DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
 
   OpenDoor(DOOR_OPEN_1);
 
@@ -1902,43 +1884,39 @@ boolean Request(char *text, unsigned int req_state)
 
   while(result < 0)
   {
-    if (XPending(display))
+    if (PendingEvent())
     {
-      XEvent event;
+      Event event;
 
-      XNextEvent(display, &event);
+      NextEvent(&event);
 
       switch(event.type)
       {
-       case ButtonPress:
-       case ButtonRelease:
-       case MotionNotify:
+       case EVENT_BUTTONPRESS:
+       case EVENT_BUTTONRELEASE:
+       case EVENT_MOTIONNOTIFY:
        {
-         if (event.type == MotionNotify)
+         if (event.type == EVENT_MOTIONNOTIFY)
          {
-           Window root, child;
-           int root_x, root_y;
            int win_x, win_y;
-           unsigned int mask;
 
-           if (!XQueryPointer(display, window, &root, &child,
-                              &root_x, &root_y, &win_x, &win_y, &mask))
-             continue;
+           if (!QueryPointer(window, &win_x, &win_y))
+             continue; /* window and pointer are on different screens */
 
            if (!button_status)
              continue;
 
            motion_status = TRUE;
-           mx = ((XMotionEvent *) &event)->x;
-           my = ((XMotionEvent *) &event)->y;
+           mx = ((MotionEvent *) &event)->x;
+           my = ((MotionEvent *) &event)->y;
          }
          else
          {
            motion_status = FALSE;
-           mx = ((XButtonEvent *) &event)->x;
-           my = ((XButtonEvent *) &event)->y;
-           if (event.type==ButtonPress)
-             button_status = ((XButtonEvent *) &event)->button;
+           mx = ((ButtonEvent *) &event)->x;
+           my = ((ButtonEvent *) &event)->y;
+           if (event.type == EVENT_BUTTONPRESS)
+             button_status = ((ButtonEvent *) &event)->button;
            else
              button_status = MB_RELEASED;
          }
@@ -1978,9 +1956,9 @@ boolean Request(char *text, unsigned int req_state)
          break;
        }
 
-       case KeyPress:
-         switch(XLookupKeysym((XKeyEvent *)&event,
-                              ((XKeyEvent *)&event)->state))
+       case EVENT_KEYPRESS:
+         switch(XLookupKeysym((KeyEvent *)&event,
+                              ((KeyEvent *)&event)->state))
          {
            case XK_Return:
              result = 1;
@@ -1997,7 +1975,7 @@ boolean Request(char *text, unsigned int req_state)
            result = 0;
          break;
 
-       case KeyRelease:
+       case EVENT_KEYRELEASE:
          key_joystick_mapping = 0;
          break;
 
@@ -2033,9 +2011,9 @@ boolean Request(char *text, unsigned int req_state)
 
     if (!(req_state & REQ_STAY_CLOSED) && (old_door_state & DOOR_OPEN_1))
     {
-      XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
-               DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
-               DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1);
+      BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR],
+                DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
+                DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1);
       OpenDoor(DOOR_OPEN_1);
     }
   }
@@ -2059,9 +2037,9 @@ unsigned int OpenDoor(unsigned int door_state)
 
   if (door_state & DOOR_COPY_BACK)
   {
-    XCopyArea(display, pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], gc,
-             DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE + VYSIZE,
-             DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+    BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR],
+              DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE + VYSIZE,
+              DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
     door_state &= ~DOOR_COPY_BACK;
   }
 
@@ -2074,10 +2052,10 @@ unsigned int CloseDoor(unsigned int door_state)
 {
   unsigned int new_door_state;
 
-  XCopyArea(display, backbuffer, pix[PIX_DB_DOOR], gc,
-           DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
-  XCopyArea(display, backbuffer, pix[PIX_DB_DOOR], gc,
-           VX, VY, VXSIZE, VYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
+  BlitBitmap(backbuffer, pix[PIX_DB_DOOR],
+            DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+  BlitBitmap(backbuffer, pix[PIX_DB_DOOR],
+            VX, VY, VXSIZE, VYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
 
   new_door_state = MoveDoor(door_state);
 
@@ -2132,40 +2110,41 @@ unsigned int MoveDoor(unsigned int door_state)
        int i = (door_state & DOOR_OPEN_1 ? DXSIZE-x : x);
        int j = (DXSIZE - i) / 3;
 
-       XCopyArea(display, pix[PIX_DB_DOOR], drawto, gc,
-                 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1 + i/2,
-                 DXSIZE,DYSIZE - i/2, DX, DY);
-
-       XFillRectangle(display, drawto, gc, DX, DY + DYSIZE - i/2, DXSIZE,i/2);
-
-       XSetClipOrigin(display, clip_gc[PIX_DOOR],
-                      DX - i, (DY + j) - DOOR_GFX_PAGEY1);
-       XCopyArea(display, pix[PIX_DOOR], drawto,clip_gc[PIX_DOOR],
-                 DXSIZE, DOOR_GFX_PAGEY1, i, 77, DX + DXSIZE - i, DY + j);
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 DXSIZE, DOOR_GFX_PAGEY1 + 140, i, 63, DX + DXSIZE - i,
-                 DY + 140 + j);
-       XSetClipOrigin(display, clip_gc[PIX_DOOR],
-                      DX - DXSIZE + i, DY - (DOOR_GFX_PAGEY1 + j));
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 DXSIZE - i, DOOR_GFX_PAGEY1 + j, i, 77 - j, DX, DY);
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 DXSIZE-i, DOOR_GFX_PAGEY1 + 140, i, 63, DX, DY + 140 - j);
-
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 DXSIZE - i, DOOR_GFX_PAGEY1 + 77, i, 63,
-                 DX, DY + 77 - j);
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 DXSIZE - i, DOOR_GFX_PAGEY1 + 203, i, 77,
-                 DX, DY + 203 - j);
-       XSetClipOrigin(display, clip_gc[PIX_DOOR],
-                      DX - i, (DY + j) - DOOR_GFX_PAGEY1);
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 DXSIZE, DOOR_GFX_PAGEY1 + 77, i, 63,
-                 DX + DXSIZE - i, DY + 77 + j);
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 DXSIZE, DOOR_GFX_PAGEY1 + 203, i, 77 - j,
-                 DX + DXSIZE - i, DY + 203 + j);
+       BlitBitmap(pix[PIX_DB_DOOR], drawto,
+                  DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1 + i/2,
+                  DXSIZE,DYSIZE - i/2, DX, DY);
+
+       ClearRectangle(drawto, DX, DY + DYSIZE - i/2, DXSIZE,i/2);
+
+       SetClipOrigin(clip_gc[PIX_DOOR], DX - i, (DY + j) - DOOR_GFX_PAGEY1);
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        DXSIZE, DOOR_GFX_PAGEY1, i, 77,
+                        DX + DXSIZE - i, DY + j);
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        DXSIZE, DOOR_GFX_PAGEY1 + 140, i, 63,
+                        DX + DXSIZE - i, DY + 140 + j);
+       SetClipOrigin(clip_gc[PIX_DOOR],
+                     DX - DXSIZE + i, DY - (DOOR_GFX_PAGEY1 + j));
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        DXSIZE - i, DOOR_GFX_PAGEY1 + j, i, 77 - j,
+                        DX, DY);
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        DXSIZE-i, DOOR_GFX_PAGEY1 + 140, i, 63,
+                        DX, DY + 140 - j);
+
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        DXSIZE - i, DOOR_GFX_PAGEY1 + 77, i, 63,
+                        DX, DY + 77 - j);
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        DXSIZE - i, DOOR_GFX_PAGEY1 + 203, i, 77,
+                        DX, DY + 203 - j);
+       SetClipOrigin(clip_gc[PIX_DOOR], DX - i, (DY + j) - DOOR_GFX_PAGEY1);
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        DXSIZE, DOOR_GFX_PAGEY1 + 77, i, 63,
+                        DX + DXSIZE - i, DY + 77 + j);
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        DXSIZE, DOOR_GFX_PAGEY1 + 203, i, 77 - j,
+                        DX + DXSIZE - i, DY + 203 + j);
 
        redraw_mask |= REDRAW_DOOR_1;
       }
@@ -2175,29 +2154,30 @@ unsigned int MoveDoor(unsigned int door_state)
        int i = (door_state & DOOR_OPEN_2 ? VXSIZE - x : x);
        int j = (VXSIZE - i) / 3;
 
-       XCopyArea(display, pix[PIX_DB_DOOR], drawto, gc,
-                 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2 + i/2,
-                 VXSIZE, VYSIZE - i/2, VX, VY);
-
-       XFillRectangle(display, drawto, gc, VX, VY + VYSIZE-i/2, VXSIZE, i/2);
-
-       XSetClipOrigin(display, clip_gc[PIX_DOOR],
-                      VX - i, (VY + j) - DOOR_GFX_PAGEY2);
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 VXSIZE, DOOR_GFX_PAGEY2, i, VYSIZE / 2, VX + VXSIZE-i, VY+j);
-       XSetClipOrigin(display, clip_gc[PIX_DOOR],
-                      VX - VXSIZE + i, VY - (DOOR_GFX_PAGEY2 + j));
-       XCopyArea(display, pix[PIX_DOOR], drawto,clip_gc[PIX_DOOR],
-                 VXSIZE - i, DOOR_GFX_PAGEY2 + j, i, VYSIZE / 2 - j, VX, VY);
-
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 VXSIZE - i, DOOR_GFX_PAGEY2 + VYSIZE / 2, i, VYSIZE / 2,
-                 VX, VY + VYSIZE / 2 - j);
-       XSetClipOrigin(display, clip_gc[PIX_DOOR],
-                      VX - i, (VY + j) - DOOR_GFX_PAGEY2);
-       XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR],
-                 VXSIZE, DOOR_GFX_PAGEY2 + VYSIZE / 2, i, VYSIZE / 2 - j,
-                 VX + VXSIZE - i, VY + VYSIZE / 2 + j);
+       BlitBitmap(pix[PIX_DB_DOOR], drawto,
+                  DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2 + i/2,
+                  VXSIZE, VYSIZE - i/2, VX, VY);
+
+       ClearRectangle(drawto, VX, VY + VYSIZE-i/2, VXSIZE, i/2);
+
+       SetClipOrigin(clip_gc[PIX_DOOR], VX - i, (VY + j) - DOOR_GFX_PAGEY2);
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        VXSIZE, DOOR_GFX_PAGEY2, i, VYSIZE / 2,
+                        VX + VXSIZE-i, VY+j);
+       SetClipOrigin(clip_gc[PIX_DOOR],
+                     VX - VXSIZE + i, VY - (DOOR_GFX_PAGEY2 + j));
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        VXSIZE - i, DOOR_GFX_PAGEY2 + j, i, VYSIZE / 2 - j,
+                        VX, VY);
+
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        VXSIZE - i, DOOR_GFX_PAGEY2 + VYSIZE / 2,
+                        i, VYSIZE / 2, VX, VY + VYSIZE / 2 - j);
+       SetClipOrigin(clip_gc[PIX_DOOR], VX - i, (VY + j) - DOOR_GFX_PAGEY2);
+       BlitBitmapMasked(pix_masked[PIX_DOOR], drawto,
+                        VXSIZE, DOOR_GFX_PAGEY2 + VYSIZE / 2,
+                        i, VYSIZE / 2 - j,
+                        VX + VXSIZE - i, VY + VYSIZE / 2 + j);
 
        redraw_mask |= REDRAW_DOOR_2;
       }
@@ -2223,8 +2203,8 @@ unsigned int MoveDoor(unsigned int door_state)
 void DrawSpecialEditorDoor()
 {
   /* draw bigger toolbox window */
-  XCopyArea(display, pix[PIX_DOOR], drawto, gc,
-           DOOR_GFX_PAGEX7, 0, 108, 56, EX - 4, EY - 12);
+  BlitBitmap(pix[PIX_DOOR], drawto,
+            DOOR_GFX_PAGEX7, 0, 108, 56, EX - 4, EY - 12);
 
   redraw_mask |= REDRAW_ALL;
 }
@@ -2232,13 +2212,14 @@ void DrawSpecialEditorDoor()
 void UndrawSpecialEditorDoor()
 {
   /* draw normal tape recorder window */
-  XCopyArea(display, pix[PIX_BACK], drawto, gc,
-           562, 344, 108, 56, EX - 4, EY - 12);
+  BlitBitmap(pix[PIX_BACK], drawto,
+            562, 344, 108, 56, EX - 4, EY - 12);
 
   redraw_mask |= REDRAW_ALL;
 }
 
-int ReadPixel(Drawable d, int x, int y)
+#ifndef        USE_SDL_LIBRARY
+int ReadPixel(DrawBuffer d, int x, int y)
 {
   XImage *pixel_image;
   unsigned long pixel_value;
@@ -2250,6 +2231,7 @@ int ReadPixel(Drawable d, int x, int y)
 
   return pixel_value;
 }
+#endif
 
 /* ---------- new tool button stuff ---------------------------------------- */
 
@@ -2363,8 +2345,8 @@ void CreateToolButtons()
 
   for (i=0; i<NUM_TOOL_BUTTONS; i++)
   {
-    Pixmap gd_pixmap = pix[PIX_DOOR];
-    Pixmap deco_pixmap = None;
+    Bitmap gd_bitmap = pix[PIX_DOOR];
+    Bitmap deco_bitmap = None;
     int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
     struct GadgetInfo *gi;
     unsigned long event_mask;
@@ -2383,7 +2365,7 @@ void CreateToolButtons()
     if (id >= TOOL_CTRL_ID_PLAYER_1 && id <= TOOL_CTRL_ID_PLAYER_4)
     {
       getMiniGraphicSource(GFX_SPIELER1 + id - TOOL_CTRL_ID_PLAYER_1,
-                          &deco_pixmap, &deco_x, &deco_y);
+                          &deco_bitmap, &deco_x, &deco_y);
       deco_xpos = (toolbutton_info[i].width - MINI_TILEX) / 2;
       deco_ypos = (toolbutton_info[i].height - MINI_TILEY) / 2;
     }
@@ -2396,9 +2378,9 @@ void CreateToolButtons()
                      GDI_HEIGHT, toolbutton_info[i].height,
                      GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
-                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
-                     GDI_DECORATION_DESIGN, deco_pixmap, deco_x, deco_y,
+                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
+                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
+                     GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
                      GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
                      GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
                      GDI_DECORATION_SHIFTING, 1, 1,
index 18bce3b31fccef78ff8d00de5192e46be3f38550..0fc1f2dadd9cc2edec417a091a44ddbbd04b9577 100644 (file)
@@ -68,7 +68,7 @@ void DrawInitText(char *, int, int);
 void DrawTextF(int, int, int, char *, ...);
 void DrawTextFCentered(int, int, char *, ...);
 void DrawText(int, int, char *, int, int);
-void DrawTextExt(Drawable, GC, int, int, char *, int, int);
+void DrawTextExt(DrawBuffer, GC, int, int, char *, int, int);
 void DrawAllPlayers(void);
 void DrawPlayerField(int, int);
 void DrawPlayer(struct PlayerInfo *);
@@ -77,12 +77,12 @@ void DrawGraphicAnimation(int, int, int, int, int, int);
 void DrawGraphicAnimationThruMask(int, int, int, int, int, int);
 void getGraphicSource(int, int *, int *, int *);
 void DrawGraphic(int, int, int);
-void DrawGraphicExt(Drawable, GC, int, int, int);
+void DrawGraphicExt(DrawBuffer, GC, int, int, int);
 void DrawGraphicThruMask(int, int, int);
-void DrawGraphicThruMaskExt(Drawable, int, int, int);
+void DrawGraphicThruMaskExt(DrawBuffer, int, int, int);
 void DrawMiniGraphic(int, int, int);
-void getMiniGraphicSource(int, Pixmap *, int *, int *);
-void DrawMiniGraphicExt(Drawable, GC, int, int, int);
+void getMiniGraphicSource(int, Bitmap *, int *, int *);
+void DrawMiniGraphicExt(DrawBuffer, GC, int, int, int);
 void DrawGraphicShifted(int, int, int, int, int, int, int);
 void DrawGraphicShiftedThruMask(int, int, int, int, int, int);
 void DrawScreenElementExt(int, int, int, int, int, int, int);
@@ -110,7 +110,7 @@ unsigned int GetDoorState(void);
 unsigned int MoveDoor(unsigned int);
 void DrawSpecialEditorDoor();
 void UndrawSpecialEditorDoor();
-int ReadPixel(Drawable, int, int);
+int ReadPixel(DrawBuffer, int, int);
 
 void CreateToolButtons();