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, __dos_type
23 .export _getdefdev ; get default device (e.g. "D1:")
36 bcs argdos ; carry set = DOS supports arguments
39 ; Initialize ourcl buffer
44 ; Move SpartaDOS command line to our own buffer
64 sta ourcl,y ; null terminate behind ATEOL
66 ; Get default device (LBUF will be destroyed!!)
70 sta (DOSVEC),y ; reset buffer offset
72 ; Store dummy argument
81 ; One extra store to avoid the buggy sequence from OS/A+ DOS:
82 ; <D><RETURN><:> => drive number = <RETURN>
87 ; Create crunch vector
96 crvec: jsr $FFFF ; will be set to crunch vector
100 ldy #COMFNAM ; COMFNAM is always "Dn:"
107 ; Turn command line into argv table
110 eatspc: lda ourcl,y ; eat spaces
114 bne rpar ; begin of argument found
118 beq finargs ; only spaces is no argument
120 ; Store argument vector
122 rpar: lda argc ; low-byte
142 cpx #ATEOL ; end of line?
150 ; End of arg. -> place 0
156 cpx #ATEOL ; was it the last arg?
174 sta __dos_type ; set default
177 cmp #$53 ; "S" (SpartaDOS)
189 ldy #6 ; OS/A+ has a jmp here
196 spdos: lda #SPARTADOS
198 spdos1: sec ; SpartaDOS, OS/A+ or DOS XL
201 nordos: clc ; normal DOS (no args) detected
204 ; Get default device (set by getargs routine)
221 argv: .res (1 + MAXARGS) * 2
225 ; Buffer for command line / argv strings
227 ourcl: .res CL_SIZE+1