Index: trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 528)
@@ -57,5 +57,5 @@
 	.wFddAndHddLetters:
 	.bFddLetter			resb	1		; Floppy Drive letter hotkey (upper case)
-	.bHddLetter			resb	1		; Hard Drive letter hotkey (upper case)
+	.bHddLetter			resb	1		; Hard Drive letter hotkey (upper case). Must be after .bFddLetter!
 	.bFlags				resb	1		; Must be just after .bHddLetter!  (dependency in Hotkeybar.asm)
 	.bScancode			resb	1		; Function hotkey scancode, must be just after .bFlags!
Index: trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Inc/HotkeyBar.inc	(revision 528)
@@ -21,5 +21,5 @@
 %define HOTKEYBAR_INC
 
-MIN_TIME_TO_DISPLAY_HOTKEY_BAR			EQU	(2000/55)	; 2000 ms
+MIN_TIME_TO_DISPLAY_HOTKEY_BAR			EQU	(4000/55)	; 4000 ms
 
 ROM_BOOT_HOTKEY_SCANCODE				EQU	42h	; F8
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 528)
@@ -103,6 +103,4 @@
 ;		Never returns (loads operating system)
 ;--------------------------------------------------------------------
-SelectDriveToBootFrom:
-
 ; The following macro could be easily inlined below.  Why a macro?  Depending on the combination
 ; of MODULE_HOTKEYS or MODULE_BOOT_MENU, this code needs to either come before or after the
@@ -112,46 +110,60 @@
 	push	dx									; it's OK if this is left on the stack, if we are
 												; successful, the following call does not return
-	call	TryToBootFromPrimaryOrSecondaryBootDevice_AndBoot
+	call	BootSector_TryToLoadFromDriveDL_AndBoot
 	pop		dx
 	mov		dl, dh
-	call	TryToBootFromPrimaryOrSecondaryBootDevice_AndBoot
+	call	BootSector_TryToLoadFromDriveDL_AndBoot
 %endmacro
 
-%ifdef MODULE_HOTKEYS
-	call	HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
+
+SelectDriveToBootFrom:		; Function starts here
+%ifdef MODULE_HOTKEYS
+	call	HotkeyBar_UpdateDuringDriveDetection
+	mov		al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
 	cmp		al, ROM_BOOT_HOTKEY_SCANCODE
-	je		.RomBoot							; CF clear so ROM boot
+	je		SHORT .RomBoot						; CF clear so ROM boot
 %ifdef MODULE_BOOT_MENU
 	cmp		al, BOOT_MENU_HOTKEY_SCANCODE
-	je		.BootMenu
-%endif
+	je		SHORT .BootMenu
+%endif ; MODULE_BOOT_MENU
+
+.TryUsingHotKeysCode:
 	call	HotkeyBar_GetBootDriveNumbersToDX
-.TryUsingHotKeysCode:
+	call	DriveXlate_SetDriveToSwap			; Enable primary boot device translation
+	xchg	dl, dh
+	call	DriveXlate_SetDriveToSwap			; Enable secondary boot device translation
+	xchg	dl, dh
+	call	DriveXlate_ToOrBack					; Tranlate now so boot device will appear as 00h or 80h to OS
 	TRY_TO_BOOT_DL_AND_DH_DRIVES
 	;; falls through to boot menu, if it is present.  If not present, falls through to rom boot.
 %endif ; MODULE_HOTKEYS
 
+
 %ifdef MODULE_BOOT_MENU
 .BootMenu:
 	call	BootMenu_DisplayAndReturnDriveInDLRomBootClearCF
-	jnc		.RomBoot							; CF clear so ROM boot
-
+	jnc		SHORT .RomBoot						; CF clear so ROM boot
+
+	call	DriveXlate_Reset
+%ifdef MODULE_HOTKEYS
+	jmp		SHORT .TryUsingHotKeysCode			; Selected drive stored as hotkey
+%else ; Boot menu without hotkeys, secondary boot drive is always 00h or 80h
 	mov		dh, dl								; Setup for secondary drive
 	not		dh									; Floppy goes to HD, or vice versa
 	and		dh, 80h								; Go to first drive of the floppy or HD set
-
-%ifdef MODULE_HOTKEYS
-	jmp		.TryUsingHotKeysCode
-%else
+	call	DriveXlate_SetDriveToSwap
+	call	DriveXlate_ToOrBack
 	TRY_TO_BOOT_DL_AND_DH_DRIVES
-	jmp		.BootMenu
-%endif
+	jmp		SHORT .BootMenu						; Show boot menu again
+%endif ; MODULE_HOTKEYS
+
 %endif ; MODULE_BOOT_MENU
 
+; No hotkeys and no boot menu means fixed "A then C" boot order
 %ifndef MODULE_HOTKEYS OR MODULE_BOOT_MENU
-	xor		dl, dl			; Try to boot from Floppy Drive A
-	call	TryToBootFromPrimaryOrSecondaryBootDevice_AndBoot
-	mov		dl, 80h			; Try to boot from Hard Drive C
-	call	TryToBootFromPrimaryOrSecondaryBootDevice_AndBoot
+	xor		dl, dl							; Try to boot from Floppy Drive A
+	call	BootSector_TryToLoadFromDriveDL_AndBoot
+	mov		dl, DEFAULT_HARD_DRIVE_LETTER	; Try to boot from Hard Drive C
+	call	BootSector_TryToLoadFromDriveDL_AndBoot
 %endif
 
@@ -201,31 +213,2 @@
 .romboot:
 	int		BIOS_BOOT_FAILURE_INTERRUPT_18h	; Never returns
-
-
-;--------------------------------------------------------------------
-; TryToBootFromPrimaryOrSecondaryBootDevice_AndBoot
-;	Parameters
-;		DL:		Drive selected as boot device
-;		DS:		RAMVARS segment
-;		ES:		BDA and interrupt vector segment (zero)
-;	Returns:
-;		DL:		Drive to boot from (translated, 00h or 80h)
-;       CF:     Set for Boot Sector Boot
-;               Clear for ROM Boot
-;	   	ES:BX:	(if CF set) Ptr to boot sector
-;	Corrupts registers:
-;		AX, CX, DH, SI, DI, (DL if failed to read boot sector)
-;--------------------------------------------------------------------
-%ifndef MODULE_DRIVEXLATE
-TryToBootFromPrimaryOrSecondaryBootDevice_AndBoot	EQU		BootSector_TryToLoadFromDriveDL_AndBoot
-
-%else
-TryToBootFromPrimaryOrSecondaryBootDevice_AndBoot:
-	call	DriveXlate_SetDriveToSwap
-	call	DriveXlate_ToOrBack
-	; fall through to TryToBoot_FallThroughTo_BootSector_TryToLoadFromDriveDL_AndBoot
-
-TryToBoot_FallThroughTo_BootSector_TryToLoadFromDriveDL_AndBoot:
-; fall through to BootSector_TryToLoadFromDriveDL_AndBoot
-%endif
-
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm	(revision 528)
@@ -73,11 +73,4 @@
 	ret
 
-%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
-  %ifdef MODULE_DRIVEXLATE
-    %if TryToBoot_FallThroughTo_BootSector_TryToLoadFromDriveDL_AndBoot <> BootSector_TryToLoadFromDriveDL_AndBoot
-	  %error "TryToBoot_FallThroughTo_BootSector_TryToLoadFromDriveDL_AndBoot <> BootSector_TryToLoadFromDriveDL_AndBoot, BootSector must come immediately after int19h.asm"
-    %endif
-  %endif
-%endif
 
 ;--------------------------------------------------------------------
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 528)
@@ -47,8 +47,4 @@
 	mov		bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
 	call	StartDetectionWithDriveSelectByteInBHandStringInCX
-
-%ifdef MODULE_HOTKEYS
-	call	HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars		; Done here while CX is still protected
-%endif
 
 	pop		cx
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm	(revision 528)
@@ -69,4 +69,5 @@
 MENUEVENT_ExitMenu equ  (BootMenuEvent_Completed - FirstEvent)
 MENUEVENT_ItemHighlightedFromCX equ (EventItemHighlightedFromCX - FirstEvent)
+MENUEVENT_KeyStrokeInAX equ	(EventKeyStrokeInAX - FirstEvent)
 MENUEVENT_ItemSelectedFromCX equ (EventItemSelectedFromCX - FirstEvent)
 MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - FirstEvent)
@@ -94,4 +95,5 @@
 	dw		EventNotHandled						; MENUEVENT.IdleProcessing
 	dw		EventItemHighlightedFromCX			; MENUEVENT.ItemHighlightedFromCX
+	
 	dw		EventItemSelectedFromCX				; MENUEVENT.ItemSelectedFromCX
 	dw		EventKeyStrokeInAX					; MENUEVENT.KeyStrokeInAX
@@ -161,8 +163,37 @@
 EventItemHighlightedFromCX:
 	push	cx
+
+	; Drive number translations and hotkeys must be reset to defaults so highlighted
+	; selections are correctly displayed on Hotkey Bar and on Boot Menu
+%ifdef MODULE_HOTKEYS
+	call	BootVars_StoreDefaultDriveLettersToHotkeyVars
+%endif
+	call	DriveXlate_Reset
+
+	; Set highlighted item to be drive to boot from for visual purposes only
 	call	BootMenu_GetDriveToDXforMenuitemInCX
-	jnc		.noDriveSwap
+	jnc		SHORT .noDriveSwapSinceRomBootSelected
 	call	DriveXlate_SetDriveToSwap
-.noDriveSwap:
+
+%ifdef MODULE_HOTKEYS
+	; Store highlighted drive as hotkey
+	call	HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL
+	jmp		SHORT .UpdateHotkeyBar
+.noDriveSwapSinceRomBootSelected:
+	mov		ah, ROM_BOOT_HOTKEY_SCANCODE
+	call	HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
+
+.UpdateHotkeyBar:
+	; Redraw Hotkey Bar for updated boot drive letters
+	mov		al, MONO_NORMAL
+	CALL_DISPLAY_LIBRARY	SetCharacterAttributeFromAL
+
+	mov		bl, ATTRIBUTES_ARE_USED
+	mov		ax, TELETYPE_OUTPUT_WITH_ATTRIBUTE
+	CALL_DISPLAY_LIBRARY	SetCharOutputFunctionFromAXwithAttribFlagInBL
+	call	HotkeyBar_DrawToTopOfScreen
+%else
+.noDriveSwapSinceRomBootSelected:
+%endif ; MODULE_HOTKEYS
 
 	; Redraw changes in drive numbers
@@ -181,4 +212,29 @@
 
 ;--------------------------------------------------------------------
+; EventKeyStrokeInAX
+;	Parameters
+;		AL:		ASCII character for the key
+;		AH:		Keyboard library scan code for the key
+;		DS:		Ptr to RAMVARS
+;		ES:		Ptr to BDA (zero)
+;		SS:BP:	Menu library handle
+;	Returns:
+;		CF:		Set if event processed
+;				Cleared if event not processed
+;	Corrupts registers:
+;		Does not matter
+;--------------------------------------------------------------------
+%ifdef MODULE_HOTKEYS
+EventKeyStrokeInAX:
+	; Keypress will be the primary boot drive
+	cmp		ah, BOOT_MENU_HOTKEY_SCANCODE
+	je		SHORT BootMenuEvent_Completed	; Ignore Boot Menu hotkey
+	call	HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
+	jnc		SHORT BootMenuEvent_Completed
+	; Fall to CloseBootMenu through EventItemSelectedFromCX
+%endif
+
+
+;--------------------------------------------------------------------
 ; EventItemSelectedFromCX
 ;	Parameters
@@ -223,3 +279,6 @@
 BootMenuEvent_Completed:
 	stc
-	ret
+%ifndef MODULE_HOTKEYS
+EventKeyStrokeInAX:
+%endif
+	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/DriveXlate.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/DriveXlate.asm	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/DriveXlate.asm	(revision 528)
@@ -143,9 +143,10 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, DI, DL
+;		Nothing
 ;--------------------------------------------------------------------
 DriveXlate_Reset:
-	xor		dl, dl				; no translation for a floppy
-	;; fall through to DriveXlate_SetDriveToSwap
+	mov		WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], 8000h
+	ret
+
 
 ;--------------------------------------------------------------------
@@ -154,19 +155,21 @@
 ; DriveXlate_SetDriveToSwap
 ;	Parameters:
-;		DL:		Drive to swap to 00h or 80h
+;		DL:		Hard Drive to swap to first Hard Drive
+;				Floppy Drive to swap to first Floppy Drive
 ;		DS:		RAMVARS segment
 ;	Returns:
 ;		Nothing
 ;	Corrupts registers:
-;		AX, DI
+;		Nothing
 ;--------------------------------------------------------------------
 DriveXlate_SetDriveToSwap:
-	mov		ax, 8000h			; Default mapping (no translation)
 	test	dl, dl				; Floppy drive?
 	js		SHORT .SetHardDriveToSwap
-	mov		al, dl				; Store floppy translation
-	SKIP2B	di
+
+	; Set Floppy Drive to swap
+	mov		[RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
+	ret
+
 .SetHardDriveToSwap:
-	mov		ah, dl				; Store HD translation
-	mov		WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], ax
+	mov		[RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 528)
@@ -22,4 +22,6 @@
 
 ;--------------------------------------------------------------------
+; Scans key presses and draws any hotkey changes.
+;
 ; HotkeyBar_UpdateDuringDriveDetection
 ;	Parameters:
@@ -32,5 +34,5 @@
 ;--------------------------------------------------------------------
 HotkeyBar_UpdateDuringDriveDetection:
-	call	HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
+	call	ScanHotkeysFromKeyBufferAndStoreToBootvars
 	; Fall to HotkeyBar_DrawToTopOfScreen
 
@@ -311,5 +313,21 @@
 
 ;--------------------------------------------------------------------
-; HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL
+; HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL
+;	Parameters:
+;		DS:		RAMVARS segment
+;		ES:		BDA segment (zero)
+;		DL:		Drive Number
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, DL, DI
+;--------------------------------------------------------------------
+HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL:
+	call	DriveXlate_ConvertDriveNumberFromDLtoDriveLetter
+	; Fall to StoreHotkeyToBootvarsForDriveLetterInDL
+
+
+;--------------------------------------------------------------------
+; StoreHotkeyToBootvarsForDriveLetterInDL
 ;	Parameters:
 ;		DS:		RAMVARS segment
@@ -321,5 +339,5 @@
 ;		AX, CX, DI
 ;--------------------------------------------------------------------
-HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL:
+StoreHotkeyToBootvarsForDriveLetterInDL:
 	eMOVZX	ax, dl
 	or		al, 32	; Upper case drive letter to lower case keystroke
@@ -328,5 +346,5 @@
 
 ;--------------------------------------------------------------------
-; HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
+; ScanHotkeysFromKeyBufferAndStoreToBootvars
 ;	Parameters:
 ;		DS:		RAMVARS segment
@@ -337,9 +355,10 @@
 ;		AH, CX
 ;--------------------------------------------------------------------
-HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars:
+ScanHotkeysFromKeyBufferAndStoreToBootvars:
 	call	Keyboard_GetKeystrokeToAX
 	jz		SHORT NoHotkeyToProcess
 
-	ePUSH_T	cx, HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
+	; Prepare to read another key from buffer
+	ePUSH_T	cx, ScanHotkeysFromKeyBufferAndStoreToBootvars
 	; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
 
@@ -354,4 +373,6 @@
 ;	Returns:
 ;       AL:     Last scancode seen
+;		CF:		Set if valid hotkey in AL
+;				Clear if scancode in AL is not for any hotkey
 ;	Corrupts registers:
 ;		AH, CX, DI
@@ -387,4 +408,5 @@
 	xchg	ax, cx
 	mov		[es:di], al
+	stc								; Valid hotkey scancode returned in AL
 
 .KeystrokeIsNotValidDriveLetter:
@@ -392,4 +414,5 @@
 	mov		al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
 	ret
+
 
 ;--------------------------------------------------------------------
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/BootVars.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/BootVars.asm	(revision 527)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/BootVars.asm	(revision 528)
@@ -41,15 +41,28 @@
 	mov		di, BOOTVARS.rgDrvDetectInfo	; We must not initialize anything before this!
 	xchg	cx, ax
+%ifndef MODULE_HOTKEYS
+	jmp		Memory_ZeroESDIwithSizeInCX
 
-%ifdef MODULE_HOTKEYS
+%else ; if MODULE_HOTKEYS
 	call	Memory_ZeroESDIwithSizeInCX
 
 	; 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:
 	mov		WORD [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters], DEFAULT_FLOPPY_DRIVE_LETTER | (DEFAULT_HARD_DRIVE_LETTER<<8)
-	mov		dl, [cs:ROMVARS.bBootDrv]
-	call	DriveXlate_ConvertDriveNumberFromDLtoDriveLetter
-	jmp		HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL
+	ret
 
-%else
-	jmp		Memory_ZeroESDIwithSizeInCX
 %endif ; MODULE_HOTKEYS
