home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume18 / xmris / part02 < prev    next >
Encoding:
Text File  |  1992-07-15  |  50.2 KB  |  1,736 lines

  1. Path: uunet!usc!elroy.jpl.nasa.gov!swrinde!mips!msi!dcmartin
  2. From: nathan@inmos.co.uk (Nathan Sidwell)
  3. Newsgroups: comp.sources.x
  4. Subject: v18i023: Xmris - an X video game, Part02/09
  5. Message-ID: <1992Jul16.171707.1650@msi.com>
  6. Date: 16 Jul 92 17:17:07 GMT
  7. References: <csx-18i022-xmris@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 1722
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: Nathan Sidwell <nathan@inmos.co.uk>
  15. Posting-number: Volume 18, Issue 23
  16. Archive-name: xmris/part02
  17.  
  18. # this is part.02 (part 2 of a multipart archive)
  19. # do not concatenate these parts, unpack them in order with /bin/sh
  20. # file xmris.h continued
  21. #
  22. if test ! -r _shar_seq_.tmp; then
  23.     echo 'Please unpack part 1 first!'
  24.     exit 1
  25. fi
  26. (read Scheck
  27.  if test "$Scheck" != 2; then
  28.     echo Please unpack part "$Scheck" next!
  29.     exit 1
  30.  else
  31.     exit 0
  32.  fi
  33. ) < _shar_seq_.tmp || exit 1
  34. if test ! -f _shar_wnt_.tmp; then
  35.     echo 'x - still skipping xmris.h'
  36. else
  37. echo 'x - continuing file xmris.h'
  38. sed 's/^X//' << 'SHAR_EOF' >> 'xmris.h' &&
  39. EXTERN struct
  40. /* player specific information
  41. X * note, the playe place info is stored as monster 0
  42. X */
  43. {
  44. X  unsigned  screen;     /* current screen number */
  45. X  unsigned  score;      /* our score */
  46. X  unsigned  lives;      /* lives we have left (including on screen) */
  47. X  COORD     mouse;      /* mouse destination square */
  48. X  unsigned  throw;      /* throw the ball */
  49. X  unsigned  button;     /* throw button state */
  50. X  unsigned  mouse_dir;  /* mouse direction */
  51. X  unsigned  next_dir;   /* direction at next intersection */
  52. X  unsigned  pressed;    /* keys we have pressed */
  53. X  unsigned  bashed;     /* we bashed into a wall */
  54. X  BALL      old_ball;   /* what was the ball */
  55. X  BALL      ball;       /* ball information */
  56. X  unsigned  keyboard;   /* use keyboard */
  57. X  unsigned  cherry;     /* consecutive cherry count */
  58. X  unsigned  distance;   /* distance to next cherry */
  59. X  COORD     raw_mouse;  /* the raw mouse input */
  60. X  unsigned  old_pressed; /* old keys pressed */
  61. X  unsigned  motionevent; /* the mouse moved */
  62. } player;
  63. /*}}}*/
  64. EXTERN unsigned long seed; /* random number seed */
  65. EXTERN char const *game_name; /* name of the game */
  66. /*{{{  global*/
  67. EXTERN struct
  68. {
  69. X  unsigned  difficulty;     /* increments in to make it harder */
  70. X  unsigned  broken;         /* broken through a new path */
  71. X  unsigned  cherries;       /* number of cherries left */
  72. X  unsigned  state;          /* den state
  73. X                 * 0 - den on screen
  74. X                 * 1 - cake on screen
  75. X                 * 2 - xtras & drone running around
  76. X                 * 3 - done xtras
  77. X                 * 4 - end game
  78. X                 * 5 - extra life
  79. X                 * 6 - demo
  80. X                 * 7 - high scores
  81. X                 * 8 - history
  82. X                 */
  83. X  unsigned  missed;         /* missed interrupt count */
  84. } global;
  85. /*}}}*/
  86. /*{{{  extra*/
  87. EXTERN struct
  88. {
  89. X  unsigned  got;      /* one we've got */
  90. X  unsigned  select;   /* the one which is selected */
  91. X  unsigned  escape;   /* its out */
  92. X  unsigned  score;    /* last checked score */
  93. } extra;
  94. /*}}}*/
  95. /*{{{  apple*/
  96. EXTERN struct
  97. {
  98. X  APPLE     list[APPLES]; /* apple list */
  99. X  unsigned  apples;       /* number of apples out */
  100. } apple;
  101. /*}}}*/
  102. /*{{{  history*/
  103. EXTERN struct
  104. {
  105. X  unsigned  prize;
  106. X  unsigned  ending;
  107. } history;
  108. /*}}}*/
  109. /*{{{  monster*/
  110. EXTERN struct
  111. {
  112. X  MONSTER   list[MONSTERS]; /* monsters [0] is player */
  113. X  unsigned  monsters;       /* number of monsters out (inc player) */
  114. X  unsigned  delay;          /* escape delay */
  115. X  unsigned  den;            /* monster spawn count */
  116. X  unsigned  normals;        /* normal monsters alive */
  117. X  unsigned  drones;         /* drones out */
  118. X  unsigned  nearest;        /* what was the nearest distance to player */
  119. X  unsigned  farthest;       /* what was the farthest distance to player */
  120. } monster;
  121. /*}}}*/
  122. /*{{{  update*/
  123. EXTERN struct
  124. {
  125. X  COORD     tl;       /* top left */
  126. X  COORD     br;       /* bottom right */
  127. X  unsigned  set;      /* tl & br set */
  128. X  struct
  129. X  {
  130. X    unsigned  backs; /* number of areas to update to window */
  131. X    BACKGROUND list[BACK_UPDATES]; /* the area information */
  132. X  } back;
  133. X  struct
  134. X  {
  135. X    unsigned  scores;  /* number of displayed scores */
  136. X    SCORE     list[BOARD_SCORES];   /* the displayed scores */
  137. X  } score;
  138. } update;
  139. /*}}}*/
  140. /*{{{  tables*/
  141. extern ARG const args[];
  142. /*{{{  sprite numbers*/
  143. #define SPRITE_CENTER_BASE     0
  144. #define SPRITE_MUNCH_BASE      2
  145. #define SPRITE_EDGE_BASE       4
  146. #define SPRITE_FILL_BASE       6
  147. #define SPRITE_DIGITS         10
  148. #define SPRITE_CHERRY         11
  149. #define SPRITE_DEN            12
  150. #define SPRITE_BALL           13
  151. #define SPRITE_APPLE          14
  152. #define SPRITE_EXTRA          20
  153. #define SPRITE_XTRA_SOURCE    22
  154. #define SPRITE_MONSTERS       24
  155. #define SPRITE_NORMAL         24
  156. #define SPRITE_MUNCHER        36
  157. #define SPRITE_XTRA           48
  158. #define SPRITE_DRONE          60
  159. #define SPRITE_PLAYER         72
  160. #define SPRITE_PLAYER_PUSH    84
  161. #define SPRITE_PLAYER_DEAD    88
  162. #define SPRITE_SQUISHED       90
  163. #define SPRITE_CHOMP          100
  164. #define SPRITE_MRIS           102
  165. #define SPRITE_PRIZE_BASE     110
  166. #define SPRITES               115
  167. /*}}}*/
  168. #define SPRITE_FILLS           4
  169. #define SPRITE_PRIZES          5
  170. /*{{{  random sizes*/
  171. #define MUNCH_WIDTH     (VEL_X * 4) 
  172. #define MUNCH_HEIGHT    (VEL_Y * 4)
  173. #define EDGE_WIDTH      (CELL_WIDTH + GAP_WIDTH * 2)
  174. #define EDGE_HEIGHT     (CELL_HEIGHT + GAP_HEIGHT * 2)
  175. #define DIGIT_HEIGHT    (CELL_HEIGHT / 2)
  176. #define DIGIT_WIDTH     (CELL_WIDTH / 4)
  177. #define DECAY_WIDTH     (CELL_WIDTH / 2 * 3)
  178. #define DECAY_HEIGHT    (CELL_HEIGHT / 4 * 3)
  179. #define ROT_WIDTH       (CELL_WIDTH / 2 * 3)
  180. #define ROT_HEIGHT      (CELL_HEIGHT / 2)
  181. /*}}}*/
  182. #define BALL_WIDTH    6
  183. #define BALL_HEIGHT   6
  184. extern SPRITE sprites[SPRITES];
  185. extern APPLE_SIZE const apple_sizes[6];
  186. #define BOARDS 10
  187. extern BOARD const boards[BOARDS];
  188. extern char keystrokes[5];
  189. extern COORD const ball_hold[16];
  190. extern COORD const ball_throw[8];
  191. extern int const ball_dir[8];
  192. extern int const player_dies[8];
  193. extern char const *title_text[];
  194. #define SQUISH_SCORES 7
  195. extern int const squish_scores[SQUISH_SCORES];
  196. /*}}}*/
  197. /*{{{  prototypes*/
  198. /*{{{  apple*/
  199. extern APPLE *apple_search PROTOARGLIST((int, int, unsigned, unsigned, unsigned));
  200. extern int apple_stop PROTOARGLIST((MONSTER *, CELL *));
  201. extern void apple_under PROTOARGLIST((MONSTER *, CELL *));
  202. extern void move_apples PROTOARGLIST((void));
  203. extern APPLE *spawn_apple PROTOARGLIST((int, int, int, int));
  204. /*}}}*/
  205. /*{{{  create*/
  206. extern void create_resources PROTOARGLIST((int, char **));
  207. extern void create_xtra_monster PROTOARGLIST((int));
  208. extern void draw_extra_letter PROTOARGLIST((int));
  209. extern void release_resources PROTOARGLIST((void));
  210. /*}}}*/
  211. /*{{{  demo*/
  212. extern int demo_mode PROTOARGLIST((void));
  213. extern void extra_life PROTOARGLIST((void));
  214. extern void show_history PROTOARGLIST((void));
  215. /*}}}*/
  216. /*{{{  draw*/
  217. extern void add_background PROTOARGLIST((int, int, int, int));
  218. extern void bounding_box PROTOARGLIST((int, int, unsigned, unsigned));
  219. extern void draw_center PROTOARGLIST((int));
  220. extern void draw_extra PROTOARGLIST((void));
  221. extern void new_board PROTOARGLIST((void));
  222. extern void refresh_window PROTOARGLIST((void));
  223. extern void show_updates PROTOARGLIST((void));
  224. extern void text_size PROTOARGLIST((char const *, unsigned, TEXT *));
  225. extern void zoom_board PROTOARGLIST((void));
  226. /*}}}*/
  227. /*{{{  monster*/
  228. extern MONSTER *extra_escape PROTOARGLIST((void));
  229. extern void fall_monsters PROTOARGLIST((void));
  230. extern void move_monsters PROTOARGLIST((void));
  231. extern void new_xtra PROTOARGLIST((void));
  232. extern MONSTER *spawn_monster PROTOARGLIST((int, int, int, int, int, int, int));
  233. /*}}}*/
  234. /*{{{  move*/
  235. extern unsigned choose_direction PROTOARGLIST((unsigned));
  236. extern CELL *drop_apple PROTOARGLIST((APPLE *, CELL *));
  237. extern CELL *move_movable PROTOARGLIST((MONSTER *, CELL *));
  238. extern CELL *move_muncher PROTOARGLIST((MONSTER *));
  239. extern void munch_hole PROTOARGLIST((CELL *, int, int));
  240. extern void new_face PROTOARGLIST((MONSTER *));
  241. extern int valid_directions PROTOARGLIST((MONSTER *, CELL *));
  242. /*}}}*/
  243. /*{{{  player*/
  244. extern void bounce_ball PROTOARGLIST((void));
  245. extern void move_player PROTOARGLIST((void));
  246. /*}}}*/
  247. /*{{{  timer*/
  248. extern void timer_close PROTOARGLIST((void));
  249. extern void timer_open PROTOARGLIST((void));
  250. extern void timer_start PROTOARGLIST((unsigned long));
  251. extern void timer_stop PROTOARGLIST((void));
  252. extern void timer_wait PROTOARGLIST((void));
  253. /*}}}*/
  254. /*{{{  xmris*/
  255. extern void add_score PROTOARGLIST((int, int, int));
  256. extern void calc_distances PROTOARGLIST((void));
  257. extern void fatal_error PROTOARGLIST((char const *, ...));
  258. extern int itoa PROTOARGLIST((char *, int, int));
  259. extern int main PROTOARGLIST((int, char **));
  260. extern int process_xevents PROTOARGLIST((int));
  261. extern unsigned random PROTOARGLIST((void));
  262. /*}}}*/
  263. /*}}}*/
  264. SHAR_EOF
  265. echo 'File xmris.h is complete' &&
  266. chmod 0644 xmris.h ||
  267. echo 'restore of xmris.h failed'
  268. Wc_c="`wc -c < 'xmris.h'`"
  269. test 22124 -eq "$Wc_c" ||
  270.     echo 'xmris.h: original size 22124, current size' "$Wc_c"
  271. rm -f _shar_wnt_.tmp
  272. fi
  273. # ============= apple.c ==============
  274. if test -f 'apple.c' -a X"$1" != X"-c"; then
  275.     echo 'x - skipping apple.c (File already exists)'
  276.     rm -f _shar_wnt_.tmp
  277. else
  278. > _shar_wnt_.tmp
  279. echo 'x - extracting apple.c (Text)'
  280. sed 's/^X//' << 'SHAR_EOF' > 'apple.c' &&
  281. /*{{{  (C) 1992 Nathan Sidwell*/
  282. /*****************************************************************************
  283. X            X M R I S V1.01
  284. X            ---------------
  285. X            (C) 1992 Nathan Sidwell
  286. X
  287. This program is copyright (C) 1992 Nathan Sidwell. This software and documentation
  288. is in the public domain. Permission is granted to distribute and compile
  289. verbatim copies of this software for non-commercial, non-profit use,
  290. without fee. The software may be modified, provided that both the above copyright
  291. notice and this permission notice appear.
  292. X
  293. No guarantee is given as to the robustness or suitability of this
  294. software for your computer.
  295. X
  296. Nathan Sidwell  INMOS UK |                 | nathan@inmos.co.uk       DoD#0390
  297. *****************************************************************************/
  298. /*}}}*/
  299. #include "xmris.h"
  300. /*{{{  APPLE *apple_search(x, y, width, height, found)*/
  301. extern APPLE *apple_search FUNCARGLIST((x, y, width, height, found))
  302. int       x       FUNCARGSEP  /* x coord start */
  303. int       y       FUNCARGSEP  /* y coord start */
  304. unsigned  width   FUNCARGSEP  /* width of box */
  305. unsigned  height  FUNCARGSEP  /* hieght of box */
  306. unsigned  found   FUNCARGTERM /* already found ones */
  307. /*
  308. X * looks for an apple in the specified box
  309. X * and returns a ptr to it, if found
  310. X */
  311. {
  312. X  unsigned  i;
  313. X  APPLE     *aptr;
  314. X  
  315. X  for(aptr = apple.list, i = 0; i != apple.apples; i++, aptr++, found >>= 1)
  316. X    if(!(found & 1) && aptr->pixel.x + aptr->push - x >= 0 &&
  317. X    aptr->pixel.x + aptr->push - x < width &&
  318. X    aptr->pixel.y - y >= 0 && aptr->pixel.y - y < height)
  319. X      return aptr;
  320. X  return NULL;
  321. }
  322. /*}}}*/
  323. /*{{{  int apple_stop(mptr, cptr)*/
  324. extern int apple_stop FUNCARGLIST((mptr, cptr))
  325. MONSTER   *mptr FUNCARGSEP
  326. CELL      *cptr FUNCARGTERM
  327. /*
  328. X * sees if the monster is about to walk into an apple
  329. X * returns 0 if clear, 1 if stopped
  330. X * sets mptr->pause & mptr->stop as required
  331. X * the apples and other monsters are altered
  332. X * if they're pushed about
  333. X * called before we've moved the monster
  334. X */
  335. {
  336. X  unsigned  stop;
  337. X  unsigned  pause;
  338. X  pause = stop = 0;
  339. X  switch(mptr->dir)
  340. X  {
  341. X    /*{{{  case 0: (up)*/
  342. X    case 0:
  343. X    {
  344. X      if(mptr->offset.y == -VEL_Y)
  345. X    /*{{{  walked into apple?*/
  346. X    {
  347. X      unsigned  i;
  348. X      APPLE     *aptr;
  349. X      int       px, py;
  350. X            
  351. X      px = mptr->pixel.x;
  352. X      py = mptr->pixel.y;
  353. X      for(aptr = apple.list, i = apple.apples; i--; aptr++)
  354. X        {
  355. X          if(aptr->pixel.x + aptr->push - px < CELL_WIDTH &&
  356. X          aptr->pixel.x + aptr->push - px > -CELL_WIDTH &&
  357. X          py - aptr->pixel.y > 0 &&
  358. X          py - aptr->pixel.y <= CELL_HEIGHT)
  359. X        {
  360. X          stop = 1;
  361. X          break;
  362. X        }
  363. X        }
  364. X    }
  365. X    /*}}}*/
  366. X      break;
  367. X    }
  368. X    /*}}}*/
  369. X    /*{{{  case 1: (down)*/
  370. X    case 1:
  371. X    {
  372. X      unsigned  i;
  373. X      APPLE     *aptr;
  374. X      int       px, py;
  375. X    
  376. X      px = mptr->pixel.x;
  377. X      py = mptr->pixel.y;
  378. X      for(aptr = apple.list, i = apple.apples; i--; aptr++)
  379. X    {
  380. X      if(aptr->pixel.x + aptr->push - px < CELL_WIDTH &&
  381. X          aptr->pixel.x + aptr->push - px > -CELL_WIDTH &&
  382. X          aptr->pixel.y + apple_sizes[aptr->state].offset.y - py <=
  383. X          CELL_HEIGHT &&
  384. X          aptr->pixel.y + apple_sizes[aptr->state].offset.y - py > 0)
  385. X        {
  386. X          stop = 1;
  387. X          break;
  388. X        }
  389. X    }
  390. X      break;
  391. X    }
  392. X    /*}}}*/
  393. X    /*{{{  case 2: (left)*/
  394. X    case 2:
  395. X    {
  396. X      unsigned  found;
  397. X      int       x, y;
  398. X      int       width;
  399. X      APPLE     *final;
  400. X      
  401. X      found = 0;
  402. X      final = NULL;
  403. X      width = VEL_X;
  404. X      x = mptr->pixel.x - CELL_WIDTH + 1 - width;
  405. X      y = mptr->pixel.y - CELL_HEIGHT + VEL_Y;
  406. X      /*{{{  look for apple*/
  407. X      for(;;)
  408. X      {
  409. X    APPLE     *aptr;
  410. X    CELL      *cptr;
  411. X          
  412. X    aptr = apple_search(x, y,
  413. X        width + CELL_WIDTH / 2, 2 * (CELL_HEIGHT - VEL_Y), found);
  414. X    if(!aptr)
  415. X      break;
  416. X    else if(aptr->state > 3 || aptr->push ||
  417. X        aptr->pixel.x - width < PIXELX(0, 0))
  418. X      {
  419. X        stop = 1;
  420. X        break;
  421. X      }
  422. X    else if(aptr->state == 2 && ((mptr->type != 1 && mptr->type != 4) ||
  423. X        (aptr->offset.x < 0 &&
  424. X        (cptr = BOARDCELL(aptr->cell.x, aptr->cell.y +
  425. X        (aptr->offset.y <= 0)))->depths[2] > aptr->offset.x &&
  426. X          !cptr[-1].visit)))
  427. X      break;
  428. X    else
  429. X      {
  430. X        final = aptr;
  431. X        found |= 1 << (aptr - apple.list);
  432. X        width = aptr->pixel.x - x + 1;
  433. X        aptr->maypush = width;
  434. X        x = aptr->pixel.x - CELL_WIDTH + 1 - width;
  435. X        if(aptr->state != 2 && aptr->offset.y > 0 &&
  436. X        apple_search(x, aptr->pixel.y - aptr->offset.y +
  437. X        CELL_HEIGHT, width, aptr->offset.y, found))
  438. X          {
  439. X        stop = 1;
  440. X        break;
  441. X          }
  442. X        y = aptr->pixel.y - CELL_HEIGHT + VEL_Y;
  443. X        if(!width || aptr->state == 2)
  444. X          break;
  445. X      }
  446. X      }
  447. X      /*}}}*/
  448. X      if(found && !stop)
  449. X    {
  450. X      /*{{{  check if against monster*/
  451. X      if(width)
  452. X        {
  453. X          unsigned  i;
  454. X          MONSTER   *mptr;
  455. X          MONSTER   *list;
  456. X                
  457. X          list = NULL;
  458. X          for(mptr = monster.list, i = monster.monsters; i--; mptr++)
  459. X        {
  460. X          if(mptr->pixel.x - x >= 0 &&
  461. X              mptr->pixel.x - x < width + CELL_WIDTH &&
  462. X              mptr->pixel.y - y >= 0 &&
  463. X              mptr->pixel.y - y < 2 * (CELL_HEIGHT - VEL_Y))
  464. X            {
  465. X              if(mptr->type == 1)
  466. X            {
  467. X              if(mptr->dir & 2 ||
  468. X                  mptr->pixel.x - x >= width + CELL_WIDTH / 2)
  469. X                stop = 1;
  470. X            }
  471. X              else if(mptr->pixel.x - x >= width + CELL_WIDTH / 2)
  472. X            /*(EMPTY*/;
  473. X              else if(mptr->type == 4)
  474. X            stop = 1;
  475. X              else if(mptr->type == 0)
  476. X            {
  477. X              CELL      *cptr;
  478. X                
  479. X              cptr = BOARDCELL(mptr->cell.x, mptr->cell.y);
  480. X              if(cptr->depths[2] <= mptr->offset.x - width ||
  481. X                  ((cptr->depths[1] || cptr->depths[0]) &&
  482. X                  mptr->offset.x >= 0))
  483. X                {
  484. X                  mptr->list = list;
  485. X                  list = mptr;
  486. X                  mptr->push = -1;
  487. X                }
  488. X              else
  489. X                stop = 1;
  490. X            }
  491. X            }
  492. X        }
  493. X          if(final->state < 2)
  494. X        final->list = list;
  495. X        }
  496. X      /*}}}*/
  497. X      if(!stop)
  498. X      {
  499. X        pause = 1;
  500. X        /*{{{  push the apples*/
  501. X        {
  502. X          unsigned  i;
  503. X          APPLE     *aptr;
  504. X                  
  505. X          for(aptr = apple.list, i = apple.apples; i--; aptr++, found >>= 1)
  506. X        if(found & 1)
  507. X          aptr->push = -aptr->maypush;
  508. X        }
  509. X        /*}}}*/
  510. X      }
  511. X    }
  512. X      break;
  513. X    }
  514. X    /*}}}*/
  515. X    /*{{{  case 3: (right)*/
  516. X    case 3:
  517. X    {
  518. X      unsigned  found;
  519. X      int       x, y;
  520. X      int       width;
  521. X      APPLE     *final;
  522. X      
  523. X      found = 0;
  524. X      final = NULL;
  525. X      width = VEL_X;
  526. X      x = mptr->pixel.x + CELL_WIDTH;
  527. X      y = mptr->pixel.y - CELL_HEIGHT + VEL_Y;
  528. X      /*{{{  look for apple*/
  529. X      for(;;)
  530. X      {
  531. X    APPLE       *aptr;
  532. X          
  533. X    aptr = apple_search(x - CELL_WIDTH / 2, y,
  534. X        width + CELL_WIDTH / 2, 2 * (CELL_HEIGHT - VEL_Y), found);
  535. X    if(!aptr)
  536. X      break;
  537. X    else if(aptr->state > 3 || aptr->push ||
  538. X        aptr->pixel.x + width > PIXELX(CELLS_ACROSS - 1, 0))
  539. X      {
  540. X        stop = 1;
  541. X        break;
  542. X      }
  543. X    else if(aptr->state == 2 && ((mptr->type != 1 && mptr->type != 4) ||
  544. X        (aptr->offset.x > 0 &&
  545. X        (cptr = BOARDCELL(aptr->cell.x, aptr->cell.y +
  546. X        (aptr->offset.y <= 0)))->depths[3] < aptr->offset.x &&
  547. X          !cptr[1].visit)))
  548. X      break;
  549. X    else
  550. X      {
  551. X        final = aptr;
  552. X        found |= 1 << (aptr - apple.list);
  553. X        width -= aptr->pixel.x - x;
  554. X        aptr->maypush = width;
  555. X        x = aptr->pixel.x + CELL_WIDTH;
  556. X        if(aptr->state != 2 && aptr->offset.y > 0 &&
  557. X        apple_search(x, aptr->pixel.y - aptr->offset.y +
  558. X        CELL_HEIGHT, width, aptr->offset.y, found))
  559. X          {
  560. X        stop = 1;
  561. X        break;
  562. X          }
  563. X        y = aptr->pixel.y - CELL_HEIGHT + VEL_Y;
  564. X        if(!width || aptr->state == 2)
  565. X          break;
  566. X      }
  567. X      }
  568. X      /*}}}*/
  569. X      /*{{{  check if against monster*/
  570. X      if(found && width)
  571. X    {
  572. X      unsigned  i;
  573. X      MONSTER   *mptr;
  574. X      MONSTER   *list;
  575. X        
  576. X      list = NULL;
  577. X      for(mptr = monster.list, i = monster.monsters; i--; mptr++)
  578. X        {
  579. X          if(mptr->pixel.x - x >= -CELL_WIDTH &&
  580. X          mptr->pixel.x - x < width &&
  581. X          mptr->pixel.y - y >= 0 &&
  582. X          mptr->pixel.y - y < 2 * (CELL_HEIGHT - VEL_Y))
  583. X        {
  584. X          if(mptr->type == 1)
  585. X            {
  586. X              if(mptr->dir & 2 ||
  587. X              mptr->pixel.x - x < -CELL_WIDTH / 2)
  588. X            stop = 1;
  589. X            }
  590. X          else if(mptr->pixel.x - x < -CELL_WIDTH / 2)
  591. X            /*EMPTY*/;
  592. X          else if(mptr->type == 4)
  593. X            stop = 1;
  594. X          else if(mptr->type == 0)
  595. X            {
  596. X              CELL      *cptr;
  597. X        
  598. X              cptr = BOARDCELL(mptr->cell.x, mptr->cell.y);
  599. X              if(cptr->depths[3] >= mptr->offset.x + width ||
  600. X              ((cptr->depths[1] || cptr->depths[0]) &&
  601. X              mptr->offset.x <= 0))
  602. X            {
  603. X              mptr->list = list;
  604. X              list = mptr;
  605. X              mptr->push = 1;
  606. X            }
  607. X              else
  608. X            stop = 1;
  609. X            }
  610. X        }
  611. X        }
  612. X      if(final->state < 2)
  613. X        final->list = list;
  614. X    }
  615. X      /*}}}*/
  616. X      if(found && !stop)
  617. X    {
  618. X      pause = 1;
  619. X      /*{{{  push the apples*/
  620. X      {
  621. X        unsigned  i;
  622. X        APPLE     *aptr;
  623. X                  
  624. X        for(aptr = apple.list, i = apple.apples; i--; aptr++, found >>= 1)
  625. X          if(found & 1)
  626. X        aptr->push = aptr->maypush;
  627. X      }
  628. X      /*}}}*/
  629. X    }
  630. X      break;
  631. X    }
  632. X    /*}}}*/
  633. X  }
  634. X  mptr->stop = stop;
  635. X  mptr->pause = pause | stop;
  636. X  return stop;
  637. }
  638. /*}}}*/
  639. /*{{{  void apple_under(mptr, cptr)*/
  640. extern void apple_under FUNCARGLIST((mptr, cptr))
  641. MONSTER   *mptr FUNCARGSEP
  642. CELL      *cptr FUNCARGTERM
  643. /*
  644. X * deals with walking under apples
  645. X * so that they start or stop rocking
  646. X * called after we've done the move
  647. X * only for player and muncher
  648. X */
  649. {
  650. X  assert(mptr->type == 4 || mptr->type == 1);
  651. X  switch(mptr->dir)
  652. X  {
  653. X    /*{{{  case 0: (up)*/
  654. X    case 0:
  655. X      if(!mptr->offset.y)
  656. X    /*{{{  stop apple rocking?*/
  657. X    {
  658. X      unsigned  i;
  659. X      APPLE     *aptr;
  660. X              
  661. X      for(aptr = apple.list, i = apple.apples; i--; aptr++)
  662. X        {
  663. X          if(aptr->pixel.x - mptr->pixel.x <= CELL_WIDTH / 2 &&
  664. X         aptr->pixel.x - mptr->pixel.x >= -(CELL_WIDTH / 2) &&
  665. X          aptr->state == 1 && mptr->cell.y == aptr->cell.y + 1)
  666. X          {
  667. X        aptr->state = 0;
  668. X        aptr->count = 1;
  669. X          }
  670. X      }
  671. X    }
  672. X    /*}}}*/
  673. X      break;
  674. X    /*}}}*/
  675. X    /*{{{  case 1: (down)*/
  676. X    case 1:
  677. X      if(mptr->offset.y == VEL_Y)
  678. X    /*{{{  start apple rocking?*/
  679. X    {
  680. X      unsigned  i;
  681. X      APPLE     *aptr;
  682. X            
  683. X      for(aptr = apple.list, i = apple.apples; i--; aptr++)
  684. X        {
  685. X          if(aptr->pixel.x - mptr->pixel.x <= CELL_WIDTH / 2 &&
  686. X          aptr->pixel.x - mptr->pixel.x >= -(CELL_WIDTH / 2) &&
  687. X          !aptr->state && mptr->cell.y == aptr->cell.y + 1)
  688. X        {
  689. X          aptr->state = 1;
  690. X          aptr->count = APPLE_ROCK_DELAY;
  691. X        }
  692. X        }
  693. X    }
  694. X    /*}}}*/
  695. X      break;
  696. X    /*}}}*/
  697. X    /*{{{  case 2: (left)*/
  698. X    case 2:
  699. X    {
  700. X      unsigned  i;
  701. X      APPLE     *aptr;
  702. X      int       px, py;
  703. X      int       cy;
  704. X    
  705. X      px = mptr->pixel.x;
  706. X      py = mptr->pixel.y;
  707. X      cy = mptr->cell.y;
  708. X      /*{{{  walking under apple?*/
  709. X      for(aptr = apple.list, i = apple.apples; i--; aptr++)
  710. X    {
  711. X      if(aptr->cell.y + 1 != cy)
  712. X        /*EMPTY*/;
  713. X      else if(aptr->pixel.x - px == CELL_WIDTH / 2 && !aptr->state)
  714. X        {
  715. X          aptr->state = 1;
  716. X          aptr->count = APPLE_ROCK_DELAY;
  717. X        }
  718. X      else if(mptr->type == 4 && aptr->state == 1 &&
  719. X          aptr->pixel.x - px == -CELL_WIDTH / 2)
  720. X        {
  721. X          aptr->state = 0;
  722. X          aptr->count = 1;
  723. X        }
  724. X    }
  725. X      /*}}}*/
  726. X      break;
  727. X    }
  728. X    /*}}}*/
  729. X    /*{{{  case 3: (right)*/
  730. X    case 3:
  731. X    {
  732. X      unsigned  i;
  733. X      APPLE     *aptr;
  734. X      int       px, py;
  735. X      int       cy;
  736. X    
  737. X      px = mptr->pixel.x;
  738. X      py = mptr->pixel.y;
  739. X      cy = mptr->cell.y;
  740. X      /*{{{  walking under apple?*/
  741. X      for(aptr = apple.list, i = apple.apples; i--; aptr++)
  742. X    {
  743. X      if(aptr->cell.y + 1 != cy)
  744. X        /*EMPTY*/;
  745. X      else if(px - aptr->pixel.x == CELL_WIDTH / 2 && !aptr->state)
  746. X        {
  747. X          aptr->state = 1;
  748. X          aptr->count = APPLE_ROCK_DELAY;
  749. X        }
  750. X      else if(mptr->type == 4  && aptr->state == 1 &&
  751. X          px - aptr->pixel.x == -CELL_WIDTH / 2)
  752. X        {
  753. X          aptr->state = 0;
  754. X          aptr->count = 1;
  755. X        }
  756. X    }
  757. X      /*}}}*/
  758. X      break;
  759. X    }
  760. X    /*}}}*/
  761. X  }
  762. X  return;
  763. }
  764. /*}}}*/
  765. /*{{{  void move_apples()*/
  766. extern void move_apples FUNCARGVOID
  767. /*
  768. X * moves all the apples
  769. X */
  770. {
  771. X  APPLE     *aptr;
  772. X  unsigned  i;
  773. X
  774. X  for(aptr = apple.list, i = apple.apples; i--; aptr++)
  775. X    {
  776. X      CELL      *cptr;
  777. X  
  778. X      cptr = BOARDCELL(aptr->cell.x, aptr->cell.y);
  779. X      if(aptr->chewed)
  780. X    {
  781. X      if(aptr->monsters)
  782. X        add_score(squish_scores[aptr->monsters >= SQUISH_SCORES ?
  783. X        SQUISH_SCORES - 1 : aptr->monsters],
  784. X        aptr->pixel.x + CELL_WIDTH / 2,
  785. X        aptr->pixel.y + apple_sizes[4].size.y / 2);
  786. X      aptr->state = 6;
  787. X    }
  788. X      else
  789. X    switch(aptr->state)
  790. X    {
  791. X      /*{{{  case 0: (static) case 1: (rock)*/
  792. X      case 0: case 1:
  793. X        if(aptr->push)
  794. X          {
  795. X        aptr->pixel.x += aptr->push;
  796. X        aptr->offset.x += aptr->push;
  797. X        if(aptr->offset.x < -(CELL_WIDTH / 2))
  798. X          {
  799. X            aptr->offset.x += CELL_WIDTH + GAP_WIDTH;
  800. X            aptr->cell.x -= 1;
  801. X            cptr -= 1;
  802. X          }
  803. X        else if(aptr->offset.x > (CELL_WIDTH / 2))
  804. X          {
  805. X            aptr->offset.x -= CELL_WIDTH + GAP_WIDTH;
  806. X            aptr->cell.x += 1;
  807. X            cptr += 1;
  808. X          }
  809. X        if(cptr[0].depths[1] > aptr->offset.y)
  810. X          aptr->state = 2;
  811. X        else if(aptr->state == 0 && cptr[CELL_STRIDE].visit)
  812. X          {
  813. X            aptr->state = 1;
  814. X            aptr->count = APPLE_ROCK_DELAY;
  815. X          }
  816. X        else if(aptr->state == 1 && !cptr[CELL_STRIDE].visit)
  817. X          {
  818. X            aptr->state = 0;
  819. X            aptr->count = 1;
  820. X          }
  821. X          }
  822. X        if(aptr->state == 1 && !aptr->count--)
  823. X          aptr->state = 2;
  824. X        if(aptr->state == 2)
  825. X          {
  826. X        MONSTER   *mptr;
  827. X                  
  828. X        aptr->count = APPLE_ACC;
  829. X        aptr->distance = 0;
  830. X        if(!cptr[0].visit)
  831. X          {
  832. X            aptr->cell.y += 1;
  833. X            aptr->offset.y -= CELL_HEIGHT + GAP_HEIGHT;
  834. X          }
  835. X        if(cptr[CELL_STRIDE].visit || cptr[0].depths[1])
  836. X          /*EMPTY*/;
  837. X        else if(cptr[CELL_STRIDE-1].depths[3] +
  838. X            cptr[CELL_STRIDE+1].depths[2] > 0)
  839. X          {
  840. X            aptr->cell.x--;
  841. X            aptr->offset.x += CELL_WIDTH + GAP_WIDTH;
  842. X          }
  843. X        else if(cptr[CELL_STRIDE-1].depths[3] +
  844. X            cptr[CELL_STRIDE+1].depths[2] < 0)
  845. X          {
  846. X            aptr->cell.x++;
  847. X            aptr->offset.x -= CELL_WIDTH + GAP_WIDTH;
  848. X          }
  849. X        else
  850. X          {
  851. X            aptr->state = 0;
  852. X            aptr->list = NULL;
  853. X          }
  854. X        for(mptr = aptr->list; mptr; mptr = mptr->list)
  855. X          {
  856. X            mptr->apple = aptr;
  857. X            aptr->monsters++;
  858. X            aptr->distance = APPLE_FALL_SPLIT;
  859. X          }
  860. X          }
  861. X        else
  862. X          aptr->list = NULL;
  863. X        break;
  864. X      /*}}}*/
  865. X      /*{{{  case 2: (fall)*/
  866. X      case 2:
  867. X      {
  868. X        unsigned  j;
  869. X        APPLE     *optr;
  870. X        COORD     pixel;
  871. X                
  872. X        /*{{{  horizontal movement*/
  873. X        if(aptr->push)
  874. X          {
  875. X        aptr->pixel.x += aptr->push;
  876. X        aptr->offset.x += aptr->push;
  877. X        if(aptr->offset.x < -(CELL_WIDTH / 2))
  878. X          {
  879. X            aptr->offset.x += CELL_WIDTH + GAP_WIDTH;
  880. X            aptr->cell.x -= 1;
  881. X            cptr -= 1;
  882. X          }
  883. X        else if(aptr->offset.x > (CELL_WIDTH / 2))
  884. X          {
  885. X            aptr->offset.x -= CELL_WIDTH + GAP_WIDTH;
  886. X            aptr->cell.x += 1;
  887. X            cptr += 1;
  888. X          }
  889. X          }
  890. X        else if(aptr->waspushed)
  891. X          /*EMPTY*/;
  892. X        else if(aptr->offset.x < 0)
  893. X          {
  894. X        aptr->offset.x += APPLE_VEL_X;
  895. X        aptr->pixel.x += APPLE_VEL_X;
  896. X        assert(aptr->offset.x <= 0);
  897. X          }
  898. X        else if(aptr->offset.x > 0)
  899. X          {
  900. X        aptr->offset.x -= APPLE_VEL_X;
  901. X        aptr->pixel.x -= APPLE_VEL_X;
  902. X        assert(aptr->offset.x >= 0);
  903. X          }
  904. X        /*}}}*/
  905. X        pixel.x = aptr->pixel.x - aptr->offset.x;
  906. X        pixel.y = aptr->pixel.y - aptr->offset.y;
  907. X        aptr->offset.y += aptr->count;
  908. X        aptr->pixel.y += aptr->count;
  909. X        aptr->distance += aptr->count;
  910. X        aptr->count += APPLE_ACC;
  911. X        if(aptr->count > APPLE_VEL_Y)
  912. X          aptr->count = APPLE_VEL_Y;
  913. X        /*{{{  bashes into another?*/
  914. X        {
  915. X          int       x, y;
  916. X                
  917. X          x = aptr->pixel.x - CELL_WIDTH;
  918. X          y = pixel.y + aptr->offset.y;
  919. X          for(optr = apple.list, j = apple.apples; j--; optr++)
  920. X        if(optr != aptr &&
  921. X            optr->pixel.x - x > 0 &&
  922. X            optr->pixel.x - x < CELL_WIDTH * 2 &&
  923. X            optr->pixel.y + apple_sizes[optr->state].offset.y - y > 0 &&
  924. X            optr->pixel.y + apple_sizes[optr->state].offset.y - y <
  925. X            CELL_HEIGHT - APPLE_VEL_Y && (optr->state ||
  926. X            BOARDCELL(optr->cell.x, optr->cell.y)->visit))
  927. X          {
  928. X            if(optr->state < 3)
  929. X              {
  930. X            optr->state = 3;
  931. X            optr->count = APPLE_SPLIT_DELAY;
  932. X              }
  933. X            optr = NULL;
  934. X            break;
  935. X          }
  936. X        }
  937. X        /*}}}*/
  938. X        if(!optr)
  939. X          {
  940. X        aptr->state = 3;
  941. X        aptr->count = APPLE_SPLIT_DELAY;
  942. X          }
  943. X        else if(aptr->offset.y >= cptr[0].depths[1])
  944. X          {
  945. X        if(drop_apple(aptr, cptr))
  946. X          /*EMPTY*/;
  947. X        else if(aptr->distance >= APPLE_FALL_SPLIT ||
  948. X            aptr->cell.y == CELLS_DOWN - 1)
  949. X          /*{{{  fell too far*/
  950. X          {
  951. X            aptr->state = 3;
  952. X            aptr->count = APPLE_SPLIT_DELAY;
  953. X            aptr->offset.y = cptr[0].depths[1];
  954. X          }
  955. X          /*}}}*/
  956. X        else
  957. X          /*{{{  only fell a short way*/
  958. X          {
  959. X            aptr->state = 0;
  960. X            aptr->offset.y = cptr[0].depths[1];
  961. X          }
  962. X          /*}}}*/
  963. X          }
  964. X        else if(aptr->offset.y > 0 && cptr[CELL_STRIDE].depths[0])
  965. X          /*{{{  fall into next cell*/
  966. X          {
  967. X        aptr->cell.y += 1;
  968. X        aptr->offset.y -= CELL_HEIGHT + GAP_HEIGHT;
  969. X        pixel.y += CELL_HEIGHT + GAP_HEIGHT;
  970. X          }
  971. X          /*}}}*/
  972. X        /*{{{  crushed someone?*/
  973. X        {
  974. X          unsigned  i;
  975. X          MONSTER   *mptr;
  976. X          int       x, y;
  977. X                  
  978. X          x = pixel.x + aptr->offset.x - CELL_WIDTH + VEL_X;
  979. X          y = pixel.y + aptr->offset.y - APPLE_VEL_Y;
  980. X          for(mptr = monster.list, i = monster.monsters; i--; mptr++)
  981. X        if(!mptr->apple && !mptr->shot && mptr->type != 5 &&
  982. X            mptr->pixel.x - x > 0 &&
  983. X            mptr->pixel.x - x < 2 * (CELL_WIDTH - VEL_X) &&
  984. X            mptr->pixel.y - y > 0 &&
  985. X            mptr->pixel.y - y < CELL_WIDTH / 2 + APPLE_VEL_Y &&
  986. X            (!(mptr->type & 2) || global.state == 4 ||
  987. X              aptr->monsters || mptr->chew || mptr->dir == 1 ||
  988. X              (mptr->dir == 2 && mptr->pixel.x - x <
  989. X            CELL_WIDTH - VEL_X + CELL_WIDTH / 2) ||
  990. X              (mptr->dir == 3 && mptr->pixel.x - x >
  991. X            CELL_WIDTH - VEL_X -  CELL_WIDTH / 2)))
  992. X          {
  993. X            if(mptr->type & 2 && !mptr->dir && !mptr->chew &&
  994. X            !aptr->monsters && global.state != 4)
  995. X              {
  996. X            aptr->chewed = 1;
  997. X            mptr->chew = 1;
  998. X              }
  999. X            else
  1000. X              {
  1001. X            if(mptr != &monster.list[0])
  1002. X              aptr->monsters++;
  1003. X            mptr->apple = aptr;
  1004. X            aptr->distance = APPLE_FALL_SPLIT;
  1005. X            if(!aptr->state)
  1006. X              {
  1007. X                aptr->state = 3;
  1008. X                aptr->count = APPLE_SPLIT_DELAY;
  1009. X              }
  1010. X              }
  1011. X          }
  1012. X        }
  1013. X        /*}}}*/
  1014. X        aptr->pixel.y = pixel.y + aptr->offset.y;
  1015. X        break;
  1016. X      }
  1017. X      /*}}}*/
  1018. X      /*{{{  case 3: (split)*/
  1019. X      case 3:
  1020. X        if(!aptr->count--)
  1021. X          {
  1022. X        aptr->state = 4;
  1023. X        aptr->count = APPLE_DECAY_DELAY;
  1024. X        if(aptr->monsters)
  1025. X          add_score(squish_scores[aptr->monsters >= SQUISH_SCORES ?
  1026. X              SQUISH_SCORES - 1 : aptr->monsters],
  1027. X              aptr->pixel.x + CELL_WIDTH / 2,
  1028. X              aptr->pixel.y + apple_sizes[4].size.y / 2);
  1029. X          }
  1030. X        break;
  1031. X      /*}}}*/
  1032. X      /*{{{  case 4: (decay)*/
  1033. X      case 4:
  1034. X        if(!aptr->count--)
  1035. X          {
  1036. X        aptr->state = 5;
  1037. X        aptr->count = APPLE_ROT_DELAY;
  1038. X          }
  1039. X        break;
  1040. X      /*}}}*/
  1041. X      /*{{{  case 5: (rot)*/
  1042. X      case 5:
  1043. X        if(!aptr->count--)
  1044. X          aptr->state = 6;
  1045. X        break;
  1046. X      /*}}}*/
  1047. X      /*{{{  default:*/
  1048. X      default:
  1049. X        assert(0);
  1050. X      /*}}}*/
  1051. X    }
  1052. X      aptr->waspushed = aptr->push;
  1053. X      aptr->push = 0;
  1054. X    }
  1055. X  return;
  1056. }
  1057. /*}}}*/
  1058. /*{{{  APPLE *spawn_apple(cx, cy, ox, oy)*/
  1059. extern APPLE *spawn_apple FUNCARGLIST((cx, cy, ox, oy))
  1060. int       cx FUNCARGSEP
  1061. int       cy FUNCARGSEP
  1062. int       ox FUNCARGSEP
  1063. int       oy FUNCARGTERM
  1064. /*
  1065. X * spawns a new apple in state 0
  1066. X */
  1067. {
  1068. X  APPLE     *aptr;
  1069. X
  1070. X  assert(apple.apples != APPLES);
  1071. X  aptr = &apple.list[apple.apples++];
  1072. X  aptr->state = 0;
  1073. X  aptr->cell.x = cx;
  1074. X  aptr->cell.y = cy;
  1075. X  aptr->offset.x = ox = ox / APPLE_VEL_X * APPLE_VEL_X;
  1076. X  aptr->offset.y = oy;
  1077. X  aptr->count = 1;
  1078. X  aptr->old_pixel.x = aptr->pixel.x = PIXELX(cx, ox);
  1079. X  aptr->old_pixel.y = aptr->pixel.y = PIXELY(cy, oy);
  1080. X  aptr->distance = 0;
  1081. X  aptr->monsters = 0;
  1082. X  aptr->push = 0;
  1083. X  aptr->chewed = 0;
  1084. X  aptr->old_state = 7;
  1085. X  return aptr;
  1086. }
  1087. /*}}}*/
  1088. SHAR_EOF
  1089. chmod 0644 apple.c ||
  1090. echo 'restore of apple.c failed'
  1091. Wc_c="`wc -c < 'apple.c'`"
  1092. test 19361 -eq "$Wc_c" ||
  1093.     echo 'apple.c: original size 19361, current size' "$Wc_c"
  1094. rm -f _shar_wnt_.tmp
  1095. fi
  1096. # ============= create.c ==============
  1097. if test -f 'create.c' -a X"$1" != X"-c"; then
  1098.     echo 'x - skipping create.c (File already exists)'
  1099.     rm -f _shar_wnt_.tmp
  1100. else
  1101. > _shar_wnt_.tmp
  1102. echo 'x - extracting create.c (Text)'
  1103. sed 's/^X//' << 'SHAR_EOF' > 'create.c' &&
  1104. /*{{{  (C) 1992 Nathan Sidwell*/
  1105. /*****************************************************************************
  1106. X            X M R I S V1.01
  1107. X            ---------------
  1108. X            (C) 1992 Nathan Sidwell
  1109. X
  1110. This program is copyright (C) 1992 Nathan Sidwell. This software and documentation
  1111. is in the public domain. Permission is granted to distribute and compile
  1112. verbatim copies of this software for non-commercial, non-profit use,
  1113. without fee. The software may be modified, provided that both the above copyright
  1114. notice and this permission notice appear.
  1115. X
  1116. No guarantee is given as to the robustness or suitability of this
  1117. software for your computer.
  1118. X
  1119. Nathan Sidwell  INMOS UK |                 | nathan@inmos.co.uk       DoD#0390
  1120. *****************************************************************************/
  1121. /*}}}*/
  1122. #define EXTERN
  1123. #include "xmris.h"
  1124. /*{{{  bitmaps*/
  1125. /*{{{  bitmaps/icon/.*/
  1126. #include "bitmaps/icon/mris.h"
  1127. #include "bitmaps/icon/msit.h"
  1128. #include "bitmaps/icon/cursor.h"
  1129. #include "bitmaps/icon/cursorm.h"
  1130. #include "bitmaps/icon/solidm.h"
  1131. #include "bitmaps/icon/solidr.h"
  1132. #include "bitmaps/icon/solidi.h"
  1133. #include "bitmaps/icon/solids.h"
  1134. #include "bitmaps/icon/solidt.h"
  1135. #include "bitmaps/icon/shellm.h"
  1136. #include "bitmaps/icon/shellr.h"
  1137. #include "bitmaps/icon/shelli.h"
  1138. #include "bitmaps/icon/shells.h"
  1139. #include "bitmaps/icon/shellt.h"
  1140. #include "bitmaps/icon/bigm.h"
  1141. #include "bitmaps/icon/bigr.h"
  1142. #include "bitmaps/icon/bigi.h"
  1143. #include "bitmaps/icon/bigs.h"
  1144. #include "bitmaps/icon/bigt.h"
  1145. /*}}}*/
  1146. /*{{{  bitmaps/board/.*/
  1147. #include "bitmaps/board/oblong.h"
  1148. #include "bitmaps/board/rect.h"
  1149. #include "bitmaps/board/munchtb.h"
  1150. #include "bitmaps/board/munchlr.h"
  1151. #include "bitmaps/board/edgetb.h"
  1152. #include "bitmaps/board/edgelr.h"
  1153. #include "bitmaps/board/fill0.h"
  1154. #include "bitmaps/board/fill1.h"
  1155. #include "bitmaps/board/fill2.h"
  1156. #include "bitmaps/board/fill3.h"
  1157. #include "bitmaps/board/digits.h"
  1158. #include "bitmaps/board/digitsm.h"
  1159. #include "bitmaps/board/cherry.h"
  1160. #include "bitmaps/board/cherrym.h"
  1161. /*}}}*/
  1162. /*{{{  bitmaps/apple/.*/
  1163. #include "bitmaps/apple/apple.h"
  1164. #include "bitmaps/apple/applem.h"
  1165. #include "bitmaps/apple/rock.h"
  1166. #include "bitmaps/apple/rockm.h"
  1167. #include "bitmaps/apple/split.h"
  1168. #include "bitmaps/apple/splitm.h"
  1169. #include "bitmaps/apple/decay.h"
  1170. #include "bitmaps/apple/decaym.h"
  1171. #include "bitmaps/apple/rot.h"
  1172. #include "bitmaps/apple/rotm.h"
  1173. /*}}}*/
  1174. /*{{{  bitmaps/player/.*/
  1175. #include "bitmaps/player/ball.h"
  1176. #include "bitmaps/player/plyrrt1.h"
  1177. #include "bitmaps/player/plyrrt1m.h"
  1178. #include "bitmaps/player/plyrrt2.h"
  1179. #include "bitmaps/player/plyrrt2m.h"
  1180. #include "bitmaps/player/plyrup1.h"
  1181. #include "bitmaps/player/plyrup1m.h"
  1182. #include "bitmaps/player/plyrup2.h"
  1183. #include "bitmaps/player/plyrup2m.h"
  1184. #include "bitmaps/player/plyrps1.h"
  1185. #include "bitmaps/player/plyrps1m.h"
  1186. #include "bitmaps/player/plyrps2.h"
  1187. #include "bitmaps/player/plyrps2m.h"
  1188. #include "bitmaps/player/plyrsq.h"
  1189. #include "bitmaps/player/plyrsqm.h"
  1190. /*}}}*/
  1191. /*{{{  bitmaps/normal/.*/
  1192. #include "bitmaps/normal/normrt1.h"
  1193. #include "bitmaps/normal/normrt1m.h"
  1194. #include "bitmaps/normal/normrt2.h"
  1195. #include "bitmaps/normal/normrt2m.h"
  1196. #include "bitmaps/normal/normup1.h"
  1197. #include "bitmaps/normal/normup1m.h"
  1198. #include "bitmaps/normal/normup2.h"
  1199. #include "bitmaps/normal/normup2m.h"
  1200. #include "bitmaps/normal/normsq.h"
  1201. #include "bitmaps/normal/normsqm.h"
  1202. #include "bitmaps/normal/den.h"
  1203. #include "bitmaps/normal/denm.h"
  1204. /*}}}*/
  1205. /*{{{  bitmaps/munch/.*/
  1206. #include "bitmaps/munch/mnchrt1.h"
  1207. #include "bitmaps/munch/mnchrt1m.h"
  1208. #include "bitmaps/munch/mnchrt2.h"
  1209. #include "bitmaps/munch/mnchrt2m.h"
  1210. #include "bitmaps/munch/mnchup1.h"
  1211. #include "bitmaps/munch/mnchup1m.h"
  1212. #include "bitmaps/munch/mnchup2.h"
  1213. #include "bitmaps/munch/mnchup2m.h"
  1214. #include "bitmaps/munch/mnchsq.h"
  1215. #include "bitmaps/munch/mnchsqm.h"
  1216. /*}}}*/
  1217. /*{{{  bitmaps/xtra/.*/
  1218. #include "bitmaps/xtra/xtra1.h"
  1219. #include "bitmaps/xtra/xtra1m.h"
  1220. #include "bitmaps/xtra/xtra2.h"
  1221. #include "bitmaps/xtra/xtra2m.h"
  1222. #include "bitmaps/xtra/xtrasq.h"
  1223. #include "bitmaps/xtra/xtrasqm.h"
  1224. #include "bitmaps/xtra/xtrbold.h"
  1225. #include "bitmaps/xtra/xtrfaint.h"
  1226. /*}}}*/
  1227. /*{{{  bitmaps/drone/.*/
  1228. #include "bitmaps/drone/dronrt1.h"
  1229. #include "bitmaps/drone/dronrt1m.h"
  1230. #include "bitmaps/drone/dronrt2.h"
  1231. #include "bitmaps/drone/dronrt2m.h"
  1232. #include "bitmaps/drone/dronup1.h"
  1233. #include "bitmaps/drone/dronup1m.h"
  1234. #include "bitmaps/drone/dronup2.h"
  1235. #include "bitmaps/drone/dronup2m.h"
  1236. #include "bitmaps/drone/dronsq.h"
  1237. #include "bitmaps/drone/dronsqm.h"
  1238. /*}}}*/
  1239. /*{{{  bitmaps/chomp/.*/
  1240. #include "bitmaps/chomp/chmpopn.h"
  1241. #include "bitmaps/chomp/chmpopnm.h"
  1242. #include "bitmaps/chomp/chmpcls.h"
  1243. #include "bitmaps/chomp/chmpclsm.h"
  1244. /*}}}*/
  1245. /*{{{  bitmaps/prize/.*/
  1246. #include "bitmaps/prize/cake.h"
  1247. #include "bitmaps/prize/cakem.h"
  1248. #include "bitmaps/prize/spanner.h"
  1249. #include "bitmaps/prize/spannerm.h"
  1250. #include "bitmaps/prize/brolly.h"
  1251. #include "bitmaps/prize/brollym.h"
  1252. #include "bitmaps/prize/mushrm.h"
  1253. #include "bitmaps/prize/mushrmm.h"
  1254. #include "bitmaps/prize/clock.h"
  1255. #include "bitmaps/prize/clockm.h"
  1256. /*}}}*/
  1257. /*}}}*/
  1258. #define XTRA_LETTER_X   ((xtra1_x_hot + xtra2_x_hot) >> 1)
  1259. #define XTRA_LETTER_Y   ((xtra1_y_hot + xtra2_y_hot) >> 1)
  1260. static unsigned long const colour_zero = 0;
  1261. static unsigned long const colour_one = ~0;
  1262. /*{{{  typedef struct Context*/
  1263. typedef struct Context
  1264. /* GC definer */
  1265. {
  1266. X  int       function;         /* graphics function */
  1267. X  unsigned long const *fgp;   /* foreground colour pointer */
  1268. X  unsigned long const *bgp;   /* background colour pointer */
  1269. } CONTEXT;
  1270. /*}}}*/
  1271. /*{{{  gcsdefine*/
  1272. static CONTEXT gcsdefine[GCS] =
  1273. {
  1274. X    {GXcopy,        &colour_one,    &colour_zero},
  1275. X    {GXcopy,        &display.white, &colour_zero},
  1276. X    {GXcopy,        &display.black, &colour_zero},
  1277. X    {GXandInverted, &colour_one,    &colour_zero},
  1278. X    {GXor,          &colour_one,    &colour_zero},
  1279. X    {GXor,          &display.white, &colour_zero},
  1280. X    {GXxor,         &display.xor,   &colour_zero},
  1281. X    {GXcopy,        &display.black, &display.white},
  1282. X    {GXand,         &colour_one,    &colour_zero},
  1283. X    {GXcopy,        &display.black, &display.white},
  1284. };
  1285. /*}}}*/
  1286. /*{{{  tables*/
  1287. /*{{{  ARG const args[] =*/
  1288. ARG const args[] =
  1289. {
  1290. X  {"help",    1, &flags.help,     "This help"},
  1291. X  {"display",-1, &display.name,   "Display to run on"},
  1292. X  {"font",   -1, &font.name,      "Font name"},
  1293. X  {"rv",      1, &flags.reverse,  "Reverse video"},
  1294. X  {"bw",      1, &flags.bw,       "Force black and white"},
  1295. X  {"iconic",  1, &flags.iconic,   "Start iconic"},
  1296. X  {"mris",    0, &flags.gender,   "Male version"},
  1297. X  {"msit",    1, &flags.gender,   "Female version"},
  1298. X  {NULL}
  1299. };
  1300. /*}}}*/
  1301. /*{{{  SPRITE sprites[] =*/
  1302. SPRITE sprites[] =
  1303. {
  1304. X  /*{{{  2:center masks (oblong, rect)*/
  1305. X  {NULL, oblong_bits, oblong_width, oblong_height, {CELL_WIDTH, CELL_HEIGHT}},
  1306. X  {NULL, rect_bits, rect_width, rect_height, {CELL_WIDTH, CELL_HEIGHT}},
  1307. X  /*}}}*/
  1308. X  /*{{{  2:munch masks (tb,lr)*/
  1309. X  {NULL, munchtb_bits, munchtb_width, munchtb_height, {CELL_WIDTH, MUNCH_HEIGHT}},
  1310. X  {NULL, munchlr_bits, munchlr_width, munchlr_height, {MUNCH_WIDTH, CELL_HEIGHT}},
  1311. X  /*}}}*/
  1312. X  /*{{{  2:edge masks (tb, lr)*/
  1313. X  {NULL, edgetb_bits, edgetb_width, edgetb_height, {GAP_WIDTH * 5, EDGE_HEIGHT}},
  1314. X  {NULL, edgelr_bits, edgelr_width, edgelr_height, {EDGE_WIDTH, GAP_HEIGHT * 5}},
  1315. X  /*}}}*/
  1316. X  /*{{{  4:fills (0,1,2,3)*/
  1317. X  {fill0_bits, NULL, fill0_width, fill0_height, {0, 0}},
  1318. X  {fill1_bits, NULL, fill1_width, fill1_height, {0, 0}},
  1319. X  {fill2_bits, NULL, fill2_width, fill2_height, {0, 0}},
  1320. X  {fill3_bits, NULL, fill3_width, fill3_height, {0, 0}},
  1321. X  /*}}}*/
  1322. X  /*{{{  1:digits (0,1,2,3,4,5,6,7,8,9,' ')*/
  1323. X  {digits_bits, digitsm_bits, digits_width, digits_height, {DIGIT_WIDTH * 11, DIGIT_HEIGHT}},
  1324. X  /*}}}*/
  1325. X  /*{{{  1:cherry*/
  1326. X  {cherry_bits, cherrym_bits, cherry_width, cherry_height, {CELL_WIDTH, CELL_HEIGHT}},
  1327. X  /*}}}*/
  1328. X  /*{{{  1:den*/
  1329. X  {den_bits, denm_bits, den_width, den_height, {CELL_WIDTH, CELL_HEIGHT}},
  1330. X  /*}}}*/
  1331. X  /*{{{  1:ball*/
  1332. X  {ball_bits, ball_bits, ball_width, ball_height, {BALL_WIDTH, BALL_HEIGHT}},
  1333. X  /*}}}*/
  1334. X  /*{{{  6:apples (apple, rock, apple, split, decay, rot)*/
  1335. X  {apple_bits, applem_bits, apple_width, apple_height, {CELL_WIDTH, CELL_HEIGHT}},
  1336. X  {rock_bits,  rockm_bits,  rock_width,  rock_height,  {CELL_WIDTH, CELL_HEIGHT}},
  1337. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_APPLE, 0},
  1338. X  {split_bits, splitm_bits, split_width, split_height, {CELL_WIDTH, CELL_HEIGHT}},
  1339. X  {decay_bits, decaym_bits, decay_width, decay_height, {DECAY_WIDTH, DECAY_HEIGHT}},
  1340. X  {rot_bits,   rotm_bits,   rot_width,   rot_height, {ROT_WIDTH, ROT_HEIGHT}},
  1341. X  /*}}}*/
  1342. X  /*{{{  2:extra (bold, faint)*/
  1343. X  {xtrbold_bits,  xtrbold_bits, xtrbold_width,  xtrbold_height, {CELL_WIDTH / 2 * 5, CELL_HEIGHT / 2}},
  1344. X  {xtrfaint_bits, xtrbold_bits, xtrfaint_width, xtrfaint_height, {CELL_WIDTH / 2 * 5, CELL_HEIGHT / 2}},
  1345. X  /*}}}*/
  1346. X  /*{{{  2:xtra source*/
  1347. X  {xtra1_bits, xtra1m_bits, xtra1_width, xtra1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1348. X  {xtra2_bits, xtra2m_bits, xtra2_width, xtra2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1349. X  /*}}}*/
  1350. X  /*{{{  12:normal (ul, dr, l, r, ur, dl)*/
  1351. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_NORMAL + 8, 1},
  1352. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_NORMAL + 9, 1},
  1353. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_NORMAL + 8, 2},
  1354. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_NORMAL + 9, 2},
  1355. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_NORMAL + 6, 1},
  1356. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_NORMAL + 7, 1},
  1357. X  {normrt1_bits, normrt1m_bits, normrt1_width, normrt1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1358. X  {normrt2_bits, normrt2m_bits, normrt2_width, normrt2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1359. X  {normup1_bits, normup1m_bits, normup1_width, normup1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1360. X  {normup2_bits, normup2m_bits, normup2_width, normup1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1361. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_NORMAL + 0, 2},
  1362. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_NORMAL + 1, 2},
  1363. X  /*}}}*/
  1364. X  /*{{{  12:muncher (ul, dr, l, r, ur, dl)*/
  1365. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_MUNCHER + 8, 1},
  1366. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_MUNCHER + 9, 1},
  1367. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_MUNCHER + 8, 2},
  1368. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_MUNCHER + 9, 2},
  1369. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_MUNCHER + 6, 1},
  1370. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_MUNCHER + 7, 1},
  1371. X  {mnchrt1_bits, mnchrt1m_bits, mnchrt1_width, mnchrt1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1372. X  {mnchrt2_bits, mnchrt2m_bits, mnchrt2_width, mnchrt2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1373. X  {mnchup1_bits, mnchup1m_bits, mnchup1_width, mnchup1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1374. X  {mnchup2_bits, mnchup2m_bits, mnchup2_width, mnchup2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1375. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_MUNCHER + 0, 2},
  1376. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_MUNCHER + 1, 2},
  1377. X  /*}}}*/
  1378. X  /*{{{  12:xtra (ul, dr, l, r, ur, dl)*/
  1379. X  {xtra1_bits, xtra1m_bits, xtra1_width, xtra1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1380. X  {xtra2_bits, xtra2m_bits, xtra2_width, xtra2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1381. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 0, 0},
  1382. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 1, 0},
  1383. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 0, 0},
  1384. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 1, 0},
  1385. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 0, 0},
  1386. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 1, 0},
  1387. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 0, 0},
  1388. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 1, 0},
  1389. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 0, 0},
  1390. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_XTRA + 1, 0},
  1391. X  /*}}}*/
  1392. X  /*{{{  12:drone (ul, dr, l, r, ur, dl)*/
  1393. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_DRONE + 8, 1},
  1394. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_DRONE + 9, 1},
  1395. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_DRONE + 8, 2},
  1396. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_DRONE + 9, 2},
  1397. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_DRONE + 6, 1},
  1398. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_DRONE + 7, 1},
  1399. X  {dronrt1_bits, dronrt1m_bits, dronrt1_width, dronrt1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1400. X  {dronrt2_bits, dronrt2m_bits, dronrt2_width, dronrt2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1401. X  {dronup1_bits, dronup1m_bits, dronup1_width, dronup1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1402. X  {dronup2_bits, dronup2m_bits, dronup2_width, dronup2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1403. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_DRONE + 0, 2},
  1404. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_DRONE + 1, 2},
  1405. X  /*}}}*/
  1406. X  /*{{{  12:player (ul, dr, l, r, ur, dl)*/
  1407. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 8, 1},
  1408. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 9, 1},
  1409. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 8, 2},
  1410. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 9, 2},
  1411. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 6, 1},
  1412. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 7, 1},
  1413. X  {plyrrt1_bits, plyrrt1m_bits, plyrrt1_width, plyrrt1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1414. X  {plyrrt2_bits, plyrrt2m_bits, plyrrt2_width, plyrrt2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1415. X  {plyrup1_bits, plyrup1m_bits, plyrup1_width, plyrup1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1416. X  {plyrup2_bits, plyrup2m_bits, plyrup2_width, plyrup2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1417. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 0, 2},
  1418. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 1, 2},
  1419. X  /*}}}*/
  1420. X  /*{{{  4:player push (l, r)*/
  1421. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER_PUSH + 2, 1},
  1422. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER_PUSH + 3, 1},
  1423. X  {plyrps1_bits, plyrps1m_bits, plyrps1_width, plyrps1_height, {CELL_WIDTH, CELL_HEIGHT}},
  1424. X  {plyrps2_bits, plyrps2m_bits, plyrps2_width, plyrps2_height, {CELL_WIDTH, CELL_HEIGHT}},
  1425. X  /*}}}*/
  1426. X  /*{{{  2:player dead (l, r)*/
  1427. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 4, 2},
  1428. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_PLAYER + 6, 2},
  1429. X  /*}}}*/
  1430. X  /*{{{  10:squished*/
  1431. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_SQUISHED + 1, 1},
  1432. X  {normsq_bits, normsqm_bits, normsq_width, normsq_height, {CELL_WIDTH, CELL_HEIGHT / 4}},
  1433. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_SQUISHED + 3, 1},
  1434. X  {mnchsq_bits, mnchsqm_bits, mnchsq_width, mnchsq_height, {CELL_WIDTH, CELL_HEIGHT / 4}},
  1435. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_SQUISHED + 5, 0},
  1436. X  {xtrasq_bits, xtrasqm_bits, xtrasq_width, xtrasq_height, {CELL_WIDTH, CELL_HEIGHT / 4}},
  1437. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_SQUISHED + 7, 1},
  1438. X  {dronsq_bits, dronsqm_bits, dronsq_width, dronsq_height, {CELL_WIDTH, CELL_HEIGHT / 4}},
  1439. X  {NULL, NULL, 0, 0, {0, 0}, SPRITE_SQUISHED + 9, 1},
  1440. X  {plyrsq_bits, plyrsqm_bits, plyrsq_width, plyrsq_height, {CELL_WIDTH, CELL_HEIGHT / 4}},
  1441. X  /*}}}*/
  1442. X  /*{{{  2:chomp (open, closed)*/
  1443. X  {chmpopn_bits, chmpopnm_bits, chmpopn_width, chmpopn_height, {CELL_WIDTH, CELL_HEIGHT}},
  1444. X  {chmpcls_bits, chmpclsm_bits, chmpcls_width, chmpcls_height, {CELL_WIDTH, CELL_HEIGHT}},
  1445. X  /*}}}*/
  1446. X  /*{{{  8:m r i s*/
  1447. X  {solidm_bits, bigm_bits, solidm_width, solidm_height, {CELL_WIDTH, CELL_HEIGHT}},
  1448. X  {solidr_bits, bigr_bits, solidr_width, solidr_height, {CELL_WIDTH, CELL_HEIGHT}},
  1449. X  {solidi_bits, bigi_bits, solidi_width, solidi_height, {CELL_WIDTH, CELL_HEIGHT}},
  1450. X  {solids_bits, bigs_bits, solids_width, solids_height, {CELL_WIDTH, CELL_HEIGHT}},
  1451. X  {shellm_bits, bigm_bits, shellm_width, shellm_height, {CELL_WIDTH, CELL_HEIGHT}},
  1452. X  {shellr_bits, bigr_bits, shellr_width, shellr_height, {CELL_WIDTH, CELL_HEIGHT}},
  1453. X  {shelli_bits, bigi_bits, shelli_width, shelli_height, {CELL_WIDTH, CELL_HEIGHT}},
  1454. X  {shells_bits, bigs_bits, shells_width, shells_height, {CELL_WIDTH, CELL_HEIGHT}},
  1455. X  /*}}}*/
  1456. X  /*{{{  5:prizes*/
  1457. X  {cake_bits,    cakem_bits,    cake_width,    cake_height,    {CELL_WIDTH, CELL_HEIGHT}},
  1458. X  {spanner_bits, spannerm_bits, spanner_width, spanner_height, {CELL_WIDTH, CELL_HEIGHT}},
  1459. X  {brolly_bits,  brollym_bits,  brolly_width,  brolly_height,  {CELL_WIDTH, CELL_HEIGHT}},
  1460. X  {mushrm_bits,  mushrmm_bits,  mushrm_width,  mushrm_height,  {CELL_WIDTH, CELL_HEIGHT}},
  1461. X  {clock_bits,   clockm_bits,   clock_width,   clock_height,   {CELL_WIDTH, CELL_HEIGHT}},
  1462. X  /*}}}*/
  1463. };
  1464. /*}}}*/
  1465. /*{{{  static SPRITE spritet[2] =*/
  1466. static SPRITE spritet[2] =
  1467. {
  1468. X  {solidt_bits, bigt_bits, solidt_width, solidt_height, {CELL_WIDTH, CELL_HEIGHT}},
  1469. X  {shellt_bits, bigt_bits, shellt_width, shellt_height, {CELL_WIDTH, CELL_HEIGHT}},
  1470. };
  1471. /*}}}*/
  1472. /*{{{  static SPRITE icons[2] =*/
  1473. static SPRITE icons[2] =
  1474. {
  1475. X  {NULL, mris_bits, mris_width, mris_height},
  1476. X  {NULL, msit_bits, msit_width, msit_height},
  1477. };
  1478. /*}}}*/
  1479. /*{{{  APPLE_SIZE const apple_sizes[6] =*/
  1480. APPLE_SIZE const apple_sizes[6] =
  1481. X  {
  1482. X    {{CELL_WIDTH, CELL_HEIGHT}, {0, 0}},
  1483. X    {{CELL_WIDTH, CELL_HEIGHT}, {0, 0}},
  1484. X    {{CELL_WIDTH, CELL_HEIGHT}, {0, 0}},
  1485. X    {{CELL_WIDTH, CELL_HEIGHT}, {0, 0}},
  1486. X    {{DECAY_WIDTH, DECAY_HEIGHT},
  1487. X      {(CELL_WIDTH - DECAY_WIDTH) / 2, CELL_HEIGHT - DECAY_HEIGHT}},
  1488. X    {{ROT_WIDTH, ROT_HEIGHT},
  1489. X      {(CELL_WIDTH - ROT_WIDTH) / 2, CELL_HEIGHT - ROT_HEIGHT}},
  1490. X  };
  1491. /*}}}*/
  1492. /*{{{  BOARD const boards[10] =*/
  1493. #if BOARDS != 10
  1494. X  #error BOARDS != 10
  1495. #endif
  1496. /*
  1497. X * the initial board maps are stored as character arrays
  1498. X * X for a path
  1499. X * @ for cherry
  1500. X */
  1501. BOARD const boards[BOARDS] =
  1502. X  {
  1503. X    /*{{{  board 0*/
  1504. X    {
  1505. X      0,
  1506. X      {
  1507. X    "..XXXXXXXX..",
  1508. X    ".XX......XX.",
  1509. X    "XXXX......XX",
  1510. X    "X..XX..@@@@X",
  1511. X    "X...XX.@@@@X",
  1512. X    "X@@@@X.....X",
  1513. X    "X@@@@X...@@X",
  1514. X    "X....XX..@@X",
  1515. X    "X@@@@.XX.@@X",
  1516. X    "X@@@@..XX@@X",
  1517. X    "XX..@@@@XXXX",
  1518. X    ".XX.@@@@.XX.",
  1519. X    "..XXXXXXXX..",
  1520. X      }
  1521. X    },
  1522. X    /*}}}*/
  1523. X    /*{{{  board 1*/
  1524. X    {
  1525. X      0,
  1526. X      {
  1527. X    "....XXXXXX..",
  1528. X    "@@...X...XX.",
  1529. X    "@@...X@@@@XX",
  1530. X    "@@.@@X@@@@.X",
  1531. X    "@@.@@X.....X",
  1532. X    "...@@X.....X",
  1533. X    "...@@X..@@.X",
  1534. X    ".....X..@@.X",
  1535. X    "@@@@.X..@@.X",
  1536. X    "@@@@.X..@@.X",
  1537. X    "XXX..X....XX",
  1538. X    "X.X..X...XX.",
  1539. X    "XXXXXXXXXX..",
  1540. X      }
  1541. X    },
  1542. X    /*}}}*/
  1543. X    /*{{{  board 2*/
  1544. X    {
  1545. X      1,
  1546. X      {
  1547. X    "..XXXXXXXX..",
  1548. X    ".XX......XX.",
  1549. X    "XX@@@@....XX",
  1550. X    "X.@@@@..@@.X",
  1551. X    "........@@.X",
  1552. X    "@@......@@.X",
  1553. X    "@@...X..@@XX",
  1554. X    "@@...XXXXXX.",
  1555. X    "@@.XXX....@@",
  1556. X    ".XXX@@@@..@@",
  1557. X    "XX..@@@@..@@",
  1558. X    "X.........@@",
  1559. X    "XXXXXXXXXXXX",
  1560. X      }
  1561. X    },
  1562. X    /*}}}*/
  1563. X    /*{{{  board 3*/
  1564. X    {
  1565. X      2,
  1566. X      {
  1567. X    "..XXXXXXXX..",
  1568. X    ".XX......XX.",
  1569. X    "XX........XX",
  1570. X    "X..@@@@.@@.X",
  1571. X    "@@.@@@@.@@.X",
  1572. X    "@@......@@.X",
  1573. X    "@@...X..@@XX",
  1574. X    "@@..XXXXXXX.",
  1575. X    "...@@.....XX",
  1576. X    "...@@..@@@@X",
  1577. X    "X..@@..@@@@X",
  1578. X    "XX.@@.....XX",
  1579. X    ".XXXXXXXXXX.",
  1580. X      }
  1581. X    },
  1582. X    /*}}}*/
  1583. X    /*{{{  board 4*/
  1584. X    {
  1585. X      2,
  1586. X      {
  1587. X    "....XXXXXX..",
  1588. X    "@@@@X....X..",
  1589. X    "@@@@X....X@@",
  1590. X    "...XX....X@@",
  1591. X    "@@.X...@@X@@",
  1592. X    "@@XX...@@X@@",
  1593. X    "@@X..X.@@X..",
  1594. X    "@@XXXX.@@X..",
  1595. X    "XXX......X..",
  1596. X    "X........X..",
  1597. X    "XXXXXXXXXXXX",
  1598. X    ".@@@@....X..",
  1599. X    ".@@@@XXXXX..",
  1600. X      }
  1601. X    },
  1602. X    /*}}}*/
  1603. X    /*{{{  board 5*/
  1604. X    {
  1605. X      2,
  1606. X      {
  1607. X    "XXXXXXXXXXXX",
  1608. X    "X...........",
  1609. X    "X.@@@@......",
  1610. X    "X.@@@@..@@@@",
  1611. X    "X.......@@@@",
  1612. X    "XXXXXXXXXXX.",
  1613. X    "....XXX...XX",
  1614. X    ".@@.XXX..@@X",
  1615. X    ".@@......@@X",
  1616. X    ".@@.@@@@.@@X",
  1617. X    "X@@.@@@@.@@X",
  1618. X    "XX........XX",
  1619. X    ".XXXXXXXXXX.",
  1620. X      }
  1621. X    },
  1622. X    /*}}}*/
  1623. X    /*{{{  board 6*/
  1624. X    {
  1625. X      2,
  1626. X      {
  1627. X    "..XXXXXXXXXX",
  1628. X    ".XX.........",
  1629. X    "XX..........",
  1630. X    "X.@@.@@@@.@@",
  1631. X    "X.@@.@@@@.@@",
  1632. X    "X.@@......@@",
  1633. X    "X.@@.X....@@",
  1634. X    "XXXXXXXXXXX.",
  1635. X    "X.........XX",
  1636. X    "X@@@@......X",
  1637. X    "X@@@@.@@@@.X",
  1638. X    "XX....@@@@XX",
  1639. X    ".XXXXXXXXXX.",
  1640. X      }
  1641. X    },
  1642. X    /*}}}*/
  1643. X    /*{{{  board 7*/
  1644. X    {
  1645. X      3,
  1646. X      {
  1647. X    "XXXXXXXXXXXX",
  1648. X    "X..........X",
  1649. X    ".@@.......XX",
  1650. X    ".@@.@@@@.XX.",
  1651. X    ".@@.@@@@XX..",
  1652. X    ".@@....XX.@@",
  1653. X    ".....XXX..@@",
  1654. X    ".....XX...@@",
  1655. X    "@@@@.X.@@.@@",
  1656. X    "@@@@.X.@@...",
  1657. X    ".....X.@@...",
  1658. X    ".....X.@@...",
  1659. X    ".....X......",
  1660. X      }
  1661. X    },
  1662. X    /*}}}*/
  1663. X    /*{{{  board 8*/
  1664. X    {
  1665. X      3,
  1666. X      {
  1667. X    "..XXXXXXXX..",
  1668. X    ".XX......XX.",
  1669. X    "XX@@.@@.@@XX",
  1670. X    "X.@@.@@.@@.X",
  1671. X    "X.@@.@@.@@.X",
  1672. X    "XX@@.@@.@@XX",
  1673. X    ".XX..X...XX.",
  1674. X    "..XXXXXXXX..",
  1675. X    "XXX......XXX",
  1676. X    "X@@@@......X",
  1677. X    "X@@@@.@@@@.X",
  1678. X    "XX....@@@@XX",
  1679. X    ".XXXXXXXXXX.",
  1680. X      }
  1681. X    },
  1682. X    /*}}}*/
  1683. X    /*{{{  board 9*/
  1684. X    {
  1685. X      3,
  1686. X      {
  1687. X    "..XXXXXXXX..",
  1688. X    ".XX......XX.",
  1689. X    "XX...@@@@.XX",
  1690. X    "X.@@.@@@@..X",
  1691. X    "X.@@.......X",
  1692. X    "X.@@...@@@@X",
  1693. X    "XX@@.X.@@@@X",
  1694. X    ".XXXXXXXXXXX",
  1695. X    "@@.........X",
  1696. X    "@@....@@@@.X",
  1697. X    "@@....@@@@XX",
  1698. X    "@@.......XX.",
  1699. X    "XXXXXXXXXX..",
  1700. X      }
  1701. X    },
  1702. X    /*}}}*/
  1703. X  };
  1704. /*}}}*/
  1705. char keystrokes[5] = {'\'', '/', 'z', 'x', ' '};
  1706. /*{{{  COORD const ball_hold[16] =*/
  1707. /*{{{  held ball offsets*/
  1708. #define PLAYER_RIGHT1_BALL_X   (plyrrt1_x_hot - CELL_WIDTH / 2)
  1709. #define PLAYER_RIGHT1_BALL_Y   (plyrrt1_y_hot - CELL_HEIGHT / 2)
  1710. #define PLAYER_UP1_BALL_X      (plyrup1_x_hot - CELL_WIDTH / 2)
  1711. #define PLAYER_UP1_BALL_Y      (plyrup1_y_hot - CELL_HEIGHT / 2)
  1712. #define PLAYER_RIGHT2_BALL_X   (plyrrt2_x_hot - CELL_WIDTH / 2)
  1713. #define PLAYER_RIGHT2_BALL_Y   (plyrrt2_y_hot - CELL_HEIGHT / 2)
  1714. #define PLAYER_UP2_BALL_X      (plyrup2_x_hot - CELL_WIDTH / 2)
  1715. #define PLAYER_UP2_BALL_Y      (plyrup2_y_hot - CELL_HEIGHT / 2)
  1716. #define PLAYER_PUSH1_BALL_X    (plyrps1_x_hot - CELL_WIDTH / 2)
  1717. #define PLAYER_PUSH1_BALL_Y    (plyrps1_y_hot - CELL_HEIGHT / 2)
  1718. #define PLAYER_PUSH2_BALL_X    (plyrps2_x_hot - CELL_WIDTH / 2)
  1719. #define PLAYER_PUSH2_BALL_Y    (plyrps2_y_hot - CELL_HEIGHT / 2)
  1720. /*}}}*/
  1721. COORD const ball_hold[16] =
  1722. {
  1723. X {-PLAYER_UP1_BALL_X - BALL_WIDTH / 2,  PLAYER_UP1_BALL_Y - BALL_HEIGHT / 2},
  1724. SHAR_EOF
  1725. true || echo 'restore of create.c failed'
  1726. fi
  1727. echo 'End of  part 2'
  1728. echo 'File create.c is continued in part 3'
  1729. echo 3 > _shar_seq_.tmp
  1730. exit 0
  1731. -- 
  1732. ---
  1733. Senior Systems Scientist        mail: dcmartin@msi.com
  1734. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  1735. 796 North Pastoria Avenue        at&t: 408/522-9236
  1736.