8 CARD PATIENCE by Colin Gooch from ZX Computing Aug/Sep.1984 CARD CORNER - PATIENCE II Colin Gooch presents a variation known as 8 Card Patience in part 2 of his series. This is a traditional Patience game, which involves us in quite a lot of intricate programming. This is because we can have up to ten different stacks of cards displayed, plus another one 'in our hand', and we need a separate string for each stack so that we can know where each card is. These stacks have to be moved visually from one place to another. Fairly full rules are given in the programme. Briefly the object is to build four stacks by suit in ascending order, from a further hidden stack and the remainder in our hand. The card presentation is on a five by seven matrix which allows for a reasonable representation of a standard card in two rows of five. For identification purposes each card position is numbered underneath and it is these numbers that you enter to make a move. Also indicated is the base card; ie. the card at the bottom of each stack. Programme operation The fifty two cards are each represented by a string of five characters representing card name, value (2 characters), suit, and colour. These are originally formed in A\$ which is then shuffled. After the hidden stack of 13 cards has been formed the remainder becomes P\$ and this is manipulated to gradually build up the various stacks by dealing them out three at a time. The cards are not transferred to another string as they are dealt but a variable PSL slices P\$ at the correct place. A choice of two deals is available, the second of which is a shuffling deal which gives an easier game. A string array R\$ holds the eight possible stacks of played cards and is shadowed by a numerical array R which acts as a slicer for each stack. Also the hidden stack has a slice SLST. Program lines A line by line breakdown of the action is as follows: 1020-1060 Initialises and calls up instructions. 1070-1090 Chooses hidden stack. 1100-1200 Deals out stack face down then removes the first card to top row. 1210-1230 Prints out bottom row of cards then moves on to 1420 which is start of main programme. 1250 Prints a card back 1260-1410 Prints out a card. The position is fixed by a defined function based on the card that has been chosen. 1420-1430 Choose to move a card or to deal. 1490-1530 Subroutine to accept a card move. Will reject an illegal entry. 1540-1560 Chooses appropriate routine from either moving a stack or taking a dealt card. 1570-1580 Reprints a card if entry is at fault 1585-1690 Moves cards one by one from one stack to another. 1700-1770 Checks validity of the destination. If wrong sets FLT flag. If correct prints card at new location. 1780-1800 Removes card from the pack and resets variable holding number of cards. 1810-1830 Removes card from one of the stacks and resets slicer. 1850-1890 Removes card from stack of hidden cards. 1900-2050 Deals the cards. The correct deal will be used as set by DEALTYP. 2060-2150 Sets up and shuffles the pack. 2160 Subroutine called at end of others to continue game. 2170-2260 End game. Called when the RES flag is set by programmer or player resigns. Gives options for continuing. 2270-2630 Instruction routine. It can be a temptation to miss out instructions but it is recommended you enter these for future reference. In any case the lines from 2530 must be included as they set the deal-type. The POKEs seen in this section POKE values directly into the attributes file to highlight certain points. 2640-2690 Initialise values. 2700-2880 Sets up the graphics 9990-9993 SAVEing and LOADing instructions. Variables A\$ Complete pack B\$ Pictures of suits C\$ Card in play D\$ Temporary string E\$ F\$ Components of card K\$ Base value for top row T\$ Title P\$ Pack in play R\$(x) Stacks of cards in rows S\$ Spare stack Z\$ Choice of cards to play COL Colour of card DEALT Cards dealt DEALTYP Type of deal to use ENDP Flag to indicate all cards used FA FD Temporary Flags FLT Flag to indicate faulty input L M Position of cards (face down) B M N P Q FOR-NEXT loops PCD Number of cards in pack PSL Slicer for pack R(x) Slicer for R\$ RES Flag to indicate game end STACK Cards in hidden stack SLST Slicer for stack X Y Position of card to be printed Z(x) Card to be played. Derived from Z\$ NOTE This program will not fit into a 16K machine. -- Another Fine Product transcribed by: Jim Grimwood (jimg@globalnet.co.uk), Weardale, England -- 