Classic Computer Magazine Archive START VOL. 3 NO. 1 / SUMMER 1988


North To Alaska

START's Klondike Solitaire Game

by Rob Lech


Computer card games come and go, but now START brings you the classic solitaire game--guaranteed to keep you playing and playing again! Boot up your color monitor in low resolution for hours of relaxation with START Klondike--the ultimate ST solitaire game.

Ready to play a great card game? Check out SOLITAIR.ARC on your START disk.

Summertime is when most people relax a bit, put their feet up and while away the hours. There's nothing like sitting out on the veranda in peace with a tall lemonade and a deck of cards, just playing solitaire as the sun arcs across the blue sky. But if you don't have a veranda or can't find that deck of cards the kids were playing with last winter, fire up your ST and play START Klondike. You'll find it every bit as enjoyable and addictive as it is with the pasteboards.

Up until a few months ago, I also used a deck of cards whenever I wanted to play a game of solitaire. But after a few games, I realized that the ST could not only save time shuffling, but could also keep all the cards straight and off my lap. All I had to do then was to write the program. . .

Klondike, also called Canfield, is a classic solitaire game with a long history. Because of its popularity over the decades, Klondike has many rules variations. For START Klondike, I chose the most commonly used set of rules outside of Reno, Las Vegas and Atlantic City. To achieve the look and feel of a real card game, START Klondike runs in low resolution on a color monitor only.


In START Klondike, your ST deals seven stacks of cards beginning from the left every time you click on the GAME button. On the left is one card face up. The second stack has two cards, one face up and the other face down under it. The third has three cards with two of the three face down, and so on so that the stack on the far right has six cards face down and one face up. The rest of the cards forms the pack. This set-up is called the tableau. If you don't like the way your hand looks, just click on the GAME button again to redeal.

The object of Klondike is to build four suit piles from ace to king. If you have an ace face up in the tableau when you start a game, you can start its suit pile immediately by placing it onto the matching location at the bottom of the screen. You may play the next card in order onto a suit pile of the same suit. For example, you may play the two of diamonds onto the ace of diamonds and the three of diamonds onto the two of diamonds, but not a heart onto a diamond.


To play or move a card in START Klondike, move the mouse pointer inside the outline of the card you want to move and hold down the left mouse button. The card can then be dragged to wherever you want to play it. Before you release the mouse button, make sure that the upper left corner of the card is inside the outline of the spot you want to place the card. START Klondike will not let you make an illegal move.

To uncover the cards in the stacks, you have to play them on other cards or on the suit piles. You can move a card onto another card in the tableau only if it's of the opposite color and a number one less than the card you're playing it on. In other words, you can play a red seven on a black eight, a black queen on a red king and so on. The king is the highest in a suit and the ace the lowest.


As you move a card or column from a stack and lay it down in its new spot, START Klondike automatically turns over the next card in the stack. The width of the grey borders on the stacks will give you an idea of how many cards there are in stack. When you have turned over all of the cards in a stack, you will have an open stack with your green tabletop where the stack was. If you want to, you can move a king--and only a king--into an open stack from the turn pile or another stack.

If you have a column of cards on a stack and the top one can be played on another card, put the mouse cursor inside the outline of the top card and drag it (and the whole stack) onto its new location. All of the cards in the column will follow. Also, START Klondike allows you to split stacks by moving a part of a stack onto another if the top card of the portion you're moving can be played on the other stack. This can be very handy to uncover a card to play on a suit pile.

START Klondike.


After you have played all of the cards you can play from the deal, click the left mouse button on the pack in the lower left corner of the screen. This will turn over the top three cards from the pack, but you will only be able to see the top one of the three in the turn pile next to the pack. You can play any card in the turn pile just as if it were on the table. Playing a card from the turn pile will reveal the next card below it. Playing or discarding three cards in a row from the turn pile will reveal the last card you turned. When you have played all of the cards in the pack, click again in the green space where the pack was and START Klondike will flip the pack over and start back through it again.

If you get stuck so that you can't play any card on the board or the turn pile, you've lost that hand. Just click on the GAME button again and you will have a fresh hand to play.


The most useful portion of the Klondike source code is the subroutine that draws the playing cards. Draw_card(x,y,c) displays a 35 x 39 pixel playing card of value "c" where the screen coordinates of the upper leftcorner are "x" and "y". If the card value is zero, a card will be erased (i.e a 35 x 39 rectangle will be drawn and filled with the background color). If the card value is 1-52, a playing card will be displayed. Hearts are numbered 1-13, clubs 4-26, diamonds 27-39, and spades 40-52. Card values of 53 and 54 will display the back of a card and the outline of a card, respectively.

Card_out is unique in the sense that it doesn't simply index into an array of data and blast out a card. It actually builds the card using suit symbols and colors. This technique, although more complicated, has rather modest data requirements. The required data and brief comments can be found in the file DAT1.S.

Draw_out can be altered to meet the requirements of almost any card-type application you might have in mind. It should be altered in one very important aspect. The visual organization of ST Klondike required that the display of stacked cards end at y = 154 to leave room at the bottom of the screen for the pack, turn and suit piles. This was accomplished by clipping GEM primitives and altering the display of raster forms. To remove or alter this restriction, pay careful attention to the "vs_clip" calls upon entry and exit and to the testing of y > 154.

I hope you enjoy playing START Klondike. For me it was a challenge to write the most efficient card game I could. If you are a programmer, look at the source code for the method I used to draw the cards. I think you'll find it useful. If you'd like to see more articles like this, circle 199 on the Reader Service Card.

Rob Lech and his partner, Troy Dahlam, are experienced games programmers. Together they wrote Joust and the soon-to-be-released Centipede for the ST.