40K Disk (requires Minicomp)
by David Bohlke
Androton is a game that has been designed to be used with Minicomp, a BASIC compiler also written by David Bohlke, which appeared in issue 23. If you do not have issue 23 of ANALOG Computing, it is available as a back issue (see page 95). - Ed.
One of the comments I hear most often is, "How can you write an arcade-style game using only the eleven statements the Minicomp program can compile?" When you consider all the enhanced commands of BASIC that make programming easy for us, then this is a legitimate concern.
But what makes BASIC run? It is the machine language interpreter, and - as I understand it - machine language as four major groups of commands. You can move and store data between memory locations; you can add and compare memory locations; you can branch to different segments of your program, and you can have direct processor control.
Even though Minicomp has just eleven commands, it (like BASIC) has the ability to perform most of the functions of machine language, with the exception of direct processor control. With Minicomp you can move and store data using PEEK and POKE; you can add and compare using A=B+C and IF...THENl and you can branch to different parts of the program with GOTO and GOSUB.
Considering these general capabilities, it shouldn't be too surprising that it is possible to write longer games using the compiler. Androton is presented in this article as an example of an arcade-style game written with the Minicomp statement set.
Androton.
Androton features a graphics I screen, a redefined character set, a full screen random maze each time you clear the board, color, sound, high score, game timer, bonus score and one- or two-player option. All these functions make the program listing fairly long, and the Minicomp compiler (written in BASIC) will require about twenty-five minutes to compile this program.
Fortunately, if you save the object code to disk or tape, you'll only need to compile it once. But the compile time raises an interesting conjecture: can you compile the compiler? In other words, is it possible to rewrite the Minicomp listing using only line numbers 1-999 and the eleven Minicomp statements? If so, compile time should be about 100 times faster. Would this mean that Minicomp's eleven -statement set is quite powerful-if it can, in fact, compile itself? Seems like a good topic for a future article...
I believe you'll really enjoy this game. It is one of my favorites- mostly, I think, because it is possible to achieve very high scores. Another plus in this Pac-Manlike action is the option that allows two players to participate at the same time, in a co-op fashion.
To begin the compile process, power up your system and RUN the INIT96 program to adjust LOMEM, then type in the program listing. Be sure to LIST the program to disk or tape before you proceed. If you want to RUN the BASIC listing of the game at this time, you'll need to be patient, as the code runs extremely slowly. When you are ready to compile the program, ENTER the Minicomp compile from disk or tape. You'll notice that the Androton listing has some line numbers beyond 999. Specifically, the coding at Line 9500 will put the new character set into low memory. This will be explained further later on, but, for now, type GOTO 9500 then RETURN to move the character set.
Next, type GOTO 1000 and RETURN to initiate the compile process. When the program has been compiled, a RETURN prompt will be displayed on the upper right of the screen. Make a note of the end of the object code buffer (around 22000). Now you can execute the game by pressing RETURN.
Before you begin play, and at the end of each game, the program will be in the attract mode. At this time, you can press the SELECT key for the one- or twoplayer option (joystick slot 1, slot 2). Also, the speed of the deadly blue droids will be printed in the center of the maze. This speed difficulty level can be altered from the fastest setting of 1 to the slower setting of 5 by pressing the OPTION key. To the maze's left, the maze number (M) and lives remaining (L) will be displayed. The bottom screen line will show the current score, high score and the time remaining (T) for you to clear the maze. Once you press START, play will begin.
Push the stick in the four cardinal directions to move your green man through the maze, trying to pick up the pulsing blue proton bars. For each red trip sensor you cross, an additional blue droid will be released to hunt you down. If any droid touches you, or if the timer runs to zero before you can collect all the bars, you'll lose one life. Once you collect all the bars in the maze, a new random maze will be constructed, and your adventure begins again.
For each proton bar you pick up, your score will be incremented by the maze number in which you currently find yourself. Each 10,000 points, you will be rewarded with an extra life (the maximum is nine). Finally, whenever you clear the maze by collecting all the proton bars, you will receive a bonus score equal to the maze number times ten for each tick left on the timer.
I have included a line listing description for Androton and also a description for the major variables used. You can use these two charts to investigate how some of the games routines are set up.
Of special note is the code at 9500 to initiate a new character set. Line 9502 will move the character set in ROM to memory location 11776 (page 46). This area of memory is above DOS I, yet below the object code buffer (12288). Line 9510 will read and place several new characters into the character set. The routine at 9500 will not be compiled, but after the character set is moved to page 46 (by typing GOTO 9500), it can be saved to disk or tape, along with the object code buffer (after you compile Androton) by using 11776 as the beginning address for the save.
This save ability makes page 46 an extremely useful location to store character sets, messages, large amounts of data or special screen images, all of which can be easily accessed by the compiled code.
Another program listing section of general interest is that in Lines 50-59. This code will develop a graphics 1 display list located at decimal 1536, plus move the display memory to decimal 24064 (page 94). We must create our own display list, because Minicomp cannot compile the GRAPHICS command from BASIC. I like to use graphics 1, because you can utilize five colors (plus P/M colors) in this mode, and it requires less than 500 bytes for display memory.
Several routines from last months program were expanded for Androton. The game uses three timers: one controls the speed of the blue droids; another keeps track of the countdown game timer; and the third slows down the movement of your players.
A data table is also used to store the location and direction of each droid. In additional to the regular running score, a high score is displayed on the lower right screen line. Also, in Androton, we have to read two STICK positions for the two-player option. The locations of all these routines are identified in the line summary chart (Figure 1).
Sound is generated through the use of memory locations 53760 and 53761. The command SOUND 0,A,B,C can be duplicated by using POKE 53760,A: POKE 5 3 761,B * 16 + C. In a similar manner, locations 53762 and 53763 can be used to set up sound channel 1 (SOUND 1,A,B,C). You'll have to adjust your sound routines, though-to the extremely fast speed of machine language.
We have covered a lot of material this month, and I'm sure there are a lot of questions left unanswered. The routine starting at Line 800, for example, constructs the entire random maze with a fairly simple algorithm-but it would take several pages to explain completely. For now, I would prefer to use my print space to introduce you to several different games in the coming months. Then, when I get some feedback from you, perhaps I can concentrate on more specific routines utilizing Minicomp.
DS | Display memory start |
CS | Location of character set |
T1 | Game cycle timer |
T2 | Player timer |
T3 | Droid timer |
AT | Droid table |
A1 | Index to droid table |
MP | Man POKE number |
AP | Droid POKE number |
NB | Number of proton bars in maze |
IV | Number of lives |
TI | Countdown time remaining |
MZ | Maze cycle number |
SP | Speed of droids |
NA | Number of active droids |
SC | Current score |
P1 | Player I location |
P2 | Player 2 location |
NP | Number of players |
ST | Stick being read |
EG | End of game flag |
NL | New life counter |
Figure 2.
Line | Function |
10 | Initialization |
50-59 | GR.1 display list |
60 | Colors |
90-92 | Color, zero score line |
95 | Initial variables |
100-198 | New game routine |
110-115 | Check option keys |
130-132 | One or two players |
140-142 | Speed option |
180-198 | Check if new high score |
200-290 | New maze routine |
200-205 | Set up droid table/directions |
260-265 | Set proton bars in maze |
282-285 | Set trip wires in maze |
290 | Print routines |
300-399 | Logic to move droids |
400-490 | Move players |
450 | Player captured proton bar |
460 | Player hit droid (lose life) |
470 | Player hit trip wire |
500-506 | Check if maze is cleared of proton bars |
510-530 | New maze, bonus score for time remaining |
570-572 | Lose life |
615-622 | Exchange droid character for animation |
670-672 | New life each 10000 points |
680-685 | Game timer, speed for one or two players |
700-704 | Print title |
710-712 | Digits in time display |
720 | Print lives |
730 | Print maze number |
740 | Print time numbers |
750 | Zero sound |
800-897 | Compute and plot random maze |
900-904 | Multiply routine |
910-914 | Divide routine |
950-959 | Increment score |
9500-9534 | New character set (not compiled) |
Figure 1.