support for arguments (with DeskTop drag&drop feature)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2133 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
55d0596aba
commit
2c825f2bb3
1 changed files with 57 additions and 1 deletions
|
@ -1,21 +1,77 @@
|
||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 2003-03-07
|
; Ullrich von Bassewitz, 2003-03-07
|
||||||
|
; Maciej Witkowiak, 2003-05-02
|
||||||
;
|
;
|
||||||
; Setup arguments for main
|
; Setup arguments for main
|
||||||
;
|
;
|
||||||
|
; There is always either 1 or 3 arguments:
|
||||||
|
; <program name>,0
|
||||||
|
; 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
|
||||||
|
;
|
||||||
|
|
||||||
.constructor initmainargs, 24
|
.constructor initmainargs, 24
|
||||||
.import __argc, __argv
|
.import __argc, __argv
|
||||||
|
|
||||||
|
.include "../inc/const.inc"
|
||||||
|
.include "../inc/geossym.inc"
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;---------------------------------------------------------------------------
|
||||||
; Setup arguments for main
|
; Setup arguments for main
|
||||||
|
|
||||||
.proc initmainargs
|
.proc initmainargs
|
||||||
|
|
||||||
|
; Setup a pointer to our argv vector
|
||||||
|
|
||||||
|
lda #<argv
|
||||||
|
sta __argv
|
||||||
|
lda #>argv
|
||||||
|
sta __argv+1
|
||||||
|
|
||||||
|
; Copy program name
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
@fn_loop:
|
||||||
|
lda dirEntryBuf+OFF_FNAME,y
|
||||||
|
cmp #$a0
|
||||||
|
beq @fn_end
|
||||||
|
sta argv0,y
|
||||||
|
iny
|
||||||
|
cpy #16
|
||||||
|
bne @fn_loop
|
||||||
|
@fn_end:
|
||||||
|
lda #0
|
||||||
|
sta argv0,y
|
||||||
|
sta __argc+1
|
||||||
|
|
||||||
|
; Check if there are any more arguments
|
||||||
|
|
||||||
|
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
|
||||||
|
@threeargs:
|
||||||
|
ldx #3 ; there are three arguments
|
||||||
|
@setargc:
|
||||||
|
stx __argc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------------
|
||||||
|
; Data
|
||||||
|
|
||||||
|
.data
|
||||||
|
|
||||||
|
argv: .word argv0 ; Pointer to program name
|
||||||
|
.word dataFileName ; dataFileName or NULL if last one
|
||||||
|
.word dataDiskName ; dataDiskName
|
||||||
|
.word $0000 ; last one must be NULL
|
||||||
|
|
||||||
|
.bss
|
||||||
|
argv0: .res 17 ; Program name
|
||||||
|
|
Loading…
Add table
Reference in a new issue