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