Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Help/IDE_CommandPort.txt
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Help/IDE_CommandPort.txt	(revision 481)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Help/IDE_CommandPort.txt	(revision 483)
@@ -1,1 +1,1 @@
-IDE controller command block address is the usual address mentioned for IDE controllers. By default the primary IDE controller uses port 1F0h and secondary controller uses port 170h. XTIDE card uses port 300h by default.
+IDE controller command block address is the usual address mentioned for IDE controllers. By default the primary IDE controller uses port 1F0h and secondary controller uses port 170h. XTIDE card uses port 300h by default. JR-IDE/ISA do not use ports but you need to set ROM space segment address for JR-IDE/ISA.
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm	(revision 481)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm	(revision 483)
@@ -25,4 +25,5 @@
 %include "AssemblyLibrary.inc"	; Assembly Library. Must be included first!
 %include "Romvars.inc"			; XTIDE Universal BIOS variables
+%include "JRIDE_ISA.inc"		; For JR-IDE/ISA default segment
 %include "XTCF.inc"				; For XT-CF modes
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm	(revision 481)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm	(revision 483)
@@ -26,5 +26,5 @@
 	at	MENUPAGE.fnEnter,			dw	IdeControllerMenu_EnterMenuOrModifyItemVisibility
 	at	MENUPAGE.fnBack,			dw	ConfigurationMenu_EnterMenuOrModifyItemVisibility
-	at	MENUPAGE.wMenuitems,		dw	11
+	at	MENUPAGE.wMenuitems,		dw	12
 iend
 
@@ -83,5 +83,5 @@
 	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeCmdPort
 	at	MENUITEM.szHelp,			dw	g_szHelpIdeCmdPort
-	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bFlags,			db	NULL
 	at	MENUITEM.bType,				db	TYPE_MENUITEM_HEX
 	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
@@ -98,5 +98,5 @@
 	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeCtrlPort
 	at	MENUITEM.szHelp,			dw	g_szHelpIdeCtrlPort
-	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bFlags,			db	NULL
 	at	MENUITEM.bType,				db	TYPE_MENUITEM_HEX
 	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
@@ -185,4 +185,21 @@
 	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	2
 	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	15
+iend
+
+g_MenuitemIdeControllerXTCFwindow:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateHexInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemIdeXTCFwindow
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeXTCFwindow
+	at	MENUITEM.szHelp,			dw	g_szNfoIdeXTCFwindow
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_HEX
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgIdeXTCFwindow
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	0A000h
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	0E800h
+	at	MENUITEM.itemValue + ITEM_VALUE.fnValueReader,				dw	ReaderForXTCFwindow
+	at	MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,				dw	WriterForXTCFwindow
 iend
 
@@ -209,5 +226,4 @@
 	dw	g_szValueCfgDeviceJrIdeIsa
 	dw	g_szValueCfgDeviceSerial
-
 
 g_rgbChoiceToValueLookupForCOM:
@@ -315,4 +331,7 @@
 	mov		[cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
 
+	lea		ax, [bx+IDEVARS.bXTCFcontrolRegister]
+	mov		[cs:g_MenuitemIdeControllerXTCFwindow+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
 	lea		ax, [bx+IDEVARS.bSerialCOMPortChar]
 	mov		[cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
@@ -338,9 +357,54 @@
 	push	cs
 	pop		ds
+	call	.EnableOrDisableCommandBlockPort
+	call	.EnableOrDisableControlBlockPort
 	call	.DisableIRQchannelSelection
 	call	.EnableOrDisableEnableInterrupt
+	call	.EnableOrDisableXTCFwindow
 	call	.EnableOrDisableSerial
 	mov		si, g_MenupageForIdeControllerMenu
 	jmp		Menupage_ChangeToNewMenupageInDSSI
+
+
+;--------------------------------------------------------------------
+; .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:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableControlBlockPort:
+	mov		bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	mov		bx, g_MenuitemIdeControllerControlBlockAddress
+	cmp		al, DEVICE_8BIT_XTCF_PIO8
+	jb		SHORT .EnableMenuitemFromCSBX
+	jmp		SHORT .DisableMenuitemFromCSBX
 
 
@@ -389,4 +453,23 @@
 	mov		bx, g_MenuitemIdeControllerIdeIRQ
 	jz		SHORT .DisableMenuitemFromCSBX
+	jmp		SHORT .DisableMenuitemFromCSBX
+
+
+;--------------------------------------------------------------------
+; .EnableOrDisableXTCFwindow
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableXTCFwindow:
+	mov		bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	mov		bx, g_MenuitemIdeControllerXTCFwindow
+	cmp		al, DEVICE_8BIT_XTCF_MEMMAP
+	je		SHORT .EnableMenuitemFromCSBX
 	; Fall to .DisableMenuitemFromCSBX
 
@@ -414,10 +497,4 @@
 
 .EnableOrDisableSerial:
-	mov		bx, g_MenuitemIdeControllerCommandBlockAddress
-	call	.DisableMenuitemFromCSBX
-
-	mov		bx, g_MenuitemIdeControllerControlBlockAddress
-	call	.DisableMenuitemFromCSBX
-
 	mov		bx, g_MenuitemIdeControllerSerialBaud
 	call	.DisableMenuitemFromCSBX
@@ -446,13 +523,5 @@
 	jz		.EnableMenuitemFromCSBX
 	jmp		.DisableMenuitemFromCSBX
-
 .DisableAllSerial:
-
-	mov		bx, g_MenuitemIdeControllerCommandBlockAddress
-	call	.EnableMenuitemFromCSBX
-
-	mov		bx, g_MenuitemIdeControllerControlBlockAddress
-	call	.EnableMenuitemFromCSBX
-
 	ret
 
@@ -527,4 +596,16 @@
 ;		AX
 ;
+ALIGN JUMP_ALIGN
+WriterForXTCFwindow:
+	mov		al, ah
+	xor		ah, ah
+	ret
+
+ALIGN JUMP_ALIGN
+ReaderForXTCFwindow:
+	mov		ah, al
+	xor		al, al
+	ret
+
 
 ;
@@ -534,28 +615,26 @@
 ALIGN JUMP_ALIGN
 IdeControllerMenu_WriteDevice:
-		push	ax
 		push	bx
 		push	di
-
-		mov		bl,[es:di]							; what is the current Device?
-
-		add		di,IDEVARS.wBasePort - IDEVARS.bDevice	; Get ready to set the Port addresses
-
-		cmp		al,DEVICE_SERIAL_PORT
-		jz		.changingToSerial
-
-		cmp		bl,DEVICE_SERIAL_PORT
-		jnz		.done								; if we weren't Serial before, nothing to do
-
-.changingFromSerial:
-		cmp		al,DEVICE_16BIT_ATA
-
-		mov		ax,DEVICE_XTIDE_DEFAULT_PORT		; Defaults for 8-bit XTIDE devices
-		mov		bx,DEVICE_XTIDE_DEFAULT_PORTCTRL
-
-		jb		.writeNonSerial
-
+		push	di
+		push	ax
+
+		; Note! AL is the choice index, not device code
+		shl		ax, 1								; Selection to device code
+		mov		bl, [es:di]							; what is the current Device we are changing from?
+		sub		di, BYTE IDEVARS.bDevice - IDEVARS.wBasePort	; Get ready to set the Port addresses
+		cmp		al, DEVICE_SERIAL_PORT
+		je		SHORT .changingToSerial
+		cmp		al, DEVICE_8BIT_JRIDE_ISA
+		je		SHORT .ChangingToJrIdeIsa
+
+		; Restore ports to default values
+		cmp		al, DEVICE_8BIT_ATA					; Standard ATA controllers, including 8-bit mode
 		mov		ax, DEVICE_ATA_PRIMARY_PORT			; Defaults for 16-bit and better ATA devices
 		mov		bx, DEVICE_ATA_PRIMARY_PORTCTRL
+		jbe		SHORT .writeNonSerial
+
+		mov		ax, DEVICE_XTIDE_DEFAULT_PORT		; Defaults for 8-bit XTIDE devices
+		mov		bx, DEVICE_XTIDE_DEFAULT_PORTCTRL
 
 .writeNonSerial:
@@ -563,23 +642,48 @@
 		xchg	bx, ax
 		stosw
-
-		jmp		.done
+		jmp		SHORT .done
+
+.ChangingToJrIdeIsa:
+		mov		ax, JRIDE_DEFAULT_SEGMENT_ADDRESS
+		xor		bx, bx
+		jmp		SHORT .writeNonSerial
 
 .changingToSerial:
-		cmp		bl,DEVICE_SERIAL_PORT
-		jz		.done								; if we were already serial, nothing to do
-
-		mov		byte [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort],SERIAL_DEFAULT_BAUD
-
-		mov		al,SERIAL_DEFAULT_COM
-		add		di,IDEVARS.bSerialCOMPortChar-IDEVARS.wBasePort
+		cmp		bl, DEVICE_SERIAL_PORT
+		je		SHORT .done							; if we were already serial, nothing to do
+
+		mov		BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
+
+		mov		al, SERIAL_DEFAULT_COM
+		sub		di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
 		call	IdeControllerMenu_SerialWriteCOM
 		stosb
 
 .done:
+		; See if we are changing to XT-CF. If we are, store
+		; byte for Control Register.
+		pop		ax
+		pop		di			; IDEVARS.bDevice
+		sub		di, BYTE IDEVARS.bDevice - IDEVARS.bXTCFcontrolRegister	; IDEVARS.bXTCFcontrolRegister
+		cmp		al, DEVICE_8BIT_XTCF_PIO8 >> 1
+		je		SHORT .ChangingToPioModeXTCF
+		cmp		al, DEVICE_8BIT_XTCF_DMA >> 1
+		je		SHORT .ChangingToDmaModeXTCF
+		cmp		al, DEVICE_8BIT_XTCF_MEMMAP >> 1
+		jne		SHORT .NoNeedToChangeXTCFsettings
+
+		; XT-CF Memory Mapped Mode
+		mov		WORD [es:di], DEFAULT_XTCF_SECTOR_WINDOW_SEGMENT >> 8	; Store word to clear Control Block Port high byte
+		jmp		SHORT .NoNeedToChangeXTCFsettings
+.ChangingToPioModeXTCF:
+		mov		BYTE [es:di], XTCF_8BIT_PIO_MODE
+		jmp		SHORT .NoNeedToChangeXTCFsettings
+.ChangingToDmaModeXTCF:
+		mov		BYTE [es:di], XTCF_DMA_MODE
+		; Fall to .NoNeedToChangeXTCFsettings
+
+.NoNeedToChangeXTCFsettings:
 		pop		di
 		pop		bx
-		pop		ax
-
 		ret
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 481)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 483)
@@ -196,8 +196,8 @@
 g_szItemIdeEnIRQ:		db	"Enable interrupt",NULL
 g_szItemIdeIRQ:			db	"IRQ",NULL
+g_szItemIdeXTCFwindow:	db	"XT-CF Sector Window",NULL
 g_szItemSerialCOM:		db	"COM Port",NULL
 g_szItemSerialBaud:		db	"Baud Rate",NULL
 g_szItemSerialPort:		db	"COM Port I/O address",NULL
-
 g_szItemIdeSerialComPort:	db	"COM port",NULL
 g_szItemIdeSerialBaudRate:	db	"Baud rate",NULL
@@ -208,4 +208,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_szNfoIdeBackToCfgMenu:db	"Back to XTIDE Universal BIOS Configuration Menu.",NULL
@@ -213,8 +214,9 @@
 g_szNfoIdeSlave:		db	"Settings for Slave Drive.",NULL
 g_szNfoIdeDevice:		db	"Select controller device type.",NULL
-g_szNfoIdeCmdPort:		db	"IDE Controller Command Block (base port) address.",NULL
+g_szNfoIdeCmdPort:		db	"IDE Controller Command Block (base port) address or segment address for JR-IDE/ISA.",NULL
 g_szNfoIdeCtrlPort:		db	"IDE Controller Control Block address. Usually Cmd Block + 8 for XTIDE, and Cmd Block + 200h for ATA.",NULL
 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_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."
