]> git.sur5r.net Git - cc65/blob - libsrc/atari/getdefdev.s
92db7484823444cc6389138c971b7e226e7d5a6b
[cc65] / libsrc / atari / getdefdev.s
1 ;
2 ; Freddy Offenga & Christian Groessler, June 2004
3 ;
4 ; function to get default device: char *_getdefdev(void);
5 ;
6 ; SpartaDOS:
7 ; the ZCRNAME routine is only used to get the default drive because
8 ; ZCRNAME has two disadvantages:
9 ; 1. It will convert D: into D1: instead of Dn: (n = default drive)
10 ; 2. It will give a 'no arguments' status if it detects something
11 ;    like Dn: (without filename).
12 ;
13 ; OS/A+ DOS:
14 ; ZCRNAME is slightly different from SpartaDOS. It will convert D:
15 ; into Dn: where n is the default drive.
16
17         .include        "atari.inc"
18         .import         __dos_type
19         .export         __getdefdev             ; get default device (e.g. "D1:")
20
21 ; Get default device (LBUF will be destroyed!!)
22
23 __getdefdev:
24
25         lda     __dos_type      ; which DOS?
26         cmp     #ATARIDOS
27         beq     finish
28         cmp     #MYDOS
29         beq     finish
30
31         ldy     #BUFOFF
32         lda     #0
33         sta     (DOSVEC),y      ; reset buffer offset
34
35 ; Store dummy argument
36
37         ldy     #LBUF
38         lda     #'X'
39         sta     (DOSVEC),y
40         iny
41         lda     #ATEOL
42         sta     (DOSVEC),y
43
44 ; One extra store to avoid the buggy sequence from OS/A+ DOS:
45 ; <D><RETURN><:> => drive number = <RETURN>
46
47         iny
48         sta     (DOSVEC),y
49
50 ; Create crunch vector
51
52         ldy     #ZCRNAME+1
53         lda     (DOSVEC),y
54         sta     crvec+1
55         iny
56         lda     (DOSVEC),y
57         sta     crvec+2
58
59 crvec:  jsr     $FFFF           ; will be set to crunch vector
60
61 ; Get default device
62
63         ldy     #COMFNAM        ;  COMFNAM is always "Dn:"
64         lda     (DOSVEC),y
65         sta     defdev
66         iny
67         lda     (DOSVEC),y
68         sta     defdev+1
69
70 ; return ointer to default device
71
72 finish: lda     #<defdev
73         ldx     #>defdev
74         rts
75
76         .data
77
78 ; Default device
79
80 defdev:
81         .byte   "D1:", 0
82