1745
|
1 * DIR Edition #8 - Released Mar. 12/2000
|
|
2 * Added the '-c' option, which stands for case insensitive. This means that
|
|
3 * wildcard filename matches do not care as to whether the filenames are
|
|
4 * upper or lowercase, when compared to the wildcard filename search you
|
|
5 * specified. There still are some quirks to using the '*' wildcard in some
|
|
6 * cases... I am still tracking down why that is happening.
|
|
7 *
|
|
8 * DIR Edition #7 - Released Jan. 16/2000
|
|
9 *
|
|
10 * This is a new version of the DIR command, based on the version Alan Dekok
|
|
11 * did with wildcarding. It fixes the year to work with modern clock drivers,
|
|
12 * allowing from 1900-2155. It also fixes the help message, and changes the
|
|
13 * edition # to 7. It should work with all version of OS9/NitrOS9/PowerBoost.
|
|
14 *
|
|
15 * -Curtis-
|
|
16 *
|
|
17 * Edition #7: (L. Curtis Boyle)
|
|
18 * 2000/01/15: Fixed help message bug.
|
|
19 * 2000/01/16: Fixed year output to handle 1900-2155
|
|
20 *
|
|
21 * Edition #8 (Curtis)
|
|
22 * 2000/03/11 Fixed Bad Filename error
|
|
23 * 2000/03/12 Added -c option (case insensitive filematching)
|
|
24
|
|
25 * Need to do 1 things:
|
|
26 * Fix '*' wildcards (ex. DIR *.lzh returns completely different than
|
|
27 * DIR *lzh - 1st only does files with ONE '.' char, 2nd does mix of ONE
|
|
28 * and >1, but not all the same as first example???)
|
|
29
|
|
30 nam dir
|
|
31 ttl program module
|
|
32
|
|
33 * Disassembled 94/11/18 12:51:39 by Alan DeKok
|
|
34
|
|
35 ifp1
|
|
36 use defsfile
|
|
37 endc
|
|
38
|
|
39 tylg set Prgrm+Objct
|
|
40 atrv set ReEnt+rev
|
|
41 rev set $01
|
|
42 mod eom,name,tylg,atrv,start,size
|
|
43
|
|
44 u0000 rmb 1 Path to current Directory
|
|
45 u0001 rmb 1 Path to RAW drive (current data or exec dir's drive)
|
|
46 u0002 rmb 2 Pointer to directory we are DIRing
|
|
47 u0004 rmb 2 Ptr to end of current sub-parm (if more than 1)
|
|
48 u0006 rmb 2 Pointer to filename match string we are DIRing
|
|
49 u0008 rmb 1 Case insensitive flag (0=NO)
|
|
50 u0009 rmb 1 Wildcard matched flag (0=NO)
|
|
51 u000A rmb 1 0=Filename not written yet, <>0 means is written out
|
|
52 u000B rmb 1 Merge of directories/non-directories/ext. info flags
|
|
53 u000C rmb 1 Wildcards in effect flag
|
|
54 u000D rmb 1 Extended info flag (0=No)
|
|
55 u000E rmb 1 Directories ONLY (0=No)
|
|
56 u000F rmb 1 Non-directories ONLY (0=NO)
|
|
57 u0010 rmb 1 One entry/line flag (0=Yes, else no)
|
|
58 u0011 rmb 1 Screen width
|
|
59 u0012 rmb 1 # chars left on current output line
|
|
60 u0013 rmb 2 Length of current filename
|
|
61 u0015 rmb 1 char from current directory entry
|
|
62 u0016 rmb 1 char from wild card string
|
|
63 u0017 rmb 1 Attributes for DIR open (Ex. EXEC)
|
|
64 * File descriptor info - 1st 13 bytes - only used if certain options and/or
|
|
65 * extended directory listings are requested.
|
|
66 u0018 rmb 1 File attributes
|
|
67 u0019 rmb 2 File owner ID
|
|
68 u001B rmb 5 Date last modified
|
|
69 u0020 rmb 1 DIR path # (link count on FD read, but not used)
|
|
70 u0021 rmb 4 File size (in bytes)
|
|
71 * Start of WritLn buffer for each directory entry starts here
|
|
72 u0025 rmb 1
|
|
73 * Information to be printed out goes here
|
|
74 * user-number, 4 bytes of hex, space space
|
|
75 u0026 rmb 6
|
|
76 * YY/MM/DD HHMM
|
|
77 u002C rmb 17
|
|
78 * file attributes
|
|
79 u003B rmb 10
|
|
80 * starting sector number
|
|
81 u0045 rmb 8
|
|
82 * file size
|
|
83 u004D rmb 8
|
|
84 * a space
|
|
85 u0055 rmb 1
|
|
86 * file name
|
|
87 u0056 rmb 25
|
|
88 u006F rmb 1
|
|
89 u0070 rmb 4
|
|
90 * starting sector of the file (3 bytes)
|
|
91 u0074 rmb 2
|
|
92 u0076 rmb 1
|
|
93 u0077 rmb 1 always 0
|
|
94 AllFlag rmb 1 $2E=don't print out .foo, $00=print out .foo
|
|
95 rmb 256 leave room for the stack
|
|
96 size equ .
|
|
97
|
|
98 name fcs /dir/
|
|
99 fcb $08
|
|
100
|
|
101 start ldd #$0150 Default to multiple entries/line, 80 column width
|
|
102 std <u0010
|
|
103 lda #'. default to NOT printing files with this first char
|
|
104 sta <AllFlag
|
|
105 clra
|
|
106 clrb
|
|
107 std <u000E directories only/non-directories only flags
|
|
108 std <u000C Clear wildcard & extended info flags
|
|
109 sta <u0008 Set case sensitivity to ON
|
|
110 leay >L0449,pc point to '.'
|
|
111 sty <u0002 Default to current data directory as DIR path
|
|
112 ldb #READ. directory attribute=READ.
|
|
113 clr <u0077 Always 0
|
|
114 * Process parameter line
|
|
115 L003F lda ,x get character
|
|
116 cmpa #$0D End of parms?
|
|
117 beq L0071 yup, time to dir!
|
|
118 cmpa #$20 space?
|
|
119 beq L006D yup, skip it
|
|
120 pshs x save ptr to start of current sub-parm
|
|
121 L004B lda ,x+ get char, bump up ptr
|
|
122 cmpa #$20 if a space, skip it
|
|
123 beq L0057
|
|
124 cmpa #$0D if not a CR, skip
|
|
125 bne L004B
|
|
126 leax -1,x save address of the CR
|
|
127 L0057 stx <u0004 Save ptr to end of current sub-parm
|
|
128 puls x Restore start of current sub-parm
|
|
129 lda ,x Get 1st char of sub-parm
|
|
130 cmpa #'- option flag?
|
|
131 bne L0066 no, must be dir/filename, go process
|
|
132 lbsr L023A Update flags based on hyphen options
|
|
133 bra L0069 Continue from end of current sub-parm block
|
|
134
|
|
135 L0066 lbsr L0286 Process dir and/or filenames
|
|
136 L0069 ldx <u0004 Continue from end of current sub-parm block
|
|
137 bra L003F Start working on next sub-parm
|
|
138
|
|
139 L006D leax 1,x skip this character
|
|
140 bra L003F and get another one
|
|
141
|
|
142 * Done processing parameter line - start doing actual DIR
|
|
143 * Entry: A=13 (which looks to be width if SS.ScSiz fails).
|
|
144 L0071 stb <u0017 Save directory attributes byte
|
|
145 ldb <u000D Get extended info flag
|
|
146 orb <u000E Merge setting with Directories flag
|
|
147 orb <u000F Merge with non-directories flag
|
|
148 stb <u000B Save merged flag
|
|
149 tst <u0010 one line/entry?
|
|
150 beq L00B3 if so, continue
|
|
151 pshs x,a
|
|
152 * Calculate dir table width
|
|
153 lda #1
|
|
154 ldb #SS.ScSiz return screen size
|
|
155 os9 I$GetStt
|
|
156 bcs L00A6 Check for unknown service error
|
|
157 tfr x,d Move screen width to D
|
|
158 cmpb #80 >=80 characters/line?
|
|
159 bhs L00AF Yes, continue
|
|
160 lda #60 go to 64
|
|
161 cmpb #60 64 to 79 chars?
|
|
162 bhs L00AD Yes, set width to 64
|
|
163 lda #48 48 to 63 chars?
|
|
164 cmpb #48 Yes, set width to 48
|
|
165 bhs L00AD
|
|
166 lda #32 32 to 47 chars?
|
|
167 cmpb #32 Yes, set to 32 chars
|
|
168 bhs L00AD
|
|
169 clr <u0010 if <32, do 1 file/line
|
|
170 bra L00AD
|
|
171
|
|
172 L00A6 cmpb #E$UnkSvc Unknown service code?
|
|
173 beq L00AF Yes, skip ahead
|
|
174 lbra L0430 Check for EOF, or exit with error
|
|
175
|
|
176 L00AD sta <u0011 Save screen width we will use
|
|
177 L00AF andcc #$FE Clear error flag
|
|
178 puls x,a Restore regs
|
|
179 L00B3 lda <u0017 Get current attributes flag
|
|
180 ora #$80 Add DIR attribute
|
|
181 ldx <u0002 Get ptr to DIR directory path
|
|
182 os9 I$Open Open directory
|
|
183 lbcs L0430 Error, exit with it
|
|
184 sta <u0000 Save DIR path
|
|
185 ldx <u0002 Get ptr to DIR pathname
|
|
186 lda <u0017 Get DIR attributes we used to OPEN
|
|
187 os9 I$ChgDir Change directory to DIR path
|
|
188 tst <u000B Get dir vs. nondir, extended info flags
|
|
189 beq L00ED None set, skip ahead
|
|
190 lda <u0017 Get DIR attributes
|
|
191 leax >L044B,pc point to '@'
|
|
192 os9 I$Open Open current drive RAW (to get file descriptors)
|
|
193 lbcs L0430 Error, check for EOF, or exit with it
|
|
194 sta <u0001 Save path to raw drive
|
|
195 L00ED lda <u0011 Get screen width
|
|
196 sta <u0012 Save it as # chars left on current output line
|
|
197 lda <u000D Get extended info requested flag
|
|
198 ora <u0010 Merge with 1 line/entry flag
|
|
199 beq L0145 All clear, skip 'Directory of'
|
|
200 leax >L044D,pc Print ' Directory of ' to screen
|
|
201 ldy #$000F
|
|
202 lda #$01
|
|
203 os9 I$Write
|
|
204 lbcs L0430
|
|
205 leay <u0025,u Point to directory entries buffer area
|
|
206 ldx <u0002 Get pathname to directory
|
|
207 L010D lda ,x+ Copy pathname up until CR
|
|
208 sta ,y+
|
|
209 cmpa #$0D
|
|
210 bne L010D
|
|
211 tst <u000C Separate filename?
|
|
212 beq L0127 No, skip ahead
|
|
213 lda #'/ Yes, Add slash to end of buffer
|
|
214 sta -1,y
|
|
215 ldx <u0006 Get pointer to user filename request
|
|
216 * Copy User filename to end of 'dir of' line
|
|
217 L011F lda ,x+ Copy it over until CR
|
|
218 * Force to uppercase if case insensitive flag set AND char is lowercase
|
|
219 * Will make for faster compares later.
|
|
220 lbsr ForcUppr Do uppercase change if needed
|
|
221 sta -1,x Save over original char (in case changed)
|
|
222 sta ,y+
|
|
223 cmpa #$0D
|
|
224 bne L011F
|
|
225 L0127 leax <u0025,u Point to full directory path/file requested
|
|
226 ldy #$00FF Max of 255 chars to print
|
|
227 lda #$01 Print directory name out (with 'directory of')
|
|
228 os9 I$WritLn
|
|
229 tst <u000D Extended info requested?
|
|
230 beq L0145 No, skip extended info header
|
|
231 ldd #$0102 std out for output, 2 lines to print
|
|
232 leax >L045C,pc Write out extended info header lines
|
|
233 lbsr L0627
|
|
234 lbcs L0430
|
|
235
|
|
236 * Main dir entry reading loop
|
|
237 L0145 lda <u0000 get path number to current directory
|
|
238 ldy #$001D get the filename
|
|
239 leax <u0056,u where to put it
|
|
240 os9 I$Read read it
|
|
241 lbcs L0430
|
|
242 ldy #$0003 and the starting sector
|
|
243 leax <u0074,u
|
|
244 os9 I$Read
|
|
245 lbcs L0430
|
|
246 lda <u0056 get the first character of filename
|
|
247 beq L0145 if zero (deleted), skip it
|
|
248 cmpa #$80 hi bit (deleted), ignore it
|
|
249 beq AllCont continue
|
|
250 * Now A<>0, and AllFlag may be zero (=print out all files)
|
|
251 anda #$7F
|
|
252 cmpa <AllFlag do all files?
|
|
253 beq L0145 if the first character is '.', don't print it
|
|
254 * Non '.' leading char filenames go here
|
|
255 AllCont clrb Filename size set to 0
|
|
256 leax <u0056,u Point to filename
|
|
257 L016D lda ,x+ Check char
|
|
258 incb Bump up filename size
|
|
259 cmpa #$80 End of filename marker?
|
|
260 blo L016D No, keep getting size
|
|
261 anda #$7F make it a real character
|
|
262 sta -1,x save it back
|
|
263 lda #$0D Add carriage return to filename
|
|
264 sta ,x
|
|
265 stb <u0013 Save filename size
|
|
266 tst <u000C filename to match specified?
|
|
267 beq L0191 No, skip ahead
|
|
268 leax <u0056,u Point to filename part of write buffer
|
|
269 ldy <u0006 Get ptr to filename match string
|
|
270 lbsr L0324 Do wildcard compare
|
|
271 tst <u0009 Did we have a match?
|
|
272 beq L0145 No, skip to next filename
|
|
273 L0191 tst <u000B Any files we have to weed out?
|
|
274 beq L01CA No, just print
|
|
275 * we only want certain types of files - check
|
|
276 ldx <u0074 Get FD sector # - hi word
|
|
277 pshs u Preserve U
|
|
278 ldu <u0076 Get FD sector # - low word
|
|
279 lda <u0001 Get path to raw drive
|
|
280 os9 I$Seek seek to the file descriptor
|
|
281 lbcs L0430
|
|
282 puls u Restore U
|
|
283 leax <u0018,u Point to place to store FD info
|
|
284 ldy #13 We only need 1st 13 bytes
|
|
285 os9 I$Read Read it in
|
|
286 lbcs L0430
|
|
287 lda <u0018 Get file attributes
|
|
288 anda #$80 Ignore all but DIR attribute
|
|
289 tst <u000E Directories ONLY?
|
|
290 beq L01C1 No, skip ahead
|
|
291 tsta This file a directory?
|
|
292 lbeq L0145 No, skip to next filename
|
|
293 bra L01CA Yes, print dir name out
|
|
294
|
|
295 L01C1 tst <u000F Non-directories ONLY?
|
|
296 beq L01CA No, print filename out
|
|
297 tsta This file a non-directory?
|
|
298 lbne L0145 It is a DIR, skip to next filename
|
|
299 * Print current dir entry out
|
|
300 L01CA tst <u0010 do one entry/line?
|
|
301 beq L0221 yes, print it out
|
|
302 clr <u000A Flag we have NOT printed filename yet.
|
|
303 ldb <u0013 Get filename size
|
|
304 cmpb <u0012 enough chars left in current output line to fit?
|
|
305 bge L0205 No, Print CR
|
|
306 inc <u000A Flag that we will have printed filename
|
|
307 L01D8 clra D=Current filename size
|
|
308 tfr d,y Y=size of filename
|
|
309 inca Std Out
|
|
310 leax <u0056,u Point to filename in output buffer
|
|
311 os9 I$Write Write out filename
|
|
312 lbcs L0430
|
|
313 lda <u0012 Get # chars left on current output line
|
|
314 * Add spaces between filenames - they are 'tabbed' at 16 or 32 chars,
|
|
315 * depending on filename size
|
|
316 L01E8 suba #16 Subtract 16 from # chars left on output line
|
|
317 ble L0205 Done line, print CR
|
|
318 subb #16 Not done, subtract 16 chars from filename size
|
|
319 bge L01E8 filename was >16 chars, bump to next 'tab' stop
|
|
320 negb # spaces we have to print to pad to next 'tab'
|
|
321 sta <u0012 Save # chars left on output line
|
|
322 clra Y=# spaces to print to finish current tab field
|
|
323 tfr d,y
|
|
324 inca Std out
|
|
325 leax >L04F2,pc Write spaces out
|
|
326 os9 I$Write
|
|
327 lbcs L0430
|
|
328 lbra L0145 On to next filename entry
|
|
329
|
|
330 * Flush out current output line to screen, reset # chars left on output line
|
|
331 * to screen width.
|
|
332 L0205 lda #$01 Print CR by itself
|
|
333 ldy #$0001
|
|
334 leax >L044A,pc
|
|
335 os9 I$WritLn
|
|
336 lbcs L0430
|
|
337 lda <u0011 Get screen width
|
|
338 sta <u0012 Save as size available on current line
|
|
339 tst <u000A Did we print filename out yet?
|
|
340 beq L01D8 No, do it now
|
|
341 lbra L0145 Already printed, skip to next filename
|
|
342
|
|
343 L0221 tst <u000D
|
|
344 lbne L036A if not zero, print out all the information
|
|
345 lda #$01
|
|
346 leax <u0056,u
|
|
347 ldy #$001E length of the filename
|
|
348 os9 I$WritLn dump out the filename
|
|
349 lbcs L0430
|
|
350 lbra L0145
|
|
351
|
|
352 * parse the path options
|
|
353 * Entry: X=ptr to current char being checked in parameter line
|
|
354 L023A leax 1,x Point to next char
|
|
355 lda ,x Get it
|
|
356 cmpa #$20 Space?
|
|
357 beq L025E Yes, done current parm, return
|
|
358 cmpa #$0D CR?
|
|
359 beq L025E Yes, done parm line, return
|
|
360 anda #$DF make it uppercase
|
|
361 cmpa #'E extended directory?
|
|
362 beq L0274
|
|
363 cmpa #'S Single entry/line
|
|
364 beq L0270
|
|
365 cmpa #'D Directories only
|
|
366 beq L027A
|
|
367 cmpa #'F Non-Dirs only
|
|
368 beq L0280
|
|
369 cmpa #'X Execution directory
|
|
370 beq L026C
|
|
371 * Curt's additions here
|
|
372 cmpa #'C Case insensitve?
|
|
373 beq CaseIns
|
|
374 *--- my additions here
|
|
375 cmpa #'L Extended dir
|
|
376 beq L0274
|
|
377 cmpa #'A do _all_ files (includes '.' and '..')
|
|
378 beq DoAll
|
|
379 bra L025F
|
|
380
|
|
381 L025E rts
|
|
382
|
|
383 CaseIns inc <u0008 Set case insensitivity ON
|
|
384 bra L023A
|
|
385
|
|
386 L025F ldd #$010c 12 lines of text in help
|
|
387 leax >L0505,pc Point to help message
|
|
388 lbsr L0627 Print it out
|
|
389 lbra L0430
|
|
390
|
|
391 L026C addb #EXEC. add in exec attribute
|
|
392 bra L023A and get another character
|
|
393
|
|
394 L0270 clr <u0010 one line/entry
|
|
395 bra L023A
|
|
396
|
|
397 L0274 inc <u000D print out all info
|
|
398 clr <u0010 one line/entry
|
|
399 bra L023A
|
|
400
|
|
401 L027A inc <u000E Set directories only flag
|
|
402 clr <u000F Clear non-directories only flag
|
|
403 bra L023A
|
|
404
|
|
405 L0280 inc <u000F Set non-directories only flag
|
|
406 clr <u000E Clear directories only flag
|
|
407 bra L023A
|
|
408
|
|
409 DoAll clr <AllFlag do all files
|
|
410 bra L023A and get another character
|
|
411
|
|
412 * Process requested dir/file name from user
|
|
413 * Entry: X=ptr to start of wildcard matching filename
|
|
414 * Exit: u0002=ptr to start of dir name
|
|
415 * u0006=ptr to start of filename to match (if any)
|
|
416 *
|
|
417 L0286 stx <u0002 save ptr to start of file/dir name
|
|
418 L0288 lda ,x+ Get char from file/dir name
|
|
419 cmpa #'_ underscore?
|
|
420 beq L0288 skip it
|
|
421 cmpa #'. period or under?
|
|
422 blo L02A6 special checks, skip ahead
|
|
423 cmpa #'9 9?
|
|
424 bls L0288 Below, skip to next char
|
|
425 cmpa #'A Between ':' and '@', skip ahead
|
|
426 blo L02A6
|
|
427 cmpa #'Z Uppercase letter, skip to next char
|
|
428 bls L0288
|
|
429 cmpa #'a Between '[' and "'", skip ahead
|
|
430 blo L02A6
|
|
431 cmpa #'z lowercase, skip to next char
|
|
432 bls L0288
|
|
433 L02A6 cmpa #$0D cr?
|
|
434 beq L02B2 exit if so
|
|
435 cmpa #$20 space?
|
|
436 bne L02B3 no, go do more checks
|
|
437 lda #$0D replace space with CR (only 1 file/dirname allowed)
|
|
438 sta ,-x save in the parameter area
|
|
439 L02B2 rts
|
|
440
|
|
441 * Special char check
|
|
442 L02B3 cmpa #'* any sequence match wildcard?
|
|
443 beq L02C1 yes, process it
|
|
444 cmpa #'? one-character wildcard?
|
|
445 beq L02C1 yes, process it
|
|
446 ldb #E$BNam Exit with Bad filename error
|
|
447 orcc #1
|
|
448 lbra L0430
|
|
449
|
|
450 L02C1 stx <u0006 Save pointer to filename match string
|
|
451 L02C3 lda ,x+ grab another byte
|
|
452 cmpa #$0D CR?
|
|
453 beq L02D1 yup, exit
|
|
454 cmpa #$20 space?
|
|
455 bne L02C3 no, skip it
|
|
456 lda #$0D dump a CR at the end of the filename
|
|
457 sta ,-x
|
|
458 L02D1 ldx <u0006 Get ptr to start of filename again
|
|
459 L02D3 lda ,-x get the previous character to filename
|
|
460 cmpx <u0002 was dirname ptr?
|
|
461 bne L02E3 no, check for user specified dir separator
|
|
462 stx <u0006 save start of filename
|
|
463 leax >L0449,pc point to a '.' (current dir)
|
|
464 stx <u0002 save dir pathname
|
|
465 bra L02ED
|
|
466
|
|
467 L02E3 cmpa #'/ slash (wildcard is start of filename after dir)?
|
|
468 bne L02D3 no, keep searching back until '/' or start of entry
|
|
469 lda #$0D Found '/', Put CR over slash
|
|
470 sta ,x+ (separate dir name from filename)
|
|
471 stx <u0006 Save new wildcard start
|
|
472 L02ED inc <u000C Set wildcards used flag
|
|
473 ldx <u0006 Get wildcard start
|
|
474 L02F1 lda #$0D Is current char of wildcard CR?
|
|
475 cmpa ,x
|
|
476 beq L0323 Yes, skip ahead
|
|
477 lda #'* wildcard?
|
|
478 cmpa ,x
|
|
479 beq L0301 yes, do it
|
|
480 leax 1,x otherwise skip the character
|
|
481 bra L02F1
|
|
482
|
|
483 L0301 leay 1,x
|
|
484 cmpa ,y
|
|
485 beq L0311
|
|
486 lda #'? one-character wildcard?
|
|
487 cmpa ,y
|
|
488 beq L031B
|
|
489 leax $01,x
|
|
490 bra L02F1
|
|
491
|
|
492 L0311 lda ,y+
|
|
493 sta -$02,y
|
|
494 cmpa #$0D
|
|
495 bne L0311
|
|
496 bra L02F1
|
|
497
|
|
498 L031B sta ,x+
|
|
499 lda #'* save a wildcard
|
|
500 sta ,x
|
|
501 bra L02F1
|
|
502
|
|
503 L0323 rts
|
|
504
|
|
505 * Compare current dir entry filename to user specified match filename
|
|
506 * Entry: X=ptr to current filename from dir
|
|
507 * Y=ptr to wildcard match filename
|
|
508 * Exit: <u0009=0, no match
|
|
509 * <>1, match
|
|
510 L0324 lda ,x Get char from current dir entry filename
|
|
511
|
|
512 bsr ForcUppr Change case if needed
|
|
513
|
|
514 ldb ,y Get char from user match filename
|
|
515 std <u0015 Save both 1st chars
|
|
516 cmpb #$0D CR of wildcard?
|
|
517 bne L0334 No, skip ahead
|
|
518 cmpa #$0D CR of current DIR entry filename?
|
|
519 beq L0362 Yes, matched
|
|
520 bra L0367 No match
|
|
521
|
|
522 L0334 cmpb #'* any char match wildcard?
|
|
523 beq L034A yes, do it
|
|
524 cmpa #$0D End of filename from current dir entry?
|
|
525 beq L0367 Yes, flag that filename did NOT match
|
|
526 cmpb #'? one-character wildcard?
|
|
527 beq L0344 yes, simply skip over 1 char in both strings
|
|
528 cmpb <u0015 non-wildcard char from user match dir entry?
|
|
529 bne L0367 No, flag no match & return
|
|
530 L0344 leax 1,x next up in current dir entry
|
|
531 leay 1,y next up in wildcard
|
|
532 bra L0324 Continue comparing
|
|
533
|
|
534 L034A leay 1,y Bump up user filename char ptr
|
|
535 ldb ,y Get that char from user filename string
|
|
536 cmpb #$0D End of wildcard match string?
|
|
537 beq L0362 Yes, set flag & return
|
|
538 L0352 cmpb <u0015 Same as current char from current filename?
|
|
539 beq L0344 Yes, bump both string pointers up and do next chars
|
|
540 leax 1,x Bump up dir entry char ptr
|
|
541 lda ,x Get char
|
|
542 cmpa #$0D End of filename?
|
|
543 beq L0367 Yes, clear flag and return
|
|
544 sta <u0015 Save char from current dir entry
|
|
545 bra L0352 Try next
|
|
546
|
|
547 * Flag that wildcard compare has a match (so far)
|
|
548 L0362 lda #$01
|
|
549 sta <u0009
|
|
550 rts
|
|
551
|
|
552 * Flag that wildcard compare did NOT match
|
|
553 L0367 clr <u0009
|
|
554 rts
|
|
555
|
|
556 * Change current char in A to uppercase, if <u0008 <>0
|
|
557 ForcUppr tst <u0008 Case insensitive?
|
|
558 beq NoChange No, check char as is
|
|
559 cmpa #'a
|
|
560 blo NoChange Non-lowercase, check as is
|
|
561 cmpa #'z Lowercase?
|
|
562 bhi NoChange No, check as is
|
|
563 anda #$DF Force uppercase
|
|
564 NoChange rts
|
|
565
|
|
566 * Copy default output line information to output line buffer
|
|
567 L036A leax >L04D4,pc Point to default date/attributes string
|
|
568 leay <u0025,u Point to output line buffer
|
|
569 L0371 lda ,x+ Copy until we hit LF
|
|
570 cmpa #$0A
|
|
571 beq L037B
|
|
572 sta ,y+
|
|
573 bra L0371
|
|
574
|
|
575 L037B leay <u0026,u Point to start of output line buffer
|
|
576 leax <u0019,u Point to file creator's user #
|
|
577 ldb #$02 print out user number, in hex (2 bytes)
|
|
578 L0383 lda ,x+
|
|
579 lbsr L0409 dump hex ASCII number into 2 bytes @ y
|
|
580 decb Do 2nd byte
|
|
581 bne L0383
|
|
582 leax <u0026,u Point to start of user # in output buffer
|
|
583 lbsr L0420 replace leading zeros with spaces
|
|
584 leay <u002C,u Where ASCII date/time info goes in write buffer
|
|
585 leax <u001B,u Point to date/time last modified binary data
|
|
586 * Y2k - Treat century as separate #
|
|
587 ldb ,x Get year
|
|
588 clra Century offset starts @ 0
|
|
589 LoopCent cmpb #100 Calculate century offset (0-2) into A
|
|
590 blo DoCent
|
|
591 inca
|
|
592 subb #100
|
|
593 bra LoopCent
|
|
594
|
|
595 DoCent tfr a,b Save century offset
|
|
596 adda #19 actual century offset
|
|
597 bsr L03F8 Convert A to 2 digit century
|
|
598 lda #100
|
|
599 mul Calculate # of years already accounted for
|
|
600 pshs b Save it
|
|
601 lda ,x+ Get original year back
|
|
602 suba ,s+ Calculate years left
|
|
603 bsr L03F8 Dump rest of year out
|
|
604 leay 1,y Skip slash
|
|
605 ldb #2 We are converting 3 #'s into 2 digit ASCII
|
|
606 L0399 lda ,x+ Get binary value
|
|
607 bsr L03F8 dump it out in ASCII
|
|
608 leay 1,y Skip over when '/'
|
|
609 decb
|
|
610 bne L0399
|
|
611 lda ,x+
|
|
612 bsr L03F8 HH
|
|
613 lda ,x
|
|
614 bsr L03F8 MM
|
|
615 * Attributes
|
|
616 leay <u003B,u
|
|
617 leax <u0018,u
|
|
618 ldd #$2D08 hyphen, 8-times
|
|
619 L03B3 lsl ,x
|
|
620 bcs L03B9
|
|
621 sta ,y save hyphen if bit is not set
|
|
622 L03B9 leay $01,y go to the next byte
|
|
623 decb
|
|
624 bne L03B3 Do all 8 attribute bits
|
|
625 leay <u0045,u Point to part of output buffer for start sector #
|
|
626 leax <u0074,u Point to start sector # data
|
|
627 ldb #$03 3 bytes of data to do
|
|
628 L03C6 lda ,x+ Convert to hex
|
|
629 bsr L0409
|
|
630 decb
|
|
631 bne L03C6
|
|
632 leax <u0045,u
|
|
633 bsr L0420 replace leading 0's with spaces
|
|
634 leay <u004D,u Point to file size in output buffer
|
|
635 leax <u0021,u Point to file size data
|
|
636 ldb #$04 4 bytes of data to do
|
|
637 L03DB lda ,x+ Convert to hex
|
|
638 bsr L0409
|
|
639 decb
|
|
640 bne L03DB
|
|
641 leax <u004D,u
|
|
642 bsr L0420 replace leading 0's with spaces
|
|
643 leax <u0025,u Point to output buffer
|
|
644 ldy #$0050 Print line (filename done earlier)
|
|
645 lda #$01
|
|
646 os9 I$WritLn
|
|
647 bcs L0430
|
|
648 lbra L0145 Onto next dir entry
|
|
649
|
|
650 * Dump decimal ASCII out for contents of A (2 digit max)
|
|
651 * ,y must contain a '0' for this to work.
|
|
652 L03F8 cmpa #10 <10?
|
|
653 blo L0402 Yes, just do one digit
|
|
654 inc ,y Bump up 10's counter
|
|
655 suba #10 Subtract 10 from byte
|
|
656 bra L03F8 Do until 10's digit is done.
|
|
657
|
|
658 L0402 leay 1,y Skip to 2nd byte
|
|
659 adda #'0 add in a zero (for bin to ASCII)
|
|
660 sta ,y+ Save it & return
|
|
661 rts
|
|
662
|
|
663 * Convert binary to hex
|
|
664 * Entry: A=byte to convert to 2 digit hex
|
|
665 * Y=ptr to 2 byte buffer to hold ASCII HEX chars
|
|
666 L0409 pshs a Save byte
|
|
667 lsra A=high nibble (shifted down)
|
|
668 lsra
|
|
669 lsra
|
|
670 lsra
|
|
671 bsr L0415 Make digit
|
|
672 puls a Restore original
|
|
673 anda #$0F Mask out high nibble
|
|
674 L0415 adda #'0 Convert to ASCII char
|
|
675 cmpa #'9
|
|
676 bls L041D
|
|
677 adda #$07
|
|
678 L041D sta ,y+
|
|
679 rts
|
|
680
|
|
681 * replace leading zeros with spaces from ASCII sequence, stopping at non-zero
|
|
682 * Entry: X=ptr to string
|
|
683 L0420 ldd #$3020 Zero & space chars
|
|
684 L0423 cmpa ,x is the first character a zero?
|
|
685 bne L042F if not, return
|
|
686 cmpb 1,x is the 2nd character a space?
|
|
687 beq L042F if '0 ', return without any changes
|
|
688 stb ,x+ otherwise save space over '0', go onto next char
|
|
689 bra L0423
|
|
690
|
|
691 L042F rts
|
|
692
|
|
693 L0430 cmpb #E$EOF
|
|
694 bne L0435
|
|
695 clrb ignore EOF errors
|
|
696 L0435 tst <u0010 one file/line?
|
|
697 beq L0446 if so, exit
|
|
698 leax >L044A,pcr output a CR
|
|
699 lda #$01
|
|
700 ldy #$0001
|
|
701 os9 I$WritLn and then exit
|
|
702 L0446 os9 F$Exit
|
|
703
|
|
704 L0449 fcc /./
|
|
705 L044A fcb $0d
|
|
706 L044B fcc /@/
|
|
707 fcb $0d
|
|
708 L044D fcb $0a
|
|
709 fcc / Directory of /
|
|
710 L045C fcb $0a
|
|
711 fcc /User # Last Modified Attributes Sector File Size File Name/
|
|
712 fcb $0d
|
|
713 fcc /------ --------------- ---------- ------ --------- ----------/
|
|
714 fcb $0d
|
|
715 L04D4 fcc ' 0000/00/00 0000 dsewrewr'
|
|
716 L04F2 fcc / /
|
|
717 L0505 fcb $0a
|
|
718 fcc 'dir [-opts] [path/patt] [-opts]'
|
|
719 fcb $0d
|
|
720 fcc /opts: x - use current exec dir/
|
|
721 fcb $0d
|
|
722 fcc ' s - one entry/line'
|
|
723 fcb $0d
|
|
724 fcc ' e/l - extended directory'
|
|
725 fcb $0d
|
|
726 fcc / a - show '.files', too/
|
|
727 fcb $0d
|
|
728 fcc / d - only directory files/
|
|
729 fcb $0d
|
|
730 fcc / f - only non-dir files/
|
|
731 fcb $0d
|
|
732 fcc / c - case insensitive filename match (BUT NOT DIR NAME)/
|
|
733 fcb $0d
|
|
734 fcc / ? - help message/
|
|
735 fcb $0d
|
|
736 fcc /pattern: may include wild cards/
|
|
737 fcb $0d
|
|
738 fcc / * - multiple character/
|
|
739 fcb $0d
|
|
740 fcc / ? - single character/
|
|
741 fcb $0d
|
|
742
|
|
743 * Print several lines of text up to 80 chars each
|
|
744 * Entry: X=Ptr to multi-line text string (CR terminates lines)
|
|
745 * B=# of lines to write.
|
|
746 L0627 decb Dec line counter
|
|
747 ldy #80
|
|
748 os9 I$WritLn
|
|
749 bcs L0642 Error writing, return with it
|
|
750 pshs d preserve path/line count
|
|
751 tfr y,d Move size actually written to D
|
|
752 leax d,x Bump source buffer ptr to next line
|
|
753 puls d Restore path/line count
|
|
754 tstb Any lines left to print?
|
|
755 beq L0642 No, exit
|
|
756 bra L0627 Yes, print next line
|
|
757
|
|
758 L0642 rts
|
|
759
|
|
760 emod
|
|
761 eom equ *
|