1 ; get arguments from command line (when DOS supports it)
3 ; Freddy Offenga, 4/21/2000
5 MAXARGS = 16 ; max. amount of arguments in arg. table
6 CL_SIZE = 64 ; command line buffer size
7 SPACE = 32 ; SPACE char.
10 .import __argc, __argv
13 .constructor initmainargs,25
15 ; --------------------------------------------------------------------------
27 lda __dos_type ; which DOS?
29 beq nargdos ; DOS does not support arguments
31 bne argdos ; DOS supports arguments
34 ; Initialize ourcl buffer
39 ; Move SpartaDOS command line to our own buffer
59 sta ourcl,y ; null terminate behind ATEOL
61 ; Turn command line into argv table
65 eatspc: lda ourcl,y ; eat spaces
69 bne rpar ; begin of argument found
73 beq finargs ; only spaces is no argument
75 ; Store argument vector
77 rpar: lda __argc ; low-byte
97 cpx #ATEOL ; end of line?
105 ; End of arg. -> place 0
111 cpx #ATEOL ; was it the last arg?
129 ; --------------------------------------------------------------------------
134 argv: .res (1 + MAXARGS) * 2
136 ; Buffer for command line / argv strings
138 ourcl: .res CL_SIZE+1