$CPU 8086 ' make compatible with XT systems $LIB ALL OFF ' turn off all PowerBASIC libraries $ERROR ALL OFF ' turn off all PowerBASIC error checking $OPTIMIZE SIZE ' optimize for smaller code $COMPILE UNIT ' compile to a UNIT (.PBU) '$COMPILE EXE ' compile to a UNIT (.PBU) DEFINT A-Z ' Required for all numeric functions, forces PB to not ' include floating point in UNIT (makes it smaller) '/*------------------------------------------------------------------*/ $CODE SEG "MLIB5" '/*------------------------------------------------------------------*/ FUNCTION ISDRIVEREADY( BYVAL Drive$ ) PUBLIC AS INTEGER ' This FUNCTION returns -1 (true) if the drive is ready, or 0 (false), ' if the drive is not ready, or the drive letter is an invalid drive. ' It will NOT recognize a CD-ROM drive as being ready. DIM DriveNum AS LOCAL INTEGER DIM DriveIsReady AS LOCAL INTEGER DriveNum = ( ASC( Drive$ ) OR 32 ) - 97 DriveIsReady = -1 'assume drive will be ready ! push DS ! xor AX, AX ! mov DX, DriveNum ; zero - based drive numbering used ! int &H13 ; CALL BIOS TO RESET the drive controller ! mov AX, &H401 ! mov CX, &H101 ! mov DX, DriveNum ! int &H13 ! mov AX, &H401 ! mov CX, &H101 ! mov DX, DriveNum ! int &H13 ! jnc DriveOK ; carry set could be a fixed disk ! mov AH, &H1C ; so LET us look, USING DOS ! mov DX, DriveNum ! inc DX ; one - based drive numbering used ! int &H21 ! cmp DX, &HFF ! je DriveOK ! mov AX, [BX] ! cmp AX, &HF8 ! je DriveOK ! mov DriveIsReady, 0 DriveOK: ! pop DS DriveReady = DriveIsReady IF DriveReady = -1 THEN FUNCTION = 1 ELSE FUNCTION = 0 END FUNCTION '/*------------------------------------------------------------------*/ ' $INCLUDE "C:\CODE\MLIB\MLIB.INC" ' CLS ' PRINT "CHECKING DRIVE A = " ISDRIVEREADY("A") ' PRINT "CHECKING DRIVE C = " ISDRIVEREADY("C") ' Y$ = GETKEY ' PRINT "CHECKING DRIVE A = " ISDRIVEREADY("A") ' Y$ = GETKEY