include	clib.inc
include	disk.inc
include	errno.inc

PPROC	_disk_test, disk:word
	invoke _disk_type, disk
	.if ax != _DISK_NOSUCHDRIVE
	    invoke _disk_ready, disk
	    .if ax
		mov ax,1
	    .elseif errno != ENOENT
		mov ax,-1
	    .else
		.while 1
	    	    invoke _disk_retry, disk
	    	    .if ax
	    	    	invoke _disk_ready, disk
	    	    	.break .if ax
	    	    .else
	    	    	mov ax,-1
	    	    	.break
	    	    .endif
		.endw
	    .endif
	.endif
	ret
PEND	_disk_test

	END
