2003-03-10 21:21:46 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2003-03-07
|
2003-05-02 20:16:32 +00:00
|
|
|
; Maciej Witkowiak, 2003-05-02
|
2003-03-10 21:21:46 +00:00
|
|
|
;
|
|
|
|
; Setup arguments for main
|
|
|
|
;
|
2003-05-02 20:16:32 +00:00
|
|
|
; There is always either 1 or 3 arguments:
|
2016-03-16 15:28:32 +00:00
|
|
|
; <program name>, 0
|
2003-05-02 20:16:32 +00:00
|
|
|
; or
|
|
|
|
; <program name>, <data file name>, <data disk name>, 0
|
|
|
|
; the 2nd case is when using DeskTop user drags an icon of a file and drops it
|
|
|
|
; on icon of your application
|
|
|
|
;
|
2003-03-10 21:21:46 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.constructor initmainargs, 24
|
|
|
|
.import __argc, __argv
|
2003-03-10 21:21:46 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "const.inc"
|
|
|
|
.include "geossym.inc"
|
2003-03-10 21:21:46 +00:00
|
|
|
|
2016-03-06 20:26:22 +00:00
|
|
|
.segment "ONCE"
|
2005-02-26 09:28:46 +00:00
|
|
|
|
2012-02-08 16:56:54 +00:00
|
|
|
; Setup arguments for main
|
2003-03-10 21:21:46 +00:00
|
|
|
|
2012-02-08 16:56:54 +00:00
|
|
|
initmainargs:
|
2003-05-02 20:16:32 +00:00
|
|
|
; Setup a pointer to our argv vector
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #<argv
|
|
|
|
sta __argv
|
|
|
|
lda #>argv
|
|
|
|
sta __argv+1
|
2003-05-02 20:16:32 +00:00
|
|
|
|
|
|
|
; Copy program name
|
2013-05-09 11:56:54 +00:00
|
|
|
ldy #0
|
2003-05-02 20:16:32 +00:00
|
|
|
@fn_loop:
|
2013-05-09 11:56:54 +00:00
|
|
|
lda dirEntryBuf+OFF_FNAME,y
|
2012-02-22 22:59:38 +00:00
|
|
|
.ifdef __GEOS_CBM__
|
2013-05-09 11:56:54 +00:00
|
|
|
cmp #$a0
|
2012-02-07 16:14:23 +00:00
|
|
|
.else
|
2013-05-09 11:56:54 +00:00
|
|
|
cmp #0
|
2012-02-07 16:14:23 +00:00
|
|
|
.endif
|
2013-05-09 11:56:54 +00:00
|
|
|
beq @fn_end
|
|
|
|
sta argv0,y
|
|
|
|
iny
|
|
|
|
cpy #16+1
|
|
|
|
bne @fn_loop
|
2003-05-02 20:16:32 +00:00
|
|
|
@fn_end:
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #0
|
|
|
|
sta argv0,y
|
|
|
|
sta __argc+1
|
2003-05-02 20:16:32 +00:00
|
|
|
|
|
|
|
; Check if there are any more arguments
|
2013-05-09 11:56:54 +00:00
|
|
|
lda dataFileName
|
|
|
|
bne @threeargs
|
|
|
|
ldx #0 ; no dataFileName - NULL the 2nd argument
|
|
|
|
stx argv+2
|
|
|
|
stx argv+3
|
|
|
|
inx ; there is only one argument
|
|
|
|
bne @setargc
|
2003-05-02 20:16:32 +00:00
|
|
|
@threeargs:
|
2013-05-09 11:56:54 +00:00
|
|
|
ldx #3 ; there are three arguments
|
2003-05-02 20:16:32 +00:00
|
|
|
@setargc:
|
2013-05-09 11:56:54 +00:00
|
|
|
stx __argc
|
|
|
|
rts
|
2003-05-02 20:16:32 +00:00
|
|
|
|
|
|
|
.data
|
|
|
|
|
2012-02-08 16:56:54 +00:00
|
|
|
argv:
|
2013-05-09 11:56:54 +00:00
|
|
|
.word argv0 ; Pointer to program name
|
|
|
|
.word dataFileName ; dataFileName or NULL if last one
|
|
|
|
.word dataDiskName ; dataDiskName
|
|
|
|
.word $0000 ; last one must be NULL
|
2003-03-10 21:21:46 +00:00
|
|
|
|
2016-03-16 15:28:32 +00:00
|
|
|
.segment "INIT"
|
2012-02-08 16:56:54 +00:00
|
|
|
|
|
|
|
argv0:
|
2013-05-09 11:56:54 +00:00
|
|
|
.res 17 ; Program name
|