Grab An Apple

Jamie Athas and Garry Francis, New South Wales, Australia


Issue 4

Jul/Aug 83

Next Article >>

<< Prev Article


This game is designed in ANTIC mode 4, a character mode which allows up to four colours to be displayed within the same character. Each character is set up in a 4 x 8 grid giving a total screen resolution of 160 across by 192 down. To use ANTIC mode 4 it is basically a matter of changing a Graphics 0 display list, then redefining the character set. You are welcome to experiment with the techniques we have used. The game was originally in Graphics 5 but ANTIC 4 increases its visual impact tenfold.

How to play

This is a game where you control a giant lengthening caterpillar, and have to eat the apple. The quicker you eat the apple, the more points you get, but if you take too long, it will disappear to a new location and you will lose five points. If you run over yourself or hit the wall, you lose a life. You have three lives per game. Every time you eat an apple, the caterpillar is 'cut up' and your speed increases by 1 k/mh.

Program notes

The concept behind this game is a familiar one, but don't let that fool you. This game is totally original.

When the program begins, a title page is scrolled up the screen. This is for visual impact only and serves no useful purpose, however anyone wishing to examine the code will find it quite interesting. Firstly let me assure you that it is NOT genuine scrolling, but display list manipulation. It works by writing your own display list (lines 1010 to 1030) consisting of a screenful of blank mode lines and a few GRAPHICS 2 lines which begin at the bottom of the screen. (This is cheating the system and I suggest that you avoid such things unless you know what you are doing.) The number of blank mode lines is gradually reduced using the simple FOR-NEXT loop in line 1060, so that the GRAPHICS 2 lines slowly creep up the screen. The technique is crude, but it works. You'll notice a certain degree of jerkiness, as the movements are not synchronised with the vertical blank. You can experiment with the speed by changing the delay (i.e. FOR W= 1 TO 15: NEXT W) in line 1060.

When the scrolling is finished, the character set is copied from ROM to RAM (line 1070) using the machine language routine out of Stan Ockers Doggies, then seven of the special characters are redefined (line 1100). I was going to draw up some pretty pictures to show how this is done in ANTIC mode 4 but unfortunately I ran out of time.

The screen is then cleared and another custom display list is created (line 1160), this time for a screenful of ANTIC mode 4 with 3 lines of Graphics 0 at the bottom for scoring information. If you want an entire screen of ANTIC mode 4 in your own programs, then change the loop to read FOR I=DL+6 TO DL+28. This completes the initialisation.

If you care to draw a flowchart of the main program (lines 20 to 370) you'll notice that it follows a very efficient and logical flow. Beginners should take particular note of this. It is something that you should always strive for to achieve peak efficiency without losing readability. This is something I can never stress too much. Too many programs are written with a spaghetti - like structure! As a result, they run slow and use up about twice the memory necessary. In Grab an Apple, the effort has paid off. Speed is no longer a problem despite the delays for sounds. In fact, I had to insert a lengthy delay loop (line 240) to slow the game down. The game becomes more difficult as it progresses by reducing the length of this loop every time you eat an apple. You'll also notice a certain 'beat' to the program, which starts the adrenalin flowing as the pace increases. (This was the secret to Space Invaders success.) You have to eat 50 apples in one game to reach the fastest speed. I certainly can't do it! If you want to see the game at maximum speed, change the loop to read FOR I=1 TO 1:NEXT I.

Anyway, I hope you enjoy playing Grab an Apple as much as Jamie and I did writing it. 

This article and program originally appeared in INSIDE INFO, the newsletter of Atari Computer Enthusiasts (N.S.W.) - Australia.

AtariLister - requires Java