Index: /trunk/Assembly_Library/Inc/Emulate.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Emulate.inc	(revision 59)
+++ /trunk/Assembly_Library/Inc/Emulate.inc	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Emulation library
 ; Created date	:	21.10.2009
-; Last update	:	9.10.2010
+; Last update	:	25.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Macros for emulating later x86 instruction with older
@@ -157,4 +157,10 @@
 %macro eCMOVE 2
 	jne		SHORT %%Return
+	mov		%1, %2
+%%Return:
+%endmacro
+
+%macro eCMOVB 2
+	jnb		SHORT %%Return
 	mov		%1, %2
 %%Return:
Index: /trunk/Assembly_Library/Inc/Menu.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Menu.inc	(revision 59)
+++ /trunk/Assembly_Library/Inc/Menu.inc	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	13.7.2010
-; Last update	:	23.10.2010
+; Last update	:	22.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Defines for Menu library.
@@ -75,6 +75,5 @@
 	.RefreshInformation							resb	2
 
-	.RestartTimeout								resb	2
-	.SetTimeoutValueFromAX:
+	.StartSelectionTimeoutWithTicksInAX			resb	2
 
 %ifdef INCLUDE_MENU_DIALOGS
@@ -94,5 +93,4 @@
 ; Menu initialization parameters
 struc MENUINIT
-	.wTimeoutTicks					resb	2	; Selection timeout in system timer ticks
 	.wItems							resb	2	; Number of items in menu
 	.wHighlightedItem				resb	2	; Index for highlighted item
@@ -124,4 +122,5 @@
 FLG_MENU_NOHIGHLIGHT				EQU		(1<<1)	; Never highlight items
 FLG_MENU_USER_HANDLES_SCROLLING		EQU		(1<<2)
+FLG_MENU_TIMEOUT_COUNTDOWN			EQU		(1<<3)	; Timeout countdown in progress
 
 
Index: /trunk/Assembly_Library/Src/LibraryTests.asm
===================================================================
--- /trunk/Assembly_Library/Src/LibraryTests.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/LibraryTests.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	27.6.2010
-; Last update	:	12.10.2010
+; Last update	:	22.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Tests for Assembly Library.
@@ -65,5 +65,4 @@
 ALIGN JUMP_ALIGN
 .InitializeMenu:
-	mov		WORD [si+MENUINIT.wTimeoutTicks], 10000 / 55	; 10 seconds
 	mov		WORD [si+MENUINIT.wItems], 51
 	mov		BYTE [si+MENUINIT.bWidth], 40
@@ -72,4 +71,7 @@
 	mov		BYTE [si+MENUINIT.bInfoLines], TEST_MENU_INFO_LINES
 	mov		WORD [si+MENUINIT.wHighlightedItem], 1
+	
+	mov		ax, 10000 / 55	; 10 seconds
+	CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
 	stc
 	ret
@@ -166,5 +168,5 @@
 	CALL_MENU_LIBRARY SetInformationHeightFromAL
 .RefreshMenuWindow:
-	CALL_MENU_LIBRARY RestartTimeout
+	;CALL_MENU_LIBRARY RestartTimeout
 	CALL_MENU_LIBRARY RefreshWindow
 	stc
Index: /trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	6.8.2010
-; Last update	:	18.11.2010
+; Last update	:	22.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Common functions for many dialogs.
@@ -232,5 +232,4 @@
 Dialog_RemoveFromScreenByRedrawingParentMenu:
 	mov		si, [bp+DIALOG.pParentMenu]	; SS:SI points to parent MENU
-	call	.ResetSelectionTimeoutFromParentMenuInSSSI
 	call	.GetParentTitleBorderCoordinatesToDX
 	call	MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
@@ -238,20 +237,4 @@
 	jb		SHORT .RedrawDialogAreaAndWholeParentWindow
 	jmp		SHORT .RedrawWholeParentWindow
-
-;--------------------------------------------------------------------
-; .ResetSelectionTimeoutFromParentMenuInSSSI
-;	Parameters:
-;		SS:SI:	Ptr to parent MENU
-;	Returns:
-;		Nothing
-;	Corrupts:
-;		AX, BX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.ResetSelectionTimeoutFromParentMenuInSSSI:
-	xchg	bp, si
-	call	MenuTime_RestartSelectionTimeout	; Restart timeout for parent MENU
-	xchg	si, bp
-	ret
 
 ;--------------------------------------------------------------------
Index: /trunk/Assembly_Library/Src/Menu/Menu.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Menu.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/Menu/Menu.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	3.8.2010
-; Last update	:	23.10.2010
+; Last update	:	22.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Menu Library functions for CALL_MENU_LIBRARY macro
@@ -57,6 +57,5 @@
 	at	MENU_LIB.RefreshInformation,			dw	MenuText_RefreshInformation
 
-	at	MENU_LIB.RestartTimeout,				dw	MenuTime_RestartSelectionTimeout
-	;at	MENU_LIB.SetTimeoutValueFromAX,			dw	MenuTime_SetSelectionTimeoutValueFromAX	; Special case in CALL_MENU_LIBRARY
+	at	MENU_LIB.StartSelectionTimeoutWithTicksInAX,	dw	MenuTime_StartSelectionTimeoutWithTicksInAX
 
 %ifdef INCLUDE_MENU_DIALOGS
Index: /trunk/Assembly_Library/Src/Menu/MenuBorders.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuBorders.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/Menu/MenuBorders.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	14.7.2010
-; Last update	:	11.10.2010
+; Last update	:	25.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for drawing menu borders.
@@ -34,6 +34,42 @@
 	call	RefreshInformationBorders
 	call	DrawBottomBorderLine
-	call	DrawBottomShadowLine
-	jmp		MenuTime_DrawWithoutUpdating
+	call	DrawTimeoutCounterOverBottomBorderLine
+	jmp		DrawBottomShadowLine
+
+
+;--------------------------------------------------------------------
+; MenuBorders_RedrawBottomBorderLine
+;	Parameters
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuBorders_RedrawBottomBorderLine:
+	call	MenuBorders_AdjustDisplayContextForDrawingBorders
+	call	MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
+	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
+	call	GetNumberOfMiddleCharactersToDX
+	jmp		DrawBottomBorderLine
+
+
+;--------------------------------------------------------------------
+; MenuBorders_RedrawTimeoutValue
+;	Parameters
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuBorders_RedrawTimeoutValue:
+	call	MenuBorders_AdjustDisplayContextForDrawingBorders
+	call	MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
+	inc		ah		; Increment for shadow border
+	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
+	jmp		DrawTimeoutCounterOverBottomBorderLine
 
 
@@ -174,4 +210,5 @@
 ; DrawSeparationBorderLine
 ; DrawBottomBorderLine
+; DrawTimeoutCounterOverBottomBorderLine
 ; DrawBottomShadowLine
 ; DrawTextBorderLine
@@ -201,8 +238,19 @@
 
 ALIGN JUMP_ALIGN
+DrawTimeoutCounterOverBottomBorderLine:
+	test	BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN
+	jz		SHORT .NoNeedToDrawSinceTimeoutDisabled
+	mov		ax, (-1)<<8	; Decrement row
+	call	MenuLocation_MoveCursorByALcolumnsAndAHrows
+	call	MenuTime_GetTimeoutSecondsLeftToAX
+	call	PrintTimeoutStringWithSecondsInAX
+	jmp		SHORT PrintNewlineToEndBorderLine
+.NoNeedToDrawSinceTimeoutDisabled:
+	ret
+
+ALIGN JUMP_ALIGN
 DrawBottomShadowLine:
-	CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
-	inc		ax			; Increment column
-	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
+	mov		ax, 1		; Increment column
+	call	MenuLocation_MoveCursorByALcolumnsAndAHrows
 	inc		dx			; Increment repeat count...
 	inc		dx			; ...for both corner characters
@@ -333,4 +381,51 @@
 
 
+;--------------------------------------------------------------------
+; PrintTimeoutStringWithSecondsInAX
+;	Parameters
+;		AX:		Seconds to print
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+PrintTimeoutStringWithSecondsInAX:
+	push	bp
+
+	xchg	di, ax
+	mov		bp, sp
+	call	.GetTimeoutAttributeToAXfromSecondsInDI
+	mov		si, .szSelectionTimeout
+	push	ax			; Push attribute
+	push	di			; Push seconds
+	CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
+	pop		bp
+
+	; Draw right border with normal border color
+	mov		al, DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL
+	jmp		MenuBorders_PrintSingleBorderCharacterFromAL
+.szSelectionTimeout:
+	db		DOUBLE_BOTTOM_LEFT_CORNER
+	db		DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL
+	db		"%AAutoselection in %2u s",NULL
+
+;--------------------------------------------------------------------
+; .GetTimeoutAttributeToAXfromSecondsInDI
+;	Parameters
+;		DI:		Seconds to print
+;	Returns:
+;		AX:		Attribute byte for seconds
+;	Corrupts registers:
+;		SI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.GetTimeoutAttributeToAXfromSecondsInDI:
+	mov		si, ATTRIBUTE_CHARS.cNormalTimeout
+	cmp		di, BYTE 3
+	eCMOVB	si, ATTRIBUTE_CHARS.cHurryTimeout
+	jmp		MenuAttribute_GetToAXfromTypeInSI
+
 
 ; Lookup tables for border characters
Index: /trunk/Assembly_Library/Src/Menu/MenuInit.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	13.7.2010
-; Last update	:	12.10.2010
+; Last update	:	22.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for initializing menu system.
@@ -60,5 +60,4 @@
 	CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
 	call	MenuEvent_InitializeMenuinit		; User initialization
-	call	MenuTime_RestartSelectionTimeout
 	call	MenuInit_RefreshMenuWindow
 	jmp		MenuLoop_Enter
Index: /trunk/Assembly_Library/Src/Menu/MenuLocation.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuLocation.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/Menu/MenuLocation.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	14.7.2010
-; Last update	:	11.8.2010
+; Last update	:	25.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for calculation menu window dimensions.
@@ -160,2 +160,23 @@
 	sub		ax, BYTE MENU_HORIZONTAL_BORDER_LINES + MENU_TEXT_COLUMN_OFFSET
 	ret
+
+
+;--------------------------------------------------------------------
+; MenuLocation_MoveCursorByALcolumnsAndAHrows
+;	Parameters
+;		AL:		Number of columns to move
+;		AH:		Numver of rows to move
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuLocation_MoveCursorByALcolumnsAndAHrows:
+	push	ax
+	CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
+	pop		di
+	add		ax, di
+	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
+	ret
Index: /trunk/Assembly_Library/Src/Menu/MenuLoop.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuLoop.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/Menu/MenuLoop.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	22.7.2010
-; Last update	:	18.10.2010
+; Last update	:	25.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Menu loop for waiting keystrokes.
@@ -70,5 +70,8 @@
 ALIGN JUMP_ALIGN
 ProcessKeystrokeFromAX:
-	call	.ProcessMenuSystemKeystroke
+	xchg	cx, ax
+	call	MenuTime_StopSelectionTimeout
+	xchg	ax, cx
+	call	.ProcessMenuSystemKeystrokeFromAX
 	jc		SHORT .Return
 	jmp		MenuEvent_KeyStrokeInAX
@@ -78,5 +81,5 @@
 
 ;--------------------------------------------------------------------
-; .ProcessMenuSystemKeystroke
+; .ProcessMenuSystemKeystrokeFromAX
 ;	Parameters
 ;		AL:		ASCII character
@@ -92,5 +95,5 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-.ProcessMenuSystemKeystroke:
+.ProcessMenuSystemKeystrokeFromAX:
 	cmp		ah, MENU_KEY_ESC
 	je		SHORT .LeaveMenuWithoutSelectingItem
@@ -194,5 +197,4 @@
 .MoveHighlightedItemByAX:
 	call	MenuScrollbars_MoveHighlightedItemByAX
-	call	MenuTime_RestartSelectionTimeout
 	stc
 	ret
Index: /trunk/Assembly_Library/Src/Menu/MenuTime.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuTime.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/Menu/MenuTime.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	25.7.2010
-; Last update	:	4.10.2010
+; Last update	:	25.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Menu timeouts other time related functions.
@@ -10,22 +10,7 @@
 
 ;--------------------------------------------------------------------
-; MenuTime_SetSelectionTimeoutValueFromAX
+; MenuTime_StartSelectionTimeoutWithTicksInAX
 ;	Parameters
-;		AX:		Selection timeout in system timer ticks
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-MenuTime_SetSelectionTimeoutValueFromAX:
-	mov		[bp+MENUINIT.wTimeoutTicks], ax
-	ret
-
-
-;--------------------------------------------------------------------
-; MenuTime_RestartSelectionTimeout
-;	Parameters
+;		AX:		Timeout ticks
 ;		SS:BP:	Ptr to MENU
 ;	Returns:
@@ -35,10 +20,30 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-MenuTime_RestartSelectionTimeout:
+MenuTime_StartSelectionTimeoutWithTicksInAX:
 	push	ds
 	call	PointDSBXtoTimeoutCounter
-	mov		ax, [bp+MENUINIT.wTimeoutTicks]
-	call	TimerTicks_InitializeTimeoutFromAX	; End time to [DS:BX]
+	call	TimerTicks_InitializeTimeoutFromAX
+	or		BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN
 	pop		ds
+	ret
+
+
+;--------------------------------------------------------------------
+; MenuTime_StopSelectionTimeout
+;	Parameters
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuTime_StopSelectionTimeout:
+	test	BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN
+	jz		SHORT .TimeoutAlreadyStopped
+	and		BYTE [bp+MENU.bFlags], ~FLG_MENU_TIMEOUT_COUNTDOWN
+	jmp		MenuBorders_RedrawBottomBorderLine
+ALIGN JUMP_ALIGN
+.TimeoutAlreadyStopped:
 	ret
 
@@ -52,41 +57,25 @@
 ;				Cleared if time left
 ;	Corrupts registers:
-;		AX, BX, CX, DX, SI, DI
+;		AX, BX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 MenuTime_UpdateSelectionTimeout:
+	test	BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN
+	jz		SHORT .ReturnSinceTimeoutDisabled
+
 	push	ds
-
-	call	MenuTime_DrawWithoutUpdating
-	jnc		SHORT .TimeoutDisabled
 	call	PointDSBXtoTimeoutCounter
-	call	TimerTicks_SetCarryIfTimeoutFromDSBX
+	call	TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
+	pop		ds
+	jnc		SHORT .RedrawSinceNoTimeout
+	and		BYTE [bp+MENU.bFlags], ~FLG_MENU_TIMEOUT_COUNTDOWN
+	stc
+	ret
 
 ALIGN JUMP_ALIGN
-.TimeoutDisabled:
-	pop		ds
-	ret
-
-;--------------------------------------------------------------------
-; MenuTime_DrawWithoutUpdating
-;	Parameters
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		CF:		Set if timeout enabled
-;				Cleared if timeout disabled
-;	Corrupts registers:
-;		AX, BX, CX, DX, SI, DI
-;--------------------------------------------------------------------
+.RedrawSinceNoTimeout:
+	call	MenuBorders_RedrawTimeoutValue
+	clc
 ALIGN JUMP_ALIGN
-MenuTime_DrawWithoutUpdating:
-	cmp		WORD [bp+MENUINIT.wTimeoutTicks], BYTE 0
-	je		SHORT .ReturnSinceTimeoutDisabled	; Clear CF
-
-	push	ds
-	call	GetSecondsLeftUntilTimeoutToAXandCounterToDSBX
-	call	DrawTimeoutInAXoverMenuBorders
-	pop		ds
-	stc
-ALIGN JUMP_ALIGN, ret
 .ReturnSinceTimeoutDisabled:
 	ret
@@ -94,21 +83,36 @@
 
 ;--------------------------------------------------------------------
-; GetSecondsLeftUntilTimeoutToAXandCounterToDSBX
+; MenuTime_GetTimeoutSecondsLeftToAX
 ;	Parameters
 ;		SS:BP:	Ptr to MENU
 ;	Returns:
 ;		AX:		Seconds until timeout
-;		DS:BX:	Ptr to timeout counter
 ;	Corrupts registers:
-;		AX, CX, DX
+;		AX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-GetSecondsLeftUntilTimeoutToAXandCounterToDSBX:
+MenuTime_GetTimeoutSecondsLeftToAX:
+	push	ds
+	push	dx
+	push	cx
+	push	bx
+
 	call	PointDSBXtoTimeoutCounter
-	call	TimerTicks_GetElapsedToAXfromDSBX
-	neg		ax			; Negate since DS:BX points to end time
-	MAX_S	ax, 0		; Set to zero if overflow
+	call	TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
+	jc		SHORT .TimeoutHasOccurred
+
 	xchg	dx, ax
-	jmp		TimerTicks_GetSecondsToAXfromTicksInDX
+	call	TimerTicks_GetSecondsToAXfromTicksInDX
+	clc
+	jmp		SHORT .PopRegistersAndReturn
+.TimeoutHasOccurred:
+	xor		ax, ax
+	stc
+.PopRegistersAndReturn:
+	pop		bx
+	pop		cx
+	pop		dx
+	pop		ds
+	ret
 
 
@@ -128,71 +132,2 @@
 	lea		bx, [bp+MENU.wTimeoutCounter]
 	ret
-
-
-;--------------------------------------------------------------------
-; DrawTimeoutInAXoverMenuBorders
-;	Parameters
-;		AX:		Seconds to draw
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, CX, DX, SI, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-DrawTimeoutInAXoverMenuBorders:
-	xchg	cx, ax
-	call	MenuBorders_AdjustDisplayContextForDrawingBorders
-	call	MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
-	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
-	; Fall to .PrintTimeoutStringWithSecondsInDX
-
-;--------------------------------------------------------------------
-; .PrintTimeoutStringWithSecondsInDX
-;	Parameters
-;		CX:		Seconds to print
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, DX, SI, DI
-;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
-.PrintTimeoutStringWithSecondsInDX:
-	push	bp
-
-	mov		bp, sp
-	call	.GetTimeoutAttributeToAXfromSecondsInCX
-	mov		si, .szSelectionTimeout
-	push	ax			; Push attribute
-	push	cx			; Push seconds
-	CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
-	pop		bp
-
-	; Draw right border with normal border color
-	mov		al, DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL
-	jmp		MenuBorders_PrintSingleBorderCharacterFromAL
-.szSelectionTimeout:
-	db		DOUBLE_BOTTOM_LEFT_CORNER
-	db		DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL
-	db		"%AAutoselection in %2u s",NULL
-
-;--------------------------------------------------------------------
-; .GetTimeoutAttributeToAXfromSecondsInCX
-;	Parameters
-;		CX:		Seconds to print
-;	Returns:
-;		AX:		Attribute byte for seconds
-;		CX:		Seconds to print
-;	Corrupts registers:
-;		SI, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.GetTimeoutAttributeToAXfromSecondsInCX:
-	mov		si, ATTRIBUTE_CHARS.cNormalTimeout
-	cmp		cx, BYTE 3
-	ja		SHORT .GetAttributeToAX
-	add		si, BYTE ATTRIBUTE_CHARS.cHurryTimeout - ATTRIBUTE_CHARS.cNormalTimeout
-ALIGN JUMP_ALIGN
-.GetAttributeToAX:
-	jmp		MenuAttribute_GetToAXfromTypeInSI
Index: /trunk/Assembly_Library/Src/Time/TimerTicks.asm
===================================================================
--- /trunk/Assembly_Library/Src/Time/TimerTicks.asm	(revision 59)
+++ /trunk/Assembly_Library/Src/Time/TimerTicks.asm	(revision 60)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	24.7.2010
-; Last update	:	3.8.2010
+; Last update	:	22.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for system timer related operations.
@@ -72,9 +72,9 @@
 	ret
 
+
 ;--------------------------------------------------------------------
-; Timeout counter can be initialized with TimerTicks_InitializeTimeoutFromAX.
-;
-; TimerTicks_SetCarryIfTimeoutFromDSBX
+; TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
 ;	Parameters:
+;		AX:			Number of ticks left before timeout
 ;		DS:BX:		Ptr to timeout variable WORD
 ;	Returns:
@@ -85,9 +85,11 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-TimerTicks_SetCarryIfTimeoutFromDSBX:
-	push	ax
+TimerTicks_GetTimeoutTicksLeftToAXfromDSBX:
+	push	dx
+	mov		dx, [bx]
 	call	TimerTicks_ReadFromBdaToAX
-	cmp		[bx], ax		; Set CF if timeout WORD is less than time
-	pop		ax
+	xchg	ax, dx
+	sub		ax, dx		; AX = End time - current time
+	pop		dx
 	ret
 
