Centipedeis a "fixed shooter" game, developed for video arcades in the 1980s. It was oneof the top-selling games of the era, and one of the first to have a significantfemale player base.
Four revisions of the official Centipede ROMs were released. The finalrevision caused some controversy among game emulator enthusiasts, becauseit replaced support for two-player games with a countdown timer. Most ofthe code was untouched, so the disassembly here is for revision 4.
Centipede is copyright 1980 Atari, Inc.
Related resources:
The controls are simple. The game is designed to work with either atrackball or a digital joystick. The player positions a gun in the lowerpart of the play area, and fires one shot at a time with the fire button.
The easiest way to play is via emulation on a computer. Once youhave the Centipede ROM file, save it in the MAME "roms" folder".When you start the MAME UI front-end, it will find the game automatically.Select it from the list and hit Enter. When the system summary displays,hit Enter again. (If this doesn't work for you, please visit one of themany MAME help sites.)
While the game is running, you can get a list of keys by hitting Tab,selecting "Input (this Machine)" with the arrow keys, and hitting Enter.The most important are:
HitTab to open a menu with a "DIP Switches"sub-menu that will let you set the machine for free play so you can stopinserting virtual quarters.
If you don't want to move the crosshairs with the arrow keys, you'llwant to configure MAME to use a mouse or game controller. From the mainMAME menu, select Configure Options, then Device Mapping, then adjustthe Trackball Device Assignment. If you select "mouse", you can use themouse to move the pointer and the button to fire.Note that selecting the mouse as the controller will cause MAME to grabthe mouse cursor, which is fine while playing full-screen but inconvenientwhile trying to use the debugger.
I used MAME v0.236 for my testing.
The basic idea is to shoot everything that moves without running intoanything, as colliding with any moving object will kill the player. Theplayer starts with 2-5 lives (determined by the DIP switch configuration),and will be awarded bonus lives as their score increases. The player canhave at most 6 lives.
Points are awarded for shooting enemies:
Target | Points |
---|---|
Mushroom | 1 (4th hit) |
Centipede head | 100 |
Centipede body | 10 |
Spider | 300 / 600 / 900 |
Flea | 200 (2nd hit) |
Scorpion | 1000 |
Additionally, partially-destroyed mushrooms count for 5 pointswhen the screen is resetting after the player dies.
A field of mushrooms is randomly planted at the start of the game.Mushrooms are destroyed when shot multiple times by the player or touchedby the spider, are created by fleas, and appear when a centipede segmentis destroyed.
The initial field has up to 46 mushrooms. The code walks through rows27 to 2, where row 31 holds the scores at the top and row 0 is below theplayer, and adds a new mushroom in a random column. When it reaches thebottom, it returns to the top. This means that most rows after the bottomfive will have two mushrooms, though if both mushrooms in a row happenedto land in the same column it will only have one. (See $28e4.)
There are 12 centipede segments. Initially the centipedeis created as a single entity, but with each new wave the maincentipede becomes shorter. The unaffiliated segments are created assingle-segment heads with random position and direction.
At the start of a wave, the main centipede moves at 1 pixel/frame,until 40K points when the initial speed increases to 2 pixels/frame.Independent heads always start at 2 pixels/frame.
When the centipede reaches the bottom of the screen, new headswill start to replace any destroyed segments. The pace at whichthey appear increases every 10K points. Initially the delay is192 frames (~3.2 sec), but reduces by 8 every time a head iscreated, to a minimum of 96 (~1.6 sec). It's further reduced by2 frames every 10K points.
The first spider appears 96 frames (~1.6sec) after a wave starts.After being killed, the cooldown is set to 128 frames (~2.1 sec).Spiders move at 1 pixel/frame until the score reaches 5,000 points,when the speed increases to 2 pixels/frame. In hard mode, thescore threshold is lowered to 1,000 points.
Spiders move in a random direction for 48 frames (~3/4 sec), then havea 50% chance of changing direction. In hard mode, the chance of changingdirection is 75%, making the movement more erratic. The only exceptionis if a spider reaches the limits of vertical movement, in which case itreverses direction immediately. The upper bound for a spider starts at 96(12 rows up), but steadily contracts as the player's score increases from60K to 180K points, eventually being reduced to 56 (7 rows).
Killing a spider earns the player 300, 600, or 900 points. Thevalue is determined by the vertical distance between the player's gunand the spider at the time of the collision.
If a spider collides with a mushroom, the mushroom is destroyed.
Fleas are the main source of new mushrooms. They don't spawn in waveswhere the centipede is 12 segments long, such as the first, and don'tappear if there are enough mushrooms in the lower part of the screen(rows 1-11).
If the player's score is under 20K, a flea appears when there arefive or fewer mushrooms near the bottom. At 120K points, the thresholdincreases to 9 or fewer. After that, it's 6 + (score / 20000), i.e. 12or fewer at 120K points.
The flea moves at 2 pixels/frame, until the player reaches 60K points,when it speeds up to 3 pixels/frame. The first time the player shoots theflea, the speed increases to 4 pixels/frame. A second hit will destroythe flea.
As the flea moves down the screen, it has a 25% chance of creatinga mushroom under it. This is tested every 4 frames, so when moving at2 pixels/frame this is a 25% chance per tile. At faster speeds, fewermushrooms will be created on average.
The flea has 4 animation frames defined for it, but only uses two.This appears to be a coding mistake.
Scorpions move horizontally across the upper part of the screen. Anymushroom they touch becomes poisoned, changing appearance. If a centipedetouches a poisoned mushroom, it goes crazy and charges straight down thescreen. When it reaches the bottom, the madness ends.
Scorpions use the same object slot as fleas, so the two will never beon screen at the same time. They move at 1 pixel/frame, until theplayer reaches 20K points, when it gains a 75% chance of moving at2 pixels/frame instead. The movement direction is chosen at random.
In the original sources, fleas are called "ants", and spiders arecalled "bugs".
The game uses a 30x32 grid of 8x8 tiles. Moving objects are 16x8,two tiles wide.If the game is being played on a cocktail cabinet, the display needs tobe rotated 180 degrees when player 2 is active. This is done entirely insoftware, by flipping the various graphics and rearranging their positions.For more details, see thegraphics page.
The POKEY provides four sound channels. Assignments:
The hardware provides a 64-byte Electrically Alterable Read Only Memory(EAROM). This type of storage is slow to write and requires that thesoftware obey various timing requirements. For Centipede, it's used tohold the top 3 high scores, the total time spent playing games, and thetotal number of games played. This allows an average game time value tobe shown in the self-test screen.
The revision 4 ROM replaced support for two-player games with a hardtimer. The three DIP switches that configured the coin slot multipliersettings were repurposed to specify a timer value, 0-7 minutes (where zeromeans no time limit). The timer is displayed where player 2's score wouldgo (and is actually stored in player 2's score variables), and supportfor player 2 was removed in a few places. Most of the code was unchanged,however, so you can still see most of the screen-flipping code in rev4.
The self-test feature has color bars and an alignment grid that aren'tmentioned in the service manual.
The word "centipede" doesn't appear in the ROM, and there is no graphicimage for it. There is no title screen; the game just puts up the highscore list and lets "attract" mode run. Without the cabinet artwork,you wouldn't know what the game was called.
The copyright date displayed by the game is 1980, but the internaldocumentation is dated May 1981, and the game wasn't shipped until late1981. The copyright notice is "booby trapped", with various strangethings happening if the notice or the code that copies it to the screenis altered, so it's possible the programmers just didn't think it wasworth the trouble to update the notice from "1980" to "1981" (it makes nodifference legally).
MAME v0.236 oddities:
Copyright 2022 byAndy McFadden