Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm	(revision 200)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm	(revision 204)
@@ -106,15 +106,15 @@
 g_MenuitemConfigurationIdeControllers:
 istruc MENUITEM
-	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+	at	MENUITEM.fnActivate,		dw	ActivateInputForNumberOfIdeControllersMenuitemInDSSI
 	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
 	at	MENUITEM.szName,			dw	g_szItemCfgIdeCnt
 	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgIdeCnt
 	at	MENUITEM.szHelp,			dw	g_szNfoCfgIdeCnt
-	at	MENUITEM.bFlags,			db	FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE
 	at	MENUITEM.bType,				db	TYPE_MENUITEM_UNSIGNED
 	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	ROMVARS.bIdeCnt
 	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgCfgIdeCnt
 	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	1
-	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	4
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	MAX_ALLOWED_IDE_CONTROLLERS
 iend
 
@@ -139,5 +139,5 @@
 	call	.EnableIdeControllerMenuitemsBasedOnConfiguration
 	call	.EnableOrDisableKiBtoStealFromRAM
-	call	.EnableOrDisableIdeControllerCount
+	call	LimitIdeControllersForLiteMode
 	mov		si, g_MenupageForConfigurationMenu
 	jmp		Menupage_ChangeToNewMenupageInDSSI
@@ -151,5 +151,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, CX
+;		AX, BX, CX, DI, ES
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -166,7 +166,7 @@
 ALIGN JUMP_ALIGN
 .EnableIdeControllerMenuitemsBasedOnConfiguration:
-	call	.GetIdeControllerCountToCX
+	call	Buffers_GetIdeControllerCountToCX
 	dec		cx			; Primary always enabled
-	jz		.PrimaryControllerAlreadyEnabled
+	jz		SHORT .PrimaryControllerAlreadyEnabled
 	mov		bx, g_MenuitemConfigurationSecondaryIdeController
 ALIGN JUMP_ALIGN
@@ -178,27 +178,4 @@
 	ret
 
-;--------------------------------------------------------------------
-; .GetIdeControllerCountToCX
-;	Parameters:
-;		SS:BP:	Menu handle
-;	Returns:
-;		CX:		Number of IDE controllers to configure
-;	Corrupts registers:
-;		AX, BX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.GetIdeControllerCountToCX:
-	call	Buffers_GetRomvarsFlagsToAX
-	test	ax, FLG_ROMVARS_FULLMODE
-	mov		al, 1	; Assume lite mode
-	jz		SHORT .AllowOnlyOneIdeControllerInLiteMode
-
-	mov		bx, ROMVARS.bIdeCnt
-	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
-ALIGN JUMP_ALIGN
-.AllowOnlyOneIdeControllerInLiteMode:
-	cbw		; A maximum of 127 controllers should be sufficient
-	xchg	cx, ax
-	ret
 
 ;--------------------------------------------------------------------
@@ -217,26 +194,6 @@
 	test	ax, FLG_ROMVARS_FULLMODE
 	jz		SHORT .DisableMenuitemFromCSBX
-	jmp		SHORT .EnableMenuitemFromCSBX
-
-;--------------------------------------------------------------------
-; .EnableOrDisableKiBtoStealFromRAM
-;	Parameters:
-;		SS:BP:	Menu handle
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.EnableOrDisableIdeControllerCount:
-	call	Buffers_GetRomvarsFlagsToAX
-	mov		bx, g_MenuitemConfigurationIdeControllers
-	test	ax, FLG_ROMVARS_FULLMODE
-	jnz		SHORT .EnableMenuitemFromCSBX
-
-	; Limit controller count for lite mode
-	call	Buffers_GetFileBufferToESDI
-	mov		BYTE [es:di+ROMVARS.bIdeCnt], MAX_LITE_MODE_CONTROLLERS
-	jmp		SHORT .DisableMenuitemFromCSBX
+	; Fall to .EnableMenuitemFromCSBX
+
 
 ;--------------------------------------------------------------------
@@ -295,2 +252,27 @@
 	call	IdeControllerMenu_InitializeToIdevarsOffsetInBX
 	jmp		IdeControllerMenu_EnterMenuOrModifyItemVisibility
+
+
+ALIGN JUMP_ALIGN
+ActivateInputForNumberOfIdeControllersMenuitemInDSSI:
+	call	Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+	; Fall to LimitIdeControllersForLiteMode
+
+;--------------------------------------------------------------------
+; LimitIdeControllersForLiteMode
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+LimitIdeControllersForLiteMode:
+	push	es
+	call	Buffers_GetIdeControllerCountToCX
+	mov		[es:di+ROMVARS.bIdeCnt], cl
+	CALL_MENU_LIBRARY GetHighlightedItemToAX
+	CALL_MENU_LIBRARY RefreshItemFromAX
+	pop		es
+	ret
