Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 11, NO. 6 / JUNE 1985 / PAGE 100

SwapDos: a program to lesson aggravation and waiting time. (Outpost: Atari) David Small; Sandy Small.

SwapDOS: A Program to Lessen Aggravation and Waiting Time

The Atari has a program called the Disk Operating System which you load from disk any time you start up from disk. The Dist Operating System handles everything that has to do with the disk drive. If you switch on the machine without a disk drive attached, you won't load the DOS, which means that until you turn the power off, you can't do anything with a disk drive. You can't, for instance, SAVE a Basic program to disk.

Nearly everyone I know has been caught by this once or twice--you turn the Atari on, then the disk drive. The Atari upon awakening concludes that there is no disk drive attached, so no DOS is loaded. You type in a long program, type SAVE, and the Atari doesn't know what to do.

If you get into this fix, you might try saving the program to cassette, if you have a cassette drive. Otherwise, you're out of luck; print a copy of the program, restart the machine, and type it back in.

DOS is a computer program like any other, made out of bytes, and stored on disk in the file DOS.SYS.

(How can the Atari load DOS.SYS when it doesn't know how to deal with disk drive until DOS.SYS is loaded? Good question; are you considering computer science for a career? Anyway, the Atari has the ability to do one thing with a disk drive when it turns on. That one thing is loading DOS.SYS.)

If a disk does not have the DOS.SYS file on it, you will see repeated BOOT ERROR messages on the screen; the Atari is trying to tell you that it wants to bring DOS in so it can deal with disk drives, but it can't, since DOS is not on your disk. The solution is to insert a disk with DOS.SYS on it. (Also, the DOS.SYS file might be scrozzled.)

DOS loads into "low' computer memory and stays there as long as the Atari is on. Your Basic program, and everything else, stays above DOS (see Figure 1). If you don't load DOS, you have more room for Basic (see Figure 2).

Next, let's assume you type DOS from Basic. What happens? DOS loads the Disk Utility Package, a collection of programs to deal with disks. You have seen the Utility Package many times; it enables you to format disks, look at disk directories, and the like. Its title is the DOS Menu.

This menu package is stored on disk in a file called DUP.SYS (short for Disk Utility Package). When you type DOS, the DOS program loads DUP into memory right above DOS, and you get the menu (see Figure 3).

The reason I have stressed the difference between DOS, the program that is in memory all the time, that handles all disk requests, and DUP, the program that is there only when you are working with the DOS menu, is that you type DOS to get to the DUP menu. Confusing, right?

Now, what if you had a Basic program stored where the DUP package loaded in? It will disappear; the DUP package writes over it in memory. This means that you can never get to the DOS menu without clobbering whatever you are working on.

The designers of the Atari have a solution: something called MEN.SAV. You create MEM.SAV with option N from the DOS menu. If you have MEM.SAV, when you type DOS, the area that the DUP package will load into is first saved to disk, saving the Basic program (or whatever) that is in that section of memory. Next, DUP is brought in, and you do whatever you want with the menu. When you exit DUP, the old memory region is read back in from disk and restored to its original state. The upshot is that you haven't lost your Basic program by going to the DOS menu.

Of course, there is a tradeoff: all this disk access really slows down access to the DOS menu. If you should get tired of this, just delete the MEM.SAV file and things will return to normal.

At this point I have a confession to make: I really dislike typing DOS. Why? It takes so long to get to the darn DOS menu, and I have done it thousands of times. Furthermore, I don't like losing whatever I was doing to get to a DOS menu, either. MEM.SAV takes so long that I can shave while it is beating on the disk (I tried it).

SwapDOS

Speed, speed, speed. We computer types are obsessed with it. Otherwise why bother with a computer? However, it is not a vain obsession; time is money for people, and saving ten seconds for thousands of times really adds up. Hence, SwapDOS.

SwapDOS is a modification to the standard Atari DOS 2.0S and the Atari 800XL.

SwapDOS does two things for you: it allows you to get in and out of the DOS menu instantly, and it preserves anything you are working on when you go to the DOS menu.

By the way, other DOSes can be modified with the principles within, but don't expect SwapDOS to work with them as printed. I have commented the assembly source code listing (Listing 1) as much as possible to make it easier for you.

The key to SwapDOS is the design of the newer XL. There is 16K of RAM in these XLs that is generally not available to the user, although Atari never had any qualms about advertising it. It lies "under' the operating system area; you can select either the operating system or RAM to be in that memory region, by writing a 1 or 0 (respectively) to the lowest bit of PORTB, the old joystick port.

To use SwapDOS on the XL, type in the Basic program (Listing 2). This will generate an assembly language program called SWAPDOS.OBJ. Go to the DOS menu. Use option L (Binary Load), and load "SWAPDOS.OBJ'; then return to Basic.

Now, the system is ready. Type DOS. You'll be in the DOS menu in half a second. And when you exit DOS, you'll not have lost anythign you were working on.

Needless to say, this is a but of a change from the old DOS. You know, waiting forever for the DOS menu to load up. The combination of saving time and preserving my work makes this program very useful for me.

SwapDOS is meant for the XL machines; if you have an older Atari, you can see what all the fuss is about by using the alternate SwapDOS listing (Listing 3). There are limitations on the older machines, however; I use memory from $8000-$9400 for the swap, so if you have a Basic (or other program much longer than 24K, or use graphics modes other than 0, it won't fly.

How it Works

On to the details of how this works.

The problem, you recall, was when you typed DOS, a large program had to be brought into memory (DUP.SYS) where it overlaid whatever was in memory locations hex $17D7-$3305.

Instead, let's do things a different way. When we load SwapDOS, it makes a copy of DUP.SYS in memory and places it up under the operating system in alternate RAM memory. This does not occupy any memory you are used to using (e.g., FRE(0)). This RAM memory is difficult to use because the operating system is used so much; the operating system program must stay available in memory except under special circumstances. For instance, no interrupts can be processed when the operating system is switched out, and the character set goes away (see Figure 4).

Next, we make some selective patches to the DOS.SYS program in memory. First, we tell it that there is a MEM.SAV file active. Next, whenever it handles a DOS request, it interchanges the memory up under the operating system ($E000-F500) with Utility Menu memory ($17D7-$3305). This does two things. First, whatever you were working on is saved up under the operating system. Second, the DOS utility menu is loaded nearly instantly, because the 6502 processor in the Atari is so fast.

When you exit DOS, the two are again interchanged, which brings your program back and saves the DOS menu where it can be re-used.

If you haven't done much with the Atari, this may not seem too useful. However, if you are an old hand at waiting for DOS, this program might just make your day.

Some modifications that might be a good idea:

AUTORUN.SYS)
files.

Right now, if you write the DOS files and try to use them, after you have patched them, you won't be able to get to DOS (because nothing will have put the DOS menu up under the operating system). Perhaps a check if the files are already loaded would be in order.

Table: Listing 1.

Table: Listing 2

Table: Listing 3.

Photo: Figure 1.

Photo: Figure 2.

Photo: Figure 3.

Photo: Figure 4.