'Proper' Compact (C) John Robinson 1989 This program does what *COMPACT doesn't do - it moves ALL the free space on an ADFS disc to the end of the disc. This may seem rather obvious, but when using the normal *COMPACT command, the free space is not always completely collected together - it just does exactly what the manual says it does though; free space tends to migrate towards higher disc addresses. Apart from being a nuisance, I find it absolutely infuriating (having been used to the DFS' *COMPACT command)! Other programs have been written to do this by copying everything to another disc, but this wastes discs, is obviously useless with a hard disc, and is a terrible slog for users with only a single drive. People have suggested repeatedly using *COMPACT until there's only one space left, but this takes an excruciatingly long time. To run the program, first do everything you can to get more memory - turn off ROMs which push page up (not the ADFS!); put shadow RAM on; or, on a 6502 second processor or Master Turbo CoPro, start up HiBasic. The extra memory is advisable so that you have a larger data buffer while the data is being moved around the disc. This will make the process slightly faster. Then just type CHAIN "Compactor" When the program loads, you will be presented with the message Drive? when you should insert the disc you want compacted, and give its drive number. Then leave the computer alone until you get the ALL FINISHED message. During the first stage of the program, when directories' information is changed, you have no idea of how much of this process has been done. However, it should not take very long; most discs don't have a lot of directories on them. The time taken is roughly proportional to the number of files and directories on the disc. The second stage is the slowest one; here the data is actually moved around on the disc. This is where the extra buffer comes in useful: it is used so that fewer disc accesses have to be made (although the same amount is read in all, the drive has to be prepared each time you access it - this slows everything down), allowing the program to work more quickly. A percentage count of how much of the disc has been completed is displayed; this is calculated from the amount of data which is in the right place divided by the total amount of data on the disc. The last stage is a relatively fast one: the new free space map (with only one entry) is created and written to the disc. However, strangely enough, this is the stage that took the longest to write. Most of that time was spent trying to find out the correct method for calculating the checksum. I asked many people, including Acorn, and they didn't know! How's that for customer service? I ended up hacking through the ADFS ROM code, and extracted the following routine (to calculate the first sector's checksum): CLC LDY #&FF TYA ADC &DFF,Y DEY BNE P%-4 A similar routine is used for the second sector's checksum, but with the value &EFF instead of the &DFF. Simple, when you know how! The public should be told... Well, may you have many happy hours compacting away! €RJJohn Robinson. PS. The program "FixFSM" will recover a disc from the dreaded "Bad FS map" error or even a "Disc error 48 at :x/000000". It would be advisable to copy all the files on that disc onto another disc as soon as possible if you ever need to use this program (do NOT just use *BACKUP, instead use something like DIRCOPY - and do it on a double disc drive), because the FSM may be corrupt even though it looks OK and lets the disc work. Maybe someone could write a program to check each sector of a disc to see if it's filled (by directory checking recusively), and make a new FSM out of that? Good luck to you if you try. Please send me a copy if you succeed.