PAGE SEVEN, EIGHT, NINE...

If you're not using a disk drive, then location 1792 is the beginning of free memory. If you're using BASIC, "free memory" doesn't mean memory for you to use; it means memory for BASIC to use. There's a difference between the two, and you should go back to locations 128 through 145 if you don't know what it is.

If you are using a disk drive, then the locations from 1792 to the address stored in MEMLO (743,744) are used by DOS and the File Management System (FMS). The value of MEMLO will depend on the version of DOS that you're using, and also on a couple of other things that will be mentioned next. Use PRINT PEEK (743) +PEEK(744)*256 to find out the value for your particular setup.

This book is designed to teach you about your Atari and not about DOS, so I'm not going to go into any detail about how it works or what the memory locations are for. If you're interested in DOS, take a look at COMPUTE's book Inside Atari DOS. I will, however, mention a few useful locations, and give you an idea of how DOS is arranged in memory. This information applies to DOS 2.0S only.

FMS

FMS, or the File Management System, takes up locations 1792 through 5439. What's an FMS? The FMS is essentially the disk handler. The OS does have a disk handler built in, but it doesn't work the same way as the other handlers (see the OS manual for more details) and under normal circumstances is only used to load in FMS. That means that the disk entry in HATABS (794 through 831) points to the handler information pertaining to FMS.

Page seven (1792 to 2047) is also called the "user boot area" for some reason. "User boot area" implies that this area is free for loading boot files into, which is true. Everything after page seven is also free though, so technically it should also be considered as part of the user boot area. It's only a name though, so do with it what you will.

There is a small bug in the FMS that can cause problems when a file has been OPENed for update (updating adds information to the end of a file rather than erasing it and starting over again). To get rid of it, run the following program and then re-save DOS using menu selection "H":

100 FOR LOC=2592 TO 2599
110 READ DAT
120 POKE LOC,DAT
130 NEXT LOC
140 POKE 2625,16
150 POKE 2773,31
160 DATA 130,19,73,12,240,36,106,234

gofer



SABYTE
1801         0709

In case you didn't know already, DOS limits the number of files you can have OPEN at one time to three. Since you have a total of seven free IOCBs though, there is nothing wrong with having all seven open at one time (other than the fact that DOS tells you you can't). SABYTE lets you change DOS's mind. If you POKE it with some number from one to seven, then that becomes the number of files you can have open at once. You do pay a price, however. For each file that you allow to be open (whether it actually is open or not), a 128-byte data buffer is reserved. So don't make SABYTE larger than you need.

Oh, DOS will only remember this change as long as the computer is turned on. If you want a special version of DOS that always remembers, change SABYTE and then re-save DOS using menu selection "H".

DRVBYT
1802         070A

DOS originally expects to see no more than two disk drives. This can also be changed using DRVBYT as in Figure 28.

 0000---1 means that drive one is available.
 0000--1- means that drive two is available.
 0000-1-- means that drive three is available.
 00001--- means that drive four is available.

            FIGURE 28. DRVBYT bit chart

Notice that a value of three in DRVBYTE does not mean that DOS can handle three drives. The binary representation of three is 00000011, which means that drives one and two are available.

Each available drive also has a 128-byte buffer reserved for it, so don't waste memory by telling DOS you have more drives than you really do (if you only have one drive, you can save 128 bytes by setting DRVBYT to one).

Once you've changed DRVBYT, you can make your change a permanent part of DOS by re-saving DOS using menu selection "H", just like you did for SABYTE.

VERFLG
1913         0779

Actually, this location doesn't have a name so I made one up. In any case, this is the "write verify flag." What is "write verify"? When you save something to disk, DOS first writes the data onto the disk and then reads it back to verify that it was written correctly. This takes time, and the disk very seldom makes an error (very, very seldom). So, if you want to turn the verify off, POKE VERFLG with an 80. To turn it back on again, POKE VERFLG with an 87.

I personally have never had a problem writing without verify. There is, however, a slight chance that the data will not be saved correctly, and if this happens, your program probably won't work. Therefore, you may want to have the verify on when you're saving important programs.

As in the last two locations, menu selection "H" will create a version of DOS that includes your change to VERFLG.

DSKFLE
3118         0C2E

More than once I have ended up with two files on a disk with the same name. If you tell DOS to erase one of the files, both will be done. By changing the normal value here to a zero, DOS will only erase the first file.

WLDCRD
3783         0EC7

Look at your DOS manual and find out what a wildcard is. The wildcard that comes with DOS is the asterisk ("*"). If you want to change it to something else, this is where its ATASCII value is stored.

Again, re-save DOS if you want the change to be permanent.

CHRLO, CHRHI
3818,3822        0EEA,0EEE

DOS only lets you use uppercase letters and numbers in your filenames. This too can be changed. CHRLO and CHRHI define the range of ATASCII characters that can appear in a filename. They are originally set to 65 ("A") and 91 ("["). CHRHI, as you can see, actually holds the ATASCII value of the character after the last allowable one. The number appear to be taken care of elsewhere and are automatically included in the list of allowable characters.

A few warnings if you decide to change CHRLO and CHRHI. First of all, don't define a space or a period as an allowable character. If you do, you may not be able to load your file back in again. Also, if you include the asterisk as an allowable character, don't forget to change WLDCRD.

To specify uppercase, lowercase, and numbers as allowable characters, set CHRLO to 48 and CHRHI to 123. No guarantees are made if you make CHRHI any larger than this.

Don't forget to re-save DOS so it includes your changes.

Noname
4148,4149         1034,1035

Another problem with DOS is error message #164, which means your data is messed up on the disk. It's fine if you have really goofed up your file, but what if it has only a few problems. Perhaps a few numbers are unreadable. You would like to be able to load these in and fix them on the screen. NO WAY usually. Try POKEing 234 into location 4148 and 234 into 4149 also. These are NOP (no operation) instructions in machine language. Now you will never get error #164. For that reason I don't suggest using this permanently, but rather only when you need it.

Noname
4226 & 4229            1082, 1085

Disk directory sector number. Here is a nice trick discovered by Cordon Banks, a dedicated ATARI nut like those of us here. Did you ever want to have two disk directories? Of course not, but think about it for a moment. A second directory could be used to protect certain files on a disk from being there when others look at the disk. You might have a second set of programs become available to a program after a certain point in the game or drill was passed.

What you do is treat these two locations as the low byte and high byte of the number of the sector that the directory should start on. Normally this is 361, which means 4226 holds 105 and 4229 holds 1 (105+1*256=361). If you wanted to have your directory start at sector 700, POKE in 188 and 2. Now the only problem is how to get the directory to 700. Simply do the POKES before you save the files to the disk. Then POKE the normal values back in before writing DOS to the disk.

DOS

Remember that FMS is just a handler, which means it can only do a limited number of things to the disk. DOS takes care of the more complicated tasks and tells FMS what it can do to help get these tasks done. A large part of DOS, called the Disk Utilities Package (DUP), stays out of memory until you call DOS. The rest can be found in locations 5440 through 6779. This part of DOS, called "mini-DOS," is mainly used to load in DUP from the disk and take care of the MEM. SAV file (see your DOS manual) if necessary.

DOSLO, DOSHI
5446,5460         1546,154A

These two locations hold the address that BASIC will jump to when you call DOS. They initially hold the same value as DOSVEC (10, 11).

BUFFERS

Following the resident part of DOS are the buffers. There are two drive buffers and three data buffers, unless you specify otherwise by changing SABYTE (1801) and/or DRVBYT (1802). The buffers start at 6781 ($IA7D) and, since each buffer takes up 128 bytes, and at 7420 ($1CFC) unless you've made the changes described. This means that MEMLO (743,744) normally points to 7420 if you're using disk.

DISK UTILITIES PACKAGE (DUP)

You call DOS from BASIC and "whirrr... beep... beep..." from the disk drive, right? So what's loading in? All the routines that are needed to perform the menu selections that appear on the screen. These routines, along with the menu itself and various buffers and the like, load into locations 7548 through 13062 ($ID7C through $3306). Look at the DOS listing if you need more information about the routines. By the way, if you go to BASIC from DUP and haven't loaded or created a BASIC program that is large enough to wipe out any of the DUP file, you can go to DUP by typing

X=USR (8309)

instead of typing DOS. This saves all the time of loading in DUP again.

FREE RAM

The memory area from the address pointed to by MEMLO (743,744) up to that pointed to by RAMTOP (106) is free RAM. That doesn't mean you didn't pay for it; it means that it is unused. If you are using BASIC, then your program uses the memory from the address pointed to by MEMLO up to the address pointed to by MEMTOP (144,145).

RAM ROM



As mentioned already, the value of MEMLO will depend on whether or not you are using disk (and the RS-232 handler, which takes up another 1728 bytes). The value in RAMTOP depends on how much total memory you have. The various values it can have are listed in Figure 29. Don't forget that the value in RAMTOP is the high byte of the address (the number of pages).

 MEMORY    RAMTOP BYTES
  8K
32
  8192
16K
64
16384
24K
96
24576
32K
128
32768
40K
160
40960*
48K
192
49152*

            FIGURE 29. RAMTOP chart

*These values depend on whether or not any cartridges are in place. See the sections on cartridges.


PROTO



CARTRIDGE B (RIGHT CARTRIDGE)

The cartridges are a strange breed. They contain their own 8K of ROM, yet they feel the need to shove 8K of RAM out of the way in order to run. The right cartridge gives notice to locations 32768 through 40959 ($8000 through $9FFF). This means that if you have 40K of RAM or more, you'll lose 8K of it. Note that since the 800 is the only Atari that has a right cartridge slot, few companies have cartridges for the right slot.

If a right cartridge is present, TSTDAT at location seven gets set to one during powerup.

CARTRIDGE A (LEFT CARTRIDGE)

OK, all Atari computers have a left cartridge slot. Since it may be the only slot, it makes more sense to refer to it as cartridge A.

Cartridge A takes up memory locations 40960 through 49151 ($A000 through $BFFF). This will only affect you if you have 48K of RAM, since these locations are the last 8K.

The last six bytes in a cartridge provide the information that the OS needs in order to run the cartridge. Thus:

49146,49147 ($BFFA, $BFFB) holds the starting (run) address of the cartridge.

49148 ($BFFC) equals zero if a cartridge is plugged in, and doesn't if one isn't.

49149 ($BFFD) tells the OS how to get the cartridge going. If bit zero is set, then the OS boots the disk before it runs the cartridge. If bit two is set, then the cartridge is initialized but not run (if it's not set then it gets run).

49150,49151 ($BFFE,$BFFF) holds the initialization address of the cartridge.

Note that these addresses are all for cartridge A. For cartridge B, just subtract 8192 from each address.

If cartridge A is present, TRAMSZ at location six gets set to one during powerup.

If you're using BASIC, then the BASIC cartridge is cartridge A. Because this book is designed to teach you about your Atari, and not about the languages that can be used with it, I'm not going to give you a detailed listing of all the locations in the BASIC cartridge. Don't feel as though you're missing out on something great, however; there's very little in there that would be useful to you. The OS listing does mention four routines, however, so I will mention those.

SIN
48551         BDA7

This routine calculates the sine of the number in floating point register zero (FR0). You should take a look at FR0 (212 to 217) and RADFLG (251) if you're going to try to use it. It might also help to disassemble the code for the routine to get an idea of what's going on.

COS
48561         BDB1

This routine calculates the cosine of FR0.

ATAN
48759         BE77

The arctangent of FR0.

SQR
48869         BEE5

And lastly, the square root of FR0. Note that the carry is significant in all of these operations, in that it will be set if an error occurs during the operation.


Return to Table of Contents | Previous Chapter | Next Chapter