From: Holger Schemel Date: Thu, 20 Jul 2000 22:49:49 +0000 (+0200) Subject: rnd-20000720-1-src X-Git-Tag: 2.0.0^2~55 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=36357e8399d0a42ac45a1cd096aee24a9008b5f5;p=rocksndiamonds.git rnd-20000720-1-src --- diff --git a/src/Makefile b/src/Makefile index 044e136d..ef2154ba 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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) diff --git a/src/buttons.c b/src/buttons.c index 4844f2fe..9f9a78df 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -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; ipixmap, 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; ipixmap, 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 */ diff --git a/src/buttons.h b/src/buttons.h index f3d93c89..85b38b53 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -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 diff --git a/src/cartoons.c b/src/cartoons.c index 07394acd..3290331e 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -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(); } diff --git a/src/editor.c b/src/editor.c index 91e10699..618c272f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -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; ipixmap, &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; } diff --git a/src/events.c b/src/events.c index 1866e7ae..32e0013b 100644 --- a/src/events.c +++ b/src/events.c @@ -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; itype == 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) diff --git a/src/events.h b/src/events.h index a7980e5a..bf3276e2 100644 --- a/src/events.h +++ b/src/events.h @@ -17,16 +17,16 @@ #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); diff --git a/src/game.c b/src/game.c index 14e6445d..7c6cf159 100644 --- a/src/game.c +++ b/src/game.c @@ -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=0; i++) @@ -680,33 +676,31 @@ void InitGfx() for(j=0; jformat, 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; iformat, 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=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(); diff --git a/src/main.h b/src/main.h index 4c1d57d5..adf82efa 100644 --- a/src/main.h +++ b/src/main.h @@ -25,12 +25,14 @@ #define XK_MISCELLANY #define XK_LATIN1 +/* #include #include #include #include #include #include +*/ #ifdef XPM_INCLUDE_FILE #define USE_XPM_LIBRARY @@ -40,10 +42,6 @@ #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 diff --git a/src/misc.c b/src/misc.c index c32aa555..e1badb59 100644 --- a/src/misc.c +++ b/src/misc.c @@ -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 */ diff --git a/src/misc.h b/src/misc.h index d2749225..5aa6c15c 100644 --- a/src/misc.h +++ b/src/misc.h @@ -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 */ diff --git a/src/screens.c b/src/screens.c index f2335cac..8fb300aa 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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; iformat, 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 */ diff --git a/src/sdl.h b/src/sdl.h index 9bfcff3b..dfe39e50 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -12,10 +12,15 @@ * sdl.h * ***********************************************************/ -#include -#include +#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 index 00000000..71b248e8 --- /dev/null +++ b/src/system.c @@ -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 index 00000000..35351e32 --- /dev/null +++ b/src/system.h @@ -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 +#include +#include +#include +#include +#include +#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 */ diff --git a/src/tape.c b/src/tape.c index 15a8dc20..f778c715 100644 --- a/src/tape.c +++ b/src/tape.c @@ -328,7 +328,7 @@ void CreateTapeButtons() for (i=0; i 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= 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= 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, diff --git a/src/tools.h b/src/tools.h index 18bce3b3..0fc1f2da 100644 --- a/src/tools.h +++ b/src/tools.h @@ -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();