0
|
1 ********************************************************************
|
|
2 * SCF - OS-9 Level One V2 SCF file manager
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
1287
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
0
|
8 * ------------------------------------------------------------------
|
1287
|
9 * 10 ????/??/??
|
|
10 * From Tandy OS-9 Level One VR 02.00.00
|
0
|
11
|
|
12 nam SCF
|
|
13 ttl OS-9 Level One V2 SCF file manager
|
|
14
|
|
15 ifp1
|
|
16 use defsfile
|
|
17 use scfdefs
|
|
18 endc
|
|
19
|
|
20 tylg set FlMgr+Objct
|
|
21 atrv set ReEnt+rev
|
1287
|
22 rev set $00
|
201
|
23 edition set 10
|
0
|
24
|
|
25 mod eom,name,tylg,atrv,start,size
|
|
26
|
|
27 size equ .
|
|
28
|
|
29 name fcs /SCF/
|
|
30 fcb edition
|
|
31
|
|
32 start lbra Create
|
|
33 lbra Open
|
|
34 lbra MakDir
|
|
35 lbra ChgDir
|
|
36 lbra Delete
|
|
37 lbra Seek
|
|
38 lbra Read
|
|
39 lbra Write
|
|
40 lbra ReadLn
|
|
41 lbra WriteLn
|
|
42 lbra GetStat
|
|
43 lbra PutStat
|
|
44 lbra Term
|
|
45
|
|
46 L0038 puls y
|
|
47
|
|
48
|
|
49 * ChgDir/MakDir entry
|
|
50 ChgDir
|
|
51 MakDir comb
|
|
52 ldb #E$BPNam
|
|
53 L003D rts
|
|
54
|
|
55
|
|
56 * Open/Create entry
|
|
57 Open
|
|
58 Create ldx PD.DEV,y
|
|
59 stx <$3B,y
|
|
60 ldu PD.RGS,y
|
|
61 pshs y
|
|
62 ldx R$X,u
|
|
63 os9 F$PrsNam
|
|
64 bcs L0038
|
|
65 lda -1,y get last char
|
|
66 bmi L0059 branch if hi bit set
|
|
67 leax ,y else point X at last char + 1
|
|
68 os9 F$PrsNam
|
|
69 bcc L0038
|
|
70 L0059 sty R$X,u
|
|
71 puls y
|
|
72 lda #READ.
|
|
73 bita PD.MOD,y
|
|
74 beq L00A2
|
|
75 ldd #$0001
|
|
76 os9 F$SRqMem allocate buffer
|
|
77 bcs L003D
|
|
78 stu PD.BUF,y
|
|
79 clrb
|
|
80 bsr L0091
|
|
81
|
|
82 * cute message
|
184
|
83 cute fcb $62,$1B,$59,$6B,$65,$65,$2A,$11,$1C,$0D,$0F
|
0
|
84 fcb $42,$0C,$6C,$62,$6D,$31,$13,$0F,$0B,$49,$0C
|
|
85 fcb $72,$7C,$6A,$2B,$08,$00,$02,$11,$00,$79
|
|
86
|
|
87 * put cute message into our newly allocated PD buffer
|
|
88 L0091 puls x get PC into X
|
|
89 clra
|
|
90 L0094 eora ,x+
|
|
91 sta ,u+
|
|
92 decb
|
184
|
93 cmpa #C$CR
|
0
|
94 bne L0094
|
|
95 L009D sta ,u+
|
|
96 decb
|
|
97 bne L009D
|
|
98 L00A2 ldu PD.DEV,y
|
|
99 beq MakDir
|
|
100 ldx V$STAT,u X = static storage ptr
|
|
101 lda <PD.PAG,y get page len
|
|
102 sta V.LINE,x store in static
|
|
103 ldx V$DESC,u
|
|
104 ldd <PD.D2P,y
|
|
105 beq L00C6
|
|
106 leax d,x
|
|
107 lda PD.MOD,y
|
|
108 lsra
|
|
109 rorb
|
|
110 lsra
|
|
111 rolb
|
|
112 rola
|
|
113 rorb
|
|
114 rola
|
|
115 os9 I$Attach attach to DEV2
|
|
116 bcs L00FD
|
|
117 stu PD.DV2,y save dev entry
|
|
118 L00C6 ldu V$STAT,u
|
|
119 clra
|
|
120 clrb
|
|
121 pshs b,a
|
|
122 ldx <V.PDLHd,u
|
|
123 bne L00D9
|
|
124 sty <V.PDLHd,u
|
|
125 bra L00E9
|
|
126 L00D7 tfr d,x
|
|
127 L00D9 ldb <$3F,x
|
|
128 bne L00E0
|
|
129 inc 1,s in B on stack
|
|
130 L00E0 ldd <$3D,x
|
|
131 bne L00D7
|
|
132 sty <$3D,x
|
|
133 L00E9 lda #$29
|
|
134 pshs a
|
|
135 inc 2,s inc B on stack
|
|
136 lbsr L01BD
|
|
137 lda 2,s get B on stack
|
|
138 leas 3,s clean up stack
|
|
139 deca
|
|
140 bne L00FC
|
|
141 lbra L01B2
|
|
142 L00FC clrb
|
|
143 L00FD rts
|
|
144
|
|
145
|
|
146 * term routine
|
|
147 Term tst PD.CNT,y
|
|
148 beq L0104 branch if count is zero
|
|
149
|
|
150
|
|
151 * seek/delete routine
|
|
152 Seek
|
|
153 Delete clra
|
|
154 rts
|
|
155
|
|
156 L0104 ldu PD.DV2,y
|
|
157 beq L010B
|
|
158 os9 I$Detach
|
|
159 L010B ldu PD.BUF,y
|
|
160 beq L0115
|
|
161 ldd #$0001
|
|
162 os9 F$SRtMem
|
|
163 L0115 ldx #$0001
|
|
164 lda #$2A
|
|
165 pshs x,a
|
|
166 ldu PD.DEV,y
|
|
167 ldu V$STAT,u
|
|
168 ldx <V.PDLHd,u
|
|
169 ldd <$3D,y
|
|
170 cmpy <V.PDLHd,u
|
|
171 bne L013A
|
|
172 std <V.PDLHd,u
|
|
173 bne L0143
|
|
174 clr 2,s
|
|
175 bra L0143
|
|
176 L0135 ldx <$3D,x
|
|
177 beq L0147
|
|
178 L013A cmpy <$3D,x
|
|
179 bne L0135
|
|
180 std <$3D,x
|
|
181 L0143 sty <$3D,y
|
|
182 L0147 lbsr L01BD
|
|
183 leas 3,s fix stack
|
|
184 rts
|
|
185
|
|
186
|
|
187 * getstat routine
|
|
188 GetStat lda <$3F,y
|
|
189 lbne L0404
|
|
190 ldx PD.RGS,y
|
|
191 lda R$B,x get status code
|
184
|
192 cmpa #SS.Opt
|
0
|
193 bne L0179 branch if not
|
|
194 pshs y,x,a
|
184
|
195 lda #SS.ComSt call driver's SS.ComSt
|
|
196 sta R$B,x
|
|
197 ldu R$Y,x
|
0
|
198 pshs u
|
|
199 bsr L0179
|
|
200 puls u
|
|
201 puls y,x,a
|
184
|
202 sta R$B,x
|
|
203 ldd R$Y,x
|
|
204 stu R$Y,x
|
0
|
205 bcs L0177
|
|
206 std <$34,y
|
|
207 L0177 clrb
|
|
208 rts
|
|
209 L0179 ldb #$09 getstat offset
|
|
210 JsrDrvr pshs a
|
|
211 clra
|
|
212 ldx PD.DEV,y
|
|
213 ldu V$STAT,x
|
|
214 ldx V$DRIV,x
|
|
215 addd M$Exec,x
|
|
216 leax d,x
|
|
217 puls a
|
|
218 jmp ,x jump into driver
|
|
219
|
|
220
|
|
221 * putstat routine
|
|
222 PutStat lbsr L03E0
|
|
223 L018F bsr L0198
|
|
224 pshs b,cc
|
|
225 lbsr L0391
|
|
226 puls pc,b,cc
|
|
227 L0198 lda R$B,u
|
|
228 ldb #$0C setstat offset
|
|
229 cmpa #SS.Opt SS.Opt?
|
|
230 bne JsrDrvr jsr into driver
|
|
231 * copy passed options to path desc
|
|
232 pshs y
|
|
233 ldx R$X,u
|
|
234 leay <PD.OPT,y
|
|
235 ldb #OPTCNT
|
|
236 L01A9 lda ,x+
|
|
237 sta ,y+
|
|
238 decb
|
|
239 bne L01A9
|
|
240 puls y
|
|
241
|
|
242 L01B2 ldx <$34,y
|
184
|
243 lda #SS.ComSt
|
0
|
244 pshs x,a
|
|
245 bsr L01BD
|
|
246 puls pc,x,a
|
|
247 L01BD pshs u,y,x
|
|
248 ldx PD.RGS,y
|
|
249 ldu R$Y,x
|
|
250 lda R$B,x
|
|
251 pshs u,y,x,a
|
|
252 ldd <$10,s
|
|
253 std R$Y,x
|
|
254 lda $0F,s
|
|
255 sta R$B,x
|
|
256 ldb #$0C
|
|
257 lbsr L03E5
|
|
258 bsr L018F
|
|
259 puls u,y,x,a
|
|
260 stu R$Y,x
|
|
261 sta R$B,x
|
|
262 bcc L01E6
|
|
263 cmpb #E$UnkSvc
|
|
264 orcc #Carry
|
|
265 bne L01E6
|
|
266 clrb
|
|
267 L01E6 puls u,y,x
|
|
268 L01E8 rts
|
|
269
|
|
270
|
|
271 * read routine
|
|
272 Read lbsr L03E0
|
|
273 bcs L01E8
|
|
274 inc PD.RAW,y
|
184
|
275 ldx R$Y,u
|
0
|
276 beq L0235
|
|
277 pshs x
|
|
278 ldx #$0000
|
184
|
279 ldu R$X,u
|
0
|
280 lbsr L0348
|
|
281 bcs L020A
|
|
282 tsta
|
|
283 beq L0220
|
|
284 cmpa <PD.EOF,y
|
|
285 bne L0218
|
|
286 L0208 ldb #E$EOF
|
|
287 L020A leas 2,s
|
|
288 pshs b
|
|
289 bsr L0231
|
|
290 comb
|
|
291 puls pc,b
|
|
292
|
|
293 L0213 lbsr L0348
|
|
294 bcs L020A
|
184
|
295 L0218 tst <PD.EKO,y
|
0
|
296 beq L0220
|
|
297 lbsr L046C
|
184
|
298 L0220 leax 1,x
|
0
|
299 sta ,u+
|
|
300 beq L022B
|
184
|
301 cmpa <PD.EOR,y
|
0
|
302 beq L022F
|
|
303 L022B cmpx ,s
|
|
304 bcs L0213
|
|
305 L022F leas $02,s
|
184
|
306 L0231 ldu PD.RGS,y
|
|
307 stx R$Y,u
|
0
|
308 L0235 lbra L0391
|
|
309
|
|
310
|
|
311 * readln routine
|
|
312 ReadLn lbsr L03E0
|
|
313 bcs L01E8
|
184
|
314 ldx R$Y,u
|
0
|
315 beq L0231
|
184
|
316 tst R$Y,u
|
0
|
317 beq L0248
|
184
|
318 ldx #256
|
0
|
319 L0248 pshs x
|
|
320 ldd #$FFFF
|
184
|
321 std PD.MAX,y
|
0
|
322 lbsr L030D
|
|
323 L0252 lbsr L0348
|
|
324 bcs L02C8
|
|
325 tsta
|
|
326 beq L0265
|
|
327 ldb #$29
|
|
328 L025C cmpa b,y
|
|
329 beq L0285
|
|
330 incb
|
|
331 cmpb #$31
|
|
332 bls L025C
|
184
|
333 L0265 cmpx PD.MAX,y
|
0
|
334 bls L026B
|
184
|
335 stx PD.MAX,y
|
|
336 L026B leax 1,x
|
0
|
337 cmpx ,s
|
|
338 bcs L027B
|
|
339 lda <$33,y
|
|
340 lbsr L046C
|
184
|
341 leax -1,x
|
0
|
342 bra L0252
|
|
343 L027B lbsr L0369
|
|
344 sta ,u+
|
|
345 lbsr L0379
|
|
346 bra L0252
|
|
347 L0285 pshs pc,x
|
|
348 leax >L0298,pcr
|
|
349 subb #$29
|
|
350 lslb
|
|
351 leax b,x
|
184
|
352 stx 2,s
|
0
|
353 puls x
|
|
354 jsr [,s++]
|
|
355 bra L0252
|
|
356 L0298 bra L0313
|
|
357 bra L02FD
|
|
358 bra L02AA
|
|
359 bra L02BE
|
|
360 bra L02D9
|
|
361 bra L02E3
|
|
362 puls pc
|
|
363 bra L02FD
|
|
364 bra L02FD
|
184
|
365 L02AA leas 2,s
|
0
|
366 sta ,u
|
|
367 lbsr L0379
|
184
|
368 ldu R$Y,y
|
|
369 leax 1,x
|
|
370 stx R$Y,u
|
0
|
371 bsr L0332
|
184
|
372 leas 2,s
|
0
|
373 lbra L0391
|
184
|
374 L02BE leas 2,s
|
0
|
375 leax ,x
|
|
376 lbeq L0208
|
|
377 bra L0265
|
184
|
378
|
0
|
379 L02C8 pshs b
|
184
|
380 lda #C$CR
|
0
|
381 sta ,u
|
|
382 bsr L02D5
|
|
383 puls b
|
|
384 lbra L020A
|
184
|
385 L02D5 lda #C$CR
|
0
|
386 bra L032F
|
184
|
387 L02D9 lda <PD.EOR,y
|
0
|
388 sta ,u
|
|
389 bsr L030D
|
|
390 L02E0 lbsr L037E
|
184
|
391 L02E3 cmpx PD.MAX,y
|
0
|
392 beq L02FA
|
184
|
393 leax 1,x
|
|
394 cmpx 2,s
|
0
|
395 bcc L02F8
|
|
396 lda ,u+
|
|
397 beq L02E0
|
184
|
398 cmpa <PD.EOR,y
|
0
|
399 bne L02E0
|
184
|
400 leau -1,u
|
|
401 L02F8 leax -1,x
|
0
|
402 L02FA rts
|
|
403 L02FB bsr L0317
|
|
404 L02FD leax ,x
|
|
405 beq L030D
|
184
|
406 tst <PD.DLO,y
|
0
|
407 beq L02FB
|
184
|
408 tst <PD.EKO,y
|
0
|
409 beq L030D
|
|
410 bsr L02D5
|
|
411 L030D ldx #$0000
|
184
|
412 ldu PD.BUF,y
|
0
|
413 L0312 rts
|
|
414 L0313 leax ,x
|
|
415 beq L02FA
|
184
|
416 L0317 leau -1,u
|
|
417 leax -1,x
|
|
418 tst <PD.EKO,y
|
0
|
419 beq L0312
|
184
|
420 tst <PD.BSO,y
|
0
|
421 beq L032C
|
|
422 bsr L032C
|
184
|
423 lda #C$SPAC
|
0
|
424 lbsr L046C
|
184
|
425 L032C lda <PD.BSE,y
|
0
|
426 L032F lbra L046C
|
184
|
427 L0332 ldx R$X,u
|
|
428 ldu PD.BUF,y
|
0
|
429 L0336 lda ,u+
|
|
430 sta ,x+
|
184
|
431 cmpa <PD.EOR,y
|
0
|
432 bne L0336
|
|
433 rts
|
184
|
434
|
0
|
435 L0340 pshs u,y,x
|
184
|
436 ldx PD.DV2,y
|
|
437 ldu PD.DEV,y
|
0
|
438 bra L0350
|
184
|
439
|
0
|
440 L0348 pshs u,y,x
|
184
|
441 ldx PD.DEV,y
|
|
442 ldu PD.DV2,y U now points to dev table entry of device 2
|
0
|
443 beq L0357
|
184
|
444 L0350 ldu V$STAT,u U now points to static storage of device 2
|
|
445 ldb <PD.PAG,y
|
|
446 stb V.LINE,u
|
0
|
447 L0357 leax ,x
|
|
448 beq L0367
|
184
|
449 tfr u,d D now holds pointer to static storage of device 2
|
|
450 ldu V$STAT,x U now holds ???
|
|
451 std V.DEV2,u
|
0
|
452 ldu #$0003
|
|
453 lbsr L04D3
|
|
454 L0367 puls pc,u,y,x
|
184
|
455
|
|
456 L0369 tst <PD.UPC,y
|
0
|
457 beq L0378
|
184
|
458 cmpa #'a
|
0
|
459 bcs L0378
|
184
|
460 cmpa #'z
|
0
|
461 bhi L0378
|
184
|
462 suba #32
|
0
|
463 L0378 rts
|
184
|
464 L0379 tst <PD.EKO,y
|
0
|
465 beq L0378
|
184
|
466 L037E cmpa #C$SPAC
|
0
|
467 bcc L0386
|
184
|
468 cmpa #C$CR
|
0
|
469 bne L0389
|
|
470 L0386 lbra L046C
|
|
471 L0389 pshs a
|
184
|
472 lda #C$PERD
|
0
|
473 bsr L0386
|
|
474 puls pc,a
|
|
475
|
|
476 L0391 ldx <D.Proc
|
|
477 lda P$ID,x
|
|
478 ldx PD.DEV,y
|
|
479 bsr L039B
|
|
480 ldx PD.DV2,y
|
|
481 L039B beq L03A5
|
|
482 ldx V$STAT,x
|
|
483 cmpa V.BUSY,x
|
|
484 bne L03A5
|
|
485 clr V.BUSY,x
|
|
486 L03A5 rts
|
|
487
|
|
488 * A = PID
|
|
489 * X = dev entry
|
|
490 * Y = path desc
|
|
491 L03A6 pshs x,a
|
|
492 ldx V$STAT,x
|
|
493 lda V.BUSY,x
|
|
494 beq L03C8
|
|
495 cmpa ,s compare to A on stack
|
|
496 beq L03DD branch if same
|
|
497 pshs a
|
|
498 bsr L0391
|
|
499 puls a
|
|
500 os9 F$IOQu
|
|
501 inc PD.MIN,y
|
|
502 ldx <D.Proc
|
|
503 ldb <P$Signal,x
|
|
504 puls x,a
|
|
505 beq L03A6
|
|
506 coma
|
|
507 rts
|
|
508 L03C8 lda ,s get passed PID on stack
|
|
509 sta V.BUSY,x
|
|
510 sta V.LPRC,x
|
|
511 lda <PD.PSC,y
|
|
512 sta V.PCHR,x
|
|
513 ldd <PD.INT,y get int/qut
|
|
514 std V.INTR,x save in static
|
|
515 ldd <PD.XON,y get xon/xoff
|
|
516 std V.XON,x save in static
|
|
517 L03DD clra
|
|
518 puls pc,x,a
|
|
519
|
|
520 L03E0 lda <$3F,y
|
|
521 bne L0402
|
|
522 L03E5 ldx <D.Proc
|
|
523 lda P$ID,x
|
|
524 clr PD.MIN,y
|
|
525 ldx PD.DEV,y
|
|
526 bsr L03A6
|
|
527 bcs L03FF
|
184
|
528 ldx PD.DV2,y
|
0
|
529 beq L03F9
|
|
530 bsr L03A6
|
|
531 bcs L03FF
|
184
|
532 L03F9 tst PD.MIN,y
|
0
|
533 bne L03E0
|
184
|
534 clr PD.RAW,y
|
|
535 L03FF ldu PD.RGS,y
|
0
|
536 rts
|
|
537 L0402 leas 2,s
|
184
|
538 L0404 ldb #E$HangUp
|
0
|
539 cmpa #$02
|
|
540 bcs L0411
|
184
|
541 lda PD.CPR,y
|
|
542 ldb #S$Kill
|
0
|
543 os9 F$Send
|
|
544 L0411 inc <$3F,y
|
|
545 orcc #Carry
|
|
546 rts
|
|
547
|
|
548
|
|
549 * writeln routine
|
|
550 WriteLn bsr L03E0
|
|
551 bra L041F
|
|
552
|
|
553
|
|
554 * write routine
|
|
555 Write bsr L03E0
|
|
556 inc PD.RAW,y
|
|
557 L041F ldx R$Y,u
|
|
558 beq L0461
|
|
559 pshs x
|
|
560 ldx #$0000
|
|
561 ldu R$X,u
|
|
562 L042A lda ,u+
|
|
563 tst PD.RAW,y
|
|
564 bne L0444
|
|
565 lbsr L0369
|
|
566 cmpa #C$LF
|
|
567 bne L0444
|
|
568 lda #C$CR
|
|
569 tst <PD.ALF,y
|
|
570 bne L0444
|
|
571 bsr L047A
|
|
572 bcs L0464
|
|
573 lda #C$LF
|
|
574 L0444 bsr L047A
|
|
575 bcs L0464
|
|
576 leax 1,x
|
|
577 cmpx ,s
|
|
578 bcc L045B
|
|
579 lda -1,u
|
|
580 beq L042A
|
|
581 cmpa <PD.EOR,y
|
|
582 bne L042A
|
|
583 tst PD.RAW,y
|
|
584 bne L042A
|
|
585 L045B leas 2,s
|
|
586 L045D ldu PD.RGS,y
|
|
587 stx R$Y,u
|
|
588 L0461 lbra L0391
|
|
589 L0464 leas 2,s
|
|
590 pshs b,cc
|
|
591 bsr L045D
|
|
592 puls pc,b,cc
|
|
593
|
|
594 L046C pshs u,x,a
|
184
|
595 ldx PD.DV2,y
|
0
|
596 beq L0478
|
|
597 cmpa #C$CR
|
|
598 beq L04A9
|
|
599 L0476 bsr L04D0
|
|
600 L0478 puls pc,u,x,a
|
|
601
|
|
602 L047A pshs u,x,a
|
|
603 ldx PD.DEV,y
|
|
604 cmpa #C$CR
|
|
605 bne L0476
|
|
606 ldu V$STAT,x
|
|
607 tst V.PAUS,u
|
|
608 bne L0497
|
|
609 tst PD.RAW,y
|
|
610 bne L04A9
|
|
611 tst <PD.PAU,y
|
|
612 beq L04A9
|
|
613 dec V.LINE,u
|
|
614 bne L04A9
|
|
615 bra L04A1
|
|
616 L0497 lbsr L0340
|
|
617 bcs L04A1
|
|
618 cmpa <PD.PSC,y
|
|
619 bne L0497
|
|
620 L04A1 lbsr L0340
|
|
621 cmpa <PD.PSC,y
|
|
622 beq L04A1
|
|
623 L04A9 ldu V$STAT,x
|
|
624 clr V$USRS,u
|
|
625 lda #C$CR
|
|
626 bsr L04D0
|
|
627 tst PD.RAW,y
|
|
628 bne L04CE
|
|
629 ldb <PD.NUL,y
|
|
630 pshs b
|
|
631 tst <PD.ALF,y
|
|
632 beq L04C5
|
|
633 lda #C$LF
|
|
634 L04C1 bsr L04D0
|
|
635 bcs L04CC
|
|
636 L04C5 lda #C$NULL
|
|
637 dec ,s
|
|
638 bpl L04C1
|
|
639 clra
|
|
640 L04CC leas 1,s
|
|
641 L04CE puls pc,u,x,a
|
|
642
|
|
643 L04D0 ldu #$0006
|
|
644 L04D3 pshs u,y,x,a
|
184
|
645 ldu V$STAT,x
|
|
646 clr V.WAKE,u
|
|
647 ldx V$DRIV,x
|
|
648 ldd M$Exec,x
|
0
|
649 addd $05,s
|
|
650 leax d,x
|
|
651 lda ,s+
|
|
652 jsr ,x
|
|
653 puls pc,u,y,x
|
|
654
|
|
655 emod
|
|
656 eom equ *
|
|
657 end
|