home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume18 / xmris / patch1 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  13.9 KB

  1. Path: uunet!ogicse!uwm.edu!caen!sdd.hp.com!mips!msi!dcmartin
  2. From: fred@gna.axis-design.fr (Frederic Cirera)
  3. Newsgroups: comp.sources.x
  4. Subject: v18i059: Xmris, Patch1, Part01/01
  5. Message-ID: <1992Jul23.150715.27775@msi.com>
  6. Date: 23 Jul 92 15:07:15 GMT
  7. Article-I.D.: msi.1992Jul23.150715.27775
  8. References: <csx-18i059-xmris@uunet.UU.NET>
  9. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  10. Organization: Molecular Simulations, Inc.
  11. Lines: 503
  12. Approved: dcmartin@msi.com
  13. Originator: dcmartin@fascet
  14.  
  15. Submitted-by: fred@gna.axis-design.fr (Frederic Cirera)
  16. Posting-number: Volume 18, Issue 59
  17. Archive-name: xmris/patch1
  18. Patch-To: xmris: Volume 18, Issue 22-30
  19.  
  20.     patch01 for Xrmis game.
  21.     replace z x ' / keys by arrows
  22.  
  23. #!/bin/sh
  24. # This is a shell archive (produced by shar 3.50)
  25. # To extract the files from this archive, save it to a file, remove
  26. # everything above the "!/bin/sh" line above, and type "sh file_name".
  27. #
  28. # made 07/23/1992 15:05 UTC by dcmartin@fascet
  29. # Source directory /home/fascet/dcmartin/csx/src
  30. #
  31. # existing files will NOT be overwritten unless -c is specified
  32. #
  33. #                                                                          
  34. #                                                                          
  35. #
  36. # This shar contains:
  37. # length  mode       name
  38. # ------ ---------- ------------------------------------------
  39. #  12010 -rw-r--r-- patch-1
  40. #
  41. if test -r _shar_seq_.tmp; then
  42.     echo 'Must unpack archives in sequence!'
  43.     echo Please unpack part `cat _shar_seq_.tmp` next
  44.     exit 1
  45. fi
  46. # ============= patch-1 ==============
  47. if test -f 'patch-1' -a X"$1" != X"-c"; then
  48.     echo 'x - skipping patch-1 (File already exists)'
  49.     rm -f _shar_wnt_.tmp
  50. else
  51. > _shar_wnt_.tmp
  52. echo 'x - extracting patch-1 (Text)'
  53. sed 's/^X//' << 'SHAR_EOF' > 'patch-1' &&
  54. *** create.c    Tue Jul 21 14:40:28 1992
  55. --- ../create.c    Tue Jul 21 14:23:01 1992
  56. ***************
  57. *** 18,23 ****
  58. --- 18,24 ----
  59. X  /*}}}*/
  60. X  #define EXTERN
  61. X  #include "xmris.h"
  62. + #include <X11/keysym.h>
  63. X  /*{{{  bitmaps*/
  64. X  /*{{{  bitmaps/icon/.*/
  65. X  #include "bitmaps/icon/mris.h"
  66. ***************
  67. *** 599,605 ****
  68. X      /*}}}*/
  69. X    };
  70. X  /*}}}*/
  71. ! char keystrokes[5] = {'\'', '/', 'z', 'x', ' '};
  72. X  /*{{{  COORD const ball_hold[16] =*/
  73. X  /*{{{  held ball offsets*/
  74. X  #define PLAYER_RIGHT1_BALL_X   (plyrrt1_x_hot - CELL_WIDTH / 2)
  75. --- 600,607 ----
  76. X      /*}}}*/
  77. X    };
  78. X  /*}}}*/
  79. ! /* char keystrokes[5] = {'\'', '/', 'z', 'x', ' '}; */
  80. ! KeySym keystrokes[5] = { XK_Up, XK_Down, XK_Left, XK_Right, XK_space};
  81. X  /*{{{  COORD const ball_hold[16] =*/
  82. X  /*{{{  held ball offsets*/
  83. X  #define PLAYER_RIGHT1_BALL_X   (plyrrt1_x_hot - CELL_WIDTH / 2)
  84. ***************
  85. *** 671,677 ****
  86. X  #else
  87. X      "                           ", /* should be enough space */
  88. X  #endif
  89. !     "Z - Left", "X - Right", "' - Up", "/ - Down", "Space - Throw",
  90. X      "Or use the mouse", "P - Pause", "Q - Quit",
  91. X      "Press a key or button to start", NULL
  92. X    };
  93. --- 673,679 ----
  94. X  #else
  95. X      "                           ", /* should be enough space */
  96. X  #endif
  97. !     "Left arrow - Left", "Right arrow - Right", "Up arrow - Up", "Down arrow - Down", "Space - Throw",
  98. X      "Or use the mouse", "P - Pause", "Q - Quit",
  99. X      "Press a key or button to start", NULL
  100. X    };
  101. No differences encountered
  102. No differences encountered
  103. No differences encountered
  104. No differences encountered
  105. No differences encountered
  106. No differences encountered
  107. *** timer.c    Tue Jul 21 14:40:33 1992
  108. --- ../timer.c    Mon Jul 20 14:51:20 1992
  109. ***************
  110. *** 20,25 ****
  111. --- 20,26 ----
  112. X  #include <time.h>
  113. X  #include <sys/time.h>
  114. X  #include <signal.h>
  115. + #define    sigmask(n)        ((unsigned long)1 << ((n) - 1))
  116. X  /*{{{  timer*/
  117. X  static struct
  118. X  {
  119. *** xmris.c    Tue Jul 21 14:40:34 1992
  120. --- ../xmris.c    Tue Jul 21 14:27:51 1992
  121. ***************
  122. *** 609,778 ****
  123. X  extern int process_xevents FUNCARGLIST((pausable))
  124. X  int     pausable  FUNCARGTERM
  125. X  {
  126. !   int       quit;
  127. !   int       paused;
  128. !   player.motionevent = 0;
  129. !   quit = 0;
  130. !   paused = 0;
  131. !   /*{{{  read the events*/
  132. !   while(QLength(display.display) || paused)
  133. !     {
  134. !       XEvent    event;
  135. X      
  136. !       XNextEvent(display.display, &event);
  137. !       if(event.xany.window != display.window)
  138. !     continue;
  139. !       switch (event.type)
  140. !       {
  141. !     /*{{{  case KeyPress:*/
  142. !     case KeyPress:
  143. !     /*
  144. !      * When a key is pressed, we check to see if it is
  145. !      * a control key. If so, then we set the relevant pressed bit.
  146. !      */
  147. !     {
  148. !       char      chr;
  149. !       KeySym    symbol;
  150. !       XComposeStatus status;
  151. !                       
  152. !       XLookupString(&event.xkey, &chr, 1, &symbol, &status);
  153. !       if(isupper(chr))
  154. !         chr = tolower(chr);
  155. !       if(chr == 'p' && pausable)
  156. !         paused++;
  157. !       else if(paused && chr == ' ')
  158. !         player.motionevent = paused = 0;
  159. !       else if((paused || !pausable) && chr == 'q')
  160. !         {
  161. !           paused = 0;
  162. !           quit = 1;
  163. !         }
  164. !       else if(global.state > 5)
  165. !         player.keyboard = player.button = 1;
  166. !       else if(!paused && player.keyboard)
  167. !         {
  168. !           int       index;
  169. X                      
  170. !           for(index = 5; index--;)
  171. !         if(chr == keystrokes[index])
  172. !           {
  173. !             if(index == 4)
  174. !               player.button = 1;
  175. !             else
  176. !               player.pressed |= 1 << index;
  177. !             break;
  178. !           }
  179. !         }
  180. !       break;
  181. !     }
  182. X      /*}}}*/
  183. !     /*{{{  case KeyRelease:*/
  184. !     case KeyRelease:
  185. !     /*
  186. !      * when a key is released, we check to see if it is
  187. !      * the controlling direction key. If so, then we stop
  188. !      */
  189. !     {
  190. !       if(player.keyboard)
  191. !         {
  192. !           char      chr;
  193. !           KeySym    symbol;
  194. !           XComposeStatus status;
  195. !           unsigned  index;
  196. !                         
  197. !           XLookupString(&event.xkey, &chr, 1, &symbol, &status);
  198. !           if(isupper(chr))
  199. !         chr = tolower(chr);
  200. !           for(index = 5; index--;)
  201. !         if(chr == keystrokes[index])
  202. !           {
  203. !             if(index == 4)
  204. !               player.button = 0;
  205. !             else
  206. !               player.pressed &= ~(1 << index);
  207. !             break;
  208. !           }
  209. !           break;
  210. !         }
  211. !     }
  212. !     /*}}}*/
  213. !     /*{{{  case MotionNotify:*/
  214. !     case MotionNotify:
  215. !     /*
  216. !      * for mouse motion, we save the coordinate and process the
  217. !      * final one only
  218. !      */
  219. !     {
  220. !       player.raw_mouse.x = event.xmotion.x;
  221. !       player.raw_mouse.y = event.xmotion.y;
  222. !       player.motionevent = 1;
  223. !       break;
  224. !     }
  225. !     /*}}}*/
  226. !     /*{{{  case ButtonPress:*/
  227. !     case ButtonPress:
  228. !       if(!player.keyboard)
  229. !         player.button = 1;
  230. !       break;
  231. !     /*}}}*/
  232. !     /*{{{  case ButtonRelease:*/
  233. !     case ButtonRelease:
  234. !       if(!player.keyboard && player.throw)
  235. !         player.button = 0;
  236. !       break;
  237. !     /*}}}*/
  238. !     /*{{{  case Expose:*/
  239. !     case Expose:
  240. !       refresh_window();
  241. !       break;
  242. !     /*}}}*/
  243. !     /*{{{  case UnmapNotify:*/
  244. !     case UnmapNotify:
  245. !       paused++;
  246. !       break;
  247. !     /*}}}*/
  248. !     /*{{{  case MapNotify:*/
  249. !     case MapNotify:
  250. !       if(!pausable)
  251. !         paused = 0;
  252. !       break;
  253. !     /*}}}*/
  254. !     /*{{{  case PropertyNotify:*/
  255. !     case PropertyNotify:
  256. !       if(event.xproperty.atom == display.DEC_icon_atom)
  257. !         paused++;
  258. !       break;
  259. !     /*}}}*/
  260. !     default:
  261. !       break;
  262. !       }
  263. !       /*{{{  started to pause?*/
  264. !       if(paused == 1)
  265. !     {
  266. !       char const *text = "Space to continue, Q to quit";
  267. !       TEXT      info;
  268. !       unsigned  length;
  269. !         
  270. !       paused++;
  271. !       length = strlen(text);
  272. !       text_size(text, length, &info);
  273. !       add_background(0, PIXELY(CELLS_DOWN, 0), WINDOW_WIDTH, CELL_HEIGHT);
  274. !       XFillRectangle(display.display, display.copy, GCN(GC_CLEAR),
  275. !           0, PIXELY(CELLS_DOWN, 0), WINDOW_WIDTH, CELL_HEIGHT);
  276. !       XDrawImageString(display.display, display.copy, GCN(GC_TEXT),
  277. !           WINDOW_WIDTH / 2 - info.width / 2,
  278. !           PIXELY(CELLS_DOWN, CELL_HEIGHT / 2) +
  279. !           (info.ascent - info.descent) / 2, text, length);
  280. !       XCopyArea(display.display, display.copy, display.window, GCN(GC_COPY),
  281. !           0, PIXELY(CELLS_DOWN, 0), WINDOW_WIDTH, CELL_HEIGHT,
  282. !           0, PIXELY(CELLS_DOWN, 0));
  283. !       XSync(display.display, False);
  284. !     }
  285. !       /*}}}*/
  286. !     }
  287. !   /*}}}*/
  288. !   return quit;
  289. X  }
  290. X  /*}}}*/
  291. X  /*{{{  unsigned random()*/
  292. --- 609,778 ----
  293. X  extern int process_xevents FUNCARGLIST((pausable))
  294. X  int     pausable  FUNCARGTERM
  295. X  {
  296. !     int       quit;
  297. !     int       paused;
  298. X      
  299. !     player.motionevent = 0;
  300. !     quit = 0;
  301. !     paused = 0;
  302. !     /*{{{  read the events*/
  303. !     while(QLength(display.display) || paused)
  304. !         {
  305. !             XEvent    event;
  306. !             
  307. !             XNextEvent(display.display, &event);
  308. !             if(event.xany.window != display.window)
  309. !                 continue;
  310. !             switch (event.type)
  311. !                 {
  312. !                     /*{{{  case KeyPress:*/
  313. !                   case KeyPress:
  314. !                     /*
  315. !                      * When a key is pressed, we check to see if it is
  316. !                      * a control key. If so, then we set the relevant pressed bit.
  317. !                      */
  318. !                     {
  319. !                         char      chr;
  320. !                         KeySym    symbol;
  321. !                         XComposeStatus status;
  322. !                         
  323. !                         XLookupString(&event.xkey, &chr, 1, &symbol, &status);
  324. !                         if(isupper(chr))
  325. !                             chr = tolower(chr);
  326. !                         if(chr == 'p' && pausable)
  327. !                             paused++;
  328. !                         else if(paused && chr == ' ')
  329. !                             player.motionevent = paused = 0;
  330. !                         else if((paused || !pausable) && chr == 'q')
  331. !                             {
  332. !                                 paused = 0;
  333. !                                 quit = 1;
  334. !                             }
  335. !                         else if(global.state > 5)
  336. !                             player.keyboard = player.button = 1;
  337. !                         else if(!paused && player.keyboard)
  338. !                             {
  339. !                                 int       index;
  340. !                                 
  341. !                                 for(index = 5; index--;)
  342. !                                     if(symbol == keystrokes[index])
  343. !                                         {
  344. !                                             if(index == 4)
  345. !                                                 player.button = 1;
  346. !                                             else
  347. !                                                 player.pressed |= 1 << index;
  348. !                                             break;
  349. !                                         }
  350. !                             }
  351. !                         break;
  352. !                     }
  353. !                     /*}}}*/
  354. !                     /*{{{  case KeyRelease:*/
  355. !                   case KeyRelease:
  356. !                     /*
  357. !                      * when a key is released, we check to see if it is
  358. !                      * the controlling direction key. If so, then we stop
  359. !                      */
  360. !                     {
  361. !                         if(player.keyboard)
  362. !                             {
  363. !                                 char      chr;
  364. !                                 KeySym    symbol;
  365. !                                 XComposeStatus status;
  366. !                                 unsigned  index;
  367. !                                 
  368. !                                 XLookupString(&event.xkey, &chr, 1, &symbol, &status);
  369. !                                 if(isupper(chr))
  370. !                                     chr = tolower(chr);
  371. !                                 for(index = 5; index--;)
  372. !                                     if(symbol == keystrokes[index])
  373. !                                         {
  374. !                                             if(index == 4)
  375. !                                                 player.button = 0;
  376. !                                             else
  377. !                                                 player.pressed &= ~(1 << index);
  378. !                                             break;
  379. !                                         }
  380. !                                 break;
  381. !                             }
  382. !                     }
  383. !                     /*}}}*/
  384. !                     /*{{{  case MotionNotify:*/
  385. !                   case MotionNotify:
  386. !                     /*
  387. !                      * for mouse motion, we save the coordinate and process the
  388. !                      * final one only
  389. !                      */
  390. !                     {
  391. !                         player.raw_mouse.x = event.xmotion.x;
  392. !                         player.raw_mouse.y = event.xmotion.y;
  393. !                         player.motionevent = 1;
  394. !                         break;
  395. !                     }
  396. !                     /*}}}*/
  397. !                     /*{{{  case ButtonPress:*/
  398. !                   case ButtonPress:
  399. !                     if(!player.keyboard)
  400. !                         player.button = 1;
  401. !                     break;
  402. !                     /*}}}*/
  403. !                     /*{{{  case ButtonRelease:*/
  404. !                   case ButtonRelease:
  405. !                     if(!player.keyboard && player.throw)
  406. !                         player.button = 0;
  407. !                     break;
  408. !                     /*}}}*/
  409. !                     /*{{{  case Expose:*/
  410. !                   case Expose:
  411. !                     refresh_window();
  412. !                     break;
  413. !                     /*}}}*/
  414. !                     /*{{{  case UnmapNotify:*/
  415. !                   case UnmapNotify:
  416. !                     paused++;
  417. !                     break;
  418. !                     /*}}}*/
  419. !                     /*{{{  case MapNotify:*/
  420. !                   case MapNotify:
  421. !                     if(!pausable)
  422. !                         paused = 0;
  423. !                     break;
  424. !                     /*}}}*/
  425. !                     /*{{{  case PropertyNotify:*/
  426. !                   case PropertyNotify:
  427. !                     if(event.xproperty.atom == display.DEC_icon_atom)
  428. !                         paused++;
  429. !                     break;
  430. !                     /*}}}*/
  431. !                   default:
  432. !                     break;
  433. !                 }
  434. !             /*{{{  started to pause?*/
  435. !             if(paused == 1)
  436. !                 {
  437. !                     char const *text = "Space to continue, Q to quit";
  438. !                     TEXT      info;
  439. !                     unsigned  length;
  440. X                      
  441. !                     paused++;
  442. !                     length = strlen(text);
  443. !                     text_size(text, length, &info);
  444. !                     add_background(0, PIXELY(CELLS_DOWN, 0), WINDOW_WIDTH, CELL_HEIGHT);
  445. !                     XFillRectangle(display.display, display.copy, GCN(GC_CLEAR),
  446. !                                    0, PIXELY(CELLS_DOWN, 0), WINDOW_WIDTH, CELL_HEIGHT);
  447. !                     XDrawImageString(display.display, display.copy, GCN(GC_TEXT),
  448. !                                      WINDOW_WIDTH / 2 - info.width / 2,
  449. !                                      PIXELY(CELLS_DOWN, CELL_HEIGHT / 2) +
  450. !                                      (info.ascent - info.descent) / 2, text, length);
  451. !                     XCopyArea(display.display, display.copy, display.window, GCN(GC_COPY),
  452. !                               0, PIXELY(CELLS_DOWN, 0), WINDOW_WIDTH, CELL_HEIGHT,
  453. !                               0, PIXELY(CELLS_DOWN, 0));
  454. !                     XSync(display.display, False);
  455. !                 }
  456. !             /*}}}*/
  457. !         }
  458. X      /*}}}*/
  459. !     return quit;
  460. X  }
  461. X  /*}}}*/
  462. X  /*{{{  unsigned random()*/
  463. *** xmris.h    Tue Jul 21 14:40:26 1992
  464. --- ../xmris.h    Tue Jul 21 10:57:40 1992
  465. ***************
  466. *** 568,574 ****
  467. X  extern APPLE_SIZE const apple_sizes[6];
  468. X  #define BOARDS 10
  469. X  extern BOARD const boards[BOARDS];
  470. ! extern char keystrokes[5];
  471. X  extern COORD const ball_hold[16];
  472. X  extern COORD const ball_throw[8];
  473. X  extern int const ball_dir[8];
  474. --- 568,574 ----
  475. X  extern APPLE_SIZE const apple_sizes[6];
  476. X  #define BOARDS 10
  477. X  extern BOARD const boards[BOARDS];
  478. ! extern KeySym keystrokes[5];
  479. X  extern COORD const ball_hold[16];
  480. X  extern COORD const ball_throw[8];
  481. X  extern int const ball_dir[8];
  482. *** Imakefile    Tue Jul 21 14:40:24 1992
  483. --- ../Imakefile    Tue Jul 21 14:39:52 1992
  484. ***************
  485. *** 10,16 ****
  486. X  /**/# frame rate in microseconds
  487. X  /**/#FRAME = -DFRAME_RATE=37000
  488. X  /**/# font name
  489. ! /**/#FONT = -DFONT_NAME="-*-courier-*-r-*-*-18-*-*-*-*-*-*-*"
  490. X  /**/# do you trust the code?
  491. X  /**/# NDEBUG = -DNDEBUG
  492. X  /**/# K&R doesn't have __DATE__ so we supply it here
  493. --- 10,16 ----
  494. X  /**/# frame rate in microseconds
  495. X  /**/#FRAME = -DFRAME_RATE=37000
  496. X  /**/# font name
  497. ! /**/# FONT = -DFONT_NAME="\"-*-courier-*-r-*-*-18-*-*-*-*-*-*-*\""
  498. X  /**/# do you trust the code?
  499. X  /**/# NDEBUG = -DNDEBUG
  500. X  /**/# K&R doesn't have __DATE__ so we supply it here
  501. X
  502. -- 
  503. SHAR_EOF
  504. chmod 0644 patch-1 ||
  505. echo 'restore of patch-1 failed'
  506. Wc_c="`wc -c < 'patch-1'`"
  507. test 12010 -eq "$Wc_c" ||
  508.     echo 'patch-1: original size 12010, current size' "$Wc_c"
  509. rm -f _shar_wnt_.tmp
  510. fi
  511. exit 0
  512. -- 
  513. ---
  514. Senior Systems Scientist        mail: dcmartin@msi.com
  515. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  516. 796 North Pastoria Avenue        at&t: 408/522-9236
  517.