]> git.sur5r.net Git - cc65/blob - libsrc/atari/sysremove.s
a11af79fe870eac481b9ee957a9b09d287bb71b1
[cc65] / libsrc / atari / sysremove.s
1 ;
2 ; Christian Groessler, Aug-2003
3 ;
4 ; int remove (const char* name);
5 ;
6
7         .include "atari.inc"
8         .include "errno.inc"
9         .import findfreeiocb
10         .importzp tmp4
11 .ifdef  UCASE_FILENAME
12         .importzp tmp3
13         .import addysp
14         .import ucase_fn
15 .endif
16         .export __sysremove
17
18 .proc   __sysremove
19
20         pha                     ; save input parameter
21         txa
22         pha
23
24         jsr     findfreeiocb
25         beq     iocbok          ; we found one
26
27         pla
28         pla                     ; fix up stack
29
30         lda     #TMOF           ; too many open files
31         rts
32
33 iocbok: stx     tmp4            ; remember IOCB index
34         pla
35         tax
36         pla                     ; get argument again
37
38 .ifdef  UCASE_FILENAME
39
40         jsr     ucase_fn
41         bcc     ucok1
42
43         lda     #182            ; see oserror.s
44         rts
45 ucok1:
46
47 .endif  ; defined UCASE_FILENAME
48
49         ldy     tmp4            ; IOCB index
50         sta     ICBAL,y         ; store pointer to filename
51         txa
52         sta     ICBAH,y
53         tya
54         tax
55         lda     #DELETE
56         sta     ICCOM,x
57         lda     #0
58         sta     ICAX1,x
59         sta     ICAX2,x
60         sta     ICBLL,x
61         sta     ICBLH,x
62         jsr     CIOV
63
64 .ifdef  UCASE_FILENAME
65         tya
66         pha
67         ldy     tmp3            ; get size
68         jsr     addysp          ; free used space on the stack
69         pla
70         tay
71 .endif  ; defined UCASE_FILENAME
72
73         bmi     cioerr
74         lda     #0
75         rts
76 cioerr: tya
77         rts
78
79 .endproc        ; __sysremove