Index: /trunk/Assembly_Library/Inc/BiosFunctions.inc
===================================================================
--- /trunk/Assembly_Library/Inc/BiosFunctions.inc	(revision 591)
+++ /trunk/Assembly_Library/Inc/BiosFunctions.inc	(revision 592)
@@ -6,4 +6,5 @@
 ; BIOS interrupts
 BIOS_VIDEO_INTERRUPT_10h		EQU		10h
+BIOS_EQUIPMENT_INTERRUPT_11h	EQU		11h
 BIOS_DISK_INTERRUPT_13h			EQU		13h
 BIOS_SYSTEM_INTERRUPT_15h		EQU		15h
Index: /trunk/Assembly_Library/Inc/Debug.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Debug.inc	(revision 591)
+++ /trunk/Assembly_Library/Inc/Debug.inc	(revision 592)
@@ -24,5 +24,5 @@
 	mov		bl, %2
 	CALL_DISPLAY_LIBRARY PrintWordFromAXWithBaseInBL
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	call	Keyboard_RemoveAllKeystrokesFromBuffer
 %endif
@@ -52,5 +52,5 @@
 	mov		al, %1
 	CALL_DISPLAY_LIBRARY PrintCharacterFromAL
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	call	Keyboard_RemoveAllKeystrokesFromBuffer
 %endif
@@ -95,5 +95,5 @@
 %macro WAIT_ANY_KEY_TO_CONTINUE 0
 	push	ax
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	call	Keyboard_RemoveAllKeystrokesFromBuffer
 %endif
Index: /trunk/Assembly_Library/Inc/Display.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Display.inc	(revision 591)
+++ /trunk/Assembly_Library/Inc/Display.inc	(revision 592)
@@ -61,5 +61,5 @@
 	.InitializeDisplayContext						resb	2
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	.SetCharacterPointerFromBXAX					resb	2
 %endif
@@ -74,5 +74,5 @@
 	.SynchronizeDisplayContextToHardware			resb	2
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	.GetCharacterPointerToBXAX						resb	2
 %endif
@@ -81,9 +81,9 @@
 
 	.FormatNullTerminatedStringFromCSSI				resb	2
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	.PrintSignedWordFromAXWithBaseInBL				resb	2
 %endif
 	.PrintWordFromAXWithBaseInBL					resb	2
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 	.PrintQWordFromSSBPwithBaseInBX					resb	2
 %endif
@@ -94,5 +94,5 @@
 	.PrintCharacterFromAL							resb	2
 	.PrintNewlineCharacters							resb	2
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	.ClearAreaWithHeightInAHandWidthInAL			resb	2
 %endif
Index: /trunk/Assembly_Library/Inc/DosFunctions.inc
===================================================================
--- /trunk/Assembly_Library/Inc/DosFunctions.inc	(revision 591)
+++ /trunk/Assembly_Library/Inc/DosFunctions.inc	(revision 592)
@@ -6,4 +6,5 @@
 ; DOS interrupts
 DOS_INTERRUPT_21h									EQU		21h
+DOS_CTRL_C_CTRL_BREAK_HANDLER_23h					EQU		23h
 DOS_CRITICAL_ERROR_HANDLER_24h						EQU		24h
 DOS_TSR_MULTIPLEX_INTERRUPT_2Fh						EQU		2Fh
@@ -31,4 +32,5 @@
 FIND_FIRST_MATCHING_FILE							EQU		4Eh		; DOS 2+
 FIND_NEXT_MATCHING_FILE								EQU		4Fh		; DOS 2+
+GET_EXTENDED_ERROR_INFORMATION						EQU		59h		; DOS 3.0+
 
 ; DOS errors
Index: /trunk/Assembly_Library/Inc/Emulate.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Emulate.inc	(revision 591)
+++ /trunk/Assembly_Library/Inc/Emulate.inc	(revision 592)
@@ -60,4 +60,34 @@
 
 ;--------------------------------------------------------------------
+; Find String In String
+;
+; FSIS
+;	Parameters:
+;		%1:		String to search for (case-insensitive)
+;		%2:		String to search in
+;	Returns:
+;	strpos:		Position of %1 in %2 if found, 0 if not found
+;--------------------------------------------------------------------
+%macro FSIS 2.nolist
+%defstr	s1 %1
+%defstr	s2 %2
+%strlen sl1 s1
+%strlen sl2 s2
+%assign strpos 0
+	%if sl1 <= sl2
+		%assign strpos sl2 - sl1 + 1
+		%rep strpos
+			%substr %%ss s2 strpos, sl1
+			%ifidni %%ss, s1
+				%exitrep
+			%else
+				%assign strpos strpos - 1
+			%endif
+		%endrep
+	%endif
+%endmacro
+
+
+;--------------------------------------------------------------------
 ; The undocumented instruction SALC (Set AL According to CF).
 ; Available on all Intel processors and truly compatible clones.
@@ -108,7 +138,4 @@
 ;--------------------------------------------------------------------
 ; The AAM instruction (ASCII Adjust after Multiplication).
-; Available on all Intel processors and truly compatible clones.
-; Does not work on the NEC V20/V30 or Sony CXQ70108 processors
-; unless %1 is 10 (0Ah).
 ;
 ; eAAM
@@ -152,9 +179,9 @@
 %macro eBSF 2
 %ifndef USE_386
-	push	cx
 	cmp		WORD %2, BYTE 0		; Source operand is zero?
 	je		SHORT %%Return		;  If so, return with ZF set
 
 	; Set destination to zero and load mask for bit 0
+	push	cx
 	xor		%1, %1
 	mov		cx, 1
@@ -163,10 +190,11 @@
 %%BitLoop:
 	test	%2, cx				; Bit set?
-	jnz		SHORT %%Return		;  If so, return with ZF cleared
+	jnz		SHORT %%PopAndReturn;  If so, return with ZF cleared
 	shl		cx, 1				; Prepare to test next bit
 	inc		%1					; Increment bit index
 	jmp		SHORT %%BitLoop		; Loop until bit found
-%%Return:
+%%PopAndReturn:
 	pop		cx
+%%Return:
 ;-----------------------------------
 %else
@@ -193,9 +221,9 @@
 %macro eBSR 2
 %ifndef USE_386
-	push	cx
 	cmp		WORD %2, BYTE 0		; Source operand is zero?
 	je		SHORT %%Return		;  If so, return with ZF set
 
 	; Load mask for highest order bit
+	push	cx
 	mov		cx, 1<<15
 	mov		%1, 15
@@ -204,10 +232,11 @@
 %%BitLoop:
 	test	%2, cx				; Bit set?
-	jnz		SHORT %%Return		;  If so, return with ZF cleared
+	jnz		SHORT %%PopAndReturn;  If so, return with ZF cleared
 	shr		cx, 1				; Prepare to test next bit
 	dec		%1					; Decrement bit index
 	jmp		SHORT %%BitLoop		; Loop until bit found
-%%Return:
+%%PopAndReturn:
 	pop		cx
+%%Return:
 ;-----------------------------------
 %else
@@ -260,15 +289,13 @@
 
 %macro eCMOVE 2
-	eCMOVZ %1, %2
+	eCMOVZ	%1, %2
 %endmacro
 
 %macro eCMOVNE 2
-	eCMOVNZ %1, %2
+	eCMOVNZ	%1, %2
 %endmacro
 
 %macro eCMOVB 2
-	jnb		SHORT %%Return
-	mov		%1, %2
-%%Return:
+	eCMOVC	%1, %2
 %endmacro
 
@@ -289,5 +316,5 @@
 ; Conditional Set.
 ;
-; eCSETcc
+; eSETcc
 ;	Parameters:
 ;		%1:		Destination data
@@ -297,5 +324,5 @@
 ;		Flags
 ;--------------------------------------------------------------------
-%macro eCSETZ 1
+%macro eSETZ 1
 	mov		%1, 0			; Clear while preserving flags
 	jnz		SHORT %%Return	; Nothing to set
@@ -304,5 +331,5 @@
 %endmacro
 
-%macro eCSETNZ 1
+%macro eSETNZ 1
 	mov		%1, 0			; Clear while preserving flags
 	jz		SHORT %%Return	; Nothing to set
@@ -339,9 +366,17 @@
 		xor		dh, dh
 	%else	; SI, DI, BP (all may be used in effective address)
-		push	ax
-		mov		al, %2
-		xor		ah, ah
-		xchg	ax, %1
-		pop		ax
+		FSIS	%1, %2
+		%if strpos
+			push	ax
+			mov		al, %2
+			xor		ah, ah
+			xchg	%1, ax
+			pop		ax
+		%else
+			xchg	%1, ax
+			mov		al, %2
+			xor		ah, ah
+			xchg	%1, ax
+		%endif
 	%endif
 ;-----------------------------------
@@ -484,5 +519,5 @@
 ; eSEG_STR
 ;	Parameters:
-;		%1:		REP/REPNE or REPE prefix
+;		%1:		REP/REPE/REPZ or REPNE/REPNZ prefix
 ;		%2:		Source segment override (destination is always ES)
 ;		%3:		String instruction
@@ -491,5 +526,5 @@
 ;		FLAGS for cmps and scas only
 ;	Corrupts registers:
-;		Nothing
+;		FLAGS
 ;--------------------------------------------------------------------
 %macro eSEG_STR 3
@@ -499,7 +534,16 @@
 		%2						; SEG is the prefix that won't be lost
 		%3						; String instruction
+FSIS	cmps, %3
+%ifn strpos
+	FSIS	scas, %3
+%endif
+%if strpos						; Must preserve FLAGS
 		jcxz	%%End			; Jump to end if no repeats left (preserves FLAGS)
 		jmp		SHORT %%Loop	; Loop while repeats left
 	%%End:
+%else							; No need to preserve FLAGS
+		inc		cx
+		loop	%%Loop
+%endif
 %else	; No bug on V20/V30 and later, don't know about 188/186
 	%2
@@ -556,5 +600,10 @@
 %ifdef USE_386
 	%if %2 = 1
-		add		%1, %1	; Same size but faster on 386 and 486. Fails if %1 is a memory operand.
+		FSIS	], %1
+		%if strpos
+			eSHIFT_IM	%1, %2, shl
+		%else
+			add		%1, %1	; Same size but faster on 386 and 486.
+		%endif
 	%else
 		eSHIFT_IM	%1, %2, shl
@@ -582,5 +631,10 @@
 %ifdef USE_386
 	%if %2 = 1
-		adc		%1, %1	; Same size but faster on 386 and 486. Fails if %1 is a memory operand.
+		FSIS	], %1
+		%if strpos
+			eSHIFT_IM	%1, %2, rcl
+		%else
+			adc		%1, %1	; Same size but faster on 386 and 486.
+		%endif
 	%else
 		eSHIFT_IM	%1, %2, rcl
Index: /trunk/Assembly_Library/Inc/Macros.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Macros.inc	(revision 591)
+++ /trunk/Assembly_Library/Inc/Macros.inc	(revision 592)
@@ -18,5 +18,5 @@
 ;		%1
 ;--------------------------------------------------------------------
-%macro SKIP2B 1
+%macro SKIP2B 1.nolist
 	%ifidni		%1, f
 		db	03Dh					; Opcode byte for CMP AX, <immed>
Index: /trunk/Assembly_Library/Inc/Math.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Math.inc	(revision 591)
+++ /trunk/Assembly_Library/Inc/Math.inc	(revision 592)
@@ -23,5 +23,4 @@
 	jb		%%Return			;  If so, return
 	mov		%1, %2				; Copy %2 to %1
-ALIGN JUMP_ALIGN
 %%Return:
 %endmacro
@@ -31,5 +30,4 @@
 	jl		%%Return			;  If so, return
 	mov		%1, %2				; Copy %2 to %1
-ALIGN JUMP_ALIGN
 %%Return:
 %endmacro
@@ -51,5 +49,4 @@
 	ja		%%Return			;  If so, return
 	mov		%1, %2				; Copy %2 to %1
-ALIGN JUMP_ALIGN
 %%Return:
 %endmacro
@@ -59,5 +56,4 @@
 	jg		%%Return			;  If so, return
 	mov		%1, %2				; Copy %2 to %1
-ALIGN JUMP_ALIGN
 %%Return:
 %endmacro
@@ -67,5 +63,5 @@
 ; SHL_DXAX
 ;	Parameters:
-;		%1:		Number of bits to shift
+;		%1:		Number of bits to shift. Can be (in preferred order) CX, CL or an immediate value.
 ;	Returns:
 ;		DX:AX	Shifted value
@@ -74,5 +70,20 @@
 ;--------------------------------------------------------------------
 %macro SHL_DXAX 1
+%ifdef USE_386
 	%ifnidni %1, cx
+		; %1 is CL or an immediate
+		shld	dx, ax, %1
+		shl		ax, %1
+	%else
+		; %1 is CX
+		shld	dx, ax, cl
+		shl		ax, cl
+	%endif
+%else
+	%ifidni %1, cl
+		; %1 is CL
+		xor		ch, ch
+	%elifnidni %1, cx
+		; %1 is an immediate
 		mov		cx, %1
 	%endif
@@ -82,4 +93,5 @@
 	eRCL_IM	dx, 1
 	loop	.ShiftNextBit
+%endif
 %endmacro
 
@@ -88,5 +100,5 @@
 ; SHR_DXAX
 ;	Parameters:
-;		%1:		Number of bits to shift
+;		%1:		Number of bits to shift. Can be (in preferred order) CX, CL or an immediate value.
 ;	Returns:
 ;		DX:AX	Shifted value
@@ -95,5 +107,20 @@
 ;--------------------------------------------------------------------
 %macro SHR_DXAX 1
+%ifdef USE_386
 	%ifnidni %1, cx
+		; %1 is CL or an immediate
+		shrd	ax, dx, %1
+		shr		dx, %1
+	%else
+		; %1 is CX
+		shrd	ax, dx, cl
+		shr		dx, cl
+	%endif
+%else
+	%ifidni %1, cl
+		; %1 is CL
+		xor		ch, ch
+	%elifnidni %1, cx
+		; %1 is an immediate
 		mov		cx, %1
 	%endif
@@ -103,4 +130,5 @@
 	rcr		ax, 1
 	loop	.ShiftNextBit
+%endif
 %endmacro
 
Index: /trunk/Assembly_Library/Inc/Menu.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Menu.inc	(revision 591)
+++ /trunk/Assembly_Library/Inc/Menu.inc	(revision 592)
@@ -159,5 +159,5 @@
 SCROLL_THUMB_CHARACTER				EQU		BLOCK_FULL_FOREGROUND
 
-NO_ITEM_SELECTED					EQU		-1
+;NO_ITEM_SELECTED					EQU		-1
 NO_ITEM_HIGHLIGHTED					EQU		-1
 NO_TIMEOUT_USED						EQU		0
Index: /trunk/Assembly_Library/Src/AssemblyLibrary.asm
===================================================================
--- /trunk/Assembly_Library/Src/AssemblyLibrary.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/AssemblyLibrary.asm	(revision 592)
@@ -90,5 +90,5 @@
   %endif
 	%include "Char.asm"
-	%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 		%include "String.asm"
 		%include "StringProcess.asm"
@@ -106,5 +106,5 @@
 
 %ifdef INCLUDE_TIME_LIBRARY
-	%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef EXCLUDE_FROM_XUB
 		%include "Delay.asm"
 		%ifndef EXCLUDE_FROM_XTIDECFG
@@ -119,13 +119,17 @@
 	%define UTIL_SIZE_JUMP_ALIGN 1
   %endif
-	%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
-		%include "Bit.asm"
+	%ifndef EXCLUDE_FROM_XUB
+		%ifndef EXCLUDE_FROM_BIOSDRVS
+			%include "Bit.asm"
+		%endif
+		%include "Math.asm"
 	%endif
-	%include "Math.asm"
-	%include "Registers.asm"
-	%include "Reboot.asm"
-	%include "Memory.asm"
+	%ifndef EXCLUDE_FROM_BIOSDRVS
+		%include "Registers.asm"
+		%include "Reboot.asm"
+		%include "Memory.asm"
+	%endif
 	%include "Size.asm"
-	%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 		%include "Sort.asm"
 	%endif
Index: /trunk/Assembly_Library/Src/Display/CgaSnow.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/CgaSnow.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Display/CgaSnow.asm	(revision 592)
@@ -106,5 +106,5 @@
 ;		AX, CX, DX
 ;--------------------------------------------------------------------
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifdef MODULE_STRINGS_COMPRESSED
 		%define EXCLUDE
Index: /trunk/Assembly_Library/Src/Display/Display.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/Display.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Display/Display.asm	(revision 592)
@@ -38,5 +38,7 @@
 	push	dx
 
+%ifdef CLD_NEEDED
 	cld
+%endif
 	LOAD_BDA_SEGMENT_TO	ds, dx
 	mov		dx, di
@@ -76,5 +78,5 @@
 	%define InitializeDisplayContext						DisplayContext_Initialize
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	%define SetCharacterPointerFromBXAX						DisplayContext_SetCharacterPointerFromBXAX
 %endif
@@ -89,5 +91,5 @@
 	%define SynchronizeDisplayContextToHardware				DisplayContext_SynchronizeToHardware
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	%define GetCharacterPointerToBXAX						DisplayContext_GetCharacterPointerToBXAX
 %endif
@@ -96,9 +98,9 @@
 
 	%define FormatNullTerminatedStringFromCSSI				Display_FormatNullTerminatedStringFromCSSI
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	%define PrintSignedWordFromAXWithBaseInBL				DisplayPrint_SignedWordFromAXWithBaseInBL
 %endif
 	%define PrintWordFromAXWithBaseInBL						DisplayPrint_WordFromAXWithBaseInBL
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 	%define PrintQWordFromSSBPwithBaseInBX					DisplayPrint_QWordFromSSBPwithBaseInBX
 %endif
@@ -109,5 +111,5 @@
 	%define PrintCharacterFromAL							DisplayPrint_CharacterFromAL
 	%define PrintNewlineCharacters							DisplayPrint_Newline
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	%define ClearAreaWithHeightInAHandWidthInAL				DisplayPrint_ClearAreaWithHeightInAHandWidthInAL
 %endif
Index: /trunk/Assembly_Library/Src/Display/DisplayContext.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 592)
@@ -110,5 +110,5 @@
 ;		AX, DI
 ;--------------------------------------------------------------------
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifndef MODULE_BOOT_MENU
 		%define EXCLUDE
@@ -116,5 +116,5 @@
 %endif
 
-%ifndef EXCLUDE
+%ifndef EXCLUDE OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_Push:
@@ -170,5 +170,5 @@
 	mov		ds, di					; Restore DS
 	ret
-%endif ; EXCLUDE
+%endif ; EXCLUDE OR EXCLUDE_FROM_BIOSDRVS
 %undef EXCLUDE
 
@@ -184,5 +184,5 @@
 ;		AX, DI
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX:
@@ -202,5 +202,5 @@
 	pop		ds
 	ret
-%endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%endif ; EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 
 
@@ -215,5 +215,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_SetCharacterPointerFromBXAX:
@@ -235,5 +235,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_GetCharacterPointerToBXAX:
@@ -244,5 +244,5 @@
 
 
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifndef MODULE_BOOT_MENU
 		%define EXCLUDE
@@ -282,4 +282,5 @@
 ;--------------------------------------------------------------------
 %ifndef EXCLUDE	; 2 of 3
+%ifndef EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_SetCharacterAttributeFromAL:
@@ -287,4 +288,5 @@
 	ret
 %endif
+%endif
 
 
@@ -300,4 +302,5 @@
 ;--------------------------------------------------------------------
 %ifndef EXCLUDE	; 3 of 3
+%ifndef EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_SetCharacterOutputParameterFromAX:
@@ -305,4 +308,5 @@
 	ret
 %endif
+%endif
 
 %undef EXCLUDE
@@ -318,5 +322,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_GetCharacterOutputParameterToDX:
Index: /trunk/Assembly_Library/Src/Display/DisplayCursor.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayCursor.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Display/DisplayCursor.asm	(revision 592)
@@ -48,5 +48,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifndef MODULE_BOOT_MENU
 		%define EXCLUDE
@@ -54,5 +54,5 @@
 %endif
 
-%ifndef EXCLUDE
+%ifndef EXCLUDE OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayCursor_SetShapeFromAX:
Index: /trunk/Assembly_Library/Src/Display/DisplayFormat.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayFormat.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Display/DisplayFormat.asm	(revision 592)
@@ -142,5 +142,5 @@
 
 .rgcFormatCharToLookupIndex:
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	db		"aIAduxsSctz-+%"
 %else
@@ -150,10 +150,10 @@
 ALIGN WORD_ALIGN
 .rgfnFormatSpecifierParser:
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	dw		a_FormatAttributeForNextCharacter
 %endif
 	dw		I_FormatDashForZero
 	dw		A_FormatAttributeForRemainingString
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	dw		d_FormatSignedDecimalWord
 %endif
@@ -161,14 +161,14 @@
 	dw		x_FormatHexadecimalWord
 	dw		s_FormatStringFromSegmentCS
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	dw		S_FormatStringFromFarPointer
 %endif
 	dw		c_FormatCharacter
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	dw		t_FormatRepeatCharacter
 %endif
 	dw		z_FormatStringFromSegmentZero
 	dw		PrepareToPrependParameterWithSpaces
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	dw		PrepareToAppendSpacesAfterParameter
 	dw		percent_FormatPercent
@@ -308,5 +308,5 @@
 ;		AX, BX, DX
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN DISPLAY_JUMP_ALIGN
 a_FormatAttributeForNextCharacter:
@@ -330,5 +330,5 @@
 	ret
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN DISPLAY_JUMP_ALIGN
 d_FormatSignedDecimalWord:
@@ -391,5 +391,5 @@
 	ret
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN DISPLAY_JUMP_ALIGN
 S_FormatStringFromFarPointer:
@@ -408,5 +408,5 @@
 	jmp		DisplayPrint_CharacterFromAL
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN DISPLAY_JUMP_ALIGN
 t_FormatRepeatCharacter:
Index: /trunk/Assembly_Library/Src/Display/DisplayPage.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayPage.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Display/DisplayPage.asm	(revision 592)
@@ -31,5 +31,5 @@
 ;		AX, DX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayPage_SetFromAL:
@@ -41,5 +41,5 @@
 
 
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%define EXCLUDE
 	%ifdef MODULE_HOTKEYS OR MODULE_BOOT_MENU
@@ -48,5 +48,5 @@
 %endif
 
-%ifndef EXCLUDE
+%ifndef EXCLUDE OR EXCLUDE_FROM_BIOSDRVS
 ;--------------------------------------------------------------------
 ; DisplayPage_GetColumnsToALandRowsToAH
Index: /trunk/Assembly_Library/Src/Display/DisplayPrint.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayPrint.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Display/DisplayPrint.asm	(revision 592)
@@ -94,5 +94,5 @@
 ;		AX, BH, DX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayPrint_SignedWordFromAXWithBaseInBL:
@@ -163,5 +163,5 @@
 ;		AX, DX, [SS:BP]
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayPrint_QWordFromSSBPwithBaseInBX:
@@ -194,5 +194,5 @@
 ;		AX, DX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayPrint_CharacterBufferFromBXSIwithLengthInCX:
@@ -261,5 +261,5 @@
 ;		AX, DX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayPrint_ClearAreaWithHeightInAHandWidthInAL:
@@ -292,5 +292,5 @@
 %endif
 
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%define EXCLUDE
 	%ifndef MODULE_STRINGS_COMPRESSED
Index: /trunk/Assembly_Library/Src/File/Directory.asm
===================================================================
--- /trunk/Assembly_Library/Src/File/Directory.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/File/Directory.asm	(revision 592)
@@ -99,4 +99,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
 Directory_GetMatchCountToAXforSearchStringInDSSIwithAttributesInCX:
@@ -115,4 +116,5 @@
 	pop		dx
 	ret
+%endif
 
 
Index: /trunk/Assembly_Library/Src/File/DosCritical.asm
===================================================================
--- /trunk/Assembly_Library/Src/File/DosCritical.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/File/DosCritical.asm	(revision 592)
@@ -1,7 +1,3 @@
-; File name		:	DosCritical.asm
 ; Project name	:	Assembly Library
-; Created date	:	1.9.2010
-; Last update	:	2.9.2010
-; Author		:	Tomi Tilli
 ; Description	:	DOS Critical Error Handler (24h) replacements.
 
@@ -22,4 +18,5 @@
 ;
 
+; Note! Only DOS functions 01h - 0Ch, 30h and 59h can be called from a Critical Error Handler.
 
 ; DOS Critical Error Handler return values
@@ -28,5 +25,5 @@
 	.retryOperation								resb	1
 	.terminateProgramAsThoughInt21hAH4ChCalled	resb	1
-	.failSystemCallInProgress					resb	1
+	.failSystemCallInProgress					resb	1	; Needs DOS 3.1+
 endstruc
 
@@ -83,4 +80,36 @@
 
 ;--------------------------------------------------------------------
+; DosCritical_CustomHandler
+;	Parameters:
+;		Nothing
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+DosCritical_CustomHandler:
+	add		sp, 6	; Remove the INT 24h return address and flags from stack
+
+	mov		ah, GET_EXTENDED_ERROR_INFORMATION	; Requires DOS 3.0+
+	xor		bx, bx
+	int		DOS_INTERRUPT_21h
+	mov		[cs:bLastCriticalError], al
+
+	pop		ax
+	pop		bx
+	pop		cx
+	pop		dx
+	pop		si
+	pop		di
+	pop		bp
+	pop		ds
+	pop		es
+	iret			; Return from the INT 21h call
+
+bLastCriticalError:		db	0
+
+
+;--------------------------------------------------------------------
 ; DosCritical_HandlerToIgnoreAllErrors
 ;	Parameters:
@@ -95,2 +124,3 @@
 	mov		al, CRITICAL_ERROR_ACTION.ignoreErrorAndContinueProcessingRequest
 	iret
+
Index: /trunk/Assembly_Library/Src/File/Drive.asm
===================================================================
--- /trunk/Assembly_Library/Src/File/Drive.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/File/Drive.asm	(revision 592)
@@ -30,4 +30,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
 Drive_GetNumberOfAvailableDrivesToAX:
@@ -42,4 +43,5 @@
 	pop		dx
 	ret
+%endif
 
 
Index: /trunk/Assembly_Library/Src/File/FileIO.asm
===================================================================
--- /trunk/Assembly_Library/Src/File/FileIO.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/File/FileIO.asm	(revision 592)
@@ -35,4 +35,5 @@
 ;		AX, BX
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
 FileIO_CreateWithPathInDSSIandAttributesInCX:
@@ -40,4 +41,5 @@
 	SKIP2B	bx
 	; Fall to FileIO_OpenWithPathInDSSIandFileAccessInAL
+%endif
 
 ;--------------------------------------------------------------------
Index: /trunk/Assembly_Library/Src/Keyboard/Keyboard.asm
===================================================================
--- /trunk/Assembly_Library/Src/Keyboard/Keyboard.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Keyboard/Keyboard.asm	(revision 592)
@@ -37,5 +37,5 @@
 ;		DX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN KEYBOARD_JUMP_ALIGN
 Keyboard_ReadUserInputtedWordWhilePrinting:
@@ -87,5 +87,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN KEYBOARD_JUMP_ALIGN
 Keyboard_ReadUserInputtedStringToESDIWhilePrinting:
@@ -98,5 +98,7 @@
 	xor		bx, bx								; Zero character counter
 	dec		cx									; Decrement buffer size for NULL
+%ifdef CLD_NEEDED
 	cld
+%endif
 ALIGN KEYBOARD_JUMP_ALIGN
 .GetCharacterFromUser:
@@ -197,5 +199,5 @@
 	xor		al, al								; Set ZF and clear CF
 	ret
-%endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%endif ; EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 
 
@@ -209,5 +211,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN KEYBOARD_JUMP_ALIGN
 Keyboard_PrintBackspace:
@@ -230,5 +232,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN KEYBOARD_JUMP_ALIGN
 Keyboard_PlayBellForUnwantedKeystroke:
@@ -246,5 +248,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN KEYBOARD_JUMP_ALIGN
 Keyboard_PrintInputtedCharacter:
@@ -266,5 +268,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS	; Only used when debugging
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS				; Only used when debugging
 ALIGN KEYBOARD_JUMP_ALIGN
 Keyboard_RemoveAllKeystrokesFromBuffer:
@@ -289,5 +291,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%define EXCLUDE
 	%ifdef MODULE_HOTKEYS OR MODULE_BOOT_MENU
Index: /trunk/Assembly_Library/Src/LibSizeCheck.asm
===================================================================
--- /trunk/Assembly_Library/Src/LibSizeCheck.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/LibSizeCheck.asm	(revision 592)
@@ -20,5 +20,5 @@
 
 ; Include .inc files
-%define EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%define EXCLUDE_FROM_XUB
 ;%define INCLUDE_DISPLAY_LIBRARY
 ;%define INCLUDE_FILE_LIBRARY
Index: /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 592)
@@ -249,6 +249,11 @@
 ALIGN JUMP_ALIGN
 AppendFileFromDTAinDSSItoOffScreenBuffer:
-	call	.FilterCurrentDirectory			; We never want "."
-	call	.FilterUpDirectoryWhenInRoot	; No ".." when in root directory
+	cmp		WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
+	je		SHORT .Return					; We never want "."
+	test	dl, dl
+	jnz		SHORT .NotInRootDirectory
+	cmp		WORD [si+DTA.szFile], UPDIR_CHARACTERS
+	je		SHORT .Return					; No ".." when in root directory
+.NotInRootDirectory:
 	inc		cx								; Nothing filtered so increment files/directories
 
@@ -262,34 +267,5 @@
 	pop		si
 	pop		bp
-	ret
-
-;--------------------------------------------------------------------
-; .FilterCurrentDirectory
-; .FilterUpDirectoryWhenInRoot
-;	Parameters:
-;		DL:		Zero if root directory selected
-;		DS:SI:	Ptr to DTA containing file information
-;	Returns:
-;		Nothing
-;		Returns from AppendFileToBufferInESDIfromDtaInDSSI when filtering
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.FilterCurrentDirectory:
-	cmp		WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
-	je		SHORT .DoFilter
-	ret
-
-ALIGN JUMP_ALIGN
-.FilterUpDirectoryWhenInRoot:
-	test	dl, dl			; Set ZF if root directory selected
-	jnz		SHORT .ReturnWithoutFiltering
-	cmp		WORD [si+DTA.szFile], UPDIR_CHARACTERS
-	jne		SHORT .ReturnWithoutFiltering
-.DoFilter:
-	add		sp, BYTE 2		; Remove return address from stack
-ALIGN JUMP_ALIGN, ret
-.ReturnWithoutFiltering:
+.Return:
 	ret
 
@@ -473,7 +449,7 @@
 ALIGN JUMP_ALIGN
 GetInfoLinesToCXandDialogFlagsToAX:
-	xor		ax, ax
-	call	GetDialogFlagsToAL
-	jmp		Bit_GetSetCountToCXfromAX
+	ePUSH_T	ax, Bit_GetSetCountToCXfromAX
+	xor		ah, ah
+	; Fall to GetDialogFlagsToAL
 
 ;--------------------------------------------------------------------
@@ -696,4 +672,5 @@
 	call	.ChangeDriveToUserSelectionFromIoInDSSI
 	add		sp, BYTE DRIVE_DIALOG_IO_size
+.UserCancelledDriveChange:
 	ret
 
@@ -729,9 +706,48 @@
 	jne		SHORT .UserCancelledDriveChange
 
+	; Install our Custom Critical Error Handler to catch "Drive Not Ready" errors. This handler only works on DOS 3.0+ systems
+	; but that should be OK because only DOS 3.1+ will trigger it. Under older DOS versions drives are enumerated using
+	; GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE which will access the drive so we know it is available at this point.
+	mov		dx, DosCritical_CustomHandler
+	call	DosCritical_InstallNewHandlerFromCSDX
+
+	; Save the current drive on stack in case the selected drive is not ready and the user decides to cancel the change.
+	call	Drive_GetDefaultToAL
+	xchg	dx, ax
+
+.RetryDrive:
+	push	dx									; Save the previous current drive to stack
+
 	mov		dl, [si+DRIVE_DIALOG_IO.bReturnDriveNumber]
 	call	Drive_SetDefaultFromDL
+
+	; Now we must try to force a media access to catch "Drive Not Ready".
+	push	ds
+	push	ss
+	pop		ds
+	ePUSH_T	ax, CURRENTDIR_CHARACTERS
+	mov		cx, FLG_FILEATTR_DIRECTORY
+	mov		dx, sp
+	mov		ax, FIND_FIRST_MATCHING_FILE<<8
+	int		DOS_INTERRUPT_21h
+	pop		ax
+	pop		ds
+
+	pop		dx									; Restore the previous current drive from stack
+
+	xchg	ah, [cs:bLastCriticalError]			; Zero bLastCriticalError and fetch error code to AH
+	cmp		ah, ERR_DOS_DRIVE_NOT_READY
+	jne		SHORT .DriveIsReady
+
+	mov		bx, g_szDlgDriveNotReady
+	call	Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX
+	jz		SHORT .RetryDrive
+	; The user cancelled the drive change. Restore current drive to what it was previously.
+	call	Drive_SetDefaultFromDL
+	jmp		DosCritical_RestoreDosHandler
+
+.DriveIsReady:
+	call	DosCritical_RestoreDosHandler
 	jmp		RefreshFilesToDisplay
-.UserCancelledDriveChange:
-	ret
 
 
Index: /trunk/Assembly_Library/Src/Menu/MenuAttributes.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuAttributes.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Menu/MenuAttributes.asm	(revision 592)
@@ -91,4 +91,5 @@
 
 .rgcColorAttributes:
+; Classic (default theme)
 istruc ATTRIBUTE_CHARS
 	at	ATTRIBUTE_CHARS.cBordersAndBackground,	db	COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_BLUE)
@@ -100,4 +101,5 @@
 	at	ATTRIBUTE_CHARS.cNormalTimeout,			db	COLOR_ATTRIBUTE(COLOR_GREEN, COLOR_BLUE)
 iend
+ColorTheme	equ		MenuAttribute_GetToAXfromTypeInSI.rgcColorAttributes
 
 .rgcBlackAndWhiteAttributes:	; Only COLOR_WHITE, COLOR_BRIGHT_WHITE and COLOR_BLACK should be used
Index: /trunk/Assembly_Library/Src/Menu/MenuBorders.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuBorders.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Menu/MenuBorders.asm	(revision 592)
@@ -87,5 +87,5 @@
 ;		AX, BX, CX, DX, SI, DI
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 ALIGN MENU_JUMP_ALIGN
 MenuBorders_RefreshItemBorders:
Index: /trunk/Assembly_Library/Src/Menu/MenuInit.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 592)
@@ -114,5 +114,5 @@
 ;		AX, BX, DX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN MENU_JUMP_ALIGN
 MenuInit_CloseMenuIfExitEventAllows:
@@ -138,5 +138,5 @@
 
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ;--------------------------------------------------------------------
 ; MenuInit_HighlightItemFromAX
@@ -168,5 +168,5 @@
 	mov		ax, [bp+MENUINIT.wHighlightedItem]
 	ret
-%endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%endif ; EXCLUDE_FROM_XUB
 
 
@@ -183,5 +183,6 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
+%ifndef EXCLUDE_FROM_XTIDECFG
 ALIGN MENU_JUMP_ALIGN
 MenuInit_SetTitleHeightFromAL:
@@ -193,4 +194,5 @@
 	mov		[bp+MENUINIT.bInfoLines], al
 	ret
+%endif ; EXCLUDE_FROM_XTIDECFG
 
 ALIGN MENU_JUMP_ALIGN
@@ -198,5 +200,5 @@
 	mov		[bp+MENUINIT.wItems], ax
 	ret
-%endif
+%endif ; EXCLUDE_FROM_XUB
 
 
@@ -212,5 +214,6 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
+%ifndef EXCLUDE_FROM_XTIDECFG
 ALIGN MENU_JUMP_ALIGN
 MenuInit_SetUserDataFromDSSI:
@@ -218,4 +221,5 @@
 	mov		[bp+MENU.dwUserData+2], ds
 	ret
+%endif ; EXCLUDE_FROM_XTIDECFG
 
 ALIGN MENU_JUMP_ALIGN
@@ -223,3 +227,3 @@
 	lds		si, [bp+MENU.dwUserData]
 	ret
-%endif
+%endif ; EXCLUDE_FROM_XUB
Index: /trunk/Assembly_Library/Src/Menu/MenuLocation.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuLocation.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Menu/MenuLocation.asm	(revision 592)
@@ -55,5 +55,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
 %endif
Index: /trunk/Assembly_Library/Src/Menu/MenuText.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuText.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Menu/MenuText.asm	(revision 592)
@@ -32,5 +32,5 @@
 ;		AX, BX, CX, DX, SI, DI
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 ALIGN MENU_JUMP_ALIGN
 MenuText_ClearTitleArea:
Index: /trunk/Assembly_Library/Src/Serial/SerialServer.asm
===================================================================
--- /trunk/Assembly_Library/Src/Serial/SerialServer.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Serial/SerialServer.asm	(revision 592)
@@ -61,6 +61,8 @@
 		push	ax				; working copy on the top of the stack
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS	; DF already cleared in Int13h.asm
+%ifndef EXCLUDE_FROM_XUB		; DF already cleared in Int13h.asm
+%ifdef CLD_NEEDED
 		cld
+%endif
 %endif
 
Index: /trunk/Assembly_Library/Src/String/Char.asm
===================================================================
--- /trunk/Assembly_Library/Src/String/Char.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/String/Char.asm	(revision 592)
@@ -51,5 +51,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifndef MODULE_HOTKEYS
 		%define EXCLUDE
@@ -57,5 +57,5 @@
 %endif
 
-%ifndef EXCLUDE
+%ifndef EXCLUDE OR EXCLUDE_FROM_BIOSDRVS
 ALIGN STRING_JUMP_ALIGN
 Char_IsLowerCaseLetterInAL:
@@ -76,5 +76,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN STRING_JUMP_ALIGN
 Char_IsUpperCaseLetterInAL:
@@ -95,5 +95,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN STRING_JUMP_ALIGN
 Char_IsHexadecimalDigitInAL:
@@ -136,5 +136,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN STRING_JUMP_ALIGN
 Char_ConvertIntegerToALfromDigitInALwithBaseInBX:
@@ -166,5 +166,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN STRING_JUMP_ALIGN
 Char_CharIsValid:
@@ -174,5 +174,5 @@
 
 
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifndef MODULE_HOTKEYS
 		%define EXCLUDE
@@ -201,5 +201,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN STRING_JUMP_ALIGN
 Char_ALtoLowerCaseLetter:
@@ -218,5 +218,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN STRING_JUMP_ALIGN
 Char_ALtoUpperCaseLetter:
@@ -237,5 +237,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 Char_ChangeCaseInAL:
 	xor		al, 32
@@ -254,5 +254,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
 ALIGN STRING_JUMP_ALIGN
 Char_GetFilterFunctionToDXforNumericBaseInBX:
Index: /trunk/Assembly_Library/Src/Time/TimerTicks.asm
===================================================================
--- /trunk/Assembly_Library/Src/Time/TimerTicks.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Time/TimerTicks.asm	(revision 592)
@@ -48,5 +48,5 @@
 ;		CX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 %ifndef EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
@@ -64,7 +64,7 @@
 	div		cx		; Divide DX:AX by CX, Minutes to AX, remainder ticks to DX
 	ret
-%endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
-
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+%endif ; EXCLUDE_FROM_XUB
+
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
 TimerTicks_GetSecondsToAXandRemainderTicksToDXfromTicksInDX:
@@ -80,5 +80,5 @@
 
 
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifndef MODULE_BOOT_MENU
 		%define EXCLUDE
@@ -164,5 +164,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
 TimerTicks_GetElapsedToAXandResetDSBX:
@@ -184,5 +184,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
 TimerTicks_GetElapsedToAXfromDSBX:
@@ -202,5 +202,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifndef MODULE_BOOT_MENU OR MODULE_HOTKEYS
 		%define EXCLUDE
Index: /trunk/Assembly_Library/Src/Util/Bit.asm
===================================================================
--- /trunk/Assembly_Library/Src/Util/Bit.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Util/Bit.asm	(revision 592)
@@ -24,5 +24,5 @@
 ; Bit_GetSetCountToCXfromDXAX
 ;	Parameters
-;		DX:AX:		Source DWORD
+;		DX:AX:	Source DWORD
 ;	Returns:
 ;		CX:		Number of bits set in DX:AX
@@ -58,14 +58,12 @@
 	push	ax
 
-	xor		cx, cx
+	mov		cx, -1
 ALIGN JUMP_ALIGN
-.BitScanLoop:
+.IncrementCX:
+	inc		cx
+.ShiftLoop:
 	shr		ax, 1
-	jz		SHORT .LastBitInCF
-	adc		cl, ch
-	jmp		SHORT .BitScanLoop
-ALIGN JUMP_ALIGN
-.LastBitInCF:
-	adc		cl, ch
+	jc		SHORT .IncrementCX
+	jnz		SHORT .ShiftLoop
 
 	pop		ax
@@ -95,4 +93,5 @@
 	ret
 
+
 ;--------------------------------------------------------------------
 ; Bit_SetToAXfromIndexInCL
@@ -115,2 +114,3 @@
 	pop		dx
 	ret
+
Index: /trunk/Assembly_Library/Src/Util/Math.asm
===================================================================
--- /trunk/Assembly_Library/Src/Util/Math.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Util/Math.asm	(revision 592)
@@ -33,27 +33,7 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+%ifndef EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
 Math_DivQWatSSBPbyCX:
-%if 1
-	xor		dx, dx
-	mov		ax, [bp+6]		; Load highest divident WORD to DX:AX
-	div		cx
-	mov		[bp+6], ax		; Store quotient
-
-	mov		ax, [bp+4]
-	div		cx
-	mov		[bp+4], ax
-
-	mov		ax, [bp+2]
-	div		cx
-	mov		[bp+2], ax
-
-	mov		ax, [bp]
-	div		cx
-	mov		[bp], ax
-	ret
-%else ; ~1
-; This is about half the size compared to the above code but it's not tested which is why it's commented away.
 	push	di
 	mov		di, 6
@@ -65,8 +45,7 @@
 	dec		di
 	dec		di
-	jns		.Next
+	jns		SHORT .Next
 	pop		di
 	ret
-%endif ; 1
 %endif
 
@@ -83,5 +62,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDECFG
+%ifndef EXCLUDE_FROM_XTIDECFG OR EXCLUDE_FROM_BIOSDRVS
 ALIGN JUMP_ALIGN
 Math_DivDXAXbyCX:
Index: /trunk/Assembly_Library/Src/Util/Memory.asm
===================================================================
--- /trunk/Assembly_Library/Src/Util/Memory.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Util/Memory.asm	(revision 592)
@@ -24,27 +24,20 @@
 ; OPTIMIZE_STRING_OPERATION
 ;	Parameters
-;		%1:		Repeat instruction
-;		%2:		String instruction without size (for example MOVS and not MOVSB or MOVSW)
+;		%1:		String instruction without size (only MOVS and STOS is supported)
 ;		CX:		Number of BYTEs to operate
-;		DS:SI:	Ptr to source data
+;		DS:SI:	Ptr to source data (for MOVS)
 ;		ES:DI:	Ptr to destination
 ;	Returns:
+;		CF:		Cleared
+;		CX:		Zero
 ;		SI, DI:	Updated by number of bytes operated
 ;	Corrupts registers:
 ;		Nothing
 ;--------------------------------------------------------------------
-%macro OPTIMIZE_STRING_OPERATION 2
-	push	cx
-
-	shr		cx, 1			; Operate with WORDs for performance
-	jz	%%HandleRemainingByte
-	%1		%2w
-%%HandleRemainingByte:
-	jnc		SHORT %%OperationCompleted
-	%2b
-
-ALIGN JUMP_ALIGN
-%%OperationCompleted:
-	pop		cx
+%macro OPTIMIZE_STRING_OPERATION 1
+	shr		cx, 1
+	rep		%1w
+	eRCL_IM	cx, 1
+	rep		%1b
 %endmacro
 
@@ -57,12 +50,15 @@
 ;		ES:DI:	Ptr to destination buffer
 ;	Returns:
+;		CF:		Cleared
 ;		SI, DI:	Updated by number of bytes copied
 ;	Corrupts registers:
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN JUMP_ALIGN
 Memory_CopyCXbytesFromDSSItoESDI:
-	OPTIMIZE_STRING_OPERATION rep, movs
+	push	cx
+	OPTIMIZE_STRING_OPERATION movs
+	pop		cx
 	ret
 %endif
@@ -77,5 +73,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		Nothing
+;		CX
 ;--------------------------------------------------------------------
 %ifdef INCLUDE_MENU_LIBRARY
@@ -102,5 +98,5 @@
 ;		DI:		Updated by number of BYTEs stored
 ;	Corrupts registers:
-;		AX
+;		AX, CX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -118,9 +114,8 @@
 ;		DI:		Updated by number of BYTEs stored
 ;	Corrupts registers:
-;		Nothing
+;		CX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 Memory_StoreCXbytesFromAccumToESDI:
-	OPTIMIZE_STRING_OPERATION rep, stos
+	OPTIMIZE_STRING_OPERATION stos
 	ret
 
@@ -135,5 +130,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN JUMP_ALIGN
 Memory_ReserveCXbytesFromStackToDSSI:
Index: /trunk/Assembly_Library/Src/Util/Reboot.asm
===================================================================
--- /trunk/Assembly_Library/Src/Util/Reboot.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Util/Reboot.asm	(revision 592)
@@ -44,5 +44,5 @@
 	mov		al, 0FEh				; System reset (AT+ keyboard controller)
 	out		64h, al					; Reset computer (AT+)
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 	%ifdef INCLUDE_TIME_LIBRARY
 		mov		ax, 10
Index: /trunk/Assembly_Library/Src/Util/Registers.asm
===================================================================
--- /trunk/Assembly_Library/Src/Util/Registers.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Util/Registers.asm	(revision 592)
@@ -59,5 +59,5 @@
 %endif
 
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XUB
 ALIGN JUMP_ALIGN
 Registers_CopySSBPtoDSSI:
@@ -91,15 +91,15 @@
 ;
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
 Registers_NormalizeESSI:
 	mov			cx, si
-	and			si, byte 0fh
-	jmp			Registers_NormalizeFinish
+	and			si, BYTE 0Fh
+	jmp			SHORT Registers_NormalizeFinish
 
 ALIGN JUMP_ALIGN
 Registers_NormalizeESDI:
 	mov			cx, di
-	and			di, byte 0fh
+	and			di, BYTE 0Fh
 ;;; fall-through
 
Index: /trunk/Assembly_Library/Src/Util/Size.asm
===================================================================
--- /trunk/Assembly_Library/Src/Util/Size.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Util/Size.asm	(revision 592)
@@ -70,22 +70,15 @@
 	jae		SHORT Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX
 	add		sp, BYTE 2					; Clean return address from stack
-	xchg	si, cx						; CX = Remainder (0...1023), SI = Magnitude
 
 	; Convert remainder to tenths
-	xchg	bx, ax						; Store AX
-	mov		al, 5						; AH = 0
-	mul		cx							; DX:AX = remainder * (10 / 2)
-%ifdef USE_186
-	shr		ax, 9						; Divide AX by (1024 / 2)
-%else
-	shr		ax, 1
-	mov		al, ah
-	cbw
-%endif
-	xchg	cx, ax						; CX = tenths
-	xchg	ax, bx
+	mov		bx, 640
+	xchg	bx, ax						; BX = Size, AX = (10 / 1024) * 65536
+	mul		si							; DX = Remainder * (10 / 1024)
+	xchg	dx, ax
+	xchg	cx, ax						; CX = Tenths, AX = Magnitude
+	xchg	bx, ax						; AX = Size, BX	= Magnitude
 
 	; Convert magnitude to character
-	mov		dl, [cs:si+.rgbMagnitudeToChar]
+	mov		dl, [cs:bx+.rgbMagnitudeToChar]
 
 	pop		si
@@ -154,5 +147,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifdef EXCLUDE_FROM_XUB
 	%ifdef USE_386
 		%define EXCLUDE
Index: /trunk/Assembly_Library/Src/Util/Sort.asm
===================================================================
--- /trunk/Assembly_Library/Src/Util/Sort.asm	(revision 591)
+++ /trunk/Assembly_Library/Src/Util/Sort.asm	(revision 592)
@@ -63,5 +63,7 @@
 	push	cx
 
+%ifdef CLD_NEEDED
 	cld
+%endif
 	mov		cx, di						; Restore item size to CX
 	xor		ax, ax						; Zero starting index
@@ -191,5 +193,5 @@
 
 	cmp		ax, dx	; If (left <= right)
-	jg		SHORT ArrangeItemsInRangeAXtoDXtoBothSidesOfPivotInESDI
+	jg		SHORT .BreakLoopSinceAllItemsExamined
 	call	SwapItemsFromIndexesAXandDX
 	inc		ax
Index: /trunk/BIOS_Drive_Information_Tool/Src/AtaInfo.asm
===================================================================
--- /trunk/BIOS_Drive_Information_Tool/Src/AtaInfo.asm	(revision 591)
+++ /trunk/BIOS_Drive_Information_Tool/Src/AtaInfo.asm	(revision 592)
@@ -71,5 +71,5 @@
 
 	; Print L-CHS generated by XTIDE Universal BIOS
-	call	DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
+	call	DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX
 
 .SkipAtaInfoSinceError:
@@ -80,5 +80,5 @@
 
 ;--------------------------------------------------------------------
-; DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
+; DisplayPCHSusingAtaInfoFromDSBX
 ;	Parameters:
 ;		BX:		Offset to ATA Information
@@ -193,7 +193,8 @@
 DisplayPioModeInformationUsingAtaInfoFromDSBX:
 	; Load standard timings (up to PIO-2)
-	mov		ax, [bx+ATA1.bPioMode]
+	mov		al, [bx+ATA1.bPioMode]
+	cbw
 	mov		si, ax
-	shl		si, 1		; Shift for WORD lookup
+	eSHL_IM	si, 1		; Shift for WORD lookup
 	mov		dx, [si+.rgwStandardPioTimings]	; Load min cycle time
 	mov		cx, -1		; IORDY not supported
@@ -203,5 +204,7 @@
 	jz		SHORT .NoAdvancedPioModesSupported
 
-	mov		si, [bx+ATA2.bPIOSupp]	; Advanced mode flags
+	mov		si, 0FFh
+	and		si, [bx+ATA2.bPIOSupp]	; Advanced mode flags
+	jz		SHORT .NoAdvancedPioModesSupported
 .IncrementPioMode:
 	inc		ax
@@ -222,5 +225,5 @@
 
 ;--------------------------------------------------------------------
-; DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
+; DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX
 ;	Parameters:
 ;		BX:		Offset to ATA Information
@@ -230,8 +233,8 @@
 ;		AX, BX, CX, DX, BP, SI, DI
 ;--------------------------------------------------------------------
-DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX:
+DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX:
 	; Display header
-	mov		ax, g_szXTUBversion
-	mov		si, g_szXTUB
+	mov		ax, g_szXUBversion
+	mov		si, g_szXUB
 	call	Print_FormatStringFromSIwithParameterInAX
 
Index: /trunk/BIOS_Drive_Information_Tool/Src/Print.asm
===================================================================
--- /trunk/BIOS_Drive_Information_Tool/Src/Print.asm	(revision 591)
+++ /trunk/BIOS_Drive_Information_Tool/Src/Print.asm	(revision 592)
@@ -149,5 +149,5 @@
 	xor		dh, dh
 	mov		si, dx
-	shl		si, 1		; Shift for WORD lookup
+	eSHL_IM	si, 1		; Shift for WORD lookup
 	push	WORD [si+.rgszXlateModeToString]
 
@@ -197,6 +197,10 @@
 ;--------------------------------------------------------------------
 Print_NameFromAtaInfoInBX:
+%ifdef CLD_NEEDED
 	cld
+%endif
+	mov		bp, sp
 	lea		si, [bx+ATA1.strModel]
+	push	si
 	mov		di, si
 	mov		cx, A1_MODEL_NUMBER_LENGTH/2
@@ -211,7 +215,4 @@
 	stosb				; Terminate with NULL
 
-	mov		bp, sp
-	lea		si, [bx+ATA1.strModel]
-	push	si
 	mov		si, g_szFormatDrvName
 	jmp		SHORT JumpToFormatNullTerminatedStringFromSI
Index: /trunk/BIOS_Drive_Information_Tool/Src/Strings.asm
===================================================================
--- /trunk/BIOS_Drive_Information_Tool/Src/Strings.asm	(revision 591)
+++ /trunk/BIOS_Drive_Information_Tool/Src/Strings.asm	(revision 592)
@@ -21,6 +21,6 @@
 SECTION .data
 
-g_szProgramName:	db	"BIOS Drive Information Tool v1.0.2",CR,LF
-					db	"(C) 2012-2016 by XTIDE Universal BIOS Team",CR,LF
+g_szProgramName:	db	"BIOS Drive Information Tool v1.0.3",CR,LF
+					db	"(C) 2012-2018 by XTIDE Universal BIOS Team",CR,LF
 					db	"Released under GNU GPL v2",CR,LF
 					db	"http://xtideuniversalbios.org/",CR,LF,NULL
@@ -42,6 +42,6 @@
 g_szBlockMode:		db	" Block mode   : Set to %u from max %u sectors",CR,LF,NULL
 g_szPIO:			db	" PIO mode     : Max %u, Min cycle times: %u ns, with IORDY %d ns",CR,LF,NULL
-g_szXTUB:			db	"XTIDE Universal BIOS %s generates following L-CHS...",CR,LF,NULL
-g_szXTUBversion:	db	ROM_VERSION_STRING	; This one is NULL terminated
+g_szXUB:			db	"XTIDE Universal BIOS %s generates following L-CHS...",CR,LF,NULL
+g_szXUBversion:		db	ROM_VERSION_STRING	; This one is NULL terminated
 
 g_szOldInfoHeader:	db	"Old INT 13h information from AH=08h and AH=15h...",CR,LF,NULL
Index: /trunk/BIOS_Drive_Information_Tool/makefile
===================================================================
--- /trunk/BIOS_Drive_Information_Tool/makefile	(revision 591)
+++ /trunk/BIOS_Drive_Information_Tool/makefile	(revision 592)
@@ -52,5 +52,5 @@
 # Assembler preprocessor defines.                               #
 #################################################################
-DEFINES = 
+DEFINES = EXCLUDE_FROM_BIOSDRVS
 DEFINES_XT = ELIMINATE_CGA_SNOW
 DEFINES_XTPLUS = USE_186 ELIMINATE_CGA_SNOW
@@ -98,5 +98,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
 
 
@@ -130,2 +130,7 @@
 	@upx -qq --8086 --ultra-brute $(TARGET).$(EXTENSION)
 	@echo Done! XT version is ready for release.
+
+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
+
Index: /trunk/Serial_Server/library/Checksum.cpp
===================================================================
--- /trunk/Serial_Server/library/Checksum.cpp	(revision 591)
+++ /trunk/Serial_Server/library/Checksum.cpp	(revision 592)
@@ -343,5 +343,5 @@
 			}
 
-			bbuff[ rand() % 512 ] ^= bit[ rand() % 8 ];
+			bbuff[ rand() & 511 ] ^= bit[ rand() & 7 ];
 
 			if( b > 0 )
Index: /trunk/Serial_Server/library/Image.cpp
===================================================================
--- /trunk/Serial_Server/library/Image.cpp	(revision 591)
+++ /trunk/Serial_Server/library/Image.cpp	(revision 592)
@@ -131,5 +131,5 @@
 			sect = 63;
 		}
-		else if( (totallba % 16) != 0 || ((totallba/16) % 63) != 0 )
+		else if( (totallba & 15) != 0 || ((totallba/16) % 63) != 0 )
 		{
 			log( -1, "'%s', file size does not match standard CHS geometry (x:16:63), please specify geometry explicitly with -g", name );
Index: /trunk/Serial_Server/win32/Win32.cpp
===================================================================
--- /trunk/Serial_Server/win32/Win32.cpp	(revision 591)
+++ /trunk/Serial_Server/win32/Win32.cpp	(revision 592)
@@ -37,5 +37,5 @@
 char *bannerStrings[] = {
 	"SerDrive - XTIDE Universal BIOS Serial Drive Server",
-	"Copyright (C) 2012-2013 by XTIDE Universal BIOS Team",
+	"Copyright (C) 2012-2018 by XTIDE Universal BIOS Team",
 	"Released under GNU GPL v2, with ABSOLUTELY NO WARRANTY",
 	ROM_VERSION_STRING,
@@ -49,6 +49,5 @@
  	"http://www.gnu.org/licenses/gpl-2.0.html",
 	"",
-	"Visit the wiki on http://code.google.com/p/xtideuniversalbios for detailed",
-	"serial drive usage directions.",
+	"Visit the wiki on http://xtideuniversalbios.org for detailed usage directions.",
 	"",
 	"Usage: SerDrive [options] imagefile [[slave-options] slave-imagefile]",
Index: /trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 592)
@@ -28,6 +28,4 @@
 ; Number of times to retry booting before accepting error
 BOOT_READ_RETRY_TIMES		EQU		3
-
-
 
 ; Pre-boot variables. These do not exist after successful boot to OS.
@@ -69,4 +67,7 @@
 %endif ; MODULE_HOTKEYS
 
+; MAX_HARD_DISK_NAME_LENGTH must be defined ahead of the DRVDETECTINFO structure to avoid problems with NASM
+MAX_HARD_DISK_NAME_LENGTH	EQU		30		; Bytes reserved for drive name
+
 struc DRVDETECTINFO
 	.StartOfDrvDetectInfo:
@@ -79,24 +80,10 @@
 endstruc
 
-; Boot Menu Information Table. These are generated for all XTIDE Universal
-; BIOS drives. Available only until boot is successful.
-MAX_HARD_DISK_NAME_LENGTH			EQU		30		; Bytes reserved for drive name
 DPT_DRVDETECTINFO_SIZE_MULTIPLIER	EQU		DRVDETECTINFO_size / LARGEST_DPT_SIZE
 
-
 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
-
 %if MAX_HARD_DISK_NAME_LENGTH % 2 <> 0
 	%error "MAX_HARD_DISK_NAME_LENGTH needs to be a multiple of 2, memory is moved with word operations."
 %endif
-
-%if DRVDETECTINFO_size % LARGEST_DPT_SIZE <> 0
-	%error "DRVDETECTINFO's size must be an even multiple of DPT's size.  Add or remove padding at the bottom of DRVDETECTINFO to bring the two sizes into alignment.  As DRVDETECTINFO is only used at boot time, with plenty of memory to consume, it is OK to waste some space here."
-%endif
-
-%if DRVDETECTINFO.szDrvName <> 0
-	%error "DRVDETECTINFO.szDrvName is assumed to be the first member of struc DRVDETECTINFO, in BootMenuPrint_RefreshItem"
-%endif
-
 %endif
 
Index: /trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc	(revision 592)
@@ -57,8 +57,8 @@
 %ifndef MODULE_8BIT_IDE	; Standard IDE controllers only
 
+	eMOVZX	bx, [di+DPT.bIdevarsOffset]
 	%ifnidni %1, dx
 		mov		dx, %1
 	%endif
-	eMOVZX	bx, BYTE [di+DPT.bIdevarsOffset]
 	add		dx, [cs:bx+IDEVARS.wControlBlockPort]
 	out		dx, al
Index: /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 592)
@@ -35,4 +35,5 @@
 	.wDisplayMode		resb	2	; Display mode for boot menu
 	.wBootTimeout		resb	2	; Boot Menu selection timeout in system timer ticks
+	.pColorTheme		resb	2	; Ptr to the color attribute struc used by the boot menu and hotkey bar
 	.bIdeCnt			resb	1	; Number of available IDE controllers
 	.bBootDrv			resb	1	; Default drive to boot from
@@ -182,5 +183,5 @@
 endstruc
 
-; Bit defines for DRVPARAMS.wFlags
+; Bit defines for DRVPARAMS.wFlags - these flags are accessed as bytes so changes here might require changes elsewhere
 MASK_DRVPARAMS_WRITECACHE		EQU	(3<<0)	; Bits 0...1, Drive internal write cache settings (must start at bit 0)
 	DEFAULT_WRITE_CACHE				EQU	0	; Must be 0
Index: /trunk/XTIDE_Universal_BIOS/Inc/Version.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/Version.inc	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Inc/Version.inc	(revision 592)
@@ -20,4 +20,5 @@
 
 ; Flash signature revisions:
+; XTIDE206	Added support for Color Themes
 ; XTIDE205	Added DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD after other XT-CF
 ;			PIO modes (prevents empty indexes in PIO jump tables)
@@ -48,5 +49,5 @@
 %define	TITLE_STRING			TITLE_STRING_START, TITLE_STRING_END
 %define	ROM_VERSION_STRING		"v2.0.0",BETA,"3+ (",__DATE__,")",NULL
-%define	FLASH_SIGNATURE			"XTIDE205"	; Do not terminate with NULL
+%define	FLASH_SIGNATURE			"XTIDE206"	; Do not terminate with NULL
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 592)
@@ -200,8 +200,12 @@
 %ifdef MODULE_IRQ
 	test	BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN
+%ifdef USE_386
+	jnz		IdeWait_IRQorStatusFlagInBLwithTimeoutInBH
+%else
 	jz		SHORT .PollStatusFlagInsteadOfWaitIrq
 	jmp		IdeWait_IRQorStatusFlagInBLwithTimeoutInBH
 .PollStatusFlagInsteadOfWaitIrq:
 %endif
+%endif ; MODULE_IRQ
 	jmp		IdeWait_PollStatusFlagInBLwithTimeoutInBH
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm	(revision 592)
@@ -121,5 +121,5 @@
 	jnz		SHORT .ChangeTo32bitDevice
 
-	and		BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_IORDY	; No IORDY supported if need to limit
+	and		[di+DPT.bFlagsHigh], ah		; Mask off FLGH_DPT_IORDY if IORDY not supported
 	MIN_U	[di+DPT_ADVANCED_ATA.bPioMode], al
 	mov		[di+DPT_ADVANCED_ATA.wMinPioCycleTime], bx
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm	(revision 592)
@@ -147,5 +147,5 @@
 	lds		di, [bp+MEMPIOVARS.fpDPT]			; DPT now in DS:DI
 %ifdef USE_386
-	movzx	cx, BYTE [bp+MEMPIOVARS.bSectorsDone]
+	movzx	cx, [bp+MEMPIOVARS.bSectorsDone]
 %else
 	mov		ch, 0								; Preserve CF
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 592)
@@ -97,5 +97,7 @@
 	sti									; Enable interrupts
 %endif
+%ifdef CLD_NEEDED
 	cld									; String instructions to increment pointers
+%endif
 	ePUSHA
 	push	ds
@@ -193,6 +195,10 @@
 
 	; Push old INT 13h handler and restore registers
+%ifdef USE_386
+	push	DWORD [RAMVARS.fpOldI13h]
+%else
 	push	WORD [RAMVARS.fpOldI13h+2]
 	push	WORD [RAMVARS.fpOldI13h]
+%endif
 	mov		bx, [bp+IDEPACK.intpack+INTPACK.bx]
 	mov		di, [bp+IDEPACK.intpack+INTPACK.di]
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 592)
@@ -126,5 +126,5 @@
 	mov		cx, NUMBER_OF_IDEVARS
 
-.loop:
+.Loop:
 	call	FindDPT_MasterOrSingleForIdevarsOffsetInDL
 	jc		SHORT .ControllerNotAvailable
@@ -162,4 +162,4 @@
 .ControllerNotAvailable:
 	add		dl, IDEVARS_size							; move Idevars pointer forward
-	loop	.loop
+	loop	.Loop
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 592)
@@ -121,7 +121,7 @@
 	;
 	; Also note that some machines, noteably the Olivetti M24 (also known as
-	; the AT&T PC6300 and Xerox 6060), have hardware errors in the BIU logic,
-	; resulting in reversed byte ordering.  Therefore, XTCF_8BIT_PIO_MODE is
-	; the default transfer mode for best system compatibility.
+	; the AT&T PC6300 or Xerox 6060 or Logabax Persona 1600), have hardware errors
+	; in the BIU logic, resulting in reversed byte ordering.  Therefore,
+	; XTCF_8BIT_PIO_MODE is the default transfer mode for best system compatibility.
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm	(revision 592)
@@ -46,5 +46,5 @@
 
 	mov		BYTE [bp+IDEPACK.intpack+INTPACK.ah], EBIOS_VERSION
-	mov		WORD [bp+IDEPACK.intpack+INTPACK.bx], 0AA55h
+	not		WORD [bp+IDEPACK.intpack+INTPACK.bx]	; 55AAh = AA55h
 
 %ifdef MODULE_COMPATIBLE_TABLES
@@ -75,11 +75,19 @@
 ;--------------------------------------------------------------------
 AH41h_GetSupportBitsToCX:
+%ifdef USE_AT	; Always in Full mode
+%ifndef MODULE_8BIT_IDE OR MODULE_SERIAL
+	mov		cx, ENHANCED_DRIVE_ACCESS_SUPPORT | ENHANCED_DISK_DRIVE_SUPPORT
+%else
+	mov		cx, ENHANCED_DRIVE_ACCESS_SUPPORT
+	cmp		BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_ATA
+	jae		SHORT .DoNotSetEDDflag
+	or		cl, ENHANCED_DISK_DRIVE_SUPPORT
+%endif
+%else ; ~USE_AT
 	mov		cx, ENHANCED_DRIVE_ACCESS_SUPPORT
 
 	; DPTE needs buffer from RAM so do not return it in lite mode
-%ifndef USE_AT
 	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
 	jz		SHORT .DoNotSetEDDflag
-%endif
 
 %ifdef MODULE_8BIT_IDE OR MODULE_SERIAL
@@ -91,4 +99,5 @@
 
 	or		cl, ENHANCED_DISK_DRIVE_SUPPORT	; AH=48h returns DPTE
+%endif ; USE_AT
 .DoNotSetEDDflag:
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 592)
@@ -110,12 +110,12 @@
 	and		al, MASKL_DPT_TRANSLATEMODE
 
-;;; 0: ADDRESSING_MODE_NORMAL
+;;; 0: TRANSLATEMODE_NORMAL
 	jz		SHORT DoNotConvertLCHS
 
-;;; 1: ADDRESSING_MODE_LARGE
+;;; 1: TRANSLATEMODE_LARGE
 	test	al, FLGL_DPT_ASSISTED_LBA
 	jz		SHORT ConvertLargeModeLCHStoPCHS
 
-;;; 2: ADDRESSING_MODE_ASSISTED_LBA
+;;; 2: TRANSLATEMODE_ASSISTED_LBA
 	; Fall to ConvertAssistedLBAModeLCHStoLBARegisterValues
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 592)
@@ -30,5 +30,7 @@
 Int19h_BootLoaderHandler:
 	sti											; Enable interrupts
+%ifdef CLD_NEEDED
 	cld											; String instructions to increment pointers
+%endif
 %ifdef MODULE_VERY_LATE_INIT
 	LOAD_BDA_SEGMENT_TO	ds, ax					; Load BDA segment (zero) to DS
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm	(revision 592)
@@ -60,6 +60,6 @@
 ;		AX:		ID WORD specific for detected controller
 ;	Returns:
-;		AL:		Max supported PIO mode
-;		AH:		FLGH_DPT_IORDY if IORDY supported, zero otherwise
+;		AL:		Max supported PIO mode (only if ZF set)
+;		AH:		~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set)
 ;		BX:		Min PIO cycle time (only if ZF set)
 ;		ZF:		Set if PIO limit necessary
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/PDC20x30.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/PDC20x30.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/PDC20x30.asm	(revision 592)
@@ -127,5 +127,5 @@
 
 	; PDC20230C and PDC20630 clears the bit we set at the beginning
-	in		al, dx
+	in		al, dx	; 1F2h
 	dec		dx
 	dec		dx		; Base port
@@ -139,6 +139,6 @@
 ;		AX:		ID WORD specific for detected controller
 ;	Returns:
-;		AL:		Max supported PIO mode
-;		AH:		FLGH_DPT_IORDY if IORDY supported, zero otherwise
+;		AL:		Max supported PIO mode (only if ZF set)
+;		AH:		~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set)
 ;		BX:		Min PIO cycle time (only if ZF set)
 ;		ZF:		Set if PIO limit necessary
@@ -148,9 +148,8 @@
 ;--------------------------------------------------------------------
 PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX:
-	cmp		ah, ID_PDC20630
-	je		SHORT .Return		; No need to limit anything
-	mov		ax, 2				; Limit PIO to 2 for ID_PDC20230
+	cmp		ah, ID_PDC20230
+	jne		SHORT .Return							; No need to limit anything for ID_PDC20630
+	mov		ax, (~FLGH_DPT_IORDY & 0FFh) << 8 | 2	; Limit PIO to 2 for ID_PDC20230
 	mov		bx, PIO_2_MIN_CYCLE_TIME_NS
-	stc
 .Return:
 	ret
@@ -206,7 +205,9 @@
 ;--------------------------------------------------------------------
 SetSpeedForDriveInCX:
-	eMOVZX	bx, BYTE [di+DPT_ADVANCED_ATA.bPioMode]
-	MIN_U	bl, 2	; Limit to PIO2
-	mov		bl, [cs:bx+.rgbPioModeToPDCspeedValue]
+	mov		bx, .rgbPioModeToPDCspeedValue
+	mov		al, [di+DPT_ADVANCED_ATA.bPioMode]
+	MIN_U	al, 2	; Limit to PIO2
+	cs xlat
+	xchg	bx, ax
 
 	add		dx, BYTE SECTOR_NUMBER_REGISTER
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm	(revision 592)
@@ -131,6 +131,6 @@
 ;		AH:		QDI Vision Controller ID
 ;	Returns:
-;		AL:		Max supported PIO mode
-;		AH:		FLGH_DPT_IORDY if IORDY supported, zero otherwise
+;		AL:		Max supported PIO mode (only if ZF set)
+;		AH:		~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set)
 ;		BX:		Min PIO Cycle Time (only if ZF set)
 ;		ZF:		Set if PIO limit necessary
@@ -142,6 +142,5 @@
 	cmp		ah, ID_QD6500
 	jne		SHORT .NoNeedToLimitForQD6580
-
-	mov		ax, 2	; Limit to PIO 2 because QD6500 does not support IORDY
+	mov		ax, (~FLGH_DPT_IORDY & 0FFh) << 8 | 2	; Limit to PIO 2 because QD6500 does not support IORDY
 	mov		bx, PIO_2_MIN_CYCLE_TIME_NS
 .NoNeedToLimitForQD6580:
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 592)
@@ -104,5 +104,5 @@
 ;		DX:		User defined P-CHS to L-CHS translate mode
 ;	Corrupts registers:
-;		AX, BX, CX
+;		AX, BX
 ;--------------------------------------------------------------------
 AtaID_ModifyESSIforUserDefinedLimitsAndReturnTranslateModeInDX:
@@ -113,8 +113,8 @@
 	pop		ds
 
-	; Load User Defined CHS or LBA to CX:AX
-	mov		dx, [bx+DRVPARAMS.wFlags]
+	; Load User Defined CHS or LBA to BX:AX
+	mov		dl, [bx+DRVPARAMS.wFlags]			; Only load the flags we actually need
 	mov		ax, [bx+DRVPARAMS.wCylinders]		; Or .dwMaximumLBA
-	mov		cx, [bx+DRVPARAMS.wHeadsAndSectors]	; Or .dwMaximumLBA+2
+	mov		bx, [bx+DRVPARAMS.wHeadsAndSectors]	; Or .dwMaximumLBA+2
 
 	push	es
@@ -127,7 +127,7 @@
 	; Apply new CHS and disable LBA (we also want to set CHS addressing)
 	mov		[si+ATA1.wCylCnt], ax
-	eMOVZX	ax, cl
+	eMOVZX	ax, bl
 	mov		[si+ATA1.wHeadCnt], ax
-	mov		al, ch
+	mov		al, bh
 	mov		[si+ATA1.wSPT], ax
 	and		BYTE [si+ATA1.wCaps+1], ~(A1_wCaps_LBA>>8)
@@ -140,5 +140,5 @@
 
 	; Apply new LBA and disable LBA48
-	cmp		cx, [si+ATA1.dwLBACnt+2]
+	cmp		bx, [si+ATA1.dwLBACnt+2]
 	ja		SHORT .NoUserDefinedLBA		; Do not set larger than drive
 	jb		SHORT .StoreNewLBA
@@ -147,5 +147,5 @@
 .StoreNewLBA:
 	mov		[si+ATA1.dwLBACnt], ax
-	mov		[si+ATA1.dwLBACnt+2], cx
+	mov		[si+ATA1.dwLBACnt+2], bx
 	and		BYTE [si+ATA6.wSetSup83+1], ~(A6_wSetSup83_LBA48>>8)
 .NoUserDefinedLBA:
@@ -173,13 +173,18 @@
 AtaID_GetMaxPioModeToAXandMinCycleTimeToCX:
 	; Get PIO mode and cycle time for PIO 0...2
-	mov		bx, [es:si+ATA1.bPioMode]
-	mov		ax, bx					; AH = 0, AL = PIO mode 0, 1 or 2
-	eSHL_IM	bx, 1					; Shift for WORD lookup
+%ifdef USE_386
+	movzx	ax, [es:si+ATA1.bPioMode]	; AH = 0, AL = PIO mode 0, 1 or 2
+%else
+	mov		al, [es:si+ATA1.bPioMode]
+	cbw
+%endif
+	mov		bx, ax
+	eSHL_IM	bx, 1						; Shift for WORD lookup
 	mov		cx, [cs:bx+.rgwPio0to2CycleTimeInNanosecs]
 
 	; Check if IORDY is supported
 	test	BYTE [es:si+ATA2.wCaps+1], A2_wCaps_IORDY >> 8
-	jz		SHORT .ReturnPioTimings	; No PIO 3 or higher if no IORDY
-	mov		ah, FLGH_DPT_IORDY
+	jz		SHORT .ReturnPioTimings		; No PIO 3 or higher if no IORDY
+	mov		ah, FLGH_DPT_IORDY			; *FIXME* Actually, CF specification v4.1 says that use of IORDY is invalid for PIO modes 5 and 6.
 
 	; Check if Advanced PIO modes are supported (3 and above)
@@ -187,10 +192,10 @@
 	jz		SHORT .ReturnPioTimings
 
-	; Get Advanced PIO mode
-	; (Hard Disks supports up to 4 but CF cards can support 5 and 6)
-	mov		bl, [es:si+ATA2.bPIOSupp]
+	; Get Advanced PIO mode (Hard Disks supports up to 4 but CF cards can support 5 and 6)
+	or		bh, [es:si+ATA2.bPIOSupp]
+	jz		SHORT .ReturnPioTimings
 .CheckNextFlag:
 	inc		ax
-	shr		bl, 1
+	shr		bh, 1
 	jnz		SHORT .CheckNextFlag
 	MIN_U	al, 6						; Make sure not above lookup tables
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 592)
@@ -150,6 +150,12 @@
 	push	bp
 	mov		bp, sp
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+%if DRVDETECTINFO.szDrvName = 0
+	push	bx
+%else
 	lea		si, [bx+DRVDETECTINFO.szDrvName]
 	push	si
+%endif
+%endif
 	mov		si, g_szDriveName
 	jmp		SHORT DetectPrint_FormatCSSIfromParamsInSSBP
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 592)
@@ -190,16 +190,8 @@
 	LOAD_BDA_SEGMENT_TO	ds, ax
 	mov		al, [BDA.wEquipment]	; Load Equipment WORD low byte
+	and		al, 0C1h				; Leave bits 7..6 and 0
+	eAAM	64
+	add		al, ah					; AL = Floppy Drive count
 	pop		ds
-
-%ifdef USE_UNDOC_INTEL
-	and		al, 0C1h
-	eAAM	64
-%else
-	mov		ah, al					; Copy it to AH
-	and		ax, 0C001h				; Leave bits 15..14 and 0
-	eROL_IM	ah, 2					; EW low byte bits 7..6 to 1..0
-%endif ; USE_UNDOC_INTEL
-
-	add		al, ah					; AL = Floppy Drive count
 %endif ; USE_AT
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 592)
@@ -239,8 +239,8 @@
 .ClearBitFrom8259MaskRegister:
 	push	cx
-	xchg	ax, cx				; IRQ index to CL
+	xchg	cx, ax				; IRQ index to CL
+	in		al, dx				; Read Interrupt Mask Register
 	mov		ch, ~1				; Load bit mask to be rotated
 	rol		ch, cl				; Rotate mask to correct position for clearing
-	in		al, dx				; Read Interrupt Mask Register
 	and		al, ch				; Clear wanted bit
 	out		dx, al				; Write modified Interrupt Mask Register
Index: /trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 592)
@@ -32,5 +32,5 @@
 
 	; We must define included libraries before including "AssemblyLibrary.inc".
-%define	EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS	; Exclude unused library functions
+%define	EXCLUDE_FROM_XUB					; Exclude unused library functions
 %ifdef MODULE_BOOT_MENU
 	%define MENUEVENT_INLINE_OFFSETS		; Only one menu required, save space and inline offsets
@@ -81,4 +81,5 @@
 %ifdef MODULE_BOOT_MENU
 	at	ROMVARS.wBootTimeout,	dw	BOOT_MENU_DEFAULT_TIMEOUT
+	at	ROMVARS.pColorTheme,	dw	ColorTheme				; Offset to the ATTRIBUTE_CHARS struc that holds the color theme
 %endif
 	at	ROMVARS.bIdeCnt,		db	2						; Number of supported controllers
@@ -105,5 +106,5 @@
 	at	ROMVARS.ideVars2+IDEVARS.wControlBlockPort,	dw	DEVICE_ATA_TERTIARY_PORTCTRL
 	at	ROMVARS.ideVars2+IDEVARS.bDevice,			db	DEVICE_16BIT_ATA
-	at	ROMVARS.ideVars2+IDEVARS.bIRQ,				db	0
+	at	ROMVARS.ideVars2+IDEVARS.bIRQ,				db	0	; Should be 11 on the GSI Inc. Model 2C
 	at	ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	dw	DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
 	at	ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	dw	DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
@@ -112,5 +113,5 @@
 	at	ROMVARS.ideVars3+IDEVARS.wControlBlockPort,	dw	DEVICE_ATA_QUATERNARY_PORTCTRL
 	at	ROMVARS.ideVars3+IDEVARS.bDevice,			db	DEVICE_16BIT_ATA
-	at	ROMVARS.ideVars3+IDEVARS.bIRQ,				db	0
+	at	ROMVARS.ideVars3+IDEVARS.bIRQ,				db	0	; Should be 10 on the GSI Inc. Model 2C
 	at	ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	dw	DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
 	at	ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	dw	DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
@@ -127,4 +128,5 @@
 %ifdef MODULE_BOOT_MENU
 	at	ROMVARS.wBootTimeout,	dw	BOOT_MENU_DEFAULT_TIMEOUT
+	at	ROMVARS.pColorTheme,	dw	ColorTheme				; Offset to the ATTRIBUTE_CHARS struc that holds the color theme
 %endif
 	at	ROMVARS.bIdeCnt,		db	1
@@ -301,4 +303,5 @@
 
 
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 ; Although it's very unlikely to happen, we give warnings for builds that cannot be automatically checksummed due to the size being too large.
 ; In some cases it's theoretically possible to checksum the build anyway (manually) which is why these are warnings and not errors.
@@ -309,5 +312,6 @@
 		%endif
 	%endif
-%elif ($-$$) = BIOS_SIZE			; A large build.
+%elif ($-$$) = BIOS_SIZE			; A large or tiny build.
 	%warning "This build is too large to be auto-checksummed!"
 %endif
+%endif
Index: /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm	(revision 592)
@@ -141,5 +141,5 @@
 
 	; Store default Menuitem (=default drive to boot from)
-	eMOVZX	dx, BYTE [cs:ROMVARS.bBootDrv]
+	eMOVZX	dx, [cs:ROMVARS.bBootDrv]
 	call	GetMenuitemToDXforDriveInDL
 	mov		[bp+MENUINIT.wHighlightedItem], dx
Index: /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrint.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrint.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrint.asm	(revision 592)
@@ -54,5 +54,5 @@
 	test	dl, dl
 	js		SHORT .go
-	mov		bl, ((g_szFloppyDrv)-$$ & 0xff)			; and revisit the earlier assumption...
+	mov		bl, (g_szFloppyDrv - $$) & 0xff			; and revisit the earlier assumption...
 
 .go:
Index: /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm	(revision 592)
@@ -63,6 +63,10 @@
 	;; with AL clear, and so we exchange AL and AH after the multiply for the final result.
 	;;
+%ifdef USE_186
+	imul	ax, g_szAddressingModes_Displacement << (8-TRANSLATEMODE_FIELD_POSITION)
+%else
 	mov		cx, g_szAddressingModes_Displacement << (8-TRANSLATEMODE_FIELD_POSITION)
 	mul		cx
+%endif
 	xchg	al, ah		; AL = always zero after above multiplication
 	add		ax, g_szAddressingModes
Index: /trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 592)
@@ -407,5 +407,5 @@
 	sbb		di, BYTE 1				; Sub CF if Floppy Drive
 	xchg	ax, cx
-	mov		[es:di], al
+	stosb
 	stc								; Valid hotkey scancode returned in AL
 
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 592)
@@ -114,8 +114,104 @@
 	; slower. The speed difference doesn't matter on AT systems.
 .UseAssistedLBA:
-	call	GetSectorCountToDXAXfromCHSinAXBLBH
-	call	ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
-	xor		cx, cx		; No bits to shift
+	; Fall to GetSectorCountToDXAXfromCHSinAXBLBH
+
+
+;--------------------------------------------------------------------
+; GetSectorCountToDXAXfromCHSinAXBLBH
+;	Parameters:
+;		AX:		Number of cylinders (1...16383)
+;		BL:		Number of heads (1...255)
+;		BH:		Number of sectors per track (1...63)
+;	Returns:
+;		DX:AX:	Total number of CHS addressable sectors
+;	Corrupts registers:
+;		BX
+;--------------------------------------------------------------------
+GetSectorCountToDXAXfromCHSinAXBLBH:
+	xchg	ax, bx
+	mul		ah			; AX = Heads * Sectors per track
+	mul		bx
+	; Fall to ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
+
+
+;--------------------------------------------------------------------
+; LBA assist calculation (or Assisted LBA)
+;
+; This algorithm translates P-CHS sector count up to largest possible
+; L-CHS sector count (1024, 255, 63). Note that INT 13h interface allows
+; 256 heads but DOS supports up to 255 head. That is why BIOSes never
+; use 256 heads.
+;
+; L-CHS parameters generated here require the drive to use LBA addressing.
+;
+; Here is the algorithm:
+; If cylinders > 8192
+;  Variable CH = Total CHS Sectors / 63
+;  Divide (CH - 1) by 1024 and add 1
+;  Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads.
+;  Divide CH by the number of heads. This is the value to be used for the number of cylinders.
+;
+; ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
+;	Parameters:
+;		DX:AX:	Total number of P-CHS sectors for CHS addressing
+;				(max = 16383 * 16 * 63 = 16,514,064)
+;	Returns:
+;		AX:		Number of cylinders (?...1027)
+;		BL:		Number of heads (16, 32, 64, 128 or 255)
+;		BH:		Number of sectors per track (always 63)
+;		CX:		Number of bits shifted (0)
+;		DL:		TRANSLATEMODE_ASSISTED_LBA
+;	Corrupts registers:
+;		DH
+;--------------------------------------------------------------------
+ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
+	; Value CH = Total sector count / 63
+	; Max = 16,514,064 / 63 = 262128
+	mov		cx, LBA_ASSIST_SPT			; CX = 63
+
+	; --- Math_DivDXAXbyCX inlined (and slightly modified) since it's only used here
+	xor		bx, bx
+	xchg	bx, ax
+	xchg	dx, ax
+	div		cx
+	xchg	ax, bx
+	div		cx
+	mov		dx, bx
+	; ---
+
+	push	ax
+	push	dx							; Value CH stored for later use
+
+	; BX:DX:AX = Value CH - 1
+	; Max = 262128 - 1 = 262127
+	xor		bx, bx
+	sub		ax, BYTE 1
+	sbb		dx, bx
+
+	; AX = Number of heads = ((Value CH - 1) / 1024) + 1
+	; Max = (262127 / 1024) + 1 = 256
+	call	Size_DivideSizeInBXDXAXby1024	; Preserves CX and returns with BH cleared
+	pop		dx
+	inc		ax							; + 1
+
+	; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest)
+	; Max = 255
+	mov		bl, 16						; Min number of heads
+.CompareNextValidNumberOfHeads:
+	cmp		ax, bx
+	jbe		SHORT .NumberOfHeadsNowInBX
+	eSHL_IM	bx, 1						; Double number of heads
+	jpo		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
+	dec		bx							;  If so, limit heads to 255
+.NumberOfHeadsNowInBX:
+
+	; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads
+	; Max = 262128 / 255 = 1027
+	pop		ax							; Value CH back to DX:AX
+	div		bx
+
+	xchg	bh, cl						; Sectors per Track to BH, zero to CL (CX)
 	mov		dl, TRANSLATEMODE_ASSISTED_LBA
+ReturnLCHSinAXBLBH:
 	ret
 
@@ -136,22 +232,4 @@
 	mov		bl, [es:si+ATA1.wHeadCnt]	; Heads (1...16)
 	mov		bh, [es:si+ATA1.wSPT]		; Sectors per Track (1...63)
-	ret
-
-
-;--------------------------------------------------------------------
-; GetSectorCountToDXAXfromCHSinAXBLBH
-;	Parameters:
-;		AX:		Number of cylinders (1...16383)
-;		BL:		Number of heads (1...255)
-;		BH:		Number of sectors per track (1...63)
-;	Returns:
-;		DX:AX:	Total number of CHS addressable sectors
-;	Corrupts registers:
-;		BX
-;--------------------------------------------------------------------
-GetSectorCountToDXAXfromCHSinAXBLBH:
-	xchg	ax, bx
-	mul		ah			; AX = Heads * Sectors per track
-	mul		bx
 	ret
 
@@ -175,4 +253,8 @@
 ;  Do a standard ECHS translation
 ;
+; *FIXME* The above algorithm seems to be conflicting with info found here
+; https://web.archive.org/web/20000817071418/http://www.firmware.com:80/support/bios/over4gb.htm
+; which says that Revised ECHS is used when the cylinder count is > 8191.
+;
 ; ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL:
 ;	Parameters:
@@ -183,5 +265,5 @@
 ;		BL:		Number of L-CHS heads (?...240)
 ;		CX:		Number of bits shifted (0...3)
-;		DX:		ADDRESSING_MODE_NORMAL or ADDRESSING_MODE_LARGE
+;		DX:		TRANSLATEMODE_NORMAL or TRANSLATEMODE_LARGE
 ;	Corrupts registers:
 ;		Nothing
@@ -271,72 +353,2 @@
 	ret
 
-
-;--------------------------------------------------------------------
-; LBA assist calculation (or Assisted LBA)
-;
-; This algorithm translates P-CHS sector count up to largest possible
-; L-CHS sector count (1024, 255, 63). Note that INT 13h interface allows
-; 256 heads but DOS supports up to 255 head. That is why BIOSes never
-; use 256 heads.
-;
-; L-CHS parameters generated here require the drive to use LBA addressing.
-;
-; Here is the algorithm:
-; If cylinders > 8192
-;  Variable CH = Total CHS Sectors / 63
-;  Divide (CH  1) by 1024 and add 1
-;  Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads.
-;  Divide CH by the number of heads. This is the value to be used for the number of cylinders.
-;
-; ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
-;	Parameters:
-;		DX:AX:	Total number of P-CHS sectors for CHS addressing
-;				(max = 16383 * 16 * 63 = 16,514,064)
-;	Returns:
-;		AX:		Number of cylinders (?...1027)
-;		BL:		Number of heads (16, 32, 64, 128 or 255)
-;		BH:		Number of sectors per track (always 63)
-;	Corrupts registers:
-;		CX, DX
-;--------------------------------------------------------------------
-ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
-	; Value CH = Total sector count / 63
-	; Max = 16,514,064 / 63 = 262128
-	mov		cx, LBA_ASSIST_SPT			; CX = 63
-	call	Math_DivDXAXbyCX			; Preserves CX
-	push	dx
-	push	ax							; Value CH stored for later use
-
-	; BX:DX:AX = Value CH - 1
-	; Max = 262128 - 1 = 262127
-	xor		bx, bx
-	sub		ax, BYTE 1
-	sbb		dx, bx
-
-	; AX = Number of heads = ((Value CH - 1) / 1024) + 1
-	; Max = (262127 / 1024) + 1 = 256
-	call	Size_DivideSizeInBXDXAXby1024	; Preserves CX
-	inc		ax							; + 1
-
-	; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest)
-	; Max = 255
-	mov		cl, 16						; Min number of heads
-.CompareNextValidNumberOfHeads:
-	cmp		ax, cx
-	jbe		SHORT .NumberOfHeadsNowInCX
-	eSHL_IM	cx, 1						; Double number of heads
-	jpo		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
-	dec		cx							;  If so, limit heads to 255
-.NumberOfHeadsNowInCX:
-	mov		bx, cx						; Number of heads are returned in BL
-	mov		bh, LBA_ASSIST_SPT			; Sectors per Track
-
-	; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads
-	; Max = 262128 / 255 = 1027
-	pop		ax
-	pop		dx							; Value CH back to DX:AX
-	div		cx
-
-	; Return L-CHS
-ReturnLCHSinAXBLBH:
-	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/DrvDetectInfo.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/DrvDetectInfo.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/DrvDetectInfo.asm	(revision 592)
@@ -46,8 +46,10 @@
 
 	add		si, BYTE ATA1.strModel				; DS:SI now points drive name (Clears CF)
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 %if DRVDETECTINFO.szDrvName = 0
 	mov		di, bx
 %else
 	lea		di, [bx+DRVDETECTINFO.szDrvName]	; ES:DI now points to name destination
+%endif
 %endif
 	mov		cx, MAX_HARD_DISK_NAME_LENGTH / 2	; Max number of WORDs allowed
@@ -78,14 +80,19 @@
 ;--------------------------------------------------------------------
 DriveDetectInfo_ConvertDPTtoBX:
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 %if DPT_DRVDETECTINFO_SIZE_MULTIPLIER = 2
 %if BOOTVARS.rgDrvDetectInfo & 1					; Should never be odd but better safe than sorry
-	lea		ax, [di-RAMVARS_size]
-	eSHL_IM	ax, 1
-	add		ax, BOOTVARS.rgDrvDetectInfo
+	lea		bx, [di-RAMVARS_size]
+	eSHL_IM	bx, 1
+	add		bx, BOOTVARS.rgDrvDetectInfo
 %else
-	lea		ax, [di-RAMVARS_size+(BOOTVARS.rgDrvDetectInfo/2)]
-;	eSHL_IM	ax, 1									; *FIXME* For some reason this will cause NASM to crap itself.
-	shl		ax, 1									; So this will have to suffice for now.
+	lea		bx, [di-RAMVARS_size+(BOOTVARS.rgDrvDetectInfo/2)]
+	eSHL_IM	bx, 1
 %endif
+%else
+%ifdef USE_186
+	lea		bx, [di-RAMVARS_size]
+	imul	bx, DPT_DRVDETECTINFO_SIZE_MULTIPLIER
+	add		bx, BOOTVARS.rgDrvDetectInfo
 %else
 	lea		ax, [di-RAMVARS_size]					; subtract off base of DPTs
@@ -93,5 +100,7 @@
 	mul		bl
 	add		ax, BOOTVARS.rgDrvDetectInfo			; add base of DRVDETECTINFO
+	xchg	bx, ax
 %endif
-	xchg	bx, ax
+%endif
+%endif
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 592)
@@ -31,20 +31,9 @@
 ;		DS:		RAMVARS segment
 ;	Corrupts registers:
-;		AX, CX, DI
+;		AX, CX, DX, DI
 ;--------------------------------------------------------------------
 RamVars_Initialize:
 	push	es
-	; Fall to .StealMemoryForRAMVARS
 
-;--------------------------------------------------------------------
-; .StealMemoryForRAMVARS
-;	Parameters:
-;		Nothing
-;	Returns:
-;		DS:		RAMVARS segment
-;	Corrupts registers:
-;		AX, CL
-;--------------------------------------------------------------------
-.StealMemoryForRAMVARS:
 %ifndef USE_AT
 	mov		ax, LITE_MODE_RAMVARS_SEGMENT
@@ -56,27 +45,16 @@
 	mov		al, [cs:ROMVARS.bStealSize]
 	sub		[BDA.wBaseMem], ax
-	mov		ax, [BDA.wBaseMem]
 %ifdef USE_186
-	shl		ax, 6						; Segment to first stolen kB (*=40h)
+	imul	ax, [BDA.wBaseMem], 64
 %else
-	mov		cl, 6
-	shl		ax, cl
+	mov		al, 64
+	mul		WORD [BDA.wBaseMem]
 %endif
-	; Fall to .InitializeRamvars
 
-;--------------------------------------------------------------------
-; .InitializeRamvars
-;	Parameters:
-;		AX:		RAMVARS segment
-;	Returns:
-;		DS:		RAMVARS segment
-;	Corrupts registers:
-;		AX, CX, DI, ES
-;--------------------------------------------------------------------
 .InitializeRamvars:
+	xor		di, di
 	mov		ds, ax
 	mov		es, ax
 	mov		cx, RAMVARS_size
-	xor		di, di
 	call	Memory_ZeroESDIwithSizeInCX
 	mov		WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE
@@ -121,6 +99,10 @@
 .GetStolenSegmentToDS:
 	LOAD_BDA_SEGMENT_TO	ds, di
+;%ifdef USE_186
+;	imul	di, [BDA.wBaseMem], 64	; 2 bytes less but slower, especially on 386/486 processors
+;%else
 	mov		di, [BDA.wBaseMem]		; Load available base memory size in kB
 	eSHL_IM	di, 6					; Segment to first stolen kB (*=40h)
+;%endif
 ALIGN JUMP_ALIGN
 .LoopStolenKBs:
Index: /trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- /trunk/XTIDE_Universal_BIOS/makefile	(revision 591)
+++ /trunk/XTIDE_Universal_BIOS/makefile	(revision 592)
@@ -41,4 +41,5 @@
 # USE_AT                      Use features supported on AT and later systems (not available on XT) #
 # USE_UNDOC_INTEL             Optimizations for Intel CPU:s - do NOT use on NEC V20/V30/Sony CPU:s #
+# CLD_NEEDED                  Only needed for compatibility with buggy software/BIOSes             #
 #                                                                                                  #
 # ** AT Builds only (when USE_AT is defined)                                                       #
@@ -103,5 +104,5 @@
 # Assembler preprocessor defines.                               #
 #################################################################
-DEFINES_COMMON = MODULE_STRINGS_COMPRESSED MODULE_HOTKEYS MODULE_8BIT_IDE MODULE_EBIOS MODULE_SERIAL MODULE_SERIAL_FLOPPY MODULE_POWER_MANAGEMENT RESERVE_DIAGNOSTIC_CYLINDER NO_ATAID_VALIDATION
+DEFINES_COMMON = MODULE_STRINGS_COMPRESSED MODULE_HOTKEYS MODULE_8BIT_IDE MODULE_EBIOS MODULE_SERIAL MODULE_SERIAL_FLOPPY MODULE_POWER_MANAGEMENT RESERVE_DIAGNOSTIC_CYLINDER NO_ATAID_VALIDATION CLD_NEEDED
 DEFINES_COMMON_LARGE = MODULE_BOOT_MENU MODULE_8BIT_IDE_ADVANCED MODULE_COMPATIBLE_TABLES
 
@@ -114,5 +115,5 @@
 DEFINES_AT_LARGE = $(DEFINES_AT) $(DEFINES_COMMON_LARGE)
 
-DEFINES_XT_TINY = MODULE_STRINGS_COMPRESSED MODULE_8BIT_IDE NO_ATAID_VALIDATION
+DEFINES_XT_TINY = MODULE_STRINGS_COMPRESSED MODULE_8BIT_IDE NO_ATAID_VALIDATION CLD_NEEDED
 DEFINES_386_8K = $(DEFINES_AT) USE_386 MODULE_ADVANCED_ATA
 
@@ -125,19 +126,19 @@
 ###################
 
-# Target size of the ROM, used in main.asm for number of 512B blocks and by checksum Perl script below
-BIOS_SIZE = 8192		# For BIOS header (use even multiplier!)
-ROMSIZE = $(BIOS_SIZE)	# Size of binary to build when building with make checksum
-BIOS_SIZE_LARGE = 12288
-ROMSIZE_LARGE = $(BIOS_SIZE_LARGE)
+# Target size of the BIOS, used in main.asm for number of 512B blocks (CNT_ROM_BLOCKS) and by checksum Perl script below ('make checksum').
+# Note! The size must be a multiple of 2 KB for compatibility reasons.
+BIOS_SIZE_TINY = 4096
+BIOS_SIZE_SMALL = 8192
+BIOS_SIZE_LARGE = 10240
 
 # Add -D in front of every preprocessor define declaration
-DEFS_XT = $(DEFINES_XT:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE)
-DEFS_XTPLUS = $(DEFINES_XTPLUS:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE)
-DEFS_AT = $(DEFINES_AT:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE)
+DEFS_XT = $(DEFINES_XT:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_SMALL)
+DEFS_XTPLUS = $(DEFINES_XTPLUS:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_SMALL)
+DEFS_AT = $(DEFINES_AT:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_SMALL)
 DEFS_XT_LARGE = $(DEFINES_XT_LARGE:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_LARGE)
 DEFS_XTPLUS_LARGE = $(DEFINES_XTPLUS_LARGE:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_LARGE)
 DEFS_AT_LARGE = $(DEFINES_AT_LARGE:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_LARGE)
-DEFS_XT_TINY = $(DEFINES_XT_TINY:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE)
-DEFS_386_8K = $(DEFINES_386_8K:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE)
+DEFS_XT_TINY = $(DEFINES_XT_TINY:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_TINY)
+DEFS_386_8K = $(DEFINES_386_8K:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_SMALL)
 DEFS_ALL_FEATURES = $(DEFINES_ALL_FEATURES:%=-D%)
 
@@ -220,5 +221,5 @@
 strings: src\Strings.asm
 	@$(AS) src\Strings.asm $(ASFLAGS) $(DEFS_AT_LARGE) -DCHECK_FOR_UNUSED_ENTRYPOINTS -DMODULE_STRINGS_COMPRESSED_PRECOMPRESS -o build\Strings.bin -l build\StringsPrecompress.lst
-	@perl ..\tools\StringsCompress.pl < build\StringsPrecompress.lst > src\StringsCompressed.asm
+	@perl ..\Tools\StringsCompress.pl < build\StringsPrecompress.lst > src\StringsCompressed.asm
 	@echo StringsCompressed.asm updated!
 
@@ -228,12 +229,12 @@
 
 checksum: all
-	@perl ..\tools\checksum.pl $(TARGET)_tiny.bin $(ROMSIZE)
-	@perl ..\tools\checksum.pl $(TARGET)_xt.bin $(ROMSIZE)
-	@perl ..\tools\checksum.pl $(TARGET)_xtp.bin $(ROMSIZE)
-	@perl ..\tools\checksum.pl $(TARGET)_at.bin $(ROMSIZE)
-	@perl ..\tools\checksum.pl $(TARGET)_xtl.bin $(ROMSIZE_LARGE)
-	@perl ..\tools\checksum.pl $(TARGET)_xtpl.bin $(ROMSIZE_LARGE)
-	@perl ..\tools\checksum.pl $(TARGET)_atl.bin $(ROMSIZE_LARGE)
-	@perl ..\tools\checksum.pl $(TARGET)_386.bin $(ROMSIZE)
+	@perl ..\Tools\checksum.pl $(TARGET)_tiny.bin $(BIOS_SIZE_TINY)
+	@perl ..\Tools\checksum.pl $(TARGET)_xt.bin $(BIOS_SIZE_SMALL)
+	@perl ..\Tools\checksum.pl $(TARGET)_xtp.bin $(BIOS_SIZE_SMALL)
+	@perl ..\Tools\checksum.pl $(TARGET)_at.bin $(BIOS_SIZE_SMALL)
+	@perl ..\Tools\checksum.pl $(TARGET)_xtl.bin $(BIOS_SIZE_LARGE)
+	@perl ..\Tools\checksum.pl $(TARGET)_xtpl.bin $(BIOS_SIZE_LARGE)
+	@perl ..\Tools\checksum.pl $(TARGET)_atl.bin $(BIOS_SIZE_LARGE)
+	@perl ..\Tools\checksum.pl $(TARGET)_386.bin $(BIOS_SIZE_SMALL)
 
 unused:
@@ -241,21 +242,21 @@
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_ALL_FEATURES) $(DEFS_XT) $(DEFS_XT_PLUS) $(DEFS_AT) $(DEFS_XT_LARGE) $(DEFS_XTPLUS_LARGE) $(DEFS_AT_LARGE) $(DEFS_XT_TINY) $(DEFS_386_8K) -o"$(TARGET)_unused.asm" -l"$(TARGET)_unused.lst"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_ALL_FEATURES) $(DEFS_XT) $(DEFS_XT_PLUS) $(DEFS_AT) $(DEFS_XT_LARGE) $(DEFS_XTPLUS_LARGE) $(DEFS_AT_LARGE) $(DEFS_XT_TINY) $(DEFS_386_8K) -o"$(TARGET)_unused.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS
-	@perl ..\tools\unused.pl $(TARGET)_unused.lst $(TARGET)_unused.asm
+	@perl ..\Tools\unused.pl $(TARGET)_unused.lst $(TARGET)_unused.asm
 	@echo "XT Small"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT) -o"$(TARGET)_unused_xt.asm" -l"$(TARGET)_unused_xt.lst"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT) -o"$(TARGET)_unused_xt.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS
-	@perl ..\tools\unused.pl $(TARGET)_unused_xt.lst $(TARGET)_unused_xt.asm
+	@perl ..\Tools\unused.pl $(TARGET)_unused_xt.lst $(TARGET)_unused_xt.asm
 	@echo "XT Large"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_LARGE) -o"$(TARGET)_unused_xtl.asm" -l"$(TARGET)_unused_xtl.lst"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_LARGE) -o"$(TARGET)_unused_xtl.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS
-	@perl ..\tools\unused.pl $(TARGET)_unused_xtl.lst $(TARGET)_unused_xtl.asm
+	@perl ..\Tools\unused.pl $(TARGET)_unused_xtl.lst $(TARGET)_unused_xtl.asm
 	@echo "AT Small"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT) -o"$(TARGET)_unused_at.asm" -l"$(TARGET)_unused_at.lst"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT) -o"$(TARGET)_unused_at.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS
-	@perl ..\tools\unused.pl $(TARGET)_unused_at.lst $(TARGET)_unused_at.asm
+	@perl ..\Tools\unused.pl $(TARGET)_unused_at.lst $(TARGET)_unused_at.asm
 	@echo "AT Large"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT_LARGE) -o"$(TARGET)_unused_atl.asm" -l"$(TARGET)_unused_atl.lst"
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT_LARGE) -o"$(TARGET)_unused_atl.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS
-	@perl ..\tools\unused.pl $(TARGET)_unused_atl.lst $(TARGET)_unused_atl.asm
-
-
+	@perl ..\Tools\unused.pl $(TARGET)_unused_atl.lst $(TARGET)_unused_atl.asm
+
+
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Variables.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Variables.inc	(revision 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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 591)
+++ /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
 
