include	clib.inc
include	disk.inc

PPROC	_disk_type, disk:word
	mov dx,disk
	.if dl <= 1
	    mov ah,15h 		; GET DISK TYPE
	    int 13h
	    .if CARRY? || !ah
		xor ax,ax
	    .elseif disk == 1	; remapped B drive ?
		mov bx,disk
		inc bx
		mov ax,440Eh
		int 21h		; IOCTL - GET LOGICAL DRIVE MAP
		.if al
		    xor ax,ax
		.else
		    mov ax,_DISK_FLOPPY
		.endif
	    .else
		mov ax,_DISK_FLOPPY
	    .endif
	.else
	    mov bx,dx
	    inc bx
	    mov ax,4409h	; IOCTL - CHECK IF BLOCK DEVICE REMOTE
	    int 21h
	    .if CARRY?
		xor ax,ax
	    .elseif dh & 80h	; bit 15: drive is SUBSTituted
		mov ax,_DISK_SUBST
	    .elseif dh & 10h	; bit 12: drive is remote
		mov ax,_DISK_NETWORK
	    .else
		mov ax,_DISK_LOCAL
	    .endif
	.endif
	ret
PEND	_disk_type

	END
