Index: trunk/Assembly_Library/Inc/Emulate.inc
===================================================================
--- trunk/Assembly_Library/Inc/Emulate.inc	(revision 489)
+++ trunk/Assembly_Library/Inc/Emulate.inc	(revision 491)
@@ -57,4 +57,79 @@
 
 ;==========================================================================
+
+;--------------------------------------------------------------------
+; The undocumented instruction SALC (Set AL According to CF).
+; Available on all Intel processors and truly compatible clones.
+; Does not work on the NEC V20/V30 or Sony CXQ70108 processors.
+;
+; eSALC
+;	Parameters:
+;		Nothing
+;	Returns:
+;		AL:		FFh if CF=1
+;				00h if CF=0
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+%macro eSALC 0
+	db		0D6h
+%endmacro
+
+
+;--------------------------------------------------------------------
+; The AAD instruction (ASCII Adjust before Division).
+; 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).
+;
+; eAAD
+;	Parameters:
+;		%1:		Any 8 bit number (0...255)
+;	Returns:
+;		AL:		AH * %1 + AL
+;		AH:		0
+;		Flags:	Set according to result
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+%macro eAAD 1
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+	%if %1 > 255
+		%error Invalid parameter passed to eAAD (%1 > 255)
+	%else
+		db		0D5h, %1
+	%endif
+%endif
+%endmacro
+
+
+;--------------------------------------------------------------------
+; 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
+;	Parameters:
+;		%1:		Any 8 bit number except 0 (1...255)
+;	Returns:
+;		AL:		AL MOD %1
+;		AH:		AL / %1
+;		Flags:	Set according to result
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+%macro eAAM 1
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+	%if %1 > 255
+		%error Invalid parameter passed to eAAM (%1 > 255)
+	%elif %1 = 0
+		%error Invalid parameter passed to eAAM (%1 = 0). This would cause a divide-by-zero exception!
+	%else
+		db		0D4h, %1
+	%endif
+%endif
+%endmacro
+
 
 ;--------------------------------------------------------------------
Index: trunk/Assembly_Library/Src/Display/CgaSnow.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/CgaSnow.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Display/CgaSnow.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Section containing code
@@ -94,5 +94,5 @@
 	ret
 
-%ifdef INCLUDE_MENU_LIBRARY
+
 ;--------------------------------------------------------------------
 ; CgaSnow_RepMovsb
@@ -107,4 +107,14 @@
 ;		AX, CX, DX
 ;--------------------------------------------------------------------
+%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifdef MODULE_STRINGS_COMPRESSED
+		%define EXCLUDE
+	%endif
+	%ifdef MODULE_BOOT_MENU
+		%undef EXCLUDE
+	%endif
+%endif
+
+%ifndef EXCLUDE
 ALIGN DISPLAY_JUMP_ALIGN
 CgaSnow_RepMovsb:
@@ -123,4 +133,6 @@
 	ret
 %endif
+%undef EXCLUDE
+
 
 ;--------------------------------------------------------------------
Index: trunk/Assembly_Library/Src/Display/DisplayContext.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Section containing code
@@ -102,8 +102,7 @@
 
 
-%ifdef INCLUDE_MENU_LIBRARY
-
 ;--------------------------------------------------------------------
 ; DisplayContext_Push
+; DisplayContext_Pop
 ;	Parameters:
 ;		Nothing
@@ -113,4 +112,11 @@
 ;		AX, DI
 ;--------------------------------------------------------------------
+%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef MODULE_BOOT_MENU
+		%define EXCLUDE
+	%endif
+%endif
+
+%ifndef EXCLUDE
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_Push:
@@ -126,17 +132,9 @@
 	%endrep
 %endif
-		
+
 	mov		ds, di					; Restore DS
 	jmp		ax
 
-;--------------------------------------------------------------------
-; DisplayContext_Pop
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, DI
-;--------------------------------------------------------------------
+
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_Pop:
@@ -145,5 +143,5 @@
 	pop		ax						; Pop return address
 
-%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS		
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 	%assign i DISPLAY_CONTEXT_size-2
 	%rep DISPLAY_CONTEXT_size / 2
@@ -152,5 +150,5 @@
 	%endrep
 %endif
-		
+
 	push	ax						; Push return address
 	push	dx
@@ -159,5 +157,7 @@
 	mov		ds, di					; Restore DS
 	ret
-%endif
+%endif ; EXCLUDE
+%undef EXCLUDE
+
 
 ;--------------------------------------------------------------------
@@ -189,6 +189,5 @@
 	pop		ds
 	ret
-
-%endif  ; INCLUDE_MENU_LIBRARY
+%endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 
 
@@ -231,6 +230,10 @@
 %endif
 
-%ifdef INCLUDE_MENU_LIBRARY
-
+
+%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef MODULE_BOOT_MENU
+		%define EXCLUDE
+	%endif
+%endif
 ;--------------------------------------------------------------------
 ; DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
@@ -244,4 +247,5 @@
 ;		BL
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE	; 1 of 3
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL:
@@ -251,4 +255,5 @@
 	mov		[VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], ax
 	ret
+%endif
 
 
@@ -263,8 +268,10 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE	; 2 of 3
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_SetCharacterAttributeFromAL:
 	mov		[VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], al
 	ret
+%endif
 
 
@@ -279,11 +286,14 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE	; 3 of 3
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_SetCharacterOutputParameterFromAX:
 	mov		[VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam], ax
 	ret
-		
-%endif	 ; INCLUDE_MENU_LIBRARY
-		
+%endif
+
+%undef EXCLUDE
+
+
 ;--------------------------------------------------------------------
 ; DisplayContext_GetCharacterOutputParameterToDX
@@ -295,5 +305,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG	; This is currently unused (dead code)
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayContext_GetCharacterOutputParameterToDX:
@@ -322,5 +332,5 @@
 %endif
 
-		
+
 ;--------------------------------------------------------------------
 ; DisplayContext_GetByteOffsetToAXfromCharacterOffsetInAX
Index: trunk/Assembly_Library/Src/Display/DisplayCursor.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/DisplayCursor.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Display/DisplayCursor.asm	(revision 491)
@@ -37,5 +37,5 @@
 	ret
 
-%ifdef INCLUDE_MENU_LIBRARY
+
 ;--------------------------------------------------------------------
 ; DisplayCursor_SetShapeFromAX
@@ -48,4 +48,11 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef MODULE_BOOT_MENU
+		%define EXCLUDE
+	%endif
+%endif
+
+%ifndef EXCLUDE
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayCursor_SetShapeFromAX:
@@ -53,5 +60,7 @@
 	ret
 %endif
-		
+%undef EXCLUDE
+
+
 ;--------------------------------------------------------------------
 ; DisplayCursor_SetCoordinatesFromAX
Index: trunk/Assembly_Library/Src/Display/DisplayPrint.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/DisplayPrint.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Display/DisplayPrint.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Section containing code
@@ -109,5 +109,4 @@
 
 
-%ifndef MODULE_STRINGS_COMPRESSED
 ;--------------------------------------------------------------------
 ; DisplayPrint_WordFromAXWithBaseInBX
@@ -122,4 +121,5 @@
 ;		AX, DX
 ;--------------------------------------------------------------------
+%ifndef MODULE_STRINGS_COMPRESSED
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayPrint_WordFromAXWithBaseInBX:
@@ -152,4 +152,6 @@
 g_rgcDigitToCharacter:	db	"0123456789ABCDEF"
 
+%endif ; MODULE_STRINGS_COMPRESSED
+
 ;--------------------------------------------------------------------
 ; DisplayPrint_QWordFromSSBPwithBaseInBX
@@ -164,5 +166,5 @@
 ;		AX, DX, [SS:BP]
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDECFG	; Not used in XTIDECFG
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayPrint_QWordFromSSBPwithBaseInBX:
@@ -181,7 +183,5 @@
 	mov		cx, bx				; Character count to CX
 	jmp		SHORT PrintAllPushedDigits
-%endif	; EXCLUDE_FROM_XTIDECFG
-
-%endif	; MODULE_STRINGS_COMPRESSED
+%endif
 
 
@@ -220,5 +220,4 @@
 
 
-%ifdef INCLUDE_MENU_LIBRARY
 ;--------------------------------------------------------------------
 ; DisplayPrint_ClearScreenWithCharInALandAttributeInAH
@@ -233,4 +232,5 @@
 ;		AX, DX
 ;--------------------------------------------------------------------
+%ifdef INCLUDE_MENU_LIBRARY
 ALIGN DISPLAY_JUMP_ALIGN
 DisplayPrint_ClearScreenWithCharInALandAttributeInAH:
@@ -251,5 +251,6 @@
 	ret
 %endif
-		
+
+
 ;--------------------------------------------------------------------
 ; DisplayPrint_ClearAreaWithHeightInAHandWidthInAL
Index: trunk/Assembly_Library/Src/File/FileIO.asm
===================================================================
--- trunk/Assembly_Library/Src/File/FileIO.asm	(revision 489)
+++ trunk/Assembly_Library/Src/File/FileIO.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,12 +10,12 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ;
-		
+
 
 ; Section containing code
@@ -37,8 +37,7 @@
 ALIGN JUMP_ALIGN
 FileIO_CreateWithPathInDSSIandAttributesInCX:
-	xchg	dx, si		; Path now in DS:DX
 	mov		ah, CREATE_OR_TRUNCATE_FILE
-	jmp		SHORT CreateOrOpenFile
-
+	SKIP2B	bx
+	; Fall to FileIO_OpenWithPathInDSSIandFileAccessInAL
 
 ;--------------------------------------------------------------------
@@ -55,9 +54,7 @@
 ;		AX, BX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 FileIO_OpenWithPathInDSSIandFileAccessInAL:
+	mov		ah, OPEN_EXISTING_FILE
 	xchg	dx, si		; Path now in DS:DX
-	mov		ah, OPEN_EXISTING_FILE
-CreateOrOpenFile:
 	int		DOS_INTERRUPT_21h
 	xchg	si, dx
@@ -87,29 +84,4 @@
 	ret
 
-;--------------------------------------------------------------------
-; File position is updated so next read will start where
-; previous read stopped.
-;
-; FileIO_ReadCXbytesToDSSIusingHandleFromBX
-;	Parameters:
-;		BX:		File handle
-;		CX:		Number of bytes to read
-;		DS:SI:	Ptr to destination buffer
-;	Returns:
-;		AX:		Number of bytes actually read if successful (0 if at EOF before call)
-;				DOS error code if CF set
-;		CF:		Clear if successful
-;				Set if error
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-FileIO_ReadCXbytesToDSSIusingHandleFromBX:
-	xchg	dx, si				; DS:DX now points to destination buffer
-	mov		ah, READ_FROM_FILE_OR_DEVICE
-	int		DOS_INTERRUPT_21h
-	xchg	si, dx
-	ret
-
 
 ;--------------------------------------------------------------------
@@ -134,9 +106,33 @@
 	ret
 
+
+;--------------------------------------------------------------------
+; File position is updated so next read will start where
+; previous read stopped.
+;
+; FileIO_ReadCXbytesToDSSIusingHandleFromBX
+;	Parameters:
+;		BX:		File handle
+;		CX:		Number of bytes to read
+;		DS:SI:	Ptr to destination buffer
+;	Returns:
+;		AX:		Number of bytes actually read if successful (0 if at EOF before call)
+;				DOS error code if CF set
+;		CF:		Clear if successful
+;				Set if error
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+FileIO_ReadCXbytesToDSSIusingHandleFromBX:
+	mov		ah, READ_FROM_FILE_OR_DEVICE
+	SKIP2B	f
+	; Fall to FileIO_WriteCXbytesFromDSSIusingHandleFromBX
+
 ;--------------------------------------------------------------------
 ; File position is updated so next write will start where
 ; previous write stopped.
 ;
-; FileIO_WriteCXbytesFromDSSIusingHandleFromBX:
+; FileIO_WriteCXbytesFromDSSIusingHandleFromBX
 ;	Parameters:
 ;		BX:		File handle
@@ -151,8 +147,7 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 FileIO_WriteCXbytesFromDSSIusingHandleFromBX:
-	xchg	dx, si				; DS:DX now points to source buffer
 	mov		ah, WRITE_TO_FILE_OR_DEVICE
+	xchg	dx, si				; DS:DX now points to buffer
 	int		DOS_INTERRUPT_21h
 	xchg	si, dx
@@ -232,5 +227,5 @@
 
 ;--------------------------------------------------------------------
-; FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition:
+; FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition
 ;	Parameters:
 ;		BX:		File handle
@@ -287,5 +282,5 @@
 
 ;--------------------------------------------------------------------
-; FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX:
+; FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX
 ;	Parameters:
 ;		AL:		SEEK_FROM.(origin)
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,12 +10,12 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ;
-		
+
 
 ; Section containing code
@@ -99,5 +99,5 @@
 	mov		[si+PROGRESS_DIALOG_IO.wStartTimeTicks], ax
 
-	; 0 = 65536 but it needs to be adjusted to 65535 prevent division by zero
+	; 0 = 65536 but it needs to be adjusted to 65535 to prevent division by zero
 	cmp		WORD [si+PROGRESS_DIALOG_IO.wMaxProgressValue], BYTE 0
 	jne		SHORT CalculateProgressNeededBeforeUpdatingCharacter
@@ -288,5 +288,5 @@
 	div		cx			; AX = Estimated ticks left
 	xchg	dx, ax
-	SKIP2B	f	; cmp ax, <next instruction>
+	SKIP2B	ax
 .PreventDivisionByZero:
 	xor		dx, dx
@@ -309,5 +309,5 @@
 	mov		bp, sp
 	mov		si, g_szTimeFormat
-	call	TimerTicks_GetMinutesToAXfromTicksInDX
+	call	TimerTicks_GetMinutesToAXandRemainderTicksToDXfromTicksInDX
 	push	ax
 	call	TimerTicks_GetSecondsToAXfromTicksInDX
Index: trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,12 +10,12 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ;
-		
+
 
 ; Section containing code
@@ -79,5 +79,5 @@
 ;		AX:		Item line for last thumb character
 ;	Corrupts registers:
-;		CX, DX
+;		DX
 ;--------------------------------------------------------------------
 ALIGN MENU_JUMP_ALIGN
@@ -95,5 +95,5 @@
 ;		AX:		Item line for first thumb character
 ;	Corrupts registers:
-;		CX, DX
+;		DX
 ;--------------------------------------------------------------------
 ALIGN MENU_JUMP_ALIGN
Index: trunk/Assembly_Library/Src/Menu/MenuTime.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuTime.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Menu/MenuTime.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,12 +10,12 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ;
-		
+
 
 ; Section containing code
@@ -101,5 +101,5 @@
 ;		AX:		Seconds until timeout
 ;	Corrupts registers:
-;		AX
+;		Nothing
 ;--------------------------------------------------------------------
 ALIGN MENU_JUMP_ALIGN
@@ -116,5 +116,5 @@
 	xchg	dx, ax
 	call	TimerTicks_GetSecondsToAXfromTicksInDX
-	SKIP2B	f	; cmp ax, <next instruction>
+	SKIP2B	dx
 .TimeoutHasOccurredSoMakeSureTicksAreNotBelowZero:
 	xor		ax, ax
Index: trunk/Assembly_Library/Src/Serial/SerialServer.asm
===================================================================
--- trunk/Assembly_Library/Src/Serial/SerialServer.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Serial/SerialServer.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,12 +10,12 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ;
-		
+
 
 %include "SerialServer.inc"
@@ -75,5 +75,5 @@
 
 		mov		al,83h
-		add		dl,Serial_UART_lineControl
+		add		dl, Serial_UART_lineControl	; Clears CF
 		out		dx,al
 
@@ -82,5 +82,9 @@
 		out		dx,al
 
+%ifdef USE_UNDOC_INTEL
+		eSALC	; Clear AL using CF
+%else
 		xor		ax,ax
+%endif
 		inc		dx				; divisor high
 		push	dx
@@ -103,5 +107,9 @@
 
 		pop		dx				; base, interrupts disabled
+%ifdef USE_UNDOC_INTEL
+		eSALC	; Clear AL using CF
+%else
 		xor		ax,ax
+%endif
 		out		dx,al
 
Index: trunk/Assembly_Library/Src/String/Char.asm
===================================================================
--- trunk/Assembly_Library/Src/String/Char.asm	(revision 489)
+++ trunk/Assembly_Library/Src/String/Char.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Section containing code
@@ -29,5 +29,5 @@
 ;		%3:		Last accepted value in range
 ;	Returns:
-;		CF:		Set if character is range
+;		CF:		Set if character in range
 ;				(Jumps to Char_CharIsNotValid if before range)
 ;	Corrupts registers:
@@ -51,8 +51,18 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef MODULE_HOTKEYS
+		%define EXCLUDE
+	%endif
+%endif
+
+%ifndef EXCLUDE
 ALIGN STRING_JUMP_ALIGN
 Char_IsLowerCaseLetterInAL:
 	IS_BETWEEN_IMMEDIATES al, 'a', 'z'
 	ret
+%endif
+%undef EXCLUDE
+
 
 ;--------------------------------------------------------------------
@@ -72,4 +82,5 @@
 	ret
 %endif
+
 
 ;--------------------------------------------------------------------
@@ -94,4 +105,5 @@
 %endif
 
+
 ;--------------------------------------------------------------------
 ; Char_IsDecimalDigitInAL
@@ -110,4 +122,5 @@
 	ret
 %endif
+
 
 ;--------------------------------------------------------------------
@@ -141,4 +154,5 @@
 %endif
 
+
 ;--------------------------------------------------------------------
 ; Char_CharIsValid
@@ -159,8 +173,21 @@
 %endif
 
+
+%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef MODULE_HOTKEYS
+		%define EXCLUDE
+	%endif
+	%ifndef MODULE_STRINGS_COMPRESSED
+		%undef EXCLUDE
+	%endif
+%endif
+
+%ifndef EXCLUDE
 ALIGN STRING_JUMP_ALIGN
 Char_CharIsNotValid:
 	clc
 	ret
+%endif
+%undef EXCLUDE
 
 
@@ -181,5 +208,5 @@
 %endif
 
-				
+
 ;--------------------------------------------------------------------
 ; Char_ALtoUpperCaseLetter
@@ -191,5 +218,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS		
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 ALIGN STRING_JUMP_ALIGN
 Char_ALtoUpperCaseLetter:
@@ -200,5 +227,5 @@
 %endif
 
-		
+
 ;--------------------------------------------------------------------
 ; Char_ChangeCaseInAL
@@ -210,8 +237,11 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 Char_ChangeCaseInAL:
 	xor		al, 32
 .Return:
 	ret
+%endif
+
 
 ;--------------------------------------------------------------------
Index: trunk/Assembly_Library/Src/Time/TimerTicks.asm
===================================================================
--- trunk/Assembly_Library/Src/Time/TimerTicks.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Time/TimerTicks.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,14 +10,23 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
-
-; System timer ticks 18.2 times per second = 54.9 ms / tick
-TICKS_PER_HOUR			EQU		65520
+;
+
+; With a PIT input clock of 1193181.6666... Hz and a maximum
+; 16 bit divisor of 65536 (if PIT programmed with 0) we get:
+;
+; Clock / Divisor = ~18.2065 ticks per second
+; Clock * SecondsPerMinute / Divisor = ~1092 ticks per minute
+; Clock * SecondsPerHour / Divisor = ~65543 ticks per hour
+;
+; Since 65543 can't fit in a 16 bit register we use the
+; maximum possible instead and disregard the last ~8 ticks.
+
+TICKS_PER_HOUR			EQU		65535
 TICKS_PER_MINUTE		EQU		1092
 TICKS_PER_SECOND		EQU		18
@@ -28,7 +37,7 @@
 
 ;--------------------------------------------------------------------
-; TimerTicks_GetHoursToAXfromTicksInDXAX
-; TimerTicks_GetMinutesToAXfromTicksInDX
-; TimerTicks_GetSecondsToAXfromTicksInDX
+; TimerTicks_GetHoursToAXandRemainderTicksToDXfromTicksInDXAX
+; TimerTicks_GetMinutesToAXandRemainderTicksToDXfromTicksInDX
+; TimerTicks_GetSecondsToAXandRemainderTicksToDXfromTicksInDX
 ;	Parameters
 ;		DX(:AX):	Timer ticks to convert
@@ -42,5 +51,5 @@
 %ifndef EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
-TimerTicks_GetHoursToAXfromTicksInDXAX:
+TimerTicks_GetHoursToAXandRemainderTicksToDXfromTicksInDXAX:
 	mov		cx, TICKS_PER_HOUR
 	div		cx		; Divide DX:AX by CX, Hours to AX, remainder ticks to DX
@@ -49,5 +58,5 @@
 
 ALIGN JUMP_ALIGN
-TimerTicks_GetMinutesToAXfromTicksInDX:
+TimerTicks_GetMinutesToAXandRemainderTicksToDXfromTicksInDX:
 	xor		ax, ax
 	xchg	ax, dx	; Ticks now in DX:AX
@@ -57,7 +66,9 @@
 %endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 
-%ifdef INCLUDE_MENU_LIBRARY
-ALIGN JUMP_ALIGN
-TimerTicks_GetSecondsToAXfromTicksInDX:
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
+ALIGN JUMP_ALIGN
+TimerTicks_GetSecondsToAXandRemainderTicksToDXfromTicksInDX:
+	; This procedure can handle at most 4607 ticks in DX (almost 256 seconds)
+	; More than 4607 ticks will generate a divide overflow exception!
 	xchg	ax, dx	; Ticks now in AX
 	mov		cl, TICKS_PER_SECOND
@@ -68,4 +79,29 @@
 %endif
 
+
+%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef MODULE_BOOT_MENU
+		%define EXCLUDE
+	%endif
+%endif
+;--------------------------------------------------------------------
+; TimerTicks_GetSecondsToAXfromTicksInDX
+;	Parameters
+;		DX:			Timer ticks to convert
+;	Returns:
+;		AX:			Seconds
+;	Corrupts registers:
+;		DX
+;--------------------------------------------------------------------
+%ifndef EXCLUDE	; 1 of 3
+ALIGN JUMP_ALIGN
+TimerTicks_GetSecondsToAXfromTicksInDX:
+	mov		ax, 3600	; Approximately 65536 / (Clock / Divisor)
+	mul		dx
+	xchg	dx, ax
+	ret
+%endif
+
+
 ;--------------------------------------------------------------------
 ; First tick might take 0...54.9 ms and remaining ticks
@@ -82,5 +118,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-%ifdef INCLUDE_MENU_LIBRARY		
+%ifndef EXCLUDE	; 2 of 3
 ALIGN JUMP_ALIGN
 TimerTicks_InitializeTimeoutFromAX:
@@ -90,4 +126,5 @@
 	ret
 %endif
+
 
 ;--------------------------------------------------------------------
@@ -102,5 +139,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifdef INCLUDE_MENU_LIBRARY		
+%ifndef EXCLUDE	; 3 of 3
 ALIGN JUMP_ALIGN
 TimerTicks_GetTimeoutTicksLeftToAXfromDSBX:
@@ -114,4 +151,7 @@
 %endif
 
+%undef EXCLUDE
+
+
 ;--------------------------------------------------------------------
 ; TimerTicks_GetElapsedToAXandResetDSBX
@@ -134,4 +174,5 @@
 %endif
 
+
 ;--------------------------------------------------------------------
 ; TimerTicks_GetElapsedToAXfromDSBX
@@ -161,4 +202,11 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+	%ifndef MODULE_BOOT_MENU OR MODULE_HOTKEYS
+		%define EXCLUDE
+	%endif
+%endif
+
+%ifndef EXCLUDE
 ALIGN JUMP_ALIGN
 TimerTicks_ReadFromBdaToAX:
@@ -170,2 +218,4 @@
 	pop		ds
 	ret
+%endif
+%undef EXCLUDE
Index: trunk/Assembly_Library/Src/Util/Registers.asm
===================================================================
--- trunk/Assembly_Library/Src/Util/Registers.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Util/Registers.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,12 +10,12 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ;
-		
+
 ; Section containing code
 SECTION .text
@@ -52,6 +52,6 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifdef INCLUDE_MENU_LIBRARY
 ALIGN JUMP_ALIGN
-%ifdef INCLUDE_MENU_LIBRARY		
 Registers_CopySSBPtoESDI:
 	COPY_SSBP_TO_ESDI
Index: trunk/Assembly_Library/Src/Util/Size.asm
===================================================================
--- trunk/Assembly_Library/Src/Util/Size.asm	(revision 489)
+++ trunk/Assembly_Library/Src/Util/Size.asm	(revision 491)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 %ifdef INCLUDE_MENU_LIBRARY
@@ -68,7 +68,13 @@
 	; Convert remainder to tenths
 	xchg	bx, ax						; Store AX
-	mov		ax, 10
-	mul		cx							; DX:AX = remainder * 10
-	eSHR_IM	ax, 10						; Divide AX by 1024
+	mov		ax, 5
+	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
@@ -124,5 +130,5 @@
 ;--------------------------------------------------------------------
 ALIGN UTIL_SIZE_JUMP_ALIGN
-Size_ConvertSectorCountInBXDXAXtoKiB:               ; unused entrypoint ok
+Size_ConvertSectorCountInBXDXAXtoKiB:	; unused entrypoint ok
 Size_DivideBXDXAXbyTwo:
 	shr		bx, 1					; Divide sector count by 2...
