]> git.sur5r.net Git - cc65/blob - libsrc/apple2/initcwd.s
Update from Oliver Schmidt
[cc65] / libsrc / apple2 / initcwd.s
1 ;
2 ; Oliver Schmidt, 18.04.2005
3 ;
4
5         .export         initcwd
6         .import         __cwd
7         .import         subysp, addysp
8
9         .include        "zeropage.inc"
10         .include        "mli.inc"
11
12         .segment        "INIT"
13
14 initcwd:
15         ; Alloc prefix buffer
16         ldy     #1 + 64+1       ; Length byte + max pathname length+trailing slash
17         jsr     subysp
18
19         ; Use allocated prefix buffer
20         lda     sp
21         ldx     sp+1
22         sta     mliparam + MLI::PREFIX::PATHNAME
23         stx     mliparam + MLI::PREFIX::PATHNAME+1
24
25         ; Get current working directory
26         lda     #GET_PREFIX_CALL
27         ldx     #PREFIX_COUNT
28         jsr     callmli
29         bcs     done
30
31         ; Check for null prefix
32         ldy     #$00
33         lda     (sp),y
34         beq     done
35
36         ; Set current working directory
37         ; - omit trailing slash and length byte
38         ; - terminating zero already in place
39         tay
40         dey
41 :       lda     (sp),y
42         sta     __cwd-1,y
43         dey
44         bne     :-
45
46         ; Cleanup stack
47 done:   ldy     #1 + 64+1       ; Length byte + max pathname length+trailing slash
48         jmp     addysp
49