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.

tst2.src 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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. ; initialize drive (drvnum)
  217. ;
  218. itrial
  219. jsr bam2a
  220. tay ; bam lindx from buf0
  221. ldx buf0,y
  222. cpx #$ff
  223. bne it30 ; valid buffer #
  224. ;
  225. pha ; save bam-lindx
  226. jsr getbuf ; get a buffer
  227. tax ; test it
  228. bpl it20 ; no error
  229. ;
  230. lda #nochnl
  231. jsr cmder3
  232. it20
  233. pla
  234. tay ; restore bam-lindx
  235. txa
  236. ora #$80 ; set inactive
  237. sta buf0,y
  238. it30
  239. txa
  240. and #$f ; stip to buf #
  241. sta jobnum
  242. ldx #0
  243. stx sector
  244. ldx dirtrk
  245. stx track
  246. jsr seth ; set the bam header
  247. lda #seek
  248. jmp dojob ; do a seek
  249. ;
  250. ;
  251. initdr
  252. jsr clnbam
  253. jsr cldchn
  254. jsr itrial
  255. ldx drvnum
  256. lda #0
  257. sta mdirty,x
  258. txa
  259. asl a
  260. tax
  261. lda header
  262. sta dskid,x
  263. lda header+1
  264. sta dskid+1,x
  265. jsr doread
  266. lda jobnum
  267. asl a
  268. tax
  269. lda #2
  270. sta buftab,x
  271. lda (buftab,x)
  272. ldx drvnum
  273. sta dskver,x ; set up disk version #
  274. ;
  275. lda #0
  276. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  277. jmp ptch21 ; *rom ds 09/03/85* *GCB 11/20/86*
  278. nop ; fill
  279. ; sta wpsw,x ; clear wp switch
  280. ; sta nodrv,x ; clear not active flag
  281. rtch21
  282. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  283. ;
  284. ; count the number of free blocks here
  285. ;
  286. nfcalc
  287. jsr setbpt
  288. ldy #4
  289. lda #0
  290. tax ; 0 hi byte
  291. numf1
  292. clc
  293. adc (bmpnt),y
  294. bcc numf2
  295. inx
  296. numf2
  297. iny
  298. iny
  299. iny
  300. iny
  301. cpy #$48 ; dont count the dir
  302. beq numf2
  303. cpy #$90
  304. bne numf1
  305. pha
  306. txa
  307. ldx drvnum
  308. sta ndbh,x
  309. pla
  310. sta ndbl,x
  311. ;
  312. rts
  313. ;
  314. ;
  315. ; start double buffering
  316. ; use track,sector as starting bloack
  317. ;
  318. strrd
  319. jsr sethdr
  320. jsr rdbuf
  321. jsr watjob
  322. jsr getbyt
  323. sta track
  324. jsr getbyt
  325. sta sector
  326. rts
  327. ;
  328. strdbl
  329. jsr strrd
  330. lda track
  331. bne str1
  332. rts
  333. str1
  334. jsr dblbuf
  335. jsr sethdr
  336. jsr rdbuf
  337. jmp dblbuf
  338. ;
  339. ; start a read job on track,sector
  340. ;
  341. rdbuf lda #read
  342. bne strtit
  343. ;
  344. ; start a write job on track,sector
  345. ;
  346. wrtbuf lda #write
  347. strtit sta cmd
  348. jsr getact
  349. tax
  350. jsr setljb
  351. txa
  352. pha
  353. asl a
  354. tax
  355. lda #0
  356. sta buftab,x
  357. jsr typfil
  358. cmp #4
  359. bcs wrtc1 ; not sequential type
  360. ;
  361. inc nbkl,x
  362. bne wrtc1
  363. inc nbkh,x
  364. wrtc1 pla
  365. tax
  366. rts
  367. ;
  368. ;
  369. ;****************************
  370. ;*
  371. ;* fndrch
  372. ;******************************
  373. ;*
  374. ;*
  375. fndrch lda sa
  376. cmp #maxsa+1
  377. bcc fndc20
  378. and #$f
  379. fndc20
  380. cmp #cmdsa
  381. bne fndc25
  382. lda #errsa
  383. fndc25
  384. tax
  385. sec
  386. lda lintab,x
  387. bmi fndc30
  388. and #$f
  389. sta lindx
  390. tax
  391. clc
  392. fndc30 rts
  393. ;
  394. ;
  395. ;*
  396. ;*
  397. ;*****************************
  398. ;*
  399. ;* fndwch
  400. ;*
  401. ;*****************************
  402. ;*
  403. ;*
  404. fndwch lda sa
  405. cmp #maxsa+1
  406. bcc fndw13
  407. and #$f
  408. fndw13 tax
  409. lda lintab,x
  410. tay
  411. asl a
  412. bcc fndw15
  413. bmi fndw20
  414. fndw10 tya
  415. and #$0f
  416. sta lindx
  417. tax
  418. clc
  419. rts
  420. fndw15 bmi fndw10
  421. fndw20 sec
  422. rts
  423. ;
  424. typfil ; get file type
  425. ldx lindx
  426. lda filtyp,x
  427. lsr a
  428. and #7
  429. cmp #reltyp
  430. rts
  431. ;
  432. getpre jsr getact
  433. asl a
  434. tax
  435. ldy lindx
  436. rts
  437. ; read byte from active buffer
  438. ; and set flag if last data byte
  439. ; if last then z=1 else z=0 ;
  440. getbyt jsr getpre
  441. lda lstchr,y
  442. beq getb1
  443. lda (buftab,x)
  444. pha
  445. lda buftab,x
  446. cmp lstchr,y
  447. bne getb2
  448. lda #$ff
  449. sta buftab,x
  450. getb2 pla
  451. inc buftab,x
  452. rts
  453. getb1 lda (buftab,x)
  454. inc buftab,x
  455. rts
  456. ;
  457. ;
  458. ; read a char from file and read next
  459. ; block of file if needed.
  460. ; set chnrdy=eoi if end of file
  461. ;
  462. rdbyt jsr getbyt
  463. bne rd3
  464. sta data
  465. rd0 lda lstchr,y
  466. beq rd1
  467. lda #eoiout
  468. rd01 sta chnrdy,y
  469. lda data
  470. rts
  471. rd1 jsr dblbuf
  472. lda #0
  473. jsr setpnt
  474. jsr getbyt
  475. cmp #0
  476. beq rd4
  477. sta track
  478. jsr getbyt
  479. sta sector
  480. jsr dblbuf
  481. jsr setdrn
  482. jsr sethdr
  483. jsr rdbuf
  484. jsr dblbuf
  485. lda data
  486. rd3 rts
  487. rd4 jsr getbyt
  488. ldy lindx
  489. sta lstchr,y
  490. lda data
  491. rts
  492. ; write a char to chanl and write
  493. ; buffer out to disk if its full
  494. ;
  495. wrtbyt jsr putbyt
  496. beq wrt0
  497. rts
  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