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.

lccend.src 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. ;.page 'lcc.end'
  2. ;
  3. ;
  4. ;
  5. ; motor and stepper control
  6. ;
  7. ;
  8. ; irq into controller every 8 ms
  9. end
  10. lda t1hl2 ; set irq timer
  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 ; phase <-- 0
  31. sta phase
  32. beq end40
  33. ;
  34. end003 sta steps
  35. lda #2 ; phase <-- 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. ;---------rom05-bc 09/12/84--------
  115. ;stpout inc steps
  116. ;ldx dskcnt
  117. ;dex
  118. ;jmp stp
  119. stpout jmp patch9 ; check track 0 (photo sensor)
  120. nop ;
  121. nop ;
  122. nop ;
  123. pppppp jmp stp ; goto step
  124. ;----------------------------------
  125. ;
  126. short lda steps ; step end ?
  127. bne dostep ; no
  128. ;
  129. lda #<setle ; settle
  130. sta nxtst
  131. lda #>setle
  132. sta nxtst+1
  133. lda #5 ; settle time (5*8=40ms)
  134. sta aclstp
  135. jmp end33
  136. ;
  137. setle dec aclstp ; settle end ?
  138. bne end33 ; no
  139. ;
  140. lda drvst
  141. and #$ff-$40
  142. sta drvst
  143. ;
  144. lda #<inact
  145. sta nxtst
  146. lda #>inact
  147. sta nxtst+1
  148. jmp end33
  149. ;
  150. stpin dec steps
  151. ldx dskcnt
  152. inx
  153. ;
  154. stp txa
  155. and #3
  156. sta tmp
  157. lda dskcnt
  158. and #$ff-$03 ; mask out old
  159. ora tmp
  160. sta dskcnt
  161. jmp end33
  162. ;
  163. ssacl ; sub acel factor
  164. sec
  165. lda t1hl2
  166. sbc af
  167. sta t1hc2
  168. ;
  169. dec aclstp
  170. bne ssa10
  171. ;
  172. lda as
  173. sta aclstp
  174. ;
  175. lda #<ssrun
  176. sta nxtst
  177. lda #>ssrun
  178. sta nxtst+1
  179. ;
  180. ssa10 jmp dostep
  181. ;
  182. ssrun dec rsteps
  183. bne ssa10
  184. ;
  185. lda #<ssdec
  186. sta nxtst
  187. lda #>ssdec
  188. sta nxtst+1
  189. bne ssa10
  190. ;
  191. ssdec ; decel
  192. lda t1hl2
  193. clc
  194. adc af
  195. sta t1hc2
  196. ;
  197. dec aclstp
  198. bne ssa10
  199. ;
  200. lda #<setle ; goto settle mode
  201. sta nxtst
  202. lda #>setle
  203. sta nxtst+1
  204. ;
  205. lda #5
  206. sta aclstp ; settle timer
  207. ;
  208. ;
  209. end33 lda pcr2 ; disable s.o. to 6502
  210. and #$ff-$02
  211. sta pcr2
  212. ;
  213. rts
  214. ;
  215. ;
  216. ;
  217. ;.end