]> git.sur5r.net Git - cc65/blob - libsrc/cbm/diskinit.s
Shorten a URL.
[cc65] / libsrc / cbm / diskinit.s
1 ;
2 ; Oliver Schmidt, 2012-10-17
3 ;
4
5         .export         diskinit
6         .import         opencmdchannel, closecmdchannel
7         .import         writefndiskcmd, readdiskerror
8         .import         isdisk, fnunit, fncmd
9
10 ;------------------------------------------------------------------------------
11 ; diskinit
12
13 .proc   diskinit
14
15 ; Save device
16
17         sta     fnunit
18
19 ; Check for disk device
20
21         tax
22         jsr     isdisk
23         bcc     open
24         lda     #9              ; "Illegal device"
25         rts
26
27 ; Open channel
28
29 open:   jsr     opencmdchannel
30         bne     done
31
32 ; Write command
33
34         lda     #'i'            ; Init command
35         sta     fncmd
36         jsr     writefndiskcmd
37         bne     close
38
39 ; Read error
40
41         ldx     fnunit
42         jsr     readdiskerror
43
44 ; Close channel
45
46 close:  pha
47         ldx     fnunit
48         jsr     closecmdchannel
49         pla
50
51 done:   rts
52
53 .endproc