]> git.sur5r.net Git - cc65/blob - libsrc/atari/sysrmdir.s
Merge remote-tracking branch 'upstream/master' into creativision
[cc65] / libsrc / atari / sysrmdir.s
1 ;
2 ; Stefan Haubenthal, 2005-12-24
3 ; Christian Groessler, 2013-07-16
4 ;
5 ; unsigned char __fastcall__ _sysrmdir (const char* name);
6 ;
7 ; for SpartaDOS and MyDOS
8 ;
9
10         .include        "atari.inc"
11         .export         __sysrmdir
12         .import         __sysremove
13         .import         __dos_type
14         .import         findfreeiocb
15         .importzp       tmp4
16 .ifdef  UCASE_FILENAME
17         .import         ucase_fn
18         .import         addysp
19         .importzp       tmp3
20 .ifdef  DEFAULT_DEVICE
21         .importzp tmp2
22 .endif
23 .endif
24
25 .proc   __sysrmdir
26
27         pha
28         lda     __dos_type
29         cmp     #OSADOS+1
30         bcc     do_sparta               ; OS/A and SpartaDOS
31         cmp     #MYDOS
32         bne     not_impl                ; neither MyDOS, OS/A, nor SpartaDOS
33         pla
34         jmp     __sysremove             ; MyDOS
35
36 not_impl:
37         pla
38         lda     #NVALID
39         rts
40
41 iocberr:
42         pla                             ; cleanup stack
43         pla
44         lda     #TMOF
45         rts
46
47 do_sparta:
48         txa
49         pha
50         jsr     findfreeiocb
51         bne     iocberr                 ; no IOCB available
52
53         stx     tmp4                    ; remember IOCB
54         pla
55         tax
56         pla
57
58 .ifdef  UCASE_FILENAME
59
60 .ifdef  DEFAULT_DEVICE
61         ldy     #$80
62         sty     tmp2            ; set flag for ucase_fn
63 .endif
64         jsr     ucase_fn
65         bcc     ucok1
66
67         lda     #183                    ; see oserror.s
68         rts
69 ucok1:
70
71 .endif  ; defined UCASE_FILENAME
72
73         ldy     tmp4                    ; IOCB index
74         sta     ICBAL,y                 ; store pointer to filename
75         txa
76         sta     ICBAH,y
77         tya
78         tax
79         lda     #RMDIR
80         sta     ICCOM,x
81         lda     #0
82         sta     ICAX1,x
83         lda     #0
84         sta     ICAX2,x
85         sta     ICBLL,x
86         sta     ICBLH,x
87         jsr     CIOV
88
89 .ifdef  UCASE_FILENAME
90         tya
91         pha
92         ldy     tmp3                    ; get size
93         jsr     addysp                  ; free used space on the stack
94         pla
95         tay
96 .endif  ; defined UCASE_FILENAME
97
98         bmi     cioerr
99         lda     #0
100         rts
101
102 cioerr: tya
103         rts
104
105 .endproc        ; __sysrmdir