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.

342 lines
4.8KB

  1. .PAGE 'JOBS'
  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
  20. ASL A
  21. ASL A
  22. TAX
  23. LDA HDRS+3,X
  24. STA CMD ;SAVE SECTOR
  25. LDA HDRS+2,X
  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 BAM0+2 ;GET VERSION #
  43. BCC SJB3
  44. SJB2
  45. LDA BAM1+2 ;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
  71. ASL A
  72. ASL A
  73. TAX
  74. LDA HDRS+2,X
  75. STA TRACK
  76. LDA HDRS+3,X
  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. BNE RECOV
  151. TJ10
  152. JMP QUIT2
  153. ;
  154. OK CLC ;C=0 FINISHED OK OR QUIT
  155. RTS
  156. ;
  157. NOTYET SEC ;C=1 NOT YET
  158. RTS
  159. ;
  160. ;
  161. RECOV
  162. TYA ;SAVE .Y
  163. PHA
  164. LDA DRVNUM ;SAVE DRIVE #
  165. PHA
  166. JSR DOREC
  167. CMP #2
  168. BCS REC01
  169. JMP REC95
  170. REC01
  171. LDA LSTJOB,X
  172. PHA ;SAVE ORIGINAL JOB FOR LATER
  173. AND #1
  174. STA DRVNUM ;SET ACTIVE DRIVE #
  175. ;
  176. PLA ;ORIGINAL JOB
  177. AND #$F0 ;MASK JOB CODE
  178. PHA ;SAVE IT
  179. CMP #WRITE
  180. BNE REC0 ;NOT A WRITE
  181. ;
  182. LDA DRVNUM
  183. ORA #SECSEK ;REPLACE W/ SECTOR SEEK...
  184. STA LSTJOB,X ;... DURING RECOVERY
  185. REC0
  186. BIT REVCNT
  187. BVS REC5 ;NO TRACK OFFSET
  188. ;
  189. LDA #0
  190. STA EPTR ;CLR OFFSET TABLE PTR
  191. STA TOFF ;CLR TOTAL OFFSET
  192. REC1
  193. LDY EPTR
  194. LDA TOFF
  195. SEC
  196. SBC OFFSET,Y
  197. STA TOFF ;KEEP TRACK OF ALL OFFSETS
  198. LDA OFFSET,Y
  199. JSR HEDOFF
  200. ;
  201. INC EPTR ;BUMP TABLE PTR
  202. JSR DOREC ;DO THE RECOVERY
  203. CMP #2 ;ERROR CODE < 2?
  204. BCC REC3 ;JOB WORKED
  205. ;
  206. LDY EPTR
  207. LDA OFFSET,Y
  208. BNE REC1 ;NULL INDICATES END
  209. REC3
  210. LDA TOFF
  211. JSR HEDOFF
  212. ;
  213. LDA JOBS,X
  214. CMP #2
  215. BCC REC9 ;NO ERROR
  216. REC5
  217. BIT REVCNT ;CHECK BUMP-ON FLAG
  218. BPL REC7 ;NO BUMP
  219. ;
  220. QUIT
  221. PLA
  222. CMP #WRITE ;CHECK ORIGINAL JOB
  223. BNE QUIT2
  224. ;
  225. ORA DRVNUM
  226. STA LSTJOB,X ;MUST RESTORE ORIGINAL
  227. QUIT2
  228. LDA JOBS,X ;.A= ERROR #
  229. JSR ERROR
  230. REC7 ;DO THE BUMP
  231. LDA #BUMP
  232. ORA DRVNUM
  233. STA JOBS,X
  234. REC8
  235. LDA JOBS,X
  236. BMI REC8 ;WAIT
  237. ;
  238. JSR DOREC ;TRY ONE LAST SET
  239. CMP #2
  240. BCS QUIT ;IT CLEARLY AIN'T GONNA WORK
  241. REC9
  242. PLA ;CHECK ORIGINAL JOB FOR WRITE
  243. CMP #WRITE
  244. BNE REC95 ;ORIGINAL JOB WORKED
  245. ;
  246. ORA DRVNUM
  247. STA LSTJOB,X ;SET WRITE JOB BACK
  248. JSR DOREC ;TRY LAST SET OF WRITES
  249. CMP #2 ;CHECK ERROR CODE
  250. BCS QUIT2 ;ERROR
  251. REC95
  252. PLA
  253. STA DRVNUM ;RESTORE DRIVE #
  254. PLA
  255. TAY ;RESTORE .Y
  256. LDA JOBS,X
  257. CLC ;OK!
  258. RTS
  259. ;
  260. HEDOFF ;.A=OFFSET
  261. CMP #0
  262. BEQ HOF3 ;NO OFFSET
  263. BMI HOF2 ;STEPS ARE INWARD
  264. HOF1
  265. LDY #1 ;STEP OUT 1 TRACK
  266. JSR MOVHED
  267. SEC
  268. SBC #1
  269. BNE HOF1 ;NOT FINISHED
  270. BEQ HOF3
  271. HOF2
  272. LDY #$FF ;STEP IN 1 TRACK
  273. JSR MOVHED
  274. CLC
  275. ADC #1
  276. BNE HOF2 ; NOT FINISHED
  277. HOF3
  278. RTS
  279. ;
  280. MOVHED
  281. PHA ;SAVE .A
  282. TYA ;PUT PHASE IN .A
  283. LDY DRVNUM
  284. STA PHASE,Y
  285. MH10
  286. CMP PHASE,Y
  287. BEQ MH10 ;WAIT FOR CONTROLLER
  288. ;TO CHANGE IT
  289. LDA #0
  290. STA PHASE,Y ;CLEAR IT OUT
  291. PLA ;RESTORE
  292. RTS
  293. ;
  294. ;
  295. DOREC ;DO LAST JOB RECOVERY
  296. LDA REVCNT ;RE-TRY JOB REVCNT...
  297. AND #$3F ;...# OF TIMES
  298. TAY
  299. DOREC1
  300. LDA ERRPRT
  301. EOR #ERRLED
  302. STA ERRPRT
  303. LDA LSTJOB,X ;SET LAST JOB
  304. STA JOBS,X
  305. DOREC2
  306. LDA JOBS,X ;WAIT
  307. BMI DOREC2
  308. CMP #2
  309. BCC DOREC3 ;IT WORKED
  310. ;
  311. DEY
  312. BNE DOREC1 ;KEEP TRYING
  313. DOREC3
  314. PHA
  315. JSR ERROFF
  316. PLA
  317. RTS ;FINISHED
  318. ;
  319. ; SET HEADER OF ACTIVE BUFFER OF THE
  320. ; CURRENT LINDX TO TRACK,SECTOR,ID
  321. ;
  322. SETHDR JSR GETACT
  323. SETH
  324. ASL A
  325. ASL A
  326. ASL A
  327. TAY
  328. LDA TRACK
  329. STA HDRS+2,Y ;SET TRACK
  330. LDA SECTOR
  331. STA HDRS+3,Y ;SET SECTOR
  332. LDA DRVNUM ;GET PROPER ID(DRVNUM)
  333. ASL A
  334. TAX
  335. LDA DSKID,X
  336. STA HDRS,Y
  337. LDA DSKID+1,X
  338. STA HDRS+1,Y
  339. RTS
  340. ;
  341. .END