]> git.sur5r.net Git - cc65/blob - libsrc/atari/sysrmdir.s
Merge pull request #24 from greg-king5/oric
[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         .include        "errno.inc"
12         .export         __sysrmdir
13         .import         __sysremove
14         .import         __dos_type
15         .import         findfreeiocb
16         .importzp       tmp4
17 .ifdef  UCASE_FILENAME
18         .import         ucase_fn
19         .import         addysp
20         .importzp       sreg
21         .importzp       tmp3
22 .ifdef  DEFAULT_DEVICE
23         .importzp tmp2
24 .endif
25 .endif
26
27 .proc   __sysrmdir
28
29         pha
30         lda     __dos_type
31         beq     not_impl                ; AtariDOS
32         cmp     #OSADOS+1
33         bcc     do_sparta               ; OS/A and SpartaDOS
34         pla
35         jmp     __sysremove             ; MyDOS and others (TODO: check XDOS)
36
37 not_impl:
38         pla
39         lda     #NVALID
40         rts
41
42 iocberr:
43         pla                             ; cleanup stack
44         pla
45         lda     #TMOF
46         rts
47
48 do_sparta:
49         txa
50         pha
51         jsr     findfreeiocb
52         bne     iocberr                 ; no IOCB available
53
54         stx     tmp4                    ; remember IOCB
55         pla
56         tax
57         pla
58
59 .ifdef  UCASE_FILENAME
60
61 .ifdef  DEFAULT_DEVICE
62         ldy     #$80
63         sty     tmp2            ; set flag for ucase_fn
64 .endif
65         jsr     ucase_fn
66         bcc     ucok1
67
68         lda     #183                    ; see oserror.s
69         rts
70 ucok1:
71
72 .endif  ; defined UCASE_FILENAME
73
74         ldy     tmp4                    ; IOCB index
75         sta     ICBAL,y                 ; store pointer to filename
76         txa
77         sta     ICBAH,y
78         tya
79         tax
80         lda     #RMDIR
81         sta     ICCOM,x
82         lda     #0
83         sta     ICAX1,x
84         lda     #0
85         sta     ICAX2,x
86         sta     ICBLL,x
87         sta     ICBLH,x
88         jsr     CIOV
89
90 .ifdef  UCASE_FILENAME
91         tya
92         pha
93         ldy     tmp3                    ; get size
94         jsr     addysp                  ; free used space on the stack
95         pla
96         tay
97 .endif  ; defined UCASE_FILENAME
98
99         bmi     cioerr
100         lda     #0
101         rts
102
103 cioerr: tya
104         rts
105
106 .endproc        ; __sysrmdir