-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathcmds
321 lines (321 loc) · 6.27 KB
/
cmds
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
.PAG 'COMMANDS'
;
; MODE 001 (9)
; WRITE
;
WRITE CMP #$10
BNE VRFY
;
JSR CHKBLK
STA CHKSUM
;
LDA PB
AND #08 ; ISOLATE WRITE PROTECT BIT
BEQ L198 ; BRANCH IF OK
;
L104 JMP ERROR
;
L198 JSR SRCH ; GET CORRECT BLOCK
;
LDX GAP1 ; LOAD WAIT GAP 1
L200 BVC L200 ;WAIT X CHARS
CLV
DEX
BNE L200
;
LDA #WRTSYN ; WRITE SYNC MODE
STA PCR
LDA #WRTDAT
;
LDX #$FF ; LOAD FILL CODE
JSR OUT2 ; WRITE 4 SYNC CHARS OUT
JSR OUT2 ; 1 ST
;
L202 BVC L202 ; 4 TH
CLV
;
STA PCR ; STORE NORMAL CODE MODE
;
LDA #7
STA DOUT ; 2ND SYNC
;
LDY #0
.PAGE
; WRITE BLOCK
L203 BVC L203
CLV
;
LDA (BUFPT),Y
STA DOUT
;
;
INY
BNE L203 ; LOOP FOR WHOLE BLOCK
;
LDX CHKSUM ; WRITE OUT CKSUM
L204 BVC L204
CLV
STX DOUT
JSR OUT ; SEND A BYTE
LDX #00
JSR OUT ; SEND A BYTE
LDA #$FC ; NORMAL, READ MODE
;
L442 BVC L442 ; TEST IF BYTE PRESENT
CLV
;
STA PCR ; CHANGE TO SEND SYNC
;
LDX #40
L205 JSR BYTE
DEX
BNE L205
;
LDY JOBNUM
LDA JOBS,Y ; LOAD OLD WRITE JOB
EOR #$30 ; MAKE INTO VERIFY
STA JOBS,Y
JMP FSNUM ; FIX SECTOR# FOR NEXT JOB
.PAGE
; MODE= 010 (A)
; VERIFY
;
VRFY CMP #$20
BNE SECSEK ; SECTOR SEEK
JSR DSTRT ; START READING DATA
;
L210 BVC L210 ;NO TIME FOR JSR
CLV
;
LDA DIN ; GET BYTE
CMP (BUFPT),Y ; COMPARE TO CONTENTS OF BUFFER
BNE L212 ; VERIFY ERROR
;
INY
BNE L210 ; 256 BYTES
JMP L101 ; COMPARE CKSUM BYTES
L212 LDA #7 ; VERIFY ERROR
BNE ERR2
;
; END READING DATA
.PAG
;
; MODE= 011 (B) X011 100D
; SECTOR SEEK
;
SECSEK
JSR SRCH ; GET CORRECT BLOCK
BEQ DONE ; JUMP TO DONE
.PAGE
; SEEK TO DETERMINE NEXT SECTOR#
;
SEEK
;
LDX #180 ; READ HEADER
JSR HEAD ; GET BLOCK HEAD
;
LDY #5-1
L250 BVC L250
CLV
LDA DIN ; GET BYTE
STA STAB,Y ; STORE IN TABLE
DEY
BPL L250 ; LOOP
;
LDY #4 ; CREATE CKSUM
LDA #0
L254 EOR STAB,Y
DEY
BPL L254
;
CMP #0
BNE CSERR ; BRANCH IF ERROR
;
LDX DRIVE ;INDEX BY DRIVE#
LDA STAB+2
STA DRVTRK,X ; UPDATE CORRECT TRACK#
;
LDA JOB ; LOAD JOB TYPE
CMP #$30 ; TEST IF SEEK
BEQ ESEEK ; BRANCH IF YES
;
LDY #1
;
L252 LDA (HDRPT),Y ; LOAD ID
CMP STAB,Y ; CHECK IF SAME AS HEADER
BNE L253 ; BRANCH IF MISMATCH
;
DEY
BPL L252 ; LOOP
;
JMP FSNUM1 ; DECIDE WHICH SECTORS TO SERVICE
.PAGE
; MODE= 011 (B)
; SEEK
;
ESEEK
;
LDY #4
L251 LDA STAB,Y ; LOAD HEADER
STA (HDRPT),Y ; STORE HEADER
DEY
BPL L251 ; LOOP FOR WHOLE HEADER
;
DONE LDA #1 ; ERROR CODE FOR NO ERROR
.BYTE SKIP2
CSERR LDA #9
.BYTE SKIP2
L253 LDA #11
ERR2 JMP ERROR ; JUMP TO ERROR
;
.PAGE
; SEARCH FOR SPECIFIC BLOCK
;
SRCH LDY #4-1
LDA #0
;
L412 EOR (HDRPT),Y ; COMPUTE CHECKSUM
DEY
BPL L412
;
LDY #4 ; OFFSET FOR CHECKSUM
STA (HDRPT),Y ; STORE CHECKSUM
;
LDY JOBNUM
LDX #180 ; SEARCH FOR A SECTOR
;
L410 JSR HEAD ; EVERY BYTE IN THE HEADER
LDY #5-1 ; MUST BE IDENTICAL
;
L411 BVC L411
CLV
;
LDA DIN
CMP (HDRPT),Y ; COMPARE TO HEADER
BNE L410 ; LOOP IF NOT RIGHT BLOCK
;
DEY
BPL L411 ; LOOP FOR WHOLE HEADER
;
INY ; SET Y TO 0
;
;
RTS
;
; SEARCH FOR BLOCK HEAD
;
HEAD CLI
DEX ; X HAS MAX # OF TRIALS
BNE L420 ; TRIALS LEFT
;
LDA #2 ; ERROR CODE
.PAGE
; SEND ERROR CODE
;
ERROR
LDY JOBNUM ; LOAD JOB#
STA JOBS,Y ; SEND JOB STATUS
PHA
;
LDA MTRCLK
LDX DRIVE
ADC CUTMT
STA MTRTM,X ; MAKE MOTOR STAY ON LONGER
;
JSR SETSRH
;
;
PLA ; LOAD ERROR TYPE
LSR A ; TEST IF OK EXIT
BNE L421 ; BRANCH IF NOT
;
JMP FSNUM ; LOOP FOR ALL SECTORS
;
L421 LDX #$3F
TXS ; PURGE STACK
JMP START ; GO TO NEXT JOB
;
L420 JSR SYNC ; GET A BYTE
CMP #$08 ; COMPARE TO START OF HEADER
BNE HEAD
RTS
;
; ERRORS:
; #1: NO ERROR
; #2: CAN'T FIND BLOCK HEAD
; #3: NO SYNC CHARACTER
; #4: DATA BLOCK NOT PRESENT
; #5: CHECKSUM ERROR
; #7: VERIFY ERROR
; #8: WRITE WITH WRITE PROTECT ON
; #9: CHECKSUM ERROR IN SEEKED HEADER
; #10: DATA RAN INTO NEXT HEADER
; #11: DISK ID MISMATCH
; #16: DECODING ERROR
.PAGE
;
; HUNT FOR SYNC CHARACTER
;
SYNC
LDA #30
STA SYNCS
SYNC1 JSR SETSRH ; GOTO SEARCH MODE
;
SEI
LDA #$80+80
STA TIMER ; 20 MS LIMIT
;
LDA #3 ; ERROR CODE
DEC SYNCS
BMI ERROR ; > 30 FALSE SYNCS
L430 BIT TIMER ; TEST IF OVER TIME LIMIT
BPL ERROR ; BRANCH IF OVER
BIT VB ; TEST IF SYNC PRESENT
BMI L430 ; LOOP UNTIL SYNC
;
LDY SYNDLY ; LOAD SYNCDLY
WATSYN BIT VB ; TEST SYNC PRESENT
BMI SYNC1 ; GONE, FIND AGAIN
DEY
BNE WATSYN ; 10 US PER LOOP DELAY
;
LDA VB ; GOTO READ MODE
ORA #PLLBIT
STA VB
;
BIT DIN ; RESET VIA LATCHING DATA
CLV
;
; GET A BYTE
;
BYTE BVC BYTE ; TEST IF BYTE PRESENT
CLV
;
LDA DIN ; LOAD BYTE
RTS
;
; BYTE TO BE SENT IS IN X
OUT2 JSR OUT ; DO 2 OUTS
OUT BVC OUT ;DATA IN 6530 WAS LATCHED
CLV
STX DOUT ;WRITE NEW BYTE INTO PA
RTS
;
;
CHKBLK LDA #0 ; CREATE BLOCK CHKSUM
TAY
CHKB10 EOR (BUFPT),Y
INY
BNE CHKB10
RTS
;
;
;
SETSRH LDA VB ; SET PLL INTO SEARCH MODE
AND #255-PLLBIT
STA VB
RTS
;
;
;
.END