System Guide Commodore 128 Personal Computer Hosted at www.commodore.ca or text.commodore.ca SECTION 16 16. Introduction 16.1 ORGANIZATION OF ENCYCLOPAEDIA 16.2 COMMAND AND STATEMENT FORMAT 16.3 GRAPHIC AND SOUND COMMAND FORMAT 16.4 DISK COMMAND FORMAT 16.1 ORGANIZATION OF ENCYCLOPAEDIA This chapter lists BASIC 7.0 language elements and describe how to use those elements. It gives a complete list of the rules (syntax) of Commodore 128 BASIC 7.0, along with a concise description of each. Basic 7.0 includes all the elements of BASIC 2.0. The new commands, state- ments, functions and operators provided in Basic 7.0 are underlined and commands which have been modified are printed in plain and underlined text. The different types of BASIC operations are listed in individual sections, as follows: 1. COMMANDS AND STATEMENTS: the commands used to edit, store and erase programs; and the BASIC program statements used in the numbered lines of a program. 2. FUNCTIONS: the string, numeric and print functions. 3. VARIABLES AND OPERATORS: the different types of variables, legal names, arithmetic operators and logical operators. 4. RESERVED WORDS, SYMBOLS AND ABBREVIATIONS: the words, symbols and abbreviations reserved for use in the BASIC 7.0 language, and which cannot be used for any other purpose. 16.2 COMMAND AND STATEMENT FORMAT +-------------------------------------------------------------------------+ | command name -> AUTO | | ---- | | | | brief description -> Enable/disable automatic line numbering | | command format -> AUTO [line#] | | | | Discussion of This command turns on the automatic line-number- | | format and use -> ing feature. This eases the job of entering pro- | | grams, by automatically typing the line numbers | | for the user. As each program line is entered by | | pressing {return}, the next line number is prin- | | ted on the screen, and the cursor is positioned | | two spaces to the right of the line number. The | | line number argument refers to the desired incre- | | ment between line numbers. AUTO without an argu- | | ment turns off the auto line numbering, as does | | RUN. This statement can be used only indirect | | mode (outside of a program). | | | | EXAMPLES: | | AUTO 10 Automatically numbers program lines | | in increments of 10. | | Example(s) -> AUTO 50 Automatically numbers lines in | | increments of 50. | | AUTO Turns off automatic line numbering. | +-------------------------------------------------------------------------+ The boldface line that defines the format consists of the following elements: DLOAD "program name" [D0,U8] ^ ^ ^ | | | additional arguments keyword argument +-- (possibly optional) The parts of the command or statement that must be typed exactly are shown in capital letters. Words the user supplies, such as the name of a program, are not capitalized. When quote marks (" ") appear (usually around a program name or file name), the user should include them in the appropriate place, according to the format example. KEYWORDS, also called reserved words, appear in upper case letters. Key- words may be typed using the full word or the approved abbreviation (a full list is given in Appendix K). The keyword or abbreviation must be entered correctly or an error will result. The BASIC and DOS error messages are defined in Appendices A and B, respectively. Keywords are words that are part of the BASIC language. The are the central part of a command or statement, and the tell the computer what kind of action to take. These words cannot be used as variable names. A complete list of reserved words is given in Section 20. ARGUMENTS, also called parameters, appear in lower case letters. Arguments complement keywords by providing specific information to the command or statement. For example, the keyword LOAD tells the computer to load a pro- gram while the argument tells the computer which specific program to load. A second argument specifies from which drive to load the program. Arguments include filenames, variables, line numbers, etc. SQUARE BRACKETS [ ] show optional arguments. The user selects any or none of the arguments listed, depending on requirements. The user should not type the SQUARE BRACKETS, which are only there to describe the format. ANGLE BRACKETS < > indicate the user MUST choose one of the arguments lis- ted. The user should not type the ANGLE BRACKETS, which are only there to describe the format. A VERTICAL BAR | seperates items in a list of arguments when the choices are limited to those arguments listed. When the vertical bar appears in a list enclosed by SQUARE BRACKETS, the choices are limited to the items in the list, but the user still has the option not to use any arguments. ELIPSIS ... a sequence of three dots means an option or argument can be repeated more than once. The user should not type the ELIPSIS, which is only there to describe the format. QUOTATION MARKS " " enclose character strings, filenames and other expres- sions. When arguments are enclosed in quotation marks, the quotation marks must be included in the command or statement. Quotations marks are not con- ventions used to describe formats; they are required parts of a command or statement. PARENTHESES ( ) When arguments are enclosed in parentheses, they must be included in the command or statement. Parentheses are not conventions used to describe formats; they are required parts of a command or statement. VARIABLE refers to any valid BASIC variable name, such as X, A$, T%, etc. EXPRESSION refers to any valid BASIC expression, such as A+B+2, 5*(X+3), etc. COMMAS (,) COLONS (:) and SEMICOLONS (;) These MUST be included, they are required parts of the command or statement. 16.3 GRAPHIC AND SOUND COMMAND FORMAT Optional parameters in Graphics and Sound commands are represented like this: [,parameter] When parameters are omitted the comma MUST be included, this is because the parameters are position dependent. You must not, however, include commas after the last specified parameter. EXAMPLE: ENVELOPE n [,atk] [,dec] [,sus] [,rel] [,wf] [,pw] To alter just the rel parameter, use: ENVELOPE n,,,,rel The first three commas mark the positions of atk, dec, sus and the fourth is the comma for rel. The commas for wf and pw must not be entered. In the GRAPHICS commands whenever there is a coordinate specified by (X,Y) it is possible to replace this with a vector (X;Y). In this case: X is the distance (scaled) Y is the angle in degrees (0 = up; 90 = right etc.) For example: LOCATE 160,100 DRAW TO 40;45 will draw a line at 45 degrees of length 40. 16.4 DISK COMMAND FORMAT Optional parameters in disk commands are shown thus: [,parameter] The comma is not required if the parameter is the first after the command itself. If other parameters which require commas are omitted the commas should be omitted too. EXAMPLE: DIRECTORY [Ddrive][Udevice number] [,wildcard] would in full produce: DIRECTORY D0 ON U8,"AB*" To specify only the wild card, no comma is required, i.e. DIRECTORY "AB*" Whenever variables are used in disk commands the MUST be enclosed in paren- theses ( ). For example: DIRECTORY D(DV),(A$) SECTION 17 17. Basic Commands and Statements 17.1 APPEND ------ Append new data to the end of a sequential file. APPEND #logical file number, "filename" [,Ddrive number] [ Udevice] This command opens the file having the specified filename, and positions the pointer at the end of the file. Subsequent PRINT# (write) statements will cause data to be appended to the end of this file. Default values for drive number and device number are 0 and 8 respectively. Variables or Expressions used as filenames must be enclosed within paren- theses. EXAMPLES: APPEND#8,"MYFILE" OPEN logical file 8 called "MYFILE" for appending with subsequent PRINT# statements. APPEND#7,(A$),D0,U9 OPEN logical file named by the variable A$ on drive 0, device number 9 and prepare to APPEND. 17.2 AUTO ---- Enable/disable automatic line numbering. AUTO [line#] This command turns on the automatic line-numbering feature. This eases the job of entering programs, by automatically typing the line numbers for the user. As each program line is entered by pressing {return}, the next line number is printed on the screen, and the cursor is positioned on the second space to the right of the line number. The line number argument refers to the desired increment between line numbers. AUTO without an argument turns off the auto line numbering, as does RUN. This statement can be used only in direct mode (outside of a program). EXAMPLES: AUTO 10 Automatically numbers program lines in increments of 10. AUTO 50 Automatically numbers lines in increments of 50. AUTO Turns off automatic line numbering. 17.3 BACKUP ------ Copy the entire contents from one disk to another on a dual disk drive. BACKUP source Ddrive number TO destination Ddrive number [Udevice] This command copies all the data from the source diskette onto the desti- nation diskette using a dual diskdrive. With the BACKUP command, a new dis- kette can be used without first formatting it. This is because the BACKUP command copies all the information on the diskette, including the format. Because of this, the BACKUP command destroys any information already on the destination disk. Therefore, when backing up onto a previously used disket- te, make sure it contains no programs you mean to keep. As a precaution the computer asks "ARE YOU SURE?" before it starts the operation. Press the {y} key to perform the BACKUP, or any other key to stop it. You should always create a backup of all your disks, in case the original diskette is lost or damaged. Also see the COPY command in paragraph 17.21. The default device number is unit 8. NOTE: This command can be used only with a dual-disk drive. It will not allow you to make copies of protected disks (most prepackaged software). EXAMPLES: BACKUP D0 TO D1 Copies all data from the disk in drive 0 to the disk in drive 1, in dual disk drive unit 8. BACKUP DO TO D1 ON U9 Copies all data from drive 0 to drive 1, in disk drive unit 9. 17.4 BANK ---- Select one of the 16 banks, numbered 0-15. BANK bank number This statement specifies the bank number and corresponding memory configu- ration for the Commodore 128 memory. The default bank is 15. Here is a table of available BANK configurations in the Commodore 128 memory: BANK CONFIGURATION 0 RAM(0) only 1 RAM(1) only 2 RAM(2) only* 3 RAM(3) only* 4 Internal ROM, RAM(0), I/O 5 Internal ROM, RAM(1), I/O 6 Internal ROM, RAM(2), I/O* 7 Internal ROM, RAM(3), I/O* 8 External ROM, RAM(0), I/O 9 External ROM, RAM(1), I/O 10 External ROM, RAM(2), I/O* 11 External ROM, RAM(3), I/O* 12 Kernal and Internal ROM(LOW), RAM(0), I/O 13 Kernal and External ROM(LOW), RAM(0), I/O 14 Kernal and BASIC ROM, RAM(0), Character ROM 15 Kernal and BASIC ROM, RAM(0), I/O * For use on extended C128s with a larger internal memory eg: 256K. In un- expanded machines there is no RAM in these BANKs and 2 echoes 0 and 3 echoes 1. To access a particular bank, type BANK n (n=0-15) and then use PEEK/POKE or SYS. From within the monitor, precede the four-digit hexadecimal number of the address range you are viewing with a hexadecimal digit (0-F). 17.5 BEGIN/BEND ---------- A structure used with IF... THEN ELSE so that you can include several pro- gram lines between the start (BEGIN) and end (BEND) of the structure. Here is the format: IF Condition THEN BEGIN : statement statement statement BEND : ELSE BEGIN statement statement BEND EXAMPLE: 10 IF X=1 THEN BEGIN: PRINT "X=1 is True" 20 PRINT "So this part of the statement is performed" 30 PRINT "When X equals 1" 40 BEND: PRINT "End of BEGIN/BEND structure":GOTO 60 50 PRINT "X does not equal 1":PRINT "The statements between BEGIN/BEND are skipped" 60 PRINT "Rest of Program" If the Conditional (IF... THEN) statement in line 10 is true, the state- ments between the keywords BEGIN and BEND are performed, including all the statements on the same line as BEND. If the (IF... THEN) conditional state- ment in line 10 is False, all statements between the BEGIN and BEND, inclu- ding the ones on the same program line as BEND are skipped, and the program resumes with the first program line immediately following the line con- taining BEND. The BEGIN/BEND essentially treats line 10 through 40 as one long line. The same rules are true if the ELSE:BEGIN clause is specified. If the con- dition is true all statements between ELSE:BEGIN and BEND are performed, including all statements on the same line as BEND. If False, the program resumes with the line immediately following the line containing BEND. 17.6 BLOAD ----- Load a binary file starting at the specified memory location. BLOAD "filename" [,Ddrive number] [Udevice number] [,Bbank number] [,Pstart address] where: * filename is the name of your file * bank number lets you select one of the 16 banks * start address is the memory location where loading begins A binary file is a file, whether a program or data, that has been SAVEd either within the machine language monitor or by the BSAVE command. The BLOAD command loads the binary file into the location specified by the start address. EXAMPLES: BLOAD "SPRITES", B0, P3584 LOADs the binary file "SPRITES" starting in location 3584 in BANK 0. BLOAD "DATA1", D0, U8, B1, P4096 LOADs the binary file "DATA1" into location 4096 (BANK 1) from Drive 0, unit 8. If start address is not specified the file will load at the same address it was saved from. 17.7 BOOT ---- Load and execute a program which has been saved as a binary file. BOOT ["filename"] [,Ddrive number] [Udevice] The command loads an executable binary file and begins execution at the predefined starting address. The default device number is 8 drive 0. EXAMPLES: BOOT BOOT an executable program, (CP/M Plus for example). This is a special case and requires setting up a specific sector on the disk. BOOT"GRAPHICS 1", D0, U9 BOOTs the program "GRAPHICS 1" from unit 9, drive 0 and executes it. Execu- tion begins at the start address of the program (i.e. where it starts loading). 17.8 BOX --- Draw a box at specific position on screen. BOX [color source], x1, y1 [, x2, y2] [,angle] [,paint] where: color source 0=Background color 1=Foreground color 2=Multicolor 1 } 3=Multicolor 2 } Only in Graphics modes 3 and 4 x1, y1 Top left corner coordinate (scaled). x2, y2 Bottom right corner opposite x1, y1 (scaled); default is the PC location. angle Rotation in clockwise degrees; default is zero degrees. paint Paint shape with color 0=Do not paint 1=Paint (default 0) This statement allows the user to draw a rectangle of any size on the screen. Rotation is based on the centre of the rectangle. The pixel cursor (PC) is located at x2, y2 after the BOX statement is executed. The color source number must be zero (0) or one (1) if in standard bit map or a 2 or 3 if in multicolor bit map mode. Also see the GRAPHIC command, in paragraph 17.47, for selecting the appro- priate graphic mode to be used with the BOX color source number. Also see the LOCATE command, in paragraph 17. for information on the pixel cursor. EXAMPLES: BOX 1, 10, 10, 60, 60 Draws the outline of a rectangle. BOX 1, 10, 10, 60, 45, 1 Draws a painted, rotated box (a diamond). DRAW , 30, 90, , 45, 1 Draws a filled, rotated polygon (see note). BOX 1, 20, 20, , ,1 Draws a filled rectangle from 20, 20 to the current pixel cursor. Any parameter can be omitted but you must include a comma in its place, as in the last two examples. NOTE: x2, y2 count as one parameter so only one extra comma is required. Wrapping occurs if the degree is greater than 360, i.e. 360=0 (450=90). 17.9 BSAVE ----- Save a binary file from the specified memory locations. BSAVE "filename" [,Ddrive number] [Udevice number] [,Bbank number], Pstart address TO Pend address+1 where: * filename is the name you give the file * drive number is either 0 or 1 on a dual drive (0 is the default) * device number is the number of disk drive unit (default is 8) * bank number is the number of the bank you specify (0-15) * start address is the starting address where the program is SAVEd from * end address+1 is the end address of the program plus one, i.e. the end address you specify in BSAVE is one byte higher than the end address of the memory range This is the same as the SAVE command in the machine language monitor. EXAMPLES: BSAVE "SPRITE DATA",B0,P3584 TO P4096 Saves the binary file named "SPRITE DATA" starting at location 3584 through 4095 (BANK 0). BSAVE "PROGRAM.SCR",D0,U9,B0,P3182 TO P8000 Saves the binary file named "PROGRAM.SCR" in the memory address range 3182 through 7999 (BANK 0) on drive 0, unit 9. 17.10 CATALOG ------- Displays the disk directory. CATALOG [Ddrive number] [Udevice number] [,wildcard string] The CATALOG command displays the directory on the specified drive just as the directory command. See this command, in paragraph 17.28, for more examples (DIRECTORY and CATALOG are completely interchangeable). EXAMPLE: CATALOG Displays the disk directory on drive 0 of unit 8. 17.11 CHAR ---- Displays characters at the specific position on the screen. CHAR [color source], x, y [,string] [,rvs] This is primarily designed to display characters on a bit mapped screen, but it can also be used on a text screen. Here is what the parameters mean: color source 0=Background color 1=Foreground color 2=Multicolor 1 3=Multicolor 2 x Character column (0-79) (wraps around to the next line in 40-column mode) y Character row (0-24) string String to print RVS Reverse field flag (0=off, 1=on, default=0) Text (alphanumeric strings) can be displayed on any screen at a given loca- tion by the CHAR statement. Character data is read from Commodore 128 character ROM area. The user supplies the x and y coordinates of the star- ting position and the text string to be displayed. Color source and reverse imaging are optional. The string is continued on the next line if it attempts to print past the right hand edge of the screen. When used in text mode, the string printed by the CHAR command works just like a PRINT string, including cursor and color control. These control functions inside the string do not work when the CHAR command is used to display text in bit map mode. Upper/Lower case controls (CHR$(142) or CHR$(14)) also operate in bit map mode. Multicolor characters are handled differently from standard characters. The following table shows how to generate the possible combinations. +------------------------------------------+ | Reverse Flag | | ------------ | | 0(OFF) 1(ON) | +---------------------------+--------------+ | Text | 1 1 | | Color source 0 | | | Background | 2 3 | +---------------------------+--------------+ | Text | 1 0 | | Color source 1 | | | Background | 0 1 | +---------------------------+--------------+ | Text | 2 0 | | Color source 2 | | | Background | 0 2 | +---------------------------+--------------+ | Text | 3 0 | | Color source 3 | | | Background | 0 3 | +---------------------------+--------------+ EXAMPLE: 10 COLOR 2,3: REM multicolor 1=Red 20 COLOR 3,7: REM multicolor 2=Blue 30 GRAPHIC 3,1 40 CHAR 0,10,10,"TEXT",0 50 CHAR 0,10,11,"TEXT",1 17.12 CIRCLE ------ Draws circles, ellipses, arcs, etc. at specific positions on the screen. CIRCLE [color source],x,y,xr [,yr] [,sa] [,ea] [,angle] [,inc] where: color source 0=Background color 1=Foreground color 2=Multicolor 1 } 3=Multicolor 2 } Only in Graphics modes 3 and 4 x,y Centre coordinates of the CIRCLE. xr X radius (scaled). yr Y radius (scaled). sa Starting arc angle (default 0 degrees). ea Ending arc angle (default 360 degrees). angle Rotation in clockwise degrees (default is 0 degrees). inc Degrees between segments (default is 2 degrees). +++ +++ sa + + + / + + + + + xy xr+ + xy + + +---+ + + + + | + + + + |yr+ + + + | + + \ +++ +++ ea With the CIRCLE statement, the user can draw a circle, ellipse, arc, tri- angle, octagon, or other polygon. The final pixel cursor (PC) is left at the circumference of the circle at the ending arc angle. Any rotation is relative to the centre. Arcs are drawn from the starting angle clockwise to the ending angle. The increment controls the smoothness of the shape; using lower values results in more nearly circular shapes. Specifying the inc greater than 2 creates a rough-edged boxed-in shape. Also see the LOCATE command, in paragraph 17.57, for information on the pixel cursor. EXAMPLES: CIRCLE 1,160,100,65,10 Draws an ellipse CIRCLE 1,160,100,65 Draws a circle CIRCLE 1,60,40,20,18,,,,45 Draws an octagon CIRCLE 1,260,40,20,30,,,,90 Draws a diamond CIRCLE 1,60,140,20,18,,,,120 Draws a triangle You may omit a parameter, but you must still place a comma in the appro- priate position. Omitting parameters take on the default values. 17.13 CLOSE Close logical file. CLOSE file number This statement closes any files used by DOPEN or OPEN statements. The num- ber following the word CLOSE is the file number to be closed. EXAMPLE: CLOSE 2 Logical file 2 is closed. 17.14 CLR Clear program variables. CLR This statement erases any variables in memory, but leaves the program in- tact. This statement is automatically executed when a RUN or NEW command is given. 17.15 CMD Redirect screen output. CMD logical file number [,write list] This command sends the output, which normally goes to the screen (i.e. PRINT statements, LIST, but not POKES into the screen) to another device, such as a disk data file or printer. This device or file must be OPENed first. The CMD command must be followed by a number or numeric variable referring to the file or device. The write list can be any alphanumeric string or variable. This command is useful for printing at the top of program listings. EXAMPLES: OPEN 1,4 OPENs device #4, which is the printer. CMD 1 All normal output now goes to the printer. LIST The LISTing goes to the printer, not the screen - even the word READY. PRINT#1 Sends output back to the screen. CLOSE 1 Close the file. 17.16 COLLECT ------- Free inaccessible disk space. COLLECT [Ddrive number] [Udevice] Use this command to make available any disk space that has been allocated to improperly closed (splat) files, and to delete references to these files from the directory. Splat files are files that appear on the directory with an asterisk next to them. Defaults to device number 8. EXAMPLE: COLLECT D0 Free all available space which has been incorrectly allocated to improperly closed files. NOTE: It will also free space allocated for direct access and any boot sector. See your disk drive manual for more information. 17.17 COLLISION --------- Define handling for sprite collision interrupt. COLLISION type [, statement] type Type of interrupt as follows: 1 = Sprite-to-sprite collision 2 = Sprite-to-display collision 3 = Light pen statement BASIC line number of a subroutine When the specified situation occurs, BASIC will finish processing the cur- rent executing instruction and perform a GOSUB to the line number given. When the subroutine terminates (it must end with a RETURN), BASIC will re- sume processing where it left off. Interrupt action continues until a COLLISION of the same type without a line number is specified. More than one type of interrupt may be enabled at the same time, but only one inter- rupt can be handled at a time (i.e. there can be no recursion and no nes- ting of interrupts). The cause of an interrupt may continue causing interrupts for some time unless the situation is altered or the interrupt is disabled. To determine which sprites have collided since the last check, use the BUMP function. EXAMPLES: COLLISION 1, 5000 Detects a sprite-to-sprite collision and program control sent to subroutine at line 5000. COLLISION 1 Stops interrupt action which was initiated in above example. COLLISION 2,1000 Detect sprite-to-display collision and program control directed to subroutine in line 1000. NOTE: Sprites can still collide even if they are set off the screen, but not if they are switched off. 17.18 COLOR ----- Define colors for each screen area. COLOR source number, color number This statement assigns a color to one of the seven color areas: Source Numbers Area Source 0 40-column (VIC) background 1 40-column (VIC) foreground 2 multicolor 1 3 multicolor 2 4 40-column (VIC) border 5 character color (40- or 80-column screen) 6 80-column (VDC) background color Colors that are usable are in the range 1-16: Color Code Color Color Code Color 1 Black 9 Orange 2 White 10 Brown 3 Red 11 Light Red 4 Cyan 12 Dark Gray 5 Purple 13 Medium Gray 6 Green 14 Light Green 7 Blue 15 Light Blue 8 Yellow 16 Light Gray Color Numbers in 40-Column Format 1 Black 9 Dark Purple 2 White 10 Brown 3 Dark Red 11 Light Red 4 Light Cyan 12 Light Purple 5 Dark Cyan 13 Medium Gray 6 Dark Green 14 Light Green 7 Dark Blue 15 Light Blue 8 Light Yellow 16 Light Gray Color Numbers in 80-Column Format EXAMPLES: COLOR 0,1 Change background color of 40-column screen to black. COLOR 5,8 Change character color to yellow. 17.19 CONCAT ------ Concatenates two data files. CONCAT "file 2" [,Ddrive number] TO "file 1" [,Ddrive number] [Udevice] The CONCAT command attaches file 2 to the end of file 1 and retains the name of file 1. The device number defaults to 8 and the drive number defaults to 0. EXAMPLES: CONCAT "FILE B" TO "FILE A" FILE B is attached to FILE A and the combined file is designated FILE A. CONCAT (A$) TO (B$), D1, U9 The file named by B$ becomes a new file of the same name, with the file named by A$ attached to the end of B$ - this is performed on Unit 9, Drive 1 (a dual disk drive). Whenever a variable is used as a filename as in the last example, the file- name variable must be surrounded by parentheses. NOTE: Keep the filenames short (10 characters) because the command buffer is limited in some disk drives. 17.20 CONT Continue program execution. CONT This command is used to restart a program that has been stopped by either using the {stop} key, a STOP statement, or an END statement. The program resumes execution where it left off. CONT will not resume with the program if lines have been changed or added to the program or if any editing of the program is performed on the screen. If the program stopped due to an error, or if you have caused an error before trying to restart the program, CONT will not work. The error message in this case is CAN'T CONTINUE ERROR. 17.21 COPY ---- Copy files from one drive to another in a dual disk drive or within a single drive. COPY <["source filename"] [,Ddrive number]> TO <["destination filename"] [,Ddrive number]> [Udevice] This command copies files from one disk (the source file) to another (the destination file) on a dual-disk drive. It can also create a copy of a file on the same disk within a single drive, but the filename must be different. When copying from one drive to another, the filename may be the same. The COPY command can also COPY all files from one drive to another on a dual disk drive. In this case the drive numbers are specified and the source and destination filenames are omitted. The default parameters for the COPY command are device number 8, drive 0. NOTE: Copying between two single or double drive units cannot be done. See BACKUP, in paragraph 17.3. EXAMPLES: COPY "TEST",D0 TO "TEST PROG",D1 Copies "TEST" from drive 0 to drive 1, renaming it "TEST PROG" on drive 1. COPY "STUFF",D0 TO "STUFF",D1 Copies "STUFF" from drive 0 to drive 1. COPY D0 TO D1 Copies all files from drive 0 to drive 1. COPY "WORK.PROG" TO "BACKUP" Copies "WORK.PRG" as a file called "BACKUP" on the same disk (drive 0). 17.22 DATA Define data to be used by a program. DATA list of constants This statement is followed by a list of data items to be input into the computer's memory by READ statements. The items may be numeric or string and are seperated by commas. String data need not be inside quote marks, unless they contain any of the following characters: {space}, {colon}, or {comma}. If two commas have nothing between them, the value is READ as a zero if numeric or as an empty string. Also see the RESTORE statement, in paragraph 17.75, which allows the Commodore 128 to reREAD data. EXAMPLE: DATA 100,200, FRED, "HELLO MUM", , 3, 14, ABC123 17.23 DCLEAR ------ Clear all open channels on disk drive. DCLEAR [Ddrive number] [Udevice] This statement closes and clears all open channels on the specified device number. Default is U8. This command is analogous to OPEN 0,8,15,"I0": CLOSE 0. EXAMPLES: DCLEAR D0 Clears all open channels on drive 0, device number 8. DCLEAR D1,U9 Clears all open channels on drive 1, device number 9. NOTE: Files will be aborted, data may not be recoverable from files which were being written to. See CLOSE/DCLOSE, in paragraphs 17.13/17.24. 17.24 DCLOSE ------ Close disk file. DCLOSE [#logical file number] [Udevice] This statement closes a single file or all the files currently open on a disk unit. If no logical file number is specified, all currently open files are closed. The default device number is 8. Note the following examples: EXAMPLES: DCLOSE Closes all files currently open on unit 8. DCLOSE #2 Closes the file associated with the logical file number 2. DCLOSE ON U9 Closes all files curently open on unit 9. 17.25 DEF FN Define a user-defined function. DEF FN name(variable) = expression This statement allows definition of a complex calculation as a function. In the case of a long formula that is used several times within a program, this keyword can save valuable program space. The name given to the func- tion begins with the letters FN, followed by any legal numeric variable name (not integer or array). First, define the function by using the state- ment DEF, followed by the name given to the function. Following the name is a set of parentheses ( ) with a local variable name enclosed. This variable only has a value if it appears in the expression on the right of the equal sign. The same variable name can be used elsewhere in a program but it will be completely seperate from its use in the function. Other variables and/or functions can be used in the expression and these are evaluated as their value at the time the function is called. Next is an equal sign, followed by the formula to be defined. The function can be performed by sustituting any number for variable, using the format shown in lines 40 and 50 of the example below. EXAMPLE: 10 DEF FNEG(LO)=INT((V1*LO^2)*100)/100 LO is local to this line 20 LO=15 A normal program variable 30 V1=3.14159 Approximation of {pi} 40 PRINT FNEG(5) Assign 5 to the local value LO in the function. 50 PRINT FNEG(1) Use 1 in the function instead of LO. 60 PRINT INT(V1*LO^2)*100)/100 Variable LO used 70 PRINT LO Remains unchanged 17.26 DELETE ------ Delete lines of a BASIC program in the specified range. DELETE This command can be executed only in direct mode. EXAMPLES: DELETE 75 Deletes line 75. DELETE 10-50 Deletes lines 10 through 50, inclusive. DELETE-50 Deletes all lines from the beginning of the program up to and including line 50. DELETE 75- Deletes all lines from 75 to the end of the program, inclusive. 17.27 DIM Declare number of elements in an array. DIM variable(subscripts) [, variable(subscripts)] [...] Before arrays of variables can be used, the program must first execute a DIM statement to establish DIMensions of the array (unless there are 11 or fewer elements in each DIMension of the array). The DIM statement is fol- lowed by the name of the array, which may be any legal variable name. Then, enclosed in parantheses, the number (or numeric variable) of elements in each dimension. An array with more than one dimension is called a matrix. Any number of dimensions may be used, but keep in mind the whole list of variables being created takes up space in memory, and it is easy to run out of memory if too many are used. Here's how to calculate the amount of memo- ry used by an array: 5 bytes for the array name 2 bytes for each dimension 2 bytes/element for integer variables 5 bytes/element for normal numeric variables 3 bytes/element for string variables 1 byte for each character in each string element Integer arrays take up two-fifths the space of floating point arrays (e.g. DIM A%(100) requires 209 bytes; DIM A(100) requires 512 bytes). NOTE: Elements are numbered from 0, e.g. DIM A(100) gives 101 elements. More than one array can be dimensioned in a DIM statement by seperating the array variable names by commas. If the program executes a DIM statement for any array more than once, the message RE'DIM ARRAY ERROR is posted. It is good programming practice to place DIM statements near the beginning of the program. EXAMPLE: 10 DIM A$(40),B7(15),CC%(4,4,4) 41 elements, 16 elements, 125 elements. 17.28 DIRECTORY --------- Displays the contents of the disk directory on the screen. DIRECTORY [Ddrive number] [Udevice] [, wildcard] The {f3} function key in C128 mode displays the DIRECTORY for device number 8, drive 0. Use CONTROL S or NOSCROLL to pause the display. The DIRECTORY command should not be used to print a hard copy, because some printers interfere with the data coming from the disk drive. The disk directory should be loaded (LOAD "$",8) destroying the current program in memory in order to print a hard copy. The default device number is 8, and the default drive number is 0. EXAMPLES: DIRECTORY Lists all files on the disks in unit 8. DIRECTORY D1, U9, "WORK" Lists the file named "WORK" on drive 1 of unit 9. DIRECTORY "AB*" Lists all files starting with the letters "AB" like ABOVE, ABOARD, etc. on all drives of unit 8. The asterisk specifies a wild card, where all files starting with "AB" are displayed. DIRECTORY D0, "FILE ?.BAK" The ? is a wild card that matches a single character in that position. For example: FILE 1.BAK, FILE 2.BAK, FILE 3.BAK all mat- ching the string. DIRECTORY D1,U9,(A$) Lists the filename stored in the variable A$, on device number 9, drive 1. Remember whenever a variable is used as a filename, surround the variable in parentheses. NOTE: To print the DIRECTORY of the disk in drive 0, unit 8, use the fol- lowing example: LOAD"$0",8 OPEN4,4:CMD4:LIST PRINT#4:CLOSE4 17.29 DLOAD ----- Load a BASIC program from disk. DLOAD "filename" [,Ddrive number] [< ON | ,>Udevice number] This command loads a BASIC program from disk into current memory. (Use LOAD to load programs from tape.) The program must be specified by a file- name of up to 16 characters. DLOAD assumes device number 8, drive 0. EXAMPLES: DLOAD "BANKRECS" Searches the disk for the program "BANKRECS" and LOADs it. DLOAD (A$) LOADs a program from disk whose name is stored in the variable A$. An error message is given if A$ is empty. Remember, when a variable is used as a filename, it must be enclosed in parentheses. The DLOAD command can be used within a BASIC program to find another pro- gram on disk. This is called chaining. 17.30 DO/LOOP/WHILE/UNTIL/EXIT ------------------------ Define and control progam loop. DO [UNTIL condition | WHILE condition] statement [EXIT] LOOP [UNTIL condition | WHILE condition] This loop structure performs the statements between the DO statement and the LOOP statement. If no UNTIL or WHILE statements modifies either the DO or the LOOP statement, execution of the statements in between continues indefinitely. If an EXIT statement is encountered in the body of a DO loop, execution is transferred to the first statement following the LOOP state- ment. DO loops may be nested, following the rules defined by the FOR... NEXT structure. If the UNTIL parameter is specified, the program continues looping until the condition is satisfied (becomes true). The WHILE para- meter is basically the oposite of the UNTIL parameter: the program conti- nues looping as long as the condition is true. As soon as the condition is no longer true, program control resumes with the statement immediately fol- lowing the LOOP statement. An example of a condition (boolean operation) is A=1, or G>65. EXAMPLES: 10 X=25 20 DO UNTIL X=0 30 X=X-1 40 PRINT "X=";X 50 LOOP 60 PRINT "END OF LOOP" This example performs the statement X=X-1 and PRINTs "X=";X until X=0. When X=0 the program resumes with the statement following LOOP, PRINT "END OF LOOP" 10 DO WHILE A$="":GET A$:LOOP 20 PRINT "THE ";A$;" KEY HAS BEEN PRESSED" A$ remains null as long as no key is pressed. As soon as a key is pressed program control passes to the statement immediately following LOOP, PRINT "THE ";A$;" KEY HAS BEEN PRESSED". The example performs a GET A$ as long as A$ is a null character. This loop constantly checks to see if a key on the keyboard is being pressed. Note that the statement GETKEY A$ has the same effect as line 10. 10 OPEN #8,"SEQFILE" 20 DO 30 GET #8,A$ 40 PRINT A$; 50 LOOP UNTIL ST 60 DCLOSE #8 This program opens the file "SEQFILE" and gets data until the ST system variable indicates all data is input. A value of 0 indicates a FALSE con- dition, nonzero is true. ST is normally 0. 17.31 DOPEN ----- Open a disk file for a read and/or write operation. DOPEN #logical file number,"filename[,]" [,Lrecord length] [,Ddrive number] [Udevice number] [,w] where: S = Sequential file type. P = Program file type. L = Record length = the length of records in a relative file only. w = Write operation (if not specified a read operation occurs). This statement opens a sequential, program or relative file for a read or write operation. The record length (L) pertains to a relative file, which can be as long as 254. The w parameter is specified only during a write (PRINT#) operation in a sequential file. If not specified, the disk drive assumes the disk operation to be a read operation. Relative file are open for both read and write operations at the same time. The logical file number associates a number to a file for future disk operations such as a read (INPUT# or GET#) or write (PRINT#) operation. The logical file number can range from 1 to 255. Logical file numbers greater than 128 automatically send a carriage return and linefeed with each PRINT# command. Logical file number less than 128 send only a carriage return, which can be suppressed with a semicolon at the end of the PRINT# command. The default device number is 8, and the default drive is 0. EXAMPLES: DOPEN#1,"ADDRESS",W Open the sequential file number 1 (ADDRESS) for a write operation. DOPEN#2,"RECIPES",D1,U9 Open the sequential file number 2 (RECIPES) for a read operation on device number 9, drive 1. DOPEN#3,"BOOKS",L128 Open the relative file number 3 (BOOKS) for read and write on unit 8 drive 0. Record length is 128 characters. 17.32 DRAW ---- Draw dots, lines and shapes at specified positions on screen. DRAW [color source], x1,y1 [TO x2,y2] ... This statement draws individual dots, lines, and shapes. Here are the para- meter values: color source= 0 Background color 1 Foreground color 2 Multicolor 1 } 3 Multicolor 2 } Only in Graphics modes 3 and 4 x1, y1 Starting coordinate, scaled x2, y2 Ending coordinate, scaled Also see the LOCATE command, in paragraph 17.57, for information on the pixel cursor. EXAMPLES: DRAW 1,100,50 Draw a dot DRAW ,10,10 TO 100,60 Draw a line DRAW ,10,10 TO 10,60 TO 100,60 TO 10,10 Draw a triangle You may omit a parameter but you still must include the comma that would have followed the unspecified parameter. 17.33 DSAVE ----- Save a BASIC program file to disk. DSAVE "filename" [,Ddrive number] [Udevice number] This command stores (SAVEs) a BASIC program on disk. (See SAVE, in paragraph 17.80, to store programs on tape.) A filename up to 16 characters long must be supplied. The default device number is 8, while the default drive number is 0. EXAMPLES: DSAVE "BANKRECS" SAVEs the program "BANKRECS" to disk. DSAVE (A$) SAVEs the disk program named in the variable A$. DSAVE "PROG 3",D1,U9 SAVEs the program "PROG 3" to disk on unit 9, drive 1 (on a dual drive unit). 17.34 DVERIFY ------- Verify the program in memory against the one on disk. DVERIFY "filename" [,Ddrive number] [Udevice number] This command causes the Commodore 128 to check the program on the specified drive against the program in memory. The default drive number is 0 and the default device number is 8. NOTE: If graphic area is allocated or deallocated after a SAVE, an error occurs. Technically this is correct. Because BASIC text is moved from its original (SAVEd) location when a bit mapped graphics area is allocated or deallocated, the original location where the C128 verified the SAVEd pro- gram changes. Hence, VERIFY, which performs byte-to-byte comparisons, fails, even though the program is valid. To verify binary data, see VERIFY "filename",8,1 format, under VERIFY command description. EXAMPLES: DVERIFY "C128" Verifies program "C128" on drive 0, unit 8. DVERIFY "SPRITES",D0,U9 Verifies program "SPRITES" on drive 0, device 9. 17.35 END Define the end of program execution. END When the program encounters the END statement, it stops RUNning immediate- ly. The CONT command can be used to restart the program at the next state- ment (if any) following the END statement. 17.36 ENVELOPE -------- Define a musical instrument envelope. ENVELOPE n [,atk] [,dec] [,sus] [,rel] [,wf] [,pw] where: n Envelope number (0-9) atk Attack rate (0-15) dec Decay rate (0-15) sus Sustain level (0-15) rel Release rate (0-15) wf Waveform: 0 = triangle 1 = sawtooth 2 = variable pulse (square) 3 = noise 4 = ring modulation pw Pulse width (0-4095) A parameter that is not specified will retain its predefined or currently redefined value. Pulse width applies to the width of the variable pulse waveform (wf=2) only and is determined by the formula: pwout = pw/40.95, so that pw=2048 produces a square wave and values 0 and 4095 produce constant DC output. The Commodore 128 has initialized the following 10 envelopes: n, A, D, S, R, wf, pw instrument ENVELOPE 0, 0, 9, 0, 0, 2, 1536 piano ENVELOPE 1, 12, 0, 12, 0, 1 accordion ENVELOPE 2, 0, 0, 15, 0, 0 calliope ENVELOPE 3, 0, 5, 5, 0, 3 drum ENVELOPE 4, 9, 4, 4, 0, 0 flute ENVELOPE 5, 0, 9, 2, 1, 1 guitar ENVELOPE 6, 0, 9, 0, 0, 2, 512 harpsicord ENVELOPE 7, 0, 9, 9, 0, 2, 2048 organ ENVELOPE 8, 8, 9, 4, 1, 2, 512 trumpet ENVELOPE 9, 0, 9, 0, 0, 0 xylophone To play predefined musical instrument envelopes, you simply specify the envelope number in the PLAY command (see PLAY, paragraph 17.64). You do not need to use the ENVELOPE command. The ENVELOPE command is used only when you need to change the envelope. 17.37 FAST ---- Put machine in 2 Mhz mode of operation. FAST This command initiates 2 Mhz mode, causing VIC's 40 column screen to be turned off. All operartions (except I/O) are speeded up considerably. Graphics may be used, but will not be visible until a SLOW command is issued. 17.38 FETCH ----- Get data from expansion (RAM module) memory. FETCH #bytes, intsa, expsa, expb where #bytes = number of bytes to get from expansion memory (0-65535) intsa = starting address of host RAM (0-65535) expsa = starting address of expansion RAM (0-65535) expb = 64K expansion RAM bank number (0-15) 17.39 FILTER ------ Define sound (SID chip) filter parameters. FILTER [freq] [,lp] [,bp] [,hp] [,res] where: freq Filter cut-off frequency (0-2047). lp Low-pass filter on (1), off (0). bp Band-pass filter on (1), off (0). hp High-pass filter on (1), off (0). res Resonance (0-15). Unspecified parameters result in no change to the current value. You can use more than one type of filter at a time. For example, both low- pass and high-pass filters can be used together to produce a notch (or band- reject) filter response. For the filter to have an audible effect, at least one type of filter must be selected and at least one voice must be routed through the filter. EXAMPLES: FILTER 1024,0,1,0,2 Set the cutoff frequency at 1024, select the band pass filter and a resonance level of 2. FILTER 2000,1,0,1,10 Set the cutoff frequency at 2000, select both the low pass and high pass filters (to form a notch- reject) and set the resonance level at 10. 17.40 FOR/TO/STEP/NEXT Define a repetitive program loop structure. FOR variable = start value TO end value [STEP increment] NEXT [variable] The FOR statement works with the NEXT statement to set up a section of the program that repeats for a set number of times (i.e. a loop). This is use- ful when something needs to be counted or something must be done a certain number of times (such as printing). This statement executes all the commands enclosed between the FOR and NEXT statements repetitively, according to the start and end values. The start value and end value are the beginning and ending counts for the loop variable. The loop variable is added to or subtracted from during the FOR... NEXT loop. The logic of the FOR... NEXT statement is as follows. First, the loop variable is set to the start value. When the program reaches a program line containing the NEXT statement, it adds the STEP increment (default = 1) to the value of the loop variable and checks to see if it is higher than the end value of the loop. If the loop variable is less than or equal to the end value, the loop is executed again, starting with the statement imme- diately following the FOR statement. If the loop variable is greater than the end value, the loop terminates and the program resumes immediately fol- lowing the NEXT statement. The opposite is true if the step size is nega- tive. EXAMPLE A EXAMPLE B 10 FOR L=1 TO 10 10 FOR L=10 TO 1 STEP-1 20 PRINT L 20 PRINT L 30 NEXT L 30 NEXT L 40 PRINT "I'M DONE! L =";L 40 PRINT "I'M DONE! L =";L Program A prints the number from one to 10, followed by the message I'M DONE! L = 11. Program B prints the numbers down to one and them I'M DONE! L = 0. The end value of the loop may be followed by the word STEP and another num- ber or variable. In this case, the value following the word STEP is added each time, instead of the default value one. This allows counting back- wards, by fractions, or increments other than one. The user can set up loops inside one another. These are known as nested loops. Care must be taken when nesting loops so, that the last loop to start is the first one to end. EXAMPLE: 10 FOR L = 1 TO 100 20 FOR A = 5 TO 11 STEP .5 30 NEXT A 40 NEXT L The FOR... NEXT loop in lines 20 and 30 are nested inside the one in line 10 and 40. The STEP increment of .5 is used to illustrate the fact that floating point indices are valid. 17.41 GET Receive input data from the keyboard, one character at a time without waiting for a key to be pressed. GET variable list The GET statement reads each key typed by the user. As the user types, the characters are stored in the computer's memory (in an area called the key- board buffer). Up to 10 characters can be stored here1, any characters typed after the 10th character are lost. The GET statement reads the first character from the buffer and moves the rest up, allowing room for more. If there are no characters in the buffer a null (empty) character is returned. The word GET is followed by a variable name, either numeric or string. GET will not pause the program if no characters are in the buffer (see GETKEY, in paragraph 17.42). If the C128 intends to GET a numeric key and a key other than a number is pressed, the program stops and a TYPE MISMATCH error message is displayed. The GET statement may also be put into a loop, checking for an empty result. The GETKEY statement could also be used in this case. See GETKEY, in paragraph 17.42, for more information. The GET and GETKEY statements can be executed only within a program. EXAMPLES: 10 DO:GET A$:LOOP UNTIL A$="A" This line waits for the A key to be pressed to continue. 20 GET B, C, D Get numeric variables B, C and D from the keyboard without waiting for a key to be pressed. 17.42 GETKEY ------ Receive input data from the keyboard, one character at a time and wait for a key to be pressed. GETKEY variable list The GETKEY statement is very similar to the GET statement. Unlike the GET statement, GETKEY, if there is no character in the keyboard buffer, will wait for the user to type a character on the keyboard. This lets the com- puter wait for a single character to be typed. This statement can be exe- cuted only within a program. EXAMPLES: 10 GETKEY A$ This line waits for a key to be pressed. Typing any key continues the program. 10 GETKEY A$,B$,C$ This line waits for three alphanumeric characters to be entered from the keyboard. GETKEY can also be used to READ numeric keys. NOTE: GETKEY cannot return a null (empty) character. 17.43 GET# Receive input data from a tape, disk or RS232. GET#file number, variable list This statement inputs one character at a time from a previously opened file. Otherwise, it works like the GET statement. This statement can be executed only within a program. EXAMPLE: GET#1,A$ This example receives one character, which is stored in the variable A$, from file number 1. This example assumes that file 1 was previously opened. See the OPEN and DOPEN state- ments, in paragraphs 17.62 and 17.31,respectively. 17.44 GO64 ---- Switch to C64 mode. GO64 This statement switches from C128 mode to C64 mode. The question "Are You Sure?" is displayed in response to the GO64 statement. If {y} is typed, then the currently loaded program is lost and control is given to the C64 mode; otherwise, if any other key is pressed, the computer remains in C128 mode. This statement can be used in direct mode or within a program. The prompt is not displayed in program mode. 17.45 GOSUB Call a subroutine from the specified line number. GOSUB line number This statement is similar to the GOTO statement, except the Commodore 128 returns from where it came when the subroutine is finished. When a line with a RETURN statement is encountered, the program jumps back to the statement immediately following the GOSUB statement. The target of a GOSUB statement is called a subroutine. A subroutine is useful if a task is repeated several times within a program. Instead of duplicating the section of program over and over, set up a subroutine, and GOSUB to it at the appropriate time in the program. See also the RETURN statement, in paragraph 17.77. EXAMPLE: 20 GOSUB 800 : : 799 END 800 PRINT "HI THERE": RETURN This example calls the subroutine beginning at line 800 and executes it. All subroutines terminate with a RETURN statement. Line 799 stops the program accidentally falling into the subroutine. 17.46 GOTO/GO TO Transfer program execution to the specified line number. GOTO line number After a GOTO statement is encountered in a program, the computer executes the statement specified by the line number in the GOTO statement. When used in direct mode, GOTO executes (RUNs) the program starting at the specified line number, without clearing the variables. This is the same as the RUN command except it does not clear variable values. EXAMPLES: 10 PRINT"COMMODORE" 20 GOTO 10 The GOTO in line 20 makes line 10 repeat continuously until {run/stop} is pressed. GOTO 100 Starts (RUNs) the program starting at line 100, without clearing the variable storage area. 17.47 GRAPHIC ------- Select a graphic mode. GRAPHIC mode [,clear] [,s] GRAPHIC CLR This statement puts the Commodore 128 in one of the six graphic modes: Mode Description 0 40-column (VIC) standard text 1 Standard bit map 2 Standard bit map (split screen) 3 Multicolor bit map 4 Multicolor bit map (split screen) 5 80-column text The clear parameter specifies whether the bit mapped screen is cleared (equal to 1) upon running the program, or left intact (equal to 0). The s parameter indicates the starting line number of the split screen when in graphic mode 2 or 4 (standard or multicolor bit map split screen modes). The default starting line number of the split screen is 19. When executed, GRAPHIC 1-4 allocated a 9K bit mapped area. The start of BASIC text area is moved above the bit map area, and any BASIC program is automatically relocated. This area remains allocated even if the user returns to TEXT mode (GRAPHIC 0). If the clear option is specified as 1, the screen is cleared. The GRAPHIC CLR command deallocates the 9K bit mapped area, making it available again for BASIC text. Any BASIC program is relocated. EXAMPLES: GRAPHIC 1,1 Select standard bit map mode and clear the bit map. GRAPHIC 4,0,10 Select split screen multicolor bit map mode, do not clear the bit map and start the split screen at line 10. GRAPHIC 0 Select 40 column text. GRAPHIC 5 Select 80 column text. GRAPHIC CLR Clear and deallocate the bit map screen. 17.48 HEADER ------ Formats a diskette. HEADER diskname [,I i.d.] [,Ddrive number] [Udevice number] where: diskname - Any name up to 16 characters. i.d. - Any two alphanumeric characters. You must use two - you may not leave a space. Before a new disk can be used for the first time, it must be formatted with the HEADER command. The HEADER command can also be used to erase a pre- viously formatted disk, which can then be reused. When you enter a HEADER command in direct mode, the prompt ARE YOU SURE? appears. In program mode, the prompt does not appear. The command divides the disk into sections called blocks. It creates a table of contents of files, called a directory. Give each disk a unique i.d. number. Be careful when using the HEADER command because it erases all stored data. You can HEADER a diskette more quickly if it was already formatted (by a HEADER command), by omitting the new disk i.d. The old i.d. is used in- stead. The quick HEADER can be used only if the disk was previously format- ted, since it clears out the directory rather than formatting the disk. The default device number is 8 and the default drive is 0. As a precaution, the system asks ARE YOU SURE? before the Commodore 128 completes the operation. Press the {y} key to perform the HEADER, or press any other key to cancel it. The HEADER command reads the disk command error channel, and if any error is encountered, the error message ?BAD DISK is displayed. The HEADER command is analogous to the BASIC 2.0 command: OPEN 1,8,15,"N0:diskname,i.d." : CLOSE 1 EXAMPLES: HEADER "MYDISK",I51,D0 This HEADERs "MYDISK" using i.d. 51 on drive 0, (default) device number 8. HEADER "RECS",I45,D1 ON U9 This HEADERs "RECS" using i.d. 45, on Drive 1, device number 9. HEADER "C128 PROGRAMS",D0 This is a quick HEADER on drive 0, device number 8, assuming the disk in the drive was already formatted. The old i.d. is used. 17.49 HELP ---- Highlight the line where the error occurred. HELP The HELP command is used after an error has been reported in a program. When HELP is typed in 40-column format, the line where the error occurs is listed, with the portion containing the error displayed in reverse field. In 80-column format, the portion of the line where the error occurs is underlined. Pressing the {help} key types HELP{return} automatically. 17.50 IF/THEN/ELSE ---- Evaluate a conditional expression and execute portions of a program depen- ding on the outcome of the expression. IF expression THEN statements (BASIC 2.0) IF expression THEN statements [:ELSE else-clause] (BASIC 7.0) The IF... THEN statement evaluates a BASIC expression and takes one or two possible courses of action depending upon the outcome of the expression. If the expression is true, the statement(s) following THEN is executed. This may be any BASIC statement. If the expression if false, the program resumes with the program line immediately following the program line containing the IF statement, unless an ELSE clause is present. The entire IF... THEN statement must be contained within 160 characters (80 in C64 mode). Also see BEGIN/BEND, in paragraph 17.5. The ELSE clause, if present, must be on the same line as the IF... THEN portion of the statement, and separated from the THEN clause by a colon {:}. When an ELSE clause is present, it is executed only when the expres- sion if false. The expression being evaluated may be a variable or a for- mula, in which case it is considered true if nonzero, and false if zero. In most cases, there is an expression involving relational operators (=, <, >, >=, <>). The IF... THEN statement can take two alternate forms: IF expression THEN line number or IF expression THEN GOTO line number These forms transfer program execution to the specific line number if the expression is true. Otherwise, the program resumes with the program line number immediately following the line containing the IF statement. EXAMPLES: 50 IF X>0 THEN PRINT "OK": ELSE END This line checks the value of X. If X is greater than 0, the statement im- mediately following the keyword THEN (PRINT"OK") is executed and the ELSE clause is ignored. If X is less than or equal to 0, the ELSE clause is exe- cuted and the statement immediately following THEN is ignored. 10 IF X=10 THEN 100 20 PRINT"X does not equal 10" . . 99 STOP 100 PRINT "X equals 10" This example evaluates the value of X. If X equals 10, the program control is transferred to line 100 and the message "X EQUALS 10" is printed. If X does not equal 10, the program resumes with line 20, the C128 prints the prompt "X DOES NOT EQUAL 10" and the program stops. NOTE: The ELSE extension cannot be used in C64 mode. 17.51 INPUT Receive a data string or a number from the keyboard and wait for the user to press {return}. INPUT ["prompt string";] variable list The INPUT statement asks for data from the user while the program is RUNning and places the data into a variable or variables. The program stops, prints a question mark (?) on the screen, and waits for the user to type the answer and hit the {return} key. The word INPUT is followed by a prompt string and a variable name or list of variable names separated by commas. The message in the prompt string inside quotes suggests (prompts) the information the user should enter. If this message is present, there must be a semicolon (;) after the closing quote of the prompt. When more than one variable is INPUT, seperate them by commas. The compu- ter asks for the remaining values by typing two question marks (??). If the {return} key is pressed without INPUTting a value, the INPUT variable retains its previous value. The INPUT statement can be executed only with- in a program. EXAMPLE: 10 INPUT "PLEASE TYPE TWO NUMBER";A,B 20 INPUT "AND YOUR NAME";A$ 30 PRINT A$;", YOU TYPED THE NUMBER"A;"AND";B 17.52 INPUT# Inputs data from a file into the computer's memory. INPUT#file number, variable list This statement works like input, but takes the data from a previously OPENed file usually on a disk or tape instead of the keyboard. No prompt string is used. This statement can be used only within a program. EXAMPLE: 10 OPEN 2,8,2,"DATAFILE,S,R" 20 INPUT#2,A$, C, D$ 30 CLOSE 2 In line 20 data is INPUT from the file "DATAFILE" and stores it in varia- bles A$, C and D$. 17.53 KEY --- Define or list function key assignments. KEY [key number, string] There are eight function keys (F1 - F8) available to the user on the Commo- dore 128: four unshifted and four shifted. The Commodore 128 allows you to perform a function or operation for each time the specified function key is pressed. The definition assigned to a key can consist of data, or a command or series of commands. KEY with no parameters specified returns a listing displaying all current KEY assignments. If data is assigned to a function key, that data is displayed on the screen when that function key is pres- sed. The maximum length of all the definitions together is 246 characters. EXAMPLES: KEY 7,"GRAPHIC0" + CHR$(13) + "LIST" + CHR$(13) This tells the computer to select the (VIC) 40-column text screen and list the program whenever the {f7} key is pressed (in direct mode). CHR$(13) is the ASCII character for {return} and performs the same action as pressing the {return} key. Use CHR$(27) for the {esc} key. Use CHR$(34) to incor- porate the double quote character into a KEY string. The keys may be rede- fined in a program. For example: 10 KEY 2,"PRINT DS$" + CHR$(13) This tells the computer to check and display the disk drive error channel variable (PRINT DS$) each time the {f2} key is pressed. To restore all function keys to their BASIC default values, reset the Com- modore 128 by pressing the {reset} button (or switch off and then on). 17.54 LET Assigns a value to a variable. [LET] variable = expression The word LET is rarely used in programs, since it is not necessary. When- ever a variable is defined or given a value, LET is always implied. The variable name that receives the result of a calculation is on the left side of the equal sign. The number, string or formula is on the right side. You can only assign one value with each (implied) LET statement. For example, LET A=B=2 is not (normally) legal. EXAMPLES: LET A = 5 Assign the value 5 to numeric variable A. B = 6 Assign the value 6 to numeric variable B. C = A * B + 3 Assign the numeric variable C, the value resulting from 5 times 6 plus 3. D$ = "HELLO" Assign the string "HELLO" to string variable D$. 17.55 LIST List the BASIC program currently in memory. LIST [line | first- | first-last | -last] The LIST command displays a BASIC program listing that has been typed or LOADed into the Commodore 128's memory so you can read and edit it. When LIST is used alone (without numbers following it), the Commodore 128 gives a complete LISTing of the program on the screen. The listing process may be slowed down by holding the {C=} key, paused by {ctrl s} or {noscroll} key (and resumed by pressing any key), or stopped by hitting the {run/stop} key. If the word LIST is followed by a line number, the Commodore 128 shows only that line number. If LIST is typed with two line numbers seperated by a dash all lines from the first to the second number are displayed. If LIST is typed followed by a number and just a dash, the Commodore 128 shows all line from that number to the end of the program. And if LIST is typed with a dash, then a number, all lines from the beginning of the program to that line number are LISTed. By using these variations, any portion of a program can be examined or brought to the screen for modification. In Commodore 128 mode, LIST can be used in a program. EXAMPLES: LIST Shows entire program. LIST 100- Shows from line 100 until the end of the program. LIST 10 Shows only line 10. LIST -100 Shows all lines from the beginning to line 100 inclusive. LIST 10-200 Shows lines from 10 to 200, inclusive. 17.56 LOAD Load a program from a peripheral device such as the disk drive or Datas- sette. LOAD ["filename"] [,device number] [,relocate flag] This is the command used to recall a program stored on disk or cassette tape. Here, the filename is a program name up to 16 characters long, in quotes. The name must be followed by a comma (outside the quotes) and a number which acts as a device number to determine where the program is stored (disk or tape). If no number is supplied, the Commodore 128 assumes device number 1 (the Datassette tape recorder). The relocate flag is a number (0 or 1) that determines where a program is loaded in memory. A relocate flag of 0 tells the Commodore 128 to load the program at the start of the BASIC program area. A flag of 1 tells the com- puter to LOAD from the point where it was SAVEd. The default value of the relocate flag is 0. The relocate parameter of 1 is generally used when loading machine language programs. The device most commonly used with the LOAD command is the disk drive. This is device number 8, though the DLOAD command is more convenient to use when working with disk. If LOAD is typed with no arguments, followed by {return}, the C128 assumes you are loading from tape and you are prompted to "PRESS PLAY ON TAPE". When you press PLAY, the Commodore 128 starts looking for a program on tape. When the program is found, the Commodore 128 prints FOUND "filename", where the filename is the name of the first file which the datassette finds on the tape. Press the {C=} key to LOAD the found filename, or press the {spacebar} to keep searching on the tape. Once the program is LOADed, it can be RUN, LISTed or modified. NOTE: Pressing the {spacebar} does not cause the next file to be searched for in C64 mode. EXAMPLES: LOAD Reads in the next program from tape. LOAD "HELLO" Searches tape for a program called "HELLO", and LOADs it if found. LOAD A$,8 LOADs the program from disk whose name is stored in the variable A$. (This is the equivalent to DLOAD(A$).) LOAD"HELLO",8 Looks for the program called "HELLO" on disk drive number 8, drive 0. (This is equivalent to DLOAD "HELLO".) LOAD"MACHLANG",8,1 LOADs the machine language program called "MACHLANG" into the location from which it was saved. The LOAD command can be used within a BASIC program to find and RUN the next program on a tape or disk. This is called chaining. 17.57 LOCATE ------ Position the bit map pixel cursor on the screen. LOCATE x,y The LOCATE statement places the pixel cursor (PC) at any specified pixel coordinate on the screen. The pixel cursor (PC) is the coordinate on the bit map screen where drawing of circles, boxes, lines and points and where PAINTing begins. The PC ranges from x,y coordinates 0,0 throught 319,199 (scaled) in hi-res and 159,199 (scaled) in multicolor bit map. The PC is not visible like the text cursor, but it can be controlled through the graphics statements (BOX, CIRCLE, DRAW, etc.). The default location of the pixel cursor is the coor- dinate specified by the x and y portions in each particular graphics com- mand. So the LOCATE command does not have to be specified. EXAMPLE: LOCATE 160,100 Position the PC in the centre of the standard bit map screen. Nothing will be seen until something is drawn. The PC can be found by using RDOT(0) function to get the x-coordinate and RDOT(1) to get the y-coordinate. The color source of the dot at the PC can be found by PRINTing RDOT(2). 17.58 MONITOR ------- Enter the Commodore 128 machine language monitor. MONITOR See Appendix J for details on the Commodore 128 Machine Language Monitor. 17.59 MOVSPR ------ Position or move sprite on the screen. MOVSPR number,x1,y1 Place the specified sprite at absolute coordinate x,y (scaled). MOVSPR number,+/- x, +/- y Move sprite relative to its current posi- tion. MOVSPR number,X;Y Move sprite distance X at angle Y relative to its current position. MOVSPR number,x angle #y speed Move sprite at an angle relative to its original coordinates, in the specified clockwise direction and speed. where: number is sprite's number (1 through 8) <,x,y> is the coordinate of the sprite location (scaled) angle is the angle (0-360) of motion in the clockwise direction relative to the sprite's original coordinates speed is a speed (0-15) at which the sprite moves This statement locates a sprite at a specific location on the screen accor- ding to the SPRITE coordinate plane (not the bit map plane) or initiates sprite motion at a specific rate. See MOVSPR in paragraph 6.3.7 of Section 6 for a diagram of the sprite coordinate system. EXAMPLES: MOVSPR 1,150,150 Position sprite 1 near the centre ot the screen, x,y coordinate 150, 150. MOVSPR 1,+20,-30 Move sprite 1 to the right 20 coordinates and up 30 coordinates. MOVSPR 4,-50,+100 Move sprite 4 to the left 50 coordinates and down 100. MOVSPR 5,45 #15 Move sprite 5 at an 45 degree angle in the clockwise direction, relative to its original x and y coor- dinate. The sprite moves at the fastest rate (15). NOTE: Once you specify an angle and a speed in the fourth form of the MOVSPR statement, you must set a speed of zero to stop the sprite moving. 17.60 NEW Clear (erase) program and variable storage. NEW This command erases the entire program in memory and clears any variables that may have been used. Unless the program was stored on disk or tape, it is lost. Be careful with the use of this command. The NEW command also can be used as a statement in a BASIC program. However, when the Commodore 128 gets to this line, the program is erased and everything stops. 17.61 ON Conditional branch to a specified program line number according to the re- sults of the specified expression. ON expression line #1 [,line #2, ...] This statement can make the GOTO and GOSUB statements operate like special versions of the (conditional) IF statement. The word ON is followed by an expression, then either of the keywords GOTO or GOSUB and a list of line numbers separated by commas. If the result of the expression is 1, the first line number in the list is executed. If the result is 2, the second line number is executed on so on. If the result is 0, or larger than the number of line numbers in the list, the program resumes with the statement immediately following the ON statement. If the number is negative, an ILLEGAL QUANTITY error results. EXAMPLE: 10 INPUT X:IF X<0 THEN 10 20 ON X GOSUB 30, 40, 50, 60 25 GOTO 10 30 PRINT "X=1":RETURN 40 PRINT "X=2":RETURN 50 PRINT "X=3":RETURN 60 PRINT "X=4":RETURN When X=1, ON sends control to the first line number in the list (30). When X=2, ON sends control to the second line (40), etc. 17.62 OPEN Open files for input or output. OPEN logical file number, device number [,secundary address] [<,"filename, filetype, mode" | cmd string>] The OPEN statement allows the Commodore 128 to access files within devices such as a disk drive, a Datassette cassette recorder, a printer or even the screen of the Commodore 128. The word OPEN is followed by a logical file number, which is the number to which all other BASIC input/output statements will refer, such as PRINT# (write), INPUT# (read), etc. This number is from 1 to 255. The second number, called the device number follows the logical file num- ber. Device number 0 is the Commodore 128 keyboard; 1 is the cassette recorder; 3 is the Commodore 128 screen; 4-7 are normally the printer(s); 8-11 are reserved for disk drives. It is often a good idea to use the same file number as the device number, because it makes it easy to remember which is which. Following the device number may be a third parameter called the secundary address. In the case of the cassette, this can be 0 for read, 1 for write and 2 for write with END-OF-TAPE marker at the end. In case of the disk, the number refers to the channel number. See you disk drive manual for more information on channels and channel numbers. For the printer, the secundary addresses are used to select certain programming functions. There may also be a filename specified for disk or tape OR a string fol- lowing the secundary address, which could be a command to the disk/tape drive or the name of the file on tape or disk. If the filename is speci- fied, the type and mode refer to disk files only. File types are PROGRAM, SEQUENTIAL, RELATIVE and USER; modes are READ and WRITE. EXAMPLES: 10 OPEN 3,3 OPENs the screen as file number 3. 20 OPEN 1,0 OPENs the keyboard as file number 1. 30 OPEN 1,1,0,"DOT" OPENs the cassette for reading, as file number 1, using "DOT" as the filename. OPEN 4,4 OPENs the printer as file number 4. OPEN 15,8,15 OPENs the command channel on the disk as file 15, with secundary address 15. (Secundary address 15 is reserved for the disk drive error command channel.) 5 OPEN 8,8,12, OPENs a sequential disk file for writing called "TESTFILE,SEQ,WRITE" "TESTFILE" as file number 8, with secundary address 12. See also: CLOSE (17.13), CMD (17.15), GET# (17.43), INPUT# (17.52), and PRINT# (17.67) statements and system variables ST, DS and DS$ (19.1). 17.63 PAINT ----- Fill area with color. PAINT [color source], x, y [,mode] where: color source 0 Background color 1 Foreground color 2 Multicolor 1 3 Multicolor 2 x,y Starting coordinates, scaled (default at pixel cursor (PC)). mode 0 = Paint an area defined by the color source selected (default). 1 = paint an area defined by any non-background source. The PAINT command fills an area with color, the area is defined by a fully enclosed shape around, but not including the x,y coordinates specified. Points where the color source is the same as the source of the pixel are not PAINTed. (See example 3.) If mode=0 the area filled must be bounded by the color source, any other color sources which lie within this boundery are overPAINTed. (See example 1.) If mode=1 the boundery of the area is any color source (except 0). No color sources will be overPAINTed; i.e. only non-PAINTed areas can be filled when mode=1. (See example 2.) EXAMPLE 1: 10 COLOR 0,1:COLOR 1,2: COLOR 2,5:COLOR 3,7 20 GRAPHIC 3,1 multicolor graphics 30 CIRCLE 1,80,100,30 draw circle in color source 1 40 CIRCLE 3,80,100,35 draw circle in color source 3 50 BOX 2,80,100,90,110,45,1 draw filled box in color source 2 60 PAINT 3,70,100,0 paint inner circle in color source 3 bounded only by color source 3 EXAMPLE 2: As example 1, but change line 60 to: 60 PAINT 3,70,100,1 paint inner circle bounded by non-background color source EXAMPLE 3: As example 2, but add lines 70 and 80: 70 COLOR 2,8 change color source to yellow 80 PAINT 2,90,110,1 attempt to repaint the box fails, because color source in PAINT and at (90,100) are the same (2). 17.64 PLAY ---- Define and play musical notes and elements. PLAY "[Vn] [On] [Tn] [Un] [Xn] [elements] [...]" where: Vn = Voice (n=1-3) On = Octave (n=0-6) Tn = Tune Envelope (n=0-9) 0 = piano 1 = accordion For 2 = calliope default envelope 3 = drum settings 4 = flute (see ENVELOPE 5 = guitar command, paragraph 6 = harpsichord 17.36) 7 = organ 8 = trumpet 9 = xylophone Un = Volume (n=0-9) (0=off; 9=full (VOL 15)) Xn = Filter on (n=1), off (n=0) Elements: NOTES: A, B, C, D, E, F, G # Sharp* $ Flat* W Whole note H Half note Q Quarter note I Eighth note S Sixteenth note . Dotted* R Rest M Wait for all voices currently playing to end current measure The PLAY statement gives you the power to select voice, octave and tune envelope (including ten predefined musical instrument envelopes), the volume and the notes you want to PLAY. All these controls are enclosed in quotes. All elements except R and M precede the musical notes in a PLAY string. NOTE: * These must precede each musical note. EXAMPLES: PLAY "V1O4T0U5X0CDEFGAB" Play the notes C, D, E, F, G, A, and B in voice 1, octave 4, tune enve- lope 0 (piano - assuming you have not altered it with ENVELOPE), at volume 5, with the filter off. PLAY "V3O5T6U7X1#B$AW.CHDQEIF" Play the notes B-sharp, A-flat, a whole dotted-C note, a half D-note, a quarter E-note and an eighth F-note. NOTE: You will need to set up a filter before you can hear anything with this example - try FILTER 1024,1. 17.65 POKE Change the contents of a RAM memory location. POKE address, value The POKE statement allows changing of any value in the Commodore 128 RAM, and allows modification of many of the Commodore 128 Input/Output registers. The keyword POKE is always followed by two parameters. The first is a location inside the Commodore 128 memory, this can be a value from 0 to 65535. The second parameter is a value from 0 to 255, which is placed in the location, replacing any value that was there previously. The value of the memory location determines the bit pattern of the memory location. In C128 mode the POKE occurs into the current selected RAM bank. The POKE address depends on the BANK number. See BANK in paragraph 17.4 of this Ency- clopaedia for the appropriate BANK configurations. EXAMPLE: 10 POKE 53280,1 Changes VIC border color (BANK 15 in C128 mode). NOTE: PEEK, a function related to POKE, which returns the contents of the specified memory location is listed under BASIC Functions. 17.66 PRINT Output to text screen PRINT print list The PRINT statement is the major output statement in BASIC. While the PRINT statement is the first BASIC statement most people learn to use, there are many variations of this statement. The word PRINT can be followed by any of the following: Characters inside of quotes ("text" lines) Variable names (A, B, A$, X$) Functions (SIN(23), ABS(33)) Punctuation marks (; ,) The characters inside quotes are often called literals because they are printed literally, exactly as they appear. Variable names have the value they contain (either a number or a string) printed. Functions also have their number values printed. Punctuation marks are used to help format the data neatly on the screen. The comma tabs to the nearest tenth column, while the semicolon prints items next to each other. Either punctuation mark can be used as the last symbol in the statement. This results in the next PRINT statement acting as if it is continuing the previous PRINT statement. PRINT on its own moves to the start of the next line - leaving a blank line. EXAMPLES: RESULTS 10 PRINT "HELLO" HELLO 20 A$=" THERE":PRINT "HELLO";A$ HELLO THERE 30 A=4:B=2:PRINT A+B 6 40 J=41:PRINT J;:PRINT J-1 41 40 50 PRINT A;B;:D=A+B:PRINTD;A-B 4 2 6 2 See also POS, SPC and TAB Functions, in Section 18, paragraphs 18.24, 18.37, and 18.40, respectively. 17.67 PRINT# Output data to files. PRINT# file number, print list There are a few differences between this statement and the PRINT. Most im- portantly, the word PRINT# is followed by a number, which refers to the data file previously OPENed. The number is followed by a comma and a list of items to be output to the file. The semicolon acts in the same manner for spacing in printers as it does in the PRINT statement, commas output 10 spaces. Some devices may not work with TAB and SPC. EXAMPLES: 10 OPEN 4,4 20 PRINT#4,"HELLO THERE!",A$,B$ Outputs the data "HELLO THERE" and the variables A$ and B$ to the printer. 10 OPEN 2,8,2,"DATAFILES,S,W" 20 PRINT#2,A,B$,C,D This example outputs the data variables A, B$, C and D to the disk file number 2. NOTE: The PRINT# command is used by itself to clear the channel to a device after outputting via CMD and before closing the file as follows: OPEN 4,4 CMD 4 LIST PRINT#4 CLOSE 4 See also the CMD command, in paragraph 17.15. 17.68 PRINT USING ----------- Output using format PRINT[#filenumber,] USING "format list"; print list This statement defines the format of string and numeric items for printing to the text screen, printer or other device. The format is put in quotes. This is the format list. Then add a semicolon and a list of what is to be printed in the format for the print list. The list can be variables or the actual values to be printed, separated by commas. FORMAT STRING USED WITH CHARACTER NUMERIC STRING Hash sign (#) X X Plus sign (+) X Minus sign (-) X Decimal point (.) X Comma (,) X Dollar sign ($) X Four Carets (^^^^) X Equal sign (=) X Greater than sign (>) X The hash sign {#} reserves room for a single character in the output field. With Numeric Data if the data item contains more characters than there are # signs in the format field, the entire field is filled with asterisks {*}; no characters are printed. EXAMPLE: 10 PRINT USING "####";X For these values of X, this format displays: X = 12.34 12 X = 567.89 568 Note that the number is rounded up. X = 123456 **** For a STRING item, the string data is truncated at the bounds of the field. Only as many characters are printed as there are hash signs in the format item. Truncation occurs on the right. The plus (+) and minus (-) signs can be used in either the first or the last position of the format field, but not both. The plus sign is printed if the number is positive. The minus sign is printed if the number is nega- tive. If a minus sign is used and the number is positive, a blank is printed in the character position indicated by the minus sign. If neither a plus nor a minus sign is used in the format field for a nume- ric data item, a minus sign is printed before the first digit or dollar symbol if the number is negative. No sign is printed if the number is posi- tive. This means that one additional character, the minus sign, is printed if the number is negative. If there are too many characters to fit into the field specified by the hash signs and plus/minus sign, then an overflow oc- curs and the field is filled with asterisks {*}. A decimal point {.} symbol designates the position of the decimal point in the number. There can be only one decimal point in any format field. If a decimal point is not specified in the format field, the value is rounded to the nearest integer and printed without decimal places. When a decimal point is specified, the number of digits preceding the deci- mal point (including the minus sign, if the value is negative) must not exceed the number of hash signs before the decimal point. If there are too many digits, an overflow occurs and the field is filled with asterisks {*}. A comma {,} allows placing of commas in numeric fields. The position of the comma in the format list indicates where the commas appear in a printed number. Only commas within a number are printed. Unused commas to the left of the first digit appear as filler character. At least one hash sign must precede the first comma in the field. If commas are specified in a field and the number is negative, then a minus sign is printed as the first character, even if the character position is specified as a comma. A dollar sign ($) symbol shows that a dollar sign will be printed in the number. If the dollar sign is to float (always be placed before the num- ber), at least one hash sign must be specified before the dollar sign. If a dollar sign is specified without a leading hash sign, the dollar sign is printed in the position shown in the format field. If a plus or minus sign are specified in a format field with a dollar sign, the program prints the sign before the dollar sign. EXAMPLES: Field Expression Result Comment ##.# -.1 -0.1 Leading zero added. ##.# 1 1.0 Trailing zero added. #### -100.5 -101 Rounded to no decimal places. #### -1000 **** Overflow because four digits and a minus sign cannot fit in field. ###. 10 10. Decimal point added. #$## 1 $1 Leading dollar sign. The up arrows or caret symbols {^^^^} are used to specify that the number is to be printed in the E format (scientific notation). A hash sign must be used in addition to the four carets to specify the field width. The carets must appear after the hash sign in the format field. Four carets must be specified when a number is to be printed in E format. If fewer than four carets are specified, a syntax error results. If more than four carets are specified, only the first four are used. The fifth and subsequent carets are interpreted as text symbols. You can specify a {+} or {-} sign after the carets if you require a trailing sign. An equal {=} sign is used to centre a string in a field. The field width is specified by the number of characters (the hash signs and an equal sign) in the format field. If the string contains fewer characters than the field width, the string is cen- tered in the field. If the string contains more characters than can be fitted into the field, then the rightmost characters are truncated and the string fills the entire field. A greater than {>} sign is used to right justify a string in a field. Other characters can be included in a format string, these are treated as literals. This allows you to build up tables and charts. See line 30 in the program below for a specific example of this. EXAMPLE: 5 X=32: Y=100.23: A$="CAT": B$="COMPUTER" 6 F$=* #=########## * #$##.## *+CHR$(13) 10 PRINT USING "$##.##";13.25,X,Y 20 PRINT USING "###>#";"CBM",A$ 30 PRINT USING F$;A$,X,B$,Y (CHR$(13) is {return}) When this program is RUN, line 10 prints: $13.25 $32.00 $***** Five asterisks {*****} are printed instead of a Y value, because Y has five digits which does not con- form to the format list (as explained above). Line 20 prints this: CBM CAT Leaves two spaces before printing the string, as defined in the format list. Line 30 prints this: * CAT * $23.00 * * COMPUTER * $100.23 * 17.69 PUDEF ----- Redefine symbols in PRINT USING statements. PUDEF "nnnn" Where "nnnn" is any combination of characters, up to four in all, PUDEF allows you to redefine any of the following four symbols in the PRINT USING statement: blanks, commas, decimal points and dollar signs. These four sym- bols can be changed into some other character by placing the new character in the correct position in the PUDEF control string. Position 1 is the filler character. The default is a blank. Place a new character here for another character to appear in place of blanks. Position 2 is the comma character. Default is a comma. Position 3 is the decimal point. Default is a decimal point. Position 4 is the dollar sign. Default is a dollar sign. EXAMPLE: 10 PUDEF"*" PRINTs * in the place of blanks. 20 PUDEF" <" PRINTs < in the place of commas. NOTE: All positions up to the one(s) to be changed must be specified. For example PUDEF " $" would print the $ in place of the dollar sign, but the decimal point, comma and filler character would all be set to space. PUDEF only affects numeric formats i.e. PUDEF "0" will change filler spaces in numbers to leading 0s, but will not affect filler spaces in strings. The character to replace the $ has no effect unless the $ in the format string of PRINT USING is preceded by a # (i.e. is floating). 17.70 READ Read data from DATA statements and input it into the computer's memory (while the program is RUNning) READ variable list This statement takes information from DATA statements and stores them in variables, where the data can be used by the RUNning program. The READ statement variable list may contain both strings and numbers. Be careful to avoid reading strings where the READ statement expects a number, this pro- duces a TYPE MISMATCH ERROR message. The data in the DATA statements are READ in sequential order. Each READ statement can read one or more data items. Every variable in the READ statement requires a DATA item. If one is not supplied, an OUT OF DATA ERROR occurs. In a program, you can READ the data and the reREAD by issuing the RESTORE statement. The RESTORE statement sets the sequential data pointer back to the beginning, where the data can be READ again. See the RESTORE statement, in paragraph 17.75. EXAMPLES: 10 READ A, B, C 20 DATA 3, 4, 5 READ 3 data items (which must be numeric or an error will occur) into variables A, B and C. 10 READ A$, B$, C$ 20 DATA JOHN, PAUL, GEORGE READ three strings from DATA statements. 10 READ A, B$, C 20 DATA 1200, NANCY, 345 READ a numeric value, a string, and another numeric value. 17.71 RECORD ------ Position relative file pointers. RECORD#logical file number, record number [,byte] This statement positions a relative file pointer to select any byte (character) of any record in the relative file. The logical file number can be in the range between 1 and 255. The record number can be in the range 1 through 65535. Byte number is in the range 1 through 254. See your disk drive manual for details about relative files. When the record number value is set higher than the last record number in the file, the following occurs: For a write (PRINT#) operation, additional records are created to expand the file to the desired record number. For a read (INPUT# or GET#) operation, a null record is returned and a RECORD NOT PRESENT error occurs. EXAMPLE: 10 DOPEN #2,"CUSTOMER" 20 RECORD#2,10,1 30 PRINT#2,A$ 40 DCLOSE #2 This example opens an existing relative file called "CUSTOMER" as file number 2 in line 10. Line 20 positions the relative file pointer at the first byte in record number 10. Line 30 actually writes the data, A$, to the file. The RECORD command accepts variables for its parameters. It is often con- venient to place the RECORD command within a FOR... NEXT or DO loop. Also see DOPEN, in paragraph 17.31. 17.72 REM Comment or remark about the operation of a program line. REM [message] The REMark statement is a note to whoever is reading a listing of the pro- gram. REM may explain a section of the program, give information about the author, etc. REM statements do not affect the operation of the program, except to add length to it (and therefore use more memory). Nothing to the right of the keyword REM is interpreted by the computer as an executable instruction. Therefore, no other executable statement can follow a REM on the same line. EXAMPLE: 1010 NEXT X: REM END OF MAIN PROGRAM LOOP 17.73 RENAME ------ Change the name of a file on disk. RENAME [Ddrive number,] "old filename" TO "new filename" [Udevice number] This command is used to rename a file on disk, from the old filename to the new filename. The diskdrive does not RENAME a file if it is OPEN. EXAMPLES: RENAME D0, "TEST" TO "FINAL TEST" Change the name of the file "TEST" to "FINAL TEST". RENAME D0,(A$) TO (B$),U9 Change the filename specified in A$ to the filename specified in B$ on drive 0, device number 9. Remember, whenever a variable name is used as a filename, it must be enclosed in parentheses. 17.74 RENUMBER -------- Renumber lines of a BASIC program. RENUMBER [new starting line number] [,increment] [,old starting line number] The new starting line is the number of the first line in the program after renumbering; the default is 10. The increment is the interval between line numbers (i.e. 10, 20, 30, etc.); the increment default value is also 10. The old starting line number is the first line number before you renumber the program. The default in this case is the first line of the program. This command can only be executed from direct mode. An UNRESOLVED REFERENCE error occurs if any reference to number that does not exist is encountered. An OUT OF MEMORY occurs if RENUMBERing expands the program beyond its limits. A LINE NUMBER TOO LARGE error occurs if RENUMBER generates a line number of 64000 or higher. These errors leave the program unharmed. EXAMPLES: RENUMBER Renumbers the program starting at 10, and increments each additional line by 10. RENUMBER 20,20,15 Starting at line 15, renumbers the program. Line 15 becomes 20, and other lines are numbered in incre- ments of 20. RENUMBER,,65 Starting at line 65, renumbers in increments of 10. Line 65 becomes 10. If you omit a parameter, you must still enter a comma as a placeholder. There must be no line between 10 and 64 inclusive. ALWAYS SAVE YOUR PROGRAM BEFORE RENUMBERING, because very long programs can cause a SYSTEM crash when RENUMBERed with larger line numbers. Also note that long programs should be RENUMBERed in FAST mode as they will take a long time to renumber (up to 30 minutes for a 55K program in FAST). If you only have a 40 column display use FAST:RENUMBER... {return}. Then type SLOW {return}. While RENUMBERing is taking place you will not see any- thing happening. When RENUMBERing has finished, you display will return. If you have an 80 column display or 40/80 column display select the 80 column screen before typing FAST. 17.75 RESTORE/RESTORE ------- Reset READ pointer to DATA statement so the DATA can be reREAD. RESTORE (C64 mode) RESTORE [line #] (C128 mode) When executed in a program, the pointer to the item in a DATA statement that is to be READ next is reset to the first item in the DATA statement. This provides the capability to reREAD the data. If a line number follows the RESTORE statement the READ pointer is set to the first data item after the specified program line. Otherwise the pointer is reset to the beginning of the BASIC program. In C64 mode there is no option to specify the line number, i.e. you can only RESTORE to the beginning of the program. EXAMPLES: 10 FOR I=1 TO 3 20 READ X 30 T = X + T 40 NEXT 45 PRINT T 50 RESTORE 69 GOTO 10 70 DATA 10,20,30 This example READs the data in line 70 and stores it in numeric variable X. It adds the total (T) of all the numeric data items. Once all the data has been READ, three cycles through the loop, the READ pointer is RESTOREd to the beginning of the program and it returns to line 10 and performs repeti- tively. 10 READ A,B,C 20 DATA 100,500,750 30 READ X,Y,Z 40 DATA 36,24,38 50 RESTORE 40 60 READ S,P,Q 70 PRINT A,B,C 80 PRINT X,Y,Z 90 PRINT S,P,Q This example RESTOREs the DATA pointer to the first data item in line 40. When line 60 is executed, it will READ the DATA 36,24,38 from line 40, since you don't need to READ line 20's DATA again. NOTE: If a line number is specified the line must exist! A variable can be used e.g. RESTORE LR. 17.76 RESUME ------ Define where the program will continue (RESUME) after an error has been trapped. RESUME [line # | NEXT] This statement is used to restart program execution after TRAPping an error. With no parameters, RESUME attempts to re-execute the line in which the error occurred. RESUME NEXT resumes execution at the statement im- mediately following the one containing the error; RESUME followed by a line number will GOTO the specific line and resumes execution from that line number. RESUME can only be used in program mode. EXAMPLE: 10 TRAP 100 20 INPUT "ENTER A NUMBER";A 30 B=100/A 40 PRINT"THE RESULT=",B:PRINT"THE END" 50 PRINT"DO YOU WANT TO RUN IT AGAIN(Y/N)":GETKEYZ$:IF Z$="Y"THEN 20 60 STOP 100 INPUT"ENTER ANOTHER NUMBER (NOT ZERO)";A 110 RESUME This example traps a division by zero error in line 30 if 0 is entered in line 20. If zero is entered, the program goes to line 100, where you are asked to input another number besides 0. Line 110 returns to line 30 to complete the calculation. Line 50 asks if you want to repeat the program again. If you do, press the {y} key. 17.77 RETURN Return from subroutine. RETURN This statement is always paired with the GOSUB statement. When a program encounters a RETURN statement, it goes to the statement immediately fol- lowing the last GOSUB command executed. If no GOSUB was previously issued, the a RETURN WITHOUT GOSUB error message is displayed and the program stops. All subroutines end with a RETURN statement. EXAMPLE: 10 PRINT "ENTER SUBROUTINE" 20 GOSUB 100 30 PRINT "END OF SUBROUTINE" . . . 90 STOP 100 PRINT "SUBROUTINE 1" 110 RETURN This example calls the subroutine at line 100 which prints the message "SUBROUTINE 1" and RETURNs to line 30, the rest of the program. 17.78 RREG ---- Read the contents of the accumulator AC, X register XR, Y register YR and Status register SR. RREG [var1] [, [var2] [, [var3] [, [var4] ] ] ] After a SYS command is issued, the contents of the CPU registers AC, XR, YR and SR are stored in memory before the C128 returns to BASIC. The memory locations of these stores are: AC -> 6 XR -> 7 YR -> 8 SR -> 5 With the RREG command the values in these memory stores are loaded into the specified variables. The values range between zero and 255 (inclusive). Not all variables have to be specified. For instance, it is possible to only read the contents of YR: RREG , ,YR : PRINT YR EXAMPLE: 100 FOR I=4864 TO 4870 110 READ D : POKE I,D 120 NEXT I 130 DATA 169,6,162,7,160,8,96 131 REM ML PRG 132 REM 133 REM 01300 LDA #6 ; LOAD AC WITH VALUE 6 134 REM 01302 LDX #7 ; LOAD XR WITH VALUE 7 135 REM 01304 LDY #8 ; LOAD YR WITH VALUE 8 136 REM 01306 RTS ; END ML SUBROUTINE 140 SYS 4864 150 RREG AC, XR, YR 160 PRINT "AC=";AC, "XR=";XR, "YR=";YR 170 M6 = PEEK(6) : REM MEMORY LOCATION 6 180 M7 = PEEK(7) : REM MEMORY LOCATION 7 190 M8 = PEEK(8) : REM MEMORY LOCATION 8 200 PRINT "MEMORY LOCATIONS 6, 7 AND 8:"; M6;","M7;","M8 Line 160 prints this: AC= 6 XR= 7 YR= 8 Line 200 prints this: MEMORY LOCATIONS 6, 7 AND 8: 6 , 7 , 8 17.79 RUN/RUN --- Execute BASIC program. RUN [line #] RUN "filename" [,Ddrive number] [Udevice number] (BASIC 7.0 only) Once a program has been typed into memory or LOADed, the RUN command exe- cutes it. RUN clears all variables in the program before starting program execution. If there is a number following the RUN command, execution starts at that line number. If there is a filename following the RUN command, the named file is loaded from the disk drive and RUN, with no further action required by the user. RUN may be used within a program. The default drive number is 0 and default device number is 8. EXAMPLES: RUN Starts execution from the beginning of the program currently in memory. RUN 100 Starts program execution at line 100. RUN"PRG1" DLOADs "PRG1" from disk drive 8, and runs it from the first line. RUN(A$) DLOADs the program named in the variable A$ and runs it from the first line. 17.80 SAVE Store the program in memory to disk or tape. SAVE ["filename"] [,device number] [,EOT flag] This command stores the program currently in memory onto cassette tape or disk for later retrieval. If SAVE is typed alone an unnamed file will be saved to tape. Tape is a sequential system and, therefore, it is up to the user to ensure that there is nothing important on the tape before SAVEing (see VERIFY, in paragraph 17.100). To give your program a name simply en- close the chosen name in quotes (or use a string variable) immediately after typing SAVE. A filename can be up to 16 characters. NOTE: When SAVEing to disk you must specify a filename or you will get a MISSING FILE NAME ERROR. To specify the device number (e.g. 1 for tape) place a comma followed by the device number after the closing quote following the filename. The final parameter (EOT) follows the device number and is again seperated by a comma. It has no significance when used with disk and can have one of four values when used with tape. These options are: 0 Default - no action. 1 SAVE so that the relocate function of LOAD does not work, i.e. the file will always load back at the address from which it was SAVEd. 2 Write an END OF TAPE marker at the end of the file - attempts to LOAD beyond the end of a file saved this way will generate a FILE NOT FOUND ERROR. 3 SAVEs in non-relocatable format (1) and writes the EOT (2). NOTE: If you specify the device number or EOT parameter the filename (and device number) must be included. For tape this may be a null (""). See the following examples. EXAMPLES: SAVE "HELLO" Stores a program on tape, under the name HELLO SAVE A$,8 Stores on disk, with the name stored in variable A$. SAVE "HELLO",8 Stores on disk, with the name HELLO (equivalent to DSAVE "HELLO"). SAVE "HELLO", 1, 2 Stores on tape, with the name HELLO, and places an END-OF-TAPE marker after the program. SAVE "",1,3 Stores on tape, with no name, places an EOT marker after the program, does not allow the program to be relocated on loading. 17.81 SCALE ----- Alter scaling in graphics mode. SCALE n [,xmax,ymax] where: n = 1 (on) or 0 (off) xmax is in the range 320-32767, default 1023 (hi-res) default 2047 (multicolor) ymax is in the range 200-32767, default 1023 Changes the scaling of the bit map display coordinates in both multicolor and high resolution modes. Coordinates for the MOVSPR command are also scaled. Maps many logical points to one physical point. This is helpful when you need to plot data over a wide range of values - it will not help if you have a large cluster of data with only high values. Because multicolor uses 2 physical pixels on the x-axis per dot, its normal display is: X=0 to 159 ; Y=0 to 199 as opposed to X=0 to 319 ; y=0 to 199 If you wish to use the same coordinates for multicolor and hi-res use SCALE 1,640,200 after setting up a multicolor screen and use the default SCALE values for both types of screen. NOTE: The GRAPHIC command turns scaling off, i.e. using GRAPHIC (something) is equivalent to GRAPHIC...: SCALE 0. EXAMPLE: 10 GRAPHIC 1: GOSUB 100 20 SCALE 1: GOSUB 100 30 SCALE 1,5000,5000: GOSUB 100 40 END 100 CIRCLE 1,160,100,60: RETURN 17.82 SCNCLR ------ Clear screen. SCNCLR [mode number] Mode Number Mode 0 40 column (VIC) text. 1 bit map*. 2 split screen bit map*. 3 multicolor bit map*. 4 split screen multicolor bit map*. 5 80 column (VDC 8563) text. This statement with no arguments clears the graphics screen, if it is pre- sent, otherwise the current text screen is cleared**. EXAMPLES: SCNCLR 5 Clears 80 column text screen. SCNCLR 1 Clears the (VIC) bit map screen. SCNCLR 4 Clears the (VIC) multicolor bit map split screen. NOTE *: The bit map area is the same for both hi-res and multicolor, the different mode numbers select other parameters to clear e.g. 40 column text (2 and 4) and color RAM (3 and 4). NOTE **: If a graphics screen has been created but is not selected (GRAPHIC=0) it will not be cleared. If you are using 2 screens (80 column for text and 40 column for graphics) SCNCLR will clear both text and graphics screens if called from the 80 column screen. 17.83 SCRATCH ------- Delete a file from the disk directory. SCRATCH "filename" [,Ddrive number] [Udevice number] This command deletes a file form the disk directory. As a precaution, the system asks "Are you sure?" (in direct mode only) before the Commodore 128 starts the operation. Type a {y} to perform the SCRATCH or press any other key to cancel the operation. Use this command to erase unwanted files, and to create more space on the disk. The filename may contain template, or wildcards (?,*). The default drive number is 0 and default device number is 8. EXAMPLE: SCRATCH "MY BACK",D0 This erases the file "MY BACK" from the disk in drive 0 of unit 8. 17.84 SLEEP ----- Delay program for a specific period of time. SLEEP n where n is seconds (0 < n < 65536) If you select a delay which is too long for your program and you want to halt it, the {stop} key can be used to break into a delay. 17.85 SLOW ---- Return the Commodore 128 to 1 Mhz operation. SLOW The Commodore 128 is capable of running the 8502 microprocessor at a speed of 1 or 2 Megahertz (Mhz). The SLOW command slows down the microprocessor to 1 Megahertz from 2 Mega- hertz. The FAST command sets the Commodore 128 at 2 Mhz. The Commodore 128 can process commands substantially faster at 2 Mhz than at 1 Mhz. Note, however, that the 40 column screen cannot be used at 2 Mhz. 17.86 SOUND ----- Outputs sound effects and musical notes. SOUND v, f, d [, dir] [, m] [, s] [, w] [, p] where: v = voice 1, 2 or 3 f = frequency value (0-65535) d = duration (0-32767) dir = step direction (0 = up, 1 = down, 2 = oscillate), default=0 m = minimum frequency (0-65535) if the sweep is used, default=0 s = step value for sweep (0-65535), default=0 w = waveform (0 = triangle, 1 = sawtooth, 2 = pulse, 3 = noise), default=2 p = pulse width (0-4095), default=2048 The SOUND command is a fast and easy way to create sound effects and musi- cal tones. The three required parameters v, f and d select the voice, fre- quency and duration of the sound. The duration is in units called jiffies. Sixty jiffies equals 1 second. The SOUND command can sweep through a series of frequencies which allows sound effects to pass through a range of notes. Specify the direction of the sweep with the dir parameter. Set the minimum frequency of the sweep with m and the step value of the sweep with s. Select the appropriate wave- form with w and specify p as the width of the variable pulse waveform if selected in w. EXAMPLES: SOUND 1,40960,60 Play a SOUND at frequency 40960 in voice 1 for 1 second. SOUND 2,2000,5,0,2000,100 Output a sound by sweeping through the fre- quencies starting at 2000 and incrementing upward in units of 100. SOUND 3,5000,1,2,3000,500,1 This example outputs a range of sounds starting at a minimum frequency of 3000, through 5000, in increments of 500. The di- rection of the sweep is back and forth (oscillating). The selected waveform is saw- tooth and the voice selected is 3. 17.87 SPRCOLOR -------- Set multicolor 1 and/or multicolor 2 colors for all sprites. SPRCOLOR [smcr1] [, smcr2] where: smcr1 = multicolor 1 for all sprites. smcr2 = multicolor 2 for all sprites. These parameters may be any color from 1 through 16. EXAMPLES: SPRCOLOR 3,7 Sets sprite multicolor 1 to red and multicolor 2 to blue. SPRCOLOR 1,2 Sets sprite multicolor 1 to black and multicolor 2 to white. 17.88 SPRDEF ------ Enter the SPRite DEFinition mode to create and edit sprite images (40 column display only). SPRDEF The SPRDEF command defines sprites interactively. Entering the SPRDEF command, displays a sprite work area on the screen which is 24 characters wide by 21 characters tall. Each character position in the grid corresponds to a sprite pixel in the sprite displayed to the right of the work area. Here is a summary of the SPRite DEFinition mode operations and the keys that perform them: At the SPRITE NUMBER? prompt user input description {return} Exits SPRite DEFinition mode at the SPRITE NUMBER? prompt only. {1} - {8} Selects a sprite number and enters sprite edit mode. In the sprite edit mode user input description {a} Turns on and off Automatic cursor movement. {crsr} Moves cursor. keys {return} Moves cursor to start of next line. {home} Moves cursor to top left corner of sprite work area. {clr} Erases entire grid. {1}-{4} Selects color source: 1 = clear 2 = foreground 3 = multicolor 1 4 = multicolor 2 {ctrl 1} - Selects sprite foreground color (1-8). {ctrl 8} {C= 1} Selects sprite foreground color (9-16). - {C= 8} {stop} Cancels changes and returns to the READY prompt. {shift Saves sprite in memory and returns to the SPRITE NUMBER? return} prompt. {x} Expands sprite in X (horizontal) direction - Toggle. {y} Expands sprite in Y (vertical) direction - Toggle. {m} Standard sprite / Multicolor sprite - Toggle. {c} Copies sprite data from one sprite to another. NOTE: Using SPRDEF will clear the bit map screen. 17.89 SPRITE ------ Turn on or off, color, expand and set screen priorities for a sprite. SPRITE [,on/off] [,fgnd] [,priority] [,x-exp] [,y-exp] [,mode] The SPRITE statement controls most of the characteristics of a sprite. Parameter Description number Sprite number (1-8). on/off Turns sprite on (1) or off (0). fgnd Sprite foreground color (1-16). priority Priority is 0 if sprites appear in front of object on the screen; priority is 1 if sprites appear behind objects on the screen. x-exp Horizontal EXPansion on (1) or off (0). y-exp Vertical EXPansion on (1) or off (0). mode Select standard sprite (0) or multicolor sprite (1). (See SPRCOLOR, in paragraph 17.87) Unspecified parameters in subsequent sprite statements take on the charac- teristics of the previous SPRITE statement. You can check the characteris- tics of a SPRITE with the RSPRITE function. EXAMPLES: SPRITE 1,1,3 Turn on SPRITE number 1 and color it red. SPRITE 2,1,7,1,1,1 Turn on SPRITE number 2, color it blue, make it pass behind objects on the screen and expand it in horizontal and vertical directions. SPRITE 6,1,1,0,0,1,1 Turn on SPRITE number 6, color it black. The first appearing 0 tells the computer display the sprites are in front of objects on the screen. The second 0 and the following 1 tell the C128 to expand the sprite vertically only. The last 1 specifies the sprite to be displayed in multico- lor mode. Use the SPRCOLOR command to select the sprite's multicolor. SPRITE 7,,,,1 Set the horizontal expansion of SPRITE number 7 - all other options retain their previous settings. 17.90 SPRSAV ------ Store a sprite data from a text string variable into a sprite storage area or vice versa. SPRSAV origin,destination This command transfers a sprite image from a string variable to a sprite storage area. It can also tranfer data from the sprite storage area into a string variable. Either the origin or the destination can be a sprite num- ber or a string variable but they both cannot be string variables (they both CAN be sprite numbers, however). If you are moving a string into a sprite, only the first 63 bytes of data are used. The rest are ignored, since a sprite can only hold 63 data bytes. NOTE: SPRSAV sprite, string produces a string in the same format as SSHAPE so that it can be used with GSHAPE to 'fix' a sprite onto hi-res screen. The string will be 67 characters long. EXAMPLES: SPRSAV 1,A$ Transfers the image pattern from sprite 1 to the string named A$. SPRSAV B$,2 Transfers the data from the string variable B$ into sprite 2. SPRSAV 2,3 Transfers the data from sprite 2 to sprite 3. 17.91 SSHAPE/GSHAPE ------------- Save/retrieve shapes to/from string variables. SSHAPE and GSHAPE are used to save and load rectangular areas of multicolor or standard bit mapped screen to/from BASIC string variables. The command to save an area of the screen into a string variable is: SSHAPE string variable, x1, y1 [, x2, y2] where: string variable String name to save data in x1, y1 Corner coordinates (0,0 through 319,199) (scaled). x2, y2 Corner coordinates opposite (x1,y1) (default is the PC) Because BASIC limits strings to 255 characters, the size of the area that can be saved is limited. The string size required can be calculated using one of the following (unscaled) formulas: L(hi-res) = INT( (ABS(x1-x2) + 1) / 8 + .99) * (ABS(y1-y2) + 1) + 4 L(multicolor) = INT( (ABS(x1-x2) + 1) / 4 + .99) * (ABS(y1-y2) + 1) + 4 NOTE: The upper limits of the coordinates (319,199 for standard and 159,199 for multicolor bit mapped graphics) apply to the unSCALEd coordinate system. When SCALE is turned on, the limit are set by the SCALE command. The command to retrieve (load) the data from a string variable and display it on specified screen coordinates is: GSHAPE string variable, [x,y] [,mode] where: string Contains shape to be drawn. x,y Top left coordinates (0,0 through 319,199) telling where to draw the shape (scaled), default is the pixel cursor. mode Replacement mode: 0: place shape as is (default). 1: invert (reverse) shape. 2: OR shape with area. 3: AND shape with area. 4: XOR shape with area. The replacement mode allows you to change the data in the string variable so that you can invert it, perform a logical OR, exclusive OR or AND operation on the image. Also see the LOCATE command, in paragraph 17.57, for information on the pixel cursor. EXAMPLES: SSHAPE A$,10,10 Saves a rectangular area from the coordinates (10,10) to the location of the pixel cursor, into string variable A$. SSHAPE B$,20,30,47,51 Saves a rectangular area from top left coordinates (20,30) throught bottom coordinates (47,51) into string variable B$. GSHAPE A$,120,20 Retrieves shaped contained in string variable A$ and displays it at top left corner at coordinates (120, 20). GSHAPE B$,30,30,1 Retrieves shape contained in string B$ and displays it at top left coordinates (30,30). The shape is inverted due to the replacement mode being selected by the 1. NOTE: Beware using modes 1-4 with multicolor shapes. You may obtain unpre- dictable results. 17.92 STASH ----- Move contents of host memory to expansion RAM. STASH #bytes, intsa, expsa, expb Refer to FETCH command for description of parameters. 17.93 STOP Halt program execution. STOP This statement halts the program. A message, BREAK IN LINE xxx occurs (in program mode), where xxx is the line number containing the STOP command. The program can be restarted at the statement following STOP if the CONT command is used immediately, without any editing occuring in the listing. The STOP statement is often used while debugging a program. 17.94 SWAP ---- Swap contents of host RAM with contents of expansion RAM. SWAP #bytes, intsa, expsa, expb Refer to FETCH command for description of parameters. 17.95 SYS/SYS --- Call and execute a machine language subroutine at the specified address. SYS address (C64 mode) SYS address [, [a] [, [x] [, [y] [, [s] ] ] ] ] (C128 mode) This statement performs a call to a machine code subroutine at the given address in a memory configuration set up according to the BANK command. Optionally, arguments a, x, y and s are loaded into the accumulator, x, y and status registers respectively, before the subroutine is called. The address range is 0 to 65535 (both inclusive). The program begins exe- cuting the machine language program starting at that memory location. Also see the BANK command, in paragraph 17.4. EXAMPLES: SYS 40960 Calls and executes the machine language routine at location 40960. SYS 8192,0 Calls and executes the machine language routine at location 8192 and loads zero into the accumulator. 17.96 TEMPO ----- Define the speed of the song being played. TEMPO n where n is a relative duration between 1 and 255 (inclusive). The actual duration for a whole note is determined by using the formula given below: whole note duration = 23.06/n seconds The default value of n is 8, and note duration decreases with n. EXAMPLES: TEMPO 16 Defines the TEMPO at 16. TEMPO 1 Defines the TEMPO at the slowest speed. TEMPO 250 Defines the TEMPO at 250. 17.97 TRAP ---- Detect and handle program errors while a BASIC program is RUNning. TRAP [line#] When turned on, TRAP intercepts all error conditions (excluding DOS error messages, but including the {stop} key). In the event of any execution er- ror, the error flag is set and execution is transferred to the line number specified in the TRAP statement. The line number in which the error occurred can be found by using the system variable EL. The specific error condition is contained in system variable ER. The string function ERR$(ER) gives the error message corres- ponding to the error condition. The RESUME statement can be used to resume program execution. TRAP with no line number turns off error trapping. An error in a TRAP routine cannot be trapped, unless it contains a TRAP statement of its own. EXAMPLE: 100 TRAP 1000 If an error occurs, go to line 1000. 1000 ?ERR$(ER);EL Print the error message, and the error line number. 1010 RESUME Resume program execution. 17.98 TROFF ----- Turn OFF error TRacing mode. TROFF This statement turns off trace mode. 17.99 TRON ---- Turn ON error TRacing mode. TRON TRON is used in program debugging. This statement begins trace mode. When you RUN the program, the line numbers of the program appear in brackets be- fore any action for that line occurs. If you have multistatement lines, the line number will be printed before each statement is processed. 17.100 VERIFY Verify program in memory against one saved to disk or to tape. VERIFY ["filename"] [,device number] [,relocate flag] This command causes the Commodore 128 to check the program on tape or disk against the one in memory, to determine if the program is really SAVEd. This command is also very useful for positioning a tape so that the Commo- dore 128 writes after the last program on tape. VERIFY, with no arguments after the command, causes the Commodore 128 to check the next program on tape, regardless of its name, against the program now in memory. VERIFY, followed by a program name in quotes or a string variable, searches the tape for that program and when found checks it against the program in memory. VERIFY, followed by a name, a comma and a number, checks the program on the device with that number (1 for tape, 8 for disk). The relocate flag is the same as in the LOAD command. It veri- fies the program from the memory location from which it was SAVEd. (See also DVERIFY, in paragraph 17.34.) EXAMPLES: VERIFY "HELLO" Searches for HELLO on tape, checks it against memory. VERIFY "HELLO",8,1 Searches for HELLO on disk, then checks it against memory. VERIFY "LASTFILE" Searches tape for LASTFILE, checks it, reports an error if there is no match. You can then save you new program after it, without erasing previous programs. NOTE: If graphic area is allocated or deallocated after a SAVE, VERIFY and DVERIFY will report an error. Technically this is correct. BASIC text in this case has moved from its original (SAVEd) location to another address range. Hence, VERIFY, which performs byte-to-byte comparisons, will fail, even though the program is valid. 17.101 VOL --- Define output level of sound. VOL volume level This statement sets the volume for SOUND and PLAY statements. VOLUME level can be set from 0 to 15, where 15 is the maximum volume, and 0 is off. VOL affects all voices. EXAMPLES: VOL 0 Turns volume off. VOL 1 Sets volume to its lowest audible level. VOL 15 Sets volume for SOUND and PLAY statements to its highest level. 17.102 WAIT Pause program execution until a data condition is satisfied. WAIT location, mask1 [, mask2] The WAIT statement causes program execution to be suspended until a given memory address recognizes a specific bit pattern or value. In other words, WAIT can be used to halt the program until some external event has occur- red. This is done by monitoring the status of bits in the Input/Output re- gisters. The data items used with the WAIT can be any values. For most pro- grammers, this statement should never be used. It causes the program to be halt until a specific memory location's bits change in a specific way. This is used for certain I/O operations and almost nothing else. The WAIT statement takes the value in the memory location and performs a logical AND operation with the value in mask1. If mask2 is specified, the result of the first operation is exclusively ORed with mask2. In other words, mask1 "filters out" any bits not to be tested. Where the bit is 0 in mask1, the corresponding bit in the result will always be 0 . The mask2 value flips any bits, so that an off condition can be tested as well as an on condi- tion. Any bits being tested for a 0 should have a 1 in the corresponding bit position in mask2. If corresponding bits of the mask1 and mask2 operands differ, the exclusive-OR operation gives a bit result of 1. If the corresponding bits get the same the bit is 0. It is possible to enter an infinite pause with the WAIT statement, in which case the {run/stop} and {restore} keys can be used to recover. WAIT may require a bank command if the memory you wish to access is not in the currently selected BANK. The following examples are for the C128 mode only. The first example WAITs until a key is pressed on the tape unit to continue with the program. The second example will WAIT until the {shift} key is pressed and then released. The third example will WAIT until either bit 7 (128) is on or bit 4 (16) if off. EXAMPLES: WAIT 1,32,32 WAIT 211,1:WAIT 211,1,1 WAIT 36868, 144, 16 (144 and 16 are binary masks. 144=%10010000 in binary and 16 = %10000 in binary.) 17.103 WIDTH ----- Set the width of drawn lines. WIDTH n This command sets the width of lines drawn using BASIC's graphic commands to either single or double width. Giving n a value of 1 defines a single width line; a value of 2 defines a double width line. EXAMPLES: WIDTH 1 Set width for graphic commands. WIDTH 2 Set double width for drawn lines. 17.104 WINDOW ------ Defines a screen window. WINDOW top left col, top left row, bot right col, bot right row [, clear] This command defines a logical window within the 40 or 80 column text screen. The coordinates must be in the range 0-39/79 for column values and 0-24 for row values. The clear flag, if provided (1), causes a screen-clear to be performed (but only within the limits of the newly described window). EXAMPLES: WINDOW 5,5,35,20 Defines a window with top left corner coordinates (5,5) and bottom right corner coordinates (35,20). WINDOW 10,2,33,34,1 Defines a window with upper left corner coordinates (10,2) and lower right coordinates (33,24). Also clears the portion of the screen within the window as specified by the 1. NOTE: If you specify a column greater than 39 on a 40-column display you will get an "ILLEGAL QUANTITY ERROR". SECTION 18 18. Basic Functions The format of the function description is: FUNCTION(argument) where the argument can be a numeric value, variable or string. Each func- tion description is following by an example. 18.1 ABS Return absolute value. ABS(x) The absolute value function returns the positive value of the argument. EXAMPLE: PRINT ABS(7*(-5)) 35 18.2 ASC Return CBM ASCII code for character. ASC(x$) This function returns the ASCII code for the first character of x$. In C128 mode you no longer have to append CHR$(0) to a null string; ILLEGAL QUANTITY ERROR is no longer issued. EXAMPLE: X$="C128":PRINTASC(X$) 67 18.3 ATN Return angle whose tangent is X radians. ATN(x) This function returns the angle whose tangent is x, measured in radians. EXAMPLE: PRINT ATN(3) 1.24904577 18.4 BUMP ---- Return sprite collision information. BUMP(n) To determine which sprites have collided since the last check, use the BUMP function. BUMP(1) records which sprites have collided with each other and BUMP(2) records which sprites have collided with other objects on the screen. COLLISION need not be active to use BUMP. The bit positions (0-7) in the BUMP value correspond to sprites 1 through 8 respectively. BUMP(n) is reset to zero after each call. The value returned by BUMP is the result of two raised to the power of the bit position. Remember bit position range from zero to seven, so a bit po- sition corresponds to the sprite number - 1. For example, if BUMP returned a value of 16, sprite 5 was involved since 2 raised to the power (5 minus 1) equals 16. EXAMPLES: PRINT BUMP(1) Indicates that sprites 3 and 4 have collided. 12 PRINT BUMP(2) Indicates that sprite 6 has collided with an object on 32 the screen. 18.5 CHR$ Return ASCII character for specified CBM ASCII code. CHR$(x) This is the opposite of ASC and returns the string character whose CBM ASCII code is x. Refer to Appendix E for a table of CHR$ codes. EXAMPLES: PRINT CHR$(65) Prints the a character A PRINT CHR$(147) Clears the text screen. 18.6 COS Return cosine of angle of x radians. COS(x) This function returns the value of the cosine of x, where x is an angle measured in radians. EXAMPLE: PRINT COS({pi}) -1 18.7 DEC --- Return decimal value of hexadecimal number string. DEC(hexadecimal-string) This function returns the decimal value of hexadecimal-string. EXAMPLES: PRINT DEC("D020") 53280 F$="F":PRINT DEC(F$) 15 18.8 ERR$ ---- Return the string describing an error condition. ERR$(n) This function returns a string describing an error condition. Also see system variables EL and ER, in paragraph 19.1, and Appendix A for a list of BASIC error messages. EXAMPLE: PRINT ERR$(10) NEXT WITHOUT FOR 18.9 EXP Return value of an approximation of e (2.7182813) raised to the power x. EXP(x) This function returns a value of e (2.7182813) raised to the power x. EXAMPLE: PRINT EXP(1) 2.7182813 18.10 FNxx Return value from user defined function. FNxx(x) This function returns the value from the user-defined function xx created by a DEF FNxx statement. EXAMPLE: 10 DEF FNAA(X)=(X-32)*5/9 20 INPUT X 30 PRINT FNAA(X) RUN ? 40 (? is input prompt) 4.44444445 18.11 FRE Return number of available bytes in memory. FRE(x) Where x is the bank number. x=0 BASIC program storage, and x=1 to check for available BASIC variable storage. EXAMPLES: PRINT FRE(0) Returns the number of free bytes for BASIC programs. 48893 PRINT FRE(1) Returns the number of free bytes for BASIC variable 64256 storage. 18.12 HEX$ ---- Return hexadecimal number string from decimal number. HEX$(x) This function returns a four-character string containing the hexadecimal representation of value x (0 <= x < 65536). The decimal counterpart of this function is DEC. EXAMPLE: PRINT HEX$(53280) D020 NOTE: HEX$(0) is "0000". 18.13 INSTR ----- Return position of string 1 in string 2. INSTR(string 1, string 2 [, starting position]) The INSTR function searches for the first occurrance of string 2 within string 1, and returns the position within string 1 where the match is found. The optional parameter for starting position establishes the posi- tion in string 1 where the search begins. The starting position must be in the range of 1 through 255. If no match is found or, if starting position is greater than the length of string 1 or if string 1 is null, INSTR re- turns the value 0. If string 2 is null, INSTR returns 0. EXAMPLE: PRINT INSTR("COMMODORE 128","128") 11 18.14 INT Return integer form (whole number part) of a floating point value. INT(x) This function returns the integer value of the expression. If the expres- sion is positive, the fractional part is left out. If the expression is negative, any fraction causes the next lower integer to be returned. EXAMPLES: PRINT INT(3.14) 3 PRINT INT(-3.14) -4 18.15 JOY --- Return position of joystick and the status of the fire button. JOY(n) where n equals: 1 JOY returns position of joystick 1 2 JOY returns position of joystick 2 Any value of 128 or more means that the fire button is also pressed. To find the JOY value, add the direction value of the joystick plus 128, if the JOY fire button is pressed. The direction is indicated as follows: 1 8 2 7 0 3 6 4 5 EXAMPLES: JOY(2) is 135 When joystick 2 fires and goes to the left. IF (JOY(1) AND 128) = 128 THEN PRINT "FIRE" Determines whether the fire button of joystick 1 is pressed. 18.16 LEFT$ Return the leftmost characters of string. LEFT$(string, length) This function returns a string comprised of the number of leftmost charac- ters of the string determined by the length argument. The length argument must be an integer in the range of 0 to 255. If this integer value is greater than the length of the string, the entire string is returned. If the value is equal to zero, then a null string (of zero length) is retur- ned. EXAMPLE: PRINT LEFT$("COMMODORE",5) COMMO 18.17 LEN Return the length of a string. LEN(string) This function returns the number of characters in the string expression. Non-printable characters and blanks are included. EXAMPLE: PRINT LEN("COMMODORE128") 12 18.18 LOG Return natural log of x. LOG(x) This function returns the natural log of x. The natural log is log to the base e (see EXP(x), in paragraph 18.9). To convert to log base 10, divide by LOG(10). EXAMPLE: PRINT LOG(37 / 5) 2.00148 18.19 MID$ Return a substring from a larger string or overlay a substring into a larger string. MID$(string, starting position [, length]) This function returns a substring specified by the length, starting at the character specified by the starting position. The starting position of the substring defines the first character where the substring begins. The length of the substring is specified by the length argument. Both of the numeric arguments can have values ranging from 0 to 255. If the starting position value is greater than the length of the string, or if the length of the string is zero, then MID$ returns a null string value (of length zero). If the length argument is left out, all characters to the right of the starting position are returned (which is equivalent with RIGHT$). EXAMPLE: PRINT MID$("COMMODORE 128",3,5) MMODO EXAMPLE using overlay: A$="123456":MID$(A$,3,2)="ABCDE":PRINT A$ 12AB56 NOTE: Overlay cannot be used to expand the size of a string, thus in the example above MID$(A$,3,5) is not possible. 18.20 PEEK Return contents of a specific memory location. PEEK(x) This function returns the contents of memory location x, where x is located in the range 0 through 65535, returning a result between 0 and 255 (inclusive). This is the counterpart of the POKE statement. The data will be returned from the bank selected by the most recent BANK command. See the BANK command, in paragraph 17.4 of Section 17. EXAMPLE: 10 BANK 15:VIC=DEC("D000") 20 FOR I=1 TO 47 30 PRINT PEEK(VIC+I) 40 NEXT This example displays the contents of the registers of the VIC chip. 18.21 PEN --- Return x and y coordinates of the light pen. PEN(n) where: n=0 PEN returns the x coordinate of the light pen position. n=1 PEN returns the y coordinate of the light pen position. n=2 PEN returns the x coordinate of the light pen position of the 80 column display. n=3 PEN returns the y coordinate of the light pen position of the 80 column display. n=4 PEN returns the light pen trigger value. Note that, like sprite coordinates, the PEN value is not scaled and uses real coordinates, not graphic bit map coordinates. The x position is given as a number, ranging from approximately 60 to 320, while the y position can be any number from 50 to 250. These are the visible screen coordinate ranges, where all other values are not visible on the screen. A value of zero for either position means the light pen is off screen and has not triggered an interrupt since the last read. Note that COLLISION need not be active to use PEN. A white background is usually required to stimulate the light pen. PEN values vary from system to system. Unlike the 40 column (VIC), the 80 column (VDC 8563) coordinates are character row and column positions and not pixel coordinates, like the VIC screen. Both the 40 and 80 column screen coordinate values are approximate and vary, due to the nature of light pens. The read values are not valid until PEN(4) is true. EXAMPLES: 10 PRINT PEN(0);PEN(1) Display the x and y coordinates of the light pen. 10 DO UNTIL PEN(4):LOOP Ensure the read values are valid. 20 X=PEN(2) 30 X=PEN(3) 40 REM:REST OF PROGRAM 18.22 {pi} Return the value of pi (3.14159265). {pi} EXAMPLE: PRINT {pi} 3.14159265 18.23 POINTER ------- Return the address of a variable name. POINTER(variable name) EXAMPLE: PRINT POINTER(Z) This example returns the address of variable Z. 18.24 POS Return the current cursor column position within the current screen window. POS(x) The POS function indicates where the cursor is within the defined screen window. X is a dummy argument, which must be specified, but the value is ignored. EXAMPLE: PRINT "0123456789"POS(1) 0123456789 10 This displays the current cursor position within the defined text window, in this case 10. 18.25 POT --- Return the value of the game-paddle potentiometer. POT(n) when: n=1, POT returns the position of paddle #1. n=2, POT returns the position of paddle #2. n=3, POT returns the position of paddle #3. n=4, POT returns the position of paddle #4. The values for POT range from 0 to 255. Any value of 256 or more means that the fire button is also depressed. EXAMPLE: 10 PRINT POT(1) 20 IF POT(1) >=256 THEN PRINT"FIRE" This example displays the value of the game paddle 1. Note: A value of 255 is returned if no paddles are connected. 18.26 RCLR ---- Return color of color source. RCLR(n) This function returns the color (1 to 16) assigned to the color source n (0 <= n <= 6), where the following n values apply: 0 = RCLR returns the 40-column background color. 1 = RCLR returns the bit map foreground color. 2 = RCLR returns multicolor 1. 3 = RCLR returns multicolor 2. 4 = RCLR returns the 40-column border color. 5 = RCLR returns the 40- or 80-column character color. 6 = RCLR returns the 80-column background color. The counterpart to the RCLR function is the COLOR command. EXAMPLE: 10 FOR I=0 TO 6 20 PRINT "SOURCE";I;"IS COLOR CODE";RCLR(I) 30 NEXT This example prints the color codes for all seven color sources. 18.27 RDOT ---- Return current position or color of pixel cursor. RDOT(n) where: n=0 returns the x coordinate of the pixel cursor. n=1 returns the y coordinate of the pixel cursor. n=2 returns the color source of the pixel cursor. This function returns the location of the current position of the pixel cursor (PC) or the current color source ot the pixel cursor. EXAMPLES: PRINT RDOT(0) Returns x position of PC. PRINT RDOT(1) Returns y position of PC. PRINT RDOT(2) Returns color source of PC (0 to 3). 18.28 RGR --- Return current graphic mode. RGR(x) This function returns the current graphic mode. x is a dummy argument, which must be specified. The counterpart of the RGR function is the GRAPHIC command. The value returned by RGR(x) pertains to the following modes: VALUE GRAPHIC MODE 0 40 column (VIC) text. 1 Standard bit map. 2 Split screen bit map. 3 Multicolor bit map. 4 Split screen multicolor bit map. 5 80 column (VDC 8563) text. EXAMPLE: PRINT RGR(0) 1 This displays the current graphic mode, in this case, standard bit map mode. 18.29 RIGHT$ Return substring from rightmost end of string. RIGHT$( , ) This function returns a substring taken from the rightmost characters of the string argument. The length of the substring is defined by the length argument, which can be any integer in the range of 0 to 255. If the value of length is zero, then a null string ("") is returned. If the value given in the length argument is greater than the length of the string, the entire string is returned. Also see LEFT$ and MID$ functions, in paragraphs 18.16 and 18.19, respectively. EXAMPLE: PRINT RIGHT$("BASEBALL",5) EBALL 18.30 RND Return a random number. RND(x) This function returns a random number, which value lies between 0 (inclu- sive) and 1 (exclusive). This is usefull in games, to simulate dice roll and other elements of chance. It is also used in some statistical appli- cations. If x = 0 RND returns a random number based on the hardware clock. If x > 0 RND generates a reproducable pseudo-random number based on the seed value (see below - "If x < 0"). If x < 0 Produces a random number which is used as a base called a seed. To simulate the rolling of a dice, use the formula INT(RND(1) * 6 + 1). First the random number is multiplied by 6, which expands the range to 0-6 (actually, less than six). Then 1 is added, making the range from 1 to less than 7. The INT function truncates all the decimal places, leaving the result as a digit from 1 to 6. EXAMPLES: PRINT RND(0) This displays a random number. .507824123 PRINT INT(RND(1)*100 + 1) This displays a random positive number 89 less than 100. 18.31 RSPCOLOR -------- Return sprite multicolor values. RSPCOLOR(n) When: n=1 RSPCOLOR returns the sprite multicolor 1. n=2 RSPCOLOR returns the sprite multicolor 2. The returned color value is a value between 1 and 16 (inclusive). The counterpart of the RSPCOLOR function is the SPRCOLOR command. Also see the SPRCOLOR command, in paragraph 17.87 of Section 17. EXAMPLE: 10 SPRITE 1,1,2,0,1,1,1 20 SPRCOLOR 5,7 30 PRINT"SPRITE MULTICOLOR 1 IS";RSPCOLOR(1) 40 PRINT"SPRITE MULTICOLOR 2 IS";RSPCOLOR(2) RUN SPRITE MULTICOLOR 1 IS 5 SPRITE MULTICOLOR 2 IS 7 In this example line 10 turns on sprite 1, colors it white, expands it in both the x and y directions and displays it in multicolor mode. Line 20 selects sprite multicolors 1 and 2. Lines 30 and 40 print the RSPCOLOR values for multicolor 1 and 2. 18.32 RSPPOS ------ Return the speed and position values of a sprite. RSPPOS(sprite number, n) where sprite number identifies which sprite is being checked and n specifies x and y coordinates or the sprite's speed. When n equals: 0 RSPPOS returns the current x position of the specified sprite. 1 RSPPOS returns the current y position of the specified sprite. 2 RSPPOS returns the speed (0-15) of the specified sprite. EXAMPLE: 10 SPRITE 1,1,2 20 MOVSPR 1,45#13 30 PRINT RSPPOS(1,0);RSPPOS(1,1);RSPPOS(1,2) This example returns the current x and y sprite coordinates and the speed (13), all of sprite 1. 18.33 RSPRITE ------- Return sprite characteristics. RSPRITE(sprite number, characteristic) RSPRITE returns sprite characteristics that were specified in the SPRITE command. Sprite number specifies the sprite you are checking and the argument characteristics specifies the sprite's display qualities as follows: Characteristic RSPRITE returns these values: 0 Enabled (1) / Disabled (0). 1 Sprite color (0-16). 2 Sprites are displayed in front of (0) or behind (1). 3 Expand in x direction, yes=1, no=0. 4 Expand in y direction, yes=1, no=0. 5 Multicolor, yes=1, no=0. EXAMPLE: 10 FOR I=0 TO 5 This example prints all 6 characteristics of 20 PRINT RSPRITE(1,I) sprite 1. 30 NEXT 18.34 RWINDOW ------- Return the size of the current window. RWINDOW(n) When n equals: 0 RWINDOW returns the number of lines in the current window. 1 RWINDOW returns the number of rows in the current window. 2 RWINDOW returns either of the values 40 or 80, depending on the current screen output format you are using. The counterpart of the RWINDOW function is the WINDOW command. EXAMPLE: 10 WINDOW 1,1,10,10 20 PRINT RWINDOW(0);RWINDOW(1);RWINDOW(2); RUN 9 9 40 This example returns the number of lines (9) and columns (9) in the current window. The example assumes you are displaying the window in 40 column format. 18.35 SGN Return sign of argument x. SGN(x) This function returns the sign (positive, negative or zero) of x. The result is +1 if x > 0, 0 if x = 0, and -1 if x < 0. EXAMPLE: PRINT SGN(4.5);SGN(0);SGN(-2.3) 1 0 -1 18.36 SIN Return sine of argument x. SIN(x) This is the trigonometric sine function. The result is the sine of x, where x is an angle measured in radians. EXAMPLE: PRINT SIN({pi}/3) .866025404 18.37 SPC Skip spaces on the screen. SPC(x) This function is used in PRINT or PRINT# commands to control the formatting of data, as either output to the screen or output to a logical file. The number of SPaCes specified by the x parameter determines the number of characters to fill with spaces across the screen or in a file. For screen or tape files, the value of the argument is in the range 0 to 255, and for disk files the maximum is 254. For printer files, an automatic carriage- return and line-feed will be performed by the printer if a SPaCe is printed in the last character position of a line; no SPaCes are printed on the fol- lowing line. EXAMPLE: PRINT "COMMODORE";SPC(3);"128" COMMODORE 128 18.38 SQR Return square root of argument. SQR(x) This function returns the value of the SQuare Root of x, where x is a posi- tive number or 0. The value of the argument must not be negative, or the BASIC error message ?ILLEGAL QUANTITY ERROR is displayed. EXAMPLE: PRINT SQR(25) 5 18.39 STR$ Return string representation of number. STR$(x) This function returns the STRing representation of the numeric value of the argument x. When the STR$ value is converted, any number displayed is pre- ceded and followed by a space except for negative numbers, which are preceded by a minus sign. The counterpart of the STR$ function is the VAL function. EXAMPLES: PRINT STR$(123.45) 123.45 PRINT STR$(-89.03) -89.03 PRINT STR$(1E20) 1E+20 18.40 TAB Moves cursor to tab position in present statement. TAB(x) This function moves the cursor forward if possible to a relative position on the text screen given by the argument x, starting with the leftmost position of the current line. The value of the argument can range from 0 to 255. If the current print position is already beyond position x, the TAB function is ignored. The TAB function should only be used with the PRINT statement, since it has varied effects if used with the PRINT# to a logical file, depending on the device being used. EXAMPLE: 10 PRINT"COMMODORE"TAB(25)"128" COMMODORE 128 18.41 TAN Return tangent of argument. TAN(x) This function returns the tangent of x, where x is an angle measured in radians. EXAMPLE: PRINT TAN(.785398163) 1 18.42 USR Call user-defined subfunction USR(x) When this function is used, the program jumps to a machine language program whose starting point is contained in memory locations (low order byte first, high order byte last): 4633 ($1219) and 4634 ($121A) ... C128 mode 785 ($0311) and 786 ($0312) ... C64 mode The parameter x is passed to the machine language program in the floating point accumulator. A value is returned to the BASIC program through the calling variable. You must redirect the value into a variable in your program in order to receive the value back from the floating point accumu- lator. An ILLEGAL QUANTITY ERROR results if you don't specify this variable. This allows the user to exchange a variable between machine code and BASIC. EXAMPLE (128 Only): 10 POKE 4633,0 20 POKE 4634,192 NOTE: Default Commodore 128 bank is 15. 30 A = USR(X) 40 PRINT A Place starting location ($C000=49152: $00=0: $C0=192) of machine language routine in location 4633 and 4634. Line 30 stores the returning value from the floating point accumulator. 18.43 VAL Return the numeric value of a number string. VAL(numeric string) This function converts the numeric string argument into a number. It is the inverse operation of STR$. The string is examined from the leftmost character to the right, for as many characters as are in recognizable num- ber format. If the Commodore 128 finds illegal characters, only the portion of the string up to that point is converted. If no numeric characters are present VAL returns a 0. EXAMPLE: 10 A$ = "120" 20 B$ = "365" 30 PRINT VAL(A$) + VAL(B$) 485 18.44 XOR --- Returns exclusive OR XOR(n1,n2) This function provides the exclusive OR of the argument values n1 and n2. x = XOR(n1,n2) where n1, n2 are 2 unsigned values (0-65535). EXAMPLE: PRINT XOR(128,64) 192 NOTE: n1 and n2 need not be whole numbers. SECTION 19 19. Variables and Operators 19.1 VARIABLES 19.2 OPERATORS 19.1 VARIABLES The Commodore 128 uses three types of variables in BASIC. These are: normal numeric, integer numeric, string (alfanumeric). Normal NUMERIC VARIABLES, also called floating point variables, can have any exponent value from -10 to +10, with up to nine digits of accuracy. When a number becomes larger than nine digits can show, the computer dis- plays it in scientific notation form, with the number normalized to one digit and eight decimal places, followed by the letter E and the power of 10 by which the number is multiplied. For example, the number 12345678901 is displayed as 1.23456789E+10. INTEGER VARIABLES can be used when the number is from +32767 to -32768 (inclusive), and with no fractional portion. An integer variable is a num- ber like 5, 10 or -100. Integers take up less space than floating point variables, particularly when used in an array (see below). STRING VARIABLES are those used for character data, which may contain num- bers, letters and any other characters the Commodore 128 can display. An example of a string variable is "COMMODORE 128". VARIABLE NAMES may consist of a single letter, a letter followed by a num- ber, or two letters. Variable names may be longer than two characters, but only the first two are significant. An integer is specified by using the percent sign (%) after the variable name. String variables have a dollar sign ($) after their names. EXAMPLES: Numeric Variable Names: A, A5, BZ Integer Variable Names: A%, A5%, BZ% String Variable Names: A$, A5$, BZ$ ARRAYS are lists of variables with the same name, using an extra number (or numbers) to specify an element of the array. Arrays are defined using the DIM statement and may be floating point, integer or string variable arrays. The array variable name is followed by a set of parentheses () enclosing the number of the variable in the list. EXAMPLE: A(7),BZ%(11),A$(87) Arrays can have more than one dimension. A two-dimensional array may be viewed as having rows and columns, with the first number identifying the row and the second number identifying the column (as specifying a certain grid on the map). EXAMPLE: A(7,2), BZ%(2,3,4), Z$(3,2) RESERVED VARIABLE NAMES are names reserved for use by the Commodore 128, and may not be used for any other purpose. These are the variables: DS, DS$, ER, EL, ST, TI and TI$. KEYWORDS such as TO and IF or any other name that contain keywords, such as RUN, NEW or LOAD cannot be used as variable names. ST is a status variable for input and output (except normal screen/keyboard operations). The value of ST depends on the result of the last I/O opera- tion. In general, if the value of ST is 0, then the operation was success- ful. TI and TI$ are variables that relate to the real time clock built into the Commodore 128. The system clock is updated every 1/60th of a second. It starts at 0 when the Commodore 128 is turned on, and is reset only by changing the value of TI$. The variable TI gives the current value of the clock in 1/60th of a second. TI$ is a string that reads the value of the real time clock as an 24-hour clock. The first two characters of TI$ con- tain the hour, the third and fourth characters are minutes and the fifth and sixth characters are seconds. This variable can be set to any value (so long as all characters are numbers) and will be updated automatically as a 24-hour clock. EXAMPLE: TI$="101530" sets the clock to 10:15 and 30 seconds (AM). The value of the clock is lost when the Commodore 128 is turned off. It starts at zero when the Commodore 128 is turned on, and is reset to zero when the value of the clock exceeds 235959 (23 hours, 59 minutes and 59 seconds). The variable DS reads the disk drive command channel and returns the cur- rent status of the drive. To get this information in words, PRINT DS$. These status variables can be used after a disk operation, like DLOAD and DSAVE, to find out why the red error light on the disk drive is blinking. ER and EL are variables used in error trapping routines. They are usually only useful within a program. ER returns the last error encountered since the program was RUN. EL is the line where the error occurred. ERR$ is a function that allows the program to print one of the BASIC error messages. PRINT ERR$(ER) prints out the proper error message. 19.2 Operators The BASIC OPERATORS include: ARITHMETIC OPERATORS, RELATIONAL OPERATORS and LOGICAL OPERATORS. The ARITHMETIC OPERATORS include the following signs: + addition - subtraction * multiplication / division ^ raising to a power (exponentiation) On a line containing more than one operator, there is a set order in which operations always occur. If several operators are used together, the compu- ter assigns priorities as follows: First exponentiation, then multiplica- tion and division, and last, addition and subtraction. If two operators have the same priority, then calculations are performed in order from left to right. If these operations are to occur in a different order, Commodore 128 BASIC allows giving a calculation higher priority by placing parenthe- ses around it. Operations enclosed with parentheses will be calculated be- fore any other operation. Make sure the equations have the same number of left and right parentheses, or a SYNTAX ERROR message is displayed when the program is run. There are also operators for equalities and inequalities, called RELATIONAL OPERATORS. Arithmetic operators always take priority over relational opera- tors. = is equal to < is less than > is greater than <= or =< is less than or equal to >= or => is greater than or equal to <> or >< is not equal to Finally, there are three LOGICAL OPERATORS, with lower priority than both arithmetic and relational operators: AND OR NOT These are most often used to join multiple formulas in IF... THEN state- ments. When they are used with arithmetic operators, they are evaluated last (i.e. after + and -). If the relationship stated in the expression is true, the result is assigned an integer value of -1. If false, a value of 0 (zero) is assigned. EXAMPLES: IF A=B AND C=D THEN 100 Requires both A=B and C=D to be true. IF A=B OR C=D THEN 100 Allows either A=B, C=D, or both, to be true. A=5:B=4:PRINT A=B Displays a value of zero. A=5:B=4:PRINT A>3 Displays a value of -1. PRINT 123 AND 15:PRINT 5 OR 7 Displays 11 and 7. SECTION 20 20. Reserved Words and Symbols 20.1 Reserved System Words (Keywords) 20.2 Reserved System Symbols 20.1 Reserved System Words (Keywords) This section lists the words and symbols used to make up the BASIC 7.0 language. These words and symbols cannot be used within a program as other than a component of the BASIC language. The only exception is that they may be used within quotes in a PRINT or LET statement. ABS DIM HEX$ PRINT SPRITE AND DIRECTORY IF PRINT# SPRSAV APPEND DLOAD INPUT PUDEF SQR ASC DO INPUT# QUIT** SSHAPE ATN DOPEN INSTR RCLR ST AUTO DRAW INT RDOT STASH BACKUP DS JOY READ STEP BANK DSAVE KEY RECORD STOP BEGIN DS$ LEFT$ REM STR$ BEND DVERIFY LEN RENAME SWAP BLOAD EL LET* RENUMBER SYS BOOT ELSE LIST RESTORE TAB( BOX END LOAD RESUME TAN BSAVE ENVELOPE LOCATE RETURN TEMPO BUMP ER LOG RGR THEN CATALOG ERR$ LOOP RIGHT$ TI CHAR EXIT MID$ RND TI$ CHR$ EXP MONITOR RREG TO CIRCLE FAST MOVSPR RSPCOLOR TRAP CLOSE FETCH NEW RSPPOS TROFF CLR FILTER NEXT RSPRITE TRON CMD FN NOT RUN UNTIL COLLECT FOR OFF** RWINDOW USING COLLISION FRE ON SAVE USR COLOR GET OPEN SCALE VAL CONCAT GETKEY OR SCNCLR VERIFY CONT GET# PAINT SCRATCH VOL COPY GO64 PEEK SGN WAIT COS GOSUB PEN SIN WHILE DATA GOTO {pi} SLEEP WIDTH DCLEAR GO TO PLAY SLOW WINDOW DCLOSE GRAPHIC POINTER SOUND XOR DEC GSHAPE POKE SPC( DEF HEADER POS SPRCOLOR DELETE HELP POT SPRDEF * LET may be left out of the statement, so LET A=10 may be written as A=10. ** OFF and QUIT are unimplemented. 20.2 Reserved System Symbols The following characters are reserved system symbols. Symbol Use(s) + Plus sign Arithmetic addition; string concatenation; rela- tive sprite movement; declare decimal number in machine language monitor. - Minus sign Arithmetic subtraction; negative number; unary minus; relative sprite movement. * Asterisk Arithmetic multiplication. / Slash Arithmetic division. ^ Up arrow Arithmetic exponentiation. Blank space Separate keywords and variable names. = Equal sign Value assignment; relationship testing. < Less than Relationship testing. > Greater than Relationship testing. , Comma Format output in variable lists; separate mul- tiple function parameters in commands or state- ments. . Period Decimal point in floating constants. ; Semicolon Format output in variable lists. : Colon Separate multiple BASIC statements on a program line; logical end of line in machine language monitor. " " Quotation mark Enclose string constants ? Question mark Abbreviation for the keyword PRINT; logical end of line in machine language monitor. ( Left parenthesis Expression evaluation and functions. ) Right parenthesis Expression evaluation and functions. % Percent Declare a variable name as integer; declare binary number in machine language monitor. # Hash Precede the logical file number in input/output statements. $ Dollar sign Declare a variable name as a string; declare hexadecimal number in machine language monitor. & And sign Declare octal number in machine language monitor. {pi} Pi Declare the numeric constant - approximately 3.14159265 APPENDICES APPENDIX A - BASIC LANGUAGE ERROR MESSAGES APPENDIX B - DOS ERROR MESSAGES APPENDIX C - CONNECTORS/PORTS FOR PERIPHERAL EQUIPMENT APPENDIX D - SCREEN DISPLAY CODES APPENDIX E - ASCII AND CHR$ CODES APPENDIX F - SCREEN AND COLOR MEMORY MAPS APPENDIX G - DERIVED MATHEMATICAL FUNCTIONS APPENDIX H - MEMORY MAP APPENDIX I - CONTROL AND ESCAPE CODES APPENDIX J - MACHINE LANGUAGE MONITOR APPENDIX K - BASIC 7.0 ABBREVIATIONS APPENDIX L - DISK COMMAND SUMMARY APPENDIX A A. BASIC LANGUAGE ERROR MESSAGES The following error messages are displayed by BASIC. Error messages can also be displayed with the use of the ERR$() function. The error numbers below refer only to the number assigned to the error for use with the ERR$() function. ERROR# ERROR NAME DESCRIPTION 1 TOO MANY FILES There is a limit of 10 files OPEN at one time. 2 FILE OPEN An attempt was made to open a file using the number of an already open file. 3 FILE NOT OPEN The file number specified in an I/O state- ment must be opened before use. 4 FILE NOT FOUND Either no file with that name exists (disk) or an end-of-tape marker was read (tape). 5 DEVICE NOT PRESENT The required I/O device is not available or buffers deallocated (cassette). Check to make sure the device is connected and turned on. 6 NOT INPUT FILE An attempt was made to GET or INPUT data from a file that was specified as output only. 7 NOT OUTPUT FILE An attempt was made to send data to a file that was specified as input only. 8 MISSING FILE NAME File name missing in command. 9 ILLEGAL DEVICE An attempt was made to use a device im- NUMBER properly (SAVE to the screen, etc.). 10 NEXT WITHOUT FOR Either loops are nested incorrectly, or there is a variable name in a NEXT state- ment that doesn't correspond with one in FOR. 11 SYNTAX A statement not recognized by BASIC. This could be because of a missing or extra parenthesis, misspelled key word, etc. 12 RETURN WITHOUT A RETURN statement was encountered when no GOSUB GOSUB statement was active. 13 OUT OF DATA A READ statement was encountered without data left unREAD. 14 ILLEGAL QUANTITY A number used as the argument of a function or statement is outside the allowable range. 15 OVERFLOW The result of a computation is larger than the largest number allowed (1.701411833E+38). 16 OUT OF MEMORY Either there is no more room for program code and/or program variables, or there are too many nested DO, FOR or GOSUB statements in effect. 17 UNDEF'D STATEMENT A line number referenced doesn't exist in the program. 18 BAD SUBSCRIPT The program tried to reference an element of an array out of the range specified by the DIM statement. 19 REDIM'D ARRAY An array can only be DIMensioned once. 20 DIVISION BY ZERO Division by zero is not allowed. 21 ILLEGAL DIRECT INPUT or GET, or INPUT# or GET# statements are only allowed within a program. 22 TYPE MISMATCH This occurs when a numeric value is used in place of a string or vice versa. 23 STRING TOO LONG A string can contain up to 255 characters. 24 FILE DATA Bad data read from a tape or disk file. 25 FORMULA TOO The computer was unable to understand this COMPLEX expression. Simplify the expression (break into two parts or use fewer parentheses). 26 CAN'T CONTINUE The CONT command does not work if the pro- gram was not RUN, there was an error, or a line had been edited. 27 UNDEFINED FUNCTION A user-defined function was referenced that was never defined. 28 VERIFY The program on tape or disk does not match the program in memory. 29 LOAD There was a problem loading. Try again. 30 BREAK The stop key was hit to halt program exe- cution. 31 CAN'T RESUME A RESUME statement was encountered without a TRAP statement in effect. 32 LOOP NOT FOUND The program has encountered a DO statement and cannot find the corresponding LOOP. 33 LOOP WITHOUT DO LOOP was encountered without a DO statement active. 34 DIRECT MODE ONLY This command is allowed only in direct mode, not from a program. 35 NO GRAPHICS AREA A command (DRAW, BOX, etc.) to create graphics was encountered before the GRAPHIC command was executed. 36 BAD DISK An attempt failed to HEADER a diskette, because the quick header method (no ID) was attempted on a unformatted diskette or the diskette is bad. 37 BEND NOT FOUND The program encountered an "IF... THEN BEGIN" or "IF... THEN... ELSE BEGIN" con- struct, and could not find a BEND keyword to match the BEGIN. 38 LINE # TOO LARGE An error has occurred in renumbering a BASIC program. The given parameters result in a line number > 63999 being generated; therefore, the renumbering was not per- formed. 39 UNRESOLVED An error has occurred in renumbering a REFERENCE BASIC program. A line number referred to by a command (e.g., GOTO 999) does not exist. Therefore the renumbering was not per- formed. 40 UNIMPLEMENTED A command not supported by BASIC 7.0 was COMMAND encountered. 41 FILE READ An error condition was encountered while loading or reading a program or file from the disk drive (e.g., opening the disk drive door while a program was loading). APPENDIX B B. DOS ERROR MESSAGES The following error messages are returned through the DS and DS$ variables. The DS variable contains just the error number and the DS$ variable contains the error number, the error messages and any correspon- ding track and sector number. Note: Error message numbers less than 20 should be ignored with the excep- tion of 01, which gives information about the number of files scratched with the SCRATCH command. ERROR ERROR MESSAGE AND NUMBER DESCRIPTION 20: READ ERROR (block header not found) The disk controller is unable to locate the header of the requested data block. Caused by an illegal sector number, or the header has been destroyed. 21: READ ERROR (no sync character) The disk controller is unable to detect a sync mark on the desired track. Caused by misalignment of the read/write head, no diskette is present, or unformatted or improperly seated diskette. Can also indicate a hardware failure. 22: READ ERROR (data block not present) The disk controller has been requested to read or verify a data block that was not properly written. This error occurs in conjunc- tion with the BLOCK commands and indicates an illegal track and/or sector request. 23: READ ERROR (checksum error in data block) This error message indicates there is an error in one or more of the data bytes. The data has been read into the DOS memory, but the checksum over the data is in error. This message may also indicate hardware grounding problems. 24: READ ERROR (byte decoding error) The data or header has been read into the DOS memory but a hardware error has been created due to an invalid bit pattern in the data byte. This message may also indicate grounding problems. 25: WRITE ERROR (write-verify error) This message is generated if the controller detects a mismatch be- tween the written data and the data in DOS memory. 26: WRITE PROTECT ON This message is generated when the controller has been requested to write a data block while the write protect switch is depressed. This is caused by using a diskette with a write protect tab over the notch. 27: READ ERROR (checksum error in header) This message is generated when a checksum error had been detected in the header of the requested data block. The block has not been read into DOS memory. 28: WRITE ERROR (long data block) This error message is generated when a data block is too long and overwrites the sync mark of the next header. 29: DISK ID MISMATCH This message is generated when the controller has been requested to access a diskette which has not been initialized. The message can also occur if a diskette has a bad header. 30: SYNTAX ERROR (general syntax) The DOS cannot interpret the command sent to the command channel. Typically, this is caused by an illegal number of file names, or patterns are illegally used. For example, file names appear on the left side of the COPY command. 31: SYNTAX ERROR (invalid command) The DOS does not recognize the command. The command must start in the first position. 32: SYNTAX ERROR (long line) The command sent is longer than 58 characters. Use abbreviated disk commands. 33: SYNTAX ERROR (invalid file name) Pattern matching is invalidly used in the OPEN or SAVE command. Spell out the file name. 34: SYNTAX ERROR (no file given) The file name was left out of the command or the DOS does not recognize it as such. Typically, a colon {:} has been left out of the command. 39: SYNTAX ERROR (invalid command) This error may result if the command sent to the command channel (secondary address 15) is unrecognized by the DOS. 50: RECORD NOT PRESENT Result of disk reading past the last record through INPUT# or GET# commands. This message will also occur after positioning to a record beyond the end-of-file in a relative file. If the intent is to expand the file by adding the new record (with a PRINT# com- mand), the error message may be ignored. INPUT# or GET# should not be attempted after this error is detected without first reposi- tioning. 51: OVERFLOW IN RECORD PRINT# statement exceeds record boundery. Information is truncated. Since the carriage return which is sent as a record terminator is counted in the record size, this message will occur if the total of characters in the record (including the final carriage return) exceeds the defined size of the record. 52: FILE TOO LARGE Record position within a relative file indicates that disk overflow will result. 60: WRITE FILE OPEN This message is generated when a write file that has not been closed is being opened for reading. 61: FILE NOT OPEN This message is generated when a file is being accessed that has not been opened in the DOS. Sometimes, in this case, a message is not generated; the request is simply ignored. 62: FILE NOT FOUND The requested file does not exist on the indicated drive. 63: FILE EXISTS The file name of the file being created already exists on the dis- kette. 64: FILE TYPE MISMATCH The requested file access is not possible using files of the type named. Reread the chapter covering that file type. 65: NO BLOCK Occurs in conjunction with Block Allocation. The sector you tried to allocated is already allocated. The track and sector numbers re- turned are the next higher track and sector available. If the track number returned zero (0), all remaining sectors are full. If the diskette is not full yet, try a lower track and sector. 66: ILLEGAL TRACK AND SECTOR The DOS has attempted to access a track or block which does not exist in the format being used. This may indicate a problem reading the pointer of the next block. 67: ILLEGAL SYSTEM T OR S This special error message indicates an illegal system track or sector. 70: NO CHANNEL (available) The requested channel is not available, or all channels are in use. A maximum of five buffers are available for use. A sequential file requires two buffers; a relative file requires three buffers; and the error/command channel requires one buffer. You may use any com- bination of those as long as the combination does not exceed five buffers. 71: DIRECTORY ERROR The BAM (Block Availability Map) on the diskette does not match the copy on disk memory. To correct, initialize the diskette. 72: DISK FULL Either the blocks on the diskette are used or the directory is at its entry limit. DISK FULL is sent when two blocks are still available on the diskette, in order to allow the current file to be closed. 73: DOS MISMATCH (VERSION NUMBER) DOS 1 and 2 are read compatible but not write compatible. Disks may be interchangeably read with either DOS, but a disk formatted on one version cannot be written upon with the other version, because the format is different. This error is displayed whenever an attempt is made to write upon a disk which has been formatted in a non-compatible format. This message will also appear after power up and is not an error in this case. 74: DRIVE NOT READY An attempt has been made to access the disk drive without any in- serted diskette; or the drive lever or door is open. APPENDIX C C. CONNECTORS/PORTS FOR PERIPHERAL EQUIPMENT [PICTURES ARE MISSING] C.1 Side Panel Connections 1. Power Socket - The five pin square plug from the power supply is con- nected here. 2. Power Switch - Turns on power from the power supply. 3. Reset Button - Resets computer (warm start). 4. Controller Ports - There are two Controller ports, numbered 1 and 2. Each Controller port can accept a joystick or game controller paddle. The light pen can be plugged only into port 1, the port closest to the front of the computer. Use the ports as instructed with the software. Control Port 1 +-----+-------------+-----------+ | Pin | Type | Note | +-------------------+ | 1 | JOYA0 | | / 1 2 3 4 5 \ | 2 | JOYA1 | | + O O O O O + | 3 | JOYA2 | | \ / | 4 | JOYA3 | | + O O O O + | 5 | POT AY | | \ 6 7 8 9 / | 6 | BUTTON A/LP | | +---------------+ | 7 | +5V | MAX. 50mA | | 8 | GND | | | 9 | POT AX | | +-----+-------------+-----------+ Control Port 2 +-----+-------------+-----------+ | Pin | Type | Note | | 1 | JOYB0 | | | 2 | JOYB1 | | | 3 | JOYB2 | | | 4 | JOYB3 | | | 5 | POT BY | | | 6 | BUTTON B | | | 7 | +5V | MAX. 50mA | | 8 | GND | | | 9 | POT BX | | +-----+-------------+-----------+ C.2 Rear Connections 5. Expansion Port - This rectangular slot is a parallel port that accepts programs or game cartridges as well as special interfaces. Cartridge Expansion Slot +----+----------+ +----+----------+ +----+----------+ +----+----------+ | Pin| Type | | Pin| Type | | Pin| Type | | Pin| Type | +----+----------+ +----+----------+ +----+----------+ +----+----------+ | 1 | GND | | 12 | BA | | A | GND | | N | A9 | | 2 | +5V | | 13 | /DMA | | B | /ROMH | | P | A8 | | 3 | +5V | | 14 | D7 | | C | /RESET | | R | A7 | | 4 | /IRQ | | 15 | D6 | | D | /NMI | | S | A6 | | 5 | R/W | | 16 | D5 | | E | 02 | | T | A5 | | 6 | Dot Clock| | 17 | D4 | | F | A15 | | U | A4 | | 7 | I/O1 | | 18 | D3 | | H | A14 | | V | A3 | | 8 | /GAME | | 19 | D2 | | J | A13 | | W | A2 | | 9 | /EXROM | | 20 | D1 | | K | A12 | | X | A1 | | 10 | I/O2 | | 21 | D0 | | L | A11 | | Y | A0 | | 11 | /ROML | | 22 | GND | | M | A10 | | Z | GND | +----+----------+ +----+----------+ +----+----------+ +----+----------+ 2 2 2 1 1 1 1 1 1 1 1 1 1 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 +---@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@---+ | | +---@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@-@---+ Z Y X W V U T S R P N M L K J H F E D C B A 6. Cassette Port - A 1530 Datassette recorder can be attached here to store programs and information. Cassette Port +-------+--------------------+ | Pin | Type | +-------+--------------------+ | A-1 | GND | 1 2 3 4 5 6 | B-2 | +5V | +---@-@-@-@-@-@---+ | C-3 | CASSETTE MOTOR | | | | D-4 | CASSETTE READ | +---@-@-@-@-@-@---+ | E-5 | CASSETTE WRITE | A B C D E F | F-6 | CASSETTE SENSE | +-------+--------------------+ 7. Serial Port - A Commodore Serial printer or disk drive can be attached directly to the Commodore 128 through this port. Serial I/O Port +-------+----------------------+ | Pin | Type | ++ ++ +-------+----------------------+ / +-+ \ | 1 | /SERIAL SRQ IN | /5 1\ | 2 | GND | + O O + | 3 | SERIAL ATN OUT | | 6 | | 4 | SERIAL CLK IN/OUT | | O | | 5 | SERIAL DATA IN/OUT | | | | 6 | /RESET | + O O + +-------+----------------------+ \4 O 2/ \ 3 / +---+ Note: The Commodore Serial Port is not RS-232 compatible. TTL RS-232 levels can be obtained from the User Port. 8. 40 Column Video Connector - This DIN connector provides audio and com- posite video signals which can be directly connected to suitable audio and monitor equipment. These signals can be connected to the Commodore monitor or used with separate components. Audio/Composite Video Connector +-------+----------------------+ | Pin | Type | ++ ++ +-------+----------------------+ /8+-+7\ | 1 | LUMINANCE/SYNC | /O O\ | 2 | GND | | 6 | | 3 | AUDIO OUT | |3O O O1| | 4 | VIDEO OUT | | | | 5 | AUDIO IN | + O O + | 6 | CHROMINANCE | \5 O 4/ | 7 | NC | \ 2 / | 8 | NC | +---+ +-------+----------------------+ 9. RF Connector - This connector supplies both picture and sound to your television set. (A television can display only a 40 column picture.) 10. 80 Column RGBI Connector - This 9-pin connector supplies an RGBI (Red/ Green/Blue/Intensity) signal. 80 Column RGBI Connector +----+-------------------------+ | Pin| Signal | +-------------------+ +----+-------------------------+ / 1 2 3 4 5 \ | 1 | Ground | + O O O O O + | 2 | Ground | \ / | 3 | Red | + O O O O + | 4 | Green | \ 6 7 8 9 / | 5 | Blue | +---------------+ | 6 | Intensity | | 7 | Monochrome | | 8 | Horizontal Sync | | 9 | Vertical Sync | +----+-------------------------+ 11. User Port - Various interface devices can be attached here. User I/O User I/O Port +-----+---------------+-----------+ +-----+---------------+-----------+ | Pin | Type | Note | | Pin | Type | Note | +-----+---------------+-----------+ +-----+---------------+-----------+ | 1 | GND | | | A | GND | | | 2 | +5V |MAX. 100 mA| | B | /FLAG2 | | | 3 | /RESET | | | C | PB0 | | | 4 | CNT1 | | | D | PB1 | | | 5 | SP1 | | | E | PB2 | | | 6 | CNT2 | | | F | PB3 | | | 7 | SP2 | | | H | PB4 | | | 8 | /PC2 | | | I | PB5 | | | 9 | SER. ATN OUT | | | K | PB6 | | | 10 | 9 VAC |MAX. 100 mA| | L | PB7 | | | 11 | 9 VAC |MAX. 100 mA| | M | PA2 | | | 12 | GND | | | N | GND | | +-----+---------------+-----------+ +-----+---------------+-----------+ 1 1 1 1 2 3 4 5 6 7 8 9 0 1 2 +--@-@-@-@-@-@-@-@-@-@-@-@--+ | | +--@-@-@-@-@-@-@-@-@-@-@-@--+ A B C D E F H J K L M N APPENDIX D D. SCREEN DISPLAY CODES - 40 Columns The following chart lists all of the characters built into the Commodore screen character sets. It shows which numbers should be POKED into screen memory (locations 1024-2023) to get a desired character on the 40-column screen (Remember, to set color memory, use locations 55296 to 56295). Also shown is which character corresponds to a number PEEKed from the screen. Two character sets are available. Both are available simultaneously in 80- column mode, but only is available at a time on the 40-column screen. The sets are switched by holding down the {shift} and {C=} (Commodore) keys simultaneously. From BASIC, PRINT CHR$(142) will switch to upper case/graphics mode and PRINT CHR$(14) will switch to upper/lower case mode. Any number on the chart may also be displayed in REVERSE. The reverse character code may be obtained by adding 128 to the values shown. SET 1 SET 2 POKE | SET 1 SET 2 POKE | SET 1 SET 2 POKE ------------------------+------------------------+----------------------- @ 0 | + 43 | V 86 A a 1 | , 44 | W 87 B b 2 | - 45 | X 88 C c 3 | . 46 | Y 89 D d 4 | / 47 | Z 90 E e 5 | 0 48 | 91 F f 6 | 1 49 | 92 G g 7 | 2 50 | 93 H h 8 | 3 51 | 94 I i 9 | 4 52 | SPACE 95 J j 10 | 5 53 | 96 K k 11 | 6 54 | 97 L l 12 | 7 55 | 98 M m 13 | 8 56 | 99 N n 14 | 9 57 | 100 O o 15 | : 58 | 101 P p 16 | ; 59 | 102 Q q 17 | < 60 | 103 R r 18 | = 61 | 104 S s 19 | > 62 | 105 T t 20 | ? 63 | 106 U u 21 | 64 | 107 V v 22 | A 65 | 108 W w 23 | B 66 | 109 X x 24 | C 67 | 110 Y y 25 | D 68 | 111 Z z 26 | E 69 | 112 [ 27 | F 70 | 113 pound 28 | G 71 | 114 ] 29 | H 72 | 115 ^ 30 | I 73 | 116 <- 31 | J 74 | 117 SPACE 32 | K 75 | 118 ! 33 | L 76 | 119 " 34 | M 77 | 120 # 35 | N 78 | 121 $ 36 | O 79 | 122 % 37 | P 80 | 123 & 38 | Q 81 | 124 ' 39 | R 82 | 125 ( 40 | S 83 | 126 ) 41 | T 84 | 127 * 42 | U 85 | Codes from 128-255 are reversed images of codes 0-127. APPENDIX E E. ASCII AND CHR$ CODES This appendix shows you what characters will appear if you PRINT CHR$(X), for all possible values of X. It will also show the values obtained by typing PRINT ASC("x"), where x is any character that can be displayed. This is useful in evaluating the character received in a GET statement, conver- ting upper to lower case, and printing character based commands (like switch to upper/lower case) that could not be enclosed in quotes. +-----------------+-----------------+-----------------+-----------------+ | PRINTS CHR$ | PRINTS CHR$ | PRINTS CHR$ | PRINTS CHR$ | +-----------------+-----------------+-----------------+-----------------+ | 0 | 0 48 | 96 | {black} 144 | | 1 | 1 49 | 97 | {up} 145 | | 2 | 2 50 | 98 | {rvs off} 146 | | 3 | 3 51 | 99 | {clear} 147 | | 4 | 4 52 | 100 | {inst} 148 | | {white} 5 | 5 53 | 101 | {brown} 149 | | 6 | 6 54 | 102 | {lt. red} 150 | | 7 | 7 55 | 103 | {grey 1} 151 | | disSHIFT+C= 8 | 8 56 | 104 | {grey 2} 152 | | enaSHIFT+C= 9 | 9 57 | 105 | {lt.green}153 | | 10 | : 58 | 106 | {lt.blue} 154 | | 11 | ; 59 | 107 | {grey 3} 155 | | 12 | < 60 | 108 | {purple} 156 | | return 13 | = 61 | 109 | {left} 157 | | lower case 14 | > 62 | 110 | {yellow} 158 | | 15 | ? 63 | 111 | {cyan} 159 | | 16 | @ 64 | 112 | SPACE 160 | | {down} 17 | A 65 | 113 | 161 | | {rvs on} 18 | B 66 | 114 | 162 | | {home} 19 | C 67 | 115 | 163 | | {del} 20 | D 68 | 116 | 164 | | 21 | E 69 | 117 | 165 | | 22 | F 70 | 118 | 166 | | 23 | G 71 | 119 | 167 | | 24 | H 72 | 120 | 168 | | 25 | I 73 | 121 | 169 | | 26 | J 74 | 122 | 170 | | 27 | K 75 | 123 | 171 | | {red} 28 | L 76 | 124 | 172 | | {right} 29 | M 77 | 125 | 173 | | {green} 30 | N 78 | 126 | 174 | | {blue} 31 | O 79 | 127 | 175 | | SPACE 32 | P 80 | 128 | 176 | | ! 33 | Q 81 | {orange} 129 | 177 | | " 34 | R 82 | 130 | 178 | | # 35 | S 83 | 131 | 179 | | $ 36 | T 84 | 132 | 180 | | % 37 | U 85 | f1 133 | 181 | | & 38 | V 86 | f3 134 | 182 | | ' 39 | W 87 | f5 135 | 183 | | ( 40 | X 88 | f7 136 | 184 | | ) 41 | Y 89 | f2 137 | 185 | | * 42 | Z 90 | f4 138 | 186 | | + 43 | [ 91 | f6 139 | 187 | | , 44 | pound 92 | f8 140 | 188 | | - 45 | ] 93 |shift+ret. 141 | 189 | | . 46 | ^ 94 |upper case 142 | 190 | | / 47 |{arrow left}95 | 143 | 191 | +-----------------+-----------------+-----------------+-----------------+ CODES 192-223 SAME AS 96-127 CODES 224-254 SAME AS 160-190 CODE 255 SAME AS 126 Note: The above codes are for C64 mode. See Appendix I for special codes in C128 mode. APPENDIX F F. SCREEN AND COLOR MEMORY MAPS - C128 Mode, 40 Column and C64 Mode The following maps display the memory locations used in 40-column mode (C128 and C64) for identifying the characters on the screen as well as their color. Each map is separately controlled and consists of 1,000 posi- tions. The character displayed on the maps can be controlled directly with the POKE command. F.1 SCREEN MEMORY MAP COLUMN 1063 0 10 20 30 39 / +------------------------------------------------------------/ 1024 | | 0 1064 | | 1104 | | 1144 | | 1184 | | 1224 | | 1264 | | 1304 | | 1344 | | 1384 | | 1424 | | 10 1464 | | 1504 | | ROW 1544 | | 1584 | | 1624 | | 1664 | | 1704 | | 1744 | | 1784 | | 1824 | | 20 1864 | | 1904 | | 1944 | | 1984 | | 24 +------------------------------------------------------------\ The Screen Map is POKEd with a Screen Display Code value (see Appendix D). For example: POKE 1024,13 will display the letter {M} in the upper-left corner of the screen. F.2 COLOR MEMORY MAP COLUMN 55335 0 10 20 30 39 / +------------------------------------------------------------/ 55296| | 0 55336| | 55376| | 55416| | 55456| | 55496| | 55536| | 55576| | 55616| | 55656| | 55696| | 10 55736| | 55776| | ROW 55816| | 55856| | 55896| | 55936| | 55976| | 56016| | 56056| | 56096| | 20 56136| | 56176| | 56216| | 56256| | 24 +------------------------------------------------------------\ 56295 If the color map is POKEd with a color value, this changes the character color. For example: POKE 55296,1 will change the letter {M} inserted above from light green to white. F.3 Color Codes - 40 Columns 0 Black 8 Orange 1 White 9 Brown 2 Red 10 Light Red 3 Cyan 11 Dark Gray 4 Purple 12 Medium Gray 5 Green 13 Light Green 6 Blue 14 Light Blue 7 Yellow 15 Light Gray Border Control Memory 53280 Background Control Memory 53281 APPENDIX G G. DERIVED TRIGONOMETRIC FUNCTIONS +------------------------------+------------------------------------------+ | FUNCTION | BASIC EQUIVALENT | +------------------------------+------------------------------------------+ | SECANT | SEC(X)=1/COS(X) | | COSECANT | CSC(X)=1/SIN(X) | | COTANGENT | COT(X)=1/TAN(X) | | INVERSE SINE | ARCSIN(X)=ATN(X/SQR(-X*X+1)) | | INVERSE COSINE | ARCCOS(X)=-ATN(X/SQR(-X*X+1))+{pi}/2 | | INVERSE SECANT | ARCSEC(X)=ATN(SQR(X*X-1)) | | INVERSE COSECANT | ARCCSC(X)=ATN(1/SQR(X*X-1)) | | INVERSE COTANGENT | ARCCOT(X)=ATN(1/X) | | HYPERBOLIC SINE | SINH(X)=(EXP(X)-EXP(-X))/2 | | HYPERBOLIC COSINE | COSH(X)=(EXP(X)+EXP(-X))/2 | | HYPERBOLIC TANGENT | TANH(X)=(EXP(X)-EXP(-X))/(EXP(X)+EXP(-X))| | HYPERBOLIC SECANT | SECH(X)=2/(EXP(X)+EXP(-X)) | | HYPERBOLIC COSECANT | CSCH(X)=2/(EXP(X)-EXP(-X)) | | HYPERBOLIC COTANGENT | COTH(X)=EXP(-X)/(EXP(X)-EXP(-X))*2+1 | | INVERSE HYPERBOLIC SINE | ARCSINH(X)=LOG(X+SQR(X*X+1)) | | INVERSE HYPERBOLIC COSINE | ARCCOSH(X)=LOG(X+SQR(X*X-1)) | | INVERSE HYPERBOLIC TANGENT | ARCTANH(X)=LOG((1+X)/(1-X))/2 | | INVERSE HYPERBOLIC SECANT | ARCSECH(X)=LOG(SQR(-X*X+1)+1)/X) | | INVERSE HYPERBOLIC COSECANT | ARCCSCH(X)=LOG((SGN(X)*SQR(X*X+1)+1/X) | | INVERSE HYPERBOLIC COTANGENT | ARCCOTH(X)=LOG((X+1)/(X-1))/2 | +------------------------------+------------------------------------------+ APPENDIX H H. MEMORY MAP SYSTEM MEMORY MAP The Commodore 128 BASIC memory map is shown below: COMMODORE 128 MODE MEMORY MAP --------------------------------------- C128 RAM C128 ROM FFFF+-------------+ FFFF+-------------+ FFFA|NMI RST IRQ | | | |CP/M RAM Code| | | FFD0| | FF4D+-------------+- - Kernal Jump Table - - |krnl RAM Code| | | & Hardware Vectors | FF05+-------------+ FF05+-------------+- - Kernal interrupt |MMU | | | Dispatch Code | |Configuration| | | |Register | | | | FF00+-------------+ FF00|/////////////|- - MMU Configuration | | | | Registers |\ | | FC80| - - - - - - |- - ROM Reserved for |HIGH | | | | Foreign Lang. |/ ROM | | | | Versions | | FA00| - - - - - - |- - Editor Tables | | | | | | | E000| - - - - - - |- - Kernal ROM Code | | | |/////////////| | | D000|/////////////|- - I/O Space | | | | | | | C000| - - - - - - |- - Editor ROM Code - - -| | | | | | | B000| - - - - - - |- - Monitor ROM Code - -|\_MID | | | | / ROM | | 8000| |- - - - - - - - - - - - -| | | | | | | | | |\ LOW | | | | |ROM 4000+-------------+ 4000+-------------+- - Basic ROM Code - - -|/ COMMODORE 128 MODE MEMORY MAP --------------------------------------- C128 RAM 4000+---------------------------------+ | VIC BIT-MAP Screen | 2000| - - - - - - - - - - - - - - - - | | VIC BIT-MAP Color (VM #2) | 1C00+---------------------------------+ | Reserved for | | Function Key Software | 1800+---------------------------------+ | Reserved for | | Foreign Lang.Systems | 1400+---------------------------------+ | | 1300+---------------------------------+ | Basic Absolute Variables | 1200+---------------------------------+ | Basic DOS/VSP Variables | 1108+---------------------------------+ | CP/M Reset Code | 1100+---------------------------------+ | Function Key Buffer | 1000+---------------------------------+ | Sprite Definition Area | 0E00+---------------------------------+ | RS/232 Output Buffer | 0D00+---------------------------------+ | RS/232 Input Buffer | 0C00+---------------------------------+ | (Disk Boot Page) | 0BC0| - - - - - - - - - - - - - - - - | | Cassette Buffer | 0B00+---------------------------------+ |Monitor & Kernal Absolute Values | 0A00+---------------------------------+ | Basic Run-Time Stack | 0800+---------------------------------+ | VIC Text Screen (VM #1) | 0400+---------------------------------+ COMMODORE 128 MODE MEMORY MAP --------------------------------------- C128 RAM 0400+---------------------------------+ | Basic RAM Code | 0380+ - - - - - - - - - - - - - - - - + | Kernal Tables | 033C+ - - - - - - - - - - - - - - - - + | Indirects | 02FC+ - - - - - - - - - - - - - - - - + | Kernal RAM Code | 02A2+ - - - - - - - - - - - - - - - - + | Basic & Monitor Input Buffer | 0200+ - - - - - - - - - - - - - - - - + | System Stack | 0149+ - - - - - - - - - - - - - - - - + | Basic DOS Using | 0110+ - - - - - - - - - - - - - - - - + | F Buffer | 0100+ - - - - - - - - - - - - - - - - + | Kernal Z.P. | 0090+ - - - - - - - - - - - - - - - - + | Basic Z.P. | 0002+ - - - - - - - - - - - - - - - - + 0000+---------------------------------+ APPENDIX I I. CONTROL AND ESCAPE CODES I.1 CONTROL CODES Effective Key in Mode: CHR$ Sequence Function C64 C128 --------------------------------------------------------------------------- CHR$(2) CTRL B Underline (80) * CHR$(5) CTRL 2 or Set character color to white CTRL E (40) and (80) * * CHR$(7) CTRL G Produce bell tone * CHR$(8) CTRL H Disable character set change * CHR$(9) CTRL I Enable character set change * Move cursor to next tab position * CHR$(10) CTRL J Send a carriage return with line feed * Send a line feed * CHR$(11) CTRL K Disable character set change * CHR$(12) CTRL L Enable character set change * CHR$(13) CTRL M Send a carriage return and line feed to the computer and enter a line of BASIC * * CHR$(14) CTRL N Set character set to lower/upper case set * * CHR$(15) CTRL O Turn flash on (80) * CHR$(17) CRSR DOWN or Move the cursor down one row * * CTRL Q CHR$(18) CTRL 9 characters to be printed in reverse field * * CHR$(19) HOME or Move the cursor to the home CTRL S position (top left) of the display (the current window) * * CHR$(20) DEL or Delete last character typed and CTRL T move all characters to the right one space to the left * * CHR$(24) CTRL X Tab set/clear * CHR$(27) ESC or CTRL [ Send an ESC character * CHR$(28) CTRL 3 or Send character color to red CTRL / (40) and (80) * * CHR$(29) CRSR RIGHT or Move cursor one column to the CTRL ] right * * CHR$(30) CTRL 6 or Set character color to green CTRL ^ (40) and (80) * * CHR$(34) " Print a double quote on screen and place editor in quote mode * * CHR$(129) C= 1 Set character color to orange (40); dark purple (80) * * CHR$(130) Underline off (80) * CHR$(131) Run a program. This CHR$ code does not work in PRINT CHR$(131), but works from keyboard buffer * CHR$(133) F1 Reserved CHR$ code for F1 key * CHR$(134) F3 Reserved CHR$ code for F3 key * CHR$(135) F5 Reserved CHR$ code for F5 key * CHR$(136) F7 Reserved CHR$ code for F7 key * CHR$(137) F2 Reserved CHR$ code for F2 key * CHR$(138) F4 Reserved CHR$ code for F4 key * CHR$(139) F6 Reserved CHR$ code for F6 key * CHR$(140) F8 Reserved CHR$ code for F8 key * CHR$(141) SHIFT RETURN Send a carriage return and line feed without entering a BASIC line * * CHR$(142) Set the character set to upper case/graphics * * CHR$(143) Turn flash off (80) * CHR$(144) CTRL 1 Set character color to black (40) and (80) * * CHR$(145) CRSR UP Move cursor or printing position up one row * * CHR$(146) CTRL 0 Terminate reverse field display * * CHR$(147) HOME Clear the window screen and move the cursor to the top left position * * CHR$(148) INST Move character from cursor position right one column * * CHR$(149) C= 2 Set character color to brown (40); dark yellow (80) * * CHR$(150) C= 3 Set character color to light red (40) and (80) * * CHR$(151) C= 4 Set character color to dark gray (40); dark cyan (80) * * CHR$(152) C= 5 Set character color to medium gray (40) and (80) * * CHR$(153) C= 6 Set character color to light green (40) and (80) * * CHR$(154) C= 7 Set character color to light blue (40) and (80) * * CHR$(155) C= 8 Set character color to light gray (40) and (80) * * CHR$(156) CTRL 5 Set character color to purple (40) and (80) * * CHR$(157) CRSR LEFT Move cursor left one column * * CHR$(158) CTRL 8 Set character color to yellow (40) and (80) * * CHR$(159) CTRL 4 Set character color to cyan (40); light cyan (80) * * Note: (40) ... 40 column screen only; (80) ... 80 column screen only I.2 ESCAPE CODES Following are key sequences for the ESCape functions available on the Commodore 128. ESCape sequences are entered by pressing and releasing the {ESC} key, following by pressing the key listed below. ESCAPE FUNCTION ESCAPE KEY --------------- ---------- Cancel quote and insert mode ESC O Erase to end of current line ESC Q Erase to start of current line ESC P Erase to end of screen ESC @ Move to start of current line ESC J Move to end of current line ESC K Enable auto-insert mode ESC A Disable auto-insert mode ESC C Delete current line ESC D Insert line ESC I Set default tab stops (8 spaces) ESC Y Clear all tab stops ESC Z Enable scrolling ESC L Disable scrolling ESC M Scroll up ESC V Scroll down ESC W Enable bell (by CTRL G) ESC G Disable bell ESC H Set cursor to non-flashing mode ESC E Set cursor to flashing mode ESC F Set bottom of screen window at cursor position ESC B Set top of screen window at cursor position ESC T Swap 40/80 column display output device ESC X The following ESCape sequences are valid on an 80-column screen only. (See Section 8 for information on using an 80-column screen.) Change to underlined cursor ESC U Change to block cursor ESC S Set screen to reverse video ESC R Set screen to normal (non reverse video) state ESC N APPENDIX J J. MACHINE LANGUAGE MONITOR J.1 Introduction Commodore 128 has a built-in machine language monitor which lets the user write and examine machine language programs easily. Commodore 128 MONITOR includes a machine language monitor, a mini-assembler and a disassembler. The built-in monitor works only in C128 mode; either 40 column or 80 column. Machine language programs written using Commodore 128 MONITOR can run by themselves or be used as very fast subroutines for BASIC programs since the Commodore 128 MONITOR has the ability to coexist peacefully with BASIC. Care must be taken to position the assembly language programs in memory so the BASIC program does not overwrite them. To enter the monitor from BASIC, type: MONITOR {return} Summary of Commodore 128 Monitor Commands ASSEMBLE Assembles a line of 8502 code. COMPARE Compares two sections of memory and reports differences. DISASSEMBLE Disassembles a line of 8502 code. FILL Fills a range of memory with the specified byte. GO Starts execution at the specified address. HUNT Hunts through memory within a specified range for all occur- rances of a set of bytes. JUMP Jumps to the subroutine. LOAD Loads a file from tape or disk. MEMORY Displays the hexadecimal values of memory locations. REGISTERS Displays the 8502 registers. SAVE Saves to tape or disk. TRANSFER Transfers code from one section of memory to another. VERIFY Compares memory with tape or disk. EXIT Exits Commodore 128 MONITOR (period) Assembles a line of 8502 code (same as Assemble). (greater than) Modifies memory. (semicolon) Modifies 8502 register displays. @ (at sign) Displays disk status, sends disk command, displays direc- tory. The Commodore 128 displays 5-digit hexadecimal addresses within the machine language monitor. Normally, a hexadecimal number is only four digits, representing the allowable address range. The extra left-most (high order) digit specifies the BANK configuration (at the time the given command is executed) according to the following memory configuration table: 0 - RAM 0 only 8 - EXT ROM, RAM 0, I/O 1 - RAM 1 only 9 - EXT ROM, RAM 1, I/O 2 - RAM 2 only A - EXT ROM, RAM 2, I/O 3 - RAM 3 only B - EXT ROM, RAM 3, I/O 4 - INT ROM, RAM 0, I/O C - KERNAL + INT (lo), RAM 0, I/O 5 - INT ROM, RAM 1, I/O D - KERNAL + EXT (lo), RAM 0, I/O 6 - INT ROM, RAM 2, I/O E - KERNAL + BASIC, RAM 0, CHARROM 7 - INT ROM, RAM 3, I/O F - KERNAL + BASIC, RAM 0, I/O J.2 Summary for Monitor Field Descriptors The following designators precede monitor data fields (e.g. memory dumps). When encountered as a command, these designators instruct the monitor to alter memory or register contents using the given data. . {period} precedes lines of disassembled code > {right angle} precedes lines of memory dump ; {semicolon} precedes line of a register dump The following designators precede number fields (e.g. addresses) and spe- cify the radix (number base) of the value. Entered as commands, these designators instruct the monitor simply to display the given value in each of the four radices. {null} (default) precedes hexadecimal values. $ {dollar} precedes hexadecimal (base-16) values + {plus} precedes decimal (base-10) values & {ampersand} precedes octal (base-8) values % {percent} precedes binary (base-2) values The following characters are used by the monitor as field delimiters or line terminators (unless encountered within an ASCII string). {space} delimiter seperates two fields , {comma} delimiter seperates two fields : {colon} terminator logical end of line ? {question} terminator logical end of line J.3 Command descriptions Note: < > enclose required parameters [ ] enclose optional parameters Please note that any number field (e.g. addresses, device number, and data bytes) may be specified as a based number. This affects the operand field of the ASSEMBLE command as well. Also note the addition of the directory syntax to the disk command. As a further aid to programmers, the Kernel error message facility has been automatically enabled while in the Monitor. This means the Kernel will display "I/O ERROR#" and the error code, should there be any failed I/O attempt from the MONITOR. The message facility is turned off when exiting the MONITOR. COMMAND: A PURPOSE: Enter a line of assembly code SYNTAX: A
A hexadecimal number indicating the location in memory to place the opcode. A standard MOS technology assembly language mne- monic, e.g. LDA, STX, ROR. The operand, when required, can be any of the legal addressing modes. A {return} is used to indicate the end of the assembly line. If there are any errors on the line, a question mark is displayed to indicate an error, and the cursor moves to the next line. The screen editor can be used to correct the error(s) on that line. EXAMPLE: A01200 LDX #$00 A 1202 NOTE: A period (.) is equal to the ASSEMBLE command. EXAMPLE: .02000 LDA #$23 COMMAND: C PURPOSE: Compare two areas of memory SYNTAX: C
A number indicating the start address of the area of memory to compare against.
A number indicating the end address of the area of memory to compare against.
A number indicating the start address of the other area of memory to compare with. Addresses that do not agree are printed on the screen. COMMAND: D PURPOSE: Disassemble machine code into assembly language mnemonics and operands. SYNTAX: D [
] [
]
A number setting the address to start the dis- assembly.
An optional ending address of code to be dis- assembled. The format of the disassembly differs slightly from the input format of an assembly. The difference is that the first character of a disassembly is a period rather than an A (for readability), and the hexadecimal code is listed as well. A disassembly listing can be modified using the screen editor. Make any changes to the mnemonic or operand on the screen, then hit the carriage return. This enters the line and calls the assembler for further modifi- cations. A disassembly can be paged. Typing a D{return} causes the next page of disassembly to be displayed. EXAMPLE: D 3000 3003 .03000 A9 00 LDA #$00 .03002 FF ??? .03003 D0 2B BNE $3030 COMMAND: F PURPOSE: Fill a range of locations with a specified byte. SYNTAX: F
The first location to fill with the .
The last location to fill with the . Number to be written. This command is useful for initializing data structures or any other RAM area. EXAMPLE: F 0400 0518 EA Fill memory locations from $0400 to $0518 with $EA (a NOP instruction). COMMAND: G PURPOSE: Begin execution of a program at a specified address. SYNTAX: G [
]
An address where execution is to start. When address is left out, execution begins at the current PC. (The current PC can be viewed using the R command.) The GO command restores all registers (displayable by using the R command) and begins execution at the specified starting address. Caution is recom- mended in using the GO command. To return to Commodore 128 MONITOR mode after executing a machine language program, use the BRK instruction at the end of the program. EXAMPLE: G 140C Execution begins at location $140C. COMMAND: H PURPOSE: Hunt through memory within a specified range for all occurrences of a set of bytes. SYNTAX: H
Beginning address of hunt procedure.
Ending address of hunt procedure. Data set to search for data may be numbers or an ASCII string. EXAMPLES: H A000 A101 A9 FF 4C Search for data $A9, $FF, $4C, from $A000 to $A101. H 2000 9800 'CASH Search for the alpha string "CASH". COMMAND: J PURPOSE: Begin execution of a program at a specified address. SYNTAX: J [
]
An address where execution is to start. When address is left out, execution begins at the current PC. (The current PC can be viewed using the R command.) The JUMP command restores all registers (displayable by using the R com- mand) and begins execution at the specified starting address. Caution is recommended in using the JUMP command. To return to Commodore 128 MONITOR mode after executing a machine language program, use the RTS instruction at the end of the program. EXAMPLE: J 1300 Execution begins at location $1300. COMMAND: L PURPOSE: Load a file from cassette or disk. SYNTAX: L <"file name"> [, [,alt load address] ] <"file name"> Any legal Commodore 128 file name. A hexadecimal number indicating the device to load from, 1 is cassette, 8 is disk (or 9, A, etc.). [alt load address] Option to load a file to a specific address (4-digit number), or a bank configuration and address (5-digit number). The LOAD command causes a file to be loaded into memory. If the alternate load address is not used, the file will be loaded to the address in bank 0 that is specified in the cassette header, or the first two bytes of a disk file. The alternate load address is used to specify a different start address, which may range from $00000 to $FFFFF. EXAMPLE: L "PROGRAM", $12000 Loads the file named PROGRAM in from the disk in to bank 1, starting at $2000. COMMAND: M PURPOSE: To display memory as a hexadecimal and ASCII dump within the specified address range. SYNTAX: M [
[
]]
First address of memory dump. Optional. If omitted, one page is displayed. The first byte is the bank number to be displayed, the next four bytes are the first address to be displayed.
Last address of memory dump. Optional. If omitted, one page is displayed. The first byte is the bank number to be displayed, the next four bytes are the ending address to be displayed. Memory is displayed in the following format: >03000 45 58 2E 56 41 4C 55 45:EX.VALUE Memory content may be edited using the screen editor. Move the cursor to the data to be modified, type the desired correction and hit {return}. If there is a bad RAM location or an attempt to modify ROM has occurred, an error flag (?) is displayed. An ASCII dump of the data is displayed in REVERSE (to contrast with other data displayed on the screen) to the right of the hex data. When a charac- ter is not printable, it is displayed as a reverse period (.). As with the disassembly command, paging down is accomplished by typing M and {return}. EXAMPLE: M F4151 F4201 >F41F1 20 43 4F 4D 4D 4F 44 4F: COMMODO >F41F9 52 45 20 45 4C 45 43 54:RE ELECT >F4201 52 4F 4E 49 43 53 2C 20:TRONICS, NOTE: The above display is produced by the 40-column editor. COMMAND: R PURPOSE: Show important 8502 registers. The program status register, the program counter, the accumulator, the X and Y index registers and the stack pointer are displayed. SYNTAX: R The values of PC, SR, AC, XR, YR and SP are transfered to the 8502 before the Go or Jump command is executed. EXAMPLE: R PC SR AC XR YR SP ;01002 01 02 03 04 F6 NOTE: ; {semicolon} can be used to modify register displays in the same fashion as > (greater than) can be used to modify memory registers. COMMAND: S PURPOSE: Save an area of memory onto tape or disk. SYNTAX: S <"file name">, ,
,
<"file name"> Any legal Commodore 128 file name. To save the data the name must be enclosed in double quotes. Single quotes cannot be used. A hexadecimal number indicating on which device the file is to be placed. Cassette is 1; disk is 8, 9, etc.
Starting address of memory to be saved.
Ending address of memory to be saved + 1. All data up to, but not including the byte of data at this address, is saved. The file may be recalled, using the L command. When saving to cassette only bank 0 can be saved from. EXAMPLE: S "GAME",8,0400,0C00 Saves memory from $0400 to $0C00 onto disk. COMMAND: T PURPOSE: Transfer segments of memory from one memory area to another. SYNTAX: T
Starting address of data to be moved.
Ending address of data to be moved.
Starting address of of new location where data will be moved. Data can be moved from low memory to high memory and vice versa. Additional memory segments of any length can be moved forward or backward. An auto- matic "compare" is performed as each byte is transferred, and any differen- ces are listed by address. EXAMPLE: T 1400 1600 1401 Shifts data from $1400 up to and including $1600 one byte higher in memory. COMMAND: V PURPOSE: Verify a file on cassette or disk with the memory contents. SYNTAX: L <"file name"> [, [,alt start address] ] <"file name"> Any legal Commodore 128 file name. A hexadecimal number indicating the device to load from, 1 is cassette, disk is 8, 9, etc.). [alt start address] Option to start verification at this address (4- digit number), or a bank configuration and address (5-digit number). The Verify command compares a file to memory contents. The Commodore 128 responds with VERIFYING. If an error is found the word ERROR is added; if the file is successfully verified the cursor reappears. EXAMPLE: V "WORKLOAD", 8 COMMAND: X PURPOSE: Exit to BASIC. SYNTAX: X COMMAND: . {point} PURPOSE: Can be used to enter a line of assembly code. SYNTAX: see the A command. COMMAND: > (greater than) PURPOSE: Can be used to set up to 8 or 16 memory locations. SYNTAX: >
[]
First memory address to set. Data to be placed in succesive memory locations following the address, with a space preceding each data byte. The maximum number of bytes that can be entered is 8 (in 40 column mode) or 16 (in 80 column mode). When the {return} key is pressed the contents of the 8/16 locations after the address are displayed in hexadecimal value and as ASCII character. EXAMPLES: >2000 Displays line of bytes following $2000. >2000 31 32 38 Enters values at $2000 and displays line of bytes following $2000. COMMAND: ; {semicolon} PURPOSE: Can be used to modify the display of important 8502 registers. SYNTAX: ; [ [ [ [ [ []]]]]] A 5 digit hexadecimal number, consisting of the (leading) 1-digit bank configuration number and 4-digit value of the 8502 Program Counter. A 2-digit hexadecimal number, indicating the value of the 8502 Status Register. A 2-digit hexadecimal number, indicating the value of the 8502 Accumulator. A 2-digit hexadecimal number, indicating the value of the 8502 X index Register. A 2-digit hexadecimal number, indicating the value of the 8502 Y index Register. A 2-digit hexadecimal number, indicating the value of the 8502 Stack Pointer. It is easier to use the R command, because the register labels are listed above the line containing the register values. The values of PC, SR, AC, XR, YR and SP are transfered to the 8502 before the Go or Jump command is executed. COMMAND: @ {at sign} PURPOSE: Can be used to display the disk status. SYNTAX: @ [], Device unit number (optional). String command to disk. NOTE: @ alone gives the status of the disk drive. EXAMPLES: @ 00, OK, 00, 00 Checks disk status. @,I Initializes drive 8. @,$ Displays directory of drive 8. APPENDIX K K. BASIC 7.0 ABBREVIATIONS Note: The abbreviations below operate in uppercase/graphic mode. Press the letter key(s) indicated, then hold down the {shift} key and press the letter key following the word SHIFT. KEYWORD ABBREVIATION ABS A SHIFT B AND A SHIFT N APPEND A SHIFT P ASC A SHIFT S ATN A SHIFT T AUTO A SHIFT U BACKUP BA SHIFT C BANK B SHIFT A BEGIN B SHIFT E BEND BE SHIFT N BLOAD B SHIFT L BOOT B SHIFT O BOX none BSAVE B SHIFT S BUMP B SHIFT U CATALOG C SHIFT A CHAR CH SHIFT A CHR$ C SHIFT H CIRCLE C SHIFT I CLOSE CL SHIFT O CLR C SHIFT L CMD C SHIFT M COLLECT COLL SHIFT E COLINT none COLLISION COL SHIFT L COLOR COL SHIFT O CONCAT C SHIFT O CONT none COPY CO SHIFT P COS none DATA D SHIFT A DEC none DCLEAR DCL SHIFT E DCLOSE D SHIFT C DEF FN none DELETE DE SHIFT L DIM D SHIFT I DIRECTORY DI SHIFT R DLOAD D SHIFT L DO none DOPEN D SHIFT O DRAW D SHIFT R DS none DS$ none DSAVE D SHIFT S DVERIFY D SHIFT V EL none ELSE E SHIFT L END none ENVELOPE E SHIFT N ER none ERR$ E SHIFT R EXIT EX SHIFT I EXP E SHIFT X FAST none FETCH F SHIFT E FILTER F SHIFT I FN none FOR F SHIFT O FRE F SHIFT R GET G SHIFT E GETKEY GETK SHIFT E GET# none GO64 none GOSUB GO SHIFT S GOTO G SHIFT O GRAPHIC G SHIFT R GSHAPE G SHIFT S HEADER HE SHIFT A HELP HE SHIFT L HEX$ H SHIFT E IF none INPUT none INPUT# I SHIFT N INSTR IN SHIFT S INT none JOY J SHIFT O KEY K SHIFT E LEFT$ LE SHIFT F LEN none LET L SHIFT E LIST L SHIFT I LOAD L SHIFT O LOCATE LO SHIFT C LOG none LOOP LO SHIFT O MID$ M SHIFT I MONITOR MO SHIFT N MOVSPR none NEW none NEXT N SHIFT E NOT N SHIFT O ON none OPEN O SHIFT P OR none PAINT P SHIFT A PEEK PE SHIFT E PEN P SHIFT E (PI) none PLAY P SHIFT L POINTER PO SHIFT I POKE PO SHIFT K POS none POT P SHIFT O PRINT ? PRINT# P SHIFT R PRINT USING ?US SHIFT I PUDEF P SHIFT U RCLR R SHIFT C RDOT R SHIFT D READ RE SHIFT A RECORD R SHIFT E REM none RENAME RE SHIFT N RENUMBER REN SHIFT U KEYWORD ABBREVIATION RESTORE RE SHIFT S RESUME RES SHIFT U RETURN RE SHIFT T RGR R SHIFT G RIGHT$ R SHIFT I RND R SHIFT N RREG R SHIFT R RSPCOLOR RSP SHIFT C RSPPOS R SHIFT S RSPRITE RSP SHIFT R RUN R SHIFT U RWINDOW R SHIFT W SAVE S SHIFT A SCALE SC SHIFT A SCNCLR S SHIFT C SCRATCH SC SHIFT R SGN S SHIFT G SIN S SHIFT I SLEEP S SHIFT L SLOW none SOUND S SHIFT O SPC( none SPRCOLOR SPR SHIFT C SPRDEF SPR SHIFT D SPRITE S SHIFT P SPRSAV SPR SHIFT S SQR S SHIFT Q SSHAPE S SHIFT S STASH S SHIFT T ST none STEP ST SHIFT E STOP ST SHIFT O STR$ ST SHIFT R SWAP S SHIFT W SYS none TAB( T SHIFT A TAN none TEMPO T SHIFT E THEN T SHIFT H TI none TI$ none TO none TRAP T SHIFT R TROFF TRO SHIFT F TRON TR SHIFT O USR U SHIFT S VAL none VERIFY V SHIFT E VOL V SHIFT O WAIT W SHIFT A WHILE WH SHIFT I WIDTH W SHIFT I XOR X SHIFT O APPENDIX L L. DISK COMMAND SUMMARY This appendix lists the commands used for disk operation in C128 and C64 modes on the Commodore 128. For detailed information on any of these com- mands, see Chapter V, BASIC 7.0 Encyclopaedia. Your disk drive manual also has information on disk commands. The new BASIC 7.0 commands can be used only in C128 mode. All BASIC 2.0 commands can be used in both C128 and C64 modes. Command Use Basic 2.0 Basic 7.0 APPEND Append data to file * X BLOAD Load a binary file starting at the specified memory location X BOOT Load and execute program X BSAVE Save a binary file from the specified memory location X CATALOG Display directory contents of disk on screen * X CLOSE Close logical disk file X X CMD Redirect screen output to disk file X X COLLECT Free inaccessible disk space * X CONCAT Concatenates two data files * X COPY Copy files between drives * X DCLEAR Resets and initializes disk drives * X DCLOSE Close logical disk files * X DIRECTORY Display directory of contents of disk on screen * X DLOAD Load a BASIC program from disk * X DOPEN Open a disk file for a read and/or write operation * X DSAVE Save a BASIC program to disk * X DVERIFY Verify program in memory against program on disk * X GET# Receive input from open disk file X X HEADER Format a disk * X LOAD Load a file from disk X X OPEN Open a file for input or output X X PRINT# Output data to file X X RECORD Position relative file pointers * X RENAME Change name of a file on disk * X RUN filename Execute BASIC program from disk X SAVE Store program in memory to disk X X VERIFY Verify program in memory against program on disk X X * Although there is no single equivalent command in BASIC 2.0, there is an equivalent multi-command instruction. See your drive manual for these BASIC 2.0 conventions. GLOSSARY This glossary provides brief definitions of frequently used computing terms. Acoustic Coupler or Acoustic Modem: A device that converts digital signals to audible tones for transmission over telephone lines. Speed is limited to about 1,200 baud, or bits per second (bps). Compare direct- connect modem. Address: The label or number identifying the register or memory location where a unit of information is stored. Alphanumeric: Letters, numbers and special symbols found on the keyboard, excluding graphic characters. ALU: Arithmetic Logic Unit. The part of a Central Processing Unit (CPU) where binary data is acted upon. Animation: The use of computer instructions to simulate motion of an object on the screen through gradual, progressive movements. Array: A data-storage structure in which a series of related constants or variables are stored in consecutive memory locations. Each constant or variable contained in an array is referred to as an element. An ele- ment is accessed using a subscript. See subscript. ASCII: Acronym for American Standard Code for Information Interchange. A seven-bit code used to represent alphanumeric characters. It is useful for such things as sending information from a keyboard to the com- puter, and from one computer to another. See Character String Code. Assembler: A program that translates assembly-language instructions into machine-language instructions. Assembly Language: A machine-orientated language in which mnemonics are used to represent each machine-language instruction. Each CPU has its own specific assembly language. See CPU and machine language. Asynchronous Transmission: A scheme in which data characters are sent at random time intervals. Limits phone-line transmission to about 2,400 baud (bps). See Synchronous Transmission. Attack: The rate at which the volume of a musical note rises from zero to peak volume. Background Color: The color of the portion of the screen that the charac- ters are placed upon. BASIC: Acronym for Beginner's All-purpose Symbolic Instruction Code. Baud: Serial-data transmission speed. Originally a telegraph term, 300 baud is approximately equal to a transmission speed of 30 characters per second. Binary: A base-2 number system. All numbers are represented as a sequence of zeros and ones. Bit: The abbreviation for Binary digIT. A bit is the smallest unit in a computer. Each binary digit can have one of two values, zero or one. A bit is referred to as enabled or "on" if it equals one. A bit is disabled or "off" if it equals zero. Bit Control: A means of transmitting serial data in which each bit has a significant meaning and a single character is surrounded with start and stop bits. Bit Map Mode: An advanced graphic mode in the Commodore 128 in which you can control every dot on the screen. Border Color: The color of the edges around the screen. Branch: To jump to a section of a program and execute it. GOTO and GOSUB are examples of BASIC branch instructions. Bubble Memory: A relatively new type of computer memory; it uses tiny magnetic "pockets" or "bubbles" to store data. Burst Mode: A special high speed mode of communication between a disk drive and a computer, in which information is transmitted at many times normal speed. Bus: Parallel or serial lines used to transfer signals between devices. Computers are often described by their bus structure (i.e. S-100-bus computers, etc.). Bus Network: A system in which all stations or computer devices communicate by using a common distribution channel or bus. Byte: A group of eight bits that make up the smallest unit of addressable storage in a computer. Each memory location in the Commodore 128 con- tains one byte of information. One byte is the unit of storage needed to represent one character in memory. See Bit. Carrier Frequency: A constant signal transmitted between communicating devices that is modulated to encode binary information. Character: Any symbol on the computer keyboard that is printed on the screen. Characters include numbers, letters, punctuation and graphic symbols. Character Memory: The area in Commodore 128's memory which stores the en- coded character patterns that are displayed on the screen. Character Set: A group of related characters. The Commodore 128 character set consists of: upper-case letters, lower-case letters and graphic characters. Character String Code: The numeric value assigned to represent a Commodore 128 character in the computer's memory. Chip: A miniature electronic circuit that performs a computer operation such as graphics, sound and input/output. Clock: The timing circuit for a microprocessor. Clocking: A technique used to synchronize a sending and a receiving data- communications device that is modulated to encode binary information. Collision Detection: The recognition of the collision of sprites with other sprites or display data. Color Memory: The area in the Commodore 128's memory that controls the color of each location in screen memory. Command: A BASIC instruction used in direct mode to perform an action. See Direct Mode. Compiler: A program that translates a high-level language, such as BASIC, into machine language. Composite Monitor: A device used to provide a 40-column video display. Computer: An electronic, digital device that stores and processes infor- mation. Condition: Expression(s) between the words IF and THEN, evaluated as either true or false in an IF...THEN statement. The condition in the IF...THEN statement gives the computer the ability to make decissions. Coordinate: A single point on a grid having vertical (Y) and horizontal (X) values. Counter: A variable used to keep track of the number of times an event has occurred in a program. CPU: Acronym for Central Processing Unit. The part of the computer con- taining the circuits that control and perform the execution of com- puter instructions. Crunch: To minimize the amount of computer memory used to store a program. Cursor: The flashing square that marks the current location on the screen. Data: Numbers, letters or symbols that are input into the computer to be processed. Data Base: A large amount of data stored in a well-organized manner. A database management system is a program that allows access to the information. Data Link Layer: A logical portion of data communication control that mainly ensures that communication between adjacent devices is error free. Data Packet: A means of transmitting serial data in an efficient package that includes an error-checking sequence. Data Rate or Data Transfer Rate: The speed at which data is sent to a receiving computer - given in baud, or bits per second (bps). Datassette: A device used to store programs and data files sequentially on tape. Debug: To correct errors in a program. Decay: The rate at which the volume of a musical note decreases from its peak value to a mid-range volume called the sustain level. See Sustain. Decrement: To decrease an index variable or counter by a specific value. Dedicated Line or Leased Line: A special telephone line arrangement sup- plied by the telephone company, and required by certain computers or terminals, whereby the connection is always established (an exclusive, rented line). Delay Loop: An empty FOR...NEXT loop that slows the execution of a program. Dial-Up Line: The normal switched telephone line that can be used as a transmission medium for data communications. Digital: Of or relating to the technology of computers and data communica- tions where all information is encoded as bits of 1s and 0s that re- present on or off states. Dimension: The property of an array that specifies the direction along an axis in which the array elements are stored. For example, a two- dimensional array has an X-axis for columns and a Y-axis for rows. See Array. Direct Mode: The mode of operation that executes BASIC commands immediately after the {return} key is pressed. Also called Immediate Mode. See Command. Direct Connect Modem: A digital non-acoustic modem. Disable: To turn off a bit, byte or specific operation of the computer. Disk Drive: A random access, mass-storage devices that saves and loads files to and from a floppy diskette. Disk Operating System: Program used to transfer information to and from a disk. Often referred to as DOS. Duration: The length of time a musical note is played. Electronic Mail or E-Mail: A communications service for computer users where textual messages are sent to a central computer, or electronic "mail box", and later retreive by the addressee. Enable: To turn on a bit, byte or specific operation of the computer. Envelope Generator: Portion of the Commodore 128 that produces specific envelopes (attack, decay, sustain, release) for musical notes. See Waveform. EPROM: A PROM that can be erased by the user, usually by exposing it to ultraviolet light. See PROM. Error Checking or Error Detection: Software routines that identify, and often correct, erroneous data. Execute: To perform the specified instructions in a command or program statement. Expression: A combination of constants, variables or array elements acted upon by logical, mathematical or relational operators that return a numeric value. File: A program or collection of data treated as a unit and stored on disk or tape. Firmware: Computer instructions stored in ROM, as in a game cartridge. Frequency: The number of sound waves per second of a tone. The frequency corresponds to the pitch of the audible tone. Full-Duplex Mode: Allows two computers on the same line to transmit and receive data at the same time. Function: A predefined operation that returns a single value. Function Keys: The four keys on the far right of the Commodore 128 key- board. Each key can be programmed to execute a series of instructions. Since the keys can be SHIFTed, you can create eight different sets of instructions. Graphics: Visual screen images representing computer data in memory (i.e. characters, symbols and pictures). Graphic Characters: Non-alphanumeric characters on the computer's keyboard. Grid: A two-dimensional matrix divided into rows and columns. Grids are used to design sprites and programmable characters. Half-Duplex Mode: Allows transmission in only one direction at a time; if one device is sending, the other must simply receive data until it's time for it to transmit. Hardware: Physical components in a computer system such as keyboard, disk drive and printer. Hexadecimal: Refers to the base-16 number system. Machine language programs are often written in hexadecimal notation. Home: The upper-left corner of the screen. IC: Integrated Circuit. A silicon chip containing an electic circuit made up of components such as transistors, diodes, resistors and capaci- tors. Integrated circuits are smaller, faster and more efficient that the individual circuits used in older computers. Increment: To increase an index variable or counter with a specified value. Index: The variable counter within a FOR...NEXT loop. Input: Data fed into the computer to be processed. Input sources include the keyboard, disk drive, Datassette or modem. Integer: A whole number (i.e. a number containing no fractional part), such as 0, 1, 2, etc. Interface: The point of meeting between a computer and an external entity, whether an operator, a peripheral device or a communications medium. An interface may be physical, involving a connector, or logical, in- volving software. I/O: Input/Output. Refers to the process ot entering data into the com- puter, or transferring data from the computer to a disk drive, printer or storage medium. Keyboard: Input component of a computer system. Kilobyte (K): 1,024 bytes. Local Network: One of several short-distance data communications schemes typified by common use of a transmission medium by many devices and high-data speeds. Also called a Local Area Network, or LAN. Loop: A program segment executed repitively a specified number of times. Machine Language: The lowest level language the computer understands. The computer converts all high-level languages, such as BASIC, into machine language before executing any statements. Machine language is written in binary form that a computer can execute directly. Also called machine code or object code. Matrix: A two-dimensional rectangle with row and column values. Memory: Storage locations inside the computer. ROM and RAM are two dif- ferent types of memory. Memory location: A specific storage address in the computer. There are 131,072 memory locations in the Commodore 128. Microprocessor: A CPU that is contained on a single integrated circuit (IC). Microprocessors used in Commodore personal computers include the 6510, the 8502 and the Z80. Mode: A state of operation. Modem: Acronym for MODulator/DEModulator. A device that transforms digital signals from the computer into electrical impulses for transmission over telephone lines, and does the reverse in reception. Monitor: A display device resembling a television set but with a higher- resolution (sharper) image on the video screen. Motherboard: In a bus-oriented system, the board that contains the bus lines and edge connectors to accommodate the other boards in the system. Multi-Color Character Mode: A graphic mode that allows you to display four different colors within an 8 X 8 character grid. Multi-Color Bit Map Mode: A graphic mode that allows you to display one of four colors for each pixel within an 8 X 8 character grid. See Pixel. Multi-Access Network: A flexible system by which every station can have access to the network at all times; provisions are made for times when two computers decide to transmit at the same time. Null String: An empty character (""). A character that is not yet assigned a character string code. Octave: One full series of eight notes on the musical scale. Operating System: A built-in program that controls everything your computer does. Operator: A symbol that tells the computer to perform a mathematical, logical or relational operation on the specified variables, constants or array elements in the expression. The mathematical operators are +, -, *, / and ^. The relational operators are <, =, >, <=, >= and <>. The logical operators are AND, OR, NOT, and XOR. Order of Operations: Sequence in which computations are performed in a mathematical expression. Also called Hierarchy of Operations. Parallel Port: A port used for simultaneous transmission of data, one byte at a time over multiple wires, one bit per wire. Parity Bit: A 1 or 0 added to a group of bits that identifies the sum of the bits as odd or even. Peripheral: Any accessory device attached to the computer such as a disk drive, printer, modem or joystick. Pitch: The pitch of a note is determined by the frequency of the sound wave. The higher the frequency of a note, the higher its pitch. See Frequency. Pixel: Computer term for picture element. Each dot on the screen that makes up an image is called a pixel. Each character on the screen is dis- played within a 8 X 8 grid of pixels. The entire screen is composed of a 320 X 200 pixel grid. In bit-map mode, each pixel corresponds to one bit in the computer's memory. Polling: A communications control method used by some computer/terminal systems whereby a "master" station asks many devices attached to a common transmission medium, in turn, whether they have information to send. Pointer: A register used to indicate the address of a location in memory. Port: A channel through which data is transferred to and from the CPU. An 8-bit CPU can address 256 ports. Printer: Peripheral device that outputs onto a sheet of paper. This paper is referred to as a hard copy. Program: A series of instructions that direct the computer to perform a specific task. Programs can be stored on diskette or cassette, reside in the computer's memory, or be listed on a printer. Programmable: Capable of being processed with computer instructions. Program Line: A statement or series of statements preceded by a line number in a program. The maximum length of a program line on the Commodore 128 is 160 characters. PROM: Acronym for Programmable Read Only Memory. A semiconductor memory whose contents can only be written to once, after which the contents is permanent. See also EPROM and Read Only Memory (ROM). Protocol: The rules under which computers exchange information, including the organization of the units of data to be transferred. Random Access Memory (RAM): The programmable area of the computer's memory that can be read from and written to (changed). All RAM locations are equally accessible at any time in any order. The components of RAM are erased when the computer is turned off. Random Number: A nine-digit decimal number from 0.000000001 to 0.999999999 generated by the RaNDom (RND) function. Read Only Memory (ROM): The permanent portion of the computer's memory. The contents of ROM locations can be read, but not changed. The ROM in the Commodore 128 contains the BASIC language interpreter, character-image patterns and portions of the operating system. Register: Any memory location in RAM. Each register stores one byte. A register can store any value between 0 and 255 in binary form. Release: The rate at which the volume of a musical note decreases from the sustain level to zero. Remark: Comment used to document a program. Remarks are not executed by the computer, but are displayed in the program listing. Resolution: The density of pixels on the screen that determines the fine- ness of detail of a displayed image. RGBI Monitor: Red/Green/Blue/Intensity. A high-resolution display device necessary to produce an 80-column screen format. Ribbon Cable: A group of attached parallel wires. Also called flat cable. Ring Network: A system in which all stations are linked to form a conti- nuous loop or circle. RS-232: A recommended standard for electronic and mechanical specifications or serial transmission ports. The Commodore 128 parallel user port can be treated as a serial port if accessed through software, sometimes with the addition of an interface device. Screen: Video display unit which can be either a television or video monitor. Screen code: The number assigned to represent a character in screen memory. When you type a key on the keyboard, the screen code for that charac- ter is entered into screen memory automatically. You can also display a character by storing its screen code directly into screen memory with the POKE command. Screen Memory: The area of the Commodore 128's memory that contains the information displayed on the video screen. Serial Port: A port used for serial transmission of data; bits are trans- mitted one bit after the other over a single wire. Serial Transmission: The sending of sequentially ordered data bits. Software: Computer programs (sets of instructions) stored on disk, tape or cartridge that can be loaded into random access memory (RAM). Soft- ware, in essence, tells the computer what to do. Sound Interface Device (SID): The MOS 6581 sound synthesizer chip respon- sible for all the audio features of the Commodore 128. Source Code: A non-executable program written in a high-level language. A compiler or assembler must translate the source code into an object code (machine language) that the computer can understand. Sprite: A programmable, movable, high-resolution graphic image. Also called a Movable Object Block (MOB). Standard Character Mode: The mode the Commodore 128 operates in when you turn it on and when you write programs. Start Bit: A bit or group of bits that identifies the beginning of a data word. Statement: A BASIC instruction contained in a program line. Stop Bit: A bit or group of bits that identifies the end of a data word and defines the space between data words. String: An alphanumeric character or series of characters surrounded by quotation marks. Subroutine: An independent program segment separate from the main program that performs a specific task. Subroutines are called from the main program with the GOSUB statement and must end with a RETURN statement. Subscript: A variable or constant that refers to a specific element in an array by its position within the array. Sustain: The midranged volume of a musical note. Synchronous Transmission: Data communications using a synchronizing, or clocking, signal between sending and receiving devices. Syntax: The grammatical rules of a programming language. Tone: An audible sound of specific pitch and waveform. Transparent: Describes a computer operation that does not require user intervention, i.e. the user is unaware that it is taking place. Variable: A unit of storage respresenting a character string or numeric value. Variable names can be any length, but only the first two characters are stored by the Commodore 128. The first character must be a letter. Video Interface Controller (VIC): The MOS 6566 chip responsible for the 40-column graphic features of the Commodore 128. Voice: A sound-producing component inside the SID chip. There are three voices within the SID chip, so the Commodore 128 can produce three different sounds simultaneously. Each voice consists of a tone oscil- lator/waveform generator, an envelope generator and an amplitude modulator. Waveform: A graphic representation of the shape of a sound wave. The wave- form determines some of the physical characteristics of the sound. Word: Number of bits treated as a single unit by the CPU. In an eight-bit machine, the word length is eight bits; in a 16-bit machine, the word length is 16 bits. INDEX A Abbreviations - BASIC, 3.3.2, K ABS function, 4.6.7, 18.1 Addition, 3.6.1 ADM, 15.2 ADSR, 7.1, 7.3.2.1 Alt key, 5.9.3.5 Alt mode, 15.2 Animation, 6.3, 6.3.11 APPEND, 17.1 Arrays, 4.3.6, 19.1 ASC function, 4.6.4, 18.2 ASCII character codes, 4.6.4, E ASM, 12.3.7 Asterisk key {*}, 3.6.2 Attack, 7.3.2.1 ATN function, 18.3 AUTO, 5.6.1.1, 17.2 AUXIN, 14.5 AUXOUT, 14.5 B Bach, 7.4 BACKUP, 17.3 Bandpass, 7.3.2.4 BANK, 17.4 Bank table, 17.4 BAS, 12.3.7 BASIC abbreviations, 3.3.2 commands, 17 functions, 4.6, 18 mathematics, 3.6 operators, 3.6.1 statements, 17 variables, 19.1 BASIC 2.0, 2.1.2, 16.1 BASIC 7.0, 2.1.1, 16.1 BEGIN/BEND, 17.5 Binary files, 6.3.12 Bit Map mode, 6.2.2 BLOAD, 6.3.10, 6.3.12.2, 17.6 BOOT, 17.7 Booting, 11.4.3 BOX, 6.1.2, 6.2.4.2, 17.8 BSAVE, 6.3.10, 6.3.12, 6.3.12.1, 17.9 BUMP, 18.4 C C128 Mode, 2.1.1 C64 Mode, 2.1.2 Caps Lock key, 5.9.3.3 Cartridge Port, C.2 Cassette Port, C.2 CATALOG, 17.10 CHAR, 6.1.2, 6.2.4.5, 17.11 Character sets, 3.2.1 Character string code, 4.6.4 CHR$ codes, 9.6, E, I CHR$ function, 4.6.4, 18.5 CIRCLE, 6.1.2, 6.2.4.1, 17.12 Clock, 19.1 CLOSE, 10.1, 17.13 CLR, 3.7.3, 6.2.3, 17.14 CLR/HOME key, 3.2.2.9 CMD, 17.15, 17.28 COLLECT, 17.16 COLLISION, 17.17 Colon {:}, 4.1.1 COLOR, 6.1.2, 6.2.1, 17.18 Color code display chart, 3.3.4, 6.2.1, 17.18 control, 3.2.2.6, 3.4.6, 15.2 CHR$ codes, E keys, 3.3.4 memory map, F.2 screen and border, 6.2.2 source code, 6.2.1 COM, 11.5.1, 12.3.7 Comma {,}, 3.3.1 Command, 3.1.1 Command keys, 3.2.2 Command keyword, 11.5 Command line, 11.5 Command tail, 11.5 Commodore key, 3.2.2.6, 3.2.2.10 Composite monitor, 2.1.1, 8.5 CONCAT, 17.19 CONIN, 14.5 Connections, C CONOUT, 14.5 Constants, 3.7.1 CONTinue command, 4.7, 17.20 Control characters table, 7.3.2.3 Control key, 3.2.2.6, 11.2 Coordinate grid, 6.2.4.1 COPY, 17.21 Copying music, 7.4 Copying programs, 11.6.2 COSine function, 18.6 CP/M characters, 12.3.6 CP/M mode, 11 CP/M Plus User's Guide, 15.2 CP/M Plus 3.0, 2.1.3, 11 CTRL-, 11.5, 13.4 CuRSoR keys, 3.2.2.4.2, 9.5 Cursor, 3.2.2.4 Cutoff frequency, 7.3.2.4 D Datassette, 3.9 DATA, 4.3.4, 17.22 Data file, 12.1 DATE, 14.3 DCLEAR, 17.23 DCLOSE, 17.24 Debug, 4.7, 5.6.2.3 DEC, 18.7 Decay, 7.1, 7.3.2.1 DEF FN, 17.25 Delay loops, 4.2.1 DELETE, 5.6.1.3, 17.26 DELete key, 3.2.2.5 DEVICE, 14.3 Dice, 4.6.3 DIMension statement, 4.3.6.2, 17.27 DIR command, 11.5, 14.3 Direct mode, 3.1.1 DIRECTORY, 3.6.9.2, 17.28 DIRSYS, 14.3 Disk commands, 3.9, 10.4, L Disk directory, 3.6.9.2, 10.4 Disk Parameters, 3.9, 11.4.2 Division, 3.6.2 DLOAD", 3.1.2, 3.9.4, 17.29 Dollar sign {$}, 3.7.3, 7.3.2.3, 10.4.2 DO/LOOP, 17.30 DOPEN, 17.31 DRAW, 6.1.2, 6.2.4.3, 17.32 Drive Specifier, 12.3.1.1 DS/DS$ variables, 19.1 DSAVE", 3.1.2, 3.9.2, 17.33 Dual screens, 8.5 DUMP, 14.3 Duration, 7.2, 7.3.2.3 DVERIFY", 3.9.6.1, 17.34 E Echo, 13.2 ED, 12.2, 14.3 Editing, 3.5, 13.3 EL variable, 19.1 ELSE clause, 5.2.2, 17.50 END statement, 4.1, 17.35 Envelope generator, 7.3.2.1 ENVELOPE, 7.3.2.1, 17.36 Equals {=}, 3.7.2, 4.1 ERASE, 14.2 14.3 ER/ERR$ variables, 5.6.2.3, 18.8, 19.1 Error functions, 5.6.2.3 Error messages, A, B Escape codes, I.1 ESCape key, 6.2.3, 15.2 EXIT, 5.2.1.3, 17.30 Exponentiation, 3.6.3 EXPonent function, 18.9 F 40/80 Display key, 5.9.3.4, 8.2 FAST command, 5.8, 17.37 FETCH, 17.38 File, 12.2 Filename, 12.3.1.3 File specifications, 12.3.1 File type, 12.3.1.3 FILE NOT FOUND, 3.9.4 FILTER, 7.3.2.5, 17.39 Filter - SID, 7.3.2.4 Flat {$}, 7.3.2.3 FN function, 18.10 FOR...NEXT statement, 4.2, 17.40 FORMAT, 14.3 Formatting disks, 3.9.1, 10.1 FRE function, 18.11 Frequency, 7.2, 7.3.1 Function, 3.1 Function keys, 3.2.3, 5.9.1, 9.6 G Game control and ports, C.1 GENCOM, 14.3 GET, 4.3.2, 14.3, 14.4, 17.41 GETKEY, 5.5, 17.42 GET# statement, 17.43 GO64, 17.44 GOSUB, 4.4.2, 17.45 GOTO, 3.4.4, 17.46 GRAPHIC, 6.1.2, 6.2.3, 17.47 Graphic characters, 3.2.4 Graphic modes, 5.8.1, 6.2.3 GSHAPE, 17.91 H Harmonics, 7.3.1 Hash mark {#}, 5.3.1, 6.3.6, 17.24, 17.68 HEADER, 3.9.1, 17.48 HELP key, 5.6.2.1, 5.9.3.1 HEX, 12.3.7 HEX$, 18.12 HLP, 12.3.7 HOME key, 3.2.2.9 Hyperbolic functions, G I IF...THEN statement, 4.1, 17.50 INITDIR, 14.3 Initializing, 10.4.3 INPUT, 4.3.1, 17.51 INPUT#, 17.52 Input Prompt, 4.3.1.2 INSerT key, 3.2.2.5 INSTR, 18.13 INTeger function, 4.6.2, 18.14 J JOY, 18.15 Joystick ports, C.1 K KEY command, 5.9.2, 17.53 KEYFIG, 14.3 Keyboard, 3.2.0.1 Key assignment - CP/M, 15.1.1 L LEFT$ function, 18.16 LENgth function, 18.17 LET statement, 17.54 Line Feed key, 5.9.3.7 Line numbers, 3.4.2 LOAD command, 3.9.4, 10.3.1, 17.56 LOADing cassette software, 10.3.2 LOADing CP/M software, 11.4.1 LOADing disk software, 10.3.1 LOCATE, 17.57 LOGarithm function, 18.18 Loops, 4.2 LST, 14.5 M Machine language, J Mathematics, 3.6, G Memory maps, F, H MID$ function, 18.19 Mode switching chart, 2.2.1 MONITOR, 17.58 Monitor - dual, 8.5 Monitor - machine language, 5.9.1, J Monitor switching, 6.2.3, 8.5 MOVSPR, 6.3.7, 17.59 Multicolor bit mode, 6.2.2 Multiplication, 3.6.2 Music programs, 7.3.3, 7.4 Music videos, 7.3.4 Musical notes, 7.3.2.3 Musical instruments, 7.3.2.1 Musical staff, 7.4 N Nested loops, 4.2.1 NEW, 3.4.6, 17.60 NEXT statement, 4.2, 17.40 Noise, 7.3.1 No Scroll key, 5.9.3.2, 13.1 Notch Reject Filter, 7.3.4 Notes, 7.3.2.3 Numeric functions, 4.6.1 O Object code file, 6.3.12 ON GOTO/GOSUB, 4.4.2 OPEN statement, 10.1, 17.62 Operating System, 11.1 Operators, arithmetic, 3.6, 19.2 logical, 19.2 order of, 3.6.4 relational, 4.1, 19.2 P PAINT, 6.1.2, 6.2.4.4, 17.63 Parentheses, 3.6.4, 12.3.6 Password, 12.3.1.4 PATCH, 14.3 PEEK function, 4.5.1.1, 18.20 PEN, 18.21 Period {.}, 7.3.2.3 PI, 18.22 PIP, 11.6, 14.3 Pixel, 6.2.2, 6.3.4 PLAY, 7.3.2.3, 17.64 POINTER, 18.23 POKE, 4.5.1.2, 17.65 POS function, 18.24 POT, 18.25 PRINT, 3.3.1, 17.66 PRINT#, 10.1, 17.67 PRINT USING, 5.3.1, 17.68 Printer control - CP/M, 13.2 PRN, 12.3.7 Program file, 11.2 Program mode, 3.1.2 Programmable keys, 5.9.1, 9.6 Programming aids, 5.6 PUDEF, 5.3.2, 17.69 Pulse width, 7.2.1, 7.3.2.1 PUT, 14.3 Q Question mark {?}, 3.3.2, 12.3.5 Quotation marks {"}, 3.3.3 Quote mode, 3.3.5 R RAM, 4.5.1, 11.3 Random sounds, 7.2.2 RCLR, 18.26 RDOT, 18.27 READ, 4.3.4, 17.70 RECORD, 17.71 Relational operators, 4.1 REL, 12.3.7 Release, 7.1, 7.3.2.1 REMark statement, 3.2.5, 17.72 RENAME, 14.2, 14.3, 17.73 RENUMBER, 5.6.1.2, 17.74 Reset button, 8.2 Reserved variables, 19.1 Rest, 7.3.2.3 Restore key, 3.2.2.8 RESTORE statement, 4.3.5, 17.75 RESUME command, 5.6.2.2, 17.76 Return key, 3.2.2.1 RETURN statement, 4.4.1, 17.77 RGR, 18.28 RIGHT$ function, 18.29 RREG, 17.78 RSPCOLOR, 18.31 RSPPOS, 18.32 RSPRITE, 18.33 RUN command, 3.4.2, 17.79 RUN/STOP key, 3.2.2.7, 6.2.3, 7.2.1, 7.3.2.3, 8.2 RWINDOW, 18.34 S SAVE command, 3.9.2, 10.2.1, 14.3, 17.80 Saving programs on tape, 3.9.3, 10.2.2 Saving progams on disk, 3.9.2, 10.2.1 Sawtooth waveform, 7.3.1 SCALE, 6.1.2, 6.2.4.7, 17.81 SCNCLR command, 17.82 SCRATCH command, 17.83 Screen display codes, D Screen display, 6.2.2, 8.1 Screen memory map, F Scrolling, 5.7.2 Sector, 3.9.1 Semicolon {;}, 3.3.1 Serial port, C.2 SET, 14.3 SETDEF, 13.1 SGN function, 18.35 Sharp {#}, 7.3.2.3 Sheet music, 7.4 Shift key, 3.2.2.2 SHOW, 14.3 SID chip, 7.1 SINe function, 18.36 Slash key {/}, 3.6.2 SLEEP, 5.2.4, 17.84 SLOW command, 5.8.1, 17.85 Software - 80 column, 8.3 SOUND, 7.2, 17.86 Sound Interface Device, 7.1 Sound Player Program, 7.2.1 Sound reset, 7.2.1, 7.3.2.3 SPC function, 18.37 Split screen display, 6.2.2 SPRCOLOR, 17.87 SPRDEF, 6.1.2, 6.3.9, 17.88 SPRITE, 6.1.2, 6.3.6, 17.89 Sprite Combinations, 6.3.11 Sprite Control, 6.3.6 Sprite Editor, 6.3.9 Sprite Programming, 6.3, 6.3.8 Sprite memory map, 6.3.12 Sprite movement, 6.3.7 Sprite viewing area, 6.3.7 Sprites, 6.3 SPRSAV, 6.1.2, 6.3.5, 17.90 SQR function, 4.6.2, 4.6.6, 18.38 SSHAPE, 6.1.2, 6.3.4, 17.91 ST variable, 19.1 STASH, 17.92 Statement, 3.1, 3.4.1 STEP, 4.2.2, 17.40 STOP, 4.7, 17.93 STOP key, 3.2.2.7 Storing programs, 3.9, 10.2 String functions, 4.6.4 Strings, 3.3.3, 3.7.3 STR$ function, 4.6.5.2, 18.39 SUB, 12.3.5.1 SUBMIT, Table 14-2 Subroutine, 4.4 Subscripts, 4.3.6.1 Subtraction, 3.6.1 Sustain, 7.1, 7.3.2.1 SWAP, 17.94 Sweep, 7.2 Syntax, 3.1 Syntax error, 3.2.2.1 Synthesizer, 7.1, 7.3.2.3 SYM, 12.3.5.1 SYS, 12.3.5.1, 17.95 System prompt, 11.5 T Tab key, 5.9.3.6 TAB function, 18.40 TAB stops, 5.7.2 TANgent function, 18.41 TEMPO, 7.3.2.2, 17.96 Terminating CP/M, 14.8 THEN, 4.1, 17.50 Timbre, 7.3.1 Time delay, 4.2.1 TI/TI$ variables, 19.1 TO, 4.2, 17.40 Track, 3.9.1 Transient Utility Commands, 11.5.1, 14.1, 14.3 TRAP, 5.6.2.2, 17.97 Triangle waveform, 7.3.1.3 Trigonometric functions, G TRON/TROFF, 5.6.2.3, 17.98, 17.99 TYPE, Table 14-1, Table 14-2 Typing rules, 3.2.5 U UNTIL statement, 5.2.1.1, 17.30 Up arrow key {^}, 3.6.3 Upper case/graphics set, 3.2.1, 9.2 Upper/Lower case set, 3.2.1, 9.2 USER, 12.3.4, 14.2 User Number, 12.3.4 User port, C.2 USR function, 18.42 V VALue function, 4.6.5.1, 18.43 Variables, 3.7.2, 4.3.6.1, 19.1 VERIFY command, 3.9.6.1, 10.4.1, 17.100 VIC chip, 6.1 Video ports, C.2 Voice, 7.1 VOLume, 7.2.1, 7.3.2.1, 17.101 W WAIT command, 17.102 Waveform, 7.1, 7.3.1, 7.3.2.1 WHILE statement, 5.2.1.2, 17.30 WIDTH, 17.103 Wildcard, 12.3.5 WINDOW command, 5.7.1, 17.104 Windowing, 5.7 X XOR, 18.44 Z Z80 Microprocessor, 11.2 Commodore Commodore Buromaschinen Commodore Buromaschinen Business Machines (UK) GmbH GmbH Ltd. Lyoner Str. 38 Kinskygasse 40-44 1, Hunters Road 6000 Frankfurt/Main 71 1232 Vienna Weldon, Corby West Germany Austria Northamptonshire, NN 17 1QX Great Britain Commodore AG Commodore France S.R.L. Commodore Italiana S.R.L. Aeschenvorstadt 57 8 Rue Copernic Via Fratelli Gracchi 48 4010 Basel 75116 Paris 20092 Cinisello Balsamo Switzerland France Italy Commodore Computers Commodore Data AS COE Computer Products AB Norge A/S Bjerrevej 67 Fagerstagatan 9 Brobekkveien 38 8700 Horsens 163 53 Spanga 0509 Oslo 5 Denmark Sweden Norway Commodore Computer Commodore Computer BV Commodore Business NV-SA Kabelweg 88 Machines (Pty.) Ltd. Leuvensesteenweg 43 1014 Amsterdam BC 5, Mars Road 1940 St. Stevens- Netherlands Lane Cove Woluse N.S.W. 2066 Belgium Australia