8-Bit Software Online Conversion
Viewcon utility sourcecode - Listing
10REM Program ViewCon to convert VIEW
files to plain text without carriage re
tuns (unless multiple)
20REM for text submissions to 8bs
30REM derived from VIEWASC
40REM this draft 5/9/1992
50REM by H. L. Clarke
60oscli=&FFF7:OSBYTE=&FFF4:OSWORD=&FF
F1:OSWRCH=&FFEE:OSNEWL=&FFE7:OSASCI=&FFE
3:OSRDCH=&FFE0:OSFILE=&FFDD
70HIMEM=&7000
80ftop=&7700
90FOR pass%=0 TO 3 STEP 3
100P%=&7780
110[OPT pass%
120JMP setup
130JSR blank:JMP load
140JSR blank:JMP savefile
150EQUW 0:EQUS"(C) 1992 - H.L.Clarke":
BRK
160.setup:CLD
170LDA #22:JSR OSWRCH:LDA #7:JSR OSWRC
H
180LDA #&83:JSR OSBYTE½get OSHWM
190STY getad+1:STY putad+1:INC getad+1
½store MSB of addresses for start of old
and new files
200LDA #0:STA getad:LDA #2:STA putad½e
dited file starting @ OSHWM+2 to preserv
e on <BREAK>
210½print header and soft key instruct
ions
220LDX #(header MOD 256):LDY #(header
DIV 256):JSR print
230LDX #&30:JSR skey:LDX #(mkey0 MOD 2
56):LDY #(mkey0 DIV 256):JSR print
240LDX #&31:JSR skey:LDX #(mkey1 MOD 2
56):LDY #(mkey1 DIV 256):JSR print
250LDX #9:LDA #32:JSR repeat:LDX #&32:
JSR skey:LDX #(mkey2 MOD 256):LDY #(mkey
2 DIV 256):JSR print
260JSR OSNEWL:JSR OSNEWL:LDA #60:LDX #
20:JSR repeat:LDA #62:LDX #20:JSR repeat
270LDA #28:JSR OSWRCH½set up text wind
ow
280LDA #0:JSR OSWRCH:LDA #24:JSR OSWRC
H
290LDA #39:JSR OSWRCH:LDA #6:JSR OSWRC
H
300LDA #(ftop MOD 256):SEC:SBC getad:S
TA room
310LDA #(ftop DIV 256):SBC getad+1:STA
room+1
320LDX #(fk0 MOD 256):LDY #(fk0 DIV 25
6):JSR oscli
330LDX #(fk1 MOD 256):LDY #(fk1 DIV 25
6):JSR oscli
340LDX #(fk2 MOD 256):LDY #(fk2 DIV 25
6):JSR oscli
350½
360½
370½
380½
390.load:LDX #(old MOD 256):LDY #(old
DIV 256):JSR print:JSR OSNEWL
400LDX #8:LDA #32:JSR repeat:LDX #(wor
d MOD 256):LDY #(word DIV 256):LDA #0:JS
R OSWORD
410LDA #5:LDX #(file MOD 256):LDY #(fi
le DIV 256):JSR OSFILE½get file length f
rom catalogue
420½
430½
440½
450.checklen:LDA room:CMP startad:LDA
room+1:SBC startad+1:LDA room+2:SBC star
tad+2:LDA room+3:SBC startad+3
460BCC toolong:JMP fload½check file no
t too long for available memory
470.toolong:BRK
480EQUB 129
490EQUS"File too long"
500BRK
510.fload:LDA getad:STA loadad½set up
parameter block for OSFILE
520LDA getad+1:STA loadad+1
530LDA #0:STA exad
540LDA #&FF:LDX #(file MOD 256):LDY #(
file DIV 256):JSR OSFILE½load file
550LDA startad:CLC:ADC getad:STA endad
560LDA startad+1:ADC getad+1:STA endad
+1½identify end of file
570LDA endad:STA &72:LDA endad+1:STA &
73:LDY #0:LDA #0:STA (&72),Y½put zero by
te after end of file
580½
590½
600.edit:LDA #0:STA gety:STA puty:STA
&72:LDA #2:STA &74
610LDA getad+1:STA &73:LDA putad+1:STA
&75
620.editloop:LDY gety:LDA (&72),Y:BEQ
finish:BMI negative½identify ruler & edi
t commands
630CMP #&D:BNE notcr
640JSR addall:JMP editloop
650.notcr:CMP #32:BCC less½identify so
ft spaces, &c
660INY:STY gety
670LDY puty:STA (&74),Y:INY:STY puty
680JMP editloop
690.less:INY:STY gety:JMP editloop
700.negative:CMP #&80:BNE discard
710INY:LDA (&72),Y:CMP #67:BNE discard
720INY:LDA (&72),Y:CMP #69:BNE discard
:INY:STY gety:JMP editloop½Command is CE
730.discard:LDY gety
740.disloop:LDA (&72),Y:CMP #13:BEQ en
druler
750INY:JMP disloop
760.endruler:STY gety:JSR addget:JMP e
ditloop
770.finish:JSR addall
780.savefile:JSR OSNEWL
790LDX #(new MOD 256):LDY #(new DIV 25
6):JSR print
800LDX #8:LDA #32:JSR repeat:LDX #(wor
d MOD 256):LDY #(word DIV 256):LDA #0:JS
R OSWORD
810LDA name:CMP #42:BNE sroutine½check
for '*' as first character
820JSR comd:JMP savefile
830.sroutine:LDA #0:STA loadad:STA loa
dad+1:STA loadad+2:STA loadad+3:STA exad
:STA exad+1:STA exad+2:STA exad+3
840STA startad+2:STA startad+3:STA las
tbyte+2:STA lastbyte+3
850LDA &74:STA lastbyte
860LDA &75:STA lastbyte+1:LDA putad:ST
A startad:LDA putad+1:STA startad+1½set
yp parameter block for OSFILE
870LDA #0:LDX #(file MOD 256):LDY #(fi
le DIV 256):JSR OSFILE½save file
880JSR OSNEWL
890LDX #(mback MOD 256):LDY #(mback DI
V 256):JSR print
900LDX #(mquery MOD 256):LDY #(mquery
DIV 256):JSR print
910LDA #32:LDX #8:JSR OSRDCH
920AND #&5F:CMP #89:BNE final
930JMP savefile
940.final:RTS
950½
960½
970½
980.print:STX &70:STY &71:LDY #0
990.printloop:LDA (&70),Y:BEQ endprint
1000JSR OSASCI:INY:JMP printloop
1010.endprint:RTS
1020½
1030½
1040.blank:LDA #11:JSR OSWRCH:LDA #13:J
SR OSWRCH
1050LDX #10:LDA #32
1060.blankloop:JSR OSWRCH:DEX:BNE blank
loop
1070LDA #&D:JSR OSWRCH:RTS
1080½
1090½
1100.skey:LDA #129:JSR OSWRCH
1110LDA #157:JSR OSWRCH:LDA #135:JSR OS
WRCH
1120LDA #102:JSR OSWRCH
1130TXA:JSR OSWRCH
1140LDA #32:JSR OSWRCH:JSR OSWRCH
1150LDA #156:JSR OSWRCH
1160LDA #32:JSR OSWRCH:RTS
1170½
1180½
1190.addall:STY gety:LDY puty:BEQ mult:
LDA #32:JMP insert
1200.mult:LDA &74:SEC:SBC #1:STA &76
1210LDA &75:SBC #0:STA &77
1220LDA #13:STA (&76),Y
1230.insert:STA (&74),Y:INY:TYA:CLC
1240ADC &74:STA &74
1250LDA #0:STA puty:ADC &75:STA &75
1260.addget:LDY gety:INY:TYA:CLC
1270ADC &72:STA &72
1280LDA #0:STA gety:ADC &73:STA &73
1290RTS
1300½
1310½
1320.comd:LDX #(name MOD 256):LDY #(nam
e DIV 256):JSR oscli:RTS
1330½
1340½
1350.repeat:JSR OSWRCH
1360DEX:BNE repeat
1370RTS
1380½
1390½
1400.word:EQUW name½parameter block for
OSWORD 0
1410EQUB 32½maximum line length
1420EQUB 32½lowest acceptable character
1430EQUB 126½highest acceptable charact
er
1440BRK
1450.file:EQUW name½parameter block for
OSFILE
1460.loadad:EQUD 0
1470.exad:EQUD 0
1480.startad:EQUD 0
1490.lastbyte:EQUD 0½end address + 1
1500BRK
1510BRK
1520.header:EQUB 132:EQUB 157:EQUB 135
1530EQUS"VIEW to text conversion for 8b
s "
1540EQUB 156:EQUB 13:BRK
1550.mkey0:EQUS"Restart ":BRK
1560.mkey1:EQUS"Load/Edit":EQUB 13:BRK
1570.mkey2:EQUS"Save/"
1580.mback:EQUS"Backup":BRK
1590.old:EQUS"Name of file to be conver
ted :":EQUB &D:BRK
1600.new:EQUS"Name of converted file to
be saved":EQUB &D:EQUS"OR * command if
required":EQUB &D:BRK
1610.fk0:EQUS"KEY 0 CALL &7780 |M":EQUB
13
1620.fk1:EQUS"KEY 1 CALL &7783 |M":EQUB
13
1630.fk2:EQUS"KEY 2 CALL &7789 |M":EQUB
13
1640.name:EQUS"
"
1650.mquery:EQUS" ? Y/N":EQUB &0D:BRK
1660.getad:EQUW 0
1670.putad:EQUW 0
1680.gety:BRK
1690.puty:BRK
1700.room:EQUD 0
1710.endad:EQUW 0
1720]
1730NEXT
1740VDU3
1750INPUT"Save ViewCon ? Y/N ",yn$
1760IF LEFT$(yn$,1)="Y" OR LEFT$(yn$,1)
="y" THEN 1770 ELSE END
1770PRINT'"Press Space Bar when ready"
1780IF GET=32 THEN 1790 ELSE 1770
1790*SAVE ViewCon 7780 7C00
1800INPUT"Backup copy ? Y/N ",yn$
1810IF LEFT$(yn$,1)="Y" OR LEFT$(yn$,1)
="y" THEN 1770
1820END