Index: trunk/Assembly_Library/Inc/Display.inc
===================================================================
--- trunk/Assembly_Library/Inc/Display.inc	(revision 131)
+++ trunk/Assembly_Library/Inc/Display.inc	(revision 133)
@@ -37,5 +37,7 @@
 	.InitializeDisplayContext						resb	2
 
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 	.SetCharacterPointerFromBXAX					resb	2
+%endif
 	.SetCharOutputFunctionFromAXwithAttribFlagInBL	resb	2
 	.SetCharacterOutputParameterFromAX				resb	2
@@ -46,5 +48,7 @@
 	.SynchronizeDisplayContextToHardware			resb	2
 
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 	.GetCharacterPointerToBXAX						resb	2
+%endif
 	.GetSoftwareCoordinatesToAX						resb	2
 	.GetColumnsToALandRowsToAH						resb	2
Index: trunk/Assembly_Library/Src/Display/Display.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/Display.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Display/Display.asm	(revision 133)
@@ -63,5 +63,7 @@
 	at	DISPLAY_LIB.InitializeDisplayContext,						dw	DisplayContext_Initialize
 
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 	at	DISPLAY_LIB.SetCharacterPointerFromBXAX,					dw	DisplayContext_SetCharacterPointerFromBXAX
+%endif
 	at	DISPLAY_LIB.SetCharOutputFunctionFromAXwithAttribFlagInBL,	dw	DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
 	at	DISPLAY_LIB.SetCharacterOutputParameterFromAX,				dw	DisplayContext_SetCharacterOutputParameterFromAX
@@ -72,5 +74,7 @@
 	at	DISPLAY_LIB.SynchronizeDisplayContextToHardware,			dw	DisplayContext_SynchronizeToHardware
 
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 	at	DISPLAY_LIB.GetCharacterPointerToBXAX,						dw	DisplayContext_GetCharacterPointerToBXAX
+%endif
 	at	DISPLAY_LIB.GetSoftwareCoordinatesToAX,						dw	DisplayCursor_GetSoftwareCoordinatesToAX
 	at	DISPLAY_LIB.GetColumnsToALandRowsToAH,						dw	DisplayPage_GetColumnsToALandRowsToAH
Index: trunk/Assembly_Library/Src/Display/DisplayContext.asm
===================================================================
--- trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 133)
@@ -148,4 +148,5 @@
 ;		AX, DI
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 ALIGN JUMP_ALIGN
 DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX:
@@ -165,4 +166,5 @@
 	pop		ds
 	ret
+%endif
 
 
@@ -177,4 +179,5 @@
 ;		AX
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 ALIGN JUMP_ALIGN
 DisplayContext_SetCharacterPointerFromBXAX:
@@ -184,4 +187,5 @@
 	mov		es, bx
 	ret
+%endif
 
 
@@ -195,4 +199,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 ALIGN JUMP_ALIGN
 DisplayContext_GetCharacterPointerToBXAX:
@@ -200,4 +205,5 @@
 	mov		bx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
 	ret
+%endif
 
 
@@ -261,9 +267,11 @@
 ;	Corrupts registers:
 ;		Nothing
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS	; This appears to be completely unused
 ALIGN JUMP_ALIGN
 DisplayContext_GetCharacterOutputParameterToDX:
 	mov		dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
 	ret
+%endif
 
 
@@ -277,5 +285,5 @@
 ;	Corrupts registers:
 ;		Nothing
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 DisplayContext_GetCharacterOffsetToAXfromByteOffsetInAX:
@@ -294,5 +302,5 @@
 ;	Corrupts registers:
 ;		Nothing
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 DisplayContext_GetByteOffsetToAXfromCharacterOffsetInAX:
Index: trunk/Assembly_Library/Src/File/Drive.asm
===================================================================
--- trunk/Assembly_Library/Src/File/Drive.asm	(revision 131)
+++ trunk/Assembly_Library/Src/File/Drive.asm	(revision 133)
@@ -1,7 +1,3 @@
-; File name		:	Drive.asm
 ; Project name	:	Assembly Library
-; Created date	:	1.9.2010
-; Last update	:	3.9.2010
-; Author		:	Tomi Tilli
 ; Description	:	Functions for accessing drives.
 
@@ -52,5 +48,5 @@
 	xor		bx, bx
 	xor		ax, ax				; Temporary use BX:AX for flags
-	xor		dx, dx				; Start from drive 0
+	cwd							; Start from drive 0
 	call	.CheckDriveValidityUntilCXisZero
 	mov		dx, bx				; Flags now in DX:AX
@@ -163,6 +159,6 @@
 Drive_GetDefaultToAL:
 	mov		ah, GET_CURRENT_DEFAULT_DRIVE
-	int		DOS_INTERRUPT_21h
-	ret
+	SKIP2B	f	; cmp ax, <next instruction>
+	; Fall to Drive_SetDefaultFromDL
 
 
@@ -176,8 +172,6 @@
 ;		AH
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 Drive_SetDefaultFromDL:
 	mov		ah, SELECT_DEFAULT_DRIVE
 	int		DOS_INTERRUPT_21h
 	ret
-	
Index: trunk/Assembly_Library/Src/File/FileIO.asm
===================================================================
--- trunk/Assembly_Library/Src/File/FileIO.asm	(revision 131)
+++ trunk/Assembly_Library/Src/File/FileIO.asm	(revision 133)
@@ -25,22 +25,4 @@
 	xchg	si, dx
 	mov		bx, ax		; Copy file handle to BX
-	ret
-
-
-;--------------------------------------------------------------------
-; FileIO_CloseUsingHandleFromBX
-;	Parameters:
-;		BX:		File handle
-;	Returns:
-;		AX:		DOS error code if CF set
-;		CF:		Clear if file closed successfully
-;				Set if error
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-FileIO_CloseUsingHandleFromBX:
-	mov		ah, CLOSE_FILE
-	int		DOS_INTERRUPT_21h
 	ret
 
@@ -70,5 +52,5 @@
 ; File position is updated so next read will start where
 ; previous read stopped.
-; 
+;
 ; FileIO_ReadCXbytesToDSSIusingHandleFromBX
 ;	Parameters:
@@ -117,5 +99,5 @@
 ; File position is updated so next write will start where
 ; previous write stopped.
-; 
+;
 ; FileIO_WriteCXbytesFromDSSIusingHandleFromBX:
 ;	Parameters:
@@ -249,4 +231,22 @@
 
 ;--------------------------------------------------------------------
+; FileIO_CloseUsingHandleFromBX
+;	Parameters:
+;		BX:		File handle
+;	Returns:
+;		AX:		DOS error code if CF set
+;		CF:		Clear if file closed successfully
+;				Set if error
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+FileIO_CloseUsingHandleFromBX:
+	mov		ah, CLOSE_FILE
+	SKIP2B	f	; cmp ax, <next instruction>
+	; Fall to FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX
+
+
+;--------------------------------------------------------------------
 ; FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX:
 ;	Parameters:
@@ -262,5 +262,4 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX:
 	mov		ah, SET_CURRENT_FILE_POSITION
Index: trunk/Assembly_Library/Src/Keyboard/Keyboard.asm
===================================================================
--- trunk/Assembly_Library/Src/Keyboard/Keyboard.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Keyboard/Keyboard.asm	(revision 133)
@@ -10,5 +10,5 @@
 ; Reads user inputted word.
 ; Function returns when ENTER or ESC will be pressed.
-; 
+;
 ; Keyboard_ReadUserInputtedWordWhilePrinting
 ;	Parameters
@@ -51,5 +51,5 @@
 ; supported to ignore unwanted characters.
 ; Function returns when ENTER or ESC will be pressed.
-; 
+;
 ; Keyboard_ReadUserInputtedStringToESDIWhilePrinting
 ;	Parameters:
@@ -249,4 +249,5 @@
 ;		AX
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS	; Only used when debugging
 ALIGN JUMP_ALIGN
 Keyboard_RemoveAllKeystrokesFromBuffer:
@@ -254,4 +255,5 @@
 	jnz		SHORT Keyboard_RemoveAllKeystrokesFromBuffer
 	ret
+%endif
 
 
@@ -271,13 +273,13 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-Keyboard_GetKeystrokeToAX:
-	call	Keyboard_GetKeystrokeToAXandLeaveItToBuffer
-	jnz		SHORT Keyboard_GetKeystrokeToAXandWaitIfNecessary
-	ret	
-ALIGN JUMP_ALIGN
 Keyboard_GetKeystrokeToAXandLeaveItToBuffer:
 	mov		ah, CHECK_FOR_KEYSTROKE
 	int		BIOS_KEYBOARD_INTERRUPT_16h
 	ret
+ALIGN JUMP_ALIGN
+Keyboard_GetKeystrokeToAX:
+	call	Keyboard_GetKeystrokeToAXandLeaveItToBuffer
+	jz		SHORT Keyboard_GetKeystrokeToAXReturn
+	; Fall to Keyboard_GetKeystrokeToAXandWaitIfNecessary
 ALIGN JUMP_ALIGN
 Keyboard_GetKeystrokeToAXandWaitIfNecessary:
@@ -285,3 +287,4 @@
 	int		BIOS_KEYBOARD_INTERRUPT_16h
 	test	ax, ax						; Clear ZF
-	ret
+Keyboard_GetKeystrokeToAXReturn:
+	ret
Index: trunk/Assembly_Library/Src/Menu/Dialog/ItemLineSplitter.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/ItemLineSplitter.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Menu/Dialog/ItemLineSplitter.asm	(revision 133)
@@ -1,7 +1,3 @@
-; File name		:	ItemLineSplitter.asm
 ; Project name	:	Assembly Library
-; Created date	:	12.10.2010
-; Last update	:	12.10.2010
-; Author		:	Tomi Tilli
 ; Description	:	Functions for splitting strings to item lines.
 
@@ -130,8 +126,7 @@
 
 	inc		bx					; Increment line
-	xor		cx, cx				; Zero character counter
+	xor		cx, cx				; Zero character counter (and clear CF)
 	mov		si, di				; Start from complete word
 	mov		[bp+ITEM_LINE_SPLITTER.wStartOfLine], di
-	clc
 	ret
 
Index: trunk/Assembly_Library/Src/Menu/MenuEvent.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuEvent.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Menu/MenuEvent.asm	(revision 133)
@@ -21,5 +21,5 @@
 	pop		ds
 	mov		si, bp
-	mov		bx, MENUEVENT.InitializeMenuinitFromDSSI
+	mov		bl, MENUEVENT.InitializeMenuinitFromDSSI
 	jmp		SHORT MenuEvent_SendFromBX
 
@@ -37,5 +37,5 @@
 ALIGN JUMP_ALIGN
 MenuEvent_ExitMenu:
-	mov		bx, MENUEVENT.ExitMenu
+	mov		bl, MENUEVENT.ExitMenu
 	jmp		SHORT MenuEvent_SendFromBX
 
@@ -53,5 +53,5 @@
 ALIGN JUMP_ALIGN
 MenuEvent_IdleProcessing:
-	mov		bx, MENUEVENT.IdleProcessing
+	mov		bl, MENUEVENT.IdleProcessing
 	jmp		SHORT MenuEvent_SendFromBX
 
@@ -71,11 +71,9 @@
 ALIGN JUMP_ALIGN
 MenuEvent_RefreshTitle:
-	mov		bx, MENUEVENT.RefreshTitle
-	jmp		SHORT LoadHighlightedItemToCXandSendMessageFromBX
+	mov		bl, MENUEVENT.RefreshTitle
+	SKIP2B	cx	; mov cx, <next instruction>
 
-ALIGN JUMP_ALIGN
 MenuEvent_RefreshInformation:
-	mov		bx, MENUEVENT.RefreshInformation
-LoadHighlightedItemToCXandSendMessageFromBX:
+	mov		bl, MENUEVENT.RefreshInformation
 	mov		cx, [bp+MENUINIT.wHighlightedItem]
 	jmp		SHORT MenuEvent_SendFromBX
@@ -96,5 +94,5 @@
 ALIGN JUMP_ALIGN
 MenuEvent_RefreshItemFromCX:
-	mov		bx, MENUEVENT.RefreshItemFromCX
+	mov		bl, MENUEVENT.RefreshItemFromCX
 	jmp		SHORT MenuEvent_SendFromBX
 
@@ -116,5 +114,5 @@
 	push	dx
 
-	mov		bx, MENUEVENT.ItemHighlightedFromCX
+	mov		bl, MENUEVENT.ItemHighlightedFromCX
 	call	MenuEvent_SendFromBX
 
@@ -139,6 +137,6 @@
 ALIGN JUMP_ALIGN
 MenuEvent_KeyStrokeInAX:
-	mov		bx, MENUEVENT.KeyStrokeInAX
-	jmp		SHORT MenuEvent_SendFromBX
+	mov		bl, MENUEVENT.KeyStrokeInAX
+	SKIP2B	dx	; mov dx, <next instruction>
 
 
@@ -154,8 +152,7 @@
 ;		AX, BX, DX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 MenuEvent_ItemSelectedFromCX:
-	mov		bx, MENUEVENT.ItemSelectedFromCX
-	jmp		SHORT MenuEvent_SendFromBX
+	mov		bl, MENUEVENT.ItemSelectedFromCX
+	; Fall to MenuEvent_SendFromBX
 
 
@@ -163,5 +160,5 @@
 ; MenuEvent_SendFromBX
 ;	Parameters
-;		BX:					Menu event to send
+;		BL:					Menu event to send
 ;		SS:BP:				Ptr to MENU
 ;		Other registers:	Event specific parameters
@@ -180,4 +177,5 @@
 	push	si
 	push	cx
+	xor		bh, bh
 	call	[bp+MENU.fnEventHandler]
 	pop		cx
Index: trunk/Assembly_Library/Src/Menu/MenuInit.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 133)
@@ -57,6 +57,11 @@
 	CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
 	call	MenuEvent_InitializeMenuinit	; User initialization
+%ifndef USE_186
 	call	MenuInit_RefreshMenuWindow
 	jmp		MenuLoop_Enter
+%else
+	push	MenuLoop_Enter
+	; Fall to MenuInit_RefreshMenuWindow
+%endif
 
 
@@ -117,8 +122,10 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 ALIGN JUMP_ALIGN
 MenuInit_GetHighlightedItemToAX:
 	mov		ax, [bp+MENUINIT.wHighlightedItem]
 	ret
+%endif
 
 
@@ -135,4 +142,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 ALIGN JUMP_ALIGN
 MenuInit_SetTitleHeightFromAL:
@@ -149,4 +157,5 @@
 	mov		[bp+MENUINIT.wItems], ax
 	ret
+%endif
 
 
@@ -162,4 +171,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
 ALIGN JUMP_ALIGN
 MenuInit_SetUserDataFromDSSI:
@@ -172,2 +182,3 @@
 	lds		si, [bp+MENU.dwUserData]
 	ret
+%endif
Index: trunk/Assembly_Library/Src/Menu/MenuLoop.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuLoop.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Menu/MenuLoop.asm	(revision 133)
@@ -56,5 +56,5 @@
 ;		SS:BP:	Ptr to MENU
 ;	Returns:
-;		Nothing	
+;		Nothing
 ;	Corrupts registers:
 ;		AX, BX, CX, DX, SI, DI
@@ -92,6 +92,5 @@
 	test	BYTE [bp+MENU.bFlags], FLG_MENU_USER_HANDLES_SCROLLING
 	jz		SHORT MenuLoop_ProcessScrollingKeysFromAX
-	clc		; Clear CF since keystroke not processed
-	ret
+	ret		; Return with CF cleared since keystroke not processed
 
 ALIGN JUMP_ALIGN
Index: trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm	(revision 133)
@@ -59,5 +59,5 @@
 ;	Corrupts registers:
 ;		CX, DX
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 .GetLastThumbLineToAX:
@@ -161,6 +161,6 @@
 .RotateItemInCX:
 	mov		dx, [bp+MENUINIT.wItems]
-	cmp		cx, BYTE 0
-	jl		SHORT .RotateNegativeItemInCX
+	test	cx, cx
+	js		SHORT .RotateNegativeItemInCX
 	cmp		cx, dx
 	jae		SHORT .RotatePositiveItemInCX
@@ -193,6 +193,6 @@
 ALIGN JUMP_ALIGN
 MenuScrollbars_IsItemInCXonVisiblePage:
-	cmp		cx, [bp+MENU.wFirstVisibleItem]
-	jb		SHORT .ItemIsNotVisible
+	cmp		[bp+MENU.wFirstVisibleItem], cx
+	ja		SHORT .ItemIsNotVisible
 
 	call	MenuScrollbars_GetLastVisibleItemOnPageToAX
@@ -200,8 +200,6 @@
 	ja		SHORT .ItemIsNotVisible
 	stc		; Item is visible
-	ret
-ALIGN JUMP_ALIGN
+ALIGN JUMP_ALIGN, ret
 .ItemIsNotVisible:
-	clc
 	ret
 
Index: trunk/Assembly_Library/Src/Menu/MenuText.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuText.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Menu/MenuText.asm	(revision 133)
@@ -155,5 +155,5 @@
 	call	MenuLocation_GetTextCoordinatesToAXforItemInAX
 	mov		dx, MenuCharOut_MenuTeletypeOutput
-	; Fall to AdjustDisplayContextForDrawingTextsAtCoordinatesInAXwithAttributeTypeInSI
+	; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
 
 ;--------------------------------------------------------------------
Index: trunk/Assembly_Library/Src/Menu/MenuTime.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuTime.asm	(revision 131)
+++ trunk/Assembly_Library/Src/Menu/MenuTime.asm	(revision 133)
@@ -97,8 +97,8 @@
 	xchg	dx, ax
 	call	TimerTicks_GetSecondsToAXfromTicksInDX
-	jmp		SHORT .PopRegistersAndReturn
+	SKIP2B	f	; cmp ax, <next instruction>
 .TimeoutHasOccurredSoMakeSureTicksAreNotBelowZero:
 	xor		ax, ax
-.PopRegistersAndReturn:
+
 	pop		bx
 	pop		cx
