-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathopchnl
460 lines (459 loc) · 5.83 KB
/
opchnl
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
.PAGE 'OPEN CHANNEL'
; OPCHNL
;
; OPEN A READ CHANL WITH 2 BUFFERS
; WILL INSERT SA IN LINTAB
; AND INITS ALL POINTERS.
; RELATIVE SS AND PTRS ARE SET.
;
OPNRCH LDA #2 ;GET TWO DATA BUFFERS
JSR GETRCH
JSR INTPNT ;CLEAR POINTERS
LDA TYPE
PHA
ASL A
ORA DRVNUM
STA FILTYP,X ;SET FILE TYPE
JSR STRDBL ;READ 1ST ONE OR TWO BLOCKS
LDX LINDX
LDA TRACK
BNE OR10
;
LDA SECTOR
STA LSTCHR,X ;SET LAST CHAR PTR
OR10
PLA
CMP #RELTYP
BNE OR30 ;MUST BE SEQUENTIAL STUFF
;
LDY SA
LDA LINTAB,Y ;SET CHANNEL AS R/W
ORA #$40
STA LINTAB,Y
;
;
LDA REC
STA RS,X ;SET RECORD SIZE
;
JSR GETBUF ;GET SS BUFFER
BPL OR20
JMP GBERR ;NO BUFFER
OR20
LDX LINDX
STA SS,X
LDY TRKSS ;SET SS TRACK
STY TRACK
LDY SECSS ;SET SS SECTOR
STY SECTOR
JSR SETH ;SET SS HEADER
JSR RDSS ;READ IT IN
JSR WATJOB
OROW
;
LDX LINDX
LDA #2
STA NR,X ;SET FOR NXTREC
;
LDA #0
JSR SETPNT ;SET FIRST DATA BYTE
;
JSR RD40 ;SET UP 1ST RECORD
JMP GETHDR ;RESTORE T&S
;
OR30
JSR RDBYT ;SEQUENTIAL SET UP
LDX LINDX
STA CHNDAT,X
LDA #RDYTLK
STA CHNRDY,X
RTS
;
; INITIALIZE VARIABLES FOR OPEN CHANL
; LSTJOB,SETS ACTIVE BUFFER#,LSTCHR,
; BUFFER POINTERS IN BUFTAB=2
;
INTPNT LDX LINDX
LDA DRVNUM
LDY BUF0,X
STA LSTJOB,Y
LDY BUF1,X
STA LSTJOB,Y
STA JOBS,Y
LDA BUF0,X
ASL A
TAY
LDA #2
STA BUFTAB,Y
LDA BUF1,X
ORA #$80
STA BUF1,X
ASL A
TAY
LDA #2
STA BUFTAB,Y
LDA #0
STA NBKL,X
STA NBKH,X
LDA #0
STA LSTCHR,X
RTS
;
;
; OPEN A WRITE CHANL WITH 2 BUFFERS
OPNWCH JSR INTTS ;GET FIRST TRACK,SECTOR
LDA #2
JSR GETWCH ;GET 2 BUFFERS FOR WRITING
JSR SETHDR ;SET UP BUFFER HEADERS
JSR INTPNT ;ZROPNT
LDX LINDX
LDA TYPE
PHA
ASL A
ORA DRVNUM
STA FILTYP,X ;SET FILTYP=SEQ
PLA
CMP #RELTYP
BEQ OW10
LDA #RDYLST ; ACTIVE LISTENER
STA CHNRDY,X
RTS
;
OW10
LDY SA
LDA LINTAB,Y
AND #$3F
ORA #$40
STA LINTAB,Y ;SET CHANNEL AS R/W
;
LDA REC
STA RS,X ;SET RECORD SIZE
;
JSR GETBUF ;GET SS BUFFER
BPL OW20
JMP GBERR ;NO BUFFER
OW20
LDX LINDX
STA SS,X
JSR CLRBUF
;
JSR NXTTS
LDA TRACK
STA TRKSS ;SAVE SS T&S
LDA SECTOR
STA SECSS
;
LDX LINDX
LDA SS,X
JSR SETH ;SET SS HEADER
LDA #0
JSR SETSSP
LDA #0 ;SET NULL LINK
JSR PUTSS
LDA #SSIOFF+1 ;SET LAST CHAR
JSR PUTSS
LDA #0 ;SET THIS SS #
JSR PUTSS
LDA REC ;RECORD SIZE
JSR PUTSS
LDA TRACK
JSR PUTSS
LDA SECTOR
JSR PUTSS
LDA #SSIOFF
JSR SETSSP
JSR GETHDR ;GET FIRST T&S
LDA TRACK
JSR PUTSS
LDA SECTOR
JSR PUTSS
;
JSR WRTSS ;WRITE IT OUT
JSR WATJOB
LDA #2
JSR SETPNT
;
LDX LINDX
SEC
LDA #0
SBC RS,X
STA NR,X
;
JSR NULBUF ;NULL RECORDS
JSR NULLNK
JSR WRTOUT
JSR WATJOB
JMP OROW
;
;*
;*
;***********************
;*
;* PUTSS
;*
;* PUT BYTE INTO SIDE SECTOR
;*
;***********************
;*
;*
PUTSS PHA
LDX LINDX
LDA SS,X
JMP PUTB1
;
.END
OR BOTH DRIVES
BPL ID20
JSR TOGDRV
JSR SETLDS
JSR INITDR
JSR TOGDRV
ID20 JMP ENDCMD
.SKIP
; INITIALIZE DRIVE (DRVNUM)
;
INITSU
LDA DRVNUM ;DO A BUMP TO TRK 1
CLC ;READ IN BIT MAP (18.00)
ADC #BAMJOB ; AND SAVE DISK ID
STA JOBNUM
LDX #18
STX TRACK
LDX #0
STX SECTOR
JSR SETH
LDX JOBNUM
LDA DRVNUM
ORA #SEEK
JMP DOIT
;
INITDR JSR CLDCHN
JSR INITSU
LDA #0
STA HDRS+3,Y
LDA DRVNUM
ORA #READ
JSR DOIT
LDA DRVNUM
ASL A
TAX
LDA HDRS,Y
STA DSKID,X
LDA HDRS+1,Y
STA DSKID+1,X
RTS
;
;
; START DOUBLE BUFFERING
; USE TRACK,SECTOR AS STARTING BLOACK
;
STRDBL JSR GETACT
JSR SETHDR
JSR RDBUF
JSR WATJOB
JSR GETBYT
STA TRACK
JSR GETBYT
STA SECTOR
LDA TRACK
BNE STR1
RTS
STR1 JSR DBLBUF
JSR SETHDR
JSR RDBUF
JMP DBLBUF
;
; START A READ JOB ON TRACK,SECTOR
;
RDBUF LDA #READ
BNE STRTIT
;
; START A WRITE JOB ON TRACK,SECTOR
;
WRTBUF LDA #WRITE
STRTIT STA CMD
JSR GETACT
TAX
JSR SETLJB
TXA
PHA
ASL A
TAX
LDA #0
STA BUFTAB,X
JSR TYPFIL
CMP #4
BCS WRTC1 ;NOT SEQUENTIAL TYPE
;
INC NBKL,X
BNE WRTC1
INC NBKH,X
WRTC1 PLA
TAX
RTS
;
;
;****************************
;*
;* FNDRCH
;******************************
;*
;*
FNDRCH LDA SA
CMP #MAXSA+1
BCC FNDC20
AND #$F
FNDC20
CMP #CMDSA
BNE FNDC25
LDA #ERRSA
FNDC25
TAX
SEC
LDA LINTAB,X
BMI FNDC30
AND #$F
STA LINDX
TAX
CLC
FNDC30 RTS
;
;
;*
;*
;*****************************
;*
;* FNDWCH
;*
;*****************************
;*
;*
FNDWCH LDA SA
CMP #MAXSA+1
BCC FNDW13
AND #$F
FNDW13 TAX
LDA LINTAB,X
TAY
ASL A
BCC FNDW15
BMI FNDW20
FNDW10 TYA
AND #$0F
STA LINDX
TAX
CLC
RTS
FNDW15 BMI FNDW10
FNDW20 SEC
RTS
;
TYPFIL ;GET FILE TYPE
LDX LINDX
LDA FILTYP,X
LSR A
AND #7
RTS
;
GETPRE JSR GETACT
ASL A
TAX
LDY LINDX
RTS
.SKIP
; READ BYTE FROM ACTIVE BUFFER
; AND SET FLAG IF LAST DATA BYTE
; IF LAST THEN Z=1 ELSE Z=0 ;
GETBYT JSR GETPRE
LDA LSTCHR,Y
BEQ GETB1
LDA (BUFTAB,X)
PHA
LDA BUFTAB,X
CMP LSTCHR,Y
BNE GETB2
LDA #$FF
STA BUFTAB,X
GETB2 PLA
INC BUFTAB,X
RTS
GETB1 LDA (BUFTAB,X)
INC BUFTAB,X
RTS
;
;
; READ A CHAR FROM FILE AND READ NEXT
; BLOCK OF FILE IF NEEDED.
; SET CHNRDY=EOI IF END OF FILE
;
RDBYT JSR GETBYT
BNE RD3
STA DATA
.SKIP
RD0 LDA LSTCHR,Y
BEQ RD1
LDA #EOIOUT
RD01 STA CHNRDY,Y
LDA DATA
RTS
RD1 JSR DBLBUF
JSR GETBYT
CMP #0
BEQ RD4
STA TRACK
JSR GETBYT
STA SECTOR
JSR DBLBUF
JSR SETDRN
JSR SETHDR
JSR RDBUF
JSR DBLBUF
LDA DATA
RD3 RTS
RD4 JSR GETBYT
LDY LINDX
STA LSTCHR,Y
LDA DATA
RTS
.SKIP 2
.SKIP
; WRITE A CHAR TO CHANL AND WRITE
; BUFFER OUT TO DISK IF ITS FULL
;
WRTBYT JSR PUTBYT
BEQ WRT0
RTS
.SKIP
WRT0 JSR SETDRN
JSR NXTTS
LDA TRACK
JSR PUTBYT
LDA SECTOR
JSR PUTBYT
JSR WRTBUF
LDA #2
JSR SETPNT
JSR DBLBUF
JMP SETHDR
;
; INC POINTER OF ACTIVE BUFFER
; BY .A
;
;
INCPTR ; SCOTT PATCH
INCPNT STA TEMP
JSR GETPNT
CLC
ADC TEMP
STA BUFTAB,X
STA DIRBUF
RTS
; SET DRVNUM TO DRIVE INDICATED BY
; LSTJOB OF ACTIVE BUFFER
;
SETDRN JSR GETACT
TAX
LDA LSTJOB,X
AND #1
STA DRVNUM
RTS
.END