1987 · Konami

Gradius

This minisite was curated by unorig, air.

What the code holds that the game never shows: a cheat one byte from working, a music player nobody calls, a pause key that was cut, and the test loops and file names the developer left behind.

01 · Secret

Secret: a cheat that one byte switches off

The routine that reads the keys on the title screen (title_keys, $1881) ends in an RTS at $18D0 (cheat_switch). The code after it, cheat_key ($18D1), is never reached. It begins with the second byte of an LDA #$FF, so the RTS sits exactly where the instruction's first byte, $A9, belongs.

Put $A9 back and the cheat works. With four players chosen, holding left SHIFT on the title sets cheat_mode ($6ED2) and puts a "C" at the top left of the screen. While the flag is set, the play loop skips its checks for a hit ship and a finished turn, so the Vic Viper flies through enemies unharmed. Q still gives up the game, and clears the flag as it does (quit_key, $6B02).

In the European release, Nemesis, the cheat works as it stands: SPACE pressed twice on the title, then a third time with left SHIFT held, puts up the "C".7 Three presses of SPACE step the title from one player to four, which is why this copy's dormant code wants four players. C64-Wiki also says that in Gradius the most important part of the routine was overwritten; the one byte at $18D0 is that part.

EvidenceWhat was seen
Tried in VICEWith $A9 written at $18D0, four players chosen and left SHIFT held on the title, a "C" appeared, and in play the ship flew through enemies without losing a life.
As shippedThe RTS at $18D0 returns before the key is read, and nothing else jumps into cheat_key.

02 · Secret

Secret: a music player with two tunes that never play

From $1CA1 to $1FF9 the game holds two tunes for two voices, and from $19D2 the player that plays them (tune_tick, $1AB5). The game never plays a note of them, because two links are missing. In the European release, Nemesis, the M key switches between music and sound effects, and C64-Wiki notes that Gradius has only the effects:7 the American release was cut off from its music.

The first missing link is the M key. Each frame of play calls jmp_music_key ($6AA6), which is a lone RTS. With a JMP there it would go on to music_key ($6AB9), which turns music_on on and off. The second link is the tick. music_tick ($6AA9), the routine that would step the tune once a frame while music_on is set, has no caller anywhere in memory. The events that start each stage still choose a tune (set_tune, $1C5B), but all that does is clear the sound chip.

Patching the RTS into a JMP makes M switch music_on, and the only effect is that the sound effects go quiet, as the effects player gives way to the music (play_effect, $9B71). The tune still has nothing to step it.

A test loop at $1BEC shows how the tunes were tried out: it starts tune 1 and plays it for ever, one tick a frame, flashing the border black and white to show how long each tick takes.

Had the music played, it would have been slightly out of tune. When tune_tick sets a note's frequency, it adds the voice's register offset to the low byte at $1B4D. The offset is 0 for the first voice and 7 for the second, so every note of the second voice is 7 units too high: barely out of tune on high notes, where the frequency numbers are large, and clearly out on low ones.

EvidenceWhat was seen
Tried in VICEWith $4C (JMP) written at $6AA6 in a saved moment of play, pressing M set music_on to 1, and the sound effects went quiet.
Still missingNo instruction anywhere in memory calls music_tick ($6AA9), so even with the patch no note of either tune plays.
On this siteThe player on How it works runs the game's own tune_tick, so both tunes, and the sharp second voice, can be heard there.

03 · Bug

Bug: on a European machine the screen splits wander

The game splits the screen with two interrupts a frame from CIA 2's timers (start_split_timers, $FD50, and nmi_split, $0840). Both timers count 17,095 cycles, one frame of an American (NTSC) C64. A European (PAL) frame is 19,656 cycles, so on a PAL machine each split comes 2,561 cycles earlier every frame and creeps up the screen. Where it lands in the playfield, the playfield is drawn in the power-up bar's mode and its characters turn to garbage. The stepper on How it works follows the splits frame by frame on both machines.

04 · Oddity

Oddity: a hatch scores only when it gets away

The enemy hatches on the floor and ceiling take eight hits (hatch_hits). The eighth starts the explosion and plays the explosion sound, but calls nothing that adds points. The 1000 points are in move_hatch ($64FD) instead, at $6560: they are given when a hatch scrolls off the left edge of the screen. So the player scores for letting a hatch go, and nothing for destroying it.

05 · Oddity

Oddity: stage 6 points at a map it never draws

Every stage has an entry in the table of map starts (map_starts, $50B4), and stage 6's points at stage 2's map at $AD00. But a stage's scenery comes on only when its event list runs event 16 (start_tune2, $7431), which calls event_scenery ($50C4). Stage 6's list never runs it, so the map is never read and the stage is open space: spheres and tentacles over the stars, and then the Big Core. Its event 12, which ends the scroll, comes at position 312, earlier than on any other stage. Stage 6 on the Levels tab shows it.

06 · Leftover

Leftover: a pause on P that was cut

At $6B29, next to the routine for Q, sits a pause. It switches the interrupt and the screen off, silences the sound chip, waits for P to be let go, pressed and let go again, and turns everything back on. Nothing calls it, and it could not run as it stands: its calls to a delay routine land in the middle of an instruction at $6B81. The game shipped with no pause.

07 · Leftover

Leftover: test loops for single enemies

Five loops in the game run one part of it on its own, frame after frame, and nothing calls any of them. They look like the developer's test benches, each built to watch one enemy or one piece of the game without playing up to it.

WhereWhat it runs
$0C98Stage 4's volcano: waits for raster line 255, then runs the eruption and its rocks and draws the sprites.
$1BECTune 1, for ever, with the border flashing to time each tick.
$4495The Big Core: sets it up, then runs its movement, lasers and sprites once a frame.
$8C38Stage 6's spheres and tentacles, with the border flashing, until a key on the bottom row is pressed.
$95A2Stage 5's blocks: they appear, burst and their fragments fly, for ever.

Beside them is an older main loop. $5F6D plays a game for one player: it zeroes the score, gives three lives, moves on when a stage is cleared and ends when the lives run out. The loop the game uses, for up to four players taking turns, replaced it.

08 · Leftover

Leftover: lines from the developer's disk

The program was saved from memory as it stood on the developer's machine, so scraps of what was there before came with it.

WhereWhat is there
$0801A BASIC line, 9 SYS 5768, which would start the game at $1688. The loader jumps there itself, so the line never runs. After it come the remains of more BASIC lines: "C)LM87 SIM. P." and "NO RASTER FLICKER !!!".
$9FF5The file name OBJNEMMAIN3. Nemesis is the game's name in Europe, which suggests what "NEM" stands for.
$B5C5The end of stage 2's map runs into the developer's assembler source: "ALIENBKH BYT 170,186,198,..." and "BANK".
$BBDDThe end of stage 2's event list holds more source: "BCC MTHS7" and "JSR CLEARMOUTH".

The bytes themselves, as they sit in the load, with a dot for each byte that is not a printable character:

$0801  0C 08 09 00 9E 20 35 37 36 38 00 00 00 14 00 00  ····· 5768······
$0811  43 29 4C 4D 38 37 20 53 49 4D 91 20 50 2E 00 48  C)LM87 SIM· P.·H
$0821  08 1E 00 4E 4F 20 52 41 53 54 45 52 20 46 4C 49  ···NO RASTER FLI
$0831  43 4B 45 52 20 21 21 21 20 59 4E 4F 20 59 55     CKER !!! YNO YU

$9FF0  00 00 5D 00 00 4F 42 4A 4E 45 4D 4D 41 49 4E 33  ··]··OBJNEMMAIN3

$B5C0  32 30 36 00 F5 58 54 38 41 4C 49 45 4E 42 4B 48  206··XT8ALIENBKH
$B5D0  20 42 59 54 20 31 37 30 2C 31 38 36 2C 31 39 38   BYT 170,186,198
$B5E0  2C 31 37 30 2C 31 35 37 2C 32 30 34 2C 32 34 38  ,170,157,204,248
$B5F0  2C 32 33 39 00 0E 59 5E 38 42 41 4E 4B 00 00 00  ,239··Y^8BANK···

$BBD0  13 06 10 09 0D 50 20 23 35 00 18 77 C2 4C 42 43  ·····P #5··w·LBC
$BBE0  43 20 4D 54 48 53 37 00 2B 77 CC 4C 4A 53 52 20  C MTHS7·+w·LJSR 
$BBF0  43 4C 45 41 52 4D 4F 55 54 48 00 05 09 0D 12 AD  CLEARMOUTH······

From the listing, at the four addresses in the table above. The text in the first block is BASIC, so its keywords are stored as single bytes: $9E is SYS.

The loading screen credits the programming to Simon Pick, and C64-Wiki credits him with the programming and graphics, so "SIM. P." in the BASIC line is most likely him.7 The 87 beside it fits the European release's year.