Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm	(revision 567)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm	(revision 592)
@@ -53,5 +53,5 @@
 	call	Memory_ReserveCXbytesFromStackToDSSI
 	call	InitializeDialogInputInDSSIfromMenuitemInESDI
-	mov		ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.szMultichoice]
+	mov		ax, [es:di+MENUITEM.itemValue+ITEM_VALUE.szMultichoice]
 	mov		[si+DIALOG_INPUT.fszItems], ax
 	push	di
@@ -59,6 +59,7 @@
 	pop		di
 
-	cmp		ax, BYTE NO_ITEM_SELECTED
-	je		SHORT .NothingToChange
+	inc		ax				; NO_ITEM_SELECTED ?
+	jz		SHORT .NothingToChange
+	dec		ax
 	call	Registers_CopyESDItoDSSI
 	call	Menuitem_StoreValueFromAXtoMenuitemInDSSI
@@ -70,43 +71,27 @@
 ;--------------------------------------------------------------------
 ; Menuitem_ActivateHexInputForMenuitemInDSSI
-;	Parameters:
-;		DS:SI:	Ptr to MENUITEM
-;	Returns:
-;		Nothing
+; Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		CF:		Cleared if value inputted
+;				Set if user cancellation
 ;	Corrupts registers:
 ;		AX, BX, CX, SI, DI, ES
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 Menuitem_ActivateHexInputForMenuitemInDSSI:
+	mov		bl, 16
+	SKIP2B	ax
+Menuitem_ActivateUnsignedInputForMenuitemInDSSI:
+	mov		bl, 10
+
 	call	Registers_CopyDSSItoESDI
-
 	mov		cx, WORD_DIALOG_IO_size
 	call	Memory_ReserveCXbytesFromStackToDSSI
 	call	InitializeDialogInputInDSSIfromMenuitemInESDI
-	mov		BYTE [si+WORD_DIALOG_IO.bNumericBase], 16
-	jmp		SHORT ContinueWordInput
-
-;--------------------------------------------------------------------
-; Menuitem_ActivateUnsignedInputForMenuitemInDSSI
-;	Parameters:
-;		DS:SI:	Ptr to MENUITEM
-;	Returns:
-;		CF:		Cleared if value inputted
-;				Set if user cancellation
-;	Corrupts registers:
-;		AX, BX, CX, SI, DI, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-Menuitem_ActivateUnsignedInputForMenuitemInDSSI:
-	call	Registers_CopyDSSItoESDI
-
-	mov		cx, WORD_DIALOG_IO_size
-	call	Memory_ReserveCXbytesFromStackToDSSI
-	call	InitializeDialogInputInDSSIfromMenuitemInESDI
-	mov		BYTE [si+WORD_DIALOG_IO.bNumericBase], 10
-ContinueWordInput:
-	mov		ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMinValue]
+	mov		[si+WORD_DIALOG_IO.bNumericBase], bl
+	mov		ax, [es:di+MENUITEM.itemValue+ITEM_VALUE.wMinValue]
 	mov		[si+WORD_DIALOG_IO.wMin], ax
-	mov		ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMaxValue]
+	mov		ax, [es:di+MENUITEM.itemValue+ITEM_VALUE.wMaxValue]
 	mov		[si+WORD_DIALOG_IO.wMax], ax
 	push	di
@@ -138,5 +123,5 @@
 ALIGN JUMP_ALIGN
 InitializeDialogInputInDSSIfromMenuitemInESDI:
-	mov		ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.szDialogTitle]
+	mov		ax, [es:di+MENUITEM.itemValue+ITEM_VALUE.szDialogTitle]
 	mov		[si+DIALOG_INPUT.fszTitle], ax
 	mov		[si+DIALOG_INPUT.fszTitle+2], cs
@@ -162,6 +147,15 @@
 ALIGN JUMP_ALIGN
 Menuitem_StoreValueFromAXtoMenuitemInDSSI:
+%if 0
+	; 3 bytes more but this will always invoke the Writer, even if it's an invalid item type (which might be useful).
 	eMOVZX	bx, [si+MENUITEM.bType]
 	cmp		bl, TYPE_MENUITEM_HEX
+%else
+	; This will only invoke the Writer for valid item types.
+	mov		bx, -TYPE_MENUITEM_MULTICHOICE & 0FFh
+	add		bl, [si+MENUITEM.bType]
+	jnc		SHORT .InvalidItemType
+	cmp		bl, TYPE_MENUITEM_HEX - TYPE_MENUITEM_MULTICHOICE
+%endif
 	ja		SHORT .InvalidItemType
 
@@ -169,21 +163,18 @@
 	add		di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 
-	push	bx
-	mov		bx,[si+MENUITEM.itemValue+ITEM_VALUE.fnValueWriter]
-	test	bx,bx
-	jz		SHORT .NoWriter
-	call	bx
-.NoWriter:
+	push	WORD [cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
+	mov		bx, [si+MENUITEM.itemValue+ITEM_VALUE.fnValueWriter]
+	test	bx, bx
+	jnz		SHORT .InvokeWriter
+.InvalidItemType:
 	pop		bx
-
-	jmp		[cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
-.InvalidItemType:
-	ret
+.InvokeWriter:
+	jmp		bx				; The Writer can freely corrupt BX
 
 ALIGN WORD_ALIGN
 .rgfnJumpToStoreValueBasedOnItemType:
-	dw		.InvalidItemType									; TYPE_MENUITEM_PAGEBACK
-	dw		.InvalidItemType									; TYPE_MENUITEM_PAGENEXT
-	dw		.InvalidItemType									; TYPE_MENUITEM_ACTION
+;	dw		.InvalidItemType									; TYPE_MENUITEM_PAGEBACK
+;	dw		.InvalidItemType									; TYPE_MENUITEM_PAGENEXT
+;	dw		.InvalidItemType									; TYPE_MENUITEM_ACTION
 	dw		.StoreMultichoiceValueFromAXtoESDIwithItemInDSSI	; TYPE_MENUITEM_MULTICHOICE
 	dw		.StoreByteOrWordValueFromAXtoESDIwithItemInDSSI		; TYPE_MENUITEM_UNSIGNED
@@ -237,5 +228,5 @@
 	jz		.StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
 
-	shl		ax, 1			; Shift for WORD lookup
+	eSHL_IM	ax, 1			; Shift for WORD lookup
 	add		bx, ax
 	mov		ax, [bx]		; Lookup complete
@@ -317,5 +308,5 @@
 ;		AX:		Menuitem value
 ;	Corrupts registers:
-;		BX
+;		Nothing
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -330,6 +321,6 @@
 	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
 	jz		SHORT .NoConvertWordToByteValue
-	xor		ah, ah				; conversion needs to happen before call to the reader,
-								; in case the reader unpacks the byte to a word
+	xor		ah, ah			; conversion needs to happen before call to the reader,
+							; in case the reader unpacks the byte to a word
 
 .NoConvertWordToByteValue:
@@ -338,5 +329,5 @@
 	jz		SHORT .NoReader
 
-	call	bx
+	call	bx				; The Reader can freely corrupt BX, DI and ES
 
 .NoReader:
