home *** CD-ROM | disk | FTP | other *** search
- ; Drives.asm
-
- ; Contains 2 functions:
-
- ; Syntax : DrvType( <N>)
- ; Purpose : To determine the type of floppy disk drive.
- ; Parameter: <N> 0 = 1st diskette drive (A:), 1 = 2nd (B:), etc.
- ; Return : <N> 0 = error or no such floppy drive
- ; 1 = 360 floppy drive
- ; 2 = 1.2 mb floppy
- ; 3 = 720k floppy
- ; 4 = 1.44mb floppy
-
- ; Syntax : DrvNum()
- ; Purpose : To determine the number of floppy drives.
- ; Parameter: None.
- ; Return : <N> Number of floppy drives.
- ;-----------------------------------------------------
-
- EXTRN __PARNI:far
- EXTRN __RETNI:far
-
- PUBLIC DrvType, DrvNum
-
- DGROUP GROUP DATASG ; Combine my data segment with Clipper's.
-
- DATASG SEGMENT 'DATA' ; Start of data segment.
-
- numdrvs db 0 ; number of floppy drives.
-
- DATASG ENDS ; End of data segment.
-
-
- ASM_TEXT segment byte public 'CODE'
- ASSUME cs:ASM_TEXT, DS:DGROUP
-
-
-
- DrvType PROC FAR
-
- push bp
- mov bp,sp
- push es
- push di
-
- call GetNumdrvs ; Determine # of floppy drives.
-
- mov ax, 1 ; Which one do we want to check?
- push ax
- call __PARNI
- add sp, 2
-
- cmp numdrvs, al ; Was a valid drive requested?
- jb NoCanDo ; No. Jump to end.
-
- mov dl, al ; Move selected drive # to DL
- ; in prep. for int 13h
- Retry:
- mov ah, 08 ; Function: Get current drive params
- int 13h ; Disk I/O services
- jnc Done ; Finished
-
- cmp ah, 06h ; Has diskette changed?
- jne NoCanDo ; No. Error condition.
- mov ah, 0 ; Reset the disk
- int 13h
- jmp Retry ; Retry
-
- NoCanDo:
- mov bl, 0 ; Set return value to error condition.
- Done:
- xor bh, bh ; blank out the high byte
- push bx ; Return result to Clipper via Extend
- call __RETNI
- add sp, 2
-
- pop di
- pop es
- pop bp
- ret
-
- DrvType endp
-
- DrvNum proc far
- push bp
- mov bp,sp
- push es
- push di
-
- call GetNumdrvs ; Determine # of floppy drives.
- inc numdrvs ; Function GetNumdrvs returns 1 less
- ; than actual number of drives.
- mov al, numdrvs ; Return via Extend.
- xor ah, ah
- push ax
- call __RETNI
- add sp, 2
-
- pop di
- pop es
- pop bp
- ret
- DrvNum endp
-
- GetNumdrvs proc near
- mov ax, 0040h ; Necessary because immediate mode
- ; not legal with ES.
- mov es, ax ; Segment of equipment list
- mov ax, ES:[0010h] ; Move equipment list to AX
- mov bx, ax ; Store it for later.
- test al, 1 ; Isolate bit 0 to determine if there are any floppies.
- jz NoCanDo ; No, finished.
-
- and bl, 192 ; Find # of floppy drives by
- ; stripping all bits except
- ; 6 and 7.
- mov cl, 6 ; Set number of bits to shift.
- shr bl, cl ; Shift right 6 bits so that bits
- ; 6 & 7 are now in bits 0 & 1.
- mov numdrvs, bl ; Store # of drives (minus 1) in variable.
-
- ret
- GetNumdrvs endp
-
- ASM_TEXT ENDS
- END
-
-