home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / 3b1 / volume02 / klndike2 / part01 < prev    next >
Encoding:
Internet Message Format  |  1992-06-27  |  46.8 KB

  1. Path: comp-sources-3b1
  2. From: vern@zebra.alphacdc.com (vern)
  3. Subject:  v02i009:  Klondike, version 2, Part01/06
  4. Newsgroups: comp.sources.3b1
  5. Approved: dave@galaxia.network23.com
  6. X-Checksum-Snefru: 8053e686 b5bea1bf 1b3ad936 c7c6f2ed
  7.  
  8. Submitted-by: vern@zebra.alphacdc.com (vern)
  9. Posting-number: Volume 2, Issue 9
  10. Archive-name: klondike2/part01
  11.  
  12. [ Vern doesn't really call this "version 2" but since there was already an  ]
  13. [ existing klondike in the archives I have taken the liberty of adding the  ]
  14. [ version number.  Consider this as meaning "the second version of klondike ]
  15. [ that was posted in this newsgroup".                                       ]
  16. [     Dave.                                                                 ]
  17.  
  18. This is the same 'klondike' game that Tom Tkacik posted some time ago.
  19. I have hacked in some additional compile time options. These new
  20. "features"?? are:
  21.  
  22. SCORES:    Calculate and display the score when playing the "Vegas" style.
  23.     Scoring starts at -52 points for each new hand and all cards in
  24.     the upper our stacks count +5 points except for uncovered Aces.
  25.     Another way to state this is that Aces count zero, Dueces count
  26.     +10 and all other cards count +5.
  27.  
  28.     Scores are displayed for the current hand, accumulated scores
  29.     for this session and accumulated scores since forever.  You can
  30.     reset "forever" with the 'F7', ZERO HIST, key.
  31.  
  32. CHEAT:    This displays a prompt if you attempt to turn over a card from
  33.     the down deck and another play can be made on the board.  The
  34.     suggested play is not necessarily the best play, it is the just
  35.     the first one the computer found.
  36.  
  37.     A second click on the left mouse button will ignore the prompt
  38.     and allow you to proceed.
  39.  
  40.     This option can enabled or disabled at any time with the 'F4',
  41.     CHEAT ON/OFF, key.
  42.  
  43. UNDO:    Now we are getting into some serious cheating.  The 'F5', UNDO,
  44.     key or the 'Undo' key on the left of the keyboard allows you to
  45.     backtrack one play at a time.  This will continue until you reach
  46.     the original display.  A quicker way of starting over is to press
  47.     the 'F3', REPLAY HAND, key.
  48.  
  49. MARKS:    Keeping on with more and better cheating, The 'Mark' key at the
  50.     lower left corner of the keyboard can be pressed at any time.
  51.     Later, should you care to return to this display, use the 'Slect'
  52.     or 'Shift Mark' key.
  53.  
  54.     The number of marked displays is indicated just below the unturned
  55.     deck.
  56.  
  57. RUN:    This was suggested Kris Kugel and Tom Tkacik.  After all the down
  58.     cards have been turned up, the game has been essentially won.
  59.     The 'F6' key is activated and is identified on the screen as "RUN".
  60.     Selecting RUN lets the computer move all the up cards to the upper
  61.     out stacks and finish the game.
  62.  
  63.     You can still UNDO or Slect marked displays if winning isn't all
  64.     you have in mind.
  65.  
  66. Included in this package are several ways to install this game.  Check
  67. the README for instructions.  This not truly an "+IN" type suite, it does
  68. not contain the binaries.  However it does have the scripts needed
  69. to 'Install' via the User Agent.
  70.  
  71. If you would like to test the RUN feature, try "klondike -n2533814".
  72. This hand is hard to lose.  For a more challenging win, try playing
  73. "klondike -n6287970".  It can be won!
  74.  
  75. vern
  76.  
  77. Vernon C. Hoxie                            {ncar,boulder}!scicom!zebra!vern
  78. 3975 W. 29th Ave.                                       voice: 303-477-1780
  79. Denver, Colo., 80212                                     uucp: 303-455-2670
  80.  
  81. ------------------------------ cut here -----------------------------------
  82.  
  83. #! /bin/sh
  84. # This is a shell archive.  Remove anything before this line, then unpack
  85. # it by saving it into a file and typing "sh file".  To overwrite existing
  86. # files, type "sh file -c".  You can also feed this as standard input via
  87. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  88. # will see the following message at the end:
  89. #        "End of archive 1 (of 6)."
  90. # Contents:  Files History INSTALL.sh Install MAKEcpio MAKEflop
  91. #   MANIFEST Makefile Name Office README Remove Size Toybox cards.c
  92. #   drag.c klondike.6 klondike.h window.c
  93. # Wrapped by vern@zebra on Tue Jun 23 07:22:36 1992
  94. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  95. if test -f Files -a "${1}" != "-c" ; then 
  96.   echo shar: Will not over-write existing file \"Files\"
  97. else
  98. echo shar: Extracting \"Files\" \(267 characters\)
  99. sed "s/^X//" >Files <<'END_OF_Files'
  100. X.
  101. X./Files
  102. X./History
  103. X./INSTALL.sh
  104. X./Install
  105. X./MAKEcpio
  106. X./MAKEflop
  107. X./Makefile
  108. X./Name
  109. X./Office
  110. X./README
  111. X./Remove
  112. X./Size
  113. X./Toybox
  114. X./cards.c
  115. X./check.c
  116. X./club.c
  117. X./diamond.c
  118. X./drag.c
  119. X./heart.c
  120. X./klondike.6
  121. X./klondike.c
  122. X./klondike.h
  123. X./other.c
  124. X./patch.01
  125. X./spade.c
  126. X./window.c
  127. END_OF_Files
  128. if test 267 -ne `wc -c <Files`; then
  129.     echo shar: \"Files\" unpacked with wrong size!
  130. fi
  131. # end of overwriting check
  132. fi
  133. if test -f History -a "${1}" != "-c" ; then 
  134.   echo shar: Will not over-write existing file \"History\"
  135. else
  136. echo shar: Extracting \"History\" \(4750 characters\)
  137. sed "s/^X//" >History <<'END_OF_History'
  138. XKlondike is that most popular of solitaire card games you learned as a child.
  139. XThis version was written specifically for the AT&T UnixPC (3B1 or 7300).
  140. XIt uses UnixPC graphics, and will probably not be very easy to port to
  141. Xother machines, (though I don't doubt that someone try it.:-)
  142. X
  143. XIt is played with a single deck of cards, and the goal is to move as many
  144. Xcards as possible from their initial positions (the tableau),
  145. Xto output piles, (or foundations).
  146. XThe game is won if all of the cards are removed from the tableau.
  147. X
  148. XI must thank Kent Quander for allowing me to
  149. Xuse and distribute his wonderfully drawn playing cards.
  150. X
  151. XThere are a couple of compile time options.
  152. XNormally the games beeps when you make a mistake, but I got tired of the
  153. Xnoise, so there is a NOBEEP option which will make it keep quiet.
  154. X
  155. XI have also included an alternative to Kent's Ace of spades.
  156. XLeaving off the BYQ option, you will see it.
  157. X(The original is more imaginative.)
  158. X
  159. XAnd finally, I had trouble getting the mouse to repond properly when I
  160. Xcompiled it with cc.  I had no problems with gcc.
  161. XI added a couple of patches, (invoked with BADMOUSE), which fixed things.
  162. XYou should not need it, but it does not hurt.
  163. XYou can try leaving it out if you want.
  164. X
  165. XI do not like the borders on the standard windows, so (as is my practice),
  166. XI made my own.  All that is lacking are the move and resize icons.
  167. XIf anyone can figure out how they might be implemented, I would
  168. Xlike to hear about it.
  169. X
  170. XType make, and have fun.
  171. X
  172. XTom Tkacik
  173. Xtkacik@kyzyl.mi.org
  174. X...!rphroy!kyzyl!tkacik
  175. X
  176. XNov. 2, 1991
  177. X
  178. XI added the scoring and cheating features.
  179. X
  180. X"Scoring" provides a score keeping facility.  It is active only for the
  181. X"Vegas" style of playing.  Each new game starts at -52.  Then each card
  182. Xover a covered ace counts +5.  With these rules, uncovered aces count
  183. Xnothing.  Dueces count +10 and all subsequent cards in that suit count
  184. X+5 points.
  185. X
  186. XUpon exiting, the three display score are added together and saved with
  187. Xthe players login name until the next time the game is played.
  188. X
  189. XThe "cheating" feature will beep if another play is available when you
  190. Xtry to turn over a new card from the down deck.  This feature may be
  191. Xdisabled/enabled with the 'F4' function key.  If you prefer to ignore
  192. Xany possible moves, a second push on the left mouse button will go ahead
  193. Xand turn over the next card.
  194. X
  195. XIn this mode, one possible move is displayed at the bottom of the playing
  196. Xarea.  This is not the only move possible nor the smartest move, it is
  197. Xonly one posibility.  In 'Vegas' mode, an additional push on the left
  198. Xmouse button will check for any final moves.
  199. X
  200. XThese features may be eliminated at compile time by commenting out the
  201. X"#define CHEAT" and/or "#define SCORES" lines in 'klondike.h'.
  202. X
  203. XHave fun!
  204. X
  205. Xvern
  206. X
  207. XVernon C. Hoxie                            {ncar,boulder}!scicom!zebra!vern
  208. X3975 W. 29th Ave.                                       voice: 303-477-1780
  209. XDenver, Colo., 80212                          TB+        uucp: 303-455-2670
  210. X
  211. XJune 5, 1992
  212. X
  213. XSome refinments were added to the CHEAT option.
  214. X
  215. XThe UNDO feature was added.  Each time the F5 button is pressed, the
  216. Xdisplay is moved back one move.  Like CHEAT and SCORES, this is a
  217. Xcompile time option.  
  218. X
  219. XThe MARKS option was added.  This allows a specific screen to be marked
  220. Xby pressing the Mark Key ( lower left corner of the 3b1 keyboard ).  It
  221. Xis then recalled by pressing the Slect Key ( shift Mark Key ).  The UNDO
  222. Xoption must be implemented to use this feature.
  223. X
  224. XThe window initialization routine was modified to easier define the
  225. X"slk" lines depending upon the options selected.
  226. X
  227. XThe BADMOUSE, BYQ and NOBEEP options were moved from the Makefile to
  228. Xklondike.h so that all the compile time options could be set at one
  229. Xlocation.
  230. X
  231. Xvern
  232. X
  233. XVernon C. Hoxie                            {ncar,boulder}!scicom!zebra!vern
  234. X3975 W. 29th Ave.                                       voice: 303-477-1780
  235. XDenver, Colo., 80212                          TB+        uucp: 303-455-2670
  236. X
  237. XJune 15, 1992
  238. X
  239. XAt the suggestion of Kris Kugel and Tom Tkacik, I added RUN.  This
  240. Xactivates the F6 key when all the cards have been turned over.  It will
  241. Xthen move all the cards to the out stacks.
  242. X
  243. XJine 23, 1992
  244. X
  245. XCleaned up some glitches in the RUN option.  The cards were getting
  246. Xclipped when they were moved to the top stacks.  Also the "RUN" slck
  247. Xline didn't reset after an UNDO.  I also revised the scoring display
  248. Xafter and UNDO.
  249. X
  250. XJust for the heck of it, I activated the 'Undo' key to operate as an
  251. Xalternative to the 'F5' key.
  252. X
  253. Xvern
  254. X
  255. XVernon C. Hoxie                            {ncar,boulder}!scicom!zebra!vern
  256. X3975 W. 29th Ave.                                       voice: 303-477-1780
  257. XDenver, Colo., 80212                          TB+        uucp: 303-455-2670
  258. END_OF_History
  259. if test 4750 -ne `wc -c <History`; then
  260.     echo shar: \"History\" unpacked with wrong size!
  261. fi
  262. # end of overwriting check
  263. fi
  264. if test -f INSTALL.sh -a "${1}" != "-c" ; then 
  265.   echo shar: Will not over-write existing file \"INSTALL.sh\"
  266. else
  267. echo shar: Extracting \"INSTALL.sh\" \(723 characters\)
  268. sed "s/^X//" >INSTALL.sh <<'END_OF_INSTALL.sh'
  269. X# This script allows installation of a game from a Unix shell rather
  270. X# than from an "Install" window.  It works best if you are 'root'!
  271. X
  272. XNAME=KLONDIKE+IN
  273. X
  274. Xmessage -c "You must be 'root' to run the Install script."
  275. Xif [ "$?" != "0" ]
  276. Xthen
  277. X    exit
  278. Xfi
  279. X
  280. Xif [ ! -f "$NAME" ]
  281. Xthen
  282. X    MAKEcpio
  283. Xfi
  284. X/usr/bin/Instcpio.sh $NAME
  285. X
  286. X# This does leave you in one of those obnoxious, undersized windows.
  287. X# Maybe someone can tell me how to stretch them back to full size
  288. X# without exiting the shell.
  289. X
  290. X# To remove 'klondike', run /usr/bin/Uninstall.sh.  This will get you a
  291. X# menu to select what to remove.  Once again, you will end up in ome of
  292. X# those obnoxious, undersized windows.
  293. X
  294. X# I have learned that 'windy' will restore the full window.
  295. END_OF_INSTALL.sh
  296. if test 723 -ne `wc -c <INSTALL.sh`; then
  297.     echo shar: \"INSTALL.sh\" unpacked with wrong size!
  298. fi
  299. chmod +x INSTALL.sh
  300. # end of overwriting check
  301. fi
  302. if test -f Install -a "${1}" != "-c" ; then 
  303.   echo shar: Will not over-write existing file \"Install\"
  304. else
  305. echo shar: Extracting \"Install\" \(1008 characters\)
  306. sed "s/^X//" >Install <<'END_OF_Install'
  307. XUA=/usr/lib/ua
  308. XDIR=/usr/games
  309. XGAME="klondike"
  310. XTITLE="Klondike"
  311. XMAN=/usr/man/cat
  312. X
  313. Xif [ ! -d $DIR ] ; then
  314. X    mkdir $DIR
  315. X    chmod 755 $DIR
  316. X    chown bin $DIR
  317. X    chgrp users $DIR
  318. Xfi
  319. X
  320. Xif [ ! -f $GAME -a ! -f $DIR/$GAME ]
  321. Xthen
  322. X    make
  323. X    ret=$?
  324. X    if [ $ret -ne "0" ]
  325. X    then
  326. X        echo "Couldn't make $GAME" $ret
  327. X        exit
  328. X    fi
  329. X    make clean
  330. Xfi
  331. X
  332. Xif [ ! -d ${MAN}6 ]
  333. Xthen
  334. X    mkdir ${MAN}6
  335. X    chmod 777 ${MAN}6
  336. X    chown bin ${MAN}6
  337. X    chgrp users ${MAN}6
  338. Xfi
  339. X
  340. Xif [ ! -d ${MAN}6/$GAME\.6 ]
  341. Xthen
  342. X    cp $GAME\.6 ${MAN}6/$GAME\.6
  343. X    chmod 666 ${MAN}6/$GAME\.6
  344. X    chown bin ${MAN}6/$GAME\.6
  345. X    chgrp users ${MAN}6/$GAME\.6
  346. Xfi
  347. X
  348. Xif [ -f $GAME ]
  349. Xthen
  350. X    echo "copying $GAME into $DIR:"
  351. X
  352. X    for fn in $GAME
  353. X    do
  354. X        mv $fn $DIR/$fn
  355. X        chmod 755 $DIR/$fn
  356. X        chown bin $DIR/$fn
  357. X        chgrp bin $DIR/$fn
  358. X    done
  359. X
  360. X    if [ -s $UA/Toybox ]
  361. X    then
  362. X        uaupd -r $TITLE -a Toybox Toybox
  363. X    else
  364. X        ln Toybox $UA/Toybox
  365. X        chown bin $UA/Toybox
  366. X        chgrp bin $UA/Toybox
  367. X        chmod 666 $UA/Toybox
  368. X        uaupd -r Toybox -a Office Office
  369. X    fi
  370. X    message -i "$TITLE is now installed.
  371. XPress <Enter> to continue.\n"
  372. Xfi
  373. X
  374. END_OF_Install
  375. if test 1008 -ne `wc -c <Install`; then
  376.     echo shar: \"Install\" unpacked with wrong size!
  377. fi
  378. chmod +x Install
  379. # end of overwriting check
  380. fi
  381. if test -f MAKEcpio -a "${1}" != "-c" ; then 
  382.   echo shar: Will not over-write existing file \"MAKEcpio\"
  383. else
  384. echo shar: Extracting \"MAKEcpio\" \(49 characters\)
  385. sed "s/^X//" >MAKEcpio <<'END_OF_MAKEcpio'
  386. XGAME=KLONDIKE
  387. X
  388. Xcat Files | cpio -ocBv > $GAME+IN
  389. END_OF_MAKEcpio
  390. if test 49 -ne `wc -c <MAKEcpio`; then
  391.     echo shar: \"MAKEcpio\" unpacked with wrong size!
  392. fi
  393. chmod +x MAKEcpio
  394. # end of overwriting check
  395. fi
  396. if test -f MAKEflop -a "${1}" != "-c" ; then 
  397.   echo shar: Will not over-write existing file \"MAKEflop\"
  398. else
  399. echo shar: Extracting \"MAKEflop\" \(52 characters\)
  400. sed "s/^X//" >MAKEflop <<'END_OF_MAKEflop'
  401. XGAME=KLONDIKE
  402. X
  403. Xcat Files | cpio -ocBv > /dev/rfp021
  404. END_OF_MAKEflop
  405. if test 52 -ne `wc -c <MAKEflop`; then
  406.     echo shar: \"MAKEflop\" unpacked with wrong size!
  407. fi
  408. chmod +x MAKEflop
  409. # end of overwriting check
  410. fi
  411. if test -f MANIFEST -a "${1}" != "-c" ; then 
  412.   echo shar: Will not over-write existing file \"MANIFEST\"
  413. else
  414. echo shar: Extracting \"MANIFEST\" \(1574 characters\)
  415. sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
  416. X   File Name        Archive #    Description
  417. X-----------------------------------------------------------
  418. X Files                     1    A listing of the files in this archive
  419. X History                   1    A development history
  420. X INSTALL.sh                1    Script for installing from any directory
  421. X Install                   1    Script for "Install from floppy"
  422. X MAKEcpio                  1    Generates KLONDIKE+IN cpio file
  423. X MAKEflop                  1    Generates an installable floppy
  424. X MANIFEST                  1    This shipping list
  425. X Makefile                  1    'make' script
  426. X Name                      1    required by UA install script
  427. X Office                    1    Makes a 'Toybox' window
  428. X README                    1    Installation instructions
  429. X Remove                    1    Removal script for UA
  430. X Size                      1    Required by UA
  431. X Toybox                    1    Put's 'Klondike' in 'Toybox' window
  432. X cards.c                   1    An array of the unshuffled deck
  433. X check.c                   2    CHEAT, SCORE, UNDO and MARKS routines
  434. X club.c                    3    Bitmap arrays for Clubs suit
  435. X diamond.c                 4    Bitmap arrays for Diamonds suit
  436. X drag.c                    1    Mouse dragging routines
  437. X heart.c                   5    Bitmap arrays for Hearts suit
  438. X klondike.6                1    Manual
  439. X klondike.c                2    The main playing routines
  440. X klondike.h                1    Defines and Macros
  441. X other.c                   2    Bitmap arrays for Blank, Back and Joker cards
  442. X spade.c                   6    Bitmap arrays for Spade suit
  443. X window.c                  1    window generation routines
  444. END_OF_MANIFEST
  445. if test 1574 -ne `wc -c <MANIFEST`; then
  446.     echo shar: \"MANIFEST\" unpacked with wrong size!
  447. fi
  448. # end of overwriting check
  449. fi
  450. if test -f Makefile -a "${1}" != "-c" ; then 
  451.   echo shar: Will not over-write existing file \"Makefile\"
  452. else
  453. echo shar: Extracting \"Makefile\" \(1452 characters\)
  454. sed "s/^X//" >Makefile <<'END_OF_Makefile'
  455. X#
  456. X# The Makefile for the solitaire game klondike
  457. X#
  458. X# This makefile uses the shared libraries
  459. X# just type make
  460. X#
  461. X
  462. X# Uncomment the next two lines if you have GCC
  463. X#CC = /gnu/bin/gcc
  464. X#GNULIB = /gnu/lib/gcc-gnulib
  465. X
  466. XCFLAGS = -O
  467. XLDFLAGS = -s
  468. XSHAREDLIB = /lib/crt0s.o /lib/shlib.ifile
  469. XNAME = klondike
  470. XBIN = /usr/games
  471. XMANDIR = /usr/man/cat6
  472. XLINT = lint -xbp
  473. X
  474. XSRC=klondike.c drag.c window.c cards.c spade.c heart.c club.c \
  475. X    diamond.c other.c check.c
  476. XOBJ=klondike.o drag.o window.o cards.o spade.o heart.o club.o \
  477. X    diamond.o other.o check.o
  478. X
  479. Xall: $(NAME)
  480. X
  481. X$(NAME): $(OBJ) Makefile
  482. X    $(LD) $(LDFLAGS) -o $(NAME) $(SHAREDLIB) $(OBJ) $(GNULIB)
  483. X
  484. Xinstall: $(NAME)
  485. X    cp $(NAME) $(BIN)/$(NAME)
  486. X    chgrp bin $(BIN)/$(NAME)
  487. X    chown bin $(BIN)/$(NAME)
  488. X    cp $(NAME).6 $(MANDIR)/$(NAME).6
  489. X    @if [ ! -d $(BIN)/lib ]; \
  490. X    then \
  491. X        mkdir $(BIN)/lib; \
  492. X        chown bin $(BIN)/lib; \
  493. X        chgrp bin $(BIN)/lib; \
  494. X    fi
  495. X    rm -f $(BIN)/lib/klon*
  496. X
  497. Xcpio:
  498. X    cpio -oBvcd < Files > KLONDIKE+IN
  499. X    compress KLONDIKE+IN
  500. X
  501. Xclean:
  502. X    rm -f *.o core
  503. X
  504. Xshar:
  505. X    shar -h shar1 README Makefile klondike.6 cards.c diamond.c
  506. X    shar -h shar2 klondike.c club.c
  507. X    shar -h shar3 drag.c heart.c klondike.h window.c
  508. X    shar -h shar4 other.c spade.c
  509. X
  510. Xlint:
  511. X    $(LINT) $(SRC)
  512. X
  513. X# Depedencies
  514. Xklondike.o : klondike.c klondike.h
  515. Xdrag.o : drag.c klondike.h
  516. Xwindow.o : window.c klondike.h
  517. Xcheck.o : check.c klondike.h
  518. Xcards.o : cards.c klondike.h
  519. Xclub.o : club.c
  520. Xdiamond.o : diamond.c
  521. Xheart.o : heart.c
  522. Xspade.o : spade.c
  523. Xother.o : other.c
  524. X
  525. END_OF_Makefile
  526. if test 1452 -ne `wc -c <Makefile`; then
  527.     echo shar: \"Makefile\" unpacked with wrong size!
  528. fi
  529. # end of overwriting check
  530. fi
  531. if test -f Name -a "${1}" != "-c" ; then 
  532.   echo shar: Will not over-write existing file \"Name\"
  533. else
  534. echo shar: Extracting \"Name\" \(45 characters\)
  535. sed "s/^X//" >Name <<'END_OF_Name'
  536. XKlondike, a game of solitaire by Tom Tkacik.
  537. END_OF_Name
  538. if test 45 -ne `wc -c <Name`; then
  539.     echo shar: \"Name\" unpacked with wrong size!
  540. fi
  541. # end of overwriting check
  542. fi
  543. if test -f Office -a "${1}" != "-c" ; then 
  544.   echo shar: Will not over-write existing file \"Office\"
  545. else
  546. echo shar: Extracting \"Office\" \(47 characters\)
  547. sed "s/^X//" >Office <<'END_OF_Office'
  548. XName=Toybox
  549. XExpert
  550. XDefault=Open
  551. XOpen=UA Toybox
  552. END_OF_Office
  553. if test 47 -ne `wc -c <Office`; then
  554.     echo shar: \"Office\" unpacked with wrong size!
  555. fi
  556. chmod +x Office
  557. # end of overwriting check
  558. fi
  559. if test -f README -a "${1}" != "-c" ; then 
  560.   echo shar: Will not over-write existing file \"README\"
  561. else
  562. echo shar: Extracting \"README\" \(1602 characters\)
  563. sed "s/^X//" >README <<'END_OF_README'
  564. XJune 16, 1992
  565. X
  566. XIf you received this from 'comp.sources.3b1', place all the prsts into a
  567. Xseparate directory.  Then:
  568. X    unshar *
  569. X
  570. XIf you received this as KLONDIKE+IN.Z, place this file in a separate
  571. Xdirectory then:
  572. X    uncompress KLONDIKE+IN.Z
  573. X    cpio -iBvcd < KLONDIKE+IN
  574. X
  575. XYou will then have four choices of how to install the program.  If you
  576. Xdo not have "Klondike" in your User Agent Toybox, you can use options 1,
  577. X2, or 3.  If already have "Klondike" in the Toybox window or if you
  578. Xdon't care for any UA interface, use option 4.
  579. X
  580. X1.  a. Place a formatted disk in the disk drive and enter the command:
  581. X    MAKEfloppy
  582. X
  583. X    b. Go to the "install" login.
  584. X
  585. X    c. From the "Office of install" window, select "Administration".
  586. X
  587. X    d. From the "Administration" window, select "Software Setup".
  588. X
  589. X    e. From the "Software Setup" window, select "Install Software from Floppy".
  590. X
  591. X2.  a.Enter MAKEcpio and move the resulting KLONDIKE+IN file to
  592. X/usr/spool/uucppublic.
  593. X
  594. X    b. Perform step b, c and d listed above.
  595. X
  596. X    c. From the "Software Setup" window, select "Install Software sent
  597. Xby Electronic Mail".
  598. X
  599. X3.  a. Enter "INSTALL.sh".  This performs all the steps required from
  600. Xthe current directory.
  601. X
  602. X4.  a. Enter "make install".
  603. X
  604. XYou must login as 'root' to perform options 3 or 4.
  605. X
  606. XTo produce a back up disk for options 2, 3, or 4, you can execute
  607. X"make cpio".  The resulting "KLONDIKE+IN.Z" file can then be copied to
  608. Xany formatted floppy.
  609. X
  610. Xvern
  611. X
  612. X--------
  613. XVernon C. Hoxie               {ncar,nbires,boulder,isis}!scicom!zebra!vern
  614. X3975 W. 29th Ave.                    voice: 303-477-1780
  615. XDenver, Colo., 80212                  TB+     uucp: 303-455-2670
  616. END_OF_README
  617. if test 1602 -ne `wc -c <README`; then
  618.     echo shar: \"README\" unpacked with wrong size!
  619. fi
  620. # end of overwriting check
  621. fi
  622. if test -f Remove -a "${1}" != "-c" ; then 
  623.   echo shar: Will not over-write existing file \"Remove\"
  624. else
  625. echo shar: Extracting \"Remove\" \(796 characters\)
  626. sed "s/^X//" >Remove <<'END_OF_Remove'
  627. X# This gets moved to /usr/installed with an entry in the
  628. X# /usr/installed/CONTENTS file.  You can remove any installed software
  629. X# from a full screen Unix window by calling /usr/bin/Uninstall.sh.
  630. X# This will provide you with a menu to select which package you wish
  631. X# to remove.  Unfortunately, it leaves you with an obnoxious, undersized
  632. X# window which I don't know how to resize. --vch
  633. X
  634. XUA=/usr/lib/ua
  635. XDIR=/usr/games
  636. XGAME="klondike"
  637. XTITLE="Klondike"
  638. XMAN=/usr/man/cat
  639. X
  640. Xecho "removing $TITLE ..."
  641. X
  642. Xuaupd -r $TITLE Toybox
  643. X
  644. Xif [ ! -s $UA/Toybox ]
  645. Xthen
  646. X    /bin/rm -f $UA/Toybox
  647. X    uaupd -r Toybox Office
  648. Xfi
  649. X
  650. Xfor fn in $DIR/$GAME $DIR/$GAME/lib/TetScores
  651. Xdo
  652. X    /bin/rm -f $fn
  653. Xdone
  654. X
  655. Xrm -f ${MAN}6/$GAME\.6
  656. X
  657. Xrm -f ${DIR}/lib/klon*
  658. X
  659. Xmessage -i "$TITLE the game has been removed. \nPress <Enter> to continue.\n"
  660. END_OF_Remove
  661. if test 796 -ne `wc -c <Remove`; then
  662.     echo shar: \"Remove\" unpacked with wrong size!
  663. fi
  664. chmod +x Remove
  665. # end of overwriting check
  666. fi
  667. if test -f Size -a "${1}" != "-c" ; then 
  668.   echo shar: Will not over-write existing file \"Size\"
  669. else
  670. echo shar: Extracting \"Size\" \(4 characters\)
  671. sed "s/^X//" >Size <<'END_OF_Size'
  672. X400
  673. END_OF_Size
  674. if test 4 -ne `wc -c <Size`; then
  675.     echo shar: \"Size\" unpacked with wrong size!
  676. fi
  677. # end of overwriting check
  678. fi
  679. if test -f Toybox -a "${1}" != "-c" ; then 
  680.   echo shar: Will not over-write existing file \"Toybox\"
  681. else
  682. echo shar: Extracting \"Toybox\" \(59 characters\)
  683. sed "s/^X//" >Toybox <<'END_OF_Toybox'
  684. XName=Klondike
  685. XDefault=Run
  686. XRun=EXEC -wd /usr/games/klondike
  687. END_OF_Toybox
  688. if test 59 -ne `wc -c <Toybox`; then
  689.     echo shar: \"Toybox\" unpacked with wrong size!
  690. fi
  691. chmod +x Toybox
  692. # end of overwriting check
  693. fi
  694. if test -f cards.c -a "${1}" != "-c" ; then 
  695.   echo shar: Will not over-write existing file \"cards.c\"
  696. else
  697. echo shar: Extracting \"cards.c\" \(1131 characters\)
  698. sed "s/^X//" >cards.c <<'END_OF_cards.c'
  699. X/*
  700. X *    Copyright 1990, Thomas E. Tkacik
  701. X *            tkacik@kyzyl.mi.org
  702. X *
  703. X *    Acknowledgments to Kent Quander allowing me to
  704. X *     use and distribute his wonderfully drawn playing cards.
  705. X *
  706. X *    Permission is given to copy and distribute for non-profit purposes.
  707. X *
  708. X */
  709. X
  710. X#include "klondike.h"
  711. X
  712. X/* define the card locations */
  713. Xint deck[52];
  714. X
  715. Xint outcard[4];    /* number of cards played out */
  716. X
  717. Xint down[7][7];    /* cards down in each column */
  718. Xint numdown[7];
  719. Xint up[7][13];        /* cards showing in each column */
  720. Xint numup[7];
  721. X
  722. Xunsigned short *images[NUMCARDS] = {
  723. X    spadea[0], spade2[0], spade3[0], spade4[0], spade5[0], spade6[0],
  724. X    spade7[0], spade8[0], spade9[0], spade10[0], spadej[0], spadeq[0],
  725. X    spadek[0],
  726. X    hearta[0], heart2[0], heart3[0], heart4[0], heart5[0], heart6[0],
  727. X    heart7[0], heart8[0], heart9[0], heart10[0], heartj[0], heartq[0],
  728. X    heartk[0],
  729. X    cluba[0], club2[0], club3[0], club4[0], club5[0], club6[0],
  730. X    club7[0], club8[0], club9[0], club10[0], clubj[0], clubq[0],
  731. X    clubk[0],
  732. X    diama[0], diam2[0], diam3[0], diam4[0], diam5[0],
  733. X    diam6[0], diam7[0], diam8[0], diam9[0], diam10[0],
  734. X    diamj[0], diamq[0], diamk[0],
  735. X    joker[0], joker[0]
  736. X};
  737. END_OF_cards.c
  738. if test 1131 -ne `wc -c <cards.c`; then
  739.     echo shar: \"cards.c\" unpacked with wrong size!
  740. fi
  741. # end of overwriting check
  742. fi
  743. if test -f drag.c -a "${1}" != "-c" ; then 
  744.   echo shar: Will not over-write existing file \"drag.c\"
  745. else
  746. echo shar: Extracting \"drag.c\" \(5636 characters\)
  747. sed "s/^X//" >drag.c <<'END_OF_drag.c'
  748. X/*
  749. X *    Copyright 1990, Thomas E. Tkacik
  750. X *            tkacik@kyzyl.mi.org
  751. X *
  752. X *    Acknowledgments to Kent Quander allowing me to
  753. X *     use and distribute his wonderfully drawn playing cards.
  754. X *
  755. X *    Permission is given to copy and distribute for non-profit purposes.
  756. X *
  757. X */
  758. X
  759. X/*
  760. X * double buffered dragging of the selected cards with the mouse
  761. X */
  762. X
  763. X#include <malloc.h>
  764. X#include <sys/window.h>
  765. X#include "klondike.h"
  766. X
  767. X/* card that the mouse should drag */
  768. Xextern int ucard;
  769. X
  770. X/* location of the upper left corner of the card  */
  771. X/* the mouse pointer is at the center of the card */
  772. Xstatic int x_screenoff, y_screenoff;
  773. X
  774. X/* the visible size of the card -- it may be against an edge */
  775. Xstatic int drag_w, drag_h;
  776. X
  777. X/* buffer for holding the drag region */
  778. Xstatic unsigned short dragged[12*FACE_SEP+CARD_H][5];
  779. X
  780. X/* number of bytes in the image buffer */
  781. Xstatic unsigned int region_size = 0;
  782. X
  783. X/* pointer to dynamically allocated image buffer */
  784. Xstatic unsigned short *save_region = 0;
  785. X
  786. X/*
  787. X * set up parameters to be able to drag a card
  788. X * and draw the card where the mouse is
  789. X */
  790. X
  791. Xstart_dragging(x,y)
  792. Xint x,y;  /* current mouse position */
  793. X{
  794. X
  795. X    int x_cardoff, y_cardoff;
  796. X
  797. X     /* parameters required to display cards in the proper position */
  798. X
  799. X    x_screenoff = x - (w_cards/2);
  800. X    y_screenoff = y - (h_cards/2);
  801. X    drag_w = w_cards;
  802. X    drag_h = h_cards;
  803. X    x_cardoff = 0;
  804. X    y_cardoff = 0;
  805. X
  806. X       /* modify the parameters if the cards are only partially
  807. X         * on the screen */
  808. X
  809. X    if(x_screenoff <= SIDEBORDER + 1) {
  810. X        x_cardoff = SIDEBORDER - x_screenoff + 1;
  811. X        drag_w -= x_cardoff;
  812. X        x_screenoff = SIDEBORDER + 1;
  813. X    }
  814. X    else if(x_screenoff >= WIND_W-SIDEBORDER-w_cards-1) {
  815. X        drag_w = WIND_W - SIDEBORDER - x_screenoff - 1;
  816. X    }
  817. X    if(y_screenoff <= TOPBORDER + 1) {
  818. X        y_cardoff = TOPBORDER - y_screenoff + 1;
  819. X        drag_h -= y_cardoff;
  820. X        y_screenoff = TOPBORDER + 1;
  821. X    }
  822. X    else if(y_screenoff >= WIND_H-TOPBORDER-h_cards-1) {
  823. X        drag_h = WIND_H - TOPBORDER - y_screenoff - 1;
  824. X    }
  825. X
  826. X     /* save the current area */
  827. X
  828. X    wrastop(wn, (unsigned short *)0, 0, dragged[0], 10,
  829. X        x_screenoff, y_screenoff, 0, 0,
  830. X        drag_w, drag_h, SRCSRC, DSTSRC, (unsigned short *)0);
  831. X
  832. X     /* draw the cards */
  833. X
  834. X    wrastop(wn, cards[0], 10, (unsigned short *)0, 0,
  835. X        x_cardoff, y_cardoff, x_screenoff, y_screenoff,
  836. X        drag_w, drag_h, SRCSRC, DSTSRC, (unsigned short *)0);
  837. X}
  838. X
  839. X/*
  840. X * clean up after placing the cards
  841. X */
  842. X
  843. Xstop_dragging()
  844. X{
  845. X     /* redisplay the saved current area */
  846. X
  847. X    wrastop(wn, dragged[0], 10, (unsigned short *)0, 0,
  848. X        0, 0, x_screenoff, y_screenoff,
  849. X        drag_w, drag_h, SRCSRC, DSTSRC, (unsigned short *)0);
  850. X}
  851. X
  852. X/*
  853. X * restore the screen under the old position
  854. X * and display the cards where the mouse is currently
  855. X */
  856. X
  857. Xkeep_dragging(x,y)
  858. Xint x, y;    /* current mouse position */
  859. X{
  860. X    int xmin, ymin, xmax, ymax;
  861. X    int rows, cols, bytes_per_row;
  862. X    int byte_count;
  863. X    int new_x, new_y, newoff_x, newoff_y, new_w, new_h;
  864. X
  865. X
  866. X     /* paramters for the new mouse location */
  867. X
  868. X    new_x = x - (w_cards/2);
  869. X    new_y = y - (h_cards/2);
  870. X    new_w = w_cards;
  871. X    new_h = h_cards;
  872. X    newoff_x = 0;
  873. X    newoff_y = 0;
  874. X
  875. X     /* modify them if the cards run off the screen */
  876. X
  877. X    if(new_x <= SIDEBORDER + 1) {
  878. X        newoff_x = SIDEBORDER - new_x + 1;
  879. X        new_w -= newoff_x;
  880. X        new_x = SIDEBORDER + 1;
  881. X    }
  882. X    else if(new_x >= WIND_W-SIDEBORDER-w_cards-1) {
  883. X        new_w = WIND_W - SIDEBORDER - new_x - 1;
  884. X    }
  885. X    if(new_y <= TOPBORDER + 1) {
  886. X        newoff_y = TOPBORDER - new_y + 1;
  887. X        new_h -= newoff_y;
  888. X        new_y = TOPBORDER + 1;
  889. X    }
  890. X    else if(new_y >= WIND_H-TOPBORDER-h_cards-1) {
  891. X        new_h = WIND_H - TOPBORDER - new_y - 1;
  892. X    }
  893. X
  894. X     /* need an off screen version of the playing area containing */
  895. X     /* both the old mouse position and the new one */
  896. X
  897. X    xmin = (new_x < x_screenoff) ? new_x : x_screenoff;
  898. X    ymin = (new_y < y_screenoff) ? new_y : y_screenoff;
  899. X    xmax = (new_x+new_w > x_screenoff+drag_w) ?
  900. X                    new_x+new_w : x_screenoff+drag_w;
  901. X    ymax = (new_y+new_h > y_screenoff+drag_h) ?
  902. X                    new_y+new_h : y_screenoff+drag_h;
  903. X
  904. X     /* how big an array is required to hold this part */
  905. X     /*  the playing area? */
  906. X
  907. X    rows = ymax - ymin + 1;
  908. X    cols = xmax - xmin + 1;
  909. X    bytes_per_row = ((cols/16) + (((cols%16)>0)?1:0))*2;
  910. X    byte_count = rows * bytes_per_row;
  911. X
  912. X     /* if the array is too small, make it bigger */
  913. X
  914. X    if(save_region == 0) {
  915. X        region_size = byte_count;
  916. X        save_region = (unsigned short*)malloc(region_size);
  917. X     } else if(byte_count > region_size) {
  918. X        region_size = byte_count;
  919. X        save_region = (unsigned short*)
  920. X                realloc((char*)save_region, region_size);
  921. X    }
  922. X
  923. X
  924. X     /* now drag the cards */
  925. X     /* do everything in the off screen buffer first */
  926. X     /* so we do not see ghost images */
  927. X
  928. X     /* buffer the region we need to mess around with */
  929. X
  930. X    wrastop(wn, (unsigned short *)0, 0, save_region, bytes_per_row,
  931. X        xmin, ymin, 0, 0,
  932. X        cols, rows, SRCSRC, DSTSRC, (unsigned short *)0);
  933. X
  934. X     /* restore the image */
  935. X
  936. X    wrastop(wn, dragged[0], 10, save_region, bytes_per_row,
  937. X        0, 0, x_screenoff-xmin, y_screenoff-ymin,
  938. X        drag_w, drag_h, SRCSRC, DSTSRC, (unsigned short *)0);
  939. X
  940. X     /* save the area that will be overdrawn by the cards */
  941. X
  942. X    wrastop(wn, save_region, bytes_per_row, dragged[0], 10,
  943. X        new_x-xmin, new_y-ymin, 0, 0,
  944. X        new_w, new_h, SRCSRC, DSTSRC, (unsigned short *)0);
  945. X        
  946. X     /* draw the cards */
  947. X
  948. X    wrastop(wn, cards[0], 10, save_region, bytes_per_row,
  949. X        newoff_x, newoff_y, new_x-xmin, new_y-ymin,
  950. X        new_w, new_h, SRCSRC, DSTSRC, (unsigned short *)0);
  951. X
  952. X     /* put the whole thing back on the screen */
  953. X
  954. X    wrastop(wn, save_region, bytes_per_row, (unsigned short *)0, 0,
  955. X        0, 0, xmin, ymin,
  956. X        cols, rows, SRCSRC, DSTSRC, (unsigned short *)0);
  957. X
  958. X     /* update parameters */
  959. X
  960. X    x_screenoff = new_x;
  961. X    y_screenoff = new_y;
  962. X    drag_w = new_w;
  963. X    drag_h = new_h;
  964. X}
  965. END_OF_drag.c
  966. if test 5636 -ne `wc -c <drag.c`; then
  967.     echo shar: \"drag.c\" unpacked with wrong size!
  968. fi
  969. # end of overwriting check
  970. fi
  971. if test -f klondike.6 -a "${1}" != "-c" ; then 
  972.   echo shar: Will not over-write existing file \"klondike.6\"
  973. else
  974. echo shar: Extracting \"klondike.6\" \(5032 characters\)
  975. sed "s/^X//" >klondike.6 <<'END_OF_klondike.6'
  976. X.\"    Copyright 1990 Thomas E. Tkacik
  977. X.\"            tkacik@kyzyl.mi.org
  978. X.\"
  979. X.\"    Acknowledgments to Kent Quander allowing me to
  980. X.\"     use and distribute his wonderfully drawn playing cards.
  981. X.\"
  982. X.\"    Permission is given to copy and distribute for non-profit purposes.
  983. X.\"
  984. X.TH KLONDIKE 6 "6 October 1990"
  985. X.SH NAME
  986. Xklondike \- solitaire card game
  987. X.SH SYNOPSIS
  988. X.B /usr/games/klondike
  989. X[\fB-v\fP] [ \fB-n \fI###\fR ]
  990. X.SH DESCRIPTION
  991. X.I Klondike
  992. Xis that most popular of solitaire card games you learned as a child.
  993. XIt is played with a single deck of cards, and the goal is to move as many
  994. Xcards as possible from their initial positions (the tableau),
  995. Xto output piles, (or foundations).
  996. XThe game is won if all of the cards are removed from the tableau.
  997. X.SH LAYOUT
  998. XInitially, there are seven piles making up the tableau,
  999. Xwith from one to seven cards in each pile.
  1000. XThe top most card is turned face up.
  1001. XAbove the tableau are the four output piles (foundations), initially empty.
  1002. XTo the left of the tableau is the stock, the unused cards, turned down.
  1003. X.SH PLAY
  1004. XThe mouse is used to move cards from either one of the piles, or the stock,
  1005. Xto another pile, or the foundation.
  1006. XA card may be moved onto another pile if it is a different color, and is one
  1007. Xless than the top card, (which is actually shown at the bottom of the screen).
  1008. XAll of the face up cards in a pile may be moved together.
  1009. X
  1010. XAfter moving the visible cards from a pile, the next card is turned up.
  1011. XWhen a pile is empty, a King may be played there.
  1012. XThis is the only way a King may be moved.
  1013. X
  1014. XA press of the left mouse button selects a card to move.
  1015. XA second press of left button postitions the card.
  1016. XThe middle button may be pressed to unselect a card.
  1017. X
  1018. XIf the left mouse button is pressed while the pointer is on the face down
  1019. Xcards of the stock, three cards are turned up.
  1020. XWhen the stock is empty, the face up cards are turned over, and you may
  1021. Xgo through them again.
  1022. X(If the \fB-v\fP option was given, then only one card is turned up, and
  1023. Xyou may only go through them once.)
  1024. X
  1025. XUsing the right mouse button to select a card, will move it from the tableau
  1026. Xto the proper foundation.
  1027. XA card may only be moved to the foundation if it is one greater than the
  1028. Xcard of the same suit showing already showing in the foundation.
  1029. XAn Ace may be moved to the foundation at any time.
  1030. XOnce a card has been moved to the foundation, it may not be moved back to
  1031. Xthe tableau.
  1032. X
  1033. XScore keeping capabilty has been included.  Each new game starts with a
  1034. Xscore of -52.  As cards are added to the upper region, +5 points are
  1035. Xadded to the score.  Only covered aces are scored.  That is, uncovered
  1036. Xaces score nothing and dueces score +10.  All other cards count +5.
  1037. X
  1038. XA summary score is maintained for all games in the current session.  An
  1039. Xall time score is saved from session to session on disk.  Separate
  1040. Xhistory files are maintained for each players login name.
  1041. X
  1042. XPrompting or "CHEAT"ing is also available.  This may be turned on and
  1043. Xoff with the F4 function key.  When ON, missed moves are printed on the
  1044. Xlower portion of the playing area.  These are computed when the left
  1045. Xmouse button is pressed with the mouse pointer in the unturned deck
  1046. Xregion.
  1047. X
  1048. XThe play displayed is not the only play possible nor is it the best play
  1049. Xpossible.  If you wish to ignore the play displayed, press the left
  1050. Xmouse button a second time.  To check for possible plays after turning
  1051. Xover all the card in 'Vegas' mode, put the mouse pointer in the empty
  1052. Xunturned deck region and press the left mouse button.
  1053. X
  1054. XMoves may be deleted by pressing F5 ( UNDO ).
  1055. X
  1056. XWhen all the cards from the deck have been played and all the down cards
  1057. Xon the tableau have been turned over, the RUN option will appear over
  1058. XF6.  When F6 is pressed, all the cards will move to the upper stacks.
  1059. X
  1060. X.SH OPTIONS
  1061. X.IP \fB-v\fP
  1062. XPlay Las Vegas style.
  1063. XTurn up one card at a time from the stock, and go through the stock only once.
  1064. XNormally three cards are turned, and you may go through the stock any number
  1065. Xof times.
  1066. X.IP \fB\-n \fI###\fR
  1067. XStart by dealing hand number ###.
  1068. X.SH BUTTONS
  1069. X\fIVEGAS RULES\fP plays a new hand, using Vegas style of play.
  1070. X\fIHOUSE RULES\fP plays a new hand, using the house rules, (turn three
  1071. Xcards at a time).
  1072. X\fIREPLAY HAND\fP does the obvious.  The only way to play the same hand
  1073. Xagain, but with different rules is to quit (either \fIQUIT\fP or \fIExit\fP)
  1074. Xand restart \fIklondike\fP.
  1075. X\fCHEAT ON\OFF\fP to provide missed play prompting.
  1076. X\fUNDO\fP redisplay the previous board.
  1077. X\RUN\fP put all exposed cards into the out decks.
  1078. X\fZERO HIST\fP reset all scores to zero.
  1079. X\fMark\fP mark this board for redisplaying.
  1080. X\fSlectlP return to the most recently 'marked' board.
  1081. X.SH AKNOWLEDGEMENTS
  1082. XThe playing cards are By Q.  They are the artistic creation of Kent Quander.
  1083. X.SH FILES
  1084. X/usr/games/klondike            executable
  1085. X.SH AUTHOR
  1086. XCopyright 1988 Thomas E. Tkacik
  1087. X.br
  1088. Xtkacik@kyzyl.mi.org
  1089. X.br
  1090. X<kyzyl!tkacik>
  1091. X.SH ADDITIONAL CONTRIBUTION
  1092. XProvided Nov. 2, 1991 and June 5, 1992 by Vernon C. Hoxie
  1093. X.br
  1094. X<zebra!vern>
  1095. X.SH BUGS
  1096. XHopefully none, but I am not betting on it.
  1097. END_OF_klondike.6
  1098. if test 5032 -ne `wc -c <klondike.6`; then
  1099.     echo shar: \"klondike.6\" unpacked with wrong size!
  1100. fi
  1101. # end of overwriting check
  1102. fi
  1103. if test -f klondike.h -a "${1}" != "-c" ; then 
  1104.   echo shar: Will not over-write existing file \"klondike.h\"
  1105. else
  1106. echo shar: Extracting \"klondike.h\" \(6330 characters\)
  1107. sed "s/^X//" >klondike.h <<'END_OF_klondike.h'
  1108. X/*
  1109. X *    Copyright 1990, Thomas E. Tkacik
  1110. X *            tkacik@kyzyl.mi.org
  1111. X *
  1112. X *    Acknowledgments to Kent Quander allowing me to
  1113. X *     use and distribute his wonderfully drawn playing cards.
  1114. X *
  1115. X *    Permission is given to copy and distribute for non-profit purposes.
  1116. X *
  1117. X */
  1118. X
  1119. X        /* 
  1120. X         * The following are the compile time options.
  1121. X         * They may be invoked by removing the leading comment
  1122. X         * symbol or omitted by adding a leading comment symbol
  1123. X         * at the left.
  1124. X         */
  1125. X/*
  1126. X * Define VEGAS 0 for House Rules default
  1127. X * or VEGAS 1 for Las Vegas Rules default.
  1128. X */
  1129. X#define VEGAS 1
  1130. X
  1131. X/* Uncomment if you would like to see the original ByQ A of spades */
  1132. X/* #define DByQ    /* */
  1133. X
  1134. X/* Uncomment one or the other of the following. */
  1135. X/* #define beep()                        /* Uncomment to inhibit beeping. */
  1136. X#define beep()    wputc(wn, 007)        /* Uncomment to enable beeping. */
  1137. X
  1138. X/* 
  1139. X * Uncomment if the mouse refuses to let go of the cards.
  1140. X * I need to define BADMOUSE when I compile with cc, but not with gcc
  1141. X * I do not know why:-(.  You should never need it.
  1142. X * I would like to hear if this works with cc and BADMOUSE undefined
  1143. X */
  1144. X#define BADMOUSE    /*  */
  1145. X
  1146. X                /* CHEAT added by VCH 11-2-91 */
  1147. X                /* CHEAT revised by VCH 6-3-92 */
  1148. X/* Uncomment the next line to display missed moves. */
  1149. X#define CHEAT    /*  */
  1150. X
  1151. X                /* SCORES added by VCH 11-2-91 */
  1152. X/* Uncomment the next line to compute and save scores. */
  1153. X#define SCORES    /*  */
  1154. X
  1155. X                /* UNDO added by VCH 6-3-92 */
  1156. X/* Uncomment the next line to activate undo. */
  1157. X#define UNDO    /*  */
  1158. X
  1159. X                /* MARKS added by VCH 6-7-92 */
  1160. X/* Uncomment the next line to activate marking of screens */
  1161. X#define MARKS    /*  */
  1162. X
  1163. X                /* RUN added by VCH 6-15-92 */
  1164. X/* Uncomment the next line to activate running of tableau */
  1165. X#define RUN        /*  */
  1166. X
  1167. X/* 
  1168. X * End of Compile time options.
  1169. X */
  1170. X
  1171. X/* The MARKS option requires use of UNDO */
  1172. X#ifdef MARKS
  1173. X#ifndef UNDO
  1174. X#define UNDO
  1175. X#endif
  1176. X#endif
  1177. X
  1178. X#define    NUMCARDS  54        /* number of different images */
  1179. X
  1180. X#define COLOR(x) (((x)/13)&1)
  1181. X#define VALUE(x) (((x)%13)+1)
  1182. X#define SUIT(x)  ((x)/13)
  1183. X
  1184. X/* window size and offset */
  1185. X#define  SIDEBORDER 6
  1186. X#define  TOPBORDER  4
  1187. X#define  WINDOW_X   4        /* characters */
  1188. X#define  WINDOW_Y   1        /* characters */
  1189. X#define  ROWS       24        /* characters */
  1190. X#define  COLS       74        /* characters */
  1191. X#define  WIND_H     (ROWS*12)
  1192. X#define  WIND_W     (COLS*9)
  1193. X
  1194. X/* CARD size and offsets */
  1195. X#define  CARD_W    71                            /* each card 71 pixels wide */
  1196. X#define  CARD_H    65                            /* each card 65 pixels high */
  1197. X#define  TOP        6
  1198. X#define  DECK        16
  1199. X#define  LEFT        (16 + DECK + CARD_W)
  1200. X#define  SUIT_SEP    1
  1201. X#define  ROW_SEP    8
  1202. X#define  BACK_SEP    6  
  1203. X#define    FACE_SEP    10
  1204. X
  1205. X#define    CARDSHORTS ((CARD_W/16)+((CARD_W%16)?1:0)) /* shorts per row */
  1206. X#define    CARDSIZE (CARD_H * CARDSHORTS)             /* shorts per image */
  1207. X
  1208. Xextern int deck[52];
  1209. X
  1210. Xextern int outcard[4];    /* number of cards played in each suit */
  1211. X
  1212. Xextern int down[7][7];    /* cards down in each column */
  1213. Xextern int numdown[7];    /* number down cards in each column */
  1214. Xextern int up[7][13];    /* cards showing in each column */
  1215. Xextern int numup[7];        /* number of cards showing in each column */
  1216. X
  1217. X/* individual cards */
  1218. Xextern unsigned short spadea[65][5];
  1219. Xextern unsigned short spade2[65][5];
  1220. Xextern unsigned short spade3[65][5];
  1221. Xextern unsigned short spade4[65][5];
  1222. Xextern unsigned short spade5[65][5];
  1223. Xextern unsigned short spade6[65][5];
  1224. Xextern unsigned short spade7[65][5];
  1225. Xextern unsigned short spade8[65][5];
  1226. Xextern unsigned short spade9[65][5];
  1227. Xextern unsigned short spade10[65][5];
  1228. Xextern unsigned short spadej[65][5];
  1229. Xextern unsigned short spadeq[65][5];
  1230. Xextern unsigned short spadek[65][5];
  1231. Xextern unsigned short hearta[65][5];
  1232. Xextern unsigned short heart2[65][5];
  1233. Xextern unsigned short heart3[65][5];
  1234. Xextern unsigned short heart4[65][5];
  1235. Xextern unsigned short heart5[65][5];
  1236. Xextern unsigned short heart6[65][5];
  1237. Xextern unsigned short heart7[65][5];
  1238. Xextern unsigned short heart8[65][5];
  1239. Xextern unsigned short heart9[65][5];
  1240. Xextern unsigned short heart10[65][5];
  1241. Xextern unsigned short heartj[65][5];
  1242. Xextern unsigned short heartq[65][5];
  1243. Xextern unsigned short heartk[65][5];
  1244. Xextern unsigned short cluba[65][5];
  1245. Xextern unsigned short club2[65][5];
  1246. Xextern unsigned short club3[65][5];
  1247. Xextern unsigned short club4[65][5];
  1248. Xextern unsigned short club5[65][5];
  1249. Xextern unsigned short club6[65][5];
  1250. Xextern unsigned short club7[65][5];
  1251. Xextern unsigned short club8[65][5];
  1252. Xextern unsigned short club9[65][5];
  1253. Xextern unsigned short club10[65][5];
  1254. Xextern unsigned short clubj[65][5];
  1255. Xextern unsigned short clubq[65][5];
  1256. Xextern unsigned short clubk[65][5];
  1257. Xextern unsigned short diama[65][5];
  1258. Xextern unsigned short diam2[65][5];
  1259. Xextern unsigned short diam3[65][5];
  1260. Xextern unsigned short diam4[65][5];
  1261. Xextern unsigned short diam5[65][5];
  1262. Xextern unsigned short diam6[65][5];
  1263. Xextern unsigned short diam7[65][5];
  1264. Xextern unsigned short diam8[65][5];
  1265. Xextern unsigned short diam9[65][5];
  1266. Xextern unsigned short diam10[65][5];
  1267. Xextern unsigned short diamj[65][5];
  1268. Xextern unsigned short diamq[65][5];
  1269. Xextern unsigned short diamk[65][5];
  1270. Xextern unsigned short back[65][5];
  1271. Xextern unsigned short blank[65][5];
  1272. Xextern unsigned short joker[65][5];
  1273. X
  1274. X/* card image definitions */
  1275. Xextern unsigned short *images[NUMCARDS];
  1276. X
  1277. X/* cards to be dragged */
  1278. Xextern unsigned short cards[12*FACE_SEP+CARD_H][5];
  1279. X
  1280. X/* size of cards to be dragged, in pixels */
  1281. Xextern int h_cards, w_cards;
  1282. X
  1283. X/* built-in pattern used for wrastop() */
  1284. Xextern unsigned short patwhite[];
  1285. Xextern unsigned short patblack[];
  1286. X
  1287. X/* window discriptor */
  1288. Xextern int wn;
  1289. X
  1290. X#ifdef SCORES
  1291. X        /* Where the history scores are stored. */
  1292. X#define    SFILE "/usr/games/lib/klon."
  1293. X
  1294. X        /* The struct saved in SCORES */
  1295. Xtypedef struct {
  1296. X    char name[16];
  1297. X    int score;
  1298. X} str_score;
  1299. X#endif    /* SCORES */
  1300. X
  1301. X#ifdef UNDO
  1302. X
  1303. X#define UFILE "/usr/tmp/klon.undo"
  1304. Xextern int fu;                /* UNDO file descriptor */
  1305. Xextern int rec_num;        /* number of moves recorded */
  1306. X
  1307. Xtypedef struct {
  1308. X    int rec_indeck;        /* number of cards in down deck */
  1309. X    int rec_over;            /* number of cards turned over */
  1310. X    int rec_deck[52];        /* the unplayed deck */
  1311. X    int rec_outcard[4];    /* number of cards played in each suit */
  1312. X    int rec_down[7][7];    /* cards down in each column */
  1313. X    int rec_numdown[7];    /* number down cards in each column */
  1314. X    int rec_up[7][13];    /* cards showing in each column */
  1315. X    int rec_numup[7];        /* number of cards showing in each column */
  1316. X} record;
  1317. X
  1318. X#endif    /* UNDO */
  1319. X
  1320. X    
  1321. END_OF_klondike.h
  1322. if test 6330 -ne `wc -c <klondike.h`; then
  1323.     echo shar: \"klondike.h\" unpacked with wrong size!
  1324. fi
  1325. # end of overwriting check
  1326. fi
  1327. if test -f window.c -a "${1}" != "-c" ; then 
  1328.   echo shar: Will not over-write existing file \"window.c\"
  1329. else
  1330. echo shar: Extracting \"window.c\" \(4698 characters\)
  1331. sed "s/^X//" >window.c <<'END_OF_window.c'
  1332. X/*
  1333. X *    Copyright 1990, Thomas E. Tkacik
  1334. X *            tkacik@kyzyl.mi.org
  1335. X *
  1336. X *    Acknowledgments to Kent Quander allowing me to
  1337. X *     use and distribute his wonderfully drawn playing cards.
  1338. X *
  1339. X *    Permission is given to copy and distribute for non-profit purposes.
  1340. X *
  1341. X */
  1342. X
  1343. X/*
  1344. X * window routines
  1345. X */
  1346. X
  1347. X#include <stdio.h>
  1348. X#include <fcntl.h>
  1349. X#include <termio.h>
  1350. X#include <sys/signal.h>
  1351. X#include <sys/window.h>
  1352. X#include <sys/font.h>
  1353. X#include "klondike.h"
  1354. X
  1355. Xint (*signal())();
  1356. X
  1357. X/* window discriptor */
  1358. Xint wn;
  1359. X
  1360. X/* window width and height */
  1361. Xint win_width, win_height;
  1362. X
  1363. Xint reborder(), leave();
  1364. X
  1365. X/*
  1366. X * initialize window and draw initial borders
  1367. X */
  1368. X
  1369. Xinitwindow()
  1370. X{
  1371. X     /* start with a clean window */
  1372. X     /*  this needs to be done because winit() uses the */
  1373. X     /*  current window first, so we open a new one     */
  1374. X
  1375. X    void do_slk();
  1376. X
  1377. X    (void)close(0);
  1378. X    (void)close(1);
  1379. X    (void)close(2);
  1380. X    wn = open("/dev/window", O_RDWR );
  1381. X    (void)dup(wn);
  1382. X    (void)dup(wn);
  1383. X
  1384. X     /* initialize the tam routines */
  1385. X
  1386. X    winit();
  1387. X
  1388. X     /* can only be run on the unixpc screen */
  1389. X     /* this is the official way to do this, but it does not
  1390. X       * work properly. I still do not have a correct method
  1391. X       * to do this */
  1392. X
  1393. X    if(iswind()==0) {
  1394. X        (void)fprintf(stderr, "must use bitmapped screen\n");
  1395. X        wexit(1);
  1396. X    }
  1397. X
  1398. X     /* open the playing window */
  1399. X
  1400. X    if((wn = wcreate(WINDOW_Y, WINDOW_X, ROWS, COLS, NBORDER)) == -1) {
  1401. X        (void)fprintf(stderr, "could not open window  wn = %d\n",wn);
  1402. X        wexit(1);
  1403. X    }
  1404. X
  1405. X     /* draw the initial border around the playing region */
  1406. X
  1407. X    do_slk( );                                    /* set cheating on */
  1408. X    initborder();
  1409. X
  1410. X     /* set up function keys */
  1411. X    wuser(wn, "klondike");
  1412. X
  1413. X     /* allow mouse inputs in 8 bit mode */
  1414. X
  1415. X    keypad(0,1);
  1416. X
  1417. X     /* turn off the cursor */
  1418. X
  1419. X    wputs(wn,"\033[=1C");
  1420. X
  1421. X     /* catch the signals */
  1422. X
  1423. X    (void)signal(SIGHUP,  leave);
  1424. X    (void)signal(SIGINT,  leave);
  1425. X    (void)signal(SIGQUIT, leave);
  1426. X    (void)signal(SIGWIND, reborder);
  1427. X}
  1428. X
  1429. X#ifdef CHEAT
  1430. X    extern int cheat;
  1431. X#endif
  1432. X#ifdef RUN
  1433. X    extern int run_deck;
  1434. X#endif
  1435. X
  1436. Xvoid
  1437. Xdo_slk( )
  1438. X{
  1439. X    char *upper, *lower;
  1440. X    char *p, *q;
  1441. X
  1442. X    upper =
  1443. X"  VEGAS    HOUSE    REPLAY                                              QUIT  ";
  1444. X    lower =
  1445. X"  RULES    RULES     HAND                                            ";
  1446. X
  1447. X#ifdef CHEAT
  1448. X    p = upper + 31;
  1449. X    q = "  CHEAT ";
  1450. X    while ( *q ) *p++ = *q++;
  1451. X    p = lower + 31;
  1452. X    if ( cheat ) q = "   ON   ";
  1453. X    else q = "   OFF  ";
  1454. X    while ( *q ) *p++ = *q++;
  1455. X#endif
  1456. X#ifdef UNDO
  1457. X    p = upper + 40;
  1458. X    q = "  UNDO  ";
  1459. X    while ( *q ) *p++ = *q++;
  1460. X#endif
  1461. X#ifdef RUN
  1462. X    p = upper + 52;
  1463. X    if ( run_deck ) q = "  RUN   ";
  1464. X    else q = "        ";
  1465. X    while ( *q ) *p++ = *q++;
  1466. X#endif
  1467. X#ifdef SCORES
  1468. X    p = upper + 61;
  1469. X    q = "  ZERO  ";
  1470. X    while ( *q ) *p++ = *q++;
  1471. X    p = lower + 61;
  1472. X    q = "  HIST  ";
  1473. X    while ( *q ) *p++ = *q++;
  1474. X#endif
  1475. X    wslk(wn, 0, upper, lower );
  1476. X}
  1477. X
  1478. X/*
  1479. X * draw the initial border around the playing window
  1480. X */
  1481. X
  1482. Xinitborder()
  1483. X{
  1484. X    struct uwdata win;
  1485. X
  1486. X     /* determine the initial window size in pixels */
  1487. X
  1488. X    (void)ioctl(wn, WIOCGETD, &win);
  1489. X
  1490. X     /* save the size so that everyone can use it */
  1491. X
  1492. X    win_width  = win.uw_width;
  1493. X    win_height = win.uw_height;
  1494. X
  1495. X     /* draw the border in the screen image */ 
  1496. X
  1497. X    wrastop(wn, (unsigned short *)0, 0, (unsigned short *)0, 0,
  1498. X        0, 0, 0, 0,
  1499. X        win_width, TOPBORDER, SRCPAT, DSTSRC, patwhite);
  1500. X    wrastop(wn, (unsigned short *)0, 0, (unsigned short *)0, 0,
  1501. X        0, 0, 0, win_height-TOPBORDER,
  1502. X        win_width, TOPBORDER, SRCPAT, DSTSRC, patwhite);
  1503. X    wrastop(wn, (unsigned short *)0, 0, (unsigned short *)0, 0,
  1504. X        0, 0, 0, 0,
  1505. X        SIDEBORDER, win_height, SRCPAT, DSTSRC, patwhite);
  1506. X    wrastop(wn, (unsigned short *)0, 0, (unsigned short *)0, 0,
  1507. X        0, 0, win_width-SIDEBORDER, 0,
  1508. X        SIDEBORDER, win_height, SRCPAT, DSTSRC, patwhite);
  1509. X}
  1510. X
  1511. X/*
  1512. X * catch SIGWIND -- draw border as forground or background
  1513. X */
  1514. X
  1515. Xreborder()
  1516. X{
  1517. X    unsigned short *pat;
  1518. X    struct uwdata win;
  1519. X
  1520. X     /* determine if the window is on top */
  1521. X
  1522. X    (void)ioctl(wn, WIOCGETD, &win);
  1523. X
  1524. X     /* if current window then add border interior, else remove it */
  1525. X
  1526. X    pat = (win.uw_uflags & KBDWIN) ? patwhite : patblack;
  1527. X
  1528. X    wrastop(wn, (unsigned short *)0, 0, (unsigned short *)0, 0,
  1529. X        0, 0, 1, 1,
  1530. X        win_width-2, TOPBORDER-2, SRCPAT, DSTSRC, pat);
  1531. X    wrastop(wn, (unsigned short *)0, 0, (unsigned short *)0, 0,
  1532. X        0, 0, 1, win_height-TOPBORDER+1,
  1533. X        win_width-2, TOPBORDER-2, SRCPAT, DSTSRC, pat);
  1534. X    wrastop(wn, (unsigned short *)0, 0, (unsigned short *)0, 0,
  1535. X        0, 0, 1, 1,
  1536. X        SIDEBORDER-2, win_height-2, SRCPAT, DSTSRC, pat);
  1537. X    wrastop(wn, (unsigned short *)0, 0, (unsigned short *)0, 0,
  1538. X        0, 0, win_width-SIDEBORDER+1, 1,
  1539. X        SIDEBORDER-2, win_height-2, SRCPAT, DSTSRC, pat);
  1540. X
  1541. X     /* reset signal trap */
  1542. X
  1543. X    (void) signal(SIGWIND, reborder);
  1544. X}
  1545. X
  1546. X/*
  1547. X * SIGINT, SIGQUIT -- close windows and cleanup
  1548. X */
  1549. X
  1550. Xleave()
  1551. X{
  1552. X    wdelete(wn);
  1553. X    wexit(0);
  1554. X}
  1555. END_OF_window.c
  1556. if test 4698 -ne `wc -c <window.c`; then
  1557.     echo shar: \"window.c\" unpacked with wrong size!
  1558. fi
  1559. # end of overwriting check
  1560. fi
  1561. echo shar: End of archive 1 \(of 6\).
  1562. cp /dev/null ark1isdone
  1563. MISSING=""
  1564. for I in 1 2 3 4 5 6 ; do
  1565.     if test ! -f ark${I}isdone ; then
  1566.     MISSING="${MISSING} ${I}"
  1567.     fi
  1568. done
  1569. if test "${MISSING}" = "" ; then
  1570.     echo You have unpacked all 6 archives.
  1571.     rm -f ark[1-9]isdone
  1572. else
  1573.     echo You still need to unpack the following archives:
  1574.     echo "        " ${MISSING}
  1575. fi
  1576. ##  End of shell archive.
  1577. exit 0
  1578. -- 
  1579. David H. Brierley
  1580. Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
  1581. Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
  1582. %% Can I be excused, my brain is full. **
  1583.