+void DrawPlayerButton(unsigned long state, int mode)
+{
+ Drawable dest_drawto;
+ int dest_xoffset, dest_yoffset;
+ int graphic;
+ int graphic_offset = (PLAYER_BUTTON_XSIZE - TILEX/2)/2;
+ int xpos, ypos;
+ int cx = DOOR_GFX_PAGEX4, cy = 0;
+
+ if (mode == DB_INIT)
+ {
+ dest_drawto = pix[PIX_DB_DOOR];
+ dest_xoffset = DOOR_GFX_PAGEX1;
+ dest_yoffset = 0;
+ }
+ else
+ {
+ dest_drawto = drawto;
+ dest_xoffset = DX;
+ dest_yoffset = DY;
+ }
+
+ if (state & BUTTON_PLAYER_1)
+ graphic = GFX_SPIELER1;
+ else if (state & BUTTON_PLAYER_2)
+ graphic = GFX_SPIELER2;
+ else if (state & BUTTON_PLAYER_3)
+ graphic = GFX_SPIELER3;
+ else if (state & BUTTON_PLAYER_4)
+ graphic = GFX_SPIELER4;
+
+ xpos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_3 ?
+ PLAYER_BUTTON_1_XPOS : PLAYER_BUTTON_2_XPOS);
+ ypos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_2 ?
+ PLAYER_BUTTON_1_YPOS : PLAYER_BUTTON_3_YPOS);
+
+ if (state & BUTTON_PRESSED)
+ {
+ cx = DOOR_GFX_PAGEX3;
+ graphic_offset += 1;
+ }
+
+ XCopyArea(display,pix[PIX_DOOR],dest_drawto,gc,
+ cx + PLAYER_BUTTON_GFX_XPOS, cy + PLAYER_BUTTON_GFX_YPOS,
+ PLAYER_BUTTON_XSIZE, PLAYER_BUTTON_YSIZE,
+ dest_xoffset + xpos, dest_yoffset + ypos);
+ DrawMiniGraphicExt(dest_drawto,gc,
+ dest_xoffset + xpos + graphic_offset,
+ dest_yoffset + ypos + graphic_offset,
+ graphic);
+
+ redraw_mask |= REDRAW_DOOR_1;
+}
+