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
24 lda __dos_type ; which DOS?
26 beq nargdos ; DOS does not support arguments
28 bne argdos ; DOS supports arguments
31 ; Initialize ourcl buffer
36 ; Move SpartaDOS command line to our own buffer
56 sta ourcl,y ; null terminate behind ATEOL
58 ; Turn command line into argv table
62 eatspc: lda ourcl,y ; eat spaces
66 bne rpar ; begin of argument found
70 beq finargs ; only spaces is no argument
72 ; Store argument vector
74 rpar: lda __argc ; low-byte
94 cpx #ATEOL ; end of line?
102 ; End of arg. -> place 0
108 cpx #ATEOL ; was it the last arg?
128 argv: .res (1 + MAXARGS) * 2
130 ; Buffer for command line / argv strings
132 ourcl: .res CL_SIZE+1