10 REM TXTCONV 20 REM Add text file to dictionary 30 REM For B/B+/E/M/C (with discs) 40 REM by Alan Blundell 50 REM (c) 1989 60 : 70 PROCinit 80 REPEAT 90 PROCaddword(FNreadword) 100 UNTIL eof% 110 PROCfinish 120 CHAIN "Spell" 130 : 140 DEFPROCinit 150 DIM wordbuf% 100 160 maxunits%=28 170 DIM dictbuf% maxunits%*256 180 DIM index% 211 190 DIM block% 12 200 osgbpb=&FFD1 210 PROCasm 220 ON ERROR CLOSE #0:PRINT''':REPORT:PRINT:END 230 in%=OPENIN("DictTxt") 240 IF in%=0 PRINT '"No DictTxt file !":END 250 eof%=FALSE 260 out%=OPENUP("Diction") 270 IF out%=0 PRINT '''"No dictionary!":END 280 PROCgbpb(3,out%,index%,212,0) 290 oldletter%=-1 300 CLS 310 PRINT "Adding words in 'DictTxt' to dictionary" 320 PRINT "Words starting with ' ' being added"; 330 ENDPROC 340 : 350 DEFFNreadword 360 LOCAL char%,word$ 370 REPEAT 380 char%=(BGET #in%) AND 223 390 UNTIL (char%>64 AND char%<91) OR EOF #in% 400 IF EOF #in% eof%=TRUE : = "" 410 word$=CHR$(char%) 420 REPEAT 430 char%=(BGET #in%) AND 223 440 IF (char%>64 AND char%<91) word$=word$+CHR$(char%) 450 UNTIL char%<65 OR char%>90 OR EOF #in% 460 IF EOF #in% eof%=TRUE 470 wordcount%=wordcount%+1 480 PRINT TAB(21,1) LEFT$(word$,1) 490 =word$ 500 : 510 DEFPROCaddword(word$) 520 letter%=ASC(word$)-65 530 word$=RIGHT$(word$,LEN(word$)-1) 540 IF letter%<>oldletter% PROCchangedict 550 length%=LEN(word$)+1 560 IF length%>(dictsize%-dictlen%) PRINT "Not enough room - word not added!":ENDPROC 570 IF FNfindword(dictbuf%,dicttop%,word$) ENDPROC 580 dictptr%=!buffptr% 590 IF dicttop%=dictptr% GOTO 640 600 !source%=dictptr% 610 !dest%=dictptr%+length% 620 !len%=dicttop%-dictptr% 630 CALL move 640 dicttop%=dicttop%+length% 650 $dictptr%=word$ 660 dictlen%=dictlen%+length% 670 index%!(letter%*8+4)=dictlen% 680 ENDPROC 690 : 700 DEFPROCfinish 710 CLOSE #in% 720 PROCsavedict 730 PROCgbpb(1,out%,index%,212,0) 740 CLOSE #out% 750 ENDPROC 760 : 770 DEFPROCchangedict 780 PROCsavedict 790 PROCloaddict(letter%) 800 oldletter%=letter% 810 ENDPROC 820 : 830 DEFPROCloaddict(letter%) 840 A%=3 850 fileptr%=index%!(letter%*8) 860 dictsize%=index%!((letter%+1)*8)-fileptr% 870 dictlen%=index%!(letter%*8+4) 880 dicttop%=dictbuf%+dictlen% 890 PROCgbpb(A%,out%,dictbuf%,dictsize%,fileptr%) 900 ENDPROC 910 : 920 DEFPROCsavedict 930 IF oldletter%=-1 ENDPROC 940 A%=1 950 PROCgbpb(A%,out%,dictbuf%,dictsize%,fileptr%) 960 ENDPROC 970 : 980 DEFPROCasm 990 DIM code% &B0 1000 source%=&70 1010 dest%=&72 1020 len%=&74 1030 buffptr%=&70 1040 buffend%=&74 1050 searchptr%=&76 1060 result%=&78 1070 temp%=&78 1080 FOR pass = 0 TO 2 STEP 2 1090 P%=code% 1100 [ 1110 OPT pass 1120 .move 1130 \-------- 1140 SEC 1150 LDA dest% 1160 SBC source% 1170 TAX 1180 LDA dest%+1 1190 SBC source%+1 1200 TAY 1210 TXA 1220 CMP len% 1230 TYA 1240 SBC len%+1 1250 BCS moveleft 1260 BCC moveright 1270 .moveleft 1280 LDY #0 1290 LDX len%+1 1300 BEQ mlskip 1310 .mlloop 1320 LDA (source%),Y 1330 STA (dest%),Y 1340 INY 1350 BNE mlloop 1360 INC source%+1 1370 INC dest%+1 1380 DEX 1390 BNE mlloop 1400 .mlskip 1410 LDX len% 1420 BEQ moveout 1430 .mlloop2 1440 LDA (source%),Y 1450 STA (dest%),Y 1460 INY 1470 DEX 1480 BNE mlloop2 1490 .moveout 1500 RTS 1510 1520 .moveright 1530 CLC 1540 LDA len%+1 1550 PHA 1560 ADC source%+1 1570 STA source%+1 1580 CLC 1590 PLA 1600 ADC dest%+1 1610 STA dest%+1 1620 LDY len% 1630 BEQ mrskip 1640 .mrloop 1650 DEY 1660 LDA (source%),Y 1670 STA (dest%),Y 1680 CPY #0 1690 BNE mrloop 1700 .mrskip 1710 LDX len%+1 1720 BEQ moveout 1730 .mrloop2 1740 DEC source%+1 1750 DEC dest%+1 1760 .mrloop3 1770 DEY 1780 LDA (source%),Y 1790 STA (dest%),Y 1800 CPY #0 1810 BNE mrloop3 1820 DEX 1830 BNE mrloop2 1840 RTS 1850 \ 1860 .search 1870 LDY #255 1880 .sloop 1890 INY 1900 LDA (buffptr%),Y 1910 CMP #13 1920 BEQ foundword 1930 CMP (searchptr%),Y 1940 BEQ sloop 1950 BCC nextword 1960 .notfound 1970 LDY #0 1980 STY result% 1990 RTS 2000 .foundword 2010 LDA (searchptr%),Y 2020 CMP #13 2030 BNE incptr 2040 LDY #1 2050 STY result% 2060 RTS 2070 .nextword 2080 INY 2090 LDA (buffptr%),Y 2100 CMP #13 2110 BNE nextword 2120 .incptr 2130 INY 2140 STY temp% 2150 LDY #255 2160 CLC 2170 LDA buffptr% 2180 ADC temp% 2190 STA buffptr% 2200 LDA buffptr%+1 2210 ADC #0 2220 STA buffptr%+1 2230 CMP buffend%+1 2240 BCC sloop 2250 LDA buffptr% 2260 CMP buffend% 2270 BCC sloop 2280 JMP notfound 2290 ] 2300 NEXT 2310 ENDPROC 2320 : 2330 DEFFNfindword(buf%,top%,word$) 2340 IF buf%=top% !buffptr%=buf%:=0 2350 !buffptr%=buf% 2360 !buffend%=top% 2370 !searchptr%=wordbuf% 2380 $wordbuf%=word$ 2390 CALL search 2400 =?result% 2410 : 2420 DEFFNgetkey 2430 LOCAL key% 2440 PROCcursor(1) 2450 *FX 21 0 2460 key%=GET 2470 PROCcursor(0) 2480 =CHR$(key% AND 223) 2490 : 2500 DEFPROCcursor(on%) 2510 VDU 23,1,on%;0;0;0; 2520 ENDPROC 2530 : 2540 DEFPROCgbpb(A%,out%,address%,size%,fileptr%) 2550 X%=block% MOD 256 2560 Y%=block% DIV 256 2570 block%?0=out% 2580 block%!1=address% 2590 block%!5=size% 2600 block%!9=fileptr% 2610 CALL osgbpb 2620 ENDPROC