Classic Computer Magazine Archive COMPUTE! ISSUE 51 / AUGUST 1984 / PAGE 83


Rick Rothstein

Now you can experience the thrill of slot machines without the danger of losing your money. These programs will show you how the bandits work and also how difficult it really is to hit a jackpot! Versions for TI-99/4A with Extended BASIC, Commodore 64, VIC-20, Atari, and IBM PC/PCjr (Color/Graphics Monitor Adapter required on PC).

Have you ever been to a casino in Las Vegas or Atlantic City? If so, your first visit probably left you dumbstruck over the sheer number of slot machines waiting to take your money. These nefarious one-arm bandits dazzle you with bright lights and promises of instant wealth.

A recent trip to Atlantic City—and an unprofitable encounter with some of these machines—prompted me to write "Jackpot." The program features three very different playing levels. Level one offers true casino odds; level two offers very generous odds which gives the player roughly the same odds that a casino normally enjoys; and level three will, in the long run, make you the owner of the casino.

Frustrating Experiences

After you experience the frustrations of playing against the legitimate odds of level one, level two should give you a small measure of satisfaction if you play it long enough. Level three was included for you to play after you discover that level two, although tilted in your favor, is not overly generous.

Colorful graphics are used to display a payout chart, your current monetary status, and three large windows through which cherries, limes, plums, bells, bars, or lucky sevens will show. The shape displayed in each window is picked at random from 20-position wheels containing the above six shapes scattered randomly around them. The number of times each shape appears on each wheel was selected to produce the desired odds for each level of play.


Before play begins in the TI version, the number 1 is displayed in each window, and the prompt ENTER LEVEL appears under the payout chart. If you press the space bar, the displayed level number will change. Press ENTER to begin the game at the displayed level. The payout chart continually prompts you to press the letter P to play and S to stop (the game). In addition, press­ing AID (FCTN-7) will allow you to enter a new level of play, and pressing REDO (FCTN-8) will reset your money status to even while retaining the same level of play.

This program is written in Extended BASIC, and because it uses both upper- and lowercase letters, it can only be typed into a 99/4A console. However, once the program is recorded on tape or disk it will load and run properly on the older 99/4 console.

A winning combiation on the TI version of "Jackpot."

In order to facilitate use of the automatic NUMBERing command built into the 99/4A, the line numbers for the program logic begin at line 100 and increase in increments of ten. (Except for the introductory REMarks, all other REMark statements have line numbers ending in five and may be omitted.)

A Character Of Its Own

One of the strongest features of the 99/4A is its ability to display high-resolution graphics and up to 16 colors simultaneously. This program makes excellent use of these features by using seven different colors and redefining all 112 Extended BASIC characters which make up the highly detailed displays.

Although the program logic and mathematical theory of slot machines will not be explained, here are some of the programming techniques used in the TI version:

Line 120 sets the foreground and back­ground colors of character set 0, which contains the cursor symbol and the edge character, to the same color and then fills the screen with the cursor symbol. Although the characters in this set cannot be redefined, turning the foreground and background to the same color has the same effect as redefining them to solid blocks of color. Filling the screen with one of these characters produces a solid background color which is independent of any other character—something the blank character cannot do.

After all of the characters have been redefined, they are combined into strings and placed on the screen with the DISPLAY AT command of Extended BASIC. This is a much faster way to place graphics on the screen than using the CALL HCHAR or CALL VCHAR subprograms.

The first statement in line 170 uses a random number, from the sequence that RANDOMIZE generates, for each loop in which either no key or an unrecognized key is pressed. This technique insures that the sequence of plays will not be repeated, since the time period between recognized keypresses will vary from play to play and from person to person.

Sluggish Sprites

Most programmers who work in Extended BASIC think sprites are useful only when they move. Actually, they can be very handy if placed on the screen and left stationary. In this program, one sprite, doubled in size by the CALL MAGNIFY (2) subprogram, is placed in front of each window. They serve as level-of-play indicators and are left transparent during game play. When needed, a simple CALL COLOR makes them visible. The advantage of using sprites in this particular application is that characters (numbers in this case) defined in an area measuring two characters by two characters are displayed with no additional character redefinitions. (Remember, all 112 Extended BASIC characters were redefined and used for the display graphics.) Without sprites, 12 additional character redefinitions would have been necessary to create the three large-sized numbers needed for the level-of-play indicator.

Notes For The Commodore And IBM Versions

The VIC-20 version of "Jackpot" (Program 2) plays the same as the TI version, but does not offer a choice of different levels at the beginning of the program. The faces of each of the three wheels are numerically represented in the DATA statements in lines 310-330. A 1 represents a bar, 2 is a seven, 3 a bell, 4 a cherry, 5 a lime, 6 a plum, and 7 a lemon. To change the odds, simply change the numbers in the DATA statements. For example, if you change all the numbers in the DATA statements to 1, you will always spin triple bar.

The Commodore 64 version (Program 3) is very different from the other games. Using a machine language subroutine and colored sprites, a smooth spinning effect is created. A total of six sprites are used (two for each window). The different shapes are displayed by changing the sprites' data pointers.

You can alter the odds, in the same way as the VIC version, by changing the numbers in the DATA statements in lines 155-165.

The IBM version of Jackpot (Program 4) uses the graphics PUT and GET commands to display various shapes on the screen. To run this program, therefore, requires either Cartridge BASIC (PCjr) or BASICA and the Color/Graphics Adapter (PC). The rules are the same as for the TI version, but the pay­offs are slightly different. In the IBM version, you begin with $100. If you want to change the odds, change the numbers in the DATA statements in lines 1310-1330.

Atari Jackpot

Ray Patrick

"Jackpot" for the Atari is a random slot-machine simulation that uses a fancy technique to manipulate the image on the screen. Strings are used to hold the character images that are placed on the screen. A pointer to the string is used to specify which character is being displayed on the screen. The character codes on the screen are never changed, but the data that the character code references is changed to simulate the movement. This is done through the pointer.

This technique allows BASIC to appear a lot faster than it really is. If you were to change the character code on the screen instead of changing the pointer, the simulation would slow down considerably and the only thing that could speed it up would be machine language.

The game is very easy to play. All you really have to do is press the P key to play and the E key to end. You will begin each game with five dollars. Each bet is limited to a quarter to force you to be thrifty. You may be glad about this restriction after you re­alize how difficult it is to win. Payouts are based on odds.