Home

Airwolf

Back in 1987, most of my friends had either a Sinclari ZX Spectrum, or a clone. And as they had many more games that I did, I used to visit them and play their games.
One of those games was "Airwolf", and after playing it a few times, I tried my best to write a BASIC version.
I remember not being able to give it a decent last level, because I was running out ot memory, but also, being mostly happy with the outcome.
Looking at it almost 35 years later, I decided that it needed a "remix".
By making the helicopter graphic a bit smaller, rearranging, compacting, and optimizing the code, I was able to speed it up considerably and save about 2 KB of RAM. I took advantage of that to animate the wolf's graphic and add laser beams to the fortress' defenses. The game is still 50% faster than the original.
One of the tricks I used to save memory, was take advantage that the graphic mode I use, basically maps a 128x192 resolution to a 256x192 screen. This means that if you set a pixel to one color, the next one is also set, therefore, you can define a 30 pixel wide graphic by giving data for just 15 pixels, saving plenty of space.

You can download a .DSK file with the original and Remixed version of this and other games.
Or, if you have a Dragon, here is a .CAS file for you.
* iF YOU USE A COCO 3, REPLACE POKE 65495,0 WITH POKE 65497,0 IN LINE 0 *

Source Code

Here is the source, and below are some explanations on how it works.

Program Structure and routines

Lines 1 to 10: Get joysticks and keyboard input, update coordinates and check for collision.
Lines 11 to 17: 1st level main loop.
Lines 20 to 31: 2nd level main loop.
Lines 40 to 49: 3rd level main loop.
Lines 50 to 55: Draw Airwolf, going left and going right.
Lines 60 to 63: Airwolf is destroyed.
Lines 70 to 78: Airwolf fires to the left and to the right.
Lines 80 to 82: Game over, play again?
Lines 100 to 130: Intro. Variable initialization. Graphics loaded.
Lines 150 to 152: Set 1st level
Lines 153 to 157: Set 2nd level
Lines 158 to 160: Set 3rd level
Line 180: You win! Go again.
Lines 190 to 191: Graphics data.

Variables

A: joystick horizontal
B: Joystick vertical
C: Color while creating graphics
D:Shoot direction
D,D1:Airwolf going right graphics
DH: Shoot horizontal position
E1, E2: Explosion graphics
F: Which frame of the Airwolf animation to "put"
H: Loop horizontal coordinate while creating graphics
H: Airwolf horizontal position
HS: High Score
I, I1: Airwolf going left graphics
K(n): Horizontal position of missiles
KF(n): Target horizontal coordinate of missiles
L, L1, L2, L3, L4: Laser beam cycles
LI: Lives left
M: Loop missiles in screen 3
NP: Current level / screen
P: Shoot has hit something and exploded.
PP,P1, P2, P3: Flag control box status
Q: Turbo fuel left (0 is a full tank)
SC: Score
T: Airwolf horizontal speed (Controls Turbo)
V: Loop vertical coordinate while creating graphics
V: Airwolf vertical position
X: loops horizontal coordinates
Y(n): Vertical position of missiles
YF(n): Target vertical coordinate of missiles
B$: First part of the theme music
C$: Second part of the theme music
F$: String for explosion sound
R$: Reply string to "Play again?"

Other stuff

Most numbers over 10 are in hexadecimal format. This speeds up calculation and performance in general. I found that this does not make much difference in single digit numbers, so I kept those in decimal format.
The CoCo 3 handles the keyboard rollover tables in a different way than the CoCo 1/2 do, so I had to change the way that the detection of the "T" keypress works. (PEEK &H156)
Blue walls can be destroyed by shooting at them, but each hit actually decreases your score.
When a control box is destroyed, some lasers and force fields are disabled, but other lasers are turned on. This keeps the number of active items in a screen low, and helps keep a reasonable speed.
All the text in the original game is in Spanish - my native language - and I decided to leave it that way in the "remix".
The game runs considerably slower in XRoar than it does in other emulators and in real hardware (12 timer cycles for each frame, compared to 10)
Only what is drawn in graphics page 5 (PMODE x,5) is permanent, as the content of page 1 is replaced with page 5 using PCOPY in each cycle.
And here are the download links again, for your CoCo and for your Dragon.