-
Notifications
You must be signed in to change notification settings - Fork 82
/
lccseek.src
213 lines (146 loc) · 2.73 KB
/
lccseek.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
.page
.subttl lccseek
seak ldx #90 ;search 90 headers
stx tmp
ldx #0 ;read in 8 gcr bytes
lda #$52 ;header block id
sta stab
seek10 jsr sync ;find sync char
bvc * ;wait for block id
clv
lda data2
cmp stab ;test if header block
bne seek20 ;not header
seek15 bvc *
clv ;read in gcr header
lda data2
sta stab+1,x
inx
cpx #7
bne seek15
jsr cnvbin ;convert header in stab to binary in header
ldy #4 ;compute checksum
lda #0
seek30 eor header,y
dey
bpl seek30
cmp #0 ;test if ok
bne cserr ;nope, checksum error in header
ldx cdrive ;update drive track#
lda header+2
sta drvtrk,x
lda job ;test if a seek job
cmp #$30
beq eseek
lda cdrive
asl a ;test if correct id
tay
lda dskid,y
cmp header
bne badid
lda dskid+1,y
cmp header+1
bne badid
jmp wsect ;find best sector to service
seek20 dec tmp ;search more?
bne seek10 ;yes
lda #2 ;cant find a sector
jsr errr
eseek lda header ;harris fix....
sta dskid ;....
lda header+1 ;....
sta dskid+1 ;....
done lda #1 ;return ok code
.byte skip2
badid lda #11 ;disk id mismatch
.byte skip2
cserr lda #9 ;checksum error in header
jmp errr
wsect lda #$7f ;find best job
sta csect
lda header+3 ;get upcoming sector #
clc
adc #2
cmp sectr
bcc l460
sbc sectr ;wrap around
l460 sta nexts ;next sector
ldx #numjob-1
stx jobn
ldx #$ff
l480 jsr setjb
bpl l470
sta work
and #1
cmp cdrive ;test if same drive
bne l470 ;nope
ldy #0 ;test if same track
lda (hdrpnt),y
cmp tracc
bne l470
lda job ;test if execute job
cmp #execd
beq l465
ldy #1
sec
lda (hdrpnt),y
sbc nexts
bpl l465
clc
adc sectr
l465 cmp csect
bcs l470
pha ;save it
lda job
beq tstrdj ;must be a read
pla
cmp #wrtmin ;{if(csect<9)return;
bcc l470 ;{if(csect>12)return;
cmp #wrtmax
bcs l470
doitt sta csect ;its better
lda jobn
tax
adc #>bufs
sta bufpnt+1
bne l470
tstrdj pla
cmp #rdmax ;if(csect>6)return;
bcc doitt
l470 dec jobn
bpl l480
txa ;test if a job to do
bpl l490
jmp end ;no job found
l490 stx jobn
jsr setjb
lda job
jmp reed
cnvbin lda bufpnt
pha
lda bufpnt+1
pha ;save buffer pntr
lda #<stab
sta bufpnt ;point at gcr code
lda #>stab
sta bufpnt+1
lda #0
sta gcrpnt
jsr get4gb ;convert 4 bytes
lda btab+3
sta header+2
lda btab+2
sta header+3
lda btab+1
sta header+4
jsr get4gb ;get 2 more
lda btab ;get id
sta header+1
lda btab+1
sta header
pla
sta bufpnt+1 ;restore pointer
pla
sta bufpnt
rts
; .end