Index: trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc	(revision 471)
+++ trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc	(revision 472)
@@ -58,14 +58,4 @@
 
 ;--------------------------------------------------------------------
-; IS_XTCF_IN_PORT_CX
-;	Parameters:
-;		CX:		Port to search XT-CF from (can be anything)
-;	Returns:
-;		AH:		RET_HD_SUCCESS if XT-CF is found from port
-;				RET_HD_INVALID if XT-CF is not found
-;--------------------------------------------------------------------
-IS_XTCF_IN_PORT_CX					EQU		1
-
-;--------------------------------------------------------------------
 ; READ_XTCF_CONTROL_REGISTER_TO_DH
 ;	Parameters:
@@ -74,5 +64,5 @@
 ;		DH:		XT-CF Control Register contents
 ;--------------------------------------------------------------------
-READ_XTCF_CONTROL_REGISTER_TO_DH	EQU		2
+READ_XTCF_CONTROL_REGISTER_TO_DH	EQU		1
 
 ;--------------------------------------------------------------------
@@ -82,5 +72,5 @@
 ;		DL:		Drive Number
 ;--------------------------------------------------------------------
-WRITE_DH_TO_XTCF_CONTROL_REGISTER	EQU		3
+WRITE_DH_TO_XTCF_CONTROL_REGISTER	EQU		2
 
 
Index: trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 471)
+++ trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 472)
@@ -23,6 +23,6 @@
 
 ; Base DPT for all device types
-struc DPT	; 10 or 18 bytes
-	; General Disk Parameter Table related
+struc DPT
+	; General Disk Parameter Table related (Bytes 0...3)
 	.wFlags:
 	.bFlagsLow				resb	1
@@ -31,5 +31,5 @@
 	.bInitError				resb	1	; Flags for AH=09h initialization errors
 
-	; CHS variables
+	; CHS variables (Bytes 4...8)
 	.wLchsCylinders			resb	2	; (1...1027, yes 1027)
 	.wLchsHeadsAndSectors:
@@ -43,7 +43,10 @@
 	.wPchsCylinders			resb	2
 	.twLbaSectors			resb	6	; 48-bit sector count for LBA addressing
-%else
-							resb	1	; Alignment
 %endif
+
+%ifdef MODULE_8BIT_IDE
+	.wXTCFport				resb	2	; Autodetected XT-CF port
+%endif
+							alignb	2	; WORD alignent for DPT_SERIAL or DPT_ATA
 endstruc
 
@@ -115,5 +118,5 @@
 	.wMinPioCycleTime		resb	2	; Minimum PIO Cycle Time in ns
 	.bPioMode				resb	1	; Best supported PIO mode
-							resb	1
+							alignb	2
 endstruc
 %endif
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 471)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 472)
@@ -38,18 +38,18 @@
 ;--------------------------------------------------------------------
 AH1Eh_HandlerForXTCFfeatures:
-	eMOVZX	bx, al	; Subcommand to BX
+	xor		ah, ah		; Subcommand now in AX
 %ifndef USE_186
-	call	AH1Eh_ProcessXTCFsubcommandFromBX
+	call	AH1Eh_ProcessXTCFsubcommandFromAX
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %else
 	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
-	; Fall to AH1Eh_ProcessXTCFsubcommandFromBX
+	; Fall to AH1Eh_ProcessXTCFsubcommandFromAX
 %endif
 
 
 ;--------------------------------------------------------------------
-; AH1Eh_ProcessXTCFsubcommandFromBX
+; AH1Eh_ProcessXTCFsubcommandFromAX
 ;	Parameters:
-;		BX:		XT-CF subcommand (see XTCF.inc for more info)
+;		AX:		XT-CF subcommand (see XTCF.inc for more info)
 ;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;		SS:BP:	Ptr to IDEPACK
@@ -60,3 +60,55 @@
 ;		AL, BX, CX, DX
 ;--------------------------------------------------------------------
-AH1Eh_ProcessXTCFsubcommandFromBX:
+AH1Eh_ProcessXTCFsubcommandFromAX:
+	; IS_THIS_DRIVE_XTCF. We check this for all commands.
+	dec		ax		; Subcommand
+	mov		dx, [di+DPT.wXTCFport]
+	test	dx, dx	; Never zero for XT-CF, Always zero for other devices
+	jz		SHORT XTCFnotFound
+
+	; READ_XTCF_CONTROL_REGISTER_TO_DH
+	add		dl, XTCF_CONTROL_REGISTER	; DX to Control Register
+	dec		ax		; Subcommand
+	jnz		SHORT .SkipReadXtcfControlRegisterToDH
+	in		al, dx
+	mov		[bp+IDEPACK.intpack+INTPACK.dh], al
+	jmp		SHORT .ReturnWithSuccess
+.SkipReadXtcfControlRegisterToDH:
+
+	; WRITE_DH_TO_XTCF_CONTROL_REGISTER
+	dec		ax		; Subcommand
+	jnz		SHORT XTCFnotFound			; Invalid subcommand
+	mov		al, [bp+IDEPACK.intpack+INTPACK.dh]
+	out		dx, al
+.ReturnWithSuccess:
+	xor		ah, ah
+	ret
+
+
+;--------------------------------------------------------------------
+; AH1Eh_DetectXTCFwithBasePortInDX
+;	Parameters:
+;		DX:		Base I/O port address to check
+;	Returns:
+;		AH:		RET_HD_SUCCESS if XT-CF is found from port
+;				RET_HD_INVALID if XT-CF is not found
+;		CF:		Cleared if XT-CF found
+;				Set if XT-CF not found
+;	Corrupts registers:
+;		AL, DX
+;--------------------------------------------------------------------
+AH1Eh_DetectXTCFwithBasePortInDX:
+	add		dl, XTCT_CONTROL_REGISTER_INVERTED_in	; set DX to XT-CF config register (inverted)
+	in		al, dx		; get value
+	mov		ah, al		; save in ah
+	inc		dx			; set DX to XT-CF config register (non-inverted)
+	in		al, dx		; get value
+	not		al			; invert it
+	sub		ah, al		; do they match? (clear AH if they do)
+	jz		SHORT XTCFfound
+
+XTCFnotFound:
+	stc					; set carry flag since XT-CF not found
+	mov		ah, RET_HD_INVALID
+XTCFfound:
+	ret					; and return
