Classic Computer Magazine Archive ANTIC VOL. 8, NO. 6 / OCTOBER/NOVEMBER 1989

Mapping the Atari Exclusive! (Part 3)

Classic 8-bit reference book returns.

By Ian Chadwick

Antic continues the exclusive serialization of key excerpts from the revised second edition of Ian Chadwick's "Mapping the Atari." Virtually impossible to obtain today, this book has been one of the key reference sources for intermediate and advanced Atari 8-bit programmers since 1983. This exclusive Antic serialization began in the August 1989 issue.

DECIMAL HEX LABEL
112,113 70,71 ROWAC
ROWAC and COLAC (below) are both working accumulators for the control of row and column point plotting and the increment and decrement functions.

 

114,115 72,73 COLAC
Controls column point plotting.

 

116,117 74,75 ENDPT
End point of the line to be drawn. Contains the larger value of either DELTAR or DELTAC (locations 118 and 119, below) to be used in conjunction with ROWAC/COLAC (locations 112 and 114, above) to control the plotting of line points.

 

118 76 DELTAR
Delta row; contains the absolute value of NEWROW (location 96; $60) minus ROWCRS (location 84; $54).

 

119,120 77,78 DELTAC
Delta column; contains the absolute value of NEWCOL (location 97; $61) minus the value in COLCRS (location 85; $55). These delta register values, along with locations 121 and 122 below, are used to define the slope of the line to be drawn.

 

121 79 ROWINC
The row increment or decrement value (plus or minus one).

 

122 7A COLINC
The column increment or decrement value (plus or minus one). ROWINC and COLINC control the direction of the line drawing routine. The values represent the signs derived from the value in NEWROW (location 96; $60) minus the value in ROWCRS (location 84; $54) and the value in NEWCOL (locations 97,98; $61,$62) minus the value in COLCRS (locations 85,86; $55,$56).

 

123 7B SWPFLG
Split-screen cursor control. Equal to 255 ($FF) if the text window RAM and regular RAM are swapped; otherwise, it is equal to zero. In split-screen modes, the graphics cursor data and the text window data are frequently swapped in order to get the values associated with the area being accessed into the OS data base locations 84 to 95 ($54 to $5F).

 

124 7C HOLDCH
A character value is moved here before the control and shift logic are processed for it.

 

125 7D INSDAT
Temporary storage byte used by the display handler for the character under the cursor and end of line detection.

 

126,127 7E,7F COUNTR
Starts out containing the larger value of either DELTAR (location 118; $76) or DELTAC (location 119; $77). This is the number of iterations required to draw a line. As each point on a line is drawn, this value is decremented. When the byte equals zero, the line is complete (drawn).

USER PAGE ZERO RAM

User and/or BASIC page zero RAM begins here. Locations 128 to 145 ($80 to $91) are for BASIC program pointers; 146 to 202 ($92 to $CA) are for miscellaneous BASIC RAM; 203 to 209 ($CB to $D1) are unused by BASIC, and 210 to 255 ($D2 to $FF) are the floating point routine work area.

128,129 80,81 LOMEM
Pointer to BASIC's low memory (at the high end of OS RAM space). The fist 256 bytes of the memory pointed to are the token output buffer, which is used by BASIC to convert BASIC statements into numeric representation (tokens; see locations 136, 137; $88, $89). This value is loaded from MEMLO (locations 743,744; $2E7,2E8) on initialization or the execution of a NEW command (not on RESET!). Remember to update this value when changing MEMLO to reserve space for drivers or buffers.

 

130,131 82,83 VNTP
Beginning address of the variable name table. Variable names are store in the order input into your program, in ATASCII format. You can have up to 128 variable names. These are stored as tokens representing the variable number in the tokenized BAISC program, numbered from 128 to 255 ($80 to $FF).

The table continues to store variable names, even those no longer used in your program and those used in direct mode entry. It is not cleared by SAVEing your program. LOADing a new program replaces the current VNT with the one it retrieves from the file. You must LIST the program to tape or disk to save your program without these unwanted variables from the table. LIST does not SAVE the variable name or variable value tables with your program. It stores the program in ATASCII, not tokenized form, and requires an ENTER command to retrieve it. You would use a NEW statement to clear the VNT in memory once you have LISTed you program.

Each variable name is stored in the order it was entered, not the ATASCII order. With numeric (scalar) variables, the MSB is set on the last character in a name. With string variables, the last character is a " $" with the MSB (BIT 7) set. With array variables, the last character is a "(" with the MSB set.

 

132,133 84,85 VNTD
Pointer to the ending address of the variable name table plus one byte. When fewer than 128 variables are present, it points to a dummy zero byte. When 128 variables are present, this points to the last byte of the last variable name, plus one.

 

134,135 86,87 VVTP
Address for the variable value table. Eight bytes are allocated for each variable in the name table as follows:

 

Byte 1 2 3  4 5  6 7  8
Variable
Scalar 00 var# --six byte BCD constant--
Array;DIMed 65 var# offset first second
unDIMed 64 from DIM + 1 DIM + 1
STARP
String;DIMed 129 var# offset length DIM
unDIMed 128 from
STARP

 

In scalar (undimensioned numeric) variables, bytes three to eight are the FP number; byte three is the exponent; byte four contains the least significant two decimal digits, and byte eight contains the most significant two decimal digits.

In array variables, bytes five and six contain the size plus one of the first dimension of the array (DIM + 1; LSB/MSB), and bytes seven and eight contain the size plus one of the second dimension (the second DIM + 1; LSB/MSB).

In string variables, bytes five and six contain the current length of the variable (LSB/MSB), and bytes seven and eight contain the actual dimension (up to 32767).

 

136,137 88,89 STMTAB
The address of the statement table (which is the beginning of the user's BASIC program), containing all the tokenized lines of code plus the immediate mode lines entered by the user. Line numbers are stored as two-byte integers, and immediate mode lines are given the default value of line 32768 ($8000). The first two bytes of a tokenized line are the line number, and the next is a dummy byte reserved for the byte count (or offset) from the start of this line to the start of the next line.

Following that is another count byte for the start of this line to the start of the next statement. These count values are set only when tokenization for the line and statement are complete.

Tokenization takes place in a 256 byte ($100) buffer that resides at the end of the reserved OS RAM (pointed to by locations 128,129; $80,$81).

 

138,139 8A,8B STMCUR
Current BASIC statement pointer, used to access the tokens being currently processed within a line of the statement table. When BASIC is awaiting input, this pointer is set to the beginning of the immediate mode (line 32768).

 

140,141 8C,8D STARP
The address for the string and array table and a pointer to the end of your BASIC program. Arrays are stored as six-byte binary coded decimal numbers (BCD) while string characters use one byte each. The address of the strings in the table are the same as those returned by the BASIC ADR function. Always use this function under program control, since the addresses in the table change according to your program size.

 

142,143 8E,8F RUNSTK
Address of the runtime stack which holds the GOSUB entries (four bytes each) and the FOR NEXT entries (16 bytes each). The POP command in BASIC affects this stack, pulling entries off it one at a time for each POP executed. The stack expands and contracts as necessary while the program is running.

Each GOSUB entry consists of four bytes in this order: a zero to indicate a GOSUB, a two-byte integer line number on which the call occurred, and an offset into that line so the RETURN can come back and execute the next statement.

Each FOR-NEXT entry contains 16 bytes in this order: first, the limit the counter variable can reach; second, the step or counter increment. These two are allocated six bytes each in BCD format (12 bytes total). The 13th byte is the counter variable number with the MSB set; the 14th and 15th are the line number and the 16th is the line offset to the FOR statement.

 

144,145 90,91 MEMTOP
Pointer to the top of BASIC memory, the end of the space the program takes up. There may still be space between this address and the display list, the size of which may be retrieved by the FRE(0) command (which actually subtracts the MEMTOP value that is at locations 741 and 742; $2E5, $2E6). Not to be confused with locations 741 and 742, which have the same name but are an OS variable. MEMTOP is also called TOPSTK; it points to the top of the stack space pointed to by RUNSTK above.

 

186,187 BA,BB STOPLN
The line where a program was stopped either due to an error or the use of the BREAK key, or a STOP or a TRAP statement occurred. You can use PEEK (186) + PEEK (187) * 256 in a GOTO or GOSUB statement.

 

195 C3 ERRSAVE
The number of the error code that caused the stop or the TRAP. You can use this location in a program in a line such as:
10 IF PEEK (195) < > 144 THEN 100

 

201 C9 PTABW
This location specifies the number of columns between TAB stops. The first tab will be at PEEK (201). The default is ten. This is the value between items separated in a PRINT statement by commas-such as PRINT A$,LOOP,C(12) - not by the TAB key spacing.

The minimum number of spaces between TABS is three. If you POKE 201,2, it will be treated as four spaces, and POKE 201,1 is treated as three spaces. POKE 201,0 will cause the system to hang when it encounters a PRINT statement with commas. To change the TAB key settings, see TABMAP (locations 675 to 689; $2A3-$2B1). PTABW is not reset to the default value by pressing RESET or changing GRAPHICS modes (unlike TABMAP). PTABW works in all GRAPHICS modes, not merely in text modes. The size of the spaces between items depends on the pixel size in the GRAPHICS mode in use. For example, in GR.0, each space is one character wide, while in GR.8 each space is one-half color clock (one dot) wide.

 

203-207 CB-CF * * * *
Unused by either BASIC or Assembler.

 

208-209 D0-D1 * * * *
Unused by BASIC.

 

210-211 D2-D3 * * * *
Reserved for BASIC use.

Locations 212 to 255 ($D4 to $FF) are reserved for the floating point package use. The FP routines ae in ROM, from locations 55296 to 57393 ($D800 to $E031). These page zero locations may be used if the FP package is not called by the user's program. However, do not use any of these locations for an interrupt routine, since such routines might occur during an FP routine called by BASIC, causing the system to crash.

 

212-217 D4-D9 FR0
Floating point register zero; holds a six byte internal form of the FP number. The value at locations 212 and 213 are used to return a two byte hexadecimal value in the range of zero to 65536 ($FFFF) to the BASIC program (low byte in 212, high byte in 213). The floating point package, if used, requires all locations from 212 to 255. All six bytes of FRO can be used by a machine language routine, provided FRO isn't used and no FP functions are used by that routine. To use 16 bit values in FP, you would place the two bytes of the number into the least two bytes of FRO (212,213; $D4,$D5), and then do a JSR to $D9AA (55722), which will convert the integer to its FP representation, leaving the result in FR0. To reverse this operation, do a JSR to $D9D2 (55762).

 

218-223 DA-DF FRE
FP extra register (?)

 

224-229 E0-E5 FR1
Floating point register one; holds a six-byte internal form of the FP number as does FR0. The FP package frequently transfers data between these two registers and uses both for two-number arithmetic operations.

Copyright 1983 and 1985, COMPUTE! Publications, Inc.

MAPPING THE ATARI
$16.95, COMPUTE! Books, P.O. Box
5406, Greensboro, NC
27403, (919) 275-9809. 

Ian Chadwick is a Toronto-based freelance Writer.