Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
  Tue Jul 17 11:00:19 2018                                                                                               Page    1
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
          2500 A.D. 65816 Macro Assembler #26960 - Version 5.02g
10
          -----------------------------------------------------
11
 
12
                       Input  Filename : src\F9\fdir.asm
13
                       Output Filename : obj\F9\fdir.obj
14
                       Listing Has Been Relocated
15
 
16
 
17
 2473                        		.LIST on
18
 2474
19
 2475                        	;---------------------------------------------------------------------------
20
 2476                        	; direct-page working area for filesystem managment
21
 2477                        	;---------------------------------------------------------------------------
22
 2478
23
 2479                        	DPFSW:	.SECTION page0, ref_only, common	;Direct Page f.s. working area
24
 2480
25
 2481  000000                		.ABSOLUTE		;; start always at $00
26
 2482  000000                		.ORG		0x00
27
 2483
28
 2484                        	;---------------------------------------------------------------------------
29
 2485                        	; this section is copied from the PDT of selected drive
30
 2486                        	; note: in the LBA address we assume that the MSB 4 bit are all '0'
31
 2487  000000  00            	fdrvfg		.DB		; <7>: H.D. (1) / F.D. (0)
32
 2488                        					; <6>: 1440k (1) / 720k (0) if <7> = 1
33
 2489  000001  00            	ffsfg		.DB		; <7>: FAT (1) / CBM (0)
34
 2490  000002  00            	fclusiz		.DB		; cluster size in # sector's (1,2,4,8,10,20,40)
35
 2491  000003  00            	fclush		.DB		; shift cluster (0,1,2,3,4,5,6)
36
 2492  000004  00            	fatsiz		.DB		; FAT table size in # sector's (0 = 256 sect.)
37
 2493  000005  00            	frootsiz	.DB		; root directory size in # sector's
38
 2494  000006  0000          	frootent	.DW		; root directory # entries
39
 2495  000008                	ffat1lba	.DS	3	; LBA of FAT 1 starting
40
 2496  00000B                	ffat2lba	.DS	3	; LBA of FAT 2 starting
41
 2497  00000E                	frootlba	.DS	3	; LBA of root directory starting
42
 2498  000011                	fclulba		.DS	3	; LBA of first cluster (cluster #2)
43
 2499  000014  0000          	fclucnt		.DW		; # of cluster's in FAT volume
44
 2500  000016  0000          	fclufree	.DW		; the count of free cluster's
45
 2501  000018  0000          	fclunxt		.DW		; the next free cluster #
46
 2502  00001A  0000          	fcdclu		.DW		; cluster # where starting c.d.
47
 2503  00001C  0000          	fcdparent	.DW		; cluster # parent of the c.d.
48
 2504  00001E  0000          	fcdparx		.DW		; index entry on parent cluster of c.d.
49
 2505  000020  00            	fcdlen		.DB		; lenght of current directory string
50
 2506                        					; c.d. string start with '/', w/o trailing '/'
51
 2507  000021  00            	fcdlst		.DB		; index of last '/' in c.d. string
52
 2508
53
 2509                        	;---------------------------------------------------------------------------
54
 2510
55
 2511  000022                	FPathStr	.DS	2
56
 2512
57
 2513  000024                	fpaths		.DS	78	; path string (without starting 'X:')
58
 2514  000072  00            	fdrive		.DB		; the drive used in current operation
59
 2515  000073  00            	fdefdrv		.DB		; default drive (the one currently selected)
60
 2516  000074  00            	fexpfg		.DB		; <7>: fexpand file name (1) / directory (0)
61
 2517                        					; <6>: local calls to fexpand (1)
62
 2518  000075  00            	devfg		.DB		; <7>: specified a device name in path
63
  Tue Jul 17 11:00:19 2018                                                                                               Page    2
64
 
65
 
66
 
67
 
68
 2519  000076  00            	devidx		.DB		; index of device
69
 2520  000077  00            	haswild		.DB		; <7>: path contain wildcards
70
 2521  000078  00            	fdrvlst		.DB		; last operative drive ($FF mean invalid)
71
 2522  000079                	fpdtp		LP		; long pointer to PDT of fdrive
72
 2523  00007C  00            	storfg		.DB
73
 2524  00007D  00            	wildfg		.DB
74
 2525  00007E  00            	dotfg		.DB
75
 2526  00007F  00            	maxcnt		.DB
76
 2527  000080  00            	cnt		.DB
77
 2528  000081  00            	cnt1		.DB
78
 2529  000082  00            	cntx		.DB
79
 2530  000083                	LPtr1		LP
80
 2531  000086                	LPtr2		LP
81
 2532  000089  00            	FDirIdx		.DB
82
 2533                        	;FPathStr	.DS	2
83
 2534  00008A                	CDLen		.DS	6
84
 2535  000090  00            	lstidx		.DB
85
 2536  000091  00            	FEndDir		.DB
86
 2537  000092                	tmpfcb		.DS	16
87
 2538  0000A2                	LPtr3		LP
88
 2539
89
 2540  0000A5                		.RELATIVE
90
 2541
91
 2542                        		.ENDS
92
 2543
93
 2544                        	;---------------------------------------------------------------------------
94
 2545
95
 2609                        	.LIST		on
96
 2610
97
 2611                        		;.INCLUDE inc\sys_fs2.inc
98
 2612
99
 2613                        	.LIST on
100
 2614
101
 2615                        		.CODEF9
102
 2616                        		;.GLOBAL _chkfat
103
 2617                        		;.EXTERN _ATARead
104
 2618  F9609D
105
 2619                        		.LONGA	off
106
 2620                        		.LONGI	off
107
 2621
108
 2622
109
 2623          000005        	LSTDRIVE .EQU	$05
110
 2624          00004D        	MFATPATH .EQU	77
111
 2625
112
 2626                        		.GLOBAL _truenam
113
 2627  F9609D                	_truenam:
114
 2628                        		;phd
115
 2629                        		;phb
116
 2630                        		;pea	#DP05ADDR
117
 2631                        		;pld
118
 2632  F9609D  85 83         		sta	LPtr1
119
 2633  F9609F  EB            		xba
120
 2634  F960A0  85 84         		sta	LPtr1+1
121
 2635  F960A2  86 85         		stx	LPtr1+2
122
 2636  F960A4  84 74         		sty	fexpfg
123
 2637                        		;tya
124
 2638                        		;and	#$7F
125
  Tue Jul 17 11:00:19 2018                                                                                               Page    3
126
 
127
 
128
 
129
 
130
 2639                        		;sta	FDefDrv
131
 2640  F960A6
132
 2641  F960A6  A2 00         		ldx	#0
133
 2642  F960A8  9B            		txy
134
 2643  F960A9  B7 83         	?1000:	lda	[LPtr1],y
135
 2644  F960AB  9F 00 00 20   		sta	$200000,x
136
 2645  F960AF  C9 00         		cmp	#0
137
 2646  F960B1  F0 04         		beq	?1001
138
 2647  F960B3  E8            		inx
139
 2648  F960B4  C8            		iny
140
 2649  F960B5  D0 F2         		bne	?1000
141
 2650  F960B7  A9 00         	?1001:	lda	#$00
142
 2651  F960B9  EB            		xba
143
 2652  F960BA  A9 00         		lda	#$00
144
 2653  F960BC  A2 20         		ldx	#$20
145
 2654  F960BE
146
 2655                        		;jsr	_ftrim
147
 2656  F960BE  85 83         		sta	LPtr1
148
 2657  F960C0  EB            		xba
149
 2658  F960C1  85 84         		sta	LPtr1+1
150
 2659  F960C3  86 85         		stx	LPtr1+2
151
 2660  F960C5  20 E8 60      		jsr	?02
152
 2661                        		;jsr	_frest
153
 2662  F960C8  A6 89         		ldx	FDirIdx
154
 2663  F960CA  E8            		inx
155
 2664  F960CB  74 24         		stz	fpaths,x
156
 2665  F960CD  B0 18         		bcs	?1002
157
 2666  F960CF  24 75         		bit	devfg
158
 2667  F960D1  30 14         		bmi	?1002
159
 2668  F960D3  A6 90         		ldx	lstidx
160
 2669  F960D5  CA            		dex
161
 2670  F960D6  86 91         		stx	FEndDir
162
 2671  F960D8  F0 0D         		beq	?1002
163
 2672  F960DA  CA            		dex
164
 2673  F960DB  24 74         		bit	fexpfg			; check the directory length
165
 2674  F960DD  30 02         		bmi	?1001a			; if file name request
166
 2675  F960DF  A6 89         		ldx	FDirIdx
167
 2676  F960E1  E0 40         	?1001a:	cpx	#$40
168
 2677  F960E3  90 02         		bcc	?1002
169
 2678  F960E5  A9 23         		lda	#EINVPATH
170
 2679                        	?1002:	;tay
171
 2680                        		;ldx	#$00
172
 2681                        		;lda	#$05
173
 2682                        		;xba
174
 2683                        		;lda	#FPathStr
175
 2684                        		;plb
176
 2685                        		;pld
177
 2686  F960E7  60            		rts
178
 2687
179
 2688  F960E8                	?02:
180
 2689  F960E8  64 77         		stz	haswild
181
 2690  F960EA  64 75         		stz	devfg
182
 2691  F960EC  A5 73         		lda	fdefdrv
183
 2692  F960EE  18            		clc
184
 2693  F960EF  69 41         		adc	#'A'
185
 2694  F960F1  85 22         		sta	FPathStr
186
 2695  F960F3  A9 3A         		lda	#':'
187
  Tue Jul 17 11:00:19 2018                                                                                               Page    4
188
 
189
 
190
 
191
 
192
 2696  F960F5  85 23         		sta	FPathStr+1
193
 2697  F960F7  64 24         		stz	fpaths
194
 2698  F960F9  A9 FF         		lda	#$FF
195
 2699  F960FB  85 89         		sta	FDirIdx			; empty string
196
 2700  F960FD  A7 83         		lda	[LPtr1]			; first char
197
 2701  F960FF  F0 31         		beq	?14			; null string -> error
198
 2702  F96101  EB            		xba				; B = first char
199
 2703  F96102  A0 01         		ldy	#1
200
 2704  F96104  B7 83         		lda	[LPtr1],y		; 2nd char
201
 2705  F96106  C9 3A         		cmp	#':'			; check 'X:' at starting string
202
 2706  F96108  D0 1A         		bne	?10			; no drive specified - use default
203
 2707  F9610A  EB            		xba				; A = drive letter
204
 2708  F9610B  C9 61         		cmp	#'a'
205
 2709  F9610D  90 06         		bcc	?04
206
 2710  F9610F  C9 7B         		cmp	#'z'+1
207
 2711  F96111  B0 0E         		bcs	?08			; invalid drive
208
 2712  F96113  29 DF         		and	#$DF			; up case letter drive
209
 2713  F96115  E9 40         	?04:	sbc	#'A'-1			; here always CF = 0
210
 2714  F96117  90 07         		bcc	?06			; invalid drive number
211
 2715  F96119  C9 06         		cmp	#LSTDRIVE+1		; drive number <= LAST DRIVE ?
212
 2716  F9611B  B0 04         		bcs	?08			; invalid drive
213
 2717  F9611D  C8            		iny				; bump pointer (3nd char, Y = 2)
214
 2718  F9611E  90 08         		bcc	?12			; store drive number
215
 2719  F96120  38            	?06:	sec				; error flag
216
 2720  F96121  A9 0F         	?08:	lda	#ENODEV			; invalid drive error
217
 2721  F96123  60            		rts
218
 2722  F96124  A5 73         	?10:	lda	fdefdrv			; use default drive
219
 2723  F96126  18            		clc
220
 2724  F96127  88            		dey				; pointer = 0
221
 2725  F96128  85 72         	?12:	sta	fdrive			; store drive number
222
 2726  F9612A  69 41         		adc	#'A'
223
 2727  F9612C  85 22         		sta	FPathStr
224
 2728  F9612E  B7 83         		lda	[LPtr1],y		; first or 3nd char (Y = 0 or Y = 2)
225
 2729  F96130  D0 04         		bne	?16			; can't be NULL
226
 2730  F96132  A9 23         	?14:	lda	#EINVPATH		; invalid path format
227
 2731  F96134  38            		sec
228
 2732  F96135  60            		rts
229
 2733  F96136  C9 2F         	?16:	cmp	#'/'			; string start with root dir. ?
230
 2734  F96138  F0 04         		beq	?18			; absolute path
231
 2735  F9613A  C9 5C         		cmp	#'\'
232
 2736  F9613C  D0 0F         		bne	?20			; relative path
233
 2737  F9613E  C8            	?18:	iny				; pointer to char after '/' Y=3 or 1
234
 2738  F9613F  B7 83         		lda	[LPtr1],y		; skip consecutive '/' or '\'
235
 2739  F96141  C9 2F         		cmp	#'/'
236
 2740  F96143  F0 F9         		beq	?18
237
 2741  F96145  C9 5C         		cmp	#'\'
238
 2742  F96147  F0 F5         		beq	?18
239
 2743  F96149  A2 00         		ldx	#0			; index of fpaths
240
 2744  F9614B  F0 03         		beq	?22			; store '/'
241
 2745  F9614D
242
 2746                        	?20:	; copy in fpaths the current directory of the drive fdrive
243
 2747  F9614D  20 24 63      		jsr	?250
244
 2748  F96150
245
 2749                        	; if src start with "path"	Y= 0
246
 2750                        	; if src start with "/path"	Y= 1
247
 2751                        	; if src start with "X:path" 	Y= 2
248
 2752                        	; if src start with "X:/path" 	Y= 3
249
  Tue Jul 17 11:00:19 2018                                                                                               Page    5
250
 
251
 
252
 
253
 
254
 2753  F96150  18            	?22:	clc
255
 2754  F96151                		CPU16				; adjust pointer
256
 2755  F96151  C2 30         		rep	#(PMFLAG.OR.PXFLAG)
257
 2756                        		.LONGA	on
258
 2757                        		.LONGI	on
259
 2758                        		.MNLIST
260
 2759  F96153  98            		tya				; Y can be 0,1,2 or 3
261
 2760  F96154  65 83         		adc	LPtr1			; now LPtr1 point to first char
262
 2761  F96156  85 83         		sta	LPtr1			; of the path
263
 2762  F96158                		CPU08
264
 2763  F96158  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
265
 2764                        		.LONGA	off
266
 2765                        		.LONGI	off
267
 2766                        		.MNLIST
268
 2767  F9615A  90 02         		bcc	?24
269
 2768  F9615C  E6 85         		inc	LPtr1+2
270
 2769  F9615E  A9 2F         	?24:	lda	#'/'			; the last '/' of path
271
 2770  F96160  95 24         		sta	fpaths,x
272
 2771  F96162  86 89         		stx	FDirIdx			; current index
273
 2772  F96164  A7 83         		lda	[LPtr1]
274
 2773  F96166  D0 06         		bne	?25			; not only root directory in source
275
 2774  F96168  24 74         		bit	fexpfg			; filename ?
276
 2775  F9616A  30 C6         		bmi	?14			; yes -- error
277
 2776  F9616C  18            		clc				; root directory ending scan
278
 2777  F9616D  60            		rts
279
 2778  F9616E
280
 2779                        	?25:	; now search the last subcomponent - search last '/' or last '\'
281
 2780  F9616E  A0 00         		ldy	#0			; scan string from beginning
282
 2781  F96170  BB            		tyx				; sub-component lenght
283
 2782  F96171  B7 83         	?26:	lda	[LPtr1],y
284
 2783  F96173  F0 05         		beq	?28			; end string
285
 2784  F96175  C8            		iny
286
 2785  F96176  D0 F9         		bne	?26			; loop -- find end of string
287
 2786  F96178  F0 B8         		beq	?14			; error -- string too long
288
 2787  F9617A  E8            	?28:	inx
289
 2788  F9617B  88            		dey				; scan source for '/' or '\'
290
 2789  F9617C  30 0A         		bmi	?30			; reached string beginning
291
 2790  F9617E  B7 83         		lda	[LPtr1],y
292
 2791  F96180  C9 2F         		cmp	#'/'
293
 2792  F96182  F0 04         		beq	?30
294
 2793  F96184  C9 5C         		cmp	#'\'
295
 2794  F96186  D0 F2         		bne	?28			; scan source string
296
 2795  F96188  CA            	?30:	dex				; last sub-component lenght
297
 2796  F96189  F0 A7         		beq	?14			; string ending with '/' - error
298
 2797  F9618B  84 90         		sty	lstidx			; pointer to last '/'
299
 2798  F9618D  C8            		iny
300
 2799  F9618E  F0 42         		beq	?60			; exist last sub-component only
301
 2800  F96190
302
 2801                        		; sub-components scan - Y point always at first char after '/'
303
 2802  F96190  A0 00         		ldy	#0			; start with source string begin
304
 2803  F96192  C4 90         	?40:	cpy	lstidx
305
 2804  F96194  B0 39         		bcs	?58			; end (remain last sub-component)
306
 2805  F96196  B7 83         		lda	[LPtr1],y		; skip consecutive '/'
307
 2806  F96198  C8            		iny
308
 2807  F96199  C9 2F         		cmp	#'/'
309
 2808  F9619B  F0 F5         		beq	?40
310
 2809  F9619D  C9 5C         		cmp	#'\'
311
  Tue Jul 17 11:00:19 2018                                                                                               Page    6
312
 
313
 
314
 
315
 
316
 2810  F9619F  F0 F1         		beq	?40
317
 2811  F961A1  C9 2E         	?44:	cmp	#'.'			; check './'
318
 2812  F961A3  D0 22         		bne	?50			; parse sub-component
319
 2813  F961A5  B7 83         		lda	[LPtr1],y		; next char
320
 2814  F961A7  C8            		iny
321
 2815  F961A8  C9 2F         		cmp	#'/'
322
 2816  F961AA  F0 E6         		beq	?40			; skip './' entry
323
 2817  F961AC  C9 5C         		cmp	#'\'
324
 2818  F961AE  F0 E2         		beq	?40
325
 2819  F961B0  C9 2E         		cmp	#'.'			; check '../' entry
326
 2820  F961B2  D0 0B         		bne	?46			; malformed path
327
 2821  F961B4  B7 83         		lda	[LPtr1],y		; next char
328
 2822  F961B6  C8            		iny
329
 2823  F961B7  C9 2F         		cmp	#'/'
330
 2824  F961B9  F0 07         		beq	?48			; handle '../' entry
331
 2825  F961BB  C9 5C         		cmp	#'\'
332
 2826  F961BD  F0 03         		beq	?48			; handle '../' entry
333
 2827  F961BF  4C 32 61      	?46:	jmp	?14			; error - malformed path
334
 2828  F961C2  20 C4 62      	?48:	jsr	?200			; handle '../'entry
335
 2829  F961C5  80 CB         		bra	?40
336
 2830  F961C7  64 7D         	?50:	stz	wildfg			; no wildcards allowed
337
 2831  F961C9  88            		dey				; point to first char of the sub-comp
338
 2832  F961CA  20 EC 61      		jsr	?100			; parse sub-component
339
 2833  F961CD  80 C3         		bra	?40			; next su-component
340
 2834  F961CF  A4 90         	?58:	ldy	lstidx			; this point to last '/'
341
 2835  F961D1  C8            		iny				; point to first char after '/'
342
 2836  F961D2  A9 80         	?60:	lda	#$80
343
 2837  F961D4  85 7D         		sta	wildfg
344
 2838  F961D6  A6 89         		ldx	FDirIdx
345
 2839  F961D8  E8            		inx
346
 2840  F961D9  86 90         		stx	lstidx			; point to last sub-component
347
 2841  F961DB  20 D5 62      		jsr	?220			; parse last sub-component
348
 2842  F961DE  18            		clc
349
 2843  F961DF  60            		rts
350
 2844
351
 2845                        		; terminate sub-component with '/'
352
 2846  F961E0  A9 2F         	?90:	lda	#'/'			; store '/'
353
 2847  F961E2  64 7C         	?92:	stz	storfg			; don't store in tmpfcb
354
 2848  F961E4  20 A5 62      		jsr	?130			; store char A
355
 2849  F961E7  20 5D 63      	?94:	jsr	?360			; check device name
356
 2850  F961EA  18            		clc				; no error
357
 2851  F961EB  60            		rts
358
 2852  F961EC
359
 2853                        	?100:	; parse sub-component - Y point to first char of the sub-component
360
 2854  F961EC  A9 80         		lda	#$80
361
 2855  F961EE  85 7C         		sta	storfg			; store name part in tmpfcb
362
 2856  F961F0  64 7E         		stz	dotfg			; dot flag
363
 2857  F961F2  64 82         		stz	cntx			; tmpfcb current index
364
 2858  F961F4  A9 20         		lda	#' '			; fill an empty tmpfcb
365
 2859  F961F6  A2 07         		ldx	#7
366
 2860  F961F8  95 92         	?101:	sta	tmpfcb,x
367
 2861  F961FA  CA            		dex
368
 2862  F961FB  10 FB         		bpl	?101
369
 2863  F961FD  A9 08         		lda	#8			; max. name lenght
370
 2864  F961FF  85 7F         	?102:	sta	maxcnt			; max lenght name/ext
371
 2865  F96201  64 80         		stz	cnt			; chars counter
372
 2866  F96203  B7 83         	?104:	lda	[LPtr1],y		; scan string
373
  Tue Jul 17 11:00:19 2018                                                                                               Page    7
374
 
375
 
376
 
377
 
378
 2867  F96205  F0 E0         		beq	?94			; end string
379
 2868  F96207  C8            		iny
380
 2869  F96208  C9 2F         		cmp	#'/'
381
 2870  F9620A  F0 D6         		beq	?92			; end sub-component
382
 2871  F9620C  C9 5C         		cmp	#'\'
383
 2872  F9620E  F0 D0         		beq	?90			; end sub-component
384
 2873  F96210  C9 2E         		cmp	#'.'
385
 2874  F96212  D0 28         		bne	?106			; no dot char
386
 2875  F96214  24 7E         		bit	dotfg			; bit 7 mean dot already scanned
387
 2876  F96216  10 03         		bpl	?105			; ok -- first dot
388
 2877  F96218  4C 9F 62      		jmp	?125			; multiple dot - error
389
 2878  F9621B  A2 80         	?105:	ldx	#$80
390
 2879  F9621D  86 7E         		stx	dotfg			; signal dot already scanned
391
 2880  F9621F  64 7C         		stz	storfg			; don't store extension in tmpfcb
392
 2881  F96221  A6 80         		ldx	cnt			; sub-component cannot start with dot
393
 2882  F96223  F0 7A         		beq	?125			; start with dot - error\
394
 2883  F96225  AA            		tax
395
 2884  F96226  B7 83         		lda	[LPtr1],y		; check char after dot
396
 2885  F96228  F0 BD         		beq	?94			; ignore trailing dot
397
 2886  F9622A  C8            		iny
398
 2887  F9622B  C9 2F         		cmp	#'/'
399
 2888  F9622D  F0 B3         		beq	?92			; end sub-component
400
 2889  F9622F  C9 5C         		cmp	#'\'
401
 2890  F96231  F0 AD         		beq	?90			; end sub-component
402
 2891  F96233  88            		dey
403
 2892  F96234  8A            		txa
404
 2893  F96235  20 A5 62      		jsr	?130			; store dot
405
 2894  F96238  A9 03         		lda	#3			; max. ext lenght
406
 2895  F9623A  80 C3         		bra	?102			; scan ext
407
 2896  F9623C  24 7D         	?106:	bit	wildfg			; after a '*' expect the '.' or
408
 2897  F9623E  70 5F         		bvs	?125			; '/' or '\' or NULL
409
 2898  F96240  C9 3F         		cmp	#'?'
410
 2899  F96242  D0 0A         		bne	?108
411
 2900  F96244  24 7D         		bit	wildfg			; bit 7 mean '?' allowed
412
 2901  F96246  10 57         		bpl	?125			; wildcards not allowed - error
413
 2902  F96248  A2 80         		ldx	#$80
414
 2903  F9624A  86 77         		stx	haswild			; flag path contain wild chars
415
 2904  F9624C  80 2D         		bra	?117			; store '?'
416
 2905  F9624E  C9 2A         	?108:	cmp	#'*'
417
 2906  F96250  D0 21         		bne	?116
418
 2907  F96252  24 7D         		bit	wildfg
419
 2908  F96254  10 49         		bpl	?125			; wildcards not allowed
420
 2909  F96256  A2 80         		ldx	#$80
421
 2910  F96258  86 77         		stx	haswild			; flag path contain wild chars
422
 2911  F9625A  38            		sec
423
 2912  F9625B  A5 7F         		lda	maxcnt
424
 2913  F9625D  E5 80         		sbc	cnt			; how much char ?
425
 2914  F9625F  90 3E         		bcc	?125			; error
426
 2915  F96261  F0 A0         		beq	?104
427
 2916  F96263  85 81         		sta	cnt1
428
 2917  F96265  A9 3F         		lda	#'?'			; convert in right numbers of '?'
429
 2918  F96267  20 A5 62      	?114:	jsr	?130
430
 2919  F9626A  C6 81         		dec	cnt1
431
 2920  F9626C  D0 F9         		bne	?114
432
 2921  F9626E  20 49 63      		jsr	?350			; ignore all after '*'
433
 2922  F96271  80 90         		bra	?104			; loop
434
 2923  F96273  C9 7F         	?116:	cmp	#$7F			; only standard ASCII
435
  Tue Jul 17 11:00:19 2018                                                                                               Page    8
436
 
437
 
438
 
439
 
440
 2924  F96275  B0 29         		bcs	?126
441
 2925  F96277  C9 20         		cmp	#' '
442
 2926  F96279  90 24         		bcc	?125
443
 2927  F9627B  A6 80         	?117:	ldx	cnt			; test max. 8 chars for fname
444
 2928  F9627D  E4 7F         		cpx	maxcnt			; 3 chars for ext
445
 2929  F9627F  B0 1F         		bcs	?126			; fname or ext too long - error
446
 2930  F96281  E8            		inx				; update counter
447
 2931  F96282  86 80         		stx	cnt
448
 2932  F96284  A2 0B         		ldx	#NDCHCNT		; ready to store char in fpaths
449
 2933  F96286  DF B8 63 F9   	?118:	cmp	>NDIRCHRS,x		; test for illegals chars
450
 2934  F9628A  F0 13         		beq	?125			; illegal char - error
451
 2935  F9628C  CA            		dex
452
 2936  F9628D  10 F7         		bpl	?118
453
 2937  F9628F  C9 61         		cmp	#'a'			; up case char
454
 2938  F96291  90 06         		bcc	?120
455
 2939  F96293  C9 7B         		cmp	#'z'+1
456
 2940  F96295  B0 02         		bcs	?120
457
 2941  F96297  29 DF         		and	#$DF			; up-case
458
 2942  F96299  20 A5 62      	?120:	jsr	?130			; store
459
 2943  F9629C  4C 03 62      		jmp	?104			; loop
460
 2944  F9629F  38            	?125:	sec				; error
461
 2945  F962A0  68            	?126:	pla				; skip return
462
 2946  F962A1  68            		pla
463
 2947  F962A2  A9 23         		lda	#EINVPATH
464
 2948  F962A4  60            		rts
465
 2949
466
 2950                        	?130:	; store char in fpaths and update index
467
 2951                        		; store the name part only in tmpfcb for check device name
468
 2952                        		; full path 79 chars max - subctract 2 bytes for drive letter -> 77
469
 2953  F962A5  24 7C         		bit	storfg
470
 2954  F962A7  10 0B         		bpl	?132			; not store char in tmpfcb
471
 2955  F962A9  A6 82         		ldx	cntx			; index
472
 2956  F962AB  E0 08         		cpx	#8			; max. 8 chars
473
 2957  F962AD  B0 05         		bcs	?132
474
 2958  F962AF  95 92         		sta	tmpfcb,x		; store
475
 2959  F962B1  E8            		inx
476
 2960  F962B2  86 82         		stx	cntx
477
 2961  F962B4  A6 89         	?132:	ldx	FDirIdx
478
 2962  F962B6  E8            		inx				; update index
479
 2963  F962B7  E0 4D         		cpx	#MFATPATH		; check index range (0..76)
480
 2964  F962B9  B0 05         		bcs	?134			; no room to store - error
481
 2965  F962BB  86 89         		stx	FDirIdx			; here CF = 0
482
 2966  F962BD  95 24         		sta	fpaths,x		; store char
483
 2967  F962BF  60            		rts				; CF = 0
484
 2968  F962C0  68            	?134:	pla				; here CF = 1
485
 2969  F962C1  68            		pla				; skip return
486
 2970  F962C2  80 DC         		bra	?126
487
 2971  F962C4
488
 2972                        	?200:	; handle '../' entry
489
 2973  F962C4  A6 89         		ldx	FDirIdx			; current index
490
 2974  F962C6  F0 D7         		beq	?125			; already in root - error
491
 2975  F962C8  CA            		dex
492
 2976  F962C9  B5 24         	?202:	lda	fpaths,x
493
 2977  F962CB  C9 2F         		cmp	#'/'
494
 2978  F962CD  F0 03         		beq	?204
495
 2979  F962CF  CA            		dex
496
 2980  F962D0  D0 F7         		bne	?202
497
  Tue Jul 17 11:00:19 2018                                                                                               Page    9
498
 
499
 
500
 
501
 
502
 2981                        	?204:	;txa
503
 2982                        		;beq	?125
504
 2983                        		;dex
505
 2984  F962D2  86 89         		stx	FDirIdx
506
 2985  F962D4  60            	?206:	rts
507
 2986  F962D5
508
 2987                        	?220:	; parse the last sub-component -- Y = actual pointer to source
509
 2988  F962D5  B7 83         		lda	[LPtr1],y		; check first char
510
 2989  F962D7  C9 2E         		cmp	#'.'			; begin with '.' ?
511
 2990  F962D9  D0 46         		bne	?240			; no -- parse
512
 2991  F962DB  24 74         		bit	fexpfg			; is a file name ?
513
 2992  F962DD  30 C0         		bmi	?125			; yes -- error
514
 2993  F962DF  C8            		iny
515
 2994  F962E0  A6 89         		ldx	FDirIdx			; actual pointer to path
516
 2995  F962E2  B7 83         		lda	[LPtr1],y		; check 2nd char
517
 2996  F962E4  D0 07         		bne	?222			; not a '.' entry
518
 2997  F962E6  8A            		txa
519
 2998  F962E7  F0 EB         		beq	?206			; root directory -- ok
520
 2999  F962E9  64 80         		stz	cnt			; mean to handle '.' entry
521
 3000  F962EB  80 10         		bra	?224
522
 3001  F962ED  C9 2E         	?222:	cmp	#'.'			; '..' entry ?
523
 3002  F962EF  D0 AE         		bne	?125			; no -- error
524
 3003  F962F1  C8            		iny
525
 3004  F962F2  B7 83         		lda	[LPtr1],y		; check 3nd char
526
 3005  F962F4  D0 A9         		bne	?125			; will be 0 -- error
527
 3006  F962F6  8A            		txa
528
 3007  F962F7  F0 A6         		beq	?125			; already in root -- error
529
 3008  F962F9  A9 80         		lda	#$80
530
 3009  F962FB  85 80         		sta	cnt			; mean to handle '..' entry
531
 3010  F962FD  CA            	?224:	dex				; for now the end of path
532
 3011  F962FE  86 89         		stx	FDirIdx			; pointer to last char of path
533
 3012  F96300  E8            		inx
534
 3013  F96301  CA            	?226:	dex				; find previous sub-component
535
 3014  F96302  B5 24         		lda	fpaths,x
536
 3015  F96304  C9 2F         		cmp	#'/'
537
 3016  F96306  D0 F9         		bne	?226
538
 3017  F96308  9B            		txy
539
 3018  F96309  E8            		inx
540
 3019  F9630A  86 90         		stx	lstidx			; this become the last sub-component
541
 3020  F9630C  24 80         		bit	cnt			; handle '.' entry ?
542
 3021  F9630E  10 10         		bpl	?230			; yes -- end parse
543
 3022  F96310  BB            		tyx
544
 3023  F96311  F0 0B         		beq	?229			; root directory
545
 3024  F96313  88            		dey				; before the final '/'
546
 3025  F96314  CA            	?228:	dex				; find previous sub-component
547
 3026  F96315  B5 24         		lda	fpaths,x
548
 3027  F96317  C9 2F         		cmp	#'/'
549
 3028  F96319  D0 F9         		bne	?228
550
 3029  F9631B  E8            		inx
551
 3030  F9631C  86 90         		stx	lstidx			; this become the last sub-component
552
 3031  F9631E  84 89         	?229:	sty	FDirIdx			; pointer to last path char
553
 3032  F96320  60            	?230:	rts
554
 3033  F96321  4C EC 61      	?240:	jmp	?100			; parse normal
555
 3034  F96324
556
 3035                        	?250:	; copy in fpaths the current directory of the drive fdrive
557
 3036  F96324  98            		tya				; save Y in B (Y = 0 or Y = 2)
558
 3037  F96325  EB            		xba
559
  Tue Jul 17 11:00:19 2018                                                                                               Page   10
560
 
561
 
562
 
563
 
564
 3038  F96326  A6 72         		ldx	fdrive
565
 3039  F96328  BF B0 63 F9   		lda	>CDPTRL,x		; pointer of the current directory
566
 3040  F9632C  85 86         		sta	LPtr2
567
 3041  F9632E  BF B4 63 F9   		lda	>CDPTRH,x
568
 3042  F96332  85 87         		sta	LPtr2+1
569
 3043  F96334  A9 01         		lda	#^DEFDIR0
570
 3044  F96336  85 88         		sta	LPtr2+2
571
 3045  F96338  B4 8A         		ldy	CDLen,x			; Y = len - 1
572
 3046  F9633A  BB            		tyx				; X = index fpaths
573
 3047  F9633B  F0 09         		beq	?254			; root directory
574
 3048  F9633D  E8            		inx				; index next char
575
 3049  F9633E  B7 86         	?252:	lda	[LPtr2],y		; copy directory
576
 3050  F96340  99 24 05      		sta	FSWP0+fpaths,y
577
 3051  F96343  88            		dey
578
 3052  F96344  10 F8         		bpl	?252
579
 3053  F96346  EB            	?254:	xba				; restore Y
580
 3054  F96347  A8            		tay
581
 3055  F96348  60            		rts
582
 3056
583
 3057                        	?350:	; search final '/', or '\', or end of string, or '.'
584
 3058  F96349  B7 83         		lda	[LPtr1],y
585
 3059  F9634B  F0 0F         		beq	?352
586
 3060  F9634D  C9 2F         		cmp	#'/'
587
 3061  F9634F  F0 0B         		beq	?352
588
 3062  F96351  C9 5C         		cmp	#'\'
589
 3063  F96353  F0 07         		beq	?352
590
 3064  F96355  C9 2E         		cmp	#'.'
591
 3065  F96357  F0 03         		beq	?352
592
 3066  F96359  C8            		iny
593
 3067  F9635A  80 ED         		bra	?350
594
 3068  F9635C  60            	?352:	rts
595
 3069
596
 3070                        	?360:	; check if file name = device name (ignore extension)
597
 3071  F9635D                		ACC16
598
 3072  F9635D  C2 20         		rep	#PMFLAG
599
 3073                        		.LONGA	on
600
 3074                        		.MNLIST
601
 3075  F9635F  A9 C4 63      		lda	#DEVSTR			; pointer to device name array
602
 3076  F96362  85 A2         		sta	LPtr3
603
 3077  F96364                		ACC08
604
 3078  F96364  E2 20         		sep	#PMFLAG
605
 3079                        		.LONGA	off
606
 3080                        		.MNLIST
607
 3081  F96366  A9 F9         		lda	#^DEVSTR
608
 3082  F96368  85 A4         		sta	LPtr3+2
609
 3083  F9636A  64 76         		stz	devidx			; device name index
610
 3084  F9636C  5A            		phy				; save Y
611
 3085  F9636D  A2 07         	?362:	ldx	#7			; device name 8 chars
612
 3086  F9636F  9B            		txy
613
 3087  F96370  B5 92         	?364:	lda	tmpfcb,x		; compare tmpfcb with device name
614
 3088  F96372  D7 A2         		cmp	[LPtr3],y
615
 3089  F96374  D0 27         		bne	?370			; unmatch
616
 3090  F96376  CA            		dex
617
 3091  F96377  88            		dey
618
 3092  F96378  10 F6         		bpl	?364			; loop
619
 3093  F9637A  E8            		inx
620
 3094  F9637B  C8            		iny				; copy device name in path
621
  Tue Jul 17 11:00:19 2018                                                                                               Page   11
622
 
623
 
624
 
625
 
626
 3095  F9637C  A9 2F         		lda	#'/'
627
 3096  F9637E  85 24         		sta	fpaths
628
 3097  F96380  E8            		inx
629
 3098  F96381  B7 A2         	?366:	lda	[LPtr3],y
630
 3099  F96383  C9 20         		cmp	#' '			; first blank terminate string
631
 3100  F96385  F0 08         		beq	?368
632
 3101  F96387  95 24         		sta	fpaths,x
633
 3102  F96389  E8            		inx
634
 3103  F9638A  C8            		iny
635
 3104  F9638B  C0 08         		cpy	#8
636
 3105  F9638D  90 F2         		bcc	?366			; loop 8 chars
637
 3106  F9638F  CA            	?368:	dex				; update index
638
 3107  F96390  86 89         		stx	FDirIdx
639
 3108  F96392  7A            		ply				; recover Y
640
 3109  F96393  68            		pla				; skip 2 return address
641
 3110  F96394  68            		pla
642
 3111  F96395  68            		pla
643
 3112  F96396  68            		pla
644
 3113  F96397  A9 80         		lda	#$80
645
 3114  F96399  85 75         		sta	devfg			; set device name flag
646
 3115  F9639B  18            		clc
647
 3116  F9639C  60            		rts				; terminate parsing and exit
648
 3117  F9639D  A9 08         	?370:	lda	#8			; update array pointer
649
 3118  F9639F  18            		clc
650
 3119  F963A0  65 A2         		adc	LPtr3
651
 3120  F963A2  85 A2         		sta	LPtr3
652
 3121  F963A4  90 02         		bcc	?372
653
 3122  F963A6  E6 A3         		inc	LPtr3+1
654
 3123  F963A8  E6 76         	?372:	inc	devidx			; update device name array index
655
 3124  F963AA  A7 A2         		lda	[LPtr3]
656
 3125  F963AC  D0 BF         		bne	?362			; loop next device name
657
 3126  F963AE  7A            		ply				; recover Y
658
 3127  F963AF  60            		rts
659
 3128
660
 3129  F963B0
661
 3130  F963B0                	CDPTRL:
662
 3131  F963B0  00 40 80 C0   		.DB	<DEFDIR0, <DEFDIR1, <DEFDIR2, <DEFDIR3
663
 3132  F963B4
664
 3133  F963B4                	CDPTRH:
665
 3134  F963B4  9C 9C 9C 9C   		.DB	>DEFDIR0, >DEFDIR1, >DEFDIR2, >DEFDIR3
666
 3135
667
 3136  F963B8                	NDIRCHRS:
668
 3137  F963B8  22 5B 5D 3A 7C 		.DB	'"[]:|<>+=;, '
669
               3C 3E 2B 3D 3B
670
               2C 20
671
 3138          00000B        	NDCHCNT .EQU	$ - NDIRCHRS - 1
672
 3139
673
 3140  F963C4                	DEVSTR:
674
 3141  F963C4  4B 45 59 42 44 		.DB	'KEYBD$  '	; Keyboard
675
               24 20 20
676
 3142  F963CC  53 43 52 45 45 		.DB	'SCREEN$ '	; Display
677
               4E 24 20
678
 3143  F963D4  43 4F 4E 20 20 		.DB	'CON     '	; Keyboard and display
679
               20 20 20
680
 3144  F963DC  50 52 4E 20 20 		.DB	'PRN     '	; System list device, usually a parallel port
681
               20 20 20
682
 3145  F963E4  4C 53 54 20 20 		.DB	'LST     '	; System list device, usually a parallel port
683
  Tue Jul 17 11:00:19 2018                                                                                               Page   12
684
 
685
 
686
 
687
 
688
               20 20 20
689
 3146  F963EC  4C 50 54 31 20 		.DB	'LPT1    '	; First parallel printer port
690
               20 20 20
691
 3147  F963F4  4C 50 54 32 20 		.DB	'LPT2    '	; Second parallel printer port
692
               20 20 20
693
 3148  F963FC  4C 50 54 33 20 		.DB	'LPT3    '	; Third parallel printer port
694
               20 20 20
695
 3149  F96404  41 55 58 20 20 		.DB	'AUX     '	; Auxiliary device, usually a serial port
696
               20 20 20
697
 3150  F9640C  43 4F 4D 31 20 		.DB	'COM1    '	; First serial communications port
698
               20 20 20
699
 3151  F96414  43 4F 4D 32 20 		.DB	'COM2    '	; Second serial communications port
700
               20 20 20
701
 3152  F9641C  43 4F 4D 33 20 		.DB	'COM3    '	; Third serial communications port
702
               20 20 20
703
 3153  F96424  43 4F 4D 34 20 		.DB	'COM4    '	; Fourth serial communications port
704
               20 20 20
705
 3154  F9642C  4E 55 4C 20 20 		.DB	'NUL     '	; Bit-bucket device
706
               20 20 20
707
 3155  F96434  24 49 44 4C 45 		.DB	'$IDLE$  '	; Bit-bucket device
708
               24 20 20
709
 3156  F9643C  43 4C 4F 43 4B 		.DB	'CLOCK$  '	; System real-time clock
710
               24 20 20
711
 3157  F96444  43 4C 4F 43 4B 		.DB	'CLOCK   '	; System real-time clock
712
               20 20 20
713
 3158  F9644C  43 4F 4E 46 49 		.DB	'CONFIG$ '
714
               47 24 20
715
 3159  F96454  43 4F 4E 53 4F 		.DB	'CONSOLE$'
716
               4C 45 24
717
 3160  F9645C  00            		.DB	0
718
 3161
719
 3162                        	; --- TEST ---
720
 3163                        		.GLOBAL dummydir
721
 3164  F9645D                	dummydir:
722
 3165  F9645D  0B            		phd
723
 3166  F9645E  F4 00 05      		pea	#FSWP0
724
 3167  F96461  2B            		pld
725
 3168  F96462  A2 00         		ldx	#0
726
 3169  F96464  86 73         		stx	fdefdrv
727
 3170  F96466  BF B0 64 F9   	?01:	lda	>TEST1,x
728
 3171  F9646A  F0 07         		beq	?02
729
 3172  F9646C  9F 00 9C 01   		sta	>DEFDIR0,x
730
 3173  F96470  E8            		inx
731
 3174  F96471  D0 F3         		bne	?01
732
 3175  F96473  CA            	?02:	dex
733
 3176  F96474  86 8A         		stx	CDLen
734
 3177  F96476  A2 00         		ldx	#0
735
 3178  F96478  BF B2 64 F9   	?03:	lda	>TEST2,x
736
 3179  F9647C  F0 07         		beq	?04
737
 3180  F9647E  9F 40 9C 01   		sta	>DEFDIR1,x
738
 3181  F96482  E8            		inx
739
 3182  F96483  D0 F3         		bne	?03
740
 3183  F96485  CA            	?04:	dex
741
 3184  F96486  86 8B         		stx	CDLen+1
742
 3185  F96488  A2 00         		ldx	#0
743
 3186  F9648A  BF BF 64 F9   	?05:	lda	>TEST3,x
744
 3187  F9648E  F0 07         		beq	?06
745
  Tue Jul 17 11:00:19 2018                                                                                               Page   13
746
 
747
 
748
 
749
 
750
 3188  F96490  9F 80 9C 01   		sta	>DEFDIR2,x
751
 3189  F96494  E8            		inx
752
 3190  F96495  D0 F3         		bne	?05
753
 3191  F96497  CA            	?06:	dex
754
 3192  F96498  86 8C         		stx	CDLen+2
755
 3193  F9649A  A2 00         		ldx	#0
756
 3194  F9649C  BF C6 64 F9   	?07:	lda	>TEST4,x
757
 3195  F964A0  F0 07         		beq	?08
758
 3196  F964A2  9F C0 9C 01   		sta	>DEFDIR3,x
759
 3197  F964A6  E8            		inx
760
 3198  F964A7  D0 F3         		bne	?07
761
 3199  F964A9  CA            	?08:	dex
762
 3200  F964AA  86 8D         		stx	CDLen+3
763
 3201  F964AC  A2 00         		ldx	#0
764
 3202  F964AE  2B            		pld
765
 3203  F964AF  6B            		rtl
766
 3204  F964B0
767
 3205  F964B0                	TEST1:
768
 3206  F964B0  2F 00         		.DB	'/', 0
769
 3207  F964B2                	TEST2:
770
 3208  F964B2  2F 50 41 54 48 		.DB	'/PATH1/PATH2', 0
771
               31 2F 50 41 54
772
               48 32 00
773
 3209  F964BF                	TEST3:
774
 3210  F964BF  2F 50 41 54 48 		.DB	'/PATH1', 0
775
               31 00
776
 3211  F964C6                	TEST4:
777
 3212  F964C6  2F 50 41 54 48 		.DB	'/PATH1/PATH2/PATH3', 0
778
               31 2F 50 41 54
779
               48 32 2F 50 41
780
               54 48 33 00
781
 3213  F964D9                	TEST5:
782
 3214  F964D9  2F 50 41 54 48 		.DB	'/PATH1/PATH2/PATH3/PATH4', 0
783
               31 2F 50 41 54
784
               48 32 2F 50 41
785
               54 48 33 2F 50
786
               41 54 48 34 00
787
 3215  F964F2                	TEST6:
788
 3216  F964F2  2F 50 41 54 48 		.DB	'/PATH1/PATH2/PATH3/PATH4/PATH5', 0
789
               31 2F 50 41 54
790
               48 32 2F 50 41
791
               54 48 33 2F 50
792
               41 54 48 34 2F
793
               50 41 54 48 35
794
               00
795
 3217
796
 
797
 
798
             Lines Assembled : 3194                  Errors : 0
799
 
800
 
801