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 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. .PAGE 'BLOCK COMMAND'
  2. ;
  3. ; USER COMMANDS
  4. ;
  5. USER
  6. LDY CMDBUF+1
  7. CPY #'0
  8. BNE US10 ; 0 RESETS PNTR
  9. USRINT
  10. LDA #<UBLOCK ; SET DEFAULT BLOCK ADD
  11. STA USRJMP
  12. LDA #>UBLOCK
  13. STA USRJMP+1
  14. RTS
  15. US10
  16. JSR USREXC ; EXECUTE CODE BY TABLE
  17. JMP ENDCMD
  18. USREXC
  19. DEY ; ENTRY IS (((INDEX-1)AND$F)*2)
  20. TYA
  21. AND #$F
  22. ASL A
  23. TAY
  24. LDA (USRJMP),Y
  25. STA IP
  26. INY
  27. LDA (USRJMP),Y
  28. STA IP+1
  29. JMP (IP)
  30. .PAGE 'BLOCK COMMANDS'
  31. ;
  32. ; OPEN DIRECT ACCESS BUFFER
  33. ; FROM OPEN "#"
  34. ;
  35. OPNBLK
  36. LDA LSTDRV
  37. STA DRVNUM
  38. LDA SA
  39. PHA
  40. JSR AUTOI
  41. PLA
  42. STA SA
  43. LDX CMDSIZ
  44. DEX
  45. BNE OB10
  46. LDA #1 ; GET ANY BUFFER
  47. JSR GETRCH
  48. JMP OB30
  49. OB05
  50. LDA #NOCHNL
  51. JMP CMDERR
  52. OB10
  53. LDY #1 ; BUFFER # IS REQUESTED
  54. JSR BP05
  55. LDX FILSEC
  56. CPX #BAMJOB ; MUST BE LESS THAN 13
  57. BCS OB05
  58. LDA #0
  59. STA TEMP
  60. STA TEMP+1
  61. SEC
  62. OB15
  63. ROL TEMP
  64. ROL TEMP+1
  65. DEX
  66. BPL OB15
  67. LDA TEMP
  68. AND BUFUSE
  69. BNE OB05 ; BUFFER IS USED
  70. LDA TEMP+1
  71. AND BUFUSE+1
  72. BNE OB05 ; BUFFER IS USED
  73. LDA TEMP
  74. ORA BUFUSE ; SET BUFFER AS USED
  75. STA BUFUSE
  76. LDA TEMP+1
  77. ORA BUFUSE+1
  78. STA BUFUSE+1
  79. LDA #0 ; SET UP CHANNEL
  80. JSR GETRCH
  81. LDX LINDX
  82. LDA FILSEC
  83. STA BUF0,X
  84. TAX
  85. LDA DRVNUM
  86. STA LSTJOB,X
  87. OB30
  88. LDX SA
  89. LDA LINTAB,X ; SET LINDX TABLE
  90. ORA #$40
  91. STA LINTAB,X
  92. LDY LINDX
  93. LDA #$FF
  94. STA LSTCHR,Y
  95. LDA #RNDRDY
  96. STA CHNRDY,Y ; SET CHANNEL READY
  97. LDA BUF0,Y
  98. STA CHNDAT,Y ; BUFFER # AS 1ST CHAR
  99. ASL A
  100. TAX
  101. LDA #1
  102. STA BUFTAB,X
  103. LDA #DIRTYP+DIRTYP
  104. STA FILTYP,Y ; SET DIRECT FILE TYPE
  105. JMP ENDCMD
  106. ;
  107. ; BLOCK COMMANDS
  108. ;
  109. BLOCK
  110. LDY #0
  111. LDX #0
  112. LDA #'- ; '-' SEPARATES CMD FROM SUBCMD
  113. JSR PARSE ; LOCATE SUB-CMD
  114. BNE BLK40
  115. BLK10
  116. LDA #BADCMD
  117. JMP CMDERR
  118. BLK30
  119. LDA #BADSYN
  120. JMP CMDERR
  121. BLK40
  122. TXA
  123. BNE BLK30
  124. LDX #NBCMDS-1 ; FIND COMMAND
  125. LDA CMDBUF,Y
  126. BLK50
  127. CMP BCTAB,X
  128. BEQ BLK60
  129. DEX
  130. BPL BLK50
  131. BMI BLK10
  132. BLK60
  133. TXA
  134. ORA #$80
  135. STA CMDNUM
  136. JSR BLKPAR ; PARSE PARMS
  137. LDA CMDNUM
  138. ASL A
  139. TAX
  140. LDA BCJMP+1,X
  141. STA TEMP+1
  142. LDA BCJMP,X
  143. STA TEMP
  144. JMP (TEMP) ; GOTO COMMAND
  145. BCTAB
  146. .BYTE 'AFRWEP'
  147. NBCMDS = *-BCTAB
  148. BCJMP
  149. .WORD BLKALC ; BLOCK-ALLOCATE
  150. .WORD BLKFRE ; BLOCK-FREE
  151. .WORD BLKRD ; BLOCK-READ
  152. .WORD BLKWT ; BLOCK-WRITE
  153. .WORD BLKEXC ; BLOCK-EXECUTE
  154. .WORD BLKPTR ; BLOCK-POINTER
  155. BLKPAR
  156. LDY #0 ; PARSE BLOCK PARMS
  157. LDX #0
  158. LDA #':
  159. JSR PARSE
  160. BNE BP05 ; FOUND ':'
  161. LDY #3 ; ELSE CHAR #3 IS BEGINNING
  162. BP05
  163. LDA CMDBUF,Y
  164. CMP #'
  165. BEQ BP10
  166. CMP #29 ; SKIP CHARACTER
  167. BEQ BP10
  168. CMP #',
  169. BNE BP20
  170. BP10
  171. INY
  172. CPY CMDSIZ
  173. BCC BP05
  174. RTS ; THAT'S ALL
  175. BP20
  176. JSR ASCHEX
  177. INC F1CNT
  178. LDY F2PTR
  179. CPX #MXFILS-1
  180. BCC BP10
  181. BCS BLK30 ; BAD SYNTAX
  182. ;
  183. ; CONVERT ASCII TO HEX (BINARY)
  184. ; & STORE CONVERSION IN TABLES
  185. ; .Y = PTR INTO CMDBUF
  186. ;
  187. ASCHEX
  188. LDA #0
  189. STA TEMP
  190. STA TEMP+1
  191. STA TEMP+3
  192. LDX #$FF
  193. AH10
  194. LDA CMDBUF,Y ; TEST FOR DEC #
  195. CMP #$40
  196. BCS AH20 ; NON-NUMERIC TERMINATES
  197. CMP #$30
  198. BCC AH20 ; NON-NUMERIC
  199. AND #$F
  200. PHA
  201. LDA TEMP+1 ; SHIFT DIGITS (*10)
  202. STA TEMP+2
  203. LDA TEMP
  204. STA TEMP+1
  205. PLA
  206. STA TEMP
  207. INY
  208. CPY CMDSIZ
  209. BCC AH10 ; STILL IN STRING
  210. AH20
  211. STY F2PTR ; CONVERT DIGITS TO...
  212. CLC ; ...BINARY BY DEC TABLE
  213. LDA #0
  214. AH30
  215. INX
  216. CPX #3
  217. BCS AH40
  218. LDY TEMP,X
  219. AH35
  220. DEY
  221. BMI AH30
  222. ADC DECTAB,X
  223. BCC AH35
  224. CLC
  225. INC TEMP+3
  226. BNE AH35
  227. AH40
  228. PHA
  229. LDX F1CNT
  230. LDA TEMP+3
  231. STA FILTRK,X ; STORE RESULT IN TABLE
  232. PLA
  233. STA FILSEC,X
  234. RTS
  235. DECTAB
  236. .BYTE 1,10,100 ; DECIMAL TABLE
  237. ;
  238. ; BLOCK-FREE
  239. ;
  240. BLKFRE
  241. JSR BLKTST
  242. JSR FRETS
  243. JMP ENDCMD
  244. ;
  245. ; BLOCK-ALLOCATE
  246. ;
  247. BLKALC
  248. JSR BLKTST
  249. JSR GETHED ; EXTRACT THE HEAD NUMBER
  250. LDA SECTOR
  251. PHA
  252. JSR GETSEC
  253. BEQ BA15 ; NONE GREATER ON THIS TRACK
  254. PLA
  255. CMP SECTOR
  256. BNE BA30 ; REQUESTED SECTOR NOT AVAIL
  257. JSR USEDT0 ; HEAD ALREADY OUT
  258. JMP ENDCMD
  259. BA15
  260. PLA ; POP STACK
  261. BA20
  262. LDA #0
  263. STA SECTOR ; START AT SECTOR 0
  264. INC HEAD ; HEAD+1
  265. LDA HEAD
  266. CMP HEADS
  267. BCC BA25
  268. LDA #0
  269. STA HEAD ; SET HEAD = 0
  270. INC TRACK
  271. LDA TRACK
  272. CMP MAXTRK
  273. BCS BA40 ; GONE ALL THE WAY
  274. BA25
  275. JSR GETSEC
  276. BEQ BA20
  277. BA30
  278. JSR ADDHED ; ADD THE HEAD TO THE SECTOR
  279. LDA #NOBLK
  280. JSR CMDER2
  281. BA40
  282. LDA #NOBLK
  283. JSR CMDERR ; T = 0, S = 0, NONE LEFT
  284. ;
  285. ; BLOCK READ SUBS
  286. ;
  287. BLKRD2
  288. JSR BKOTST ; TEST PARMS
  289. JMP DRTRD
  290. GETSIM
  291. JSR GETPRE ; GET BYTE W/O INC
  292. LDA (BUFTAB,X)
  293. RTS
  294. ;
  295. ; BLOCK READ
  296. ;
  297. BLKRD3
  298. JSR BLKRD2
  299. LDA #0
  300. JSR SETPNT
  301. JSR GETSIM ; .Y = LINDX
  302. STA LSTCHR,Y
  303. LDA #RNDRDY
  304. STA CHNRDY,Y
  305. RTS
  306. BLKRD
  307. JSR BLKRD3
  308. JSR RNGET1
  309. JMP ENDCMD
  310. ;
  311. ; USER DIRECT READ, LSTCHR = $FF
  312. ;
  313. UBLKRD
  314. JSR BLKPAR
  315. JSR BLKRD3
  316. LDA LSTCHR,Y
  317. STA CHNDAT,Y
  318. LDA #$FF
  319. STA LSTCHR,Y
  320. JMP ENDCMD ; (RTS)
  321. ;
  322. ; BLOCK-WRITE
  323. ;
  324. BLKWT
  325. JSR BKOTST
  326. JSR GETPNT
  327. TAY
  328. DEY
  329. CMP #2
  330. BCS BW10
  331. LDY #1
  332. BW10
  333. LDA #0 ; SET RECORD SIZE
  334. JSR SETPNT
  335. TYA
  336. JSR PUTBYT
  337. TXA
  338. PHA
  339. BW20
  340. JSR DRTWRT ; WRITE BLOCK
  341. PLA
  342. TAX
  343. LDY LINDX
  344. JSR RNGET2
  345. JMP ENDCMD
  346. ;
  347. ; USER DIRCT WRITE, NO LSTCHR
  348. ;
  349. UBLKWT
  350. JSR BLKPAR
  351. JSR BKOTST
  352. JSR DRTWRT
  353. JMP ENDCMD
  354. ;
  355. ; BLOCK-EXECUTE
  356. ;
  357. BLKEXC
  358. JSR BLKRD2 ; READ BLOCK & EXECUTE
  359. LDA #0
  360. BE05
  361. STA TEMP
  362. LDX JOBNUM
  363. LDA BUFIND,X
  364. STA TEMP+1
  365. JSR BE10 ; INDIRECT JSR
  366. JMP ENDCMD
  367. BE10
  368. JMP (TEMP)
  369. ;
  370. ; BUFFER-POINTER, SET BUFFER POINTER
  371. ;
  372. BLKPTR
  373. JSR BUFTST
  374. LDA JOBNUM
  375. ASL A
  376. TAX
  377. LDA FILSEC+1
  378. STA BUFTAB,X
  379. JSR GETPRE
  380. JSR RNGET2 ; SET UP GET
  381. JMP ENDCMD
  382. ;
  383. ; TEST FOR ALLOCATED BUFFER..
  384. ; ..RELATED TO SA
  385. ;
  386. BUFTST
  387. LDX F1PTR
  388. INC F1PTR
  389. LDA FILSEC,X
  390. TAY
  391. DEY
  392. DEY
  393. CPY #BAMJOB
  394. BCC BT20
  395. BT15
  396. LDA #NOCHNL
  397. JMP CMDERR
  398. BT20
  399. STA SA
  400. JSR FNDRCH
  401. BCS BT15
  402. JSR GETACT
  403. STA JOBNUM
  404. RTS
  405. ;
  406. ; TEST BLOCK OPERATION PARMS
  407. ;
  408. BKOTST
  409. JSR BUFTST
  410. ;
  411. ; TEST FOR LEGAL BLOCK &..
  412. ; ..SET UP DRV, TRK, SEC
  413. ;
  414. BLKTST
  415. LDX F1PTR
  416. LDA FILSEC,X
  417. AND #1
  418. STA DRVNUM
  419. LDA FILSEC+2,X
  420. STA SECTOR
  421. LDA FILSEC+1,X
  422. STA TRACK
  423. BT05
  424. JSR TSCHK
  425. JMP SETLDS ; (RTS)
  426. .END