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