1987 · Activision

Rampage

This minisite was contributed by air. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/c64/rampage with me to Gold.

Three monsters punch a city flat while the army shoots at them. The game-over screen says "you must eat food to survive", and in this version eating does nothing at all.

01 · The game

Three monsters and a city to knock down

Rampage is the Commodore 64 version of Bally Midway's 1986 arcade game, converted by Catalyst Coders and published by Activision in Europe in 1987. The second loading picture credits M. Archer, D. Jolliff, M. Jones, and D. Wainwright.

The newspaper screen: a strip each for George, Lizzie and Ralph, each reading READY FOR ACTION
The newspaper screen before each level. A fire button joins the game.
The three monsters among the buildings of the first level
The first level, with all three monsters on screen.

Three people have been turned into monsters: George the gorilla, Lizzie the lizard, and Ralph the wolf. Up to three players take one each, two with joysticks and one on the keyboard, and the computer plays any monster nobody joined as. All three are always on the screen.

A level is one screen of buildings. A monster walks along the street, climbs a building's side, and punches the wall while it hangs there. Every punch that breaks something scores 100 points and weakens the building, and a building that has taken enough punches crumbles to the ground. When every building is down, the next level begins.

The army fights back. Soldiers lean out of the holes the monsters make and shoot, a helicopter fires as it dives, and a fall costs energy at every step. Each monster's energy is shown by the word DAMAGE under its score, which turns red a letter at a time. A monster with no energy left shrinks back into a human and walks off the screen.

02 · Music

Music: one tune plays on every text screen

There is no music during play. The tune belongs to the screens between levels.

The page runs the game's own music player on a copy of the C64's processor, the 6502, and plays what the code writes through the site's model of the sound chip. The player and its tunes are at $0200-$0575: a number after a $ is an address in the game's memory, written in hexadecimal, and links to that place on the Source code tab. A test compares every write with the same calls made on the game's whole memory, frame by frame, for 7,500 frames of the first button and to the end of the second. The first tune repeats after 6,912 frames, about two minutes and eighteen seconds. It sets a low-pass filter, which the player models on a 6581 chip; real chips differ from each other in how the filter sounds.

The music player is a routine that the text screens run once a frame, 50 times a second ($AD3B). The sound chip can play three notes at once, on three voices, and each voice reads its own list of bytes. A byte is a number from 0 to 255. Most of the list is pairs: a length, then a note. A length is a number from 1 to 12 that picks a duration from a table ($0233), and a note packs a pitch from 1 to 12 with an octave. Bytes of $80 and over are commands that repeat a passage or write straight to the chip.

The game asks for three different tunes: the first for the game-over screen, the second for the list of things to eat, and the third for the newspaper. Every one of those requests gets the first tune, and the player's second button plays what is left of the second. Discoveries has the reason.

03 · Sound

Sound: every effect is a single burst of noise

The game has five sound effects and starts three of them.

Each button calls the game's own $822F with the effect and the voice the game uses for it, on the site's 6502, and plays what it writes. The game writes to the chip once for each effect and never again, so the sound fades at the rate its envelope sets. The punch takes many seconds to fade, and in the game the next effect on the same voice cuts it off; a button here stops after three seconds. The same test as the music's compares every write with the game's code.

An effect is eight bytes in a table at $82EC: a pitch, a length, a waveform (noise or a tone), a filter setting, an envelope (how fast the sound rises and how fast it dies away), and a figure to slide the pitch by. Four of the five are noise and the last is a plain tone. Effect 3 makes no sound at all: it switches off all three of the filter's outputs, and the game sends every voice through the filter. Starting an effect writes the pitch, the waveform and the envelope to one voice of the chip and switches the filter on.

The length and the slide are never used. The routine that would count an effect down, slide its pitch and stop it exists at $82AC, and nothing calls it. Discoveries plays the effects with that routine running.

04 · One frame

One frame, rebuilt from memory

The page draws this picture from a recording of the video chip's registers and the memory they point at.

One frame of play, drawn again by this page. George and Lizzie stand on a roof, Ralph is in the street beside a tank, and one helicopter crosses the status lines.

The C64 can show eight sprites, movable pictures 24 pixels wide and 21 tall. This frame shows fourteen sprite-sized pieces. Each monster is 48 pixels wide and 48 tall, which is two sprites side by side and more than two sprites high, and on top of the three monsters come two helicopters in the status lines, two more among the buildings, and a vehicle in the street.

The game gets there by giving each sprite several jobs in one frame. The video chip draws the screen from the top down, 50 times a second, and the program can ask to be interrupted when the drawing reaches a chosen line. An interrupt makes the processor drop what it is doing, run a short routine, and go back. Sprites 0 and 1 are the helicopters in the status lines at the top of the screen, the two helicopters among the buildings from about a quarter of the way down, and the two halves of the street vehicle at the bottom. Sprites 2 to 7 are the three monsters, a pair for each, and every pair is moved down twice while the frame is drawn so that it covers the monster's whole height.

The interrupts that move the pairs are sorted afresh every frame. At the bottom of the picture a routine ($7B4A) works out the nine lines at which a pair must move, three for each monster, puts them in order from the top, and writes each line number into one of nine short interrupt routines ($7979 is the first). When two lines are within two of each other, the first routine jumps straight into the second, so one interrupt does both jobs. In this frame George and Lizzie are level, and three interrupts serve the two of them.

The background is characters, the C64's 8 by 8 pixel tiles. The three status lines use one character set and the city another, switched by a timer in the machine about 73 lines down the frame. Black is the background colour, so the dark skyline is empty space and the blue sky is a solid blue character.

05 · The monsters

A monster is 36 tiles copied into six sprites

The monsters are too big to store as sprites, so the game stores them as tiles and builds the sprites while it runs.

Left: the frame's 36 tile numbers, each drawn from the character's own set of 256 tiles. Right: the picture as the six sprites show it. The page runs the game's own $B3F6 and $B520 on the site's 6502 to build it. A test checks all 228 pictures against the tiles they are built from.

A frame of a monster is a list of 36 tile numbers, six rows of six. A tile is eight bytes, a strip 8 pixels wide and 8 tall, so the whole picture is 48 by 48. Each character has 38 frames facing left and 38 facing right, and a set of 256 tiles for each facing ($4000-$6FFF). Stored as finished sprites, the six tables of frames would need 65,664 bytes, more than the machine has. Stored as tile numbers and tiles, they take 20,496.

Whenever a monster has moved, a routine ($B3F6) copies its frame's 36 tiles into a working area of 288 bytes. Once a frame, the interrupt at the top of the screen copies one monster's working area into its six sprite shapes, a different monster each frame, so each monster's picture is refreshed every third frame. The copying routine has no loop. It is 288 instructions that read a byte and 336 that write one, written out one after another. There are three such routines, one for each monster, and together they take 5,619 bytes.

The picture is 48 lines tall and a sprite is 21, so each pair of sprites is shown three times down the monster's height. The interrupt that moves a pair down and gives it its next shapes cannot land on an exact line, and the game hides the join by storing the lines around it twice: the last four lines of each row are in the shape above the join and in the shape below it, at the same height. Whichever shape the chip is reading when it draws those lines, the picture is the same.

Every shape for every character is on the Graphics tab.

06 · The buildings

A building is a grid of blocks, and a punch rewrites one block

Click a wall or a window to punch it, as a monster hanging on the building would.

The page runs the game's own code on the site's 6502: the routines that set a level up, draw it, change a block for a punch ($A62F) and bring a building down ($B281). The monsters, the soldiers, and the things in the windows are left out. A building that has no strength left falls at the game's own speed of about 4.8 passes a second.

A building is stored as a small map of block numbers. A block is four characters, two by two ($3C10), and there are blocks for a wall, each half of a window, a roof edge, and a door. Six building shapes exist ($9A0D), between four and five blocks wide and from six to fourteen rows of characters tall. A level copies the shapes it uses into working maps at $7500, and the whole screen is drawn again from those maps on every pass of the game. A pass is one turn of the game's main loop, which works out everything that has happened and draws the screen again, about five times a second.

A punch looks up the block it lands on in a table of 128 entries ($A73F). The entry says what the block becomes: a window half becomes its broken form, a piece of wall becomes one of four holes, and some blocks, such as most of the roof, do not change. A new hole joins up with a hole in the block above it. Each punch that changes a block takes one from the building's strength and scores 100 points.

At strength 0 the building crumbles for 15 passes and then sinks a row at a time. While it falls, each block number has 100 added to it, which is the same block in its ruined form. Only a punch thrown while climbing reaches a building. A punch from the street is tested against the other monsters, the helicopters, and the vehicle.

Punching the first or the second building flat here also shows a slip: the whole picture is left a few pixels to the right. Discoveries explains it.

07 · The levels

A level is a list of buildings and the columns they stand in

The game has 20 levels, and each is described by a handful of bytes.

The first level's two lists, read from $A48E and $A462: three buildings, each a shape and the screen column of its left edge.

Two tables hold an address for each level. One address leads to a list of building shapes and the other to a list of screen columns. The level's number also picks its colours from two tables of sixteen ($9DC1, $9DD0), which is why the same six shapes look like different buildings from level to level. Levels 5 to 8 and 13 to 16 swap the city skyline for hills.

After level 20 the game goes back to the first. The Levels tab draws all twenty.

08 · Energy

The word DAMAGE is the energy bar

Each monster starts with 56 units of energy. Slide a monster's energy down and watch its word.

The status lines as the game's own code draws them ($9C62 colours the letters and $994A prints them), run on the site's 6502 with the energy the sliders give. At 0 the page runs the game's routine for a monster that has just lost its last unit ($9B9B).

The manual promises energy bars. The game colours a word instead: the energy divided by 8, plus one, is the number of letters shown in white from the left, and the rest are red. With six letters in DAMAGE, the word stays white down to 40 and then loses a letter for every 8 units.

Damage arrives as flags. A flag is a byte that is either 0 or 1. A bullet, each step of a fall, each step of being knocked back by another monster, and standing in a hole in the road all set a monster's "hit" flag to 1. Once a pass the game looks at the flag, and every second time it finds the flag set it takes one unit of energy. Several hits in the same pass count as one.

Nothing gives energy back. Sliding George to 0 with Lizzie above 0 shows one of the game's slips, which is in Discoveries with the others about energy.

09 · Helicopters

The helicopters fly eight fixed routes

Each helicopter among the buildings follows a script: a kind of move and a number of frames, over and over.

The route is read from the game's tables ($8D48, $8D21) and flown at the game's speed, 50 steps a second, over the first level. The dotted line is the whole route. A test flies every route with the game's own code and compares the position and the shape at each frame.

Two helicopters share the eight routes, each picking one at random when it has finished the last. A route starts off one edge of the screen and is a list of pairs: one of eight kinds of move, and the number of frames to keep it up. A move is a step across, a step down, and the picture to show, so "left and down" is a dive with the nose-down picture. The second helicopter starts 20 pixels higher than the route says, so the two do not fly on top of each other.

The first helicopter fires a bullet while it is diving. The second never fires. A punch that lands near either one sends it down a ninth route, the explosion, from wherever it is.

10 · The street

The street vehicle is drawn from a list of sixteen

When the street is empty the game picks the next vehicle at random.

The sixteen entries of the vehicle tables ($8CC7-$8D06), each drawn from its two sprite shapes. A step is 2 pixels a frame.

A vehicle is two sprites side by side: a car, a tram, or a tank. Each entry in the list gives the picture, the edge of the screen it starts from, and its speed. A monster in the street can punch downwards at one. A car or a tank is wrecked, and a tram drives away faster. Vehicles do no harm to a monster.

The last entry in the list is a mistake, and so is the second picture of every wreck. Both are in Discoveries.

11 · The computer's monsters

A monster nobody plays presses buttons at random

The computer steers its monsters by pressing the same five controls a player has.

The button runs the game's own routine ($B380) a thousand times on the site's 6502, with the game's random number routine, and counts what it pressed.

Once each pass the routine draws a random number for each monster it steers. About 6 times in 256 it lets go of every direction and presses fire, which is a jump on the street and lets go of a wall. About 50 times in 256 it chooses new directions: left or right evenly, and up three times in four. The rest of the time it leaves the directions as they were. Fire is pressed about two times in nine, and fire with a direction is a punch.

The routine never looks at the screen. A computer monster climbs because "up" beside a building starts a climb, and it damages buildings because fire while climbing is a punch. With nobody playing, the game runs as a demonstration in which the monsters cannot lose energy.