Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm	(revision 498)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm	(revision 502)
@@ -70,7 +70,14 @@
 	mov		ax, DISABLE_WRITE_CACHE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) | FLG_DRVPARAMS_BLOCKMODE
 	mov		[di+ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
+	mov		[di+ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
+
 	mov		[di+ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
+	mov		[di+ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
+
 	mov		[di+ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
+	mov		[di+ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
+
 	mov		[di+ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
+	mov		[di+ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
 	ret
 
@@ -95,5 +102,6 @@
 	jz		SHORT .AllPortsAlreadyDetected
 	push	cx
-	call	IdeAutodetect_DetectIdeDeviceFromPortDX
+	call	IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInCX
+	mov		bx, cx
 	pop		cx
 	jc		SHORT .DetectFromNextPort
@@ -101,5 +109,4 @@
 	; Device found from port DX, Device Type returned in AL
 	inc		cx	; Increment number of controllers found
-	call	GetControlBlockPortToBXfromDeviceTypeInALandBasePortInDX
 	mov		[si+IDEVARS.wBasePort], dx
 	mov		[si+IDEVARS.wControlBlockPort], bx
@@ -112,34 +119,4 @@
 	jmp		SHORT .DetectFromNextPort
 .AllPortsAlreadyDetected:
-	ret
-
-
-;--------------------------------------------------------------------
-; GetControlBlockPortToBXfromDeviceTypeInALandBasePortInDX
-;	Parameters:
-;		AL:		Device Type
-;		DX:		Base port
-;	Returns:
-;		BX:		Control Block Port
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-GetControlBlockPortToBXfromDeviceTypeInALandBasePortInDX:
-	mov		bx, dx
-	cmp		al, DEVICE_8BIT_XTIDE_REV1
-	jae		SHORT .NonStandardControlBlockPortLocation
-
-	; Standard IDE Devices
-	add		bx, STANDARD_CONTROL_BLOCK_OFFSET
-	ret
-
-.NonStandardControlBlockPortLocation:
-	cmp		al, DEVICE_8BIT_JRIDE_ISA
-	je		SHORT .JrIdeIsaDoesNotNeedControlBlockAddress
-
-	; 8-bit Devices
-	add		bx, BYTE XTIDE_CONTROL_BLOCK_OFFSET	; XT-CF also
-.JrIdeIsaDoesNotNeedControlBlockAddress:
 	ret
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm	(revision 498)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm	(revision 502)
@@ -22,5 +22,5 @@
 
 ;--------------------------------------------------------------------
-; IdeAutodetect_DetectIdeDeviceFromPortDX
+; IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInCX
 ;	Parameters:
 ;		DX:		IDE Base Port
@@ -28,14 +28,16 @@
 ;	Returns:
 ;		AL:		Device Type
+;		CX:		Control Block Base port (detected since there is no
+;				standard address for Tetriary and Quaternary IDE controllers)
 ;		CF:		Clear if IDE Device found
 ;				Set if IDE Device not found
 ;	Corrupts registers:
-;		AH, BX, CX
-;--------------------------------------------------------------------
-IdeAutodetect_DetectIdeDeviceFromPortDX:
+;		AH, BX
+;--------------------------------------------------------------------
+IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInCX:
 	cmp		dx, FIRST_MEMORY_SEGMENT_ADDRESS
 	jb		SHORT .DetectPortMappedDevices
 
-	; Try to detect JR-IDE/ISA (only if MODULE_8BIT_IDE_ADVANCED is present)
+	; *** Try to detect JR-IDE/ISA (only if MODULE_8BIT_IDE_ADVANCED is present) ***
 	test	WORD [di+ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE_ADVANCED
 	jz		SHORT .SkipRestOfDetection
@@ -43,25 +45,41 @@
 	push	ds
 	mov		ds, dx
-	cli							; Disable Interrupts
+	cli									; Disable Interrupts
 	mov		ah, [JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET + STATUS_REGISTER_in]
 	mov		al, [JRIDE_CONTROL_BLOCK_REGISTER_WINDOW_OFFSET + ALTERNATE_STATUS_REGISTER_in]
-	sti							; Enable Interrupts
+	sti									; Enable Interrupts
 	pop		ds
 	call	CompareIdeStatusRegistersFromALandAH
-	mov		al, DEVICE_8BIT_JRIDE_ISA
-	ret
+	mov		al, DEVICE_8BIT_JRIDE_ISA	; Assume CF was cleared
+	ret									; No need to return Control Block Port
 .DetectPortMappedDevices:
 
 
-	; Try to detect Standard 16- and 32-bit IDE Devices
+	; *** Try to detect Standard 16- and 32-bit IDE Devices ***
 	mov		bh, DEVICE_16BIT_ATA		; Assume 16-bit ISA slot for AT builds
 	call	Buffers_IsXTbuildLoaded
 	eCMOVE	bh, DEVICE_8BIT_ATA			; Assume 8-bit ISA slot for XT builds
+
 	mov		bl, STATUS_REGISTER_in
 	mov		cx, STANDARD_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in
+.RedetectTertiaryOrQuaternaryWithDifferentAlternativeStatusRegisterPort:
 	call	DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX
 	mov		al, bh
 	jnc		SHORT .IdeDeviceFound
 
+	; 16- or 32-bit IDE Device was not found but we may have used wrong Control Block port if we were trying
+	; to detect Tertiary or Quaternary IDE controllers. Control Block port location is not standardized. For
+	; example Promise FloppyMAX has Control Block at STANDARD_CONTROL_BLOCK_OFFSET but Sound Blaster 16 (CT2290)
+	; use DEVICE_ATA_SECONDARY_PORTCTRL for Tertiary and Quaternary even though only Secondary should use that.
+	cmp		cx, STANDARD_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in
+	jne		SHORT .AlreadyTriedAlternativeControlBlock
+	mov		cx, DEVICE_ATA_SECONDARY_PORTCTRL + ALTERNATE_STATUS_REGISTER_in
+	sub		cx, dx						; Offset to add to DX
+	cmp		dx, DEVICE_ATA_TERTIARY_PORT
+	je		SHORT .RedetectTertiaryOrQuaternaryWithDifferentAlternativeStatusRegisterPort
+	cmp		dx, DEVICE_ATA_QUATERNARY_PORT
+	je		SHORT .RedetectTertiaryOrQuaternaryWithDifferentAlternativeStatusRegisterPort
+.AlreadyTriedAlternativeControlBlock:
+
 
 	; Detect 8-bit devices only if MODULE_8BIT_IDE is available
@@ -69,16 +87,19 @@
 	jz		SHORT .SkipRestOfDetection
 
-	; Try to detect XT-CF
+	; *** Try to detect XT-CF ***
 	mov		bl, STATUS_REGISTER_in << 1
 	mov		cx, (XTIDE_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in) << 1
 	call	DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX
+	rcl		ax, 1						; Store CF
+	shr		cx, 1						; XTIDE_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in
+	rcr		ax, 1						; Restore CF
 	mov		al, DEVICE_8BIT_XTCF_PIO8
 	jnc		SHORT .IdeDeviceFound
 
-	; Try to detect 8-bit XT-IDE rev 1 or rev 2.
+
+	; *** Try to detect 8-bit XT-IDE rev 1 or rev 2 ***
 	; Note that A0<->A3 address swaps Status Register and Alternative
 	; Status Register addresses. That is why we need another step
 	; to check is this XT-IDE rev 1 or rev 2.
-	shr		cx, 1
 	call	DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX
 	jc		SHORT .SkipRestOfDetection	; No XT-IDE rev 1 or rev 2 found
@@ -99,6 +120,7 @@
 	je		SHORT .IdeDeviceFound
 	mov		al, DEVICE_8BIT_XTIDE_REV1	; We must have rev 1
-	clc
 .IdeDeviceFound:
+	sub		cl, ALTERNATE_STATUS_REGISTER_in	; Clear CF
+	add		cx, dx								; CX = Control Block address
 	ret
 .SkipRestOfDetection:
@@ -156,6 +178,8 @@
 
 	; Bytes were the same but it is possible they were both FFh, for 
-	; example. We must make sure bit are what is expected from valid
-	; IDE Status Register.
+	; example. We must make sure bits are what is expected from valid
+	; IDE Status Register. So far all drives I've tested return 50h
+	; (FLG_STATUS_DRDY and FLG_STATUS_DSC set) but I don't want to assume
+	; just yet that all drives report 50h.
 	test	al, FLG_STATUS_BSY | FLG_STATUS_DF | FLG_STATUS_DRQ | FLG_STATUS_ERR
 	jnz		SHORT .InvalidStatusRegister	; Busy or Errors cannot be set
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm	(revision 498)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm	(revision 502)
@@ -83,5 +83,5 @@
 	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeCmdPort
 	at	MENUITEM.szHelp,			dw	g_szHelpIdeCmdPort
-	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
 	at	MENUITEM.bType,				db	TYPE_MENUITEM_HEX
 	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
@@ -357,5 +357,4 @@
 	push	cs
 	pop		ds
-	call	.EnableOrDisableCommandBlockPort
 	call	.EnableOrDisableControlBlockPort
 	call	.DisableIRQchannelSelection
@@ -368,27 +367,4 @@
 
 ;--------------------------------------------------------------------
-; .EnableOrDisableCommandBlockPort
-;	Parameters:
-;		SS:BP:	Menu handle
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.EnableOrDisableCommandBlockPort:
-	mov		bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
-	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
-	mov		bx, g_MenuitemIdeControllerCommandBlockAddress
-	cmp		al, DEVICE_8BIT_XTCF_PIO8
-	jb		SHORT .EnableMenuitemFromCSBX
-	cmp		al, DEVICE_SERIAL_PORT
-	je		SHORT .DisableMenuitemFromCSBX
-	cmp		al, DEVICE_8BIT_XTCF_MEMMAP
-	ja		SHORT .EnableMenuitemFromCSBX
-	jmp		SHORT .DisableMenuitemFromCSBX
-
-
-;--------------------------------------------------------------------
 ; .EnableOrDisableControlBlockPort
 ;	Parameters:
@@ -405,5 +381,5 @@
 	mov		bx, g_MenuitemIdeControllerControlBlockAddress
 	cmp		al, DEVICE_8BIT_XTCF_PIO8
-	jb		SHORT .EnableMenuitemFromCSBX
+	jb		SHORT .EnableMenuitemFromCSBX	; Not needed for XT-CF and JR-IDE/ISA
 	jmp		SHORT .DisableMenuitemFromCSBX
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 498)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 502)
@@ -201,5 +201,5 @@
 g_szItemIdeEnIRQ:		db	"Enable interrupt",NULL
 g_szItemIdeIRQ:			db	"IRQ",NULL
-g_szItemIdeXTCFwindow:	db	"XT-CF Sector Window",NULL
+g_szItemIdeXTCFwindow:	db	"XT-CF v2 Sector Window",NULL
 g_szItemSerialCOM:		db	"COM Port",NULL
 g_szItemSerialBaud:		db	"Baud Rate",NULL
@@ -213,5 +213,5 @@
 g_szDlgIdeEnIRQ:		db	"Enable interrupt?",NULL
 g_szDlgIdeIRQ:			db	"Enter IRQ channel (2...7 for 8-bit controllers, 2...15 for any other controller).",NULL
-g_szDlgIdeXTCFwindow:	db	"XT-CF Sector Window segment (A000h...E800h).",NULL
+g_szDlgIdeXTCFwindow:	db	"XT-CF v2 Sector Window segment (A000h...E800h).",NULL
 
 g_szNfoIdeBackToCfgMenu:db	"Back to XTIDE Universal BIOS Configuration Menu.",NULL
@@ -223,5 +223,5 @@
 g_szNfoIdeEnIRQ:		db	"Interrupt or polling mode.",NULL
 g_szNfoIdeIRQ:			db	"IRQ channel to use.",NULL
-g_szNfoIdeXTCFwindow:	db	"Segment Address for XT-CF 4 kiB Sector Access Window.",NULL
+g_szNfoIdeXTCFwindow:	db	"Segment Address for XT-CF v2 4 kiB Sector Access Window.",NULL
 g_szNfoIdeSerialCOM:	db	"Select a COM port by number.",NULL
 g_szNfoIdeSerialBaud:	db	"Select the COM port's Baud Rate. The server must match this speed."
@@ -250,7 +250,7 @@
 						db	"XTIDE rev 1",LF
 						db	"XTIDE rev 2 or modded rev 1",LF
-						db	"Lo-tech XT-CF in PIO mode",LF
-						db	"Lo-tech XT-CF in DMA mode",LF
-						db	"Lo-tech XT-CF in memory mode",LF
+						db	"XT-CF v2/v3/Lite in PIO mode",LF
+						db	"XT-CF v2 in DMA mode",LF
+						db	"XT-CF v2 in memory mode",LF
 						db	"JR-IDE/ISA",LF
 						db	"Serial port virtual device",NULL
