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 "telemon30.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
26 ; lda #0 ; The terminating NUL character
27 ; beq L1 ; Branch always
41 inc __argc ; argc always is equal to, at least, 1
47 ldy #1 * 2 ; Point to second argv slot
50 beq done ; End of line reached
52 cmp #' ' ; Skip leading spaces
59 found: cmp #'"' ; Is the argument quoted?
60 beq setterm ; Jump if so
61 dex ; Reset pointer to first argument character
64 lda #' ' ; A space ends the argument
65 setterm:sta term ; Set end of argument marker
67 ; Now, store a pointer, to the argument, into the next slot.
76 sta argv,y ; argv[y]=&arg
83 inc __argc ; Found another arg
85 ; Search for the end of the argument
95 ; We've found the end of the argument. X points one character behind it, and
96 ; A contains the terminating character. To make the argument a valid C string,
97 ; replace the terminating character by a zero.
102 ; Check if the maximum number of command line arguments is reached. If not,
103 ; parse the next one.
105 lda __argc ; Get low byte of argument count
106 cmp #MAXARGS ; Maximum number of arguments reached?
107 bcc next ; Parse next one if not
127 name: .res FNAME_LEN + 1
128 args: .res SCREEN_XSIZE * 2 - 1
134 ; char* argv[MAXARGS+1]={name};