Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Variables.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Variables.inc	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Variables.inc	(revision 592)
@@ -34,5 +34,5 @@
 struc CFGVARS
 	.pMenupage			resb	2			; Offset to MENUPAGE to display
-	.wFlags				resb	2			; Program flags
+	.wFlags				resb	2			; Program flags - Only the low byte is used currently and code depend on this
 	.wImageSizeInWords	resb	2			; Size in words for loaded ROM or FILE
 	.wEepromSegment		resb	2			; Segment where EEPROM is located
@@ -44,5 +44,5 @@
 endstruc
 
-; Bit defines for CFGVARS.wFlags
+; Bit defines for CFGVARS.wFlags (changes here might require changes elsewhere)
 FLG_CFGVARS_FILELOADED	EQU		(1<<0)	; BIOS is loaded from file
 FLG_CFGVARS_ROMLOADED	EQU		(1<<1)	; BIOS is loaded from EEPROM
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm	(revision 592)
@@ -43,5 +43,5 @@
 	call	ResetIdevarsToDefaultValues
 	call	DetectIdePortsAndDevices
-	call	EnableInterruptsForPrimaryAndSecondaryControllers
+	call	EnableInterruptsForAllStandardControllers
 	call	StoreAndDisplayNumberOfControllers
 
@@ -55,4 +55,5 @@
 ;	Parameters:
 ;		DS:DI:	Ptr to ROMVARS
+;		ES:DI:	Ptr to ROMVARS
 ;	Returns:
 ;		Nothing
@@ -123,5 +124,5 @@
 
 ;--------------------------------------------------------------------
-; EnableInterruptsForPrimaryAndSecondaryControllers
+; EnableInterruptsForAllStandardControllers
 ;	Parameters:
 ;		DS:DI:	Ptr to ROMVARS
@@ -130,8 +131,8 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-EnableInterruptsForPrimaryAndSecondaryControllers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+EnableInterruptsForAllStandardControllers:
 	jcxz	.NoControllersDetected
 	call	Buffers_IsXTbuildLoaded
@@ -148,4 +149,17 @@
 	inc		ax	; 15
 	cmp		WORD [di+IDEVARS.wBasePort], DEVICE_ATA_SECONDARY_PORT
+
+%if 0
+	je		SHORT .EnableIrqAL
+
+	; Defaults on the GSI Inc. Model 2C EIDE controller
+	mov		al, 11
+	cmp		WORD [di+IDEVARS.wBasePort], DEVICE_ATA_TERTIARY_PORT
+	je		SHORT .EnableIrqAL
+
+	dec		ax	; 10
+	cmp		WORD [di+IDEVARS.wBasePort], DEVICE_ATA_QUATERNARY_PORT
+%endif
+
 	jne		SHORT .DoNotEnableIRQ
 
@@ -153,4 +167,5 @@
 	mov		[di+IDEVARS.bIRQ], al
 .DoNotEnableIRQ:
+	add		di, IDEVARS_size
 	loop	.CheckNextController
 	pop		cx
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm	(revision 592)
@@ -44,11 +44,10 @@
 	call	FileIO_CloseUsingHandleFromBX
 	call	DisplayFileLoadedSuccessfully
-	jmp		SHORT .Return
+	pop		ds
+	ret
 
 .DisplayErrorMessage:
 	call	FileIO_CloseUsingHandleFromBX
 	call	DisplayFailedToLoadFile
-ALIGN JUMP_ALIGN
-.Return:
 	pop		ds
 	ret
@@ -117,5 +116,7 @@
 	pop		es
 	mov		di, g_cfgVars+CFGVARS.szOpenedFile
+%ifdef CLD_NEEDED
 	cld
+%endif
 	call	String_CopyDSSItoESDIandGetLengthToCX
 	clc
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.asm	(revision 592)
@@ -49,7 +49,7 @@
 ALIGN JUMP_ALIGN
 Buffers_IsXtideUniversalBiosLoaded:
-	test	WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
+	test	BYTE [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
 	jnz		SHORT .FileOrBiosLoaded
-	or		cl, 1		; Clear ZF
+	test	sp, sp		; Clear ZF
 	ret
 
@@ -76,5 +76,7 @@
 	add		di, BYTE ROMVARS.rgbSign
 	mov		cx, XTIDE_SIGNATURE_LENGTH / 2
+%ifdef CLD_NEEDED
 	cld
+%endif
 	eSEG_STR repe, cs, cmpsw
 
@@ -91,11 +93,15 @@
 ;				Cleared if some other (AT, 386) build is loaded
 ;	Corrupts registers:
-;		DI, ES
+;		Nothing
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 Buffers_IsXTbuildLoaded:
 %strlen BUILD_TYPE_OFFSET	TITLE_STRING_START
+	push	es
+	push	di
 	call	Buffers_GetFileBufferToESDI
 	cmp		WORD [es:di+ROMVARS.szTitle+BUILD_TYPE_OFFSET+1], 'XT'	; +1 is for '('
+	pop		di
+	pop		es
 	ret
 %undef BUILD_TYPE_OFFSET
@@ -105,15 +111,15 @@
 ; Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
 ;	Parameters:
-;		AX:		EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
+;		AL:		EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
 ;		DX:CX:	EEPROM size in bytes
 ;	Returns:
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, DX
+;		CX, DX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration:
-	and		WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
-	or		WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
+	and		BYTE [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
+	or		[cs:g_cfgVars+CFGVARS.wFlags], al
 	shr		dx, 1
 	rcr		cx, 1
@@ -135,10 +141,10 @@
 ALIGN JUMP_ALIGN
 Buffers_SetUnsavedChanges:
-	or		WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
+	or		BYTE [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
 	ret
 
 ALIGN JUMP_ALIGN
 Buffers_ClearUnsavedChanges:
-	and		WORD [cs:g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
+	and		BYTE [cs:g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
 	ret
 
@@ -155,9 +161,10 @@
 ALIGN JUMP_ALIGN
 Buffers_SaveChangesIfFileLoaded:
-	mov		ax, [cs:g_cfgVars+CFGVARS.wFlags]
-	and		ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
-	cmp		ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
-	jne		SHORT .NothingToSave
-	call	Dialogs_DisplaySaveChangesDialog
+	mov		al, [cs:g_cfgVars+CFGVARS.wFlags]
+	and		al, FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED
+	jz		SHORT .NothingToSave
+	jpo		SHORT .NothingToSave
+	mov		bx, g_szDlgSaveChanges
+	call	Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX
 	jnz		SHORT .NothingToSave
 	jmp		BiosFile_SaveUnsavedChanges
@@ -181,5 +188,9 @@
 
 	eMOVZX	di, [cs:g_cfgVars+CFGVARS.bEepromType]
-	mov		cx, [cs:di+g_rgwEepromTypeToSizeInWords]
+;%if g_rgwEepromTypeToSizeInWords = 0	; *FIXME* It really is but NASM won't accept this.
+	mov		cx, [cs:di]
+;%else
+;	mov		cx, [cs:di+g_rgwEepromTypeToSizeInWords]
+;%endif
 	sub		cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]	; CX = WORDs to append
 	jbe		SHORT .NoNeedToAppendZeroes
@@ -187,8 +198,10 @@
 	call	Buffers_GetFileBufferToESDI
 	mov		ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
-	shl		ax, 1
+	eSHL_IM	ax, 1
 	add		di, ax			; ES:DI now point first unused image byte
 	xor		ax, ax
+%ifdef CLD_NEEDED
 	cld
+%endif
 	rep stosw
 ALIGN JUMP_ALIGN
@@ -214,4 +227,7 @@
 	call	Buffers_GetFileBufferToESDI
 	call	EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
+%ifdef CLD_NEEDED
+	cld
+%endif
 
 ; Compatibility fix for 3Com 3C503 cards where the ASIC returns 8080h as the last two bytes of the ROM.
@@ -223,6 +239,5 @@
 	jne		SHORT .BiosSizeIsNot8K
 	; The BIOS size is 8K and therefore a potential candidate for a 3Com 3C503 card.
-	dec		cx
-	dec		cx
+	mov		cl, (8192 - 3) & 0FFh
 	mov		ah, 3
 ALIGN JUMP_ALIGN
@@ -230,10 +245,9 @@
 .SumNextByte:
 	add		al, [es:di]
-.NextChecksumByte:
 	inc		di
 	loop	.SumNextByte
+.NextChecksumByte:
 	neg		al
-	mov		[es:di], al
-	inc		cx
+	stosb
 	dec		ah
 	jnz		SHORT .NextChecksumByte
@@ -306,7 +320,7 @@
 
 ;--------------------------------------------------------------------
-; Buffers_GetFileBufferToESDI
 ; Buffers_GetFlashComparisonBufferToESDI
 ; Buffers_GetFileDialogItemBufferToESDI
+; Buffers_GetFileBufferToESDI
 ;	Parameters:
 ;		Nothing
@@ -320,11 +334,6 @@
 Buffers_GetFileDialogItemBufferToESDI:
 	call	Buffers_GetFileBufferToESDI
-	push	di
 	mov		di, es
-	add		di, 1000h		; Third 64k page
-	mov		es, di
-	pop		di
-	ret
-ALIGN JUMP_ALIGN
+	SKIP2B	f
 Buffers_GetFileBufferToESDI:
 	mov		di, cs
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm	(revision 592)
@@ -41,5 +41,4 @@
 	mov		cx, DIALOG_INPUT_size
 	call	Memory_ReserveCXbytesFromStackToDSSI
-	call	InitializeDialogInputFromDSSI
 	mov		[si+DIALOG_INPUT.fszTitle], di
 	jmp		SHORT DisplayMessageDialogWithMessageInCSDXandDialogInputInDSSI
@@ -65,5 +64,4 @@
 	mov		cx, DIALOG_INPUT_size
 	call	Memory_ReserveCXbytesFromStackToDSSI
-	call	InitializeDialogInputFromDSSI
 	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szNotificationDialog
 	jmp		SHORT DisplayMessageDialogWithMessageInCSDXandDialogInputInDSSI
@@ -123,7 +121,7 @@
 
 ;--------------------------------------------------------------------
-; Dialogs_DisplayQuitDialog
-; Dialogs_DisplaySaveChangesDialog
+; Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX
 ;	Parameters:
+;		BX:		Offset to dialog title string
 ;		SS:BP:	Menu handle
 ;	Returns:
@@ -134,5 +132,5 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-Dialogs_DisplayQuitDialog:
+Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX:
 	push	ds
 
@@ -140,21 +138,9 @@
 	call	Memory_ReserveCXbytesFromStackToDSSI
 	call	InitializeDialogInputFromDSSI
-	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szDlgExitToDos
-	jmp		Dialogs_DisplayQuitAndSaveChangesDialogsSharedEnding
-
-
-ALIGN JUMP_ALIGN
-Dialogs_DisplaySaveChangesDialog:
-	push	ds
-
-	mov		cx, DIALOG_INPUT_size
-	call	Memory_ReserveCXbytesFromStackToDSSI
-	call	InitializeDialogInputFromDSSI
-	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szDlgSaveChanges
-Dialogs_DisplayQuitAndSaveChangesDialogsSharedEnding:
+	mov		[si+DIALOG_INPUT.fszTitle], bx
 	mov		WORD [si+DIALOG_INPUT.fszItems], g_szMultichoiceBooleanFlag
 	CALL_MENU_LIBRARY GetSelectionToAXwithInputInDSSI
 	add		sp, BYTE DIALOG_INPUT_size
-	cmp		ax, BYTE 1		; 1 = YES
+	dec		ax				; -1 = NO, 0 = YES
 
 	pop		ds
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm	(revision 592)
@@ -50,5 +50,5 @@
 ;		DX:CX:	BIOS size in bytes
 ;	Corrupts registers:
-;		AX, BX, SI, DI
+;		BX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -61,5 +61,4 @@
 	call	LoadBytesFromRomToRamBuffer
 
-	call	EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
 	pop		es
 	ret
@@ -90,8 +89,8 @@
 ;		Nothing
 ;	Returns:
-;		CF:		Set if EEPROM was found
-;				Cleared if EEPROM not found
-;	Corrupts registers:
-;		AX, BX, CX, SI, DI
+;		CF:		Cleared if EEPROM was found
+;				Set if EEPROM not found
+;	Corrupts registers:
+;		BX, CX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -107,8 +106,8 @@
 ;		SI:		Offset to first byte to load
 ;	Returns:
-;		CF:		Set if EEPROM was found
-;				Cleared if EEPROM not found
-;	Corrupts registers:
-;		AX, BX, CX, SI
+;		CF:		Cleared if EEPROM was found
+;				Set if EEPROM not found
+;	Corrupts registers:
+;		BX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -119,5 +118,5 @@
 
 	call	EEPROM_FindXtideUniversalBiosROMtoESDI
-	jnc		SHORT .XtideUniversalBiosNotFound
+	jc		SHORT .XtideUniversalBiosNotFound
 	push	es
 	pop		ds											; DS:SI points to ROM
@@ -126,7 +125,8 @@
 	mov		di, si										; ES:DI points to RAM buffer
 
+%ifdef CLD_NEEDED
 	cld
-	call	Memory_CopyCXbytesFromDSSItoESDI
-	stc
+%endif
+	call	Memory_CopyCXbytesFromDSSItoESDI			; Clears CF
 
 .XtideUniversalBiosNotFound:
@@ -143,8 +143,8 @@
 ;	Returns:
 ;		ES:DI:	EEPROM segment
-;		CF:		Set if EEPROM was found
-;				Cleared if EEPROM not found
-;	Corrupts registers:
-;		AX, BX
+;		CF:		Cleared if EEPROM was found
+;				Set if EEPROM not found
+;	Corrupts registers:
+;		BX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -159,13 +159,8 @@
 	mov		es, bx					; Possible ROM segment to ES
 	call	Buffers_IsXtideUniversalBiosSignatureInESDI
-	je		SHORT .RomFound
+	je		SHORT .RomFound			; If equal, CF=0
 	add		bx, 80h					; Increment by 2kB (minimum possible distance from the beginning of one option ROM to the next)
 	jnc		SHORT .SegmentLoop		; Loop until segment overflows
-	clc
-	jmp		SHORT .ReturnWithoutUpdatingCF
-ALIGN JUMP_ALIGN
 .RomFound:
-	stc
-.ReturnWithoutUpdatingCF:
 	pop		cx
 	pop		si
@@ -191,6 +186,12 @@
 	call	Buffers_GetFlashComparisonBufferToESDI
 	eMOVZX	bx, [cs:g_cfgVars+CFGVARS.bEepromType]
-	mov		cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
+%ifdef CLD_NEEDED
 	cld
+%endif
+;%if g_rgwEepromTypeToSizeInWords = 0	; *FIXME* It really is but NASM won't accept this.
+	mov		cx, [cs:bx]
+;%else
+;	mov		cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
+;%endif
 	rep movsw
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Flash.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Flash.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Flash.asm	(revision 592)
@@ -78,5 +78,7 @@
 ALIGN JUMP_ALIGN
 Flash_SinglePageWithFlashvarsInSSBP:
+%ifdef CLD_NEEDED
 	cld
+%endif
 	call	AreSourceAndDestinationPagesEqualFromFlashvarsInSSBP
 	je		SHORT .NoNeedToFlashThePage	; CF cleared
@@ -305,53 +307,21 @@
 ALIGN JUMP_ALIGN
 WaitUntilEepromPageWriteHasCompleted:
-	call	.InitializeTimeoutCounterForEepromPollingWithFlashvarsInSSBP
-	mov		es, [bp+FLASHVARS.fpNextDestinationPage+2]
-	mov		di, [bp+FLASHVARS.wLastOffsetWritten]
-ALIGN JUMP_ALIGN
-.PollEeprom:
-	call	.HasWriteCycleCompleted
-	je		SHORT .PageWriteCompleted	; CF cleared
-	call	TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
-	jnc		SHORT .PollEeprom
-ALIGN JUMP_ALIGN
-.PageWriteCompleted:
-	ret
-
-;--------------------------------------------------------------------
-; .InitializeTimeoutCounterForEepromPollingWithFlashvarsInSSBP
-;	Parameters:
-;		SS:BP:	Ptr to FLASHVARS
-;	Returns:
-;		DS:BX:	Ptr to timeout counter variable
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.InitializeTimeoutCounterForEepromPollingWithFlashvarsInSSBP:
 	push	ss
 	pop		ds
 	lea		bx, [bp+FLASHVARS.wTimeoutCounter]
 	mov		ax, EEPROM_POLLING_TIMEOUT_TICKS
-	jmp		TimerTicks_InitializeTimeoutFromAX
-
-;--------------------------------------------------------------------
-; .HasWriteCycleCompleted
-;	Parameters:
-;		ES:DI:	Ptr to last written byte in EEPROM
-;		SS:BP:	Ptr to FLASHVARS
-;	Returns:
-;		ZF:		Set if write cycle has completed
-;				Cleared if write cycle in progress
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.HasWriteCycleCompleted:
-	mov		ah, [es:di]		; Load byte from EEPROM
-	mov		al, [bp+FLASHVARS.bLastByteWritten]
-	and		ax, 8080h		; Clear all but bit 7 from both bytes
-	cmp		al, ah			; Set ZF if high bits are the same
-	ret
-
+	call	TimerTicks_InitializeTimeoutFromAX
+	mov		es, [bp+FLASHVARS.fpNextDestinationPage+2]
+	mov		di, [bp+FLASHVARS.wLastOffsetWritten]
+ALIGN JUMP_ALIGN
+.PollEeprom:
+	mov		al, [es:di]							; Load byte from EEPROM
+	xor		al, [bp+FLASHVARS.bLastByteWritten]	; Clear SF if the most significant bits are the same
+	jns		SHORT .PageWriteCompleted			; With CF cleared
+	call	TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
+	jnc		SHORT .PollEeprom
+ALIGN JUMP_ALIGN, ret
+.PageWriteCompleted:
+	ret
 
 ;--------------------------------------------------------------------
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm	(revision 592)
@@ -118,6 +118,6 @@
 	; example Promise FloppyMAX has Control Block at STANDARD_CONTROL_BLOCK_OFFSET but Sound Blaster 16 (CT2290)
 	; use DEVICE_ATA_SECONDARY_PORTCTRL for Tertiary and Quaternary even though only Secondary should use that.
-	call	ChangeDifferentControlBlockAddressToSI
-	je		SHORT .RedetectTertiaryOrQuaternaryWithDifferentControlBlockAddress
+	call	ChangeControlBlockAddressInSI
+	jz		SHORT .RedetectTertiaryOrQuaternaryWithDifferentControlBlockAddress
 
 
@@ -130,5 +130,5 @@
 	mov		si, dx
 	add		si, BYTE XTCF_CONTROL_BLOCK_OFFSET
-	shl		bx, 1						; SHL 1 register offsets for XT-CF
+	eSHL_IM	bx, 1						; SHL 1 register offsets for XT-CF
 	call	DetectIdeDeviceFromPortsDXandSIwithOffsetsInBLandBH
 	mov		al, DEVICE_8BIT_XTCF_PIO8
@@ -233,5 +233,5 @@
 
 ;--------------------------------------------------------------------
-; ChangeDifferentControlBlockAddressToSI
+; ChangeControlBlockAddressInSI
 ;	Parameters:
 ;		DX:		IDE Base Port address
@@ -241,7 +241,7 @@
 ;				Cleared if different control block address is not possible
 ;	Corrupts registers:
-;		AH
-;--------------------------------------------------------------------
-ChangeDifferentControlBlockAddressToSI:
+;		Nothing
+;--------------------------------------------------------------------
+ChangeControlBlockAddressInSI:
 	cmp		si, 368h
 	je		SHORT .TrySecondAlternative
@@ -252,6 +252,5 @@
 	je		SHORT .TryLastAlternative
 	cmp		si, 3E0h
-	je		SHORT .TryLastAlternative
-	ret		; Return with ZF cleared
+	jne		SHORT .Return	; With ZF cleared
 
 .TryLastAlternative:
@@ -260,5 +259,6 @@
 .TrySecondAlternative:
 	sub		si, BYTE 8h		; 368h to 360h, 3E8h to 3E0h
-	xor		ah, ah			; Set ZF
+	cmp		sp, sp			; Set ZF
+.Return:
 	ret
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm	(revision 592)
@@ -132,5 +132,5 @@
 	call	Buffers_Clear
 	call	EEPROM_FindXtideUniversalBiosROMtoESDI
-	jnc		SHORT .InitializationCompleted
+	jc		SHORT .InitializationCompleted
 	mov		[CFGVARS.wEepromSegment], es
 .InitializationCompleted:
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm	(revision 592)
@@ -84,7 +84,6 @@
 	pop		ds
 
-	mov		WORD [si+MENUINIT.wItems], ax
-	mov		WORD [si+MENUINIT.bTitleLines], TITLE_LINES_IN_MENU
-	mov		WORD [si+MENUINIT.bInfoLines], INFO_LINES_IN_MENU
+	mov		[si+MENUINIT.wItems], ax
+	mov		WORD [si+MENUINIT.wTitleAndInfoLines], INFO_LINES_IN_MENU << 8 | TITLE_LINES_IN_MENU
 	mov		BYTE [si+MENUINIT.bWidth], MENU_WIDTH
 	CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
@@ -112,5 +111,6 @@
 ALIGN JUMP_ALIGN
 .QuitProgram:
-	call	Dialogs_DisplayQuitDialog
+	mov		bx, g_szDlgExitToDos
+	call	Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX
 	jz		SHORT .ExitToDOS
 	clc
@@ -169,6 +169,7 @@
 ALIGN JUMP_ALIGN
 .RefreshItemFromCX:
-	cmp		cx, NO_ITEM_HIGHLIGHTED
-	je		SHORT .NothingToRefresh
+	inc		cx					; NO_ITEM_HIGHLIGHTED ?
+	jz		SHORT .NothingToRefresh
+	dec		cx
 	call	Menupage_GetActiveMenupageToDSDI
 	call	Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
@@ -185,6 +186,7 @@
 ALIGN JUMP_ALIGN
 .RefreshInformation:
-	cmp		cx, NO_ITEM_HIGHLIGHTED
-	je		SHORT .NothingToRefresh
+	inc		cx					; NO_ITEM_HIGHLIGHTED ?
+	jz		SHORT .NothingToRefresh
+	dec		cx
 	call	Menupage_GetActiveMenupageToDSDI
 	call	Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
@@ -213,8 +215,8 @@
 ALIGN JUMP_ALIGN
 .PrintLoadStatus:
-	mov		ax, [g_cfgVars+CFGVARS.wFlags]
-	test	ax, FLG_CFGVARS_FILELOADED
+	mov		al, [g_cfgVars+CFGVARS.wFlags]
+	test	al, FLG_CFGVARS_FILELOADED
 	jnz		SHORT .PrintNameOfLoadedFile
-	test	ax, FLG_CFGVARS_ROMLOADED
+	test	al, FLG_CFGVARS_ROMLOADED
 	mov		si, g_szEEPROM
 	jnz		SHORT .PrintNameOfLoadedFileOrEeprom
@@ -253,5 +255,5 @@
 ALIGN JUMP_ALIGN
 .PrintStatusOfUnsavedChanges:
-	test	WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
+	test	BYTE [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
 	jz		SHORT .ReturnSinceNothingToPrint
 	mov		si, g_szUnsaved
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm	(revision 590)
+++ 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:
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuitemPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuitemPrint.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuitemPrint.asm	(revision 592)
@@ -168,5 +168,5 @@
 MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI:
 	call	Menuitem_GetValueToAXfromMenuitemInDSSI
-	shl		ax, 1
+	eSHL_IM	ax, 1
 	jmp		SHORT PrintLookupValueFromAXtoBufferInESDI
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/BootMenuSettingsMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/BootMenuSettingsMenu.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/BootMenuSettingsMenu.asm	(revision 592)
@@ -1,4 +1,4 @@
 ; Project name	:	XTIDE Universal BIOS Configurator v2
-; Description	:	"Boot Menu Settings" menu structs and functions.
+; Description	:	"Boot settings" menu structs and functions.
 
 ;
@@ -26,5 +26,5 @@
 	at	MENUPAGE.fnEnter,			dw	BootMenuSettingsMenu_EnterMenuOrModifyItemVisibility
 	at	MENUPAGE.fnBack,			dw	ConfigurationMenu_EnterMenuOrModifyItemVisibility
-	at	MENUPAGE.wMenuitems,		dw	6
+	at	MENUPAGE.wMenuitems,		dw	7
 iend
 
@@ -55,4 +55,22 @@
 iend
 
+g_MenuitemBootMnuStngsColorTheme:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemColorTheme
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoColorTheme
+	at	MENUITEM.szHelp,			dw	g_szHelpColorTheme
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOICE
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	ROMVARS.pColorTheme		; Only ever read - never modified
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgColorTheme
+	at	MENUITEM.itemValue + ITEM_VALUE.szMultichoice,				dw	g_szMultichoiceColorTheme
+	at	MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,	dw	g_rgszValueToStringLookupForColorTheme
+	at	MENUITEM.itemValue + ITEM_VALUE.fnValueReader,				dw	ReadColorTheme
+	at	MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,				dw	WriteColorTheme
+iend
+
 g_MenuitemBootMnuStngsFloppyDrives:
 istruc MENUITEM
@@ -116,9 +134,4 @@
 	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	1092
 iend
-
-
-g_rgwChoiceToValueLookupForEnableBootMenu:
-	dw	FALSE
-	dw	BOOT_MENU_DEFAULT_TIMEOUT
 
 g_rgwChoiceToValueLookupForDisplayModes:
@@ -146,4 +159,64 @@
 	dw	g_szValueBootFloppyDrvs4
 
+g_rgszValueToStringLookupForColorTheme:
+	dw	g_szValueColorTheme0
+	dw	g_szValueColorTheme1
+	dw	g_szValueColorTheme2
+	dw	g_szValueColorTheme3
+	dw	g_szValueColorTheme4
+	dw	g_szValueColorTheme5
+
+ColorThemeTable:
+	; Classic (default)
+	db	COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_BLUE)							; .cBordersAndBackground
+	db	COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)							; .cShadow
+	db	COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLUE)						; .cTitle
+	db	COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLUE)							; .cItem
+	db	COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_CYAN)						; .cHighlightedItem
+	db	COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLUE) | FLG_COLOR_BLINK			; .cHurryTimeout
+	db	COLOR_ATTRIBUTE(COLOR_GREEN, COLOR_BLUE)							; .cNormalTimeout
+	; Argon Blue
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_BLUE, COLOR_BLACK)						; .cBordersAndBackground
+	db	COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)							; .cShadow
+	db	COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)					; .cTitle
+	db	COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)							; .cItem
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_BLUE, COLOR_BLACK)						; .cHighlightedItem
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_BLUE, COLOR_BLACK) | FLG_COLOR_BLINK	; .cHurryTimeout
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_BLUE, COLOR_BLACK)						; .cNormalTimeout
+	; Neon Red
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK)						; .cBordersAndBackground
+	db	COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)							; .cShadow
+	db	COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)					; .cTitle
+	db	COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)							; .cItem
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK)						; .cHighlightedItem
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK) | FLG_COLOR_BLINK		; .cHurryTimeout
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK)						; .cNormalTimeout
+	; Phosphor Green
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)						; .cBordersAndBackground
+	db	COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)							; .cShadow
+	db	COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)					; .cTitle
+	db	COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)							; .cItem
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)						; .cHighlightedItem
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK) | FLG_COLOR_BLINK	; .cHurryTimeout
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)						; .cNormalTimeout
+	; Moon Surface
+	db	COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)							; .cBordersAndBackground
+	db	COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)							; .cShadow
+	db	COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)					; .cTitle
+	db	COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)							; .cItem
+	db	COLOR_ATTRIBUTE(COLOR_BROWN, COLOR_BLACK)							; .cHighlightedItem
+	db	COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK) | FLG_COLOR_BLINK	; .cHurryTimeout
+	db	COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)							; .cNormalTimeout
+	; Toxic Waste
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)						; .cBordersAndBackground
+	db	COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)							; .cShadow
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)						; .cTitle
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_CYAN, COLOR_BLACK)						; .cItem
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_CYAN, COLOR_BLUE)						; .cHighlightedItem
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK) | FLG_COLOR_BLINK		; .cHurryTimeout
+	db	COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK)						; .cNormalTimeout
+EndOfColorThemeTable:
+CountOfThemes	equ		(EndOfColorThemeTable-ColorThemeTable) / ATTRIBUTE_CHARS_size
+
 
 ; Section containing code
@@ -166,4 +239,5 @@
 	call	.EnableOrDisableScanForSerialDrives
 	call	.EnableOrDisableDefaultBootDrive
+	call	.EnableOrDisableColorThemeSelection
 	call	.EnableOrDisableBootMenuSelectionTimeout
 	mov		si, g_MenupageForBootMenuSettingsMenu
@@ -202,4 +276,21 @@
 	mov		bx, g_MenuitemBootMnuStngsDefaultBootDrive
 	test	ax, FLG_ROMVARS_MODULE_HOTKEYS | FLG_ROMVARS_MODULE_BOOT_MENU
+	jmp		SHORT .DisableMenuitemFromCSBXifZFset
+
+
+;--------------------------------------------------------------------
+; .EnableOrDisableColorThemeSelection
+;	Parameters:
+;		AX:		ROMVARS.wFlags
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableColorThemeSelection:
+	mov		bx, g_MenuitemBootMnuStngsColorTheme
+	test	ax, FLG_ROMVARS_MODULE_BOOT_MENU
 	jmp		SHORT .DisableMenuitemFromCSBXifZFset
 
@@ -244,19 +335,92 @@
 
 ;--------------------------------------------------------------------
-; MENUITEM value reader functions
-;	Parameters:
-;		AX:		Value from MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset
-;		DS:SI:	Ptr to MENUITEM
-;		ES:DI:	Ptr to value variable
-;	Returns:
-;		AX:		Value with possible modifications
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-ValueReaderForEnableBootMenu:
-	test	ax, ax
-	jz		SHORT .NoNeedToModify
-	mov		ax, TRUE<<1
-.NoNeedToModify:
+; ReadColorTheme
+;	Parameters:
+;		AX:		Value read from the ROMVARS location
+;		ES:DI:	ROMVARS location where the value was just read from
+;		DS:SI:	MENUITEM pointer
+;	Returns:
+;		AX:		Value that the MENUITEM system will interact with and display
+;	Corrupts registers:
+;		BX, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+ReadColorTheme:
+	push	ds
+
+	push	es							; ES -> DS
+	pop		ds
+	push	cs							; CS -> ES
+	pop		es
+
+	mov		di, EndOfColorThemeTable-1	; ES:DI now points to the end of the last theme in the table of available themes in XTIDECFG
+	xor		bx, bx
+
+	push	si
+	push	cx
+	mov		cx, CountOfThemes
+	std
+.NextTheme:
+	push	cx
+	mov		cl, ATTRIBUTE_CHARS_size
+	mov		si, ax						; [ROMVARS.pColorTheme] to SI
+	dec		si
+	add		si, cx						; DS:SI now points to the end of the ColorTheme in the loaded BIOS
+	sub		di, bx						; Update the pointer to the end of the next theme in the table
+
+	; We verify that the theme in the loaded BIOS exists in our table. If it doesn't exist then that most likely means
+	; the loaded BIOS doesn't contain MODULE_BOOT_MENU and the theme actually isn't a theme - it's code. Either way,
+	; we don't trust it enough to copy it over as corrupt/invalid settings could render the UI in XTIDECFG unreadable.
+	repe	cmpsb
+	mov		bx, cx
+	pop		cx
+	loopne	.NextTheme
+	cld
+	mov		ax, cx
+	jne		SHORT .SkipCopy
+
+	; Copy the color theme fron the loaded BIOS overwriting XTIDECFG's own theme
+	inc		si
+	mov		di, ColorTheme				; ES:DI now points to ColorTheme in XTIDECFG
+
+	mov		cl, ATTRIBUTE_CHARS_size
+	call	Memory_CopyCXbytesFromDSSItoESDI
+
+.SkipCopy:
+	pop		cx
+	pop		si
+	pop		ds
 	ret
+
+
+;--------------------------------------------------------------------
+; WriteColorTheme
+;	Parameters:
+;		AX:		Value that the MENUITEM system was interacting with
+;		ES:DI:	ROMVARS location where the value is to be stored
+;		DS:SI:	MENUITEM pointer
+;	Returns:
+;		AX:		Value to actually write to ROMVARS
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+WriteColorTheme:
+	push	cx
+	push	si
+	push	di
+
+	mov		cx, ATTRIBUTE_CHARS_size
+	mul		cl							; Multiply with the menu choice index
+	mov		si, ColorThemeTable
+	add		si, ax
+	mov		ax, [es:di]					; Fetch the ptr to ColorTheme
+	mov		di, ax
+
+	call	Memory_CopyCXbytesFromDSSItoESDI
+
+	pop		di
+	pop		si
+	pop		cx
+	ret
+
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm	(revision 592)
@@ -245,5 +245,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		BX, DI, ES
+;		BX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -262,5 +262,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, CX
+;		AX, BX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -268,5 +268,5 @@
 	call	Buffers_GetRomvarsFlagsToAX
 	mov		bx, g_MenuitemConfigurationKiBtoStealFromRAM
-	test	ax, FLG_ROMVARS_FULLMODE
+	test	al, FLG_ROMVARS_FULLMODE
 	jz		SHORT .DisableMenuitemFromCSBX
 	jmp		SHORT .EnableMenuitemFromCSBX
@@ -319,4 +319,20 @@
 ;		All, except segments
 ;--------------------------------------------------------------------
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+%if (ROMVARS.ideVars0 | ROMVARS.ideVars1 | ROMVARS.ideVars2 | ROMVARS.ideVars3) & 0FF00h = 0
+PrimaryIdeController:
+	mov		bl, ROMVARS.ideVars0 & 0FFh
+	SKIP2B	f
+SecondaryIdeController:
+	mov		bl, ROMVARS.ideVars1 & 0FFh
+	SKIP2B	f
+TertiaryIdeController:
+	mov		bl, ROMVARS.ideVars2 & 0FFh
+	SKIP2B	f
+QuaternaryIdeController:
+	mov		bl, ROMVARS.ideVars3 & 0FFh
+	xor		bh, bh
+	; Fall to DisplayIdeControllerMenu
+%else
 ALIGN JUMP_ALIGN
 PrimaryIdeController:
@@ -338,4 +354,6 @@
 	mov		bx, ROMVARS.ideVars3
 	; Fall to DisplayIdeControllerMenu
+%endif
+%endif
 
 ALIGN JUMP_ALIGN
@@ -383,5 +401,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		All
+;		AX, BX, CX, DX
 ;----------------------------------------------------------------------
 ConfigurationMenu_CheckAndMoveSerialDrivesToBottom:
@@ -428,10 +446,9 @@
 ; move serial to end of list, others up
 ;
+%ifdef CLD_NEEDED
 	cld
-
+%endif
 	mov		ax, di						; save end pointer of list after scan
-
 	sub		sp, IDEVARS_size			; copy serial to temporary space on stack
-
 	mov		di, sp
 
@@ -439,4 +456,5 @@
 	pop		es
 
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 %if IDEVARS_size & 1
 	mov		cl, IDEVARS_size
@@ -446,7 +464,7 @@
 	rep movsw
 %endif
+%endif
 
 	lea		di, [si-IDEVARS_size]		; move up all the idevars below the serial, by one slot
-
 	mov		cx, ax						; restore end pointer of list, subtract off end of serial idevars
 	sub		cx, si
@@ -462,4 +480,5 @@
 	; di is already at last IDEVARS position
 
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 %if IDEVARS_size & 1
 	mov		cl, IDEVARS_size
@@ -469,4 +488,5 @@
 	rep movsw
 %endif
+%endif
 
 	add		sp, IDEVARS_size
@@ -476,5 +496,4 @@
 
 	mov		dh, 1						; set flag that we have done a relocation
-
 	jmp		SHORT .outerLoop
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm	(revision 592)
@@ -185,21 +185,19 @@
 	pop		ds
 
-	cmp		WORD [cs:g_cfgVars+CFGVARS.wEepromSegment], 0
-	jne		.alreadySet
+	cmp		WORD [g_cfgVars+CFGVARS.wEepromSegment], 0
+	jne		SHORT .AlreadySet
 
 	push	es
 	push	di
 	call	EEPROM_FindXtideUniversalBiosROMtoESDI
-	push	es
-	pop		ax
+	mov		ax, es
 	pop		di
 	pop		es
-	jc		.storeEepromSegment
+	jnc		SHORT .StoreEepromSegment
 	mov		ax, DEFAULT_EEPROM_SEGMENT
-.storeEepromSegment:
-	mov		WORD [cs:g_cfgVars+CFGVARS.wEepromSegment], ax
-
-.alreadySet:
-
+.StoreEepromSegment:
+	mov		[g_cfgVars+CFGVARS.wEepromSegment], ax
+
+.AlreadySet:
 	mov		si, g_MenupageForFlashMenu
 	jmp		Menupage_ChangeToNewMenupageInDSSI
@@ -256,4 +254,5 @@
 ALIGN JUMP_ALIGN, ret
 .ImageFitsInSelectedEeprom:
+.DoNotGenerateChecksumByte:
 	ret
 
@@ -271,9 +270,7 @@
 	call	EEPROM_LoadFromRomToRamComparisonBuffer
 	call	Buffers_AppendZeroesIfNeeded
-	test	WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_CHECKSUM
+	test	BYTE [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_CHECKSUM
 	jz		SHORT .DoNotGenerateChecksumByte
 	jmp		Buffers_GenerateChecksum
-.DoNotGenerateChecksumByte:
-	ret
 
 ;--------------------------------------------------------------------
@@ -349,5 +346,9 @@
 .GetSelectedEepromSizeInWordsToAX:
 	eMOVZX	bx, [cs:g_cfgVars+CFGVARS.bEepromType]
-	mov		ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
+;%if g_rgwEepromTypeToSizeInWords = 0	; *FIXME* It really is but NASM won't accept this.
+	mov		ax, [cs:bx]
+;%else
+;	mov		ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
+;%endif
 	ret
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm	(revision 592)
@@ -135,5 +135,5 @@
 	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgIdeCmdPort
 	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	8h
-	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	3f8h
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	3F8h
 	at	MENUITEM.itemValue + ITEM_VALUE.fnValueReader,				dw	IdeControllerMenu_SerialReadPort
 	at	MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,				dw	IdeControllerMenu_SerialWritePort
@@ -306,9 +306,19 @@
 	mov		[cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
 
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+%if IDEVARS.wBasePort = 0
+	mov		[cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], bx
+%else
 	lea		ax, [bx+IDEVARS.wBasePort]
 	mov		[cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
-
+%endif
+
+%if IDEVARS.bSerialPort = 0
+	mov		[cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], bx
+%else
 	lea		ax, [bx+IDEVARS.bSerialPort]
 	mov		[cs:g_MenuitemIdeControllerSerialPort+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+%endif
+%endif
 
 	lea		ax, [bx+IDEVARS.bSerialBaud]
@@ -361,5 +371,5 @@
 ALIGN JUMP_ALIGN
 .EnableOrDisableCommandBlockPort:
-	mov		bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	mov		bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
 	mov		bx, g_MenuitemIdeControllerCommandBlockAddress
@@ -380,5 +390,5 @@
 ALIGN JUMP_ALIGN
 .EnableOrDisableControlBlockPort:
-	mov		bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	mov		bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
 	mov		bx, g_MenuitemIdeControllerControlBlockAddress
@@ -404,5 +414,5 @@
 	jz		SHORT .DisableMenuitemFromCSBX
 
-	mov		bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	mov		bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
 	mov		bx, g_MenuitemIdeControllerEnableInterrupt
@@ -424,5 +434,5 @@
 ALIGN JUMP_ALIGN
 .EnableOrDisableIRQchannelSelection:
-	mov		bx, [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	mov		bx, [g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
 	mov		bx, g_MenuitemIdeControllerIdeIRQ
@@ -453,4 +463,13 @@
 
 
+;--------------------------------------------------------------------
+; .EnableOrDisableSerial
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
 .EnableOrDisableSerial:
 	mov		bx, g_MenuitemIdeControllerSerialBaud
@@ -463,8 +482,8 @@
 	call	DisableMenuitemFromCSBX
 
-	mov		bx, [cs:g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	mov		bx, [g_MenuitemIdeControllerDevice+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
 	cmp		al, DEVICE_SERIAL_PORT
-	jne		.DisableAllSerial
+	jne		SHORT .DisableAllSerial
 
 	mov		bx, g_MenuitemIdeControllerSerialCOM
@@ -474,5 +493,5 @@
 	call	EnableMenuitemFromCSBX
 
-	mov		bx, [cs:g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	mov		bx, [g_MenuitemIdeControllerSerialCOM+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
 	mov		bx, g_MenuitemIdeControllerSerialPort
@@ -483,4 +502,5 @@
 	ret
 
+
 ;--------------------------------------------------------------------
 ; MENUITEM activation functions (.fnActivate)
@@ -531,47 +551,21 @@
 	jmp		MasterSlaveMenu_EnterMenuOrModifyItemVisibility
 
-;------------------------------------------------------------------------------------------
-;
-; Reader/Writer Routines
-;
-; For serial drives, we pack the port number and baud rate into a single byte, and thus
-; we need to take care to properly read/write just the bits we need.  In addition, since
-; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
-; default the values stored in both these words when switching in and out of the Serial
-; device choice.
-;
-; Writers:
-;	Parameters:
-;		AX:		Value that the MENUITEM system was interacting with
-;		ES:DI:	ROMVARS location where the value is to be stored
+
+;--------------------------------------------------------------------
+; IdeControllerMenu_WriteDevice
+;
+; Sets default values to ports and other device dependent stuff
+;
+;	Parameters:
+;		AX:		IDE controller/Device type menu choice index
+;		ES:DI:	Ptr to IDEVARS.bDevice
 ;		DS:SI:	MENUITEM pointer
 ;	Returns:
-;		AX:		Value to actually write to ROMVARS
-;	Corrupts registers:
-;		AX
-;
-; Readers:
-;	Parameters:
-;		AX:		Value read from the ROMVARS location
-;		ES:DI:	ROMVARS location where the value was just read from
-;		DS:SI:	MENUITEM pointer
-;	Returns:
-;		AX:		Value that the MENUITEM system will interact with and display
-;	Corrupts registers:
-;		AX
-;
-ALIGN JUMP_ALIGN
-WriterForXTCFwindow:
-	xor		al, al
-	SKIP2B	f
-ReaderForXTCFwindow:
-	xor		ah, ah
-	xchg	al, ah
-	ret
-
-
+;		AX:		IDE controller/Device type menu choice index
+;	Corrupts registers:
+;		BX, DX
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 IdeControllerMenu_WriteDevice:
-	push	bx
 	push	di
 	push	ax
@@ -581,7 +575,5 @@
 
 	; Note! AL is the choice index, not device code
-	shl		al, 1								; Selection to device code
-
-	; Restore ports and other stuff to default values
+	eSHL_IM	al, 1								; Selection to device code
 	jz		SHORT .StandardIdeDevice			; DEVICE_16BIT_ATA
 
@@ -603,5 +595,5 @@
 	div		bl
 	mov		bx, .rgbLowByteOfStdIdeInterfacePorts
-	xlat
+	xlat										; DS=CS so no segment override needed
 	mov		ah, 1								; DEVICE_ATA_*_PORT >> 8
 	mov		bh, 3								; DEVICE_ATA_*_PORTCTRL >> 8
@@ -622,8 +614,6 @@
 
 .SupportForDeviceNotAvailable:
-	push	dx
 	mov		dx, g_szUnsupportedDevice
 	call	Dialogs_DisplayErrorFromCSDX
-	pop		dx
 
 	; Restore device type to the previous value
@@ -631,5 +621,6 @@
 	mov		al, bl								; Previous device type to AL
 	shr		al, 1								; Device code to choice index
-	jmp		SHORT .DoneWithNoChangeOfDevice
+	pop		di
+	ret
 
 .NotSerialDevice:
@@ -670,11 +661,15 @@
 
 .ChangingToSerial:
-	cmp		bl, DEVICE_SERIAL_PORT
-	je		SHORT .Done							; if we were already serial, nothing to do
-
+;
+; For serial drives, we pack the port number and baud rate into a single byte, and thus
+; we need to take care to properly read/write just the bits we need.  In addition, since
+; we use the Port/PortCtrl bytes in a special way for serial drives, we need to properly
+; default the values stored in both these words when switching in and out of the Serial
+; device choice.
+;
+	mov		al, SERIAL_DEFAULT_COM
 	mov		BYTE [es:di+IDEVARS.bSerialBaud-IDEVARS.wBasePort], SERIAL_DEFAULT_BAUD
-	mov		BYTE [es:di+IDEVARS.bIRQ-IDEVARS.wBasePort], 0	; Clear .bIRQ to keep the boot menu from printing it
-
-	mov		al, SERIAL_DEFAULT_COM
+	mov		[es:di+IDEVARS.bIRQ-IDEVARS.wBasePort], ah	; Clear .bIRQ to keep the boot menu from printing it
+
 	sub		di, IDEVARS.wBasePort - IDEVARS.bSerialCOMPortChar
 	call	IdeControllerMenu_SerialWriteCOM
@@ -683,53 +678,64 @@
 .Done:
 	pop		ax
-.DoneWithNoChangeOfDevice:
-	pop		di			; IDEVARS.bDevice
-	pop		bx
+	pop		di
 	ret
 
-;
-; Doesn't modify COM character (unless it is not recognized, which would be an error case),
-; But does update the port address based on COM port selection
-;
+
+;--------------------------------------------------------------------
+; IdeControllerMenu_SerialWriteCOM
+;
+; Updates the port address based on COM port selection
+;
+;	Parameters:
+;		AL:		COM port
+;		ES:DI:	Ptr to IDEVARS.bSerialCOMPortChar
+;		DS:SI:	MENUITEM pointer
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		BX
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 IdeControllerMenu_SerialWriteCOM:
 	push	ax
-	push	bx
 	push	si
 
-	mov		si, g_rgbChoiceToValueLookupForCOM
-	mov		bx, PackedCOMPortAddresses
-
-.loop:
-	mov		ah, [bx]
-
-	cmp		ah, (SERIAL_DEFAULT_CUSTOM_PORT >> 2)
-	je		.notFound
-
-	cmp		al, [si]
-	je		.found
-
+	mov		bx, PackedCOMPortAddresses - 1
+	mov		si, g_rgbChoiceToValueLookupForCOM - 2
+
+.Loop:
+	inc		bx
 	inc		si
 	inc		si
-	inc		bx
-
-	jmp		.loop
-
-.notFound:
-	mov		al, 'x'
-
-.found:
+
+	mov		ah, [bx]
+	cmp		ah, SERIAL_DEFAULT_CUSTOM_PORT >> 2
+	je		SHORT .NotFound
+
+	cmp		al, [si]
+	jne		SHORT .Loop
+
+.NotFound:
 	mov		[es:di+IDEVARS.bSerialPort-IDEVARS.bSerialCOMPortChar], ah
 
 	pop		si
-	pop		bx
 	pop		ax
-
 	ret
 
 
+;--------------------------------------------------------------------
+; IdeControllerMenu_SerialReadPort
 ;
 ; Packed Port (byte) -> Numeric Port (word)
 ;
+;	Parameters:
+;		AX:		Value read from the ROMVARS location
+;		ES:DI:	ROMVARS location where the value was just read from
+;		DS:SI:	MENUITEM pointer
+;	Returns:
+;		AX:		Value that the MENUITEM system will interact with and display
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 IdeControllerMenu_SerialReadPort:
@@ -738,39 +744,48 @@
 	ret
 
+
+;--------------------------------------------------------------------
+; IdeControllerMenu_SerialWritePort
 ;
 ; Numeric Port (word) -> Packed Port (byte)
-; And convert from Custom to a defined COM port if we match one of the pre-defined COM port numbers
-;
+;
+; And convert from Custom to a defined COM port if we
+; match one of the pre-defined COM port numbers
+;
+;	Parameters:
+;		AX:		Value that the MENUITEM system was interacting with
+;		ES:DI:	ROMVARS location where the value is to be stored
+;		DS:SI:	MENUITEM pointer
+;	Returns:
+;		AX:		Value to actually write to ROMVARS
+;	Corrupts registers:
+;		BX
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 IdeControllerMenu_SerialWritePort:
-	push	bx
 	push	si
 
 	eSHR_IM	ax, 2
-	and		al, 0feh			; force 8-byte boundary
-
-	mov		si, g_rgbChoiceToValueLookupForCOM
-	mov		bx, PackedCOMPortAddresses			; loop, looking for port address in known COM address list
-
-.loop:
-	mov		ah, [si]
-	cmp		ah, 'x'
-	je		.found
-
-	cmp		al, [bx]
-	je		.found
-
+	and		al, 0FEh							; Force 8-byte boundary
+
+	mov		si, g_rgbChoiceToValueLookupForCOM - 2
+	mov		bx, PackedCOMPortAddresses - 1		; Loop, looking for port address in known COM address list
+
+.Loop:
 	inc		si
 	inc		si
 	inc		bx
 
-	jmp		.loop
-
-.found:
+	mov		ah, [si]
+	cmp		ah, 'x'
+	je		SHORT .Found
+
+	cmp		al, [bx]
+	jne		SHORT .Loop
+
+.Found:
 	mov		[es:di+IDEVARS.bSerialCOMPortChar-IDEVARS.bSerialPort], ah
 
 	pop		si
-	pop		bx
-
 	ret
 
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MainMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MainMenu.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MainMenu.asm	(revision 592)
@@ -155,5 +155,5 @@
 .EnableOrDisableXtideRomItems:
 	call	EEPROM_FindXtideUniversalBiosROMtoESDI
-	jnc		SHORT .DisableAllRomItems
+	jc		SHORT .DisableAllRomItems
 	or		BYTE [g_MenuitemMainMenuLoadXtideUniversalBiosFromRom+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
 	call	Buffers_IsXtideUniversalBiosLoaded
@@ -201,5 +201,5 @@
 ALIGN JUMP_ALIGN
 .EnableOrDisableFlashEeprom:
-	test	WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
+	test	BYTE [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
 	jz		SHORT .DisableFlashEeprom
 	or		BYTE [g_MenuitemMainMenuFlashEeprom+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
@@ -222,5 +222,5 @@
 ALIGN JUMP_ALIGN
 .EnableOrDisableSave:
-	test	WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED
+	test	BYTE [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED
 	jz		SHORT .DisableSave
 	or		BYTE [g_MenuitemMainMenuSaveFile+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
@@ -257,4 +257,6 @@
 	add		si, BYTE FILE_DIALOG_IO.szFile
 	call	BiosFile_LoadFileFromDSSItoRamBuffer
+	call	LoadColorTheme
+	; *FIXME* Will load themes even from unrecognized versions of the BIOS which isn't really a problem but still 'unexpected behaviour' and therefore a bug.
 	call	MainMenu_EnterMenuOrModifyItemVisibility
 .CancelFileLoading:
@@ -272,4 +274,5 @@
 	mov		dx, g_szDlgMainLoadROM
 	call	Dialogs_DisplayNotificationFromCSDX
+	call	LoadColorTheme
 	jmp		MainMenu_EnterMenuOrModifyItemVisibility
 
@@ -281,4 +284,24 @@
 	call	Buffers_SetUnsavedChanges
 	mov		dx, g_szDlgMainLoadStngs
-	jmp		Dialogs_DisplayNotificationFromCSDX
-
+	call	Dialogs_DisplayNotificationFromCSDX
+	call	EEPROM_FindXtideUniversalBiosROMtoESDI
+	call	LoadColorTheme.FromROM
+	jmp		MainMenu_EnterMenuOrModifyItemVisibility
+
+
+;--------------------------------------------------------------------
+; LoadColorTheme
+;	Parameters:
+;		ES:		ROMVARS segment (only when loading theme from ROM)
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+LoadColorTheme:
+	call	Buffers_GetFileBufferToESDI
+.FromROM:
+	mov		ax, [es:ROMVARS.pColorTheme]
+	jmp		ReadColorTheme
+
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MasterSlaveMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MasterSlaveMenu.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MasterSlaveMenu.asm	(revision 592)
@@ -196,5 +196,4 @@
 	dw	DISABLE_WRITE_CACHE
 	dw	ENABLE_WRITE_CACHE
-
 g_rgszChoiceToStringLookupForWriteCache:
 	dw	g_szValueBootDispModeDefault
@@ -207,5 +206,4 @@
 	dw	TRANSLATEMODE_ASSISTED_LBA
 	dw	TRANSLATEMODE_AUTO
-
 g_rgszChoiceToStringLookupForXlateMode:
 	dw	g_szValueDrvXlateNormal
@@ -229,22 +227,35 @@
 ALIGN JUMP_ALIGN
 MasterSlaveMenu_InitializeToDrvparamsOffsetInBX:
+	push	ds
+
+	push	cs
+	pop		ds
+
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+%if DRVPARAMS.wFlags = 0
+	mov		ax, bx
+%else
 	lea		ax, [bx+DRVPARAMS.wFlags]
-	mov		[cs:g_MenuitemMasterSlaveBlockModeTransfers+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
-	mov		[cs:g_MenuitemMasterSlaveChsTranslateMode+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
-	mov		[cs:g_MenuitemMasterSlaveWriteCache+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
-	mov		[cs:g_MenuitemMasterSlaveUserCHS+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
-	mov		[cs:g_MenuitemMasterSlaveUserLBA+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+%endif
+%endif
+	mov		[g_MenuitemMasterSlaveBlockModeTransfers+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[g_MenuitemMasterSlaveChsTranslateMode+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[g_MenuitemMasterSlaveWriteCache+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[g_MenuitemMasterSlaveUserCHS+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[g_MenuitemMasterSlaveUserLBA+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
 
 	lea		ax, [bx+DRVPARAMS.wCylinders]
-	mov		[cs:g_MenuitemMasterSlaveCylinders+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[g_MenuitemMasterSlaveCylinders+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
 
 	lea		ax, [bx+DRVPARAMS.bHeads]
-	mov		[cs:g_MenuitemMasterSlaveHeads+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[g_MenuitemMasterSlaveHeads+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
 
 	lea		ax, [bx+DRVPARAMS.bSect]
-	mov		[cs:g_MenuitemMasterSlaveSectors+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[g_MenuitemMasterSlaveSectors+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
 
 	lea		ax, [bx+DRVPARAMS.dwMaximumLBA]
-	mov		[cs:g_MenuitemMasterSlaveUserLbaValue+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[g_MenuitemMasterSlaveUserLbaValue+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	pop		ds
 	ret
 
@@ -283,7 +294,7 @@
 	mov		bx, [g_MenuitemMasterSlaveUserLBA+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
-	test	ax, FLG_DRVPARAMS_USERLBA
+	test	al, FLG_DRVPARAMS_USERLBA
 	jnz		SHORT .DisableCHSandEnableLBA
-	test	ax, FLG_DRVPARAMS_USERCHS
+	test	al, FLG_DRVPARAMS_USERCHS
 	jnz		SHORT .EnableCHSandDisableLBA
 
@@ -320,9 +331,9 @@
 ALIGN JUMP_ALIGN
 .EnableOrDisableCHandS:
-	mov		bx, [cs:g_MenuitemMasterSlaveUserCHS+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	mov		bx, [g_MenuitemMasterSlaveUserCHS+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
-	test	ax, FLG_DRVPARAMS_USERCHS
+	test	al, FLG_DRVPARAMS_USERCHS
 	jz		SHORT .DisableCHandS
-	test	ax, FLG_DRVPARAMS_USERLBA
+	test	al, FLG_DRVPARAMS_USERLBA
 	jnz		SHORT .DisableCHandS
 
@@ -355,10 +366,10 @@
 ALIGN JUMP_ALIGN
 .EnableOrDisableUserLbaValue:
-	mov		bx, [cs:g_MenuitemMasterSlaveUserLBA+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	mov		bx, [g_MenuitemMasterSlaveUserLBA+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
 	mov		bx, g_MenuitemMasterSlaveUserLbaValue
-	test	ax, FLG_DRVPARAMS_USERCHS
+	test	al, FLG_DRVPARAMS_USERCHS
 	jnz		SHORT .DisableMenuitemFromCSBX
-	test	ax, FLG_DRVPARAMS_USERLBA
+	test	al, FLG_DRVPARAMS_USERLBA
 	jz		SHORT .DisableMenuitemFromCSBX
 	; Fall to .EnableMenuitemFromCSBX
@@ -443,6 +454,6 @@
 ALIGN JUMP_ALIGN
 MasterSlaveMenu_WriteCHSFlag:
-	test	word [es:di], FLG_DRVPARAMS_USERCHS
-	jnz		.alreadySet
+	test	BYTE [es:di], FLG_DRVPARAMS_USERCHS
+	jnz		SHORT .AlreadySet
 
 	push	ax
@@ -466,5 +477,5 @@
 	pop		ax
 
-.alreadySet:
+.AlreadySet:
 	ret
 
@@ -475,6 +486,6 @@
 ALIGN JUMP_ALIGN
 MasterSlaveMenu_WriteLBAFlag:
-	test	word [es:di], FLG_DRVPARAMS_USERLBA
-	jnz		.alreadySet
+	test	BYTE [es:di], FLG_DRVPARAMS_USERLBA
+	jnz		SHORT .AlreadySet
 
 	push	ax
@@ -490,4 +501,5 @@
 	pop		ax
 
-.alreadySet:
+.AlreadySet:
 	ret
+
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 592)
@@ -42,8 +42,8 @@
 g_szYes:							db	"Yes",NULL
 
-; Exit messages
+; General Yes/No response type dialog messages
 g_szDlgExitToDos:		db	"Exit to DOS?",NULL
 g_szDlgSaveChanges:		db	"Do you want to save changes to XTIDE Universal BIOS image file?",NULL
-
+g_szDlgDriveNotReady:	db	"Drive not ready! Retry?",NULL
 
 ; Generic dialog strings
@@ -92,10 +92,10 @@
 g_szNfoMainFlash:		db	"Flash loaded BIOS image to EEPROM.",NULL
 g_szNfoMainSave:		db	"Save BIOS changes back to original file from which it was loaded.",NULL
-g_szNfoMainLicense:		db	"XTIDE Universal BIOS and XTIDECFG Copyright (C) 2009-2010 by Tomi Tilli, 2011-2016 by XTIDE Universal BIOS Team."
+g_szNfoMainLicense:		db	"XTIDE Universal BIOS and XTIDECFG Copyright (C) 2009-2010 by Tomi Tilli, 2011-2018 by XTIDE Universal BIOS Team."
 						db	" Released under GNU GPL v2, with ABSOLUTELY NO WARRANTY. Press ENTER for more details...",NULL
 g_szNfoMainHomePage:	db	"Visit http://xtideuniversalbios.org (home page) and http://vcfed.org/forum (support)",NULL
 
 g_szHelpMainLicense:	db	"XTIDE Universal BIOS and XTIDECFG Configuration program are Copyright 2009-2010 by Tomi Tilli,"
-						db	" 2011-2016 by XTIDE Universal BIOS Team. Released under GNU GPL v2. This software comes with ABSOLUTELY NO WARRANTY."
+						db	" 2011-2018 by XTIDE Universal BIOS Team. Released under GNU GPL v2. This software comes with ABSOLUTELY NO WARRANTY."
 						db	" This is free software, and you are welcome to redistribute it under certain conditions."
 						db	" See the LICENSE.TXT file that was included with this distribution,"
@@ -423,4 +423,5 @@
 g_szItemBootDrive:		db	"Default boot drive",NULL
 g_szItemBootDispMode:	db	"Display Mode",NULL
+g_szItemColorTheme:		db	"Color Theme",NULL
 g_szItemBootFloppyDrvs:	db	"Number of Floppy Drives",NULL
 g_szItemSerialDetect:	db	"Scan for Serial Drives",NULL
@@ -429,4 +430,5 @@
 g_szDlgBootDrive:		db	"Enter default drive number (0xh for Floppy Drives, 8xh for Hard Disks).",NULL
 g_szDlgBootDispMode:	db	"Select display mode.",NULL
+g_szDlgColorTheme:		db	"Select color theme.",NULL
 g_szDlgBootFloppyDrvs:	db	"Select number of Floppy Drives in system.",NULL
 g_szDlgSerialDetect:	db	"Scan for serial drives?",NULL
@@ -435,4 +437,5 @@
 g_szNfoBootDrive:		db	"Default boot drive.",NULL
 g_szNfoDispMode:		db	"Display mode to set when booting.",NULL
+g_szNfoColorTheme:		db	"Color theme used by the boot menu and the hotkey bar.",NULL
 g_szNfoBootFloppyDrvs:	db	"Number of Floppy Drives in system.",NULL
 g_szNfoSerialDetect:	db	"Scans all standard COM ports for serial drives."
@@ -442,10 +445,13 @@
 						db	" When timer goes to zero, currently selected drive will be booted automatically."
 						db	" Timeout can be disabled by setting this to 0.",NULL
-
 g_szHelpBootDrive:		db	"Drive to be set selected by default when Boot Menu is displayed.",NULL
-
+g_szHelpColorTheme:		db	"Pick a theme from a list of several pre-defined themes to customize the colors used by the boot menu and, if"
+						db	" available, the hotkey bar. Selecting a theme or loading a BIOS, or its settings, from file or from ROM will"
+						db	" make XTIDECFG apply the theme to itself for easy preview. The ability to preview themes requires that"
+						db	" XTIDECFG is running in a display mode that can display colors. In other words, you may configure the"
+						db	" BIOS on a machine with a monochrome graphics adapter and not be able to preview the theme but the BIOS will"
+						db	" still use the selected theme when installed in a machine with a color graphics adapter.",NULL
 g_szHelpBootFloppyDrvs:	db	"Detecting the correct number of floppy drives might fail when using a floppy controller with its own BIOS."
 						db	" A minimum number of floppy drives can be specified to force non-detected drives to appear on boot menu.",NULL
-
 g_szHelpSerialDetect:	db	"Set to Yes, at the end of normal drive detection, COM ports 1-7 (in reverse order) will be scanned for a connection"
 						db	" to a serial drive server. This option provides flexibility with the COM port and baud rate to be used,"
@@ -468,4 +474,17 @@
 g_szValueBootDispModeCO80:		db	"CO80",NULL
 g_szValueBootDispModeMono:		db	"Mono",NULL
+
+g_szMultichoiceColorTheme:		db	"Classic (default)",LF
+								db	"Argon Blue",LF
+								db	"Neon Red",LF
+								db	"Phosphor Green",LF
+								db	"Moon Surface",LF
+								db	"Toxic Waste",NULL
+g_szValueColorTheme0:			db	"Classic",NULL
+g_szValueColorTheme1:			db	"Argon",NULL
+g_szValueColorTheme2:			db	"Neon",NULL
+g_szValueColorTheme3:			db	"Phosphor",NULL
+g_szValueColorTheme4:			db	"Moon",NULL
+g_szValueColorTheme5:			db	"Toxic",NULL
 
 g_szMultichoiceBootFloppyDrvs:	db	"Autodetect",LF
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile	(revision 590)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile	(revision 592)
@@ -100,5 +100,5 @@
 ASFLAGS += $(IHEADERS)			# Set header file directory paths
 ASFLAGS += -Worphan-labels		# Warn about labels without colon
-ASFLAGS += -O9					# Optimize operands to their shortest forms
+ASFLAGS += -Ox					# Optimize operands to their shortest forms
 
 
@@ -135,4 +135,4 @@
 xt_unused: xt
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT) -o"$(TARGET)_xt_unused.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS
-	@perl ..\tools\unused.pl $(TARGET)_xt.lst $(TARGET)_xt_unused.asm
+	@perl ..\Tools\unused.pl $(TARGET)_xt.lst $(TARGET)_xt_unused.asm
 
