home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / xmille.zip / XMILLE1.3 < prev    next >
Text File  |  1987-07-05  |  61KB  |  2,384 lines

  1. Article 42 of comp.sources.games:
  2. Path: ncrcce!rd1632!ncrlnk!ncrcae!hubcap!gatech!mcnc!seismo!rutgers!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request
  3. From: games-request@tekred.TEK.COM
  4. Newsgroups: comp.sources.games
  5. Subject: v01i068:  xmille - mille bournes for X-windows, Part01/03
  6. Message-ID: <1358@tekred.TEK.COM>
  7. Date: 30 Jun 87 17:27:12 GMT
  8. Expires: 30 Jul 87 17:19:24 GMT
  9. Sender: billr@tekred.TEK.COM
  10. Lines: 2369
  11. Approved: billr@tekred.TEK.COM
  12.  
  13. Submitted by: keithp@copper.TEK.COM (Keith Packard)
  14. Comp.sources.games: Volume 1, Issue 68
  15. Archive-name: xmille/Part01
  16.  
  17.     [The following note is from the author...    -br]
  18.  
  19.     [Well, after a letter arrived from Ken Arnold, I found out
  20.      that these sources are public domain, so I'm posting the
  21.      whole mess.
  22.      This and the next two articles make up xmille - a mille
  23.      bournes program that has a fun user-interface.  The last
  24.      article will be a uuencoded compress'ed shar file.  I know
  25.      this sounds a bit silly, but in compressed form it's only
  26.      60K while in uncompressed form it's 600K, about what you'd
  27.      expect from bitmaps.  So, you'll need to uudecode and
  28.      uncompress it and *then* un-shar it.  Make a directory,
  29.      un-shar the files in it and type 'make'.  Then fix the
  30.      porting problems and flame me for a crummy distribution.
  31.      I'll ignore those.
  32.      Don't spend too much time playing, your manager will start
  33.      to suspect things when you start talking about
  34.      'coup-fourre's' in meetings...
  35.         keith packard         keithp@copper.tek.com]
  36.  
  37.  
  38. #! /bin/sh
  39. # This is a shell archive.  Remove anything before this line, then unpack
  40. # it by saving it into a file and typing "sh file".  To overwrite existing
  41. # files, type "sh file -c".  You can also feed this as standard input via
  42. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  43. # will see the following message at the end:
  44. #        "End of archive 1 (of 3)."
  45. # Contents:  README MANIFEST comp.c control curses_ui.c drawcard.c
  46. #   end.c fill ui.c
  47. # Wrapped by billr@tekred on Mon Jun 29 17:24:34 1987
  48. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  49. if test -f README -a "${1}" != "-c" ; then 
  50.   echo shar: Will not over-write existing file \"README\"
  51. else
  52. echo shar: Extracting \"README\" \(736 characters\)
  53. sed "s/^X//" >README <<'END_OF_README'
  54. XNotes on porting xmille:
  55. X
  56. X    The bitmaps in 'cards' are set up for a color display, they probably
  57. Xwill not be readable in monocrome without a bit of editing.  Also, the
  58. Xcard display routines insist on color, so those will need fixing as well.
  59. X
  60. X    The major porting headache of mille is roll.c.  You'll probably
  61. Xhave to fix it for your machine, it's terrible now -- but that's what came
  62. Xwith it and it works on *my* machine...
  63. X
  64. X    I'll cheerfully accept bug reports in xmille, and may even be
  65. Xwilling to maintain a current version; but I wash my hands of this mess by
  66. Xputting it into the public domain, I don't care what you do with it.
  67. X
  68. X    May 28, 1987
  69. X
  70. X    keith packard
  71. X
  72. X    keithp@copper.tek.com    (at least for now)
  73. X
  74. X    reed!dinadan!keith    (at home)
  75. X
  76. END_OF_README
  77. if test 736 -ne `wc -c <README`; then
  78.     echo shar: \"README\" unpacked with wrong size!
  79. fi
  80. # end of overwriting check
  81. fi
  82. if test -f MANIFEST -a "${1}" != "-c" ; then 
  83.   echo shar: Will not over-write existing file \"MANIFEST\"
  84. else
  85. echo shar: Extracting \"MANIFEST\" \(974 characters\)
  86. sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
  87.    File Name        Archive #    Description
  88. -----------------------------------------------------------
  89.  MANIFEST                  1    This shipping list
  90.  Makefile                  2    
  91.  README                    1    
  92.  animate.c                 2    
  93.  background.h              2    
  94.  card.h                    2    
  95.  cards.Z.uu           3    compressed shar file of bitmaps
  96.  color.h                   2    
  97.  comp.c                    1    
  98.  control                   1    
  99.  curses_ui.c               1    
  100.  drawcard.c                1    
  101.  end.c                     1    
  102.  extern.c                  2    
  103.  fill                      1    
  104.  init.c                    2    
  105.  mille.c                   2    
  106.  mille.h                   2    
  107.  misc.c                    2    
  108.  move.c                    2    
  109.  print.c                   2    
  110.  roll.c                    2    
  111.  save.c                    2    
  112.  table.c                   2    
  113.  types.c                   2    
  114.  ui.c                      1    
  115.  ui.h                      2    
  116.  varpush.c                 2    
  117. END_OF_MANIFEST
  118. if test 974 -ne `wc -c <MANIFEST`; then
  119.     echo shar: \"MANIFEST\" unpacked with wrong size!
  120. fi
  121. # end of overwriting check
  122. fi
  123. if test -f comp.c -a "${1}" != "-c" ; then 
  124.   echo shar: Will not over-write existing file \"comp.c\"
  125. else
  126. echo shar: Extracting \"comp.c\" \(9582 characters\)
  127. sed "s/^X//" >comp.c <<'END_OF_comp.c'
  128. X# include    "mille.h"
  129. X
  130. X/*
  131. X * @(#)comp.c    1.1 (Berkeley) 4/1/82
  132. X */
  133. X
  134. X# define    V_VALUABLE    40
  135. X
  136. Xcalcmove() {
  137. X
  138. X    reg CARD    card;
  139. X    reg int        *value;
  140. X    reg PLAY    *pp, *op;
  141. X    reg bool    foundend, cango, canstop, foundlow;
  142. X    reg unsgn int    i, count200, badcount, nummin, nummax, diff;
  143. X    reg int        curmin, curmax;
  144. X    reg CARD    safe, oppos;
  145. X    int        valbuf[HAND_SZ], count[NUM_CARDS];
  146. X    bool        playit[HAND_SZ];
  147. X
  148. X    Message ("");
  149. X    pp = &Player[COMP];
  150. X    op = &Player[PLAYER];
  151. X    safe = 0;
  152. X    cango = 0;
  153. X    canstop = FALSE;
  154. X    foundend = FALSE;
  155. X    for (i = 0; i < NUM_CARDS; i++)
  156. X        count[i] = 0;
  157. X    for (i = 0; i < HAND_SZ; i++) {
  158. X        card = pp->hand[i];
  159. X        switch (card) {
  160. X          case C_STOP:    case C_CRASH:
  161. X          case C_FLAT:    case C_EMPTY:
  162. X            if (playit[i] = canplay(pp, op, card))
  163. X                canstop = TRUE;
  164. X            goto norm;
  165. X          case C_LIMIT:
  166. X            if ((playit[i] = canplay(pp, op, card))
  167. X                && Numseen[C_25] == Numcards[C_25]
  168. X                && Numseen[C_50] == Numcards[C_50])
  169. X                canstop = TRUE;
  170. X            goto norm;
  171. X          case C_25:    case C_50:    case C_75:
  172. X          case C_100:    case C_200:
  173. X            if ((playit[i] = canplay(pp, op, card))
  174. X                && pp->mileage + Value[card] == End)
  175. X                foundend = TRUE;
  176. X            goto norm;
  177. X          default:
  178. X            playit[i] = canplay(pp, op, card);
  179. Xnorm:
  180. X            if (playit[i])
  181. X                ++cango;
  182. X            break;
  183. X          case C_GAS_SAFE:    case C_DRIVE_SAFE:
  184. X          case C_SPARE_SAFE:    case C_RIGHT_WAY:
  185. X            if (pp->battle == opposite(card)
  186. X               || (pp->speed == C_LIMIT && card == C_RIGHT_WAY)) {
  187. X                Movetype = M_PLAY;
  188. X                Card_no = i;
  189. X                return;
  190. X            }
  191. X            ++safe;
  192. X            playit[i] = TRUE;
  193. X            break;
  194. X        }
  195. X        ++count[card];
  196. X    }
  197. X    if (pp->hand[0] == C_INIT && Topcard > Deck) {
  198. X        Movetype = M_DRAW;
  199. X        return;
  200. X    }
  201. X    if (Debug)
  202. X        fprintf(outf, "CALCMOVE: cango = %d, canstop = %d, safe = %d\n", cango, canstop, safe);
  203. X    if (foundend)
  204. X        foundend = !check_ext(TRUE);
  205. X    for (i = 0; safe && i < HAND_SZ; i++) {
  206. X        if (issafety(pp->hand[i])) {
  207. X            if (onecard(op) || (foundend && cango && !canstop)) {
  208. X                if (Debug)
  209. X                    fprintf(outf, "CALCMOVE: onecard(op) = %d, foundend = %d\n", onecard(op), foundend);
  210. Xplaysafe:
  211. X                Movetype = M_PLAY;
  212. X                Card_no = i;
  213. X                return;
  214. X            }
  215. X            oppos = opposite(pp->hand[i]);
  216. X            if (Numseen[oppos] == Numcards[oppos])
  217. X                goto playsafe;
  218. X            else if (!cango
  219. X                && (op->can_go || !pp->can_go || Topcard < Deck)) {
  220. X                card = (Topcard - Deck) - roll(1, 10);
  221. X                if ((!pp->mileage) != (!op->mileage))
  222. X                    card -= 7;
  223. X                if (Debug)
  224. X                    fprintf(outf, "CALCMOVE: card = %d, DECK_SZ / 4 = %d\n", card, DECK_SZ / 4);
  225. X                if (card < DECK_SZ / 4)
  226. X                    goto playsafe;
  227. X            }
  228. X            safe--;
  229. X            playit[i] = cango;
  230. X        }
  231. X    }
  232. X    if (!pp->can_go && !isrepair(pp->battle))
  233. X        Numneed[opposite(pp->battle)]++;
  234. Xredoit:
  235. X    foundlow = (cango || count[C_END_LIMIT] != 0
  236. X              || Numseen[C_LIMIT] == Numcards[C_LIMIT]
  237. X              || pp->safety[S_RIGHT_WAY] != S_UNKNOWN);
  238. X    foundend = FALSE;
  239. X    count200 = pp->nummiles[C_200];
  240. X    badcount = 0;
  241. X    curmax = -1;
  242. X    curmin = 101;
  243. X    nummin = -1;
  244. X    nummax = -1;
  245. X    value = valbuf;
  246. X    for (i = 0; i < HAND_SZ; i++) {
  247. X        card = pp->hand[i];
  248. X        if (issafety(card) || playit[i] == (cango != 0)) {
  249. X            if (Debug)
  250. X                fprintf(outf, "CALCMOVE: switch(\"%s\")\n", C_name[card]);
  251. X            switch (card) {
  252. X              case C_25:    case C_50:
  253. X                diff = End - pp->mileage;
  254. X                /* avoid getting too close */
  255. X                if (Topcard > Deck && cango && diff <= 100
  256. X                    && diff / Value[card] > count[card]
  257. X                    && (card == C_25 || diff % 50 == 0)) {
  258. X                    if (card == C_50 && diff - 50 == 25
  259. X                        && count[C_25] > 0)
  260. X                        goto okay;
  261. X                    *value = 0;
  262. X                    if (--cango <= 0)
  263. X                        goto redoit;
  264. X                    break;
  265. X                }
  266. Xokay:
  267. X                *value = (Value[card] >> 3);
  268. X                if (pp->speed == C_LIMIT)
  269. X                    ++*value;
  270. X                else
  271. X                    --*value;
  272. X                if (!foundlow
  273. X                   && (card == C_50 || count[C_50] == 0)) {
  274. X                    *value = (pp->mileage ? 10 : 20);
  275. X                    foundlow = TRUE;
  276. X                }
  277. X                goto miles;
  278. X              case C_200:
  279. X                if (++count200 > 2) {
  280. X                    *value = 0;
  281. X                    break;
  282. X                }
  283. X              case C_75:    case C_100:
  284. X                *value = (Value[card] >> 3);
  285. X                if (pp->speed == C_LIMIT)
  286. X                    --*value;
  287. X                else
  288. X                    ++*value;
  289. Xmiles:
  290. X                if (pp->mileage + Value[card] > End)
  291. X                    *value = (End == 700 ? card : 0);
  292. X                else if (pp->mileage + Value[card] == End) {
  293. X                    *value = (foundend ? card : V_VALUABLE);
  294. X                    foundend = TRUE;
  295. X                }
  296. X                break;
  297. X              case C_END_LIMIT:
  298. X                if (pp->safety[S_RIGHT_WAY] != S_UNKNOWN)
  299. X                    *value = (pp->safety[S_RIGHT_WAY] == S_PLAYED ? -1 : 1);
  300. X                else if (pp->speed == C_LIMIT && End - pp->mileage <= 50)
  301. X                    *value = 1;
  302. X                else if (pp->speed == C_LIMIT
  303. X                    || Numseen[C_LIMIT] != Numcards[C_LIMIT]) {
  304. X                    safe = S_RIGHT_WAY;
  305. X                    oppos = C_LIMIT;
  306. X                    goto repair;
  307. X                }
  308. X                else {
  309. X                    *value = 0;
  310. X                    --count[C_END_LIMIT];
  311. X                }
  312. X                break;
  313. X              case C_REPAIRS:    case C_SPARE:    case C_GAS:
  314. X                safe = safety(card) - S_CONV;
  315. X                oppos = opposite(card);
  316. X                if (pp->safety[safe] != S_UNKNOWN)
  317. X                    *value = (pp->safety[safe] == S_PLAYED ? -1 : 1);
  318. X                else if (pp->battle != oppos
  319. X                    && (Numseen[oppos] == Numcards[oppos] || Numseen[oppos] + count[card] > Numcards[oppos])) {
  320. X                    *value = 0;
  321. X                    --count[card];
  322. X                }
  323. X                else {
  324. Xrepair:
  325. X                    *value = Numcards[oppos] * 6;
  326. X                    *value += (Numseen[card] - Numseen[oppos]);
  327. X                    if (!cango)
  328. X                        *value /= (count[card]*count[card]);
  329. X                    count[card]--;
  330. X                }
  331. X                break;
  332. X              case C_GO:
  333. X                if (pp->safety[S_RIGHT_WAY] != S_UNKNOWN)
  334. X                    *value = (pp->safety[S_RIGHT_WAY] == S_PLAYED ? -1 : 2);
  335. X                else if (pp->can_go
  336. X                 && Numgos + count[C_GO] == Numneed[C_GO]) {
  337. X                    *value = 0;
  338. X                    --count[C_GO];
  339. X                }
  340. X                else {
  341. X                    *value = Numneed[C_GO] * 3;
  342. X                    *value += (Numseen[C_GO] - Numgos);
  343. X                    *value /= (count[C_GO] * count[C_GO]);
  344. X                    count[C_GO]--;
  345. X                }
  346. X                break;
  347. X              case C_LIMIT:
  348. X                if (op->mileage + 50 >= End) {
  349. X                    *value = (End == 700 && !cango);
  350. X                    break;
  351. X                }
  352. X                if (canstop || (cango && !op->can_go))
  353. X                    *value = 1;
  354. X                else {
  355. X                    *value = (pp->safety[S_RIGHT_WAY] != S_UNKNOWN ? 2 : 3);
  356. X                    safe = S_RIGHT_WAY;
  357. X                    oppos = C_END_LIMIT;
  358. X                    goto normbad;
  359. X                }
  360. X                break;
  361. X              case C_CRASH:    case C_EMPTY:    case C_FLAT:
  362. X                safe = safety(card) - S_CONV;
  363. X                oppos = opposite(card);
  364. X                *value = (pp->safety[safe]!=S_UNKNOWN ? 3 : 4);
  365. Xnormbad:
  366. X                if (op->safety[safe] == S_PLAYED)
  367. X                    *value = -1;
  368. X                else {
  369. X                    *value *= (Numneed[oppos] + Numseen[oppos] + 2);
  370. X                    if (!pp->mileage || foundend || onecard(op))
  371. X                    *value += 5;
  372. X                    if (op->mileage == 0 || onecard(op))
  373. X                    *value += 5;
  374. X                    if (op->speed == C_LIMIT)
  375. X                    *value -= 3;
  376. X                    if (cango && pp->safety[safe] != S_UNKNOWN)
  377. X                    *value += 3;
  378. X                    if (!cango)
  379. X                    *value /= ++badcount;
  380. X                }
  381. X                break;
  382. X              case C_STOP:
  383. X                if (op->safety[S_RIGHT_WAY] == S_PLAYED)
  384. X                    *value = -1;
  385. X                else {
  386. X                    *value = (pp->safety[S_RIGHT_WAY] != S_UNKNOWN ? 3 : 4);
  387. X                    *value *= (Numcards[C_STOP] + Numseen[C_GO]);
  388. X                    if (!pp->mileage || foundend || onecard(op))
  389. X                    *value += 5;
  390. X                    if (!cango)
  391. X                    *value /= ++badcount;
  392. X                    if (op->mileage == 0)
  393. X                    *value += 5;
  394. X                    if ((card == C_LIMIT
  395. X                      && op->speed == C_LIMIT) || (!op->can_go))
  396. X                    *value -= 5;
  397. X                    if (cango && pp->safety[S_RIGHT_WAY] != S_UNKNOWN)
  398. X                    *value += 5;
  399. X                }
  400. X                break;
  401. X              case C_GAS_SAFE:    case C_DRIVE_SAFE:
  402. X              case C_SPARE_SAFE:    case C_RIGHT_WAY:
  403. X                *value = cango ? 0 : 101;
  404. X                break;
  405. X              case C_INIT:
  406. X                *value = 0;
  407. X            }
  408. X        }
  409. X        else
  410. X            *value = cango ? 0 : 101;
  411. X        if (card != C_INIT) {
  412. X            if (*value >= curmax) {
  413. X                nummax = i;
  414. X                curmax = *value;
  415. X            }
  416. X            if (*value <= curmin) {
  417. X                nummin = i;
  418. X                curmin = *value;
  419. X            }
  420. X        }
  421. X        if (Debug)
  422. X            debug(i, "%3d %-14s",*value,C_name[pp->hand[i]]);
  423. X        value++;
  424. X    }
  425. X    if (!pp->can_go && !isrepair(pp->battle))
  426. X        Numneed[opposite(pp->battle)]++;
  427. X    if (cango) {
  428. X        ComputerStatus ("PLAY\n");
  429. X        if (Debug)
  430. X            getmove();
  431. X        if (!Debug || Movetype == M_DRAW) {
  432. X            Movetype = M_PLAY;
  433. X            Card_no = nummax;
  434. X        }
  435. X    }
  436. X    else {
  437. X        ComputerStatus ("DISCARD\n");
  438. X        if (Debug)
  439. X            getmove();
  440. X        if (!Debug || Movetype == M_DRAW) {
  441. X            Movetype = M_DISCARD;
  442. X            Card_no = nummin;
  443. X        }
  444. X    }
  445. X    ComputerCard (pp->hand[Card_no]);
  446. X}
  447. X
  448. Xonecard(pp)
  449. Xreg PLAY    *pp; {
  450. X
  451. X    reg CARD    bat, spd, card;
  452. X
  453. X    bat = pp->battle;
  454. X    spd = pp->speed;
  455. X    card = -1;
  456. X    if (pp->can_go || ((isrepair(bat) || bat == C_STOP
  457. X        || spd == C_LIMIT) && Numseen[S_RIGHT_WAY] != 0)
  458. X        || Numseen[safety(bat)] != 0)
  459. X        switch (End - pp->mileage) {
  460. X          case 200:
  461. X            if (pp->nummiles[C_200] == 2)
  462. X                return FALSE;
  463. X            card = C_200;
  464. X          case 100:
  465. X          case 75:
  466. X            if (card == -1)
  467. X                card = (End - pp->mileage == 75 ? C_75 : C_100);
  468. X            if (spd == C_LIMIT)
  469. X                return Numseen[S_RIGHT_WAY] == 0;
  470. X          case 50:
  471. X          case 25:
  472. X            if (card == -1)
  473. X                card = (End - pp->mileage == 25 ? C_25 : C_50);
  474. X            return Numseen[card] != Numcards[card];
  475. X        }
  476. X    return FALSE;
  477. X}
  478. X
  479. Xcanplay(pp, op, card)
  480. Xreg PLAY    *pp, *op;
  481. Xreg CARD    card; {
  482. X
  483. X    switch (card) {
  484. X      case C_200:
  485. X        if (pp->nummiles[C_200] == 2)
  486. X            break;
  487. X      case C_75:    case C_100:
  488. X        if (pp->speed == C_LIMIT)
  489. X            break;
  490. X      case C_50:
  491. X        if (pp->mileage + Value[card] > End)
  492. X            break;
  493. X      case C_25:
  494. X        if (pp->can_go)
  495. X            return TRUE;
  496. X        break;
  497. X      case C_EMPTY:    case C_FLAT:    case C_CRASH:
  498. X      case C_STOP:
  499. X        if (op->can_go && op->safety[safety(card) - S_CONV] != S_PLAYED)
  500. X            return TRUE;
  501. X        break;
  502. X      case C_LIMIT:
  503. X        if (op->speed != C_LIMIT && op->safety[S_RIGHT_WAY] != S_PLAYED
  504. X            && op->mileage + 50 < End)
  505. X            return TRUE;
  506. X        break;
  507. X      case C_GAS:    case C_SPARE:    case C_REPAIRS:
  508. X        if (pp->battle == opposite(card))
  509. X            return TRUE;
  510. X        break;
  511. X      case C_GO:
  512. X        if (!pp->can_go
  513. X            && (isrepair(pp->battle) || pp->battle == C_STOP))
  514. X            return TRUE;
  515. X        break;
  516. X      case C_END_LIMIT:
  517. X        if (pp->speed == C_LIMIT)
  518. X            return TRUE;
  519. X    }
  520. X    return FALSE;
  521. X}
  522. END_OF_comp.c
  523. if test 9582 -ne `wc -c <comp.c`; then
  524.     echo shar: \"comp.c\" unpacked with wrong size!
  525. fi
  526. # end of overwriting check
  527. fi
  528. if test ! -d control ; then
  529.     echo shar: Creating directory \"control\"
  530.     mkdir control
  531. fi
  532. if test -f curses_ui.c -a "${1}" != "-c" ; then 
  533.   echo shar: Will not over-write existing file \"curses_ui.c\"
  534. else
  535. echo shar: Extracting \"curses_ui.c\" \(10994 characters\)
  536. sed "s/^X//" >curses_ui.c <<'END_OF_curses_ui.c'
  537. X/*
  538. X * ui.c
  539. X *
  540. X * curses interface routines for mille
  541. X */
  542. X
  543. X# include    "mille.h"
  544. X#undef TRUE
  545. X#undef FALSE
  546. X# include    "ui.h"
  547. X#ifdef CTRL
  548. X# undef CTRL
  549. X#endif
  550. X#define CTRL(x)    (x - 'A' + 1)
  551. X
  552. XWINDOW    *Board, *Miles, *Score;
  553. X
  554. Xchar    *C_fmt = "%-18.18s";    /* format for printing cards        */
  555. Xchar    Initstr[100];        /* initial string for error field    */
  556. Xchar    *_cn[NUM_CARDS] = {    /* Card name buffer            */
  557. X        "",
  558. X        "25",
  559. X        "50",
  560. X        "75",
  561. X        "100",
  562. X        "200",
  563. X        "Out of Gas",
  564. X        "Flat Tire",
  565. X        "Accident",
  566. X        "Stop",
  567. X        "Speed Limit", 
  568. X        "Gasoline",
  569. X        "Spare Tire",
  570. X        "Repairs",
  571. X        "Go",
  572. X        "End of Limit",
  573. X        "Extra Tank",
  574. X        "Puncture Proof",
  575. X        "Driving Ace",
  576. X        "Right of Way"
  577. X    },
  578. X    **C_name = &_cn[1];    /* Card names                */
  579. X
  580. XMessage (string)
  581. Xchar    *string;
  582. X{
  583. X    wmove (Score, ERR_Y, ERR_X);
  584. X    waddstr (Score, string);
  585. X    wclrtoeol (Score);
  586. X}
  587. X
  588. Xdebug (pos, string, a0, a1, a2)
  589. X{
  590. X    mvprintw (pos+6, 2, string, a0, a1, a2);
  591. X}
  592. X
  593. XComputerStatus (string)
  594. X{
  595. X    mvaddstr (MOVE_Y + 1, MOVE_X, string);
  596. X}
  597. X
  598. XComputerCard (type)
  599. Xint    type;
  600. X{
  601. X    mvprintw (MOVE_Y + 2, MOVE_X, "%16s", C_name[type]);
  602. X}
  603. X
  604. X
  605. XPrompt (string)
  606. Xchar *string;
  607. X{
  608. X    mvaddstr (MOVE_Y, MOVE_X, string);
  609. X    clrtoeol ();
  610. X    refresh ();
  611. X}
  612. X
  613. Xchar *
  614. XGetpromptedInput (string)
  615. Xchar    *string;
  616. X{
  617. X    static char    buf[1024];
  618. X    char        *sp;
  619. X    
  620. X    sp = buf;
  621. X    Prompt (string);
  622. X    leaveok (Board, FALSE);
  623. X    while ((*sp = readch()) != '\n') {
  624. X        if (*sp == _tty.sg_kill) {
  625. X            sp = buf;
  626. X            break;
  627. X        }
  628. X        else if (*sp == _tty.sg_erase) {
  629. X            if (--sp < buf)
  630. X                sp = buf;
  631. X            else {
  632. X                addch('\b');
  633. X                /*
  634. X                 * if the previous char was a control
  635. X                 * char, cover up two characters.
  636. X                 */
  637. X                if (*sp < ' ')
  638. X                    addch('\b');
  639. X                clrtoeol();
  640. X            }
  641. X        }
  642. X        else
  643. X            addstr(unctrl(*sp++));
  644. X        refresh();
  645. X    }
  646. X    *sp = '\0';
  647. X    leaveok (Board, TRUE);
  648. X    return buf;
  649. X}
  650. X
  651. Xnewboard()
  652. X{
  653. X    werase(Board);
  654. X    werase(Score);
  655. X    mvaddstr(5, 0, "--HAND--");
  656. X    mvaddch(6, 0, 'P');
  657. X    mvaddch(7, 0, '1');
  658. X    mvaddch(8, 0, '2');
  659. X    mvaddch(9, 0, '3');
  660. X    mvaddch(10, 0, '4');
  661. X    mvaddch(11, 0, '5');
  662. X    mvaddch(12, 0, '6');
  663. X    mvaddstr(13, 0, "--BATTLE--");
  664. X    mvaddstr(15, 0, "--SPEED--");
  665. X    mvaddstr(5, 20, "--DECK--");
  666. X    mvaddstr(7, 20, "--DISCARD--");
  667. X    mvaddstr(13, 20, "--BATTLE--");
  668. X    mvaddstr(15, 20, "--SPEED--");
  669. X    wmove(Miles, 0, 0);
  670. X    if (winch(Miles) != '-') {
  671. X        werase(Miles);
  672. X        mvwaddstr(Miles, 0, 0, "--MILEAGE--");
  673. X        mvwaddstr(Miles, 0, 41, "--MILEAGE--");
  674. X    }
  675. X    else {
  676. X        wmove(Miles, 1, 0);
  677. X        wclrtobot(Miles);
  678. X    }
  679. X    newscore();
  680. X    stdscr = Board;
  681. X}
  682. X
  683. Xnewscore() {
  684. X
  685. X    reg int    i;
  686. X
  687. X    stdscr = Score;
  688. X    move(0, 22);
  689. X    if (inch() != 'Y') {
  690. X        erase();
  691. X        mvaddstr(0, 22,  "You   Comp   Value");
  692. X        mvaddstr(1, 2, "Milestones Played");
  693. X        mvaddstr(2, 8, "Each Safety");
  694. X        mvaddstr(3, 5, "All 4 Safeties");
  695. X        mvaddstr(4, 3, "Each Coup Fourre");
  696. X        mvaddstr(2, 37, "100");
  697. X        mvaddstr(3, 37, "300");
  698. X        mvaddstr(4, 37, "300");
  699. X    }
  700. X    else {
  701. X        move(5, 1);
  702. X        clrtobot();
  703. X    }
  704. X    for (i = 0; i < SCORE_Y; i++)
  705. X        mvaddch(i, 0, '|');
  706. X    move(SCORE_Y - 1, 1);
  707. X    while (addch('_') != ERR)
  708. X        continue;
  709. X    if (WIndow == W_FULL || Finished) {
  710. X        mvaddstr(5, 5, "Trip Completed");
  711. X        mvaddstr(6, 10, "Safe Trip");
  712. X        mvaddstr(7, 5, "Delayed Action");
  713. X        mvaddstr(8, 10, "Extension");
  714. X        mvaddstr(9, 11, "Shut-Out");
  715. X        mvaddstr(10, 21, "----   ----   -----");
  716. X        mvaddstr(11, 9, "Hand Total");
  717. X        mvaddstr(12, 20, "-----  -----");
  718. X        mvaddstr(13, 6, "Overall Total");
  719. X        mvaddstr(14, 15, "Games");
  720. X        mvaddstr(5, 37, "400");
  721. X        mvaddstr(6, 37, "300");
  722. X        mvaddstr(7, 37, "300");
  723. X        mvaddstr(8, 37, "200");
  724. X        mvaddstr(9, 37, "500");
  725. X    }
  726. X    else {
  727. X        mvaddstr(5, 21, "----   ----   -----");
  728. X        mvaddstr(6, 9, "Hand Total");
  729. X        mvaddstr(7, 20, "-----  -----");
  730. X        mvaddstr(8, 6, "Overall Total");
  731. X        mvaddstr(9, 15, "Games");
  732. X        mvaddstr(11, 2, "p: pick");
  733. X        mvaddstr(12, 2, "u: use #");
  734. X        mvaddstr(13, 2, "d: discard #");
  735. X        mvaddstr(14, 2, "w: toggle window");
  736. X        mvaddstr(11, 21, "q: quit");
  737. X        mvaddstr(12, 21, "o: order hand");
  738. X        mvaddstr(13, 21, "s: save");
  739. X        mvaddstr(14, 21, "r: reprint");
  740. X    }
  741. X    stdscr = Board;
  742. X}
  743. X
  744. Xinit_ui ()
  745. X{
  746. X    initscr();
  747. X# ifdef attron
  748. X#    define    CA    cursor_address
  749. X# endif
  750. X    if (!CA) {
  751. X        printf("Sorry.  Need cursor addressing to play mille\n");
  752. X        exit(-1);
  753. X    }
  754. X    delwin(stdscr);
  755. X    stdscr = Board = newwin(BOARD_Y, BOARD_X, 0, 0);
  756. X    Score = newwin(SCORE_Y, SCORE_X, 0, 40);
  757. X    Miles = newwin(MILES_Y, MILES_X, 17, 0);
  758. X#ifdef attron
  759. X    idlok(Board, TRUE);
  760. X    idlok(Score, TRUE);
  761. X    idlok(Miles, TRUE);
  762. X#endif
  763. X    leaveok(Score, TRUE);
  764. X    leaveok(Miles, TRUE);
  765. X    clearok(curscr, TRUE);
  766. X    crmode();
  767. X    noecho();
  768. X}
  769. X
  770. XError (string, arg)
  771. Xchar *string;
  772. X{
  773. X    stdscr = Score;
  774. X    mvprintw (Score, ERR_Y, ERR_X, string, arg);
  775. X    clrtoeol ();
  776. X    stdscr = Board;
  777. X}
  778. X
  779. Xfinish_ui ()
  780. X{
  781. X    mvcur(0, COLS - 1, LINES - 1, 0);
  782. X    endwin();
  783. X}
  784. X
  785. Xupdate_ui ()
  786. X{
  787. X    refresh ();
  788. X}
  789. X
  790. XBeep ()
  791. X{
  792. X    putchar ('\007');
  793. X}
  794. X
  795. XCARD
  796. Xgetcard()
  797. X{
  798. X    reg char    c, c1;
  799. X
  800. X    for (;;) {
  801. X        while ((c = readch()) == '\n' || c == '\r' || c == ' ')
  802. X            continue;
  803. X        if (islower(c))
  804. X            c = toupper(c);
  805. X        if (c == _tty.sg_kill || c == _tty.sg_erase)
  806. X            return -1;
  807. X        addstr(unctrl(c));
  808. X        clrtoeol();
  809. X        switch (c) {
  810. X          case '1':    case '2':    case '3':
  811. X          case '4':    case '5':    case '6':
  812. X            c -= '0';
  813. X            break;
  814. X          case '0':    case 'P':    case 'p':
  815. X            c = 0;
  816. X            break;
  817. X          default:
  818. X            putchar('');
  819. X            addch('\b');
  820. X            if (!isprint(c))
  821. X                addch('\b');
  822. X            c = -1;
  823. X            break;
  824. X        }
  825. X        refresh();
  826. X        if (c >= 0) {
  827. X            while ((c1=readch()) != '\r' && c1 != '\n' && c1 != ' ')
  828. X                if (c1 == _tty.sg_kill)
  829. X                    return -1;
  830. X                else if (c1 == _tty.sg_erase) {
  831. X                    addch('\b');
  832. X                    clrtoeol();
  833. X                    refresh();
  834. X                    goto cont;
  835. X                }
  836. X                else
  837. X                    write(0, "", 1);
  838. X            return c;
  839. X        }
  840. Xcont:        ;
  841. X    }
  842. X}
  843. X
  844. X
  845. X/*
  846. X *    Get a yes or no answer to the given question.  Saves are
  847. X * also allowed.  Return TRUE if the answer was yes, FALSE if no.
  848. X */
  849. Xgetyn(prompt)
  850. Xreg char    *prompt; {
  851. X
  852. X    reg char    c;
  853. X
  854. X    Saved = FALSE;
  855. X    for (;;) {
  856. X        leaveok(Board, FALSE);
  857. X        mvaddstr(MOVE_Y, MOVE_X, prompt);
  858. X        clrtoeol();
  859. X        refresh();
  860. X        switch (c = readch()) {
  861. X          case 'n':    case 'N':
  862. X            addch('N');
  863. X            refresh();
  864. X            leaveok(Board, TRUE);
  865. X            return FALSE;
  866. X          case 'y':    case 'Y':
  867. X            addch('Y');
  868. X            refresh();
  869. X            leaveok(Board, TRUE);
  870. X            return TRUE;
  871. X          case 's':    case 'S':
  872. X            addch('S');
  873. X            refresh();
  874. X            Saved = save();
  875. X            continue;
  876. X          default:
  877. X            addstr(unctrl(c));
  878. X            refresh();
  879. X            putchar('');
  880. X            break;
  881. X        }
  882. X    }
  883. X}
  884. X
  885. Xreadch()
  886. X{
  887. X    reg int        cnt;
  888. X    static char    c;
  889. X
  890. X    for (cnt = 0; read(0, &c, 1) <= 0; cnt++)
  891. X        if (cnt > 100)
  892. X            exit(1);
  893. X    return c;
  894. X}
  895. X
  896. X
  897. Xgetmove()
  898. X{
  899. X    reg char    c, *sp;
  900. X    static char    moveprompt[] = ">>:Move:";
  901. X#ifdef EXTRAP
  902. X    static bool    last_ex = FALSE;    /* set if last command was E */
  903. X
  904. X    if (last_ex) {
  905. X        undoex();
  906. X        prboard();
  907. X        last_ex = FALSE;
  908. X    }
  909. X#endif
  910. X    for (;;) {
  911. X        stand(MOVE_Y, MOVE_X, moveprompt);
  912. X        clrtoeol();
  913. X        move(MOVE_Y, MOVE_X + sizeof moveprompt);
  914. X        leaveok(Board, FALSE);
  915. X        refresh();
  916. X        while ((c = readch()) == _tty.sg_kill || c == _tty.sg_erase)
  917. X            continue;
  918. X        if (islower(c))
  919. X            c = toupper(c);
  920. X        if (isprint(c) && !isspace(c)) {
  921. X            addch(c);
  922. X            refresh();
  923. X        }
  924. X        switch (c)
  925. X        {
  926. X          case 'P':        /* Pick */
  927. X            Movetype = M_DRAW;
  928. X            goto ret;
  929. X          case 'U':        /* Use Card */
  930. X          case 'D':        /* Discard Card */
  931. X            if ((Card_no = getcard()) < 0)
  932. X                break;
  933. X            Movetype = (c == 'U' ? M_PLAY : M_DISCARD);
  934. X            goto ret;
  935. X          case 'O':        /* Order */
  936. X            Order = !Order;
  937. X            Movetype = M_ORDER;
  938. X            goto ret;
  939. X          case 'Q':        /* Quit */
  940. X            rub();        /* Same as a rubout */
  941. X            break;
  942. X          case 'W':        /* WIndow toggle */
  943. X            WIndow = nextwin(WIndow);
  944. X            newscore();
  945. X            prscore(TRUE);
  946. X            wrefresh(Score);
  947. X            break;
  948. X          case 'R':        /* Redraw screen */
  949. X          case CTRL('L'):
  950. X            clearok(curscr, TRUE);
  951. X            newboard();
  952. X            prboard();
  953. X            break;
  954. X          case 'S':        /* Save game */
  955. X            On_exit = FALSE;
  956. X            save();
  957. X            break;
  958. X          case 'E':        /* Extrapolate */
  959. X#ifdef EXTRAP
  960. X            if (last_ex)
  961. X                break;
  962. X            Finished = TRUE;
  963. X            if (WIndow != W_FULL)
  964. X                newscore();
  965. X            prscore(FALSE);
  966. X            wrefresh(Score);
  967. X            last_ex = TRUE;
  968. X            Finished = FALSE;
  969. X#else
  970. X            error("%c: command not implemented", c);
  971. X#endif
  972. X            break;
  973. X          case '\r':        /* Ignore RETURNs and    */
  974. X          case '\n':        /* Line Feeds        */
  975. X          case ' ':        /* Spaces        */
  976. X          case '\0':        /* and nulls        */
  977. X            break;
  978. X          case 'Z':        /* Debug code */
  979. X            if (geteuid() == ARNOLD) {
  980. X                if (!Debug && outf == NULL) {
  981. X                    char    buf[40];
  982. Xover:
  983. X                    mvaddstr(MOVE_Y, MOVE_X, "file: ");
  984. X                    clrtoeol();
  985. X                    leaveok(Board, FALSE);
  986. X                    refresh();
  987. X                    sp = buf;
  988. X                    while ((*sp = readch()) != '\n') {
  989. X                        if (*sp == _tty.sg_kill)
  990. X                            goto over;
  991. X                        else if (*sp == _tty.sg_erase) {
  992. X                            if (--sp < buf)
  993. X                                sp = buf;
  994. X                            else {
  995. X                                addch('\b');
  996. X                                if (*sp < ' ')
  997. X                                    addch('\b');
  998. X                                clrtoeol();
  999. X                            }
  1000. X                        }
  1001. X                        else
  1002. X                            addstr(unctrl(*sp++));
  1003. X                        refresh();
  1004. X                    }
  1005. X                    *sp = '\0';
  1006. X                    leaveok(Board, TRUE);
  1007. X                    if ((outf = fopen(buf, "w")) == NULL)
  1008. X                        perror(buf);
  1009. X                    setbuf(outf, 0);
  1010. X                }
  1011. X                Debug = !Debug;
  1012. X                break;
  1013. X            }
  1014. X            /* FALLTHROUGH */
  1015. X          default:
  1016. X            error("unknown command: %s", unctrl(c));
  1017. X            break;
  1018. X        }
  1019. X    }
  1020. Xret:
  1021. X    leaveok(Board, TRUE);
  1022. X}
  1023. X
  1024. X
  1025. X# define    COMP_STRT    20
  1026. X# define    CARD_STRT    2
  1027. X
  1028. Xprboard() {
  1029. X
  1030. X    reg PLAY    *pp;
  1031. X    reg int        i, j, k, temp;
  1032. X
  1033. X    for (k = 0; k < 2; k++) {
  1034. X        pp = &Player[k];
  1035. X        temp = k * COMP_STRT + CARD_STRT;
  1036. X        for (i = 0; i < NUM_SAFE; i++)
  1037. X            if (pp->safety[i] == S_PLAYED) {
  1038. X                mvaddstr(i, temp, C_name[i + S_CONV]);
  1039. X                if (pp->coups[i])
  1040. X                    mvaddch(i, temp - CARD_STRT, '*');
  1041. X            }
  1042. X        mvprintw(14, temp, C_fmt, C_name[pp->battle]);
  1043. X        mvprintw(16, temp, C_fmt, C_name[pp->speed]);
  1044. X        for (i = C_25; i <= C_200; ) {
  1045. X            reg char    *name;
  1046. X            reg int        end;
  1047. X
  1048. X            name = C_name[i];
  1049. X            temp = k * 40;
  1050. X            end = pp->nummiles[i++];
  1051. X            for (j = 0; j < end; j++)
  1052. X                mvwaddstr(Miles, i, (j << 2) + temp, name);
  1053. X        }
  1054. X    }
  1055. X    prscore(TRUE);
  1056. X    temp = CARD_STRT;
  1057. X    pp = &Player[PLAYER];
  1058. X    for (i = 0; i < HAND_SZ; i++)
  1059. X        mvprintw(i + 6, temp, C_fmt, C_name[pp->hand[i]]);
  1060. X    mvprintw(6, COMP_STRT + CARD_STRT, "%2d", Topcard - Deck);
  1061. X    mvprintw(8, COMP_STRT + CARD_STRT, C_fmt, C_name[Discard]);
  1062. X    if (End == 1000) {
  1063. X        static char    ext[] = "Extension";
  1064. X
  1065. X        stand(EXT_Y, EXT_X, ext);
  1066. X    }
  1067. X    wrefresh(Board);
  1068. X    wrefresh(Miles);
  1069. X    wrefresh(Score);
  1070. X}
  1071. X
  1072. X/*
  1073. X *    Put str at (y,x) in standout mode
  1074. X */
  1075. Xstand(y, x, str)
  1076. Xreg int        y, x;
  1077. Xreg char    *str; {
  1078. X
  1079. X    standout();
  1080. X    mvaddstr(y, x, str);
  1081. X    standend();
  1082. X    return TRUE;
  1083. X}
  1084. X
  1085. Xprscore(for_real)
  1086. Xreg bool    for_real; {
  1087. X
  1088. X    reg PLAY    *pp;
  1089. X    reg int        x;
  1090. X    reg char    *Score_fmt = "%4d";
  1091. X
  1092. X    stdscr = Score;
  1093. X    for (pp = Player; pp < &Player[2]; pp++) {
  1094. X        x = (pp - Player) * 6 + 21;
  1095. X        mvprintw(1, x, Score_fmt, pp->mileage);
  1096. X        mvprintw(2, x, Score_fmt, pp->safescore);
  1097. X        if (pp->safescore == 400)
  1098. X            mvaddstr(3, x + 1, "300");
  1099. X        else
  1100. X            mvaddch(3, x + 3, '0');
  1101. X        mvprintw(4, x, Score_fmt, pp->coupscore);
  1102. X        if (WIndow == W_FULL || Finished) {
  1103. X#ifdef EXTRAP
  1104. X            if (for_real)
  1105. X                finalscore(pp);
  1106. X            else
  1107. X                extrapolate(pp);
  1108. X#else
  1109. X            finalscore(pp);
  1110. X#endif
  1111. X            mvprintw(11, x, Score_fmt, pp->hand_tot);
  1112. X            mvprintw(13, x, Score_fmt, pp->total);
  1113. X            mvprintw(14, x, Score_fmt, pp->games);
  1114. X        }
  1115. X        else {
  1116. X            mvprintw(6, x, Score_fmt, pp->hand_tot);
  1117. X            mvprintw(8, x, Score_fmt, pp->total);
  1118. X            mvprintw(9, x, Score_fmt, pp->games);
  1119. X        }
  1120. X    }
  1121. X    stdscr = Board;
  1122. X}
  1123. X
  1124. XFlushInput ()
  1125. X{
  1126. X    raw();    /* Flush input */
  1127. X    noraw();
  1128. X
  1129. X}
  1130. END_OF_curses_ui.c
  1131. if test 10994 -ne `wc -c <curses_ui.c`; then
  1132.     echo shar: \"curses_ui.c\" unpacked with wrong size!
  1133. fi
  1134. # end of overwriting check
  1135. fi
  1136. if test -f drawcard.c -a "${1}" != "-c" ; then 
  1137.   echo shar: Will not over-write existing file \"drawcard.c\"
  1138. else
  1139. echo shar: Extracting \"drawcard.c\" \(4771 characters\)
  1140. sed "s/^X//" >drawcard.c <<'END_OF_drawcard.c'
  1141. X/*
  1142. X * drawcard.c
  1143. X *
  1144. X * display cards on the table
  1145. X */
  1146. X
  1147. X# include    "mille.h"
  1148. X# include    "ui.h"
  1149. X# include    "card.h"
  1150. X
  1151. Xstruct card_init {
  1152. X    short    *bits;
  1153. X    short    *mask;
  1154. X    int    color;
  1155. X};
  1156. X
  1157. Xextern short    go_bits[], go_mask_bits[];
  1158. Xextern short    stop_bits[], stop_mask_bits[];
  1159. Xextern short    right_bits[], right_mask_bits[];
  1160. Xextern short    speed_bits[], speed_mask_bits[];
  1161. Xextern short    end_bits[], end_mask_bits[];
  1162. Xextern short    accident_bits[], accident_mask_bits[];
  1163. Xextern short    repairs_bits[], repairs_mask_bits[];
  1164. Xextern short    ace_bits[], ace_mask_bits[];
  1165. Xextern short    flat_bits[], flat_mask_bits[];
  1166. Xextern short    spare_bits[], spare_mask_bits[];
  1167. Xextern short    puncture_bits[], puncture_mask_bits[];
  1168. Xextern short    out_bits[], out_mask_bits[];
  1169. Xextern short    gas_bits[], gas_mask_bits[];
  1170. Xextern short    extra_bits[], extra_mask_bits[];
  1171. Xextern short    miles_mask_bits[];
  1172. Xextern short    _25_bits[], _50_bits[], _75_bits[], _100_bits[], _200_bits[];
  1173. X
  1174. Xstruct card_init card_inits[NUM_CARDS] = {
  1175. X{    _25_bits,    miles_mask_bits,    BLUE_COLOR,    },
  1176. X{    _50_bits,    miles_mask_bits,    BLUE_COLOR,    },
  1177. X{    _75_bits,    miles_mask_bits,    BLUE_COLOR,    },
  1178. X{    _100_bits,    miles_mask_bits,    BLUE_COLOR,    },
  1179. X{    _200_bits,    miles_mask_bits,    BLUE_COLOR,    },
  1180. X{    out_bits,    out_mask_bits,        RED_COLOR,    },
  1181. X{    flat_bits,    flat_mask_bits,        RED_COLOR,    },
  1182. X{    accident_bits,    accident_mask_bits,    RED_COLOR,    },
  1183. X{    stop_bits,    stop_mask_bits,        RED_COLOR,    },
  1184. X{    speed_bits,    speed_mask_bits,    RED_COLOR,    },
  1185. X{    gas_bits,    gas_mask_bits,        GREEN_COLOR,    },
  1186. X{    spare_bits,    spare_mask_bits,    GREEN_COLOR,    },
  1187. X{    repairs_bits,    repairs_mask_bits,    GREEN_COLOR,    },
  1188. X{    go_bits,    go_mask_bits,        GREEN_COLOR,    },
  1189. X{    end_bits,    end_mask_bits,        GREEN_COLOR,    },
  1190. X{    extra_bits,    extra_mask_bits,    BLUE_COLOR,    },
  1191. X{    puncture_bits,    puncture_mask_bits,    BLUE_COLOR,    },
  1192. X{    ace_bits,    ace_mask_bits,        BLUE_COLOR,    },
  1193. X{    right_bits,    right_mask_bits,    RED_COLOR,    },
  1194. X};
  1195. X
  1196. Xextern short    deck_red_bits[], deck_blue_bits[], deck_mask_bits[];
  1197. X
  1198. Xextern short    blank_bits[];
  1199. X
  1200. Xstruct card cards[NUM_CARDS];
  1201. X
  1202. Xstruct card backside;
  1203. Xstruct card eraseCard;
  1204. X
  1205. X
  1206. Xinit_cards ()
  1207. X{
  1208. X    int    i;
  1209. X    for (i = 0; i < NUM_CARDS; i++) {
  1210. X        cards[i].planes[2].bits = XStoreBitmap (WIDTH, HEIGHT, card_inits[i].bits);
  1211. X        cards[i].planes[2].pixel = colorMap[card_inits[i].color].pixel;
  1212. X        cards[i].planes[1].bits = XStoreBitmap (WIDTH, HEIGHT, card_inits[i].mask);
  1213. X        cards[i].planes[1].pixel = colorMap[BLACK_COLOR].pixel;
  1214. X        cards[i].planes[0].bits = fill;
  1215. X        cards[i].planes[0].pixel = colorMap[WHITE_COLOR].pixel;
  1216. X        cards[i].nPlanes = 3;
  1217. X    }
  1218. X    backside.planes[3].bits = XStoreBitmap (WIDTH, HEIGHT, deck_red_bits);
  1219. X    backside.planes[3].pixel = colorMap[RED_COLOR].pixel;
  1220. X    backside.planes[2].bits = XStoreBitmap (WIDTH, HEIGHT, deck_blue_bits);
  1221. X    backside.planes[2].pixel = colorMap[BLUE_COLOR].pixel;
  1222. X    backside.planes[1].bits = XStoreBitmap (WIDTH, HEIGHT, deck_mask_bits);
  1223. X    backside.planes[1].pixel = colorMap[BLACK_COLOR].pixel;
  1224. X    backside.planes[0].bits = fill;
  1225. X    backside.planes[0].pixel = colorMap[GREEN_COLOR].pixel;
  1226. X    backside.nPlanes = 4;
  1227. X    eraseCard.planes[0].bits = XStoreBitmap (WIDTH, HEIGHT, blank_bits);
  1228. X    eraseCard.planes[0].pixel = colorMap[GREY_COLOR].pixel;
  1229. X    eraseCard.nPlanes = 1;
  1230. X}
  1231. X
  1232. XdisplayCard (card, x, y)
  1233. Xint    card;
  1234. Xint    x, y;
  1235. X{
  1236. X    if (card < 0 || card >= NUM_CARDS) {
  1237. X        cardDisplay (&eraseCard, x, y);
  1238. X    } else {
  1239. X        cardDisplay (&cards[card], x, y);
  1240. X    }
  1241. X}
  1242. X
  1243. Xstruct displayed {
  1244. X    struct displayed    *next;
  1245. X    struct card        *card;
  1246. X    int            x, y;
  1247. X    int            flag;
  1248. X};
  1249. X
  1250. Xstatic struct displayed    *onscreen;
  1251. X
  1252. XcardDisplay (c, x, y)
  1253. Xstruct card    *c;
  1254. X{
  1255. X    int    i;
  1256. X    struct displayed    *d, *p;
  1257. X    char            *malloc ();
  1258. X
  1259. X    p = 0;
  1260. X    for (d = onscreen; d; d = d->next) {
  1261. X        if (d->x == x && d->y == y) {
  1262. X            if (d->card == c)
  1263. X                return;
  1264. X            if (p) {
  1265. X                p->next = d->next;
  1266. X                d->next = onscreen;
  1267. X                onscreen = d;
  1268. X            }
  1269. X            goto gotim;
  1270. X        }
  1271. X        p = d;
  1272. X    }
  1273. X    d = (struct displayed *) malloc (sizeof (struct displayed));
  1274. X    d->x = x;
  1275. X    d->y = y;
  1276. X    if (p)
  1277. X        p->next = d;
  1278. X    else
  1279. X        onscreen = d;
  1280. X    d->next = 0;
  1281. Xgotim:    ;
  1282. X    d->card = c;
  1283. X    drawIm (c, x, y);
  1284. X}
  1285. X
  1286. Xstatic
  1287. XdrawIm (c, x, y)
  1288. Xstruct card    *c;
  1289. Xint        x, y;
  1290. X{
  1291. X    int    i;
  1292. X
  1293. X    for (i = 0; i < c->nPlanes; i++) {
  1294. X        XPixFill (xwindow, x, y, WIDTH, HEIGHT,
  1295. X            c->planes[i].pixel, c->planes[i].bits, GXcopy, AllPlanes);
  1296. X    }
  1297. X}
  1298. X
  1299. XcardRedisplay (x, y, w, h)
  1300. X{
  1301. X    struct displayed    *d;
  1302. X
  1303. X    for (d = onscreen; d; d = d->next)
  1304. X        d->flag = 0;
  1305. X    redisplaybelow (onscreen, x, y, w, h);
  1306. X}
  1307. X
  1308. Xstatic
  1309. Xredisplaybelow (d, x, y, w, h)
  1310. Xstruct displayed    *d;
  1311. X{
  1312. X    int            x2, y2;
  1313. X
  1314. X    x2 = x + w;
  1315. X    y2 = y + h;
  1316. X    for (; d; d = d->next) {
  1317. X        if ((d->x <= x2 && x <= (d->x + WIDTH)) &&
  1318. X            (d->y <= y2 && y <= (d->y + HEIGHT)))
  1319. X         {
  1320. X                if (d->flag == 0) {
  1321. X                drawIm (d->card, d->x, d->y);
  1322. X                d->flag = 1;
  1323. X                redisplaybelow (d->next, d->x, d->y, WIDTH, HEIGHT);
  1324. X            }
  1325. X        }
  1326. X    }
  1327. X
  1328. X}
  1329. X
  1330. XcardEraseAll ()
  1331. X{
  1332. X    struct displayed    *d, *n;
  1333. X
  1334. X    for (d = onscreen; d; d = n) {
  1335. X        n = d->next;
  1336. X        free (d);
  1337. X    }
  1338. X    onscreen = 0;
  1339. X}
  1340. END_OF_drawcard.c
  1341. if test 4771 -ne `wc -c <drawcard.c`; then
  1342.     echo shar: \"drawcard.c\" unpacked with wrong size!
  1343. fi
  1344. # end of overwriting check
  1345. fi
  1346. if test -f end.c -a "${1}" != "-c" ; then 
  1347.   echo shar: Will not over-write existing file \"end.c\"
  1348. else
  1349. echo shar: Extracting \"end.c\" \(2207 characters\)
  1350. sed "s/^X//" >end.c <<'END_OF_end.c'
  1351. X# include    "mille.h"
  1352. X
  1353. X/*
  1354. X * @(#)end.c    1.1 (Berkeley) 4/1/82
  1355. X */
  1356. X
  1357. X/*
  1358. X *    print out the score as if it was final, and add the totals for
  1359. X * the end-of-games points to the user who deserves it (if any).
  1360. X */
  1361. Xfinalscore(pp)
  1362. Xreg PLAY    *pp; {
  1363. X
  1364. X    reg int        temp, tot, num;
  1365. X
  1366. X    num = pp - Player;
  1367. X    for (tot = 4; tot <= 8; tot++) {
  1368. X        InScore (tot, num, "   0  ");
  1369. X    }
  1370. X    if (pp->mileage == End) {
  1371. X        InScore (4, num, " 400  ");
  1372. X        tot = SC_TRIP;
  1373. X        if (pp->nummiles[C_200] == 0) {
  1374. X            InScore (5, num, " 300  ");
  1375. X            tot = SC_TRIP + SC_SAFE;
  1376. X        }
  1377. X        if (Topcard <= Deck) {
  1378. X            InScore (6, num, " 300  ");
  1379. X            tot += SC_DELAY;
  1380. X        }
  1381. X        if (End == 1000) {
  1382. X            InScore (7, num, " 200  ");
  1383. X            tot += SC_EXTENSION;
  1384. X        }
  1385. X        if (Player[other(num)].mileage == 0) {
  1386. X            InScore (8, num, " 500  ");
  1387. X            tot += SC_SHUT_OUT;
  1388. X        }
  1389. X        pp->total += tot;
  1390. X        pp->hand_tot += tot;
  1391. X    }
  1392. X}
  1393. X
  1394. X# ifdef EXTRAP
  1395. Xstatic int    Last_tot[2];    /* last tot used for extrapolate    */
  1396. X
  1397. X/*
  1398. X *    print out the score as if it was final, and add the totals for
  1399. X * the end-of-games points to the user who deserves it (if any).
  1400. X */
  1401. Xextrapolate(pp)
  1402. Xreg PLAY    *pp; {
  1403. X
  1404. X    reg int        x, num, tot, count;
  1405. X
  1406. X#ifdef NOTYET
  1407. X    num = pp - Player;
  1408. X    tot += SC_TRIP + SC_DELAY + SC_EXT;
  1409. X    x = num * 6 + 21 + 3;
  1410. X    for (tot = 5; tot <= 9; tot++)
  1411. X        mvaddch(tot, x, '0');
  1412. X    x -= 2;
  1413. X    pp = &Player[other(num)];
  1414. X    for (count = 0, tot = 0; tot < NUM_SAFE; tot++)
  1415. X        if (pp->safety[tot] != S_PLAYED)
  1416. X            count += SC_SAFE;
  1417. X    mvprintw(3, x, "%3d", count);
  1418. X    tot += count;
  1419. X    if (count == 400) {
  1420. X        mvaddstr(4, x, "30");
  1421. X        tot += SC_ALL_SAFE;
  1422. X    }
  1423. X    pp = &Player[num];
  1424. X    for (count = 0, tot = 0; tot < NUM_SAFE; tot++)
  1425. X        if (pp->safety[tot] != S_PLAYED)
  1426. X            count += SC_COUP / 10;
  1427. X    mvprintw(4, x - 1, "%3d", count);
  1428. X    tot += count;
  1429. X    tot += 1000 - pp->mileage;
  1430. X    mvaddstr(5, x, "40");
  1431. X    mvaddstr(7, x, "30");
  1432. X    mvaddstr(8, x, "20");
  1433. X    if (pp->nummiles[C_200] == 0) {
  1434. X        mvaddstr(6, x, "30");
  1435. X        tot = SC_TRIP + SC_SAFE;
  1436. X    }
  1437. X    if (Player[other(num)].mileage == 0) {
  1438. X        mvaddstr(9, x, "50");
  1439. X        tot += SC_SHUT_OUT;
  1440. X    }
  1441. X    pp->total += tot;
  1442. X    pp->hand_tot += tot;
  1443. X    Last_tot[num] = tot;
  1444. X#endif
  1445. X}
  1446. X
  1447. Xundoex() {
  1448. X
  1449. X    reg PLAY    *pp;
  1450. X    reg int        i;
  1451. X
  1452. X    i = 0;
  1453. X    for (pp = Player; pp < &Player[2]; pp++) {
  1454. X        pp->total -= Last_tot[i];
  1455. X        pp->hand_tot -= Last_tot[i++];
  1456. X    }
  1457. X}
  1458. X# endif
  1459. END_OF_end.c
  1460. if test 2207 -ne `wc -c <end.c`; then
  1461.     echo shar: \"end.c\" unpacked with wrong size!
  1462. fi
  1463. # end of overwriting check
  1464. fi
  1465. if test -f fill -a "${1}" != "-c" ; then 
  1466.   echo shar: Will not over-write existing file \"fill\"
  1467. else
  1468. echo shar: Extracting \"fill\" \(9266 characters\)
  1469. sed "s/^X//" >fill <<'END_OF_fill'
  1470. X#define fill_width 100
  1471. X#define fill_height 150
  1472. Xstatic short fill_bits[] = {
  1473. X   0x0000, 0x0000, 0x0000, 0x0000,
  1474. X   0x0000, 0x0000, 0xfff0, 0xff00,
  1475. X   0xffff, 0xffff, 0xffff, 0xffff,
  1476. X   0x0fff, 0xfff0, 0xffc0, 0xffff,
  1477. X   0xffff, 0xffff, 0xffff, 0x3fff,
  1478. X   0xfff0, 0xfff0, 0xffff, 0xffff,
  1479. X   0xffff, 0xffff, 0xffff, 0xfff0,
  1480. X   0xfff8, 0xffff, 0xffff, 0xffff,
  1481. X   0xffff, 0xffff, 0xfff1, 0xfff8,
  1482. X   0xffff, 0xffff, 0xffff, 0xffff,
  1483. X   0xffff, 0xfff1, 0xfffc, 0xffff,
  1484. X   0xffff, 0xffff, 0xffff, 0xffff,
  1485. X   0xfff3, 0xfffc, 0xffff, 0xffff,
  1486. X   0xffff, 0xffff, 0xffff, 0xfff3,
  1487. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1488. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1489. X   0xffff, 0xffff, 0xffff, 0xffff,
  1490. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1491. X   0xffff, 0xffff, 0xffff, 0xffff,
  1492. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1493. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1494. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1495. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1496. X   0xffff, 0xffff, 0xffff, 0xffff,
  1497. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1498. X   0xffff, 0xffff, 0xffff, 0xffff,
  1499. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1500. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1501. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1502. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1503. X   0xffff, 0xffff, 0xffff, 0xffff,
  1504. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1505. X   0xffff, 0xffff, 0xffff, 0xffff,
  1506. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1507. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1508. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1509. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1510. X   0xffff, 0xffff, 0xffff, 0xffff,
  1511. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1512. X   0xffff, 0xffff, 0xffff, 0xffff,
  1513. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1514. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1515. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1516. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1517. X   0xffff, 0xffff, 0xffff, 0xffff,
  1518. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1519. X   0xffff, 0xffff, 0xffff, 0xffff,
  1520. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1521. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1522. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1523. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1524. X   0xffff, 0xffff, 0xffff, 0xffff,
  1525. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1526. X   0xffff, 0xffff, 0xffff, 0xffff,
  1527. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1528. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1529. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1530. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1531. X   0xffff, 0xffff, 0xffff, 0xffff,
  1532. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1533. X   0xffff, 0xffff, 0xffff, 0xffff,
  1534. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1535. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1536. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1537. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1538. X   0xffff, 0xffff, 0xffff, 0xffff,
  1539. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1540. X   0xffff, 0xffff, 0xffff, 0xffff,
  1541. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1542. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1543. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1544. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1545. X   0xffff, 0xffff, 0xffff, 0xffff,
  1546. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1547. X   0xffff, 0xffff, 0xffff, 0xffff,
  1548. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1549. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1550. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1551. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1552. X   0xffff, 0xffff, 0xffff, 0xffff,
  1553. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1554. X   0xffff, 0xffff, 0xffff, 0xffff,
  1555. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1556. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1557. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1558. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1559. X   0xffff, 0xffff, 0xffff, 0xffff,
  1560. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1561. X   0xffff, 0xffff, 0xffff, 0xffff,
  1562. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1563. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1564. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1565. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1566. X   0xffff, 0xffff, 0xffff, 0xffff,
  1567. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1568. X   0xffff, 0xffff, 0xffff, 0xffff,
  1569. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1570. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1571. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1572. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1573. X   0xffff, 0xffff, 0xffff, 0xffff,
  1574. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1575. X   0xffff, 0xffff, 0xffff, 0xffff,
  1576. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1577. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1578. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1579. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1580. X   0xffff, 0xffff, 0xffff, 0xffff,
  1581. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1582. X   0xffff, 0xffff, 0xffff, 0xffff,
  1583. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1584. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1585. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1586. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1587. X   0xffff, 0xffff, 0xffff, 0xffff,
  1588. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1589. X   0xffff, 0xffff, 0xffff, 0xffff,
  1590. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1591. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1592. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1593. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1594. X   0xffff, 0xffff, 0xffff, 0xffff,
  1595. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1596. X   0xffff, 0xffff, 0xffff, 0xffff,
  1597. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1598. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1599. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1600. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1601. X   0xffff, 0xffff, 0xffff, 0xffff,
  1602. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1603. X   0xffff, 0xffff, 0xffff, 0xffff,
  1604. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1605. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1606. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1607. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1608. X   0xffff, 0xffff, 0xffff, 0xffff,
  1609. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1610. X   0xffff, 0xffff, 0xffff, 0xffff,
  1611. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1612. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1613. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1614. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1615. X   0xffff, 0xffff, 0xffff, 0xffff,
  1616. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1617. X   0xffff, 0xffff, 0xffff, 0xffff,
  1618. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1619. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1620. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1621. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1622. X   0xffff, 0xffff, 0xffff, 0xffff,
  1623. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1624. X   0xffff, 0xffff, 0xffff, 0xffff,
  1625. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1626. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1627. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1628. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1629. X   0xffff, 0xffff, 0xffff, 0xffff,
  1630. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1631. X   0xffff, 0xffff, 0xffff, 0xffff,
  1632. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1633. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1634. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1635. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1636. X   0xffff, 0xffff, 0xffff, 0xffff,
  1637. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1638. X   0xffff, 0xffff, 0xffff, 0xffff,
  1639. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1640. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1641. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1642. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1643. X   0xffff, 0xffff, 0xffff, 0xffff,
  1644. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1645. X   0xffff, 0xffff, 0xffff, 0xffff,
  1646. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1647. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1648. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1649. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1650. X   0xffff, 0xffff, 0xffff, 0xffff,
  1651. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1652. X   0xffff, 0xffff, 0xffff, 0xffff,
  1653. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1654. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1655. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1656. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1657. X   0xffff, 0xffff, 0xffff, 0xffff,
  1658. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1659. X   0xffff, 0xffff, 0xffff, 0xffff,
  1660. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1661. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1662. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1663. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1664. X   0xffff, 0xffff, 0xffff, 0xffff,
  1665. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1666. X   0xffff, 0xffff, 0xffff, 0xffff,
  1667. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1668. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1669. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1670. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1671. X   0xffff, 0xffff, 0xffff, 0xffff,
  1672. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1673. X   0xffff, 0xffff, 0xffff, 0xffff,
  1674. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1675. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1676. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1677. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1678. X   0xffff, 0xffff, 0xffff, 0xffff,
  1679. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1680. X   0xffff, 0xffff, 0xffff, 0xffff,
  1681. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1682. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1683. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1684. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1685. X   0xffff, 0xffff, 0xffff, 0xffff,
  1686. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1687. X   0xffff, 0xffff, 0xffff, 0xffff,
  1688. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1689. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1690. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1691. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1692. X   0xffff, 0xffff, 0xffff, 0xffff,
  1693. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1694. X   0xffff, 0xffff, 0xffff, 0xffff,
  1695. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1696. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1697. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1698. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1699. X   0xffff, 0xffff, 0xffff, 0xffff,
  1700. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1701. X   0xffff, 0xffff, 0xffff, 0xffff,
  1702. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1703. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1704. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1705. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1706. X   0xffff, 0xffff, 0xffff, 0xffff,
  1707. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1708. X   0xffff, 0xffff, 0xffff, 0xffff,
  1709. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1710. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1711. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1712. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1713. X   0xffff, 0xffff, 0xffff, 0xffff,
  1714. X   0xffff, 0xfff7, 0xfffe, 0xffff,
  1715. X   0xffff, 0xffff, 0xffff, 0xffff,
  1716. X   0xfff7, 0xfffe, 0xffff, 0xffff,
  1717. X   0xffff, 0xffff, 0xffff, 0xfff7,
  1718. X   0xfffe, 0xffff, 0xffff, 0xffff,
  1719. X   0xffff, 0xffff, 0xfff7, 0xfffe,
  1720. X   0xffff, 0xffff, 0xffff, 0xffff,
  1721. X   0xffff, 0xfff7, 0xfffc, 0xffff,
  1722. X   0xffff, 0xffff, 0xffff, 0xffff,
  1723. X   0xfff3, 0xfffc, 0xffff, 0xffff,
  1724. X   0xffff, 0xffff, 0xffff, 0xfff3,
  1725. X   0xfff8, 0xffff, 0xffff, 0xffff,
  1726. X   0xffff, 0xffff, 0xfff1, 0xfff8,
  1727. X   0xffff, 0xffff, 0xffff, 0xffff,
  1728. X   0xffff, 0xfff1, 0xfff0, 0xffff,
  1729. X   0xffff, 0xffff, 0xffff, 0xffff,
  1730. X   0xfff0, 0xffc0, 0xffff, 0xffff,
  1731. X   0xffff, 0xffff, 0x3fff, 0xfff0,
  1732. X   0xff00, 0xffff, 0xffff, 0xffff,
  1733. X   0xffff, 0x0fff, 0xfff0, 0x0000,
  1734. X   0x0000, 0x0000, 0x0000, 0x0000,
  1735. X   0x0000, 0xfff0};
  1736. END_OF_fill
  1737. if test 9266 -ne `wc -c <fill`; then
  1738.     echo shar: \"fill\" unpacked with wrong size!
  1739. fi
  1740. # end of overwriting check
  1741. fi
  1742. if test -f ui.c -a "${1}" != "-c" ; then 
  1743.   echo shar: Will not over-write existing file \"ui.c\"
  1744. else
  1745. echo shar: Extracting \"ui.c\" \(12859 characters\)
  1746. sed "s/^X//" >ui.c <<'END_OF_ui.c'
  1747. X/*
  1748. X * ui.c
  1749. X *
  1750. X * interface routines for mille
  1751. X */
  1752. X
  1753. X# include    "mille.h"
  1754. X# include    "ui.h"
  1755. X
  1756. X#ifdef CTRL
  1757. X# undef CTRL
  1758. X#endif
  1759. X#define CTRL(x)    (x - 'A' + 1)
  1760. X
  1761. X# include    "background.h"
  1762. X# include    "card.h"
  1763. X
  1764. Xstruct color colorMap[NUM_COLOR] = {
  1765. X    "black",    0,
  1766. X    "white",    0,
  1767. X    "red",        0,
  1768. X    "green",    0,
  1769. X    "light gray",    0,
  1770. X    "blue",        0,
  1771. X};
  1772. X
  1773. Xchar    *C_fmt = "%-18.18s";    /* format for printing cards        */
  1774. Xchar    Initstr[100];        /* initial string for error field    */
  1775. Xchar    *_cn[NUM_CARDS] = {    /* Card name buffer            */
  1776. X        "",
  1777. X        "25",
  1778. X        "50",
  1779. X        "75",
  1780. X        "100",
  1781. X        "200",
  1782. X        "Out of Gas",
  1783. X        "Flat Tire",
  1784. X        "Accident",
  1785. X        "Stop",
  1786. X        "Speed Limit", 
  1787. X        "Gasoline",
  1788. X        "Spare Tire",
  1789. X        "Repairs",
  1790. X        "Go",
  1791. X        "End of Limit",
  1792. X        "Extra Tank",
  1793. X        "Puncture Proof",
  1794. X        "Driving Ace",
  1795. X        "Right of Way"
  1796. X    },
  1797. X    **C_name = &_cn[1];    /* Card names                */
  1798. X
  1799. XWindow        xwindow;
  1800. XFontInfo    *font;
  1801. XBitmap        fill;
  1802. XButton        QUIT, SAVE;
  1803. XWindow        qwindow, swindow;
  1804. X
  1805. Xstruct safety_offset safety_offsets[4] = {
  1806. X    0,        0,
  1807. X    WIDTH+PAD_CARD,    0,
  1808. X    0,        HEIGHT+PAD_CARD,
  1809. X    WIDTH+PAD_CARD,    HEIGHT+PAD_CARD,
  1810. X};
  1811. X
  1812. Xchar *
  1813. Xprune (orig, max)
  1814. Xchar    *orig;
  1815. X{
  1816. X    static char    buf[512];
  1817. X    int        len;
  1818. X    char        c;
  1819. X
  1820. X    if (XStringWidth (orig, font, 0, 0) < max)
  1821. X        return orig;
  1822. X    strcpy (buf, orig);
  1823. X    len = strlen (orig);
  1824. X    do {
  1825. X        buf[--len] = '\0';
  1826. X    } while (len > 0 && XStringWidth (buf, font, 0, 0) >= max);
  1827. X    return buf;
  1828. X}
  1829. X
  1830. XMessage (string)
  1831. Xchar    *string;
  1832. X{
  1833. X    string = prune (string, MESS_W);
  1834. X    XPixSet (xwindow, MESS_X, MESS_Y, MESS_W, MESS_H, colorMap[GREY_COLOR].pixel);
  1835. X    XText (xwindow, MESS_X, MESS_Y, string, strlen(string), font->id,
  1836. X         colorMap[BLACK_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  1837. X}
  1838. X
  1839. XError (string, arg)
  1840. Xchar *string;
  1841. X{
  1842. X    char    buf[512];
  1843. X    char    *o;
  1844. X
  1845. X    sprintf (buf, string, arg);
  1846. X    o = prune (buf, ERROR_W);
  1847. X    XPixSet (xwindow, ERROR_X, ERROR_Y, ERROR_W, ERROR_H, colorMap[GREY_COLOR].pixel);
  1848. X    XText (xwindow, ERROR_X, ERROR_Y, o, strlen(o), font->id,
  1849. X         colorMap[BLACK_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  1850. X}
  1851. X
  1852. XPrompt (string)
  1853. Xchar *string;
  1854. X{
  1855. X    string = prune (string, PROMPT_W);
  1856. X    XPixSet (xwindow, PROMPT_X, PROMPT_Y, PROMPT_W, PROMPT_H, colorMap[GREY_COLOR].pixel);
  1857. X    XText (xwindow, PROMPT_X, PROMPT_Y, string, strlen(string), font->id,
  1858. X         colorMap[BLACK_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  1859. X}
  1860. X
  1861. Xdebug (pos, string, a0, a1, a2)
  1862. X{
  1863. X}
  1864. X
  1865. XComputerStatus (string)
  1866. X{
  1867. X    char    buffer[512];
  1868. X/*
  1869. X    sprintf (buffer, "I %-10.10s", string);
  1870. X    XText (xwindow, COMP_CARD_TX, COMP_CARD_TY, buffer, strlen(buffer), font->id,
  1871. X        colorMap[BLACK_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  1872. X*/
  1873. X}
  1874. X
  1875. XComputerCard (type)
  1876. Xint    type;
  1877. X{
  1878. X/*    displayCard (type, COMP_CARD_X, COMP_CARD_Y);*/
  1879. X}
  1880. X
  1881. Xstatic int    computer_distance = 0;
  1882. X
  1883. XComputerDistance (distance)
  1884. X{
  1885. X    displayDistance (COMP_DIST_X, COMP_DIST_Y, distance, DIST_WIDTH, DIST_HEIGHT);
  1886. X    computer_distance = distance;
  1887. X}
  1888. X
  1889. XEraseComputerDistance ()
  1890. X{
  1891. X    computer_distance = 0;
  1892. X}
  1893. X
  1894. XRedisplayComputerDistance ()
  1895. X{
  1896. X    displayDistance (COMP_DIST_X, COMP_DIST_Y, computer_distance, DIST_WIDTH, DIST_HEIGHT);
  1897. X}
  1898. X
  1899. XComputerSpeed (type)
  1900. X{
  1901. X    displayCard (type, COMP_PLAY_X, COMP_PLAY_Y);
  1902. X}
  1903. X
  1904. XComputerBattle (type)
  1905. X{
  1906. X    displayCard (type, COMP_PLAY_X + WIDTH + PAD_CARD, COMP_PLAY_Y);
  1907. X}
  1908. X
  1909. Xstatic int computer_miles_count[5];
  1910. X
  1911. XComputerMiles (type, index, count)
  1912. X{
  1913. X    while (computer_miles_count[index] < count) {
  1914. X        displayCard (type, COMP_PLAY_X + (WIDTH + PAD_CARD) * (index + 2),
  1915. X            COMP_PLAY_Y + (MILE_OFFSET * computer_miles_count[index]));
  1916. X        ++computer_miles_count[index];
  1917. X    }
  1918. X}
  1919. X
  1920. XEraseComputerMiles ()
  1921. X{
  1922. X    int    i;
  1923. X
  1924. X    for (i = 0; i < 5; i++)
  1925. X        computer_miles_count[i] = 0;
  1926. X}
  1927. X
  1928. XComputerSafety (type, index)
  1929. X{
  1930. X    displayCard (type, COMP_SAFE_X + safety_offsets[index].x,
  1931. X        COMP_SAFE_Y + safety_offsets[index].y);
  1932. X}
  1933. X
  1934. XDisplayDiscard (type)
  1935. X{
  1936. X    displayCard (type, DISCARD_X, DISCARD_Y);
  1937. X}
  1938. X
  1939. XDisplayDeck (numberLeft)
  1940. X{
  1941. X    char    buffer[512];
  1942. X
  1943. X    sprintf (buffer, "Cards: %3d  ", numberLeft);
  1944. X    XText (xwindow, DECK_TX, DECK_TY, buffer, strlen (buffer), font->id,
  1945. X        colorMap[BLACK_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  1946. X}
  1947. X
  1948. Xstatic int human_distance = 0;
  1949. X
  1950. XHumanDistance (distance)
  1951. X{
  1952. X    displayDistance (HUM_DIST_X, HUM_DIST_Y, distance, DIST_WIDTH, DIST_HEIGHT);
  1953. X    human_distance = distance;
  1954. X}
  1955. X
  1956. XEraseHumanDistance ()
  1957. X{
  1958. X    human_distance = 0;
  1959. X}
  1960. X
  1961. XRedisplayHumanDistance ()
  1962. X{
  1963. X    displayDistance (HUM_DIST_X, HUM_DIST_Y, human_distance, DIST_WIDTH, DIST_HEIGHT);
  1964. X}
  1965. X
  1966. XHumanSpeed (type)
  1967. X{
  1968. X    displayCard (type, HUM_PLAY_X, HUM_PLAY_Y);
  1969. X}
  1970. X
  1971. XHumanBattle (type)
  1972. X{
  1973. X    displayCard (type, HUM_PLAY_X + WIDTH + PAD_CARD, HUM_PLAY_Y);
  1974. X}
  1975. X
  1976. Xstatic int human_miles_count[5];
  1977. X
  1978. XHumanMiles (type, index, count)
  1979. X{
  1980. X    while (human_miles_count[index] < count) {
  1981. X        displayCard (type, HUM_PLAY_X + (WIDTH + PAD_CARD) * (index + 2),
  1982. X            HUM_PLAY_Y + (MILE_OFFSET * human_miles_count[index]));
  1983. X        ++human_miles_count[index];
  1984. X    }
  1985. X}
  1986. X
  1987. XEraseHumanMiles ()
  1988. X{
  1989. X    int    i;
  1990. X
  1991. X    for (i = 0; i < 5; i++)
  1992. X        human_miles_count[i] = 0;
  1993. X}
  1994. X
  1995. XHumanSafety (type, index)
  1996. X{
  1997. X    displayCard (type, HUM_SAFE_X + safety_offsets[index].x,
  1998. X        HUM_SAFE_Y + safety_offsets[index].y);
  1999. X}
  2000. X
  2001. XHumanHand (type, index)
  2002. Xint    type, index;
  2003. X{
  2004. X    displayCard (type, HUM_HAND_X + (WIDTH + PAD_CARD) * index, HUM_HAND_Y);
  2005. X}
  2006. X
  2007. XdisplayDistance (x, y, value, width, height)
  2008. X{
  2009. X    XPixSet (xwindow, x, y, (value * width) / 1000, height, colorMap[BLUE_COLOR].pixel);
  2010. X}
  2011. X
  2012. XeraseDistance (x, y, value, width, height)
  2013. X{
  2014. X    XPixSet (xwindow, x, y, (value * width) / 1000, height, colorMap[GREY_COLOR].pixel);
  2015. X}
  2016. X
  2017. Xchar *
  2018. XGetpromptedInput (string)
  2019. Xchar    *string;
  2020. X{
  2021. X    extern char    *co_prompted ();
  2022. X
  2023. X    return co_prompted (string);
  2024. X}
  2025. X
  2026. Xnewboard()
  2027. X{
  2028. X    int    i;
  2029. X    char    buffer[20];
  2030. X    int    len;
  2031. X    int    x, y1, y2, ym1, ym2;
  2032. X    int    width;
  2033. X
  2034. X    XClear (xwindow);
  2035. X    cardEraseAll ();
  2036. X    EraseHumanMiles ();
  2037. X    EraseComputerMiles ();
  2038. X    EraseHumanDistance ();
  2039. X    EraseComputerDistance ();
  2040. X    cardDisplay (&backside, DECK_X, DECK_Y);
  2041. X    redraw_board ();
  2042. X}
  2043. X
  2044. Xnewscore()
  2045. X{
  2046. X    register int    i;
  2047. X
  2048. X    InScore (-1, 0, "You");
  2049. X    InScore (-1, 1, "Computer");
  2050. X    InScore (0, -1, "Milestones");
  2051. X    InScore (1, -1, "Safeties");
  2052. X    InScore (2, -1, "All 4 Safeties");
  2053. X    InScore (3, -1, "Coup Fourre");
  2054. X    InScore (4, -1, "Trip Complete");
  2055. X    InScore (5, -1, "Safe Trip");
  2056. X    InScore (6, -1, "Delayed Action");
  2057. X    InScore (7, -1, "Extension");
  2058. X    InScore (8, -1, "Shut Out");
  2059. X    InScore (9, -1, "Hand Total");
  2060. X    InScore (10, -1, "Overall Total");
  2061. X    InScore (11, -1, "Games");
  2062. X}
  2063. X
  2064. Xredraw_board ()
  2065. X{
  2066. X    redraw_region (0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
  2067. X}
  2068. X
  2069. XexposeBoard (rep)
  2070. XXExposeEvent    *rep;
  2071. X{
  2072. X    redraw_region (rep->x, rep->y, rep->width, rep->height);
  2073. X}
  2074. X
  2075. Xredraw_region (xpos, ypos, w, h)
  2076. X{
  2077. X    int    x1, y1, x2, y2;
  2078. X    int    i;
  2079. X    int    ym1, ym2, x;
  2080. X    char    buffer[20];
  2081. X    int    width;
  2082. X
  2083. X    XText (xwindow, DISCARD_TX, DISCARD_TY, "Discard Pile", 12, font->id,
  2084. X        colorMap[BLACK_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  2085. X    newscore ();
  2086. X    RedisplayHumanDistance ();
  2087. X    RedisplayComputerDistance ();
  2088. X    x1 = HUM_HAND_X - PAD_CARD/2;
  2089. X    y1 = HUM_HAND_Y - PAD_CARD/2,
  2090. X    x2 = HUM_HAND_X + (WIDTH + PAD_CARD) * 7 - PAD_CARD/2;
  2091. X    y2 = HUM_HAND_Y + (HEIGHT + PAD_CARD) - PAD_CARD/2;
  2092. X    XLine (xwindow, x1, y1, x2, y1, 1, 1, colorMap[BLACK_COLOR].pixel, GXcopy, AllPlanes);
  2093. X    XLine (xwindow, x2, y1, x2, y2, 1, 1, colorMap[BLACK_COLOR].pixel, GXcopy, AllPlanes);
  2094. X    XLine (xwindow, x2, y2, x1, y2, 1, 1, colorMap[BLACK_COLOR].pixel, GXcopy, AllPlanes);
  2095. X    XLine (xwindow, x1, y2, x1, y1, 1, 1, colorMap[BLACK_COLOR].pixel, GXcopy, AllPlanes);
  2096. X    for (i = 0; i <= 1000; i += 100) {
  2097. X        sprintf (buffer, "%d", i);
  2098. X        x = COMP_DIST_TX + (i * DIST_WIDTH) / 1000;
  2099. X        y1 = COMP_DIST_TY;
  2100. X        ym1 = COMP_DIST_MY;
  2101. X        y2 = HUM_DIST_TY;
  2102. X        ym2 = HUM_DIST_MY;
  2103. X        width = XQueryWidth (buffer, font->id);
  2104. X        XText (xwindow, x - width / 2, y1, buffer, strlen(buffer), font->id,
  2105. X            colorMap[BLACK_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  2106. X        XLine (xwindow, x, ym1, x, ym1 + DIST_MARK, 1, 1, colorMap[BLACK_COLOR].pixel, GXcopy, AllPlanes);
  2107. X        XText (xwindow, x - width / 2, y2, buffer, strlen(buffer), font->id,
  2108. X            colorMap[BLACK_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  2109. X        XLine (xwindow, x, ym2, x, ym2 + DIST_MARK, 1, 1, colorMap[BLACK_COLOR].pixel, GXcopy, AllPlanes);
  2110. X    }
  2111. X    cardRedisplay (xpos, ypos, w, h);
  2112. X}
  2113. X
  2114. Xinit_ui ()
  2115. X{
  2116. X    Color    hardware_color, exact_color;
  2117. X    XEvent    rep;
  2118. X    Pixmap    background;
  2119. X    Pixmap    border;
  2120. X    int    i;
  2121. X    int    do_quit (), do_save ();
  2122. X    int    CmanageButton ();
  2123. X
  2124. X    XOpenDisplay ("");
  2125. X    for (i = 0; i < NUM_COLOR; i++) {
  2126. X        XGetColor (colorMap[i].name, &hardware_color, &exact_color);
  2127. X        colorMap[i].pixel = hardware_color.pixel;
  2128. X    }
  2129. X    fill = XStoreBitmap (WIDTH, HEIGHT, fill_bits);
  2130. X    init_cards ();
  2131. X    co_init ();
  2132. X    background = XMakePixmap (0, colorMap[GREY_COLOR].pixel, colorMap[WHITE_COLOR].pixel);
  2133. X    border = XMakePixmap (0, colorMap[WHITE_COLOR].pixel, colorMap[GREY_COLOR].pixel);
  2134. X    font = XOpenFont ("timrom12");
  2135. X    xwindow = XCreateWindow (RootWindow, 50, 50, WINDOW_WIDTH, WINDOW_HEIGHT, 1,
  2136. X        WhitePixmap, background);
  2137. X    QUIT = CcreateButton (font, "Quit", 50, colorMap[WHITE_COLOR].pixel,
  2138. X        colorMap[GREY_COLOR].pixel, 1);
  2139. X    SAVE = CcreateButton (font, "Save", 50, colorMap[WHITE_COLOR].pixel,
  2140. X        colorMap[GREY_COLOR].pixel, 1);
  2141. X    qwindow = CmapButton (xwindow, QUIT_X, QUIT_Y, QUIT, do_quit);
  2142. X    swindow = CmapButton (xwindow, SAVE_X, SAVE_Y, SAVE, do_save);
  2143. X    bindEvent (qwindow, ExposeWindow|ButtonPressed|LeaveWindow|ButtonReleased,
  2144. X        CmanageButton);
  2145. X    bindEvent (swindow, ExposeWindow|ButtonPressed|LeaveWindow|ButtonReleased,
  2146. X        CmanageButton);
  2147. X    XMapWindow (xwindow);
  2148. X
  2149. X    bindEvent (xwindow, ExposeWindow|ExposeRegion, exposeBoard);
  2150. X}
  2151. X
  2152. X
  2153. Xfinish_ui ()
  2154. X{
  2155. X}
  2156. X
  2157. Xupdate_ui ()
  2158. X{
  2159. X    XFlush ();
  2160. X}
  2161. X
  2162. XBeep ()
  2163. X{
  2164. X    XFeep (0);
  2165. X}
  2166. X
  2167. X/*
  2168. X *    Get a yes or no answer to the given question.  Saves are
  2169. X * also allowed.  Return TRUE if the answer was yes, FALSE if no.
  2170. X */
  2171. X
  2172. Xgetyn(prompt)
  2173. Xregister char    *prompt;
  2174. X{
  2175. X
  2176. X    register char    c;
  2177. X
  2178. X    return co_affirm (prompt);
  2179. X}
  2180. X
  2181. Xstatic char    incharacter;
  2182. Xstatic int    gotcharacter;
  2183. X
  2184. Xstatic int    getmove_done;
  2185. X
  2186. Xmouse_event (rep)
  2187. XXButtonEvent    *rep;
  2188. X{
  2189. X    int    x, y;
  2190. X    
  2191. X    x = rep->x;
  2192. X    y = rep->y;
  2193. X    if (HUM_HAND_Y <= y && y <= HUM_HAND_Y + HEIGHT &&
  2194. X        HUM_HAND_X <= x && x <= HUM_HAND_X + (WIDTH + PAD_CARD) * 7) {
  2195. X        switch (rep->detail & 0377) {
  2196. X        case RightButton:
  2197. X            Movetype = M_DISCARD;
  2198. X            break;
  2199. X        case MiddleButton:
  2200. X            Movetype = M_REASONABLE;
  2201. X            break;
  2202. X        case LeftButton:
  2203. X            Movetype = M_PLAY;
  2204. X            break;
  2205. X        }
  2206. X        Card_no = (x - HUM_HAND_X) / (WIDTH + PAD_CARD);
  2207. X        getmove_done = 1;
  2208. X        return;
  2209. X    }
  2210. X    if (DECK_Y <= y && y <= DECK_Y + HEIGHT &&
  2211. X        DECK_X <= x && x <= DECK_X + WIDTH) {
  2212. X        Movetype = M_DRAW;
  2213. X        getmove_done = 1;
  2214. X        return;
  2215. X    }
  2216. X    Beep ();
  2217. X}
  2218. X
  2219. Xgetmove()
  2220. X{
  2221. X    
  2222. X    getmove_done = 0;
  2223. X    bindEvent (xwindow, ButtonPressed, mouse_event);
  2224. X    while (!getmove_done) {
  2225. X        dispatch ();
  2226. X    }
  2227. X    unbindEvent (xwindow, ButtonPressed);
  2228. X}
  2229. X
  2230. X
  2231. Xdo_save ()
  2232. X{
  2233. X    save ();
  2234. X}
  2235. X
  2236. Xdo_quit ()
  2237. X{
  2238. X    rub();
  2239. X}
  2240. X
  2241. X# define    COMP_STRT    20
  2242. X# define    CARD_STRT    2
  2243. X
  2244. Xprboard() {
  2245. X
  2246. X    register PLAY    *pp;
  2247. X    register int        i, j, k, temp;
  2248. X
  2249. X    for (k = 0; k < 2; k++) {
  2250. X        pp = &Player[k];
  2251. X        temp = k * COMP_STRT + CARD_STRT;
  2252. X        for (i = 0; i < NUM_SAFE; i++)
  2253. X            if (pp->safety[i] == S_PLAYED) {
  2254. X                if (k == 0) {
  2255. X                    HumanSafety (i + S_CONV, i);
  2256. X                } else {
  2257. X                    ComputerSafety (i + S_CONV, i);
  2258. X                }
  2259. X            }
  2260. X        if (k == 0) {
  2261. X            HumanBattle (pp->battle);
  2262. X            HumanSpeed (pp->speed);
  2263. X        } else {
  2264. X            ComputerBattle (pp->battle);
  2265. X            ComputerSpeed (pp->speed);
  2266. X        }
  2267. X        for (i = C_25; i <= C_200; i++) {
  2268. X            register char    *name;
  2269. X            register int        end;
  2270. X
  2271. X            name = C_name[i];
  2272. X            temp = k * 40;
  2273. X            end = pp->nummiles[i];
  2274. X            if (k == 0)
  2275. X                HumanMiles (i, C_200-i, end);
  2276. X            else
  2277. X                ComputerMiles (i, C_200-i, end);
  2278. X        }
  2279. X    }
  2280. X    prscore(TRUE);
  2281. X    temp = CARD_STRT;
  2282. X    pp = &Player[PLAYER];
  2283. X    for (i = 0; i < HAND_SZ; i++) {
  2284. X        HumanHand (pp->hand[i], i);
  2285. X    }
  2286. X    DisplayDeck (Topcard - Deck);
  2287. X    DisplayDiscard (Discard);
  2288. X    if (End == 1000) {
  2289. X        static char    ext[] = "Extension";
  2290. X
  2291. X/*        stand(EXT_Y, EXT_X, ext); */
  2292. X    }
  2293. X}
  2294. X
  2295. X/*
  2296. X *    Put str at (y,x) in standout mode
  2297. X */
  2298. X
  2299. Xstand(y, x, str)
  2300. Xregister int        y, x;
  2301. Xregister char    *str;
  2302. X{
  2303. X}
  2304. X
  2305. XInScore (line, player, text)
  2306. Xint    line, player;
  2307. Xchar    *text;
  2308. X{
  2309. X    XText (xwindow, SCORE_X + player * SCORE_W, SCORE_Y + SCORE_H * (line + 1),
  2310. X        text, strlen (text), font->id, colorMap[BLACK_COLOR].pixel,
  2311. X         colorMap[GREY_COLOR].pixel);
  2312. X}
  2313. X
  2314. Xprscore(for_real)
  2315. Xregister bool    for_real;
  2316. X{
  2317. X
  2318. X    register PLAY    *pp;
  2319. X    register int        x;
  2320. X    register char    *Score_fmt = "%4d  ";
  2321. X    char        buffer[512];
  2322. X
  2323. X    ComputerDistance (Player[1].mileage);
  2324. X    HumanDistance (Player[0].mileage);
  2325. X
  2326. X    for (pp = Player; pp < &Player[2]; pp++) {
  2327. X        x = (pp - Player) * 6 + 21;
  2328. X        sprintf (buffer, Score_fmt, pp->mileage);
  2329. X        InScore (0, pp - Player, buffer);
  2330. X        sprintf (buffer, Score_fmt, pp->safescore);
  2331. X        InScore (1, pp - Player, buffer);
  2332. X        if (pp->safescore == 400)
  2333. X            InScore (2, pp - Player, " 300 ");
  2334. X        else
  2335. X            InScore (2, pp - Player, "   0 ");
  2336. X        sprintf (buffer, Score_fmt, pp->coupscore);
  2337. X        InScore (3, pp - Player, buffer);
  2338. X#ifdef EXTRAP
  2339. X        if (for_real)
  2340. X            finalscore(pp);
  2341. X        else
  2342. X            extrapolate(pp);
  2343. X#else
  2344. X        finalscore(pp);
  2345. X#endif
  2346. X        sprintf (buffer, Score_fmt, pp->hand_tot);
  2347. X        InScore (9, pp - Player, buffer);
  2348. X        sprintf (buffer, Score_fmt, pp->total);
  2349. X        InScore (10, pp - Player, buffer);
  2350. X        sprintf (buffer, Score_fmt, pp->games);
  2351. X        InScore (11, pp - Player, buffer);
  2352. X    }
  2353. X}
  2354. X
  2355. XFlushInput ()
  2356. X{
  2357. X}
  2358. END_OF_ui.c
  2359. if test 12859 -ne `wc -c <ui.c`; then
  2360.     echo shar: \"ui.c\" unpacked with wrong size!
  2361. fi
  2362. # end of overwriting check
  2363. fi
  2364. echo shar: End of archive 1 \(of 3\).
  2365. cp /dev/null ark1isdone
  2366. MISSING=""
  2367. for I in 1 2 3 ; do
  2368.     if test ! -f ark${I}isdone ; then
  2369.     MISSING="${MISSING} ${I}"
  2370.     fi
  2371. done
  2372. if test "${MISSING}" = "" ; then
  2373.     echo You have unpacked all 3 archives.
  2374.     echo "Now uudecode and uncompress 'cards.Z.uu' and feed to sh"
  2375.     rm -f ark[1-9]isdone
  2376. else
  2377.     echo You still need to unpack the following archives:
  2378.     echo "        " ${MISSING}
  2379. fi
  2380. ##  End of shell archive.
  2381. exit 0
  2382.  
  2383.  
  2384.