FLOYD THE DROID ON THE RUN

A SPECIAL INCLUSION

Our 8-bit gladiator makes his move to the ST, with plenty of action.

Programmed by
Paul Lay

Graphics by
Harvey A. Kong Tin

Download Game (48K), PaCifST emulator format

We're proud to present this, the first-prize effort in our ST Programming Contest. Readers of ANALOG Computing have met Floyd before, in issue 53, where he bravely battled mutants on the Atari B-bit computers. Next month, we'll bring ST-Log readers the high-resolution image of Floyd... on the Run.

Readers will find the Listings for Floyd the Droid on the Run on the magazine's disk version, since the program was far too long to print in these pages. Our Atari Users' Group on Delphi will also carry the complete program.

You control the latest in robot technology, a cute little droid called Floyd. You're surrounded by hordes of evil beings which are out for Floyd's blood (sorry, oil). They shoot past you from side to side in all directions, and, if you collide with them, theye xplode, zapping your strength down. Luckily, you're a highly maneuverable droid. Armed with the latest in photon weaponry, you can simultaneously fire four photons in any direction. Also flying around are Atari logos which, if collected, will increase your strength. In all, one hell of a blast!

Floyd the Droid on the Run represents my first project of any real significance on the ST. It has taken almost two months to complete, from start to finish, and it's been great fun exploring a whole new machine.

Thanks must be expressed to all those programmers whose programs and utilities were used in the creation of Floyd. Very special thanks go to Harvey A. Kong Tin, who did most of the graphics design work (incredible, really, as he only borrowed an ST for a couple of weekends).

The source code was written with Metacomco's Macro Assembler. All screens are held in straight DEGAS format, which made their editing simple.

Note that there's a significant difference between the low- and high-resolution programs, particularly the graphics data and the high-score screen material.

Using the program.

Floyd can be loaded by clicking on the DROIDLO.PRG icon. On loading, an ANALOG logo screen will fade in, followed by the title screen. The program will then be loaded and executed within a few seconds.

The keyboard controls are used for various levels and functions of the game. Keys Fl through F6 will begin the game, at levels 1, 10, 20, 30, 40 or 50. Hitting C lets you continue from the previous level. Press D if you want to see a crazy demo. The V key toggles volume on or off, while P dumps the screen to your printer. To abort a game, press ESCAPE, and use the SPACE BAR to pause or resume the game.

A joystick in the second port is used to control the droid. Moving the joystick in any direction moves Floyd in that direction. Pressing the trigger fires a photon in the direction of the joystick. Four photons can be fired at once.

If your score is high enough, you'll be able to enter your name in the high-score table. All alphanumeric characters are available, plus the SPACE and BACKSPACE. To terminate the entry of a name, press RETURN.

Game play.

You begin each game with a strength level of 75 percent, which is reduced by 4 percent every time you collide with a creature and increased by 6 percent every time you collect an Atari logo.

Your strength level cannot exceed 100 percent, and the game ends when it falls below 0 percent. For every creature that you kill, you score 10 points - but you don't score anything for killing Atari logos. You advance onto the next wave once all the creatures in the current wave have been killed. Once you reach wave 40, all the creatures start moving at double speed.

A line at the bottom of the display during the game shows the current status of your strength, the wave which you're on and your score (or demo indicator).

Notes.

It would take far too long to explain in detail what features of the ST the program uses. Basically, everything is used, apart from the GEM graphics library routines for which there was no real need in this type of program. I will, however, try to outline some important aspects of the program.

Floyd runs entirely in the supervisor mode of the M68000, which allows the interrupt vectors and the hardware addresses at the top and bottom of memory to be accessed directly. The GEMDOS, BIOS and XBIOS routines were very useful, providing easy access in machine language to quite complex operations (such as file handling; and so on). I didn't use any of the Line-A graphics operations; I found it better to code the drawing routines and, so on exactly, as I needed them.

A lot of work had to be done in writing a keyboard interrupt routine to allow the use of the joystick. .As far as I can make out, there isn't any support for a joystick in the operating system (in other words, you have to write your own interrupt routine). Note that I used a really simple vertical blank interrupt (used only for synchronization to the display), so, once the program's running, there's no checking for a new monitor. Also, the disk drive "busy" light. remains on.

One interesting point concerning the hardware: a couple of the chips are accessed via only two addresses. One is used for control, the other for data. Thus, a register within the chip is accessed by writing the required control code followed by writing (or reading) the data. This is quite different from the 8-bit machines, where all the register addresses are hardwired into memory.

All the creatures, in both resolutions, are drawn on a 32-by-32 grid, using two colors in high resolution and sixteen in low. I used my own text routines, because I wanted them to be as fast as possible during the game. The high- resolution font is based on a 16-by-16 grid, and the low- resolution font is based on an 8-by-8 grid, using the 8-bit character set. The star-scrolling in the background uses a simple algorithm, made possible by the fact that the screen is redrawn every vertical blank period. Also, as collision checking is done by comparing positions, it isn't necessary to worry about overwriting things on the screen.

The pause display feature, although quite simple, does show that fine scrolling is possible on the ST. Basically, by using auto-increment and longword addressing, memory can be moved at a very fast rate. The screen dump was easy to implement, because the routine is provided as an X BIOS routine. Note, however, if no printer is connected, the time out period is drastically decreased. This was done by increasing the rate of the 200Hz system clock.

The demonstration uses completely random movements, with constant firing. The result is impressive and, surprisingly, gets through quite a few levels. The sound is white noise for the missiles, normal control for the creatures' movements and an envelope for their explosions. I found the sound chip difficult to use, probably because I haven't got any good documentation on it.

I could go on and on, but I think I've covered all the major points. It's been great getting to know a new machine, like starting with an 8-bit all over again. At first, programming the ST in machine language looked like it was going to be a nightmare, with hundreds of different routines available, hundreds of different interrupts, the complicated GEM operating system, and so on.

My first task, then, was to get into the ST and turn everything off so that I had a simple machine to work with, and full control. Then I was able to start using various interrupts and operating system routines as I needed them. I strongly advise this route to anyone wanting to program the ST in machine code. The M68000 processor really sets the ST apart, not just because of its incredible speed, but also because of its fantastic architecture (addressing modes and instruction set).

The only reference I've used in writing this program is The Anatomy of the Atari ST by First Publishing. It contains almost everything you'll need to know about the ST, other than the GEM graphics library routines. The only drawbacks are that the English is pretty bad (it was written by Germans), and the explanations aren't always clear. I used the Metacomco Macro Assembler to write the program, but can't really recommend it for anyone who wants to do serious machine language programming on the ST. I bought it because it was available at the time, and I'll be upgrading to a different assembler for my next project. Harvey used DEGAS for all the graphics designs. I'll let them speak for themselves.

In summary, I'm really pleased with Floyd the Droid on the Run. I did not convert the program over from the 8-bit version (in fact, it wouldn't have been possible, because of special features of the 8-bits), but rewrote the entire program, based around the same algorithm and design principles. I've been pretty dedicated to the 8-bits over the years, but the ST has, for me, aroused new excitement and a new challenge!

Paul Lay studied Computing Science at Imperial College in London. He's owned his Atari 800 for about four years, and has had several programs published in various English magazines (personal Computer World, Page 6 Magazine and Atari User). He has also written an arcade game, Sprong, released by Bignose Software in the U.K.