1987 · Konami

Gradius

This minisite was curated by unorig, air.

Konami's shooter on the Commodore 64 keeps all eight stages in memory at once, carries a music player with two tunes that never play, and times its screen splits for an American machine, so a European one draws the picture wrong.

01 · The game

Eight stages in one load

Gradius is the American release of Konami's Commodore 64 shooter, sold in Europe as Nemesis.7 It loads once and never touches the disk again: all eight stages sit in memory from the start. It also carries music it never plays, and times its screen for American machines, so on a European one the picture falls apart.

The loading screen: the Gradius logo over a space stationThe title screen: GRADIUS and ONE PLAYER GAME over a star fieldStage 1: the Vic Viper over ground and trees, the power-up bar along the bottom

The loading screen, the title and stage 1. The loading screen credits the programming to Simon Pick and dates the game KONAMI 1986. The title and the stage are from an NTSC C64, where the screen splits land where the game expects them.

You fly the Vic Viper from left to right while the screen scrolls on its own. Shooting a red enemy, or the sixth of a group of fliers, leaves a capsule. Each capsule you pick up moves a light along the power-up bar at the bottom of the screen: SPEEDUP, MISSILE, DOUBLE, LASER, MULTI and ?. Right SHIFT takes the power-up that is lit, and the light goes out.

Each stage's scenery is read from a map one column at a time. When it runs out, the scroll stops and the stage's own attack begins: rocks from volcanoes, darts, bursting blocks or a block to shoot through. Then comes a boss, most often the Big Core. One to four players take turns, each with three lives, and a lost life past the stage's checkpoint starts again from there.

02 · Power-ups

What each box gives

Right SHIFT takes the lit box. The joystick has no way to take one: the only call to take_powerup is in the keyboard reader.

SPEEDUP · A flame behind the ship, short at speeds 2 and 3 and long at 4, shown only while it moves right. At speed 1 there is none.
MISSILE · Fire held over stage 1's ground. The missile falls a cell down for each cell on, runs along the ground and stops at the first tree.
DOUBLE · The rising shot climbs a cell for each cell it moves on; the ordinary shot moves two cells at a time along its row.
LASER · Five cells of beam, moving three cells at a time, the last one white. Its characters are picked so the beam sits level with the ship's nose to the pixel.
MULTI · Two Options, eight and fifteen moves back along the ship's path, glowing through three shapes. They share one sprite with the flame, so with two of them the flame never shows.
? · The shield is a second picture of the ship with two pods at its nose. Only the level picture has them, so the pods vanish whenever the ship tilts up or down.
BoxWhat it givesUntil
SPEEDUPOne more step of speed, across and up and downSpeed 4
MISSILEMissiles that drop and run along the ground; a second MISSILE makes them move every frame instead of every otherTwo
DOUBLEA second shot that climbs as it goes; takes LASER awayOnce
LASERLasers in place of shots; takes DOUBLE awayOnce
MULTIAn Option, which follows the ship's trail and fires with itTwo
?A shield worth four hitsWhile it lasts

What take_powerup ($5200) does for each box. A power-up that can go no further has its box blanked, and a blank box does nothing when taken.

A capsule moves the light one box on (capsule_power, $5777) and scores 500. Every seventh capsule dropped is blue instead (drop_capsule, $5630): picking it up destroys every small enemy on the screen and leaves the light where it is (blue_capsule, $5D3D). The fire button shoots every 17 frames while it is held (fire_button, $4DAC). An extra Vic Viper comes every 100,000 points (extra_life, $6B8B).

03 · The scenery

A map read one column at a time

Each time the screen has scrolled eight pixels, the game shifts the playfield one character left and reads one new column of 19 rows from the stage's map.

Forty columns of the stage's scenery from the slider's column on, drawn by the page from the map, the character set and the row colours in the listing; the outlined column is the one the bytes below it make.4

A map byte of $7F or more is a character, put in the next row down. A smaller byte is a count of empty rows, filled with spaces. A column ends when its 19 rows are full, and map_ptr moves past the bytes it read, so a column of open sky costs one byte and a column of solid rock costs nineteen. Stage 4's drawer, map_column_up, fills the column from the bottom row up, so stage 1's map comes out upside down, the volcanoes hanging from the ceiling, through a character set whose shapes are drawn upside down to match.

Characters from $80 up to a limit set for each stage (scenery_limit) are solid: the shots, lasers and missiles stop at them and the ship dies on them. The stage's own character set fills characters $80 to $FF, copied to $3C00 as the stage starts (load_stage_charset). Every stage is drawn whole on the Levels tab.

04 · The bosses

The Big Core and the last boss

Most stages end with the Big Core. Stage 7 ends with a block to shoot through, and stage 8 with a boss drawn dot by dot.

The Big Core, six double-size sprites, facing the Vic Viper

The Big Core at the end of stage 6.

The Big Core is six double-size sprites (shapes $A7-$AC) with five walls across its middle (boss_phase, $7768). A shot that strikes the two middle rows counts toward a wall, and every sixth such hit takes one away (core_shots, $7829); a laser takes one every eighth touch. As each wall goes, core_walls_draw rewrites the rows of two sprite shapes so the gap shows. With all five gone the stage is cleared for 500 points. If the Core's timer runs out first, the stage is cleared without them.

Stage 7's block takes 40 hits (target_struck, $6A16). The last boss is four double-size sprites whose shapes are cleared and then drawn in from a picture at $9C49, 25 dots a frame, until all 2,048 are in (grow_brain, $9985). It has six layers of 20 hits each (brain_struck, $9A4B). After it, the ending prints YOU HAVE SAVED THE PEOPLE OF NEMESIS over rolling bands of grey for 250 frames (ending, $CE66), and play goes back to stage 1.

05 · The screen splits

Screen splits timed for an American machine

Two timer interrupts a frame switch the screen between the playfield and the power-up bar. Their timing fits an NTSC frame exactly and a PAL frame not at all.

The screen's 25 rows of characters, with the lines where each interrupt arrives, worked out from the timer's period ($42C6, 17,095 cycles) and the frame's length. Rows drawn in the playfield's mode are plain; rows drawn in the bar's mode are hatched, labelled B.3

The playfield is drawn in multicolour character mode, where a character has four colours. The power-up bar is drawn in extended colour mode, where a character has a background colour of its own but only 64 shapes. The game switches between the two with two timers on the second CIA chip, which fire non-maskable interrupts (NMIs), handled at nmi_split ($0840). start_split_timers ($FD50) starts timer A at raster line 70 and timer B at line 230, and gives both the same period: 17,095 cycles. The handlers' writes land about twelve lines later, at lines 82 and 242.

An NTSC C64 draws a frame in 263 lines of 65 cycles, 17,095 cycles: the timers come round at the same lines every frame. A PAL C64 draws a frame in 312 lines of 63 cycles, 19,656 cycles, so each timer comes 2,561 cycles, about 41 lines, earlier in each frame than in the last, and sometimes twice in one frame. The bar's mode creeps up over the playfield, where its 64 shapes turn the scenery into letters and digits. Press PAL and move through the frames.

06 · Music

Music: two tunes the game never plays

The game carries a two-voice music player and two tunes for it. In the European Nemesis the M key switches between the music and the sound effects;7 in this Gradius nothing calls the player, so the tunes are never heard.

The game's own tune player running on the page, over the bytes in the listing: set_tune ($1C5B) to start, as the stage's events do, then tune_tick ($1AB5) once a frame, as music_tick ($6AA9) would call it. The clock is an NTSC C64's.1

Each tune is two lists of notes, one for each voice, two bytes a note: the note and its length. Three more bytes are commands: $FE loads one of 15 instruments, $FD jumps to the tune's second section and $FF starts both voices again. Tune 1 steps every six frames and is played an octave up; tune 2 steps every four frames (tune_tempo, tune_transpose).

The stages still start the tunes: event 15 calls set_tune for tune 1 and event 16 for tune 2. But set_tune only clears the chip and points the voices at the notes. The routine that would play a step each frame, music_tick, has no caller, and the M key that would switch the music on is cut off by a single byte (Discoveries).

The player on this page plays the notes as the bytes give them, faults included: the second voice is slightly sharp.

07 · Sound effects

Sound: nine effects, eight pitches each

Every sound in the game is one of nine effects, each a waveform, an envelope and eight pitches played round and round.

Each button runs the game's play_effect ($9B71) with the effect's number, then effects_tick ($9BE1) once a frame, as the play frame calls it, until the effect's time runs out.2

play_effect puts each new effect on the next of the three voices in turn, so three can sound at once and a fourth cuts off the oldest. Each frame effects_tick sets the voice's pitch to the next of the effect's eight steps in effect_pitch and counts down its time from effect_time. The explosions (effects 2, 5 and 6) use noise; the rest use triangle or sawtooth waves.