1 ; get arguments from command line (when DOS supports it)
2 ; and supply function to get default device: char *getdefdev(void);
4 ; Freddy Offenga, 4/21/2000
7 ; the ZCRNAME routine is only used to get the default drive because
8 ; ZCRNAME has two disadvantages:
9 ; 1. It will convert D: into D1: instead of Dn: (n = default drive)
10 ; 2. It will give a 'no arguments' status if it detects something
11 ; like Dn: (without filename).
14 ; ZCRNAME is slightly different from SpartaDOS. It will convert D:
15 ; into Dn: where n is the default drive.
17 MAXARGS = 16 ; max. amount of arguments in arg. table
18 CL_SIZE = 64 ; command line buffer size
19 SPACE = 32 ; SPACE char.
22 .export getargs, argc, argv
23 .export _getdefdev ; get default device (e.g. "D1:")
36 bcs argdos ; carry set = DOS supports arguments
39 ; Move SpartaDOS command line to our own buffer
59 sta ourcl,y ; null terminate behind ATEOL
61 ; Get default device (LBUF will be destroyed!!)
65 sta (DOSVEC),y ; reset buffer offset
67 ; Store dummy argument
76 ; One extra store to avoid the buggy sequence from OS/A+ DOS:
77 ; <D><RETURN><:> => drive number = <RETURN>
82 ; Create crunch vector
91 crvec: jsr $FFFF ; will be set to crunch vector
95 ldy #COMFNAM ; COMFNAM is always "Dn:"
102 ; Turn command line into argv table
105 eatspc: lda ourcl,y ; eat spaces
109 bne rpar ; begin of argument found
113 beq finargs ; only spaces is no argument
115 ; Store argument vector
117 rpar: lda argc ; low-byte
137 cpx #ATEOL ; end of line?
145 ; End of arg. -> place 0
151 cpx #ATEOL ; was it the last arg?
169 cmp #$53 ; "S" (SpartaDOS)
181 ldy #6 ; OS/A+ has a jmp here
185 spdos: sec ; SpartaDOS, OS/A+ or DOS XL
188 nordos: clc ; normal DOS (no args) detected
191 ; Get default device (set by getargs routine)
200 ; Dummy argument to get default device
207 ; Buffer for command line / argv strings
220 argv: .res (1 + MAXARGS) * 2