2 ; 2003-03-07, Ullrich von Bassewitz
3 ; 2011-01-28, Stefan Haubenthal
4 ; 2014-09-10, Greg King
6 ; Set up arguments for main
9 .constructor initmainargs, 24
10 .import __argc, __argv
12 .include "telestrat.inc"
15 MAXARGS = 10 ; Maximum number of arguments allowed
21 ; Assume that the program was loaded, a moment ago, by the traditional LOAD
22 ; statement. Save the "most-recent filename" as argument #0.
25 ldx #0 ; Limit the length
39 inc __argc ; argc always is equal to, at least, 1
42 ldy #1 * 2 ; Point to second argv slot
45 beq done ; End of line reached
47 cmp #' ' ; Skip leading spaces
50 found: cmp #'"' ; Is the argument quoted?
51 beq setterm ; Jump if so
52 dex ; Reset pointer to first argument character
54 lda #' ' ; A space ends the argument
55 setterm:sta term ; Set end of argument marker
57 ; Now, store a pointer, to the argument, into the next slot.
65 sta argv,y ; argv[y]=&arg
71 inc __argc ; Found another arg
73 ; Search for the end of the argument
83 ; We've found the end of the argument. X points one character behind it, and
84 ; A contains the terminating character. To make the argument a valid C string,
85 ; replace the terminating character by a zero.
90 ; Check if the maximum number of command line arguments is reached. If not,
93 lda __argc ; Get low byte of argument count
94 cmp #MAXARGS ; Maximum number of arguments reached?
95 bcc next ; Parse next one if not
112 name: .res FNAME_LEN + 1
113 args: .res SCREEN_XSIZE * 2 - 1
117 ; char* argv[MAXARGS+1]={name};