home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_24_1988_Transactor_Publishing.d64
/
badcat.a
< prev
next >
Wrap
Text File
|
2023-02-26
|
3KB
|
262 lines
argstk = $033c
sysdev = $17fa
sysdrv = $17fb
wrkdev = $17fc
wrkdrv = $17fd
s2000 = $2000
;
setlfs = $ffba
setnam = $ffbd
open = $ffc0
close = $ffc3
chkin = $ffc6
chkout = $ffc9
clrchn = $ffcc
chrin = $ffcf
chrout = $ffd2
readst = $ffb7
load = $ffd5
getin = $ffe4
;
;
;
; * = $1800 ;; use link -s $1800
;
usrprog = *
jsr clrchn
lda #15
ldx wrkdev
tay
jsr setlfs
lda #3
ldx #<sm$r
ldy #>sm$r
jsr setnam
jsr open
;
lda #0
sta dstnam+2
;
lda argstk+2
sta $4b
lda argstk+3
sta $4c
;
inc argstk ;; goes to zero when done
jsr getarg
bne arglp
jmp usage
;
arglp = *
jsr getarg
beq done
lda ($4d),y
cmp #'-
bne nodash
dashlp iny
lda ($4d),y
beq t0130f
jmp dashlp
t0120f jmp usage
jmp dashlp
t0130f jmp arglp
;
nodash = *
lda dstnam+2
bne sources
jsr opndst
bcc arglp
jmp bad
;
sources = *
jsr opnsrc
bcs bad
jsr tcopy ; copies 3 to 2, closes 3
lda #3
jsr close
jmp arglp
;
done = *
lda dstnam+2
bne okay
;
bad = *
lda #3
jsr close
;
okay = *
lda #2
jsr close
jsr chkchn ; but ignore result
jsr clrchn
lda #15
jmp close ; and return to shell
;
;
;
;
; getarg - put next arg pointer into ($4d,$4e)
; y is set to zero
; argv is incremented
; argc is decremented
;
getarg = *
ldy #1
lda ($4b),y
sta $4e
dey
lda ($4b),y
sta $4d
clc
lda $4b
adc #2
sta $4b
bcc t0200f
inc $4c
t0200f dec argstk
rts
;
;
; opndst - open destination file from current arg
;
opndst = *
lda #2
ldx wrkdev
tay
jsr setlfs
lda wrkdrv
clc
adc #'0
sta dstnam
ldy #0
ldx #2
t0310b lda ($4d),y
sta dstnam,x ;; file name including '\0' is stored
beq t0320f
iny
inx
bne t0310b
t0320f stx dstlen
lda #',
sta dstnam,x
inx
lda #'w
sta dstnam,x
inx
lda #0
sta dstnam,x
txa
ldx #<dstnam
ldy #>dstnam
jsr setnam
jsr open ; 2,work,2,dstnam,w
jsr chkchn
bcc t0330f
ldx #<scnoof
ldy #>scnoof
jmp outstr ; and return
t0330f rts ;; carry clear; okay
;
;
;
opnsrc lda #3
ldx wrkdev
tay
jsr setlfs
ldy #$ff
t0410b iny
lda ($4d),y
bne t0410b
tya
ldx $4d
ldy $4e
jsr setnam
jsr open ; 3,work,3,source
jsr chkchn
bcc t0420f
ldx #<scno
ldy #>scno
jsr outstr
ldx $4d
ldy $4e
jsr outstr
ldx #<snl
ldy #>snl
jmp outstr ; and return
t0420f rts
;
; tcopy - copy (opened) 3 to 2
;
tcopy = *
ldx #3
jsr chkin
jsr chrin
tay
jsr readst
pha
ldx #2
jsr chkout
tya
jsr chrout
pla
beq tcopy
;
jsr clrchn
lda #3
jmp close ; and return
;
;
; chkchn - check error channel
;
chkchn ldx #15
jsr chkin
jsr chrin
cmp #'0
bne t0730f
jsr chrin
cmp #'0
t0730f php
t0740b jsr chrin
cmp #$0d
bne t0740b
jsr clrchn
plp
clc
beq t0750f
sec ;; carry indicates error
t0750f rts ;; carry clear; okay
;
;
;
; usage - give error message
;
usage ldx #<susage
ldy #>susage
;
; sets carry, since all messages are errors
;
outstr stx $4b
sty $4c
ldy #0
t1000b lda ($4b),y
beq t1010f
jsr chrout
iny
bne t1000b
t1010f sec
rts
;
;
susage .byte "usage: concat filename"
.byte " [filename...]"
.byte $0d, $0d, $00
scnoof .byte "cannot open output file"
.byte $0d, $0d, $00
scno .byte "cannot open: "
.byte $00
sm$r .byte "m-r"
snl .byte $0d, $0d, $00
dstlen .byte $00
dstnam .byte "0:"
.bss 22