1989 · Monarch Software

Music

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/a-nightmare-on-elm-street with me to Gold.

One tune, heard at the start and again at the end, and 36 sound effects, all played by one small routine.

01 · The tune

One tune, played twice

The game has a single piece of music. It plays over the credits, the title, and Freddy's picture as the game starts, and again over the ending when Freddy is beaten.

The player runs the street part's own sound routine on a copy of the C64's processor in the page: start_effect once, then effect_tick each time the Kernal's timer interrupt comes, every 16,422 cycles (about 60 times a second), over the game's bytes from the Source tab.

The game has no music player of its own. street_start hands the tune at title_tune to the same routine that plays a door opening or a coin picked up, and the routine treats it as one more sound effect, three lists of notes, one for each voice. The second voice stays high, mostly between G♯5 and G♯6, and the third opens on a repeated low C♯ between rests before it moves between F♯3 and B4. It runs for about 3,060 interrupts, some 51 seconds, unless a key cuts the title sequence short, and then sound effect 34, three empty voices, silences it.

The ending plays the same tune. When Freddy falls in the final fight, game_won loads the file SONG from side 2 to $B000 and plays it through the house's copy of the routine. SONG holds the title tune's bytes again, every one of them, with only the three voice pointers at its start changed to suit its new address.

Each voice is a list of bytes. A number from 1 to 95 is a note, looked up in a table of pitches at $4C0D, and 0 is a rest; the byte after it is the length, multiplied by the voice's tempo. Commands from $C2 up set the waveform, the pulse width, the envelope, and the volume, run two kinds of counted loop, switch vibrato on and off, and change the tempo; $FF ends the voice (voice_read).

02 · Sound effects

Thirty-six sound effects

The same routine, started on each effect of the table at $0400 in the file SOUND, which side 1 loads once and the game keeps.

EffectWhere the game plays itLength

Some numbers share one effect: 4 and 30 are the same bytes, so are 6 and 31, and 16 to 19 are all one effect. Effects 7 and 16 loop, and run until another effect replaces them. A new effect always replaces the one playing, since there is only one set of three voices for the tune and the effects together, which is why a sound cuts into the last. Effects marked "from a table" are started through a table rather than by a call with their number: each monster's hit plays effect 23 (kind_hit_sound), and each gun and weapon has its sound in a table beside its handler ($4B63, $4C05).