Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 548)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 549)
@@ -65,5 +65,5 @@
 
 ;--------------------------------------------------------------------
-; AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
+; AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIwithTranslateModeInDX
 ;	Parameters:
 ;		DX:		Wanted translate mode or TRANSLATEMODE_AUTO to autodetect
@@ -78,5 +78,5 @@
 ;		DH
 ;--------------------------------------------------------------------
-AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX:
+AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIwithTranslateModeInDX:
 	call	AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI
 
@@ -92,18 +92,26 @@
 	; TRANSLATEMODE_AUTO set
 
+%ifndef MODULE_EBIOS
+	; Since we do not have EBIOS functions, we might as well use the faster
+	; LARGE mode for small drives. Assisted LBA provides more capacity for
+	; larger drives.
 	; Generate L-CHS using simple bit shift algorithm (ECHS) if
 	; 8192 or less cylinders.
 	cmp		ax, 8192
 	jbe		SHORT ConvertPCHfromAXBLtoEnhancedCHinAXBL
-
-	; We have 8193 or more cylinders so two algorithms are available:
-	; Revised ECHS or Assisted LBA. The Assisted LBA provides larger
-	; capacity but requires LBA support from drive (drives this large
-	; always support LBA but user might have unintentionally set LBA).
-.UseAssistedLBA:
+%endif
+
+	; If we have EBIOS functions, we should always use Assisted LBA
+	; for drives with LBA support. Otherwise the EBIOS functions are
+	; useless since we never do LBA to P-CHS translation.
+	; Even if we do not have EBIOS functions, we must do this check
+	; since user might have forced LBA mode even though the drive does
+	; not support LBA addressing.
 	test	BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8
 	jz		SHORT ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL
 
-	; Drive supports LBA
+	; Assisted LBA provides most capacity but translation algorithm is
+	; slower. The speed difference doesn't matter on AT systems.
+.UseAssistedLBA:
 	call	GetSectorCountToDXAXfromCHSinAXBLBH
 	call	ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
@@ -183,8 +191,6 @@
 	; Generate L-CHS using simple bit shift algorithm (ECHS) if
 	; 8192 or less cylinders
-	cmp		ax, 8192
-	jbe		SHORT ConvertPCHfromAXBLtoEnhancedCHinAXBL
-	cmp		bl, 16	; Drives with 8193 or more cylinders can report 15 heads
-	jb		SHORT ConvertPCHfromAXBLtoEnhancedCHinAXBL
+	call	AtaGeometry_IsDriveSmallEnoughForECHS
+	jc		SHORT ConvertPCHfromAXBLtoEnhancedCHinAXBL
 
 	eMOVZX	cx, bl	; CX = 16
@@ -239,4 +245,30 @@
 	mov		dl, TRANSLATEMODE_LARGE
 	jmp		SHORT .ShiftIfMoreThan1024Cylinder
+
+
+;--------------------------------------------------------------------
+; Checks should LARGE mode L-CHS be calculated with ECHS or Revised ECHS
+; algorithm. Revised ECHS is needed for drives with 8193 or more cylinders
+; AND 16 heads.
+;
+; AtaGeometry_IsDriveSmallEnoughForECHS:
+;	Parameters:
+;		AX:		Number of P-Cylinders
+;		BL:		Number of P-Heads
+;	Returns:
+;		CF:		Clear if Reviced ECHS is necessary
+;				Set if ECHS is enough
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+AtaGeometry_IsDriveSmallEnoughForECHS:
+	; Generate L-CHS using simple bit shift algorithm (ECHS) if
+	; 8192 or less cylinders. Use Revised ECHS if 8193 or more cylinders
+	; AND 16 heads.
+	cmp		ax, 8193
+	jb		SHORT .RevisedECHSisNotNeeded
+	cmp		bl, 16	; Drives with 8193 or more cylinders can report 15 heads
+.RevisedECHSisNotNeeded:
+	ret
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 548)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 549)
@@ -100,5 +100,5 @@
 
 	; Translate P-CHS to L-CHS
-	call	AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
+	call	AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIwithTranslateModeInDX
 	mov		[di+DPT.wLchsCylinders], ax
 	mov		[di+DPT.wLchsHeadsAndSectors], bx
@@ -113,8 +113,16 @@
 	jz		SHORT .LimitHeadsForLargeAddressingMode
 
-	or		cl, FLGL_DPT_LBA		; Set LBA bit for Assisted LBA
+	; Set LBA bit for Assisted LBA
+	or		cl, FLGL_DPT_LBA
 	jmp		SHORT .NothingToChange
+
 .LimitHeadsForLargeAddressingMode:
-	MIN_U	bl, 15					; Cannot have 16 P-Heads in LARGE addressing mode
+	; We cannot have 16 P-Heads heads in Revised ECHS mode (8193 or more cylinders)
+	; but 16 heads are allowed when there are 8192 or less cylinders (ECHS).
+	; Both of these are LARGE modes so do not confuse with NORMAL mode.
+	call	AtaGeometry_IsDriveSmallEnoughForECHS
+	jc		SHORT .NothingToChange
+	dec		bx						; Adjust 16 P-Heads to 15
+
 .NothingToChange:
 	or		[di+DPT.bFlagsLow], cl	; Shift count and addressing mode
