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