]> git.sur5r.net Git - cc65/blob - libsrc/atari/syschdir.s
Removed (pretty inconsistently used) tab chars from source code base.
[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 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 .endif
19         .export __syschdir
20
21 .proc   __syschdir
22
23         pha                     ; save input parameter
24         txa
25         pha
26
27         jsr     findfreeiocb
28         beq     iocbok          ; we found one
29
30         pla
31         pla                     ; fix up stack
32
33         lda     #TMOF           ; too many open files
34         rts
35
36 iocbok: stx     tmp4            ; remember IOCB index
37         pla
38         tax
39         pla                     ; get argument again
40
41 .ifdef  UCASE_FILENAME
42
43         jsr     ucase_fn
44         bcc     ucok1
45
46         lda     #183            ; see oserror.s
47         rts
48 ucok1:
49
50 .endif  ; defined UCASE_FILENAME
51
52         ldy     tmp4            ; IOCB index
53         sta     ICBAL,y         ; store pointer to filename
54         txa
55         sta     ICBAH,y
56         tya
57         tax
58         lda     __dos_type
59         cmp     #SPARTADOS
60         beq     :+
61         lda     #41
62         .byte   $2C             ; BIT <abs>
63 :       lda     #44
64         sta     ICCOM,x
65         lda     #0
66         sta     ICAX1,x
67         sta     ICAX2,x
68         sta     ICBLL,x
69         sta     ICBLH,x
70         jsr     CIOV
71
72 .ifdef  UCASE_FILENAME
73         tya
74         pha
75         ldy     tmp3            ; get size
76         jsr     addysp          ; free used space on the stack
77         pla
78         tay
79 .endif  ; defined UCASE_FILENAME
80
81         bmi     cioerr
82         jsr     initcwd
83         lda     #0
84         rts
85 cioerr: tya
86         rts
87
88 .endproc        ; __syschdir