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.

223 lines
2.8KB

  1. .PAGE 'LCC.CNTRL'
  2. ;
  3. ;
  4. ;
  5. ; *CONTRL
  6. ;
  7. ; MAIN CONTROLLER LOOP
  8. ;
  9. ; SCANS JOB QUE FOR JOBS
  10. ;
  11. ; FINDS JOB ON CURRENT TRACK
  12. ; IF IT EXISTS
  13. ;
  14. LCC
  15. ;
  16. TSX ; SAVE CURRENT STACK POINTER
  17. STX SAVSP
  18. ;
  19. LDA T1LC2 ;RESET IRQ FLAG
  20. ;
  21. LDA PCR2 ; ENABLE S.O. TO 6502
  22. ORA #$0E ; HI OUTPUT
  23. STA PCR2
  24. ;
  25. ;
  26. ;
  27. TOP LDY #NUMJOB-1 ; POINTER INTO JOB QUE
  28. ;
  29. CONT10
  30. LDA JOBS,Y ; FIND A JOB (MSB SET)
  31. BPL CONT20 ; NOT ONE HERE
  32. ;
  33. CMP #JUMPC ; TEST IF ITS A JUMP COMMAND
  34. BNE CONT30
  35. ;
  36. TYA ; PUT JOB NUM IN .A
  37. JMP EX2
  38. ;
  39. ;
  40. CONT30
  41. AND #1 ; GET DRIVE #
  42. BEQ CONT35
  43. ;
  44. STY JOBN
  45. LDA #$0F ;BAD DRIVE # ERROR
  46. JMP ERRR
  47. ;
  48. CONT35 TAX
  49. STA DRIVE
  50. ;
  51. CMP CDRIVE ; TEST IF CURRENT DRIVE
  52. BEQ CONT40
  53. ;
  54. JSR TURNON ; TURN ON DRIVE
  55. LDA DRIVE
  56. STA CDRIVE
  57. JMP END ; GO CLEAN UP
  58. ;
  59. ;
  60. CONT40 LDA DRVST ; TEST IF MOTOR UP TO SPEED
  61. BMI CONT50
  62. ;
  63. ASL A ; TEST IF STEPPING
  64. BPL QUE ; NOT STEPPING
  65. ;
  66. CONT50 JMP END
  67. ;
  68. CONT20 DEY
  69. BPL CONT10
  70. ;
  71. JMP END
  72. ;
  73. ;
  74. ;
  75. ;
  76. QUE LDA #$20 ; STATUS=RUNNING
  77. STA DRVST
  78. ;
  79. LDY #NUMJOB-1
  80. STY JOBN
  81. ;
  82. QUE10 JSR SETJB
  83. BMI QUE20
  84. ;
  85. QUE05 DEC JOBN
  86. BPL QUE10
  87. ;
  88. ;
  89. LDY NXTJOB
  90. JSR SETJB1
  91. ;
  92. LDA NXTRK
  93. STA STEPS
  94. ASL STEPS ; STEPS*2
  95. ;
  96. LDA #$60 ; SET STATUS=STEPPING
  97. STA DRVST
  98. ;
  99. ;
  100. ;
  101. LDA (HDRPNT),Y ; GET DEST TRACK #
  102. STA DRVTRK
  103. FIN JMP END
  104. ;
  105. ;
  106. QUE20 AND #1 ; TEST IF SAME DRIVE
  107. CMP DRIVE
  108. BNE QUE05
  109. ;
  110. LDA DRVTRK
  111. BEQ GOTU ; UNINIT. TRACK #
  112. ;
  113. SEC ; CALC DISTANCE TO TRACK
  114. SBC (HDRPNT),Y
  115. BEQ GOTU ; ON TRACK
  116. ;
  117. EOR #$FF ; 2'S COMP
  118. STA NXTRK
  119. INC NXTRK
  120. ;
  121. LDA JOBN ; SAVE JOB# AND DIST TO TRACK
  122. STA NXTJOB
  123. ;
  124. JMP QUE05
  125. ;
  126. ;
  127. ;
  128. ;
  129. GOTU LDX #4 ; SET TRACK AND SECTR
  130. LDA (HDRPNT),Y
  131. STA TRACC
  132. ;
  133. GOTU10 CMP TRKNUM-1,X
  134. ;
  135. DEX
  136. BCS GOTU10
  137. ;
  138. LDA NUMSEC,X
  139. STA SECTR
  140. ;
  141. TXA ; SET DENSITY
  142. ASL A
  143. ASL A
  144. ASL A
  145. ASL A
  146. ASL A
  147. STA WORK
  148. ;
  149. LDA DSKCNT
  150. AND #$9F ; CLEAR DENSITY BITS
  151. ORA WORK
  152. STA DSKCNT
  153. ;
  154. LDX DRIVE ; DRIVE NUM IN .X
  155. ;
  156. LDA JOB ; YES, GO DO THE JOB
  157. CMP #BUMPC ; TEST FOR BUMP
  158. BEQ BMP
  159. ;
  160. ;
  161. EXE CMP #EXECD ; TEST IF EXECUTE
  162. BEQ EX
  163. ;
  164. JMP SEAK ; DO A SECTOR SEEK
  165. ;
  166. EX LDA JOBN ; JUMP TO BUFFER
  167. EX2 CLC
  168. ADC #>BUFS
  169. STA BUFPNT+1
  170. LDA #0
  171. STA BUFPNT
  172. EX3 JMP (BUFPNT)
  173. ;
  174. ;
  175. BMP
  176. LDA #$60 ; SET STATUS=STEPPING
  177. STA DRVST
  178. ;
  179. LDA DSKCNT
  180. AND #$FF-$03 ; SET PHASE A
  181. STA DSKCNT
  182. ;
  183. ;
  184. ;
  185. LDA #256-92 ; STEP BACK 45 TRAKS
  186. STA STEPS
  187. ;
  188. LDA #1 ; DRVTRK NOW 1
  189. STA DRVTRK
  190. ;
  191. JMP ERRR ; JOB DONE RETURN 1
  192. ;
  193. ;
  194. ;
  195. ;
  196. ;
  197. SETJB LDY JOBN
  198. SETJB1 LDA JOBS,Y
  199. PHA
  200. BPL SETJ10 ; NO JOB HERE
  201. ;
  202. AND #$78
  203. STA JOB
  204. TYA
  205. ASL A
  206. ADC #<HDRS
  207. STA HDRPNT
  208. TYA ; POINT AT BUFFER
  209. CLC
  210. ADC #>BUFS
  211. STA BUFPNT+1
  212. ;
  213. ;
  214. SETJ10 LDY #0
  215. STY BUFPNT
  216. ;
  217. PLA
  218. RTS
  219. ;
  220. ;
  221. ;
  222. .END