]> git.sur5r.net Git - cc65/blob - libsrc/apple2/initcwd.s
Place initcwd in the INIT segment
[cc65] / libsrc / apple2 / initcwd.s
1 ;
2 ; Oliver Schmidt, 18.04.2005
3 ;
4
5         .export         initcwd
6         .import         __cwd
7
8         .include        "zeropage.inc"
9         .include        "mli.inc"
10
11         .segment        "INIT"
12         
13 initcwd:
14         ; Use imported buffer
15         lda     #<__cwd
16         ldx     #>__cwd
17         sta     mliparam + MLI::PREFIX::PATHNAME
18         stx     mliparam + MLI::PREFIX::PATHNAME+1
19
20         ; Get current working directory
21         lda     #GET_PREFIX_CALL
22         ldx     #PREFIX_COUNT
23         jsr     callmli
24
25         ; Check length byte
26         ldx     __cwd
27         beq     done
28
29         ; Replace trailing slash with zero
30         sta     __cwd,x         ; A = 0
31
32         ; Remove length byte
33         tax
34 :       inx
35         lda     __cwd,x
36         sta     __cwd-1,x
37         bne     :-
38
39 done:   rts