home *** CD-ROM | disk | FTP | other *** search
Text File | 2019-04-13 | 22.8 KB | 1,597 lines |
- UNBCODE = *
- ;** OPEN FILE
- LDA NAME+0
- LDY NAME+1
- STA ZP+0
- STY ZP+1
- LDA #"R"
- JSR OPEN
- BCC +
- RTS
- + STA INFILE
- ;** DECODE FILE
- JSR UNBCODE┬ODY
- ;** CLOSE FILE
- LDA INFILE
- JSR CLOSE
- RTS
-
- UNBCODE┬ODY = *
- LDA #0
- STA BUF├OUNT+0
- STA BUF├OUNT+1
- STA HIT╠AST╠INE
- STA LAST╠INE╘ERMINATOR
-
- ;** SEARCH FOR "BEGIN" LINE
- SEARCH╠INE = *
- JSR GETLINE
- BCC +
- CLC
- RTS
- + LDA IN╠INE
- CMP #"-"
- BNE SEARCH╠INE
- JSR CHECK╙TOP
- LDX #0
- LDA IN╠INE+2
- CMP #"B"
- BEQ +
- LDX #ASCII┬EGIN-PETSCII┬EGIN
- + LDY #0
- - LDA IN╠INE,Y
- CMP PETSCII┬EGIN,X
- BNE SEARCH╠INE
- INX
- INY
- CPY #ASCII┬EGIN-PETSCII┬EGIN
- BCC -
- LDY #0
- CPX #ASCII┬EGIN-PETSCII┬EGIN+1
- BCC +
- LDY #$FF
- + STY ASCII╞ILE
- JMP PROCESS┬EGIN
-
- PETSCII┬EGIN = *
- .ASC "--BCODE-BEGIN "
- ASCII┬EGIN = *
- .BYTE $2D,$2D,$62,$63,$6F,$64,$65,$2D,$62,$65,$67,$69,$6E,$20
-
- ;** PROCESS "BEGIN" LINE
- PROCESS┬EGIN = *
- ;** EXTRACT THE SEGMENT NUMBER
- LDY #14
- JSR SCAN╬UM
- BCC +
- JMP BEGIN┼RROR
- + INY
- LDA SCAN╓AL+2
- ORA SCAN╓AL+3
- BEQ +
- LDA #<SEG╘OO┬IG═SG
- LDY #>SEG╘OO┬IG═SG
- JSR EPUTS
- JMP SEARCH╠INE
- + LDA SCAN╓AL+0
- LDX SCAN╓AL+1
- STA SEGNUM+0
- STX SEGNUM+1
- LDA #0
- STA SEGNUM+2
- STA SEGNUM+3
- LDA SEGNUM+0
- ORA SEGNUM+1
- BNE +
- JMP BEGIN┼RROR
-
- ;** EXTRACT FILENAME, TRUNC TO 16 CHARS
- + CLC
- TYA
- ADC #<IN╠INE
- STA OUT╬AME+0
- LDA #>IN╠INE
- ADC #0
- STA OUT╬AME+1
- LDY #16
- LDA #0
- STA (OUT╬AME),Y
- JSR MAKE╨ETSCII╬AME
- JSR ECHO┼XTRACT╬AME
-
- ;** OPEN OUTPUT FILE
- JSR GET╘EMP╞ILE
- BCC +
- JMP SEARCH╠INE
-
- ;** READ BCODED DATA
- + JSR BUILD─ECODE╘ABLE
- JSR CRC╔NIT
- - JSR GETLINE
- BCS UNEXPECTED┼OF
- JSR CONVERT╠INE
- BCC +
- ;** CHECK IF SEGMENT-END LINE
- LDA IN╠INE
- CMP #"-"
- BEQ FINISH╞ILE
- ;** REPORT INVALID CHARACTERS
- LDA #<BAD├HARS═SG
- LDY #>BAD├HARS═SG
- JSR EPUTS
- JMP -
- + JSR CRUNCH╠INE
- JSR CRC╠INE
- JSR WRITE╠INE
- JMP -
-
- ;** FINISH WITH FILE
- FINISH╞ILE = *
- LDA OUTFILE
- JSR CLOSE
- JSR CRC╞INISH
- JSR PROCESS╞INISH
- ;** PROCESS FOR ANOTHER FILE
- JMP SEARCH╠INE
-
- UNEXPECTED┼OF = *
- LDA #<UNEX┼OF═SG
- LDY #>UNEX┼OF═SG
- JSR EPUTS
- LDA OUTFILE
- JSR CLOSE
- JSR DISCARD╙EGMENT
- SEC
- RTS
-
- UNEX┼OF═SG = *
- .ASC "UNEXPECTED ┼╧╞, IGNORING SEGMENT."
- .BYTE CHR├╥,0
-
- SEG╘OO┬IG═SG = *
- .ASC "SEGMENT NUMBER IS LARGER THAN 65535, IGNORING SEGMENT."
- .BYTE CHR├╥,0
-
- BAD├HARS═SG = *
- .ASC "WARNING: BAD CHARACTERS ON LINE, IGNORING LINE."
- .BYTE CHR├╥,0
-
- MAKE╨ETSCII╬AME = *
- BIT ASCII╞ILE
- BMI +
- RTS
- + LDY #0
- - LDA (OUT╬AME),Y
- BEQ +
- JSR CONV┴SC2╨ET
- STA (OUT╬AME),Y
- INY
- BNE -
- + RTS
-
- CONV┴SC2╨ET = *
- AND #$7F
- CMP #$60
- BCC +
- CLC
- ADC #$C0-$60
- + TAX
- AND #$7F
- CMP #"A"
- BCS +
- - TXA
- RTS
- + CMP #"Z"+1
- BCS -
- TXA
- EOR #$80
- RTS
-
- ECHO┼XTRACT╬AME = *
- LDA #<ECHO┼XTRACT═SG1
- LDY #>ECHO┼XTRACT═SG1
- JSR EPUTS
- LDA #<NUMBUF
- LDY #>NUMBUF
- STA ZP+0
- STY ZP+1
- LDA #1
- LDX #SEGNUM
- JSR UTOA
- LDA #<NUMBUF
- LDY #>NUMBUF
- JSR EPUTS
- LDA #<ECHO┼XTRACT═SG2
- LDY #>ECHO┼XTRACT═SG2
- JSR EPUTS
- LDA OUT╬AME+0
- LDY OUT╬AME+1
- JSR EPUTS
- LDA #<ECHO┼XTRACT═SG3
- LDY #>ECHO┼XTRACT═SG3
- JMP EPUTS
-
- ECHO┼XTRACT═SG1 = *
- .ASC "EXTRACTING SEG "
- .BYTE 0
- ECHO┼XTRACT═SG2 = *
- .ASC " OF "
- .BYTE CHR╤UOTE,0
- ECHO┼XTRACT═SG3 = *
- .BYTE CHR╤UOTE,CHR├╥,0
- NUMBUF .BUF 12
-
- REPORT╧PEN┼RROR = *
- LDA ZP+0
- LDY ZP+1
- JSR EPUTS
- LDA #<REPORT╧PEN┼RROR═SG
- LDY #>REPORT╧PEN┼RROR═SG
- JSR EPUTS
- RTS
-
- REPORT╧PEN┼RROR═SG = *
- .ASC ": CANNOT OPEN, CONTINUING"
- .BYTE CHR├╥,0
-
- SCAN─IGIT .BUF 1
- SCAN╙AVE .BUF 4
- SCAN╘EMP .BUF 1
- SCAN╔NDEX .BUF 1
- SCAN┴NYTHING .BUF 1
-
- SCAN╬UM = * ;( .┘=IN╠INE╔NDEX ) : .┘=SCAN, [SCAN╓AL]=NUM, .├╙=ERR
- LDX #3
- LDA #0
- - STA SCAN╓AL,X
- DEX
- BPL -
- LDA #0
- STA SCAN┴NYTHING
- - LDA IN╠INE,Y
- CMP #" "
- BNE SCAN╬UM╬EXT
- INY
- BNE -
- SEC
- RTS
-
- SCAN╬UM╬EXT = *
- LDA IN╠INE,Y
- CMP #"0"
- BCC +
- CMP #"9"+1
- BCC ++
- + LDA SCAN┴NYTHING
- BEQ SCAN┼RROR
- CLC
- RTS
- + AND #$0F
- STA SCAN─IGIT
- LDA #$FF
- STA SCAN┴NYTHING
- ;** TIMES TEN
- STY SCAN╘EMP
- LDX #3
- - LDA SCAN╓AL,X
- STA SCAN╙AVE,X
- DEX
- BPL -
- LDA #2
- STA SCAN╔NDEX
- - CLC
- LDY #4
- LDX #0
- - ROL SCAN╓AL,X
- INX
- DEY
- BNE -
- BCS SCAN┼RROR
- DEC SCAN╔NDEX
- BNE --
- CLC
- LDY #4
- LDX #0
- - LDA SCAN╓AL,X
- ADC SCAN╙AVE,X
- STA SCAN╓AL,X
- INX
- DEY
- BNE -
- BCS SCAN┼RROR
- CLC
- LDY #4
- LDX #0
- - ROL SCAN╓AL,X
- INX
- DEY
- BNE -
- BCS SCAN┼RROR
- CLC
- LDY #4
- LDX #0
- LDA SCAN─IGIT
- - ADC SCAN╓AL,X
- STA SCAN╓AL,X
- LDA #0
- INX
- DEY
- BNE -
- BCS SCAN┼RROR
-
- LDY SCAN╘EMP
- INY
- BEQ SCAN┼RROR
- JMP SCAN╬UM╬EXT
-
- SCAN┼RROR = *
- SEC
- RTS
-
- BEGIN┼RROR = *
- LDA #<BEGIN┼RROR═SG
- LDY #>BEGIN┼RROR═SG
- JSR EPUTS
- JMP SEARCH╠INE
-
- BEGIN┼RROR═SG = *
- .ASC "INVALID --BCODE-BEGIN LINE FORMAT, IGNORING SEGMENT"
- .BYTE CHR├╥,0
-
- CONVERT╨ADS .BUF 1
- CONVERT├HARS .BUF 1
-
- CONVERT╠INE = *
- LDX #0
- STX CONVERT╨ADS
- - LDA IN╠INE,X
- BNE +
- STX CONVERT├HARS
- CLC
- RTS
- + CMP #"="
- BNE +
- INC CONVERT╨ADS
- + TAY
- LDA DECODE╘ABLE,Y
- BMI +
- STA IN╠INE,X
- INX
- BNE -
- + SEC
- RTS
-
- CRUNCH┬YTES .BUF 1
-
- CRUNCH╠INE = *
- LDX #0
- LDY #0
- - JSR CRUNCH╤UANTUM
- CPX CONVERT├HARS
- BCC -
- TYA
- SEC
- SBC CONVERT╨ADS
- STA CRUNCH┬YTES
- RTS
-
- ;POS 76543210 76543210 76543210 76543210
- ;BYT XX111111 XX112222 XX222233 XX333333
- ;BIT 765432 107654 321076 543210
-
- CRUNCH╤UANTUM = * ;(.╪=╔N4BYTES╧FFSET, .┘=╧UT3BYTES╧FFSET) : .╪++, .┘++
- LDA IN╠INE,X ;*** OUTPUT BYTE 0
- ASL
- ASL
- STA TEMP
- INX
- LDA IN╠INE,X
- LSR
- LSR
- LSR
- LSR
- AND #%00000011
- ORA TEMP
- STA IN╠INE,Y
- INY
- LDA IN╠INE,X ;*** OUTPUT BYTE 1
- ASL
- ASL
- ASL
- ASL
- STA TEMP
- INX
- LDA IN╠INE,X
- LSR
- LSR
- AND #%00001111
- ORA TEMP
- STA IN╠INE,Y
- INY
- LDA IN╠INE,X ;*** OUTPUT BYTE 2
- INX
- ROR
- ROR
- ROR
- AND #%11000000
- STA TEMP
- LDA IN╠INE,X
- INX
- AND #%00111111
- ORA TEMP
- STA IN╠INE,Y
- INY
- RTS
-
- WRITE╠INE = *
- LDA #<IN╠INE
- LDY #>IN╠INE
- STA ZP+0
- STY ZP+1
- LDA CRUNCH┬YTES
- LDY #0
- LDX OUTFILE
- JSR WRITE
- RTS
-
- ;** CRC = 0X╞╞╞╞╞╞╞╞;
- ;** WHILE( (C=GETC(FP)) != ┼╧╞ )