10 '		KDRAW SCREEN GRAPHICS UTILITY
20 '
30 PRINT CHR$(26)
40 PRINT "KDRAW 1.0"
50 PRINT "created 12/27/82 by David Ring"
60 PRINT
70 PRINT
80 PRINT "This program is an MBASIC utility for composing"
90 PRINT "screens with the Osborne graphics characters.  It"
100 PRINT "creates an array representing the 24 by 52 cells"
110 PRINT "of the visible screen, allows you to enter character"
120 PRINT "codes as desired, and then prints out the screen."
130 WIDTH 128
140 DIM SCREEN(24,52)
150 PRINT
160 INPUT "When ready to proceed, press RETURN.",DUMMY$
170 PRINT CHR$(26)
180 PRINT "Your options are:"
190 PRINT
200 PRINT
210 PRINT "	(N)  Enter data for screen array"
220 PRINT "	(E)  Edit screen array data"
230 PRINT "	(D)  Display screen array"
240 PRINT "	(X)  Exit from KDRAW" 
250 PRINT
260 INPUT "Your choice";CHOICE$
270 FLAG=0
280 IF CHOICE$="N" OR CHOICE$="n" THEN GOSUB 1000
290 IF CHOICE$="E" OR CHOICE$="e" THEN GOSUB 5000
300 IF CHOICE$="D" OR CHOICE$="d" THEN GOSUB 2000
310 IF CHOICE$="X" OR CHOICE$="x" THEN END
320 IF FLAG=1 GOTO 170
330 PRINT CHR$(26)
340 PRINT "That letter is not on the menu.  Please try again."
350 PRINT
360 GOTO 180
1000 '**************************************************
1010 '
1020 '		SUBROUTINE TO ENTER SCREEN ARRAY
1030 '
1040 PRINT CHR$(26)
1050 PRINT "KDRAW allows you to enter one row of characters at"
1060 PRINT "a time.  The current row number will be displayed"
1070 PRINT "at the top of the screen.  At the prompt 'Character"
1080 PRINT "code:' enter the code of the graphics character you"
1090 PRINT "wish to display in the current row/column position."
1100 PRINT "At the prompt 'to column?' enter the column at which"
1110 PRINT "you wish use of this particular character to stop."
1120 PRINT "KDRAW will fill the row from the current position"   
1130 PRINT "to the designated ending position with the chosen"          
1140 PRINT "character."
1150 PRINT
1160 INPUT "When ready to proceed, press RETURN.",DUMMY$
1170 FOR I=1 TO 24
1180	PRINT CHR$(26)
1190	PRINT "Current row is "+STR$(I)+"."
1200	STARTCOL=1
1210	ENDCOL=1
1220	WHILE ENDCOL<52
1230		PRINT
1240		INPUT "Character code";CODE
1250		INPUT "to column";ENDCOL
1260		IF CODE>127 OR ENDCOL>52 THEN 1280 ELSE 1300
1270 PRINT
1280		PRINT "Value out of range.  Please try again."
1290		GOTO 1230
1300		FOR J=STARTCOL TO ENDCOL
1310			SCREEN(I,J)=CODE
1320			NEXT J
1330		STARTCOL=ENDCOL+1
1340		WEND
1350	NEXT I
1360 GOSUB 3000
1370 FLAG=1
1380 RETURN
2000 '**************************************************
2010 '
2020 '		SUBROUTINE TO DISPLAY SCREEN ARRAY
2030 '
2040 PRINT CHR$(26)
2050 PRINT "If you wish to display an array saved as a file,"
2060 PRINT "please enter filename, including disk prefix.  If"
2070 PRINT "you wish to display the array in current memory,"
2080 PRINT "simply press RETURN."
2090 PRINT
2100 INPUT "Filename";FILENAME$
2110 IF FILENAME$<>"" THEN GOSUB 4000
2120 PRINT CHR$(26)
2130 FOR K=1 TO 24
2140  	PRINT CHR$(27)+"g";
2150	FOR L=1 TO 52
2160		IF SCREEN(K,L)=9 THEN 2170 ELSE 2210
2170			POKE 16750,195
2180			PRINT CHR$(9);
2190			POKE 16750,194
2200			GOTO 2260 
2210		IF SCREEN(K,L)=27 THEN 2220 ELSE 2240
2220			PRINT CHR$(27)+CHR$(27);
2230			GOTO 2260 
2240		'OTHERWISE
2250			PRINT CHR$(SCREEN(K,L));
2260		NEXT L
2270	IF K<24 THEN PRINT CHR$(27)+"G"
2280	NEXT K
2290 PRINT CHR$(27)+"G";
2300 INPUT "",DUMMY$
2310 FLAG=1
2320 RETURN
3000 '**************************************************
3010 '
3020 '		SUBROUTINE TO STORE SCREEN ARRAY AS FILE
3030 '
3040 PRINT CHR$(26)
3050 PRINT "If you wish to save the current screen array"
3060 PRINT "please supply a filename, including disk prefix."
3070 PRINT
3080 INPUT "Filename";FILENAME$
3090 IF FILENAME$="" THEN RETURN
3100 OPEN "O",#1,FILENAME$
3110 FOR M=1 TO 24
3120	FOR N=1 TO 52
3130		PRINT #1,SCREEN(M,N)
3140		NEXT N
3150	NEXT M
3160 CLOSE #1
3170 RETURN
4000 '**************************************************
4010 '
4020 '		SUBROUTINE TO GET SCREEN ARRAY FROM FILE
4030 '
4040 OPEN "I",#1,FILENAME$
4050 FOR O=1 TO 24
4060	FOR P=1 TO 52
4070		INPUT #1,SCREEN(O,P)
4080		NEXT P
4090	NEXT O
4100 CLOSE #1
4110 RETURN
5000 '**************************************************
5010 '
5020 '		SUBROUTINE TO EDIT SCREEN ARRAY
5030 '
5040 PRINT CHR$(26)
5050 PRINT "If you wish to edit a screen array saved as a"
5060 PRINT "file, please enter filename, including disk"
5070 PRINT "prefix.  To edit the array in current memory,"
5080 PRINT "simply press RETURN."
5090 PRINT
5100 INPUT "Filename";FILENAME$
5110 IF FILENAME$<>"" THEN GOSUB 4000
5120 PRINT CHR$(26)
5130 PRINT "KDRAW will first prompt you for line number to"
5140 PRINT "edit, then display the line in graphics format,"
5150 PRINT "and finally allow you to re-enter code values for"
5160 PRINT "individual cells in the line.  When you are through"
5170 PRINT "with the last cell in a line, and when you are"
5180 PRINT "through with the last line you wish to edit, in"
5190 PRINT "each case enter the letter 'D' to tell KDRAW you"
5200 PRINT "are done."
5210 PRINT
5220 INPUT "Ready";DUMMY$
5230 PRINT CHR$(26)
5240 INPUT "Line number";ROW$
5250 IF ROW$="D" OR ROW$="d" THEN GOTO 5460
5260 IF VAL(ROW$)<1 OR VAL(ROW$)>24 THEN 5270 ELSE 5300
5270 PRINT
5280 PRINT "Invalid line number.  Please try again."
5290 GOTO 5230
5300 PRINT
5310 GOSUB 6000 '(DISPLAY LINE IN GRAPHICS)
5320 PRINT
5330 INPUT "Column to change";COL$
5340 IF COL$="D" OR COL$="d" THEN GOTO 5420
5350 INPUT "New character code";CODE
5360 IF VAL(COL$)>52 OR CODE>127 THEN 5370 ELSE 5400
5370 PRINT
5380 PRINT "Value out of range.  Please try again."
5390 GOTO 5320
5400 SCREEN(VAL(ROW$),VAL(COL$))=CODE
5410 GOTO 5320
5420 PRINT
5430 GOSUB 6000 '(DISPLAY LINE IN GRAPHICS)
5440 INPUT "Press RETURN to proceed",DUMMY$
5450 GOTO 5230
5460 GOSUB 3000 '(SAVE EDITED RESULTS AS FILE)
5470 FLAG=1
5480 RETURN
6000 '**************************************************
6010 '
6020 '		SUBROUTINE TO DISPLAY LINE IN GRAPHICS
6030 '
6040 PRINT "1234567890123456789012345678901234567890123456789012"
6050 PRINT CHR$(27)+"g";
6060 FOR Q=1 TO 52
6070	IF SCREEN(VAL(ROW$),Q)=9 THEN 6080 ELSE 6120
6080		POKE 16750,195
6090		PRINT CHR$(9);
6100		POKE 16750,194
6110		GOTO 6170
6120	IF SCREEN(VAL(ROW$),Q)=27 THEN 6130 ELSE 6150
6130		PRINT CHR$(27)+CHR$(27);
6140		GOTO 6170
6150	'OTHERWISE
6160		PRINT CHR$(SCREEN(VAL(ROW$),Q));
6170	NEXT Q
6180 PRINT CHR$(27)+"G"
6190 RETURN

6140		GOTO 6170
6150	'OTHERWISE
6160		PRINT 