2 ; Ullrich von Bassewitz, 2003-03-07
4 ; Setup arguments for main.
5 ; Based on code from Stefan A. Haubenthal, <polluks@web.de>
9 .constructor initmainargs, 24
10 .import __argc, __argv
14 ;---------------------------------------------------------------------------
15 ; Setup arguments for main
19 ; Setup a pointer to our argv vector
26 ; Save the last filename as argument #0. Since the buffer we're copying into
27 ; is zeroed out, we don't need to add a NUL character.
32 ldy #16 ; Limit the length
38 inc __argc ; __argc = 1
40 ; Find argument in BASIC buffer, if found, use it as arg #1
48 sty argv+2 ; Store offset
60 ;---------------------------------------------------------------------------
65 argv: .word argv0 ; Pointer to program name
66 .word $0000 ; Optional second argument
67 .word $0000 ; Last vector must always be NULL
70 argv0: .res 17 ; Program name