home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XGAMES / SPIDER.TAR / spider / defs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-28  |  5.1 KB  |  242 lines

  1. /*
  2.  *    Spider
  3.  *
  4.  *    (c) Copyright 1989, Donald R. Woods and Sun Microsystems, Inc.
  5.  *    (c) Copyright 1990, David Lemke and Network Computing Devices Inc.
  6.  *
  7.  *    See copyright.h for the terms of the copyright.
  8.  *
  9.  *    @(#)defs.h    2.3    91/05/09
  10.  *
  11.  */
  12.  
  13. /*
  14.  * std includes and types
  15.  */
  16. #include    <X11/Xlib.h>
  17. #include    <X11/Xutil.h>
  18. #include    <X11/Xos.h>
  19. #include    <stdio.h>
  20. #include    "assert.h"
  21. #include    "copyright.h"
  22.  
  23. #ifdef DEBUG
  24. /*
  25.  * so i don't have to keep looking up my constants
  26.  */
  27. typedef enum    {Spade, Heart, Diamond, Club}    Suit;
  28.  
  29. typedef enum    {Ace, Deuce, Three, Four, Five, Six, Seven,
  30.          Eight, Nine, Ten, Jack, Queen, King}    Rank;
  31.  
  32. typedef enum    {Faceup, Facedown, Joker}    Type;
  33.  
  34. #else DEBUG
  35.  
  36. typedef    char    Suit;
  37. typedef    char    Rank;
  38. typedef    char    Type;
  39.  
  40. #define    Spade    0
  41. #define    Heart    1
  42. #define    Diamond    2
  43. #define    Club    3
  44.  
  45. #define    Ace    0
  46. #define    Deuce    1
  47. #define    Three    2
  48. #define    Four    3
  49. #define    Five    4
  50. #define    Six    5
  51. #define    Seven    6
  52. #define    Eight    7
  53. #define    Nine    8
  54. #define    Ten    9
  55. #define    Jack    10
  56. #define    Queen    11
  57. #define    King    12
  58.  
  59. #define    Faceup        0
  60. #define    Facedown    1
  61. #define    Joker        2
  62.  
  63. #endif DEBUG
  64.  
  65. #define    NUM_DECKS    2
  66. #define    NUM_PILES    8
  67. #define    NUM_STACKS    10
  68. #define    NUM_RANKS    13
  69. #define    NUM_SUITS    4
  70. #define    CARDS_PER_DECK    (NUM_RANKS * NUM_SUITS)
  71. #define    NUM_CARDS    (NUM_DECKS * CARDS_PER_DECK)
  72.  
  73. /* diff locations for a cardlist */
  74. #define    DECK    0
  75.  
  76. #define    PILE_1    1
  77. #define    PILE_2    2
  78. #define    PILE_3    3
  79. #define    PILE_4    4
  80. #define    PILE_5    5
  81. #define    PILE_6    6
  82. #define    PILE_7    7
  83. #define    PILE_8    8
  84.  
  85. /* convert a pile value to an array index */
  86. #define    PILE_INDEX(i)    ((i) - 1)
  87.  
  88. #define    STACK_1        11
  89. #define    STACK_2        12
  90. #define    STACK_3        13
  91. #define    STACK_4        14
  92. #define    STACK_5        15
  93. #define    STACK_6        16
  94. #define    STACK_7        17
  95. #define    STACK_8        18
  96. #define    STACK_9        19
  97. #define    STACK_10    20
  98.  
  99. /* convert a stack value to an array index */
  100. #define    STACK_INDEX(i)    ((i) - 11)
  101.  
  102. #define    LOC_BEFORE    1
  103. #define    LOC_AFTER    2
  104. #define    LOC_END        3
  105. #define    LOC_START    4
  106.  
  107. typedef    struct    _CardStruct    {
  108.     struct _CardStruct    *prev;
  109.     struct _CardStruct    *next;
  110.     struct    _CardList    *list;
  111.     int    x,y;        /* location */
  112.     Suit    suit;
  113.     Rank    rank;
  114.     Type    type;
  115.     int    draw_count;
  116. }    CardStruct, *CardPtr;
  117.  
  118. #define    CARDNULL    ((CardPtr) 0)
  119.  
  120. typedef struct _CardList    {
  121.     CardPtr    cards;
  122.     int    place;
  123.     int    card_delta;    /* pixels between cards in stack */
  124.     int    x, y;
  125. }    CardListStruct,    *CardList;
  126.  
  127. #define    CARDLISTNULL    ((CardList) 0)
  128.  
  129. #ifndef SMALL_CARDS
  130. #define    CARD_DELTA    30    
  131. #else
  132. #define    CARD_DELTA    20
  133. #endif    /* !SMALL_CARDS */
  134.  
  135.  
  136. #define    IS_PILE(list)    (((list) != CARDLISTNULL) && (list)->place < STACK_1)
  137.  
  138. /* gfx defs */
  139.  
  140. /* card info*/
  141. #ifndef SMALL_CARDS
  142. #define    CARD_HEIGHT    123
  143. #define    CARD_WIDTH    79
  144.  
  145. #define    FACECARD_WIDTH    47
  146. #define    FACECARD_HEIGHT    92
  147.  
  148. #define    RANK_WIDTH    9
  149. #define    RANK_HEIGHT    14
  150.  
  151. #define    RANK_LOC_X    4
  152. #define    RANK_LOC_Y    7
  153.  
  154. #define    SMALL_LOC_X    4
  155. #define    SMALL_LOC_Y    (RANK_HEIGHT + RANK_LOC_Y + 3)
  156.  
  157. #define    MID_CARD_X    (CARD_WIDTH/2)
  158. #define    MID_CARD_Y    (CARD_HEIGHT/2)
  159.  
  160. #define    CARD_COL1_X    (3 * CARD_WIDTH/10)
  161. #define    CARD_COL2_X    (CARD_WIDTH/2)
  162. #define    CARD_COL3_X    (7 * CARD_WIDTH/10)
  163.  
  164. /* 5 diff rows for the two main columns */
  165. /* 1 and 5 are top and bottom, 3 is the middle */
  166. /* 2 & 4 are for the 10 & 9 */
  167. #define    CARD_ROW1_Y    (CARD_HEIGHT/5)
  168. #define    CARD_ROW2_Y    (2 * CARD_HEIGHT/5)
  169. #define    CARD_ROW3_Y    (CARD_HEIGHT/2)
  170. #define    CARD_ROW4_Y    (CARD_HEIGHT - 2 * CARD_HEIGHT/5)
  171. #define    CARD_ROW5_Y    (CARD_HEIGHT - CARD_HEIGHT/5)
  172.  
  173. /* between 1 & 3, 3 & 5 */
  174. #define    CARD_SEVEN_Y    (7 * CARD_HEIGHT/20)
  175. #define    CARD_EIGHT_Y    (CARD_HEIGHT - 7 * CARD_HEIGHT/20)
  176.  
  177. /* between rows 1 & 2, 4 & 5 */
  178. #define    CARD_TEN_Y1    (3 * CARD_HEIGHT/10)
  179. #define    CARD_TEN_Y2    (CARD_HEIGHT - 3 * CARD_HEIGHT/10)
  180.  
  181. /* card positioning */
  182. #define    CARD_INSET_X    10
  183. #define    CARD_INSET_Y    (CARD_HEIGHT/8)
  184.  
  185. #define    STACK_WIDTH    (CARD_WIDTH + 10)
  186. #define    STACK_LOC_X(i)    ((STACK_INDEX(i) * STACK_WIDTH) + CARD_INSET_X)
  187. #define    STACK_LOC_Y    (CARD_HEIGHT + 3 * CARD_INSET_Y)
  188.  
  189. #define    PILE_WIDTH    STACK_WIDTH
  190. #define    PILE_INSET_X    (STACK_WIDTH + CARD_INSET_X + CARD_WIDTH)
  191. #define    PILE_LOC_X(i)    ((PILE_INDEX(i) * PILE_WIDTH) + PILE_INSET_X)
  192. #define    PILE_LOC_Y    (CARD_INSET_Y)
  193.  
  194. #define    DECK_X        CARD_INSET_X
  195. #define    DECK_Y        CARD_INSET_Y
  196.  
  197. #define    TABLE_X        10
  198. #define    TABLE_Y        10
  199.  
  200. #define    TABLE_WIDTH    (STACK_WIDTH * NUM_STACKS + 2 * CARD_INSET_X)
  201. #define    TABLE_HEIGHT    (STACK_LOC_Y + 2 * CARD_HEIGHT)
  202. #define    TABLE_BW    2
  203.  
  204. /* pip info */
  205. #define    PIP_WIDTH    10
  206. #define    PIP_HEIGHT    10
  207.  
  208. #else    /* SMALL_CARDS */
  209.  
  210. #define    CARD_HEIGHT    60
  211. #define    CARD_WIDTH    40
  212.  
  213. /* card positioning */
  214. #define    CARD_INSET_X    10
  215. #define    CARD_INSET_Y    (CARD_HEIGHT/8)
  216.  
  217. #define    STACK_WIDTH    (CARD_WIDTH + 10)
  218. #define    STACK_LOC_X(i)    ((STACK_INDEX(i) * STACK_WIDTH) + CARD_INSET_X)
  219. #define    STACK_LOC_Y    (CARD_HEIGHT + 4 * CARD_INSET_Y)
  220.  
  221. #define    PILE_WIDTH    STACK_WIDTH
  222. #define    PILE_INSET_X    (STACK_WIDTH + CARD_INSET_X + CARD_WIDTH)
  223. #define    PILE_LOC_X(i)    ((PILE_INDEX(i) * PILE_WIDTH) + PILE_INSET_X)
  224. #define    PILE_LOC_Y    (CARD_INSET_Y)
  225.  
  226. #define    DECK_X        CARD_INSET_X
  227. #define    DECK_Y        CARD_INSET_Y
  228.  
  229. #define    TABLE_X        10
  230. #define    TABLE_Y        10
  231.  
  232. #define    TABLE_WIDTH    (STACK_WIDTH * NUM_STACKS + 2 * CARD_INSET_X)
  233. #define    TABLE_HEIGHT    (STACK_LOC_Y + 2 * CARD_HEIGHT)
  234. #define    TABLE_BW    2
  235.  
  236. #endif /* !SMALL_CARDS */
  237.  
  238. #ifdef KITLESS
  239. #define    MESSAGE_FONT    "fixed"
  240. #define    MESSAGE_X    10
  241. #endif /* KITLESS */
  242.