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.

lccseek.src 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. .page 'lcc.seek'
  2. ;
  3. ;
  4. ;
  5. seak ldx #90 ; search 90 headers
  6. stx tmp
  7. ;
  8. ldx #0 ; read in 8 gcr bytes
  9. ;
  10. lda #$52 ; header block id
  11. sta stab
  12. ;
  13. seek10 jsr sync ; find sync char
  14. ;
  15. bvc * ; wait for block id
  16. clv
  17. ;
  18. lda data2
  19. cmp stab ; test if header block
  20. bne seek20 ; not header
  21. ;
  22. seek15 bvc *
  23. clv ; read in gcr header
  24. ;
  25. lda data2
  26. sta stab+1,x
  27. ;
  28. inx
  29. cpx #7
  30. bne seek15
  31. ;
  32. jsr cnvbin ; convert header in stab to binary in header
  33. ;
  34. ldy #4 ; compute checksum
  35. lda #0
  36. ;
  37. seek30 eor header,y
  38. dey
  39. bpl seek30
  40. ;
  41. cmp #0 ; test if ok
  42. bne cserr ; nope, checksum error in header
  43. ;
  44. ldx cdrive ; update drive track#
  45. lda header+2
  46. sta drvtrk,x
  47. ;
  48. lda job ; test if a seek job
  49. cmp #$30
  50. beq eseek
  51. ;
  52. lda cdrive
  53. asl a ; test if correct id
  54. tay
  55. lda dskid,y
  56. cmp header
  57. bne badid
  58. lda dskid+1,y
  59. cmp header+1
  60. bne badid
  61. ;
  62. jmp wsect ; find best sector to service
  63. ;
  64. ;
  65. seek20 dec tmp ; search more?
  66. bne seek10 ; yes
  67. ;
  68. lda #2 ; cant find a sector
  69. jsr errr
  70. ;
  71. ;
  72. eseek lda header ; harris fix....
  73. sta dskid ; ....
  74. lda header+1 ; ....
  75. sta dskid+1 ; ....
  76. ;
  77. done lda #1 ; return ok code
  78. .byte skip2
  79. ;
  80. badid lda #11 ; disk id mismatch
  81. .byte skip2
  82. ;
  83. cserr lda #9 ; checksum error in header
  84. jmp errr
  85. ;
  86. ;
  87. ;
  88. wsect lda #$7f ; find best job
  89. sta csect
  90. ;
  91. lda header+3 ; get upcoming sector #
  92. clc
  93. adc #2
  94. cmp sectr
  95. bcc l460
  96. ;
  97. sbc sectr ; wrap around
  98. ;
  99. l460 sta nexts ; next sector
  100. ;
  101. ldx #numjob-1
  102. stx jobn
  103. ;
  104. ldx #$ff
  105. ;
  106. l480 jsr setjb
  107. bpl l470
  108. ;
  109. sta work
  110. and #1
  111. cmp cdrive ; test if same drive
  112. bne l470 ; nope
  113. ;
  114. ldy #0 ; test if same track
  115. lda (hdrpnt),y
  116. cmp tracc
  117. bne l470
  118. ;
  119. lda job ; test if execute job
  120. cmp #execd
  121. beq l465
  122. ;
  123. ldy #1
  124. sec
  125. lda (hdrpnt),y
  126. sbc nexts
  127. bpl l465
  128. ;
  129. clc
  130. adc sectr
  131. ;
  132. l465 cmp csect
  133. bcs l470
  134. ;
  135. pha ; save it
  136. lda job
  137. beq tstrdj ; must be a read
  138. ;
  139. pla
  140. cmp #wrtmin ; {if(csect<9)return;
  141. bcc l470 ; {if(csect>12)return;
  142. ;
  143. cmp #wrtmax
  144. bcs l470
  145. ;
  146. doitt sta csect ; its better
  147. lda jobn
  148. tax
  149. adc #>bufs
  150. sta bufpnt+1
  151. ;
  152. bne l470
  153. ;
  154. tstrdj pla
  155. cmp #rdmax ; if(csect>6)return;
  156. bcc doitt
  157. ;
  158. ;
  159. l470 dec jobn
  160. bpl l480
  161. ;
  162. txa ; test if a job to do
  163. bpl l490
  164. ;
  165. jmp end ; no job found
  166. ;
  167. l490 stx jobn
  168. jsr setjb
  169. lda job
  170. jmp reed
  171. ;
  172. ;
  173. ;
  174. ;
  175. cnvbin lda bufpnt
  176. pha
  177. lda bufpnt+1
  178. pha ; save buffer pntr
  179. ;
  180. lda #<stab
  181. sta bufpnt ; point at gcr code
  182. lda #>stab
  183. sta bufpnt+1
  184. ;
  185. lda #0
  186. sta gcrpnt
  187. ;
  188. jsr get4gb ; convert 4 bytes
  189. ;
  190. lda btab+3
  191. sta header+2
  192. ;
  193. lda btab+2
  194. sta header+3
  195. ;
  196. lda btab+1
  197. sta header+4
  198. ;
  199. ;
  200. jsr get4gb ; get 2 more
  201. ;
  202. lda btab ; get id
  203. sta header+1
  204. lda btab+1
  205. sta header
  206. ;
  207. pla
  208. sta bufpnt+1 ; restore pointer
  209. pla
  210. sta bufpnt
  211. ;
  212. rts
  213. ;
  214. ;
  215. ;
  216. ;
  217. ;
  218. ;
  219. ;
  220. ;.end