![]() |
SECTION 17
17. Basic Commands and Statements17.1
|
color source: |
0 = | Background color |
|
---|---|---|---|
1 = | Foreground color |
||
2 = | Multicolor 1 | } Only in Graphics |
|
3 = | Multicolor 2 | } 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 appropriate graphic mode to be used with the BOX color source number.
Also see the LOCATE command, in paragraph 17.28, for information on the pixel cursor.
BOX 1, 10, 10, 60, 60Draws the outline of a rectangle.
BOX 1, 10, 10, 60, 45, 1Draws a painted, rotated box (a diamond).
DRAW , 30, 90, , 45, 1Draws a filled, rotated polygon (see note).
BOX 1, 20, 20, , ,1Draws 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).
Save a binary file from the specified memory locations.
BSAVE "filename" [,Ddrive number] [<ON | ,>Udevice number] [,Bbank number], Pstart address TO Pend address+1where:
This is the same as the SAVE command in the machine language monitor.
BSAVE "SPRITE DATA",B0,P3584 TO P4096Saves the binary file named "SPRITE DATA" starting at location 3584 through 4095 (BANK 0).
BSAVE "PROGRAM.SCR",D0,U9,B0,P3182 TO P8000Saves the binary file named "PROGRAM.SCR" in the memory address range 3182 through 7999 (BANK 0) on drive 0, unit 9.
Displays the disk directory.
CATALOG [Ddrive number] [<ON | , >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).
CATALOGDisplays the disk directory on drive 0 of unit 8.
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 | } Only in Graphics |
|
3 = | Multicolor 2 | } modes 3 and 4 | |
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 location by the CHAR statement. Character data is read from Commodore 128 character ROM area. The user supplies the x and y coordinates of the starting 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.
Note for Lynx Users: Follow [this link] to view a better representation of the next table.
Reverse Flag | |||
---|---|---|---|
0(OFF) | 1(ON) | ||
Color source 0 | Text | 1 | 1 |
Background | 2 | 3 | |
Color source 1 | Text | 1 | 0 |
Background | 0 | 1 | |
Color source 2 | Text | 2 | 0 |
Background | 0 | 2 | |
Color source 3 | Text | 3 | 0 |
Background | 0 | 3 |
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
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 | } Only in Graphics |
|
3 = | Multicolor 2 | } 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). |
With the CIRCLE statement, the user can draw a circle, ellipse, arc, triangle, 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.28, for information on the pixel cursor.
CIRCLE 1,160,100,65,10Draws an ellipse
CIRCLE 1,160,100,65Draws a circle
CIRCLE 1,60,40,20,18,,,,45Draws an octagon
CIRCLE 1,260,40,20,30,,,,90Draws a diamond
CIRCLE 1,60,140,20,18,,,,120Draws a triangle
You may omit a parameter, but you must still place a comma in the appropriate position. Omitting parameters take on the default values.
Close logical file.
CLOSE file number
This statement closes any files used by DOPEN or OPEN statements. The number following the word CLOSE is the file number to be closed.
CLOSE 2Logical file 2 is closed.
Clear program variables.
CLR
This statement erases any variables in memory, but leaves the program intact. This statement is automatically executed when a RUN or NEW command is given.
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.
OPEN 1,4OPENs device #4, which is the printer.
CMD 1All normal output now goes to the printer.
LISTThe LISTing goes to the printer, not the screen - even the word READY.
PRINT#1Sends output back to the screen.
CLOSE 1Close the file.
Free inaccessible disk space.
COLLECT [Ddrive number] [<ON | ,>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.
COLLECT D0Free 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.
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 current executing instruction and perform a GOSUB to the line number given. When the subroutine terminates (it must end with a RETURN), BASIC will resume 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 interrupt can be handled at a time (i.e. there can be no recursion and no nesting 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.
COLLISION 1, 5000Detects a sprite-to-sprite collision and program control sent to subroutine at line 5000.
COLLISION 1Stops interrupt action which was initiated in above example.
COLLISION 2,1000Detect 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.
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
COLOR 0,1Change background color of 40-column screen to black.
COLOR 5,8Change character color to yellow.
Concatenates two data files.
CONCAT "file 2" [,Ddrive number] TO "file 1" [,Ddrive number] [<ON | ,>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.
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, U9The 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 filename variable must be surrounded by parentheses.
NOTE: Keep the filenames short (10 characters) because the command buffer is limited in some disk drives.
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.
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]> [<ON | ,>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.
COPY "TEST",D0 TO "TEST PROG",D1Copies "TEST" from drive 0 to drive 1, renaming it "TEST PROG" on drive 1.
COPY "STUFF",D0 TO "STUFF",D1Copies "STUFF" from drive 0 to drive 1.
COPY D0 TO D1Copies 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).
page URL: www.bigfoot.com/~c128page/c128sg/sect-17a.htm
contact: c128page@bigfoot.com