lynxdir Users Guide
tools/extern/lynxdir. Driven by a
.mak config file, it assembles a bootable cartridge image from a
title picture, a main executable and any data files, prepends an
encrypted loader that the Lynx boot ROM will accept, and writes both a
plain .lyx ROM and an emulator-style .lnx. It overlaps
the in-tree lnx tool but comes from the wider Lynx
homebrew ecosystem and covers loader layouts and multi-file assembly that
lnx does not.1. Overview
lynxdir builds a complete cartridge ROM: it lays out a small directory of the files that go on the cart, prepends an encrypted loader (the code the Lynx boot ROM decrypts and runs at power-on), and pads the result to a cart size. The loader shows the first file — the title picture — and loads the second file — your main executable — for execution. No checksums are written and no directory entries are baked into the loader, so the loader is copied verbatim and the cart contents can even be patched by hand afterwards.
lynxcc vendors it verbatim (unmodified) as an external tool
under tools/extern/lynxdir; see
design/LYNX_EXTERN_TOOLS_DESIGN.md for the vendoring policy and
Licenses for the notice. It is written in C++
(lynxdir.cpp, lynxrom.cpp) and builds through the
Makefile's C++ external-tools path into the shared bin/lynxdir. It
is a standalone convenience tool: it is not wired into
cl65 or any example, and the SDK's own
lnx tool (with lnx bll) is the supported way
to produce a bootable .lnx from a linked program — lynxdir is
here for projects that want its loader layouts or its .mak-driven
multi-file assembly. See §6 for the comparison.
.mak lists the loader and the files, and lynxdir emits a raw .lyx plus an emulator .lnx.2. Usage
2.1. Command line
Almost everything about a ROM is decided in the .mak
file; the command line carries only a handful of global switches. Run lynxdir
with no arguments (or -h) to print the built-in help:
LynxDir Generator Version 1.9 a replacement for the lynxer (c) 2010-2017 Bjoern Spruck based on the lynxer by Bastian Schick It can create ROMs with * BLL type 1024 bytes/block, using Troyan Horse * EPXY Loader 512/1024/2048 w/o checksum * EPXY Loader with BLL type file system * CC65/Karri MiniLoader @ $F000 and $FB68 * or without loader for later encryption ... and a few other things Usage : lynxdir [-hvsif01r] batchfile.mak lynxdir mainexe.o -h this help -v verbose -f[01r] fill ROM with 0,1,random -s dont skip exec header (adds extra 10 bytes per exec) -i remove imp (overwrite with random) -x dont write LNX -y dont write LYX all other options should be set in MAK file, see examples!
batchfile.makThe config file that lists the loader, the files and the ROM parameters. This is the normal way to invoke lynxdir; see §3.
lynxdir mainexe.oShorthand for a trivial single-executable cart: given a linked object instead of a
.mak, lynxdir builds a minimal ROM around it.-vVerbose — echo every command as the
.makis parsed and report the chosen loader, blocksize and per-file placement. Invaluable when a layout does not boot.-f0,-f1,-frFill the unused tail of the ROM with zero bytes,
$FFbytes, or random bytes. (See also theBLOCKLIMITcommand, which caps how much is filled.)-sDo not skip the 10-byte execution header on files — keep it, at a cost of 10 bytes per executable. The default strips it.
-iOverwrite the
imp(loader work area) with random bytes rather than leaving it intact; a compatibility/obfuscation knob.-x,-ySuppress one of the two outputs:
-xwrites no.lnx,-ywrites no.lyx. The same effect is available inside the.makasNOLNX/NOLYX.
2.2. The two required files
The first two filenames in a .mak are fixed by convention:
The first file is the title picture, in the boot
loader's own picture format (not a Suzy sprite). If you have no artwork, either
put in a 40-byte file of zeros for a black screen, or use the
PUTTITLE command to drop in lynxdir's
built-in “Insert Name” picture. Some layouts also need a
TITLEADR to say where the picture loads.
The second file is the main executable — the program the loader jumps to. With lynxcc this is what ld65 produced for a cart config; the mini-loader layouts skip the title picture, so there the executable is the only required file.
3. The .mak config file
3.1. Syntax
A .mak is a plain-text list, read top to bottom:
- Comments
A line (or trailing text) starting with
;.- Commands
A line starting with
#, optionally followed by a value — e.g.#BLOCKSIZE 512.- Filenames
Anything else is a filename, relative to the working directory or absolute. Avoid spaces and special characters in names.
- Blank lines
Ignored; most whitespace is ignored.
Commands split into two groups: ROM-wide commands that
affect the whole image no matter where they appear, and
per-file switches whose position matters because
they apply to the next file (or all following files). For readability keep the
ROM-wide commands at the top. A .mak can pull in another with
#INCLUDE other.mak for large projects.
3.2. Choosing a loader
Every ROM needs a loader; if none is selected (or NOLOADER is
given) lynxdir exits. The loader command also fixes the block size, the directory
start offset and the first directory entry's mode, so it is normally the first
line of the file.
| Command | Loader | Blocksize | DIRSTART | Mode |
|---|---|---|---|---|
HACK512 | EPYX “hacked” loader, 512 B/block (128k) | 512 | 203 | EPYX |
HACK1024 | EPYX hacked loader, 1024 B/block (256k) | 1024 | 203 | EPYX |
HACK2048 | EPYX hacked loader, 2048 B/block (512k) | 2048 | 203 | EPYX |
HACKAUTO | Pick the hacked loader that matches the selected blocksize | as set | 203 | EPYX |
NEWMINI_F000 | CC65/Karri mini-loader at $F000 | variable (512 default) | 203 | EPYX |
NEWMINI_FB68 | CC65/Karri mini-loader at $FB68 | variable (512 default) | 203 | EPYX |
INTERNAL | BLL “new” loader (needs TROYAN) | 1024 | 896 | BLL |
NOLOADER | No loader — just zeros, for a later external encryption pass (EPYX layouts only) | — | — | — |
The mini-loaders skip the title picture entirely, so
PUTTITLE is not allowed with them. The BLL
INTERNAL loader must be paired with TROYAN (§3.4).
Because these commands set BLOCKSIZE and DIRSTART, you
normally do not set those by hand; the explicit forms below exist for mixed and
special layouts.
3.3. ROM-wide commands
BLOCKSIZE <n>Block size in bytes:
512(default, 128k),1024(256k) or2048(512k). Usually set for you by the loader command; one of the most important values when set by hand.DIRSTART <n>Byte offset where the directory begins:
410for the EPYX loader,896for BLL,203for NewMini. Set by the loader command in the normal case.BLOCKLIMIT <n>Cap the number of unused blocks that get filled when the ROM is smaller than the cart. Default 256 (effectively no limit).
DIROFFSET <n>Move the directory pointer to a higher offset — needed only for mixed BLL/EPYX/MINI loader layouts.
FILEADR <addr>Default load address for files that carry no address in their own header (default
0000). A rarely needed, not fully supported knob.
3.4. Per-file switches
These apply to the next file, or switch a mode for all files that follow, so their order in the file matters.
TROYANPlace the “Troyan horse” entry (file position 16) — required by the BLL
INTERNALloader.PUTTITLEInsert lynxdir's built-in “Insert Name” title picture in place of a first file. Not allowed with the mini-loaders.
TITLEADR <addr>Load address for the title picture, when the title file has no header of its own (do not give it for a
.ofile). It must match the address the title file was created for.EPYX/BLLSwitch subsequent directory entries to EPYX or BLL style (BLL XORs some fields). Normally set by the loader command.
ALIGNAlign the next file to a block boundary (block offset zero) in the ROM.
COPY [n]Add a directory entry that is a copy of an earlier one (of the previous entry if
nis omitted) without duplicating the file data; adapted if the mode changed in between.NONE/EMPTYWrite one empty directory entry.
SKIP <n>Skip
nentries (writenempty entries).SKIP_BANKSkip forward to the next bank, if one is available (see §3.5).
INCLUDE <file.mak>Splice in another
.makat this point.
3.5. Bank switching
Two commands double the number of banks on the cart, for ROMs larger than a single bank can address:
AUDINUse the AUDIN line to select the extra banks.
BANK2Use the second read strobe to select the extra banks.
Your program is responsible for switching banks and reading files
— there is no runtime support and no official bank ordering (it is discussed
by ROM length in the AtariAge Lynx development forum). Both flags also set extra
bits in the .lnx header (§3.6) that only recent emulator builds
(Handy 0.98 and later) honour. Use SKIP_BANK to jump the directory to
the next bank.
3.6. .lnx header and EEPROM flags
These fill in fields of the 64-byte .lnx header that
emulators read; they do not change the raw .lyx.
LNXNAME <text>Cartridge name in the header (up to 31 characters).
LNXMANU <text>Manufacturer string (up to 15 characters).
LNXROT <0|1|2>Rotation flag for emulation:
0none,1left,2right.EE_93C46…EE_93C86Tell the emulator an SPI EEPROM of that type (93C46/56/66/76/86) is present. See the Cart ROM & EEPROM reference for the chips the runtime supports.
EE_8BIT/EE_16BITEEPROM access width; 16-bit is the default.
NOLYX/NOLNXSuppress the plain
.lyxor the.lnxoutput (same as the-y/-xcommand-line flags).
4. Output
lynxdir writes two files for a ROM built as cart:
cart.lyx is the plain ROM image — exactly the
bytes a flash cart or a real EPROM holds, loader and directory included, padded to
the cart size. This is what you burn or feed to a hardware flasher, and the file
you would run an external encryption pass over after a NOLOADER build.
cart.lnx is the same ROM behind a 64-byte
.lnx header — the emulator-friendly format
carrying the block size, name, manufacturer, rotation, bank-switch and EEPROM
flags set in the .mak. This is what you load in Handy/GearLynx. Either
output can be turned off (NOLYX/NOLNX or -y/
-x). Because no checksum is computed and the directory is stored
outside the loader, a built ROM can be inspected or patched afterwards — the
in-tree lnx tool reads and dumps the .lnx
header.
5. Config examples
The vendored tree ships a full set of annotated .mak files under
tools/extern/lynxdir/examples/, grouped by layout
(minimal_layout, epyx_layout, bll_layout).
Three representative ones:
A minimal 128k cart with the mini-loader at $F000 and no title
picture — the leanest layout, and the closest to what
lnx bll produces:
; miniloader @ $F000, 512-byte blocks #NEWMINI_F000 #BLOCKSIZE 512 #DIRSTART 203 #EPYX main.o
An EPYX-standard 128k cart with a title picture and the hacked 512-byte loader:
; EPYX standard, 512 bytes/block #HACK512 #BLOCKSIZE 512 #DIRSTART 410 #EPYX title.o main.o
A BLL 256k cart: the BLL “new” loader with the Troyan horse at file position 16 and the built-in title picture:
; BLL 1024 bytes/block, EPYX loader, troyan @ 16 #TROYAN #INTERNAL #BLOCKSIZE 1024 #DIRSTART 896 #BLL #PUTTITLE main.o ; data1.dat ; data2.dat
Build any of them by pointing lynxdir at the file:
lynxdir -v cart.mak
6. lynxdir versus lnx
The SDK ships its own lnx cartridge tool. The two
overlap where they both turn a program into a bootable cart, but they come at it
from opposite ends: lnx is a tightly focused .lnx header
inspector/patcher plus a single lnx bll build path, while lynxdir is a
flexible, config-driven multi-loader ROM builder from the wider homebrew scene.
| lnx | lynxdir | |
|---|---|---|
| Role | Inspect / patch .lnx headers; one BLL build path (lnx bll) | Build a whole ROM (loader + directory + files) from a .mak |
| Loaders | The SDK's own BLL loader | EPYX 512/1024/2048, BLL, NewMini $F000/$FB68, or none |
| Multiple files | Single executable | Title + main + arbitrary data files, copies, skips, alignment |
| Bank switching | Header bits only | AUDIN / BANK2 layouts (program-driven) |
| Output | .lnx | .lyx and .lnx |
| Config | Command line / JSON | .mak config file (with #INCLUDE) |
| Provenance | MPL-2.0, part of the SDK; wired into cl65 | External (tools/extern/lynxdir), unmodified; standalone, not in cl65 |
In short: reach for lnx for the normal
lynxcc flow of building and inspecting a .lnx from a
linked program; reach for lynxdir when you need a specific loader layout (EPYX,
BLL, NewMini), a multi-file directory, hand-tuned bank switching, or the
.mak-driven workflow familiar from the older Lynx toolchains.
7. Copyright and licence
lynxdir is (C) Copyright 2010–2017 Björn Spruck, based on the earlier
lynxer by Bastian Schick. It is vendored into lynxcc
unmodified under tools/extern/lynxdir.
Licence caveat. lynxdir ships no licence file
— its upstream repository declares only (c) Björn Spruck
2010-2017, which under default copyright law reserves all rights. It is
vendored as-is, not relicensed under the SDK's MPL-2.0, pending an
explicit grant from the author. If you redistribute the SDK, resolve this with
upstream first or omit tools/extern/lynxdir/. This is recorded in
full on the consolidated Licenses and copyright
notices page (§4.4).