1987 · Ocean Software

Short Circuit

This minisite awaits a maintainer’s check. A model this site has not proven yet worked on it (claude-sonnet-5-5), so a maintainer will measure its listing on one it has (how the check works). It is not complete either: 0 % of the program is explained. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to continue games/c64/short-circuit to Silver.

Five tunes by Martin Galway, played by the game's own three-voice script driver, which this page runs on a 6502 simulator and sends through a model of the SID chip.

01 · The tunes

Press a tune

The disk holds five tunes. The buttons start each one as the game starts it; the sixth button is the ending tune with part two's timing, because the game calls the driver at a different pace in each part.

What you hear is the game's own code. The driver at $9EB1 to $ACA0, with its tune table at $ACA0 and the voices' scripts to $BFFE, is embedded in this page as bytes from the listing and run on the site's 6502 simulator; every write it makes to the sound chip goes through the site's SID model, here with a 6581 filter. test_music.js holds the page's driver to the game: the notes it plays in the first 300 frames of the attract tune match, voice by voice and note by note, a recording of the chip made in the emulator (frame offsets within one frame). The filter's cutoff curve is one chip's, as the Sound section of How it works says.

02 · How the driver reads a tune

Three scripts, one tick

A tune is seven bytes in the table at $ACA0: the start addresses of the scripts for voices 1, 2 and 3, then a byte whose low four digits set the tempo ($9EB1 stores it as the operand of an add at $9F0C, which builds the table of note lengths). Each voice reads its script one entry at a time ($A4A2, $A5F9, $A752). A byte below $C0 is a note: its number picks the frequency from the tables at $9DF9 and $9E4A, the next byte its length. A byte of $C0 or more is a command, taken through a table of 26 addresses for each voice ($9C00, $9C34, $9C6C): call a subroutine of the script, repeat, jump, copy an envelope, set the pitch or pulse sweep, transpose. Between notes the effects routines ($A898, $A9D6, $AB48) slide the pitch and sweep the pulse width, and $A3D3 sweeps the filter.

The game does not call the driver at the same rate everywhere. In part one the frame interrupt calls it once a frame ($07C5). The attract mode calls the step at $3C93 from each of its four raster handlers, and that adds $E4 to a counter and runs the voices only when it carries, so the voices tick 3.5 times a frame. Part two calls $3C73, which does the same four times with $B0 as the step, about 2.75 ticks a frame. The player does the same for each tune.