10 'ETCH (ETCH-A-SKETCH) WRITTEN IN MBASIC AS CURSOR CONTROL EXERCISE
20 'BY DAVE BLAIR   14 JUNE 1982
21 '
22 '
30 '<CTL>C DROPS YOU BACK TO MBASIC
40 '<ESC> STARTS PROGRAM OVER
41 '
42 '<CTL> MOST KEYS GIVES A GRAPHIC
43 ' 
50 'ALL COMMANDS ARE VIA THE NUMERIC KEY PAD
51 '--1-- MOVES CURSOR UP AND TO THE LEFT
52 '--2-- MOVES CURSOR UP
53 '--3-- MOVES CURSOR UP AND TO THE RIGHT
54 '--4-- MOVES CURSOR TO THE LEFT
55 '--5-- IS A SWITCH WHICH TURNS TRACER OFF/ON/OFF/ON
56 '--6-- MOVES CURSOR TO RIGHT
57 '--7-- MOVES CURSOR DOWN AND TO THE LEFT
58 '--8-- MOVES CURSOR DOWN
59 '--9-- MOVES CURSOR DOWN AND TO THE RIGHT
60 '--0-- ERASES ANY CHARACTER AT CURSOR POSITION
70 '
80 '--x-- ANY OTHER CHARACTER BECOMES TRACER
90 '
91 'PUT MBASIC IN A
92 'PUT THEIS DISC IN B
93 'Type MBASIC B:E-SKETCH  and try it out
94 ' 
100 PRINT CHR$(26)                        'CLEAR SCREEN
110 B$ = "X"                              'SET TRACER CHARACTER
120 IPEN% = -1                            'TURN OFF TRACER
140 X% = 58                               'SET INITIAL X
150 Y% = 44                               'SET INITIAL Y
160 PRINT CHR$(27);"=";CHR$(Y%);CHR$(X%); 'POSITION CURSOR 
200 A$ = INPUT$(1)                        'INPUT A CONTROL CHARACTER
201 IF A$ = CHR$(27) THEN GOTO 100        'START OVER IF <ESC>
208 IF A$ < "0" THEN B$ = A$              'IF NOT NUMERIC, SET FOR TRACER
209 IF A$ > "9" THEN B$ = A$              
210 IF A$ = "1" THEN X% = X% - 1
211 IF A$ = "1" THEN Y% = Y% + 1
220 IF A$ = "2" THEN Y% = Y% + 1
230 IF A$ = "3" THEN X% = X% + 1
231 IF A$ = "3" THEN Y% = Y% + 1
240 IF A$ = "4" THEN X% = X% - 1
250 IF A$ = "5" THEN IPEN% = -IPEN%       'REVERSE TRACER SWITCH
260 IF A$ = "6" THEN X% = X% + 1
270 IF A$ = "7" THEN X% = X% - 1
271 IF A$ = "7" THEN Y% = Y% - 1
280 IF A$ = "8" THEN Y% = Y% - 1
290 IF A$ = "9" THEN X% = X% + 1
291 IF A$ = "9" THEN Y% = Y% - 1
300 IF X% > 81 THEN X% = 33
310 IF X% < 33 THEN X% = 81
320 IF Y% < 33 THEN Y% = 54               'KEEP CURSOR ON SCREEN
330 IF Y% > 54 THEN Y% = 33
390 PRINT                                 'KEEPS LINE COUNTER CLEAN 
400 IF A$ <> "0" THEN GOTO 500            'IF --0-- BLANK OUT CURSOR POSITION
410 PRINT CHR$(27);"=";CHR$(Y%);CHR$(X%);" ";
420 PRINT CHR$(27);"=";CHR$(Y%);CHR$(X%);
430 GOTO 200
500 PRINT CHR$(27);"=";CHR$(Y%);CHR$(X%);  'POSITION CURSOR 
510 IF IPEN% = -1 THEN GOTO 200            'IF SWITCH OFF, GO DO NEXT COMMAND
520 PRINT CHR$(27);"g";                    'SET FOR GRAPHICS
530 PRINT B$;                              'IF SWITCH ON, PRINT TRACER 
540 PRINT CHR$(27);"G";                    'RESET FOR NON-GRAPHICS
550 PRINT CHR$(27);"=";CHR$(Y%);CHR$(X%);  'POSITION CURSOR 
599 GOTO 200                               'GET NEXT COMMAND
