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.

358 lines
5.2KB

  1. .PAGE 'JOBS...SF'
  2. ;
  3. ; USE LASTJOB FOR DRIVE #
  4. ; CMD IS USED FOR JOB COMMAND
  5. ;
  6. SETLJB
  7. LDA LSTJOB,X
  8. AND #1
  9. ORA CMD
  10. ;
  11. ; SET JOB UP AND CHECK T&S
  12. ; .A=COMMAND FOR JOBS
  13. ; .X=JOB NUMBER
  14. ;
  15. SETJOB
  16. PHA
  17. STX JOBNUM
  18. TXA
  19. ;ASL A ;4/12*****************
  20. ;ASL A
  21. ASL A
  22. TAX
  23. LDA HDRS+1,X ;4/12***********
  24. STA CMD ;SAVE SECTOR
  25. LDA HDRS,X ;4/12***********
  26. BEQ TSERR
  27. ;
  28. CMP MAXTRK
  29. BCS TSERR ;TRACK TOO LARGE
  30. ;
  31. TAX
  32. PLA ;CHECK FOR WRITE
  33. PHA
  34. AND #$F0
  35. CMP #WRITE
  36. BNE SJB1 ;NOT WRITE,SKIP CHECK
  37. PLA
  38. PHA
  39. LSR A
  40. BCS SJB2 ;DRIVE 1
  41. ;
  42. LDA DSKVER ;GET VERSION #
  43. BCC SJB3
  44. SJB2
  45. LDA DSKVER+1 ;GET DRIVE 1 VER#
  46. SJB3
  47. BEQ SJB4 ;NO # IS OK, TOO
  48. CMP VERNUM
  49. BNE VNERR ;NOT SAME VERNUM #
  50. ;
  51. SJB4
  52. TXA ;RESTORE TRACK #
  53. JSR MAXSEC
  54. CMP CMD
  55. BEQ TSERR
  56. BCS SJB1 ;SECTOR IS OK!
  57. ;
  58. ;
  59. ; ILLEGAL TRACK AND SECTOR
  60. ;
  61. TSERR
  62. JSR HED2TS
  63. TSER1
  64. LDA #BADTS
  65. JMP CMDER2
  66. ;
  67. ;
  68. HED2TS
  69. LDA JOBNUM
  70. ; ASL A ;4/12*************
  71. ; ASL A
  72. ASL A
  73. TAX
  74. LDA HDRS,X ;4/12***********
  75. STA TRACK
  76. LDA HDRS+1,X ;4/12***********
  77. STA SECTOR
  78. RTS
  79. ;
  80. ;
  81. TSCHK
  82. LDA TRACK
  83. BEQ TSER1
  84. CMP MAXTRK
  85. BCS TSER1
  86. ;
  87. JSR MAXSEC
  88. CMP SECTOR
  89. BEQ TSER1
  90. BCC TSER1
  91. RTS
  92. ;
  93. VNERR
  94. JSR HED2TS
  95. LDA #CBMV2 ;WRITE TO WRONG VERSION
  96. JMP CMDER2
  97. ;
  98. SJB1
  99. LDX JOBNUM
  100. PLA
  101. STA CMD
  102. STA JOBS,X
  103. STA LSTJOB,X
  104. RTS
  105. ;
  106. ;
  107. ; DO JOB IN .A, SET UP ERROR COUNT
  108. ; AND LSTJOB. RETURN WHEN JOB DONE OK
  109. ; JMP TO ERROR IF ERROR RETURNS
  110. ;
  111. DOREAD
  112. LDA #READ
  113. BNE DOJOB ;BRA
  114. DOWRIT
  115. LDA #WRITE
  116. DOJOB
  117. ORA DRVNUM
  118. LDX JOBNUM
  119. ;
  120. DOIT STA CMD
  121. DOIT2 LDA CMD
  122. JSR SETJOB
  123. ; JMP WATJOB
  124. ;
  125. ; WAIT UNTIL JOB(.X) IS DONE
  126. ; RETURN WHEN DONE
  127. ;
  128. WATJOB JSR TSTJOB
  129. BCS WATJOB
  130. PHA ;CLR JOBRTN FLAG
  131. LDA #0
  132. STA JOBRTN
  133. PLA
  134. RTS
  135. ;
  136. ;
  137. ;TEST IF JOB(.X) IS DONE YET
  138. ;IF NOT DONE RETURN
  139. ;IF OK THEN RETURN ELSE REDO IT
  140. ;
  141. TSTJOB LDA JOBS,X
  142. BMI NOTYET
  143. CMP #2
  144. BCC OK
  145. ;
  146. CMP #8 ;CHECK FOR WP SWITCH ON
  147. BEQ TJ10
  148. ;
  149. CMP #11 ;CHECK FOR ID MISMATCH
  150. BEQ TJ10
  151. ;
  152. CMP #$F ;CHECK FOR NODRIVE
  153. BNE RECOV
  154. TJ10 BIT JOBRTN
  155. BMI OK
  156. JMP QUIT2
  157. ;
  158. OK CLC ;C=0 FINISHED OK OR QUIT
  159. RTS
  160. ;
  161. NOTYET SEC ;C=1 NOT YET
  162. RTS
  163. ;
  164. ;
  165. RECOV
  166. TYA ;SAVE .Y
  167. PHA
  168. LDA DRVNUM ;SAVE DRIVE #
  169. PHA
  170. LDA LSTJOB,X
  171. AND #1
  172. STA DRVNUM ;SET ACTIVE DRIVE #
  173. ;
  174. TAY
  175. LDA LEDMSK,Y
  176. STA ERLED
  177. ;
  178. JSR DOREC
  179. CMP #2
  180. BCS REC01
  181. JMP REC95
  182. REC01
  183. ;
  184. LDA LSTJOB,X ;ORIGINAL JOB
  185. AND #$F0 ;MASK JOB CODE
  186. PHA ;SAVE IT
  187. CMP #WRITE
  188. BNE REC0 ;NOT A WRITE
  189. ;
  190. LDA DRVNUM
  191. ORA #SECSEK ;REPLACE W/ SECTOR SEEK...
  192. STA LSTJOB,X ;... DURING RECOVERY
  193. REC0
  194. BIT REVCNT
  195. BVS REC5 ;NO TRACK OFFSET
  196. ;
  197. LDA #0
  198. STA EPTR ;CLR OFFSET TABLE PTR
  199. STA TOFF ;CLR TOTAL OFFSET
  200. REC1
  201. LDY EPTR
  202. LDA TOFF
  203. SEC
  204. SBC OFFSET,Y
  205. STA TOFF ;KEEP TRACK OF ALL OFFSETS
  206. LDA OFFSET,Y
  207. JSR HEDOFF
  208. ;
  209. INC EPTR ;BUMP TABLE PTR
  210. JSR DOREC ;DO THE RECOVERY
  211. CMP #2 ;ERROR CODE < 2?
  212. BCC REC3 ;JOB WORKED
  213. ;
  214. LDY EPTR
  215. LDA OFFSET,Y
  216. BNE REC1 ;NULL INDICATES END
  217. REC3
  218. LDA TOFF
  219. JSR HEDOFF
  220. ;
  221. LDA JOBS,X
  222. CMP #2
  223. BCC REC9 ;NO ERROR
  224. REC5
  225. BIT REVCNT ;CHECK BUMP-ON FLAG
  226. BPL REC7 ;NO BUMP
  227. ;
  228. QUIT
  229. PLA
  230. CMP #WRITE ;CHECK ORIGINAL JOB
  231. BNE QUIT2
  232. ;
  233. ORA DRVNUM
  234. STA LSTJOB,X ;MUST RESTORE ORIGINAL
  235. QUIT2
  236. LDA JOBS,X ;.A= ERROR #
  237. JSR ERROR
  238. REC7
  239. PLA
  240. BIT JOBRTN
  241. BMI REC95 ;RETURN JOB ERROR
  242. PHA
  243. ;
  244. ;DO THE BUMP
  245. LDA #BUMP
  246. ORA DRVNUM
  247. STA JOBS,X
  248. REC8
  249. LDA JOBS,X
  250. BMI REC8 ;WAIT
  251. ;
  252. JSR DOREC ;TRY ONE LAST SET
  253. CMP #2
  254. BCS QUIT ;IT CLEARLY AIN'T GONNA WORK
  255. REC9
  256. PLA ;CHECK ORIGINAL JOB FOR WRITE
  257. CMP #WRITE
  258. BNE REC95 ;ORIGINAL JOB WORKED
  259. ;
  260. ORA DRVNUM
  261. STA LSTJOB,X ;SET WRITE JOB BACK
  262. JSR DOREC ;TRY LAST SET OF WRITES
  263. CMP #2 ;CHECK ERROR CODE
  264. BCS QUIT2 ;ERROR
  265. REC95
  266. PLA
  267. STA DRVNUM ;RESTORE DRIVE #
  268. PLA
  269. TAY ;RESTORE .Y
  270. LDA JOBS,X
  271. CLC ;OK!
  272. RTS
  273. ;
  274. HEDOFF ;.A=OFFSET
  275. CMP #0
  276. BEQ HOF3 ;NO OFFSET
  277. BMI HOF2 ;STEPS ARE INWARD
  278. HOF1
  279. LDY #1 ;STEP OUT 1 TRACK
  280. JSR MOVHED
  281. SEC
  282. SBC #1
  283. BNE HOF1 ;NOT FINISHED
  284. BEQ HOF3
  285. HOF2
  286. LDY #$FF ;STEP IN 1 TRACK
  287. JSR MOVHED
  288. CLC
  289. ADC #1
  290. BNE HOF2 ; NOT FINISHED
  291. HOF3
  292. RTS
  293. ;
  294. MOVHED
  295. PHA ;SAVE .A
  296. TYA ;PUT PHASE IN .A
  297. LDY DRVNUM
  298. STA PHASE,Y
  299. MH10
  300. CMP PHASE,Y
  301. BEQ MH10 ;WAIT FOR CONTROLLER
  302. ;TO CHANGE IT
  303. LDA #0
  304. STA PHASE,Y ;CLEAR IT OUT
  305. PLA ;RESTORE
  306. RTS
  307. ;
  308. ;
  309. DOREC ;DO LAST JOB RECOVERY
  310. LDA REVCNT ;RE-TRY JOB REVCNT...
  311. AND #$3F ;...# OF TIMES
  312. TAY
  313. DOREC1
  314. LDA ERLED
  315. EOR LEDPRT
  316. STA LEDPRT
  317. LDA LSTJOB,X ;SET LAST JOB
  318. STA JOBS,X
  319. DOREC2
  320. LDA JOBS,X ;WAIT
  321. BMI DOREC2
  322. CMP #2
  323. BCC DOREC3 ;IT WORKED
  324. ;
  325. DEY
  326. BNE DOREC1 ;KEEP TRYING
  327. DOREC3
  328. PHA
  329. LDA ERLED ;LEAVE DRIVE LED ON
  330. ORA LEDPRT
  331. STA LEDPRT
  332. PLA
  333. RTS ;FINISHED
  334. ;
  335. ; SET HEADER OF ACTIVE BUFFER OF THE
  336. ; CURRENT LINDX TO TRACK,SECTOR,ID
  337. ;
  338. SETHDR JSR GETACT
  339. SETH
  340. ; ASL A ;4/12*****************
  341. ; ASL A
  342. ASL A
  343. TAY
  344. LDA TRACK
  345. STA HDRS,Y ;4/12*********** ;SET TRACK
  346. LDA SECTOR
  347. STA HDRS+1,Y ;4/12*********** ;SET SECTOR
  348. LDA DRVNUM ;GET PROPER ID(DRVNUM)
  349. ASL A
  350. TAX
  351. ; LDA DSKID,X
  352. ; STA HDRS,Y ;4/12***********
  353. ; LDA DSKID+1,X
  354. ; STA HDRS+1,Y ;4/12***********
  355. RTS
  356. ;
  357. .END