Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 421)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 422)
@@ -144,5 +144,5 @@
 ALIGN JUMP_ALIGN
 AccessDPT_GetPointerToDRVPARAMStoCSBX:
-	eMOVZX	bx, [di+DPT.bIdevarsOffset]			; CS:BX points to IDEVARS
+	eMOVZX	bx, BYTE [di+DPT.bIdevarsOffset]	; CS:BX points to IDEVARS
 	add		bx, BYTE IDEVARS.drvParamsMaster	; CS:BX points to Master Drive DRVPARAMS
 	test	BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
@@ -154,9 +154,9 @@
 
 ;--------------------------------------------------------------------
-; ACCESSDPT__GET_UNSHIFTED_ADDRESS_MODE_TO_AXZF
+; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
 ;	Parameters:
 ;		DS:DI:	Ptr to Disk Parameter Table
 ;	Returns:
-;		AX:		Addressing Mode (ADDRESSING_MODE_NORMAL, ADDRESSING_MODE_LARGE or ADDRESSING_MODE_ASSISTED_LBA)
+;		AX:		Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
 ;               unshifted (still shifted where it is in bFlagsLow)
 ;       ZF:     Set based on value in AL
@@ -168,6 +168,6 @@
 ; is not worth it for these two instructions (4 bytes total)
 ;
-%macro ACCESSDPT__GET_UNSHIFTED_ADDRESS_MODE_TO_AXZF 0
+%macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
 	mov		al, [di+DPT.bFlagsLow]
-	and		ax, BYTE MASKL_DPT_ADDRESSING_MODE
+	and		ax, BYTE MASKL_DPT_TRANSLATEMODE
 %endmacro
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 421)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 422)
@@ -34,5 +34,6 @@
 ;	Returns:
 ;		BX:DX:AX:	48-bit sector count
-;		CL:			FLGL_DPT_LBA48 if LBA48 supported, zero otherwise
+;		CL:			FLGL_DPT_LBA48 if LBA48 supported
+;					Zero if only LBA28 is supported
 ;	Corrupts registers:
 ;		Nothing
@@ -64,6 +65,8 @@
 
 ;--------------------------------------------------------------------
-; AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSI:
-;	Parameters:
+; AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
+; AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX
+;	Parameters:
+;		DX:		Wanted translate mode or TRANSLATEMODE_AUTO to autodetect
 ;		ES:SI:	Ptr to 512-byte ATA information read from the drive
 ;	Returns:
@@ -72,31 +75,43 @@
 ;		BH:		Number of L-CHS sectors per track (1...63)
 ;		CX:		Number of bits shifted (0...3)
-;		DL:		Addressing mode
+;		DL:		CHS Translate Mode
 ;	Corrupts registers:
 ;		DH
 ;--------------------------------------------------------------------
-AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSI:
+AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX:
 	call	AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI
 	; Fall to AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBH
 
-AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBH:
+AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX:
+	; Check if user defined translate mode
+	test	dx, dx
+	jnz		SHORT .CheckIfLargeTranslationWanted
+	MIN_U	ax, MAX_LCHS_CYLINDERS	; TRANSLATEMODE_NORMAL maximum cylinders
+	inc		dx
+.CheckIfLargeTranslationWanted:
+	dec		dx						; Set ZF if TRANSLATEMODE_LARGE
+	jz		SHORT ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL
+	dec		dx						; Set ZF if TRANSLATEMODE_ASSISTED_LBA
+	jz		SHORT .UseAssistedLBA
+	; TRANSLATEMODE_AUTO set
+
 	; Generate L-CHS using simple bit shift algorithm (ECHS) if
 	; 8192 or less cylinders.
 	cmp		ax, 8192
-	jbe		SHORT ConvertPCHfromAXBXtoEnhancedCHinAXBX
+	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 we may have intentionally cleared the LBA
-	; bit to force CHS addressing).
+	; always support LBA but user might have unintentionally set LBA).
+.UseAssistedLBA:
 	test	BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8
-	jz		SHORT ConvertPCHfromAXBXtoRevisedEnhancedCHinAXBX
+	jz		SHORT ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL
 
 	; Drive supports LBA
-	call	AtaGeometry_GetSectorCountToDXAXfromCHSinAXBLBH
+	call	GetSectorCountToDXAXfromCHSinAXBLBH
 	call	ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
 	xor		cx, cx		; No bits to shift
-	mov		dl, ADDRESSING_MODE_ASSISTED_LBA
+	mov		dl, TRANSLATEMODE_ASSISTED_LBA
 	ret
 
@@ -121,5 +136,5 @@
 
 ;--------------------------------------------------------------------
-; AtaGeometry_GetSectorCountToDXAXfromCHSinAXBLBH
+; GetSectorCountToDXAXfromCHSinAXBLBH
 ;	Parameters:
 ;		ES:SI:	Ptr to 512-byte ATA information read from the drive
@@ -132,5 +147,5 @@
 ;		BX
 ;--------------------------------------------------------------------
-AtaGeometry_GetSectorCountToDXAXfromCHSinAXBLBH:
+GetSectorCountToDXAXfromCHSinAXBLBH:
 	xchg	ax, bx
 	mul		ah			; AX = Heads * Sectors per track
@@ -157,5 +172,5 @@
 ;  Do a standard ECHS translation
 ;
-; ConvertPCHfromAXBXtoRevisedEnhancedCHinAXBX:
+; ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL:
 ;	Parameters:
 ;		AX:		Number of P-CHS cylinders (8193...16383)
@@ -169,7 +184,11 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ConvertPCHfromAXBXtoRevisedEnhancedCHinAXBX:
+ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL:
+	; 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 ConvertPCHfromAXBXtoEnhancedCHinAXBX
+	jb		SHORT ConvertPCHfromAXBLtoEnhancedCHinAXBL
 
 	eMOVZX	cx, bl	; CX = 16
@@ -201,5 +220,5 @@
 ;  Use the multiplier on the Cylinder and Head values to obtain the translated values.
 ;
-; ConvertPCHfromAXBXtoEnhancedCHinAXBX:
+; ConvertPCHfromAXBLtoEnhancedCHinAXBL:
 ;	Parameters:
 ;		AX:		Number of P-CHS cylinders (1...8192)
@@ -209,18 +228,18 @@
 ;		BL:		Number of L-CHS heads (?...128)
 ;		CX:		Number of bits shifted (0...3)
-;		DL:		ADDRESSING_MODE_NORMAL or ADDRESSING_MODE_LARGE
+;		DL:		TRANSLATEMODE_NORMAL or TRANSLATEMODE_LARGE
 ;	Corrupts registers:
 ;		Nothing
 ;--------------------------------------------------------------------
-ConvertPCHfromAXBXtoEnhancedCHinAXBX:
+ConvertPCHfromAXBLtoEnhancedCHinAXBL:
 	xor		cx, cx		; No bits to shift initially
-	xor		dl, dl		; Assume ADDRESSING_MODE_NORMAL
+	xor		dl, dl		; Assume TRANSLATEMODE_NORMAL
 .ShiftIfMoreThan1024Cylinder:
 	cmp		ax, MAX_LCHS_CYLINDERS
 	jbe		SHORT ReturnLCHSinAXBLBH
-	shr		ax, 1
-	shl		bl, 1
+	shr		ax, 1		; Halve cylinders
+	shl		bl, 1		; Double heads
 	inc		cx			; Increment bit shift count
-	mov		dl, ADDRESSING_MODE_LARGE
+	mov		dl, TRANSLATEMODE_LARGE
 	jmp		SHORT .ShiftIfMoreThan1024Cylinder
 
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 421)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 422)
@@ -55,5 +55,5 @@
 ;--------------------------------------------------------------------
 .InitializeDPT:
-	mov		[di+DPT.bIdevarsOffset], bp	; IDEVARS must start in first 256 bytes of ROM
+	mov		[di+DPT.bIdevarsOffset], bp		; IDEVARS must start in first 256 bytes of ROM
 	; Fall to .StoreDriveSelectAndDriveControlByte
 
@@ -95,20 +95,16 @@
 .StoreCHSparametersAndAddressingMode:
 	; Check if CHS defined in ROMVARS
-	call	AccessDPT_GetPointerToDRVPARAMStoCSBX
-	test	byte [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS    ; User specified P-CHS?
+	call	GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
+	test	cl, FLG_DRVPARAMS_USERCHS
 	jz		SHORT .AutodetectPCHSvalues
 
-	; Use DRVPARAMS P-CHS values instead of autodetected
-	mov		ax, [cs:bx+DRVPARAMS.wCylinders]
-	mov		bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]
-	call	AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBH
+	; Translate P-CHS to L-CHS
+	call	AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX
 	jmp		SHORT .StoreLCHStoDPT
-
-	; Get L-CHS parameters and addressing mode
 .AutodetectPCHSvalues:
-	call	AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSI
+	call	AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
 
 .StoreLCHStoDPT:
-	eSHL_IM	dl, ADDRESSING_MODE_FIELD_POSITION
+	eSHL_IM	dl, TRANSLATEMODE_FIELD_POSITION
 	or		cl, dl
 	or		[di+DPT.bFlagsLow], cl		; Shift count and addressing mode
@@ -144,12 +140,11 @@
 
 	; Load user defined LBA
-	call	AccessDPT_GetPointerToDRVPARAMStoCSBX
-	test	BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERLBA
+	call	GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
+	test	cl, FLG_DRVPARAMS_USERLBA
 	jz		SHORT .KeepTotalSectorsFromAtaID
-	mov		ax, [cs:bx+DRVPARAMS.dwMaximumLBA]
-	mov		dx, [cs:bx+DRVPARAMS.dwMaximumLBA+2]
-	xor		bx, bx
 
 	; Compare user defined and ATA-ID sector count and select smaller
+	xor		dx, dx
+	xchg	bx, dx		; User defined LBA now in BX:DX:AX
 	cmp		bx, [di+DPT.twLbaSectors+4]
 	jb		SHORT .StoreUserDefinedSectorCountToDPT
@@ -160,5 +155,5 @@
 	jae		SHORT .KeepTotalSectorsFromAtaID
 .StoreUserDefinedSectorCountToDPT:
-	xor		cx, cx		; Always LBA28 for user defined values
+	; CL bit FLGL_DPT_LBA48 is clear at this point
 	call	StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
 
@@ -234,4 +229,34 @@
 
 
+;--------------------------------------------------------------------
+; GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
+;	Parameters:
+;		DS:DI:		Ptr to Disk Parameter Table
+;	Returns:
+;		AX:			User defined P-CHS Cylinders or LBA low word
+;		BX:			User defined P-CHS Heads and Sectors or LBA high word
+;		DX:			Translate mode or TRANSLATEMODE_AUTO
+;		CX:			FLG_DRVPARAMS_USERCHS if user defined CHS in BX:AX
+;					FLG_DRVPARAMS_USERLBA if user defined LBA in BX:AX
+;					Zero if user has not defined capacity
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS:
+	call	AccessDPT_GetPointerToDRVPARAMStoCSBX
+
+	; Get settings
+	mov		cx, [cs:bx+DRVPARAMS.wFlags]
+	mov		dx, cx
+	and		cx, BYTE FLG_DRVPARAMS_USERCHS | FLG_DRVPARAMS_USERLBA
+	and		dx, BYTE MASK_DRVPARAMS_TRANSLATEMODE
+	eSHR_IM	dx, TRANSLATEMODE_FIELD_POSITION
+
+	; Get capacity
+	mov		ax, [cs:bx+DRVPARAMS.wCylinders]		; Or .dwMaximumLBA
+	mov		bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]	; Or .dwMaximumLBA+2
+	ret
+
+
 %ifdef MODULE_EBIOS
 ;--------------------------------------------------------------------
