Classic Computer Magazine Archive START VOL. 5 NO. 7 / APRIL/MAY 1991





Your Atari XL/XE has some hidden memory - and this machine-language program takes advantage of it to give your 800XL or 65XE the added convenience of a RAMdisk. This BASIC type-in program creates the machine language RAMdisk program and modifies DOS for you; it requires an 800XL or 65XE computer and Atari DOS 2.5.

Atari 8-hit owners have been using RAMdisks more extensively ever since the advent of the 130XE, and the RAMdisk provided for it with Atari DOS 2.5. 1 don't have a 130XE, but third-party firms have offered RAMdisk upgrades for all versions of the 8-bit Atari, up to 320K. However, Since I operate on a shoestring budget, such an upgrade was out of the Picture for me.

One day, as I was flipping through Ian Chadwick's book, Mapping the Atari, something in Appendix 12 caught my eye: the 800XL, 65XE and 130XE computers all have 24K of extra memory that has the same memory addresses as BASIC and the operating system. Of this RAM 2K is occupied by the GTIA, POKEY, PIA and ANTIC chips, but that still left 22K of RAM that could be used for a 176-sector RAMdisk.

This memory is normally inaccessible - to use it, the operating system must be shut off. (The computer would crash if you simply POKEd register $D301, the memory control, to turn on the extended RAM.) However, with a bit of assembly-language programming, I was able to modify DOS and set up a small but useful RAMdisk for users of the Atari 800XL and 65 XE.

Getting Started
Make sure you have a freshly formatted disk with Atari DOS 2.5 on it. Ideally, you want a disk with only the DOS.SYS and DUP.SYS files on it. Do not use your master DOS 2.5 disk - the RAMdisk program modifies DOS and saves the modified version on the disk, and you will not be able to recover the old version if anything goes wrong.

Type in Listing 1, RAMDISK.BAS, check it with TYPO II, and be sure to save a copy to disk before you RUN it. Also, put your fresh disk in Drive 1 just before you RUN the program. When you RUN the program, it will give you a prompt to make sure you want to continue. Press [RETURN] and the program will create the RAMDISK.COM file and save it on your disk. The program also POKEs in all the patches necessary to change DOS, and saves the modified DOS.SYS file on the disk.

Once the new files are on your disk, turn your computer off, put the disk with the modified DOS in drive I, and turn the computer on again. A line onscreen notifies you that it is "Initializing D8: for 800XL/ 65XE." Then the BASIC prompt appears, and you're ready to go as usual - except that you now have a new drive D8:, your RAMdisk.

This RAMdisk is designed specifically for the 800XL or 65 XE. to take advantage of that extra, unused memory. The RAMdisk Handler works on 130XE computers, but you would be better off using the larger RAMdisk that comes standard with DOS 2.5. The program might also work on a 1200XL, but this has not been tested. If you boot an Atari 400 or 800 with this disk, the program will not try to initialize the RAMdisk.

Using Your RAMdisk
Among other benefits, a RAMdisk makes getting to DOS from BASIC quicker and easier than ever. When the program formats the RAMdisk, it also copies DUP.SYS onto it. By changing the value in memory location $153F to $38, the program tells the computer to load DUP.SYS from the RAMdisk. Now, whenever you go to DOS from BASIC (just type DOS on an empty line below the READY prompt, and press [RETURN]) the DOS menu appears almost instantaneously - no more long waits for DOS to load from disk. If you use DOS option A to get a directory of D8:, you will See that the RAMdisk has one file, DUP.SYS, and 125 free sectors left over.

To boot with the RAMdisk and an external cartridge in place, you must hold down [HELP] when you turn the computer on. The resulting RAMdisk will have only 103 free sectors, but won't interfere with the cartridge, as the larger RAMdisk would, To use the RAMdisk with programs that normally require you to turn the computer on while holding down [OPTION], you should now hold down both [OPTION] and [HELP]. Hold down both [CONTROL] and [HELP] while booting to disable the RAMdisk.

You can use your RAMdisk much like a regular disk drive, so much so they are sometimes called "virtual" drives. To save or load files from the RAMdisk, just be sure to use D8: as your drive designation. For example, when your word processor asks for a filename, use D8:MYFILE.TXT to save your file to the RAMdisk. Because the RAMdisk is actually part of the computer's memory, files load and save with amazing speed -but if you turn the computer off, you will lose any files on the RAMdisk.

A RAMdisk makes getting to
DOS from BASIC quicker and
easier than ever.

If you have only one disk drive, having a RAMdisk can make copying files much easier. Just use DOS option C to copy them to the RAMdisk (D8:), then switch disks and copy the files to your new disk. Just keep in mind that you only have 167 sectors to work with, and that your RAMdisk is not a permanent form of storage. If you want to keep your files, make sure you have copies on floppy before you power down.

Special Notes
The RAMdisk is not infallible, unfortunately, and files you want to keep should always be saved on floppies, just in case. Also, you will notice that the screen flashes wildly whenever you access the RAMdisk. This is normal, and nothing to worry about but on rare occasions the machine may crash while trying to access a file, leaving the screen stuck in a crazy character set. If this happens, press [RESET]. If you were reading a file, try reading it again. If you were writing a file to the RAMdisk when the crash occurred, consider it lost, and don't try to do anything with it, or you re likely to crash even more permanently. Copy any other files you want to save to floppy, and reformat the RAMdisk.

Products Mentioned

Mapping the Atari $16.95
COMPUTE! Publications
825 Seventh Ave
New York, NY 10019

With the 130XE RAMdisk, DOS 2.5 expects a file called MEM.SAV to be in the RAMdisk if DUP.SYS is loaded from the RAMdisk. (The MEM.SAV file saves the part of memory occupied by BASIC programs, so they Won't be wiped out when you load DUP.SYS.) Because of possible problems concerning MEM.SAV, not to mention the amount of space the file takes up, the MEM.SAV routines have been completely disabled by the XL/ XE RAMdisk Handler. Infrequently, you may get a warning that a DOS operation may invalidate a MEM.SAV file (which doesn't exist), and you should simply type [Y] at the prompt. If you want the MEM.SAV file on your RAMdisk, eliminate lines 240-350 from the BASIC program in Listing 1, and RUN the program as directed above. Now you can use DOS option N to put the MEM.SAV file on your RAMdisk.

How it Works
The extended RAM is in the 24K block, addresses A000-$FFFF. FFFF. The 2K area from $D000-$D7ff is occupied by the GTIA, POKEY, PIA and ANTIC chips, and has no auxillary RAM substitute, leaving 22K of extended RAM. Memory location $D301 controls which block of memory are active. Bit 0 of $D301 controls the operating system, $C000-$FFFF, not including the 2K of chips. When bit 0 is set to one, the normal ROM OS is present, but when the bit is reset, the auxiliary RAM is "bank switched" in place of the operating system. Bit 1 controls the BASIC cartridge, $A000-$BFFF. When the bit is reset to zero, BASIC is active. When bit 1 is set to 1, BASIC is shut off.

For the 130XE RAMdisk. DOS 2.5 has a general sector read and write routine at address $076C. Part of this routine checks for D8:, the RAMdisk. If D8: has been specified, then the routine branches from $0784 to $1481, the RAMdisk sector read and write routine. The RAMdisk routine at $1481 generates a memory address between $4000 and $7080 based on the sector number, and determines which of the four 16K RAM banks the sector will occupy. The routine transfers the $80 bytes of data and returns.

To get DOS 2.5 to create my 22K RAMdisk, I wrote a machine-language program similar to the one at $1481. However, the routine was a few bytes too long, and didn't fit at $1481. So, I assembled the routine into the cassette buffer, at $03FD-$047F, instead. (This naturally caused problems with using cartridges, as discussed below.) I also changed the "JSR $1481" (Jump to SubRoutine at position $1481) at $0764 to "JSR $03FD" so the new routine would be accessed.

The routine checks to see if a directory sector (360-368) has been passed to the routine, and if one has, then the sector is lowered to the 171-179 range so the directory will fit in the 22K of extended RAM. The routine also ignores sectors 0 through 3 because sector 0 is nonexistent on a floppy drive, and 1 through 3 are used only for boot information. Since you won't be booting from the RAMdisk, those four are given no space on the RAMdisk, When encountered, these sectors cause the routine to simply return to the main body of DOS without doing anything.

If a sector falls in the range from 4 through 179 the routine subtracts four from the sector number. (This is a strictly local change - the sector number passed to the routine is still intact at the exit.) Then a memory address is generated based on the modified sector number. The interrupts are turned off at $D40E, auxiliary memory is called up, and $80 bytes are transferred. The ROM is bank-switched back in, and the interrupts are restarted.

Initializing the RAMdisk
Because of the odd configuration of the RAMdisk, the DOS 2.5 disk-formatting commands weren't easily modified to format the RAMdisk on the 800XL and 65XE. I wrote my own routine at $1481, the old 130XE RAMdisk sector read and write routine. The new formatting routine is too long to fit entirely at $1481, and so continues at $12CB, where the old bank-switching routine was located. At $0B84, I patched in a call to $1481. At $1481, the overwritten code from $0B84 is replaced, and then the routine checks to see if D8: is being accessed. If a floppy is being formatted, control is passed hack to the normal format routine. If the RAMdisk is being formatted, the routine zeroes out the buffer and creates a bitmap for sectors 4-170 (167 free sectors). The routine writes this bitmap, and eight zeroed sectors for the directory.

In its usual mode, the RAMdisk has 167 free sectors and can be formatted using DOS option I. In this mode, however, it uses memory addresses $A000-$BFFF as its first 64 sectors. These addresses are also used when you boot with an external cartridge, or if you boot without BASIC. (If you boot holding down [OPTION], the OS shuts BASIC off and puts the display lists in this auxillary RAM block.) To avoid the inevitable conflict over memory, the second RAMdisk mode makes it impossible to access the first 64 sectors, leaving 103 free sectors. As mentioned above, just hold down [HELP] while booting to get the 103-sector RAMdisk. In this mode, the RAMdisk can be formatted by DOS option P.

Listing on page 89

Douglas Hunt is a student at Hopewell Valley Central High School, in Pennington, NJ.