Spotlight › Gorillas

Gorillas, without the BASIC

Two gorillas stand on the rooftops of a city and take turns throwing exploding bananas at each other. This is the game that came with QBasic, rewritten in 8086 assembly: play a friend at the same keyboard or the computer, in a window or full screen.

players
1 or 2
on the disk
14,261 bytes
graphics cards
VGA, CGA, Hercules

Full screen on VGA uses the original game's colours. On CGA full screen is four colours, and Hercules is black and white.

Full screen, VGA
Gorillas filling the screen on a dark blue sky. At the top: Kong, Score 000 - 000, Angle 45, Velocity 70 and Wind +004. A yellow smiling sun hangs over a skyline of teal, grey and red buildings with lit windows, an orange gorilla stands on a roof at each end, and a small red arrow under the city points right.
Kong's turn, full screen on VGA. The angle and speed are the last ones used. The arrow under the city is the wind.

What it is

A game from 1991 that came with its own source code.

In 1991 MS-DOS 5 came with QBasic, a simple programming language, and a few example programs written in it. One of them was GORILLA.BAS. Two gorillas stand on the roofs of a random city skyline. Each turn a player types an angle and a speed, and a banana flies off under gravity and the wind. Hit the other gorilla and you score; miss and the banana blows a hole in a building. Because it was a program you could open and read, you could change its gravity or the size of its explosions and run it again to see what happened.

This version is a new program in 8086 assembly that follows the original's rules. The city is different every time. The wind blows at up to 15 either way, and an arrow under the city shows which way and how hard. Craters stay where the bananas made them. The sun looks shocked when a banana goes past it. The scorer does a victory dance to the original's tunes.

It adds a few things. You can play against the computer; the original needed two people. You choose the winning score, from 1 to 99, and the gravity, from 0.001 to 9999.999. Each player's last angle and speed are kept, so a near miss can be corrected by one number. It runs in a window beside other programs, or full screen.

Type a number and press Enter to move from the angle to the speed; Enter again throws. Tab switches between the two, and the arrow keys change them by one. P pauses, F switches to full screen and back, and N starts a new match.

See it running

From the title screen to the final score.

Title screen
The Gorillas window on the os8088 desktop, blue with a border of small red sparkles. It reads G O R I L L A S, After Microsoft QBasic 1990, and five lines of instructions ending Press any key for setup, with two orange gorillas between them.
The title screen. The border sparkles and the two gorillas take turns raising an arm while the opening tune plays.
Setup
The Gorillas window showing GAME SETUP. It asks Name of Player 1 (10 characters), says Default: Player 1, and has Kong typed in. The bottom line reads Backspace: edit, Enter: next.
Setting up a match. Five questions: one player or two, the names, the winning score and the gravity. Enter alone takes the default.
Starring
The Gorillas window reading G O R I L L A S, STARRING, Kong AND Computer, with two orange gorillas and the line Press any key to play, inside the sparkle border.
The introduction. As in the original, the two players are billed before the first throw.
In a window
The Gorillas window on the desktop with a match in progress: Kong, Score 000 - 000, Angle 45, Velocity 70 and Wind -004 at the top, the sun, a skyline of red, grey and teal buildings with a gorilla on each side, and a red arrow under the city pointing left.
In a window. The same game beside the other programs. In a window the orange is made from red and yellow dots, so the rest of the desktop keeps its own colours.
In flight
Gorillas full screen with a small yellow banana in the sky just left of the sun, above the skyline and both gorillas. The text at the top has gone.
A banana in flight. The text at the top clears during a throw, so a high banana can fly through it.
A hit
Gorillas full screen, paused. The top reads Computer, Score 000 - 001, and Paused. P or Enter to resume. A large orange blast fills the spot on the left rooftop where Kong stood; the computer's gorilla stands on the right.
A hit, paused. Kong threw with a speed of 1, which in the original as here drops the banana on the thrower. The point goes to the other side.
Victory dance
Gorillas full screen after the hit. The top reads Computer, Score 000 - 001, and Point! Next skyline shortly. A bite has been taken out of the left rooftop, and the gorilla on the right has one arm raised.
The victory dance. The crater stays. After the dance a new city is drawn and the other player throws first.
Game over
The final scorecard full screen, inside a border of red sparkles: GAME OVER!, Kong 000, Computer 001, Computer wins!, and Press any key for setup.
Game over. A match played to one point. Any key goes back to setup.

How it works

A banana's arc, a city and a typed number, on a 4.77 MHz processor.

The throw

The original's arc, in whole numbers

QBasic worked out each position of the banana in floating point. The 8088 has no floating point, so this version keeps positions as whole numbers with a fixed number of fraction bits, and looks sines up in a table. The test that checks it compares every point against the original's formula and allows three quarters of a pixel.

A throw is drawn a small rectangle at a time: each step puts back what was under the banana and draws it in its new place, so the city is never redrawn during a flight. A hit is decided against the gorilla's actual pixels, not the box around it.

The city

A new skyline in about a second

Drawing a whole city is the slowest thing the game does. It is drawn in strips from left to right and never goes blank first. Measured on an emulated IBM PC with an 8088 at 4.77 MHz, counting the processor's own cycles:

Time to draw a new Gorillas city on a 4.77 MHz IBM PC
cardin a windowfull screen
VGA1.24 s1.45 s
CGA0.37 s0.33 s
Hercules0.47 s0.52 s

An earlier version of the game took 3.3 seconds in a VGA window and 5.9 full screen.

The keys

A typed digit shows at once

Typing an angle only redraws the number that changed. The first digit of a new angle used to take 881 milliseconds to appear in a VGA window on a 4.77 MHz PC; it now takes 5.6. Typing six keys ahead, an angle, Tab and a speed, finishes within one tick of the system clock, 55 milliseconds, on all three cards.

The music and the opponent

The original's tunes, and a new player

Every tune is built from the notes written in the original program, and plays on the PC speaker without stopping the game. A note lasts at least one tick of the clock, 1/18 of a second, so the shortest notes are a little longer than they were.

The computer always throws at 55 degrees. It tries every second speed from 1 to 360, one on each tick of the clock so the game never stops to think, keeps the one that lands closest to you, and then adds an error of up to 8 either way. It misses often enough to beat.

What it does not do

Where it differs from the original, and why.

  • It does not run the original program. There is no BASIC here; it is a new program that follows the same rules, so the physics and the timing are close to the original rather than identical.
  • Angles and speeds are whole numbers from 0 to 360. The original took fractions.
  • The sound is the PC speaker only. A sound card is not used.
  • The mouse is not used to play; the game is typed, as the original was.
  • On CGA a window is black and white, as every CGA window on this system is. Colour on CGA is full screen only.
  • Two players share one keyboard. There is no play over a network.

Run it

It is on the software disk, in the games folder.

  1. Boot os8088 with the software disk in the second drive.

  2. Double-click Disk B, and open the GAMES folder.

  3. Double-click GORILLAS.O88, and press any key for setup.

  4. Answer the five questions, or press Enter for each default, then P to play.

It is on every software disk, at every size, and on the live USB image and CD. On a 360KB XT it is on apps360.img, and at the top of games360.img. It is also in The Wire.