-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathgcrcntrl.src
248 lines (188 loc) · 5.01 KB
/
gcrcntrl.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
.page
.subttl 'gcrcntrl.src'
; *contrl
; main controller loop
; scans job que for jobs
; finds job on current track
; if it exists
jlcc tsx ; save current stack pointer
stx savsp ; *
bit t1lc2 ; reset irq flag
lda pcr2 ; enable SO
ora #$0e
sta pcr2
jtop ldy #numjob-1 ; pointer into job que
2$ lda jobs,y ; find a job (msb set)
bmi 3$ ; branch if there is a job
dey
bpl 2$
jmp jend
3$ cmp #fread ; fast read cmd
bne 1$
jmp jread01 ; fill, same track read job
1$ cmp #jumpc ; jump cmd ?
bne 15$
jmp exdo
15$ and #drvmsk ; get drive #
beq 5$
sty jobn
lda #15
jmp jerrr ; bad drv
5$ tax
cmp cdrive ; test if current drive
beq 7$
sta cdrive
jsr turnon ; turn drive on
jmp jend ; go clean up
7$ lda drvst ; test if motor up to speed
bmi 8$
asl a ; test if stepping
bpl 9$ ; not stepping
8$ jmp jend
9$ lda #$20 ; status=running
sta drvst
ldy #numjob-1
sty jobn
10$ jsr jsetjb
bmi 11$
12$ dec jobn
bpl 10$
ldy nxtjob
jsr jsetjb1
lda nxtrk
sta steps
asl steps ; steps*2
lda #$60 ; set status=stepping
sta drvst
lda (hdrpnt),y ; get dest track #
sta drvtrk
jmp jend
11$ and #drvmsk ; test if same drive
cmp cdrive
bne 12$ ; test if current drive
lda drvtrk
beq 13$ ; uninit. track #
lda drvtrk ; we are here
cmp #36 ; destination
php ; save status
lda (hdrpnt),y ; destination
cmp #36
ror a ; rotate to sign bit
plp ; retrieve carry
and #$80 ; retrieve sign
bcc 16$ ; br, we are on side 0
bmi 17$ ; br, we are on side 1 & our dest is side 1
; a change ...
lda drvtrk ; we are on side 1 & and our dest is side 0
sbc #35 ; so decrement where we are
sta drvtrk
jmp 17$
16$ bpl 17$ ; br, we are on side 0 & our dest is side 0
; a change ...
lda drvtrk ; we are on side 0 & our dest is side 1
adc #35
sta drvtrk
17$ sec
lda (hdrpnt),y
sbc drvtrk
beq 13$ ; on track
sta nxtrk
lda jobn ; save job# and dist to track
sta nxtjob
jmp 12$
13$ ldx #4 ; set track and sector
lda (hdrpnt),y
sta tracc
cmp #36 ; second side ?
tay ; save track
jsr set_side ; adjust h/w and set appropiate flag
tya ; restore track
bcc 14$
sbc #35 ; track 36 is track 1 physically
14$ tax
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
; *** rom ds 11/7/86 ***, set density for tracks > 35
lda worktable-1,x
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
sta sectr ; select density
lda dskcnt
and #$9f ; clear density bits
ora sectr
sta dskcnt ; set density bits
lda num_sec-1,x
sta sectr ; get # of sector
lda job ; yes, go do the job
cmp #bump-$80 ; test for bump
beq jbmp
cmp #execd
beq exdo
cmp #frmt-$80 ; is it a format code
beq jfmt
jmp jseak ; do a sector seek
jfmt jmp jformt ; do the format
exdo lda jobn
clc
adc #>bufs
sta bufpnt+1
lda #0
sta bufpnt
jmp (bufpnt)
jbmp
lda #$60 ; set status=stepping
sta drvst
lda dskcnt
and #$ff-$03 ; set phase a
sta dskcnt
lda #256-92 ; step back 45 traks
sta steps
lda side ; what side are we on ?
bmi 1$
lda #$01 ; drvtrk now 1
.byte skip2
1$ lda #36 ; drvtrk now 36
sta drvtrk
lda #1
jmp jerrr
jsetjb ldy jobn
jsetjb1 lda jobs,y
pha
bpl 1$ ; no job here
and #$78
sta job
tya
asl a
adc #<hdrs ; hdrpnt,trk,sec for job
sta hdrpnt
lda #>hdrs
sta hdrpnt+1
tya ; point at buffer
clc
adc #>bufs
sta bufpnt+1
1$ ldy #0
sty bufpnt
pla
rts
set_side
bcs 1$
lda #0
.byte skip2
1$ lda #$84
sta side
lda pota1
and #$ff-4
ora side
sta pota1
rts
worktbl ; table of track densities
.byte $60,$60,$60,$60,$60,$60,$60,$60,$60,$60
.byte $60,$60,$60,$60,$60,$60,$60
.byte $40,$40,$40,$40,$40,$40,$40
.byte $20,$20,$20,$20,$20,$20
.byte $00,$00,$00,$00,$00
num_sec ; number of sectors per track
.byte 21,21,21,21,21,21,21,21,21,21
.byte 21,21,21,21,21,21,21
.byte 19,19,19,19,19,19,19
.byte 18,18,18,18,18,18
.byte 17,17,17,17,17