10    DIM B(7000)
20    FULLW 2
30    CLEARW 2
40    PRINT"  **** PLEASE WAIT *****
50    GOSUB 770
60    CLEARW 2
70    HP=1:Z=1
80    VP=1
90    HS=4
100   VS=2
110   INPUT"HORIZONTAL SIZE";HM
120   INPUT"VERTICAL SIZE";VM
130   INPUT"BACKGROUND COLOR";C0
140   INPUT"COLOR 1";C1
150   INPUT"COLOR 2";C2
160   INPUT"COLOR 3";C3
170   CLEARW 2
180   GOSUB 1100
190   GOSUB 840
200   HG=HS*HP
210   VG=VS*VP
220   HE=HG+(HS-1)
230   COLOR 1,6,CL,0,0
240   GOSUB 920
250   X=INP(2)
260   IF X=32 THEN CN=CN+1
270   IF CN=4 THEN CN=0
280   IF CN=0 THEN CL=C0
290   IF CN=1 THEN CL=C1
300   IF CN=2 THEN CL=C2
310   IF CN=3 THEN CL=C3
320   IF X <> 67 THEN 350
330   GOSUB 1740
340   GOSUB 610
350   IF X <> 65 THEN 380
360   GOSUB 1420
370   GOSUB 610
380   IF X <> 82 THEN 400
390   GOSUB 610
400   IF X <> 76 THEN 440
410   INPUT"FILENAME";F$
420   GOSUB 1190
430   GOSUB 610:HP=1:VP=1
440   IF X <> 83 THEN 480
450   INPUT"FILENAME";F$
460   GOSUB 1310
470   GOSUB 610:HP=1:VP=1
480   IF X=208 THEN VP=VP+1
490   IF X=200 THEN VP=VP-1
500   IF X=205 THEN HP=HP+1
510   IF X=203 THEN HP=HP-1
520   IF HP=0 THEN HP=HM
530   IF HP=HM+1 THEN HP=1
540   IF VP=VM+1 THEN VP=1
550   IF VP=0  THEN VP=VM
560   A=(((VP-1)*HM)+HP)
570   B(A)=CN
580   REM T A;VP;HP
590   GOTO 200
600   REM *** REDRAW SCREEN ***
610   CLEARW 2
620   GOSUB 1100
630   HP=0:VP=1:C=1
640   MC=B(C)
650   C=C+1:HP=HP+1
660   IF HP=HM+1 THEN HP=1:VP=VP+1
670   IF VP=VM+1 THEN RETURN
680   IF MC=0 THEN 640
690   HG=HP*HS:VG=VP*VS
700   HE=HG+(HS-1)
710   IF MC=1 THEN MC=C1:GOTO 740
720   IF MC=2 THEN MC=C2:GOTO 740
730   IF MC=3 THEN MC=C3:GOTO 740
740   COLOR 1,6,MC,0,0
750   GOSUB 920
760   GOTO 640
770   REM *** CLEAR SCREEN ***
780   A=0
790   REM Y=HM*VM
800   FOR X=1 TO 6400
810   B(X)=A
820   NEXT X
830   RETURN
840   REM *** SET WIDTH ***
850   POKE CONTRL,16
860   POKE CONTRL+2,1
870   POKE CONTRL+6,0
880   POKE PTSIN,2
890   POKE PTSIN+2,0
900   VDISYS(0)
910   RETURN
920   REM *** DRAW LINES ***
930   POKE CONTRL,6
940   POKE CONTRL+2,2
950   POKE CONTRL+6,0
960   POKE PTSIN,HG
970   POKE PTSIN+2,VG+24
980   POKE PTSIN+4,HE
990   POKE PTSIN+6,VG+24
1000  VDISYS(0)
1010  POKE CONTRL,6
1020  POKE CONTRL+2,2
1030  POKE CONTRL+6,0
1040  POKE PTSIN,HG
1050  POKE PTSIN+2,VG+25
1060  POKE PTSIN+4,HE
1070  POKE PTSIN+6,VG+25
1080  VDISYS(0)
1090  RETURN
1100  REM *** DRAW BACKGROUND ***
1110  COLOR 1,C0,C0,1,1
1120  LINEF 0,0,300,0
1130  LINEF 0,0,0,160
1140  LINEF 300,0,300,160
1150  LINEF 0,160,300,160
1160  FILL 150,80
1170  RETURN
1180  REM *** LOAD FILE ***
1190  CLEARW 2
1200  S$="LOADING FILE "+F$
1210  PRINT S$
1220  OPEN "I",#1,F$+".DEF"
1230  N=HM*VM
1240  FOR X=1 TO N
1250  INPUT#1,C
1260  B(X)=C
1270  NEXT
1280  CLOSE #1
1290  RETURN
1300  REM *** SAVE FILE ***
1310  CLEARW 2
1320  S$="SAVING FILE "+F$
1330  PRINT S$
1340  OPEN "O",#1,F$+".DEF"
1350  N=HM*VM
1360  FOR X=1 TO N
1370  C=B(X)
1380  PRINT#1,C
1390  NEXT
1400  CLOSE #1
1410  RETURN
1420  REM *** ACTUAL SCREEN ***
1430  CLEARW 2
1440  GOSUB 1100
1450  HP=0:VP=1:C=1
1460  MC=B(C)
1470  C=C+1:HP=HP+1
1480  IF HP=HM+1 THEN HP=1:VP=VP+1
1490  IF VP=VM+1 THEN 1590
1500  IF MC=0 THEN 1460
1510  HG=HP*2:VG=VP
1520  HE=HG+1
1530  IF MC=1 THEN MC=C1:GOTO 1560
1540  IF MC=2 THEN MC=C2:GOTO 1560
1550  IF MC=3 THEN MC=C3:GOTO 1560
1560  COLOR 1,6,MC,0,0
1570  GOSUB 1630
1580  GOTO 1460
1590  REM *** WAIT FOR CR SUB ***
1600  Z=INP(2)
1610  IF Z <> 13 THEN GOTO 1600
1620  RETURN
1630  REM *** DRAW LINE ***
1640  POKE CONTRL,6
1650  POKE CONTRL+2,2
1660  POKE CONTRL+6,0
1670  POKE PTSIN,HG
1680  POKE PTSIN+2,VG+24
1690  POKE PTSIN+4,HE
1700  POKE PTSIN+6,VG+24
1710  VDISYS(0)
1720  RETURN
1730  REM *** CONVERT TO 7800 ***
1740  A=0:BS=HM/4:C=1:D=64:S=HM*VM:X$="":L=1
1750  FOR F=1 TO VM
1760  FOR G=1 TO BS
1770  FOR H=1 TO 4
1780  E=B(C)*D
1790  A=A+E
1800  C=C+1
1810  D=D/4
1820  NEXT H
1830  D=64
1840  REM *** SETUP HEX ***
1850  J=INT(A/16):H$=""
1860  S=A-(J*16)
1870  H=J
1880  GOSUB 2010
1890  T$=H$
1900  H=S
1910  GOSUB 2010
1920  H$=T$+H$
1930  X$=X$+H$:A=0
1940  NEXT G
1950  LPRINT X$
1960  IF L=16 THEN LPRINT:L=0
1970  L=L+1
1980  X$=""
1990  NEXT F
2000  RETURN
2010  REM *** HEX CONVERSION ***
2020  IF H<10 THEN H$=STR$(H):H$=MID$(H$,2,1)
2030  IF H=10 THEN H$="A"
2040  IF H=11 THEN H$="B"
2050  IF H=12 THEN H$="C"
2060  IF H=13 THEN H$="D"
2070  IF H=14 THEN H$="E"
2080  IF H=15 THEN H$="F"
2090  RETURN
