-
Notifications
You must be signed in to change notification settings - Fork 84
/
jobs
341 lines (341 loc) · 4.84 KB
/
jobs
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
.PAGE 'JOBS'
;
; USE LASTJOB FOR DRIVE #
; CMD IS USED FOR JOB COMMAND
;
SETLJB
LDA LSTJOB,X
AND #1
ORA CMD
;
; SET JOB UP AND CHECK T&S
; .A=COMMAND FOR JOBS
; .X=JOB NUMBER
;
SETJOB
PHA
STX JOBNUM
TXA
ASL A
ASL A
ASL A
TAX
LDA HDRS+3,X
STA CMD ;SAVE SECTOR
LDA HDRS+2,X
BEQ TSERR
;
CMP MAXTRK
BCS TSERR ;TRACK TOO LARGE
;
TAX
PLA ;CHECK FOR WRITE
PHA
AND #$F0
CMP #WRITE
BNE SJB1 ;NOT WRITE,SKIP CHECK
PLA
PHA
LSR A
BCS SJB2 ;DRIVE 1
;
LDA BAM0+2 ;GET VERSION #
BCC SJB3
SJB2
LDA BAM1+2 ;GET DRIVE 1 VER#
SJB3
BEQ SJB4 ;NO # IS OK, TOO
CMP VERNUM
BNE VNERR ;NOT SAME VERNUM #
;
SJB4
TXA ;RESTORE TRACK #
JSR MAXSEC
CMP CMD
BEQ TSERR
BCS SJB1 ;SECTOR IS OK!
;
;
; ILLEGAL TRACK AND SECTOR
;
TSERR
JSR HED2TS
TSER1
LDA #BADTS
JMP CMDER2
;
;
HED2TS
LDA JOBNUM
ASL A
ASL A
ASL A
TAX
LDA HDRS+2,X
STA TRACK
LDA HDRS+3,X
STA SECTOR
RTS
;
;
TSCHK
LDA TRACK
BEQ TSER1
CMP MAXTRK
BCS TSER1
;
JSR MAXSEC
CMP SECTOR
BEQ TSER1
BCC TSER1
RTS
;
VNERR
JSR HED2TS
LDA #CBMV2 ;WRITE TO WRONG VERSION
JMP CMDER2
;
SJB1
LDX JOBNUM
PLA
STA CMD
STA JOBS,X
STA LSTJOB,X
RTS
;
;
; DO JOB IN .A, SET UP ERROR COUNT
; AND LSTJOB. RETURN WHEN JOB DONE OK
; JMP TO ERROR IF ERROR RETURNS
;
DOREAD
LDA #READ
BNE DOJOB ;BRA
DOWRIT
LDA #WRITE
DOJOB
ORA DRVNUM
LDX JOBNUM
;
DOIT STA CMD
DOIT2 LDA CMD
JSR SETJOB
; JMP WATJOB
;
; WAIT UNTIL JOB(.X) IS DONE
; RETURN WHEN DONE
;
WATJOB JSR TSTJOB
BCS WATJOB
PHA ;CLR JOBRTN FLAG
LDA #0
STA JOBRTN
PLA
RTS
;
;
;TEST IF JOB(.X) IS DONE YET
;IF NOT DONE RETURN
;IF OK THEN RETURN ELSE REDO IT
;
TSTJOB LDA JOBS,X
BMI NOTYET
CMP #2
BCC OK
;
CMP #8 ;CHECK FOR WP SWITCH ON
BEQ TJ10
;
CMP #11 ;CHECK FOR ID MISMATCH
BNE RECOV
TJ10
JMP QUIT2
;
OK CLC ;C=0 FINISHED OK OR QUIT
RTS
;
NOTYET SEC ;C=1 NOT YET
RTS
;
;
RECOV
TYA ;SAVE .Y
PHA
LDA DRVNUM ;SAVE DRIVE #
PHA
JSR DOREC
CMP #2
BCS REC01
JMP REC95
REC01
LDA LSTJOB,X
PHA ;SAVE ORIGINAL JOB FOR LATER
AND #1
STA DRVNUM ;SET ACTIVE DRIVE #
;
PLA ;ORIGINAL JOB
AND #$F0 ;MASK JOB CODE
PHA ;SAVE IT
CMP #WRITE
BNE REC0 ;NOT A WRITE
;
LDA DRVNUM
ORA #SECSEK ;REPLACE W/ SECTOR SEEK...
STA LSTJOB,X ;... DURING RECOVERY
REC0
BIT REVCNT
BVS REC5 ;NO TRACK OFFSET
;
LDA #0
STA EPTR ;CLR OFFSET TABLE PTR
STA TOFF ;CLR TOTAL OFFSET
REC1
LDY EPTR
LDA TOFF
SEC
SBC OFFSET,Y
STA TOFF ;KEEP TRACK OF ALL OFFSETS
LDA OFFSET,Y
JSR HEDOFF
;
INC EPTR ;BUMP TABLE PTR
JSR DOREC ;DO THE RECOVERY
CMP #2 ;ERROR CODE < 2?
BCC REC3 ;JOB WORKED
;
LDY EPTR
LDA OFFSET,Y
BNE REC1 ;NULL INDICATES END
REC3
LDA TOFF
JSR HEDOFF
;
LDA JOBS,X
CMP #2
BCC REC9 ;NO ERROR
REC5
BIT REVCNT ;CHECK BUMP-ON FLAG
BPL REC7 ;NO BUMP
;
QUIT
PLA
CMP #WRITE ;CHECK ORIGINAL JOB
BNE QUIT2
;
ORA DRVNUM
STA LSTJOB,X ;MUST RESTORE ORIGINAL
QUIT2
LDA JOBS,X ;.A= ERROR #
JSR ERROR
REC7 ;DO THE BUMP
LDA #BUMP
ORA DRVNUM
STA JOBS,X
REC8
LDA JOBS,X
BMI REC8 ;WAIT
;
JSR DOREC ;TRY ONE LAST SET
CMP #2
BCS QUIT ;IT CLEARLY AIN'T GONNA WORK
REC9
PLA ;CHECK ORIGINAL JOB FOR WRITE
CMP #WRITE
BNE REC95 ;ORIGINAL JOB WORKED
;
ORA DRVNUM
STA LSTJOB,X ;SET WRITE JOB BACK
JSR DOREC ;TRY LAST SET OF WRITES
CMP #2 ;CHECK ERROR CODE
BCS QUIT2 ;ERROR
REC95
PLA
STA DRVNUM ;RESTORE DRIVE #
PLA
TAY ;RESTORE .Y
LDA JOBS,X
CLC ;OK!
RTS
;
HEDOFF ;.A=OFFSET
CMP #0
BEQ HOF3 ;NO OFFSET
BMI HOF2 ;STEPS ARE INWARD
HOF1
LDY #1 ;STEP OUT 1 TRACK
JSR MOVHED
SEC
SBC #1
BNE HOF1 ;NOT FINISHED
BEQ HOF3
HOF2
LDY #$FF ;STEP IN 1 TRACK
JSR MOVHED
CLC
ADC #1
BNE HOF2 ; NOT FINISHED
HOF3
RTS
;
MOVHED
PHA ;SAVE .A
TYA ;PUT PHASE IN .A
LDY DRVNUM
STA PHASE,Y
MH10
CMP PHASE,Y
BEQ MH10 ;WAIT FOR CONTROLLER
;TO CHANGE IT
LDA #0
STA PHASE,Y ;CLEAR IT OUT
PLA ;RESTORE
RTS
;
;
DOREC ;DO LAST JOB RECOVERY
LDA REVCNT ;RE-TRY JOB REVCNT...
AND #$3F ;...# OF TIMES
TAY
DOREC1
LDA ERRPRT
EOR #ERRLED
STA ERRPRT
LDA LSTJOB,X ;SET LAST JOB
STA JOBS,X
DOREC2
LDA JOBS,X ;WAIT
BMI DOREC2
CMP #2
BCC DOREC3 ;IT WORKED
;
DEY
BNE DOREC1 ;KEEP TRYING
DOREC3
PHA
JSR ERROFF
PLA
RTS ;FINISHED
;
; SET HEADER OF ACTIVE BUFFER OF THE
; CURRENT LINDX TO TRACK,SECTOR,ID
;
SETHDR JSR GETACT
SETH
ASL A
ASL A
ASL A
TAY
LDA TRACK
STA HDRS+2,Y ;SET TRACK
LDA SECTOR
STA HDRS+3,Y ;SET SECTOR
LDA DRVNUM ;GET PROPER ID(DRVNUM)
ASL A
TAX
LDA DSKID,X
STA HDRS,Y
LDA DSKID+1,X
STA HDRS+1,Y
RTS
;
.END