~j-james/xminesweeper

e646171bb7a99b11dfce8ebda29d0c0adb52c030 — j-james 2 months ago a9e90b5 master
Include source code for archival purposes
45 files changed, 3300 insertions(+), 0 deletions(-)

A xdemineur-2.1.1/ANNOUNCE
A xdemineur-2.1.1/ChangeLog
A xdemineur-2.1.1/INSTALL
A xdemineur-2.1.1/Imakefile
A xdemineur-2.1.1/README
A xdemineur-2.1.1/demineur.c
A xdemineur-2.1.1/demineur.h
A xdemineur-2.1.1/main.c
A xdemineur-2.1.1/pixmaps/background.xpm
A xdemineur-2.1.1/pixmaps/digit_0.xpm
A xdemineur-2.1.1/pixmaps/digit_1.xpm
A xdemineur-2.1.1/pixmaps/digit_2.xpm
A xdemineur-2.1.1/pixmaps/digit_3.xpm
A xdemineur-2.1.1/pixmaps/digit_4.xpm
A xdemineur-2.1.1/pixmaps/digit_5.xpm
A xdemineur-2.1.1/pixmaps/digit_6.xpm
A xdemineur-2.1.1/pixmaps/digit_7.xpm
A xdemineur-2.1.1/pixmaps/digit_8.xpm
A xdemineur-2.1.1/pixmaps/digit_9.xpm
A xdemineur-2.1.1/pixmaps/face_click.xpm
A xdemineur-2.1.1/pixmaps/face_happy.xpm
A xdemineur-2.1.1/pixmaps/face_normal.xpm
A xdemineur-2.1.1/pixmaps/face_play.xpm
A xdemineur-2.1.1/pixmaps/face_sad.xpm
A xdemineur-2.1.1/pixmaps/flag.xpm
A xdemineur-2.1.1/pixmaps/mine.xpm
A xdemineur-2.1.1/pixmaps/mine_false.xpm
A xdemineur-2.1.1/pixmaps/mine_lost.xpm
A xdemineur-2.1.1/pixmaps/question.xpm
A xdemineur-2.1.1/pixmaps/relief.xpm
A xdemineur-2.1.1/pixmaps/square_0.xpm
A xdemineur-2.1.1/pixmaps/square_1.xpm
A xdemineur-2.1.1/pixmaps/square_2.xpm
A xdemineur-2.1.1/pixmaps/square_3.xpm
A xdemineur-2.1.1/pixmaps/square_4.xpm
A xdemineur-2.1.1/pixmaps/square_5.xpm
A xdemineur-2.1.1/pixmaps/square_6.xpm
A xdemineur-2.1.1/pixmaps/square_7.xpm
A xdemineur-2.1.1/pixmaps/square_8.xpm
A xdemineur-2.1.1/util.c
A xdemineur-2.1.1/util.h
A xdemineur-2.1.1/xdemineur.c
A xdemineur-2.1.1/xdemineur.h
A xdemineur-2.1.1/xdemineur.man
A xdemineur-2.1.1/xdemineur.xbm
A xdemineur-2.1.1/ANNOUNCE => xdemineur-2.1.1/ANNOUNCE +48 -0
@@ 0,0 1,48 @@
I'm pleased to announce the release of xd�mineur 2.1.1, a
minesweeper game for the X Window System.

This release only includes appicon support for the Window Maker
window manager <URL:http://www.windowmaker.org/>.

You can get xd�mineur source code from:

<URL:ftp://ftp.babafou.eu.org/pub/babafou/>   (primary site)
<URL:ftp://ftp.x.org/contrib/games/>

Precompiled packages (not necessarily up to date) are also
available for various operating systems:

* NetBSD <URL:http://www.netbsd.org/>

  <URL:ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/games/xdemineur/README.html>
  maintained by Manuel Bouyer <bouyer@netbsd.org>

* FreeBSD <URL:http://www.freebsd.org/>

  <URL:http://www.freebsd.org/ports/games.html>
  maintained by <ports@FreeBSD.ORG>

* Linux Debian <URL:http://www.debian.org/>

  <URL:http://www.debian.org/Packages/stable/games/xdemineur.html>
  maintained by Mark Baker <mbaker@iee.org>

* Linux Red Hat <URL:http://www.redhat.com/>
  Linux Suse <URL:http://www.suse.com/>

  <URL:http://rufus.w3.org/linux/RPM/xdemineur.html>
  maintained by <feedback@suse.de>

* Tru64 UNIX <URL:http://www.unix.digital.com/>

  <URL:http://www.unix.digital.com/demos/freekit/html/index.htm>
  maintained by <freeware@zk3.dec.com>

* HP-UX <URL:http://www.hp.com/>

  <URL:http://hpux.csc.liv.ac.uk/hppd/hpux/Games/Arcade/>
  maintained by <hpux@connect.org.uk>

You can also have some information about xd�mineur by visiting:

<URL:http://www.spinne.com/x/games/xdemineur/>

A xdemineur-2.1.1/ChangeLog => xdemineur-2.1.1/ChangeLog +45 -0
@@ 0,0 1,45 @@
1999-08-12  Marc Baudoin  <babafou@babafou.eu.org>

	* ANNOUNCE: Version 2.1.1 released.

1999-07-29  Marc Baudoin  <babafou@babafou.eu.org>

	* xdemineur.c (xdemineur_initialize): now generates an appicon to
	be used by the Window Maker window manager.

1998-02-09  Marc Baudoin  <babafou@agm-ita.ensta.fr>

	* ANNOUNCE: Version 2.1 released.

	* xdemineur.c: #include <errno.h> instead of <sys/errno.h>.

	* main.c (main): SA_RESTART is used only if defined (it doesn't
	exist on SunOS).

1998-02-08  Marc Baudoin  <babafou@agm-ita.ensta.fr>

	* xdemineur.c (xdemineur_event_loop): Don't change the face icon
	when button 2 is pressed over an already uncovered square or a
	square which don't have all its flags placed around yet.

	* main.c (main): Added -v option, which shows version number and
	copyright notice before exiting.

1998-02-07  Marc Baudoin  <babafou@agm-ita.ensta.fr>

	* xdemineur.xbm: Some changes in the face icons and the window
	icon, from <tfs@st-andrews.ac.uk>.

	* main.c: CVS is now used to manage the source tree.

1998-02-04  Marc Baudoin  <babafou@agm-ita.ensta.fr>

	* xdemineur.c (xdemineur_event_loop): Stop the timer when the
	window is iconified or fully obscured and start it again when the
	window is deiconified or unobscured.

1998-01-29  Marc Baudoin  <babafou@agm-ita.ensta.fr>

	* xdemineur.c: #include <sys/time.h> needed on Linux.  It is
	needed by select(2) anyway.


A xdemineur-2.1.1/INSTALL => xdemineur-2.1.1/INSTALL +73 -0
@@ 0,0 1,73 @@
INSTALL file for xd�mineur
==========================

Requirements
------------

To compile and install xd�mineur, you need:

* An ANSI C compiler such as the GNU C compiler, GCC.  You can
  get an up to date list of the existing GNU archives at:

  <URL:http://www.gnu.org/order/ftp.html>

* The X Window System (X11R4 or higher).

* The XPM library by Arnaud Le Hors.  You can get the latest
  version from the following locations:

  <URL:ftp://koala.inria.fr/pub/xpm/>
  <URL:ftp://ftp.x.org/contrib/libraries/>

Compilation and installation
----------------------------

You should normally not need to edit the Imakefile but feel free
to have a look at it (there's not much to see anyway).  Then do
the usual:

   xmkmf

to generate a Makefile from the Imakefile.  Then:

   make

to compile xd�mineur.  It should compile OK on most systems.
Anyway, if you have any difficulties, please send me a report (my
e-mail adress is <babafou@babafou.eu.org>) stating your
environment (operating system type and version, compiler, X
version and every information you find relevant) and a copy of
the errror messages from the compiler.

If the compilation was successful, you can try xd�mineur by
typing:

   ./xdemineur

If you're happy with it, you can install the binary:

   make install

and the manual page:

   make install.man

These two commands should be run as root on most systems.

Copyright
---------

Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>

Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation.  The author makes no
representations about the suitability of this software for any
purpose.  It is provided "as is" without express or implied
warranty.

-- 
Marc Baudoin
<babafou@babafou.eu.org>

A xdemineur-2.1.1/Imakefile => xdemineur-2.1.1/Imakefile +18 -0
@@ 0,0 1,18 @@
XCOMM Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
XCOMM
XCOMM Permission to use, copy, modify, and distribute this software and
XCOMM its documentation for any purpose and without fee is hereby
XCOMM granted, provided that the above copyright notice appear in all
XCOMM copies and that both that copyright notice and this permission
XCOMM notice appear in supporting documentation.  The author makes no
XCOMM representations about the suitability of this software for any
XCOMM purpose.  It is provided "as is" without express or implied
XCOMM warranty.

XCOMM        DEFINES = -Wall
LOCAL_LIBRARIES = -lXpm $(XLIB)
        DEPLIBS = $(DEPXLIB)
           SRCS = demineur.c main.c util.c xdemineur.c
           OBJS = demineur.o main.o util.o xdemineur.o

ComplexProgramTarget(xdemineur)

A xdemineur-2.1.1/README => xdemineur-2.1.1/README +73 -0
@@ 0,0 1,73 @@
README file for xd�mineur
=========================

Xd�mineur is a minesweeper game for the X Window System.

The object of this game is to find the location of the mines
hidden in the minefield and to mark their location by placing a
warning flag.  You have exactly as many flags as there are mines.
The number of flags that remain to be placed is displayed in the
top left corner of the window and a timer is displayed in the top
right corner.

The game is played using a three buttons mouse, as usual with the
X Window System.  The left button (button 1) is used to uncover
the square on which you click (hoping that a mine is not hidden
there).  The number displayed in an uncovered square indicates
how many mines are located around this square (for example, a 3
means that there are three mines within the 8 surrounding
squares).  The whole game relies on the right use of these
numbers.  The right button (button 3) is used to place a flag on
a square (this indicates that there is a mine here).  If you
click again with the right button on a square that has a flag,
the flag is changed into a question mark: this is useful if you
are trying to guess the possible location of some mine, you can
use question marks to think about it.  One more click with the
right button and the question mark disappears.  Clicking with the
middle button (button 2) on an uncovered square which has all its
flags placed around uncovers the surrounding cells which have no
flags (this will save a lot of time).

Finally, to start a new game, just click on the yellow face above
the minefield.

FTP sites
---------

You can get the latest version of xd�mineur by anonymous FTP
from:

<URL:ftp://ftp.babafou.eu.org/pub/babafou/>   (primary site)
<URL:ftp://ftp.x.org/contrib/games/>

Installation
------------

See the INSTALL file.

Bugs
----

Please report any bug you could find in xd�mineur to
<babafou@babafou.eu.org>.  Also, you should tell me the
customizations you may have done, such as adding new functions to
the game or making modifications to allow the game to run on your
system.

Copyright
---------

Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>

Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation.  The author makes no
representations about the suitability of this software for any
purpose.  It is provided "as is" without express or implied
warranty.

-- 
Marc Baudoin
<babafou@babafou.eu.org>

A xdemineur-2.1.1/demineur.c => xdemineur-2.1.1/demineur.c +435 -0
@@ 0,0 1,435 @@
/*
 * Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby
 * granted, provided that the above copyright notice appear in all
 * copies and that both that copyright notice and this permission
 * notice appear in supporting documentation.  The author makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 */

static char *const cvsid = "$Id: demineur.c,v 1.2.2.1 1999/07/29 21:25:30 babafou Exp $" ;

#include <sys/types.h>

#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>

#include <sys/time.h>

#include "demineur.h"
#include "util.h"
#include "xdemineur.h"

/* ------------------------------------------------------------------------- */

typedef struct row_column
{
   int row ;
   int column ;
   struct row_column *next ;
}
row_column_t ;

/* ------------------------------------------------------------------------- */

int demineur_flag_count ( int row , int column ) ;

void demineur_won ( ) ;

/* ------------------------------------------------------------------------- */

board_t           board ;
int               mines ;
volatile time_t   elapsed ;
state_t           state ;

/* ------------------------------------------------------------------------- */

void demineur_initialize ( int option_mines )
{
   int            row , column , m , openings ;
   row_column_t   *rc = NULL , *ptr = NULL ;

   /* There are two extra rows and two extra columns so that
    * there's no need to handle side effects when counting the
    * number of surrounding mines.
    */

   board.board = ( square_t ** ) xmalloc ( ( board.rows + 2 )
                                           * sizeof ( square_t * ) ) ;
   for ( row = 0 ; row < board.rows + 2 ; row ++ )
   {
      board.board[row] = ( square_t * ) xmalloc ( ( board.columns + 2 )
                                                  * sizeof ( square_t ) ) ;
   }

   if ( option_mines != 0 )
   {
      if ( option_mines >= board.rows * board.columns )
      {
         printf ( "Too many mines, using default number.\n" ) ;
         mines = board.mines = board.rows * board.columns / 4.8 ;
      }
      else
      {
         mines = board.mines = option_mines ;
      }
   }
   else
   {
      mines = board.mines = board.rows * board.columns / 4.8 ;
   }

   elapsed = 0 ;
   state = PLAYING ;

   /* initialize board */

   for ( row = 0 ; row < board.rows + 2 ; row ++ )
   {
      for ( column = 0 ; column < board.columns + 2 ; column ++ )
      {
         board.board[row][column].mine   = 0 ;
         board.board[row][column].around = 0 ;
         board.board[row][column].state  = HIDDEN ;
      }
   }

   /* special treatment for extra squares */

   for ( row = 0 ; row < board.rows + 2 ; row ++ )
   {
      board.board[row][0].state                 = UNCOVERED ;
      board.board[row][board.columns + 1].state = UNCOVERED ;
   }

   for ( column = 0 ; column < board.columns + 2 ; column ++ )
   {
      board.board[0][column].state              = UNCOVERED ;
      board.board[board.rows + 1][column].state = UNCOVERED ;
   }

   /* mines deposit */

   for ( row = 1 ; row <= board.rows ; row ++ )
   {
      for ( column = 1 ; column <= board.columns ; column ++ )
      {
         if ( rc == NULL )   /* first square */
         {
            rc = ( row_column_t * ) xmalloc ( sizeof ( row_column_t ) ) ;
            ptr = rc ;
         }
         else
         {
            ptr->next = ( row_column_t * )
                        xmalloc ( sizeof ( row_column_t ) ) ;
            ptr = ptr->next ;
         }

         ptr->row    = row ;
         ptr->column = column ;
         ptr->next   = NULL ;
      }
   }

   for ( m = 0 ; m < board.mines ; m ++ )
   {
      int alea = rand ( ) % ( board.rows * board.columns - m ) ;

      if ( alea == 0 )
      {
         ptr = rc ;
         rc = rc->next ;
      }
      else
      {
         row_column_t *tmp ;

         for ( ptr = rc ; alea > 1 ; alea -- , ptr = ptr->next )
         {
            continue ;
         }

         tmp = ptr->next ;
         ptr->next = ptr->next->next ;
         ptr = tmp ;
      }

      board.board[ptr->row][ptr->column].mine = 1 ;
      free ( ptr ) ;
   }

   /* free memory used by squares without mine */

   for ( ptr = rc ; ptr != NULL ; )
   {
      row_column_t *tmp = ptr->next ;

      free ( ptr ) ;
      ptr = tmp ;
   }
   rc = NULL ;

   /* mines counting */

   for ( row = 1 ; row <= board.rows ; row ++ )
   {
      for ( column = 1 ; column <= board.columns ; column ++ )
      {
         board.board[row][column].around =
                                        board.board[row - 1][column - 1].mine +
                                        board.board[row - 1][column    ].mine +
                                        board.board[row - 1][column + 1].mine +
                                        board.board[row    ][column - 1].mine +
                                        board.board[row    ][column + 1].mine +
                                        board.board[row + 1][column - 1].mine +
                                        board.board[row + 1][column    ].mine +
                                        board.board[row + 1][column + 1].mine ;
      }
   }

   /* automatic opening */

   openings = 0 ;
   for ( row = 1 ; row <= board.rows ; row ++ )
   {
      for ( column = 1 ; column <= board.columns ; column ++ )
      {
         if ( board.board[row][column].around == 0
              && ! board.board[row][column].mine )
         {
            openings ++ ;

            if ( rc == NULL )   /* first square */
            {
               rc = ( row_column_t * ) xmalloc ( sizeof ( row_column_t ) ) ;
               ptr = rc ;
            }
            else
            {
               ptr->next = ( row_column_t * )
                           xmalloc ( sizeof ( row_column_t ) ) ;
               ptr = ptr->next ;
            }

            ptr->row    = row ;
            ptr->column = column ;
            ptr->next   = NULL ;
         }
      }
   }

   if ( openings != 0 )
   {
      int alea = rand ( ) % openings , i ;

      for ( i = 0 , ptr = rc ; i < alea ; i ++ , ptr = ptr->next )
      {
         continue ;
      }

      demineur_play ( ptr->row , ptr->column ) ;
   }

   for ( ptr = rc ; ptr != NULL ; )
   {
      row_column_t *tmp = ptr->next ;

      free ( ptr ) ;
      ptr = tmp ;
   }
}

/* ------------------------------------------------------------------------- */

void demineur_start_timer ( )
{
   struct itimerval itimerval ;

   itimerval.it_interval.tv_sec  = 1 ;
   itimerval.it_interval.tv_usec = 0 ;
   itimerval.it_value.tv_sec     = 1 ;
   itimerval.it_value.tv_usec    = 0 ;
   if ( setitimer ( ITIMER_REAL , &itimerval , NULL ) == -1 )
   {
      perror ( "setitimer" ) ;
      exit ( EX_OSERR ) ;
   }
}

/* ------------------------------------------------------------------------- */

void demineur_stop_timer ( )
{
   struct itimerval itimerval ;

   timerclear ( &itimerval.it_interval ) ;
   timerclear ( &itimerval.it_value    ) ;

   if ( setitimer ( ITIMER_REAL , &itimerval , NULL ) == -1 )
   {
      perror ( "setitimer" ) ;
      exit ( EX_OSERR ) ;
   }
}

/* ------------------------------------------------------------------------- */

void demineur_play ( int row , int column )
{
   if ( row < 1 || row > board.rows || column < 1 || column > board.columns )
   {
      return ;
   }

   if ( board.board[row][column].state == HIDDEN )
   {
      board.board[row][column].state = UNCOVERED ;
      xdemineur_square ( row , column ) ;
      if ( board.board[row][column].mine )
      {
         state = LOST ;
         demineur_stop_timer ( ) ;
         xdemineur_display ( ) ;
      }
      else if ( board.board[row][column].around == 0 )
      {
         demineur_clear ( row , column ) ;
      }
   }

   if ( mines == 0 )
   {
      demineur_won ( ) ;
   }
}

/* ------------------------------------------------------------------------- */

int demineur_hidden ( int row , int column )
{
   return demineur_hidden_count ( row - 1 , column - 1 ) +
          demineur_hidden_count ( row - 1 , column     ) +
          demineur_hidden_count ( row - 1 , column + 1 ) +
          demineur_hidden_count ( row     , column - 1 ) +
          demineur_hidden_count ( row     , column + 1 ) +
          demineur_hidden_count ( row + 1 , column - 1 ) +
          demineur_hidden_count ( row + 1 , column     ) +
          demineur_hidden_count ( row + 1 , column + 1 ) ;
}

/* ------------------------------------------------------------------------- */

int demineur_hidden_count ( int row , int column )
{
   return ( board.board[row][column].state == HIDDEN ) ? 1 : 0 ;
}

/* ------------------------------------------------------------------------- */

int demineur_flags ( int row , int column )
{
   return demineur_flag_count ( row - 1 , column - 1 ) +
          demineur_flag_count ( row - 1 , column     ) +
          demineur_flag_count ( row - 1 , column + 1 ) +
          demineur_flag_count ( row     , column - 1 ) +
          demineur_flag_count ( row     , column + 1 ) +
          demineur_flag_count ( row + 1 , column - 1 ) +
          demineur_flag_count ( row + 1 , column     ) +
          demineur_flag_count ( row + 1 , column + 1 ) ;
}

/* ------------------------------------------------------------------------- */

int demineur_flag_count ( int row , int column )
{
   return ( board.board[row][column].state == FLAGGED ) ? 1 : 0 ;
}

/* ------------------------------------------------------------------------- */

void demineur_clear ( int row , int column )
{
   demineur_play ( row - 1 , column - 1 ) ;
   demineur_play ( row - 1 , column     ) ;
   demineur_play ( row - 1 , column + 1 ) ;
   demineur_play ( row     , column - 1 ) ;
   demineur_play ( row     , column + 1 ) ;
   demineur_play ( row + 1 , column - 1 ) ;
   demineur_play ( row + 1 , column     ) ;
   demineur_play ( row + 1 , column + 1 ) ;
}

/* ------------------------------------------------------------------------- */

void demineur_flag_question ( int row , int column )
{
   switch ( board.board[row][column].state )
   {
   case HIDDEN :
      if ( mines > 0 )
      {
         board.board[row][column].state = FLAGGED ;
         mines -- ;
         if ( mines == 0 )
         {
            demineur_won ( ) ;
         }
      }
      break ;
   case FLAGGED :
      board.board[row][column].state = QUESTION ;
      mines ++ ;
      break ;
   case QUESTION :
      board.board[row][column].state = HIDDEN ;
      break ;
   case UNCOVERED :
      break ;
   }
}

/* ------------------------------------------------------------------------- */

void demineur_won ( )
{
   int row , column ;

   for ( row = 1 ; row <= board.rows ; row ++ )
   {
      for ( column = 1 ; column <= board.columns ; column ++ )
      {
         if ( board.board[row][column].state == HIDDEN ||
              board.board[row][column].state == QUESTION )
         {
            return ;
         }
      }
   }

   /* if you get there, it's that you've won */

   state = WON ;
   demineur_stop_timer ( ) ;
   xdemineur_face ( ) ;
}

/* ------------------------------------------------------------------------- */

void demineur_end ( )
{
   int row ;

   for ( row = 0 ; row < board.rows + 2 ; row ++ )
   {
      free ( board.board[row] ) ;
   }
   free ( board.board ) ;
}

A xdemineur-2.1.1/demineur.h => xdemineur-2.1.1/demineur.h +72 -0
@@ 0,0 1,72 @@
/*
 * Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby
 * granted, provided that the above copyright notice appear in all
 * copies and that both that copyright notice and this permission
 * notice appear in supporting documentation.  The author makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 */

/* $Id: demineur.h,v 1.2.2.1 1999/07/29 21:25:31 babafou Exp $ */

#ifndef _DEMINEUR_H_
#define _DEMINEUR_H_

typedef struct
{
   int   mine ;     /* 1 if there's a mine, 0 otherwise */
   int   around ;   /* mine count around this square    */
   enum
   {
      HIDDEN    ,   /* hidden square    */
      FLAGGED   ,   /* flagged square   */
      QUESTION  ,   /* question mark    */
      UNCOVERED     /* uncovered square */
   }
   state ;          /* square state */
}
square_t ;

typedef struct
{
   int        rows ;      /* number of rows    */
   int        columns ;   /* number of columns */
   int        mines ;     /* number of mines   */
   square_t   **board ;   /* the game board    */
}
board_t ;

typedef enum
{
   PLAYING , WON , LOST
}
state_t ;

/* ------------------------------------------------------------------------- */

void demineur_initialize ( int option_mines ) ;

void demineur_start_timer ( ) ;

void demineur_stop_timer ( ) ;

void demineur_play ( int row , int column ) ;

int demineur_hidden ( int row , int column ) ;

int demineur_hidden_count ( int row , int column ) ;

int demineur_flags ( int row , int column ) ;

void demineur_clear ( int row , int column ) ;

void demineur_flag_question ( int row , int column ) ;

void demineur_end ( ) ;

#endif /* _DEMINEUR_H_ */

A xdemineur-2.1.1/main.c => xdemineur-2.1.1/main.c +144 -0
@@ 0,0 1,144 @@
/*
 * Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby
 * granted, provided that the above copyright notice appear in all
 * copies and that both that copyright notice and this permission
 * notice appear in supporting documentation.  The author makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 */

static char *const cvsid = "$Id: main.c,v 1.3.2.2 1999/08/01 20:57:46 babafou Exp $" ;

#include <sys/types.h>

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
#include <time.h>

#include "demineur.h"
#include "xdemineur.h"

/* ------------------------------------------------------------------------- */

void sigalrm ( int sig ) ;

/* ------------------------------------------------------------------------- */

extern volatile time_t   elapsed ;
extern state_t           state ;

/* ------------------------------------------------------------------------- */

int main ( int argc , char **argv )
{
   int                i , option_mines = 0 ;
   char               *display_name = NULL , *geometry = NULL ;
   struct sigaction   act ;

   /* command line arguments */

   for ( i = 1 ; i < argc ; i ++ )
   {
      if ( strcmp ( argv[i] , "-v" ) == 0 )
      {
         unsigned char *message = "\
xd�mineur 2.1.1\n\
\n\
Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>\n\
\n\
Permission to use, copy, modify, and distribute this software and\n\
its documentation for any purpose and without fee is hereby\n\
granted, provided that the above copyright notice appear in all\n\
copies and that both that copyright notice and this permission\n\
notice appear in supporting documentation.  The author makes no\n\
representations about the suitability of this software for any\n\
purpose.  It is provided \"as is\" without express or implied\n\
warranty.\n" ;

         printf ( "%s" , message ) ;

         exit ( EX_OK ) ;
      }
      else if ( strcmp ( argv[i] , "-display" ) == 0 )
      {
         i ++ ;
         if ( i < argc )
         {
            display_name = argv[i] ;
            continue ;
         }
         i -- ;
      }
      else if ( strcmp ( argv[i] , "-geometry" ) == 0 )
      {
         i ++ ;
         if ( i < argc )
         {
            geometry = argv[i] ;
            continue ;
         }
         i -- ;
      }
      else if ( strcmp ( argv[i] , "-m" ) == 0 )
      {
         i ++ ;
         if ( i < argc )
         {
            option_mines = atoi ( argv[i] ) ;
            continue ;
         }
         i -- ;
      }

      fprintf ( stderr , "bad command line option \"%s\"\n" , argv[i] ) ;
      fprintf ( stderr ,
        "usage: %s [-v] [-display displayname] [-geometry geom] [-m mines]\n" ,
                argv[0] ) ;
      exit ( EX_USAGE ) ;
   }

   /* initialization */

   xdemineur_initialize ( argc , argv , display_name , geometry ) ;

   srand ( time ( NULL ) ) ;

   demineur_initialize ( option_mines ) ;

   act.sa_handler = sigalrm ;
   sigemptyset ( &act.sa_mask ) ;
#ifdef SA_RESTART
   act.sa_flags = SA_RESTART ;
#else
   act.sa_flags = 0 ;
#endif
   if ( sigaction ( SIGALRM , &act , NULL ) == -1 )
   {
      perror ( "sigaction" ) ;
      exit ( EX_OSERR ) ;
   }

   /* event loop */

   xdemineur_event_loop ( ) ;

   /* the end */

   demineur_end ( ) ;

   exit ( EX_OK ) ;
}

/* ------------------------------------------------------------------------- */

void sigalrm ( int sig )
{
   elapsed ++ ;
}

A xdemineur-2.1.1/pixmaps/background.xpm => xdemineur-2.1.1/pixmaps/background.xpm +27 -0
@@ 0,0 1,27 @@
/* XPM */

static char *xpm_fond[] =
{
   /* width height ncolors chars_per_pixel */
   "16 16 2 1" ,
   /* colors */
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   /* pixels */
   "*.*.*.*.*.*.*.*." ,
   ".*.*.*.*.*.*.*.*" ,
   "*.*.*.*.*.*.*.*." ,
   ".*.*.*.*.*.*.*.*" ,
   "*.*.*.*.*.*.*.*." ,
   ".*.*.*.*.*.*.*.*" ,
   "*.*.*.*.*.*.*.*." ,
   ".*.*.*.*.*.*.*.*" ,
   "*.*.*.*.*.*.*.*." ,
   ".*.*.*.*.*.*.*.*" ,
   "*.*.*.*.*.*.*.*." ,
   ".*.*.*.*.*.*.*.*" ,
   "*.*.*.*.*.*.*.*." ,
   ".*.*.*.*.*.*.*.*" ,
   "*.*.*.*.*.*.*.*." ,
   ".*.*.*.*.*.*.*.*" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_0.xpm => xdemineur-2.1.1/pixmaps/digit_0.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_0[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "###--------------###" ,
   "##-#------------#-##" ,
   "##--#----------#--##" ,
   "##---#--------#---##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##---##########---##" ,
   "##--############--##" ,
   "##-##############-##" ,
   "####################" ,
   "##-##############-##" ,
   "##--############--##" ,
   "##---##########---##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##---#--------#---##" ,
   "##--#----------#--##" ,
   "##-#------------#-##" ,
   "###--------------###" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_1.xpm => xdemineur-2.1.1/pixmaps/digit_1.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_1[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "####################" ,
   "#################-##" ,
   "################--##" ,
   "###############---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "###############---##" ,
   "################--##" ,
   "#################-##" ,
   "####################" ,
   "#################-##" ,
   "################--##" ,
   "###############---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "###############---##" ,
   "################--##" ,
   "#################-##" ,
   "####################" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_2.xpm => xdemineur-2.1.1/pixmaps/digit_2.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_2[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "###--------------###" ,
   "####------------#-##" ,
   "#####----------#--##" ,
   "######--------#---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "###############---##" ,
   "#####----------#--##" ,
   "####------------#-##" ,
   "###--------------###" ,
   "##-#------------####" ,
   "##--#----------#####" ,
   "##---###############" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##---#--------######" ,
   "##--#----------#####" ,
   "##-#------------####" ,
   "###--------------###" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_3.xpm => xdemineur-2.1.1/pixmaps/digit_3.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_3[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "###--------------###" ,
   "####------------#-##" ,
   "#####----------#--##" ,
   "######--------#---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "###############---##" ,
   "#####----------#--##" ,
   "####------------#-##" ,
   "###--------------###" ,
   "####------------#-##" ,
   "#####----------#--##" ,
   "###############---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "######--------#---##" ,
   "#####----------#--##" ,
   "####------------#-##" ,
   "###--------------###" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_4.xpm => xdemineur-2.1.1/pixmaps/digit_4.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_4[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "####################" ,
   "##-##############-##" ,
   "##--############--##" ,
   "##---##########---##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##---##########---##" ,
   "##--#----------#--##" ,
   "##-#------------#-##" ,
   "###--------------###" ,
   "####------------#-##" ,
   "#####----------#--##" ,
   "###############---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "###############---##" ,
   "################--##" ,
   "#################-##" ,
   "####################" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_5.xpm => xdemineur-2.1.1/pixmaps/digit_5.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_5[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "###--------------###" ,
   "##-#------------####" ,
   "##--#----------#####" ,
   "##---#--------######" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##---###############" ,
   "##--#----------#####" ,
   "##-#------------####" ,
   "###--------------###" ,
   "####------------#-##" ,
   "#####----------#--##" ,
   "###############---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "######--------#---##" ,
   "#####----------#--##" ,
   "####------------#-##" ,
   "###--------------###" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_6.xpm => xdemineur-2.1.1/pixmaps/digit_6.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_6[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "###--------------###" ,
   "##-#------------####" ,
   "##--#----------#####" ,
   "##---#--------######" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##----##############" ,
   "##---###############" ,
   "##--#----------#####" ,
   "##-#------------####" ,
   "###--------------###" ,
   "##-#------------#-##" ,
   "##--#----------#--##" ,
   "##---##########---##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##---#--------#---##" ,
   "##--#----------#--##" ,
   "##-#------------#-##" ,
   "###--------------###" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_7.xpm => xdemineur-2.1.1/pixmaps/digit_7.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_7[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "###--------------###" ,
   "####------------#-##" ,
   "#####----------#--##" ,
   "######--------#---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "###############---##" ,
   "################--##" ,
   "#################-##" ,
   "####################" ,
   "#################-##" ,
   "################--##" ,
   "###############---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "###############---##" ,
   "################--##" ,
   "#################-##" ,
   "####################" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_8.xpm => xdemineur-2.1.1/pixmaps/digit_8.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_8[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "###--------------###" ,
   "##-#------------#-##" ,
   "##--#----------#--##" ,
   "##---#--------#---##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##---##########---##" ,
   "##--#----------#--##" ,
   "##-#------------#-##" ,
   "###--------------###" ,
   "##-#------------#-##" ,
   "##--#----------#--##" ,
   "##---##########---##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##---#--------#---##" ,
   "##--#----------#--##" ,
   "##-#------------#-##" ,
   "###--------------###" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/digit_9.xpm => xdemineur-2.1.1/pixmaps/digit_9.xpm +41 -0
@@ 0,0 1,41 @@
/* XPM */

static char *xpm_digit_9[] =
{
   /* width height ncolors chars_per_pixel */
   "20 30 2 1" ,
   /* colors */
   "- c red m white" ,
   "# c black" ,
   /* pixels */
   "####################" ,
   "####################" ,
   "###--------------###" ,
   "##-#------------#-##" ,
   "##--#----------#--##" ,
   "##---#--------#---##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##----########----##" ,
   "##---##########---##" ,
   "##--#----------#--##" ,
   "##-#------------#-##" ,
   "###--------------###" ,
   "####------------#-##" ,
   "#####----------#--##" ,
   "###############---##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "##############----##" ,
   "######--------#---##" ,
   "#####----------#--##" ,
   "####------------#-##" ,
   "###--------------###" ,
   "####################" ,
   "####################" ,
} ;

A xdemineur-2.1.1/pixmaps/face_click.xpm => xdemineur-2.1.1/pixmaps/face_click.xpm +55 -0
@@ 0,0 1,55 @@
/* XPM */

static char *xpm_face_click[] =
{
   /* width height ncolors chars_per_pixel */
   "40 40 6 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   "X c gray50 m black" ,
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   "- c yellow m white" ,
   /* pixels */
   "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " ,
   "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  " ,
   "XXX*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.   " ,
   "XXX.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*   " ,
   "XXX*.*.*.*.*.*.*########.*.*.*.*.*.*.   " ,
   "XXX.*.*.*.*.*###--------###.*.*.*.*.*   " ,
   "XXX*.*.*.*.##--------------##*.*.*.*.   " ,
   "XXX.*.*.*.#------------------#*.*.*.*   " ,
   "XXX*.*.*.#--------------------#*.*.*.   " ,
   "XXX.*.*.#----------------------#*.*.*   " ,
   "XXX*.*.#------------------------#*.*.   " ,
   "XXX.*.*#------------------------#.*.*   " ,
   "XXX*.*#-------##--------##-------#.*.   " ,
   "XXX.*.#------####------####------#*.*   " ,
   "XXX*.*#------####------####------#.*.   " ,
   "XXX.*#--------##--------##--------#.*   " ,
   "XXX*.#----------------------------#*.   " ,
   "XXX.*#----------------------------#.*   " ,
   "XXX*.#----------------------------#*.   " ,
   "XXX.*#----------------------------#.*   " ,
   "XXX*.#----------------------------#*.   " ,
   "XXX.*#----------------------------#.*   " ,
   "XXX*.#----------------------------#*.   " ,
   "XXX.*.#------#------------#------#*.*   " ,
   "XXX*.*#-------#----------#-------#.*.   " ,
   "XXX.*.#--------##------##--------#*.*   " ,
   "XXX*.*.#---------######---------#*.*.   " ,
   "XXX.*.*#------------------------#.*.*   " ,
   "XXX*.*.*#----------------------#.*.*.   " ,
   "XXX.*.*.*#--------------------#.*.*.*   " ,
   "XXX*.*.*.*#------------------#.*.*.*.   " ,
   "XXX.*.*.*.*##--------------##.*.*.*.*   " ,
   "XXX*.*.*.*.*.###--------###*.*.*.*.*.   " ,
   "XXX.*.*.*.*.*.*.########*.*.*.*.*.*.*   " ,
   "XXX*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.   " ,
   "XXX.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*   " ,
   "XXX                                     " ,
   "XX                                      " ,
   "X                                       " ,
} ;

A xdemineur-2.1.1/pixmaps/face_happy.xpm => xdemineur-2.1.1/pixmaps/face_happy.xpm +55 -0
@@ 0,0 1,55 @@
/* XPM */

static char *xpm_face_happy[] =
{
   /* width height ncolors chars_per_pixel */
   "40 40 6 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   "X c gray50 m black" ,
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   "- c yellow m white" ,
   /* pixels */
   "                                        " ,
   "                                       X" ,
   "                                      XX" ,
   "   *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*########.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*###--------###.*.*.*.*.*XXX" ,
   "   *.*.*.*.##--------------##*.*.*.*.XXX" ,
   "   .*.*.*.#------------------#*.*.*.*XXX" ,
   "   *.*.*.#--------------------#*.*.*.XXX" ,
   "   .*.*.#----------------------#*.*.*XXX" ,
   "   *.*.#------------------------#*.*.XXX" ,
   "   .*.*#----################----#.*.*XXX" ,
   "   *.*#----##################----#.*.XXX" ,
   "   .*.#---#-################-#---#*.*XXX" ,
   "   *.*#--#--#######--#######--#--#.*.XXX" ,
   "   .*#--#---######----######---#--#.*XXX" ,
   "   *.#-#-----####------####-----#-#*.XXX" ,
   "   .*##-------##--------##-------##.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*.#------#------------#------#*.*XXX" ,
   "   *.*#-------#----------#-------#.*.XXX" ,
   "   .*.#--------##------##--------#*.*XXX" ,
   "   *.*.#---------######---------#*.*.XXX" ,
   "   .*.*#------------------------#.*.*XXX" ,
   "   *.*.*#----------------------#.*.*.XXX" ,
   "   .*.*.*#--------------------#.*.*.*XXX" ,
   "   *.*.*.*#------------------#.*.*.*.XXX" ,
   "   .*.*.*.*##--------------##.*.*.*.*XXX" ,
   "   *.*.*.*.*.###--------###*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.########*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*XXX" ,
   "   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   "  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
} ;

A xdemineur-2.1.1/pixmaps/face_normal.xpm => xdemineur-2.1.1/pixmaps/face_normal.xpm +55 -0
@@ 0,0 1,55 @@
/* XPM */

static char *xpm_face_normal[] =
{
   /* width height ncolors chars_per_pixel */
   "40 40 6 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   "X c gray50 m black" ,
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   "- c yellow m white" ,
   /* pixels */
   "                                        " ,
   "                                       X" ,
   "                                      XX" ,
   "   *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*########.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*###--------###.*.*.*.*.*XXX" ,
   "   *.*.*.*.##--------------##*.*.*.*.XXX" ,
   "   .*.*.*.#------------------#*.*.*.*XXX" ,
   "   *.*.*.#--------------------#*.*.*.XXX" ,
   "   .*.*.#----------------------#*.*.*XXX" ,
   "   *.*.#------------------------#*.*.XXX" ,
   "   .*.*#------------------------#.*.*XXX" ,
   "   *.*#-------##--------##-------#.*.XXX" ,
   "   .*.#------####------####------#*.*XXX" ,
   "   *.*#------####------####------#.*.XXX" ,
   "   .*#--------##--------##--------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*.#------#------------#------#*.*XXX" ,
   "   *.*#-------#----------#-------#.*.XXX" ,
   "   .*.#--------##------##--------#*.*XXX" ,
   "   *.*.#---------######---------#*.*.XXX" ,
   "   .*.*#------------------------#.*.*XXX" ,
   "   *.*.*#----------------------#.*.*.XXX" ,
   "   .*.*.*#--------------------#.*.*.*XXX" ,
   "   *.*.*.*#------------------#.*.*.*.XXX" ,
   "   .*.*.*.*##--------------##.*.*.*.*XXX" ,
   "   *.*.*.*.*.###--------###*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.########*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*XXX" ,
   "   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   "  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
} ;

A xdemineur-2.1.1/pixmaps/face_play.xpm => xdemineur-2.1.1/pixmaps/face_play.xpm +55 -0
@@ 0,0 1,55 @@
/* XPM */

static char *xpm_face_play[] =
{
   /* width height ncolors chars_per_pixel */
   "40 40 6 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   "X c gray50 m black" ,
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   "- c yellow m white" ,
   /* pixels */
   "                                        " ,
   "                                       X" ,
   "                                      XX" ,
   "   *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*########.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*###--------###.*.*.*.*.*XXX" ,
   "   *.*.*.*.##--------------##*.*.*.*.XXX" ,
   "   .*.*.*.#------------------#*.*.*.*XXX" ,
   "   *.*.*.#--------------------#*.*.*.XXX" ,
   "   .*.*.#----------------------#*.*.*XXX" ,
   "   *.*.#------------------------#*.*.XXX" ,
   "   .*.*#------##--------##------#.*.*XXX" ,
   "   *.*#------####------####------#.*.XXX" ,
   "   .*.#-----######----######-----#*.*XXX" ,
   "   *.*#-----######----######-----#.*.XXX" ,
   "   .*#-------####------####-------#.*XXX" ,
   "   *.#--------##--------##--------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#-------------##-------------#*.XXX" ,
   "   .*.#-----------#--#-----------#*.*XXX" ,
   "   *.*#----------#----#----------#.*.XXX" ,
   "   .*.#----------#----#----------#*.*XXX" ,
   "   *.*.#----------#--#----------#*.*.XXX" ,
   "   .*.*#-----------##-----------#.*.*XXX" ,
   "   *.*.*#----------------------#.*.*.XXX" ,
   "   .*.*.*#--------------------#.*.*.*XXX" ,
   "   *.*.*.*#------------------#.*.*.*.XXX" ,
   "   .*.*.*.*##--------------##.*.*.*.*XXX" ,
   "   *.*.*.*.*.###--------###*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.########*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*XXX" ,
   "   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   "  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
} ;

A xdemineur-2.1.1/pixmaps/face_sad.xpm => xdemineur-2.1.1/pixmaps/face_sad.xpm +55 -0
@@ 0,0 1,55 @@
/* XPM */

static char *xpm_face_sad[] =
{
   /* width height ncolors chars_per_pixel */
   "40 40 6 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   "X c gray50 m black" ,
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   "- c yellow m white" ,
   /* pixels */
   "                                        " ,
   "                                       X" ,
   "                                      XX" ,
   "   *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*########.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*###--------###.*.*.*.*.*XXX" ,
   "   *.*.*.*.##--------------##*.*.*.*.XXX" ,
   "   .*.*.*.#------------------#*.*.*.*XXX" ,
   "   *.*.*.#--------------------#*.*.*.XXX" ,
   "   .*.*.#----------------------#*.*.*XXX" ,
   "   *.*.#------------------------#*.*.XXX" ,
   "   .*.*#------------------------#.*.*XXX" ,
   "   *.*#------#--#------#--#------#.*.XXX" ,
   "   .*.#-------##--------##-------#*.*XXX" ,
   "   *.*#-------##--------##-------#.*.XXX" ,
   "   .*#-------#--#------#--#-------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*#----------------------------#.*XXX" ,
   "   *.#----------------------------#*.XXX" ,
   "   .*.#----------######----------#*.*XXX" ,
   "   *.*#--------##------##--------#.*.XXX" ,
   "   .*.#-------#----------#-------#*.*XXX" ,
   "   *.*.#-----#------------#-----#*.*.XXX" ,
   "   .*.*#------------------------#.*.*XXX" ,
   "   *.*.*#----------------------#.*.*.XXX" ,
   "   .*.*.*#--------------------#.*.*.*XXX" ,
   "   *.*.*.*#------------------#.*.*.*.XXX" ,
   "   .*.*.*.*##--------------##.*.*.*.*XXX" ,
   "   *.*.*.*.*.###--------###*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.########*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*XXX" ,
   "   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   "  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
   " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ,
} ;

A xdemineur-2.1.1/pixmaps/flag.xpm => xdemineur-2.1.1/pixmaps/flag.xpm +35 -0
@@ 0,0 1,35 @@
/* XPM */

static char *xpm_flag[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 6 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   "X c gray50 m black" ,
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   "- c red    m black" ,
   /* pixels */
   "                    " ,
   "                   X" ,
   "                  XX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*.*--.*.*.*XXX" ,
   "   *.*.----*.*.*.XXX" ,
   "   .*------.*.*.*XXX" ,
   "   *-------*.*.*.XXX" ,
   "   .*------.*.*.*XXX" ,
   "   *.*.----*.*.*.XXX" ,
   "   .*.*.*--.*.*.*XXX" ,
   "   *.*.*.*#*.*.*.XXX" ,
   "   .*.*.*.#.*.*.*XXX" ,
   "   *.*.*####.*.*.XXX" ,
   "   .*.########*.*XXX" ,
   "   *.##########*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   XXXXXXXXXXXXXXXXX" ,
   "  XXXXXXXXXXXXXXXXXX" ,
   " XXXXXXXXXXXXXXXXXXX" ,
} ;

A xdemineur-2.1.1/pixmaps/mine.xpm => xdemineur-2.1.1/pixmaps/mine.xpm +32 -0
@@ 0,0 1,32 @@
/* XPM */

static char *xpm_mine[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 3 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   ". c gray70 m white" ,
   /* pixels */
   "...................." ,
   ".........##........." ,
   ".........##........." ,
   "...#....####....#..." ,
   "....#.########.#...." ,
   ".....##########....." ,
   "....############...." ,
   "....###   ######...." ,
   "...####   #######..." ,
   ".######   #########." ,
   ".##################." ,
   "...##############..." ,
   "....############...." ,
   "....############...." ,
   ".....##########....." ,
   "....#.########.#...." ,
   "...#....####....#..." ,
   ".........##........." ,
   ".........##........." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/mine_false.xpm => xdemineur-2.1.1/pixmaps/mine_false.xpm +34 -0
@@ 0,0 1,34 @@
/* XPM */

static char *xpm_mine_false[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 5 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   "* c black  m white" ,
   ". c gray70 m white" ,
   "- c red    m black" ,
   /* pixels */
   "...................." ,
   ".--......#*......--." ,
   ".---.....*#.....---." ,
   "..---...*#*#...---.." ,
   "...---#*#*#*#*---..." ,
   "....---#*#*#*---...." ,
   "....#---#*#*---*...." ,
   "....*#--- *---*#...." ,
   "...*#*#------*#*#..." ,
   ".#*#*#* ----*#*#*#*." ,
   ".*#*#*#*----#*#*#*#." ,
   "...#*#*------#*#*..." ,
   "....#*---*#---#*...." ,
   "....*---*#*#---#...." ,
   "....---*#*#*#---...." ,
   "...---*#*#*#*#---..." ,
   "..---...#*#*...---.." ,
   ".---.....#*.....---." ,
   ".--......*#......--." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/mine_lost.xpm => xdemineur-2.1.1/pixmaps/mine_lost.xpm +32 -0
@@ 0,0 1,32 @@
/* XPM */

static char *xpm_mine_lost[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 3 1" ,
   /* colors */
   "  c white m black" ,
   "# c black m white" ,
   ". c red   m black" ,
   /* pixels */
   "...................." ,
   ".........##........." ,
   ".........##........." ,
   "...#....####....#..." ,
   "....#.########.#...." ,
   ".....##########....." ,
   "....############...." ,
   "....###   ######...." ,
   "...####   #######..." ,
   ".######   #########." ,
   ".##################." ,
   "...##############..." ,
   "....############...." ,
   "....############...." ,
   ".....##########....." ,
   "....#.########.#...." ,
   "...#....####....#..." ,
   ".........##........." ,
   ".........##........." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/question.xpm => xdemineur-2.1.1/pixmaps/question.xpm +34 -0
@@ 0,0 1,34 @@
/* XPM */

static char *xpm_question[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 5 1" ,
   /* colors */
   "  c white" ,
   "# c black" ,
   "X c gray50 m black" ,
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   /* pixels */
   "                    " ,
   "                   X" ,
   "                  XX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*######.*.*XXX" ,
   "   *.*########.*.XXX" ,
   "   .*###*.*.###.*XXX" ,
   "   *.###.*.*###*.XXX" ,
   "   .*.*.*.*###*.*XXX" ,
   "   *.*.*.*###*.*.XXX" ,
   "   .*.*.*.###.*.*XXX" ,
   "   *.*.*.###.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   *.*.*.###.*.*.XXX" ,
   "   .*.*.*###*.*.*XXX" ,
   "   *.*.*.###.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   XXXXXXXXXXXXXXXXX" ,
   "  XXXXXXXXXXXXXXXXXX" ,
   " XXXXXXXXXXXXXXXXXXX" ,
} ;

A xdemineur-2.1.1/pixmaps/relief.xpm => xdemineur-2.1.1/pixmaps/relief.xpm +33 -0
@@ 0,0 1,33 @@
/* XPM */

static char *xpm_relief[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 4 1" ,
   /* colors */
   "  c white" ,
   "X c gray50 m black" ,
   "* c gray70 m black" ,
   ". c gray70 m white" ,
   /* pixels */
   "                    " ,
   "                   X" ,
   "                  XX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   *.*.*.*.*.*.*.XXX" ,
   "   .*.*.*.*.*.*.*XXX" ,
   "   XXXXXXXXXXXXXXXXX" ,
   "  XXXXXXXXXXXXXXXXXX" ,
   " XXXXXXXXXXXXXXXXXXX" ,
} ;

A xdemineur-2.1.1/pixmaps/square_0.xpm => xdemineur-2.1.1/pixmaps/square_0.xpm +30 -0
@@ 0,0 1,30 @@
/* XPM */

static char *xpm_square_0[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 1 1" ,
   /* colors */
   ". c gray70 m white" ,
   /* pixels */
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/square_1.xpm => xdemineur-2.1.1/pixmaps/square_1.xpm +31 -0
@@ 0,0 1,31 @@
/* XPM */

static char *xpm_square_1[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 2 1" ,
   /* colors */
   ". c gray70 m white" ,
   "- c blue   m black" ,
   /* pixels */
   "...................." ,
   "...................." ,
   "..........--........" ,
   ".........---........" ,
   "........----........" ,
   ".......-----........" ,
   "......------........" ,
   ".....-------........" ,
   "........----........" ,
   "........----........" ,
   "........----........" ,
   "........----........" ,
   "........----........" ,
   "........----........" ,
   "........----........" ,
   ".....----------....." ,
   ".....----------....." ,
   ".....----------....." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/square_2.xpm => xdemineur-2.1.1/pixmaps/square_2.xpm +31 -0
@@ 0,0 1,31 @@
/* XPM */

static char *xpm_square_2[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 2 1" ,
   /* colors */
   ". c gray70      m white" ,
   "- c forestgreen m black" ,
   /* pixels */
   "...................." ,
   "...................." ,
   "......--------......" ,
   ".....----------....." ,
   "....------------...." ,
   "....---......---...." ,
   "....---.....----...." ,
   "...........----....." ,
   "..........----......" ,
   ".........----......." ,
   "........----........" ,
   ".......----........." ,
   "......----.........." ,
   ".....----..........." ,
   "....----............" ,
   "....------------...." ,
   "....------------...." ,
   "....------------...." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/square_3.xpm => xdemineur-2.1.1/pixmaps/square_3.xpm +31 -0
@@ 0,0 1,31 @@
/* XPM */

static char *xpm_square_3[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 2 1" ,
   /* colors */
   ". c gray70 m white" ,
   "- c red    m black" ,
   /* pixels */
   "...................." ,
   "...................." ,
   "....----------......" ,
   "....-----------....." ,
   "....------------...." ,
   "............----...." ,
   "............----...." ,
   "............----...." ,
   "........-------....." ,
   "........------......" ,
   "........-------....." ,
   "............----...." ,
   "............----...." ,
   "............----...." ,
   "....------------...." ,
   "....-----------....." ,
   "....----------......" ,
   "...................." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/square_4.xpm => xdemineur-2.1.1/pixmaps/square_4.xpm +31 -0
@@ 0,0 1,31 @@
/* XPM */

static char *xpm_square_4[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 2 1" ,
   /* colors */
   ". c gray70 m white" ,
   "- c navy   m black" ,
   /* pixels */
   "...................." ,
   "...................." ,
   ".......---.----....." ,
   "......----.----....." ,
   "......----.----....." ,
   ".....----..----....." ,
   ".....----..----....." ,
   "....----...----....." ,
   "....----...----....." ,
   "....------------...." ,
   "....------------...." ,
   "....------------...." ,
   "...........----....." ,
   "...........----....." ,
   "...........----....." ,
   "...........----....." ,
   "...........----....." ,
   "...........----....." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/square_5.xpm => xdemineur-2.1.1/pixmaps/square_5.xpm +31 -0
@@ 0,0 1,31 @@
/* XPM */

static char *xpm_square_5[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 2 1" ,
   /* colors */
   ". c gray70 m white" ,
   "- c orchid m black" ,
   /* pixels */
   "...................." ,
   "...................." ,
   "....------------...." ,
   "....------------...." ,
   "....------------...." ,
   "....---............." ,
   "....---............." ,
   "....---............." ,
   "....----------......" ,
   "....-----------....." ,
   "....------------...." ,
   ".............---...." ,
   ".............---...." ,
   "....---......---...." ,
   "....------------...." ,
   ".....----------....." ,
   "......--------......" ,
   "...................." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/square_6.xpm => xdemineur-2.1.1/pixmaps/square_6.xpm +31 -0
@@ 0,0 1,31 @@
/* XPM */

static char *xpm_square_6[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 2 1" ,
   /* colors */
   ". c gray70   m white" ,
   "- c seagreen m black" ,
   /* pixels */
   "...................." ,
   "...................." ,
   "......----------...." ,
   ".....-----------...." ,
   "....------------...." ,
   "....---............." ,
   "....---............." ,
   "....---............." ,
   "....----------......" ,
   "....-----------....." ,
   "....------------...." ,
   "....---......---...." ,
   "....---......---...." ,
   "....---......---...." ,
   "....------------...." ,
   ".....----------....." ,
   "......--------......" ,
   "...................." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/square_7.xpm => xdemineur-2.1.1/pixmaps/square_7.xpm +31 -0
@@ 0,0 1,31 @@
/* XPM */

static char *xpm_square_7[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 2 1" ,
   /* colors */
   ". c gray70 m white" ,
   "- c sienna m white" ,
   /* pixels */
   "...................." ,
   "...................." ,
   "....------------...." ,
   "....------------...." ,
   "....------------...." ,
   "............---....." ,
   "............---....." ,
   "...........---......" ,
   "...........---......" ,
   "..........---......." ,
   "..........---......." ,
   ".........---........" ,
   ".........---........" ,
   "........---........." ,
   "........---........." ,
   ".......---.........." ,
   ".......---.........." ,
   ".......---.........." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/pixmaps/square_8.xpm => xdemineur-2.1.1/pixmaps/square_8.xpm +31 -0
@@ 0,0 1,31 @@
/* XPM */

static char *xpm_square_8[] =
{
   /* width height ncolors chars_per_pixel */
   "20 20 2 1" ,
   /* colors */
   ". c gray70   m white" ,
   "- c deeppink m white" ,
   /* pixels */
   "...................." ,
   "...................." ,
   "......--------......" ,
   ".....----------....." ,
   "....------------...." ,
   "....-----..-----...." ,
   "....----....----...." ,
   "....-----..-----...." ,
   ".....----------....." ,
   "......--------......" ,
   ".....----------....." ,
   "....-----..-----...." ,
   "....----....----...." ,
   "....-----..-----...." ,
   "....------------...." ,
   ".....----------....." ,
   "......--------......" ,
   "...................." ,
   "...................." ,
   "...................." ,
} ;

A xdemineur-2.1.1/util.c => xdemineur-2.1.1/util.c +37 -0
@@ 0,0 1,37 @@
/*
 * Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby
 * granted, provided that the above copyright notice appear in all
 * copies and that both that copyright notice and this permission
 * notice appear in supporting documentation.  The author makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 */

static char *const cvsid = "$Id: util.c,v 1.1.1.1.2.1 1999/07/29 21:25:32 babafou Exp $" ;

#include <sys/types.h>

#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>

/* ------------------------------------------------------------------------- */

void *xmalloc ( size_t size )
{
   void *ptr ;

   ptr = malloc ( size ) ;
   if ( ptr == NULL )
   {
      fprintf ( stderr , "Can't allocate memory.\n" ) ;
      exit ( EX_SOFTWARE ) ;
   }

   return ptr ;
}

A xdemineur-2.1.1/util.h => xdemineur-2.1.1/util.h +24 -0
@@ 0,0 1,24 @@
/*
 * Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby
 * granted, provided that the above copyright notice appear in all
 * copies and that both that copyright notice and this permission
 * notice appear in supporting documentation.  The author makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 */

/* $Id: util.h,v 1.1.1.1.2.1 1999/07/29 21:25:33 babafou Exp $ */

#ifndef _UTIL_H_
#define _UTIL_H_

#include <sys/types.h>

void *xmalloc ( size_t size ) ;

#endif /* _UTIL_H_ */

A xdemineur-2.1.1/xdemineur.c => xdemineur-2.1.1/xdemineur.c +976 -0
@@ 0,0 1,976 @@
/*
 * Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby
 * granted, provided that the above copyright notice appear in all
 * copies and that both that copyright notice and this permission
 * notice appear in supporting documentation.  The author makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 */

static char *const cvsid = "$Id: xdemineur.c,v 1.3.2.2 1999/07/29 21:25:33 babafou Exp $" ;

#include <sys/types.h>

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
#include <unistd.h>

#include <sys/time.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>

#include <X11/xpm.h>

#include "demineur.h"
#include "xdemineur.h"

#include "xdemineur.xbm"

#include "pixmaps/face_normal.xpm"
#include "pixmaps/face_click.xpm"
#include "pixmaps/face_play.xpm"
#include "pixmaps/face_happy.xpm"
#include "pixmaps/face_sad.xpm"

#include "pixmaps/digit_0.xpm"
#include "pixmaps/digit_1.xpm"
#include "pixmaps/digit_2.xpm"
#include "pixmaps/digit_3.xpm"
#include "pixmaps/digit_4.xpm"
#include "pixmaps/digit_5.xpm"
#include "pixmaps/digit_6.xpm"
#include "pixmaps/digit_7.xpm"
#include "pixmaps/digit_8.xpm"
#include "pixmaps/digit_9.xpm"

#include "pixmaps/square_0.xpm"
#include "pixmaps/square_1.xpm"
#include "pixmaps/square_2.xpm"
#include "pixmaps/square_3.xpm"
#include "pixmaps/square_4.xpm"
#include "pixmaps/square_5.xpm"
#include "pixmaps/square_6.xpm"
#include "pixmaps/square_7.xpm"
#include "pixmaps/square_8.xpm"

#include "pixmaps/relief.xpm"
#include "pixmaps/flag.xpm"
#include "pixmaps/question.xpm"
#include "pixmaps/mine.xpm"
#include "pixmaps/mine_lost.xpm"
#include "pixmaps/mine_false.xpm"

/* ------------------------------------------------------------------------- */

typedef enum
{
   ITEM_NOTHING , ITEM_SQUARE , ITEM_FACE
}
item_t ;

typedef struct
{
   int row , column ;
   enum
   {
      STATE_NONE , STATE_UNCOVER , STATE_CLEAR , STATE_FLAG_QUESTION ,
      STATE_FACE
   }
   state ;
}
previous_t ;

typedef enum
{
   RAISED , SUNKEN
}
relief_t ;

typedef enum
{
   INSIDE , OUTSIDE
}
inout_t ;

/* ------------------------------------------------------------------------- */

void xdemineur_colors ( ) ;

void xdemineur_pixmaps ( ) ;

void xdemineur_xpm ( char **data , Pixmap *pixmap_return ) ;

item_t mouse ( int x , int y , int *row , int *column ) ;


void xdemineur_frames ( ) ;

void xdemineur_frame ( int x1 , int y1 , int x2 , int y2 , int width ,
                       relief_t relief , inout_t inoutside ) ;

void xdemineur_face_click ( ) ;

void xdemineur_face_play ( ) ;

void xdemineur_face_display ( Pixmap face ) ;

void xdemineur_mines ( ) ;

void xdemineur_digits ( int number , int digits , int x , int y ) ;

void xdemineur_grid ( ) ;

void xdemineur_square_play ( int row , int column ) ;

void xdemineur_squares_clear ( int row , int column ) ;

void xdemineur_squares ( int row , int column ) ;

void xdemineur_end ( ) ;

/* ------------------------------------------------------------------------- */

extern board_t           board ;
extern int               mines ;
extern volatile time_t   elapsed ;
extern state_t           state ;

static Display   *display ;
static int       screen ;
static Window    window ;
static Pixmap    icon_bitmap ;
static Atom      protocol[1] ;
static GC        gc ;

static unsigned long black , white , gray , light_gray ;

static Pixmap face_normal , face_click , face_play , face_happy , face_sad ,
              digit[10] , square[9] ,
              relief , flag , question , mine , mine_lost , mine_false ;

/* ------------------------------------------------------------------------- */

void xdemineur_initialize ( int argc , char **argv ,
                            char *display_name , char *geometry )
{
   XSizeHints      size_hints ;
   int             x_pos = 0 , y_pos = 0 ,
                   width = MIN_WIDTH , height = MIN_HEIGHT ;
   char            *window_title = "xd�mineur" , *icon_title = "xd�mineur" ;
   XTextProperty   window_name , icon_name ;
   XWMHints        wm_hints ;
   XClassHint      class_hints ;
   XGCValues       values ;

   display = XOpenDisplay ( display_name ) ;
   if ( display == NULL )
   {
      fprintf ( stderr , "Error: Can't open display: %s\n" ,
                XDisplayName ( display_name ) ) ;
      exit ( EX_OSERR ) ;
   }

   screen = DefaultScreen ( display ) ;

   board.columns = COLUMNS_MIN ;
   board.rows    = ROWS_MIN ;

   size_hints.flags = 0 ;
   if ( geometry != NULL )
   {
      int            flags , x , y ;
      unsigned int   w , h ;

      flags = XParseGeometry ( geometry , &x , &y , &w , &h ) ;

      if ( WidthValue & flags )
      {
         if ( w < COLUMNS_MIN )
         {
            board.columns = COLUMNS_MIN ;
            fprintf ( stderr ,
                      "%d columns is too small!  Using %d columns instead.\n" ,
                      w , COLUMNS_MIN ) ;
         }
         else
         {
            board.columns = w ;
            width  = BASE_WIDTH + board.columns * WIDTH_INC ;
         }
      }

      if ( HeightValue & flags )
      {
         if ( h < ROWS_MIN )
         {
            board.rows = ROWS_MIN ;
            fprintf ( stderr ,
                      "%d rows is too small!  Using %d rows instead.\n" ,
                      h , ROWS_MIN ) ;
         }
         else
         {
            board.rows = h ;
            height = BASE_HEIGHT + board.rows * HEIGHT_INC ;
         }
      }

      if ( XValue & flags )
      {
         size_hints.flags = USPosition ;
         if ( XNegative & flags )
         {
            x_pos = DisplayWidth ( display , screen ) - width + x ;
         }
         else
         {
            x_pos = x ;
         }
      }

      if ( YValue & flags )
      {
         size_hints.flags = USPosition ;
         if ( YNegative & flags )
         {
            y_pos = DisplayHeight ( display , screen ) - height + y ;
         }
         else
         {
            y_pos = y ;
         }
      }
   }

   window = XCreateSimpleWindow ( display , RootWindow ( display , screen ) ,
                                  x_pos , y_pos , width , height , 1 ,
                                  BlackPixel ( display , screen ) ,
                                  WhitePixel ( display , screen ) ) ;

   XStringListToTextProperty ( &window_title , 1 , &window_name ) ;
   XStringListToTextProperty ( &icon_title   , 1 , &icon_name   ) ;

   size_hints.flags      |= USSize | PMinSize | PMaxSize |
                            PResizeInc | PBaseSize ;
   size_hints.min_width   = size_hints.max_width  = width ;
   size_hints.min_height  = size_hints.max_height = height ;
   size_hints.width_inc   = WIDTH_INC ;
   size_hints.height_inc  = HEIGHT_INC ;
   size_hints.base_width  = BASE_WIDTH ;
   size_hints.base_height = BASE_HEIGHT ;

   icon_bitmap = XCreateBitmapFromData ( display ,
                                         RootWindow ( display , screen ) ,
                                         xdemineur_bits ,
                                         xdemineur_width , xdemineur_height ) ;

   wm_hints.flags         = InputHint | StateHint | IconPixmapHint | WindowGroupHint;
   wm_hints.input         = True ;
   wm_hints.initial_state = NormalState ;
   wm_hints.icon_pixmap   = icon_bitmap ;
   wm_hints.window_group  = window ;

   class_hints.res_name  = argv[0] ;
   class_hints.res_class = "XD�mineur" ;

   XSetWMProperties ( display , window ,
                      &window_name , &icon_name ,
                      argv , argc ,
                      &size_hints , &wm_hints , &class_hints ) ;

   XSetCommand ( display , window , argv , argc ) ;

   protocol[0] = XInternAtom ( display , "WM_DELETE_WINDOW" , False ) ;
   XSetWMProtocols ( display , window , protocol , 1 ) ;

   values.foreground         = BlackPixel ( display , screen ) ;
   values.background         = WhitePixel ( display , screen ) ;
   values.graphics_exposures = False ;
   gc = XCreateGC ( display , window ,
                    GCForeground | GCBackground | GCGraphicsExposures ,
                    &values ) ;

   XSelectInput ( display , window ,
                  KeyPressMask         |
                  ButtonPressMask      |
                  ButtonReleaseMask    |
                  ExposureMask         |
                  VisibilityChangeMask |
                  StructureNotifyMask ) ;

   xdemineur_colors ( ) ;
   xdemineur_pixmaps ( ) ;

   XMapWindow ( display , window ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_colors ( )
{
   Colormap   default_colormap ;
   XColor     color ;

   default_colormap = DefaultColormap ( display , screen ) ;
   XParseColor ( display , default_colormap , "black" , &color ) ;
   XAllocColor ( display , default_colormap , &color ) ;
   black = color.pixel ;
   XParseColor ( display , default_colormap , "white" , &color ) ;
   XAllocColor ( display , default_colormap , &color ) ;
   white = color.pixel ;
   XParseColor ( display , default_colormap , "gray50" , &color ) ;
   XAllocColor ( display , default_colormap , &color ) ;
   gray = color.pixel ;
   XParseColor ( display , default_colormap , "gray70" , &color ) ;
   XAllocColor ( display , default_colormap , &color ) ;
   light_gray = color.pixel ;

   XSetWindowBackground ( display , window , light_gray ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_pixmaps ( )
{
   xdemineur_xpm ( xpm_face_normal , &face_normal ) ;
   xdemineur_xpm ( xpm_face_click  , &face_click  ) ;
   xdemineur_xpm ( xpm_face_play   , &face_play   ) ;
   xdemineur_xpm ( xpm_face_happy  , &face_happy  ) ;
   xdemineur_xpm ( xpm_face_sad    , &face_sad    ) ;

   xdemineur_xpm ( xpm_digit_0 , &digit[0] ) ;
   xdemineur_xpm ( xpm_digit_1 , &digit[1] ) ;
   xdemineur_xpm ( xpm_digit_2 , &digit[2] ) ;
   xdemineur_xpm ( xpm_digit_3 , &digit[3] ) ;
   xdemineur_xpm ( xpm_digit_4 , &digit[4] ) ;
   xdemineur_xpm ( xpm_digit_5 , &digit[5] ) ;
   xdemineur_xpm ( xpm_digit_6 , &digit[6] ) ;
   xdemineur_xpm ( xpm_digit_7 , &digit[7] ) ;
   xdemineur_xpm ( xpm_digit_8 , &digit[8] ) ;
   xdemineur_xpm ( xpm_digit_9 , &digit[9] ) ;

   xdemineur_xpm ( xpm_square_0 , &square[0] ) ;
   xdemineur_xpm ( xpm_square_1 , &square[1] ) ;
   xdemineur_xpm ( xpm_square_2 , &square[2] ) ;
   xdemineur_xpm ( xpm_square_3 , &square[3] ) ;
   xdemineur_xpm ( xpm_square_4 , &square[4] ) ;
   xdemineur_xpm ( xpm_square_5 , &square[5] ) ;
   xdemineur_xpm ( xpm_square_6 , &square[6] ) ;
   xdemineur_xpm ( xpm_square_7 , &square[7] ) ;
   xdemineur_xpm ( xpm_square_8 , &square[8] ) ;

   xdemineur_xpm ( xpm_relief     , &relief ) ;
   xdemineur_xpm ( xpm_flag       , &flag ) ;
   xdemineur_xpm ( xpm_question   , &question ) ;
   xdemineur_xpm ( xpm_mine       , &mine ) ;
   xdemineur_xpm ( xpm_mine_lost  , &mine_lost ) ;
   xdemineur_xpm ( xpm_mine_false , &mine_false ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_xpm ( char **data , Pixmap *pixmap_return )
{
   int xpm_status ;

   xpm_status = XpmCreatePixmapFromData ( display , window ,
                                          data , pixmap_return ,
                                          NULL , NULL ) ;
   if ( xpm_status != XpmSuccess )
   {
      fprintf ( stderr ,
                "XpmError: %s\n" , XpmGetErrorString ( xpm_status ) ) ;
      exit ( EX_OSERR ) ;
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_event_loop ( )
{
   fd_set       readfds ;
   XEvent       event ;
   Region       region ;
   XRectangle   rectangle ;
   item_t       item ;
   previous_t   previous ;

   FD_ZERO ( &readfds ) ;
   region = XCreateRegion ( ) ;
   for ( ; ; )
   {
      int row , column ;

      if ( XPending ( display ) == 0 )   /* no more events to handle */
      {
         FD_SET ( ConnectionNumber ( display ) , &readfds ) ;
         if ( select ( ConnectionNumber ( display ) + 1 , &readfds , NULL ,
                       NULL , NULL ) == -1 )   /* wait for events or signal */
         {
            if ( errno == EINTR )   /* interrupted by signal */
            {
               xdemineur_timer ( ) ;
               XFlush ( display ) ;
               continue ;
            }
         }
         /* an event occurred, proceed to XNextEvent() */
      }

      XNextEvent ( display , &event ) ;
      switch ( event.type )
      {
      case KeyPress :
         switch ( XLookupKeysym ( &event.xkey , event.xkey.state ) )
         {
         case XK_Escape :
         case XK_Q :
         case XK_q :
            XDestroyRegion ( region ) ;
            xdemineur_end ( ) ;
            return ;
         }
         break ;
      case ButtonPress :
         switch ( mouse ( event.xbutton.x , event.xbutton.y ,
                          &row , &column ) )
         {
         case ITEM_SQUARE :
            if ( state != PLAYING )
            {
               previous.state = STATE_NONE ;
               break ;
            }

            switch ( event.xbutton.button )
            {
            case Button1 :   /* uncover square */
               if ( board.board[row][column].state == HIDDEN )
               {
                  xdemineur_face_play ( ) ;
                  xdemineur_square_play ( row , column ) ;
                  previous.row    = row ;
                  previous.column = column ;
                  previous.state  = STATE_UNCOVER ;
               }
               else
               {
                  previous.state = STATE_NONE ;
               }
               break ;
            case Button2 :   /* uncover squares around */
               if ( board.board[row][column].state == UNCOVERED )
               {
                  if ( demineur_hidden ( row , column ) != 0 &&
                       board.board[row][column].around
                       == demineur_flags ( row , column ) )
                  {
                     xdemineur_face_play ( ) ;
                     xdemineur_squares_clear ( row , column ) ;
                     previous.row    = row ;
                     previous.column = column ;
                     previous.state  = STATE_CLEAR ;
                  }
                  else
                  {
                     previous.state = STATE_NONE ;
                  }
               }
               break ;
            case Button3 :   /* put flag or question mark */
               if ( board.board[row][column].state == UNCOVERED )
               {
                  previous.state = STATE_NONE;
                  break ;
               }

               xdemineur_face_play ( ) ;
               demineur_flag_question ( row , column ) ;
               xdemineur_mines ( ) ;
               xdemineur_square ( row , column ) ;
               previous.state = STATE_FLAG_QUESTION ;
               break ;
            }
            break ;
         case ITEM_FACE :
            xdemineur_face_click ( ) ;
            previous.state = STATE_FACE ;
            break ;
         case ITEM_NOTHING :
            previous.state = STATE_NONE ;
            break ;
         }
         break ;
      case ButtonRelease :
         item = mouse ( event.xbutton.x , event.xbutton.y , &row , &column ) ;
         switch ( previous.state )
         {
         case STATE_NONE :
            break ;
         case STATE_UNCOVER :
            if ( row == previous.row && column == previous.column )
            {
               demineur_play ( row , column ) ;
            }
            else
            {
               xdemineur_square ( previous.row , previous.column ) ;
            }
            xdemineur_face ( ) ;
            break ;
         case STATE_CLEAR :
            if ( row == previous.row && column == previous.column )
            {
               demineur_clear ( row , column ) ;
            }
            else
            {
               xdemineur_squares ( previous.row , previous.column ) ;
            }
            xdemineur_face ( ) ;
            break ;
         case STATE_FLAG_QUESTION :
            xdemineur_face ( ) ;
            break ;
         case STATE_FACE :
            if ( item == ITEM_FACE )   /* new game */
            {
               demineur_end ( ) ;
               demineur_initialize ( 0 ) ;
               xdemineur_display ( ) ;
               demineur_start_timer ( ) ;
            }
            else
            {
               xdemineur_face ( ) ;
            }
            break ;
         }
         previous.state = STATE_NONE ;
         break ;
      case Expose :
         rectangle.x      = ( short )          event.xexpose.x ;
         rectangle.y      = ( short )          event.xexpose.y ;
         rectangle.width  = ( unsigned short ) event.xexpose.width ;
         rectangle.height = ( unsigned short ) event.xexpose.height ;
         XUnionRectWithRegion ( &rectangle , region , region ) ;
         if ( event.xexpose.count == 0 )
         {
            XSetRegion ( display , gc , region ) ;
            xdemineur_display ( ) ;
            XSetClipMask ( display , gc , None ) ;
            XDestroyRegion ( region ) ;
            region = XCreateRegion ( ) ;
         }
         break ;
      case VisibilityNotify :
         switch ( event.xvisibility.state )
         {
         case VisibilityUnobscured :
            if ( state == PLAYING )
            {
               demineur_start_timer ( ) ;
            }
            break ;
         case VisibilityPartiallyObscured :
            break ;
         case VisibilityFullyObscured :
            if ( state == PLAYING )
            {
               demineur_stop_timer ( ) ;
            }
            break ;
         }
         break ;
      case UnmapNotify :   /* the window has been iconified */
         if ( state == PLAYING )
         {
            demineur_stop_timer ( ) ;
         }
         break ;
      case MapNotify :   /* the window has been deiconified */
         if ( state == PLAYING )
         {
            demineur_start_timer ( ) ;
         }
         break ;
      case ClientMessage :
         if ( event.xclient.data.l[0] == protocol[0] )
         {
            XDestroyRegion ( region ) ;
            xdemineur_end ( ) ;
            return ;
         }
         break ;
      }
   }
}

/* ------------------------------------------------------------------------- */

item_t mouse ( int x , int y , int *row , int *column )
{
   int board_width  = board.columns * WIDTH_INC  ,
       board_height = board.rows    * HEIGHT_INC ,
       x_face = ( BASE_WIDTH + board.columns * WIDTH_INC - FACE_WIDTH ) / 2 ;

   *row = *column = 0 ;

   if ( x > X_BOARD               &&
        x < X_BOARD + board_width &&
        y > Y_BOARD               &&
        y < Y_BOARD + board_height )
   {
      if ( ( x - X_BOARD ) % WIDTH_INC  == 0 ||
           ( y - Y_BOARD ) % HEIGHT_INC == 0 )
      {
         return ITEM_NOTHING ;
      }
      else
      {
         *column = 1 + ( x - X_BOARD ) / WIDTH_INC ;
         *row    = 1 + ( y - Y_BOARD ) / HEIGHT_INC ;
         return ITEM_SQUARE ;
      }
   }
   else if ( x >= x_face              &&
             x <= x_face + FACE_WIDTH &&
             y >= Y_FACE              &&
             y <= Y_FACE + FACE_HEIGHT )
   {
      return ITEM_FACE ;
   }
   else
   {
      return ITEM_NOTHING ;
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_display ( )
{
   int row , column ;

   xdemineur_frames ( ) ;
   xdemineur_face ( ) ;
   xdemineur_mines ( ) ;
   xdemineur_timer ( ) ;
   xdemineur_grid ( ) ;
   for ( row = 1 ; row <= board.rows ; row ++ )
   {
      for ( column = 1 ; column <= board.columns ; column ++ )
      {
         xdemineur_square ( row , column ) ;
      }
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_frames ( )
{
   int board_width   = board.columns * WIDTH_INC ;
   int board_height  = board.rows    * HEIGHT_INC ;
   int window_width  = BASE_WIDTH  + board_width ;
   int window_height = BASE_HEIGHT + board_height ;

   xdemineur_frame ( 0 , 0 , window_width - 1 , window_height - 1 ,
                     RELIEF_WIDTH , RAISED , INSIDE) ;
   xdemineur_frame ( X_BOARD , Y_BOARD ,
                     X_BOARD + board_width , Y_BOARD + board_height ,
                     RELIEF_WIDTH , SUNKEN , OUTSIDE) ;
   xdemineur_frame ( EDGE , EDGE , window_width - 1 - EDGE , Y_BOARD - EDGE ,
                     RELIEF_WIDTH , SUNKEN , OUTSIDE ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_frame ( int x1 , int y1 , int x2 , int y2 , int width ,
                       relief_t relief , inout_t inoutside )
{
   int coord ;

   if ( inoutside == OUTSIDE )
   {
      x1 -= width ; x2 += width ;
      y1 -= width ; y2 += width ;
   }

   XSetForeground ( display , gc , ( relief == RAISED ) ? white : gray ) ;
   for ( coord = 0 ; coord < width ; coord ++ )
   {
      XDrawLine ( display , window , gc ,
                  x1 , y1 + coord , x2 - coord , y1 + coord ) ;
      XDrawLine ( display , window , gc ,
                  x1 + coord , y1 , x1 + coord , y2 - coord ) ;
   }
   XSetForeground ( display , gc , ( relief == RAISED ) ? gray : white ) ;
   for ( coord = 0 ; coord < width ; coord ++ )
   {
      XDrawLine ( display , window , gc ,
                  x1 + 1 + coord , y2 - coord , x2 , y2 - coord ) ;
      XDrawLine ( display , window , gc ,
                  x2 - coord , y1 + 1 + coord , x2 - coord , y2 ) ;
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_face ( )
{
   switch ( state )
   {
   case PLAYING :
      xdemineur_face_display ( face_normal ) ;
      break ;
   case WON :
      xdemineur_face_display ( face_happy ) ;
      break ;
   case LOST :
      xdemineur_face_display ( face_sad ) ;
      break ;
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_face_click ( )
{
   xdemineur_face_display ( face_click ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_face_play ( )
{
   xdemineur_face_display ( face_play ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_face_display ( Pixmap face )
{
   XCopyArea ( display , face , window , gc ,
               0 , 0 , FACE_WIDTH , FACE_HEIGHT ,
               ( BASE_WIDTH + board.columns * WIDTH_INC - FACE_WIDTH ) / 2 ,
               Y_FACE ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_mines ( )
{
   xdemineur_digits ( mines , 4 , X_DIGITS , Y_DIGITS ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_timer ( )
{
   int x = BASE_WIDTH + board.columns * WIDTH_INC
           - X_DIGITS - 4 * DIGIT_WIDTH ;

   xdemineur_digits ( elapsed , 4 , x , Y_DIGITS ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_digits ( int number , int digits , int x , int y )
{
   int i , remainder = number ;

   for ( i = digits - 1 ; i >= 0 ; i -- , remainder /= 10 )
   {
      XCopyArea ( display , digit[remainder % 10] , window , gc ,
                  0 , 0 , DIGIT_WIDTH , DIGIT_HEIGHT ,
                  x + i * DIGIT_WIDTH , y ) ;
   }

   xdemineur_frame ( x , y ,
                     x + digits * DIGIT_WIDTH - 1 , y + DIGIT_HEIGHT - 1 ,
                     1 , SUNKEN , OUTSIDE ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_grid ( )
{
   int coord ,
       board_width  = board.columns * WIDTH_INC  + 1 ,
       board_height = board.rows    * HEIGHT_INC + 1 ;

   XSetForeground ( display , gc , black ) ;

   for ( coord = X_BOARD ;
         coord < X_BOARD + board_width ;
         coord += WIDTH_INC )
   {
      XDrawLine ( display , window , gc ,
                  coord , Y_BOARD , coord , Y_BOARD + board_height - 1 ) ;
   }

   for ( coord = Y_BOARD ;
         coord < Y_BOARD + board_height ;
         coord += HEIGHT_INC )
   {
      XDrawLine ( display , window , gc ,
                  X_BOARD , coord , X_BOARD + board_width - 1 , coord ) ;
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_square ( int row , int column )
{
   int x = X_BOARD + 1 + ( column - 1 ) * ( SQUARE_WIDTH  + 1 ) ,
       y = Y_BOARD + 1 + ( row    - 1 ) * ( SQUARE_HEIGHT + 1 ) ;

   if ( row < 1 || row > board.rows || column < 1 || column > board.columns )
   {
      return ;
   }

   switch ( board.board[row][column].state )
   {
      case HIDDEN :
         if ( state == LOST && board.board[row][column].mine )
         {
            XCopyArea ( display , mine , window , gc ,
                        0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
         }
         else
         {
            XCopyArea ( display , relief , window , gc ,
                        0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
         }
         break ;
      case FLAGGED :
         if ( state == LOST && ! board.board[row][column].mine )
         {
            XCopyArea ( display , mine_false , window , gc ,
                        0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
         }
         else
         {
            XCopyArea ( display , flag , window , gc ,
                        0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
         }
         break ;
      case QUESTION :
         if ( state == LOST && board.board[row][column].mine )
         {
            XCopyArea ( display , mine , window , gc ,
                        0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
         }
         else
         {
            XCopyArea ( display , question , window , gc ,
                        0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
         }
         break ;
      case UNCOVERED :
         if ( ! board.board[row][column].mine )
         {
            XCopyArea ( display , square[board.board[row][column].around] ,
                        window , gc ,
                        0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
         }
         else
         {
            XCopyArea ( display , mine_lost , window , gc ,
                        0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
         }
         break ;
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_square_play ( int row , int column )
{
   int x = X_BOARD + 1 + ( column - 1 ) * ( SQUARE_WIDTH  + 1 ) ,
       y = Y_BOARD + 1 + ( row    - 1 ) * ( SQUARE_HEIGHT + 1 ) ;

   if ( row < 1 || row > board.rows || column < 1 || column > board.columns )
   {
      return ;
   }

   XCopyArea ( display , square[0] , window , gc ,
               0 , 0 , SQUARE_WIDTH , SQUARE_HEIGHT , x , y ) ;
}

/* ------------------------------------------------------------------------- */

void xdemineur_squares_clear ( int row , int column )
{
   int r , c ;

   for ( r = row - 1 ; r <= row + 1 ; r ++ )
   {
      for ( c = column - 1 ; c <= column + 1 ; c ++ )
      {
         if ( board.board[r][c].state == HIDDEN )
         {
            xdemineur_square_play ( r , c ) ;
         }
      }
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_squares ( int row , int column )
{
   int r , c ;

   for ( r = row - 1 ; r <= row + 1 ; r ++ )
   {
      for ( c = column - 1 ; c <= column + 1 ; c ++ )
      {
         xdemineur_square ( r , c ) ;
      }
   }
}

/* ------------------------------------------------------------------------- */

void xdemineur_end ( )
{
   int i ;

   XFreePixmap ( display , face_normal ) ;
   XFreePixmap ( display , face_click  ) ;
   XFreePixmap ( display , face_play   ) ;
   XFreePixmap ( display , face_happy  ) ;
   XFreePixmap ( display , face_sad    ) ;
   for ( i = 0 ; i <= 9 ; i ++ )
   {
      XFreePixmap ( display , digit[i] ) ;
   }
   for ( i = 0 ; i <= 8 ; i ++ )
   {
      XFreePixmap ( display , square[i] ) ;
   }
   XFreePixmap ( display , relief     ) ;
   XFreePixmap ( display , flag       ) ;
   XFreePixmap ( display , question   ) ;
   XFreePixmap ( display , mine       ) ;
   XFreePixmap ( display , mine_lost  ) ;
   XFreePixmap ( display , mine_false ) ;

   XFreeGC ( display , gc ) ;
   XFreePixmap ( display , icon_bitmap ) ;
   XDestroyWindow ( display , window ) ;
   XCloseDisplay ( display ) ;
}

A xdemineur-2.1.1/xdemineur.h => xdemineur-2.1.1/xdemineur.h +67 -0
@@ 0,0 1,67 @@
/*
 * Copyright � 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby
 * granted, provided that the above copyright notice appear in all
 * copies and that both that copyright notice and this permission
 * notice appear in supporting documentation.  The author makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 */

/* $Id: xdemineur.h,v 1.1.1.1.2.1 1999/07/29 21:25:34 babafou Exp $ */

#ifndef _XDEMINEUR_H_
#define _XDEMINEUR_H_

#define ROWS_MIN      16
#define COLUMNS_MIN   30

#define EDGE              15   /* edge around the game board */
#define RELIEF_WIDTH       3   /* width of the relief */

#define INFO              50

#define SQUARE_WIDTH      20   /* width  of a square */
#define SQUARE_HEIGHT     20   /* height of a square */

#define BASE_WIDTH        ( EDGE + 1 + EDGE )
#define BASE_HEIGHT       ( EDGE + INFO + EDGE + 1 + EDGE )
#define WIDTH_INC         ( SQUARE_WIDTH  + 1 )
#define HEIGHT_INC        ( SQUARE_HEIGHT + 1 )

#define MIN_WIDTH  ( BASE_WIDTH  + COLUMNS_MIN * WIDTH_INC  )
#define MIN_HEIGHT ( BASE_HEIGHT + ROWS_MIN    * HEIGHT_INC )

#define X_BOARD   EDGE
#define Y_BOARD   ( EDGE + INFO + EDGE )

#define FACE_WIDTH  40
#define FACE_HEIGHT 40
#define Y_FACE      ( ( Y_BOARD - FACE_HEIGHT ) / 2 )

#define DIGIT_WIDTH  20
#define DIGIT_HEIGHT 30

#define X_DIGITS        ( ( Y_BOARD - DIGIT_WIDTH  ) / 2 )
#define Y_DIGITS        ( ( Y_BOARD - DIGIT_HEIGHT ) / 2 )

/* ------------------------------------------------------------------------- */

void xdemineur_initialize ( int argc , char **argv ,
                            char *display_name , char *geometry ) ;

void xdemineur_event_loop ( ) ;

void xdemineur_display ( ) ;

void xdemineur_face ( ) ;

void xdemineur_timer ( ) ;

void xdemineur_square ( int row , int column ) ;

#endif /* _XDEMINEUR_H_ */

A xdemineur-2.1.1/xdemineur.man => xdemineur-2.1.1/xdemineur.man +71 -0
@@ 0,0 1,71 @@
.TH XDEMINEUR 6
.SH NAME
xdemineur \- X11 minesweeper game
.SH SYNOPSIS
\fBxdemineur\fP [\fB\-v\fP] [\fB\-display\fP \fIdisplayname\fP]
[\fB\-geometry\fP \fIgeom\fP] [\fB\-m\fP \fImines\fP]
.SH DESCRIPTION
\fIXdemineur\fP is a minesweeper game for the X Window System.
.PP
The object of this game is to find the location of the mines
hidden in the minefield and to mark their location by placing a
warning flag.  You have exactly as many flags as there are mines.
The number of flags that remain to be placed is displayed in the
top left corner of the window and a timer is displayed in the top
right corner.
.PP
The game is played using a three buttons mouse, as usual with the
X Window System.  The left button (button 1) is used to uncover
the square on which you click (hoping that a mine is not hidden
there).  The number displayed in an uncovered square indicates
how many mines are located around this square (for example, a 3
means that there are three mines within the 8 surrounding
squares).  The whole game relies on the right use of these
numbers.  The right button (button 3) is used to place a flag on
a square (this indicates that there is a mine here).  If you
click again with the right button on a square that has a flag,
the flag is changed into a question mark: this is useful if you
are trying to guess the possible location of some mine, you can
use question marks to think about it.  One more click with the
right button and the question mark disappears.  Clicking with the
middle button (button 2) on an uncovered square which has all its
flags placed around uncovers the surrounding cells which have no
flags (this will save a lot of time).
.PP
Finally, to start a new game, just click on the yellow face above
the minefield.
.SH OPTIONS
.TP 8
.B \-v
Print out version number and copyright notice then exit.
.TP 8
.B \-display \fIdisplayname\fP
This option specifies the name of the X server to use.  See X(1).
.TP 8
.B \-geometry \fIgeom\fP
This option specifies the initial size and location of the
window.  See X(1).
.TP 8
.B \-m \fImines \fP
This option specifies the number of mines in the minefield.  If
there are more mines than squares in the minefield, the default
mine number is used.
.SH BUGS
Please report any bug you could find in xdemineur to
<babafou@babafou.eu.org>.  Also, you should tell me the
customizations you may have done, such as adding new functions to
the game or making modifications to allow the game to run on your
system.
.SH COPYRIGHT
Copyright (C) 1993-1999 Marc Baudoin <babafou@babafou.eu.org>
.PP
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation.  The author makes no
representations about the suitability of this software for any
purpose.  It is provided "as is" without express or implied
warranty.
.SH AUTHOR
Marc Baudoin <babafou@babafou.eu.org>

A xdemineur-2.1.1/xdemineur.xbm => xdemineur-2.1.1/xdemineur.xbm +27 -0
@@ 0,0 1,27 @@
#define xdemineur_width 48
#define xdemineur_height 48
static unsigned char xdemineur_bits[] = {
   0xff, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0xf0,
   0xfc, 0x3f, 0x00, 0x00, 0x00, 0x78, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x3c,
   0xf8, 0x7f, 0x00, 0x00, 0x00, 0x1e, 0xf0, 0xff, 0x00, 0x01, 0x00, 0x0f,
   0xe0, 0xff, 0x81, 0x02, 0x00, 0x0f, 0xc0, 0xff, 0x83, 0x02, 0x80, 0x07,
   0xc0, 0xff, 0x43, 0x04, 0xc0, 0x03, 0x80, 0xff, 0x47, 0x04, 0xe0, 0x01,
   0x00, 0xc3, 0x4f, 0x04, 0x80, 0x00, 0x00, 0x1a, 0x23, 0x08, 0xb0, 0x00,
   0x00, 0x6a, 0x18, 0x30, 0x2c, 0x00, 0x00, 0x90, 0x07, 0xc0, 0x13, 0x00,
   0x00, 0x10, 0x50, 0x00, 0x10, 0x00, 0x00, 0xa0, 0xaa, 0x00, 0x0a, 0x00,
   0x00, 0x20, 0x55, 0x00, 0x09, 0x00, 0x00, 0xa0, 0xaa, 0x80, 0x0a, 0x00,
   0x00, 0x20, 0x55, 0x41, 0x09, 0x00, 0x00, 0x90, 0xaa, 0xa2, 0x10, 0x00,
   0x00, 0x10, 0x55, 0x51, 0x10, 0x00, 0x00, 0x08, 0x2a, 0x28, 0x20, 0x00,
   0x00, 0x07, 0x94, 0x53, 0xc0, 0x01, 0xc0, 0x00, 0x48, 0x24, 0x00, 0x06,
   0x20, 0x00, 0x54, 0x15, 0x00, 0x08, 0xc0, 0x00, 0x48, 0x24, 0x00, 0x06,
   0x00, 0x07, 0x94, 0x53, 0xc0, 0x01, 0x00, 0x08, 0x28, 0xa8, 0x20, 0x00,
   0x00, 0x10, 0x14, 0x55, 0x11, 0x00, 0x00, 0x10, 0x8a, 0xaa, 0x12, 0x00,
   0x00, 0x20, 0x05, 0x55, 0x09, 0x00, 0x00, 0xa0, 0x02, 0xaa, 0x0a, 0x00,
   0x00, 0x20, 0x01, 0x55, 0x09, 0x00, 0x00, 0xa0, 0x00, 0xaa, 0x0a, 0x00,
   0x00, 0x10, 0x00, 0x14, 0x10, 0x00, 0x00, 0x90, 0x07, 0xc0, 0x13, 0x00,
   0x00, 0x68, 0x18, 0x30, 0x2c, 0x00, 0x00, 0x1a, 0x20, 0x88, 0xb1, 0x00,
   0x00, 0x02, 0x40, 0xe4, 0x87, 0x01, 0x00, 0x0f, 0x40, 0xc4, 0xff, 0x03,
   0x80, 0x07, 0x40, 0xc4, 0xff, 0x03, 0xc0, 0x03, 0x80, 0x82, 0xff, 0x07,
   0xe0, 0x01, 0x80, 0x02, 0xff, 0x0f, 0xe0, 0x01, 0x00, 0x01, 0xfe, 0x1f,
   0xf0, 0x00, 0x00, 0x00, 0xfe, 0x1f, 0x78, 0x00, 0x00, 0x00, 0xfc, 0x3f,
   0x3c, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x1e, 0x00, 0x00, 0x00, 0xf0, 0xff};