The Atom Magic Book

Contents

Breakout, 3D Maze, Letters, Matches, Russian Roulette, Compart, Talkback, Moon Lander, Bouncing Ball, Patchwork, Bugrace, Space Battle, Hammurabi, Higher/Lower, Buzz-Word, Othello, Number Guessing A, Number Guessing B, Hex Pawn, Drive, Biorythm, Sums tester, Scramble, Designs, Hunt the Wampus, Simon, Screens, Hangman

Programming Tips
Other BASICs
Tape Recording
The 6522 Versatile Interface Adapter chip
The 8255 Programmable Peripheral Interface chip
Block 0 RAM
ROM Routines
VDU codes


Notes

The complete book has been scanned. The scans have been OCR processed, but only the English text has been amenable to proof-reading and automatic spell-checking. The program listings are not so suitable, since spell checkers are not aware of Atom BASIC syntax.

Source code:

Checking the program listings is as tedious as typing them in from scratch, because the OCR process produces so many errors. Rather than type them in as text, only for someone to type them into an Atom (real or emulated), these have been left as image files for now.

If anyone is interested enough to enter one of these programs, let me know and I can send you the image files which are legible. I have not put them on my website because I'm close to my 15 Mbyte limit and the compressed scans alone would consume around 5 Mbyte. These are between 48 and 126K per page, 5.45 Mbytes in total, so don't ask for more than you really want!

In return I would ask for a copy of the program in either text form or 'virtual' tapes as used by Atom emulators.

I also have the OCR text of the program source. Pretty heavily mangled, but might be slightly better than typing the whole lot from scratch.

Mail: keith at howell1964 dot freeserve dot co dot uk


Breakout

Text; 2K
VDU K
Integer

A noisy and fast moving version of the popular computer game, Breakout starts with a wall 5 bricks thick across the top of the screen and a small star passing from side to side across the bottom of the screen.

Pressing either of the SHIFT keys will make the star shoot up diagonally towards the wall. If it hits a brick then that brick will either fall out of the wall, or - if it is held up by another brick - will turn grey and fall as soon as it is no longer supported.

Points are scored by sending the star off the top of the screen through a gap in the wall. An arrow then appears at the point of exit and your score is increased by one. But be careful; if you accidentally hit an arrow it will fall and you lose that point.

You have a limited time in which to score as many points as possible. A count-down display of the time remaining is shown at the top left of the screen. When the game has finished, a new one may be started by pressing any key.

Source code

Program Notes:

The program uses two machine language routines (lines 5020 to 5160) to generate various sound effects.

The program draws on the screen by storing appropriate values (e.g. #2A for a *) in the VDU screen memory locations 8000-81FF.

Thus line 20 draws the initial 5 rows of bricks, line 40 Plots a *, and line 55 deletes the old *.

The main program loop is from lines 30 to 210, which moves the star across the screen; line 32 branching to e if you have scored a point, line 36 reducing your score if you have hit an arrow. If you hit anything, line 37 branches to the routine at line 2000. Lines 40-55 shift the image of the star - using subroutine 5 to provide sound effects if it is moving upwards. Lines 56-60 sets W to -32 when the SHIFT key has been pressed.

Lines 490-530 increment your score, PLOT an arrow in the place where you broke through the wall, using the subroutine s to generate the winning sound.

Line 2000 is reached if the star hits anything, and returns to the main loop at line 210 if a solid brick is below the one hit. Line 2002 is executed if you have hit an arrow. Lines 2005-2040 make the falling brick images and sounds. Lines 2050-2070 repeat the process if any grey blocks are left unsupported.

Line 1010 is reached at the end of the program; it waits for any key to be pressed, then starts a new game.


3D Maze

Text; 5K
VDU; 1K
Integer

This program generates a random maze of specified dimensions then Plots it in 3D as though you were actually inside it. You then have to find your way out by moving forward (key F), or by turning right (R) or left (L). Pressing key H (for HELP!!!) will give you your co-ordinates and the direction in which you are pointing.

The exit is represented by two vertical poles;

<DIAGRAM HERE>

The maximum size of maze allowed is 19 x 18.

Source code


Letters

Text; 2K
VDU; K
Integer

This program plots a number of letters on the screen. You then have to erase them all by moving the cursor over each letter in turn. If you hit the edge of the screen or donut erase the letters in alphabetic order then the game finishes and you lose.

Once the game has started the cursor is continually moving. To change it's direction press one of the keys 4,5,6 or 7; which make it, go down, ups left or right respectively.

As it moves, the cursor leaves a trail that can cause great confusion if you have to retrace your steps, as you are then unable to see exactly where you are.

The difficulty of the game can be varied by specifying a different number of letters (1 to 26) to be erased, or by varying the speed of movement to 10) in response to questions asked when the game is started. You are also asked for a 'course number'. This is used to seed the random number generator used to position the letters, so that you may run exactly the same game again by specifying the same course number.

When the game has finished - either because you have made a mistake or because, you have successfully erased all of the letters, then another game is automatically started.

Source code

Program Notes:

By leaving out the REM lines and abbreviating the other lines, 'letters' can be made to fit into 1K text RAM space.

A machine language routine (lines 20-75) is used to scan the keyboard by directly manipulating the 8255 I/O chip ports. Line 9 prevents the assembly listing from appearing on the screen when the program is executed. Line 90 subsequently re-enables the display.

Since the random number seed occupies 5 bytes of RAM, (locations 8 to 12), while an integer variable takes only 4 bytes, pre-setting the seed to the 'course' number (C; line 115) involves setting RAM location 12 to zero as well as storing the value of C in the other four bytes.


Matches

Text; 1K
VDU K
Integer

Matches is a simplified form of NIM. Starting with a row of from 21 to 32 matches, the player and the computer take turns to remove 1, 2 or 3 matches. The player left with the last match loses.

Source code

Program Notes:

Line 100 establishes the starting number of matches and displays them by calling subroutine 900. Lines 110 to 140 then present the instructions above the displayed row of matches.

Lines 300-340 get the player's choice and check that it is valid, lines 400-470 then calculate the computer's move. If neither side has won then the current state of the game is displayed and the next move played.


Russian Roulette

Text; 1K
VDU; K
Integer

Russian Roulette is a game for two or more players who take turns to place a loaded revolver to their heads and pull the trigger. Five of the revolver's chambers are empty, the sixth contains a live round. The game is over when a player refuses to take his turn, or when the revolver fires.

In response to the question 'DO YOU WANT TO PULL THE TRIGGER', enter either Y or N, then press the Return key.

Source code

Program Notes:

The two PRINT $12 statements (lines 20 & 210) clear the VDU screen and position the cursor at the top left corner.

Line 230 gives a half-second pause to heighten the tension. Line 300 generates a 'click' sound; line 510 makes a suitable 'raspberry' noise.

Lines 400-450 may be improved by artistically minded programmers.


Compart

Text; 1K
VDU; 1K
Integer

This program draws a sequence of five abstract pictures in either black and white, or black, grey and white.

Source code

Program Notes:

If double shade drawings are selected, then I=2 and line 40 sets the VDU controller to mode 1a.

Line 70 gives a short pause at the end of each drawing for you to admire it before the computer begins its next opus.


Talkback

Text; 2K

VDU; 2-6K

Integer

While this program does not answer Man's dream of a talking computer, it does allow you to record a few seconds of speech in ATOM's memory, then play it back on demand.

The speech is converted to digital form then stored in the VDU RAM area (above the text screen area), each 1K byte giving one second of recording time. In any digital speech recording system a compromise must be made between quality of reproduction and the amount of storage needed - in this case the choice has been to extend the recording time as much as possible and accept a pretty dreadful quality for the reproduced signal) although a noticeable improvement can be made by careful choice of the recording-level and by turning any amplifier 'treble' control to minimum.

Recording is done from a microphone connected via a suitable amplifier to ATOM's 'CASS IN' port. The level needed by ATOM is about the same as when loading programs from tape, so the cassette recorder amplifier will probably be suitable. Playback is through ATOM's built-in loudspeaker.

When the program is run, it asks if you want to Record or Play-back If you choose to record then the screen will be covered by snow' for a few seconds while the program initialises the VDU RAM area. You are then asked to press any key to start the recording process. While recording, the screen will again be sprinkled with white lines as the data is stored.

Source code

Program Notes:

As given, the program expects the full 6K bytes of VDU RAM. If less RAM is available, the CPY @#98 instructions in lines 1080 and 1590 should be changed to;

CPY @#94 for 5K bytes VDU RAM
     #90 4 " "
     #8C 3 " "
     #88 2 " "

The main work is done by the two machine language routines at lines 1000-1120 and 1500-1630. When recording, the voltage on the CASS IN port is examined every 125 S, and one bit of the memory is set to either '1' or '0' depending on whether the signal was positive or negative. When playing back, a single bit is taken from the memory every 125 S and the state of the loudspeaker drive line set high or low accordingly. A large part of the machine language routines (notably lines 1040, 1100, 1110, 1560, 1600 & 1610) consists of 'time wasting' instructions inserted so that the over-all loop time is always l25 uS.

Note that lines 210-230 preset the RAM before recording so that each byte has bits 1-7 =0 and bit 0 = 1.


Moon Lander

Text; 2K
VDU; 1K
Integer

You are piloting a rocket landing on the Moon; the **!!**!!** computer has failed again (and the engine sound rough). At the start of the simulation you are 450 metres up, travelling horizontally at 300 metres per second, and starting to fall from orbit. You should aim to land within the Lunar Landing Area (the small white rectangle on the Moon's surface) with a vertical velocity of less than 50 m/s and a horizontal velocity of less than 20.

Your controls are the keys F, R and U, which apply forward, reverse or upward thrust respectively but only one at a time. Instrument readings of height, velocities and fuel remaining are given on the tight of the screen. Happy landings.

Source code

Program Notes:

A small machine language routine (line 30) is used to scan the keyboard and put the number of any key pressed into RAM location 80. Lines 100-190 set up the constants J-O which are used for speed in the main program loop, the starting values and position, and prepare the screen. Note lines 160-190 (and 280) which move the print cursor by storing a four-byte word in locations #DE-E1.

The main body of the program is lines 200 to 290 which continually plot the latest position of your craft (lines 210,220), scan the keyboard and adjust the velocities and fuel level accordingly (lines 230-260) and update your position (line 270). Every five iterations, line 280 updates the instrument readings.

When you have touched ground, lines 300-370 draw an explosion and make suitable comments if you landed too fast. If you have survived, lines 400-499 pass comment on your prowess as a pilot.


Bouncing Ball

Text; K
VDU.; K
Integer

A simple demonstration of a moving display) this program shows a ball bouncing endlessly between the walls of an enclosure. Use ESC to stop the program.

Source code

Program Notes:

Line 10 sets up the 48 x 64 graphics mode and the starting position (X,Y) and velocity (H,V) of the ball. Lines 25-40 then DRAW the four walls.

The main body of the program is the loop covering lines 50-90. Lines 50 and 60 reverse the direction of travel if the ball touches one of the walls; line 70 deletes the old image of the ball from the screen, and lines 80 and 90 calculate the new position and plot it.


Patchwork

Text; K
VDU; K
Integer

Patchwork displays a very long sequence of 'kaleidoscope' patterns. Other sequences may be obtained by changing line 140.

Source code


Bug Race

Text; 1K
VDU; 1K
Integer

Another simple moving display program, Bug race shows two specks skittering down a racetrack. The program stops when one bug reaches the end of the course - then after a short pause it runs another race.

Source code

Program Notes:

Line 5 sets up the 64 x 128 graphics mode and the starting points (A,B for the first bug, C,D for the second).

The main body of the program is the loop through lines 10-90. Line 20 erases the previous images; line 80 plots the new positions of the racers. The WAIT statements in lines 10 and 70 ensure that the VDU RAM is only accessed during the display blanking periods (and also slow the competitors down to a decent pace). Lines 30,40 calculate the new positions, and lines 50-65 make sure that the racers do not stray out of their lanes.


Space Battle

Text; 2K
VDU; 1K
Integer

You are engaged in a fast moving battle against alien spaceships that must be zapped before they can destroy you and go on to conquer Cambridge. Before the fight started, you had a chance to choose the number of enemy ships and the general level of skill needed to survive. Now' the battle is under way, the screen shows you the relative position of the nearest alien. To kill him you just have to steer your ship until his image comes within the inner aiming rectangle on your screen, then press the firing key. But be quick about it - he is liable to shoot back. New recruits to the Atomic Space Service are advised to gain experience in fights at skill level 1 before tackling trickier opponents.

Source code

Program Notes:

Lines 10-80 display the instructions at the start of the game, get the number of aliens (A) and skill level (L), then calculate the size of the aiming window (O,P,Q,R). U and V are the horizontal and vertical velocities of the alien ship, S is the number of shots fired.

The main body of the program is the loop through lines 200-280, which plots the latest position of the alien ship (line 200), then scans the keyboard (subroutine b) and acts accordingly.

Line 2l0 sometimes calls the subroutine at line 500 to give the enemy a chance to fire at you or change direction.

Lines 300-350 are the 'your shot' subroutine; line 300 makes a suitable noise, line 320 draws the shot lines and line 330 erases them. If the alien ship was within the aiming rectangle the program jumps to line 400 to draw a brief explosion with sound effects provided by line 420. If you have destroyed all of the enemy ships the program then goes to line 1000, otherwise line 440 draws a new screen with the next alien.

Lines 500-580 are executed when the alien fires at you. Lines 500 and 520 show the enemy fire and make a suitably frightening noise, line 530 changes his direction of travel. If you have suffered a direct hit (C=64, D=32) then the game ends via lines 560 to 580.

Lines 900-910 scan the keys B-F by direct manipulation of the I/O ports at B000 and B001, and put a '1' In one or the RAM locations 80-84 if the corresponding key was pressed.


Hammurabi

Text; 2K
VDU; K
Integer

Hammurabi was possibly the first 'world simulation' computer game to be written. You play the part of Hammurabi; King of ancient Sumaria. Each year your faithful servant - Atom - tells you how big your kingdom is, how many subjects you have, and how much grain is left from the harvest and from previous years. You then have to decide whether to trade land for grain with neighbouring kingdoms, how much to allocate as food for the coming year, and how much grain is to be used as seed.

Your subjects will die of starvation if you don't allocate enough food for the coming year (about 15 bushels each), but if you give them too much the surplus is wasted. Each year's harvest depends on the amount of seed used, but planting more than two bushels per acre is wasteful as is allocating more than 25 bushels of seed to each of your subjects. The harvest is also subject to a large random factor (the weather). Rats can devastate your grain stores, and your kingdom is subject to plagues about every seventh year.

Source code

Program Notes:

Line 20 sets up the initial values of H (population), S (grain in store), A (acres of land) and V (year).

The main body of the program is lines 100 to 490, which are executed once for each year of your reign. Lines 100-140 report on the extent of your kingdom, lines 200-290 then ask for your decisions about the amounts of grain to be used for food and seed, each answer being quietly checked for validity and diplomatically ignored if you ask for the impossible (subroutine a being used to delete an erroneous entry from the screen and re-position the cursor; note that there should be exactly 32 spaces, between the quotation marks in line 1000). Lines 300-360 calculate the results for the year, in terms of R (bushels of grain eaten by rats), 0 (deaths from starvation), Z (deaths from plague) and N (births). If you have any subjects left after another year of misrule, the program then loops back to line 100.


Higher/Lower

Text; 1K
VDU; K
Integer

Higher/Lower is played by one person against the computer. For each play the computer picks two numbers between 1 and 99, displays the first, then asks the player to bet on whether the second number is higher or lower than the first. Starting with a stake of 100, a really successful player can break the bank by amassing l0,000 or more. The game will also end if the player has no money left.

Source code


Buzz-Word

Text; 1K
VDU; K
Integer

An aid for the busy executive, Buzz-Word generates impressive sounding phrases for use in reports to higher management.

Source code

Program Notes:

3 lists, each containing 5 words, are stored at the end of the program listing. Each list starts with a label (a, b or c), each word or phrase starts with a *. The program displays one word or phrase - chosen at random - from each list.


Othello

Text; 3K
VDU; K
Integer

Othello is played between the computer (C) and its human opponent (H) on an 8 x 8 board. At the start of the game, each player has two pieces in the centre of the board.

H and C take turns to place a new piece in one of the vacant squares so as to 'capture' one or more opponent's pieces. Pieces are captured if they lie on a horizontal, vertical or diagonal line terminated at one end by the piece just placed, and at the other end by an existing piece belonging to the player making the move. Pieces captured change type to that of the player capturing them.

Each move must capture at least one piece, or else the player forfeits that move. The game ends when all 64 squares have been filled or when neither player can move. The winner is then the player with the most pieces.

The program displays the current scores and the state of the board after each move. The human player should enter his move as the row (1-8) and column (A-H) of the selected square (e.g. 8A), or he may forfeit his move by just pressing the Return key. The program will not accept invalid moves.

The algorithm used to calculate the computer's move is a fairly simple one, which allows the human player a reasonable chance of winning.

Source code

Program Notes:

There should be exactly 32 spaces between the quotation marks in line 4010.

By cutting out the REM statements and abbreviating wherever possible, Othello can be made to run in 2K of text RAM.

The 10 x 10 byte array A(99) is used to hold the current state of the board; each byte being either 0 (free square), H or C. A 10 x 10 array is used because by considering it to represent the 8 x 8 board plus an empty surrounding border no special treatment is needed for squares on the edge of the playing board when looking for possible moves. The variable P is used to represent the position being examined, and the array NN holds the 8 possible movements from P.

Lines 100-170 set the starting values and DRAW the board at the start of play.

Lines 200-270 get your move, check that it is valid, then update the displayed board image and the array A().

The computer calculates its best move in lines 300-390 by examining every possible position, then choosing that with the highest score S. Line 355 introduces a random element if two positions have equal scores. The algorithm used does not do any form of 'look-ahead' but just sums the number of enemy pieces that could be captured, then increases the score if the square being examined is on the edge of the board, or decreases the score if it is just one row or column away from the edge.


Number Guessing A

Text; K
VDU; K
Integer

In this simple game, the computer picks a random number from 1 to 9, the player then has 5 chances to guess it. Unless the player has considerable ESP talent, he should only be able to win about half of the games played.

Source code


Number Guessing B

Text; K
VDU; K
Integer

This number guessing game gives the player 7 chances to guess a number from 1 to 99, but tells the player whether each guess was too high or too-low - which is enough information to allow the correct number to be deduced in every game.

Source code

Program Notes:

Line 20 chooses the number (N) and sets the print field width to zero for a neater display.

The PRINT $11 statements in lines 120 and 130 move the cursor back one line so that the comment 'IS TOO SMALL' or 'IS TOO BIG' appears on the same line as the entered value.

Line 200 generates the sound of success.


Hex Pawn

Text; 3K
VDU; 1/2K
Integer

Hexpawn is a simple game played between the computer (C) and its human opponent (H) on a 3 x 3 board. It is interesting to the computer programmer as it has the right level of complexity to useful for experiments in computer 'learning' techniques. In the program given here, the computer remembers each board position (or pattern) that it encounters, and over the course of many games it learns the best move to make from each position. Given enough practice it can become very good.

As the player will soon notice, the program does not attempt to work out the best move to make from any new position, but just selects the first legal move that it can find. However, if that move results in the computer losing, then it will not play the move again if confronted by the same position in another game.

At the start of each game each player has three pieces; the computer's being along the top row of the board, the human player's being along the bottom row. The pieces are similar to chess pawns and may be moved straightforward to an empty square, or may be moved diagonally forward to take an opponent's piece. A player loses when he cannot move any of his pieces. The program assumes that its opponent knows how to play properly, and the computer will surrender if it finds itself in a position that it has learnt will always lead to defeat.

At the end of each game the computer will ask if you want to another. Note that if the program is actually stopped at any time by ESC, BREAK or by refusing the invitation to play another game, then re-starting it by typing RUN will make the computer forget all it has learned. Type GOTO 100 to avoid this.

Source code

Program Notes:

There should be exactly 32 spaces between the quotation marks in line 1010.

The current state of the board is held in the 9 byte vector A(), each byte being 0 (empty square), 1 (computer's piece) or 2 (human player's piece).

The 201-byte vector S() is used to hold previously encountered board positions and the possible moves which did not lead to disaster. Each board position is represented by three bytes, which give the states of the three columns of the board, each coded to have a value of 64 to 127 (as X, Y & Z in lines 320-340). These are followed by single byte representations of the possible moves (if any) from that position coded as values from 128 to 255 (see lines 430 & 520). The end of the list is signalled by a zero byte. When the computer finds itself in a losing position, it removes the move that lead to defeat from the list (line 710).

The learning process is simplified by allowing the computer to recognise 'reflections' of board positions - thus when searching the list to see if it has played from that position before line 380 sets U=1 if it finds the mirror image position, and lines 520 to 560 subsequently invert the move selected.

When a new position is encountered, it is added to the list by line 410, then the program examines all possible from that position and adds legal ones to the list (lines 420-440).


Drive!

Text; 1K
VDU; K
Integer

Drive is a game in which you have to steer a rapidly moving object through a course that is gradually filled with white and grey squares. The grey squares represent the enemy targets; if you hit one it is destroyed and you gain a point. The white squares, however, are dangerous if you hit one it will explode, killing you and scattering potentially lethal debris. You can survive 3 'deaths' before the game ends - and gain an extra 'life' for every 10 grey blocks hit.

The REPT and SHIFT keys are used for steering, moving you up and down the screen respectively. When the game ends (because you have run out of lives') press the space bar to play another. While the game is in progress three numbers across the top of the screen show (from left to right) your current score of grey blocks zapped, the number of lives you have left, and the best score to date in previous games.

Source code

Program Notes:

Abbreviations have been used wherever possible to fit the program into 1K text RAM.

Line 20 draws the top and bottom boundaries of the course.

The main body of the program is within the loop between lines 30 and 999. An inner loop (lines 40-110) moves the object across the screen, using subroutine p to check for collision with a white square, and line 70 to see if you have destroyed a grey one. The program branches to see if you are killed; to PLOT the debris from the explosion and to see if you have any lives left. If you are still alive, line 100 plots your new position, and lines 102,104 test the state of the SHIFT and REPT keys.


Biorythm

Text; 2K
VDU; K
Integer

This program plots graphs of your physical (P), emotional (E) and intellectual (I) cycles for a four-week period.

As well as showing the ups and downs of your biological cycles, the graphs also warn of those critical days when a cycle is crossing through the centre line. For a finale, the program calculates how many days you have lived.

Source code

Program Notes:

The program is based on the assumption that your cycles follow sine-wave patterns with periods of 23, 28 and 33 days, staring from your birth.


Sums Tester

Text; 2K
VDU; K
Integer

And now to prove that the computer has an educational value. Sums Tester provides an exercise in simple mental arithmetic by posing 10 questions to be answered in 60 seconds. The questions involve simple addition and subtraction of numbers from 1 to 99 (no negative answers), and multiplication and division using factors up to 12, and are chosen at random by the program.

If you don't finish within the time allowed, the test ends; in any case your score and the total time taken to answer are shown at the end of the test.

Source code

Program Notes:

The program loops between lines 200 and 540 ten times; each time line 300 decides whether the question is to involve addition, subtraction, multiplication or division, and calls one of the subroutines starting at lines 1000, 1100, 1200 and 1300.

Lines 9000-9080 are two machine language routines similar, to those in the 'Keyboard Timeout' program given elsewhere in this book, which increment a counter (locations #80,#81) every 1/60th of a second while the program is waiting for an answer. The counter is preset to (-T) seconds at the start of the program by line 110. If the counter times out (by reaching zero), the machine-language routine executes a BRK instruction which - because of line 120 - makes the program jump immediately to line 700.

Lines 400-450 get the answer to each question as a string and convert that to a number if possible. If the input cannot be a number then the program goes back to line 400 to ask again. This approach is used in preference to a simple 'INPUT Z' because it prevents the program crashing if the user gives a non-numeric response (such as just pressing the Return key), and it also stops him cheating by for example answering "WHAT IS 63+38" by "63+38".


Scramble

Text; 2K
VDU; K
Integer

Scramble is a computer version of the old sliding letter square puzzle, in which you have to re-arrange 24 letters in a 5 x5 board by moving one letter at a time into the empty square.

When the program is run, it first shows you the board with the letters in order. It then scrambles them according to the degree of difficulty you have chosen for the game. You then have to restore the board to its original ordered form in less than 100,000 moves.

Source code

Program Notes:

The letters are stored directly in the appropriate VDU RAM locations, lines 130-160 set up the initial (ordered) board with the letters A-X and a blank position.

Lines 300-370 then 'scramble' the board by making 5xD moves (D being the degree of difficulty chosen for the game); the array DD(3) being used to hold the four possible movements from any position J. Line 350 checks that the computer does not attempt to move outside of the playing area, and that it does not attempt to move the same piece two times running when scrambling the board.

Lines 420-460 get your move and check that it is legal. Lines 470-490 then make your move on the screen, highlighting the positions you are moving between, then lines 500-540 see if you have put the board back into its correct order. If not, the program branches to line 600 and so back for your next move.

Lines 900-930 form a subroutine which is used to clear the bottom part of the screen and re-position the text cursor ready for the next move.


Designs

Text; 1k
VDU; 6K
Integer

Three short programs that use the highest resolution graphics mode to generate attractive moir patterns each program can produce a number of different designs, a fresh one being drawn each time a key is pressed.

Source code


Hunt the Wampus

Text; 4K
VDU K
Integer

This is a game for the brave and adventurous. You are hunting the dread Wampus, in the pitch-black depths of his cave kingdom, armed only with a bow and five arrows. Super strong bats also inhabit the caves, and though they will not harm you directly, they may make you lose the trail by carrying you off to another cave - and that might be the one with the bottomless pit! Good hunting, and don't run out of arrows.

Source code

Program Notes:

The body of the program is the loop from lines 120 to 400. Lines 120-230 show which cave you are in (W), and which you can move to (S,U,V). Lines 231,245 directly examine the keyboard keys 1 and 2 to see if you want to shoot or move to another cave. If you decide to move, lines 260-270 find out which cave you want to move to and check that this is possible.

Having moved you, the program then uses lines 290-310 to warn you of any dangers lurking in adjacent caves (X is the cave occupied by the Wampus that infested by superbats, and Z is that without a floor). If you had entered the cave of the bottomless pit, line 320 drops you in it. Lines 340-370 activate the bats when you intrude upon them. If the Wampus is next door, lines 410-450 decide whether he will eat you or merely move away.

When you decide to shoot, lines 600-618 find out which caves you will shoot through - and note them in AA(). Lines 619-910 then tell you what - if any - effect your shot has had.


Simon

Text; 1k
VDU; K
Integer

The Simon of legend said "Do what I do". In this musically accompanied game, ATOM says "Remember the sequence of letters I flash onto the screen, then press the same sequence of keys". If you do well, ATOM will gradually increase the number of letters displayed each time, but if you consistently fail to remember, then ATOM will give up in disgust.

Source code

Program Notes:

A small machine language routine (lines 120-140) is used to provide the musical accompaniment by generating a short note of a pitch determined by the value put into the RAM location 80.

The main body of the program is the loop through lines 200 to 390, an inner loop (lines 220-250) chooses and displays the sequence of N letters, saving them as the string $S. If the player answers incorrectly, lines 320-330 show him what he should have entered.


Screens

Text; 2K
VDU; 2-6K
Integer

This program is useful as a lecture aid, as an advertising gimmick, or as an auto-banner for Computer Lib demonstrations, as it allows you to create a number of text 'screens' in RAM, to edit them as required, and to play them through at any rate. It will also save the screens to a tape file, and subsequently load them back into RAM.

The number of screens that can be used is limited by the amount of VDU RAM available; the minimum useable amount of 2K bytes gives 3 screens - while an ATOM fitted with the full 6K bytes of VDU RAM can handle 11 screens.

When the program is first run the screens are cleared, then a 'menu' is presented. You may then enter;

Source code

Program Notes:

When the program is started it calls the subroutine at line 9000 which modifies ATOM's normal keyboard read and BRK routines so that pressing the ESC key does not stop the program, but makes it jump to line 8000 instead

The screens are stored in the VDU RAM space above 81FF, this area being otherwise unused when the VDU is in text mode. Lines 100-140 fill this area with the VDU 'space' code and also count the number (S) of 512 byte blocks available for use as screens.

Lines 200-295 present the menu - and refuse to accept anything except a valid response from the user. If a screen number is entered the program jumps to line 1000 with T equal to the number of the selected screen. This screen is then copied into the visible area of the VDU RAM space (8000 - 81FF) by lines 1000, 1010 and the cursor positioned at the top left corner by line

1020. Line 1030 allows you to type onto the screen by repeatedly calling the (now modified) Operating System OSECHO routine.

Lines 2000-2150 are executed if you have chosen to Play through the screens; line 2120 being used to bring the appropriate screen into the viewing area.

Lines 3000-3060 save selected screens as a file on tape by using the Operating System OSSAVE routine - after getting the new file's name and setting up the appropriate data for the OSSAVE routine (lines 3020-3050). Lines 4000-4020 similarly use the OSLOAD routine to load a tape rile of screens into RAM.

Lines 6000-6020 are a subroutine which is used to convert an input string $Z to a number Z; if $Z cannot be interpreted as a number then the subroutine returns T as 0.

When the ESC key is pressed the program jumps to lines 8000-8030 which remove the cursor (line 8000), then if the program had been in Edit mode, the screen is saved in the appropriate area of RAM before branching back to line 200 to display the menu.


Hangman

Text; 2K
VDU; K
Integer

This is a computerised version of the word guessing game; Hangman. The computer picks a word, shows you how many letters it has, and then you try to guess the letters one at a time. If the letter you choose is in the word, the computer shows you where, but it you are wrong then the computer starts to hang you. For each mistake, the computer fills in part of a drawing of you dangling from a gallows. The ninth mistake is fatal.

Source code

Program Notes:

The list of words used is stored in lines 50-52, and may be changed as long as each word is preceded by a *, and N (line 10) is made equal to the number of words in the list.

When the program is run, lines 100-120 look through the text area for the * immediately following the label a. Lines 130-160 then search for the start of a randomly chosen word, and lines 170-190 copy it as a string into the byte vector W. Lines 200-220 put a line of dots onto the screen, corresponding to the number of letters in the word, and draw the stage of the gallows.

The body of the program is the loop through lines 300-440, which gets the letter you have chosen, then sees if it is in the word (lines 400-420). If it isn't, then lines 430,440 draw the next stage of your execution and - if you are still alive - go back to line 300 for your next guess. After the ninth mistake, lines 500-530 declare you dead. Note line 300, which sets the text cursor position to the start of the 14th line and turns the cursor off.

If you have guessed a letter correctly, lines 600-630 display it and see if you have completed the word. If so, your reprieve is granted via lines 700-770, if not then back to line 300.

Lines 1000-1940 are a series of subroutines used to draw various parts.