]> git.sur5r.net Git - cc65/blob - libsrc/atari/getdefdev.s
adapt to new value of dummy error code
[cc65] / libsrc / atari / getdefdev.s
1 ;
2 ; Freddy Offenga & Christian Groessler, August 2003
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
29         ldy     #BUFOFF
30         lda     #0
31         sta     (DOSVEC),y      ; reset buffer offset
32
33 ; Store dummy argument
34
35         ldy     #LBUF
36         lda     #'X'
37         sta     (DOSVEC),y
38         iny
39         lda     #ATEOL
40         sta     (DOSVEC),y
41
42 ; One extra store to avoid the buggy sequence from OS/A+ DOS:
43 ; <D><RETURN><:> => drive number = <RETURN>
44
45         iny
46         sta     (DOSVEC),y
47
48 ; Create crunch vector
49
50         ldy     #ZCRNAME+1
51         lda     (DOSVEC),y
52         sta     crvec+1
53         iny
54         lda     (DOSVEC),y
55         sta     crvec+2
56
57 crvec:  jsr     $FFFF           ; will be set to crunch vector
58
59 ; Get default device
60
61         ldy     #COMFNAM        ;  COMFNAM is always "Dn:"
62         lda     (DOSVEC),y
63         sta     defdev
64         iny
65         lda     (DOSVEC),y
66         sta     defdev+1
67
68 ; return ointer to default device
69
70 finish: lda     #<defdev
71         ldx     #>defdev
72         rts
73
74         .data
75
76 ; Default device
77
78 defdev:
79         .byte   "D1:", 0
80