/* deck_xbm.c see comments in deck_xbm.h */ /* this file has the mass of bit patterns, a few arrays and a few functions */ /*Copyright (C) 1995 Free Software Foundation This file is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "deck_xbm.h" #include #include /* the following are the bitmaps of the cards, joker and backs */ /* the card_address array is at the end */ /* any of these can be changed using the X Windows bitmap program */ #include "c01.xbm" #include "c02.xbm" #include "c03.xbm" #include "c04.xbm" #include "c05.xbm" #include "c06.xbm" #include "c07.xbm" #include "c08.xbm" #include "c09.xbm" #include "c10.xbm" #include "c11.xbm" #include "c12.xbm" #include "c13.xbm" #include "d01.xbm" #include "d02.xbm" #include "d03.xbm" #include "d04.xbm" #include "d05.xbm" #include "d06.xbm" #include "d07.xbm" #include "d08.xbm" #include "d09.xbm" #include "d10.xbm" #include "d11.xbm" #include "d12.xbm" #include "d13.xbm" #include "h01.xbm" #include "h02.xbm" #include "h03.xbm" #include "h04.xbm" #include "h05.xbm" #include "h06.xbm" #include "h07.xbm" #include "h08.xbm" #include "h09.xbm" #include "h10.xbm" #include "h11.xbm" #include "h12.xbm" #include "h13.xbm" #include "s01.xbm" #include "s02.xbm" #include "s03.xbm" #include "s04.xbm" #include "s05.xbm" #include "s06.xbm" #include "s07.xbm" #include "s08.xbm" #include "s09.xbm" #include "s10.xbm" #include "s11.xbm" #include "s12.xbm" #include "s13.xbm" #include "joker.xbm" #include "back.xbm" #include "back1.xbm" /* the names by which cards are known, used to look up bit map data */ char *card_name[num_cards] = { "c01", "c02", "c03", "c04", "c05", "c06", "c07", "c08", "c09", "c10", "c11", "c12", "c13", "d01", "d02", "d03", "d04", "d05", "d06", "d07", "d08", "d09", "d10", "d11", "d12", "d13", "h01", "h02", "h03", "h04", "h05", "h06", "h07", "h08", "h09", "h10", "h11", "h12", "h13", "s01", "s02", "s03", "s04", "s05", "s06", "s07", "s08", "s09", "s10", "s11", "s12", "s13", "joker", "back", "back1" }; /* initial deck, random permutation caused by shuffel() */ int deck[52] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51}; /* pointers to bitmaps of 52 cards, joker, backs ...*/ static char *card_bits[num_cards] = { c01_bits, c02_bits, c03_bits, c04_bits, c05_bits, c06_bits, c07_bits, c08_bits, c09_bits, c10_bits, c11_bits, c12_bits, c13_bits, d01_bits, d02_bits, d03_bits, d04_bits, d05_bits, d06_bits, d07_bits, d08_bits, d09_bits, d10_bits, d11_bits, d12_bits, d13_bits, h01_bits, h02_bits, h03_bits, h04_bits, h05_bits, h06_bits, h07_bits, h08_bits, h09_bits, h10_bits, h11_bits, h12_bits, h13_bits, s01_bits, s02_bits, s03_bits, s04_bits, s05_bits, s06_bits, s07_bits, s08_bits, s09_bits, s10_bits, s11_bits, s12_bits, s13_bits, joker_bits, back_bits, back1_bits}; /* local functions and data */ /* static double my_random (double *Gen); */ /* static void reset_r(double *Gen); */ static int next_to_deal; /* shuffle a standard deck, results are in deck[i] */ void shuffle(void) { double gen, t; double ran[52]; int i, j, k; static int first = 1; if(first) { reset_r(&gen); } first = 0; next_to_deal = 0; for(i=0; i<52; i++) { ran[i] = my_random(&gen); deck[i] = i; } for(i=0; i<51; i++) { for(j=i+1; j<52; j++) { if(ran[i]