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