Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | - | 1 | Tue Jul 17 11:00:20 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\fatdir.asm |
||
13 | Output Filename : obj\F9\fatdir.obj |
||
14 | Listing Has Been Relocated |
||
15 | |||
16 | |||
17 | 2603 .LIST on |
||
18 | 2604 |
||
19 | 2605 F8FFB1 .INCLUDE inc\dirp00.inc |
||
20 | 2606 ;---------------------------------------------------------- |
||
21 | 2607 ; DIRP00.ASM |
||
22 | 2608 ; PROGETTO: B1601 |
||
23 | 2609 ; |
||
24 | 2610 ; Variabili in Direct Page $00 |
||
25 | 2611 ;---------------------------------------------------------- |
||
26 | 2612 |
||
27 | 2613 ; sezione COMMON -- questo permette di includere il file in piu' file |
||
28 | 2614 |
||
29 | 2615 .LIST on |
||
30 | 2616 |
||
31 | 2617 DIRP00: .SECTION page0, ref_only, common ;Direct-Page 00 |
||
32 | 2618 |
||
33 | 2619 000000 .ABSOLUTE ;; inizia sempre da $00 |
||
34 | 2620 000000 .ORG 0x00 |
||
35 | 2621 000000 |
||
36 | 2622 000000 0000 JiffyClk .DW ; contatore 10ms 32 bit |
||
37 | 2623 000002 0000 .DW |
||
38 | 2624 000004 SysTmr .DS SYSTMRCNT ; system timer 0 (10ms) |
||
39 | 2625 000008 SysTMF .DS SYSTMRCNT ; flag timer (80 -> start) |
||
40 | 2626 00000C 00 Bnk0Flag .DB ; <7>: flag test RAM banco 0 ok |
||
41 | 2627 ; <6>: flag warm reset |
||
42 | 2628 00000D 00 RTCFlag .DB |
||
43 | 2629 |
||
44 | 2630 00000E diskstat .DS 2 ; flag device on ata bus #0 & #1 |
||
45 | 2631 ; <7>: device ready |
||
46 | 2632 ; <6>: compact flash device (C.F.) |
||
47 | 2633 ; <5>: device identification ok |
||
48 | 2634 ; <4>: MBR loaded |
||
49 | 2635 ; <3>: valid signature in MBR |
||
50 | 2636 ; <2>: first partition found&active |
||
51 | 2637 ; <1>: |
||
52 | 2638 ; <0>: valid partition flag |
||
53 | 2639 |
||
54 | 2640 ; <7>: device ready |
||
55 | 2641 ; <6>: USB device |
||
56 | 2642 ; <5>: compact flash device (C.F.) |
||
57 | 2643 ; <4>: device identification ok |
||
58 | 2644 ; <3>: MBR loaded |
||
59 | 2645 ; <2>: first partition found&active |
||
60 | 2646 ; <1>: always 1 |
||
61 | 2647 ; <0>: valid partition flag |
||
62 | 2648 000010 |
||
63 | Tue Jul 17 11:00:20 2018 Page 2 |
||
64 | |||
65 | |||
66 | |||
67 | |||
68 | 2649 |
||
69 | 2650 00000E atadev .EQU diskstat |
||
70 | 2651 |
||
71 | 2652 000010 usbdev .DS 2 ; flag flash disk on usb bus #0 |
||
72 | 2653 ; <7>: device plugged and ready |
||
73 | 2654 ; <6>: always 1 |
||
74 | 2655 ; <5>: device identification ok |
||
75 | 2656 ; <4>: MBR loaded |
||
76 | 2657 ; <3>: valid signature in MBR |
||
77 | 2658 ; <2>: first partition found&active |
||
78 | 2659 ; <1>: |
||
79 | 2660 ; <0>: valid partition flag |
||
80 | 2661 |
||
81 | 2662 000012 diskmax .DS 16 ; disk max. sector's |
||
82 | 2663 000012 atasec .EQU diskmax |
||
83 | 2664 00001A usbsec .EQU diskmax+8 |
||
84 | 2665 |
||
85 | 2666 |
||
86 | 2667 000022 atambr .DS 8 ; data for first partition found in mbr |
||
87 | 2668 ; first 3 bytes for start sector of partition |
||
88 | 2669 ; last byte for partition type |
||
89 | 2670 00002A usbmbr .DS 8 |
||
90 | 2671 |
||
91 | 2672 000032 ataprt .DS 8 ; total sec's of first partition |
||
92 | 2673 00003A usbprt .DS 8 ; total sec's of first partition |
||
93 | 2674 |
||
94 | 2675 |
||
95 | 2676 000042 00 usb0ch .DB ; usb0 (ch375/ch376) flag |
||
96 | 2677 ; <7>: module on |
||
97 | 2678 ; <6>: ch376 flag |
||
98 | 2679 ; <5:0>: chip version |
||
99 | 2680 |
||
100 | 2681 000043 00 usb0st .DB ; usb0 status |
||
101 | 2682 ; <7>: usb0 host mode ok |
||
102 | 2683 ; <6>: flash disk attached flag |
||
103 | 2684 ; <5>: usb device attached |
||
104 | 2685 |
||
105 | 2686 000044 00 fdcdrv .DB ; phisycal drive status (drive #0) |
||
106 | 2687 ; <7>: disk format established in bit 0&1 |
||
107 | 2688 ; <6>: double step seek done |
||
108 | 2689 ; <5>: trust format bit's (set after ok r/w) |
||
109 | 2690 ; <4>: write protect bit (if disk in drive) |
||
110 | 2691 ; <3>: don't care |
||
111 | 2692 ; <2>: don't care |
||
112 | 2693 ; <1>: HD disk if set else DD disk |
||
113 | 2694 ; <0>: CBM format if set else IBM format |
||
114 | 2695 |
||
115 | 2696 000045 00 vdrive .DB ; virtual drive status (ram disk, drive #1) |
||
116 | 2697 ; <7>: disk format established in bit 0&1 |
||
117 | 2698 ; <6>: change disk simulation (after format) |
||
118 | 2699 ; <5>: don't care |
||
119 | 2700 ; <4>: write protect bit (under sw control) |
||
120 | 2701 ; <3>: don't care |
||
121 | 2702 ; <2>: don't care |
||
122 | 2703 ; <1>: HD disk if set else DD disk |
||
123 | 2704 ; <0>: CBM format if set else IBM format |
||
124 | 2705 |
||
125 | Tue Jul 17 11:00:20 2018 Page 3 |
||
126 | |||
127 | |||
128 | |||
129 | |||
130 | 2706 000046 00 fdcctl .DB ; fdc controller status |
||
131 | 2707 ; <7>: drive is attached |
||
132 | 2708 ; <6>: drive need recalibration (restore) |
||
133 | 2709 ; <5>: FDC controller ok |
||
134 | 2710 ; <4>: motor on |
||
135 | 2711 ; <3>: dma is active |
||
136 | 2712 ; <2>: dma chip ok (post routine) |
||
137 | 2713 ; <1>: clock rate (1=HD,0=DD) |
||
138 | 2714 ; <0>: disk ready |
||
139 | 2715 |
||
140 | 2716 000047 00 fdctrk .DB ; fd: current seek track |
||
141 | 2717 000048 00 fdcerr .DB ; fd: last error code |
||
142 | 2718 000049 00 ataerr .DB ; ata: last error code |
||
143 | 2719 00004A 00 ataxer .DB ; ata: last extended error code |
||
144 | 2720 |
||
145 | 2721 00004B 00 CtrlBrk .DB ; flag CTRL+BREAK (NMI) |
||
146 | 2722 |
||
147 | 2723 00004C 0000 MemTop .DW ; top memoria RAM |
||
148 | 2724 00004E 00 .DB ; banco top mem |
||
149 | 2725 |
||
150 | 2726 00004F 00 DflTxtIn .DB ; device di default text input |
||
151 | 2727 000050 00 DflTxtOut .DB ; device di default text output |
||
152 | 2728 |
||
153 | 2729 000051 COPPtr LP ; long pointer for COP decoding |
||
154 | 2730 000054 00 COPIdx .DB ; COP signature/index |
||
155 | 2731 |
||
156 | 2732 000055 00 BiosEnt .DB ; flag accesso a bios setup |
||
157 | 2733 |
||
158 | 2734 ; variabili utilizzate da ACIA |
||
159 | 2735 000056 spwrk .DS $30 |
||
160 | 2736 |
||
161 | 2737 ; bios mem |
||
162 | 2738 000086 0000 nsize .DW ; dimensione blocco da allocare |
||
163 | 2739 ;bsize .DW ; dimensione vera blocco free |
||
164 | 2740 000088 0000 splitsz .DW ; dimensione blocco splittato |
||
165 | 2741 00008A 0000 bfree .DW ; puntatore blocco free |
||
166 | 2742 00008C 0000 hdrptr .DW ; puntatore header heap |
||
167 | 2743 |
||
168 | 2744 00008E 0000 pbrklv .DW ; current break level of current process |
||
169 | 2745 000090 0000 pbrkmin .DW ; minimum breal level of current process |
||
170 | 2746 000092 0000 pbrkmax .DW ; maximum breal level of current process |
||
171 | 2747 000094 |
||
172 | 2748 ; bios temp. work area |
||
173 | 2749 000094 bwrktmp .DS $28 |
||
174 | 2750 |
||
175 | 2751 0000BC 00 coptmp .DB ; temp. used while cop |
||
176 | 2752 |
||
177 | 2753 0000BD 00 tstser .DB ; check ser/usb test board post |
||
178 | 2754 ; <7>: VIA2 ok |
||
179 | 2755 ; <6>: PICRAM ok |
||
180 | 2756 ; <1>: UART 16C550 ok |
||
181 | 2757 ; <0>: R65C51 ok |
||
182 | 2758 |
||
183 | 2759 |
||
184 | 2760 ;crc16 .DW |
||
185 | 2761 |
||
186 | 2762 0000BD .RELATIVE |
||
187 | Tue Jul 17 11:00:20 2018 Page 4 |
||
188 | |||
189 | |||
190 | |||
191 | |||
192 | 2763 |
||
193 | 2764 .ENDS |
||
194 | 2765 |
||
195 | 2766 [01] .IFDEF _ACIA_INC_ |
||
196 | 2767 .INCLUDE INC\SP.INC |
||
197 | 2768 [00] .ENDIF |
||
198 | 2769 |
||
199 | 2794 .LIST on |
||
200 | 2795 |
||
201 | 2796 ;--------------------------------------------------------------------------- |
||
202 | 2797 |
||
203 | 2798 000020 HPLMAX .EQU 32 ; Max. subdirectory level |
||
204 | 2799 |
||
205 | 2800 000200 BCBCNT .EQU $200 ; BCB's struct's count # |
||
206 | 2801 000C00 BCBXBNK .EQU $0C00 ; starting BCB x-mem buffer # |
||
207 | 2802 000040 DMACNT .EQU 64 |
||
208 | 2803 |
||
209 | 2804 0000E0 FAT0X .EQU $E0 ; x-mem bank for fat table of ata #0 |
||
210 | 2805 0000F0 FAT1X .EQU $F0 ; x-mem bank for fat table of ata #1 |
||
211 | 2806 |
||
212 | 2807 F8FFB1 .INCLUDE INC\LDT.INC |
||
213 | 2808 ; LDT.INC |
||
214 | 2809 |
||
215 | 2810 [01] .IFNDEF __LDT_INC__ |
||
216 | 2811 000001 __LDT_INC__ .SET 1 |
||
217 | 2812 |
||
218 | 2813 .LIST on |
||
219 | 2814 ;--------------------------------------------------------------------------- |
||
220 | 2815 ; Logical Drive Table (LDT) -- page 0 offset's |
||
221 | 2816 ;--------------------------------------------------------------------------- |
||
222 | 2817 |
||
223 | 2818 F8FFB1 STRUCT LDT |
||
224 | 2819 _LDT .SECTION page0,common,ref_only,offset 0 ;LDT Struct |
||
225 | 2820 ;.ABSOLUTE |
||
226 | 2821 ;.ORG 0 |
||
227 | 2822 .MNLIST |
||
228 | 2823 000000 00 ldt_fg1 .DB ; logical volume flag's |
||
229 | 2824 ; <7>: device ready (fdc drive or ata device) |
||
230 | 2825 ; <6>: if=1->HD/CF else->FD |
||
231 | 2826 ; <1:0>: phisycal device number |
||
232 | 2827 |
||
233 | 2828 000001 00 ldt_fg2 .DB ; <7>: valid volume (fat volume or cbm disk) |
||
234 | 2829 ; <6>: if=1->FAT else->CBM (FD only) |
||
235 | 2830 ; <5>: disk format checked |
||
236 | 2831 ; <1:0>: disk format (fdc only) |
||
237 | 2832 |
||
238 | 2833 000002 0000 ldt_root .DW ; lba of root dir |
||
239 | 2834 000004 0000 ldt_fat1 .DW ; lba of fat1 table |
||
240 | 2835 000006 0000 ldt_fat2 .DW ; lba of fat2 table |
||
241 | 2836 000008 0000 ldt_cls .DW ; lba of first data cluster |
||
242 | 2837 00000A 0000 ldt_max .DW ; max usable cluster + 1 |
||
243 | 2838 00000C 0000 ldt_rent .DW ; root dir. max. entries |
||
244 | 2839 00000E 0000 ldt_cent .DW ; max. entries in dir. cluster |
||
245 | 2840 000010 0000 ldt_eoc .DW ; end of cluster chain marker |
||
246 | 2841 000012 0000 ldt_free .DW ; count of free cluster's |
||
247 | 2842 000014 0000 ldt_nxt .DW ; next free cluster |
||
248 | 2843 000016 0000 ldt_fsiz .DW ; fat table size |
||
249 | Tue Jul 17 11:00:20 2018 Page 5 |
||
250 | |||
251 | |||
252 | |||
253 | |||
254 | 2844 |
||
255 | 2845 000018 00 ldt_csiz .DB ; cluster size (1,2,4,8,16,32,64) |
||
256 | 2846 000019 00 ldt_cshf .DB ; cluster shift (0,1,2,3,4,5,6) |
||
257 | 2847 00001A 00 ldt_rsiz .DB ; root dir. size (sector's) |
||
258 | 2848 00001B 00 ldt_mcls .DB ; mask for clust. module: 00,01,03,07,0F,1F,3F |
||
259 | 2849 00001C 0000 ldt_cdlp .DW ; current working dir list pointer |
||
260 | 2850 00001E 0000 ldt_cdcls .DW ; current working dir start cluster |
||
261 | 2851 000020 00 ldt_cdlvl .DB ; current working dir level count |
||
262 | 2852 |
||
263 | 2853 000021 00 ldt_ptype .DB |
||
264 | 2854 000022 0000 0000 ldt_pstart .LWORD |
||
265 | 2855 000026 0000 0000 ldt_psize .LWORD |
||
266 | 2856 |
||
267 | 2857 000022 ldt_fp .EQU ldt_pstart ; fat table buffer long pointer |
||
268 | 2858 000025 ldt_fbuf .EQU ldt_pstart+3 ; fat table: x-mem base bank/dma buffer |
||
269 | 2859 |
||
270 | 2860 000026 ldt_pbr .EQU ldt_psize ; long pointer to PBR cache buffer |
||
271 | 2861 000029 ldt_fmt .EQU ldt_psize+3 |
||
272 | 2862 |
||
273 | 2863 00002A ESTRUCT LDT |
||
274 | 2864 00002A LDTSIZE .DS 0 |
||
275 | 2865 ;.RELATIVE |
||
276 | 2866 .ENDS |
||
277 | 2867 .MNLIST |
||
278 | 2868 |
||
279 | 2869 [00] .ENDIF |
||
280 | 2870 |
||
281 | 2871 F8FFB1 |
||
282 | 2872 ;--------------------------------------------------------------------------- |
||
283 | 2873 ; Hierarchical Path List (HPL) -- 16 bit offset's |
||
284 | 2874 ;--------------------------------------------------------------------------- |
||
285 | 2875 |
||
286 | 2876 F8FFB1 LSTRUCT HPL |
||
287 | 2877 _HPL .SECTION common,ref_only,offset 0 ;HPL Struct |
||
288 | 2878 .MNLIST |
||
289 | 2879 000000 0000 hpl_cls .DW ; parent cluster |
||
290 | 2880 000002 0000 hpl_ix .DW ; entry index in parent cluster |
||
291 | 2881 000004 hpl_fcb .DS 11 ; fcb name |
||
292 | 2882 00000F 00 hpl_lst .DB ; unused |
||
293 | 2883 000010 ESTRUCT HPL |
||
294 | 2884 000010 HPLSIZE .DS 0 |
||
295 | 2885 ;.RELATIVE |
||
296 | 2886 .ENDS |
||
297 | 2887 .MNLIST |
||
298 | 2888 |
||
299 | 2889 ;--------------------------------------------------------------------------- |
||
300 | 2890 ; Buffer Control Block (BCB) -- 16 bit offset's |
||
301 | 2891 ;--------------------------------------------------------------------------- |
||
302 | 2892 |
||
303 | 2893 F8FFB1 LSTRUCT BCB |
||
304 | 2894 _BCB .SECTION common,ref_only,offset 0 ;BCB Struct |
||
305 | 2895 .MNLIST |
||
306 | 2896 000000 0000 bcb_next .DW ; next logical linked BCB |
||
307 | 2897 000002 00 bcb_drv .DB ; logical drive |
||
308 | 2898 000003 00 bcb_sec .DB ; sector offset |
||
309 | 2899 000004 0000 bcb_cls .DW ; cluster |
||
310 | 2900 000006 0000 bcb_lba .DW ; sector lba address |
||
311 | Tue Jul 17 11:00:20 2018 Page 6 |
||
312 | |||
313 | |||
314 | |||
315 | |||
316 | 2901 000008 0000 bcb_lbah .DW ; lba high |
||
317 | 2902 000008 bcb_head .EQU bcb_lbah ; floppy head |
||
318 | 2903 00000A 0000 bcb_buf .DW ; x-mem buffer number |
||
319 | 2904 00000A bcb_trk .EQU bcb_buf ; floppy track(low) & sector(hi) |
||
320 | 2905 00000C 0000 bcb_ptr .DW ; buffer pointer |
||
321 | 2906 00000E 0000 bcb_xbnk .DW ; buffer pointer hi & x-mem bank |
||
322 | 2907 00000E bcb_dma .EQU bcb_xbnk ; buffer pointer hi & dma buffer |
||
323 | 2908 000010 ESTRUCT BCB |
||
324 | 2909 000010 BCBSIZE .DS 0 |
||
325 | 2910 ;.RELATIVE |
||
326 | 2911 .ENDS |
||
327 | 2912 .MNLIST |
||
328 | 2913 |
||
329 | 2914 ;--------------------------------------------------------------------------- |
||
330 | 2915 ; hash Control Block (BCB) -- 16 bit offset's |
||
331 | 2916 ;--------------------------------------------------------------------------- |
||
332 | 2917 |
||
333 | 2918 F8FFB1 LSTRUCT HCB |
||
334 | 2919 _HCB .SECTION common,ref_only,offset 0 ;HCB Struct |
||
335 | 2920 .MNLIST |
||
336 | 2921 000000 0000 hcb_next .DW ; pointer to next HCB |
||
337 | 2922 000002 0000 hcb_cls .DW ; cluster number |
||
338 | 2923 000004 0000 hcb_seq .DW ; sequence number + logical drive number |
||
339 | 2924 000006 0000 hcb_cnt .DW ; number of hashed entries |
||
340 | 2925 000008 hcb_data .DS 0 ; hash buffer data |
||
341 | 2926 000008 ESTRUCT HCB |
||
342 | 2927 000008 HCBSIZE .DS 0 |
||
343 | 2928 ;.RELATIVE |
||
344 | 2929 .ENDS |
||
345 | 2930 .MNLIST |
||
346 | 2931 |
||
347 | 2932 ;--------------------------------------------------------------------------- |
||
348 | 2933 ; TOS Working Segment |
||
349 | 2934 ;--------------------------------------------------------------------------- |
||
350 | 2935 |
||
351 | 2936 000001 WKB .EQU .SEG.TOSSEG ; TOS working bank |
||
352 | 2937 |
||
353 | 2938 010000 TS .SET TOSSEG |
||
354 | 2939 01FFFF TE .SET TOSSEG + $FFFF |
||
355 | 2940 018C00 TO0 .SET $018C00 |
||
356 | 2941 019E00 TO1 .SET TOSWKM |
||
357 | 2942 |
||
358 | 2943 .comment @ |
||
359 | 2944 _TOS0: .SECTION ref_only, common, offset TO0, range TS TE ;FAT Struct's |
||
360 | 2945 _TOS0_START .DS 0 |
||
361 | 2946 |
||
362 | 2947 _pbr0 .DS 512 |
||
363 | 2948 _pbr1 .DS 512 |
||
364 | 2949 _pbr2 .DS 512 |
||
365 | 2950 _pbr3 .DS 512 |
||
366 | 2951 |
||
367 | 2952 _TOS0_END .DS 0 |
||
368 | 2953 TOS0SIZ .EQU (_TOS0_END - _TOS0_START) |
||
369 | 2954 .ENDS |
||
370 | 2955 @ |
||
371 | 2956 |
||
372 | 2957 _TOS1: .SECTION ref_only, common, offset TO1, range TS TE ;FAT Struct's |
||
373 | Tue Jul 17 11:00:20 2018 Page 7 |
||
374 | |||
375 | |||
376 | |||
377 | |||
378 | 2958 019E00 _TOS1_START .DS 0 |
||
379 | 2959 |
||
380 | 2960 ; current working directory HPL |
||
381 | 2961 019E00 cwdl0 .DS (HPLSIZE*HPLMAX) |
||
382 | 2962 01A000 cwdl1 .DS (HPLSIZE*HPLMAX) |
||
383 | 2963 01A200 cwdl2 .DS (HPLSIZE*HPLMAX) |
||
384 | 2964 01A400 cwdl3 .DS (HPLSIZE*HPLMAX) |
||
385 | 2965 |
||
386 | 2966 ; current building path HPL |
||
387 | 2967 01A600 cbpl .DS (HPLSIZE*HPLMAX) |
||
388 | 2968 01A600 HPL_CLS .EQU hpl_cls+cbpl |
||
389 | 2969 01A602 HPL_IX .EQU hpl_ix+cbpl |
||
390 | 2970 01A604 HPL_FCB .EQU hpl_fcb+cbpl |
||
391 | 2971 |
||
392 | 2972 ; BCB list's |
||
393 | 2973 01A800 bcbstart .DS (BCBCNT*BCBSIZE) |
||
394 | 2974 01C800 bcbend .DS 0 |
||
395 | 2975 01C800 dmastart .DS (DMACNT*BCBSIZE) |
||
396 | 2976 01CC00 dmaend .DS 0 |
||
397 | 2977 01CC00 dma0s .DS (17*BCBSIZE) |
||
398 | 2978 01CD10 dma1s .DS (17*BCBSIZE) |
||
399 | 2979 |
||
400 | 2980 01CE20 _TOS1_END .DS 0 |
||
401 | 2981 003020 TOS1SIZ .EQU (_TOS1_END - _TOS1_START) |
||
402 | 2982 .ENDS |
||
403 | 2983 |
||
404 | 2984 ;--------------------------------------------------------------------------- |
||
405 | 2985 ; HCB Segment |
||
406 | 2986 ;--------------------------------------------------------------------------- |
||
407 | 2987 |
||
408 | 2988 000004 HCBBNK .EQU .SEG.HCBSEG |
||
409 | 2989 040000 HS .SET HCBSEG |
||
410 | 2990 04FFFF HE .SET HCBSEG + $FFFF |
||
411 | 2991 040000 HO .SET HCBSEG |
||
412 | 2992 |
||
413 | 2993 _HCBS: .SECTION ref_only, common, offset HO, range HS HE ;HCB's List |
||
414 | 2994 040000 hcb_bnk .DS 8 |
||
415 | 2995 040008 hcbstart .DS 0 |
||
416 | 2996 .ENDS |
||
417 | 2997 |
||
418 | 2998 ;.comment @ |
||
419 | 2999 ;--------------------------------------------------------------------------- |
||
420 | 3000 ; direct page for LDT var's |
||
421 | 3001 ;--------------------------------------------------------------------------- |
||
422 | 3002 |
||
423 | 3003 ; P0OS |
||
424 | 3004 DPOS: .SECTION page0, common, ref_only, offset 0 ;OS Main D.P. |
||
425 | 3005 |
||
426 | 3006 ;sysbuf .DS 2 ; floppy track 0 cache buffer |
||
427 | 3007 000000 00 defhsec .DB ; default hidden sector's in fdisk |
||
428 | 3008 000001 00 .DB |
||
429 | 3009 000002 0000 cmdstk .DW ; saved stack on TOS command's |
||
430 | 3010 000004 bpath .DS 80 |
||
431 | 3011 |
||
432 | 3012 000054 bpath1 .DS 0 |
||
433 | 3013 .ENDS |
||
434 | 3014 ;@ |
||
435 | Tue Jul 17 11:00:20 2018 Page 8 |
||
436 | |||
437 | |||
438 | |||
439 | |||
440 | 3015 |
||
441 | 3016 ; P0LDT |
||
442 | 3017 DPLDT: .SECTION page0, common, ref_only, offset 0 ;LDT D.P. |
||
443 | 3018 |
||
444 | 3019 000000 ldt0 .DS LDTSIZE |
||
445 | 3020 00002A ldt1 .DS LDTSIZE |
||
446 | 3021 000054 ldt2 .DS LDTSIZE |
||
447 | 3022 00007E ldt3 .DS LDTSIZE |
||
448 | 3023 0000A8 ldt4 .DS LDTSIZE |
||
449 | 3024 |
||
450 | 3025 0000D2 ldtp .DS 6 ; pointer to LDT's in DPLDT page |
||
451 | 3026 |
||
452 | 3027 0000D8 sysbuf .DS 4 ; floppy track 0 cache buffer |
||
453 | 3028 |
||
454 | 3029 .ENDS |
||
455 | 3030 |
||
456 | 3031 ;--------------------------------------------------------------------------- |
||
457 | 3032 ; direct page for FAT var's |
||
458 | 3033 ;--------------------------------------------------------------------------- |
||
459 | 3034 |
||
460 | 3035 ; P0FAT |
||
461 | 3036 DPFAT: .SECTION page0, common, ref_only, offset 0 ;FAT D.P. |
||
462 | 3037 |
||
463 | 3038 000000 0000 ostos .DW ; saved top of stack |
||
464 | 3039 000002 00 ioerr .DB ; i/o error |
||
465 | 3040 000003 00 ioerr2 .DB ; extended i/o error |
||
466 | 3041 000004 0000 hcbroot .DW ; HCB struct's list |
||
467 | 3042 000006 0000 hcblst .DW ; the last one HCB |
||
468 | 3043 000008 00 hsiz .DB ; how many sector's an HCB can hold |
||
469 | 3044 000009 00 hlog2 .DB ; shift count related to hsiz |
||
470 | 3045 00000A 0000 bcbroot .DW ; BCB buffer's list |
||
471 | 3046 00000C 0000 bcblst .DW ; the last one BCB |
||
472 | 3047 00000E 0000 dmaroot .DW ; dma BCB buffer's list |
||
473 | 3048 000010 0000 dmalst .DW ; the last one dma BCB |
||
474 | 3049 000012 0000 dmabcb .DW ; BCB list for floppy root, cluster#2,#3 |
||
475 | 3050 000014 00 fspt .DB ; sector per track (floppy) |
||
476 | 3051 000015 00 pdrive .DB ; phisycal drive number |
||
477 | 3052 000016 00 bplvl .DB ; subdir level while build path |
||
478 | 3053 000017 00 defdrv .DB ; default drive |
||
479 | 3054 |
||
480 | 3055 ; the first block of ldt_ var's is copied from the LDT struct |
||
481 | 3056 000018 00 ldtfg1 .DB ; logical volume flag's |
||
482 | 3057 ; <7>: device ready (fdc drive or ata device) |
||
483 | 3058 ; <6>: if=1->HD/CF else->FD |
||
484 | 3059 ; <0>: phisycal device number |
||
485 | 3060 |
||
486 | 3061 000019 00 ldtfg2 .DB ; <7>: valid volume (fat volume or cbm disk) |
||
487 | 3062 ; <6>: if=1->FAT else->CBM (FD only) |
||
488 | 3063 ; <5>: disk format checked |
||
489 | 3064 ; <1:0>: disk format (fdc only) |
||
490 | 3065 |
||
491 | 3066 00001A ldtfp LP ; fat table buffer long pointer |
||
492 | 3067 00001D 00 ldtfbuf .DB ; fat table: x-mem base bank/dma buffer |
||
493 | 3068 |
||
494 | 3069 00001E 0000 ldtroot .DW ; lba of root dir |
||
495 | 3070 000020 0000 ldtfat1 .DW ; lba of fat1 table |
||
496 | 3071 000022 0000 ldtfat2 .DW ; lba of fat2 table |
||
497 | Tue Jul 17 11:00:20 2018 Page 9 |
||
498 | |||
499 | |||
500 | |||
501 | |||
502 | 3072 000024 0000 ldtcls .DW ; lba of first data cluster |
||
503 | 3073 000026 0000 ldtmax .DW ; max usable cluster + 1 |
||
504 | 3074 000028 00 ldtcsiz .DB ; cluster size (1,2,4,8,16,32,64) |
||
505 | 3075 000029 00 ldtcshf .DB ; cluster shift (0,1,2,3,4,5,6) |
||
506 | 3076 00002A 00 ldtfsiz .DB ; fat table size (if 0 -> 256) |
||
507 | 3077 00002B 00 ldtrsiz .DB ; root dir. size (sector's) |
||
508 | 3078 00002C 0000 ldtrent .DW ; root dir. max. entries |
||
509 | 3079 00002E 0000 ldtcent .DW ; max. entries in dir. cluster |
||
510 | 3080 000030 0000 ldteoc .DW ; end of cluster chain marker |
||
511 | 3081 000032 00 ldtmcls .DB ; mask for clust. module: 00,01,03,07,0F,1F,3F |
||
512 | 3082 000033 00 ldtfmt .DB ; floppy disk format (0,1,2, FF if ata device) |
||
513 | 3083 000034 0000 ldtcdlp .DW ; current working dir list pointer |
||
514 | 3084 000036 0000 ldtcdcls .DW ; current working dir start cluster |
||
515 | 3085 000038 0000 ldtfree .DW ; count of free cluster's |
||
516 | 3086 00003A 0000 ldtnxt .DW ; next free cluster |
||
517 | 3087 00003C 00 ldtcdlvl .DB ; current working dir level count |
||
518 | 3088 00003D ldtpbr LP ; long pointer to PBR cache buffer |
||
519 | 3089 |
||
520 | 3090 000040 0000 chdcls .DW ; last accessed chained dir. cluster |
||
521 | 3091 000042 0000 clsofs .DW ; cluster's offset from start of chain |
||
522 | 3092 |
||
523 | 3093 ; not change order of the 2 following var's: will be accessed as 16 bit var |
||
524 | 3094 000044 00 entofs .DB ; entry offset from start of sector |
||
525 | 3095 000045 00 secofs .DB ; sector's offset from start of cluster |
||
526 | 3096 |
||
527 | 3097 000046 0000 dircls .DW ; directory cluster |
||
528 | 3098 000048 0000 dcnt .DW ; directory entry counter |
||
529 | 3099 00004A 0000 lba .DW ; lba sector address |
||
530 | 3100 00004C 0000 lbah .DW ; lba is 24 bit's only |
||
531 | 3101 00004E 0000 xbuf .DW ; x-mem buffer transfer number |
||
532 | 3102 |
||
533 | 3103 00004C fhead .EQU lbah ; fd head |
||
534 | 3104 00004E ftrack .EQU xbuf ; fd track |
||
535 | 3105 00004F fsec .EQU xbuf+1 ; fd sector |
||
536 | 3106 |
||
537 | 3107 000050 00 dfcbtyp .DB ; FCB type to search |
||
538 | 3108 000051 00 dfcbatt .DB ; attribute of found FCB |
||
539 | 3109 |
||
540 | 3110 000052 00 curdrv .DB ; current logical drive |
||
541 | 3111 000053 fcbs .DS 11 ; file control block name |
||
542 | 3112 |
||
543 | 3113 ;dcmask .DW ; mask to start of cluster |
||
544 | 3114 ; FFF0, FFE0, FFC0, FF80, FF00, FE00 |
||
545 | 3115 |
||
546 | 3116 00005E 0000 fcbp .DW ; FCB buffer long pointer |
||
547 | 3117 000060 0000 .DW ; low=fcbp+2, high=x-mem bank or dma buffer |
||
548 | 3118 000061 dmabuf .EQU fcbp+3 ; dma buffer # |
||
549 | 3119 000061 xmbank .EQU fcbp+3 ; x-mem bank # |
||
550 | 3120 |
||
551 | 3121 ; temp area |
||
552 | 3122 000062 00 hcbseq .DB |
||
553 | 3123 000063 00 hcbdrv .DB |
||
554 | 3124 000064 0000 bcbcls .DW |
||
555 | 3125 000066 00 bcbdrv .DB |
||
556 | 3126 000067 00 bcbsec .DB |
||
557 | 3127 |
||
558 | 3128 000068 0000 thash .DW |
||
559 | Tue Jul 17 11:00:20 2018 Page 10 |
||
560 | |||
561 | |||
562 | |||
563 | |||
564 | 3129 000068 hcbrec .EQU thash |
||
565 | 3130 000068 wtmp .EQU thash |
||
566 | 3131 |
||
567 | 3132 00006A 0000 hlast .DW |
||
568 | 3133 00006C 0000 hcbcls .DW |
||
569 | 3134 00006E 0000 hcbx .DW |
||
570 | 3135 000070 0000 hcby .DW |
||
571 | 3136 00006A tmpp .EQU hlast ; temp. long pointer |
||
572 | 3137 00006E tmpx .EQU hcbx |
||
573 | 3138 00006F wild .EQU hcbx+1 |
||
574 | 3139 000070 fsiz .EQU hcby |
||
575 | 3140 000071 fptr .EQU hcby+1 |
||
576 | 3141 00006E ldrv .EQU hcbx |
||
577 | 3142 00006F tmpldt .EQU hcbx+1 |
||
578 | 3143 |
||
579 | 3144 000072 0000 fhash .DW |
||
580 | 3145 000074 0000 fcbofs .DW |
||
581 | 3146 000076 00 bcbload .DB |
||
582 | 3147 000077 00 xstart .DB |
||
583 | 3148 000078 00 xend .DB |
||
584 | 3149 000079 00 seccnt .DB |
||
585 | 3150 00007A 00 maxseq .DB |
||
586 | 3151 00007B 00 dsiz .DB |
||
587 | 3152 |
||
588 | 3153 00007C 00 haswld .DB |
||
589 | 3154 00007D 00 strix .DB |
||
590 | 3155 00007E pathp LP ; long pointer to path string |
||
591 | 3156 |
||
592 | 3157 ; TEMP |
||
593 | 3158 000081 0000 quot .DW |
||
594 | 3159 000083 0000 dvsor .DW |
||
595 | 3160 000085 0000 troot .DW |
||
596 | 3161 000087 0000 tlst .DW |
||
597 | 3162 000089 0000 bdmask .DW |
||
598 | 3163 00008B 0000 bcmask .DW |
||
599 | 3164 |
||
600 | 3165 00008D 00 hcbuse .DB |
||
601 | 3166 |
||
602 | 3167 .ENDS |
||
603 | 3168 |
||
604 | 3172 .LIST on |
||
605 | 3173 |
||
606 | 3174 ;--------------------------------------------------------------------------- |
||
607 | 3175 ; code segment -- bank $F9 |
||
608 | 3176 ;--------------------------------------------------------------------------- |
||
609 | 3177 |
||
610 | 3178 .CODEF9 |
||
611 | 3179 .EXTERN oserror, getldt |
||
612 | 3180 .EXTERN mxdrv, fndhcb, fndbuf, cls2lba ; utils.asm |
||
613 | 3181 F91CE9 |
||
614 | 3182 .PUBLIC prslbl |
||
615 | 3183 |
||
616 | 3184 .LONGA off |
||
617 | 3185 .LONGI off |
||
618 | 3186 |
||
619 | 3187 ;--------------------------------------------------------------------------- |
||
620 | 3188 ; path parse & build |
||
621 | Tue Jul 17 11:00:20 2018 Page 11 |
||
622 | |||
623 | |||
624 | |||
625 | |||
626 | 3189 ;--------------------------------------------------------------------------- |
||
627 | 3190 |
||
628 | 3191 ; pathdrv, pathcnt & pathnxt functions |
||
629 | 3192 ; run down the path and parse final name into fcbs |
||
630 | 3193 ; set directory cluster to last but one path name |
||
631 | 3194 ; |
||
632 | 3195 ; entry: pathp = long pointer to path string |
||
633 | 3196 ; |
||
634 | 3197 ; exit: dircls = start cluster of the last but one path name |
||
635 | 3198 ; if CF=0 (no error) |
||
636 | 3199 ; |
||
637 | 3200 ; if any error, CF=1 and A=error code |
||
638 | 3201 ; error code: ED_FILE (invalid filename/file not found) |
||
639 | 3202 ; ED_PATH (path not found) |
||
640 | 3203 ; ED_ACCESS (access denied) |
||
641 | 3204 ; ED_FORMAT (invalid format) |
||
642 | 3205 ; ED_DRIVE (invalid drive) |
||
643 | 3206 ; ED_NOTRDY (drive not ready) |
||
644 | 3207 ; use: all |
||
645 | 3208 ; |
||
646 | 3209 |
||
647 | 3210 ;------- |
||
648 | 3211 setpchk: ; special entry for directory handler function's |
||
649 | 3212 ;------- |
||
650 | 3213 F91CE9 20 F6 1C jsr setpath ; parse path string & build path |
||
651 | 3214 F91CEC 20 69 20 jsr nodev ; devices not allowed |
||
652 | 3215 F91CEF 20 74 20 jsr nodot ; no subdirs entries |
||
653 | 3216 F91CF2 20 7F 20 jsr nowild ; wild cards not allowed |
||
654 | 3217 F91CF5 60 rts |
||
655 | 3218 |
||
656 | 3219 ;------- |
||
657 | 3220 F91CF6 setpath: |
||
658 | 3221 ;------- |
||
659 | 3222 F91CF6 20 FE 1C jsr pathdrv |
||
660 | 3223 F91CF9 90 0A bcc phx |
||
661 | 3224 F91CFB 4C 12 24 jmp oserror |
||
662 | 3225 |
||
663 | 3226 ;------- |
||
664 | 3227 pathdrv: ; get drive number from path or use default drive |
||
665 | 3228 ;------- |
||
666 | 3229 F91CFE 20 3E 20 jsr getpdrv ; return drive number in A |
||
667 | 3230 F91D01 90 03 bcc pathcnt |
||
668 | 3231 F91D03 A9 0F lda #ED_DRIVE ; invalid drive error |
||
669 | 3232 F91D05 60 phx: rts |
||
670 | 3233 F91D06 |
||
671 | 3234 ;------- |
||
672 | 3235 pathcnt: ; use drive in A |
||
673 | 3236 ;------- |
||
674 | 3237 F91D06 20 23 24 jsr mxdrv ; select drive in A |
||
675 | 3238 F91D09 A4 7D ldy strix ; path string index |
||
676 | 3239 F91D0B B7 7E lda [pathp],y ; get first character |
||
677 | 3240 F91D0D C8 iny |
||
678 | 3241 F91D0E 84 7D sty strix |
||
679 | 3242 F91D10 20 7B 1F jsr chkslh ; if '\' or '/' then start at root... |
||
680 | 3243 F91D13 D0 16 bne ?20 ; ...else select current working directory |
||
681 | 3244 F91D15 20 92 1F jsr fakefcb ; fake a '.' entry for the root |
||
682 | 3245 F91D18 86 46 stx dircls ; start at fake cluster 0 |
||
683 | Tue Jul 17 11:00:20 2018 Page 12 |
||
684 | |||
685 | |||
686 | |||
687 | |||
688 | 3246 F91D1A 86 47 stx dircls+1 |
||
689 | 3247 F91D1C B7 7E lda [pathp],y ; get next character |
||
690 | 3248 F91D1E F0 09 beq ?10 ; if just a '\' or '/' then stop now |
||
691 | 3249 F91D20 20 7B 1F jsr chkslh ; detected '//' or '\\' ? |
||
692 | 3250 F91D23 D0 0C bne pathnxt ; no, so start processing from root dir. |
||
693 | 3251 F91D25 A9 05 lda #ED_ACCESS ; report 'access denied' error |
||
694 | 3252 F91D27 38 sec |
||
695 | 3253 F91D28 60 rts |
||
696 | 3254 F91D29 18 ?10: clc ; no error |
||
697 | 3255 F91D2A 60 rts |
||
698 | 3256 F91D2B 88 ?20: dey ; forget about char we looked at |
||
699 | 3257 F91D2C 84 7D sty strix |
||
700 | 3258 F91D2E 20 A0 1F jsr mvtobp ; start processing from cur. dir. |
||
701 | 3259 |
||
702 | 3260 ;------- |
||
703 | 3261 pathnxt: ; parse&build path |
||
704 | 3262 ;------- |
||
705 | 3263 F91D31 A4 7D ldy strix |
||
706 | 3264 F91D33 B7 7E ?10: lda [pathp],y ; can't have trailing '/' or '\' |
||
707 | 3265 F91D35 F0 27 beq ?15 ; error |
||
708 | 3266 F91D37 20 B2 1D jsr prspath ; parse path & set up fcb |
||
709 | 3267 F91D3A B0 22 bcs ?15 ; error |
||
710 | 3268 F91D3C AA tax ; A=delimiter |
||
711 | 3269 F91D3D F0 23 beq ?20 ; we are at the end |
||
712 | 3270 F91D3F ACC16 |
||
713 | 3271 F91D3F C2 20 rep #PMFLAG |
||
714 | 3272 .LONGA on |
||
715 | 3273 .MNLIST |
||
716 | 3274 F91D41 A5 53 lda fcbs |
||
717 | 3275 F91D43 C9 2E 20 cmp #' .' ; if chdir(".")... |
||
718 | 3276 F91D46 ACC08 |
||
719 | 3277 F91D46 E2 20 sep #PMFLAG |
||
720 | 3278 .LONGA off |
||
721 | 3279 .MNLIST |
||
722 | 3280 F91D48 F0 E9 beq ?10 ; ...stay where we are |
||
723 | 3281 F91D4A A5 7C lda haswld ; no wilds cards in path's |
||
724 | 3282 F91D4C D0 10 bne ?15 ; skip if wild cards found |
||
725 | 3283 F91D4E 20 D2 20 jsr fndfcbf ; locate the directory entry |
||
726 | 3284 F91D51 B0 0B bcs ?15 ; missing directory in path: path not found |
||
727 | 3285 F91D53 A5 51 lda dfcbatt ; test entry attribute |
||
728 | 3286 F91D55 89 10 bit #DA_DIR |
||
729 | 3287 F91D57 F0 05 beq ?15 ; error: not a directory |
||
730 | 3288 F91D59 20 D2 1E jsr setdir ; set dir. cluster |
||
731 | 3289 F91D5C 90 D5 bcc ?10 ; next path name |
||
732 | 3290 F91D5E A9 03 ?15: lda #ED_PATH ; 'path not found' error |
||
733 | 3291 F91D60 38 sec |
||
734 | 3292 F91D61 60 rts |
||
735 | 3293 F91D62 A5 53 ?20: lda fcbs ; is it '.' or '..' ? |
||
736 | 3294 F91D64 C9 2E cmp #'.' ; if so get its full name |
||
737 | 3295 F91D66 D0 3F bne ?35 ; exit, no error |
||
738 | 3296 F91D68 ACC16 |
||
739 | 3297 F91D68 C2 20 rep #PMFLAG |
||
740 | 3298 .LONGA on |
||
741 | 3299 .MNLIST |
||
742 | 3300 F91D6A A5 46 lda dircls ; we are at root? |
||
743 | 3301 F91D6C F0 37 beq ?30 ; yes, exit, no error |
||
744 | 3302 F91D6E A4 16 ldy bplvl |
||
745 | Tue Jul 17 11:00:20 2018 Page 13 |
||
746 | |||
747 | |||
748 | |||
749 | |||
750 | 3303 F91D70 F0 33 beq ?30 ; no error |
||
751 | 3304 F91D72 88 dey ; go up one level |
||
752 | 3305 F91D73 A5 53 lda fcbs |
||
753 | 3306 F91D75 C9 2E 2E cmp #'..' ; parent? |
||
754 | 3307 F91D78 D0 03 bne ?25 ; no, stay here |
||
755 | 3308 F91D7A 88 dey ; go up two level's |
||
756 | 3309 F91D7B 30 2C bmi ?40 ; we are destined for the root |
||
757 | 3310 F91D7D 84 16 ?25: sty bplvl |
||
758 | 3311 F91D7F 8B phb ; save DBR |
||
759 | 3312 F91D80 A2 01 ldx #WKB |
||
760 | 3313 F91D82 DA phx |
||
761 | 3314 F91D83 AB plb |
||
762 | 3315 F91D84 A2 00 ldx #0 |
||
763 | 3316 F91D86 INDEX16 |
||
764 | 3317 F91D86 C2 10 rep #PXFLAG |
||
765 | 3318 .LONGI on |
||
766 | 3319 .MNLIST |
||
767 | 3320 F91D88 98 tya |
||
768 | 3321 F91D89 0A asl a ; get HPL pointer |
||
769 | 3322 F91D8A 0A asl a |
||
770 | 3323 F91D8B 0A asl a |
||
771 | 3324 F91D8C 0A asl a ; here CF=0 |
||
772 | 3325 ;adc #cbpl |
||
773 | 3326 F91D8D A8 tay ; HPL index access |
||
774 | 3327 F91D8E B9 00 A6 lda HPL_CLS,y |
||
775 | 3328 F91D91 85 46 sta dircls ; set up parent cluster |
||
776 | 3329 F91D93 B9 02 A6 lda HPL_IX,y |
||
777 | 3330 F91D96 85 48 sta dcnt ; set up dir. index |
||
778 | 3331 F91D98 B9 04 A6 ?28: lda HPL_FCB,y ; copy parental name |
||
779 | 3332 F91D9B 95 53 sta fcbs,x |
||
780 | 3333 F91D9D C8 iny |
||
781 | 3334 F91D9E E8 inx |
||
782 | 3335 F91D9F E0 0B 00 cpx #11 |
||
783 | 3336 F91DA2 90 F4 bcc ?28 |
||
784 | 3337 F91DA4 AB plb |
||
785 | 3338 F91DA5 ?30: CPU08 |
||
786 | 3339 F91DA5 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
787 | 3340 .LONGA off |
||
788 | 3341 .LONGI off |
||
789 | 3342 .MNLIST |
||
790 | 3343 F91DA7 18 ?35: clc |
||
791 | 3344 F91DA8 60 rts |
||
792 | 3345 F91DA9 |
||
793 | 3346 F91DA9 64 46 ?40: stz dircls ; root dir |
||
794 | 3347 F91DAB CPU08 |
||
795 | 3348 F91DAB E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
796 | 3349 .LONGA off |
||
797 | 3350 .LONGI off |
||
798 | 3351 .MNLIST |
||
799 | 3352 F91DAD 20 92 1F jsr fakefcb |
||
800 | 3353 F91DB0 18 clc |
||
801 | 3354 F91DB1 60 rts |
||
802 | 3355 F91DB2 |
||
803 | 3356 ; parse path name into fcb |
||
804 | 3357 ; |
||
805 | 3358 ; entry: Y = pointer to current name in path |
||
806 | 3359 ; pathp = long pointer to path |
||
807 | Tue Jul 17 11:00:20 2018 Page 14 |
||
808 | |||
809 | |||
810 | |||
811 | |||
812 | 3360 ; |
||
813 | 3361 ; exit: A = last char parsed |
||
814 | 3362 ; Y = pointer to next name in path |
||
815 | 3363 ; CF = 1 if parsing error |
||
816 | 3364 ; |
||
817 | 3365 ;------- |
||
818 | 3366 F91DB2 prspath: |
||
819 | 3367 ;------- |
||
820 | 3368 F91DB2 20 87 1F jsr clrfcb ; initialise fcb to blanks |
||
821 | 3369 F91DB5 64 7C stz haswld ; clear wild cards flag |
||
822 | 3370 F91DB7 B7 7E lda [pathp],y |
||
823 | 3371 F91DB9 C9 2E cmp #'.' ; if name start with '.'... |
||
824 | 3372 F91DBB D0 15 bne ?20 ; ...then we parse it differently |
||
825 | 3373 F91DBD 85 53 sta fcbs ; move '.' to fcb |
||
826 | 3374 F91DBF C8 iny |
||
827 | 3375 F91DC0 B7 7E lda [pathp],y |
||
828 | 3376 F91DC2 C8 iny |
||
829 | 3377 F91DC3 C9 2E cmp #'.' ; if name start with '..'... |
||
830 | 3378 F91DC5 D0 05 bne ?15 ; ...then we parse it differently |
||
831 | 3379 F91DC7 85 54 sta fcbs+1 ; move '..' to fcb |
||
832 | 3380 F91DC9 B7 7E ?10: lda [pathp],y |
||
833 | 3381 F91DCB C8 iny |
||
834 | 3382 F91DCC C9 20 ?15: cmp #' ' ; skip all subsequent blanks |
||
835 | 3383 F91DCE F0 F9 beq ?10 |
||
836 | 3384 F91DD0 80 2F bra ?50 ; check delimiter |
||
837 | 3385 F91DD2 20 51 1F ?20: jsr chkdlm ; filename begins with a legal char? |
||
838 | 3386 F91DD5 F0 29 beq ?40 ; no, then only allow '/' or '\' |
||
839 | 3387 F91DD7 64 6F stz wild ; yes, then parse it normally |
||
840 | 3388 F91DD9 A2 00 ldx #0 ; fcb name field ptr |
||
841 | 3389 F91DDB A9 08 lda #8 ; length of name field |
||
842 | 3390 F91DDD 20 2F 1E jsr prsone ; parse just name field |
||
843 | 3391 F91DE0 B0 4C bcs ?90 ; error |
||
844 | 3392 F91DE2 A6 6F ldx wild |
||
845 | 3393 F91DE4 85 7C sta haswld ; save name wildcard flag |
||
846 | 3394 F91DE6 C9 2E ?30: cmp #'.' |
||
847 | 3395 F91DE8 D0 17 bne ?50 ; skip if not extension |
||
848 | 3396 F91DEA 64 6F stz wild |
||
849 | 3397 F91DEC A2 08 ldx #8 ; fcb extension field ptr |
||
850 | 3398 F91DEE A9 03 lda #3 ; length of extension field |
||
851 | 3399 F91DF0 20 2F 1E jsr prsone ; parse just extension field |
||
852 | 3400 F91DF3 B0 39 bcs ?90 ; error |
||
853 | 3401 F91DF5 85 6E sta tmpx |
||
854 | 3402 F91DF7 A5 6F lda wild ; combine wild cards flag |
||
855 | 3403 F91DF9 05 7C ora haswld |
||
856 | 3404 F91DFB 85 7C sta haswld |
||
857 | 3405 F91DFD A5 6E lda tmpx |
||
858 | 3406 F91DFF 88 dey |
||
859 | 3407 F91E00 C8 ?40: iny ; point to next character |
||
860 | 3408 F91E01 AA ?50: tax ; last parsed delimiter |
||
861 | 3409 F91E02 F0 2A beq ?90 ; end of path: ok |
||
862 | 3410 F91E04 20 7B 1F jsr chkslh ; if delimiter is not '\' nor '/'... |
||
863 | 3411 F91E07 D0 25 bne ?90 ; ...error (CF=1) |
||
864 | 3412 F91E09 B7 7E ?60: lda [pathp],y ; get next character |
||
865 | 3413 F91E0B C8 iny |
||
866 | 3414 F91E0C 20 51 1F jsr chkdlm ; here we expect a normal legal character |
||
867 | 3415 F91E0F D0 1C bne ?80 ; exit if we've got one |
||
868 | 3416 F91E11 20 7B 1F jsr chkslh ; swallow '\'s at this point and leave... |
||
869 | Tue Jul 17 11:00:20 2018 Page 15 |
||
870 | |||
871 | |||
872 | |||
873 | |||
874 | 3417 F91E14 F0 F3 beq ?60 ; ...other delimiters for next time |
||
875 | 3418 F91E16 C9 2E cmp #'.' ; trailing '\.' ? |
||
876 | 3419 F91E18 D0 10 bne ?75 ; no |
||
877 | 3420 F91E1A BB tyx ; remember position of '.' |
||
878 | 3421 F91E1B B7 7E ?70: lda [pathp],y ; get next character |
||
879 | 3422 F91E1D F0 0F beq ?90 ; stop at ending of string |
||
880 | 3423 F91E1F C8 iny |
||
881 | 3424 F91E20 C9 20 cmp #' ' ; now discard trailing spaces |
||
882 | 3425 F91E22 F0 F7 beq ?70 ; keep going until we lose all spaces |
||
883 | 3426 F91E24 20 7B 1F jsr chkslh ; if it's a '\' or '/' try again |
||
884 | 3427 F91E27 F0 E0 beq ?60 |
||
885 | 3428 F91E29 9B txy ; retract to the '.' |
||
886 | 3429 F91E2A A9 2F ?75: lda #'/' ; return '/' as the delimiter... |
||
887 | 3430 F91E2C 18 clc ; ...and exit with no problems |
||
888 | 3431 F91E2D 88 ?80: dey ; retract a byte |
||
889 | 3432 F91E2E 60 ?90: rts |
||
890 | 3433 |
||
891 | 3434 ; parse a single name or extension |
||
892 | 3435 ; |
||
893 | 3436 ; entry: A = field size |
||
894 | 3437 ; X = local fcb field pointer |
||
895 | 3438 ; Y = pointer to current name in path |
||
896 | 3439 ; pathp = long pointer to path |
||
897 | 3440 ; |
||
898 | 3441 ; exit: A = last char parsed |
||
899 | 3442 ; Y = pointer to next name in path |
||
900 | 3443 ; CF = 1 if parsing error |
||
901 | 3444 ; |
||
902 | 3445 ; use: A,X,Y |
||
903 | 3446 ; |
||
904 | 3447 ;------ |
||
905 | 3448 F91E2F prsone: |
||
906 | 3449 ;------ |
||
907 | 3450 F91E2F 85 70 sta fsiz ; char's counter |
||
908 | 3451 F91E31 86 71 stx fptr ; field start |
||
909 | 3452 F91E33 B7 7E ?10: lda [pathp],y ; get next path char |
||
910 | 3453 F91E35 C8 iny |
||
911 | 3454 F91E36 20 51 1F jsr chkdlm |
||
912 | 3455 F91E39 F0 1E beq ?20 ; if it is a delimiter then return |
||
913 | 3456 F91E3B C9 2A cmp #'*' |
||
914 | 3457 F91E3D F0 1B beq ?25 ; special case if star |
||
915 | 3458 F91E3F C9 3F cmp #'?' ; is a wildcard? |
||
916 | 3459 F91E41 D0 06 bne ?15 ; no |
||
917 | 3460 F91E43 A9 80 lda #$80 |
||
918 | 3461 F91E45 04 6F tsb wild ; set wildcard flag |
||
919 | 3462 F91E47 A9 3F lda #'?' |
||
920 | 3463 F91E49 95 53 ?15: sta fcbs,x ; move char to fcb field |
||
921 | 3464 F91E4B E8 inx |
||
922 | 3465 F91E4C C6 70 dec fsiz |
||
923 | 3466 F91E4E D0 E3 bne ?10 ; loop: next path char |
||
924 | 3467 F91E50 B7 7E lda [pathp],y ; get next path char |
||
925 | 3468 F91E52 C8 iny |
||
926 | 3469 F91E53 20 51 1F jsr chkdlm ; here expected a delimiter |
||
927 | 3470 F91E56 F0 01 beq ?20 |
||
928 | 3471 F91E58 38 sec ; error flag |
||
929 | 3472 F91E59 60 ?20: rts |
||
930 | 3473 F91E5A 24 6F ?25: bit wild ; already parsed a star? |
||
931 | Tue Jul 17 11:00:20 2018 Page 16 |
||
932 | |||
933 | |||
934 | |||
935 | |||
936 | 3474 F91E5C 70 1D bvs ?38 ; yes, so error |
||
937 | 3475 F91E5E A9 C0 lda #$C0 |
||
938 | 3476 F91E60 04 6F tsb wild ; set wildcard+star flag |
||
939 | 3477 F91E62 E4 71 cpx fptr ; star is first char of the field? |
||
940 | 3478 F91E64 F0 17 beq ?40 ; yes |
||
941 | 3479 F91E66 A9 3F ?28: lda #'?' ; if not, fill rest of field with '?' |
||
942 | 3480 F91E68 95 53 ?30: sta fcbs,x |
||
943 | 3481 F91E6A E8 inx |
||
944 | 3482 F91E6B C6 70 dec fsiz |
||
945 | 3483 F91E6D D0 F9 bne ?30 |
||
946 | 3484 F91E6F B7 7E ?35: lda [pathp],y ; get next path char |
||
947 | 3485 F91E71 C8 iny |
||
948 | 3486 F91E72 20 51 1F jsr chkdlm ; here expected a delimiter... |
||
949 | 3487 F91E75 F0 E2 beq ?20 |
||
950 | 3488 F91E77 C9 2A cmp #'*' ; ...or just star... |
||
951 | 3489 F91E79 F0 F4 beq ?35 |
||
952 | 3490 F91E7B 38 ?38: sec ; ...else error |
||
953 | 3491 F91E7C 60 rts |
||
954 | 3492 F91E7D B7 7E ?40: lda [pathp],y ; get next path char |
||
955 | 3493 F91E7F C8 iny |
||
956 | 3494 F91E80 C9 2A cmp #'*' ; skips all subsequent star's |
||
957 | 3495 F91E82 F0 F9 beq ?40 |
||
958 | 3496 F91E84 20 51 1F jsr chkdlm ; is a delimiter? |
||
959 | 3497 F91E87 D0 03 bne ?45 ; no |
||
960 | 3498 F91E89 88 dey ; forgot last char |
||
961 | 3499 F91E8A 80 DA bra ?28 ; fill rest of field with '?' |
||
962 | 3500 F91E8C A9 2A ?45: lda #'*' ; first char of field is a star |
||
963 | 3501 F91E8E 95 53 sta fcbs,x |
||
964 | 3502 F91E90 E8 inx |
||
965 | 3503 F91E91 C6 70 dec fsiz |
||
966 | 3504 F91E93 88 dey ; forgot last char |
||
967 | 3505 F91E94 80 9D bra ?10 ; continue normal parsing |
||
968 | 3506 |
||
969 | 3507 ; parse a single label name (volume name) |
||
970 | 3508 ; |
||
971 | 3509 ; entry: pathp = long pointer to label name |
||
972 | 3510 ; |
||
973 | 3511 ; exit: CF = 1 if parsing error |
||
974 | 3512 ; ZF = 1 if null string |
||
975 | 3513 ; |
||
976 | 3514 ; use: A,X,Y |
||
977 | 3515 ; |
||
978 | 3516 ;------ |
||
979 | 3517 F91E96 prslbl: |
||
980 | 3518 ;------ |
||
981 | 3519 F91E96 20 87 1F jsr clrfcb ; set up a clean fcb |
||
982 | 3520 F91E99 A9 0B lda #11 |
||
983 | 3521 F91E9B 85 70 sta fsiz ; char's counter |
||
984 | 3522 F91E9D A2 00 ldx #0 ; field start |
||
985 | 3523 F91E9F 9B txy |
||
986 | 3524 F91EA0 18 clc |
||
987 | 3525 F91EA1 A7 7E lda [pathp] ; get first char |
||
988 | 3526 F91EA3 F0 2A beq ?30 ; null string |
||
989 | 3527 F91EA5 C9 20 cmp #' ' ; reject if first char is blank |
||
990 | 3528 F91EA7 F0 12 beq ?15 |
||
991 | 3529 F91EA9 80 02 bra ?12 |
||
992 | 3530 F91EAB B7 7E ?10: lda [pathp],y ; get next name char |
||
993 | Tue Jul 17 11:00:20 2018 Page 17 |
||
994 | |||
995 | |||
996 | |||
997 | |||
998 | 3531 F91EAD C8 ?12: iny |
||
999 | 3532 F91EAE 20 51 1F jsr chkdlm |
||
1000 | 3533 F91EB1 D0 0A bne ?20 ; is not a delimiter |
||
1001 | 3534 F91EB3 C9 20 cmp #' ' ; intermediate blanks are ok |
||
1002 | 3535 F91EB5 F0 0E beq ?25 |
||
1003 | 3536 F91EB7 C9 00 cmp #0 ; end of string? |
||
1004 | 3537 F91EB9 F0 11 beq ?28 ; yes |
||
1005 | 3538 F91EBB 38 ?15: sec ; reject delimiter |
||
1006 | 3539 F91EBC 60 rts |
||
1007 | 3540 F91EBD C9 2A ?20: cmp #'*' |
||
1008 | 3541 F91EBF F0 FA beq ?15 ; reject wildcard |
||
1009 | 3542 F91EC1 C9 3F cmp #'?' |
||
1010 | 3543 F91EC3 F0 F6 beq ?15 |
||
1011 | 3544 F91EC5 95 53 ?25: sta fcbs,x ; move char to fcb field |
||
1012 | 3545 F91EC7 E8 inx |
||
1013 | 3546 F91EC8 C6 70 dec fsiz |
||
1014 | 3547 F91ECA D0 DF bne ?10 ; loop: next path char |
||
1015 | 3548 F91ECC C2 03 ?28: rep #PZFLAG.OR.PCFLAG |
||
1016 | 3549 F91ECE 60 rts ; exit with ZF=0,CF=0 |
||
1017 | 3550 F91ECF E2 02 ?30: sep #PZFLAG ; null string: exit with ZF=1,CF=0 |
||
1018 | 3551 F91ED1 60 rts |
||
1019 | 3552 |
||
1020 | 3553 ; go down (or up) one level in directory |
||
1021 | 3554 ; |
||
1022 | 3555 ; entry: fcbs = local name |
||
1023 | 3556 ; fcbp = long pointer to directory entry |
||
1024 | 3557 ; bplvl = current path level |
||
1025 | 3558 ; |
||
1026 | 3559 ; exit: dircls = cluster of selected directory |
||
1027 | 3560 ; bplvl = path level |
||
1028 | 3561 ; CF = 1 if failure |
||
1029 | 3562 ; |
||
1030 | 3563 ; use: C,X |
||
1031 | 3564 ; |
||
1032 | 3565 ;------ |
||
1033 | 3566 F91ED2 setdir: |
||
1034 | 3567 ;------ |
||
1035 | 3568 F91ED2 84 7D sty strix ; save Y |
||
1036 | 3569 F91ED4 A0 0B ldy #11 |
||
1037 | 3570 F91ED6 B7 5E lda [fcbp],y ; entry attribute |
||
1038 | 3571 F91ED8 89 10 bit #DA_DIR ; check if directory |
||
1039 | 3572 F91EDA 38 sec |
||
1040 | 3573 F91EDB F0 71 beq ?30 ; fail if this is a file |
||
1041 | 3574 F91EDD A9 01 lda #WKB |
||
1042 | 3575 F91EDF 8B phb ; save current DBR |
||
1043 | 3576 F91EE0 48 pha ; set DBR bank |
||
1044 | 3577 F91EE1 AB plb |
||
1045 | 3578 F91EE2 ACC16 |
||
1046 | 3579 F91EE2 C2 20 rep #PMFLAG |
||
1047 | 3580 .LONGA on |
||
1048 | 3581 .MNLIST |
||
1049 | 3582 F91EE4 A0 1A ldy #26 |
||
1050 | 3583 F91EE6 B7 5E lda [fcbp],y ; first cluster of directory |
||
1051 | 3584 F91EE8 85 68 sta wtmp |
||
1052 | 3585 F91EEA A6 16 ldx bplvl ; current path level |
||
1053 | 3586 F91EEC A5 53 lda fcbs |
||
1054 | 3587 F91EEE C9 2E 2E cmp #'..' ; watch out if going up a level |
||
1055 | Tue Jul 17 11:00:20 2018 Page 18 |
||
1056 | |||
1057 | |||
1058 | |||
1059 | |||
1060 | 3588 F91EF1 F0 3C beq ?10 ; we go up one level |
||
1061 | 3589 F91EF3 8A txa |
||
1062 | 3590 F91EF4 E8 inx ; increment level |
||
1063 | 3591 F91EF5 E0 21 cpx #HPLMAX+1 ; level overflow? |
||
1064 | 3592 F91EF7 B0 52 bcs ?25 ; yes, return failure |
||
1065 | 3593 F91EF9 86 16 stx bplvl |
||
1066 | 3594 F91EFB A0 00 ldy #0 ; fcb name pointer |
||
1067 | 3595 F91EFD CPU16 |
||
1068 | 3596 F91EFD C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
1069 | 3597 .LONGA on |
||
1070 | 3598 .LONGI on |
||
1071 | 3599 .MNLIST |
||
1072 | 3600 F91EFF 0A asl a ; mult. x 16 to get index |
||
1073 | 3601 F91F00 0A asl a |
||
1074 | 3602 F91F01 0A asl a |
||
1075 | 3603 F91F02 0A asl a ; here always CF=0 |
||
1076 | 3604 F91F03 69 00 A6 adc #cbpl |
||
1077 | 3605 F91F06 AA tax ; point to HPL |
||
1078 | 3606 F91F07 ACC08 |
||
1079 | 3607 F91F07 E2 20 sep #PMFLAG |
||
1080 | 3608 .LONGA off |
||
1081 | 3609 .MNLIST |
||
1082 | 3610 F91F09 9E 04 00 stz !hpl_fcb,x |
||
1083 | 3611 F91F0C B7 5E ?05: lda [fcbp],y ; move fcb name |
||
1084 | 3612 F91F0E 9D 04 00 sta !hpl_fcb,x |
||
1085 | 3613 F91F11 E8 inx |
||
1086 | 3614 F91F12 C8 iny |
||
1087 | 3615 F91F13 C0 0B 00 cpy #11 |
||
1088 | 3616 F91F16 90 F4 bcc ?05 |
||
1089 | 3617 F91F18 9E 04 00 stz !hpl_fcb,x ; last unused byte |
||
1090 | 3618 F91F1B CPU16CLC |
||
1091 | 3619 F91F1B C2 31 rep #(PMFLAG.OR.PXFLAG.OR.PCFLAG) |
||
1092 | 3620 .LONGA on |
||
1093 | 3621 .LONGI on |
||
1094 | 3622 .MNLIST |
||
1095 | 3623 F91F1D A5 46 lda dircls ; set parent cluster |
||
1096 | 3624 F91F1F 9D 00 00 sta !hpl_cls,x |
||
1097 | 3625 F91F22 A5 68 lda wtmp |
||
1098 | 3626 F91F24 85 46 sta dircls ; set current directory cluster |
||
1099 | 3627 F91F26 A5 48 lda dcnt |
||
1100 | 3628 F91F28 9D 02 00 sta !hpl_ix,x ; set index entry on parent cluster |
||
1101 | 3629 F91F2B INDEX08 |
||
1102 | 3630 F91F2B E2 10 sep #PXFLAG |
||
1103 | 3631 .LONGI off |
||
1104 | 3632 .MNLIST |
||
1105 | 3633 F91F2D 80 1C bra ?25 ; done (CF=0) |
||
1106 | 3634 F91F2F 38 ?10: sec |
||
1107 | 3635 F91F30 CA dex ; decrement level |
||
1108 | 3636 F91F31 30 18 bmi ?25 ; already at level 0 (root) so failure |
||
1109 | 3637 F91F33 86 16 stx bplvl |
||
1110 | 3638 F91F35 CPU16 |
||
1111 | 3639 F91F35 C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
1112 | 3640 .LONGA on |
||
1113 | 3641 .LONGI on |
||
1114 | 3642 .MNLIST |
||
1115 | 3643 F91F37 8A txa |
||
1116 | 3644 F91F38 0A asl a ; mult. x 16 to get index |
||
1117 | Tue Jul 17 11:00:20 2018 Page 19 |
||
1118 | |||
1119 | |||
1120 | |||
1121 | |||
1122 | 3645 F91F39 0A asl a |
||
1123 | 3646 F91F3A 0A asl a |
||
1124 | 3647 F91F3B 0A asl a ; here always CF=0 |
||
1125 | 3648 F91F3C 69 00 A6 adc #cbpl |
||
1126 | 3649 F91F3F AA tax ; point to HPL of current dir. |
||
1127 | 3650 F91F40 A5 68 lda wtmp ; parent cluster |
||
1128 | 3651 F91F42 DD 00 00 cmp !hpl_cls,x ; will match... |
||
1129 | 3652 F91F45 38 sec |
||
1130 | 3653 F91F46 D0 03 bne ?25 ; ...otherwise return failure |
||
1131 | 3654 F91F48 85 46 sta dircls ; set cluster of selected directory |
||
1132 | 3655 F91F4A 18 clc |
||
1133 | 3656 F91F4B ?25: CPU08 |
||
1134 | 3657 F91F4B E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
1135 | 3658 .LONGA off |
||
1136 | 3659 .LONGI off |
||
1137 | 3660 .MNLIST |
||
1138 | 3661 F91F4D AB plb ; restore DBR |
||
1139 | 3662 F91F4E A4 7D ?30: ldy strix |
||
1140 | 3663 F91F50 60 rts |
||
1141 | 3664 |
||
1142 | 3665 ; check for a path name delimiter |
||
1143 | 3666 ; |
||
1144 | 3667 ; entry: A = path character |
||
1145 | 3668 ; |
||
1146 | 3669 ; exit: A = upper case path character |
||
1147 | 3670 ; CF = 0 |
||
1148 | 3671 ; ZF = 1 if character is a delimiter |
||
1149 | 3672 ; ZF = 0 if character is legal in file name |
||
1150 | 3673 ; |
||
1151 | 3674 ; use: A |
||
1152 | 3675 ; |
||
1153 | 3676 ;------ |
||
1154 | 3677 F91F51 chkdlm: |
||
1155 | 3678 ;------ |
||
1156 | 3679 F91F51 C9 7F cmp #$7F |
||
1157 | 3680 F91F53 B0 22 bcs ?40 ; discard if ascii code > 126 (ZF=1) |
||
1158 | 3681 F91F55 C9 21 cmp #' '+1 |
||
1159 | 3682 F91F57 90 1E bcc ?40 ; discard blank & no-printable char (ZF=1) |
||
1160 | 3683 F91F59 86 6E stx tmpx ; save X |
||
1161 | 3684 F91F5B A2 0D ldx #DLMSTR-1 |
||
1162 | 3685 F91F5D DF 6B 23 F9 ?10: cmp >dlmstr,x ; match A against list |
||
1163 | 3686 F91F61 F0 16 beq ?50 ; ZF=1 |
||
1164 | 3687 F91F63 CA dex |
||
1165 | 3688 F91F64 10 F7 bpl ?10 |
||
1166 | 3689 F91F66 A6 6E ldx tmpx ; restore X |
||
1167 | 3690 F91F68 C9 61 cmp #'a' ; make upper case |
||
1168 | 3691 F91F6A 90 06 bcc ?20 |
||
1169 | 3692 F91F6C C9 7B cmp #'z'+1 |
||
1170 | 3693 F91F6E B0 02 bcs ?20 |
||
1171 | 3694 F91F70 29 DF and #$DF |
||
1172 | 3695 F91F72 C2 03 ?20: rep #PZFLAG.OR.PCFLAG ; ZF=0, CF=0 (no delim char) |
||
1173 | 3696 F91F74 60 rts |
||
1174 | 3697 F91F75 A6 6E ?30: ldx tmpx ; restore X |
||
1175 | 3698 F91F77 E2 02 ?40: sep #PZFLAG ; ZF=1 (delim char match) |
||
1176 | 3699 F91F79 18 ?50: clc ; always return CF=0 |
||
1177 | 3700 F91F7A 60 rts |
||
1178 | 3701 |
||
1179 | Tue Jul 17 11:00:20 2018 Page 20 |
||
1180 | |||
1181 | |||
1182 | |||
1183 | |||
1184 | 3702 ; check for legal delimiter: '/' or '\' |
||
1185 | 3703 ; |
||
1186 | 3704 ; entry: A = delimiter |
||
1187 | 3705 ; |
||
1188 | 3706 ; exit: A = delimiter |
||
1189 | 3707 ; ZF = 1, CF = 0 if legal delimiter '/' or '\' |
||
1190 | 3708 ; ZF = 0, CF = 1 if not |
||
1191 | 3709 ; |
||
1192 | 3710 ; use: A |
||
1193 | 3711 ; |
||
1194 | 3712 ;------ |
||
1195 | 3713 F91F7B chkslh: |
||
1196 | 3714 ;------ |
||
1197 | 3715 F91F7B C9 2F cmp #'/' |
||
1198 | 3716 F91F7D F0 06 beq ?10 |
||
1199 | 3717 F91F7F C9 5C cmp #'\' |
||
1200 | 3718 F91F81 F0 02 beq ?10 |
||
1201 | 3719 F91F83 38 sec ; error: ZF=0, CF=1 |
||
1202 | 3720 F91F84 60 rts |
||
1203 | 3721 F91F85 18 ?10: clc ; ok: ZF=1, CF=0 |
||
1204 | 3722 F91F86 60 rts |
||
1205 | 3723 F91F87 |
||
1206 | 3724 ; sets up a clean fcb for later use |
||
1207 | 3725 ; |
||
1208 | 3726 ; entry: nothing |
||
1209 | 3727 ; |
||
1210 | 3728 ; exit: blank fcb |
||
1211 | 3729 ; X = 0 |
||
1212 | 3730 ; |
||
1213 | 3731 ; use: A,X |
||
1214 | 3732 ; |
||
1215 | 3733 ;------ |
||
1216 | 3734 F91F87 clrfcb: |
||
1217 | 3735 ;------ |
||
1218 | 3736 F91F87 A2 0A ldx #10 |
||
1219 | 3737 F91F89 A9 20 lda #' ' |
||
1220 | 3738 F91F8B 95 53 ?10: sta fcbs,x |
||
1221 | 3739 F91F8D CA dex |
||
1222 | 3740 F91F8E 10 FB bpl ?10 |
||
1223 | 3741 F91F90 E8 inx |
||
1224 | 3742 F91F91 60 rts |
||
1225 | 3743 |
||
1226 | 3744 ; sets up a fake 'root' fcb for later use |
||
1227 | 3745 ; |
||
1228 | 3746 ; entry: nothing |
||
1229 | 3747 ; |
||
1230 | 3748 ; exit: fake '.' fcb |
||
1231 | 3749 ; X = 0 |
||
1232 | 3750 ; |
||
1233 | 3751 ; use: A,X |
||
1234 | 3752 ; |
||
1235 | 3753 ;------- |
||
1236 | 3754 F91F92 fakefcb: |
||
1237 | 3755 ;------- |
||
1238 | 3756 F91F92 A9 2E lda #'.' ; start name with '.' |
||
1239 | 3757 F91F94 85 53 sta fcbs |
||
1240 | 3758 F91F96 A2 0A ldx #10 ; fill with blanks |
||
1241 | Tue Jul 17 11:00:20 2018 Page 21 |
||
1242 | |||
1243 | |||
1244 | |||
1245 | |||
1246 | 3759 F91F98 A9 20 lda #' ' |
||
1247 | 3760 F91F9A 95 53 ?10: sta fcbs,x |
||
1248 | 3761 F91F9C CA dex |
||
1249 | 3762 F91F9D D0 FB bne ?10 |
||
1250 | 3763 F91F9F 60 rts |
||
1251 | 3764 |
||
1252 | 3765 ; move current working dir. list to build path list |
||
1253 | 3766 ; |
||
1254 | 3767 ; entry: ldtcdlp = pointer to cur. dir. list |
||
1255 | 3768 ; ldtcdcls = starting cluster of cur. dir. |
||
1256 | 3769 ; ldtcdlvl = cur. dir. level |
||
1257 | 3770 ; |
||
1258 | 3771 ; exit: dircls = starting cluster of cur. dir. |
||
1259 | 3772 ; bplvl = build path level |
||
1260 | 3773 ; |
||
1261 | 3774 ; use: C,X,Y |
||
1262 | 3775 ; |
||
1263 | 3776 ;------ |
||
1264 | 3777 F91FA0 mvtobp: |
||
1265 | 3778 ;------ |
||
1266 | 3779 F91FA0 A6 52 ldx curdrv |
||
1267 | 3780 F91FA2 BC D2 40 ldy !P0LDT+ldtp,x ; LDT pointer |
||
1268 | 3781 F91FA5 ACC16 |
||
1269 | 3782 F91FA5 C2 20 rep #PMFLAG |
||
1270 | 3783 .LONGA on |
||
1271 | 3784 .MNLIST |
||
1272 | 3785 F91FA7 BE 20 40 ldx !P0LDT+ldt_cdlvl,y |
||
1273 | 3786 F91FAA 86 16 stx bplvl |
||
1274 | 3787 F91FAC AD 1E 40 lda !P0LDT+ldt_cdcls |
||
1275 | 3788 F91FAF 85 46 sta dircls ; starting directory to build path |
||
1276 | 3789 F91FB1 F0 13 beq ?10 ; done: ii is the root dir. |
||
1277 | 3790 F91FB3 INDEX16 |
||
1278 | 3791 F91FB3 C2 10 rep #PXFLAG |
||
1279 | 3792 .LONGI on |
||
1280 | 3793 .MNLIST |
||
1281 | 3794 F91FB5 8A txa ; count of list struct's |
||
1282 | 3795 F91FB6 0A asl a ; mult. x 16 (size of HPL struct's) |
||
1283 | 3796 F91FB7 0A asl a |
||
1284 | 3797 F91FB8 0A asl a |
||
1285 | 3798 F91FB9 0A asl a |
||
1286 | 3799 F91FBA 3A dec a ; count of bytes to move - 1 |
||
1287 | 3800 F91FBB BE 1C 40 ldx !P0LDT+ldt_cdlp,y |
||
1288 | 3801 ;;ldx ldtcdlp ; start source address |
||
1289 | 3802 F91FBE A0 00 A6 ldy #cbpl ; start dest address |
||
1290 | 3803 F91FC1 8B phb ; save DBR |
||
1291 | 3804 F91FC2 54 01 01 mvn #WKB,#WKB ; move |
||
1292 | 3805 F91FC5 AB plb |
||
1293 | 3806 F91FC6 ?10: CPU08 |
||
1294 | 3807 F91FC6 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
1295 | 3808 .LONGA off |
||
1296 | 3809 .LONGI off |
||
1297 | 3810 .MNLIST |
||
1298 | 3811 F91FC8 60 rts |
||
1299 | 3812 |
||
1300 | 3813 F91FC9 mvpath: |
||
1301 | 3814 F91FC9 ACC16 |
||
1302 | 3815 F91FC9 C2 20 rep #PMFLAG |
||
1303 | Tue Jul 17 11:00:20 2018 Page 22 |
||
1304 | |||
1305 | |||
1306 | |||
1307 | |||
1308 | 3816 .LONGA on |
||
1309 | 3817 .MNLIST |
||
1310 | 3818 F91FCB A9 00 A6 lda #cbpl ; offset of build path |
||
1311 | 3819 F91FCE A4 16 ldy bplvl |
||
1312 | 3820 F91FD0 90 0B bcc ?10 |
||
1313 | 3821 F91FD2 BC D2 40 ldy !P0LDT+ldtp,x ; LDT pointer |
||
1314 | 3822 F91FD5 B9 1C 40 lda !P0LDT+ldt_cdlp,y |
||
1315 | 3823 F91FD8 BE 20 40 ldx !P0LDT+ldt_cdlvl,y |
||
1316 | 3824 F91FDB 9B txy |
||
1317 | 3825 F91FDC 18 clc |
||
1318 | 3826 F91FDD 69 04 00 ?10: adc #hpl_fcb |
||
1319 | 3827 F91FE0 85 6A sta tmpp |
||
1320 | 3828 F91FE2 ACC08 |
||
1321 | 3829 F91FE2 E2 20 sep #PMFLAG |
||
1322 | 3830 .LONGA off |
||
1323 | 3831 .MNLIST |
||
1324 | 3832 F91FE4 A9 01 lda #.SEG.cbpl |
||
1325 | 3833 F91FE6 85 6C sta tmpp+2 ; set HPL pointer |
||
1326 | 3834 F91FE8 84 6E sty tmpx ; subdir level |
||
1327 | 3835 F91FEA A2 00 ldx #0 |
||
1328 | 3836 F91FEC 98 tya |
||
1329 | 3837 F91FED F0 1C beq ?30 ; is root |
||
1330 | 3838 F91FEF 20 10 20 ?20: jsr unparse |
||
1331 | 3839 F91FF2 C6 6E dec tmpx |
||
1332 | 3840 F91FF4 F0 14 beq ?25 |
||
1333 | 3841 F91FF6 CA dex |
||
1334 | 3842 F91FF7 A9 2F lda #'/' |
||
1335 | 3843 F91FF9 9D 04 42 sta !P0OS+bpath,x |
||
1336 | 3844 F91FFC E8 inx |
||
1337 | 3845 F91FFD ACC16 |
||
1338 | 3846 F91FFD C2 20 rep #PMFLAG |
||
1339 | 3847 .LONGA on |
||
1340 | 3848 .MNLIST |
||
1341 | 3849 F91FFF A5 6A lda tmpp |
||
1342 | 3850 F92001 69 10 00 adc #HPLSIZE |
||
1343 | 3851 F92004 85 6A sta tmpp |
||
1344 | 3852 F92006 ACC08 |
||
1345 | 3853 F92006 E2 20 sep #PMFLAG |
||
1346 | 3854 .LONGA off |
||
1347 | 3855 .MNLIST |
||
1348 | 3856 F92008 80 E5 bra ?20 |
||
1349 | 3857 F9200A CA ?25: dex |
||
1350 | 3858 F9200B 9E 04 42 ?30: stz !P0OS+bpath,x |
||
1351 | 3859 F9200E E8 inx |
||
1352 | 3860 F9200F 60 rts |
||
1353 | 3861 F92010 |
||
1354 | 3862 ; unparse fcb name into canonical asciiz string |
||
1355 | 3863 F92010 unparse: |
||
1356 | 3864 F92010 A0 00 ldy #0 ; unparse name |
||
1357 | 3865 F92012 A9 08 lda #8 ; string limit |
||
1358 | 3866 F92014 20 2C 20 jsr ?20 ; unparse field |
||
1359 | 3867 F92017 B7 6A lda [tmpp],y |
||
1360 | 3868 F92019 C9 20 cmp #' ' |
||
1361 | 3869 F9201B F0 0B beq ?10 ; no extension |
||
1362 | 3870 F9201D A9 2E lda #'.' |
||
1363 | 3871 F9201F 9D 04 42 sta !P0OS+bpath,x |
||
1364 | 3872 F92022 E8 inx |
||
1365 | Tue Jul 17 11:00:20 2018 Page 23 |
||
1366 | |||
1367 | |||
1368 | |||
1369 | |||
1370 | 3873 F92023 A9 0B lda #11 ; string limit |
||
1371 | 3874 F92025 20 2C 20 jsr ?20 ; unparse extension |
||
1372 | 3875 F92028 9E 04 42 ?10: stz !P0OS+bpath,x |
||
1373 | 3876 F9202B 60 rts |
||
1374 | 3877 F9202C 85 70 ?20: sta fsiz |
||
1375 | 3878 F9202E B7 6A ?25: lda [tmpp],y |
||
1376 | 3879 F92030 C9 20 cmp #' ' |
||
1377 | 3880 F92032 F0 04 beq ?30 |
||
1378 | 3881 F92034 9D 04 42 sta !P0OS+bpath,x |
||
1379 | 3882 F92037 E8 inx |
||
1380 | 3883 F92038 C8 ?30: iny |
||
1381 | 3884 F92039 C4 70 cpy fsiz |
||
1382 | 3885 F9203B 90 F1 bcc ?25 |
||
1383 | 3886 F9203D 60 rts |
||
1384 | 3887 |
||
1385 | 3888 ; get drive number from path string |
||
1386 | 3889 ; |
||
1387 | 3890 ; entry: pathp = long pointer to path string |
||
1388 | 3891 ; |
||
1389 | 3892 ; exit: A = drive number |
||
1390 | 3893 ; strix = current path string index |
||
1391 | 3894 ; CF = 1 if illegal drive name in path string |
||
1392 | 3895 ; |
||
1393 | 3896 ; use: A,X |
||
1394 | 3897 ; |
||
1395 | 3898 ;------- |
||
1396 | 3899 F9203E getpdrv: |
||
1397 | 3900 ;------- |
||
1398 | 3901 F9203E 64 7D stz strix ; clear current path string index |
||
1399 | 3902 F92040 A7 7E lda [pathp] ; check if string is empty... |
||
1400 | 3903 F92042 F0 23 beq ?30 ; ...which isn't O.K. at all |
||
1401 | 3904 F92044 AA tax |
||
1402 | 3905 F92045 A0 01 ldy #1 |
||
1403 | 3906 F92047 B7 7E lda [pathp],y ; if the second char is ':'... |
||
1404 | 3907 F92049 F0 04 beq ?10 ; ...then drive is in pathname |
||
1405 | 3908 F9204B A5 17 lda defdrv ; take the default (selected) drive |
||
1406 | 3909 F9204D 80 16 bra ?25 ; return default drive |
||
1407 | 3910 F9204F 8A ?10: txa ; grab the drive designator |
||
1408 | 3911 F92050 C9 61 cmp #'a' ; make sure it is upper case |
||
1409 | 3912 F92052 90 06 bcc ?20 |
||
1410 | 3913 F92054 C9 7B cmp #'z'+1 |
||
1411 | 3914 F92056 B0 10 bcs ?35 ; invalid drive name |
||
1412 | 3915 F92058 29 DF and #$DF |
||
1413 | 3916 F9205A E9 40 ?20: sbc #'A'-1 ; note: here always CF=0 |
||
1414 | 3917 F9205C 90 09 bcc ?30 ; invalid drive number |
||
1415 | 3918 F9205E C9 04 cmp #MAXDRV |
||
1416 | 3919 F92060 B0 06 bcs ?35 ; invalid drive number |
||
1417 | 3920 F92062 C8 iny ; bump path string pointer... |
||
1418 | 3921 F92063 84 7D sty strix ; ...past ':' |
||
1419 | 3922 F92065 18 ?25: clc |
||
1420 | 3923 F92066 60 rts |
||
1421 | 3924 F92067 38 ?30: sec ; error flag |
||
1422 | 3925 F92068 60 ?35: rts |
||
1423 | 3926 |
||
1424 | 3927 ; reject devices names -- never return to the caller if error |
||
1425 | 3928 F92069 nodev: |
||
1426 | 3929 F92069 20 A0 20 jsr chkdev ; is this a device ? |
||
1427 | Tue Jul 17 11:00:20 2018 Page 24 |
||
1428 | |||
1429 | |||
1430 | |||
1431 | |||
1432 | 3930 F9206C B0 0C bcs _eaccess ; yes |
||
1433 | 3931 F9206E 60 rts |
||
1434 | 3932 F9206F |
||
1435 | 3933 ; reject if is directory or volume label |
||
1436 | 3934 ; never return to the caller if error |
||
1437 | 3935 ; A=fcb attribute |
||
1438 | 3936 F9206F nodirvol: |
||
1439 | 3937 F9206F 89 18 bit #DA_DIR+DA_VOLUME |
||
1440 | 3938 F92071 D0 07 bne _eaccess |
||
1441 | 3939 F92073 60 rts |
||
1442 | 3940 |
||
1443 | 3941 ; reject "." and ".." names -- never return to the caller if error |
||
1444 | 3942 F92074 nodot: |
||
1445 | 3943 F92074 A5 53 lda fcbs |
||
1446 | 3944 F92076 C9 2E cmp #'.' |
||
1447 | 3945 F92078 F0 25 beq chkx |
||
1448 | 3946 F9207A _eaccess: |
||
1449 | 3947 F9207A A9 05 lda #ED_ACCESS ; access denied error |
||
1450 | 3948 F9207C 4C 12 24 jmp oserror |
||
1451 | 3949 |
||
1452 | 3950 ; reject names with wild cards -- never return to the caller if error |
||
1453 | 3951 F9207F nowild: |
||
1454 | 3952 F9207F A5 7C lda haswld |
||
1455 | 3953 F92081 F0 1C beq chkx |
||
1456 | 3954 F92083 A9 02 lda #ED_FILE ; invalid filename |
||
1457 | 3955 F92085 4C 12 24 jmp oserror |
||
1458 | 3956 |
||
1459 | 3957 ; check if fcb name = "." |
||
1460 | 3958 ; return ZF=1 if search for root (or '.' in root) |
||
1461 | 3959 F92088 chkroot: |
||
1462 | 3960 F92088 A5 46 lda dircls ; are we in the root? |
||
1463 | 3961 F9208A 05 47 ora dircls+1 |
||
1464 | 3962 F9208C D0 11 bne chkx ; no, no further checks required |
||
1465 | 3963 F9208E A5 53 lda fcbs |
||
1466 | 3964 F92090 C9 2E cmp #'.' ; is it a '.' entry ? |
||
1467 | 3965 F92092 D0 0B bne chkx |
||
1468 | 3966 F92094 A2 0A ldx #10 |
||
1469 | 3967 F92096 A9 20 lda #' ' ; check for 10 blanks |
||
1470 | 3968 F92098 D5 53 ?10: cmp fcbs,x |
||
1471 | 3969 F9209A D0 03 bne chkx |
||
1472 | 3970 F9209C CA dex |
||
1473 | 3971 F9209D D0 F9 bne ?10 |
||
1474 | 3972 F9209F 60 chkx: rts |
||
1475 | 3973 |
||
1476 | 3974 ; check if fcb name is a character device name |
||
1477 | 3975 ; return: |
||
1478 | 3976 ; CF=0 if not device name |
||
1479 | 3977 ; CF=1 if is a device name, A=index of device name |
||
1480 | 3978 ; use: A,X,Y |
||
1481 | 3979 F920A0 chkdev: |
||
1482 | 3980 F920A0 ACC16 |
||
1483 | 3981 F920A0 C2 20 rep #PMFLAG |
||
1484 | 3982 .LONGA on |
||
1485 | 3983 .MNLIST |
||
1486 | 3984 F920A2 A9 79 23 lda #devlst ; set pointer to device names list |
||
1487 | 3985 F920A5 85 6A sta tmpp |
||
1488 | 3986 F920A7 ACC08 |
||
1489 | Tue Jul 17 11:00:20 2018 Page 25 |
||
1490 | |||
1491 | |||
1492 | |||
1493 | |||
1494 | 3987 F920A7 E2 20 sep #PMFLAG |
||
1495 | 3988 .LONGA off |
||
1496 | 3989 .MNLIST |
||
1497 | 3990 F920A9 A9 F9 lda #^devlst |
||
1498 | 3991 F920AB 85 6C sta tmpp+2 |
||
1499 | 3992 F920AD 64 6E stz tmpx ; device index |
||
1500 | 3993 F920AF A2 07 ?10: ldx #7 ; loop match name |
||
1501 | 3994 F920B1 9B txy |
||
1502 | 3995 F920B2 B5 53 ?20: lda fcbs,x ; compare fcb name... |
||
1503 | 3996 F920B4 D7 6A cmp [tmpp],y ; ...against device name |
||
1504 | 3997 F920B6 D0 08 bne ?30 ; unmatch |
||
1505 | 3998 F920B8 88 dey |
||
1506 | 3999 F920B9 CA dex |
||
1507 | 4000 F920BA 10 F6 bpl ?20 |
||
1508 | 4001 F920BC 38 sec ; match |
||
1509 | 4002 F920BD A5 6E lda tmpx ; A=index |
||
1510 | 4003 F920BF 60 rts |
||
1511 | 4004 F920C0 A9 08 ?30: lda #8 |
||
1512 | 4005 F920C2 65 6A adc tmpp ; next device name |
||
1513 | 4006 F920C4 85 6A sta tmpp |
||
1514 | 4007 F920C6 90 02 bcc ?32 |
||
1515 | 4008 F920C8 E6 6B inc tmpp+1 |
||
1516 | 4009 F920CA E6 6E ?32: inc tmpx ; increment index |
||
1517 | 4010 F920CC A7 6A lda [tmpp] ; end of list? |
||
1518 | 4011 F920CE D0 DF bne ?10 ; no, so check next name |
||
1519 | 4012 F920D0 18 clc ; unmatch |
||
1520 | 4013 F920D1 60 rts |
||
1521 | 4014 |
||
1522 | 4015 ;--------------------------------------------------------------------------- |
||
1523 | 4016 ; directory search |
||
1524 | 4017 ;--------------------------------------------------------------------------- |
||
1525 | 4018 |
||
1526 | 4019 F920D2 fndfcbf: |
||
1527 | 4020 |
||
1528 | 4021 ; hashed directory search |
||
1529 | 4022 ; we try to optimize directory searches using a dynamic hash table (HCB) |
||
1530 | 4023 ; |
||
1531 | 4024 ; entry: dircls = starting cluster of directory |
||
1532 | 4025 ; curdrv = current logical drive |
||
1533 | 4026 ; fhash = hash code of searched fcb entry (=0 if search empty) |
||
1534 | 4027 ; dfcbtyp = search type (1=empty entry, 2=fcbs entry) |
||
1535 | 4028 ; fcbs = local name to search |
||
1536 | 4029 ; |
||
1537 | 4030 ; exit: CF = 1 if entry not found |
||
1538 | 4031 ; CF = 0 if entry was found |
||
1539 | 4032 ; chdcls = cluster of found entry |
||
1540 | 4033 ; entofs = entry offset number (0..15) |
||
1541 | 4034 ; secofs = sector's offset of found entry |
||
1542 | 4035 ; fcbp = long pointer to found entry |
||
1543 | 4036 ; xbuf = buffer that old sector of found entry |
||
1544 | 4037 ; lba = 24 bits address of sector |
||
1545 | 4038 ; dfcbatt = attribute of entry |
||
1546 | 4039 ; |
||
1547 | 4040 ; use: C,X,Y |
||
1548 | 4041 ; |
||
1549 | 4042 ; note: this routine should be called with 8 bit cpu mode |
||
1550 | 4043 ; |
||
1551 | Tue Jul 17 11:00:20 2018 Page 26 |
||
1552 | |||
1553 | |||
1554 | |||
1555 | |||
1556 | 4044 ;----- |
||
1557 | 4045 F920D2 hfind: |
||
1558 | 4046 ;----- |
||
1559 | 4047 F920D2 8B phb ; save current DBR |
||
1560 | 4048 F920D3 A9 00 lda #^hcb_data |
||
1561 | 4049 F920D5 48 pha |
||
1562 | 4050 F920D6 AB plb ; set DBR to HCB struct's |
||
1563 | 4051 F920D7 A6 52 ldx curdrv ; set drive |
||
1564 | 4052 F920D9 86 63 stx hcbdrv |
||
1565 | 4053 F920DB ACC16 |
||
1566 | 4054 F920DB C2 20 rep #PMFLAG |
||
1567 | 4055 .LONGA on |
||
1568 | 4056 .MNLIST |
||
1569 | 4057 F920DD A6 2B ldx ldtrsiz ; root dir. size (in sec) |
||
1570 | 4058 F920DF A5 46 lda dircls ; starting directory cluster |
||
1571 | 4059 F920E1 85 40 sta chdcls ; current chainded dir. cluster |
||
1572 | 4060 F920E3 F0 02 beq ?02 ; is root |
||
1573 | 4061 F920E5 A6 28 ldx ldtcsiz ; subdir. size (in sec.) |
||
1574 | 4062 F920E7 86 7B ?02: stx dsiz ; dir. size in sector's |
||
1575 | 4063 F920E9 CPU08 |
||
1576 | 4064 F920E9 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
1577 | 4065 .LONGA off |
||
1578 | 4066 .LONGI off |
||
1579 | 4067 .MNLIST |
||
1580 | 4068 F920EB 8A txa |
||
1581 | 4069 F920EC A6 09 ldx hlog2 ; shift count |
||
1582 | 4070 F920EE F0 08 beq ?06 |
||
1583 | 4071 F920F0 18 clc |
||
1584 | 4072 F920F1 65 08 adc hsiz ; round up to HCB size |
||
1585 | 4073 F920F3 3A dec a |
||
1586 | 4074 F920F4 4A ?04: lsr a |
||
1587 | 4075 F920F5 CA dex |
||
1588 | 4076 F920F6 D0 FC bne ?04 |
||
1589 | 4077 F920F8 85 7A ?06: sta maxseq ; how many sequnces |
||
1590 | 4078 F920FA ACC16 |
||
1591 | 4079 F920FA C2 20 rep #PMFLAG |
||
1592 | 4080 .LONGA on |
||
1593 | 4081 .MNLIST |
||
1594 | 4082 F920FC A5 40 lda chdcls ; start from here |
||
1595 | 4083 F920FE 85 6C ?10: sta hcbcls ; re-entry from this cluster |
||
1596 | 4084 F92100 85 40 sta chdcls |
||
1597 | 4085 F92102 A2 00 ldx #0 ; start with sequence=0 |
||
1598 | 4086 F92104 86 62 ?15: stx hcbseq ; re-entry from this sequence |
||
1599 | 4087 F92106 A0 00 ldy #0 ; current entry index |
||
1600 | 4088 F92108 CPU16 |
||
1601 | 4089 F92108 C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
1602 | 4090 .LONGA on |
||
1603 | 4091 .LONGI on |
||
1604 | 4092 .MNLIST |
||
1605 | 4093 F9210A 38 sec ; we want an HCB even if it's recycled |
||
1606 | 4094 F9210B 20 C9 24 jsr fndhcb ; find&fill an HCB (here return always CF=0) |
||
1607 | 4095 F9210E A6 04 ldx hcbroot ; X=HCB ptr -- start search |
||
1608 | 4096 F92110 BD 06 00 lda !hcb_cnt,x ; we have this many entries hashed |
||
1609 | 4097 F92113 29 FF 7F and #$7FFF ; strip off bit 15 |
||
1610 | 4098 F92116 0A asl a |
||
1611 | 4099 F92117 65 04 adc hcbroot |
||
1612 | 4100 F92119 85 6A sta hlast ; point past to the last hash code |
||
1613 | Tue Jul 17 11:00:20 2018 Page 27 |
||
1614 | |||
1615 | |||
1616 | |||
1617 | |||
1618 | 4101 F9211B A5 72 lda fhash ; look for this hash code |
||
1619 | 4102 F9211D DD 08 00 ?20: cmp !hcb_data,x ; try to find a match |
||
1620 | 4103 F92120 F0 24 beq ?30 ; hash code match |
||
1621 | 4104 F92122 C8 ?25: iny ; re-entry after check hash code |
||
1622 | 4105 F92123 E8 inx ; bump pointer |
||
1623 | 4106 F92124 E8 inx |
||
1624 | 4107 F92125 E4 6A cpx hlast |
||
1625 | 4108 F92127 90 F4 bcc ?20 ; loop until last code |
||
1626 | 4109 F92129 A6 04 ldx hcbroot |
||
1627 | 4110 F9212B 3C 06 00 bit !hcb_cnt,x ; test sign |
||
1628 | 4111 F9212E 30 66 bmi ?40 ; no more entries: exit with CF=1 (not found) |
||
1629 | 4112 F92130 INDEX08 |
||
1630 | 4113 F92130 E2 10 sep #PXFLAG |
||
1631 | 4114 .LONGI off |
||
1632 | 4115 .MNLIST |
||
1633 | 4116 F92132 A6 62 ldx hcbseq ; will check more entries |
||
1634 | 4117 F92134 E8 inx |
||
1635 | 4118 F92135 E4 7A cpx maxseq |
||
1636 | 4119 F92137 90 CB bcc ?15 ; ok, try next sequence |
||
1637 | 4120 F92139 A5 6C lda hcbcls ; we are at root dir.? |
||
1638 | 4121 F9213B F0 59 beq ?40 ; yes, exit with CF=1 (not found) |
||
1639 | 4122 F9213D 20 0D 23 jsr getncls ; C=next cluster in chain |
||
1640 | 4123 F92140 C5 30 cmp ldteoc ; have we fallen off the end of the chain? |
||
1641 | 4124 F92142 90 BA bcc ?10 ; no, try next cluster |
||
1642 | 4125 F92144 B0 50 bcs ?40 ; exit with CF=1 (not found) |
||
1643 | 4126 F92146 84 70 ?30: sty hcby ; save current index |
||
1644 | 4127 F92148 86 6E stx hcbx ; save current pointer |
||
1645 | 4128 F9214A 98 tya ; hash matching index |
||
1646 | 4129 F9214B 4A lsr a ; div. by 16 |
||
1647 | 4130 F9214C 4A lsr a |
||
1648 | 4131 F9214D 4A lsr a |
||
1649 | 4132 F9214E 4A lsr a |
||
1650 | 4133 F9214F AA tax ; sector's offset |
||
1651 | 4134 F92150 98 tya |
||
1652 | 4135 F92151 29 0F 00 and #$000F |
||
1653 | 4136 F92154 A8 tay |
||
1654 | 4137 F92155 0A asl a |
||
1655 | 4138 F92156 0A asl a |
||
1656 | 4139 F92157 0A asl a |
||
1657 | 4140 F92158 0A asl a |
||
1658 | 4141 F92159 0A asl a |
||
1659 | 4142 F9215A 85 74 sta fcbofs ; entry offset |
||
1660 | 4143 F9215C CPU08 |
||
1661 | 4144 F9215C E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
1662 | 4145 .LONGA off |
||
1663 | 4146 .LONGI off |
||
1664 | 4147 .MNLIST |
||
1665 | 4148 F9215E 86 45 stx secofs |
||
1666 | 4149 F92160 84 44 sty entofs |
||
1667 | 4150 F92162 A5 62 lda hcbseq |
||
1668 | 4151 F92164 F0 08 beq ?34 ; offset=0 |
||
1669 | 4152 F92166 A4 09 ldy hlog2 ; shift count |
||
1670 | 4153 F92168 F0 04 beq ?34 ; no shift |
||
1671 | 4154 F9216A 0A ?32: asl a |
||
1672 | 4155 F9216B 88 dey |
||
1673 | 4156 F9216C D0 FC bne ?32 |
||
1674 | 4157 F9216E 18 ?34: clc |
||
1675 | Tue Jul 17 11:00:20 2018 Page 28 |
||
1676 | |||
1677 | |||
1678 | |||
1679 | |||
1680 | 4158 F9216F 65 45 adc secofs |
||
1681 | 4159 F92171 85 45 sta secofs |
||
1682 | 4160 F92173 A8 tay ; sector's offset |
||
1683 | 4161 F92174 A6 52 ldx curdrv ; current logical drive |
||
1684 | 4162 F92176 ACC16 |
||
1685 | 4163 F92176 C2 20 rep #PMFLAG |
||
1686 | 4164 .LONGA on |
||
1687 | 4165 .MNLIST |
||
1688 | 4166 F92178 A5 6C lda hcbcls ; current cluster |
||
1689 | 4167 F9217A 38 sec ; preread buffer from disk |
||
1690 | 4168 F9217B 20 83 26 jsr fndbuf ; find & load buffer |
||
1691 | 4169 F9217E 18 clc |
||
1692 | 4170 F9217F A5 74 lda fcbofs |
||
1693 | 4171 F92181 65 5E adc fcbp |
||
1694 | 4172 F92183 85 5E sta fcbp |
||
1695 | 4173 F92185 CPU08 |
||
1696 | 4174 F92185 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
1697 | 4175 .LONGA off |
||
1698 | 4176 .LONGI off |
||
1699 | 4177 .MNLIST |
||
1700 | 4178 F92187 20 9A 21 jsr fcbcmp ; compare entry vs. local FCB |
||
1701 | 4179 F9218A 90 0C bcc ?45 ; match! |
||
1702 | 4180 F9218C CPU16 |
||
1703 | 4181 F9218C C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
1704 | 4182 .LONGA on |
||
1705 | 4183 .LONGI on |
||
1706 | 4184 .MNLIST |
||
1707 | 4185 F9218E A6 6E ldx hcbx ; restore pointer&index |
||
1708 | 4186 F92190 A4 70 ldy hcby |
||
1709 | 4187 F92192 A5 72 lda fhash ; hash code to find |
||
1710 | 4188 F92194 80 8C bra ?25 ; restart search |
||
1711 | 4189 F92196 ?40: CPU08 |
||
1712 | 4190 F92196 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
1713 | 4191 .LONGA off |
||
1714 | 4192 .LONGI off |
||
1715 | 4193 .MNLIST |
||
1716 | 4194 F92198 AB ?45: plb |
||
1717 | 4195 F92199 60 rts |
||
1718 | 4196 |
||
1719 | 4197 .LONGA off ; for assembler |
||
1720 | 4198 .LONGI off |
||
1721 | 4199 |
||
1722 | 4200 ; compare directory entry with local FCB |
||
1723 | 4201 F9219A fcbcmp: |
||
1724 | 4202 F9219A A5 50 lda dfcbtyp ; what kind of search? |
||
1725 | 4203 F9219C 3A dec a ; 1: wanted an empty entry? |
||
1726 | 4204 F9219D D0 0A bne ?20 ; no |
||
1727 | 4205 F9219F A7 5E lda [fcbp] |
||
1728 | 4206 F921A1 F0 19 beq ?30 ; ok, virgin entry |
||
1729 | 4207 F921A3 C9 E5 cmp #$E5 |
||
1730 | 4208 F921A5 F0 15 beq ?30 ; ok, empty entry |
||
1731 | 4209 F921A7 38 ?10: sec ; return failure |
||
1732 | 4210 F921A8 60 rts |
||
1733 | 4211 F921A9 A2 0A ?20: ldx #10 ; match on all characters |
||
1734 | 4212 F921AB 9B txy |
||
1735 | 4213 F921AC B5 53 ?22: lda fcbs,x |
||
1736 | 4214 F921AE D7 5E cmp [fcbp],y |
||
1737 | Tue Jul 17 11:00:20 2018 Page 29 |
||
1738 | |||
1739 | |||
1740 | |||
1741 | |||
1742 | 4215 F921B0 D0 F5 bne ?10 ; unmatch |
||
1743 | 4216 F921B2 88 dey |
||
1744 | 4217 F921B3 CA dex |
||
1745 | 4218 F921B4 10 F6 bpl ?22 ; loop |
||
1746 | 4219 F921B6 A0 0B ldy #11 |
||
1747 | 4220 F921B8 B7 5E lda [fcbp],y ; get file attribute |
||
1748 | 4221 F921BA 85 51 sta dfcbatt |
||
1749 | 4222 F921BC 18 ?30: clc ; return match |
||
1750 | 4223 F921BD 60 ?35: rts |
||
1751 | 4224 |
||
1752 | 4225 ; compare directory entry with local FCB |
||
1753 | 4226 F921BE dfcbcmp: |
||
1754 | 4227 F921BE A5 50 lda dfcbtyp ; what kind of search? |
||
1755 | 4228 F921C0 3A dec a ; 1: wanted an empty entry? |
||
1756 | 4229 F921C1 D0 0A bne ?20 ; no |
||
1757 | 4230 F921C3 A7 5E lda [fcbp] |
||
1758 | 4231 F921C5 F0 20 beq ?30 ; ok, virgin entry |
||
1759 | 4232 F921C7 C9 E5 cmp #$E5 |
||
1760 | 4233 F921C9 F0 1C beq ?30 ; ok, empty entry |
||
1761 | 4234 F921CB 38 ?10: sec ; return failure |
||
1762 | 4235 F921CC 60 rts |
||
1763 | 4236 F921CD 3A ?20: dec a ; 2: wanted match entry ('?' too)? |
||
1764 | 4237 F921CE D0 19 bne ?40 ; no |
||
1765 | 4238 F921D0 A2 0A ldx #10 ; match on all characters |
||
1766 | 4239 F921D2 9B txy |
||
1767 | 4240 F921D3 B5 53 ?22: lda fcbs,x |
||
1768 | 4241 F921D5 D7 5E cmp [fcbp],y |
||
1769 | 4242 F921D7 F0 04 beq ?24 ; match |
||
1770 | 4243 F921D9 C9 3F cmp #'?' ; this wild card match any character |
||
1771 | 4244 F921DB D0 EE bne ?10 ; failure: no match |
||
1772 | 4245 F921DD 88 ?24: dey |
||
1773 | 4246 F921DE CA dex |
||
1774 | 4247 F921DF 10 F2 bpl ?22 ; loop |
||
1775 | 4248 F921E1 A0 0B ?26: ldy #11 |
||
1776 | 4249 F921E3 B7 5E lda [fcbp],y ; get file attribute |
||
1777 | 4250 F921E5 85 51 sta dfcbatt |
||
1778 | 4251 F921E7 18 ?30: clc ; return match |
||
1779 | 4252 F921E8 60 ?35: rts |
||
1780 | 4253 F921E9 A2 07 ?40: ldx #7 ; caller wish a pattern match |
||
1781 | 4254 F921EB A0 00 ldy #0 ; first time match name comnponent |
||
1782 | 4255 F921ED 20 FC 21 jsr ?60 |
||
1783 | 4256 F921F0 B0 09 bcs ?50 ; no match |
||
1784 | 4257 F921F2 A2 08 ldx #8 ; 2nd time match extension component |
||
1785 | 4258 F921F4 A0 0A ldy #10 |
||
1786 | 4259 F921F6 20 FC 21 jsr ?60 |
||
1787 | 4260 F921F9 90 E6 bcc ?26 ; ok, pattern match |
||
1788 | 4261 F921FB 60 ?50: rts ; no match |
||
1789 | 4262 F921FC 86 77 ?60: stx xstart ; start of component |
||
1790 | 4263 F921FE 84 78 sty xend ; end of component |
||
1791 | 4264 F92200 B5 53 lda fcbs,x |
||
1792 | 4265 F92202 C9 2A cmp #'*' ; pattern start with star? |
||
1793 | 4266 F92204 F0 1D beq ?70 ; yes, so compare from end of string |
||
1794 | 4267 F92206 9B txy |
||
1795 | 4268 F92207 E6 78 inc xend ; one more for loop test |
||
1796 | 4269 F92209 80 02 bra ?64 |
||
1797 | 4270 F9220B B5 53 ?62: lda fcbs,x |
||
1798 | 4271 F9220D D7 5E ?64: cmp [fcbp],y ; compare |
||
1799 | Tue Jul 17 11:00:20 2018 Page 30 |
||
1800 | |||
1801 | |||
1802 | |||
1803 | |||
1804 | 4272 F9220F F0 0A beq ?66 ; match |
||
1805 | 4273 F92211 C9 3F cmp #'?' ; wildcard match any character |
||
1806 | 4274 F92213 F0 06 beq ?66 |
||
1807 | 4275 F92215 C9 2A cmp #'*' ; star match any pattern |
||
1808 | 4276 F92217 F0 08 beq ?68 |
||
1809 | 4277 F92219 D0 B0 bne ?10 ; no match |
||
1810 | 4278 F9221B E8 ?66: inx |
||
1811 | 4279 F9221C C8 iny |
||
1812 | 4280 F9221D E4 78 cpx xend ; loop until end of string |
||
1813 | 4281 F9221F 90 EA bcc ?62 |
||
1814 | 4282 F92221 18 ?68: clc ; match |
||
1815 | 4283 F92222 60 rts |
||
1816 | 4284 F92223 A4 78 ?70: ldy xend ; compare from end of string |
||
1817 | 4285 F92225 E6 77 inc xstart ; skip beginning star |
||
1818 | 4286 F92227 B7 5E ?72: lda [fcbp],y |
||
1819 | 4287 F92229 C9 20 cmp #' ' ; skip padding blanks |
||
1820 | 4288 F9222B D0 06 bne ?74 |
||
1821 | 4289 F9222D 88 dey |
||
1822 | 4290 F9222E C4 77 cpy xstart |
||
1823 | 4291 F92230 B0 F5 bcs ?72 |
||
1824 | 4292 F92232 60 rts ; here was just one star |
||
1825 | 4293 F92233 A6 78 ?74: ldx xend |
||
1826 | 4294 F92235 B5 53 ?76: lda fcbs,x |
||
1827 | 4295 F92237 C9 20 cmp #' ' ; skip padding blanks |
||
1828 | 4296 F92239 D0 06 bne ?78 |
||
1829 | 4297 F9223B CA dex |
||
1830 | 4298 F9223C E4 77 cpx xstart |
||
1831 | 4299 F9223E B0 F5 bcs ?76 |
||
1832 | 4300 F92240 60 rts ; here was just one star |
||
1833 | 4301 F92241 B5 53 ?78: lda fcbs,x |
||
1834 | 4302 F92243 C9 3F cmp #'?' |
||
1835 | 4303 F92245 F0 0B beq ?80 |
||
1836 | 4304 F92247 D7 5E cmp [fcbp],y |
||
1837 | 4305 F92249 D0 07 bne ?80 |
||
1838 | 4306 F9224B 88 dey |
||
1839 | 4307 F9224C CA dex |
||
1840 | 4308 F9224D E4 77 cpx xstart |
||
1841 | 4309 F9224F B0 F0 bcs ?78 |
||
1842 | 4310 F92251 60 rts ; match |
||
1843 | 4311 F92252 38 ?80: sec |
||
1844 | 4312 F92253 60 rts |
||
1845 | 4313 |
||
1846 | 4314 |
||
1847 | 4315 .LONGA off ; for assembler |
||
1848 | 4316 .LONGI off |
||
1849 | 4317 F92254 |
||
1850 | 4318 ; compute hash code of local FCB name (fcbs) |
||
1851 | 4319 ; |
||
1852 | 4320 ; entry: fcbs = local name to hash |
||
1853 | 4321 ; fhash = hash code of searched fcb entry (=0 if search empty) |
||
1854 | 4322 ; |
||
1855 | 4323 ; exit: fhash = hash code of local fcb name (=0 if empty) |
||
1856 | 4324 ; |
||
1857 | 4325 ; use: C,X,Y |
||
1858 | 4326 ; |
||
1859 | 4327 ; note: this routine should be called with 8 bit cpu mode |
||
1860 | 4328 ; |
||
1861 | Tue Jul 17 11:00:20 2018 Page 31 |
||
1862 | |||
1863 | |||
1864 | |||
1865 | |||
1866 | 4329 ;----- |
||
1867 | 4330 F92254 mkhsh: |
||
1868 | 4331 ;----- |
||
1869 | 4332 F92254 64 72 stz fhash |
||
1870 | 4333 F92256 64 73 stz fhash+1 |
||
1871 | 4334 F92258 A5 53 lda fcbs ; first char of file name |
||
1872 | 4335 F9225A F0 2F beq ?20 ; empty entry |
||
1873 | 4336 F9225C C9 E5 cmp #$E5 |
||
1874 | 4337 F9225E F0 2B beq ?20 ; deleted entry |
||
1875 | 4338 F92260 29 7F and #$7F |
||
1876 | 4339 F92262 85 73 sta fhash+1 |
||
1877 | 4340 F92264 A0 0A ldy #$0A ; hash all char's |
||
1878 | 4341 F92266 A2 00 ldx #0 |
||
1879 | 4342 F92268 ?10: ACC16 |
||
1880 | 4343 F92268 C2 20 rep #PMFLAG |
||
1881 | 4344 .LONGA on |
||
1882 | 4345 .MNLIST |
||
1883 | 4346 F9226A A5 72 lda fhash |
||
1884 | 4347 F9226C 0A asl a |
||
1885 | 4348 F9226D 69 00 00 adc #$0000 |
||
1886 | 4349 F92270 85 72 sta fhash |
||
1887 | 4350 F92272 ACC08 |
||
1888 | 4351 F92272 E2 20 sep #PMFLAG |
||
1889 | 4352 .LONGA off |
||
1890 | 4353 .MNLIST |
||
1891 | 4354 F92274 E8 inx |
||
1892 | 4355 F92275 B5 53 lda fcbs,x |
||
1893 | 4356 F92277 29 7F and #$7F |
||
1894 | 4357 F92279 45 72 eor fhash |
||
1895 | 4358 F9227B 85 72 sta fhash |
||
1896 | 4359 F9227D 88 dey |
||
1897 | 4360 F9227E D0 E8 bne ?10 |
||
1898 | 4361 F92280 ACC16 |
||
1899 | 4362 F92280 C2 20 rep #PMFLAG |
||
1900 | 4363 .LONGA on |
||
1901 | 4364 .MNLIST |
||
1902 | 4365 F92282 A5 72 lda fhash |
||
1903 | 4366 F92284 D0 03 bne ?15 ; hash=0 reserved for empty entry |
||
1904 | 4367 F92286 1A inc a |
||
1905 | 4368 F92287 85 72 sta fhash |
||
1906 | 4369 F92289 ?15: ACC08 |
||
1907 | 4370 F92289 E2 20 sep #PMFLAG |
||
1908 | 4371 .LONGA off |
||
1909 | 4372 .MNLIST |
||
1910 | 4373 F9228B 60 ?20: rts |
||
1911 | 4374 |
||
1912 | 4375 ;--------------------------------------------------------------------------- |
||
1913 | 4376 ; utilities |
||
1914 | 4377 ;--------------------------------------------------------------------------- |
||
1915 | 4378 |
||
1916 | 4379 ; in: dcnt, dircls, chdcls, curdrv |
||
1917 | 4380 F9228C getdfcb: |
||
1918 | 4381 F9228C getdbuf: |
||
1919 | 4382 F9228C CPU16 |
||
1920 | 4383 F9228C C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
1921 | 4384 .LONGA on |
||
1922 | 4385 .LONGI on |
||
1923 | Tue Jul 17 11:00:20 2018 Page 32 |
||
1924 | |||
1925 | |||
1926 | |||
1927 | |||
1928 | 4386 .MNLIST |
||
1929 | 4387 F9228E A5 46 lda dircls ; first cluster of directory |
||
1930 | 4388 F92290 A6 48 ldx dcnt |
||
1931 | 4389 F92292 E8 inx |
||
1932 | 4390 F92293 86 48 stx dcnt ; current directory index |
||
1933 | 4391 F92295 F0 63 beq ?18 ; first entry of dir. |
||
1934 | 4392 F92297 E0 FF FF cpx #$FFFF ; invalid next dir. index ? |
||
1935 | 4393 F9229A F0 5A beq ?16 ; yes, set end of directory condition (CF=1) |
||
1936 | 4394 F9229C 8A txa ; C=dcnt |
||
1937 | 4395 F9229D 4A lsr a ; div. by 16 (16 entries per sector) |
||
1938 | 4396 F9229E 4A lsr a |
||
1939 | 4397 F9229F 4A lsr a |
||
1940 | 4398 F922A0 4A lsr a |
||
1941 | 4399 F922A1 85 68 sta wtmp ; save sector's count |
||
1942 | 4400 F922A3 A8 tay ; Y=sector's offset |
||
1943 | 4401 F922A4 8A txa ; C=dcnt |
||
1944 | 4402 F922A5 29 0F 00 and #$000F ; entry number |
||
1945 | 4403 F922A8 AA tax ; X=entry offset |
||
1946 | 4404 F922A9 INDEX08 |
||
1947 | 4405 F922A9 E2 10 sep #PXFLAG |
||
1948 | 4406 .LONGI off |
||
1949 | 4407 .MNLIST |
||
1950 | 4408 F922AB 84 45 sty secofs ; low sector's offset (valid for root dir only) |
||
1951 | 4409 F922AD 86 44 stx entofs ; entry offset |
||
1952 | 4410 F922AF CPU16 |
||
1953 | 4411 F922AF C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
1954 | 4412 .LONGA on |
||
1955 | 4413 .LONGI on |
||
1956 | 4414 .MNLIST |
||
1957 | 4415 F922B1 A5 46 lda dircls ; we are at root dir.? |
||
1958 | 4416 F922B3 D0 08 bne ?05 ; no |
||
1959 | 4417 F922B5 A6 48 ldx dcnt |
||
1960 | 4418 F922B7 E4 2C cpx ldtrent ; end of the root directory? |
||
1961 | 4419 F922B9 B0 36 bcs ?15 ; yes, set end of directory condition (CF=1) |
||
1962 | 4420 F922BB 80 41 bra ?20 ; get buffer |
||
1963 | 4421 F922BD ?05: INDEX08 |
||
1964 | 4422 F922BD E2 10 sep #PXFLAG |
||
1965 | 4423 .LONGI off |
||
1966 | 4424 .MNLIST |
||
1967 | 4425 F922BF A5 68 lda wtmp ; sector's offset |
||
1968 | 4426 F922C1 A8 tay |
||
1969 | 4427 F922C2 A6 29 ldx ldtcshf ; sector per cluster shift count |
||
1970 | 4428 F922C4 F0 04 beq ?08 ; no shift (1 sec. per cluster) |
||
1971 | 4429 F922C6 4A ?06: lsr a |
||
1972 | 4430 F922C7 CA dex |
||
1973 | 4431 F922C8 D0 FC bne ?06 |
||
1974 | 4432 F922CA 85 42 ?08: sta clsofs ; cluster's count to skip from the first |
||
1975 | 4433 F922CC ACC08 |
||
1976 | 4434 F922CC E2 20 sep #PMFLAG |
||
1977 | 4435 .LONGA off |
||
1978 | 4436 .MNLIST |
||
1979 | 4437 F922CE 98 tya |
||
1980 | 4438 F922CF 25 32 and ldtmcls ; sector's offset within cluster |
||
1981 | 4439 F922D1 85 45 sta secofs |
||
1982 | 4440 F922D3 CPU16 |
||
1983 | 4441 F922D3 C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
1984 | 4442 .LONGA on |
||
1985 | Tue Jul 17 11:00:20 2018 Page 33 |
||
1986 | |||
1987 | |||
1988 | |||
1989 | |||
1990 | 4443 .LONGI on |
||
1991 | 4444 .MNLIST |
||
1992 | 4445 F922D5 A5 40 lda chdcls ; do we already know where we are? |
||
1993 | 4446 F922D7 F0 09 beq ?10 ; if not trace from start of chain |
||
1994 | 4447 F922D9 A4 44 ldy entofs ; entofs+secofs: null if we moved onto... |
||
1995 | 4448 ; ...next cluster |
||
1996 | 4449 F922DB D0 23 bne ?24 ; we stay at the same cluster |
||
1997 | 4450 F922DD C8 iny ; move on the next cluster in the chain... |
||
1998 | 4451 F922DE 84 42 sty clsofs ; ...starting from chdcls |
||
1999 | 4452 F922E0 80 02 bra ?12 |
||
2000 | 4453 F922E2 A5 46 ?10: lda dircls ; start cluster in the chain |
||
2001 | 4454 F922E4 A6 42 ?12: ldx clsofs ; skip along chain until we arrive... |
||
2002 | 4455 F922E6 F0 16 beq ?20 ; ...at the destination cluster |
||
2003 | 4456 F922E8 C6 42 dec clsofs ; decrement cluster offset |
||
2004 | 4457 F922EA 20 0D 23 jsr getncls ; C=next cluster in chain |
||
2005 | 4458 F922ED C5 30 cmp ldteoc ; have we fallen off the end of the chain? |
||
2006 | 4459 F922EF 90 F3 bcc ?12 ; no, loop again |
||
2007 | 4460 ; here, end of cluster's chain |
||
2008 | 4461 F922F1 A9 FF FF ?15: lda #$FFFF ; set end of directory condition |
||
2009 | 4462 F922F4 85 48 sta dcnt |
||
2010 | 4463 F922F6 64 40 ?16: stz chdcls ; forget where we are |
||
2011 | 4464 F922F8 80 10 bra ?30 ; exit with CF=1 |
||
2012 | 4465 F922FA 64 42 ?18: stz clsofs ; we are at first entry: clear offset's |
||
2013 | 4466 F922FC 64 44 stz entofs ; entofs+secofs |
||
2014 | 4467 F922FE 85 40 ?20: sta chdcls ; remember this cluster for next time |
||
2015 | 4468 F92300 ?24: CPU08 ; C=cluster (=0 if root) |
||
2016 | 4469 F92300 E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
2017 | 4470 .LONGA off |
||
2018 | 4471 .LONGI off |
||
2019 | 4472 .MNLIST |
||
2020 | 4473 F92302 A6 52 ldx curdrv ; current logical drive |
||
2021 | 4474 F92304 A4 45 ldy secofs ; sector's offset |
||
2022 | 4475 F92306 38 sec ; preread buffer from disk |
||
2023 | 4476 F92307 20 83 26 jsr fndbuf ; find & load buffer |
||
2024 | 4477 F9230A ?30: CPU08 |
||
2025 | 4478 F9230A E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
2026 | 4479 .LONGA off |
||
2027 | 4480 .LONGI off |
||
2028 | 4481 .MNLIST |
||
2029 | 4482 F9230C 60 rts |
||
2030 | 4483 |
||
2031 | 4484 ; get next cluster number |
||
2032 | 4485 ; in: C = cluster |
||
2033 | 4486 ; out: C = next chain cluster |
||
2034 | 4487 ; ldtfp preset to floppy fat table |
||
2035 | 4488 F9230D getncls: |
||
2036 | 4489 F9230D 08 php |
||
2037 | 4490 F9230E CPU08 |
||
2038 | 4491 F9230E E2 30 sep #(PMFLAG.OR.PXFLAG) |
||
2039 | 4492 .LONGA off |
||
2040 | 4493 .LONGI off |
||
2041 | 4494 .MNLIST |
||
2042 | 4495 F92310 24 18 bit ldtfg1 ; bit 6=0 if floppy |
||
2043 | 4496 F92312 50 1C bvc ?10 ; FAT12 media |
||
2044 | 4497 F92314 EB xba ; A=sector (one sec. = 256 cluster #) |
||
2045 | 4498 F92315 AA tax |
||
2046 | 4499 F92316 4A lsr a ; divide by 16 to get x-mem buffer bank |
||
2047 | Tue Jul 17 11:00:20 2018 Page 34 |
||
2048 | |||
2049 | |||
2050 | |||
2051 | |||
2052 | 4500 F92317 4A lsr a |
||
2053 | 4501 F92318 4A lsr a |
||
2054 | 4502 F92319 4A lsr a |
||
2055 | 4503 F9231A 18 clc |
||
2056 | 4504 F9231B 65 1D adc ldtfbuf ; add fat table base base bank |
||
2057 | 4505 F9231D 8F 28 FD 00 sta >PIA0+PIAPRA ; set bank |
||
2058 | 4506 F92321 8A txa |
||
2059 | 4507 F92322 EB xba ; restore cluster number in C |
||
2060 | 4508 F92323 CPU16 |
||
2061 | 4509 F92323 C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
2062 | 4510 .LONGA on |
||
2063 | 4511 .LONGI on |
||
2064 | 4512 .MNLIST |
||
2065 | 4513 F92325 29 FF 0F and #$0FFF ; mask 4096 cluster's |
||
2066 | 4514 F92328 0A asl a |
||
2067 | 4515 F92329 AA tax ; index to 8k fat table in x-mem window |
||
2068 | 4516 F9232A BF 00 20 01 lda >XMWIN,x ; get chained cluster |
||
2069 | 4517 F9232E 28 plp |
||
2070 | 4518 F9232F 60 rts |
||
2071 | 4519 F92330 ?10: CPU16 |
||
2072 | 4520 F92330 C2 30 rep #(PMFLAG.OR.PXFLAG) |
||
2073 | 4521 .LONGA on |
||
2074 | 4522 .LONGI on |
||
2075 | 4523 .MNLIST |
||
2076 | 4524 F92332 48 pha ; cluster # |
||
2077 | 4525 F92333 4A lsr a ; div. by 2 |
||
2078 | 4526 F92334 18 clc |
||
2079 | 4527 F92335 63 01 adc $01,s ; mult. x 1.5 |
||
2080 | 4528 F92337 A8 tay ; index to fat table |
||
2081 | 4529 F92338 68 pla |
||
2082 | 4530 F92339 4A lsr a ; even or odd cluster? |
||
2083 | 4531 F9233A B7 1A lda [ldtfp],y |
||
2084 | 4532 F9233C B0 05 bcs ?15 ; odd cluster |
||
2085 | 4533 F9233E 29 FF 0F and #$0FFF ; even cluster |
||
2086 | 4534 F92341 80 04 bra ?20 |
||
2087 | 4535 F92343 4A ?15: lsr a ; odd cluster: 4 bit's shift |
||
2088 | 4536 F92344 4A lsr a |
||
2089 | 4537 F92345 4A lsr a |
||
2090 | 4538 F92346 4A lsr a |
||
2091 | 4539 F92347 28 ?20: plp |
||
2092 | 4540 F92348 60 rts |
||
2093 | 4541 |
||
2094 | 4542 .LONGA off ; for assembler |
||
2095 | 4543 .LONGI off |
||
2096 | 4544 F92349 |
||
2097 | 4545 ; get pointer to directory entry given by dcnt |
||
2098 | 4546 ; in: dcnt=directory entry counter |
||
2099 | 4547 F92349 getsec: |
||
2100 | 4548 F92349 ACC16 |
||
2101 | 4549 F92349 C2 20 rep #PMFLAG |
||
2102 | 4550 .LONGA on |
||
2103 | 4551 .MNLIST |
||
2104 | 4552 F9234B A5 48 lda dcnt ; compute sector count |
||
2105 | 4553 F9234D 4A lsr a ; divide by 16 (16 entries per sector) |
||
2106 | 4554 F9234E 4A lsr a |
||
2107 | 4555 F9234F 4A lsr a |
||
2108 | 4556 F92350 4A lsr a |
||
2109 | Tue Jul 17 11:00:20 2018 Page 35 |
||
2110 | |||
2111 | |||
2112 | |||
2113 | |||
2114 | 4557 F92351 48 pha ; sector count |
||
2115 | 4558 F92352 A6 29 ldx ldtcshf ; sector per cluster shift count |
||
2116 | 4559 F92354 F0 04 beq ?06 ; no shift (1 sec. per cluster) |
||
2117 | 4560 F92356 4A ?04: lsr a |
||
2118 | 4561 F92357 CA dex |
||
2119 | 4562 F92358 D0 FC bne ?04 |
||
2120 | 4563 F9235A 85 42 ?06: sta clsofs ; cluster's count to skip from the first |
||
2121 | 4564 F9235C 68 pla |
||
2122 | 4565 F9235D ACC08 |
||
2123 | 4566 F9235D E2 20 sep #PMFLAG |
||
2124 | 4567 .LONGA off |
||
2125 | 4568 .MNLIST |
||
2126 | 4569 F9235F 25 32 and ldtmcls ; cluster sector offset |
||
2127 | 4570 F92361 85 45 sta secofs |
||
2128 | 4571 F92363 A5 48 lda dcnt |
||
2129 | 4572 F92365 29 0F and #$0F |
||
2130 | 4573 F92367 0A asl a |
||
2131 | 4574 F92368 85 44 sta entofs |
||
2132 | 4575 F9236A 60 rts |
||
2133 | 4576 F9236B |
||
2134 | 4577 ;--------------------------------------------------------------------------- |
||
2135 | 4578 ; tables |
||
2136 | 4579 ;--------------------------------------------------------------------------- |
||
2137 | 4580 |
||
2138 | 4581 F9236B 3A 2E 3B 2C 3D dlmstr .DB ':.;,=+\<>|/"[]' ; path delimeters |
||
2139 | 2B 5C 3C 3E 7C |
||
2140 | 2F 22 5B 5D |
||
2141 | 4582 00000E DLMSTR .EQU $-dlmstr |
||
2142 | 4583 |
||
2143 | 4584 F92379 devlst: |
||
2144 | 4585 F92379 43 4F 4E 20 20 .DB 'CON ' ; Keyboard and display |
||
2145 | 20 20 20 |
||
2146 | 4586 F92381 4B 45 59 42 44 .DB 'KEYBD$ ' ; Keyboard |
||
2147 | 24 20 20 |
||
2148 | 4587 F92389 53 43 52 45 45 .DB 'SCREEN$ ' ; Display |
||
2149 | 4E 24 20 |
||
2150 | 4588 F92391 43 4F 4E 53 4F .DB 'CONSOLE$' |
||
2151 | 4C 45 24 |
||
2152 | 4589 F92399 50 52 4E 20 20 .DB 'PRN ' ; System list device, usually a parallel port |
||
2153 | 20 20 20 |
||
2154 | 4590 F923A1 4C 53 54 20 20 .DB 'LST ' ; System list device, usually a parallel port |
||
2155 | 20 20 20 |
||
2156 | 4591 F923A9 4C 50 54 31 20 .DB 'LPT1 ' ; First parallel printer port |
||
2157 | 20 20 20 |
||
2158 | 4592 F923B1 4C 50 54 32 20 .DB 'LPT2 ' ; Second parallel printer port |
||
2159 | 20 20 20 |
||
2160 | 4593 F923B9 4C 50 54 33 20 .DB 'LPT3 ' ; Third parallel printer port |
||
2161 | 20 20 20 |
||
2162 | 4594 F923C1 41 55 58 20 20 .DB 'AUX ' ; Auxiliary device, usually a serial port |
||
2163 | 20 20 20 |
||
2164 | 4595 F923C9 43 4F 4D 31 20 .DB 'COM1 ' ; First serial communications port |
||
2165 | 20 20 20 |
||
2166 | 4596 F923D1 43 4F 4D 32 20 .DB 'COM2 ' ; Second serial communications port |
||
2167 | 20 20 20 |
||
2168 | 4597 F923D9 43 4F 4D 33 20 .DB 'COM3 ' ; Third serial communications port |
||
2169 | 20 20 20 |
||
2170 | 4598 F923E1 43 4F 4D 34 20 .DB 'COM4 ' ; Fourth serial communications port |
||
2171 | Tue Jul 17 11:00:20 2018 Page 36 |
||
2172 | |||
2173 | |||
2174 | |||
2175 | |||
2176 | 20 20 20 |
||
2177 | 4599 F923E9 4E 55 4C 20 20 .DB 'NUL ' ; Bit-bucket device |
||
2178 | 20 20 20 |
||
2179 | 4600 F923F1 24 49 44 4C 45 .DB '$IDLE$ ' ; Bit-bucket device |
||
2180 | 24 20 20 |
||
2181 | 4601 F923F9 43 4C 4F 43 4B .DB 'CLOCK$ ' ; System real-time clock |
||
2182 | 24 20 20 |
||
2183 | 4602 F92401 43 4C 4F 43 4B .DB 'CLOCK ' ; System real-time clock |
||
2184 | 20 20 20 |
||
2185 | 4603 F92409 43 4F 4E 46 49 .DB 'CONFIG$ ' |
||
2186 | 47 24 20 |
||
2187 | 4604 F92411 00 .DB 0 |
||
2188 | |||
2189 | |||
2190 | Lines Assembled : 4398 Errors : 0 |
||
2191 | |||
2192 | |||
2193 |