Classic Computer Magazine Archive COMPUTE! ISSUE 65 / OCTOBER 1985 / PAGE 90

64
Multicolor Graphics
Made Easy

James P. Hassett




"Color Plotter 64" gives your Commodore 64 a set of 14 powerful new commands for plotting multicolor high-resolution graphics. You can even mix text and graphics on the same screen. The photos on these pages were generated by the demo program following this article.


Have you ever admired a multicolor high-resolution graphics display on the Commodore 64? Usually you have to learn machine language to create such displays yourself-but not now.
    With "Color Plotter 64" those screens become easy because you'll have 14 special graphics commands added to your Commodore 64 BASIC. And because the commands are written in machine language, they work fast and efficiently. Here is a summary of the new commands:

IN, Turns on hi-res multicolor mode.
OFF, Turns off hi-res multicolor mode.
CL, Clears hi-res screen.
PC, Pen Clear. Clears everything on high-res screen drawn with current pen number.
P0,n Sets color of PEN 0, which is also the background color, where n is one of the 16 standard colors (0-15).
P1,n Sets color of PEN 1 (n = 0-15).
P2,n Sets color of PEN 2 (n = 0-15).
P3,n Sets color of PEN 3 (n = 0-15).
PEN,n Defines active pen number (n = 0-3).
PL,x,y Plots point on hi-res screen at coordinates x,y using active pen.
DR,x,y Draws best straight line from last point plotted to coordinates x,y using active pen.
CR,x,y Sets hi-res screen cursor to coordinates x,y.
PR,A$ Prints contents of A$ on high-res screen using active pen.
PR,"text" Prints text between quotes on hi-res screen using active pen.

    Some of these commands may look familiar to those who have plotted graphics on other computers with other languages. You might be able to jump right in and start plotting. Do note that all commands, even those without parameters (such as the IN, command), must be accompanied by the comma. There are also some special typing and loading instructions to follow with Color Plotter 64. For more details, see the sections below.

Entering The Program
Since Color Plotter is written entirely in machine language, it must be entered with the "MLX" machine language editor program, found elsewhere in this issue. To enter the Color Plotter program, load and run MLX. When MLX asks for the starting and ending addresses for the machine language data to be entered, respond with 49152 and 51353, respectively. MLX will then prompt you with the line number of the first line of data, 49152. Begin typing the data shown in Program 1 and continue until all the data is entered. If you do not type in all the data in one sitting, follow the directions in the MLX article for saving your incomplete work. When all the data is entered, you're ready to start using the Color Plotter commands.

Special Loading Instructions
You must issue a certain sequence of commands to load and activate Color Plotter 64. After turning on the power, enter these lines for disk, pressing RETURN each time:

LOAD "COLOR PLOTTER",8,1
POKE 44,64:POKE 16384,0:NEW
SYS 51260

For tape, change the first line above to:

LOAD "COLOR PLOTTER",1,1

    Of course, you can save Color Plotter 64 on disk or tape with any filename you like. To load a program that contains Color Plotter commands, use the normal LOAD command.

Color Plotter Pen
As described above, the first three Color Plotter 64 commands (IN, OFF, and CL,) turn the hi-res multicolor mode on or off and clear the screen. (For those interested, the hires screen is located at memory addresses 8192 to 16191-hex $2000-$3F3F.)
    PC, (Pen Clear) makes it possible to erase certain things off the screen while leaving all else intact. This is particularly useful for removing text, prompts, or messages while preserving the drawing in the background. To erase everything drawn with PEN 1, for example, execute:

PEN,1:PC,

    The next five commands are very similar to each other; they all select drawing colors for the various pens. The parameter n should be a number, variable, or numeric expression in the range of 0 to 15 corresponding to standard Commodore 64 color numbers. (If you specify a number larger than 15, Color Plotter 64 does not report an error, however.) All the following statements are legal:

P0,0:REM Sets PEN 0 and background color to black.
P1,J:REM Sets color of PEN 1 to previously defined value of variable J.
P2,J/2+1:REM Sets color of PEN 2 to value of expression J/2+1.

    The command PEN,n defines the active pen number-in other words, which pen will be used with the drawing, printing, and penclearing commands that follow. Since there are only four pens, the parameter n should be a number, variable, or expression in the range of 0 to 3. PEN 0 is the background color, which makes it handy for erasing lines drawn with another color (simply draw over the lines with PEN 0).
    As a technical aside, the pens draw in different colors by switching on different bit pairs on the hi-res screen. PEN 0 plots a 00 bit pair. PEN 1 plots the 01 pair, PEN 2 plots the 10 pair, and PEN 3 plots the 11 pair. PC, (Pen Clear) works by searching the screen and removing all occurrences of the bit pair that matches that of the active pen.

Drawing And Printing
The next five commands all perform the actual drawing, plotting, and printing in the colors specified by the pen commands. They use a coordinate system so you can place the pens anywhere on the screen.
    PL,x,y is the plot command. Screen coordinates in the multi color hi-res mode range from 0 to 159 horizontally (x) and 0 to 199 vertically (y). Important: The origin is the lower-left corner of the screen. That means the coordinates of the lower-left corner of the screen display are 0,0, the upper-left coordinates are 0,199, the upper-right coordinates are 159,199, and the lower-right coordinates are 159,0.
    Again, the parameters x and y can be numbers, variables, or numeric expressions. Trying to plot a location out of range causes an ILLEGAL QUANTITY ERROR.
    DR,x,y is the draw command. It works with the same coordinates as the plot command. Since the x,y parameters are the coordinates it draws to, at least one plot command should be executed to define the starting point before the first draw command.
    CR,x,y positions the invisible hi-res cursor at the coordinates specified. This defines where a following print command will begin printing the text. Since a character is 8 bits high and 16 bits wide, the allowable range for coordinates with this command is 1 to 144 for x and 1 to 192 for y. Specifying a location out of range causes an ILLEGAL QUANTITY ERROR.
    PR,A$ and PR,"" are the hi-res printing commands. To print a message, simply put the text between the quotes with PR,"" or define it as a string variable with PR,A$. String expressions such as PR,A$+B$ or PR,A$+"ABC" are not allowed.

Nondestructive Printing
The printing commands are specially written so they never write over a bit that is already on. This means they print nondestructively; they won't interfere with your graphics. This is handy in many instances. For example, if you create a drawing or a graph, you can label it without erasing any lines. Then you can erase the text with the PC, command without disturbing the graphics, assuming the text is printed in a different color.
    The printing commands also update the invisible hi-res cursor automatically. They provide for line advances and wraparound from the bottom to the top of the screen.
    There is one limitation with the printing commands. They can print only those characters with ASCII codes 33 to 95 (this includes most punctuation symbols, numbers, and letters, but no keyboard graphics). Trying to print characters out of this range will cause an error.
    You can do lots of exciting things with these 14 commands. By executing P1,1 everything drawn on the screen with PEN 1 will change to white in a flash. With a simple loop (FOR X=0 TO 15:P1, X:NEXT X) everything drawn with PEN 1 will flash through all 16 colors in an instant. Drawings or objects can be made to disappear by executing a command to match the pen color to the background color. Then they can be made to instantly reappear by executing another pen color command using a contrasting color.

Additional Notes
You should be aware that Color Plotter 64 affects a few normal BASIC commands. None of the new commands works with IF-THEN. For example, the following statement will cause a syntax error:

10 X=5:IF X=5 THEN CL,

    Otherwise, IF-THEN works normally.

    BASIC's pi function (π) also is affected. It still operates and is evaluated as 3.1415 ... but appears as a graphic symbol when listed. If a line containing a pi symbol is edited, the pi symbol will have to be retyped at the edited line. I have found it convenient to define the variable PI=3.14159 and use PI instead of the pi symbol.
    The IN, command should never be executed when already in the hi-res mode. Otherwise, a system crash and lockup may result. This is because the IN, command saves the normal error vector (ERRVEC) and replaces it with a new vector. If it is executed again before an OFF, command, the ERRVEC will point to the address of the replacement vector-in effect, it will point to itself.
    Anytime there's a syntax error, the normal text screen with the default colors is restored. When a program is running in the hi-res mode, you can stop it as usual by pressing the RUN/STOP key. To return to the normal text screen, deliberately cause a syntax error by typing a key in direct mode and pressing RETURN.
    If you press RUN/STOP-RESTORE, the Color Plotter 64 commands will no longer work. That's because BASIC ROM is switched back in. (Color Plotter 64 works by copying BASIC ROM into RAM and then modifying it to patch in the new routines.) In fact, the program won't even LIST properly. The first thing to do after pressing RUN/STOP-RESTORE is to enter SYS 51343 or POKE1,PEEK(1) AND254. Either statement will switch out BASIC ROM and resurrect Color Plotter 64.


Program 1: Color Plotter 64
Please refer to the "MLX" article before entering this listing.

49152 :076,039,192,076,092,192,155
49158 :076,134,192,076,165,192,073
49164 :076,182,192,076,254,192,216
49170 :076,068,193,076,162,198,023
49176 :076,045,194,076,059,194,156
49182 :076,150,196,076,211,196,167
49188 :076,102,197,032,253,174,102
49194 :173,017,208,009,032,141,110
49200 :017,208,173,022,208,009,173
49206 :016,141,022,208,173,024,126
49212 :208,009,008,141,024,208,146
49218 :173,000,003,141,238,207,060
49224 :173,001,003,141,239,207,068
49230 :169,168,141,000,003,169,216
49236 :196,141,001,003,076,006,251
49242 :197,096,032,253,174,173,247
49248 :017,208,041,223,141,017,231
49254 :208,173,022,208,041,239,225
49260 :141,022,208,173,024,208,116
49266 :041,240,009,004,141,024,061
49272 :208,173,238,207,141,000,063
49278 :003,173,239,207,141,001,122
49284 :003,096,032,253,174,169,091
49290 :063,133,252,169,000,133,120
49296 :251,168,133,251,145,251,063
49302 :160,063,162,032,145,251,195
49308 :136,208,251,198,252,202,123
49314 :208,246,096,032,253,174,147
49320 :032,158,173,032,170,177,142
49326 :152,141,033,208,141,032,113
49332 :208,096,032,253,174,032,207
49338 :158,173,032,170,177,152,024
49344 :010,010,010,010,141,251,112
49350 :207,162,000,189,000,004,248
49356 :041,015,013,251,207,157,120
49362 :000,004,189,000,005,041,193
49368 :015,013,251,207,157,000,091
49374 :005,189,000,006,041,015,222
49380 :013,251,207,157,000,006,094
49386 :232,208,220,162,024,189,245
49392 :232,006,041,015,013,251,030
49398 :207,157,232,006,232,208,008
49404 :242,096,032,253,174,032,057
49410 :158,173,032,170,177,152,096
49416 :041,015,141,251,207,162,057
49422 :000,189,000,004,041,240,232
49428 :013,251,207,157,000,004,140
49434 :189,000,005,041,240,013,002
49440 :251,207,157,000,005,189,073
49446 :000,006,041,240,013,251,077
49452 :207,157,000,006,232,208,086
49458 :220,162,024,189,232,006,115
49464 :041,240,013,251,207,157,197
49470 :232,006,232,208,242,096,054
49476 :032,253,174,032,158,173,122
49482 :032,170,177,152,041,015,149
49488 :162,000,157,000,216,157,004
49494 :000,217,157,000,218,232,142
49500 :208,244,162,024,157,232,095
49506 :218,232,208,250,096,032,110
49512 :253,174,032,158,173,032,158
49518 :170,177,170,240,003,076,178
49524 :166,196,140,253,207,140,194
49530 :247,207,192,160,144,004,052
49536 :234,076,166,196,032,253,061
49542 :174,032,158,173,032,170,105
49548 :177,170,240,003,076,166,204
49554 :196,140,254,207,140,248,051
49560 :207,192,200,144,004,234,109
49566 :076,166,196,169,000,133,130
49572 :254,056,169,199,237,254,053
49578 :207,072,041,248,010,038,018
49584 :254,010,038,254,010,038,012
49590 :254,170,141,251,207,165,090
49596 :254,141,252,207,138,010,166
49602 :038,254,010,038,254,109,129
49608 :251,207,133,253,165,254,183
49614 :109,252,207,133,254,173,054
49620 :253,207,041,252,010,144,095
49626 :002,230,254,024,101,253,058
49632 :133,253,169,000,101,254,110
49638 :133,254,104,041,007,101,102
49644 :253,133,253,169,032,101,153
49650 :254,133,254,173,253,207,236
49656 :041,003,141,249,207,169,034
49662 :003,056,237,249,207,141,123
49668 :249,207,170,173,250,207,236
49674 :141,251,207,169,003,141,154
49680 :252,207,138,240,015,014,114
49686 :251,207,014,251,207,014,198
49692 :252,207,014,252,207,202,138
49698 :208,241,173,252,207,073,164
49704 :255,141,252,207,096,032,255
49710 :103,193,032,077,196,160,039
49716 :000,173,255,207,145,253,061
49722 :096,032,253,174,032,158,035
49728 :173,032,170,177,072,104,024
49734 :240,003,076,166,196,140,123
49740 :247,207,192,160,144,003,005
49746 :076,166,196,032,253,174,211
49752 :032,158,173,032,170,177,062
49758 :072,104,240,003,076,166,243
49764 :196,140,248,207,192,200,003
49770 :144,003,076,166,196,173,096
49776 :247,207,205,253,207,144,095
49782 :009,237,253,207,141,246,187
49788 :207,024,144,010,173,253,167
49794 :207,056,237,247,207,141,201
49800 :246,207,173,248,207,205,142
49806 :254,207,144,009,237,254,223
49812 :207,141,245,207,024,144,092
49818 :010,173,254,207,056,237,067
49824 :248,207,141,245,207,173,101
49830 :247,207,205,253,207,144,149
49836 :056,173,248,207,205,254,035
49842 :207,144,024,173,246,207,155
49848 :205,245,207,144,008,169,138
49854 :000,141,244,207,076,026,116
49860 :195,169,001,141,244,207,129
49866 :076,026,195,173,246,207,101
49872 :205,245,207,144,008,169,162
49878 :007,141,244,207,076,026,147
49884 :195,169,006,141,244,207,158
49890 :076,026,195,173,248,207,127
49896 :205,254,207,144,024,173,215
49902 :246,207,205,245,207,144,212
49908 :008,169,003,141,244,207,248
49914 :076,026,195,169,002,141,091
49920 :244,207,076,026,195,173,153
49926 :246,207,205,245,207,144,236
^9932 :008,169,004,141,244,207,017
49938 :076,026,195,169,005,141,118
49944 :244,207,173,247,207,141,219
49950 :253,207,173,248,207,141,235
49956 :254,207,173,246,207,141,240
49962 :241,207,141,240,207,205,003
49968 :245,207,144,008,173,245,046
49974 :207,141,240,207,176,006,007
49980 :173,245,207,141,241,207,250
49986 :173,241,207,208,001,096,224
49992 :173,244,207,010,010,168,116
49998 :185,105,195,141,102,196,234
50004 :185,106,195,141,103,196,242
50010 :185,107,195,141,131,196,021
50016 :185,108,195,141,132,196,029
50022 :076,091,196,009,196,167,069
50028 :195,167,195,009,196,167,013
50034 :195,197,195,197,195,167,236
50040 :195,197,195,137,195,137,152
50046 :195,197,195,137,195,009,030
50052 :196,009,196,137,195,165,006
50058 :253,041,007,073,007,240,247
50064 :008,230,253,208,017,230,066
50070 :254,208,013,024,165,253,043
50076 :105,057,133,253,165,254,099
50082 :105,001,133,254,096,165,148
50088 :253,041,007,208,015,056,236
50094 :165,253,233,057,133,253,244
50100 :165,254,233,001,133,254,196
50106 :208,008,165,253,208,002,006
50112 :198,254,198,253,096,238,149
50118 :249,207,173,249,207,201,204
50124 :004,208,016,169,000,141,230
50130 :249,207,056,165,253,233,093
50136 :008,133,253,176,002,198,218
50142 :254,173,249,207,170,173,168
50148 :250,207,141,251,207,169,173
50154 :003,141,252,207,138,240,191
50160 :015,014,251,207,014,251,224
50166 :207,014,252,207,014,252,168
50172 :207,202,208,241,173,252,255
50178 :207,073,255,141,252,207,113
50184 :096,173,249,207,208,018,191
50190 :024,165,253,105,008,133,190
50196 :253,165,254,105,000,133,162
50202 :254,169,004,141,249,207,026
50208 :206,249,207,173,249,207,043
50214 :170,173,250,207,141,251,206
50220 :207,169,003,141,252,207,255
50226 :138,240,015,014,251,207,147
50232 :014,251,207,014,252,207,233
50238 :014,252,207,202,208,241,162
50244 :173,252,207,073,255,141,145
50250 :252,207,096,160,000,177,198
50256 :253,045,252,207,013,251,077
50262 :207,141,255,207,096,173,141
50268 :241,207,141,242,207,074,180
50274 :141,243,207,032,234,234,165
50280 :032,077,196,173,243,207,008
50286 :024,109,240,207,141,243,050
50292 :207,176,005,205,241,207,133
50298 :144,009,237,241,207,141,077
50304 :243,207,032,234,234,032,086
50310 :077,196,160,000,173,255,227
50316 :207,145,253,206,242,207,120
50322 :208,209,234,096,032,253,154
50328 :174,032,158,173,032,170,123
50334 :177,152,041,003,141,250,154
50340 :207,096,162,014,072,138,085
50346 :072,152,072,032,095,192,017
50352 :169,006,141,033,208,169,134
50358 :014,141,032,208,169,147,125
50364 :032,210,255,173,238,207,023
50370 :141,000,003,173,239,207,189
50376 :141,001,003,104,168,104,209
50382 :170,104,108,000,003,032,111
50388 :253,174,032,158,173,032,010
50394 :170,177,170,240,003,076,030
50400 :166,196,192,153,144,003,054
50406 :076,166,196,140,236,207,227
50412 :032,253,174,032,158,173,034
50418 :032,170,177,170,240,003,010
50424 :076,166,196,192,193,144,191
50430 :003,076,166,196,140,237,048
50436 :207,096,120,165,253,072,149
50442 :165,254,072,169,225,141,012
50448 :040,003,169,142,032,210,100
50454 :255,173,014,220,041,254,211
50460 :141,014,220,165,001,041,098
50466 :251,133,001,169,000,133,209
50472 :251,169,209,133,252,169,199
50478 :000,133,253,169,008,133,230
50484 :254,160,000,177,251,145,015
50490 :253,200,208,249,169,208,065
50496 :133,252,230,254,177,251,081
50502 :145,253,200,208,249,165,010
50508 :001,009,004,133,001,173,141
50514 :014,220,009,001,141,014,225
50520 :220,169,237,141,040,003,130
50526 :088,104,133,254,104,133,142
50532 :253,096,032,253,174,032,172
50538 :158,173,032,163,182,032,078
50544 :166,182,208,003,076,138,117
50550 :198,141,242,207,165,034,081
50556 :133,251,141,245,207,165,242
50562 :035,133,252,141,246,207,120
50568 :165,253,072,165,254,072,093
50574 :160,000,177,251,201,032,195
50580 :208,003,076,097,198,141,103
50586 :243,207,173,236,207,201,141
50592 :153,144,023,169,000,141,022
50598 :236,207,173,237,207,201,147
50604 :008,176,006,169,200,141,104
50610 :237,207,056,233,008,141,036
50616 :237,207,173,237,207,201,166
50622 :192,144,006,169,192,141,010
50628 :237,207,024,105,007,141,149
50634 :015,208,173,253,207,072,106
50640 :173,254,207,072,173,236,043
50646 :207,141,253,207,173,015,186
50652 :208,141,254,207,032,161,199
50658 :193,104,141,254,207,104,205
50664 :141,253,207,169,000,133,111
50670 :252,173,243,207,201,032,066
50676 :176,003,076,166,196,201,038
50682 :096,144,003,076,166,196,163
50688 :056,233,032,010,039,252,109
50694 :010,038,252,010,038,252,094
50700 :133,251,024,165,252,105,174
50706 :008,133,252,160,000,169,228
50712 :008,133,002,177,251,141,224
50718 :240,207,152,072,173,240,090
50724 :207,234,234,010,141,240,078
50730 :207,144,024,160,000,173,238
50736 :252,207,073,255,049,253,113
50742 :234,234,234,234,234,234,178
50748 :208,007,177,253,013,251,201
50754 :207,145,253,032,009,196,140
50760 :198,002,208,214,032,137,095
50766 :195,169,008,133,002,032,105
50772 :197,195,198,002,208,249,109
50778 :104,168,200,192,008,144,138
50784 :182,173,236,207,024,105,255
50790 :008,141,236,207,206,242,118
50796 :207,240,021,238,245,207,242
50802 :208,003,238,246,207,173,165
50808 :245,207,133,251,173,246,095
50814 :207,133,252,076,142,197,109
50820 :104,133,254,104,133,253,089
50826 :169,000,141,236,207,173,040
50832 :237,207,201,008,176,005,210
50838 :169,200,141,237,207,056,136
50844 :233,008,141,237,207,096,054
50850 :032,253,174,165,251,072,085
50856 :165,252,072,169,032,133,223
50862 :252,169,000,133,251,168,123
50868 :162,031,173,250,207,141,120
50874 :243,207,010,010,141,244,017
50880 :207,010,010,141,245,207,244
50886 :010,010,141,246,207,177,221
50892 :251,240,064,041,192,205,173
50898 :246,207,208,006,177,251,025
50904 :041,063,145,251,177,251,120
50910 :240,047,041,048,205,245,024
50916 :207,208,006,177,251,041,094
50922 :207,145,251,177,251,240,225
50928 :030,041,012,205,244,207,211
50934 :208,006,177,251,041,243,148
50940 :145,251,177,251,240,013,049
50946 :041,003,205,243,207,208,141
50952 :006,177,251,041,252,145,112
50958 :251,200,208,185,230,252,060
50964 :202,208,180,198,252,165,201
50970 :251,201,064,240,012,169,195
50976 :064,133,251,160,192,162,226
50982 :001,024,144,161,234,104,194
50988 :133,252,104,133,251,096,245
50994 :073,206,079,070.198,067,231
51000 :204,080,195,080,176,080,103
51006 :177,080,178,080,179,080,068
51012 :069,206,080,204,068,210,137
51018 :067,210,080,210,000,000,129
51024 :234,234,234,234,234,234,204
51030 :234,234,234,234,234,038,014
51036 :192,091,192,133,192,161,029
51042 :198,164,192,181,192,253,254
51048 :192,067,193,149,196,044,177
51054 :194,058,194,210,196,101,039
51060 :197,234,234,032,115,000,160
51066 :032,128,199,076,174,167,130
51072 :240,027,233,128,144,024,156
51078 :201,076,144,023,201,089,100
51084 :176,019,233,075,010,168,053
51090 :185,092,199,072,185,091,202
51096 :199,072,076,115,000,096,198
51102 :076,165,169,076,243,167,030
51108 :032,008,200,201,204,144,185
51114 :015,173,055,200,233,076,154
51120 :141,055,200,169,199,162,078
51126 :050,076,190,199,169,160,002
51132 :162,158,141,050,167,142,240
51138 :049,167,141,058,167,142,150
51144 :057,167,032,249,199,076,212
51150 :026,167,032,008,200,173,044
51156 :252,165,201,160,208,015,189
51162 :169,199,162,050,032,026,088
51168 :200,032,249,199,160,000,040
51174 :076,184,165,169,160,162,122
51180 :158,032,026,200,032,249,165
51186 :199,189,000,002,076,007,203
51192 :166,173,054,200,072,173,062
51198 :055,200,174,056,200,172,087
51204 :057,200,040,096,008,141,034
51210 :055,200,142,056,200,140,035
51216 :057,200,104,141,054,200,004
51222 :173,055,200,096,141,190,109
51228 :165,216,142,189,165,141,022
51234 :001,166,142,000,166,202,199
51240 :224,255,208,003,056,233,251
51246 :001,141,252,165,142,251,230
51252 :165,096,255,255,255,255,053
51258 :255,255,162,032,160,000,154
51264 :169,160,133,252,169,000,179
51270 :133,251,177,251,145,251,254
51276 :200,208,249,230,252,202,137
51282 :208,244,234,169,076,141,130
51288 :225,167,141,004,166,169,192
51294 :119,141,226,167,169,199,091
51300 :141,227,167,169,208,141,129
51306 :005,166,169,199,141,006,024
51312 :166,169,164,141,006,003,249
51318 :169,199,141,007,003,169,038
51324 :000,141,254,207,141,253,096
51330 :207,141,252,207,141,251,049
51336 :207,141,236,207,141,237,025
51342 :207,165,001,041,254,133,175
51348 :001,096,255,013,013,013,027


Program 2: Color Plotter
Demo

For instructions on entering this listing, please
refer to "COMPUTEI's Guide to Typing In
Programs" published bimonthly in COMPUTE!.


14 REM COLOR PLOTTER 64:rem 92
18 REM **** INITIALIZE FOR DEM
   O1******           :rem 32
20 PEN,I:REM START USING PEN1
                      :rem 232
25 P0,0:REM SET BKGRND COLOR=B
   LACK                :rem 30
30 P1,12:REM SET PEN1=GRAY
                        :rem 1
35 P2,14:REM SET PEN2=LT BLUE
                      :rem 159
40 P3,5:REM SET PENS=GREEN
                       :rem 22
45 IN,:REM TURN ON HI-RES SCRE
   EN                 :rem 152
47 CL,:REM CLEAR HI-RES SCREEN
                       :rem 19
50 REM*** DEMO1, RANDOM SYMMET
   RY*******          :rem 186
52 CR,0,192:PR,"DESIGNS IN ":P
   R," ":PR,"RANDOM SYMMETRY"
                      :rem 243
53 X1=79:Y1=100:X2=79:Y2=100:X
   4=79:Y4=100         :rem 60
54 CR,0,0:PR,"PRESS A KEY TO C
ONT":PEN,2:PL,X1,Y1:
                      :rem 134
55 DX=INT(RND(O)*50)-25:DY=INT
   (RND(0)*80)-40:PEN,2:rem 90
60 X1=X1+DX:IFX1>159THENX1=159
                       :rem 63
62 IFX1<OTHENXI=0      :rem 17
64 Y1=Y1+DY:IFY1>170THENY1=170
                       :rem 58
66 IFY1<9THENY1=9      :rem 41
68 X2=X2-DX:IFX2>159THENX2=159
                       :rem 77
69 IFX2<OTHENX2=0      :rem 26
70 Y2=Y2+DY:IFY2>170THENY2=170
                       :rem 59
72 IFY2<9THENY2=9      :rem 40
74 DR,X1,Y1:X3=X1:Y3=YI:PEN,3:
   PL,X4,Y4:DR,X2,Y2:X4=X2:Y4=
   Y2                 :rem 160
75 PL,X3,Y3           :rem 119
76 K=K+1:IFK>15THENK=0:FORJ=0T
   O500:NEXTJ:PC,:PEN,2:PC,:GO
   TO55                :rem 88
78 GETA$:IFA$=""THEN55:rem 252
79 POKE198,0:CL,      :rem 146
210 REM****DEMO2 GEOMETRIC PAT
    TERN*****           :rem 5
220 CL,:REM CLEAR SCREEN
                      :rem 148
225 PEN,3:CR,40,100:PR,"NOW LE
    T'S SEE":CR,40,90:PR,"A PA
    TTERN"             :rem 18
230 X1=0:Y1=0:X2=159:Y2=0:X3=1
    59:Y3=199:X4=0:Y4=199
                      :rem 175
240 PEN,1:PL,X1,Y1:DR,X2,Y2
                       :rem 84
245 PEN,2:DR,X3,Y3     :rem 27
250 PEN,I:DR,X4,Y4     :rem 24
255 PEN,2:DR,X1,Y1     :rem 24
260 X1=X1+5:Y2=Y2+6.25:X3=X3-5
    :Y4=Y4-6.25        :rem 66
265 IFX1<160THEN240    :rem 77
268 PEN,3             :rem 226
269 IFY1=50THEN280     :rem 37
270 X1=50:Y1=50:X2=110:Y2=50:X
    3=110:Y3=150:X4=50:Y4=150:
    GOTO240            :rem 92
280 PEN,3:PC,:K=0     :rem 199
290 FORI=1T015:P1,I:P2,16-I:FO
    RJ=0TO400:NEXTJ     :rem 9
295 GETA$:IFA$=""THENNEXTI:K=K
    +1:IFK<2THEN290     :rem 0
300 P1,15:P2,3:P3,14:CR,65,100
    :PEN,3:PR,"DONE"   :rem 32
310 FORI=OT0500:NEXT:PEN,1:PC,
    :FORI=0TO500:NEXT:PEN,2:PC
                       :rem 81
315 FORI=0TO200:NEXT:CL
                      :rem 217
320 CR,0,160:PR,"MORE RANDOM D
    ESIGNS"           :rem 150
330 FORI=OT0800:NEXT:CL,
                      :rem 220
350 POKE198,0:PEN,1    :rem 63
400 REM****DEM03, RANDOM DESIG
NS*******             :rem 152
402 PO,0:REM SET PEN 0(BKGRND)
    =BLK              :rem 174
403 P1,1:REM SET PEN 1=COLOR 1
    =WHITE             :rem 62
404 P2,2:REM SET PEN 2=COLOR 2
    =RED              :rem 157
405 P3,3:REM SET PEN,3=COLOR 3
    =CYAN              :rem 30
406 PEN,1:REM DEFINE ACTIVE PE
    N =PEN1           :rem 147
415 CL,:REM CLEAR HI-RES SCREE
    N                  :rem 66
418 N=3:REM SET NUMBER OF RAND
    OM PTS            :rem 123
420 N1=20:REM SET INTERVAL DIV
    IDER               :rem 42
423 REM NEXT LINE GENERATES RA
    NDOM X,Y           :rem 32
430 FORI=0TON:X(I)=INT(RND(0)*
    120)+20:Y(I)=INT(RND(1)*19
    0):NEXTI           :rem 11
438 REM NEXT LINE COMPUTES DEL
    TX,DELTYS         :rem 220
440 FORI=OTON-1:DX(I)=(X(I+1)-
    X(I))/N1:DY(I)=(Y(I+1)-Y(I
    ))/N1:NEXTI       :rem 123
450 DX(N)=(X(0)-X(N))/N1:DY(N)
    =(Y(0)-Y(N))/N1   :rem 190
465 REM DRAW LINES BETWEEN POI
    NTS                :rem 19
470 PL,X(0),Y(0):FORI=0TON:PEN
    ,I:DR,X(I),Y(I):NEXTI:PEN,
    2:DR,X(0),Y(0):PEN,3
                       :rem 61
476 REM COMPUTE NEW X AND Y VA
    LUES              :rem 224
477 REM BASED ON NEWX=OLDX+DX
                      :rem 255
478 REM AND NEWY=OLDY+DY
                      :rem 218
480 FORI=OTON:X(I)=X(I)+DX(I):
    Y(I)=Y(I)+DY(I):NEXTI
                      :rem 103
485 REM CHECK IF DONE :rem 152
486 REM IF NOT, DRAW LINES
                      :rem 219
487 REM BETWEEN NEW X AND Y'S
                      :rem 121
488 K=K+1:IFK<N1 THEN 470
                      :rem 108
491 REM KEY PRESSED?  :rem 192
492 REM IF TRUE THEN END
                       :rem 88
493 REM IF NOT THEN CONTINUE
                      :rem 152
500 GETA$:IFA$<>""THEN700
                      :rem 140
515 REM DELAY TO VIEW GRAPHICS
                       :rem 29
520 FOR I=0 TO 500:NEXTI
                       :rem 46
526 REM LOOP THROUGH GENERATEO
    N                 :rem 200
527 REM OF RANDOM COLORS
                      :rem 170
528 REM FOR PENS 2 AND 3
                      :rem 216
530 FOR I=0 TO 5:C1=INT(RND(1)
    *15)+1:C2=INT(RND(1)*15)+1
    :C3=INT(RND(1)*15)+1
                      :rem 123
532 P1,C1:P2,C2:P3,C3 :rem 119
534 REM TIME DELAY :rem 30
536 FORJ=0TO300:NEXTJ  :rem 53
537 NEXTI              :rem 39
538 CR,8,188:PR,"PRESS KEY TO
    {SPACE}EXIT":FORI=0TO500:N
    EXTI              :rem 214
540 REM CLEAR SCREEN ONE PEN
                      :rem 105
541 REM AT A TIME WITH DELAY
                       :rem 46
545 PEN,1:PC,:FORI=0TO300:NEXT
    I                 :rem 166
550 PEN,2:PC,:FORI=0TO300:NEXT
    I                 :rem 163
560 PEN,3:PC,:FORI=0TO300:NEXT
    I                 :rem 165
580 REM CHECK FOR KEYPRESS
                       :rem 60
590 REM IF TRUE THEN EXIT
                      :rem 186
600 REM ELSE CONTINUE   :rem 8
610 GETA$:IFA$<>""THEN700
                      :rem 142
640 K=0:GOTO415        :rem 95
700 REM ****DEMO4 GLOBAL GRAPH
    ICS*****           :rem 80
710 CL,:P0,0:P1,1:P2,6:P3,2:PE
    N,1                :rem 52
730 R=60:PI=3.14159     :rem 4
731 X=0:Y=0:Z=0:GOSUB900:PL,Sx
    ,SY:X=0:Y=0:Z=65:GOSUB900:
    DR,SX,SY           :rem 70
732 SX=SX+3:CR,SX,SY:PR,"Z"
                      :rem 177
733 X=0:Y=0:Z=0:GOSUB900:PL,SX
    ,SY:Y=65:GOSUB900:DR,SX,SY
    :SY=SY+3:CR,SX,SY :rem 243
734 PR,"Y":X=0:Y=0:Z=0:GOSUB90
    0:PL,SX,SY:X=80:Y=0:Z=0:GO
    SUB900:DR,SX,SY   :rem 235
735 SY=SY+4:CR,SX,SY:PR,"X":PE
    N,2                :rem 48
740 FORTH=0TOPISTEP PI/10
                       :rem 44
750 Z=R*COS(TH):R1=R*SIN(TH)
                      :rem 206
760 X=R1*COS(1.9*PI):Y=R1*SIN(
    1.9*PI)           :rem 131
770 GOSUB900:PL,SX,SY  :rem 60
775 IFTH=0THENNEXTTH   :rem 69
780 FOR BETA=0TO 2*PISTEP PI/1
    0:                 :rem 70
790 X=R1*COS(BETA):Y=R1*SIN(BE
    TA):               :rem 66
800 GOSUB900:DR,SX,SY  :rem 48
810 NEXT BETA         :rem 244
820 NEXT TH           :rem 117
830 PEN,3             :rem 221
835 X=0:Y=0:Z=R:GOSUB900:PL,SX
,SY                    :rem 96
840 FORTH=0 TO 2*PI STEP PI/10
                      :rem 137
841 X=0:Y=0:Z=R:GOSUB900:PL,SX
    ,SY                :rem 93
845 FOR BETA=0 TO PI STEP PI/1
    0                 :rem 178
850 Z=R*COS(BETA):X=R*SIN(BETA
    *COS(TH):Y=R*SIN(BETA)*SI
    N(TH)              :rem 68
855 GOSUB900:DR,SX,SY:NEXT BET
    A:X=0:Y=0:Z=-R:GOSUB900:DR
    ,SX,SY            :rem 240
860 NEXT TH           :rem 121
865 PEN,I:PC,:FORI=0TO1000:NEX
    T                 :rem 144
866 FORI=0TO10:C2=INT(RND(0)*1
    6):C3=INT(RND(0)*16):P2,C2
    :FORJ=0T0150:NEXTJ:rem 179
867 P3,C3:FORJ=0TO150:NEXTJ:NE
    XTI                :rem 96
870 PEN,1:CR,4,4:PR,"THAT'S AL
    L FOLKS"          :rem 189
875 FORI=0 TO 32:P1,I:FORJ=0TO
    50:NEXTJ,I        :rem 145
879 REM ****CLOSING CEREMONIES
    ******             :rem 41
880 CL,:P0,14:P1,6:CR,15,95
                      :rem 190
885 PR,"COLOR PLOTTER 64"
                      :rem 202
888 PR," ":P2,1:PEN,1  :rem 77
895 FORI=0 TO 1000:NEXTI
                      :rem 105
897 P3,6:FORI=0T0101:PL,0,I:DR
    ,159,I:PL,0,199-I:DR,159,1
    99-I:NEXTI        :rem 105
898 OFF,:POKE53281,6:POKE53280
    ,14:PRINT"(CLR)"   :rem 24
899 END               :rem 129
900 S1=SIN(PI/4):C1=COS(PI/4):
    S2=SIN(PI/4):C2=COS(PI/4):
    D=100:PH=120      :rem 237
905 XE=-X*S1+Y*C1     :rem 205
910 YE=-X*C1*C2-Y*S1*C2+Z*S2
                       :rem 62
915 ZE=-X*S2*C1-Y*S2*S1-Z*C2+P
    H                  :rem 25
920 SX=D*XE/ZE+80     :rem 239
925 SY=D*YE/ZE+100     :rem 31
930 RETURN            :rem 124
1000 END              :rem 152