]> git.sur5r.net Git - cc65/blob - libsrc/atari/syschdir.s
Fixed _textcolor definition.
[cc65] / libsrc / atari / syschdir.s
1 ;
2 ; Stefan Haubenthal, 2005-12-24
3 ; Based on on code by Christian Groessler
4 ;
5 ; unsigned char __fastcall__ _syschdir (const char* name);
6 ; for SpartaDOS, RealDOS, and MyDOS
7 ;
8
9         .include "atari.inc"
10         .import findfreeiocb
11         .import __dos_type
12         .import initcwd
13         .importzp tmp4
14 .ifdef  UCASE_FILENAME
15         .importzp tmp3
16         .import addysp
17         .import ucase_fn
18 .ifdef  DEFAULT_DEVICE
19         .importzp tmp2
20 .endif
21 .endif
22         .export __syschdir
23
24 .proc   __syschdir
25
26         pha                     ; save input parameter
27         txa
28         pha
29
30         jsr     findfreeiocb
31         beq     iocbok          ; we found one
32
33         pla
34         pla                     ; fix up stack
35
36         lda     #TMOF           ; too many open files
37         rts
38
39 iocbok: stx     tmp4            ; remember IOCB index
40         pla
41         tax
42         pla                     ; get argument again
43
44 .ifdef  UCASE_FILENAME
45
46 .ifdef  DEFAULT_DEVICE
47         ldy     #$80
48         sty     tmp2            ; set flag for ucase_fn
49 .endif
50         jsr     ucase_fn
51         bcc     ucok1
52
53         lda     #183            ; see oserror.s
54         rts
55 ucok1:
56
57 .endif  ; defined UCASE_FILENAME
58
59         ldy     tmp4            ; IOCB index
60         sta     ICBAL,y         ; store pointer to filename
61         txa
62         sta     ICBAH,y
63         tya
64         tax
65         lda     __dos_type
66         cmp     #SPARTADOS
67         beq     :+
68         cmp     #REALDOS
69         beq     :+
70         cmp     #BWDOS
71         beq     :+
72         lda     #CHDIR_MYDOS
73         .byte   $2C             ; BIT <abs>
74 :       lda     #CHDIR_SPDOS
75         sta     ICCOM,x
76         lda     #0
77         sta     ICAX1,x
78         sta     ICAX2,x
79         sta     ICBLL,x
80         sta     ICBLH,x
81         jsr     CIOV
82
83 .ifdef  UCASE_FILENAME
84         tya
85         pha
86         ldy     tmp3            ; get size
87         jsr     addysp          ; free used space on the stack
88         pla
89         tay
90 .endif  ; defined UCASE_FILENAME
91
92         bmi     cioerr
93         jsr     initcwd
94         lda     #0
95         rts
96 cioerr: tya
97         rts
98
99 .endproc        ; __syschdir