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.

211 lines
2.7KB

  1. .PAGE 'LCC.END'
  2. ;
  3. ;
  4. ;
  5. ; MOTOR AND STEPPER CONTROL
  6. ;
  7. ;
  8. ; IRQ INTO CONTROLLER EVERY 10 MS
  9. END
  10. LDA T1HL2
  11. STA T1HC2
  12. ;
  13. LDA DSKCNT
  14. ;
  15. END001
  16. AND #$10 ; TEST WRITE PROCTECT
  17. CMP LWPT
  18. STA LWPT ; CHANGE ?
  19. BEQ END002 ; NO
  20. ;
  21. LDA #1 ; YES, SET FLAG
  22. STA WPSW
  23. ;
  24. END002 LDA PHASE ; TEST FOR PHASE OFFSET
  25. BEQ END40
  26. ;
  27. CMP #2
  28. BNE END003
  29. ;
  30. LDA #0
  31. STA PHASE
  32. BEQ END40
  33. ;
  34. END003 STA STEPS
  35. LDA #2
  36. STA PHASE
  37. JMP DOSTEP
  38. ;
  39. END40 LDX CDRIVE ; WORK ON ACTIVE DRIVE ONLY
  40. BMI END33X ; NO ACTIVE DRIVE
  41. ;
  42. LDA DRVST ; TEST IF MOTOR ON
  43. TAY
  44. CMP #$20 ; TEST IF ANYTHING TO DO
  45. BNE END10 ; SOMETHING HERE
  46. ;
  47. END33X JMP END33 ; MOTOR JUST RUNNING
  48. ;
  49. END10 DEC ACLTIM ; DEC TIMER
  50. BNE END30
  51. ;
  52. TYA ; TEST IF ACEL
  53. BPL END20
  54. ;
  55. ;
  56. AND #$7F ; OVER, CLEAR ACEL BIT
  57. STA DRVST
  58. ;
  59. END20 AND #$10 ; TEST IF TIME OUT STATE
  60. BEQ END30
  61. ;
  62. LDA DSKCNT
  63. AND #$FF-$04 ; TURNOFF MOTOR
  64. STA DSKCNT
  65. ;
  66. ;
  67. LDA #$FF ; NO ACTIVE DRIVE NOW
  68. STA CDRIVE
  69. ;
  70. LDA #0 ; DRIVE INACTIVE
  71. STA DRVST ; CLEAR ON BIT AND TIMOUT
  72. BEQ END33X
  73. ;
  74. END30 TYA ; TEST IF STEP NEEDED
  75. AND #$40
  76. BNE END30X ; STEPPING
  77. ;
  78. JMP END33
  79. ;
  80. ;
  81. END30X JMP (NXTST) ;GOTO PROPER STEPPER STATE
  82. ;
  83. INACT LDA STEPS ; GET ABS(STEPS)
  84. BPL INAC10
  85. ;
  86. EOR #$FF
  87. CLC
  88. ADC #1
  89. ;
  90. INAC10 CMP MINSTP ; TEST IF WE CAN ACCEL
  91. BCS INAC20 ; TOO SMALL
  92. ;
  93. LDA #<SHORT ;SHORT STEP MODE
  94. STA NXTST
  95. LDA #>SHORT
  96. STA NXTST+1
  97. BNE DOSTEP
  98. ;
  99. INAC20 ; CALC THE # OF RUN STEPS
  100. SBC AS
  101. SBC AS
  102. STA RSTEPS
  103. ;
  104. LDA AS
  105. STA ACLSTP ; SET # OF ACCEL STEPS
  106. LDA #<SSACL
  107. STA NXTST
  108. LDA #>SSACL
  109. STA NXTST+1
  110. ;
  111. DOSTEP LDA STEPS
  112. BPL STPIN
  113. ;
  114. STPOUT INC STEPS
  115. LDX DSKCNT
  116. DEX
  117. JMP STP
  118. ;
  119. SHORT LDA STEPS
  120. BNE DOSTEP
  121. ;
  122. LDA #<SETLE
  123. STA NXTST
  124. LDA #>SETLE
  125. STA NXTST+1
  126. LDA #5 ; SETTLE TIME
  127. STA ACLSTP
  128. JMP END33
  129. ;
  130. SETLE DEC ACLSTP
  131. BNE END33
  132. ;
  133. LDA DRVST
  134. AND #$FF-$40
  135. STA DRVST
  136. ;
  137. LDA #<INACT
  138. STA NXTST
  139. LDA #>INACT
  140. STA NXTST+1
  141. JMP END33
  142. ;
  143. STPIN DEC STEPS
  144. LDX DSKCNT
  145. INX
  146. ;
  147. STP TXA
  148. AND #3
  149. STA TMP
  150. LDA DSKCNT
  151. AND #$FF-$03 ; MASK OUT OLD
  152. ORA TMP
  153. STA DSKCNT
  154. JMP END33
  155. ;
  156. SSACL ; SUB ACEL FACTOR
  157. SEC
  158. LDA T1HL2
  159. SBC AF
  160. STA T1HC2
  161. ;
  162. DEC ACLSTP
  163. BNE SSA10
  164. ;
  165. LDA AS
  166. STA ACLSTP
  167. ;
  168. LDA #<SSRUN
  169. STA NXTST
  170. LDA #>SSRUN
  171. STA NXTST+1
  172. ;
  173. SSA10 JMP DOSTEP
  174. ;
  175. SSRUN DEC RSTEPS
  176. BNE SSA10
  177. ;
  178. LDA #<SSDEC
  179. STA NXTST
  180. LDA #>SSDEC
  181. STA NXTST+1
  182. BNE SSA10
  183. ;
  184. SSDEC ; DECEL
  185. LDA T1HL2
  186. CLC
  187. ADC AF
  188. STA T1HC2
  189. ;
  190. DEC ACLSTP
  191. BNE SSA10
  192. ;
  193. LDA #<SETLE ; GOTO SETTLE MODE
  194. STA NXTST
  195. LDA #>SETLE
  196. STA NXTST+1
  197. ;
  198. LDA #5
  199. STA ACLSTP ; SETTLE TIMER
  200. ;
  201. ;
  202. END33 LDA PCR2 ; DISABLE S.O. TO 6502
  203. AND #$FF-$02
  204. STA PCR2
  205. ;
  206. RTS
  207. ;
  208. ;
  209. ;
  210. .END