]> git.sur5r.net Git - cc65/blob - libsrc/atari/sysmkdir.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / atari / sysmkdir.s
1 ;
2 ; Initial version: Stefan Haubenthal, 2005-12-24
3 ; Some fixes: Christian Groessler, 2009-01-28
4 ;
5 ; unsigned char _sysmkdir (const char* name, ...);
6 ; for SpartaDOS and MYDOS
7 ;
8
9         .include "atari.inc"
10         .include "errno.inc"
11         .import addysp
12         .import popax
13         .import findfreeiocb
14         .importzp tmp4
15 .ifdef  UCASE_FILENAME
16         .importzp tmp3
17         .import ucase_fn
18 .endif
19         .export __sysmkdir
20
21 .proc   __sysmkdir
22
23         dey                     ; parm count < 2 shouldn't be needed to be...
24         dey                     ; ...checked (it generates a C compiler warning)
25         beq     parmok          ; branch if parameter count ok
26         jsr     addysp          ; fix stack, throw away unused parameters
27
28 parmok: jsr     popax           ; get name
29         pha                     ; save input parameter
30         txa
31         pha
32
33         jsr     findfreeiocb
34         beq     iocbok          ; we found one
35
36         pla
37         pla                     ; fix up stack
38
39         lda     #TMOF           ; too many open files
40         rts
41
42 iocbok: stx     tmp4            ; remember IOCB index
43         pla
44         tax
45         pla                     ; get argument again
46
47 .ifdef  UCASE_FILENAME
48
49         jsr     ucase_fn
50         bcc     ucok1
51
52         lda     #183            ; see oserror.s
53         rts
54 ucok1:
55
56 .endif  ; defined UCASE_FILENAME
57
58         ldy     tmp4            ; IOCB index
59         sta     ICBAL,y         ; store pointer to filename
60         txa
61         sta     ICBAH,y
62         tya
63         tax
64         lda     #42
65         sta     ICCOM,x
66         lda     #8
67         sta     ICAX1,x
68         lda     #0
69         sta     ICAX2,x
70         sta     ICBLL,x
71         sta     ICBLH,x
72         jsr     CIOV
73
74 .ifdef  UCASE_FILENAME
75         tya
76         pha
77         ldy     tmp3            ; get size
78         jsr     addysp          ; free used space on the stack
79         pla
80         tay
81 .endif  ; defined UCASE_FILENAME
82
83         bmi     cioerr
84         lda     #0
85         rts
86 cioerr: tya
87         rts
88
89 .endproc        ; __sysmkdir