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.

534 lines
7.1KB

  1. .PAGE 'TST2'
  2. ;
  3. ;*******************************
  4. ;************ L R U I N T ****
  5. ;*******************************
  6. ;
  7. ; INITIALIZE THE LRU TABEL
  8. ;
  9. ;*******************************
  10. ;
  11. LRUINT
  12. LDX #0
  13. LRUILP
  14. TXA
  15. STA LRUTBL,X
  16. INX
  17. CPX #CMDCHN
  18. BNE LRUILP
  19. ;
  20. LDA #BLINDX
  21. STA LRUTBL,X
  22. RTS
  23. ;
  24. ;*******************************
  25. ;************* L R U U P D ***
  26. ;*******************************
  27. ;
  28. ; LEAST RECENTLY USED TABLE UPDATE
  29. ;
  30. ; INPUT PARAMETERS:
  31. ; LINDX - CURRENT CHANNEL
  32. ;
  33. ; OUTPUT PARAMETERS:
  34. ; LRUTBL - UPDATED
  35. ;
  36. ;*******************************
  37. ;
  38. LRUUPD LDY #CMDCHN
  39. LDX LINDX
  40. LRULP1 LDA LRUTBL,Y
  41. STX LRUTBL,Y
  42. CMP LINDX
  43. BEQ LRUEXT
  44. DEY
  45. BMI LRUINT
  46. TAX
  47. JMP LRULP1
  48. LRUEXT RTS
  49. ;
  50. ;*******************************
  51. ;************* D B L B U F ***
  52. ;*******************************
  53. ;
  54. ; DOUBLE BUFFER
  55. ; RTN TO SWITCH THE ACTIVE AND
  56. ; INACTIVE BUFFERS
  57. ;
  58. ;*******************************
  59. ;
  60. DBLBUF
  61. JSR LRUUPD
  62. JSR GETINA
  63. BNE DBL15
  64. JSR SETDRN
  65. JSR GETBUF
  66. BMI DBL30 ;NO BUFFERS
  67. JSR PUTINA ;STORE INACTIVE BUFF #
  68. LDA TRACK
  69. PHA
  70. LDA SECTOR
  71. PHA
  72. LDA #1
  73. JSR DRDBYT
  74. STA SECTOR
  75. LDA #0
  76. JSR DRDBYT
  77. STA TRACK
  78. ;
  79. BEQ DBL10
  80. ;
  81. JSR TYPFIL
  82. BEQ DBL05 ;IT'S REL
  83. ;
  84. JSR TSTWRT
  85. BNE DBL05 ;READ AHEAD
  86. ;
  87. JSR TGLBUF ;JUST SWITCH ON WRITE
  88. JMP DBL08
  89. ;
  90. DBL05
  91. JSR TGLBUF
  92. JSR RDAB
  93. DBL08
  94. PLA
  95. STA SECTOR
  96. PLA
  97. STA TRACK
  98. JMP DBL20
  99. DBL10
  100. PLA
  101. STA SECTOR
  102. PLA
  103. STA TRACK
  104. DBL15 JSR TGLBUF
  105. DBL20 JSR GETACT
  106. TAX
  107. JMP WATJOB
  108. ;
  109. ; THERE ARE NO BUFFERS TO STEAL
  110. ;
  111. DBL30
  112. LDA #NOCHNL
  113. JMP CMDERR
  114. ;
  115. ;********************************
  116. ;
  117. DBSET
  118. JSR LRUUPD
  119. JSR GETINA
  120. BNE DBS10
  121. JSR GETBUF
  122. BMI DBL30 ;NO BUFFERS
  123. JSR PUTINA ;STORE INACTIVE BUFF #
  124. DBS10
  125. RTS
  126. ;********************************
  127. ;************ T G L B U F *****
  128. ;********************************
  129. ;
  130. ; TOGGEL THE INACTIVE AND ACTIVE
  131. ; BUFFERS.
  132. ;
  133. ; INPUT PARAMETERS:
  134. ; LINDX - CHANNEL #
  135. ;
  136. ;********************************
  137. ;
  138. TGLBUF LDX LINDX
  139. LDA BUF0,X
  140. EOR #$80
  141. STA BUF0,X
  142. LDA BUF1,X
  143. EOR #$80
  144. STA BUF1,X
  145. RTS
  146. ;
  147. ;
  148. PIBYTE
  149. LDX #IWSA
  150. STX SA
  151. JSR FNDWCH
  152. JSR SETLDS
  153. JSR TYPFIL
  154. BCC PBYTE
  155. LDA #OVRFLO
  156. JSR CLRFLG
  157. PBYTE
  158. LDA SA
  159. CMP #15
  160. BEQ L42
  161. BNE L40
  162. ;
  163. ; MAIN ROUTINE TO WRITE TO CHANL
  164. ;
  165. PUT LDA ORGSA ;IS CHANL CMD OR DATA
  166. AND #$8F
  167. CMP #15 ;<15
  168. BCS L42
  169. L40 JSR TYPFIL ;DATA BYTE TO STORE
  170. BCS L41 ;BRANCH IF RND
  171. LDA DATA ;SEQ FILE
  172. JMP WRTBYT ;WRITE BYTE TO CHANL
  173. L41
  174. BNE L46
  175. JMP WRTREL
  176. L46 LDA DATA ;RND FILE WRITE
  177. JSR PUTBYT ;WRITE TO CHANL
  178. LDY LINDX ; PREPARE NXT BYTE
  179. JMP RNGET2
  180. L42 LDA #CMDCHN ;WRITE TO CMD CHANL
  181. STA LINDX
  182. JSR GETPNT ;TEST IF COMM AND BUFFER FULL
  183. CMP #<CMDBUF+CMDLEN+1
  184. BEQ L50 ;IT IS FULL (>CMDLEN)
  185. LDA DATA ;NOT FULL YET
  186. JSR PUTBYT ;STORE THE BYTE
  187. L50 LDA EOIFLG ;TST IF LST BYTE OF MSG
  188. BEQ L45 ;IT IS
  189. RTS ;NOT YET , RETURN
  190. L45
  191. INC CMDWAT ;SET CMD WAITING FLAG
  192. RTS
  193. ;
  194. ; PUT .A INTO ACTIVE BUFFER OF LINDX
  195. ;
  196. PUTBYT PHA ; SAVE .A
  197. JSR GETACT ;GET ACTIVE BUF#
  198. BPL PUTB1 ;BRACH IF THERE IS ONE
  199. PLA ;NO BUFFER ERROR
  200. LDA #FILNOP
  201. JMP CMDERR ; JMP TO ERROR ROUTINE
  202. PUTB1 ASL A ;SAVE THE BYTE IN BUFFER
  203. TAX
  204. PLA
  205. STA (BUFTAB,X)
  206. INC BUFTAB,X ; INC THE BUFFER POINTER
  207. RTS ;Z=1 IF LAST CHAR SLOT IN BUFFER
  208. ;
  209. ; FIND THE ACTIVE BUFFER # (LINDX)
  210. ;
  211. ;
  212. ;INITIALIZE DRIVES (COMMAND)
  213. INTDRV JSR SIMPRS
  214. JSR INITDR
  215. ID20 JMP ENDCMD
  216. .SKIP
  217. ; INITIALIZE DRIVE (DRVNUM)
  218. ;
  219. ITRIAL
  220. JSR BAM2A
  221. TAY ;BAM LINDX FROM BUF0
  222. LDX BUF0,Y
  223. CPX #$FF
  224. BNE IT30 ;VALID BUFFER #
  225. ;
  226. PHA ;SAVE BAM-LINDX
  227. JSR GETBUF ;GET A BUFFER
  228. TAX ;TEST IT
  229. BPL IT20 ;NO ERROR
  230. ;
  231. LDA #NOCHNL
  232. JSR CMDER3
  233. IT20
  234. PLA
  235. TAY ;RESTORE BAM-LINDX
  236. TXA
  237. ORA #$80 ;SET INACTIVE
  238. STA BUF0,Y
  239. IT30
  240. TXA
  241. AND #$F ;STIP TO BUF #
  242. STA JOBNUM
  243. LDX #0
  244. STX SECTOR
  245. LDX DIRTRK
  246. STX TRACK
  247. JSR SETH ;SET THE BAM HEADER
  248. LDA #SEEK
  249. JMP DOJOB ;DO A SEEK
  250. ;
  251. ;
  252. INITDR
  253. JSR CLNBAM
  254. JSR CLDCHN
  255. JSR ITRIAL
  256. LDX DRVNUM
  257. LDA #0
  258. STA MDIRTY,X
  259. TXA
  260. ASL A
  261. TAX
  262. LDA HEADER
  263. STA DSKID,X
  264. LDA HEADER+1
  265. STA DSKID+1,X
  266. JSR DOREAD
  267. LDA JOBNUM
  268. ASL A
  269. TAX
  270. LDA #2
  271. STA BUFTAB,X
  272. LDA (BUFTAB,X)
  273. LDX DRVNUM
  274. STA DSKVER,X ;SET UP DISK VERSION #
  275. ;
  276. LDA #0
  277. STA WPSW,X ;CLEAR WP SWITCH
  278. STA NODRV,X ;CLEAR NOT ACTIVE FLAG
  279. ; COUNT THE NUMBER OF FREE BLOCKS HERE
  280. ;
  281. NFCALC
  282. JSR SETBPT
  283. LDY #4
  284. LDA #0
  285. TAX ;0 HI BYTE
  286. NUMF1
  287. CLC
  288. ADC (BMPNT),Y
  289. BCC NUMF2
  290. INX
  291. NUMF2
  292. INY
  293. INY
  294. INY
  295. INY
  296. CPY #$48 ; DONT COUNT THE DIR
  297. BEQ NUMF2
  298. CPY #$90
  299. BNE NUMF1
  300. PHA
  301. TXA
  302. LDX DRVNUM
  303. STA NDBH,X
  304. PLA
  305. STA NDBL,X
  306. ;
  307. RTS
  308. ;
  309. ;
  310. ; START DOUBLE BUFFERING
  311. ; USE TRACK,SECTOR AS STARTING BLOACK
  312. ;
  313. STRRD
  314. JSR SETHDR
  315. JSR RDBUF
  316. JSR WATJOB
  317. JSR GETBYT
  318. STA TRACK
  319. JSR GETBYT
  320. STA SECTOR
  321. RTS
  322. ;
  323. STRDBL
  324. JSR STRRD
  325. LDA TRACK
  326. BNE STR1
  327. RTS
  328. STR1
  329. JSR DBLBUF
  330. JSR SETHDR
  331. JSR RDBUF
  332. JMP DBLBUF
  333. ;
  334. ; START A READ JOB ON TRACK,SECTOR
  335. ;
  336. RDBUF LDA #READ
  337. BNE STRTIT
  338. ;
  339. ; START A WRITE JOB ON TRACK,SECTOR
  340. ;
  341. WRTBUF LDA #WRITE
  342. STRTIT STA CMD
  343. JSR GETACT
  344. TAX
  345. JSR SETLJB
  346. TXA
  347. PHA
  348. ASL A
  349. TAX
  350. LDA #0
  351. STA BUFTAB,X
  352. JSR TYPFIL
  353. CMP #4
  354. BCS WRTC1 ;NOT SEQUENTIAL TYPE
  355. ;
  356. INC NBKL,X
  357. BNE WRTC1
  358. INC NBKH,X
  359. WRTC1 PLA
  360. TAX
  361. RTS
  362. ;
  363. ;
  364. ;****************************
  365. ;*
  366. ;* FNDRCH
  367. ;******************************
  368. ;*
  369. ;*
  370. FNDRCH LDA SA
  371. CMP #MAXSA+1
  372. BCC FNDC20
  373. AND #$F
  374. FNDC20
  375. CMP #CMDSA
  376. BNE FNDC25
  377. LDA #ERRSA
  378. FNDC25
  379. TAX
  380. SEC
  381. LDA LINTAB,X
  382. BMI FNDC30
  383. AND #$F
  384. STA LINDX
  385. TAX
  386. CLC
  387. FNDC30 RTS
  388. ;
  389. ;
  390. ;*
  391. ;*
  392. ;*****************************
  393. ;*
  394. ;* FNDWCH
  395. ;*
  396. ;*****************************
  397. ;*
  398. ;*
  399. FNDWCH LDA SA
  400. CMP #MAXSA+1
  401. BCC FNDW13
  402. AND #$F
  403. FNDW13 TAX
  404. LDA LINTAB,X
  405. TAY
  406. ASL A
  407. BCC FNDW15
  408. BMI FNDW20
  409. FNDW10 TYA
  410. AND #$0F
  411. STA LINDX
  412. TAX
  413. CLC
  414. RTS
  415. FNDW15 BMI FNDW10
  416. FNDW20 SEC
  417. RTS
  418. ;
  419. TYPFIL ;GET FILE TYPE
  420. LDX LINDX
  421. LDA FILTYP,X
  422. LSR A
  423. AND #7
  424. CMP #RELTYP
  425. RTS
  426. ;
  427. GETPRE JSR GETACT
  428. ASL A
  429. TAX
  430. LDY LINDX
  431. RTS
  432. .SKIP
  433. ; READ BYTE FROM ACTIVE BUFFER
  434. ; AND SET FLAG IF LAST DATA BYTE
  435. ; IF LAST THEN Z=1 ELSE Z=0 ;
  436. GETBYT JSR GETPRE
  437. LDA LSTCHR,Y
  438. BEQ GETB1
  439. LDA (BUFTAB,X)
  440. PHA
  441. LDA BUFTAB,X
  442. CMP LSTCHR,Y
  443. BNE GETB2
  444. LDA #$FF
  445. STA BUFTAB,X
  446. GETB2 PLA
  447. INC BUFTAB,X
  448. RTS
  449. GETB1 LDA (BUFTAB,X)
  450. INC BUFTAB,X
  451. RTS
  452. ;
  453. ;
  454. ; READ A CHAR FROM FILE AND READ NEXT
  455. ; BLOCK OF FILE IF NEEDED.
  456. ; SET CHNRDY=EOI IF END OF FILE
  457. ;
  458. RDBYT JSR GETBYT
  459. BNE RD3
  460. STA DATA
  461. .SKIP
  462. RD0 LDA LSTCHR,Y
  463. BEQ RD1
  464. LDA #EOIOUT
  465. RD01 STA CHNRDY,Y
  466. LDA DATA
  467. RTS
  468. RD1 JSR DBLBUF
  469. LDA #0
  470. JSR SETPNT
  471. JSR GETBYT
  472. CMP #0
  473. BEQ RD4
  474. STA TRACK
  475. JSR GETBYT
  476. STA SECTOR
  477. JSR DBLBUF
  478. JSR SETDRN
  479. JSR SETHDR
  480. JSR RDBUF
  481. JSR DBLBUF
  482. LDA DATA
  483. RD3 RTS
  484. RD4 JSR GETBYT
  485. LDY LINDX
  486. STA LSTCHR,Y
  487. LDA DATA
  488. RTS
  489. .SKIP 2
  490. .SKIP
  491. ; WRITE A CHAR TO CHANL AND WRITE
  492. ; BUFFER OUT TO DISK IF ITS FULL
  493. ;
  494. WRTBYT JSR PUTBYT
  495. BEQ WRT0
  496. RTS
  497. .SKIP
  498. WRT0 JSR SETDRN
  499. JSR NXTTS
  500. LDA #0
  501. JSR SETPNT
  502. LDA TRACK
  503. JSR PUTBYT
  504. LDA SECTOR
  505. JSR PUTBYT
  506. JSR WRTBUF
  507. JSR DBLBUF
  508. JSR SETHDR
  509. LDA #2
  510. JMP SETPNT
  511. ;
  512. ; INC POINTER OF ACTIVE BUFFER
  513. ; BY .A
  514. ;
  515. ;
  516. INCPTR ; SCOTT PATCH
  517. INCPNT STA TEMP
  518. JSR GETPNT
  519. CLC
  520. ADC TEMP
  521. STA BUFTAB,X
  522. STA DIRBUF
  523. RTS
  524. ; SET DRVNUM TO DRIVE INDICATED BY
  525. ; LSTJOB OF ACTIVE BUFFER
  526. ;
  527. SETDRN JSR GETACT
  528. TAX
  529. LDA LSTJOB,X
  530. AND #1
  531. STA DRVNUM
  532. RTS
  533. .END