-
Notifications
You must be signed in to change notification settings - Fork 82
/
lccend.src
217 lines (155 loc) · 3 KB
/
lccend.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
.page
.subttl lccend
;
; motor and stepper control
;
; irq into controller every 8 ms
end lda t1hl2 ;set irq timer
sta t1hc2
lda dskcnt
end001 and #$10 ;test write proctect
cmp lwpt
sta lwpt ;change ?
beq end002 ;no
lda #1 ;yes, set flag
sta wpsw
end002 lda phase ;test for phase offset
beq end40
cmp #2
bne end003
lda #0 ;phase <-- 0
sta phase
beq end40
end003 sta steps
lda #2 ;phase <-- 2
sta phase
jmp dostep
end40 ldx cdrive ;work on active drive only
bmi end33x ;no active drive
lda drvst ;test if motor on
tay
cmp #$20 ;test if anything to do
bne end10 ;something here
end33x jmp end33 ;motor just running
end10 dec acltim ;dec timer
bne end30
tya ;test if acel
bpl end20
and #$7f ;over, clear acel bit
sta drvst
end20 and #$10 ;test if time out state
beq end30
lda dskcnt
and #$ff-$04 ;turnoff motor
sta dskcnt
lda #$ff ;no active drive now
sta cdrive
lda #0 ;drive inactive
sta drvst ;clear on bit and timout
beq end33x
end30 tya ;test if step needed
and #$40
bne end30x ;stepping
jmp end33
end30x jmp (nxtst) ;goto proper stepper state
inact lda steps ;get abs(steps)
bpl inac10
eor #$ff
clc
adc #1
inac10 cmp minstp ;test if we can accel
bcs inac20 ;too small
lda #<short ;short step mode
sta nxtst
lda #>short
sta nxtst+1
bne dostep
inac20 sbc as ;calc the # of run steps
sbc as
sta rsteps
lda as
sta aclstp ;set # of accel steps
lda #<ssacl
sta nxtst
lda #>ssacl
sta nxtst+1
dostep lda steps
bpl stpin
;---------rom05-bc 09/12/84--------
stpout inc steps ;FAB 1541-II patch removed due to no photosensor
ldx dskcnt
dex
pppppp jmp stp
;stpout jmp patch9 ;check track 0 (photo sensor)
; nop
; nop
; nop
;pppppp jmp stp ;goto step
;----------------------------------
short lda steps ;step end ?
bne dostep ;no
lda #<setle ;settle
sta nxtst
lda #>setle
sta nxtst+1
lda #5 ;settle time (5*8=40ms)
sta aclstp
jmp end33
setle dec aclstp ;settle end ?
bne end33 ;no
lda drvst
and #$ff-$40
sta drvst
lda #<inact
sta nxtst
lda #>inact
sta nxtst+1
jmp end33
stpin dec steps
ldx dskcnt
inx
stp txa
and #3
sta tmp
lda dskcnt
and #$ff-$03 ;mask out old
ora tmp
sta dskcnt
jmp end33
ssacl sec ;sub acel factor
lda t1hl2
sbc af
sta t1hc2
dec aclstp
bne ssa10
lda as
sta aclstp
lda #<ssrun
sta nxtst
lda #>ssrun
sta nxtst+1
ssa10 jmp dostep
ssrun dec rsteps
bne ssa10
lda #<ssdec
sta nxtst
lda #>ssdec
sta nxtst+1
bne ssa10
ssdec lda t1hl2 ;decel
clc
adc af
sta t1hc2
dec aclstp
bne ssa10
lda #<setle ;goto settle mode
sta nxtst
lda #>setle
sta nxtst+1
lda #5
sta aclstp ;settle timer
end33 lda pcr2 ;disable s.o. to 6502
and #$ff-$02
sta pcr2
rts
; .end