!pr1
Quick DOS Updating vs MASTER.CREATE........Bob Sander-Cederlof

When DOS was young, Apples tended to have varying amounts of memory under 48K.  Some had 16K, which was the standard purchase at a computer store; others 24K, with one row of 16K and two of 4K; others 32K; and some 48K.  Trying to write a DOS image that would fit all of these memories was quite a task.

Apple introduced the concept of a "master" and a "slave" disk.  Master disks have a generic image of DOS.  The boot process first loads the DOS image as though the machine only has 16K RAM, and then the image is relocated as high as possible in memory.  Slave disks have a frozen image, already relocated for a particular memory size.  The INIT command always creates a slave disk.  In order to make a master disk you either copy and old master using COPYA (or equivalent copy program), or you use the MASTER.CREATE program on the DOS System Master Disk.  (For a while the MASTER.CREATE program was called UPDATE 3.3.)

But now!  But now you will have a difficult time finding an Apple with less than 48K memory.  After all, the chips are only about a dollar apiece, or $8 to $12 for a set of eight.  Who needs master disks anymore?

A lot of people think they do, because MASTER.CREATE is there and the reference manual makes such a big deal about it.  And this causes a problem.  What if I want a master disk with a modified DOS?  MASTER.CREATE always reads the DOS image off the system master disk, and it is unmodified.  Well, you can use a disk zap program on a copy of the system master.

Or, you can forget all about MASTER.CREATE and use my handy- dandy little patch installer.  The program which follows reads the DOS image from the first 3 tracks into memory from $4000 thru $64FF.  Then it installs patches from a table of patches; this part is almost identical to the patch installer published in the April 1983 issue of AAL.  Finally it writes the patched DOS back on the first three tracks.  And it does all this so fast you'll think it never happened.

Once you have coded the patches you want, and have tested them, you can update all your old DOS 3.3 disks almost as fast as you can open and close the drive door.   With slight modifications, you could have it write the patched image on successive disks without re-reading and re-patching each time.

Looking at the program, Lines 1200-1240 do the overall job.  Just below that, lines 1260-1290 give two entry points to a block of code that sets up an IOB for RWTS and then calls RWTS.  The only difference between the two calls is the opcode, either READ or WRITE.  Below that point, there is a backwards loop that counts from track 2, sector 4, back to track 0, sector 0.  Just for fun, I print out the track and sector numbers just before reading or writing each sector.  (If you get tired of the fun, simply delete line 1450, the JSR $F941.)

The DOS image on tracks 0, 1, and 2 is not in exactly the same order as you find it in memory after booting.  Therefore the patcher maps patch addresses to the new locations.  Lines 1060-1080 define the remapping constants.  Addresses which in the running image will be between $B600 and $BFFF will be located from $4000 thru $49FF.  If the original was a master, code which does the relocating part of the boot will be found from $4A00 thru $4BFF.  The code between $9D00 and $B5FF will be found from $4C00 thru $64FF.  The two constants DOS.9D and DOS.B6 are used in figuring the application points of the patches in lines 2110, 2350, and 2540.

For a full explanation of lines 1590-1900, see the April 1983 AAL, pages 24-27.  The patch set up to be installed in lines 2020-2580 is the fast LOAD, BLOAD, RUN, BRUN patch from pages 2-8 of the same issue.
