-
Notifications
You must be signed in to change notification settings - Fork 1
/
DISKIO2.TXT
464 lines (422 loc) · 8.01 KB
/
DISKIO2.TXT
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
NAM DISKIO
*(C) 1986 BY GREG MILLER*
* Modified: 9/28/87 *
DF EQU 56
NE EQU 52
IO2 EQU 40
OPENI2 PSHS X,D,Y,U
BSR OPENI1
PULS X,D,Y,U,PC
OPENI1 LDX #$94C
JSR PARSE
*FIND DIR ENTRY
LEAX 11,X
LDD ,X
STD FTYPE
STD $957
LDD 3,X
STD BLSECT
LDA 2,X
STA GRAN
JSR GRNTRK
STD >$EC
PSHS D
LDX #$600
STX >$EE
JSR DSKON2 GET FDATA!
LDX #$700
STX >$EE
LDX #$1102
STX >$EC
JSR DSKON2 GET GAT
PULS D
STD >$EC
LDA GRAN
STA GRANX
LDX #$700
LDA A,X
STA GRAN
LDX #$600
STX DATPNT
CLR EOFFLG
CLR >$70
LDA #'I
STA OPSTAT
RTS
OPSTAT FCB 0
*OPSTAT=0 IF ALL CLOSED
*='I IF OPEN FOR INPUT
*='O IF OPEN FOR OUTPUT
GRANX FCB 0
*EOF FLAG.. 0=NOT, 255=YES!
EOFFLG FCB 0
*LGRN=FLAG FOR "LAST GRAN"
LGRN2 RMB 1
GETBYT PSHS X,B,Y,U
BSR GETBY1
PULS X,B,Y,U,PC
GETBY1 CLR EOFFLG
CLR >$70
PSHS X,B,Y,U
CLR LGRN2
LDA GRAN
CMPA #$C0
BLO D@
STA LGRN2
D@ LDX DATPNT
LDA ,X+
STX DATPNT
PSHS A
TST LGRN2
BEQ E@
LDA LGRN2
SUBA #$C0
PSHS A
LDA >$ED
CMPA #10
BLO F@
SUBA #9
F@ CMPA ,S+
BNE E@
LDD BLSECT
BEQ GEND
TFR X,D
*
SUBD #$600
CLRA
*
CMPD BLSECT
BLO E@
GEND LDA #255
STA EOFFLG
STA >$70
BRA C@
E@ CMPX #$700
BHS A@
C@ PULS A
PULS X,B,Y,U,PC
A@ LDX #$600
STX >$EE
STX DATPNT
LDA >$ED
CMPA #9
BEQ R@
CMPA #18
BEQ R@
INCA
STA >$ED
BRA S@
R@ LDA GRAN
JSR GRNTRK
STD >$EC
JSR DSKON2
LDA GRAN
LDY #$700
LDA A,Y
STA GRAN
BRA C@
S@ LDA #2
STA >$EA
JSR DSKON2
TST LGRN2
BEQ C@
LDA >$ED
CMPA #10
BLO WE1
SUBA #9
WE1 LDA GRAN
ANDA #15
BEQ WEZ
PSHS A
LDA GRAN
ANDA #15
CMPA ,S+
BNE C@
PSHS D
LDD BLSECT
PULS D
BNE C@
WEZ LDA #255
STA >$70
STA EOFFLG
BRA C@
*DATPNT=POINTER TO NEXT BYTE IN DATA... WHEN REACHES $700, NEXT TRACK, SECTOR ARE READ IN..
DATPNT RMB 2
FTYPE RMB 2
*GRAN=NEXT GRAN DOWN THE LINE
GRAN RMB 1
*ENTER A (GRAN)
*EXIT A,B (T,S)
GRNTRK TFR A,B
LSRA *DIV BY 2
ANDB #1
BEQ B@
LDB #10
BRA C@
B@ LDB #1
C@ CMPA #17
BLO ?RTS
INCA
RTS
*ENTER A,B (T,S)
*EXIT-A (GRAN)
TRKGRN CMPA #18
BLO A@
DECA
A@ LSLA
CMPB #10
BLO ?RTS
INCA
RTS
*parse.. PARSES FOR THE FILENAME IN THE DIRECTORY
*TO ENTER-X POINTS TO 13 CHAR FILENAME
*ON EXIT, X=POINTER TO FILENAME
*FROM DISK--IN MEMORY.. ALL
*OTHERS PRESERVED
PARSE BSR PARSE2
CMPX #0
BNE ?RTS
LDB #NE
JMP ERRLP
*PARSE2...
*X=0 THEN NON EXISTANT
*X<>0 THEN FILENAME @ X
PARSE2 PSHS D,Y,U,CC,DP
PSHS X
LDD #$1103
STD >$EC
DECB
STB >$EA
LDX #$600
STX >$EE
PLP1 JSR DSKON2
LDY #$600
PLP2 TST ,Y
BMI NEERR
BEQ B@
LDX ,S
LDB #11
A@ LDA ,X+
CMPA ,Y+
BNE B@
DECB
BNE A@
*GOOD FNAME
LEAS 2,S
TFR Y,D
ANDB #%11100000
TFR D,X
PULS D,Y,U,CC,DP,PC
B@ TFR Y,D
ANDB #%11100000
TFR D,Y
LEAY 32,Y
CMPY #$700
BNE PLP2
INC >$ED
BRA PLP1
NEERR LEAS 2,S
LDX #0
PULS D,Y,U,CC,DP,PC
DSKON2
JSR DSKCON
TST >$F0
BEQ ?RTS
LDB #IO2 *GEN. ?IO ERROR
JMP ERRLP
BLSECT RMB 2
KILL LDX #$94C
JSR PARSE
CLR ,X
LDA 13,X
PSHS A
LDA #3
STA >$EA
JSR DSKON2
LDA #2
STA >$ED
STA >$EA
LDX #$700
STX >$EE
JSR DSKON2
PULS A
A@ LDB A,X
PSHS B
LDB #255
STB A,X
PULS B
TFR B,A
CMPB #192
BLO A@
LDA #3
STA >$EA
JSR DSKON2
DEC >$EA
RTS
OPENO2 PSHS X,D,Y,U
BSR OPENO1
PULS X,D,Y,U,PC
M@ JSR KILL
OPENO1 LDX #$94C
JSR PARSE2
CMPX #0
BNE M@
LDA #'O
STA OPSTAT
LDD #$1102
STD >$EC
STB >$EA
LDX #$700
STX >$EE
JSR DSKON2
DEC >$EE
INC >$ED
JSR DSKON2
A@ LDY #$600
B@ TST ,Y
BMI C@
BEQ C@
LEAY 32,Y
CMPY #$700
BNE B@
INC >$ED
JSR DSKON2
BRA A@
C@ STY INMEM
LDD >$EC
STD TSEC2
JSR FGRN
STA FIRSTG
STA GRAN
LDY #$700
CLR A,Y
LDU #$600
STU OPOINT
JSR GRNTRK
STD >$EC
LDA #1
STA SECTOR
LDA >$EA
CMPA #2
BNE D@
RTS
D@ RTS
OPOINT RMB 2
SECTOR RMB 1
U@ LDX #$600
STX OPOINT
STX >$EE
LDA #3
STA >$EA
JSR DSKON2
DEC >$EA
INC >$ED
RTS
WRTBY2
PSHS X,D,Y,U
BSR OUTB
PULS X,D,Y,U,PC
OUTB LDX OPOINT
STA ,X+
STX OPOINT
CMPX #$700
BNE ?RTS
LDA SECTOR
INCA
STA SECTOR
CMPA #10
BNE U@
LDX #$600
STX >$EE
STX OPOINT
LDA #3
STA >$EA
JSR DSKON2
LDA #1
STA SECTOR
DEC >$EA
JSR FGRN
LDB GRAN
LDY #$700
STA B,Y
CLR A,Y
STA GRAN
JSR GRNTRK
STD >$EC
JSR DSKON2
RTS
FGRN PSHS X,B,Y,U
LDY #$700
LDB #68
A@ LDA ,Y
CMPA #255
BEQ B@
LEAY 1,Y
DECB
BNE A@
LDB #DF
JMP ERRLP
B@ TFR Y,D
TFR B,A
PULS X,B,Y,U,PC
FIRSTG RMB 1
INMEM RMB 2
TSEC2 RMB 2
CLOSE2 PSHS X,D,Y,U
BSR CLOSE1
PULS X,D,Y,U,PC
CLOSE1 LDA OPSTAT
CMPA #'I
BEQ ?RTS
TST OPSTAT
BEQ ?RTS
CLR OPSTAT
LDX #$600
STX >$EE
LDA #3
STA >$EA
LDD >$EC
JSR DSKON2 *OUT LAST BYTES
LDA SECTOR
ORA #192
LDB GRAN
LDY #$700
STA B,Y
LDX #$700
STX >$EE
LDD #$1102
STD >$EC
INCB
STB >$EA
JSR DSKON2
LDD TSEC2
STD >$EC
LDA #2
STA >$EA
LDX #$600
STX >$EE
JSR DSKON2
LDX INMEM
LDY #$94C
A@ LDA ,Y+
STA ,X+
CMPY #$959
BNE A@
LDX INMEM
LDA FIRSTG
STA 13,X
LDD OPOINT
SUBD #$600
STD 14,X
LDA #3
STA >$EA
JSR DSKON2
DEC >$EA
RTS
ERRLP CLR OPSTAT
JSR $18E
* JMP $AC46
RBYTE FDB 0
RSEC FCB 0
RGRN FCB 0
END