-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathlookup
402 lines (402 loc) · 6.05 KB
/
lookup
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
.PAGE 'LOOKUP-OPTSCH'
;
; OPTSCH: OPTIMAL SEARCH FOR LOOKUP
; AND FNDFIL
;
OPTSCH
LDA #0 ; DETERMINE OPTIMAL SEARCH
STA TEMP ; INIT DRIVE MASK
STA DRVFLG
PHA
LDX F2CNT
OS10
PLA
ORA TEMP
PHA
LDA #1
STA TEMP
DEX
BMI OS30
LDA FILDRV,X
BPL OS15
ASL TEMP
ASL TEMP
OS15
LSR A
BCC OS10
ASL TEMP
BNE OS10 ; JUMP
OS30
PLA
TAX
LDA SCHTBL-1,X
PHA
AND #3
STA DRVCNT
PLA
ASL A
BPL OS40
LDA FILDRV
OS35
AND #1
STA DRVNUM
LDA DRVCNT
BEQ OS60 ; ONLY 1 DRIVE ADDRESSED
JSR AUTOI ; CHECK FOR AUTO INIT
BEQ OS50 ; DRIVE IS ACTIVE
JSR TOGDRV
LDA #0 ; SET 1 DRIVE ADDRESSED
STA DRVCNT
JSR AUTOI ; CHECK FOR AUTO INIT
BEQ OS70 ; DRIVE IS ACTIVE
OS45
LDA #NODRIV
JSR CMDERR ; NO DRIVE ERROR
OS50
JSR TOGDRV
JSR AUTOI
PHP
JSR TOGDRV
PLP
BEQ OS70
LDA #0
STA DRVCNT ; SET 1 DRIVE ADDRESSED
BEQ OS70 ; JUMP
OS60
JSR AUTOI
BNE OS45 ; DRIVE NOT ACTIVE
OS70
JMP SETLDS
OS40
ROL A
JMP OS35
;
SCHTBL
.BYTE 0,$80,$41
.BYTE 1,1,1,1
.BYTE $81,$81,$81,$81
.BYTE $42,$42,$42,$42
.PAGE 'LOOKUP/FNDFIL'
;
; LOOK UP ALL FILES IN STREAM
; AND FILL TABLES W/INFO
;
LOOKUP
JSR OPTSCH
LK05
LDA #0
STA DELIND
JSR SRCHST ; START SEARCH
BNE LK25
LK10
DEC DRVCNT
BPL LK15
RTS ; NO MORE DRIVE SEARCHES
LK15
LDA #1 ; TOGGLE DRIVE #
STA DRVFLG
JSR TOGDRV
JSR SETLDS ; TURN ON LED
JMP LK05
LK20
JSR SEARCH ; FIND VALID FILE NAME
BEQ LK30 ; END OF SEARCH
LK25
JSR COMPAR ; COMPARE DIR W/TABLE
LDA FOUND ; FOUND FLAG
BEQ LK26 ; ALL NAME'S NOT FOUND, YET
RTS
LK26
LDA ENTFND
BMI LK20
BPL LK25
LK30
LDA FOUND
BEQ LK10
RTS
;
; FIND NEXT FILE NAME MATCHING
; ANY FILE IN STREAM & RETURN
; WITH ENTRY FOUND STUFFED INTO
; TABLES
;
FFRE
JSR SRRE ; FIND FILE RE-ENTRY
BEQ FF10
BNE FF25
FF15
LDA #1
STA DRVFLG
JSR TOGDRV
JSR SETLDS
FFST
LDA #0 ; FIND FILE START ENTRY
STA DELIND
JSR SRCHST
BNE FF25
STA FOUND
FF10
LDA FOUND
BNE FF40
DEC DRVCNT
BPL FF15
RTS
FNDFIL
JSR SEARCH ; FIND FILE CONTINUOUS...
BEQ FF10 ; ... RE-ENTRY
FF25
JSR COMPAR ; COMPARE FILE NAMES
LDX ENTFND
BPL FF30
LDA FOUND
BEQ FNDFIL
BNE FF40
FF30
LDA TYPFLG
BEQ FF40 ; NO TYPE RESTRICTION
LDA PATTYP,X
AND #TYPMSK
CMP TYPFLG
BNE FNDFIL
FF40
RTS
.PAGE 'LOOKUP-COMPAR'
;
; COMPARE ALL FILENAMES IN STREAM TABLE
; WITH EACH VALID ENTRY IN THE
; DIRECTORY. MATCHES ARE TABULATED
;
COMPAR
LDX #$FF
STX ENTFND
INX
STX PATFLG
JSR CMPCHK
BEQ CP10
CP02
RTS ; ALL ARE FOUND
CP05
JSR CC10
BNE CP02
CP10
LDA DRVNUM
EOR FILDRV,X
LSR A
BCC CP20 ; RIGHT DRIVE
AND #$40
BEQ CP05 ; NO DEFAULT
LDA #2
CMP DRVCNT
BEQ CP05 ; DON'T USE DEFAULT
CP20
LDA FILTBL,X ; GOOD DRIVE MATCH
TAX
JSR FNDLMT
LDY #3
JMP CP33
CP30
LDA CMDBUF,X
CMP (DIRBUF),Y
BEQ CP32 ; CHARS ARE EQUAL
CMP #'?
BNE CP05 ; NO SINGLE PATTERN
LDA (DIRBUF),Y
CMP #$A0
BEQ CP05 ; END OF FILENAME
CP32
INX
INY
CP33
CPX LIMIT
BCS CP34 ; END OF PATTERN
LDA CMDBUF,X
CMP #'*
BEQ CP40 ; STAR MATCHES ALL
BNE CP30 ; KEEP CHECKING
CP34
CPY #19
BCS CP40 ; END OF FILENAME
LDA (DIRBUF),Y
CMP #$A0
BNE CP05
CP40
LDX F2PTR ; FILENAMES MATCH
STX ENTFND
LDA PATTYP,X ; STORE INFO IN TABLES
AND #$80
STA PATFLG
LDA INDEX
STA ENTIND,X
LDA SECTOR
STA ENTSEC,X
LDA TRACK
STA ENTTRK,X
LDY #0
LDA (DIRBUF),Y
INY
PHA
AND #$40
STA TEMP
PLA
AND #$FF-$20
BMI CP42
ORA #$20
CP42
AND #$27
ORA TEMP
STA TEMP
LDA #$80
AND PATTYP,X
ORA TEMP
STA PATTYP,X
LDA FILDRV,X
AND #$80
ORA DRVNUM
STA FILDRV,X
LDA (DIRBUF),Y
STA FILTRK,X
INY
LDA (DIRBUF),Y
STA FILSEC,X
LDA REC
BNE CMPCHK
LDY #21
LDA (DIRBUF),Y
STA REC
;
; CHECK TABLE FOR UNFOUND FILES
;
CMPCHK
LDA #$FF
STA FOUND
LDA F2CNT
STA F2PTR
CC10
DEC F2PTR
BPL CC15
RTS ; TABLE EXHAUSTED
CC15
LDX F2PTR
LDA PATTYP,X
BMI CC20
LDA FILTRK,X
BNE CC10
CC20
LDA #0
STA FOUND
RTS
.PAGE 'LOOKUP-SEARCH'
;
; SEARCH DIRECTORY
;
; RETURNS WITH VALID ENTRY W/DELIND = 0
; OR RETURNS W/1ST DELETED ENTRY
; W/DELIND = 1
;
; SRCHST WILL INITIATE A SEARCH
; SEARCH WILL CONTINUE A SEARCH
;
SRCHST
JSR AUTOI
LDY #0 ; INIT DELETED SECTOR
STY DELSEC
STY DELENT ; INIT DELETED ENTRY
DEY
STY ENTFND
LDX DRVNUM
LDA DSTRK,X ; START SEARCH AT BEGINNING
STA TRACK
LDA DSSEC,X
STA SECTOR
LDA #$FF
STA LSTBUF
JSR OPNIRD ; OPEN INTERNAL READ CHNL
SR10
LDA LSTBUF ; LAST BUFFER IF 0
BNE SR15
RTS ; (.Z = 1)
SR15
LDA #7
STA FILCNT
LDA #0 ; READ TRACK #
JSR DRDBYT
STA LSTBUF ; UPDATE END FLAG
SR20
JSR GETPNT
DEC FILCNT
LDY #0
LDA (DIRBUF),Y ; READ FILE TYPE
BNE SR30
LDA DELENT ; DELETED ENTRY FOUND?
BNE SEARCH ; DELETED ENTRY ALREADY FOUND
JSR CURBLK ; GET CURRENT SECTOR
LDA SECTOR
STA DELSEC
LDA #$FF
STA DELENT
LDA TRACK
STA DELTRK
LDA DIRBUF ; GET CURRENT INDEX
LDX DELIND ; BIT1: WANT DELETED ENTRY
STA DELIND
BEQ SEARCH ; NEED VALID ENTRY
RTS ; (.Z = 0)
SR30
LDX #1
CPX DELIND ; LOOKING FOR DELETED?
BNE SR50 ; NO!
BEQ SEARCH
SRRE
LDA DIRTRK
STA TRACK
LDA DIRSEC
STA SECTOR
JSR OPNIRD
LDA INDEX
JSR SETPNT
SEARCH
LDA #$FF
STA ENTFND
LDA FILCNT ; ADJUST FILE COUNT
BMI SR40
LDA #32 ; INCR BY 32
JSR INCPTR
JMP SR20
SR40
JSR NXTBUF ; NEW BUFFER
JMP SR10
SR50
LDA DIRBUF ; FOUND VALID ENTRY
STA INDEX ; SAVE INDEX
JSR CURBLK ; GET SECTOR
LDA SECTOR
STA DIRSEC
LDA TRACK
STA DIRTRK
RTS ; (.Z = 0)
JAUTOI ; AUTO-INIT SECTION
LDA AUTOFG
BNE AUTO2 ; CHECK DISABLE FLAG
LDX DRVNUM
LSR WPSW,X ; TEST & CLEAR FLAG
BCC AUTO2
LDA #$FF
STA JOBRTN ; SET ERROR RETURN CODE
JSR ITRIAL ; INIT SEEK-TEST
LDY #$FF
CMP #2
BEQ AUTO1 ; NO SYNC = NO DISKETTE
CMP #3
BEQ AUTO1 ; NO HEADER = NO DIRECTORY
LDY #00
AUTO1
LDX DRVNUM
TYA
STA NODRV,X ; SET CONDITION OF NO DRIVE
BNE AUTO2
JSR INITDR
AUTO2
LDX DRVNUM
LDA NODRV,X
RTS ; RETURN NO DRIVE STATUS
.END