Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 429)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 433)
@@ -38,6 +38,14 @@
 ;--------------------------------------------------------------------
 AH0h_HandlerForDiskControllerReset:
-	eMOVZX	bx, dl						; Copy requested drive to BL, zero BH to assume no errors
-	call	ResetFloppyDrivesWithInt40h
+	; Reset Floppy Drives with INT 40h
+	xor		bx, bx						; Zero BH to assume no errors
+	or		bl, dl						; Copy requested drive to BL
+	eCMOVS	dl, bh						; Reset Floppy Drive 00h since DL has Hard Drive number
+
+	xor		ah, ah						; Disk Controller Reset
+	int		BIOS_DISKETTE_INTERRUPT_40h
+	call	BackupErrorCodeFromTheRequestedDriveToBH
+	; We do not reset Hard Drives if DL was 0xh on entry
+
 
 %ifdef MODULE_SERIAL_FLOPPY
@@ -61,7 +69,7 @@
 %endif
 
+	; Reset foreign Hard Drives (those handled by other BIOSes)
 	test	bl, bl										; If we were called with a floppy disk, then we are done,
 	jns		SHORT .SkipHardDiskReset					; don't do hard disks.
-
 	call	ResetForeignHardDisks
 
@@ -80,21 +88,4 @@
 
 ;--------------------------------------------------------------------
-; ResetFloppyDrivesWithInt40h
-;	Parameters:
-;		BL:		Requested drive (DL when entering AH=00h)
-;	Returns:
-;		BH:		Error code from requested drive (if available)
-;	Corrupts registers:
-;		AX, DL, DI
-;--------------------------------------------------------------------
-ResetFloppyDrivesWithInt40h:
-	call	GetDriveNumberForForeignHardDiskHandlerToDL
-	and		dl, 7Fh						; Clear hard disk bit
-	xor		ah, ah						; Disk Controller Reset
-	int		BIOS_DISKETTE_INTERRUPT_40h
-	jmp		SHORT BackupErrorCodeFromTheRequestedDriveToBH
-
-
-;--------------------------------------------------------------------
 ; ResetForeignHardDisks
 ;	Parameters:
@@ -104,9 +95,16 @@
 ;		BH:		Error code from requested drive (if available)
 ;	Corrupts registers:
-;		AX, DL, DI
+;		AX, DL
 ;--------------------------------------------------------------------
 ResetForeignHardDisks:
-	call	GetDriveNumberForForeignHardDiskHandlerToDL
-	xor		ah, ah						; Disk Controller Reset
+	; If there are drives after our drives, those are already reset
+	; since our INT 13h was called by some other BIOS.
+	; We only need to reset drives from the previous INT 13h handler.
+	; There could be more in chain but let the previous one handle them.
+	mov		dl, 80h
+	cmp		[RAMVARS.bFirstDrv], dl
+	je		SHORT NoForeignDrivesToReset
+
+	xor		ah, ah					; Disk Controller Reset
 	call	Int13h_CallPreviousInt13hHandler
 ;;; fall-through to BackupErrorCodeFromTheRequestedDriveToBH
@@ -130,22 +128,6 @@
 
 
-;--------------------------------------------------------------------
-; GetDriveNumberForForeignHardDiskHandlerToDL
-;	Parameters:
-;		BL:		Requested drive (DL when entering AH=00h)
-;		DS:		RAMVARS segment
-;	Returns:
-;		DS:DI:	Ptr to DPT if our drive (or Null if foreign drive)
-;		DL:		BL if foreign drive
-;				80h if our drive
-;--------------------------------------------------------------------
-GetDriveNumberForForeignHardDiskHandlerToDL:
-	mov		dl, bl
-	test	di, di
-	jz		SHORT .Return
-	mov		dl, 80h				; First possible Hard Disk should be safe value
-.Return:
-	ret
 
+; This defines what is called when resetting our drives at the end of drive detection.
 AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization equ ResetHardDisksHandledByOurBIOS.ErrorCodeNotUsed
 
@@ -165,5 +147,5 @@
 	xor		bl, bl										; Assume Null IdevarsOffset for now, assuming foreign drive
 	test	di, di
-	jz		.ErrorCodeNotUsed
+	jz		SHORT .ErrorCodeNotUsed
 	mov		bl, [di+DPT.bIdevarsOffset]					; replace drive number with Idevars pointer for cmp with dl
 
@@ -182,5 +164,5 @@
 .loop:
 	call	FindDPT_ForIdevarsOffsetInDL				; look for the first drive on this controller, if any
-	jc		.notFound
+	jc		SHORT .notFound
 
 	call	AHDh_ResetDrive								; reset master and slave on that controller
@@ -192,3 +174,4 @@
 
 .done:
+NoForeignDrivesToReset:
 	ret
