Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 520)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 521)
@@ -119,14 +119,6 @@
 	jz		SHORT .ErrorCodeNotUsed
 	mov		bl, [di+DPT.bIdevarsOffset]					; replace drive number with Idevars pointer for cmp with dl
-.ErrorCodeNotUsed:
-
-	mov		si, ControllerResetForDPTinDSDI
-	call	.CallSIforEveryController					; Reset all drives to power on settings
-	mov		si, ControllerInitForMasterOrSingleDPTinDSDI
-	; Fall to .CallSIforEveryController					; Initialize all controllers (Master and Slave drives)
-
-.CallSIforEveryController:								; BH will be garbage on exit if this entry point is used,
+.ErrorCodeNotUsed:										; BH will be garbage on exit if this entry point is used,
 														; but reset of all drives will still happen
-
 	mov		dl, ROMVARS.ideVars0						; starting Idevars offset
 
@@ -139,68 +131,39 @@
 
 .loop:
-	push	si
-	call	FindDPT_ForIdevarsOffsetInDL				; look for the first drive on this controller, if any
-	pop		si
-	jc		SHORT .notFound
+	call	FindDPT_MasterOrSingleForIdevarsOffsetInDL
+	jc		SHORT .ControllerNotAvailable
 
-	push	bx
+	; Reset controller (both Master and Slave Drive). We ignore error codes
+	; here since initialization is the one that matters.
 	push	cx
 	push	dx
-	call	si											; Reset Master AND Slave or initialize Master OR Slave drive
+	push	bx
+%ifdef MODULE_IRQ
+	call	Interrupts_UnmaskInterruptControllerForDriveInDSDI
+%endif
+	call	Device_ResetMasterAndSlaveController
+%ifdef MODULE_ADVANCED_ATA
+	call	AdvAtaInit_InitializeControllerForDPTinDSDI
+%endif
+	pop		bx
 	pop		dx
+
+	; Initialize Master Drive
+	call	AH9h_InitializeDriveForUse					; Initialize Master drive
+	call	BackupErrorCodeFromTheRequestedDriveToBH
+
+	; Initialize Slave Drive
+	call	FindDPT_SlaveForIdevarsOffsetInDL
+	jc		SHORT .SlaveDriveNotAvailable
+	call	AH9h_InitializeDriveForUse
+	; Here we have a small problem. Since DL now has offset to IDEVARS, it will be the same
+	; for both Master and Slave Drive. We simply ignore error from slave drive reset since most
+	; systems do not have slave drives at all and it is unlikely that AH=00h would be called for
+	; specific drive anyway. AH=Dh is for that.
+
+.SlaveDriveNotAvailable:
 	pop		cx
-	pop		bx
-	call	BackupErrorCodeFromTheRequestedDriveToBH	; save error code if same controller as drive from entry
-
-.notFound:
+.ControllerNotAvailable:
 	add		dl, IDEVARS_size							; move Idevars pointer forward
 	loop	.loop
 	ret
-
-
-;--------------------------------------------------------------------
-; ControllerResetForDPTinDSDI
-;	Parameters:
-;		DS:DI:	Ptr to DPT for drive to reset (resets both Master and Slave drive)
-;		SS:BP:	Ptr to IDEPACK
-;	Returns:
-;		AH:		Int 13h return status
-;	Corrupts registers:
-;		AL, BX, CX, DX
-;--------------------------------------------------------------------
-ControllerResetForDPTinDSDI:
-%ifdef MODULE_IRQ
-	call	Interrupts_UnmaskInterruptControllerForDriveInDSDI
-%endif
-%ifdef MODULE_ADVANCED_ATA
-	call	Device_ResetMasterAndSlaveController
-	jmp		AdvAtaInit_InitializeControllerForDPTinDSDI
-%else
-	jmp		Device_ResetMasterAndSlaveController
-%endif
-
-
-;--------------------------------------------------------------------
-; ControllerInitForMasterOrSingleDPTinDSDI
-;	Parameters:
-;		DS:DI:	Ptr to DPT for Master or Single Drive (initializes both Master and Slave drive)
-;		SS:BP:	Ptr to IDEPACK
-;	Returns:
-;		AH:		Int 13h return status
-;	Corrupts registers:
-;		AL, BX, CX, DX
-;--------------------------------------------------------------------
-ControllerInitForMasterOrSingleDPTinDSDI:
-	call	AH9h_InitializeDriveForUse			; Init Master or Single drive
-	push	ax									; Store error code
-
-	eMOVZX	ax, BYTE [di+DPT.bIdevarsOffset]	; Clear AH
-	add		di, BYTE LARGEST_DPT_SIZE			; Slave drive or next controller
-	cmp		[di+DPT.bIdevarsOffset], al
-	jne		SHORT .NoSlaveDrivePresent
-
-	call	AH9h_InitializeDriveForUse			; Init Slave drive
-.NoSlaveDrivePresent:
-	pop		bx
-	MAX_U	ah, bh								; Return error code from either drive
-	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 520)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 521)
@@ -73,5 +73,5 @@
 ;		CF:		0 if successful, 1 if error
 ;	Corrupts registers:
-;		AL, BX, CX, DX
+;		AL, CX
 ;--------------------------------------------------------------------
 AH9h_InitializeDriveForUse:
@@ -93,4 +93,6 @@
 	push	es
 	push	si
+	push	dx
+	push	bx
 
 
@@ -232,4 +234,6 @@
 %endif
 
+	pop		bx
+	pop		dx
 	pop		si
 	pop		es
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 520)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 521)
@@ -161,8 +161,8 @@
 %endif
 	clc
-	;; fall through to JumpToBootSector_or_RomBoot
-
-;--------------------------------------------------------------------
-; JumpToBootSector_or_RomBoot
+	;; fall through to Int19_JumpToBootSectorOrRomBoot
+
+;--------------------------------------------------------------------
+; Int19_JumpToBootSectorOrRomBoot
 ;
 ; Switches back to the POST stack, clears the DS and ES registers,
@@ -179,5 +179,5 @@
 ;		Never returns
 ;--------------------------------------------------------------------
-JumpToBootSector_or_RomBoot:
+Int19_JumpToBootSectorOrRomBoot:
 	mov		cx, es		; Preserve MBR segment (can't push because of stack change)
 	mov		ax, 0		; NOTE: can't use XOR (LOAD_BDA_SEGMENT_TO) as it impacts CF
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm	(revision 520)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm	(revision 521)
@@ -36,10 +36,26 @@
 	call	DetectPrint_TryToBootFromDL
 	call	LoadFirstSectorFromDriveDL
-%ifndef USE_386
-	jc		SHORT .FailedToLoadFirstSector
+	jnc		SHORT .FirstSectorLoadedToESBX
+
+	; Do not display timeout error (80h) for floppy drives since
+	; it most likely mean no diskette in drive. This way we do not
+	; display error code every time user intends to boot from hard disk
+	; when A then C boot order is used.
+	js		SHORT .PrintFailedToLoadErrorCode	; Hard Drive
+	cmp		ah, RET_HD_TIMEOUT
+	je		SHORT .ReturnWithCFclearSinceFailedToLoadBootSector
+	cmp		ah, RET_HD_NOMEDIA
+	je		SHORT .ReturnWithCFclearSinceFailedToLoadBootSector
+.PrintFailedToLoadErrorCode:
+%ifdef USE_186
+	push	.ReturnWithCFclearSinceFailedToLoadBootSector
+	jmp		DetectPrint_FailedToLoadFirstSector
 %else
-	jc		DetectPrint_FailedToLoadFirstSector
+	call	DetectPrint_FailedToLoadFirstSector
+	jmp		.ReturnWithCFclearSinceFailedToLoadBootSector
 %endif
 
+
+.FirstSectorLoadedToESBX:
 	test	dl, dl
 	jns		SHORT .AlwaysBootFromFloppyDriveForBooterGames
@@ -47,15 +63,13 @@
 	jne		SHORT .FirstHardDiskSectorNotBootable
 .AlwaysBootFromFloppyDriveForBooterGames:
-	stc
-	jmp		SHORT JumpToBootSector_or_RomBoot
-
-%ifndef USE_386
-.FailedToLoadFirstSector:
-	jmp		DetectPrint_FailedToLoadFirstSector
-%endif
+	stc		; Boot Sector loaded succesfully
+	jmp		SHORT Int19_JumpToBootSectorOrRomBoot
 
 .FirstHardDiskSectorNotBootable:
 	mov		si, g_szBootSectorNotFound
-	jmp		DetectPrint_NullTerminatedStringFromCSSIandSetCF
+	call	DetectPrint_NullTerminatedStringFromCSSI
+.ReturnWithCFclearSinceFailedToLoadBootSector:
+	clc
+	ret
 
 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 520)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 521)
@@ -200,5 +200,5 @@
 ;		AH:		INT 13h error code
 ;	Returns:
-;		Nothing
+;		CF:		Set
 ;	Corrupts registers:
 ;		AX, CX, SI, DI
@@ -210,5 +210,5 @@
 	push	cx					; Push INT 13h error code
 	mov		si, g_szReadError
-	jmp		SHORT DetectPrint_FormatCSSIfromParamsInSSBP
+	jmp		SHORT DetectPrint_FormatCSSIfromParamsInSSBP	; Sets CF
 
 
@@ -261,4 +261,5 @@
 
 ;--------------------------------------------------------------------
+; DetectPrint_NullTerminatedStringFromCSSI
 ; DetectPrint_NullTerminatedStringFromCSSIandSetCF
 ;	Parameters:
@@ -269,4 +270,5 @@
 ;		AX, DI
 ;--------------------------------------------------------------------
+DetectPrint_NullTerminatedStringFromCSSI:
 DetectPrint_NullTerminatedStringFromCSSIandSetCF:
 ;
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 520)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 521)
@@ -136,5 +136,5 @@
 
 ;--------------------------------------------------------------------
-; FindDPT_ForIdevarsOffsetInDL
+; FindDPT_MasterOrSingleForIdevarsOffsetInDL
 ;	Parameters:
 ;		DL:		Offset to IDEVARS to search for
@@ -147,14 +147,31 @@
 ;		SI
 ;--------------------------------------------------------------------
-FindDPT_ForIdevarsOffsetInDL:
+FindDPT_MasterOrSingleForIdevarsOffsetInDL:
 	mov		si, IterateFindFirstDPTforIdevars			; iteration routine (see below)
 	jmp		SHORT FindDPT_IterateAllDPTs				; look for the first drive on this controller, if any
 
 ;--------------------------------------------------------------------
-; Iteration routine for FindDPT_ForIdevarsOffsetInDL,
-; for use with IterateAllDPTs
+; FindDPT_SlaveForIdevarsOffsetInDL
+;	Parameters:
+;		DL:		Offset to IDEVARS to search for
+;		DS:		RAMVARS segment
+;	Returns:
+;		DS:DI:		Ptr to second DPT with same IDEVARS as in DL
+;		CF:			Clear if wanted DPT found
+;					Set if DPT not found, or no DPTs present
+;	Corrupts registers:
+;		SI
+;--------------------------------------------------------------------
+FindDPT_SlaveForIdevarsOffsetInDL:
+	mov		si, IterateFindSecondDPTforIdevars			; iteration routine (see below)
+	jmp		SHORT FindDPT_IterateAllDPTs				; look for the second drive on this controller, if any
+
+;--------------------------------------------------------------------
+; Iteration routines for FindDPT_MasterOrSingleForIdevarsOffsetInDL and
+; FindDPT_SlaveForIdevarsOffsetInDL, for use with IterateAllDPTs
 ;
 ; Returns when DPT is found on the controller with Idevars offset in DL
 ;
+; IterateFindSecondDPTforIdevars
 ; IterateFindFirstDPTforIdevars
 ;       DL:		Offset to IDEVARS to search from DPTs
@@ -164,4 +181,13 @@
 ;				Set if wrong DPT
 ;--------------------------------------------------------------------
+IterateFindSecondDPTforIdevars:
+	call	IterateFindFirstDPTforIdevars
+	jc		SHORT IterateFindFirstDPTforIdevars.done	; Wrong controller
+
+	; We have found DPT for Master Drive,
+	; next DPT is for slave drive or master for another controller
+	add		di, BYTE LARGEST_DPT_SIZE
+	; Fall to IterateFindFirstDPTforIdevars
+
 IterateFindFirstDPTforIdevars:
 	cmp		dl, [di+DPT.bIdevarsOffset]			; Clears CF if matched
@@ -293,3 +319,2 @@
 	pop		cx
 	ret
-
