10 REM
20 REM "DRAW" 25-OCT-82 C.FLARITY
30 REM
40 REM THIS PROGRAM CONSTRUCTS A PICTURE ON C.R.T.SCREEN
42 REM 80 COLUMNS WIDE, 23 LINES LONG.
44 REM
46 REM IT OPERATES IN ONE OF TWO MODES, WHICH ARE TOGGLED
48 REM WITH [ESC] KEY. IT BEGINS IN "DRAW" MODE WHERE THE
50 REM ARROW KEYS MOVE CURSOR WITHOUT AFFECTING IMAGE.
60 REM THE NUMBER PAD THEN CONTROLS MOVEMENT OF A "PENCIL"
70 REM THE [5] KEY TOGGLES BETWEEN "ERASE" AND "MARK".
80 REM 
100 INPUT "Need instructions (Y/N)?",CMD$
102 IF CMD$="N" THEN 200
103 PRINT
104 PRINT "COPYRIGHT 1982 Marie Associates"
106 PRINT "This program may be distributed freely provided"
108 PRINT "no charge is made and that the copyright notice"
110 PRINT "be retained. Marie Associates, Micro-computer"
112 PRINT "consultants, (408) 733-8615."
114 PRINT
116 PRINT "The number pad acts as joystick for moving a
118 PRINT "'pencil'. The [5] key swaps eraser for marking
120 PRINT "end. The arrow keys move pencil without marking
122 PRINT "or erasing. Default mark = '*'. This may be 
124 PRINT "changed with the command [newmark] [RETURN].
126 PRINT "TEXT mode is entered/exited with [ESC] key.
127 PRINT "[0] Erases CRT image.
128 PRINT
130 PRINT "In DRAW mode, commands may be entered in the form
132 PRINT "<command> [RETURN]. Valid commands are:
140 PRINT "EXIT, HOUSE, BOY, CAT, DOG, TREE, CAR, TRAIN, MAN
142 PRINT "GIRL, FRAME, GRID, PRINT.
144 PRINT
146 PRINT "PRINT command prints image on line printer.
148 PRINT
190 PRINT "Press any key when you are ready -";
194 CHAR$=INPUT$(1)
200 HOME=&HF000: LYNE=128: COLUMN=1
210 CLEARSCREEN$=CHR$(26)
220 BELL$=CHR$(7): ESC$=CHR$(27)
230 DRAW=1: TEXT=0
240 BOTTOM=&HFF00
250 REM Peek into system to obtain value of arrow keys.
252 ADRS=PEEK(&HE57F)+256*PEEK(&HE580)
254 UPARROW=PEEK(ADRS): RIGHTARROW=PEEK(ADRS+1)
256 DOWNARROW=PEEK(ADRS+2): LEFTARROW=PEEK(ADRS+3)
260 DIM OLDP(20)
270 P=0: CMD$=""
280 FRAMEMARK=ASC("#")
300 REM
310 REM Turn off system's horizontal scroll.
320 REM
330 POKE &HE568,0
1000 REM
1001 REM ERASE SCREEN AND INITIALIZE
1002 REM
1010 PRINT CLEARSCREEN$;
1020 ADRS=HOME
1030 MODE=DRAW
1040 MARK=32: OLDMARK=ASC("*")
1500 REM
1501 REM START OF MAIN LOOP
1502 REM
1510 IF ADRS<HOME THEN 1590
1520 IF ADRS>=BOTTOM THEN 1590
1530 IF (ADRS AND 127)<80 THEN 1600
1590 PRINT BELL$;: ADRS=OLDADRS
1600 REM
1601 REM SET CURSOR TO NEW POSITION
1602 REM
1610 XCUR=ADRS AND 127: YCUR=INT((ADRS-HOME)/128)
1700 REM
1701 REM MOVE SCREEN OVER IF REQUIRED
1702 REM
1710 XPOS=0: YPOS=0
1720 L=INT((ADRS-HOME)/128)
1730 IF L>20 THEN YPOS=L-20
1740 C=ADRS AND 127
1750 IF C>40 THEN XPOS=C-40
1770 PRINT ESC$+"S"+CHR$(YPOS+32)+CHR$(XPOS+32);
1780 YCUR=YCUR-YPOS
1790 PRINT ESC$+"="+CHR$(YCUR+32)+CHR$(XCUR+32);
2000 REM
2001 REM READ NEXT CHARACTER
2002 REM
2010 CHAR$=INPUT$(1): CHAR=ASC(CHAR$)
2020 OLDADRS=ADRS
2024 IF CHAR$<>ESC$ THEN 2040
2030 IF MODE=DRAW THEN MODE=TEXT: PARK=ADRS: POKE ADRS,255: GOTO 5000
2034 MODE=DRAW
2036 POKE ADRS,OLDP
2040 IF MODE<>DRAW THEN 2500
2045 IF CHAR>57 THEN 6000
2046 IF CHAR>32 AND CHAR<48 THEN 6000
2047 IF CHAR=13 THEN 6100
2050 IF CHAR<ASC("0") OR CHAR>ASC("9") THEN 2500
2110 IF CHAR$="1" THEN ADRS=ADRS+LYNE-COLUMN: GOTO 2210
2120 IF CHAR$="2" THEN ADRS=ADRS+LYNE: GOTO 2210
2130 IF CHAR$="3" THEN ADRS=ADRS+LYNE+COLUMN:GOTO 2210
2140 IF CHAR$="4" THEN ADRS=ADRS-COLUMN:GOTO 2210
2150 IF CHAR$<>"5" THEN 2160
2155 IF MARK=32 THEN MARK=OLDMARK ELSE MARK=32
2160 IF CHAR$="6" THEN ADRS=ADRS+COLUMN:GOTO 2210
2170 IF CHAR$="7" THEN ADRS=ADRS-LYNE-COLUMN:GOTO 2210
2180 IF CHAR$="8" THEN ADRS=ADRS-LYNE:GOTO 2210
2190 IF CHAR$="9" THEN ADRS=ADRS-LYNE+COLUMN
2200 IF CHAR$="0" THEN 1000
2210 IF ADRS>=BOTTOM OR ADRS<HOME THEN 2230
2220 POKE ADRS,MARK+(PEEK(ADRS) AND 128)
2230 REM
2500 REM
2510 IF CHAR=LEFTARROW THEN ADRS=ADRS-COLUMN
2520 IF CHAR=RIGHTARROW THEN ADRS=ADRS+COLUMN
2530 IF CHAR=UPARROW THEN ADRS=ADRS-LYNE
2540 IF CHAR=DOWNARROW THEN ADRS=ADRS+LYNE
2550 CMD$="": P=0
3000 IF MODE<>TEXT THEN 1500
3020 POKE OLDADRS,OLDP
3030 POKE ADRS,PEEK(ADRS) OR 127
5000 REM
5001 REM JUST PUT TEXT ON THE SCREEN
5002 REM
5010 IF CHAR<>13 THEN 5020
5012 POKE ADRS,OLDP
5014 ADRS=PARK+LYNE: PARK=ADRS
5016 POKE ADRS,255
5018 GOTO 1500
5020 IF CHAR<32 THEN 1500
5030 PRINT ESC$+"="+CHR$(YCUR+32)+CHR$(XCUR+33);
5040 POKE ADRS,CHAR
5050 ADRS=ADRS+1
5060 OLDP=PEEK(ADRS): POKE ADRS,255
5100 GOTO 1500
6000 REM
6002 REM
6010 OLDP(P)=PEEK(ADRS): P=P+1
6030 PRINT ESC$+"="+CHR$(YCUR+32)+CHR$(XCUR+33);
6040 POKE ADRS,CHAR
6050 ADRS=ADRS+1
6060 CMD$=CMD$+CHAR$
6090 GOTO 1500
6100 TADRS=ADRS-1: P=P-1
6110 FOR TP=P TO 0 STEP -1
6120 POKE TADRS,OLDP(TP) AND 127
6130 TADRS=TADRS-1
6140 NEXT
6150 P2=P: P=0
6160 IF CMD$<>"PRINT" THEN 6300
6200 REM
6201 REM PRINT CONTENTS OF SCREEN ON LINE PRINTER.
6202 REM
6210 FOR TADRS=HOME TO BOTTOM STEP 128
6220 FOR TP=TADRS TO TADRS+80
6230 LPRINT CHR$(PEEK(TP));
6240 NEXT
6250 LPRINT
6260 NEXT
6270 LPRINT CHR$(12);
6290 GOTO 6900
6300 REM
6301 REM IF ONLY ONE LETTER ENTERED THEN TAKE
6302 REM IT AS THE MARK CHARACTER.
6303 REM
6310 IF P2>0 THEN 6333
6314 IF CMD$="" THEN 6900
6320 MARK=ASC(CMD$): OLDMARK=MARK
6324 POKE ADRS,MARK OR (PEEK(ADRS) AND 128)
6330 GOTO 6900
6333 RESTORE 7998
6338 IF CMD$="EXIT" THEN END
6340 IF CMD$="HOUSE" THEN RESTORE 7340
6350 IF CMD$="BOY" THEN RESTORE 7350
6360 IF CMD$="CAT" THEN RESTORE 7360
6370 IF CMD$="DOG" THEN RESTORE 7370
6380 IF CMD$="TREE" THEN RESTORE 7380
6390 IF CMD$="CAR" THEN RESTORE 7390
6400 IF CMD$="TRAIN" THEN RESTORE 7400
6410 IF CMD$="MAN" THEN RESTORE 7350
6420 IF CMD$="GIRL" THEN RESTORE 7350
6430 IF CMD$<>"FRAME" THEN 6440
6431 FOR J=HOME TO HOME+80
6432 POKE J,(PEEK(J) AND 128) + FRAMEMARK
6433 POKE J+&HF00,(PEEK(J+&HF00) AND 128) + FRAMEMARK
6434 NEXT
6435 FOR J=HOME TO HOME+&HF00 STEP 128
6436 POKE J,(PEEK(J) AND 128) + FRAMEMARK
6437 POKE J+79,(PEEK(J+79) AND 128) + FRAMEMARK
6438 NEXT
6440 IF CMD$<>"GRID" THEN 6450
6441 FOR J=HOME+3 TO HOME+79 STEP 3
6442 FOR K=J TO J+&HF00 STEP 128
6443 POKE K,(PEEK(K) AND 128)+OLDMARK
6444 NEXT: NEXT
6445 FOR J=HOME+3*LYNE TO HOME+&HF00 STEP 3*LYNE
6446 FOR K=J TO J+79
6447 POKE K,(PEEK(K) AND 128) + OLDMARK
6448 NEXT: NEXT
6450 REM
6800 READ N
6805 IF N<0 THEN 6900
6810 FOR J=1 TO N
6820 READ OFFSET,P$
6824 IF ADRS+OFFSET>=BOTTOM THEN 6840
6826 IF ((ADRS+OFFSET) AND 127)>80 THEN 6840
6830 POKE ADRS+OFFSET,ASC(P$)+(PEEK(ADRS+OFFSET) AND 128)
6840 NEXT
6900 CMD$="": P=0
6910 GOTO 1500
7340 DATA 63
7341 DATA 0,"!",-1," ",-2," ",-3," ",-4," ",-5," ",-6," ",-7,"!"
7342 DATA -128,"!",-129,"-",-130,"-",-131,"-",-132,"-",-133,"-",-134,"-",-135,"!"
7343 DATA -256,"\",-257," ",-258," ",-259," ",-260," ",-261," ",-262," ",-263,"/"
7344 DATA -385,"\",-386," ",-387," ",-388," ",-389," ",-390,"/"
7345 DATA -514,"\",-517,"/",-127,"\",-136,"/"
7346 DATA 128,"!",127," ",126," ",125,"#",124," ",123," ",122," ",121,"!"
7347 DATA 256,"!",255," ",254," ",253,"#",252," ",251," ",250," ",249,"!"
7348 DATA 384,"+",383,"-",382,"-",381,"-",380,"-",379,"-",378,"-",377,"+"
7349 DATA -641,"H",-643,"\",-644,"/",-385,"H",-513,"H"
7350 DATA 7
7351 DATA 0,"_",-1,"+",-2,"_"
7352 DATA -129,"0"
7353 DATA 127,"*",254,"/",256,"\"
7360 DATA 8
7361 DATA 0,"|",-1,"=",-2,"=",-3,"=",-4,"@"
7362 DATA 127,"^",125,"^",-128,","
7370 DATA 11
7371 DATA 1,"#",0,"#",-1,"y",-2,"y",-3,"y",-4,"y"
7372 DATA -5,"\",127,"[",124,"[",-128,",",-127,","
7380 DATA 14
7381 DATA 127,"H",-1,"H",-129,"H",-256,"*",-257,"*",-258,"*"
7382 DATA -383,"*",-384,"*",-385,"*",-386,"*",-387,"*"
7383 DATA -512,"*",-513,"*",-514,"*"
7390 DATA 41
7391 DATA 0,"\",1,"-",2,"-",3,"-",4,"]",132,"]",131,"_",130," "
7392 DATA 258,")",257," ",256,"(",128," ",127,"_",126,"_",125,"_",124,"_"
7393 DATA 123,"_",122," ",121," ",250,")",249," ",248,"(",119,"_",118,"["
7394 DATA -10,"[",-9,"-",-8,"-",-7,"-",-6,"/",-4," ",-3," ",-2," "
7395 DATA -5," ",120," ",129," ",-1," "
7396 DATA -133,"/",-132,"-",-131,"-",-130,"-",-129,"\"
7400 DATA 75
7401 DATA 262,"\",261,"\",259,"o",258,"o",257,"o",253,")",252," "
7402 DATA 251,"(",249,")",248," ",247,"(",117,"n",118,"n",119,"X"
7403 DATA 120,"^",121,"X",122,"X",123,"X",124,"^",125,"X",126,"X"
7404 DATA 127,"X",128,"X",129,"X",130,"X",131,"X",132,"X",133,"\"
7405 DATA 5,"C",4,"X",3,"X",2,"X",1,"X",0,"X",-1,"N",-2,"I"
7406 DATA -3,"A",-4,"R",-5,"T",-6,"X",-7,"X",-8,"X",-9,"X",-10,"X"
7407 DATA -138,"X",-137,"X",-136,"X",-135,"X",-134,"X",-133,"X"
7408 DATA -132,"X",-131,"X",-130,"X",-129,"X",-128,"X",-127,"X"
7409 DATA -126,"X",-124,"X",-253,"H",-254,"H",-256,"m",-258,"m"
7410 DATA -262,"]",-263," ",-264,"[",-265,"X",-266,"X",-125,"X"
7411 DATA -394,"X",-393,"X",-392,"[",-391,"^",-390,"]"
7412 DATA -382,"H",-381,"H"
7998 DATA -1,"1",-2,"2",-3,"3",-4,"4",-5,"5",-6,"6"
394,"X",-393,"X",-392,"[",-391,"^",-390,"]"
741