]> git.sur5r.net Git - cc65/blob - libsrc/cbm/scratch.s
Added getenv()
[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         opencmdchannel, closecmdchannel, writediskcmd
9         .import         fnunit, fnlen, fncmd
10         .importzp       ptr1
11
12         .include        "cbm.inc"
13
14 ;--------------------------------------------------------------------------
15 ; scratch: Scratch a file on disk. Expects the name of the file to be already
16 ; parsed. Returns an error code in A, which may either be the code read from
17 ; the command channel, or another error when accessing the command channel
18 ; failed.
19
20 .proc   scratch
21
22         ldx     fnunit
23         jsr     opencmdchannel
24         bne     done
25
26         lda     #'s'            ; Scratch command
27         sta     fncmd
28
29         lda     #<fncmd
30         sta     ptr1
31         lda     #>fncmd
32         sta     ptr1+1
33
34         ldx     fnlen
35         inx                     ; Account for "S"
36         txa                     ; Length of name into A
37         ldx     fnunit          ; Unit
38         jsr     writediskcmd
39
40         pha
41         ldx     fnunit
42         jsr     closecmdchannel
43         pla
44
45 done:   rts
46
47 .endproc
48
49