1990 · Domark

The Spy Who Loved Me

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

Matt Furniss's sound, sixteen tunes in one table: the Bond theme and fifteen sound effects, played here by the game's own code.

01 · Music and effects

One theme, fifteen effects, one table

Matt Furniss wrote the sound, though the game's credits screen leaves his name off.2 Everything the game plays, music or effect, is a "tune" in one table of sixteen, started by the same routine (play_tune). Tune 0 is the James Bond theme, 4,753 frames or about 95 seconds long.3 The other fifteen are sound effects of a quarter of a second to two and a half seconds.

The player runs the game's own sound code on a copy of the C64's processor in the page, over the game's bytes from the Source tab: play_tune to start a tune, then music_play once a frame, as the game's interrupt calls it at the top of the panel.

TuneWhen the game plays itStarted fromLength

02 · The C= key

Music or sound effects, never both

The game plays either the theme or the effects. A flag at $F4 decides, and C= flips it (read_keyboard). The game starts with the flag clear. While it is clear, play_tune ignores which tune it was asked for: if something is still playing it does nothing, and if not it starts tune 0 again. The theme has no loop of its own: when it ends, the next shot or explosion that asks for an effect starts it again, which is how it keeps going for a whole game. Pressing C= sets the flag and plays tune 8 to show that the effects are on; pressing it again plays tune 0.

Tunes 6 and 7 are in the table, with order lists of their own, but no call in the game starts either of them.

03 · How the player works

Order lists, patterns and instruments

Each tune is six bytes in the table at tune_table: the addresses of three order lists, one per voice. An order list names the patterns a voice plays, with commands between them that transpose the voice or repeat a pattern (next_order). A pattern is a run of notes, each followed by its length, with commands for instruments, arpeggios, and rests (pattern_byte). The player can also detune a voice, remap its instruments, slide a note, and switch the filter, but none of this game's tunes asks it to. The 28 patterns are listed at pattern_pointers.

An instrument sets the waveform, the envelope and the pulse width, and names a vibrato table, a table of waveform steps, and a pulse sweep that the player runs on every frame of the note (voice_effects). The instruments are packed tightly: each is ten bytes long, but they start nine bytes apart, so the last byte of one is the first byte of the next (set_instrument, instruments).

The player keeps a copy of the SID's registers for each voice and writes them to the chip once a frame. For tunes numbered 40 and above it would leave voice 3 alone; with sixteen tunes in the table, that branch is never taken (music_play).