Classic Computer Magazine Archive COMPUTE! ISSUE 53 / OCTOBER 1984 / PAGE 136


Single Disk Copying For The Commodore 64

Jim Butterfield, Associate Editor

Copying programs and sequential files can sometimes be difficult. There are backup programs, of course; but they require that you copy the whole disk, and sometimes you just want to copy one or two programs. LOAD and SAVE work for simple BASIC programs, but not for anything complex. Well-equipped users have two disk drives and can use utilities that will transfer from one to the other.

Dual disk units (notably the Commodore 4040) don't quite do the job for Commodore 64 owners. There's a slight format difference between 4040 and 1541 that makes it undesirable to write on a disk formatted on the other unit. Thus, a 4040-copied disk is not well-suited for the 1541 if you wish to write further material to the disk.

"Unicopy" will help to solve these problems. It will take your choice of programs or sequential files from the disk and hold them in memory. When you're finished, or when memory is full, you can then write the files to a new disk or to cassette tape.

Buffering Files

As you scan the input disk, you'll be offered programs and sequential files for copying. You may tap the Y or N key to signal: yes, you want to copy this file; or no, you don't want this one. More on this in a moment.

Before presenting you with the filename, Unicopy looks at the size of the file and the amount of memory space that is left. If the file is too big to fit, the program won't offer it to you; instead, it will signal MORE and quit scanning the directory. That way, you know that there is more on the disk, but it can't be fitted in this time. Unicopy could catch the missing files on a subsequent run. The program will not skip by the big ones to look at smaller files later in the directory, since it might be important to you to keep a group of files in the same order as they were shown on the previous disk.

There's one exception to the big files rule. If the file won't fit into the whole memory buffer area, there's no way to copy it with this program. Unicopy will skip such jumbo files.

How big is the buffer area? It depends on how your Commodore 64 is configured. If it's a "clean" system with no other resident programs, Unicopy will throw out BASIC (temporarily) and use all the memory it can get—about 48K, or the equivalent of 192 disk blocks. On the other hand, a program in residence—monitor, DOS wedge, interface package, or whatever—must not be disturbed; in this case, UNICOPY will become conservative and restrict itself to less than 36K or 144 disk blocks. The exact amount of space will depend on the other program's location and size.

You'll be asked "Any resident programs?" at the start of Unicopy; buffer size will be set accordingly.

One more thing: If you plan to direct the output to cassette tape, Unicopy must insure that no more than 28K or 112 blocks are used. Tape routines forbid writing a program from above address 32766; so Unicopy will trim accordingly. By the way, this solves a subtle problem with cassette tape: Normally, you can never save memory above hex $7FFE; but Unicopy will move the program down and save it successfully from where it is held in lower memory.

Initial Tasks And First Questions

If you're copying to another disk, be sure that the destination disk is formatted before running Unicopy. The disk may already be formatted if you're just adding some new files; but if not, remember to NEW it, since Unicopy won't do the job for you. You may copy files to more than one disk; format them all as necessary.

We've already mentioned ANY RESIDENT PROGRAMS?; answer Y or N.

OUTPUT TO TAPE OR DISK? calls for touching the T or D key.

If you select tape, you'll be asked WRITE END-OF-TAPE MARK? If you respond with N, you'll copy the programs to tape and that's all. If you answer Y, you'll copy the programs to tape and then write a special block called a "tape mark." Here's what the tape mark does: At some later time, if you're searching through this tape for a particular file, the tape mark will stop the search.

Thus, if you don't find the file you want on tape, you won't go running through the whole tape, most of which is blank. An unsuccessful search will terminate early, thanks to the tape mark.

DISK INPUT PATTERN? allows you to use pattern matching. You're prompted with the asterisk; if you want to see everything, just press RETURN. But there are many other combinations. AR* will present only programs that begin with AR, such as: AR, ARCHER, ARM, or ARRRRGH. R?D? will present you with such names as REDS, RIDE, or R2D2, but not RIDDLE. *=P will offer programs only. And PLUTO will offer you only a file called PLUTO.

When you are presented with names from the directory, you may tap Y or N to accept or reject the files for copying. If you know that you want to take or reject a sequence of files, you may hold down the appropriate key. The RETURN key acts to "lock in" the previous key, so that pressing Y, RETURN will accept everything and N, RETURN will reject everything.

The Output

Eventually the questionnaire will stop, and the computer will advise READING FILES. The programs or sequential files will be brought into the buffer area. The programs won't be in their usual place in memory, but that doesn't matter; we just want to copy them, not to run them.

After the files are loaded, the computer will say READY TO WRITE FILES; PRESS ANY KEY. Don't press a key—yet.

If you're writing to cassette tape, place the tape in the drive. If you have time and think it's necessary, fast forward and rewind the tape to even up the tension. Finally, press PLAY and RECORD and touch any key on the keyboard. The tape will start to write: The screen will go blank, of course.

If you're writing to another disk, take the source disk out of the drive and insert the destination disk. (You did make sure that the destination disk was preformatted, didn't you?) Now touch any key on the keyboard. As the files write to the disk, you'll see their names displayed.

If any errors are encountered during input or output, you'll be told about them.

When the copying job is done, you'll be asked ANOTHER OUTPUT? If you want to write to another tape or disk, put it into the drive and press Y for "yes." Otherwise, press N and the job is done.

The Generator

The listing given here is a generator program that will write Unicopy for you. The DATA statements will be checked carefully for accuracy before Unicopy is created for you; you'll be told of any errors.

Type in the program. Take special care with lines 200 to 320; and don't miss the semicolon at the end of line 300. When the program is complete, place a disk into your disk drive (Unicopy will be written onto it) and type RUN.

It will take the generator over a minute to check the accuracy of your DATA statements. If there are any errors, you'll be told about them (the line number will be given) and Unicopy will not be written.

If there are no errors in the DATA statements, Unicopy will be written to disk ready to be loaded and used.

Other Types Of Files

Unicopy does not attempt to copy USR or REL type files, nor does it try to copy "direct" data. This type of job should be done by the programs which use these types of files.