2 ; Freddy Offenga & Christian Groessler, December 2004
4 ; function to get default device: char *_getdefdev(void);
7 ; Default device number is derived from DUNIT. Therefore "default
8 ; device" is the one the program was loaded from.
11 ; the ZCRNAME routine is only used to get the default drive because
12 ; ZCRNAME has two disadvantages:
13 ; 1. It will convert D: into D1: instead of Dn: (n = default drive)
14 ; 2. It will give a 'no arguments' status if it detects something
15 ; like Dn: (without filename).
18 ; ZCRNAME is slightly different from SpartaDOS. It will convert D:
19 ; into Dn: where n is the default drive.
23 .export __getdefdev ; get default device
24 .export __defdev ; this is the default device string (e.g. "D1:")
26 .constructor __getdefdev, 24
29 ; Get default device (LBUF will be destroyed!!)
33 lda __dos_type ; which DOS?
35 beq xdos ; XDOS detected
36 ; cmp #OSADOS+1 ; (redundant: #OSADOS+1 = #XDOS)
37 bcs use_DUNIT ; neither XDOS, nor OS/A+ or SpartaDOS
41 sta (DOSVEC),y ; reset buffer offset
43 ; Store dummy argument
52 ; One extra store to avoid the buggy sequence from OS/A+ DOS:
53 ; <D><RETURN><:> => drive number = <RETURN>
58 ; Create crunch vector
71 ldy #COMFNAM ; COMFNAM is always "Dn:"
78 ; Return pointer to default device
80 finish: lda #<__defdev
84 ; On AtariDOS or MyDOS, use the DUNIT variable to setup the default
85 ; device. The default device will then be the one the program was
92 bne done ; jump always
94 ; XDOS default device retrieval
98 ; check XDOS version (we need >= 2.4)
101 cmp #$4C ; there needs to be a 'JMP' opcode here
102 bne finish ; older version, use DEFAULT_DEVICE or D1:
103 lda XVER ; get BCD encoded version ($24 for 2.4)
105 bcc finish ; too old, below 2.4
107 ; good XDOS version, get default drive
110 sta XLINE ; simulate empty command line
112 jsr XMOVE ; create an FMS filename (which in this case only contains the drive)
118 crvec: jmp $FFFF ; target address will be set to crunch vector
120 ; Default device string
123 .ifdef DEFAULT_DEVICE
124 .byte 'D', '0'+DEFAULT_DEVICE, ':', 0