PATIENCE IV: THE WALL
by Colin Gooch
from ZX Computing Feb/Mar.1985

Colin Gooch continues his acclaimed series of
card games for the Spectrum.


This is, I think, one of the most challenging of the wide
range of patience games. Though obviously the run of cards
plays an important part the moves that the player makes also
affect the [outcome of] the game. The full rules are in the
program, but briefly we lay out all 52 cards, remove the
aces and then use the gaps to manipulate the cards into
order.

From the programming point of view producing 52 cards on
screen is quite a challenge. There is no way that a 13 x 4
grid of simulated cards is possible as we are restricted to
a card width of two print positions. What we have as a
"card" is a four by four print position representation of a
diamond, spade, etc. underneath a value. The picture of each
suit is made up of four user defined graphics.

Each card is contained in a pack and is represented by five
elements: a name, two to represent value, the suit and the
colour. The program reads the various elements to print out
each card.

The pack remains as A$ and five blanks are inserted each
time a card is removed and five blanks replaced at the new
position. At the end of a round wrongly placed cards are
transferred to another string P$, complete with gaps. This
is shuffled, and the gaps replaced by aces. This is then
printed out, a new card going to each location where there
is no existing card, sensed by the ATTR function, which then
becomes the new A$.


Line to line

1000      Defined functions to fix position of card on
          screen and in the various strings.
1010      Sets colours and CAPS SHIFT.
1020      Calls instructions and sets up pack.
1030-1070 Prints hand at the start of each round. Each is
          referenced by row and column.
1090-1140 The aces are removed from the display.
1150-1280 This forms a main loop which is repeated throughout a round.
          It invites you to enter a card to be moved. It then checks
          through each gap held in G$ to see if one is an appropriate
          move. A special set of conditions is checked if it is a two
          which is moved to the start of a line and thus does not
          follow another card. A faulty input will be ignored and you
          must enter again.
1300-1380 Subroutine to print a card.
1390-1400 Subroutine to blank a card.
1400-1440 Determines the position of card to be printed.
1450-1590 Program is directed to this point whenever you resign at the
          end of a round. If round number is three or less the pack
          will be reshuffled and dealt again. If round is over three
          then you will be given an opportunity either to carry on or
          end the game.
1600-1680 If game is to end the program is directed to this section.
1690-1780 Subroutine to check that an input is the correct
          length and within the required limits.
1790-1880 The pack is set up and shuffled ready for play.
1900      The graphics are set up from DATA at end of the program.
1920-2060 Instructions for play. Option to read.
2080-2250 Graphics DATA.
9980-9993 Start save and load routines. It is important to
          auto start at 9980 or graphics will not form.


Variables used

A$        assembled pack
B$        suits
C$        card in play
D$        temporary string
E$        holds four aces
G$        card immediately before blank
I$        title
N$,R$     captions
P$        pack of incorrect cards
Q$        temporary string
Z$        input
ACE       slicer for E$
B,M,N,P,Q loops
C         counting variable
COL       colour of card
CREP      location of card to be replaced into pack
F         temporary flag
RES       flag to determine end of game
ROUND     round in play
X,Y       position of card
Z1,Z2     values derived from Z$
Z1B,Z2B   temporary storage of Z1,Z2


Note

The amount and size of strings to be manipulated mean that
the program will not run in 16K RAM.


--
Another Fine Product transcribed by:
Jim Grimwood (jimg@globalnet.co.uk), Weardale, England
--
