Commodore‎ > ‎BASIC‎ > ‎

Secret Variables

If you've ever written software of any reasonable complexity (something more useful than "Hello World") then you're probably aware that software typically has many internal or "secret" variables.  These are never (directly) exposed the user.  This is, generally speaking, good software design: hiding the complexity of the software (i.e., hiding trivial variables) makes it easier to use and easier to upgrade.  The CBM BASIC interpreter (really, almost any BASIC implementation) is software itself (which in this case lets you create BASIC software).
 
So on the one hand, "secret" variables should come as no suprise.  On the other hand, CBM BASIC (indeed, every BASIC that I know) includes "secret" variables that are important to the programmer but not directly accessibly.  These are usually "write-only" variables; which is to say BASIC allows you some way to change them, but BASIC provides no direct way to read them.  (In rare cases, they are read-only or completely hidden.)  This is bad because if you need to know it/their value(s) in a program, then you have only a few "bad" choices:
  1. Use machine-specific PEEKs (bad because it is non-portable)
  2. Maintain a normal variable ("shadow") that mimics the hidden variable (bad because this is very error-prone)
  3. Use knowledge of BASIC's internal behavior to anticipate the value (bad because it may be non-portable AND is error-prone) 
Most BASIC software I have seen relies on option #3.  On the one hand, this is the worst method because it allows for the greatest chance of failure.  I'm guessing the reason for its popularity is that it is the fastest method (because you are neither PEEKing nor maintaining a "shadow").
 
Below is a table listing some important "secret variables" of BASIC.  Some versions of BASIC lack the features that need an associated "secret variable" and they are indicated with "n/a".  Note that some of them are actually maintained by the KERNAL and not the BASIC interpreter.  By looking at the table, you will see that virtually all secret variables are located at a machine-specific location, which makes their use non-portable (unless you include special detection code and act appropriately).  The different values are listed under PEEK (POKE) Address; the column "CBM-II" refers to the "business" line of machines with various names in different countries (these machines are pretty easy to recognize because they power-up in lower/upper case PETSCII font, unlike all the others which default to upper/graphic ASCII-X font); the TED column refers to the C16 and Plus/4.
 
This is definately not a complete list!  Many things maintained by the system are not important to a BASIC programmer (mainly temporary values and indirect pointers) and thus are not included.  For example the BASIC Text Pointer is very important to the BASIC interpreter, but not very relevant to the BASIC programmer (mainly because it is constantly changing while a program runs).  The same is true of the floating-point accumulator; so I would not normally include it in such a listing, but it is specifically needed by the USR function.  In other words, I've tried to keep the list short, but with 110 entries (assuming I counted correctly) it seems I'm not good at picking relevant entries or CBM BASIC is littered with secret variables.  Check out the list and decide for yourself!
 
Secret Variable Type PEEK (POKE) Address Read
method
Write
method
Default
Value
Note(s)
PET CBM-II VIC-20 C64 TED C128
CPU P register Byte ? none! ? 783 2037 5 RREG SYS 0 ? RREG/SYS access only with C128
CPU A register Byte ? none! ? 780 2034 6 RREG SYS 0 ? RREG/SYS access only with C128
CPU X register Byte ? none! ? 781 2035 7 RREG SYS 0 ? RREG/SYS access only with C128
CPU Y register Byte ? none! ? 782 2036 8 RREG SYS 0 ? RREG/SYS access only with C128
File# Byte ? 26 ? 19 ? 19 ? 21 none CMD 0 0 = keyboard input and screen output
Start of Text
"TxtTab"
Unsigned Word 40 ~ 41 45 ~ 46 ? 43 ~ 44 43 ~ 44 45 ~ 46 none GRAPHIC varies GRAPHIC only in v3.5 and v7.0
End of Text
"TxtEnd"
Unsigned Word n/a 47 ~ 48 n/a n/a n/a 4624 ~ 4625 FRE CLR, DELETE, DLOAD, LOAD, NEW, RUN varies For machines with more than 64K RAM, this refers to Bank 0 (program text).  For machines with 64K or less RAM, this is equivalant to Start of Variables.
FRE() only gives a value indirectly.
Start of Variables
"VarTab"
Unsigned Word 42 ~ 43 49 ~ 50 ? 45 ~ 46 45 ~ 46 47 ~ 48 none CLR, DELETE*, DLOAD, LOAD, NEW, RUN varies (D)LOAD does not update this when executed in a program. *DELETE only affects machines with 64K or less.
Limit of Scalars
"VarEnd"
Unsigned Word n/a  51 ~ 52 n/a n/a n/a n/a FRE(2)  CLR, DLOAD, LOAD, NEW, RUN Start of variables  For machines with more than 192K.  Other machines use Start of Arrays
Start of Arrays
(Limit of Scalars)
"AryTab"
Unsigned Word 44 ~ 45 53 ~ 54 ? 47 ~ 48 47 ~ 48 49 ~ 50 none CLR, DELETE*, DLOAD, LOAD, NEW, RUN Start of variables (D)LOAD does not update this when executed in a program. *DELETE only affects machines with 64K or less.
Limit of Arrays
"AryEnd"
Unsigned Word n/a 55 ~ 56 n/a n/a n/a n/a FRE(3) CLR, DLOAD, LOAD, NEW, RUN Start of Arrays For machines with more than 128K.  Other machines use Free Space. 
Free Space
(Limit of Arrays)
"StrEnd"
Unsigned Word 46 ~ 47 57 ~ 58 ? 49 ~ 50 49 ~ 50 51 ~ 52 FRE CLR, DELETE*, DLOAD, LOAD, NEW, RUN Start of arrays
+Size of arrays
(D)LOAD does not update this when executed in a program.
FRE() only gives a value indirectly. *DELETE only affects machines with 64K or less.
Start of Strings
"FreTop"
Unsigned Word 48 ~ 49 59 ~ 60 ? 51 ~ 52 51 ~ 52 53 ~ 54 FRE CLR, DELETE*, DLOAD, LOAD, NEW, RUN End of Variables (D)LOAD does not update this when executed in a program.  Note this value grows "down" in memory.
FRE() only gives a value indirectly. *DELETE only affects machines with 64K or less.
Limit of Variables
"MemTop"
Unsigned Word 52 ~ 53 63 ~ 65 ? 55 ~ 56 55 ~ 56 57 ~ 58 FRE none Start of Strings For machines with over 64K RAM, this refers to the limit of variables (Bank 1 in the C128).  For machines with 64K or less RAM, it is the limit of BASIC (program text plus variables).  In either case, it is a memory limit.
FRE() only gives a value indirectly
Limit of Text
(Points to input buffer on CBM-II)
Unsigned Word n/a 136 ~ 137 n/a n/a n/a 4626 ~ 4627  FRE none varies  This is for machines with more than 64K RAM; it refers to the limit of program text. In other words, should End of Text (attempt) to exceed this value, an OUT OF MEMORY error is generated.  For machines with 64K or less RAM, this is equivalant to Start of Strings.  In either case, they are a memory limit.
FRE() only gives a value indirectly
Current Line# Unsigned Word ? 66 ~ 67 ? 57 ~ 58 57 ~ 58 59 ~ 60 COLLISION, ELSEGOSUB, GOTO, LOOP, NEXTRESUME, RETURNRUN, THEN, TRAP none The value here is always valid (when a program is running) and is saved to another location (the reserved variable EL) when an error occurs.
COLLISION, LOOP, NEXT, RETURN and TRAP update this value indirectly.
DATA line# Unsigned Word ? 72 ~ 73 ? 63 ~ 64 63 ~ 64 65 ~ 66 none RESTORE, RUN first line of program  
DATA pointer Unsigned Word ? 74 ~ 75 ? 65 ~ 66 65 ~ 66 67 ~ 68 none RESTORE, RUN start of first line of program RESTORE lineNumber will set this to the start of the specified lineNumber
Stop Line# Unsigned Word ? 68 ~ 69 ? 59 ~ 60 601 ~ 602 4608 ~ 4609 none none varies Set to the current line# whenever the END or STOP statements are encountered or the user presses the STOP key.  Intended for use with CONT
Stop Address Unsigned Word ? 70 ~ 71 ? 61 ~ 62 603 ~ 604 4610 ~ 4611 none none varies Save the value of TextPointer (actual RAM address) for use with CONT (see above). 
Error Line# Unsigned Word n/a 664 ~ 665 n/a n/a ? 4617 ~ 4618 EL, HELP CLR, RESUME, any program error 65535 Saved Line# where last error occured.  This is not really a secret because of "public" EL, however the related TRAP Address (see below) is a secret.
Error Address Unsigned Word n/a 666 ~ 667 n/a n/a 1269 ~ 1270 4622 ~ 4623 none any error varies Saves the value of TextPointer (actual RAM address) for use by HELP and RESUME.  The address points to the token that generated the error.
TRAP Line# Unsigned Word n/a 662 ~ 663 n/a n/a 1266 ~ 1267 4619 ~ 4620 none TRAP 65280 Line# to 'GOSUB' when an error occurs.  If the high-byte is 255 then error trapping is not enabled.  This may be due to either no TRAP routine was set, or TRAP has been disabled (such as when an error first occurs, to prevent recursion).
Enable Trace Byte n/a n/a n/a n/a 747 4463 none TRON, TROFF 0 A non-zero value (TRON sets 255) enables "tracing" of a running program.  A zero value (set by TROFF) disables program tracing. 
Collision Line# Low Bytes Byte[3] n/a n/a n/a n/a n/a 4729 ~ 4731 none COLLISION none!  Holds the low-byte of the BASIC line# to be called (like GOSUB) when a VIC-II event occurs and COLLISION is enabled.  The 3 events are: sprite-sprite collision, sprite-foreground collision, and light-pen triggered.  Set by COLLISION.  Used by the main BASIC loop (in program mode only). 
Collision Line# High Bytes Byte[3] n/a n/a n/a n/a n/a 4732 ~ 4734 none COLLISION none!  Holds the high-byte of the BASIC line# to be called (like GOSUB) when a VIC-II event occurs; see above. 
Collision Control Byte n/a n/a n/a n/a n/a 4735 none COLLISION, enter RUN mode 0 The low 3 bits determine which type of VIC-II event(s) will cause a program to call a subroutine (like GOSUB).  An event is enabled when a bit is set (1).  All three bits are set by COLLISION.  When the BASIC main loop actually calls the subroutine, bit 7 is set (to prevent recursion) and the next RETURN will clear bit 7. Cleared to zero when entering program mode (typically with RUN).
AUTO value Unsigned Word n/a n/a n/a n/a 115 ~ 116 116 ~ 117 none AUTO, CONT, GOSUB, GOTO, RUN 0 Every write method except AUTO sets the value to 0
USR Vector
"UsrPok"
Unsigned Word ? 3 ~ 4 ? 785 ~ 786 1281 ~ 1282 4633 ~ 4634 none none varies This is a pointer to some machine language routine that runs whenever USR is called.  The default routine will print an error message.
Seed Packed Float ? ? ? 139 ~ 143 1283 ~ 1287 4635 none RND varies This is a floating-point value used to generate the next random number when the argument to RND is zero.  This value may be set by giving a negative argument to RND. 
FAC (USR value) Unpacked
Float
? 113 ~ 118 ? 97 ~ 102 97 ~ 102 99 ~ 104 many many none This is the Floating Point Accumulator and is used by nearly all numeric operations of BASIC.  In particular, it holds the argument to USR function, and the result of the function should be stored in FAC as well.
BASIC top-of-stack Unsigned Word n/a n/a n/a n/a 124 ~ 125 125 ~ 126 none DO, FOR, GOSUB, LOOP, NEXT, RETURN C128: 2559, TED: 1968 Most versions of CBM BASIC use the CPU stack for DO / FOR / GOSUB.
CPU top-of-stack Byte n/a 668 n/a n/a 1271? 130 none everything, RESUME, RUN varies Almost everyting affects the CPU stack pointer; in particular, an error TRAP will (effectively) save the value, RESUME will (literaly) restore it, and RUN will reset it.
Current Bank Byte n/a 599 n/a n/a n/a 981 none BANK 15 Holds the Bank# to be used by various commands: BOOT, BLOAD, BSAVE, FETCH, PEEK, POKE, STASH, SWAP, SYS, WAIT.
RUN Mode Byte ? 67 ? ? 129 127 CONT, END, GOSUB, GOTO, LOOP, NEXTRETURN, RUN, STOP 0 A value of zero indicates direct mode; except CBM-II, a value less than 255 indicates RUN mode.  See also Enter RUN Mode.
I/O Status Byte ? 156 ? 144 144 144 ST varies 0 Updated by any non-keyboard or non-screen I/O; reading the reserved variable ST will reset this secret variable to zero
Enable Byte  673?  673  1998? 2000? 2575  none  none  varies  Bit 0 (value 1) is set when transmitting RS-232 data 
Number of OPEN files Byte ? 864 ? 152 151 152 none APPEND, CLOSE, CLR, COLLECT, DCLEAR, DCLOSE, DOPEN, OPEN, RUN 0 (D)OPEN normally increases this value by 1; DOPEN a REL files increases it by 2;
DCLEAR decreases this value based on the number files opened on the particular device;
CLR and RUN reset the value to 0.
Input Device Byte ? 161 ? 153 152 153 none GET#, INPUT# 0 Default is the keyboard
Output Device Byte ? 162 ? 154 153 154 none CMD, PRINT# 3 Default is the (active) display screen
DosFA Byte  n/a  544  n/a  n/a  631 284  none  Disk Commands 8? Used by DS and DS$.  On the C128, this is located in the cassette error pass log, so reading from cassette may foul-up DS or DS$... possibly locking up the system.  On any system it is not updated by CLOSE, CMD, GET#, LOAD, OPEN, PRINT#, SAVE, or VERIFY. 
DS Descriptor String descriptor  n/a  22 ~ 25 n/a  n/a  122  (indirect) DS, DS$ Disk commands, CLOSE, CMD, GET#, INPUT#, LOAD, OPENPRINT#, SAVE, VERIFY  null descriptor This describes a string which is the most recently read "disk" error/status message (actually any device 8 to 11, channel 15).  The descriptor is cleared (null string) for any of the listed write methods.  Some of the disk commands will later (after null) read a new string from the device.  It is referenced by DS and DS$; if the descriptior is null, the error/status channel is read into a new string.
Message Mode Byte ? ? ? 157 129 157 none error, CONT, END, GOSUB, GOTO, RUN, STOP 0 (RUN mode)
128 (direct mode)
Enables messages such as SEARCHING FOR and LOADING.  When you enter the built-in MONITOR, this value is set to 192, which results in cryptic IO ERROR numbers in some cases.
Start Address Unsigned Word n/a ? n/a n/a 178 ~ 179 172 ~ 173 none BOOT, BLOAD, BSAVE, DLOAD, DSAVE, DVERIFY, LOAD, SAVE, VERIFY varies BOOT, BLOAD, BSAVE and the ML-versions of LOAD and VERIFY set this value based on the value in the file header by default (BOOT, BLOAD, BSAVE have parameters to specify a specific value).  The BASIC-versions of LOAD, SAVE, and VERIFY set it to the Start of Text.
End Address
(plus 1)
Unsigned Word ? ? ? 174 ~ 175 157 ~ 158 174 ~ 175 none BOOT, BLOAD, BSAVE, DLOAD, DSAVE, DVERIFY, LOAD, SAVE, VERIFY varies The listed write methods set the value to the last address loaded/saved/verified plus one.
Last Device Byte ? 159 ? 186 174 186 none varies 0 Set by the most recent I/O command (except PRINT, GET, GETKEY, and INPUT)
RS-232 Input Buffer Pointer Unsigned Word ? ? ? 247 ~ 248 ? 200 ~ 201 none CLOSE*, OPEN* varies *On the C128, the default is 3072 ($C00); Dynamically set on C64 by OPEN and CLOSE.
RS-232 Output Buffer Pointer Unsigned Word ? ? ? 249 ~ 250 ? 202 ~ 203 none CLOSE*, OPEN* varies *On the C128, the default is 3328 ($D00); Dynamically set on C64 by OPEN and CLOSE.
Cursor Row Byte ? 202 ? 214 205 235 none varies none Anything that writes to the screen can update this value.  CHAR can set a specific value.
Cursor Column Byte ? 203 ? 211 202 236 POS varies none Anything that writes to the screen can update this value; only TAB() and CHAR can set a specific value.
Cursor Off Byte ? ? ? 204 1340 2599 none END, INPUT, STOP varies A zero value enables the text screen cursor (not C128 80-column mode); a non-zero value hides it.  In direct mode, or during program INPUT, the value is 0 so the user can see where (s)he is typing. A non-zero value is present during normal program execution so the cursor is hidden. 
Bottom of Window Byte n/a 221 n/a n/a 2021 228 none CMD, PRINT, PRINT#, WINDOW 18 A zero-based physical line number.  Can be set with WINDOW command or by printing "ESC B" [CHR$(27);"B"].
Top of Window Byte n/a 220 n/a n/a 2022 229 none CMD, PRINT, PRINT#, WINDOW 0 A zero-based physical line number.  Can be set with WINDOW command or by printing "ESC T" [CHR$(27);"T"].
Left of Window Byte n/a 222 n/a n/a 2023 230 none CMD, PRINT, PRINT#, WINDOW 0 A zero-based physical column number.  Can be set with WINDOW command or by printing "ESC T" [CHR$(27);"T"].
Right of Window Byte n/a 223 n/a n/a 2024 231 none CMD, PRINT, PRINT#, WINDOW 39 (most), 79 (C128 80-column) A zero-based physical column number.  Can be set with WINDOW command or by printing "ESC T" [CHR$(27);"T"].
Vertical Wrap Byte n/a 923 n/a 658 ? 2025 248 none CMD, PRINT, PRINT# 0 A value of 128 or more enables vertical wrap: printing past the last line of the screen will resume on the top screen line.  A value less than 128 enables the classic behavior: the text scrolls up one (or more) lines when printing goes past the last screen line.  Printing "ESC M" [CHR$(27);"M"] will enable vertical wrap, while "ESC L" [CHR$(27)"L"] sets normal line scrolling.
Text Attribute Byte ? ? ? 646 ? 1339 241 RCLR, RLUM CMD, COLOR, PRINT, PRINT# varies RCLR only returns the color; on the TED series, RLUM returns the luminance.  Other attribtues may present: Flashing characters for the TED series, and C128 80-column mode may include Flashing, Underline, Reverse, and Alternate Font bits.  COLOR can't change the non-color (or non-luminance) attributes. CMD/PRINT# can only write this value if the fileNumber refers to the screen.
Rvs On Byte ? 919 ? 199 194 243 none CMD, PRINT, PRINT# 0 A non-zero value enables reverse-font.  Set to non-zero by printing "Reverse on" CHR$(18).  Clear to zero by printing "Reverse off" CHR$(146) or [Shift]Return CHR$(13) [or CHR$(147)].
Quote Mode Byte ? 210 ? 212 203 244 none CMD, PRINT, PRINT# 0 A non-zero value enables "quote mode" where control characters appear as reverse-font characters. This value is toggled on/off by printing (or typing) a double-quote ("), CHR$(34). It is zeroed by [Shift]Return, CHR$(13) [or CHR$(147)].
Insert Mode Byte ? 211 ? 216 207 245 none CMD, PRINT, PRINT# 0 A non-zero value enables "insert mode" where control characters appear as reverse-font characters (similar to quote mode). This value is increased by each printing (or typing) an INSert code, CHR$(148) and is decreased (until 0) by printing/typing any other character. It is zeroed by [Shift]Return, CHR$(13) [or CHR$(147)].
Auto-Insert Byte n/a 922 n/a n/a 2026 246 none CMD, PRINT, PRINT#, RUN 0 A non-zero value enables "auto-insert mode". Unlike (manual) "Insert Mode", control characters operate normally. Printing "ESC A" [CHR$(27);"A"] sets this to non-zero.  Printing "ESC C" [CHR$(27);"C"] or  or entering RUN mode clears it to zero.
Scroll Lock Byte n/a ? n/a n/a 240 2593 none none 0 A non-zero value will prevent output to the screen, effectively halting a program using PRINT.  Unlike similar flags dealing with screen output, there are no control codes to change this value!  Without resorting to POKE, only the user can toggle the value on/off with Control+S key combination or (C128) the NO SCROLL key.
Repeat Mode Byte ? ? ? 650 1344 2594 none none varies Controls which keyboard keys will repeat when held down: 0 = few (space, cursor, insert, delete), 64 = none, 128 = all.
Font Lock Byte ? ? ? 657 ? 1351 247 none CMD, PRINT, PRINT# 0 A non-zero value locks the current font, so it can not be changed by pressing C= and Shift keys (font can still be changed with other methods).  The CHR$ code needed to enable / disable the lock varies by machine.  See the ASCII-X or PETSCII tables.
Disable Bell Byte n/a ? n/a n/a n/a 249 none CMD, PRINT, PRINT# 0 (C128 Only) A value of 128 or more will disable the "ASCII Bell", otherwise it is enabled (a little beep generated when Control-G = CHR$(7) is printed or typed).  Printing "ESC H" [CHR$(27);"H"] will set this to 128 and disable the bell; while "ESC G" [CHR$(27);"H"] will clear this and enable the bell.
Last Character Char n/a 219 n/a n/a 2027 240 none varies none Anything that writes to the screen updates this value; used to recognize ESCape key sequences. 
Keyboard Buffer Byte[10] ? 939 ~ 948 ? 631 ~ 640 1319 ~ 1328 842 ~ 851 GET, GETKEY, INPUT none Keys pressed by the user are stored here until they can be processed.  Some programs will PRINT instructions on the screen and POKE a Return-key-code (or multiple Returns) here and then END so that BASIC will execute the PRINTed instructions as if the user had typed them.  Needed for some BASIC statements that "fail" in program mode.
Number of buffered keys Byte ? 209 ? 198 239 208 none GET, GET#, GETKEY, INPUT, INPUT# 0 GET# and INPUT# only write a new value if the fileNumber refers to the keyboard
Shift flag Byte ? 224 ? 653 1348 211 none none 0
Indicates which (if any) of ALT, C=, CAPS LOCK, CTRL, or SHIFT[lock] key(s) are currently pressed
Key Code Byte ? 225 ? 197 ? 2038 212 GET, GET#, GETKEY, INPUT, INPUT# none 64 (most)
88 (C128)
A machine-specific code indicating which key is currently is pressed; if none the default value is present.  Some keys (like RESTORE and SHIFT) do not update this.  The listed read methods will translate the Key Code into a PETSCII value, but they will return the value of any buffered keys first, and GET# / INPUT# only apply if the fileNumber refers to the keyboard.
Function Key Lengths Byte[varies] n/a 899 ~ 918 n/a n/a 1375 ~ 1382 4096 ~ 4105 none KEY varies See note below
Function Key Definitions Byte[varies] n/a 64512 ~ 65022 n/a n/a 1383 ~ 1511 4106 ~ 4351 none KEY varies There is no real way to get the values; KEY can be used to display them, but the result can't be used (like assigned to a variable).
PRINT USING Virtual Characters
"PUchrs"
Char[4] n/a 627 ~ 630 n/a n/a 1255 ~ 1258 4612 ~ 4615 none PUDEF Space, Comma, Period, Dollar These are the actual characters that will be used by PRINT USING when it needs to print a corresponding virtual character.  For example, you can use PUDEF to change the monetary symbol from the default dollar ($) to British Pound (£) or some other character.  However BASIC provides no way to determine the current assignment(s).
Screen Start Byte ? ? ? 648 1342 2619 none none 4 (many) 12 (TED) The high-byte of the start of the text screen; used by the screen editor.  To relocate the text screen in RAM, not only this value, but chip register(s) must be changed too.  On the C128, this only applies to the 40-column screen. 
Screen Start 80 Byte n/a n/a n/a n/a n/a 2606 none none 0 (C128 Only) The high-byte of the start of the 80-column text screen; used by the screen editor.  To relocate the text screen in RAM, not only this value, but chip registers must be changed too 
Color Start 80 Byte n/a n/a n/a n/a n/a 2607 none none 8 (C128 Only) The high-byte of the start of the 80-column attributes; used by the screen editor.  To relocate the attributes in RAM, not only this value, but chip registers must be changed too 
PAL / NTSC Byte ? ? ? 678 ? 2563 none none varies Zero indicates an NTSC system; non-zero indicates (most) PAL systems.  Unknown value for the rare "PAL-M" system.  This may be important for using reserved variable TI or generating SOUND. 
Bitmap allocated Byte n/a n/a n/a n/a 117 118 none GRAPHIC 0  
Split Raster Byte n/a n/a n/a n/a n/a 2612 none GRAPHIC 208 (C128 Only) This value determines the start of the text-mode part of a split-screen.  Value = 48 + 8 * Text_Row (0-based row#).  Although the Plus/4 has split-screen, the text part appears at a fixed location.
SCALE X Unsigned Word n/a n/a n/a n/a n/a 137 ~ 138 none SCALE 20480 (high-res)
10240 (multi-color)
 
SCALE Y Unsigned Word n/a n/a n/a n/a n/a 139 ~ 140 none SCALE 12800  
Enable SCALE Byte n/a n/a n/a n/a 742 4458 none SCALE 0 A non-zero value enables bitmap coordinate scaling.  A zero value treats bitmap coordinates a literal pixel locations. 
Bitmap line width Byte n/a n/a n/a n/a 743 4459 none WIDTH 0 A non-zero value causes a "dot" to be plotted on the bitmap as two pixels horizontally (this applies to drawing lines, circles, and boxes, not just random dots).  A zero value draws only one pixel for each coordinate used in a bitmap drawing command.
Sprite pointers Byte[8] n/a n/a n/a 2040 ~ 2047 n/a Text: 2040 ~ 2047 Bitmap: 8184 ~ 8191 none none 56 ~ 63 These pointers determine the address where SPRITE data is stored (one pointer for each sprite).  On the C128, there are actually two sets of pointers (one for text mode, one for bitmap mode) although they both point to the same locations.  On the C64 the values are not defined but need to be set in order to use sprites. 
Sprite data Byte[8,64] n/a n/a n/a varies n/a 3584 ~ 4095 SPRSAV SPRSAV none On the C128, this area is the default area for sprite data storage; on the C64 the user must select an appropriate location(s). The SPRSAV command can be used to read/write the data to BASIC strings, but not read/write them to a disk file (use BLOAD / BSAVE instead). 
Sprite vector table Byte[8,11] n/a n/a n/a n/a n/a 4478 ~ 4565 RSPPOS MOVSPR varies This table controls the position and movement of each SPRITE (88 bytes, 11 for each of 8 sprites).  The values can be set with MOVSPR, and for moving sprites the values are updated by the BASIC IRQ routine.  The RSPPOS function can retrieve most of the values; but not the direction of movement.  The horizontal direction is determined by an unsigned word beginning at offset 3; the vertical direction is determined by an unsigned word beginning at offset 5; and the sign of those two is determined by a code at offset 2 (0=NE, 1=SE, 2=SW, 3=NW).
Alternate Font Start Byte n/a n/a n/a n/a ? 4587 none none 216 High-byte of start of font to be used by CHAR (when used on a bitmap).  By default it points to the upper/lower (PETSCII) font.  The value here may be selected by using CHR$(14) in the CHAR string.
Primary Font Start Byte n/a n/a n/a n/a ? 4588 none none 208 High-byte of start of font to be used by CHAR (when used on a bitmap).  By default it points to the upper/graphic (ASCII-X) font.  The value here is the default used by CHAR; it may be manually selected by using CHR$(142) in the CHAR string.  By POKEing this location, you make CHAR use your own custom font.
Tempo Rate Byte n/a n/a n/a n/a n/a 4642 none TEMPO 16 This determines the speed of notes during PLAY.  The default works out to about 3 quarter notes per second. 
Play Remainders Word[3] n/a n/a n/a n/a n/a 4643 ~ 4648 none PLAY -256  Remaining time for each of the 3 SID voices.  Set by PLAY and updated by the Tempo Rate during the BASIC IRQ.  The note ends when the value "underflows" (becomes negative).
Octave Byte n/a n/a n/a n/a n/a 4651 none PLAY 4 Determines note frequency.  Set by PLAY octave directive.  Should be 0 to 6. 
Current Waveform Byte[3] n/a n/a n/a n/a n/a 4656 none ENVELOPE, PLAY  65 This is the gated waveform for one of the 3 corresponding SID registers.  The value is here is copied by PLAY to the SID chip (derived from ENVELOPE).  The value minus 1 is copied by BASIC IRQ to the SID chip when the note ends (technically the value AND 254).
Attack Table Byte[10]  n/a n/a n/a n/a n/a 4671 ~ 4680 none ENVELOPE varies  Holds the SID Attack/Decay chip register settings for each of 10 instruments (selected by PLAY instrument "tone" directive). 
Sustain Table Byte[10]  n/a n/a n/a n/a n/a 4681 ~ 4690 none ENVELOPE varies  Holds the SID Sustain/Release chip register settings for each of 10 instruments (selected by PLAY instrument "tone" directive). 
Waveform Table Byte[10]  n/a n/a n/a n/a n/a 4691 ~ 4700 none ENVELOPE varies  Holds the SID waveform chip register settings for each of 10 instruments (selected by PLAY instrument "tone" directive). 
Pulse-Wdith Low Table Byte[10]  n/a n/a n/a n/a n/a 4701 ~ 4710 none ENVELOPE varies  Holds the SID Pulse Width (low byte) chip register settings for each of 10 instruments (selected by PLAY instrument "tone" directive). 
Pulse-Width High Table Byte[10]  n/a n/a n/a n/a n/a 4711 ~ 4720 none ENVELOPE varies  Holds the SID Pulse Width (high byte) chip register settings for each of 10 instruments (selected by PLAY instrument "tone" directive). 
Filter Frequency Unsigned Word n/a n/a n/a n/a n/a 4721 ~ 4722 none FILTER none! Holds the SID registers setting for filter frequency (maximum is 2047).  It has the last-used value from FILTER, it is never initialized.
Filter Resonance Byte n/a n/a n/a n/a n/a 4723 none FILTER none! Holds the SID register setting for filter resonance (upper 4 bits) and voice application (lower 3 bits).  It has the last-used value from FILTER, it is never initialized.
Filter / Volume Byte n/a n/a n/a n/a n/a 4724 none FILTER, VOL 15 Holds the SID register settings for filter mode (bits 4~6) and master volume (lower 4 bits).  The high bits are set by FILTER.  The lower four bits are set by VOL and the PLAY "u" directive. 
Sound Remainder Low Bytes Byte[2 or 3] n/a n/a n/a n/a 1276 ~ 1277 4738 ~ 4740 none SOUND none! Remaining time for each of the 3 audio voices (the TED only has 2 voices).  Set by SOUND and decremented each BASIC IRQ.  The value from this table, and a corresponding one from the next determine a 16-bit signed word.
Sound Remainder High Bytes Signed Byte[2 or 3] n/a n/a n/a n/a 1278 ~ 1279 4741 ~ 4743 none SOUND -1 Remaining time for each of the audio voices.  Set by SOUND and decremented by the BASIC IRQ until the value "underflows", and then the SOUND is silenced.
Sound Maximum Frequency Low Bytes Byte[3] n/a n/a n/a n/a n/a 4744 ~ 4746 none SOUND none! Maximum frequency for each of the 3 audio voices.  Set by SOUND and possibly checked each BASIC IRQ.  These are the low bytes of an unsigned 16-bit word.
Sound Maximum Frequency High Bytes Byte[3] n/a n/a n/a n/a n/a 4747 ~ 4749 none SOUND none! Maximum frequency for each of the 3 audio voices (see above); these are the high bytes.
Sound Minimum Frequency Low Bytes Byte[3] n/a n/a n/a n/a n/a 4750 ~ 4752 none SOUND none! Minimum frequency for each of the 3 audio voices.  Set by SOUND and possibly checked each BASIC IRQ.  These are the low bytes of an unsigned 16-bit word.
Sound Minimum Frequency High Bytes Byte[3] n/a n/a n/a n/a n/a 4753 ~ 4755 none SOUND none! Minimum frequency for each of the 3 audio voices (see above); these are the high bytes.
Sweep Modes Byte[3] n/a n/a n/a n/a n/a 4756 ~ 4758 none SOUND none! Determines how Sound Frequency is modulated; 0 = increase then reset, 1 = decrease then reset, 2 = increase then decrease, 3 =decrease then increase.  Set by SOUND and tested each BASIC IRQ.
Sound Step Low Bytes Byte[3] n/a n/a n/a n/a n/a 4759 ~ 4761 none SOUND none! Determines moulation amount (step size) for each of the 3 audio voices.  Set by SOUND and possibly used each BASIC IRQ to update Sound Frequency.
Sound Step High Bytes Byte[3] n/a n/a n/a n/a n/a 4762 ~ 4764 none SOUND none! Determines moulation amount (step size) for each of the 3 audio voices (see above); these are the high bytes.
Sound Frequency Low Bytes Byte[3] n/a n/a n/a n/a n/a 4765 ~ 4767 none SOUND varies Current audio chip freqency register value for each of the 3 audio voices.  Set by SOUND and modulated each BASIC IRQ by the "step size" according to the "sweep mode".  The value from this table, and a corresponding one from the next determine a 16-bit unsigned word.
Sound Frequency High Bytes Byte[3] n/a n/a n/a n/a n/a 4768 ~ 4770 none SOUND varies Current audio chip freqency register value for each of the 3 audio voices (see above); these are the high bytes.
Sound Pulse Width Unsigned Word n/a n/a n/a n/a n/a 4782 ~ 4783 none SOUND none Value of pulse-width used in the most recent SOUND statement.
Sound Waveform Byte n/a n/a n/a n/a n/a 4784 none SOUND varies Waveform setting for an audio chip register used in the most recent SOUND statement.

© H2Obsession, 2014
Comments