Index: trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc	(revision 584)
@@ -56,7 +56,9 @@
 ; the mode via a call to Int 13h function 1Eh accordingly (see AH1E_XTCF.asm).
 ;
-XTCF_8BIT_PIO_MODE					EQU		00h
-XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD	EQU		01h
-XTCF_DMA_MODE						EQU		02h
+XTCF_8BIT_PIO_MODE					EQU		((DEVICE_8BIT_XTCF_PIO8 >> 1) - XTCF_DEVICE_OFFSET)
+XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD	EQU		(XTCF_8BIT_PIO_MODE + 1)
+XTCF_16BIT_PIO_WITH_BIU_OFFLOAD		EQU		(XTCF_8BIT_PIO_MODE + 2)	; Lo-tech 8-bit IDE Adapter
+XTCF_DMA_MODE						EQU		(XTCF_8BIT_PIO_MODE + 3)
+
 
 ; Subcommands for AH=1Eh, Lo-tech XT-CF features.
Index: trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 584)
@@ -100,5 +100,5 @@
 struc DPT_ATA
 	.dpt					resb	DPT_size
-	.bDevice				resb	1	; Device Type from IDEVARS (overrided when 32-bit controller detected)
+	.bDevice				resb	1	; Device Type from IDEVARS (overrided when 32-bit controller detected or XT-CF mode is changed)
 	.bBlockSize				resb	1	; Current block size in sectors (do not set to zero!)
 endstruc
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 584)
@@ -146,7 +146,7 @@
 ; Device types for IDEVARS.bDevice
 ; IDE Devices are grouped so device numbers cannot be changed without modifying code elsewhere!
-;
+; (IdeTransfer.asm)
 COUNT_OF_STANDARD_IDE_DEVICES			EQU	2	; 16- and 32-bit controllers
-COUNT_OF_8BIT_IDE_DEVICES				EQU	8
+COUNT_OF_8BIT_IDE_DEVICES				EQU	9
 COUNT_OF_ALL_IDE_DEVICES				EQU	(COUNT_OF_8BIT_IDE_DEVICES + COUNT_OF_STANDARD_IDE_DEVICES)
 ; Standard port mapped I/O
@@ -158,10 +158,12 @@
 DEVICE_8BIT_XTIDE_REV2					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+2)<<1)	; Or rev 1 with swapped A0 and A3
 ; IDE Register offsets are SHL 1
-DEVICE_8BIT_XTCF_PIO8					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+3)<<1)	; XT-CF using 8-bit PIO mode
+XTCF_DEVICE_OFFSET						EQU	3
+DEVICE_8BIT_XTCF_PIO8					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+XTCF_DEVICE_OFFSET)<<1)	; XT-CF using 8-bit PIO mode
 DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD	EQU	((COUNT_OF_STANDARD_IDE_DEVICES+4)<<1)	; XT-CF using 8-bit PIO mode, but with 16-bit instructions
-DEVICE_8BIT_XTCF_DMA					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+5)<<1)	; XT-CFv3 using DMA
+DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD	EQU	((COUNT_OF_STANDARD_IDE_DEVICES+5)<<1)	; Lo-tech 8-bit IDE Adapter
+DEVICE_8BIT_XTCF_DMA					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+6)<<1)	; XT-CFv3 using DMA
 ; Memory Mapped I/O
-DEVICE_8BIT_JRIDE_ISA					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+6)<<1)	; JR-IDE/ISA (Memory Mapped I/O)
-DEVICE_8BIT_ADP50L						EQU	((COUNT_OF_STANDARD_IDE_DEVICES+7)<<1)	; SVC ADP50L (Memory Mapped I/O)
+DEVICE_8BIT_JRIDE_ISA					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+7)<<1)	; JR-IDE/ISA (Memory Mapped I/O)
+DEVICE_8BIT_ADP50L						EQU	((COUNT_OF_STANDARD_IDE_DEVICES+8)<<1)	; SVC ADP50L (Memory Mapped I/O)
 ; Virtual devices
 DEVICE_SERIAL_PORT						EQU	(COUNT_OF_ALL_IDE_DEVICES<<1)
Index: trunk/XTIDE_Universal_BIOS/Inc/Version.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/Version.inc	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Inc/Version.inc	(revision 584)
@@ -17,4 +17,9 @@
 ; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+;
+
+; Flash signature revisions:
+; XTIDE205	Added DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD after other XT-CF
+;			PIO modes (prevents empty indexes in PIO jump tables)
 ;
 
@@ -43,5 +48,5 @@
 %define	TITLE_STRING			TITLE_STRING_START, TITLE_STRING_END
 %define	ROM_VERSION_STRING		"v2.0.0",BETA,"3+ (",__DATE__,")",NULL
-%define	FLASH_SIGNATURE			"XTIDE204"	; Do not terminate with NULL
+%define	FLASH_SIGNATURE			"XTIDE205"	; Do not terminate with NULL
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 584)
@@ -89,10 +89,13 @@
 
 %ifdef MODULE_8BIT_IDE
-	; Enable 8-bit PIO mode for 8-bit ATA and XT-CF
 	push	si
+
+	; Enable 8-bit PIO for DEVICE_8BIT_ATA (no need to verify device type here)
 	call	AH9h_Enable8bitModeForDevice8bitAta
+
+	; Set XT-CF mode. No need to check here if device is XT-CF or not.
 %ifdef MODULE_8BIT_IDE_ADVANCED
-	mov		al, XTCF_8BIT_PIO_MODE		; initialise with most basic transfer mode
-	call	AH9h_SetModeFromALtoXTCF
+	call	AH1Eh_GetCurrentXTCFmodeToAX	; Reads from DPT_ATA.bDevice that we just stored
+	call	AH9h_SetModeFromALtoXTCF		; Enables/disables 8-bit mode when necessary
 %endif ; MODULE_8BIT_IDE_ADVANCED
 	pop		si
@@ -106,5 +109,4 @@
 
 	; Clean stack and return
-.FailedToSet8bitMode:
 	lea		sp, [bp+SIZE_OF_IDEPACK_WITHOUT_INTPACK]	; This assumes BP hasn't changed between Idepack_FakeToSSBP and here
 	pop		bp
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 584)
@@ -350,8 +350,9 @@
 		dw		IdePioBlock_ReadFromXtideRev1		; 3, DEVICE_8BIT_XTIDE_REV1
 		dw		IdePioBlock_ReadFrom16bitDataPort	; 4, DEVICE_8BIT_XTIDE_REV2
+%ifdef MODULE_8BIT_IDE_ADVANCED
 		dw		IdePioBlock_ReadFrom8bitDataPort	; 5, DEVICE_8BIT_XTCF_PIO8
 		dw		IdePioBlock_ReadFrom16bitDataPort	; 6, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
-%ifdef MODULE_8BIT_IDE_ADVANCED
-		dw		IdeDmaBlock_ReadFromXTCF			; 7, DEVICE_8BIT_XTCF_DMA
+		dw		IdePioBlock_ReadFrom16bitDataPort	; 7, DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD
+		dw		IdeDmaBlock_ReadFromXTCF			; 8, DEVICE_8BIT_XTCF_DMA
 %endif ; MODULE_8BIT_IDE_ADVANCED
 %endif ; MODULE_8BIT_IDE
@@ -365,8 +366,9 @@
 		dw		IdePioBlock_WriteToXtideRev1		; 3, DEVICE_8BIT_XTIDE_REV1
 		dw		IdePioBlock_WriteToXtideRev2		; 4, DEVICE_8BIT_XTIDE_REV2
+%ifdef MODULE_8BIT_IDE_ADVANCED
 		dw		IdePioBlock_WriteTo8bitDataPort		; 5, DEVICE_8BIT_XTCF_PIO8
 		dw		IdePioBlock_WriteTo16bitDataPort	; 6, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
-%ifdef MODULE_8BIT_IDE_ADVANCED
-		dw		IdeDmaBlock_WriteToXTCF				; 7, DEVICE_8BIT_XTCF_DMA
+		dw		IdePioBlock_WriteTo16bitDataPort	; 7, DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD
+		dw		IdeDmaBlock_WriteToXTCF				; 8, DEVICE_8BIT_XTCF_DMA
 %endif ; MODULE_8BIT_IDE_ADVANCED
 %endif ; MODULE_8BIT_IDE
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 584)
@@ -111,5 +111,5 @@
 	;       Selected transfer mode is stored in BIOS variable (DPT_ATA.bDevice).
 
-	; Note that when selecting 'DEVICE_8BIT_PIO_MODE_WITH_BIU_OFFLOAD' mode,
+	; Note that when selecting 'DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD' mode,
 	; the ATA device (i.e. CompactFlash card) will operate in 8-bit mode, but
 	; data will be transferred from its data register using 16-bit CPU instructions
@@ -134,4 +134,6 @@
 	dec		ax						; XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD = 1
 	jz		SHORT .Set8bitPioModeWithBIUOffload
+	dec		ax
+	jz		SHORT .Set16bitPioModeWithBIUOffload
 
 	; XTCF_DMA_MODE = 2 (allow 3 as well for more optimized code)
@@ -144,4 +146,10 @@
 	mov		al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
 	jmp		SHORT AH24h_SetBlockSize
+
+.Set16bitPioModeWithBIUOffload:
+	pop		bx								; Do not enable 8-bit PIO...
+	ePUSH_T	bx, AH23h_Disable8bitPioMode	; ...disable it instead
+	mov		al, DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD
+	SKIP2B	bx
 
 .Set8bitPioMode:
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm	(revision 584)
@@ -78,4 +78,5 @@
 ;--------------------------------------------------------------------
 ; AH23h_Enable8bitPioMode
+; AH23h_Disable8bitPioMode
 ;	Parameters:
 ;		DS:DI:	Ptr to DPT (in RAMVARS segment)
@@ -91,3 +92,8 @@
 	mov		si, FEATURE_ENABLE_8BIT_PIO_TRANSFER_MODE
 	jmp		SHORT AH23h_SetControllerFeatures
+AH23h_Disable8bitPioMode:
+	mov		si, FEATURE_DISABLE_8BIT_PIO_TRANSFER_MODE
+	call	AH23h_SetControllerFeatures
+	xor		ah, ah			; Clear error since modern drives might not understand the command and are
+	ret						; always in 16-bit mode anyway
 %endif
Index: trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 583)
+++ trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 584)
@@ -136,5 +136,5 @@
 %ifdef MODULE_8BIT_IDE_ADVANCED
 	at	ROMVARS.ideVars0+IDEVARS.wBasePort,				dw	DEVICE_XTIDE_DEFAULT_PORT		; Controller Command Block base port
-	at	ROMVARS.ideVars0+IDEVARS.bDevice,				db	DEVICE_8BIT_XTCF_PIO8
+	at	ROMVARS.ideVars0+IDEVARS.bDevice,				db	XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD
 %else
 	at	ROMVARS.ideVars0+IDEVARS.wBasePort,				dw	DEVICE_XTIDE_DEFAULT_PORT		; Controller Command Block base port
