You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

block.src 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. .page 'block command'
  2. ; rom 1.1 additions
  3. ; user commands
  4. user ldy cmdbuf+1
  5. cpy #'0
  6. bne us10 ; 0 resets pntr
  7. usrint lda #<ublock ; set default block add
  8. sta usrjmp
  9. lda #>ublock
  10. sta usrjmp+1
  11. rts
  12. us10 jsr usrexc ; execute code by table
  13. jmp endcmd
  14. usrexc dey ; entry is(((index-1)and$f)*2)
  15. tya
  16. and #$f
  17. asl a
  18. tay
  19. lda (usrjmp),y
  20. sta ip
  21. iny
  22. lda (usrjmp),y
  23. sta ip+1
  24. jmp (ip)
  25. .page 'block commands'
  26. ; open direct access buffer
  27. ; from open "#"
  28. opnblk lda lstdrv
  29. sta drvnum
  30. lda sa ; sa is destroyed by this patch
  31. pha
  32. jsr autoi ; init disk for proper channel assignment
  33. pla ; restore sa
  34. sta sa
  35. ldx cmdsiz
  36. dex
  37. bne ob10
  38. lda #1 ; get any buffer
  39. jsr getrch
  40. jmp ob30
  41. ob05 lda #nochnl
  42. jmp cmderr
  43. ob10 ldy #1 ; buffer # is requested
  44. jsr bp05
  45. ldx filsec
  46. cpx #bfcnt ; must be less than 13.
  47. bcs ob05
  48. lda #0
  49. sta temp
  50. sta temp+1
  51. sec
  52. ob15
  53. rol temp
  54. rol temp+1
  55. dex
  56. bpl ob15
  57. lda temp
  58. and bufuse
  59. bne ob05 ; buffer is used
  60. lda temp+1
  61. and bufuse+1
  62. bne ob05 ; buf is used
  63. lda temp
  64. ora bufuse ; set buffer as used
  65. sta bufuse
  66. lda temp+1
  67. ora bufuse+1
  68. sta bufuse+1
  69. lda #0 ; set up channel
  70. jsr getrch
  71. ldx lindx
  72. lda filsec
  73. sta buf0,x
  74. tax
  75. lda drvnum
  76. sta jobs,x
  77. sta lstjob,x
  78. ob30 ldx sa
  79. lda lintab,x ; set lindx table
  80. ora #$40
  81. sta lintab,x
  82. ldy lindx
  83. lda #$ff
  84. sta lstchr,y
  85. lda #rndrdy
  86. sta chnrdy,y ; set channel ready
  87. lda buf0,y
  88. sta chndat,y ; buffer # as 1st char
  89. asl a
  90. tax
  91. lda #1
  92. sta buftab,x
  93. lda #dirtyp+dirtyp
  94. sta filtyp,y ; set direct file type
  95. jmp endcmd
  96. .page
  97. ; block commands
  98. block ldy #0
  99. ldx #0
  100. lda #'- ; "-" separates cmd from subcmd
  101. jsr parse ; locate sub-cmd
  102. bne blk40
  103. blk10 lda #badcmd
  104. jmp cmderr
  105. blk30 lda #badsyn
  106. jmp cmderr
  107. blk40 txa
  108. bne blk30
  109. ldx #nbcmds-1 ; find command
  110. lda cmdbuf,y
  111. blk50 cmp bctab,x
  112. beq blk60
  113. dex
  114. bpl blk50
  115. bmi blk10
  116. blk60
  117. txa
  118. ora #$80
  119. sta cmdnum
  120. jsr blkpar ; parse parms
  121. lda cmdnum
  122. asl a
  123. tax
  124. lda bcjmp+1,x
  125. sta temp+1
  126. lda bcjmp,x
  127. sta temp
  128. jmp (temp) ; goto command
  129. bctab .byte 'AFRWEP'
  130. nbcmds =*-bctab
  131. bcjmp .word blkalc ; block-allocate
  132. .word blkfre ; block-free
  133. .word blkrd ; block-read
  134. .word blkwt ; block-write
  135. .word blkexc ; block-execute
  136. .word blkptr ; block-pointer
  137. blkpar ldy #0 ; parse block parms
  138. ldx #0
  139. lda #':
  140. jsr parse
  141. bne bp05 ; found ":"
  142. ldy #3 ; else char #3 is beginning
  143. bp05 lda cmdbuf,y
  144. cmp #'
  145. beq bp10
  146. cmp #29 ; skip character
  147. beq bp10
  148. cmp #',
  149. bne bp20
  150. bp10 iny
  151. cpy cmdsiz
  152. bcc bp05
  153. rts ; that's all
  154. bp20 jsr aschex
  155. inc f1cnt
  156. ldy f2ptr
  157. cpx #mxfils-1
  158. bcc bp10
  159. bcs blk30 ; bad syntax
  160. ; convert ascii to hex (binary)
  161. ; & store conversion in tables
  162. ; .y= ptr into cmdbuf
  163. aschex lda #0
  164. sta temp
  165. sta temp+1
  166. sta temp+3
  167. ldx #$ff
  168. ah10 lda cmdbuf,y ; test for dec #
  169. cmp #$40
  170. bcs ah20 ; non-numeric terminates
  171. cmp #$30
  172. bcc ah20 ; non-numeric
  173. and #$f
  174. pha
  175. lda temp+1 ; shift digits (*10)
  176. sta temp+2
  177. lda temp
  178. sta temp+1
  179. pla
  180. sta temp
  181. iny
  182. cpy cmdsiz
  183. bcc ah10 ; still in string
  184. ah20 sty f2ptr ; convert digits to...
  185. clc ; ...binary by dec table
  186. lda #0
  187. ah30 inx
  188. cpx #3
  189. bcs ah40
  190. ldy temp,x
  191. ah35 dey
  192. bmi ah30
  193. adc dectab,x
  194. bcc ah35
  195. clc
  196. inc temp+3
  197. bne ah35
  198. ah40 pha
  199. ldx f1cnt
  200. lda temp+3
  201. sta filtrk,x ; store result in table
  202. pla
  203. sta filsec,x
  204. rts
  205. dectab .byte 1,10,100 ; decimal table
  206. ;block-free
  207. blkfre jsr blktst
  208. jsr frets
  209. jmp endcmd
  210. ;block-allocate
  211. lda #1
  212. sta wbam
  213. blkalc
  214. jsr blktst
  215. ba10
  216. lda sector
  217. pha
  218. jsr getsec
  219. beq ba15 ; none greater on this track
  220. pla
  221. cmp sector
  222. bne ba30 ; requested sector not avail
  223. jsr wused
  224. jmp endcmd
  225. ;
  226. ba15
  227. pla ; pop stack
  228. ba20
  229. lda #0
  230. sta sector
  231. inc track
  232. lda track
  233. cmp maxtrk
  234. bcs ba40 ; gone all the way
  235. ;
  236. jsr getsec
  237. beq ba20
  238. ba30
  239. lda #noblk
  240. jsr cmder2
  241. ba40
  242. lda #noblk
  243. jsr cmderr ; t=0,s=0 :none left
  244. ;
  245. ; block read subs
  246. blkrd2 jsr bkotst ; test parms
  247. jmp drtrd
  248. getsim jsr getpre ; get byte w/o inc
  249. lda (buftab,x)
  250. rts
  251. ; block read
  252. blkrd3 jsr blkrd2
  253. lda #0
  254. jsr setpnt
  255. jsr getsim ; y=lindx
  256. sta lstchr,y
  257. lda #rndrdy
  258. sta chnrdy,y
  259. rts
  260. blkrd
  261. jsr blkrd3
  262. jsr rnget1
  263. jmp endcmd
  264. ;user direct read, lstchr=$ff
  265. ublkrd
  266. jsr blkpar
  267. jsr blkrd3
  268. lda lstchr,y
  269. sta chndat,y
  270. lda #$ff
  271. sta lstchr,y
  272. jmp endcmd ; (rts)
  273. ;block-write
  274. blkwt jsr bkotst
  275. jsr getpnt
  276. tay
  277. dey
  278. cmp #2
  279. bcs bw10
  280. ldy #1
  281. bw10 lda #0 ; set record size
  282. jsr setpnt
  283. tya
  284. jsr putbyt
  285. txa
  286. pha
  287. bw20 jsr drtwrt ; write block
  288. pla
  289. tax
  290. ;##### GCB 11/20/86 Block Read fix ############################
  291. ;jsr rnget2
  292. jsr ptch25
  293. ;###############################################################
  294. jmp endcmd
  295. ;user dirct write, no lstchr
  296. ublkwt jsr blkpar
  297. jsr bkotst
  298. jsr drtwrt
  299. jmp endcmd
  300. ;in .file vector:
  301. ;*=$fffa-6 ;user direct access
  302. ;ublock .word ublkrd
  303. ; .word ublkwt
  304. ;block-execute
  305. blkexc
  306. jsr killp ; kill protect
  307. jsr blkrd2 ; read block & execute
  308. lda #0
  309. be05 sta temp
  310. ldx jobnum
  311. lda bufind,x
  312. sta temp+1
  313. jsr be10 ; indirect jsr
  314. jmp endcmd
  315. be10 jmp (temp)
  316. ;buffer-pointer, set buffer pointer
  317. blkptr jsr buftst
  318. lda jobnum
  319. asl a
  320. tax
  321. lda filsec+1
  322. sta buftab,x
  323. jsr getpre
  324. jsr rnget2 ; set up get
  325. jmp endcmd
  326. ;test for allocated buffer..
  327. ; ..related to sa
  328. buftst ldx f1ptr
  329. inc f1ptr
  330. lda filsec,x
  331. tay
  332. dey
  333. dey
  334. cpy #$c ; set limit to # of sas
  335. bcc bt20
  336. bt15 lda #nochnl
  337. jmp cmderr
  338. bt20 sta sa
  339. jsr fndrch
  340. bcs bt15
  341. jsr getact
  342. sta jobnum
  343. rts
  344. ;test block operation parms
  345. bkotst jsr buftst
  346. ;
  347. ;test for legal block &..
  348. ; ..set up drv, trk, sec
  349. blktst ldx f1ptr
  350. lda filsec,x
  351. and #1
  352. sta drvnum
  353. lda filsec+2,x
  354. sta sector
  355. lda filsec+1,x
  356. sta track
  357. bt05
  358. jsr tschk
  359. jmp setlds ; (rts)
  360. ; .end
  361. ; rsr 1/19/80 add autoi to #cmd