home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_24_1988_Transactor_Publishing.d64 / badcat.a < prev    next >
Text File  |  2023-02-26  |  3KB  |  262 lines

  1. argstk = $033c
  2. sysdev = $17fa
  3. sysdrv = $17fb
  4. wrkdev = $17fc
  5. wrkdrv = $17fd
  6. s2000 = $2000
  7. ;
  8. setlfs = $ffba
  9. setnam = $ffbd
  10. open = $ffc0
  11. close = $ffc3
  12. chkin = $ffc6
  13. chkout = $ffc9
  14. clrchn = $ffcc
  15. chrin = $ffcf
  16. chrout = $ffd2
  17. readst = $ffb7
  18. load = $ffd5
  19. getin = $ffe4
  20. ;
  21. ;
  22. ;
  23. ; * = $1800  ;; use link -s $1800
  24. ;
  25. usrprog = *
  26.  jsr clrchn
  27.  lda #15
  28.  ldx wrkdev
  29.  tay
  30.  jsr setlfs
  31.  lda #3
  32.  ldx #<sm$r
  33.  ldy #>sm$r
  34.  jsr setnam
  35.  jsr open
  36. ;
  37.  lda #0
  38.  sta dstnam+2
  39. ;
  40.  lda argstk+2
  41.  sta $4b
  42.  lda argstk+3
  43.  sta $4c
  44. ;
  45.  inc argstk  ;; goes to zero when done
  46.  jsr getarg
  47.  bne arglp
  48.  jmp usage
  49. ;
  50. arglp = *
  51.  jsr getarg
  52.  beq done
  53.  lda ($4d),y
  54.  cmp #'-
  55.  bne nodash
  56. dashlp iny
  57.  lda ($4d),y
  58.  beq t0130f
  59.  jmp dashlp
  60. t0120f jmp usage
  61.  jmp dashlp
  62. t0130f jmp arglp
  63. ;
  64. nodash = *
  65.  lda dstnam+2
  66.  bne sources
  67.  jsr opndst
  68.  bcc arglp
  69.  jmp bad
  70. ;
  71. sources = *
  72.  jsr opnsrc
  73.  bcs bad
  74.  jsr tcopy   ; copies 3 to 2, closes 3
  75.  lda #3
  76.  jsr close
  77.  jmp arglp
  78. ;
  79. done = *
  80.  lda dstnam+2
  81.  bne okay
  82. ;
  83. bad = *
  84.  lda #3
  85.  jsr close
  86. ;
  87. okay = *
  88.  lda #2
  89.  jsr close
  90.  jsr chkchn ; but ignore result
  91.  jsr clrchn
  92.  lda #15
  93.  jmp close  ; and return to shell
  94. ;
  95. ;
  96. ;
  97. ;
  98. ; getarg - put next arg pointer into ($4d,$4e)
  99. ;  y is set to zero
  100. ;  argv is incremented
  101. ;  argc is decremented
  102. ;
  103. getarg = *
  104.  ldy #1
  105.  lda ($4b),y
  106.  sta $4e
  107.  dey
  108.  lda ($4b),y
  109.  sta $4d
  110.  clc
  111.  lda $4b
  112.  adc #2
  113.  sta $4b
  114.  bcc t0200f
  115.  inc $4c
  116. t0200f dec argstk
  117.  rts
  118. ;
  119. ;
  120. ; opndst - open destination file from current arg
  121. ;
  122. opndst = *
  123.  lda #2
  124.  ldx wrkdev
  125.  tay
  126.  jsr setlfs
  127.  lda wrkdrv
  128.  clc
  129.  adc #'0
  130.  sta dstnam
  131.  ldy #0
  132.  ldx #2
  133. t0310b lda ($4d),y
  134.  sta dstnam,x  ;; file name including '\0' is stored
  135.  beq t0320f
  136.  iny
  137.  inx
  138.  bne t0310b
  139. t0320f stx dstlen
  140.  lda #',
  141.  sta dstnam,x
  142.  inx
  143.  lda #'w
  144.  sta dstnam,x
  145.  inx
  146.  lda #0
  147.  sta dstnam,x
  148.  txa
  149.  ldx #<dstnam
  150.  ldy #>dstnam
  151.  jsr setnam
  152.  jsr open    ; 2,work,2,dstnam,w
  153.  jsr chkchn
  154.  bcc t0330f
  155.  ldx #<scnoof
  156.  ldy #>scnoof
  157.  jmp outstr  ; and return
  158. t0330f rts  ;; carry clear; okay
  159. ;
  160. ;
  161. ;
  162. opnsrc lda #3
  163.  ldx wrkdev
  164.  tay
  165.  jsr setlfs
  166.  ldy #$ff
  167. t0410b iny
  168.  lda ($4d),y
  169.  bne t0410b
  170.  tya
  171.  ldx $4d
  172.  ldy $4e
  173.  jsr setnam
  174.  jsr open   ; 3,work,3,source
  175.  jsr chkchn
  176.  bcc t0420f
  177.  ldx #<scno
  178.  ldy #>scno
  179.  jsr outstr
  180.  ldx $4d
  181.  ldy $4e
  182.  jsr outstr
  183.  ldx #<snl
  184.  ldy #>snl
  185.  jmp outstr  ; and return
  186. t0420f rts
  187. ;
  188. ; tcopy - copy (opened) 3 to 2
  189. ;
  190. tcopy = *
  191.  ldx #3
  192.  jsr chkin
  193.  jsr chrin
  194.  tay
  195.  jsr readst
  196.  pha
  197.  ldx #2
  198.  jsr chkout
  199.  tya
  200.  jsr chrout
  201.  pla
  202.  beq tcopy
  203. ;
  204.  jsr clrchn
  205.  lda #3
  206.  jmp close   ; and return
  207. ;
  208. ;
  209. ; chkchn - check error channel
  210. ;
  211. chkchn ldx #15
  212.  jsr chkin
  213.  jsr chrin
  214.  cmp #'0
  215.  bne t0730f
  216.  jsr chrin
  217.  cmp #'0
  218. t0730f php
  219. t0740b jsr chrin
  220.  cmp #$0d
  221.  bne t0740b
  222.  jsr clrchn
  223.  plp
  224.  clc
  225.  beq t0750f
  226.  sec  ;; carry indicates error
  227. t0750f rts  ;; carry clear; okay
  228. ;
  229. ;
  230. ;
  231. ; usage - give error message
  232. ;
  233. usage ldx #<susage
  234.  ldy #>susage
  235. ;
  236. ; sets carry, since all messages are errors
  237. ;
  238. outstr stx $4b
  239.  sty $4c
  240.  ldy #0
  241. t1000b lda ($4b),y
  242.  beq t1010f
  243.  jsr chrout
  244.  iny
  245.  bne t1000b
  246. t1010f sec
  247.  rts
  248. ;
  249. ;
  250. susage .byte "usage: concat filename" 
  251.  .byte " [filename...]"
  252.  .byte $0d, $0d, $00
  253. scnoof .byte "cannot open output file"
  254.  .byte $0d, $0d, $00
  255. scno .byte "cannot open: "
  256.  .byte $00
  257. sm$r .byte "m-r"
  258. snl .byte $0d, $0d, $00
  259. dstlen .byte $00
  260. dstnam .byte "0:"
  261.  .bss 22
  262.