Lost SpartaDOS X Defragmenter Source Recovered and Released
In early February 2025, AtariAge member Pab released the source code of a defragmentation program for SpartaDOS X hard disks. It was a project he had started long ago and had believed lost.
The back story
Pab explains that he once worked briefly with FTe on what was meant to be the next version of SpartaDOS X. His first, and as it turned out only, job was a hard-disk defragmenter. The project and FTe soon ended. He never got the promised NDA or source code, but he had already started on the tool. He later moved to the PC world after his 576K 130XE died.
For years he assumed the code had died with an old hard drive, which had seized up completely. Then, going through old floppies with a newly acquired US Doubler 1050 and an Incognito-equipped 800, he found everything he had written.
How it works
The method is simple:
- Go through every file on the drive and check its sector maps to find fragments.
- Find a contiguous run of free space big enough for the file and move it there.
- Update directory and parent-directory links as needed.
The search for free space can start from the beginning or the end of the drive. The program needs at least four free banks of extended RAM, where it keeps directory and disk information. Pab had converted his assembly routines to FastAssembler format, rewritten the banked-memory code to work with SpartaDOS 4.4+ using code that FJC had sent him years earlier, and written the main program in Action!, about 85% complete. He had wanted a graphical display like old PC defragmenters, but debugging the basic function was hard enough.
Release and reaction
He released all the source for anyone who wants to finish the project, with a clear warning: it is still in development, probably has bugs, and must not be used on disks or partitions you care about. When drac030 noted that the original ATR had no executable to try, Pab compiled one (defrag.xex) with the Public Domain Runtime Library. A /D switch prints detailed debug output, including the addresses of key routines for setting breakpoints in Altirra.
drac030 questioned how much a defragmenter is needed. SpartaDOS allocates new sectors starting after the highest sector already used, and its file system is less sensitive to fragmentation than FAT. He asked for statistics before more effort went into it. Pab agreed it matters little on today's CF and SD drives, and suggested floppies, with their long seek times, would actually benefit most.
Getting it
The SDX Defrag dev.atr source disk and defrag.xex are attached to the thread. Only try it on a copy of a disk image in an emulator.
Credits
- AtariAge — SpartaDOS X Defragmenter — AtariAge forum members
