Index: trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 598)
+++ trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 599)
@@ -40,4 +40,5 @@
 
 struc HOTKEYVARS
+	.fpPrevTimerHandler	resb	4		; Previous 1Ch timer hander
 	.wTimeWhenDisplayed	resb	2		; System time (ticks) when Hotkey bar was first displayed
 	.wFddAndHddLetters:
@@ -57,4 +58,5 @@
 ; Bit defines for HOTKEYVARS.bFlags
 FLG_HOTKEY_HD_FIRST			EQU		(1<<0)	; First try to boot from HDD, then FDD
+FLG_HOTKEY_UPDATING			EQU		(1<<1)	; Hotkeybar update in progress
 
 %endif ; MODULE_HOTKEYS
Index: trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc	(revision 598)
+++ trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc	(revision 599)
@@ -23,4 +23,5 @@
 MIN_TIME_TO_DISPLAY_HOTKEY_BAR			EQU	(4000/55)	; 4000 ms
 
+ESC_SCANCODE							EQU	1	; ESC key		
 FIRST_FUNCTION_KEY_SCANCODE				EQU	3Bh	; F1 key
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 598)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 599)
@@ -95,5 +95,5 @@
 	; Last hard drive might have scrolled Hotkey Bar out of screen.
 	; We want to display it during wait.
-	call	HotkeyBar_UpdateDuringDriveDetection
+	;call	HotkeyBar_UpdateDuringDriveDetection
 
 .WaitUntilTimeToCloseHotkeyBar:
@@ -102,4 +102,12 @@
 	cmp		ax, MIN_TIME_TO_DISPLAY_HOTKEY_BAR
 	jb		SHORT .WaitUntilTimeToCloseHotkeyBar
+
+	; Restore system timer tick handler since hotkeys are no longer needed
+	cli
+	mov		ax, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler]
+	mov		[es:SYSTEM_TIMER_TICK*4], ax
+	mov		ax, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler+2]
+	mov		[es:SYSTEM_TIMER_TICK*4+2], ax
+	sti
 %endif
 	; Fall to .ResetAllDrives
@@ -146,5 +154,4 @@
 SelectDriveToBootFrom:		; Function starts here
 %ifdef MODULE_HOTKEYS
-	call	HotkeyBar_UpdateDuringDriveDetection
 	mov		al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
 	cmp		al, ROM_BOOT_HOTKEY_SCANCODE
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 598)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 599)
@@ -224,8 +224,4 @@
 StartDetectionWithDriveSelectByteInBHandStringInCX:
 	call	DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP
-
-%ifdef MODULE_HOTKEYS
-	call	HotkeyBar_UpdateDuringDriveDetection
-%endif
 	; Fall to .ReadAtaInfoFromHardDisk
 
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 598)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 599)
@@ -184,6 +184,8 @@
 	mul		bl
 	xchg	ax, bx
+	cli
 	mov		[es:bx], si				; Store offset
 	mov		[es:bx+2], cs			; Store segment
+	sti
 .Interrupts_Return:
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm	(revision 598)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm	(revision 599)
@@ -169,5 +169,5 @@
 	; selections are correctly displayed on Hotkey Bar and on Boot Menu
 %ifdef MODULE_HOTKEYS
-	call	BootVars_StoreDefaultDriveLettersToHotkeyVars
+	call	HotkeyBar_StoreDefaultDriveLettersToHotkeyVars
 %endif
 	call	DriveXlate_Reset
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 598)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 599)
@@ -21,4 +21,69 @@
 SECTION .text
 
+
+;--------------------------------------------------------------------
+; Handler for INT 1Ch System Timer Tick.
+; Reads key presses and draws hotkey bar.
+;
+; HotkeyBar_TimerTickHandler
+;	Parameters:
+;		DS:		RAMVARS segment
+;		ES:		BDA segment (zero)
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, DX, SI, DI
+;--------------------------------------------------------------------
+HotkeyBar_TimerTickHandler:
+	push	es
+	push	ds
+%ifdef USE_186
+	ePUSHA
+%else
+	push	di
+	push	si
+	push	dx
+	push	cx
+	push	ax
+%endif
+	sti			; Enable interrupts (is this really necessary? Do we lose key inputs if we keep interrupts disabled?)
+				; There would be no need for FLG_HOTKEY_UPDATING if we can keep interrupts disabled during whole update.
+
+	LOAD_BDA_SEGMENT_TO es, ax
+	call	RamVars_GetSegmentToDS
+
+	; Call previous handler
+	pushf
+	call far [es:BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler]
+
+	; Do not start updating if update is already in progress (do we need this on AT systems?)
+	test	BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_UPDATING
+	jnz		SHORT .ReturnFromHandler
+
+	; Update Hotkeybar (process key input and draw)
+%ifndef USE_AT	; Ease XT systems a bit by updating every other timer tick
+	call	TimerTicks_ReadFromBdaToAX
+	shr		ax, 1
+	jnc		SHORT .ReturnFromHandler
+%endif
+	or		BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_UPDATING
+	call	UpdateDuringDriveDetection
+	and		BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], ~FLG_HOTKEY_UPDATING
+
+.ReturnFromHandler:
+%ifdef USE_186
+	ePOPA
+%else
+	pop		ax
+	pop		cx
+	pop		dx
+	pop		si
+	pop		di
+%endif
+	pop		ds
+	pop		es
+	iret
+
+
 ;--------------------------------------------------------------------
 ; Scans key presses and draws any hotkey changes.
@@ -33,6 +98,13 @@
 ;		AX, CX, DX, SI, DI
 ;--------------------------------------------------------------------
-HotkeyBar_UpdateDuringDriveDetection:
+UpdateDuringDriveDetection:
 	call	ScanHotkeysFromKeyBufferAndStoreToBootvars
+
+	; If ESC pressed, abort detection by forcing timeout
+	cmp		al, ESC_SCANCODE
+	jne		SHORT .ContinueDrawing
+	mov		BYTE [RAMVARS.bTimeoutTicksLeft], 0
+.ContinueDrawing:
+	
 	; Fall to HotkeyBar_DrawToTopOfScreen
 
@@ -78,5 +150,5 @@
 	; Clear CH if floppy drive is selected for boot
 	mov		ch, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags]
-;	and		ch, FLG_HOTKEY_HD_FIRST		; Needed if more flags are added
+	and		ch, FLG_HOTKEY_HD_FIRST
 	call	FormatDriveHotkeyString
 
@@ -97,5 +169,5 @@
 	mov		ah, ANGLE_QUOTE_RIGHT
 	mov		cx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddLetterAndFlags]	; Letter to CL, flags to CH
-;	and		ch, FLG_HOTKEY_HD_FIRST		; Needed if more flags are added
+	and		ch, FLG_HOTKEY_HD_FIRST
 	xor		ch, FLG_HOTKEY_HD_FIRST		; Clear CH if HD is selected for boot, set otherwise
 	mov		di, g_szHDD
@@ -332,4 +404,58 @@
 
 ;--------------------------------------------------------------------
+; HotkeyBar_StoreDefaultDriveLettersToHotkeyVars
+;	Parameters:
+;		ES:		BDA Segment
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+HotkeyBar_StoreDefaultDriveLettersToHotkeyVars:
+	call	BootVars_GetLetterForFirstHardDriveToAX
+	mov		ah, DEFAULT_FLOPPY_DRIVE_LETTER
+	xchg	al, ah
+	mov		[es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters], ax
+	ret
+
+
+;--------------------------------------------------------------------
+; HotkeyBar_InitializeVariables
+;	Parameters:
+;		DS:		RAMVARS Segment
+;		ES:		BDA Segment
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, DX, DI
+;--------------------------------------------------------------------
+HotkeyBar_InitializeVariables:
+	push	ds
+	push	es
+	pop		ds
+
+	; Store system 1Ch Timer Tick handler and install our hotkeybar handler
+	mov		ax, [SYSTEM_TIMER_TICK*4]
+	mov		[BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler], ax
+	mov		ax, [SYSTEM_TIMER_TICK*4+2]
+	mov		[BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler+2], ax
+	mov		al, SYSTEM_TIMER_TICK
+	mov		si, HotkeyBar_TimerTickHandler
+	call	Interrupts_InstallHandlerToVectorInALFromCSSI
+
+	; Store time when hotkeybar is displayed
+	; (it will be displayed after initialization is complete)
+	call	TimerTicks_ReadFromBdaToAX
+	mov		[BOOTVARS.hotkeyVars+HOTKEYVARS.wTimeWhenDisplayed], ax
+
+	pop		ds
+
+	; Initialize HOTKEYVARS by storing default drives to boot from
+	call	HotkeyBar_StoreDefaultDriveLettersToHotkeyVars
+	mov		dl, [cs:ROMVARS.bBootDrv]
+	; Fall to HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL
+
+
+;--------------------------------------------------------------------
 ; HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL
 ;	Parameters:
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/BootVars.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/BootVars.asm	(revision 598)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/BootVars.asm	(revision 599)
@@ -45,32 +45,5 @@
 	add		cx, BYTE HOTKEYVARS_size
 	call	Memory_ZeroESDIwithSizeInCX
-
-	; Store time when hotkeybar is displayed
-	; (it will be displayed after initialization is complete)
-	call	TimerTicks_ReadFromBdaToAX
-	mov		[es:BOOTVARS.hotkeyVars+HOTKEYVARS.wTimeWhenDisplayed], ax
-
-	; Initialize HOTKEYVARS by storing default drives to boot from
-	call	BootVars_StoreDefaultDriveLettersToHotkeyVars
-	mov		dl, [cs:ROMVARS.bBootDrv]
-	jmp		HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL
-
-
-;--------------------------------------------------------------------
-; BootVars_StoreDefaultDriveLettersToHotkeyVars
-;	Parameters:
-;		ES:		BDA Segment
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-BootVars_StoreDefaultDriveLettersToHotkeyVars:
-	call	BootVars_GetLetterForFirstHardDriveToAX
-	mov		ah, DEFAULT_FLOPPY_DRIVE_LETTER
-	xchg	al, ah
-	mov		[es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters], ax
-	ret
-
+	jmp		HotkeyBar_InitializeVariables
 %endif ; MODULE_HOTKEYS
 
