Classic Computer Magazine Archive COMPUTE! ISSUE 23 / APRIL 1982 / PAGE 132

Customizing Apple's COPY Program

Roger B. Chaffee
Menlo Park California

How many times have you used the COPY or COPYA program from the Apple DOS Master Disk? How many times have you had to tell the program that you wanted Slot 6, Drive 1, even though you have only one drive, and it's always in Slot 6, Drive 1? Every time, right?

Well, the nice people at Apple who brought you the COPY programs have made a system that works well, and is also easy to modify. Many programs, like Muffin and the DOS itself, are written in machine language (ML), and are very difficult to modify, or even to examine and understand. The main routines of COPY and COPYA, however, are written in BASIC, and only the nitty-gritty of buffer management and interface with the RWTS routine are done in ML.

Take a look at COPYA, which is written in AppleSoft BASIC, or at COPY if you want to use Integer BASIC. To look at the program, type LOAD COPYA [LOAD COPY] and then LIST. You can also list specific line numbers or ranges. Here's an explanation of some of the program lines. Later, we'll look at how to change them to fit your own system.

(Some of the information in this article depends on which program you are looking at, as in the LOAD commands above. When this is true, the information given is for the COPYA program, and the information for COPY follows it in brackets.)

Line 70 [90]: Load in the ML routines. (There is a hidden CTRL-D in this line, which will disappear if you use the BASIC editor to replace the line.)

Line 90 [120]: CALL 704 to initialize the ML routines. CS gets the current slot number, which is probably six, and location 720 gets the current drive number, either one or two. The values come from the IOB used by the DOS. Lines 100, 110 [130,140]: Set locations 715, 716 to the page numbers of the first and last pages that the ML routines will use for buffer space. They are different for AppleSoft and Integer because the two BASICs use memory and pointers differently.

Line 130 [150]: Call subroutines to ask the user for the slot and drive of the Master ("Original") diskette. MS gets the Master Slot number (zero to seven), and MD gets the Master Drive number (one or two).

Line 132 [160]: Call subroutines to ask the user for the slot and drive of the Slave ('Duplicate') diskette. SS gets the Slave Slot number (one to seven), and SD gets the Slave Drive number (one or two).

Line 165 [190]: Here's where the program stops asking for information, and starts copying the disk. Do not modify anything from here through the END statement in Line 305 [420] unless you are very sure of what you are doing! Before this line, MS and MD must be set to the slot and drive numbers for the Master diskette, and SS and SD must be set to the slot and drive numbers for the Slave diskette.

Line 310 [430]: This subroutine asks for a slot number, and is called for both Master and Slave slots. It also prints information on the screen, so you shouldn't simply replace it by a RETURN statement.

Line 320 [440]: This subroutine asks for a drive number, and is called for both Master and Slave slots. Again, don't just remove it, because it prints as well as asking you for the number.

Line 330 to 340 [450 to 460]: This subroutine gets a one-digit number, from L to H, from the keyboard. If RETURN is pressed, it uses the number already in N.

Line 350 [470]: This subroutine prints "DEFAULT =" and then puts on a flashing cursor.

Line 360 [480] to the end: This subroutine prompts you to change diskettes, if MS = SS and MD = SD. Otherwise, it just returns, with no action.

Okay, so that's how COPY gets it's parameters. But how can you change things so that it works just right for your own Apple system, which has a fixed number of drives in fixed slot locations?

Case 1: One Drive

The first case assumes you have only one drive, which is always in slot 6, drive 1. There is no choice. You always want slot 6, drive 1. The simplest way to make this happen is probably to replace lines 130 and 132 [150 and 160] by the statement but that won't give you the nicely formatted screen to tell you what's happening. Here's a better way: replace the subroutine which gets the input values.

MS = 6 : SS = 6 : MD = 1 : SD = 1
Applesoft: 	330 K= 141
[Integer:	450 REM]

Then when any value is needed, the default will be used. To make it work just right, you also need to go back to line 132 [160] and replace the statement N = 3-MD by the statement N = MD, which will set the slave drive to the same value (1) as the master drive.

Case 2: Two Drives The Easy Way

Suppose you have two drives, and you want the program to decide which gets the master and which gets the slave diskette. Make the same subroutine replacement as before:

Applesoft:	330 K= 141
[Integer:	450 REM]

Now whichever drive you used most recently will be the master, and the other will be the slave.

Case 3: Two Drive The Right Way

Finally, suppose you have two drives, both in the same slot, but you want to be able to choose which one will be the master. This time you can't just remove the subroutine which gets the numbers, because you want the program to ask you for the drive number. Instead, you can stop the program from asking you for the slot numbers:

AppleSoft: Change GOSUB 330 to GOSUB 340 in Line 310.
[Integer: Change GOSUB 450 to GOSUB 460 in Line 430.]

In this last case, to make sure that the slave drive is the "other" one, that is the one you didn't specify for the master, the simplest change is this:

AppleSoft:
Move statement 330 to 331
Insert
330 IF LEFT$(I$, 1) = "D" THEN 340
[Integer:
Move statement 450 to 451
Insert 450 IF I$(l,l) = "D" THEN 460

Leave the rest of the line alone.

Apology And Exhortation

As you read this, it probably sounds more complicated than it really is. If you have done any BASIC programming on your Apple, you already know how to modify programs, and COPY is just another BASIC program. There's no reason that you should stick with a general-purpose program, when it is easy and maybe even instructive to fit the Apple's general program to your specific needs.