1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * ©1995 Artsoft Development *
6 * 33659 Bielefeld-Senne *
7 * Telefon: (0521) 493245 *
8 * eMail: aeglos@valinor.owl.de *
9 * aeglos@uni-paderborn.de *
10 * q99492@pbhrzx.uni-paderborn.de *
11 *----------------------------------------------------------*
13 ***********************************************************/
16 #include <machine/joystick.h>
31 extern BOOL wait_for_vsync;
34 void SetDrawtoField(int mode)
36 if (mode == DRAW_BUFFERED && soft_scrolling_on)
47 drawto_field = fieldbuffer;
49 else /* DRAW_DIRECT, DRAW_BACKBUFFER */
60 drawto_field = (mode == DRAW_DIRECT ? window : backbuffer);
67 Drawable buffer = (drawto_field != window ? drawto_field : backbuffer);
69 if (direct_draw_on && game_status == PLAYING)
70 redraw_mask &= ~REDRAW_MAIN;
72 if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD)
73 redraw_mask |= REDRAW_FIELD;
75 if (redraw_mask & REDRAW_FIELD || ScreenMovPos)
76 redraw_mask &= ~REDRAW_TILES;
81 if (redraw_mask & REDRAW_ALL)
83 XCopyArea(display,backbuffer,window,gc,
84 0,0, WIN_XSIZE,WIN_YSIZE,
89 if (redraw_mask & REDRAW_FIELD)
92 wait_for_vsync = TRUE;
94 if (game_status != PLAYING || redraw_mask & REDRAW_FROM_BACKBUFFER)
95 XCopyArea(display,backbuffer,window,gc,
96 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE,
100 int fx = FX, fy = FY;
102 if (soft_scrolling_on)
104 fx += (PlayerMovDir & (MV_LEFT|MV_RIGHT) ? ScreenMovPos : 0);
105 fy += (PlayerMovDir & (MV_UP|MV_DOWN) ? ScreenMovPos : 0);
108 XCopyArea(display,buffer,window,gc,
109 fx,fy, SXSIZE,SYSIZE,
112 redraw_mask &= ~REDRAW_MAIN;
115 if (redraw_mask & REDRAW_DOORS)
118 wait_for_vsync = TRUE;
120 if (redraw_mask & REDRAW_DOOR_1)
121 XCopyArea(display,backbuffer,window,gc,
122 DX,DY, DXSIZE,DYSIZE,
124 if (redraw_mask & REDRAW_DOOR_2)
126 if ((redraw_mask & REDRAW_DOOR_2) == REDRAW_DOOR_2)
127 XCopyArea(display,backbuffer,window,gc,
128 VX,VY, VXSIZE,VYSIZE,
132 if (redraw_mask & REDRAW_VIDEO_1)
133 XCopyArea(display,backbuffer,window,gc,
134 VX+VIDEO_DISPLAY1_XPOS,VY+VIDEO_DISPLAY1_YPOS,
135 VIDEO_DISPLAY_XSIZE,VIDEO_DISPLAY_YSIZE,
136 VX+VIDEO_DISPLAY1_XPOS,VY+VIDEO_DISPLAY1_YPOS);
137 if (redraw_mask & REDRAW_VIDEO_2)
138 XCopyArea(display,backbuffer,window,gc,
139 VX+VIDEO_DISPLAY2_XPOS,VY+VIDEO_DISPLAY2_YPOS,
140 VIDEO_DISPLAY_XSIZE,VIDEO_DISPLAY_YSIZE,
141 VX+VIDEO_DISPLAY2_XPOS,VY+VIDEO_DISPLAY2_YPOS);
142 if (redraw_mask & REDRAW_VIDEO_3)
143 XCopyArea(display,backbuffer,window,gc,
144 VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS,
145 VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
146 VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
149 redraw_mask &= ~REDRAW_DOORS;
152 if (redraw_mask & REDRAW_MICROLEV)
154 XCopyArea(display,backbuffer,window,gc,
155 MICROLEV_XPOS,MICROLEV_YPOS, MICROLEV_XSIZE,MICROLEV_YSIZE,
156 MICROLEV_XPOS,MICROLEV_YPOS);
157 XCopyArea(display,backbuffer,window,gc,
158 SX,MICROLABEL_YPOS, SXSIZE,FONT4_YSIZE,
160 redraw_mask &= ~REDRAW_MICROLEV;
163 if (redraw_mask & REDRAW_TILES)
165 for(x=0; x<SCR_FIELDX; x++)
166 for(y=0; y<SCR_FIELDY; y++)
167 if (redraw[redraw_x1 + x][redraw_y1 + y])
168 XCopyArea(display,buffer,window,gc,
169 FX+x*TILEX,FX+y*TILEY, TILEX,TILEY,
170 SX+x*TILEX,SY+y*TILEY);
175 for(x=0; x<MAX_BUF_XSIZE; x++)
176 for(y=0; y<MAX_BUF_YSIZE; y++)
185 long fading_delay = 300000;
187 if (fading_on && (redraw_mask & REDRAW_FIELD))
194 XFillRectangle(display,window,gc,
195 REAL_SX,REAL_SY,FULL_SXSIZE,FULL_SYSIZE);
198 for(i=0;i<2*FULL_SYSIZE;i++)
200 for(y=0;y<FULL_SYSIZE;y++)
202 XCopyArea(display,backbuffer,window,gc,
203 REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
211 for(i=1;i<FULL_SYSIZE;i+=2)
212 XCopyArea(display,backbuffer,window,gc,
213 REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
219 XSetClipOrigin(display,clip_gc[PIX_FADEMASK],0,0);
220 XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
221 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
225 XSetClipOrigin(display,clip_gc[PIX_FADEMASK],-1,-1);
226 XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
227 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
231 XSetClipOrigin(display,clip_gc[PIX_FADEMASK],0,-1);
232 XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
233 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
237 XSetClipOrigin(display,clip_gc[PIX_FADEMASK],-1,0);
238 XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
239 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
243 redraw_mask &= ~REDRAW_MAIN;
252 XFillRectangle(display,backbuffer,gc,
253 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
255 if (soft_scrolling_on && game_status==PLAYING)
257 XFillRectangle(display,fieldbuffer,gc,
259 SetDrawtoField(DRAW_BUFFERED);
262 SetDrawtoField(DRAW_BACKBUFFER);
264 if (direct_draw_on && game_status==PLAYING)
266 XFillRectangle(display,window,gc,
267 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
268 SetDrawtoField(DRAW_DIRECT);
271 redraw_mask |= REDRAW_FIELD;
274 void DrawText(int x, int y, char *text, int font, int col)
276 DrawTextExt(drawto, gc, x, y, text, font, col);
278 redraw_mask |= REDRAW_FIELD;
280 redraw_mask |= REDRAW_DOOR_1;
283 void DrawTextExt(Drawable d, GC gc, int x, int y,
284 char *text, int font, int font_color)
286 int font_width, font_height, font_start;
289 if (font!=FS_SMALL && font!=FS_BIG)
291 if (font_color<FC_RED || font_color>FC_SPECIAL2)
295 (font==FS_BIG ? FONT1_XSIZE :
296 font_color<FC_SPECIAL1 ? FONT2_XSIZE :
297 font_color<FC_SPECIAL2 ? FONT3_XSIZE : FONT4_XSIZE);
299 (font==FS_BIG ? FONT1_XSIZE :
300 font_color<FC_SPECIAL2 ? FONT2_XSIZE: FONT4_XSIZE);
301 font_pixmap = (font==FS_BIG ? PIX_BIGFONT : PIX_SMALLFONT);
303 font_color*(font==FS_BIG ? FONT1_YSIZE : FONT2_YSIZE)*FONT_LINES_PER_FONT;
309 if (c>='a' && c<='z')
311 else if (c=='ä' || c=='Ä')
313 else if (c=='ö' || c=='Ö')
315 else if (c=='ü' || c=='Ü')
319 XCopyArea(display,pix[font_pixmap],d,gc,
320 ((c-32) % FONT_CHARS_PER_LINE)*font_width,
321 ((c-32) / FONT_CHARS_PER_LINE)*font_height + font_start,
322 font_width,font_height, x,y);
328 void DrawPlayerField()
331 int sx = SCROLLX(x), sy = SCROLLY(y);
333 int sxx = 0, syy = 0;
335 int element = Feld[x][y];
337 BOOL draw_thru_mask = FALSE;
343 if (!IN_LEV_FIELD(x,y) || !IN_SCR_FIELD(sx,sy))
345 printf("DrawPlayerField(): x = %d, y = %d\n",x,y);
346 printf("DrawPlayerField(): sx = %d, sy = %d\n",sx,sy);
347 printf("DrawPlayerField(): This should never happen!\n");
352 if (element == EL_EXPLODING)
356 SetDrawtoField(DRAW_BUFFERED);
358 /* draw things behind the player (EL_PFORTE* || mole/penguin/pig/dragon) */
369 DrawGraphic(sx,sy, el2gfx(Store[x][y]));
370 draw_thru_mask = TRUE;
372 else if (element!=EL_DYNAMIT && element!=EL_DYNABOMB)
375 draw_thru_mask = TRUE;
379 else if (element!=EL_LEERRAUM && element!=EL_DYNAMIT && element!=EL_DYNABOMB)
382 draw_thru_mask = TRUE;
387 draw_thru_mask = TRUE;
392 /* draw player himself */
394 if (PlayerMovDir==MV_LEFT)
395 graphic = (PlayerPushing ? GFX_SPIELER_PUSH_LEFT : GFX_SPIELER_LEFT);
396 else if (PlayerMovDir==MV_RIGHT)
397 graphic = (PlayerPushing ? GFX_SPIELER_PUSH_RIGHT : GFX_SPIELER_RIGHT);
398 else if (PlayerMovDir==MV_UP)
399 graphic = GFX_SPIELER_UP;
400 else /* MV_DOWN || MV_NO_MOVING */
401 graphic = GFX_SPIELER_DOWN;
403 graphic += PlayerFrame;
408 if (PlayerMovDir == MV_LEFT || PlayerMovDir == MV_RIGHT)
415 if (!soft_scrolling_on && ScreenMovPos)
424 DrawGraphicShiftedThruMask(sx,sy,sxx,syy,graphic,CUT_NO_CUTTING);
426 DrawGraphicThruMask(sx, sy, graphic);
429 DrawGraphicShifted(sx,sy,sxx,syy,graphic,CUT_NO_CUTTING);
431 DrawGraphic(sx, sy, graphic);
436 MarkTileDirty(sx,sy);
440 if (PlayerPushing && PlayerGfxPos)
442 int nextJX = JX + (JX - lastJX);
443 int nextJY = JY + (JY - lastJY);
444 int px = SCROLLX(nextJX), py = SCROLLY(nextJY);
446 if (Feld[JX][JY] == EL_SOKOBAN_FELD_LEER ||
447 Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
448 DrawGraphicShiftedThruMask(px,py,sxx,syy,
453 int element = Feld[nextJX][nextJY];
454 int graphic = el2gfx(element);
456 if (element == EL_FELSBROCKEN && sxx)
458 int phase = (PlayerGfxPos / (TILEX/4));
460 if (PlayerMovDir == MV_LEFT)
463 graphic += (phase+4)%4;
467 printf("----> (%d, %d, %d)\n",
468 PlayerGfxPos, phase, graphic);
473 DrawGraphicShifted(px,py, sxx,syy, graphic, CUT_NO_CUTTING);
479 /* draw things in front of player (EL_DYNAMIT || EL_DYNABOMB) */
481 if (element == EL_DYNAMIT || element == EL_DYNABOMB)
483 graphic = el2gfx(element);
485 if (element == EL_DYNAMIT)
487 if ((phase = (96-MovDelay[x][y])/12) > 6)
492 if ((phase = ((96-MovDelay[x][y])/6) % 8) > 3)
496 DrawGraphicThruMask(sx,sy, graphic + phase);
501 int dest_x = SX+SCROLLX(x)*TILEX;
502 int dest_y = SY+SCROLLY(y)*TILEY;
508 dest_x = SX + SCROLLX(MIN(JX,lastJX))*TILEX;
509 dest_y = SY + SCROLLY(MIN(JY,lastJY))*TILEY;
510 x_size = TILEX * (1 + ABS(JX - lastJX));
511 y_size = TILEY * (1 + ABS(JY - lastJY));
514 XCopyArea(display,drawto_field,window,gc,
515 dest_x,dest_y, x_size,y_size, dest_x,dest_y);
516 SetDrawtoField(DRAW_DIRECT);
520 static int getGraphicAnimationPhase(int frames, int delay, int mode)
524 if (mode == ANIM_OSCILLATE)
526 int max_anim_frames = frames*2 - 2;
527 phase = (FrameCounter % (delay * max_anim_frames)) / delay;
528 phase = (phase < frames ? phase : max_anim_frames - phase);
531 phase = (FrameCounter % (delay * frames)) / delay;
533 if (mode == ANIM_REVERSE)
539 void DrawGraphicAnimation(int x, int y, int graphic,
540 int frames, int delay, int mode)
542 int phase = getGraphicAnimationPhase(frames, delay, mode);
544 if (!(FrameCounter % delay) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
545 DrawGraphic(SCROLLX(x),SCROLLY(y), graphic + phase);
548 void DrawGraphic(int x, int y, int graphic)
552 if (!IN_SCR_FIELD(x,y))
554 printf("DrawGraphic(): x = %d, y = %d, graphic = %d\n",x,y,graphic);
555 printf("DrawGraphic(): This should never happen!\n");
560 DrawGraphicExt(drawto_field, gc, x, y, graphic);
564 void DrawGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
566 DrawGraphicExtHiRes(d, gc, FX+x*TILEX, FY+y*TILEY, graphic);
569 void DrawGraphicExtHiRes(Drawable d, GC gc, int x, int y, int graphic)
571 if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
573 graphic -= GFX_START_ROCKSSCREEN;
574 XCopyArea(display,pix[PIX_BACK],d,gc,
575 SX+(graphic % GFX_PER_LINE)*TILEX,
576 SY+(graphic / GFX_PER_LINE)*TILEY,
579 else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
581 graphic -= GFX_START_ROCKSHEROES;
582 XCopyArea(display,pix[PIX_HEROES],d,gc,
583 (graphic % HEROES_PER_LINE)*TILEX,
584 (graphic / HEROES_PER_LINE)*TILEY,
587 else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT)
589 graphic -= GFX_START_ROCKSFONT;
590 XCopyArea(display,pix[PIX_BIGFONT],d,gc,
591 (graphic % FONT_CHARS_PER_LINE)*TILEX,
592 (graphic / FONT_CHARS_PER_LINE)*TILEY +
593 FC_SPECIAL1*TILEY*FONT_LINES_PER_FONT,
597 XFillRectangle(display,d,gc, x,y, TILEX,TILEY);
600 void DrawGraphicThruMask(int x, int y, int graphic)
602 int src_x,src_y, dest_x,dest_y;
605 if (!IN_SCR_FIELD(x,y))
607 printf("DrawGraphicThruMask(): x = %d, y = %d\n",x,y);
608 printf("DrawGraphicThruMask(): This should never happen!\n");
613 if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
615 graphic -= GFX_START_ROCKSSCREEN;
616 src_x = SX+(graphic % GFX_PER_LINE)*TILEX;
617 src_y = SY+(graphic / GFX_PER_LINE)*TILEY;
621 XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
622 XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
623 src_x,src_y, TILEX,TILEY, dest_x,dest_y);
625 else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
627 graphic -= GFX_START_ROCKSHEROES;
628 src_x = (graphic % HEROES_PER_LINE)*TILEX;
629 src_y = (graphic / HEROES_PER_LINE)*TILEY;
633 XSetClipOrigin(display,clip_gc[PIX_HEROES],dest_x-src_x,dest_y-src_y);
634 XCopyArea(display,pix[PIX_HEROES],drawto_field,clip_gc[PIX_HEROES],
635 src_x,src_y, TILEX,TILEY, dest_x,dest_y);
639 DrawGraphic(x,y,graphic);
646 void DrawElementThruMask(int x, int y, int element)
648 DrawGraphicThruMask(x,y,el2gfx(element));
651 void DrawMiniGraphic(int x, int y, int graphic)
653 DrawMiniGraphicExt(drawto, gc, x, y, graphic);
654 MarkTileDirty(x/2, y/2);
657 void DrawMiniGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
659 DrawMiniGraphicExtHiRes(d,gc, SX+x*MINI_TILEX,SY+y*MINI_TILEY, graphic);
662 void DrawMiniGraphicExtHiRes(Drawable d, GC gc, int x, int y, int graphic)
664 if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
666 graphic -= GFX_START_ROCKSSCREEN;
667 XCopyArea(display,pix[PIX_BACK],d,gc,
668 MINI_GFX_STARTX+(graphic % MINI_GFX_PER_LINE)*MINI_TILEX,
669 MINI_GFX_STARTY+(graphic / MINI_GFX_PER_LINE)*MINI_TILEY,
670 MINI_TILEX,MINI_TILEY, x,y);
672 else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT)
674 graphic -= GFX_START_ROCKSFONT;
675 XCopyArea(display,pix[PIX_SMALLFONT],d,gc,
676 (graphic % FONT_CHARS_PER_LINE)*FONT4_XSIZE,
677 (graphic / FONT_CHARS_PER_LINE)*FONT4_YSIZE +
678 FC_SPECIAL2*FONT2_YSIZE*FONT_LINES_PER_FONT,
679 MINI_TILEX,MINI_TILEY, x,y);
682 XFillRectangle(display,d,gc, x,y, MINI_TILEX,MINI_TILEY);
685 void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int cut_mode)
687 int width = TILEX, height = TILEY;
692 DrawGraphic(x,y,graphic);
696 if (dx || dy) /* Verschiebung der Grafik? */
698 if (x < BX1) /* Element kommt von links ins Bild */
705 else if (x > BX2) /* Element kommt von rechts ins Bild */
711 else if (x==BX1 && dx<0) /* Element verläßt links das Bild */
717 else if (x==BX2 && dx>0) /* Element verläßt rechts das Bild */
719 else if (dx) /* allg. Bewegung in x-Richtung */
720 MarkTileDirty(x + SIGN(dx), y);
722 if (y < BY1) /* Element kommt von oben ins Bild */
724 if (cut_mode==CUT_BELOW) /* Element oberhalb des Bildes */
732 else if (y > BY2) /* Element kommt von unten ins Bild */
738 else if (y==BY1 && dy<0) /* Element verläßt oben das Bild */
744 else if (dy > 0 && cut_mode==CUT_ABOVE)
746 if (y == BY2) /* Element unterhalb des Bildes */
752 MarkTileDirty(x, y + 1);
753 } /* Element verläßt unten das Bild */
754 else if (dy > 0 && (y == BY2 || cut_mode==CUT_BELOW))
756 else if (dy) /* allg. Bewegung in y-Richtung */
757 MarkTileDirty(x, y + SIGN(dy));
760 if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
762 graphic -= GFX_START_ROCKSSCREEN;
763 XCopyArea(display,pix[PIX_BACK],drawto_field,gc,
764 SX+(graphic % GFX_PER_LINE)*TILEX+cx,
765 SY+(graphic / GFX_PER_LINE)*TILEY+cy,
766 width,height, FX+x*TILEX+dx,FY+y*TILEY+dy);
768 else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
770 graphic -= GFX_START_ROCKSHEROES;
771 XCopyArea(display,pix[PIX_HEROES],drawto_field,gc,
772 (graphic % HEROES_PER_LINE)*TILEX+cx,
773 (graphic / HEROES_PER_LINE)*TILEY+cy,
774 width,height, FX+x*TILEX+dx,FY+y*TILEY+dy);
778 if (!IN_SCR_FIELD(x,y))
780 printf("DrawGraphicShifted(): x = %d, y = %d, graphic = %d\n",x,y,graphic);
781 printf("DrawGraphicShifted(): This should never happen!\n");
789 void DrawElementShifted(int x, int y, int dx, int dy, int element,int cut_mode)
791 int ux = UNSCROLLX(x), uy = UNSCROLLY(y);
792 int graphic = el2gfx(element);
793 int phase4 = ABS(MovPos[ux][uy])/(TILEX/4);
794 int phase = phase4 / 2;
795 int dir = MovDir[ux][uy];
797 if (element==EL_PACMAN || element==EL_KAEFER || element==EL_FLIEGER)
803 else if (dir == MV_LEFT)
805 else if (dir == MV_DOWN)
808 else if (element==EL_MAULWURF || element==EL_PINGUIN ||
809 element==EL_SCHWEIN || element==EL_DRACHE)
812 graphic = (element==EL_MAULWURF ? GFX_MAULWURF_LEFT :
813 element==EL_PINGUIN ? GFX_PINGUIN_LEFT :
814 element==EL_SCHWEIN ? GFX_SCHWEIN_LEFT : GFX_DRACHE_LEFT);
815 else if (dir==MV_RIGHT)
816 graphic = (element==EL_MAULWURF ? GFX_MAULWURF_RIGHT :
817 element==EL_PINGUIN ? GFX_PINGUIN_RIGHT :
818 element==EL_SCHWEIN ? GFX_SCHWEIN_RIGHT : GFX_DRACHE_RIGHT);
820 graphic = (element==EL_MAULWURF ? GFX_MAULWURF_UP :
821 element==EL_PINGUIN ? GFX_PINGUIN_UP :
822 element==EL_SCHWEIN ? GFX_SCHWEIN_UP : GFX_DRACHE_UP);
824 graphic = (element==EL_MAULWURF ? GFX_MAULWURF_DOWN :
825 element==EL_PINGUIN ? GFX_PINGUIN_DOWN :
826 element==EL_SCHWEIN ? GFX_SCHWEIN_DOWN : GFX_DRACHE_DOWN);
830 else if (element==EL_SONDE)
832 graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_NORMAL);
834 else if (element==EL_BUTTERFLY || element==EL_FIREFLY)
838 else if ((element==EL_FELSBROCKEN || IS_GEM(element)) && !cut_mode)
840 graphic += phase * (element==EL_FELSBROCKEN ? 2 : 1);
842 else if ((element==EL_SIEB_LEER || element==EL_SIEB2_LEER ||
843 element==EL_SIEB_VOLL || element==EL_SIEB2_VOLL) && SiebAktiv)
845 graphic += 3-(SiebAktiv%8)/2;
847 else if (IS_AMOEBOID(element))
849 graphic = (element==EL_AMOEBE_TOT ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT);
850 graphic += (x+2*y) % 4;
852 else if (element==EL_MAUER_LEBT)
854 BOOL links_massiv = FALSE, rechts_massiv = FALSE;
856 if (!IN_LEV_FIELD(ux-1,uy) || IS_MAUER(Feld[ux-1][uy]))
858 if (!IN_LEV_FIELD(ux+1,uy) || IS_MAUER(Feld[ux+1][uy]))
859 rechts_massiv = TRUE;
861 if (links_massiv && rechts_massiv)
862 graphic = GFX_MAUERWERK;
863 else if (links_massiv)
864 graphic = GFX_MAUER_R;
865 else if (rechts_massiv)
866 graphic = GFX_MAUER_L;
870 DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode);
872 DrawGraphic(x,y, graphic);
875 void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic,
878 int width = TILEX, height = TILEY;
880 int src_x,src_y, dest_x,dest_y;
884 DrawGraphic(x,y,graphic);
888 if (dx || dy) /* Verschiebung der Grafik? */
890 if (x < BX1) /* Element kommt von links ins Bild */
897 else if (x > BX2) /* Element kommt von rechts ins Bild */
903 else if (x==BX1 && dx<0) /* Element verläßt links das Bild */
909 else if (x==BX2 && dx>0) /* Element verläßt rechts das Bild */
911 else if (dx) /* allg. Bewegung in x-Richtung */
912 MarkTileDirty(x + SIGN(dx), y);
914 if (y < BY1) /* Element kommt von oben ins Bild */
916 if (cut_mode==CUT_BELOW) /* Element oberhalb des Bildes */
924 else if (y > BY2) /* Element kommt von unten ins Bild */
930 else if (y==BY1 && dy<0) /* Element verläßt oben das Bild */
936 else if (dy > 0 && cut_mode==CUT_ABOVE)
938 if (y == BY2) /* Element unterhalb des Bildes */
944 MarkTileDirty(x, y + 1);
945 } /* Element verläßt unten das Bild */
946 else if (dy > 0 && (y == BY2 || cut_mode==CUT_BELOW))
948 else if (dy) /* allg. Bewegung in y-Richtung */
949 MarkTileDirty(x, y + SIGN(dy));
952 if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
954 graphic -= GFX_START_ROCKSSCREEN;
955 src_x = SX+(graphic % GFX_PER_LINE)*TILEX+cx;
956 src_y = SY+(graphic / GFX_PER_LINE)*TILEY+cy;
957 dest_x = FX+x*TILEX+dx;
958 dest_y = FY+y*TILEY+dy;
960 XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
961 XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
962 src_x,src_y, width,height, dest_x,dest_y);
964 else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
966 graphic -= GFX_START_ROCKSHEROES;
967 src_x = (graphic % HEROES_PER_LINE)*TILEX+cx;
968 src_y = (graphic / HEROES_PER_LINE)*TILEY+cy;
969 dest_x = FX+x*TILEX+dx;
970 dest_y = FY+y*TILEY+dy;
972 XSetClipOrigin(display,clip_gc[PIX_HEROES],dest_x-src_x,dest_y-src_y);
973 XCopyArea(display,pix[PIX_HEROES],drawto_field,clip_gc[PIX_HEROES],
974 src_x,src_y, width,height, dest_x,dest_y);
978 if (!IN_SCR_FIELD(x,y))
980 printf("DrawGraphicShiftedThruMask(): x = %d, y = %d, graphic = %d\n",
982 printf("DrawGraphicShifted(): This should never happen!\n");
990 void ErdreichAnbroeckeln(int x, int y)
992 int i, width, height, cx,cy;
993 int ux = UNSCROLLX(x), uy = UNSCROLLY(y);
994 int element, graphic;
996 static int xy[4][2] =
1004 if (!IN_LEV_FIELD(ux,uy))
1007 element = Feld[ux][uy];
1009 if (element==EL_ERDREICH)
1011 if (!IN_SCR_FIELD(x,y))
1014 graphic = GFX_ERDENRAND;
1022 if (!IN_LEV_FIELD(uxx,uyy))
1025 element = Feld[uxx][uyy];
1028 if (element==EL_ERDREICH || IS_SOLID(element))
1031 if (element==EL_ERDREICH)
1038 cx = (i==2 ? TILEX-snip : 0);
1046 cy = (i==3 ? TILEY-snip : 0);
1049 XCopyArea(display,pix[PIX_BACK],drawto_field,gc,
1050 SX+(graphic % GFX_PER_LINE)*TILEX+cx,
1051 SY+(graphic / GFX_PER_LINE)*TILEY+cy,
1052 width,height, FX+x*TILEX+cx,FY+y*TILEY+cy);
1059 graphic = GFX_ERDENRAND;
1070 if (!IN_LEV_FIELD(uxx,uyy) || Feld[uxx][uyy]!=EL_ERDREICH ||
1071 !IN_SCR_FIELD(xx,yy) || IS_SOLID(element))
1075 if (!IN_LEV_FIELD(uxx,uyy) || Feld[uxx][uyy]!=EL_ERDREICH ||
1076 !IN_SCR_FIELD(xx,yy))
1083 cx = (i==1 ? TILEX-snip : 0);
1091 cy = (i==0 ? TILEY-snip : 0);
1094 XCopyArea(display,pix[PIX_BACK],drawto_field,gc,
1095 SX+(graphic % GFX_PER_LINE)*TILEX+cx,
1096 SY+(graphic / GFX_PER_LINE)*TILEY+cy,
1097 width,height, FX+xx*TILEX+cx,FY+yy*TILEY+cy);
1099 MarkTileDirty(xx,yy);
1104 void DrawScreenElement(int x, int y, int element)
1106 DrawElementShifted(x,y,0,0,element,CUT_NO_CUTTING);
1107 ErdreichAnbroeckeln(x,y);
1110 void DrawLevelElement(int x, int y, int element)
1112 if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
1113 DrawScreenElement(SCROLLX(x),SCROLLY(y),element);
1116 void DrawScreenField(int x, int y)
1118 int ux = UNSCROLLX(x), uy = UNSCROLLY(y);
1121 if (!IN_LEV_FIELD(ux,uy))
1123 DrawScreenElement(x,y,EL_BETON);
1127 element = Feld[ux][uy];
1129 if (IS_MOVING(ux,uy))
1131 int horiz_move = (MovDir[ux][uy]==MV_LEFT || MovDir[ux][uy]==MV_RIGHT);
1132 BOOL cut_mode = CUT_NO_CUTTING;
1134 if (Store[ux][uy]==EL_MORAST_LEER ||
1135 Store[ux][uy]==EL_SIEB_LEER ||
1136 Store[ux][uy]==EL_SIEB2_LEER ||
1137 Store[ux][uy]==EL_AMOEBE_NASS)
1138 cut_mode = CUT_ABOVE;
1139 else if (Store[ux][uy]==EL_MORAST_VOLL ||
1140 Store[ux][uy]==EL_SIEB_VOLL ||
1141 Store[ux][uy]==EL_SIEB2_VOLL ||
1142 Store[ux][uy]==EL_SALZSAEURE)
1143 cut_mode = CUT_BELOW;
1145 if (cut_mode==CUT_ABOVE)
1146 DrawElementShifted(x,y,0,0,Store[ux][uy],CUT_NO_CUTTING);
1148 DrawScreenElement(x,y,EL_LEERRAUM);
1151 DrawElementShifted(x,y,MovPos[ux][uy],0,element,CUT_NO_CUTTING);
1153 DrawElementShifted(x,y,0,MovPos[ux][uy],element,cut_mode);
1155 else if (IS_BLOCKED(ux,uy))
1160 BOOL cut_mode = CUT_NO_CUTTING;
1162 Blocked2Moving(ux,uy,&oldx,&oldy);
1165 horiz_move = (MovDir[oldx][oldy]==MV_LEFT || MovDir[oldx][oldy]==MV_RIGHT);
1167 if (Store[oldx][oldy]==EL_MORAST_LEER ||
1168 Store[oldx][oldy]==EL_SIEB_LEER ||
1169 Store[oldx][oldy]==EL_SIEB2_LEER ||
1170 Store[oldx][oldy]==EL_AMOEBE_NASS)
1171 cut_mode = CUT_ABOVE;
1173 DrawScreenElement(x,y,EL_LEERRAUM);
1174 element = Feld[oldx][oldy];
1177 DrawElementShifted(sx,sy,MovPos[oldx][oldy],0,element,CUT_NO_CUTTING);
1179 DrawElementShifted(sx,sy,0,MovPos[oldx][oldy],element,cut_mode);
1181 else if (IS_DRAWABLE(element))
1182 DrawScreenElement(x,y,element);
1184 DrawScreenElement(x,y,EL_LEERRAUM);
1187 void DrawLevelField(int x, int y)
1189 if (IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
1190 DrawScreenField(SCROLLX(x),SCROLLY(y));
1191 else if (IS_MOVING(x,y))
1195 Moving2Blocked(x,y,&newx,&newy);
1196 if (IN_SCR_FIELD(SCROLLX(newx),SCROLLY(newy)))
1197 DrawScreenField(SCROLLX(newx),SCROLLY(newy));
1199 else if (IS_BLOCKED(x,y))
1203 Blocked2Moving(x,y,&oldx,&oldy);
1204 if (IN_SCR_FIELD(SCROLLX(oldx),SCROLLY(oldy)))
1205 DrawScreenField(SCROLLX(oldx),SCROLLY(oldy));
1209 void DrawMiniElement(int x, int y, int element)
1215 DrawMiniGraphic(x,y,-1);
1219 graphic = el2gfx(element);
1220 DrawMiniGraphic(x,y,graphic);
1223 void DrawMiniElementOrWall(int x, int y, int scroll_x, int scroll_y)
1225 if (x+scroll_x<-1 || x+scroll_x>lev_fieldx ||
1226 y+scroll_y<-1 || y+scroll_y>lev_fieldy)
1227 DrawMiniElement(x,y,EL_LEERRAUM);
1228 else if (x+scroll_x==-1 || x+scroll_x==lev_fieldx ||
1229 y+scroll_y==-1 || y+scroll_y==lev_fieldy)
1230 DrawMiniElement(x,y,EL_BETON);
1232 DrawMiniElement(x,y,Feld[x+scroll_x][y+scroll_y]);
1235 void DrawMicroElement(int xpos, int ypos, int element)
1239 if (element==EL_LEERRAUM)
1242 graphic = el2gfx(element);
1244 XCopyArea(display,pix[PIX_BACK],drawto,gc,
1245 MICRO_GFX_STARTX+(graphic % MICRO_GFX_PER_LINE)*MICRO_TILEX,
1246 MICRO_GFX_STARTY+(graphic / MICRO_GFX_PER_LINE)*MICRO_TILEY,
1247 MICRO_TILEX,MICRO_TILEY, xpos,ypos);
1256 for(x=BX1; x<=BX2; x++)
1257 for(y=BY1; y<=BY2; y++)
1258 DrawScreenField(x,y);
1260 if (soft_scrolling_on)
1261 XCopyArea(display,fieldbuffer,backbuffer,gc,
1262 FX,FY, SXSIZE,SYSIZE,
1265 redraw_mask |= (REDRAW_FIELD | REDRAW_FROM_BACKBUFFER);
1268 void DrawMiniLevel(int scroll_x, int scroll_y)
1274 for(x=0;x<2*SCR_FIELDX;x++)
1275 for(y=0;y<2*SCR_FIELDY;y++)
1276 DrawMiniElementOrWall(x,y,scroll_x,scroll_y);
1278 redraw_mask |= REDRAW_FIELD;
1281 void DrawMicroLevel(int xpos, int ypos)
1285 XFillRectangle(display,drawto,gc,
1286 xpos-MICRO_TILEX,ypos-MICRO_TILEY,
1287 MICRO_TILEX*(STD_LEV_FIELDX+2),
1288 MICRO_TILEY*(STD_LEV_FIELDY+2));
1289 if (lev_fieldx < STD_LEV_FIELDX)
1290 xpos += (STD_LEV_FIELDX - lev_fieldx)/2 * MICRO_TILEX;
1291 if (lev_fieldy < STD_LEV_FIELDY)
1292 ypos += (STD_LEV_FIELDY - lev_fieldy)/2 * MICRO_TILEY;
1294 for(x=-1;x<=STD_LEV_FIELDX;x++)
1295 for(y=-1;y<=STD_LEV_FIELDY;y++)
1296 if (x>=0 && x<lev_fieldx && y>=0 && y<lev_fieldy)
1297 DrawMicroElement(xpos+MICRO_TILEX*x,ypos+MICRO_TILEY*y,
1298 Feld[x][y]=Ur[x][y]);
1299 else if (x>=-1 && x<lev_fieldx+1 && y>=-1 && y<lev_fieldy+1)
1300 DrawMicroElement(xpos+MICRO_TILEX*x,ypos+MICRO_TILEY*y,
1303 XFillRectangle(display,drawto,gc, SX,MICROLABEL_YPOS, SXSIZE,FONT4_YSIZE);
1307 int len = strlen(level.name);
1308 int lxpos = SX+(SXSIZE-len*FONT4_XSIZE)/2;
1309 int lypos = MICROLABEL_YPOS;
1311 DrawText(lxpos,lypos,level.name,FS_SMALL,FC_SPECIAL2);
1314 redraw_mask |= REDRAW_MICROLEV;
1317 int AYS_in_range(int x, int y)
1319 if (y>DY+249 && y<DY+278)
1321 if (x>DX+1 && x<DX+48)
1323 else if (x>DX+51 && x<DX+98)
1329 BOOL AreYouSure(char *text, unsigned int ays_state)
1331 int mx,my, ty, result = -1;
1332 unsigned int old_door_state;
1334 old_door_state = GetDoorState();
1336 CloseDoor(DOOR_CLOSE_1);
1338 /* Alten Türinhalt sichern */
1339 XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
1340 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
1341 DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1);
1343 /* Fragetext schreiben */
1344 XFillRectangle(display,pix[PIX_DB_DOOR],gc,
1345 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1,DXSIZE,DYSIZE);
1347 for(ty=0;ty<13;ty++)
1354 for(tl=0,tx=0;tx<7;tl++,tx++)
1368 DrawTextExt(pix[PIX_DB_DOOR],gc,
1369 DOOR_GFX_PAGEX1+51-(tl*14)/2,SY+ty*16,txt,FS_SMALL,FC_YELLOW);
1370 text+=(tl+(tc==32));
1373 if (ays_state & AYS_ASK)
1374 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
1375 DOOR_GFX_PAGEX4,OK_BUTTON_GFX_YPOS,
1376 DXSIZE,OK_BUTTON_YSIZE,
1377 DOOR_GFX_PAGEX1,OK_BUTTON_YPOS);
1378 else if (ays_state & AYS_CONFIRM)
1379 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
1380 DOOR_GFX_PAGEX4,CONFIRM_BUTTON_GFX_YPOS,
1381 DXSIZE,CONFIRM_BUTTON_YSIZE,
1382 DOOR_GFX_PAGEX1,CONFIRM_BUTTON_YPOS);
1384 OpenDoor(DOOR_OPEN_1);
1387 if (!(ays_state & AYS_ASK) && !(ays_state & AYS_CONFIRM))
1390 if (game_status != MAINMENU)
1393 button_status = MB_RELEASED;
1400 if (XPending(display))
1404 XNextEvent(display, &event);
1408 HandleExposeEvent((XExposeEvent *) &event);
1411 SleepWhileUnmapped();
1419 if (event.type == MotionNotify)
1421 motion_status = TRUE;
1422 mx = ((XMotionEvent *) &event)->x;
1423 my = ((XMotionEvent *) &event)->y;
1427 motion_status = FALSE;
1428 mx = ((XButtonEvent *) &event)->x;
1429 my = ((XButtonEvent *) &event)->y;
1430 if (event.type==ButtonPress)
1431 button_status = ((XButtonEvent *) &event)->button;
1433 button_status = MB_RELEASED;
1436 if (ays_state & AYS_ASK)
1437 choice = CheckChooseButtons(mx,my,button_status);
1439 choice = CheckConfirmButton(mx,my,button_status);
1449 case BUTTON_CONFIRM:
1450 result = TRUE|FALSE;
1458 switch(XLookupKeysym((XKeyEvent *)&event,
1459 ((XKeyEvent *)&event)->state))
1470 key_joystick_mapping = 0;
1474 HandleFocusEvent((XFocusChangeEvent *) &event);
1477 HandleClientMessageEvent((XClientMessageEvent *) &event);
1483 else if (JoystickButton() == JOY_BUTTON_NEW_PRESSED)
1487 if (joy & JOY_BUTTON_1)
1489 else if (joy & JOY_BUTTON_2)
1494 if (game_status != MAINMENU)
1497 if (!(ays_state & AYS_STAY_OPEN))
1499 CloseDoor(DOOR_CLOSE_1);
1501 if (!(ays_state & AYS_STAY_CLOSED) && (old_door_state & DOOR_OPEN_1))
1503 XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
1504 DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
1505 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1);
1506 OpenDoor(DOOR_OPEN_1);
1513 unsigned int OpenDoor(unsigned int door_state)
1515 unsigned int new_door_state;
1517 if (door_state & DOOR_COPY_BACK)
1519 XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
1520 DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE+VYSIZE,
1521 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1);
1522 door_state &= ~DOOR_COPY_BACK;
1525 new_door_state = MoveDoor(door_state);
1531 return(new_door_state);
1534 unsigned int CloseDoor(unsigned int door_state)
1536 unsigned int new_door_state;
1538 XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc,
1539 DX,DY, DXSIZE,DYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1);
1540 XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc,
1541 VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
1543 new_door_state = MoveDoor(door_state);
1549 return(new_door_state);
1552 unsigned int GetDoorState()
1554 return(MoveDoor(DOOR_GET_STATE));
1557 unsigned int MoveDoor(unsigned int door_state)
1559 static unsigned int door1 = DOOR_OPEN_1;
1560 static unsigned int door2 = DOOR_CLOSE_2;
1561 int x, start, stepsize = 4, door_anim_delay = stepsize*5000;
1567 if (door_state == DOOR_GET_STATE)
1568 return(door1 | door2);
1570 if (door1==DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
1571 door_state &= ~DOOR_OPEN_1;
1572 else if (door1==DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1)
1573 door_state &= ~DOOR_CLOSE_1;
1574 if (door2==DOOR_OPEN_2 && door_state & DOOR_OPEN_2)
1575 door_state &= ~DOOR_OPEN_2;
1576 else if (door2==DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2)
1577 door_state &= ~DOOR_CLOSE_2;
1582 door_anim_delay = 0;
1583 StopSound(SND_OEFFNEN);
1586 if (door_state & DOOR_ACTION)
1588 if (!(door_state & DOOR_NO_DELAY))
1589 PlaySoundStereo(SND_OEFFNEN,PSND_MAX_RIGHT);
1591 start = ((door_state & DOOR_NO_DELAY) ? DXSIZE : 0);
1593 for(x=start;x<=DXSIZE;x+=stepsize)
1595 if (door_state & DOOR_ACTION_1)
1597 int i = (door_state & DOOR_OPEN_1 ? DXSIZE-x : x);
1598 int j = (DXSIZE - i)/3;
1600 XCopyArea(display,pix[PIX_DB_DOOR],drawto,gc,
1601 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1+i/2,
1602 DXSIZE,DYSIZE-i/2, DX,DY);
1604 XFillRectangle(display,drawto,gc,DX,DY+DYSIZE-i/2,DXSIZE,i/2);
1606 XSetClipOrigin(display,clip_gc[PIX_DOOR],
1607 DX-i,(DY+j)-DOOR_GFX_PAGEY1);
1608 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1609 DXSIZE,DOOR_GFX_PAGEY1, i,77, DX+DXSIZE-i,DY+j);
1610 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1611 DXSIZE,DOOR_GFX_PAGEY1+140, i,63, DX+DXSIZE-i,DY+140+j);
1612 XSetClipOrigin(display,clip_gc[PIX_DOOR],
1613 DX-DXSIZE+i,DY-(DOOR_GFX_PAGEY1+j));
1614 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1615 DXSIZE-i,DOOR_GFX_PAGEY1+j, i,77-j, DX,DY);
1616 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1617 DXSIZE-i,DOOR_GFX_PAGEY1+140, i,63, DX,DY+140-j);
1619 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1620 DXSIZE-i,DOOR_GFX_PAGEY1+77, i,63,
1622 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1623 DXSIZE-i,DOOR_GFX_PAGEY1+203, i,77,
1625 XSetClipOrigin(display,clip_gc[PIX_DOOR],
1626 DX-i,(DY+j)-DOOR_GFX_PAGEY1);
1627 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1628 DXSIZE,DOOR_GFX_PAGEY1+77, i,63,
1629 DX+DXSIZE-i,DY+77+j);
1630 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1631 DXSIZE,DOOR_GFX_PAGEY1+203, i,77-j,
1632 DX+DXSIZE-i,DY+203+j);
1634 redraw_mask |= REDRAW_DOOR_1;
1637 if (door_state & DOOR_ACTION_2)
1639 int i = (door_state & DOOR_OPEN_2 ? VXSIZE-x : x);
1640 int j = (VXSIZE - i)/3;
1642 XCopyArea(display,pix[PIX_DB_DOOR],drawto,gc,
1643 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2+i/2,
1644 VXSIZE,VYSIZE-i/2, VX,VY);
1646 XFillRectangle(display,drawto,gc,VX,VY+VYSIZE-i/2,VXSIZE,i/2);
1648 XSetClipOrigin(display,clip_gc[PIX_DOOR],
1649 VX-i,(VY+j)-DOOR_GFX_PAGEY2);
1650 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1651 VXSIZE,DOOR_GFX_PAGEY2, i,VYSIZE/2, VX+VXSIZE-i,VY+j);
1652 XSetClipOrigin(display,clip_gc[PIX_DOOR],
1653 VX-VXSIZE+i,VY-(DOOR_GFX_PAGEY2+j));
1654 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1655 VXSIZE-i,DOOR_GFX_PAGEY2+j, i,VYSIZE/2-j, VX,VY);
1657 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1658 VXSIZE-i,DOOR_GFX_PAGEY2+VYSIZE/2, i,VYSIZE/2,
1660 XSetClipOrigin(display,clip_gc[PIX_DOOR],
1661 VX-i,(VY+j)-DOOR_GFX_PAGEY2);
1662 XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
1663 VXSIZE,DOOR_GFX_PAGEY2+VYSIZE/2, i,VYSIZE/2-j,
1664 VX+VXSIZE-i,VY+VYSIZE/2+j);
1666 redraw_mask |= REDRAW_DOOR_2;
1671 Delay(door_anim_delay);
1674 if (game_status==MAINMENU)
1679 if (door_state & DOOR_ACTION_1)
1680 door1 = door_state & DOOR_ACTION_1;
1681 if (door_state & DOOR_ACTION_2)
1682 door2 = door_state & DOOR_ACTION_2;
1684 return(door1 | door2);
1687 int ReadPixel(Drawable d, int x, int y)
1689 static XImage *pixelimage;
1691 pixelimage = XGetImage(display, d, x,y, 1,1, AllPlanes, ZPixmap);
1692 return(XGetPixel(pixelimage,0,0));
1695 int el2gfx(int element)
1699 case EL_LEERRAUM: return(-1);
1700 case EL_ERDREICH: return(GFX_ERDREICH);
1701 case EL_MAUERWERK: return(GFX_MAUERWERK);
1702 case EL_FELSBODEN: return(GFX_FELSBODEN);
1703 case EL_FELSBROCKEN: return(GFX_FELSBROCKEN);
1704 case EL_SCHLUESSEL: return(GFX_SCHLUESSEL);
1705 case EL_EDELSTEIN: return(GFX_EDELSTEIN);
1706 case EL_AUSGANG_ZU: return(GFX_AUSGANG_ZU);
1707 case EL_AUSGANG_ACT: return(GFX_AUSGANG_ACT);
1708 case EL_AUSGANG_AUF: return(GFX_AUSGANG_AUF);
1709 case EL_SPIELFIGUR: return(GFX_SPIELFIGUR);
1710 case EL_SPIELER1: return(GFX_SPIELER1);
1711 case EL_SPIELER2: return(GFX_SPIELER2);
1712 case EL_SPIELER3: return(GFX_SPIELER3);
1713 case EL_SPIELER4: return(GFX_SPIELER4);
1714 case EL_KAEFER: return(GFX_KAEFER);
1715 case EL_KAEFER_R: return(GFX_KAEFER_R);
1716 case EL_KAEFER_O: return(GFX_KAEFER_O);
1717 case EL_KAEFER_L: return(GFX_KAEFER_L);
1718 case EL_KAEFER_U: return(GFX_KAEFER_U);
1719 case EL_FLIEGER: return(GFX_FLIEGER);
1720 case EL_FLIEGER_R: return(GFX_FLIEGER_R);
1721 case EL_FLIEGER_O: return(GFX_FLIEGER_O);
1722 case EL_FLIEGER_L: return(GFX_FLIEGER_L);
1723 case EL_FLIEGER_U: return(GFX_FLIEGER_U);
1724 case EL_BUTTERFLY: return(GFX_BUTTERFLY);
1725 case EL_BUTTERFLY_R: return(GFX_BUTTERFLY_R);
1726 case EL_BUTTERFLY_O: return(GFX_BUTTERFLY_O);
1727 case EL_BUTTERFLY_L: return(GFX_BUTTERFLY_L);
1728 case EL_BUTTERFLY_U: return(GFX_BUTTERFLY_U);
1729 case EL_FIREFLY: return(GFX_FIREFLY);
1730 case EL_FIREFLY_R: return(GFX_FIREFLY_R);
1731 case EL_FIREFLY_O: return(GFX_FIREFLY_O);
1732 case EL_FIREFLY_L: return(GFX_FIREFLY_L);
1733 case EL_FIREFLY_U: return(GFX_FIREFLY_U);
1734 case EL_MAMPFER: return(GFX_MAMPFER);
1735 case EL_ROBOT: return(GFX_ROBOT);
1736 case EL_BETON: return(GFX_BETON);
1737 case EL_DIAMANT: return(GFX_DIAMANT);
1738 case EL_MORAST_LEER: return(GFX_MORAST_LEER);
1739 case EL_MORAST_VOLL: return(GFX_MORAST_VOLL);
1740 case EL_TROPFEN: return(GFX_TROPFEN);
1741 case EL_BOMBE: return(GFX_BOMBE);
1742 case EL_SIEB_LEER: return(GFX_SIEB_LEER);
1743 case EL_SIEB_VOLL: return(GFX_SIEB_VOLL);
1744 case EL_SIEB_TOT: return(GFX_SIEB_TOT);
1745 case EL_SALZSAEURE: return(GFX_SALZSAEURE);
1746 case EL_AMOEBE_TOT: return(GFX_AMOEBE_TOT);
1747 case EL_AMOEBE_NASS: return(GFX_AMOEBE_NASS);
1748 case EL_AMOEBE_NORM: return(GFX_AMOEBE_NORM);
1749 case EL_AMOEBE_VOLL: return(GFX_AMOEBE_VOLL);
1750 case EL_AMOEBE_BD: return(GFX_AMOEBE_BD);
1751 case EL_AMOEBA2DIAM: return(GFX_AMOEBA2DIAM);
1752 case EL_KOKOSNUSS: return(GFX_KOKOSNUSS);
1753 case EL_LIFE: return(GFX_LIFE);
1754 case EL_LIFE_ASYNC: return(GFX_LIFE_ASYNC);
1755 case EL_DYNAMIT: return(GFX_DYNAMIT);
1756 case EL_BADEWANNE: return(GFX_BADEWANNE);
1757 case EL_BADEWANNE1: return(GFX_BADEWANNE1);
1758 case EL_BADEWANNE2: return(GFX_BADEWANNE2);
1759 case EL_BADEWANNE3: return(GFX_BADEWANNE3);
1760 case EL_BADEWANNE4: return(GFX_BADEWANNE4);
1761 case EL_BADEWANNE5: return(GFX_BADEWANNE5);
1762 case EL_ABLENK_AUS: return(GFX_ABLENK_AUS);
1763 case EL_ABLENK_EIN: return(GFX_ABLENK_EIN);
1764 case EL_SCHLUESSEL1: return(GFX_SCHLUESSEL1);
1765 case EL_SCHLUESSEL2: return(GFX_SCHLUESSEL2);
1766 case EL_SCHLUESSEL3: return(GFX_SCHLUESSEL3);
1767 case EL_SCHLUESSEL4: return(GFX_SCHLUESSEL4);
1768 case EL_PFORTE1: return(GFX_PFORTE1);
1769 case EL_PFORTE2: return(GFX_PFORTE2);
1770 case EL_PFORTE3: return(GFX_PFORTE3);
1771 case EL_PFORTE4: return(GFX_PFORTE4);
1772 case EL_PFORTE1X: return(GFX_PFORTE1X);
1773 case EL_PFORTE2X: return(GFX_PFORTE2X);
1774 case EL_PFORTE3X: return(GFX_PFORTE3X);
1775 case EL_PFORTE4X: return(GFX_PFORTE4X);
1776 case EL_DYNAMIT_AUS: return(GFX_DYNAMIT_AUS);
1777 case EL_PACMAN: return(GFX_PACMAN);
1778 case EL_PACMAN_R: return(GFX_PACMAN_R);
1779 case EL_PACMAN_O: return(GFX_PACMAN_O);
1780 case EL_PACMAN_L: return(GFX_PACMAN_L);
1781 case EL_PACMAN_U: return(GFX_PACMAN_U);
1782 case EL_UNSICHTBAR: return(GFX_UNSICHTBAR);
1783 case EL_ERZ_EDEL: return(GFX_ERZ_EDEL);
1784 case EL_ERZ_DIAM: return(GFX_ERZ_DIAM);
1785 case EL_BIRNE_AUS: return(GFX_BIRNE_AUS);
1786 case EL_BIRNE_EIN: return(GFX_BIRNE_EIN);
1787 case EL_ZEIT_VOLL: return(GFX_ZEIT_VOLL);
1788 case EL_ZEIT_LEER: return(GFX_ZEIT_LEER);
1789 case EL_MAUER_LEBT: return(GFX_MAUER_LEBT);
1790 case EL_EDELSTEIN_BD: return(GFX_EDELSTEIN_BD);
1791 case EL_EDELSTEIN_GELB: return(GFX_EDELSTEIN_GELB);
1792 case EL_EDELSTEIN_ROT: return(GFX_EDELSTEIN_ROT);
1793 case EL_EDELSTEIN_LILA: return(GFX_EDELSTEIN_LILA);
1794 case EL_ERZ_EDEL_BD: return(GFX_ERZ_EDEL_BD);
1795 case EL_ERZ_EDEL_GELB: return(GFX_ERZ_EDEL_GELB);
1796 case EL_ERZ_EDEL_ROT: return(GFX_ERZ_EDEL_ROT);
1797 case EL_ERZ_EDEL_LILA: return(GFX_ERZ_EDEL_LILA);
1798 case EL_MAMPFER2: return(GFX_MAMPFER2);
1799 case EL_SIEB2_LEER: return(GFX_SIEB2_LEER);
1800 case EL_SIEB2_VOLL: return(GFX_SIEB2_VOLL);
1801 case EL_SIEB2_TOT: return(GFX_SIEB2_TOT);
1802 case EL_DYNABOMB: return(GFX_DYNABOMB);
1803 case EL_DYNABOMB_NR: return(GFX_DYNABOMB_NR);
1804 case EL_DYNABOMB_SZ: return(GFX_DYNABOMB_SZ);
1805 case EL_DYNABOMB_XL: return(GFX_DYNABOMB_XL);
1806 case EL_SOKOBAN_OBJEKT: return(GFX_SOKOBAN_OBJEKT);
1807 case EL_SOKOBAN_FELD_LEER: return(GFX_SOKOBAN_FELD_LEER);
1808 case EL_SOKOBAN_FELD_VOLL: return(GFX_SOKOBAN_FELD_VOLL);
1809 case EL_MAULWURF: return(GFX_MAULWURF);
1810 case EL_PINGUIN: return(GFX_PINGUIN);
1811 case EL_SCHWEIN: return(GFX_SCHWEIN);
1812 case EL_DRACHE: return(GFX_DRACHE);
1813 case EL_SONDE: return(GFX_SONDE);
1814 case EL_PFEIL_L: return(GFX_PFEIL_L);
1815 case EL_PFEIL_R: return(GFX_PFEIL_R);
1816 case EL_PFEIL_O: return(GFX_PFEIL_O);
1817 case EL_PFEIL_U: return(GFX_PFEIL_U);
1820 if (IS_CHAR(element))
1821 return(GFX_CHAR_START + (element-EL_CHAR_START));