OSS ASCII-ATASCII Text File Converter Copyrigth (C) 1986 by OSS, Inc. and Christopher M. Kelley#
Taken from the OSS Newsletter-Fall 1986:
Christopher M. Kelley wrote a program, which converts ASCII to ATASCII and vice versa.
ATR-Image#
Source Code#
1000 ;LIST#D:CONVERT.M65
1010 ;
1020 ;
1030 ;
1040 ;ASM,,#D:CONVERT.COM
1050 ;
1060 ; ===========================
1070 ; ASCII - ATASCII Converter
1080 ; by: Christopher M. Kelley
1090 ; for: OSS, Inc. Newsletter
100 ; ===========================
110 ;
120 .OPT NO LIST
130 ;
140 ;Labels
150 ;
160 DOSVEC = $0A
170 LMARGN = $52
180 SAVLOC = $CB
190 INVFLG = $02B6
1200 SHFLOK = $02BE
1210 ICCOM = $0342
1220 ICBAL = $0344
1230 ICBAH = $0345
1240 ICBLL = $0348
1250 ICBLH = $0349
1260 ICAX1 = $034A
1270 CIOV = $E456
1280 ;
1290 ;Start
1300 ;
1310 *= $4000
1320 BEGIN
1330 JMP START
1340 ;
1350 ;Text
1360 ;
1370 TEXT
1380 .BYTE $7D,$9B," ASCII/ATASCII Text File Converter",$9B
1390 .BYTE " (c)1986 Christopher M. Kelley and
OSS.",$9B,$9B,$9B,$9B
1400 .BYTE $7F,"Conversion Type:",$9B
1410 .BYTE $7F," [1]ASCII To ATASCII",$9B
1420 .BYTE $7F," [2]ATASCII To ASCII",$9B
1430 .BYTE $7F," [Q]Quit",$9B,$9B,$9B
1440 ;
1450 QUSTN
1460 .BYTE $1C,$9C,$7F,"Please Choose:",$00
1470 ;
1480 RETURN
1490 .BYTE $9B,$9B,$00
1500 ;
1510 INFILE
1520 .BYTE $1C,$9C," File To Convert:",$00
1530 ;
1540 OUTFILE
1550 .BYTE $1C,$9C," Output File:",$00
1560 ;
1570 DONE
1580 .BYTE $9B,$9B,$7F,"DONE! - [RETURN] To Continue",$00 $
1590 ;
1600 ERR
1610 .BYTE $7F,"ERROR - [RETURN] To Retry",$00
1620 ;
1630 EDIT
1640 .BYTE "E:"
1650 ;
1660 INNAME
1670 .BYTE "D: "
1680 ;
1690 OUTNAME
1700 .BYTE "D: "
1710 ;
1720 ANSWER
1730 .BYTE $00,$00
1740 ;
1750 FLAG
1760 .BYTE $00,$00,$00
1770 ;
1780 TLEN
1790 .BYTE $00
1800 ;
1810 ATRET
1820 .BYTE $9B
1830 ;
1840 ASCRET
1850 .BYTE $0D,$0A
1860 ;
1870 SAVLM
1880 .BYTE $00
1890 ;
1900 ;Open Channel 1 To E:
1910 ;
1920 START
1930 LDA LMARGN ;SAVE ORIGINAL
1940 STA SAVLM ;LEFT MARGIN
1950 LDA #$00
1960 STA LMARGN
1970 ;
1980 LDX #$10 ;CHANNEL 1
1990 LDA #$0C ;CLOSE
2000 STA ICCOM,X ;JUST IN CASE
2010 JSR CIOV
2020 ;
2030 LDX #$10 ;CHANNEL 1
2040 LDA #$03 ;OPEN
2050 STA ICCOM,X ;EDITOR
2060 LDA # <EDIT
2070 STA ICBAL,X
2080 LDA # >EDIT
2090 STA ICBAH,X
2100 LDA #$0C ;READ,WRITE
2110 STA ICAX1,X
2120 JSR CIOV ;DO IT
2130 ;
2140 ;Print Text
2150 ;
2160 PRG
2170 LDA # <TEXT ;HOLD ADDR OF
2180 STA SAVLOC ;TEXT FOR USE
2190 LDA # >TEXT
2200 STA SAVLOC+1
2210 JSR PRNTIC1
2220 ;
2230 ;Get Answer
2240 ;
2250 GETNUM
2260 LDA # <ANSWER ;HOLD ADDR OF
2270 STA SAVLOC ;ANSWER FOR USE
2280 LDA # >ANSWER
2290 STA SAVLOC+1
2300 LDA #$02 ;ANSWER LENGTH
2310 STA TLEN
2320 JSR GETIC1
2330 ;
2340 LDA ANSWER ;FIND OUT WHAT
2350 CMP #$31 ;ANSWER WAS
2360 BNE TRY2 ;NOT 1
2370 LDA #$00 ;IT IS 1
2380 STA FLAG ;SET FLAG FOR
2390 JMP CONVRT ;ASCII - ATASCII
2400 LDA #$40 ;SET UP CAPS
2410 STA SHFLOK
2420 ;
2430 TRY2
2440 CMP #$32
2450 BNE TRYQ ;NOT 2
2460 LDA #$01 ;IT IS 2
2470 STA FLAG ;SET FLAG FOR
2480 JMP CONVRT ;ATASCII - ASCII
2490 ;
2500 TRYQ
2510 CMP #$51
2520 BNE TRYAGN ;NOT Q
2530 LDA SAVLM ;RESTORE LEFT
2540 STA LMARGN ;MARGIN
2550 JMP (DOSVEC) ;BACK TO DOS
2560 ;
2570 TRYAGN
2580 LDA # <QUSTN ;REPRINT JUST
2590 STA SAVLOC ;THE QUESTION
2600 LDA # >QUSTN
2610 STA SAVLOC+1
2620 JSR PRNTIC1 ;PRINT IT
2630 JMP GETNUM ;TRY AGAIN
2640 ;
2650 ;Print Routine
2660 ;
2670 PRNTIC1
2680 LDY #$00
2690 LDA (SAVLOC),Y ;$00=TEXT END
2700 CMP #$00 ;SAVLOC=ADDR OF
2710 BEQ ENDPRNT ;TEXT
2720 LDX #$10 ;CHANEL 1
2730 LDA #$0B ;PUT BINARY REC
2740 STA ICCOM,X
2750 LDA SAVLOC ;TEXT ADDR
2760 STA ICBAL,X
2770 LDA SAVLOC+1
2780 STA ICBAH,X
2790 LDA #$01 ;1 CHAR ONLY
2800 STA ICBLL,X
2810 LDA #$00
2820 STA ICBLH,X
2830 JSR CIOV ;DO IT
2840 INC SAVLOC ;NEXT CHAR
2850 BNE PRNTIC1
2860 INC SAVLOC+1
2870 JMP PRNTIC1 ;DO IT AGAIN
2880 ENDPRNT
2890 RTS
2900 ;
2910 ;Get Answer
2920 ;
2930 GETIC1
2940 LDA #$00 ;SET NO INVERSE
2950 STA INVFLG
2960 LDX #$10 ;CHANNEL 1
2970 LDA #$05 ;GET TEXT REC
2980 STA ICCOM,X
2990 LDA SAVLOC ;BUFFER ADDR
3000 STA ICBAL,X
3010 LDA SAVLOC+1
3020 STA ICBAH,X
3030 LDA TLEN ;GET LENGTH
3040 STA ICBLL,X
3050 LDA #$00
3060 STA ICBLH,X
3070 JSR CIOV ;DO IT
3080 RTS
3090 ;
3100 ;Get Filenames
3110 ;
3120 CONVRT
3130 LDA # <RETURN ;HOLD ADDR OF
3140 STA SAVLOC ;TEXT FOR USE
3150 LDA # >RETURN
3160 STA SAVLOC+1
3170 JSR PRNTIC1
3180 ;
3190 GETIN
3200 LDA # <INFILE ;PRINT SOME
3210 STA SAVLOC ;MORE TEXT
3220 LDA # >INFILE
3230 STA SAVLOC+1
3240 JSR PRNTIC1
3250 ;
3260 LDA #$00
3270 TAX
3280 ;
3290 CLRIN
3300 STA INNAME+2,X
3310 INX
3320 CPX #$0F
3330 BNE CLRIN
3340 ;
3350 LDA # <INNAME+2 ;GET
3360 STA SAVLOC ;FILE TO CONVERT
3370 LDA # >INNAME+2
3380 STA SAVLOC+1
3390 LDA #$0F ;TEXT LENGTH
3400 STA TLEN
3410 JSR GETIC1
3420 ;
3430 LDA INNAME+3 ;FIND COLON
3440 CMP #$3A
3450 BNE TRYNXT
3460 LDA #$00 ;FOUND IT, SET
3470 STA FLAG+1 ;FLAG
3480 JMP OPENIN
3490 ;
3500 TRYNXT
3510 LDA INNAME+4 ;TRY AGAIN FOR
3520 CMP #$3A ;COLON
3530 BNE NOTHERE
3540 LDA #$00 ;FOUNT IT, SET
3550 STA FLAG+1 ;FLAG
3560 JMP OPENIN
3570 ;
3580 NOTHERE
3590 LDA #$01 ;IT'S NOT HERE
3600 STA FLAG+1 ;SET FLAG
3610 ;
3620 OPENIN
3630 LDX #$20 ;CHANNEL 2
3640 LDA #$0C ;CLOSE - JUST
3650 STA ICCOM,X ;IN CASE
3660 JSR CIOV
3670 ;
3680 LDX #$20 ;CHANNEL 2
3690 LDA #$03 ;OPEN
3700 STA ICCOM,X
3710 LDA FLAG+1 ;CHECK FLAG
3720 CMP #$00
3730 BNE NOTSET
3740 LDA # <INNAME+2 ;FILENAME
3750 STA ICBAL,X ;ADDR
3760 LDA # >INNAME+2
3770 STA ICBAH,X
3780 JMP CONT
3790 ;
3800 NOTSET
3810 LDA # <INNAME ;FILENAME ADDR
3820 STA ICBAL,X
3830 LDA # >INNAME
3840 STA ICBAH,X
3850 ;
3860 CONT
3870 LDA #$04 ;READ FILE
3880 STA ICAX1,X
3890 JSR CIOV
3900 BPL GETOUT ;IT WORKED
3910 JMP GETIN ;FAILED - RETRY
3920 ;
3930 GETOUT
3940 LDA # <RETURN ;HOLD ADDR OF
3950 STA SAVLOC ;TEXT FOR USE
3960 LDA # >RETURN
3970 STA SAVLOC+1
3980 JSR PRNTIC1
3990 ;
4000 GETOUT1
4010 LDA # <OUTFILE ;PRINT SOME
4020 STA SAVLOC ;MORE TEXT
4030 LDA # >OUTFILE
4040 STA SAVLOC+1
4050 JSR PRNTIC1
4060 ;
4070 LDA #$00
4080 TAX
4090 ;
4100 CLROUT
4110 STA OUTNAME+2,X
4120 INX
4130 CPX #$10
4140 BNE CLROUT
4150 ;
4160 LDA # <OUTNAME+2 ;GET
4170 STA SAVLOC ;FILE TO CONVERT
4180 LDA # >OUTNAME+2
4190 STA SAVLOC+1
4200 LDA #$0F ;TEXT LENGTH
4210 STA TLEN
4220 JSR GETIC1
4230 ;
4240 LDA OUTNAME+3 ;FIND COLON
4250 CMP #$3A
4260 BNE TRYNXT1
4270 LDA #$00 ;FOUND IT, SET
4280 STA FLAG+2 ;FLAG
4290 JMP OPENOUT
4300 ;
4310 TRYNXT1
4320 LDA OUTNAME+4 ;TRY AGAIN FOR
4330 CMP #$3A ;COLON
4340 BNE NOTHERE1
4350 LDA #$00 ;FOUNT IT, SET
4360 STA FLAG+2 ;FLAG
4370 JMP OPENOUT
4380 ;
4390 NOTHERE1
4400 LDA #$01 ;IT'S NOT HERE
4410 STA FLAG+2 ;SET FLAG
4420 ;
4430 OPENOUT
4440 LDX #$30 ;CHANNEL 3
4450 LDA #$0C ;CLOSE - JUST
4460 STA ICCOM,X ;IN CASE
4470 JSR CIOV
4480 ;
4490 LDX #$30 ;CHANNEL 2
4500 LDA #$03 ;OPEN
4510 STA ICCOM,X
4520 LDA FLAG+2 ;CHECK FLAG
4530 CMP #$00
4540 BNE NOTSET1
4550 LDA # <OUTNAME+2 ;FILENAME
4560 STA ICBAL,X ;ADDR
4570 LDA # >OUTNAME+2
4580 STA ICBAH,X
4590 JMP CONT1
4600 ;
4610 NOTSET1
4620 LDA # <OUTNAME ;FILENAME
4630 STA ICBAL,X ;ADDR
4640 LDA # >OUTNAME
4650 STA ICBAH,X
4660 ;
4670 CONT1
4680 LDA #$08 ;WRITE FILE
4690 STA ICAX1,X
4700 JSR CIOV
4710 BPL DOIT
4720 JMP GETOUT1
4730 ;
4740 ;Do Conversion
4750 ;
4760 DOIT
4770 LDA FLAG ;FIND OUT WHICH
4780 CMP #$00 ;CONVERSION
4790 BEQ ASCAT
4800 JMP ATASC
4810 ;
4820 ASCAT
4830 LDA # <ANSWER ;STORE ADDR
4840 STA SAVLOC
4850 LDA # >ANSWER
4860 STA SAVLOC+1
4870 JSR GETIC2
4880 BPL GETCHAR
4890 JMP END
4900 ;
4910 GETCHAR
4920 LDA ANSWER ;IS IT CTRL-M?
4930 CMP #$0D
4940 BEQ GOTIT ;YES, REPLACE IT
4950 LDA # <ANSWER ;NO, PUT CHAR
4960 STA SAVLOC ;BACK
4970 LDA # >ANSWER
4980 STA SAVLOC+1
4990 LDA #$01
5000 STA TLEN
5010 JSR PUTIC3
5020 BPL ASCAT
5030 JMP ERROR
5040 ;
5050 GOTIT
5060 LDA # <ANSWER ;YES, GET
5070 STA SAVLOC ;SECOND PART
5080 LDA # >ANSWER
5090 STA SAVLOC+1
5100 JSR GETIC2
5110 ;
5120 LDA # <ATRET ;PUT ATASCII
5130 STA SAVLOC ;C/R TO OUTPUT
5140 LDA # >ATRET
5150 STA SAVLOC+1
5160 LDA #$01
5170 STA TLEN
5180 JSR PUTIC3
5190 BPL ASCAT
5200 JMP ERROR
5210 ;
5220 GETIC2
5230 LDX #$20 ;CHANNEL #2
5240 LDA #$07 ;GET BINARY REC
5250 STA ICCOM,X
5260 LDA SAVLOC ;BUFFER ADDR
5270 STA ICBAL,X
5280 LDA SAVLOC+1
5290 STA ICBAH,X
5300 LDA #$01 ;LENGTH = 1
5310 STA ICBLL,X
5320 LDA #$00
5330 STA ICBLH,X
5340 JSR CIOV
5350 RTS
5360 ;
5370 PUTIC3
5380 LDX #$30 ;CHANNEL #3
5390 LDA #$0B ;PUT BINARY REC
5400 STA ICCOM,X
5410 LDA SAVLOC ;TEXT ADDR
5420 STA ICBAL,X
5430 LDA SAVLOC+1
5440 STA ICBAH,X
5450 LDA TLEN ;TEXT LENGTH
5460 STA ICBLL,X
5470 LDA #$00
5480 STA ICBLH,X
5490 JSR CIOV
5500 RTS
5510 ;
5520 ATASC
5530 LDA # <ANSWER ;STORE ADDR
5540 STA SAVLOC
5550 LDA # >ANSWER
5560 STA SAVLOC+1
5570 JSR GETIC2
5580 BPL GETCHAR1
5590 JMP END
5600 ;
5610 GETCHAR1
5620 LDA ANSWER
5630 CMP #$9B ;IS IT C/R?
5640 BEQ GOTIT1 ;YES, REPLACE IT
5650 LDA # <ANSWER ;NO, PUT IT
5660 STA SAVLOC ;BACK
5670 LDA # >ANSWER
5680 STA SAVLOC+1
5690 LDA #$01
5700 STA TLEN
5710 JSR PUTIC3
5720 BPL ATASC
5730 JMP ERROR
5740 ;
5750 GOTIT1
5760 LDA # <ASCRET ;PUT ASCII
5770 STA SAVLOC ;C/R,LF PAIR IN
5780 LDA # >ASCRET
5790 STA SAVLOC+1
5800 LDA #$02
5810 STA TLEN
5820 JSR PUTIC3
5830 BPL ATASC
5840 JMP ERROR
5850 ;
5860 ;End Of Run
5870 ;
5880 END
5890 LDX #$20 ;CHANNEL 2
5900 LDA #$0C ;CLOSE
5910 STA ICCOM,X
5920 JSR CIOV
5930 ;
5940 LDX #$30 ;CHANNEL 3
5950 LDA #$0C ;CLOSE
5960 STA ICCOM,X
5970 JSR CIOV
5980 ;
5990 LDA # <DONE ;LET USER KNOW
6000 STA SAVLOC
6010 LDA # >DONE
6020 STA SAVLOC+1
6030 JSR PRNTIC1
6040 ;
6050 LDA # <ANSWER ;GET C/R
6060 STA SAVLOC
6070 LDA # >ANSWER
6080 STA SAVLOC+1
6090 LDA #$02
6100 STA TLEN
6110 JSR GETIC1
6120 ;
6130 JMP PRG
6140 ;
6150 ERROR
6160 LDX #$20 ;CHANNEL 2
6170 LDA #$0C ;CLOSE
6180 STA ICCOM,X
6190 JSR CIOV
6200 ;
6210 LDA #$30 ;CHANNEL 3
6220 LDA #$0C ;CLOSE
6230 STA ICCOM,X
6240 JSR CIOV
6250 ;
6260 LDA # <ERR ;THERE'S A PROB
6270 STA SAVLOC
6280 LDA # >ERR
6290 STA SAVLOC+1
6300 JSR PRNTIC1
6310 ;
6320 LDA # <ANSWER ;GET C/R
6330 STA SAVLOC
6340 LDA # >ANSWER
6350 STA SAVLOC+1
6360 LDA #$02
6370 STA TLEN
6380 JSR GETIC1
6390 ;
6400 JMP PRG
6410 ;
6420 ;End Of Program
6430 ;
6440 *= $02E0
6450 .WORD BEGIN
6460 ;
6470 .END