abcrom Users Guide

abcrom is a standalone Lynx Game Development SDK utility that patches a compiled tune stream into a runnable .lnx cartridge for auditioning in an emulator, with no toolchain at test time. It ships a pre-assembled template ROM — the snd sound engine plus a tiny boot harness — and patches the stream into a reserved region, so a tune reaches a playable ROM in milliseconds. It is a pure file-to-file transform: host-compiled, and it never invokes cc65 or abccc, never shells out, and never launches an emulator. Tunes are authored in ABC and compiled to a stream by abccc first; for how the engine plays a stream, see the Sound page.

1. Overview

Once a tune is written, you usually want to hear it before wiring it into a game. abcrom gives that fast feedback loop: you compile the tune to a stream with abccc, and abcrom patches that stream into a bootable .lnx that plays it on load in any Lynx emulator — no link, no cc65 installed. It is the preview companion to abccc, which does the actual ABC → stream compilation.

abcrom lives under tools/abcrom/ and its binary installs into the root bin/ alongside the rest of the SDK utilities. It is a pure file-to-file transform — it reads a compiled .bin stream and writes a .lnx, and never runs abccc, never creates a temporary file, and never launches an emulator. Compile the tune first with abccc -f bin, then run the patched ROM in the emulator of your choice. Keeping abcrom free of subprocess, temp-file and PATH dependencies lets it build and behave identically on Linux, macOS and Windows.

2. How the template patcher works

abcrom ships a pre-assembled template ROM — the snd engine plus a tiny boot harness and four fixed, reserved tune regions — and simply patches a compiled stream into the region for a channel. Because the region is fixed-size, patching never changes the file length, so the .lnx header stays valid and a tune reaches a playable ROM in milliseconds.

Each region is fronted by an "ABCR" magic header carrying the format version, channel index, capacity and used length, so the patcher locates it without hard-coded offsets and refuses a template whose version does not match the compiler. On boot the harness calls snd_init() then snd_play() for each non-empty region and loops; an empty region is a single END byte and that channel stays silent.

3. Usage

abcrom is invoked with a compiled stream and options. The input (and every --channels entry) is an abccc -f bin stream, not ABC source, and -o is required:

abcrom  -o FILE.lnx  [opts]  tune.bin
  -o FILE          output .lnx (REQUIRED)
  -t FILE          template .lnx (default: bundled template)
  --channels MAP   place streams on channels, e.g. 0:bass.bin,1:lead.bin
  --name STR       cart-name field in the .lnx header

The audition loop is three explicit steps — compile, patch, launch:

        abccc -f bin -o tune.bin tune.abc      # compile the stream
        abcrom -o test.lnx tune.bin            # patch it into the template
        handy test.lnx                         # launch the emulator yourself

        # two voices, one ROM:
        abccc -f bin -o bass.bin bass.abc
        abccc -f bin -o lead.bin lead.abc
        abcrom --channels 0:bass.bin,1:lead.bin -o song.lnx

A tune that uses pointer envelopes must be compiled at the runtime address its channel region occupies. Because abcrom no longer runs abccc, you pass that address to abccc yourself with --org: the payload sits 10 bytes past the template's _abcr_regionC symbol, which with the bundled template is $0AE2 for channel 0. Tunes without pointer envelopes are position-independent and need no --org.

        abccc -f bin --org 0x0AE2 -o tune.bin tune.abc
        abcrom -o test.lnx tune.bin

4. The template ROM

The template embeds a specific engine build and stream-format version. Its source lives in tools/abcrom/template/ and the bundled default tools/abcrom/template.lnx is committed, so abcrom works out of the box. Whenever the sound engine or the stream format changes, rebuild it once with the toolchain:

        make abcrom-template

The ABCR format-version byte turns a template/compiler mismatch into a hard error rather than silent corruption. Tunes larger than a region's capacity are rejected — bump the reserved size in the template source and rebuild. The patched .lnx carries the standard 64-byte header and runs in Handy, Mednafen and Felix; real-hardware carts need the encrypted micro-loader, a separate path outside abcrom's quick-preview scope.

5. Copyright

abcrom 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.