lynxdir Users Guide

lynxdir is Björn Spruck's Atari Lynx ROM builder, vendored into lynxcc under 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.

cart.mak loader + file list title.o main.o data… lynxdir loader + directory cart.lyx plain ROM image cart.lnx 64-byte header + ROM The first two listed files are always the title picture and the main executable; the encrypted loader shows the first and runs the second.
The lynxdir pipeline: a .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.mak

The config file that lists the loader, the files and the ROM parameters. This is the normal way to invoke lynxdir; see §3.

lynxdir mainexe.o

Shorthand for a trivial single-executable cart: given a linked object instead of a .mak, lynxdir builds a minimal ROM around it.

-v

Verbose — echo every command as the .mak is parsed and report the chosen loader, blocksize and per-file placement. Invaluable when a layout does not boot.

-f0, -f1, -fr

Fill the unused tail of the ROM with zero bytes, $FF bytes, or random bytes. (See also the BLOCKLIMIT command, which caps how much is filled.)

-s

Do not skip the 10-byte execution header on files — keep it, at a cost of 10 bytes per executable. The default strips it.

-i

Overwrite the imp (loader work area) with random bytes rather than leaving it intact; a compatibility/obfuscation knob.

-x, -y

Suppress one of the two outputs: -x writes no .lnx, -y writes no .lyx. The same effect is available inside the .mak as NOLNX / 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.

CommandLoaderBlocksizeDIRSTARTMode
HACK512EPYX “hacked” loader, 512 B/block (128k)512203EPYX
HACK1024EPYX hacked loader, 1024 B/block (256k)1024203EPYX
HACK2048EPYX hacked loader, 2048 B/block (512k)2048203EPYX
HACKAUTOPick the hacked loader that matches the selected blocksizeas set203EPYX
NEWMINI_F000CC65/Karri mini-loader at $F000variable (512 default)203EPYX
NEWMINI_FB68CC65/Karri mini-loader at $FB68variable (512 default)203EPYX
INTERNALBLL “new” loader (needs TROYAN)1024896BLL
NOLOADERNo 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) or 2048 (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: 410 for the EPYX loader, 896 for BLL, 203 for 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.

TROYAN

Place the “Troyan horse” entry (file position 16) — required by the BLL INTERNAL loader.

PUTTITLE

Insert 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 .o file). It must match the address the title file was created for.

EPYX / BLL

Switch subsequent directory entries to EPYX or BLL style (BLL XORs some fields). Normally set by the loader command.

ALIGN

Align 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 n is omitted) without duplicating the file data; adapted if the mode changed in between.

NONE / EMPTY

Write one empty directory entry.

SKIP <n>

Skip n entries (write n empty entries).

SKIP_BANK

Skip forward to the next bank, if one is available (see §3.5).

INCLUDE <file.mak>

Splice in another .mak at 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:

AUDIN

Use the AUDIN line to select the extra banks.

BANK2

Use 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: 0 none, 1 left, 2 right.

EE_93C46 … EE_93C86

Tell 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_16BIT

EEPROM access width; 16-bit is the default.

NOLYX / NOLNX

Suppress the plain .lyx or the .lnx output (same as the -y / -x command-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.

lnxlynxdir
RoleInspect / patch .lnx headers; one BLL build path (lnx bll)Build a whole ROM (loader + directory + files) from a .mak
LoadersThe SDK's own BLL loaderEPYX 512/1024/2048, BLL, NewMini $F000/$FB68, or none
Multiple filesSingle executableTitle + main + arbitrary data files, copies, skips, alignment
Bank switchingHeader bits onlyAUDIN / BANK2 layouts (program-driven)
Output.lnx.lyx and .lnx
ConfigCommand line / JSON.mak config file (with #INCLUDE)
ProvenanceMPL-2.0, part of the SDK; wired into cl65External (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).