Digital Archaeology: DOS 8 for the LTK
This is the last part of the LTK story, at least for now. The first part is from 2018, and the middle part covers how the LTK works, the copy protection, and the wall.
Well, the digging did happen, mostly in the spring of 2018 and with some help: a first pass over the boot ROM and the SYSGEN disks, and the disk driver figured out. Then the whole thing sat. In November 2026 I picked it back up, this time working with an AI agent that could drive VICE (more on that setup in Reverse engineering with an AI in the loop), and the repo went from a pile of first-pass disassembly to something you can actually build a DOS from.
Rebuild it first
Before changing anything, the sources had to build the originals exactly. Everything assembles with 6asm now, and one script builds the boot ROM and both SYSGEN disks and compares them to the originals byte for byte:
tools/check.sh # everything: ROM, side 1, side 2
tools/check.sh s1 dir era # just those modules
That script's the ground truth for everything after it. A renamed label or a new comment doesn't change any bytes, so documentation work has to keep it green too, and every change to the DOS sits behind a build flag so the 7.2 build still matches.
It turned up a little history, too. Two bytes in the fast copiers looked wrong, and chasing them down showed that the SYSGEN images I'd been working from had $20 written over four sectors at some point. The same damage had turned QUERY's "directory" into "dir ctory". A clean pair of images fixed both, and the sources build the good bytes.
The wall, in short
The middle part has the whole story of the 160 MB wall. The short version is that it's a bunch of limits stacked up, and fixing any one of them alone just runs you into the next:
- an LU's start is a 10-bit cylinder number, so nothing can start past cylinder 1023;
- each LU's bitmap is a fixed 17 blocks, and on a big LU it overflows onto the index;
- the driver's block address math drops a byte;
- READ(6) and WRITE(6) only reach 1 GB;
- the allocators only carry 16 bits of 24-bit counters;
- and there are only ten user LUs, about 330 MB in all.
DOS 8
DOS 8 is 7.2 with all of that taken out, running on the stock host adapter and the stock boot ROM. The adapter never sees a block address (the PIA just passes the command bytes through), so it's all software.
limit 7.2 DOS 8
--------------------- --------------------------- ---------------------------
LU size 65,536 blocks (32 MB) 65,535 blocks
user LUs 10 (LU 10 is the DOS) 254 (0-254, except 10)
LU start cylinder under 1024 any block on the drive
per drive 1 GB (READ(6)) 2 TB (READ(10))
per system about 330 MB about 8 GB
A flat bitmap. One bit per block. 16 blocks x 512 bytes x 8 bits is 65,536 bits, so a full 32 MB LU fits in the same 17 blocks, with no cylinders involved and the index header left right where it was. Every allocator, ACTIVATE and VALIDATE had to change. The allocators are tiny overlays that can only use the memory the 7.2 ones did, so three of them ended up split in two to make room.
An LU table of block addresses. 256 entries of 8 bytes, in four blocks of LU 10 that 7.2 never touches:
+0 flags: $ff = no such LU; bit 7 CP/M, 6-5 SCSI LUN, 4-2 SCSI ID,
bit 1 DOS image on this LU
+1-4 first block on the drive, low byte first
+5-6 size in blocks, at most 65,535
+7 0
The resident DOS doesn't have room for 2 KB of table, so it keeps a two-entry cache where 7.2's table used to be. It reads an entry off the disk on a miss, and it keeps two so a COPY between two LUs doesn't thrash.
A hybrid driver. The block address is just a 32-bit add now, start plus block. Below 2^21 it still sends READ(6), which keeps drives behind the old SASI bridges working in their first gigabyte. Above that it sends READ(10):
READ(6) 08 LUN|addr(20-16) addr(15-8) addr(7-0) count 00
READ(10) 28 LUN<<5 addr(31-24) addr(23-16) addr(15-8) addr(7-0) 00 00 count 00
LU numbers as a byte. In 7.2 the LU is the low nibble of a user/LU byte just about everywhere it's stored: file headers, index entries, open file tables, variables. Changing that touched about 60 of the hundred-odd modules. The lucky break was two bytes that 7.2 marks "reserved for future use" and never writes, one in the file header (+$1f) and one in the index entry (+$1b), so the LU byte fit without moving anything. LUs past 99 get three digits everywhere they're printed, so QUERY, TYPE, ERA, OOPS and BUILD show a file on LU 200 as 200:00:name.
No serial lock. All the serial checks from the copy protection are gone. DOS 8's setup and boot don't compare serial numbers anymore, and an 8.1 boot ROM drops the ROM's own check, so a 7.2 drive boots on any adapter and can get upgraded there. The stock ROM still works too: setup grabs the ROM's serial from the boot stub it leaves in memory after a failed boot, and writes that to the drive.
An upgrade path. SYSGEN over a 7.2 drive keeps the LUs where they are and converts the table to start blocks and sizes. Then VALIDATE rebuilds each LU's bitmap in the new format and fills in the new LU byte on every file. An 8 GB drive comes out to about 238 LUs of 32 MB, and CONFIGLU has a "fill the drive" command that lays them out end to end.
Rebuilding the DOS from source also turned up bugs in 7.2 itself, and DOS 8 fixes the ones it can test. A few of the better ones:
- OOPS on a scratched file of more than 128 blocks gave it back with the wrong contents, and past 240 blocks the wrong size too. It copied the file to new blocks with an 8-bit index, and the new blocks could be the old ones, overwritten before they got read. DOS 8 just takes the file's own blocks back.
- AUTOCOPY and AUTOMOVE, replacing a file of 256 blocks or more, lost the high byte of its block count and freed the wrong blocks, the LU's bitmap among them, before locking up.
- Writing to a file on a full LU locked the machine up. DOS 8 hands back
72,disk full, the way a 1541 does. - A SAVE that ran out of room left the blocks it had found marked in use, so they were gone until the next VALIDATE.
Testing
All of this runs in VICE, which has emulated the Lt. Kernal for a while now. Stock VICE caps an LTK drive image at 320 MB, so my build sizes the image from the file instead. One script runs the whole suite: check.sh first, then a list of scenarios on both 7.2 and DOS 8. Each one's scripted keystroke by keystroke, checks the screen, and then reads the drive image afterward to compare every LU's bitmap against its files.
$ ./test.sh --list
boot SYSGEN, boot, DOS checksum; ACTIVATE of LUs 0-2
big a 640-page SEQ file: appends past 240 blocks (expnrand, apndexrn)
oops OOPS of the scratched big file (7.2 bug: wrong size and contents,
recorded; DOS 8 takes the file's own blocks back: contents and
counts exact)
fill fill LU 2 with SAVEs until full (7.2 bug: the failing SAVE leaks
its blocks; DOS 8 must not), scratch all, VALIDATE: counts come back
upgrade DOS 8 only: upgrade a 7.2 system with files
twodrive DOS 8 only: two SCSI drives; LUs 254 and 253 on ID 1 ...
large DOS 8 only: an 8 GB drive filled by CONFIGLU; ACTIVATE, SAVE,
files, COPY and VALIDATE on LU 200 and on the last LU (past 1 GB,
READ(10)) ...
...
Wherever a 7.2 bug shows up in VICE, there's a scenario that 7.2 fails and DOS 8 passes, so the fix is proven and not just assumed. Relative files and keyed index files got their own tests. They run 400 records through two keys, grow a relative file past 240 blocks in one write, and open both from another LU.
What VICE can't prove is real hardware, so that's up next:
- The test disk. The relative-file, keyed-file and OOPS tests are also BASIC programs on a floppy image,
ltktest.d64. Each one ends withRELTEST PASSor a failure line that names the step and the numbers it saw. They go on the real rig first, against a SCSI2SD or BlueSCSI card I can image before and after. - The 8.1 EPROM. Burn it to a 27C64 and boot drives from another adapter with it.
- FASTCOPY with a 1571 and a 1581. The 1541 path is tested in VICE. The other two drives aren't, and FASTCOPY's got its own 7.2 bugs still to fix.
- C128 mode, CP/M and the multiplexer. These assemble but haven't been tested, because VICE needs a C128 Kernal I don't have here, so they come last.
- A release document. Drive layout, setting up a new drive, migration, and release notes.
After that comes the big one: an SD card in place of the SCSI drive, on a new host adapter board. That's on hold until boards can get built in January.