abccc Users Guide
snd sound engine. ABC is the authoring format
only — it is never parsed on the Lynx; abccc does the parsing at build time
and emits ca65 assembly, a C header or a raw binary. It is host-compiled and does
not depend on the cc65 toolchain. For how the engine replays that stream, and for
worked playback examples, see the Sound page; to preview a
compiled tune as a runnable cartridge, see abcrom.1. Overview
The lynxcc sound engine plays a compiled event stream: notes interleaved with opcodes that set instruments, envelopes and loops. abccc is the tool that produces those bytes. You write a tune in ABC — a compact text notation — and abccc lowers it to the stream once, at build time, so the cartridge carries only the byte-coded result and the engine never has to parse ASCII.
Keeping the compiler off-target keeps the runtime free of a stateful tokenizer,
lets the tool be written in a convenient host language, and makes its output easy
to unit-test against the stream spec. abccc lives under tools/abccc/
and its binary installs into the root bin/ alongside the rest of the
SDK utilities. The stream format, opcode map and ABC grammar are specified in full
in design/LYNX_SND_ENGINE_DESIGN.md.
2. The ABC source language
2.1. Notes, rests and durations
A tune is a NUL-terminated ASCII string. Notes are the letters
C D E F G A B in the middle octave and
c d e f g a b one octave higher.
^ sharpens and _ flattens; a trailing ,
drops an octave and ' raises one. z is a rest. Any note
or rest takes an optional duration number (C2, z4); the
real length in frames is number × T.
2.2. Inline commands
Inline commands each take a numeric argument:
| Cmd | Name | Effect | Default |
|---|---|---|---|
V | Volume | channel target volume (0–127) | 127 |
R | Ramp / attack | per-frame attack increment | 4 |
H | Hold | frames of full-volume sustain | 4 |
K | Kill / decay | per-frame decay decrement | 4 |
T | Tempo | frames per duration unit | 6 |
O | Octave base | added to each note's octave | 0 |
I | Integrate | 0 = square, 1 = integrate/triangle | — |
X | XOR taps | LFSR feedback taps (timbre / noise) | — |
2.3. Repeats and structure
For structure, |: opens a repeat (optionally followed by a count,
|:3) and :| closes it; spaces are ignored. Bar lines
| are cosmetic.
2.4. Envelopes: AHD and looping
V/R/H/K describe a simple attack–hold–decay (AHD)
amplitude shape. abccc lowers them into an ordinary three-segment
volume envelope, so the runtime needs no AHD-specific code: an AHD
instrument is just a volume envelope like any other.
V/R/H/K into a
three-segment volume envelope.Richer effects use full looping envelopes directly. An envelope is a list of
[count, increment] segments with a loop point; every interrupt the
engine advances the active segment, applying increment to volume,
frequency or the shift register. A looping frequency envelope gives vibrato; a
looping volume envelope gives tremolo.
[count, increment] envelope — the basis of
vibrato and tremolo.3. Usage
3.1. Command line
abccc reads .abc text and emits a ca65 source
(-f s), a C header (-f h) or a raw stream
(-f bin):
abccc [options] input.abc -o FILE output file -f s|h|bin output format: ca65 asm (.s), C header (.h), raw binary -l LABEL symbol/label name for the emitted stream --org ADDR load address for bin/h output that uses envelope pointers --no-compact disable default-duration compaction (emit 2-byte notes) --validate range/structure checks only, no output --version print the stream format version and exit
3.2. The build flow
abccc maps each note to a chromatic table index (the engine's tuning), folds
T and O into durations and pitches, lowers
V/R/H/K into a volume envelope, compiles repeats to
Loop/Do, and packs common notes to one byte. The emitted
bytes are the shared contract between abccc and the on-target player, so the two
must always agree on the stream format version (abccc --version).
A Makefile rule wires it in like any other generator:
ABCCC := abccc assets/%.s: assets/%.abc $(ABCCC) -f s -l $(notdir $*)_music -o $@ $< game.lnx: main.o assets/theme.o cl65 -o $@ $^
The committed examples/mikey/sndtune/theme.s is exactly this output for
theme.abc; it is checked in so the sndtune example links
without abccc present, and is regenerated by hand when the tune changes. For a
walk-through of composing a melody, a two-voice loop and an expressive instrument
— each with the resulting stream and the C that plays it — see the
worked examples on the Sound page. To hear a tune
without a full build, patch it into a test cartridge with
abcrom.
4. Copyright
abccc is part of the lynxcc Lynx Game Development SDK. The full license text is reproduced verbatim, together with every other copyright notice in the distribution, on the consolidated Licenses and copyright notices page.