]> git.sur5r.net Git - cc65/blob - libsrc/cbm/scratch.s
e8ffad9d564a37a384f87edb29c3f58841f5a9b3
[cc65] / libsrc / cbm / scratch.s
1 ;
2 ; Ullrich von Bassewitz, 16.11.2002
3 ;
4 ; Scratch a file on disk
5 ;
6
7         .export         scratch
8         .import         readdiskerror
9         .import         fnunit, fnlen, fncmd
10
11         .include        "cbm.inc"
12
13 ;--------------------------------------------------------------------------
14 ; scratch: Scratch a file on disk. Expects the name of the file to be already
15 ; parsed. Returns an error code in A, which may either be the code read from
16 ; the command channel, or another error when accessing the command channel
17 ; failed.
18
19 .proc   scratch
20
21         lda     #15             ; Command channel
22         ldx     fnunit          ; Unit
23         tay                     ; Secondary address
24         jsr     SETLFS
25
26         lda     #'s'            ; Scratch command
27         sta     fncmd
28         ldx     fnlen
29         inx                     ; Account for "S"
30         txa                     ; Length of name into A
31         ldx     #<fncmd
32         ldy     #>fncmd
33         jsr     SETNAM
34
35         jsr     OPEN
36         bcs     done
37
38         jsr     readdiskerror   ; Read the command channel
39
40         pha
41         lda     #15
42         jsr     CLOSE
43         pla
44
45 done:   rts
46
47 .endproc
48
49