home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_27_1988_Transactor_Publishing.d64 / shellram.sda / DOLOAD.A < prev    next >
Text File  |  2023-02-26  |  4KB  |  285 lines

  1. ;
  2. ; shellram
  3. ;
  4. ;  By: Adrian Pepper
  5. ;      Toronto, Ontario
  6. ;
  7. ;  based on, but heavily modified from
  8. ;  the Pro-Line/Spinnaker
  9. ;    C POWER/POWER C shell for the
  10. ;  Commodore 64 home computer.
  11. ;
  12. ;  The shell was modified to reduce
  13. ;  the size of the code, and arrange
  14. ;  things so memory page 22 (hex $16)
  15. ;  will be free for use as a "RAMdisk
  16. ;  Interface Page", for use with the
  17. ;  Commodore 1764 256K RAM expander
  18. ;  for the Commodore 64
  19. ;
  20. ;  This (basically) allows all programs
  21. ;  designed to run under the shell to
  22. ;  operate with the RAM disk
  23. ;
  24. ;
  25. ; doload.a
  26. ;
  27. ; doload, tryload;
  28. ;   load executable programs from drives
  29. ;
  30. ; also getflnm
  31. ;      ostdin
  32. ;      ostdout
  33. ;      oprout
  34. ;
  35. ;
  36. ;
  37.  .ref sysdev
  38.  .ref sysdrv
  39.  .ref wrkdev
  40.  .ref wrkdrv
  41.  .ref stdinfl
  42.  .ref stdoufl
  43. ;
  44. ; kernal routines, etc
  45. ;
  46.  .ref setlfs
  47.  .ref setnam
  48.  .ref open
  49.  .ref chkout
  50.  .ref clrchn
  51.  .ref load
  52. ;
  53. ;
  54. ;
  55.  .def getflnm
  56.  .def ostdin
  57.  .def ostdout
  58.  .def cmdchk
  59.  .def oprout
  60.  .def doload
  61.  .def tryload
  62. ;
  63.  .ref curcmdn
  64.  .ref strac   ;; same as prfbuf, remember
  65. ;
  66.  .ref strload
  67.  .ref strapnd
  68.  .ref strend
  69.  .ref streq
  70.  .ref strfopn
  71.  .ref strechn
  72.  .ref strbout
  73.  .ref cmdlbuf
  74.  .ref strout
  75. ;  
  76. ; getflnm - copies from cmdlbuf,x  
  77. ;   to strac, prepending <drv>:
  78. ;
  79. ; for ostdin, ostdout
  80. ;
  81. getflnm clc
  82.  lda wrkdrv
  83.  adc #'0
  84.  sta strac
  85.  lda  #':
  86.  sta strac+1
  87. t1070b inx
  88.  lda cmdlbuf,x
  89.  bne t1080f
  90.  sec
  91.  rts
  92. t1080f cmp #$20
  93.  beq t1090f
  94.  cmp #$a0
  95. t1090f beq t1070b
  96.  ldy #2
  97. t1100b lda cmdlbuf,x
  98.  beq t1110f
  99.  cmp #$20
  100.  beq t1110f
  101.  cmp #$a0
  102.  beq t1110f
  103.  sta strac,y
  104.  iny
  105.  inx
  106.  bne t1100b
  107. t1110f lda #0
  108.  sta strac,y
  109.  dex
  110.  stx $2a
  111.  clc
  112.  rts
  113. ;  
  114. ; ostdin - open stdin  
  115. ;  (process <filename)  
  116. ;  
  117. ostdin lda #$01
  118.  sta stdinfl
  119.  sty $2b
  120.  jsr getflnm
  121.  bcc t0980f
  122.  rts
  123. t0980f lda  #$01
  124.  ldx wrkdev
  125.  ldy #$02
  126.  jsr  strfopn ; open 1,wrkdev,2,strac
  127.  bcc t0990f
  128.  rts
  129. t0990f ldx wrkdev
  130.  jmp cmdchk ; and return
  131. ;  
  132. ; ostdout - open stdout  
  133. ;   (process >filename)  
  134. ;
  135. scoms .byte ",s"
  136.  .byte 0
  137. scomw .byte ",w"
  138.  .byte 0
  139. ostdout lda #$01
  140.  sta stdoufl
  141.  sty $2b
  142.  jsr getflnm
  143.  bcc t1000f
  144.  rts
  145. t1000f ldx #0
  146.  jsr strend
  147.  dex
  148.  dex
  149.  lda strac,x
  150.  cmp #',
  151.  beq t1010f
  152.  ldx #<scoms
  153.  ldy #>scoms
  154.  jsr strapnd
  155. t1010f ldx #<scomw
  156.  ldy #>scomw
  157.  jsr strapnd
  158.  lda #2
  159.  ldx wrkdev
  160.  ldy #3
  161.  jsr strfopn  ;; open 2,<wrk>,3,strac
  162.  bcc t1020f
  163.  rts
  164. t1020f ldx wrkdev
  165. ;  
  166. ; cmdchk - get command channel line  
  167. ;  into echnbuf;  
  168. ;  output and set carry if non-zero code
  169. ;  also restore x,y from $2a,$2b
  170. ;  
  171. cmdchk jsr strechn
  172.  bcc t1030f
  173.  jsr strbout
  174.  sec
  175. t1030f ldx $2a
  176.  ldy $2b
  177.  rts
  178. ;  
  179. ; oprout - open printer (dev 4)  
  180. ;   as stdout (process >>)  
  181. ;  
  182. oprout stx $2a
  183.  sty $2b
  184.  lda #1
  185.  sta stdoufl
  186.  lda #2
  187.  ldx #4
  188.  ldy #7
  189.  jsr setlfs
  190.  lda #0
  191.  jsr setnam
  192.  jsr open
  193.  bcs t1120f
  194.  ldx #2
  195.  jsr chkout
  196. t1120f php
  197.  jsr clrchn
  198.  plp
  199.  ldx $2a
  200.  ldy $2b
  201.  rts
  202. ;
  203. ; doload - loads name represented by string at (x,y)
  204. ;
  205. doload stx $2a
  206.  sty $2b
  207.  jsr strload
  208.  ldx #<curcmdn
  209.  ldy #>curcmdn
  210.  jsr streq ; cmp with curcmdn
  211.  bne t0870f
  212.  clc
  213.  rts
  214. t0870f ldx wrkdev
  215.  ldy wrkdrv
  216.  jsr tryload ; try work disk!
  217.  bcc t0880f
  218.  ldx sysdev
  219.  ldy sysdrv
  220.  cpx wrkdev  ; don't redo same disk!
  221.  bne t0875f
  222.  cpy wrkdrv
  223.  beq t0876f
  224. t0875f jsr tryload ; try system disk!
  225.  bcc t0880f
  226. t0876f ldx #<scmdnf
  227.  ldy #>scmdnf
  228.  jsr strout
  229.  sec
  230.  rts
  231. scmdnf .byte "command not found"
  232.  .byte $0d,0
  233. t0880f ldy #$13
  234. t0890b lda ($2a),y
  235.  sta curcmdn,y
  236.  dey
  237.  bpl t0890b
  238.  clc
  239.  rts
  240. ;  
  241. ; tryload - attempt load of ($2a,$2b)
  242. ;  from device x, drive y  
  243. ;
  244. szero .byte "0:"
  245.  .byte 0
  246. sdotsh .byte ".sh"
  247.  .byte 0
  248. ;
  249. tryload stx vtrydev
  250.  tya
  251.  clc
  252.  adc #'0
  253.  sta szero
  254.  ldx #<szero
  255.  ldy #>szero
  256.  jsr strload
  257.  ldx $2a
  258.  ldy $2b
  259.  jsr strapnd
  260.  ldx #<sdotsh
  261.  ldy #>sdotsh
  262.  jsr strapnd
  263.  ldx #0
  264.  jsr strend
  265.  txa
  266.  ldx #<strac
  267.  ldy #>strac
  268.  jsr setnam
  269.  ldx vtrydev
  270.  lda #$04
  271.  tay
  272.  jsr setlfs ; load 4,dev,4,nambuf
  273.  lda #$00
  274.  jsr load
  275.  bcc t0970f
  276.  cmp #5
  277.  bne t0940f
  278.  rts
  279. t0940f ldx vtrydev
  280.  jsr strechn
  281. ;jsr strbout
  282.  sec
  283. t0970f rts
  284. vtrydev .bss 1
  285.