Index: trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 473)
@@ -37,9 +37,13 @@
 	.dwPostStack		resb	4		; POST stack pointer when entering INT 19h
 
+%ifdef MODULE_8BIT_IDE
+	.wNextXTCFportToScan	resb	2	; Needed for XT-CF port autodetection
+%endif
+
 	.clearToZeroFromThisPoint:
 %ifdef MODULE_HOTKEYS
 	.hotkeyVars			resb	HOTKEYVARS_size
 %endif
-	
+
 	.rgDrvDetectInfo:					; Array containing DRVDETECTINFO structs
 endstruc
Index: trunk/XTIDE_Universal_BIOS/Inc/Controllers/JRIDE_ISA.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/Controllers/JRIDE_ISA.inc	(revision 473)
+++ trunk/XTIDE_Universal_BIOS/Inc/Controllers/JRIDE_ISA.inc	(revision 473)
@@ -0,0 +1,28 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	JR-IDE/ISA specifications.
+
+;
+; XTIDE Universal BIOS and Associated Tools 
+; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
+;
+; This program is free software; you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation; either version 2 of the License, or
+; (at your option) any later version.
+; 
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+; GNU General Public License for more details.		
+; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+;
+
+%ifndef JRIDEISA_INC
+%define JRIDEISA_INC
+
+JRIDE_SECTOR_ACCESS_WINDOW_OFFSET			EQU	3C00h	; 512 byte IDE Sector Access Window
+JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET	EQU	3E00h	; 8 byte CS0 IDE Register Window
+JRIDE_CONTROL_BLOCK_REGISTER_WINDOW_OFFSET	EQU	3E08h	; 8 byte CS1 IDE Register Window
+
+
+%endif ; JRIDEISA_INC
Index: trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc	(revision 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc	(revision 473)
@@ -23,4 +23,7 @@
 %define XTCF_INC
 
+XTCF_DMA_MODE_MAX_BLOCK_SIZE		EQU		64		; Sectors
+OFFSET_TO_CONTROL_BLOCK_REGISTERS	EQU		8
+
 ; Possible base addresses. Note that all XT-CF IDE registers are SHL 1 compared
 ; to standard IDE registers.
@@ -42,4 +45,7 @@
 ; 8-bit PIO transfers (port I/O) are used if Control Register is zero.
 ; Any other value means DMA transfers (using DMA channel 3).
+XTCF_8BIT_PIO_MODE					EQU		0
+XTCF_MEMORY_MAPPED_MODE				EQU		0A0h
+
 
 
Index: trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 473)
@@ -24,5 +24,5 @@
 ; Base DPT for all device types
 struc DPT
-	; General Disk Parameter Table related (Bytes 0...3)
+	; General Disk Parameter Table related
 	.wFlags:
 	.bFlagsLow				resb	1
@@ -30,6 +30,7 @@
 	.bIdevarsOffset			resb	1	; Offset to IDEVARS for this drive
 	.bInitError				resb	1	; Flags for AH=09h initialization errors
+	.wBasePort				resb	2	; Segment for JR-IDE/ISA
 
-	; CHS variables (Bytes 4...8)
+	; CHS variables
 	.wLchsCylinders			resb	2	; (1...1027, yes 1027)
 	.wLchsHeadsAndSectors:
@@ -43,8 +44,4 @@
 	.wPchsCylinders			resb	2
 	.twLbaSectors			resb	6	; 48-bit sector count for LBA addressing
-%endif
-
-%ifdef MODULE_8BIT_IDE
-	.wXTCFport				resb	2	; Autodetected XT-CF port
 %endif
 							alignb	2	; WORD alignent for DPT_SERIAL or DPT_ATA
@@ -96,13 +93,13 @@
 	FLG_INITERROR_FAILED_TO_SET_PIO_MODE				EQU (1<<5)
 	FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER	EQU	(1<<6)
-	FLG_INITERROR_FAILED_TO_ENABLE_8BIT_PIO_MODE		EQU	(1<<7)
+	FLG_INITERROR_FAILED_TO_SET_XTCF_MODE				EQU	(1<<7)
 
 
 
 ; DPT for ATA devices
-struc DPT_ATA	; 10/18 bytes + 2 bytes = 12/20 bytes
+struc DPT_ATA
 	.dpt					resb	DPT_size
+	.bDevice				resb	1	; Device Type from IDEVARS (overrided when 32-bit controller detected)
 	.bBlockSize				resb	1	; Current block size in sectors (do not set to zero!)
-	.bDevice				resb	1	; Device Type from IDEVARS (overrided when 32-bit controller detected)
 endstruc
 
@@ -112,5 +109,5 @@
 ; EBDA must be reserved for DPTs when using these!
 %ifdef MODULE_ADVANCED_ATA
-struc DPT_ADVANCED_ATA	; 12/20 bytes + 8 bytes = 20/28 bytes
+struc DPT_ADVANCED_ATA
 	.dpt_ata				resb	DPT_ATA_size
 	.wControllerID			resb	2	; Controller specific ID WORD (from Advanced Controller detection)
@@ -125,5 +122,5 @@
 ; DPT for Serial devices
 %ifdef MODULE_SERIAL
-struc DPT_SERIAL	; 8/18 bytes + 2 bytes = 10/20 bytes
+struc DPT_SERIAL
 	.dpt					resb	DPT_size
 	.wSerialPortAndBaud:
Index: trunk/XTIDE_Universal_BIOS/Inc/DeviceIDE.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/DeviceIDE.inc	(revision 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/DeviceIDE.inc	(revision 473)
@@ -32,9 +32,9 @@
 
 %ifdef MODULE_FEATURE_SETS
-TIMEOUT_BSY				EQU		TIMEOUT_MOTOR_STARTUP
-TIMEOUT_DRDY			EQU		TIMEOUT_MOTOR_STARTUP
+	TIMEOUT_BSY			EQU		TIMEOUT_MOTOR_STARTUP
+	TIMEOUT_DRDY		EQU		TIMEOUT_MOTOR_STARTUP
 %else
-TIMEOUT_BSY				EQU		(2600/55)	; 2600 ms
-TIMEOUT_DRDY			EQU		(2600/55)	; 2600 ms
+	TIMEOUT_BSY			EQU		(2600/55)	; 2600 ms
+	TIMEOUT_DRDY		EQU		(2600/55)	; 2600 ms
 %endif
 
Index: trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc	(revision 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc	(revision 473)
@@ -21,14 +21,7 @@
 %define IDE_IO_INC
 
-JRIDE_SECTOR_ACCESS_WINDOW_OFFSET			EQU	3C00h	; 512 byte IDE Sector Access Window
-JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET	EQU	3E00h	; 8 byte CS0 IDE Register Window
-JRIDE_CONTROL_BLOCK_REGISTER_WINDOW_OFFSET	EQU	3E08h	; 8 byte CS1 IDE Register Window
-JRIDE_SECTOR_ACCESS_WINDOW_SIZE				EQU	512		; 512 bytes
-
-
 ;--------------------------------------------------------------------
-; OUTPUT_AL_TO_IDE_REGISTER_IN_DL
-; JUMP_TO_OUTPUT_AL_TO_IDE_REGISTER_IN_DL
-; OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER_IN_DL
+; OUTPUT_AL_TO_IDE_REGISTER
+; OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER
 ;	Parameters:
 ;		AL:		Byte to output
@@ -42,22 +35,41 @@
 ;--------------------------------------------------------------------
 %macro OUTPUT_AL_TO_IDE_REGISTER 1
-%ifnidni %1, dl
-	mov		dl, %1
+%ifndef MODULE_8BIT_IDE	; Standard IDE controllers only
+
+	%ifnidni %1, dx
+		mov		dx, %1
+	%endif
+	add		dx, [di+DPT.wBasePort]
+	out		dx, al
+
+%else	; Register translations required
+
+	%ifnidni %1, dl
+		mov		dl, %1
+	%endif
+	call	IdeIO_OutputALtoIdeRegisterInDL
+
 %endif
-	call	IdeIO_OutputALtoIdeRegisterInDL
 %endmacro
 
-%macro JUMP_TO_OUTPUT_AL_TO_IDE_REGISTER 1
-%ifnidni %1, dl
-	mov		dl, %1
-%endif
-	jmp		IdeIO_OutputALtoIdeRegisterInDL
-%endmacro
 
 %macro OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER 1
-%ifnidni %1, dl
-	mov		dl, %1
+%ifndef MODULE_8BIT_IDE	; Standard IDE controllers only
+
+	%ifnidni %1, dx
+		mov		dx, %1
+	%endif
+	eMOVZX	bx, BYTE [di+DPT.bIdevarsOffset]
+	add		dx, [cs:bx+IDEVARS.wControlBlockPort]
+	out		dx, al
+
+%else	; Register translations required
+
+	%ifnidni %1, dl
+		mov		dl, %1
+	%endif
+	call	IdeIO_OutputALtoIdeControlBlockRegisterInDL
+
 %endif
-	call	IdeIO_OutputALtoIdeControlBlockRegisterInDL
 %endmacro
 
@@ -74,8 +86,20 @@
 ;--------------------------------------------------------------------
 %macro INPUT_TO_AL_FROM_IDE_REGISTER 1
-%ifnidni %1, dl
-	mov		dl, %1
+%ifndef MODULE_8BIT_IDE	; Standard IDE controllers only
+
+	%ifnidni %1, dx
+		mov		dx, %1
+	%endif
+	add		dx, [di+DPT.wBasePort]
+	in		al, dx
+
+%else	; Register translations required
+
+	%ifnidni %1, dl
+		mov		dl, %1
+	%endif
+		call	IdeIO_InputToALfromIdeRegisterInDL
+
 %endif
-	call	IdeIO_InputToALfromIdeRegisterInDL
 %endmacro
 
Index: trunk/XTIDE_Universal_BIOS/Inc/IdeRegisters.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/IdeRegisters.inc	(revision 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/IdeRegisters.inc	(revision 473)
@@ -103,4 +103,5 @@
 FEATURE_ENABLE_8BIT_PIO_TRANSFER_MODE	EQU		01h		; CFA feature set only
 FEATURE_ENABLE_WRITE_CACHE				EQU		02h
+FEATURE_DISABLE_8BIT_PIO_TRANSFER_MODE	EQU		81h		; CFA feature set only
 FEATURE_DISABLE_WRITE_CACHE				EQU		82h		; Can also be used to flush cache
 FEATURE_SET_TRANSFER_MODE				EQU		03h		; Transfer mode goes to the Sector Count Register
Index: trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc	(revision 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc	(revision 473)
@@ -32,10 +32,4 @@
 %endif
 
-%ifdef MODULE_JRIDE
-	%ifndef MODULE_8BIT_IDE
-		%define MODULE_8BIT_IDE
-	%endif
-%endif
-
 
 
@@ -44,4 +38,5 @@
 	%include "IDE_8bit.inc"			; For IDE 8-bit data port macros
 	%include "XTCF.inc"				; For Lo-tech XT-CF
+	%include "JRIDE_ISA.inc"		; For JR-IDE/ISA
 %endif
 
@@ -104,10 +99,4 @@
 %endif
 
-%ifdef MODULE_JRIDE
-	MAIN_FLG_MODULE_JRIDE	EQU	FLG_ROMVARS_MODULE_JRIDE
-%else
-	MAIN_FLG_MODULE_JRIDE	EQU	0
-%endif
-
 %ifdef MODULE_SERIAL
 	MAIN_FLG_MODULE_SERIAL	EQU	FLG_ROMVARS_MODULE_SERIAL
@@ -134,3 +123,3 @@
 %endif
 
-MASK_ROMVARS_INCLUDED_MODULES	EQU	MAIN_FLG_MODULE_8BIT_IDE | MAIN_FLG_MODULE_ADVANCED_ATA | MAIN_FLG_MODULE_BOOT_MENU | MAIN_FLG_MODULE_EBIOS | MAIN_FLG_MODULE_HOTKEYS | MAIN_FLG_MODULE_IRQ | MAIN_FLG_MODULE_JRIDE | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_SERIAL_FLOPPY | MAIN_FLG_MODULE_STRINGS_COMPRESSED | MAIN_FLG_MODULE_FEATURE_SETS
+MASK_ROMVARS_INCLUDED_MODULES	EQU	MAIN_FLG_MODULE_8BIT_IDE | MAIN_FLG_MODULE_ADVANCED_ATA | MAIN_FLG_MODULE_BOOT_MENU | MAIN_FLG_MODULE_EBIOS | MAIN_FLG_MODULE_HOTKEYS | MAIN_FLG_MODULE_IRQ | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_SERIAL_FLOPPY | MAIN_FLG_MODULE_STRINGS_COMPRESSED | MAIN_FLG_MODULE_FEATURE_SETS
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 473)
@@ -72,5 +72,5 @@
 FLG_ROMVARS_MODULE_FEATURE_SETS			EQU	(1<<5)
 FLG_ROMVARS_MODULE_8BIT_IDE				EQU	(1<<6)
-FLG_ROMVARS_MODULE_JRIDE				EQU (1<<7)
+
 FLG_ROMVARS_MODULE_ADVANCED_ATA			EQU	(1<<8)
 FLG_ROMVARS_MODULE_BOOT_MENU			EQU	(1<<9)
@@ -91,10 +91,11 @@
 ;;; Word 0
 	.wSerialPortAndBaud:					; Serial connection port (low, divided by 4) and baud rate divisor (high)
-	.wPort:									; IDE Base Port for Command Block (usual) Registers
+	.wBasePort:								; IDE Base Port for Command Block (usual) Registers
 	.bSerialPort				resb	1
 	.bSerialBaud				resb	1
 
 ;;; Word 1
-	.wPortCtrl:
+	.wControlBlockPort:
+	.bXTCFcontrolRegister:					; XT-CF autodetects ports
 	.bSerialUnused				resb	1	; IDE Base Port for Control Block Registers
 
@@ -104,5 +105,4 @@
 ;;; Word 2
 	.bDevice					resb	1	; Device type
-
 	.bIRQ						resb	1	; Interrupt Request Number
 
@@ -137,16 +137,22 @@
 
 ; Device types for IDEVARS.bDevice
+; IDE Devices are grouped so device numbers cannot be changed without modifying code elsewhere!
 ;
-DEVICE_8BIT_JRIDE_ISA					EQU	(0<<1)	; JR-IDE/ISA (must be 0)
-DEVICE_8BIT_XTCF						EQU	(1<<1)	; Lo-tech XT-CF
-DEVICE_8BIT_XTIDE_REV2					EQU	(2<<1)	; Or rev 1 with swapped A0 and A3 (must be 1 or 2)
-DEVICE_8BIT_XTIDE_REV1					EQU	(3<<1)	; Must be 4
-COUNT_OF_8BIT_IDE_DEVICES				EQU	4
-
-DEVICE_16BIT_ATA						EQU	(COUNT_OF_8BIT_IDE_DEVICES<<1)
-DEVICE_32BIT_ATA						EQU	((COUNT_OF_8BIT_IDE_DEVICES+1)<<1)
-COUNT_OF_16BIT_IDE_DEVICES				EQU	2
-COUNT_OF_ALL_IDE_DEVICES				EQU	(COUNT_OF_8BIT_IDE_DEVICES + COUNT_OF_16BIT_IDE_DEVICES)
-
+COUNT_OF_STANDARD_IDE_DEVICES			EQU	2
+COUNT_OF_8BIT_IDE_DEVICES				EQU	6
+COUNT_OF_ALL_IDE_DEVICES				EQU	(COUNT_OF_8BIT_IDE_DEVICES + COUNT_OF_STANDARD_IDE_DEVICES)
+; Standard port mapped I/O
+DEVICE_16BIT_ATA						EQU	(0<<1)
+DEVICE_32BIT_ATA						EQU	(1<<1)
+DEVICE_8BIT_XTIDE_REV1					EQU	(COUNT_OF_STANDARD_IDE_DEVICES<<1)
+; Address lines A0 and A3 are swapped
+DEVICE_8BIT_XTIDE_REV2					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+1)<<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+2)<<1)	; XT-CF using 8-bit PIO mode
+DEVICE_8BIT_XTCF_DMA					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+3)<<1)	; XT-CF using DMA
+DEVICE_8BIT_XTCF_MEMMAP					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+4)<<1)	; XT-CF using Memory Mapped transfers (not I/O)
+; Memory Mapped I/O
+DEVICE_8BIT_JRIDE_ISA					EQU	((COUNT_OF_STANDARD_IDE_DEVICES+5)<<1)	; JR-IDE/ISA (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 472)
+++ trunk/XTIDE_Universal_BIOS/Inc/Version.inc	(revision 473)
@@ -42,6 +42,6 @@
 
 %define	TITLE_STRING			TITLE_STRING_START, TITLE_STRING_END
-%define	ROM_VERSION_STRING		"v2.0.0",BETA,"2 (",__DATE__,")",NULL
-%define	FLASH_SIGNATURE			"XTIDE201"	; Do not terminate with NULL
+%define	ROM_VERSION_STRING		"v2.0.0",BETA,"2+ (",__DATE__,")",NULL
+%define	FLASH_SIGNATURE			"XTIDE203"	; Do not terminate with NULL
 
 
