Index: trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 399)
+++ trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 400)
@@ -49,5 +49,4 @@
 
 	; Bit definitions for DPT.bFlagsHigh
-	FLGH_DPT_REVERSED_A0_AND_A3					EQU	(1<<0)	; XTIDE mod, Address lines 0 and 3 reversed
 	FLGH_DPT_BLOCK_MODE_SUPPORTED				EQU	(1<<1)	; Use block transfer commands (must be bit 1!)
 	FLGH_DPT_SERIAL_DEVICE						EQU	(1<<2)	; Serial Port Device
@@ -75,16 +74,7 @@
 	.dpt					resb	DPT_size
 	.bBlockSize				resb	1	; Current block size in sectors (do not set to zero!)
-	.bInitError				resb	1
+	.bDevice				resb	1	; Device Type from IDEVARS (overrided when 32-bit controller detected)
 endstruc
 
-
-	; Flags for DPT_ATA.bInitError
-	FLG_INITERROR_FAILED_TO_SELECT_DRIVE				EQU (1<<0)
-	FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS	EQU (1<<1)
-	FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE				EQU (1<<2)
-	FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE			EQU (1<<3)
-	FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE				EQU (1<<4)
-	FLG_INITERROR_FAILED_TO_SET_PIO_MODE				EQU (1<<5)
-	FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER	EQU	(1<<6)
 
 ; Additional variables needed to initialize and reset Advanced IDE Controllers.
@@ -97,7 +87,16 @@
 	.wMinPioCycleTime		resb	2	; Minimum PIO Cycle Time in ns
 	.bPioMode				resb	1	; Best supported PIO mode
-	.bDevice				resb	1	; Device Type from IDEVARS (overrided when 32-bit controller detected)
+	.bInitError				resb	1	; Flags for initialization errors
 endstruc
 %endif
+
+	; Flags for DPT_ADVANCED_ATA.bInitError
+	FLG_INITERROR_FAILED_TO_SELECT_DRIVE				EQU (1<<0)
+	FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS	EQU (1<<1)
+	FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE				EQU (1<<2)
+	FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE			EQU (1<<3)
+	FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE				EQU (1<<4)
+	FLG_INITERROR_FAILED_TO_SET_PIO_MODE				EQU (1<<5)
+	FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER	EQU	(1<<6)
 
 
Index: trunk/XTIDE_Universal_BIOS/Inc/DeviceIDE.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/DeviceIDE.inc	(revision 399)
+++ trunk/XTIDE_Universal_BIOS/Inc/DeviceIDE.inc	(revision 400)
@@ -26,10 +26,15 @@
 
 ; Polling timeout delays (system timer ticks, 1 tick = 54.9 ms)
-TIMEOUT_BSY				EQU		(2000/55)	; 2000 ms
-TIMEOUT_DRDY			EQU		(2000/55)	; 2000 ms
 TIMEOUT_DRQ				EQU		255			;   14 s (some CF cards occasionally have long write delays)
 TIMEOUT_IDENTIFY_DEVICE	EQU		(500/55)	;  500 ms
 TIMEOUT_MOTOR_STARTUP	EQU		(10000/55)	;   10 s
 
+%ifdef MODULE_FEATURE_SETS
+TIMEOUT_BSY				EQU		TIMEOUT_MOTOR_STARTUP
+TIMEOUT_DRDY			EQU		TIMEOUT_MOTOR_STARTUP
+%else
+TIMEOUT_BSY				EQU		(2000/55)	; 2000 ms
+TIMEOUT_DRDY			EQU		(2000/55)	; 2000 ms
+%endif
 
 %endif ; DEVICEIDE_INC
Index: trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc	(revision 400)
+++ trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc	(revision 400)
@@ -0,0 +1,83 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	Macros for normal I/O mapped ATA controllers.
+
+;
+; 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 IDE_IO_INC
+%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
+;	Parameters:
+;		AL:		Byte to output
+;		%1:		IDE Register				(OUTPUT_AL_TO_IDE_REGISTER)
+;				IDE Control Block Register	(OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER)
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		BX, DX
+;--------------------------------------------------------------------
+%macro OUTPUT_AL_TO_IDE_REGISTER 1
+%ifnidni %1, dl
+	mov		dl, %1
+%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
+%endif
+	call	IdeIO_OutputALtoIdeControlBlockRegisterInDL
+%endmacro
+
+
+;--------------------------------------------------------------------
+; INPUT_TO_AL_FROM_IDE_REGISTER
+;	Parameters:
+;		%1:		IDE Register
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;	Returns:
+;		AL:		Inputted byte
+;	Corrupts registers:
+;		BX, DX
+;--------------------------------------------------------------------
+%macro INPUT_TO_AL_FROM_IDE_REGISTER 1
+%ifnidni %1, dl
+	mov		dl, %1
+%endif
+	call	IdeIO_InputToALfromIdeRegisterInDL
+%endmacro
+
+
+%endif ; IDE_IO_INC
Index: trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc	(revision 399)
+++ trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc	(revision 400)
@@ -32,7 +32,17 @@
 %endif
 
+%ifdef MODULE_JRIDE
+	%ifndef MODULE_8BIT_IDE
+		%define MODULE_8BIT_IDE
+	%endif
+%endif
+
 
 
 ; Include module specific .INC files
+%ifdef MODULE_8BIT_IDE
+	%include "IDE_8bit.inc"			; For IDE 8-bit data port macros
+%endif
+
 %ifdef MODULE_ADVANCED_ATA
 	%include "Vision.inc"			; For QDI Vision QD65xx VLB IDE Controllers
@@ -57,4 +67,10 @@
 
 ; Included modules for ROMVARS.wFlags
+%ifdef MODULE_8BIT_IDE
+	MAIN_FLG_MODULE_8BIT_IDE	EQU	FLG_ROMVARS_MODULE_8BIT_IDE
+%else
+	MAIN_FLG_MODULE_8BIT_IDE	EQU	0
+%endif
+
 %ifdef MODULE_ADVANCED_ATA
 	MAIN_FLG_MODULE_ADVANCED_ATA	EQU	FLG_ROMVARS_MODULE_ADVANCED_ATA
@@ -111,3 +127,9 @@
 %endif
 
-MASK_ROMVARS_INCLUDED_MODULES	EQU	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
+%ifdef MODULE_FEATURE_SETS
+	MAIN_FLG_MODULE_FEATURE_SETS	EQU	FLG_ROMVARS_MODULE_FEATURE_SETS
+%else
+	MAIN_FLG_MODULE_FEATURE_SETS	EQU	0
+%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
Index: trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc	(revision 399)
+++ trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc	(revision 400)
@@ -22,5 +22,7 @@
 
 ; Segment when RAMVARS is stored to top of interrupt vectors.
+%ifndef USE_AT
 LITE_MODE_RAMVARS_SEGMENT	EQU		30h
+%endif
 
 
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 399)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 400)
@@ -70,13 +70,16 @@
 												; (Conveniently, this is 8, a fact we exploit when testing the bit)
 
-FLG_ROMVARS_MODULE_ADVANCED_ATA			EQU	(1<<7)	; Here in case the configuration needs to know functionality is present
-FLG_ROMVARS_MODULE_BOOT_MENU			EQU	(1<<8)	; Here in case the configuration needs to know functionality is present
-FLG_ROMVARS_MODULE_EBIOS				EQU	(1<<9)	; Here in case the configuration needs to know functionality is present
-FLG_ROMVARS_MODULE_HOTKEYS				EQU	(1<<10)	; Here in case the configuration needs to know functionality is present
-FLG_ROMVARS_MODULE_IRQ					EQU	(1<<11)	; Here in case the configuration needs to know functionality is present
-FLG_ROMVARS_MODULE_JRIDE				EQU (1<<12)	; Here in case the configuration needs to know functionality is present
-FLG_ROMVARS_MODULE_SERIAL				EQU (1<<13)	; Here in case the configuration needs to know functionality is present
-FLG_ROMVARS_MODULE_SERIAL_FLOPPY		EQU (1<<14)	; Here in case the configuration needs to know functionality is present
-FLG_ROMVARS_MODULE_STRINGS_COMPRESSED	EQU (1<<15)	; Here in case the configuration needs to know functionality is present
+; Here in case the configuration needs to know functionality is present
+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)
+FLG_ROMVARS_MODULE_EBIOS				EQU	(1<<10)
+FLG_ROMVARS_MODULE_HOTKEYS				EQU	(1<<11)
+FLG_ROMVARS_MODULE_IRQ					EQU	(1<<12)
+FLG_ROMVARS_MODULE_SERIAL				EQU (1<<13)
+FLG_ROMVARS_MODULE_SERIAL_FLOPPY		EQU (1<<14)
+FLG_ROMVARS_MODULE_STRINGS_COMPRESSED	EQU (1<<15)
 
 
@@ -119,28 +122,34 @@
 ;
 DEVICE_XTIDE_DEFAULT_PORT				EQU		300h
-DEVICE_XTIDE_DEFAULT_PORTCTRL			EQU		DEVICE_XTIDE_DEFAULT_PORT + 8h
+DEVICE_XTIDE_DEFAULT_PORTCTRL			EQU		(DEVICE_XTIDE_DEFAULT_PORT + 8h)
 
 DEVICE_ATA_PRIMARY_PORT					EQU		1F0h
-DEVICE_ATA_PRIMARY_PORTCTRL				EQU		DEVICE_ATA_PRIMARY_PORT + 200h
+DEVICE_ATA_PRIMARY_PORTCTRL				EQU		(DEVICE_ATA_PRIMARY_PORT + 200h)
 
 DEVICE_ATA_SECONDARY_PORT				EQU		170h
-DEVICE_ATA_SECONDARY_PORTCTRL			EQU		DEVICE_ATA_SECONDARY_PORT + 200h
+DEVICE_ATA_SECONDARY_PORTCTRL			EQU		(DEVICE_ATA_SECONDARY_PORT + 200h)
 
 DEVICE_ATA_TERTIARY_PORT				EQU		1E8h
-DEVICE_ATA_TERTIARY_PORTCTRL			EQU		DEVICE_ATA_TERTIARY_PORT + 200h
+DEVICE_ATA_TERTIARY_PORTCTRL			EQU		(DEVICE_ATA_TERTIARY_PORT + 200h)
 
 DEVICE_ATA_QUATERNARY_PORT				EQU		168h
-DEVICE_ATA_QUATERNARY_PORTCTRL			EQU		DEVICE_ATA_QUATERNARY_PORT + 200h
+DEVICE_ATA_QUATERNARY_PORTCTRL			EQU		(DEVICE_ATA_QUATERNARY_PORT + 200h)
 
 
 ; Device types for IDEVARS.bDevice
 ;
-DEVICE_XTIDE_REV1						EQU	(0<<1)
-DEVICE_XTIDE_REV2						EQU	(1<<1)	; Or rev 1 with swapped A0 and A3 (chuck mod)
-DEVICE_FAST_XTIDE						EQU	(2<<1)	; (CPLD v2 project)
-DEVICE_16BIT_ATA						EQU	(3<<1)
-DEVICE_32BIT_ATA						EQU	(4<<1)
-DEVICE_SERIAL_PORT						EQU	(5<<1)
-DEVICE_JRIDE_ISA						EQU	(6<<1)
+DEVICE_8BIT_JRIDE_ISA					EQU	(0<<1)	; JR-IDE/ISA (must be 0)
+DEVICE_8BIT_FAST_XTIDE					EQU	(1<<1)	; CPLD v2 project (must be 1 or 2)
+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)
+
+DEVICE_SERIAL_PORT						EQU	(COUNT_OF_ALL_IDE_DEVICES<<1)
+
 
 
