Index: /trunk/XTIDE_Universal_BIOS/Inc/BootMenu.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/BootMenu.inc	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Inc/BootMenu.inc	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	BootMenu.inc
-; Project name	:	IDE BIOS
-; Created date	:	26.3.2010
-; Last update	:	26.3.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Equates used in Boot Menu.
 %ifndef BOOTMENU_INC
@@ -9,12 +5,12 @@
 
 ; Boot menu sizes
-MENU_TITLE_LINE_CNT		EQU	3		; Number of title lines
-MENU_INFO_LINE_CNT		EQU	3		; Number of info lines
-MENU_WIDTH_IN_CHARS		EQU	38		; Menu width in characters
-MENU_HEIGHT_IN_CHARS_WITH_INFO		EQU	(MENU_TITLE_LINE_CNT + MENU_INFO_LINE_CNT + 4)
-MENU_HEIGHT_IN_CHARS_WITHOUT_INFO	EQU	(MENU_TITLE_LINE_CNT + 3)
+BOOT_MENU_TITLE_LINES			EQU	2	; Number of title lines
+BOOT_MENU_INFO_LINES			EQU	3	; Number of info lines
+BOOT_MENU_TITLE_AND_INFO_LINES	EQU	(BOOT_MENU_TITLE_LINES | (BOOT_MENU_INFO_LINES<<8))
+BOOT_MENU_WIDTH					EQU	40	; Menu width in characters
+BOOT_MENU_HEIGHT_WITHOUT_ITEMS	EQU	(BOOT_MENU_TITLE_LINES + BOOT_MENU_INFO_LINES + 4)
 
 ; Function IDs
-ID_BOOTFUNC_ROMBOOT		EQU	0		; ROM boot
+ID_BOOTFUNC_ROMBOOT				EQU	0	; ROM boot
 
 
Index: /trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	BootVars.inc
-; Project name	:	IDE BIOS
-; Created date	:	23.3.2010
-; Last update	:	9.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Defines for BOOTVARS struct used by boot menu
 ;					and drive initialization.
@@ -26,6 +22,5 @@
 	.dwSys18h		resb	4		;  800h, System INT 18h handler (Diskless boot, Boot failure)
 	.dwPostStack	resb	4		;  804h, POST stack when entering INT 19h
-	.bMenuHotkey	resb	1		;  808h, Boot Menu hotkey, zero if none pressed
-					resb	3
+					resb	4
 	.rgBootNfo		resb	73F4h	;  80Ch, Array containing BOOTNFO structs
 	.rgbMnuStack:					; 7C00h and below, Boot Menu stack
Index: /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	RamVars.inc
-; Project name	:	IDE BIOS
-; Created date	:	23.3.2010
-; Last update	:	8.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	RAMVARS struct containing BIOS variables stored in RAM.
 %ifndef RAMVARS_INC
@@ -31,6 +27,5 @@
 
 	.wI13hDS:
-	.bEndTime		resb	1	; Timeout ending time
-					resb	1	; Alignment
+	.wTimeoutCounter	resb	2
 
 	.wDrvCntAndFirst:
Index: /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 88)
@@ -24,5 +24,5 @@
 	.bIdeCnt		resb	1	; Number of supported IDE controllers
 	.bBootDrv		resb	1	; Boot Menu default drive
-	.bBootMnuH		resb	1	; Boot Menu maximum height
+					resb	1	; (Was boot menu maximum height)
 	.bBootDelay		resb	1	; Boot Menu selection delay in seconds
 	.bBootLdrType	resb	1	; Boot Loader type
Index: unk/XTIDE_Universal_BIOS/Inc/emulate.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/emulate.inc	(revision 87)
+++ 	(revision )
@@ -1,477 +1,0 @@
-; File name		:	emulate.inc
-; Project name	:	Emulation library
-; Created date	:	21.10.2009
-; Last update	:	4.4.2010
-; Author		:	Tomi Tilli
-; Description	:	Macros for emulating later x86 instruction with older
-;					processors.
-;					Macros are used so optimized builds could be done
-;					easily for different processors.
-;
-;					This file must be first to be included to
-;					any source file.
-%ifndef EMULATE_INC
-%define EMULATE_INC
-
-; Defines for processor support. Unsupported instructions will be
-; emulated using macros.
-; If using 286, define USE_186 and USE_286
-; If using 386, define USE_186, USE_286 and USE_386
-; If AT class PC is used (instead of XT), define USE_AT
-;%define USE_186				; Define to use 18x/V20/V30 instructions
-;%define USE_286				; Define to use 286 instructions
-;%define USE_386				; Define to use 386 instructions
-;%define USE_AT					; Define for AT class machine
-; Above defines should be set on makefile!
-
-CPU 8086						; Allow 8088/8086 instructions only
-%ifdef USE_186
-CPU 186							; Allow instructions up to 188/186/V20/V30
-%elifdef USE_286
-CPU 286							; Allow instructions up to 286
-%elifdef USE_386
-CPU 386							; Allow instructions up to 386
-%endif
-BITS 16							; Set 16 bit code generation
-
-; Alignments for jump targets.
-; Following values are optimal for different processor types:
-; 286 and 386SX			WORD (16-bit, 2 bytes)
-; 386DX and 486			DWORD (32-bit, 4 bytes)
-; Pentium and later		QWORD (64-bit, 8 bytes)
-%ifdef USE_AT
-	%ifdef USE_386
-		JUMP_ALIGN		EQU		4
-		WORD_ALIGN		EQU		2
-	%else ; USE_286
-		JUMP_ALIGN		EQU		2
-		WORD_ALIGN		EQU		2
-	%endif
-%else ; XT
-	JUMP_ALIGN		EQU		1
-	WORD_ALIGN		EQU		1
-%endif
-
-;==========================================================================
-
-;--------------------------------------------------------------------
-; Emulates BSF (Bit Scan Forward) instruction when necessary.
-; BSF is used to find index of least significant bit.
-;
-; eBSF
-;	Parameters:
-;		%1:		Destination WORD Register for bit index (not CX or same as %2!)
-;		%2:		Source WORD operand where to search bit (not CX or same as %1!)
-;	Returns:
-;		%1:		Index of highest order bit from %2
-;		ZF:		Set if %2 is zero
-;				Cleared if %2 is non-zero
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro eBSF 2
-%ifndef USE_386
-	push	cx
-	cmp		WORD %2, BYTE 0		; Source operand is zero?
-	je		SHORT %%Return		;  If so, return with ZF set
-
-	; Set destination to zero and load mask for bit 0
-	xor		%1, %1
-	mov		cx, 1
-
-ALIGN JUMP_ALIGN
-%%BitLoop:
-	test	%2, cx				; Bit set?
-	jnz		SHORT %%Return		;  If so, return with ZF cleared
-	shl		cx, 1				; Prepare to test next bit
-	inc		%1					; Increment bit index
-	jmp		SHORT %%BitLoop		; Loop until bit found
-%%Return:
-	pop		cx
-;-----------------------------------
-%else
-	bsf		%1, %2
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates BSR (Bit Scan Reverse) instruction when necessary.
-; BSR is used to find index of most significant bit.
-;
-; eBSR
-;	Parameters:
-;		%1:		Destination WORD Register for bit index (not CX or same as %2!)
-;		%2:		Source WORD operand where to search bit (not CX or same as %1!)
-;	Returns:
-;		%1:		Index of highest order bit from %2
-;		ZF:		Set if %2 is zero
-;				Cleared if %2 is non-zero
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro eBSR 2
-%ifndef USE_386
-	push	cx
-	cmp		WORD %2, BYTE 0		; Source operand is zero?
-	je		SHORT %%Return		;  If so, return with ZF set
-
-	; Load mask for highest order bit
-	mov		cx, 1<<15
-	mov		%1, 15
-
-ALIGN JUMP_ALIGN
-%%BitLoop:
-	test	%2, cx				; Bit set?
-	jnz		SHORT %%Return		;  If so, return with ZF cleared
-	shr		cx, 1				; Prepare to test next bit
-	dec		%1					; Decrement bit index
-	jmp		SHORT %%BitLoop		; Loop until bit found
-%%Return:
-	pop		cx
-;-----------------------------------
-%else
-	bsr		%1, %2
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Moves byte with zero-extending to any Register.
-;
-; eMOVZX
-;	Parameters:
-;		%1:		Destination Register (SP not supported)
-;		%2:		Byte register or byte address
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		FLAGS
-;--------------------------------------------------------------------
-%macro eMOVZX 2
-%ifndef USE_386
-	%ifidni %1, ax
-		mov		al, %2
-		xor		ah, ah
-	%elifidni %1, bx
-		mov		bl, %2
-		xor		bh, bh		; %2 may use BX in effective address
-	%elifidni %1, cx
-		mov		cl, %2
-		xor		ch, ch
-	%elifidni %1, dx
-		mov		dl, %2
-		xor		dh, dh
-	%else	; SI, DI, BP (all may be used in effective address)
-		push	ax
-		mov		al, %2
-		xor		ah, ah
-		xchg	ax, %1
-		pop		ax
-	%endif
-;-----------------------------------
-%else
-	movzx	%1, %2
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates PUSHA instruction when necessary.
-;
-; ePUSHA
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro ePUSHA 0
-%ifndef USE_186
-	push	ax
-	push	cx
-	push	dx
-	push	bx
-	; SP before first push should be pushed here
-	push	bp
-	push	si
-	push	di
-;-----------------------------------
-%else
-	pusha
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates POPA instruction when necessary.
-;
-; ePOPA
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro ePOPA 0
-%ifndef USE_186
-	pop		di
-	pop		si
-	pop		bp
-	; Old SP should be skipped here
-	pop		bx
-	pop		dx
-	pop		cx
-	pop		ax
-;-----------------------------------
-%else
-	popa
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates ENTER instruction when necessary.
-;
-; eENTER
-;	Parameters:
-;		%1:		Number of bytes to reserve from stack
-;		%2:		The lexical nesting level (not emulated)
-;	Returns:
-;		SS:BP:	Ptr to old BP
-;				([bp-2] points to highest local stack frame word)
-;	Corrupts registers:
-;		FLAGS
-;--------------------------------------------------------------------
-%macro eENTER 2
-%ifndef USE_186
-	push	bp
-	mov		bp, sp
-	sub		sp, %1
-;-----------------------------------
-%else
-	enter	%1, %2
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates LEAVE instruction when necessary.
-;
-; eLEAVE
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro eLEAVE 0
-%ifndef USE_186
-	mov		sp, bp
-	pop		bp
-;-----------------------------------
-%else
-	leave
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates LSS instruction when necessary.
-;
-; eLSS
-;	Parameters:
-;		%1:		Destination register
-;		%2:		Source memory address without brackets
-;	Returns:
-;		IF:		0 (interrupts disabled)
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro eLSS 2
-%ifndef USE_386
-	cli							; Disable interrupts
-	mov		%1, [%2]			; Load offset
-	mov		ss, [%2+2]			; Load segment
-;-----------------------------------
-%else
-	lss		%1, [%2]
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Segment override prefix instruction.
-;
-; eSEG
-;	Parameters:
-;		%1:		Name of the segment (ES, CS, SS, DS, FS or GS)
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro eSEG 1
-	%ifidni %1, es
-		db	00100110b
-	%elifidni %1, cs
-		db	00101110b
-	%elifidni %1, ss
-		db	00110110b
-	%elifidni %1, ds
-		db	00111110b
-	%elifidni %1, fs
-		db	01100100b
-	%elifidni %1, gs
-		db	01100101b
-	%else
-		%error "Invalid segment overried passed to eSEG!"
-	%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Repeats string instruction with segment override.
-; This macro prevents 8088/8086 restart bug.
-;
-; eSEG_STR
-;	Parameters:
-;		%1:		REP/REPNE or REPE prefix
-;		%2:		Source segment override (destination is always ES)
-;		%3:		String instruction
-;		CX:		Repeat count
-;	Returns:
-;		FLAGS for cmps and scas only
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro eSEG_STR 3
-%ifndef USE_186	; 8088/8086 has string instruction restart bug when more than one prefix
-	 %%Loop:
-	 	%1						; REP is the prefix that can be lost
-	 	eSEG	%2				; SEG is the prefix that won't be lost
-	 	%3						; String instruction
-	 	jcxz	%%End			; Jump to end if no repeats left (preserves FLAGS)
-	 	jmp		SHORT %%Loop	; Loop while repeats left
-	 %%End:
-%else	; No bug on V20/V30 and later, don't know about 188/186
-	eSEG	%2
-	%1		%3
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Bit shifts and rotates with immediate.
-;
-; eSHIFT_IM
-;	Parameters:
-;		%1:		Shift target
-;		%2:		Number of bits to shift
-;		%3:		Instruction (SHL, SHR, ROL, ROR, RCL, RCR)
-;	Returns:
-;		FLAGS
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro eSHIFT_IM 3
-%ifndef USE_186
-	%ifidni %1, cl
-		times %2	%3		%1, 1
-	%elifidni %1, ch
-		times %2	%3		%1, 1
-	%elifidni %1, cx
-		times %2	%3		%1, 1
-	%else
-		%if %2 > 7
-			push	cx
-			mov		cl, %2
-			%3		%1, cl
-			pop		cx
-		%else
-			times %2	%3		%1, 1
-		%endif
-	%endif
-;-----------------------------------
-%else
-	%3		%1, %2
-%endif
-%endmacro
-%macro eSHR_IM 2
-	eSHIFT_IM	%1, %2, shr
-%endmacro
-%macro eSHL_IM 2
-	eSHIFT_IM	%1, %2, shl
-%endmacro
-%macro eROR_IM 2
-	eSHIFT_IM	%1, %2, ror
-%endmacro
-%macro eROL_IM 2
-	eSHIFT_IM	%1, %2, rol
-%endmacro
-%macro eRCR_IM 2
-	eSHIFT_IM	%1, %2, rcr
-%endmacro
-%macro eRCL_IM 2
-	eSHIFT_IM	%1, %2, rcl
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates PUSH imm instruction when necessary.
-;
-; ePUSH_I
-;	Parameters:
-;		%1:		Immediate to push
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro ePUSH_I 1
-%ifndef USE_186
-	push	bp					; Immediate goes here
-	push	bp
-	mov		bp, sp
-	mov		WORD [bp+2], %1
-	pop		bp
-;-----------------------------------
-%else
-	push	%1
-%endif
-%endmacro
-
-
-;--------------------------------------------------------------------
-; Emulates PUSH imm instruction when necessary.
-; ePUSH_T uses temporary register for faster performance
-; and smaller code size than ePUSH_I.
-;
-; ePUSH_T
-;	Parameters:
-;		%1:		Temporary Register
-;		%2:		Immediate to push
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		%1
-;--------------------------------------------------------------------
-%macro ePUSH_T 2
-%ifndef USE_186
-	%ifidni %2, 0
-		xor		%1, %1
-	%else
-		mov		%1, %2
-	%endif
-	push	%1
-;-----------------------------------
-%else
-	push	%2
-%endif
-%endmacro
-
-
-%endif ; EMULATE_INC
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm	(revision 88)
@@ -1,8 +1,4 @@
 ; File name		:	BootInfo.asm
-; Project name	:	IDE BIOS
-; Created date	:	16.3.2010
-; Last update	:	6.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for generating and accessing drive
 ;					information to be displayed on boot menu.
@@ -145,5 +141,5 @@
 	loop	BootInfo_StoreAtaString	; Loop while words left
 .Return:
-	mov		al, STOP				; End string with STOP
+	xor		ax, ax					; Terminate string with NULL
 	stosb
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm	(revision 88)
@@ -1,8 +1,3 @@
-; File name		:	BootMenu.asm
-; Project name	:	IDE BIOS
-; Created date	:	25.3.2010
-; Last update	:	14.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Displays Boot Menu.
 
@@ -28,18 +23,27 @@
 	call	DriveXlate_Reset
 	call	BootMenuPrint_TheBottomOfScreen
-	call	BootMenu_GetMenuitemCount
-	mov		di, BootMenuEvent_Handler
 	call	BootMenu_Enter			; Get selected menuitem index to CX
 	call	BootMenuPrint_ClearScreen
-	test	cx, cx					; -1 if nothing selected (ESC pressed)
-	js		SHORT BootMenu_DisplayAndReturnSelection
-	call	BootMenu_CheckAndConvertHotkeyToMenuitem
-	jc		SHORT .SetDriveTranslationForHotkey
+	cmp		cx, BYTE NO_ITEM_SELECTED
+	je		SHORT BootMenu_DisplayAndReturnSelection
 	jmp		BootMenu_ConvertMenuitemToDriveOrFunction
-ALIGN JUMP_ALIGN
-.SetDriveTranslationForHotkey:
-	call	BootMenu_ConvertMenuitemToDriveOrFunction
-	call	DriveXlate_SetDriveToSwap
-	clc
+
+
+;--------------------------------------------------------------------
+; Enters Boot Menu or submenu.
+;
+; BootMenu_Enter
+;	Parameters:
+;		Nothing
+;	Returns:
+;		CX:		Index of selected item or NO_ITEM_SELECTED
+;	Corrupts registers:
+;		BX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenu_Enter:
+	mov		bx, BootMenuEvent_Handler
+	CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
+	xchg	cx, ax
 	ret
 
@@ -48,5 +52,5 @@
 ; Returns number of menuitems in Boot Menu.
 ;
-; BootMenu_GetMenuitemCount
+; BootMenu_GetMenuitemCountToCX
 ;	Parameters:
 ;		DS:		RAMVARS segment
@@ -57,5 +61,5 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-BootMenu_GetMenuitemCount:
+BootMenu_GetMenuitemCountToCX:
 	call	RamVars_GetHardDiskCountFromBDAtoCX
 	xchg	ax, cx
@@ -89,101 +93,19 @@
 
 ;--------------------------------------------------------------------
-; Enters Boot Menu or submenu.
-;
-; BootMenu_Enter
-;	Parameters:
-;		CX:		Number of menuitems in menu
-;		DS:SI:	User specific far pointer
-;		CS:DI:	Pointer to menu event handler function
-;	Returns:
-;		CX:		Index of last pointed Menuitem (not necessary selected with ENTER)
-;				FFFFh if cancelled with ESC
-;	Corrupts registers:
-;		AX, BX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenu_Enter:
-	call	BootMenu_GetSelectionTimeout
-	call	BootMenu_GetSize
-	MIN_U	ah, [cs:ROMVARS.bBootMnuH]		; Limit to max height
-	jmp		Menu_Enter
-
-;--------------------------------------------------------------------
-; Returns Boot Menu selection timeout in milliseconds.
-;
-; BootMenu_GetSelectionTimeout
-;	Parameters:
-;		Nothing
-;	Returns:
-;		DX:		Selection timeout in millisecs
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenu_GetSelectionTimeout:
-	mov		ax, 1000			; Seconds to milliseconds
-	eMOVZX	dx, BYTE [cs:ROMVARS.bBootDelay]
-	mul		dx					; AX = seconds * milliseconds_per_second
-	xchg	ax, dx				; DX = Timeout in millisecs
-	ret
-
-;--------------------------------------------------------------------
-; Returns Boot Menu size.
-;
-; BootMenu_GetSize
-;	Parameters:
-;		Nothing
-;	Returns:
-;		AL:		Menu width with borders included (characters)
-;		AH:		Menu height with borders included (characters)
-;		BL:		Title line count
-;		BH:		Info line count
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenu_GetSize:
-	mov		al, MENU_WIDTH_IN_CHARS
-	mov		ah, cl						; Copy menuitem count to AH
-	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_DRVNFO
-	jz		SHORT .GetHeightWithoutInfoArea
-;.GetHeightWithInfoArea:
-	add		ah, MENU_HEIGHT_IN_CHARS_WITH_INFO
-	mov		bx, (MENU_INFO_LINE_CNT<<8) | MENU_TITLE_LINE_CNT
-	ret
-ALIGN JUMP_ALIGN
-.GetHeightWithoutInfoArea:
-	add		ah, MENU_HEIGHT_IN_CHARS_WITHOUT_INFO
-	mov		bx, MENU_TITLE_LINE_CNT
-	ret
-
-
-;--------------------------------------------------------------------
-; Checks if hotkey has been pressed on Boot Menu.
-; If it has been, it will be converted to menuitem index.
-;
-; BootMenu_CheckAndConvertHotkeyToMenuitem
-;	Parameters:
-;		CX:		Menuitem index (if no hotkey)
-;	Returns:
-;		CX:		Menuitem index
-;		CF:		Set if hotkey has been pressed
-;				Cleared if no hotkey selection
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenu_CheckAndConvertHotkeyToMenuitem:
-	push	es
-	LOAD_BDA_SEGMENT_TO	es, ax				; Zero AX
-	xchg	al, [es:BOOTVARS.bMenuHotkey]	; Load and clear hotkey
-	test	al, al							; No hotkey? (clears CF)
-	jz		SHORT .Return
-	call	BootMenu_ConvertHotkeyToMenuitem
-	stc
-ALIGN JUMP_ALIGN
-.Return:
-	pop		es
-	ret
+; BootMenu_GetHeightToALwithItemCountInCL
+;	Parameters:
+;		CL:		Number of menuitems
+;	Returns:
+;		AH:		Boot menu height
+;	Corrupts registers:
+;		AL, CL, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenu_GetHeightToAHwithItemCountInCL:
+	add		cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
+	CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
+	MIN_U	ah, cl
+	ret
+
 
 ;--------------------------------------------------------------------
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	BootMenuEvent.asm
-; Project name	:	IDE BIOS
-; Created date	:	26.3.2010
-; Last update	:	1.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Boot Menu event handler for menu library callbacks.
 
@@ -9,276 +5,67 @@
 SECTION .text
 
+struc ITEM_TYPE_REFRESH
+	.HardDisk			resb	2
+	.FloppyDrive		resb	2
+	.SpecialFunction	resb	2
+endstruc
+
+
 ;--------------------------------------------------------------------
-; Boot Menu event handler.
-;
 ; BootMenuEvent_Handler
-;	Parameters:
-;		BX:		Callback event
-;		CX:		Menuitem index (usually index of selected Menuitem)
-;		DX:		Event parameter (event specific)
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AH:		Event specific or unused. Set to 0 if unused.
-;		AL:		1=Event processed
-;				0=Event not processed (default action if any)
+;	Common parameters for all events:
+;		BX:			Menu event (anything from MENUEVENT struct)
+;		SS:BP:		Menu library handle
+;	Common return values for all events:
+;		CF:			Set if event processed
+;					Cleared if event not processed
 ;	Corrupts registers:
-;		BX, CX, DX
+;		All
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 BootMenuEvent_Handler:
-	push	es
-	push	ds
-	push	di
-	push	si
+	cmp		bx, MENUEVENT.RefreshItemFromCX	; Above last supported item?
+	ja		SHORT .EventNotHandled
+	jmp		[bx+.rgfnEventSpecificHandlers]
+.EventNotHandled:
+.IdleProcessing:
+	clc
+	ret
 
-	xor		ax, ax									; Event not processed
-	cmp		bx, BYTE EVNT_MNU_GETDEF				; Event in jump table?
-	ja		SHORT .Return
-	shl		bx, 1
-	call	[cs:bx+.rgwEventJmp]
-.Return:
-	pop		si
-	pop		di
-	pop		ds
-	pop		es
-	ret
 ALIGN WORD_ALIGN
-.rgwEventJmp:
-	dw		BootMenuEvent_Exit						; 0, EVNT_MNU_EXIT (Menu will quit)
-	dw		BootMenuEvent_EventItemSelectionChanged	; 1, EVNT_MMU_SELCHG (Menuitem selection changed (with arrows))
-	dw		BootMenuEvent_EventItemSelected			; 2, EVNT_MNU_SELSET (Menuitem selected (with Enter))
-	dw		BootMenuEvent_EventKeyPressed			; 3, EVNT_MNU_KEY (Keyboard key pressed)
-	dw		BootMenuEvent_EventMenuDraw				; 4, EVNT_MNU_UPD (Menu needs to be updated)
-	dw		BootMenuEvent_EventGetDefaultMenuitem	; 5, EVNT_MNU_GETDEF (Request menuitem to be selected by default)
+.rgfnEventSpecificHandlers:
+	dw		.InitializeMenuinitFromDSSI
+	dw		.EventCompleted
+	dw		.IdleProcessing
+	dw		.ItemHighlightedFromCX
+	dw		.ItemSelectedFromCX
+	dw		.KeyStrokeInAX
+	dw		BootMenuPrint_TitleStrings
+	dw		.RefreshInformation
+	dw		.RefreshItemFromCX
 
 
-;--------------------------------------------------------------------
-; Boot Menu event handler.
-; Handles Menu Exit notification (EVNT_MNU_EXIT).
-;
-; BootMenuEvent_Exit
-;	Parameters:
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AH:		1 to cancel exit
-;				0 to allow menu exit
-;		AL:		1 = Event processed
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
+; Parameters:
+;	DS:SI:		Ptr to MENUINIT struct to initialize
+; Returns:
+;	DS:SI:		Ptr to initialized MENUINIT struct
 ALIGN JUMP_ALIGN
-BootMenuEvent_Exit:
-	mov		ax, 1					; Event handled
+.InitializeMenuinitFromDSSI:
+	push	ds
+	call	RamVars_GetSegmentToDS
+	call	.GetDefaultMenuitemToDX
+	call	BootMenu_GetMenuitemCountToCX
+	pop		ds
+	mov		[si+MENUINIT.wItems], cx
+	mov		[si+MENUINIT.wHighlightedItem], dx
+	mov		WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
+	mov		BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
+	call	BootMenu_GetHeightToAHwithItemCountInCL
+	mov		[si+MENUINIT.bHeight], ah
+	stc
 	ret
 
-
-;--------------------------------------------------------------------
-; Boot Menu event handler.
-; Handles Menuitem Selection Changed notification (EVNT_MMU_SELCHG).
-;
-; BootMenuEvent_EventItemSelectionChanged
-;	Parameters:
-;		CX:		Index of selected Menuitem
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		1 = Event processed
-;	Corrupts registers:
-;		BX, CX, DX, DI
-;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-BootMenuEvent_EventItemSelectionChanged:
-	call	RamVars_GetSegmentToDS
-	call	DriveXlate_Reset
-	call	BootMenu_ConvertMenuitemToDriveOrFunction
-	jc		SHORT BootMenuEvent_UpdateAllMenuitems	; Selection changed to a function
-	call	DriveXlate_SetDriveToSwap
-	; Fall to BootMenuEvent_UpdateAllMenuitems
-
-;--------------------------------------------------------------------
-; Redraws all menuitems.
-;
-; BootMenuEvent_UpdateAllMenuitems
-;	Parameters:
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		1 = Event processed
-;	Corrupts registers:
-;		BX, CX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuEvent_UpdateAllMenuitems:
-	mov		cx, -1					; Update all items
-	mov		dl, MFL_UPD_ITEM | MFL_UPD_NFO | MFL_UPD_NOCLEAR
-	call	Menu_Invalidate
-	mov		ax, 1					; Event handled
-	ret
-
-
-;--------------------------------------------------------------------
-; Boot Menu event handler.
-; Handles Menuitem Selected notification (EVNT_MNU_SELSET).
-;
-; BootMenuEvent_EventItemSelected
-;	Parameters:
-;		CX:		Index of selected Menuitem
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		1 = Event processed
-;	Corrupts registers:
-;		BX, CX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuEvent_EventItemSelected:
-	call	Menu_Exit				; Exit from menu
-	mov		ax, 1					; Event handled
-	ret
-
-
-;--------------------------------------------------------------------
-; Boot Menu event handler.
-; Handles Key pressed notification (EVNT_MNU_KEY).
-;
-; BootMenuEvent_EventKeyPressed
-;	Parameters:
-;		CX:		Index of currently selected Menuitem
-;		DL:		ASCII character
-;		DH:		BIOS Scan Code
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		1 = Event processed
-;	Corrupts registers:
-;		BX, CX, DX, DS
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuEvent_EventKeyPressed:
-	mov		al, dl					; Copy ASCII char to AL
-	sub		al, 'a'-'A'				; To upper case character
-	cmp		al, 'A'					; First possible drive letter?
-	jb		SHORT .Return			;  If below, return
-	cmp		al, 'Z'					; Last possible drive letter?
-	ja		SHORT .Return			;  If above, return
-	LOAD_BDA_SEGMENT_TO	ds, dx
-	mov		[BOOTVARS.bMenuHotkey], al
-	jmp		SHORT BootMenuEvent_EventItemSelected
-.Return:
-	mov		ax, 1
-	ret
-
-
-;--------------------------------------------------------------------
-; Boot Menu event handler.
-; Handles Menu Update notification (EVNT_MNU_UPD).
-;
-; BootMenuEvent_EventMenuDraw
-;	Parameters:
-;		CX: 	Index of Menuitem to update (if MFL_UPD_ITEM set)
-;		DL:		Update flag (only one):
-;					MFL_UPD_TITLE	Update Menu Title string(s)
-;					MFL_UPD_NFO		Update Menu Info string(s)
-;					MFL_UPD_ITEM	Update Menuitem string
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		Was event processed
-;	Corrupts registers:
-;		BX, CX, DX, SI, DI, DS
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuEvent_EventMenuDraw:
-	test	dl, MFL_UPD_ITEM		; Need to update Menuitem?
-	jnz		SHORT BootMenuEvent_DrawMenuitem
-	test	dl, MFL_UPD_NFO			; Need to update Info String(s)?
-	jnz		SHORT BootMenuEvent_DrawInfo
-	test	dl, MFL_UPD_TITLE		; Need to update Title String(s)?
-	jnz		SHORT BootMenuEvent_DrawTitle
-	xor		ax, ax
-	ret
-
-;--------------------------------------------------------------------
-; Draws Menuitem string. Cursor is set to a menuitem location.
-;
-; BootMenuEvent_DrawMenuitem
-;	Parameters:
-;		CX: 	Index of Menuitem to draw
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		Was event processed
-;	Corrupts registers:
-;		BX, CX, DX, SI, DI, DS, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuEvent_DrawMenuitem:
-	call	RamVars_GetSegmentToDS
-	call	BootMenu_ConvertMenuitemToDriveOrFunction
-	jc		SHORT .DrawFunctionItem
-	call	BootMenuPrint_TranslatedDriveNumber
-	test	dl, 80h					; Floppy drive?
-	jz		SHORT .DrawFloppyDriveItem
-	jmp		BootMenuPrint_HardDiskMenuitem
-ALIGN JUMP_ALIGN
-.DrawFunctionItem:
-	jmp		BootMenuPrint_FunctionMenuitem
-ALIGN JUMP_ALIGN
-.DrawFloppyDriveItem:
-	jmp		BootMenuPrint_FloppyMenuitem
-
-;--------------------------------------------------------------------
-; Draws information strings. Cursor is set to a first information line.
-;
-; BootMenuEvent_DrawInfo
-;	Parameters:
-;		CX: 	Index of selected menuitem
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		Was event processed
-;	Corrupts registers:
-;		BX, CX, DX, SI, DI, DS, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuEvent_DrawInfo:
-	call	RamVars_GetSegmentToDS
-	call	BootMenu_ConvertMenuitemToDriveOrFunction
-	jc		SHORT .DrawFunctionInfo
-	test	dl, 80h					; Floppy drive?
-	jz		SHORT .DrawFloppyDriveInfo
-	jmp		BootMenuPrint_HardDiskMenuitemInformation
-ALIGN JUMP_ALIGN
-.DrawFunctionInfo:
-	jmp		BootMenuPrint_FunctionMenuitemInformation
-ALIGN JUMP_ALIGN
-.DrawFloppyDriveInfo:
-	jmp		BootMenuPrint_FloppyMenuitemInformation
-
-;--------------------------------------------------------------------
-; Draws title strings. Cursor is set to a first title line.
-;
-; BootMenuEvent_DrawTitle
-;	Parameters:
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		Was event processed
-;	Corrupts registers:
-;		CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuEvent_DrawTitle:
-	jmp		BootMenuPrint_TitleStrings
-
-
-;--------------------------------------------------------------------
-; Boot Menu event handler.
-; Handles Get Default Menuitem notification (EVNT_MNU_GETDEF).
-;
-; BootMenuEvent_EventGetDefaultMenuitem
-;	Parameters:
-;		SS:BP:	Ptr to MENUVARS
-;	Returns:
-;		AX:		Was event processed
-;		CX:		Index of menuitem to set selected
-;	Corrupts registers:
-;		BX, CX, DX, DI, DS
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuEvent_EventGetDefaultMenuitem:
-	call	RamVars_GetSegmentToDS
+.GetDefaultMenuitemToDX:
 	mov		dl, [cs:ROMVARS.bBootDrv]	; Default boot drive
 	call	BootMenu_IsDriveInSystem
@@ -286,8 +73,114 @@
 	call	DriveXlate_SetDriveToSwap
 	call	BootMenu_ConvertDriveToMenuitem
-	mov		ax, 1
+	mov		dx, cx
 	ret
 ALIGN JUMP_ALIGN
 .DoNotSetDefaultMenuitem:
-	xor		ax, ax
+	xor		dx, dx						; Whatever appears first on boot menu
 	ret
+
+
+; Parameters:
+;	CX:			Index of new highlighted item
+;	DX:			Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
+ALIGN JUMP_ALIGN
+.ItemHighlightedFromCX:
+	push	cx
+	push	dx
+	call	RamVars_GetSegmentToDS
+	call	DriveXlate_Reset
+	call	BootMenu_ConvertMenuitemToDriveOrFunction
+	jc		SHORT .UpdatePreviousAndNewMenuitem	; Selection changed to a function
+	call	DriveXlate_SetDriveToSwap
+
+.UpdatePreviousAndNewMenuitem:
+	pop		ax		; Update previous item
+	CALL_MENU_LIBRARY RefreshItemFromAX
+	pop		ax		; Update new item
+	CALL_MENU_LIBRARY RefreshItemFromAX
+	CALL_MENU_LIBRARY RefreshInformation
+	stc
+	ret
+
+
+; Parameters:
+;	AL:			ASCII character for the key
+;	AH:			Keyboard library scan code for the key
+ALIGN JUMP_ALIGN
+.KeyStrokeInAX:
+	xor		ah, ah					; ASCII drive letter now in AX
+	call	BootMenu_ConvertHotkeyToMenuitem
+	cmp		cx, [bp+MENUINIT.wItems]
+	jae		SHORT .EventNotHandled	; Invalid key
+	xchg	ax, cx
+	CALL_MENU_LIBRARY HighlightItemFromAX
+	; Fall to .ItemSelectedFromCX
+
+
+; Parameters:
+;	CX:			Index of selected item
+ALIGN JUMP_ALIGN
+.ItemSelectedFromCX:
+	CALL_MENU_LIBRARY Close
+.EventCompleted:
+	stc
+	ret
+
+
+; Parameters:
+;	CX:			Index of item to refresh
+;	Cursor has been positioned to the beginning of item line
+ALIGN JUMP_ALIGN
+.RefreshItemFromCX:
+	mov		bx, .rgwItemTypeRefresh
+	jmp		SHORT .RefreshItemOrInformationWithJumpTableInCSBX
+
+
+; Parameters:
+;	CX:			Index of highlighted item
+;	Cursor has been positioned to the beginning of first line
+ALIGN JUMP_ALIGN
+.RefreshInformation:
+	mov		bx, .rgwInformationItemTypeRefresh
+	; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
+
+;--------------------------------------------------------------------
+; RefreshItemOrInformationWithJumpTableInCSBX
+;	Parameters:
+;		CX: 	Index of selected menuitem
+;		CS:BX:	Ptr to ITEM_TYPE_REFRESH jump table
+;	Returns:
+;		CF:		set since event processed
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.RefreshItemOrInformationWithJumpTableInCSBX:
+	cmp		cl, NO_ITEM_HIGHLIGHTED
+	je		SHORT .EventCompleted
+
+	call	RamVars_GetSegmentToDS
+	call	BootMenu_ConvertMenuitemToDriveOrFunction
+	jc		SHORT .DrawFunction
+	test	dl, 80h					; Floppy drive?
+	jz		SHORT .DrawFloppyDrive
+	jmp		[cs:bx+ITEM_TYPE_REFRESH.HardDisk]
+ALIGN JUMP_ALIGN
+.DrawFunction:
+	jmp		[cs:bx+ITEM_TYPE_REFRESH.SpecialFunction]
+ALIGN JUMP_ALIGN
+.DrawFloppyDrive:
+	jmp		[cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
+
+; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
+ALIGN WORD_ALIGN
+.rgwItemTypeRefresh:
+istruc ITEM_TYPE_REFRESH
+	at	ITEM_TYPE_REFRESH.HardDisk,			dw	BootMenuPrint_HardDiskMenuitem
+	at	ITEM_TYPE_REFRESH.FloppyDrive,		dw	BootMenuPrint_FloppyMenuitem
+	at	ITEM_TYPE_REFRESH.SpecialFunction, 	dw	BootMenuPrint_FunctionMenuitem
+iend
+.rgwInformationItemTypeRefresh:
+istruc ITEM_TYPE_REFRESH
+	at	ITEM_TYPE_REFRESH.HardDisk,			dw	BootMenuPrint_HardDiskMenuitemInformation
+	at	ITEM_TYPE_REFRESH.FloppyDrive,		dw	BootMenuPrint_FloppyMenuitemInformation
+	at	ITEM_TYPE_REFRESH.SpecialFunction, 	dw	BootMenuPrint_ClearInformationArea
+iend
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 88)
@@ -1,12 +1,480 @@
-; File name		:	BootMenuPrint.asm
-; Project name	:	IDE BIOS
-; Created date	:	26.3.2010
-; Last update	:	14.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for printing boot menu strings.
 
 ; Section containing code
 SECTION .text
+
+;--------------------------------------------------------------------
+; Prints Boot Menu title strings.
+;
+; BootMenuPrint_TitleStrings
+;	Parameters:
+;		Nothing
+;	Returns:
+;		CF:		Set since menu event handled
+;	Corrupts registers:
+;		AX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_TitleStrings:
+	mov		si, ROMVARS.szTitle
+	call	PrintNullTerminatedStringFromCSSIandSetCF
+	call	BootMenuPrint_Newline
+	mov		si, ROMVARS.szVersion
+	jmp		PrintNullTerminatedStringFromCSSIandSetCF
+
+
+;--------------------------------------------------------------------
+; BootMenuPrint_Newline
+;	Parameters:
+;		Nothing
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_Newline:
+	CALL_DISPLAY_LIBRARY PrintNewlineCharacters
+	ret
+
+
+;--------------------------------------------------------------------
+; Prints Floppy Drive hotkey string.
+;
+; BootMenuPrint_FloppyHotkeyString
+;	Parameters:
+;		BL:		Number of floppy drives in system
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, SI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_FloppyHotkeyString:
+	test	bl, bl					; Any floppy drives?
+	jz		SHORT NoFloppyDrivesOrHardDisksToPrint
+	push	bp
+
+	mov		bp, sp
+	mov		al, 'A'
+	push	ax						; 'A'
+	dec		ax
+	add		al, bl
+	push	ax						; Last floppy drive letter
+	ePUSH_T	ax, g_szFDD
+	ePUSH_T	ax, g_szHDD
+	jmp		SHORT PrintHotkeyString
+
+;--------------------------------------------------------------------
+; Prints Hard Disk hotkey string.
+;
+; BootMenuPrint_FloppyHotkeyString
+;	Parameters:
+;		BH:		Number of hard disks in system
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, SI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_HardDiskHotkeyString:
+	test	bh, bh					; Any hard disks?
+	jz		SHORT NoFloppyDrivesOrHardDisksToPrint
+	push	bp
+
+	mov		bp, sp
+	call	BootMenu_GetLetterForFirstHardDisk
+	push	cx						; First hard disk letter
+	dec		cx
+	add		cl, bh
+	push	cx						; Last hard disk letter
+	ePUSH_T	ax, g_szHDD
+	ePUSH_T	ax, g_szFDD
+	; Fall to PrintHotkeyString
+
+ALIGN JUMP_ALIGN
+PrintHotkeyString:
+	mov		si, g_szBottomScrn
+	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
+NoFloppyDrivesOrHardDisksToPrint:
+	ret
+
+;--------------------------------------------------------------------
+; BootMenuPrint_ClearScreen
+;	Parameters:
+;		Nothing
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_ClearScreen:
+	push	di
+	mov		ax, ' ' | (MONO_NORMAL<<8)
+	CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
+	pop		di
+	ret
+
+
+;--------------------------------------------------------------------
+; Translates and prints drive number.
+;
+; BootMenuPrint_TranslatedDriveNumber
+;	Parameters:
+;		DL:		Untranslated drive number
+;		DS:		RAMVARS segment
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_TranslatedDriveNumber:
+	push	dx
+	push	bx
+
+	call	DriveXlate_ToOrBack
+	eMOVZX	ax, dl		; Drive number to AL
+	CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
+	mov		al, ' '		; Print space
+	CALL_DISPLAY_LIBRARY PrintCharacterFromAL
+
+	pop		bx
+	pop		dx
+	ret
+
+
+;--------------------------------------------------------------------
+; BootMenuPrint_FloppyMenuitem
+;	Parameters:
+;		DL:		Untranslated Floppy Drive number
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DX, SI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_FloppyMenuitem:
+	push	bp
+
+	mov		bp, sp
+	mov		si, g_szFDLetter
+	ePUSH_T	ax, g_szFloppyDrv
+	add		dl, 'A'
+	push	dx					; Drive letter
+	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
+
+
+;--------------------------------------------------------------------
+; BootMenuPrint_HardDiskMenuitem
+;	Parameters:
+;		DL:		Untranslated Hard Disk number
+;		DS:		RAMVARS segment
+;	Returns:
+;		CF:		Set since menu event handled
+;	Corrupts registers:
+;		AX, BX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_HardDiskMenuitem:
+	call	FindDPT_ForDriveNumber		; DS:DI to point DPT
+	jnc		SHORT .HardDiskMenuitemForForeignDrive
+	; Fall to .HardDiskMenuitemForOurDrive
+
+;--------------------------------------------------------------------
+; .HardDiskMenuitemForOurDrive
+;	Parameters:
+;		DL:		Untranslated Hard Disk number
+;		DS:		RAMVARS segment
+;	Returns:
+;		CF:		Set since menu event handled
+;	Corrupts registers:
+;		AX, BX, SI, DI
+;--------------------------------------------------------------------
+;ALIGN JUMP_ALIGN
+.HardDiskMenuitemForOurDrive:
+	call	BootInfo_GetOffsetToBX
+	lea		si, [bx+BOOTNFO.szDrvName]
+	xor		bx, bx			; BDA segment
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
+	stc
+	ret
+
+;--------------------------------------------------------------------
+; BootMenuPrint_HardDiskMenuitemForForeignDrive
+;	Parameters:
+;		DL:		Untranslated Hard Disk number
+;		DS:		RAMVARS segment
+;	Returns:
+;		CF:		Set since menu event handled
+;	Corrupts registers:
+;		AX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.HardDiskMenuitemForForeignDrive:
+	mov		si, g_szforeignHD
+	jmp		PrintNullTerminatedStringFromCSSIandSetCF
+
+
+;--------------------------------------------------------------------
+; BootMenuPrint_FunctionMenuitem
+;	Parameters:
+;		DX:		Function ID
+;	Returns:
+;		CF:		Set if menu event was handled successfully
+;	Corrupts registers:
+;		AX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_FunctionMenuitem:
+	test	dx, dx					; ID_BOOTFUNC_ROMBOOT
+	jz		SHORT .PrintRomBootMenuitem
+	ret
+
+ALIGN JUMP_ALIGN
+.PrintRomBootMenuitem:
+	mov		si, g_szRomBoot
+	jmp		PrintNullTerminatedStringFromCSSIandSetCF
+
+
+;--------------------------------------------------------------------
+; BootMenuPrint_FloppyMenuitemInformation
+;	Parameters:
+;		DL:		Untranslated Floppy Drive number
+;		DS:		RAMVARS segment
+;	Returns:
+;		CF:		Set since menu event was handled successfully
+;	Corrupts registers:
+;		AX, BX, CX, DX, SI, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_FloppyMenuitemInformation:
+	call	BootMenuPrint_ClearInformationArea
+	call	FloppyDrive_GetType			; Get Floppy Drive type to BX
+	test	bx, bx						; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
+	jz		SHORT .PrintXTFloppyType
+	cmp		bl, FLOPPY_TYPE_35_ED
+	ja		SHORT .PrintUnknownFloppyType
+	jmp		SHORT .PrintKnownFloppyType
+
+;--------------------------------------------------------------------
+; .PrintXTFloppyType
+;	Parameters:
+;		Nothing
+;	Returns:
+;		CF:		Set since menu event was handled successfully
+;	Corrupts registers:
+;		AX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.PrintXTFloppyType:
+	push	bp
+	mov		si, g_szFddSizeOr
+	jmp		SHORT .FormatXTorUnknownTypeFloppyDrive
+
+;--------------------------------------------------------------------
+; .PrintUnknownFloppyType
+;	Parameters:
+;		Nothing
+;	Returns:
+;		CF:		Set since menu event was handled successfully
+;	Corrupts registers:
+;		AX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.PrintUnknownFloppyType:
+	push	bp
+	mov		si, g_szFddUnknown
+.FormatXTorUnknownTypeFloppyDrive:
+	mov		bp, sp
+	ePUSH_T	ax, g_szCapacity
+	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
+
+;--------------------------------------------------------------------
+; .PrintKnownFloppyType
+;	Parameters:
+;		BX:		Floppy drive type
+;	Returns:
+;		CF:		Set since menu event was handled successfully
+;	Corrupts registers:
+;		AX, BX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.PrintKnownFloppyType:
+	push	bp
+
+	mov		bp, sp
+	mov		si, g_szFddSize
+	ePUSH_T	ax, g_szCapacity
+	dec		bx						; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
+	shl		bx, 1					; Shift for WORD lookup
+	mov		ax, [cs:bx+.rgwPhysicalSize]
+	push	ax						; '5' or '3'
+	mov		al, ah
+	push	ax						; '1/4' or '1/2'
+	push	WORD [cs:bx+.rgwCapacity]
+	jmp		SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
+
+ALIGN WORD_ALIGN
+.rgwCapacity:
+	dw		360
+	dw		1200
+	dw		720
+	dw		1440
+	dw		2880
+	dw		2880
+.rgwPhysicalSize:
+	db		'5', 172	; 1, FLOPPY_TYPE_525_DD
+	db		'5', 172	; 2, FLOPPY_TYPE_525_HD
+	db		'3', 171	; 3, FLOPPY_TYPE_35_DD
+	db		'3', 171	; 4, FLOPPY_TYPE_35_HD
+	db		'3', 171	; 5, 3.5" ED on some BIOSes
+	db		'3', 171	; 6, FLOPPY_TYPE_35_ED
+
+
+;--------------------------------------------------------------------
+; Prints Hard Disk Menuitem information strings.
+;
+; BootMenuPrint_HardDiskMenuitemInformation
+;	Parameters:
+;		DL:		Untranslated Hard Disk number
+;		DS:		RAMVARS segment
+;	Returns:
+;		CF:		Set since menu event was handled successfully
+;	Corrupts registers:
+;		BX, CX, DX, SI, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_HardDiskMenuitemInformation:
+	call	FindDPT_ForDriveNumber		; DS:DI to point DPT
+	jnc		SHORT .HardDiskMenuitemInfoForForeignDrive
+	call	.HardDiskMenuitemInfoSizeForOurDrive
+	jmp		BootMenuPrintCfg_ForOurDrive
+
+;--------------------------------------------------------------------
+; .HardDiskMenuitemInfoForForeignDrive
+;	Parameters:
+;		DL:		Untranslated Hard Disk number
+;		DS:		RAMVARS segment
+;	Returns:
+;		CF:		Set since menu event was handled successfully
+;	Corrupts registers:
+;		AX, BX, CX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.HardDiskMenuitemInfoForForeignDrive:
+	push	bp
+	mov		bp, sp
+	ePUSH_T	ax, g_szCapacity
+
+	call	DriveXlate_ToOrBack
+	call	HCapacity_GetSectorCountFromForeignAH08h
+	call	ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
+
+	mov		si, g_szSizeSingle
+	jmp		SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
+
+;--------------------------------------------------------------------
+; .HardDiskMenuitemInfoSizeForOurDrive
+;	Parameters:
+;		DL:		Untranslated Hard Disk number
+;		DS:DI:	Ptr to DPT
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, DX, SI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.HardDiskMenuitemInfoSizeForOurDrive:
+	push	bp
+	mov		bp, sp
+	ePUSH_T	ax, g_szCapacity
+
+	; Get and push L-CHS size
+	call	HCapacity_GetSectorCountFromOurAH08h
+	call	ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
+
+	; Get and push total LBA size
+	call	BootInfo_GetTotalSectorCount
+	call	ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
+
+	mov		si, g_szSizeDual
+	; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
+
+
+;--------------------------------------------------------------------
+; BootMenuPrint_FormatCSSIfromParamsInSSBP
+;	Parameters:
+;		CS:SI:	Ptr to string to format
+;		SS:BP:	Ptr to format parameters
+;	Returns:
+;		BP:		Popped from stack
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_FormatCSSIfromParamsInSSBP:
+	push	di
+	CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
+	stc				; Successfull return from menu event
+	pop		di
+	pop		bp
+	ret
+
+
+;--------------------------------------------------------------------
+; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
+;	Parameters:
+;		BX:DX:AX:	Sector count
+;	Returns:
+;		Size in stack
+;	Corrupts registers:
+;		AX, BX, CX, DX, SI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
+	pop		si		; Pop return address
+	call	Size_ConvertSectorCountInBXDXAXtoKiB
+	mov		cx, BYTE_MULTIPLES.kiB
+	call	Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
+	push	ax		; Size in magnitude
+	push	cx		; Tenths
+	push	dx		; Magnitude character
+	jmp		si
+
+
+;--------------------------------------------------------------------
+; PrintNullTerminatedStringFromCSSIandSetCF
+;	Parameters:
+;		CS:SI:	Ptr to NULL terminated string to print
+;	Returns:
+;		CF:		Set since menu event was handled successfully
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+PrintNullTerminatedStringFromCSSIandSetCF:
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+	stc
+	ret
+
+
+;--------------------------------------------------------------------
+; BootMenuPrint_ClearInformationArea
+;	Parameters:
+;		Nothing
+;	Returns:
+;		CF:		Set
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrint_ClearInformationArea:
+	CALL_MENU_LIBRARY ClearInformationArea
+	stc
+	ret
+
 
 ;--------------------------------------------------------------------
@@ -70,493 +538,7 @@
 ALIGN JUMP_ALIGN
 BootMenuPrint_SetCursorPosition:
-	push	bx
-	call	MenuCrsr_SetCursor
-	pop		bx
-	ret
-
-
-;--------------------------------------------------------------------
-; Prints Floppy Drive hotkey string.
-;
-; BootMenuPrint_FloppyHotkeyString
-;	Parameters:
-;		BL:		Number of floppy drives in system
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_FloppyHotkeyString:
-	test	bl, bl					; Any floppy drives?
-	jz		.Return
-	ePUSH_T	ax, g_szHDD
-	ePUSH_T	ax, g_szFDD
-	mov		ax, 'A'-1
-	add		al, bl					; Last Floppy Drive letter
-	push	ax
-	ePUSH_T	ax, 'A'
-	jmp		SHORT BootMenuPrint_HotkeyString
-.Return:
-	ret
-
-;--------------------------------------------------------------------
-; Prints Floppy Drive or Hard Disk hotkey string when
-; parameters are pushed to stack.
-;
-; BootMenuPrint_HotkeyString
-;	Parameters:
-;		Stack:	String formatting parameters
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_HotkeyString:
-	mov		si, g_szBottomScrn
-	mov		dh, 8					; 8 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
-
-
-;--------------------------------------------------------------------
-; Prints Hard Disk hotkey string.
-;
-; BootMenuPrint_FloppyHotkeyString
-;	Parameters:
-;		BH:		Number of hard disks in system
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_HardDiskHotkeyString:
-	test	bh, bh					; Any hard disks?
-	jz		.Return
-	ePUSH_T	ax, g_szFDD
-	ePUSH_T	ax, g_szHDD
-	call	BootMenu_GetLetterForFirstHardDisk
-	eMOVZX	ax, bh					; Hard disk count to AX
-	add		ax, cx					; One past last hard disk letter
-	dec		ax						; Last hard disk letter
-	push	ax
-	push	cx
-	jmp		SHORT BootMenuPrint_HotkeyString
-.Return:
-	ret
-
-
-;--------------------------------------------------------------------
-; Clears screen.
-;
-; BootMenuPrint_ClearScreen
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_ClearScreen:
-	push	cx
-	call	MenuDraw_ClrScr
-	pop		cx
-	ret
-
-
-;--------------------------------------------------------------------
-; Translates and prints drive number.
-;
-; BootMenuPrint_TranslatedDriveNumber
-;	Parameters:
-;		DL:		Untranslated drive number
-;		DS:		RAMVARS segment
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_TranslatedDriveNumber:
-	push	dx
-	call	DriveXlate_ToOrBack
-	mov		al, dl						; Drive number to AL
-	call	Print_IntHexB
-	mov		dl, ' '
-	PRINT_CHAR							; Print space
-	pop		dx
-	ret
-
-
-;--------------------------------------------------------------------
-; Prints Floppy Drive Menuitem string.
-;
-; BootMenuPrint_FloppyMenuitem
-;	Parameters:
-;		DL:		Untranslated Floppy Drive number
-;	Returns:
-;		AX:		1 if drive number was valid
-;				0 if drive number was invalid
-;	Corrupts registers:
-;		CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_FloppyMenuitem:
-	ePUSH_T	ax, BootMenuPrint_HardDiskPrinted	; Return address
-	add		dl, 'A'				; Number to letter
-	push	dx
-	ePUSH_T	ax, g_szFloppyDrv
-	mov		si, g_szFDLetter
-	mov		dh, 4				; 4 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
-
-
-;--------------------------------------------------------------------
-; Prints Hard Disk Menuitem string.
-;
-; BootMenuPrint_HardDiskMenuitem
-;	Parameters:
-;		DL:		Untranslated Hard Disk number
-;		DS:		RAMVARS segment
-;	Returns:
-;		AX:		1 if drive number was valid
-;				0 if drive number was invalid
-;	Corrupts registers:
-;		CX, DX, SI, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_HardDiskMenuitem:
-	ePUSH_T	ax, BootMenuPrint_HardDiskPrinted
-	call	FindDPT_ForDriveNumber		; DS:DI to point DPT
-	jnc		SHORT BootMenuPrint_HardDiskMenuitemForForeignDrive
-	jmp		SHORT BootMenuPrint_HardDiskMenuitemForOurDrive
-ALIGN JUMP_ALIGN
-BootMenuPrint_HardDiskPrinted:
-	mov		ax, 1
-	ret
-
-;--------------------------------------------------------------------
-; Prints Hard Disk Menuitem string for drive that is handled by
-; some another BIOS.
-;
-; BootMenuPrint_HardDiskMenuitemForForeignDrive
-;	Parameters:
-;		DL:		Untranslated Hard Disk number
-;		DS:		RAMVARS segment
-;	Returns:
-;		AX:		1 if drive number was valid
-;				0 if drive number was invalid
-;	Corrupts registers:
-;		CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_HardDiskMenuitemForForeignDrive:
-	mov		si, g_szforeignHD
-	jmp		PrintString_FromCS
-
-;--------------------------------------------------------------------
-; Prints Hard Disk Menuitem string for drive that is handled by our BIOS.
-;
-; BootMenuPrint_HardDiskMenuitemForOurDrive
-;	Parameters:
-;		DL:		Untranslated Hard Disk number
-;		DS:		RAMVARS segment
-;	Returns:
-;		AX:		1 if drive number was valid
-;				0 if drive number was invalid
-;	Corrupts registers:
-;		CX, DX, SI, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_HardDiskMenuitemForOurDrive:
-	call	BootInfo_GetOffsetToBX
-	LOAD_BDA_SEGMENT_TO	es, ax
-	lea		si, [bx+BOOTNFO.szDrvName]
-	jmp		PrintString_FromES
-
-
-;--------------------------------------------------------------------
-; Prints Function Menuitem string.
-;
-; BootMenuPrint_FunctionMenuitem
-;	Parameters:
-;		DX:		Function ID
-;	Returns:
-;		AX:		1 if function ID was valid
-;				0 if function ID was invalid
-;	Corrupts registers:
-;		DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_FunctionMenuitem:
-	test	dx, dx					; ID_BOOTFUNC_ROMBOOT
-	jz		SHORT .PrintRomBootMenuitem
-	xor		ax, ax					; Event not processed
-	ret
-
-ALIGN JUMP_ALIGN
-.PrintRomBootMenuitem:
-	mov		si, g_szRomBoot
-	; Fall to .PrintAndReturn
-
-ALIGN JUMP_ALIGN
-.PrintAndReturn:
-	call	PrintString_FromCS
-	mov		ax, 1					; Event processed
-	ret
-
-
-;--------------------------------------------------------------------
-; Prints Floppy Drive Menuitem information strings.
-;
-; BootMenuPrint_FloppyMenuitemInformation
-;	Parameters:
-;		DL:		Untranslated Floppy Drive number
-;		DS:		RAMVARS segment
-;	Returns:
-;		AX:		1 if drive number was valid
-;				0 if drive number was invalid
-;	Corrupts registers:
-;		BX, CX, DX, SI, DI, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_FloppyMenuitemInformation:
-	call	FloppyDrive_GetType						; Get Floppy Drive type to BX
-	ePUSH_T	ax, BootMenuPrint_ClearThreeInfoLines	; New return address
-	test	bx, bx									; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
-	jz		SHORT BootMenuPrint_PrintXTFloppyType
-	cmp		bl, FLOPPY_TYPE_35_ED
-	ja		SHORT BootMenuPrint_PrintUnknownFloppyType
-	jmp		SHORT BootMenuPrint_PrintKnownFloppyType
-
-;--------------------------------------------------------------------
-; Prints Menuitem information string for two possible XT floppy drives.
-;
-; BootMenuPrint_PrintXTFloppyType
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_PrintXTFloppyType:
-	mov		si, g_szFddSizeOr
-	jmp		SHORT BootMenuPrint_FormatUnknownFloppyType
-
-;--------------------------------------------------------------------
-; Prints Menuitem information string for unknown floppy drive type.
-;
-; BootMenuPrint_PrintUnknownFloppyType
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_PrintUnknownFloppyType:
-	mov		si, g_szFddUnknown
-BootMenuPrint_FormatUnknownFloppyType:
-	ePUSH_T	ax, g_szCapacity
-	mov		dh, 2					; 2 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
-
-;--------------------------------------------------------------------
-; Prints Menuitem information string for known floppy drive type.
-;
-; BootMenuPrint_PrintKnownFloppyType
-;	Parameters:
-;		BX:		Floppy drive type
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_PrintKnownFloppyType:
-	dec		bx						; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
-	shl		bx, 1					; Shift for WORD lookup
-	push	WORD [cs:bx+.rgwCapacity]
-	mov		ax, [cs:bx+.rgwPhysicalSize]
-	push	ax						; '1/4' or '1/2'
-	mov		al, ah
-	push	ax						; '5' or '3'
-	ePUSH_T	ax, g_szCapacity
-	mov		si, g_szFddSize
-	mov		dh, 8					; 8 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
-ALIGN WORD_ALIGN
-.rgwCapacity:
-	dw		360
-	dw		1200
-	dw		720
-	dw		1440
-	dw		2880
-	dw		2880
-.rgwPhysicalSize:
-	db		172, '5'	; 1, FLOPPY_TYPE_525_DD
-	db		172, '5'	; 2, FLOPPY_TYPE_525_HD
-	db		171, '3'	; 3, FLOPPY_TYPE_35_DD
-	db		171, '3'	; 4, FLOPPY_TYPE_35_HD
-	db		171, '3'	; 5, 3.5" ED on some BIOSes
-	db		171, '3'	; 6, FLOPPY_TYPE_35_ED
-
-
-;--------------------------------------------------------------------
-; Clears remaining characters from current information line
-; and clears following lines.
-;
-; BootMenuPrint_ClearThreeInfoLines
-; BootMenuPrint_ClearTwoInfoLines
-; BootMenuPrint_ClearOneInfoLine
-;	Parameters:
-;		Nothing
-;	Returns:
-;		AX:		1
-;	Corrupts registers:
-;		BX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_ClearThreeInfoLines:
-	call	MenuDraw_NewlineStrClrLn
-ALIGN JUMP_ALIGN
-BootMenuPrint_ClearTwoInfoLines:
-	call	MenuDraw_NewlineStrClrLn
-ALIGN JUMP_ALIGN
-BootMenuPrint_ClearOneInfoLine:
-	call	MenuDraw_NewlineStrClrLn
-	mov		ax, 1
-	ret
-
-
-;--------------------------------------------------------------------
-; Prints Hard Disk Menuitem information strings.
-;
-; BootMenuPrint_HardDiskMenuitemInformation
-;	Parameters:
-;		DL:		Untranslated Hard Disk number
-;		DS:		RAMVARS segment
-;	Returns:
-;		AX:		1 if drive number was valid
-;				0 if drive number was invalid
-;	Corrupts registers:
-;		BX, CX, DX, SI, DI, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_HardDiskMenuitemInformation:
-	ePUSH_T	ax, BootMenuPrint_HardDiskPrinted
-	call	FindDPT_ForDriveNumber		; DS:DI to point DPT
-	jnc		SHORT BootMenuPrint_HardDiskMenuitemInfoForForeignDrive
-	call	BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive
-	jmp		BootMenuPrintCfg_ForOurDrive
-
-;--------------------------------------------------------------------
-; Prints Hard Disk Menuitem information strings for drive that
-; is handled by some other BIOS.
-;
-; BootMenuPrint_HardDiskMenuitemInfoForForeignDrive
-;	Parameters:
-;		DL:		Untranslated Hard Disk number
-;		DS:		RAMVARS segment
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX, CX, DX, SI, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_HardDiskMenuitemInfoForForeignDrive:
-	call	DriveXlate_ToOrBack
-	call	HCapacity_GetSectorCountFromForeignAH08h
-	call	HCapacity_ConvertSectorCountToSize
-	ePUSH_T	dx, BootMenuPrint_ClearThreeInfoLines	; Return address
-	push	cx							; Magnitude character
-	push	si							; Tenths
-	push	ax							; Size in magnitude
-	ePUSH_T	ax, g_szCapacity			; "Capacity"
-	mov		si, g_szSizeSingle
-	mov		dh, 8						; 8 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
-
-;--------------------------------------------------------------------
-; Prints Hard Disk Menuitem information size string for drive that
-; is handled by our BIOS.
-;
-; BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive
-;	Parameters:
-;		DL:		Untranslated Hard Disk number
-;		DS:DI:	Ptr to DPT
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX, CX, DX, SI, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_HardDiskMenuitemInfoSizeForOurDrive:
-	ePUSH_T	ax, BootMenuPrint_ClearOneInfoLine	; Return address
-
-	; Get and push total LBA size
-	call	BootInfo_GetTotalSectorCount
-	call	HCapacity_ConvertSectorCountToSize
-	push	cx								; Magnitude character
-	push	si								; Tenths
-	push	ax								; Size in magnitude
-
-	; Get and push L-CHS size
-	mov		dl, [di+DPT.bDrvNum]			; Restore drive number
-	call	HCapacity_GetSectorCountFromOurAH08h
-	call	HCapacity_ConvertSectorCountToSize
-	push	cx								; Magnitude character
-	push	si								; Tenths
-	push	ax								; Size in magnitude
-
-	ePUSH_T	ax, g_szCapacity				; "Capacity"
-	mov		si, g_szSizeDual
-	mov		dh, 14							; 14 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
-
-
-;--------------------------------------------------------------------
-; Prints Function Menuitem information strings.
-;
-; BootMenuPrint_HardDiskMenuitemInformation
-;	Parameters:
-;		DX:		Function ID
-;		DS:		RAMVARS segment
-;	Returns:
-;		AX:		1 if function ID was valid
-;				0 if function ID was valid
-;	Corrupts registers:
-;		BX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_FunctionMenuitemInformation:
-	jmp		SHORT BootMenuPrint_ClearThreeInfoLines
-
-
-;--------------------------------------------------------------------
-; Prints Boot Menu title strings.
-;
-; BootMenuPrint_TitleStrings
-;	Parameters:
-;		Nothing
-;	Returns:
-;		AX:		Was printing successfull
-;	Corrupts registers:
-;		BX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrint_TitleStrings:
-	mov		si, ROMVARS.szTitle
-	call	PrintString_FromCS
-	call	BootMenuPrint_ClearOneInfoLine
-	mov		si, ROMVARS.szVersion
-	call	PrintString_FromCS
-	call	BootMenuPrint_ClearOneInfoLine
-	mov		si, g_szTitleLn3
-	call	PrintString_FromCS
-	jmp		SHORT BootMenuPrint_ClearOneInfoLine
+	push	di
+	mov		ax, dx
+	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
+	pop		di
+	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	BootMenuPrintCfg.asm
-; Project name	:	IDE BIOS
-; Created date	:	28.3.2010
-; Last update	:	9.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for printing drive configuration
 ;					information on Boot Menu.
@@ -20,5 +16,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, CX, DX, SI, ES
+;		AX, BX, CX, DX, SI, DI, ES
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -27,5 +23,5 @@
 	call	BootMenuPrintCfg_GetPointers
 	call	BootMenuPrintCfg_PushAndFormatCfgString
-	jmp		BootMenuPrint_ClearOneInfoLine
+	jmp		BootMenuPrint_Newline
 
 
@@ -39,11 +35,11 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, DX
+;		AX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 BootMenuPrintCfg_HeaderAndChangeLine:
 	mov		si, g_szCfgHeader
-	call	PrintString_FromCS
-	jmp		BootMenuPrint_ClearOneInfoLine
+	call	PrintNullTerminatedStringFromCSSIandSetCF
+	jmp		BootMenuPrint_Newline
 
 
@@ -83,12 +79,42 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, DX, SI
+;		AX, DX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 BootMenuPrintCfg_PushAndFormatCfgString:
+	push	bp
+
+	mov		bp, sp
 	; Fall to first push below
 
 ;--------------------------------------------------------------------
-; BootMenuPrintCfg_PushResetStatus
+; PushAddressingMode
+;	Parameters:
+;		DS:DI:	Ptr to DPT
+;		ES:BX:	Ptr to BOOTNFO
+;		CS:SI:	Ptr to IDEVARS
+;	Returns:
+;		Nothing (jumps to next push below)
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+PushAddressingMode:
+	mov		dx, bx				; Backup BX to DX
+	mov		bx, MASK_DPT_ADDR	; Load addressing mode mask
+	and		bl, [di+DPT.bFlags]	; Addressing mode now in BX
+	push	WORD [cs:bx+.rgszAddressingModeString]
+	mov		bx, dx
+	jmp		SHORT .NextPush
+ALIGN WORD_ALIGN
+.rgszAddressingModeString:
+	dw		g_szLCHS
+	dw		g_szPCHS
+	dw		g_szLBA28
+	dw		g_szLBA48
+ALIGN JUMP_ALIGN
+.NextPush:
+
+;--------------------------------------------------------------------
+; PushBlockMode
 ;	Parameters:
 ;		DS:DI:	Ptr to DPT
@@ -100,59 +126,26 @@
 ;		AX
 ;--------------------------------------------------------------------
-BootMenuPrintCfg_PushResetStatus:
-	eMOVZX	ax, BYTE [di+DPT.bReset]
+PushBlockMode:
+	eMOVZX	ax, BYTE [di+DPT.bSetBlock]
 	push	ax
 
 ;--------------------------------------------------------------------
-; BootMenuPrintCfg_PushIRQ
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;		ES:BX:	Ptr to BOOTNFO
-;		CS:SI:	Ptr to IDEVARS
-;	Returns:
-;		Nothing (falls to next push below)
+; PushBusType
+;	Parameters:
+;		DS:DI:	Ptr to DPT
+;		ES:BX:	Ptr to BOOTNFO
+;		CS:SI:	Ptr to IDEVARS
+;	Returns:
+;		Nothing (jumps to next push below)
 ;	Corrupts registers:
 ;		AX, DX
 ;--------------------------------------------------------------------
-BootMenuPrintCfg_PushIRQ:
-	mov		dl, ' '						; Load space to DL
-	mov		al, [cs:si+IDEVARS.bIRQ]
-	test	al, al						; Interrupts disabled?
-	jz		SHORT .PushIrqDisabled
-	add		al, '0'						; Digit to ASCII
-	cmp		al, '9'						; Only one digit needed?
-	jbe		SHORT .PushCharacters
-
-	; Two digits needed
-	sub		al, 10						; Limit to single digit ASCII
-	mov		dl, '1'						; Load '1 to DX
-	jmp		SHORT .PushCharacters
-ALIGN JUMP_ALIGN
-.PushIrqDisabled:
-	mov		al, '-'						; Load line to AL
-	xchg	ax, dx						; Space to AL, line to DL
-ALIGN JUMP_ALIGN
-.PushCharacters:
-	push	ax
-	push	dx
-
-;--------------------------------------------------------------------
-; BootMenuPrintCfg_PushBusType
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;		ES:BX:	Ptr to BOOTNFO
-;		CS:SI:	Ptr to IDEVARS
-;	Returns:
-;		Nothing (jumps to next push below)
-;	Corrupts registers:
-;		AX, DX
-;--------------------------------------------------------------------
-BootMenuPrintCfg_PushBusType:
+PushBusType:
 	xchg	ax, bx		; Store BX to AX
 	eMOVZX	bx, BYTE [cs:si+IDEVARS.bBusType]
 	mov		bx, [cs:bx+.rgwBusTypeValues]	; Char to BL, Int to BH	
 	eMOVZX	dx, bh
+	push	bx			; Push character
 	push	dx			; Push 8, 16 or 32
-	push	bx			; Push character
 	xchg	bx, ax		; Restore BX
 	jmp		SHORT .NextPush
@@ -167,5 +160,5 @@
 
 ;--------------------------------------------------------------------
-; BootMenuPrintCfg_PushBlockMode
+; PushIRQ
 ;	Parameters:
 ;		DS:DI:	Ptr to DPT
@@ -175,38 +168,44 @@
 ;		Nothing (falls to next push below)
 ;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+PushIRQ:
+	mov		dl, ' '						; Load space to DL
+	mov		al, [cs:si+IDEVARS.bIRQ]
+	test	al, al						; Interrupts disabled?
+	jz		SHORT .PushIrqDisabled
+	add		al, '0'						; Digit to ASCII
+	cmp		al, '9'						; Only one digit needed?
+	jbe		SHORT .PushCharacters
+
+	; Two digits needed
+	sub		al, 10						; Limit to single digit ASCII
+	mov		dl, '1'						; Load '1 to DX
+	jmp		SHORT .PushCharacters
+ALIGN JUMP_ALIGN
+.PushIrqDisabled:
+	mov		al, '-'						; Load line to AL
+	xchg	ax, dx						; Space to AL, line to DL
+ALIGN JUMP_ALIGN
+.PushCharacters:
+	push	dx
+	push	ax
+
+;--------------------------------------------------------------------
+; PushResetStatus
+;	Parameters:
+;		DS:DI:	Ptr to DPT
+;		ES:BX:	Ptr to BOOTNFO
+;		CS:SI:	Ptr to IDEVARS
+;	Returns:
+;		Nothing (falls to next push below)
+;	Corrupts registers:
 ;		AX
 ;--------------------------------------------------------------------
-BootMenuPrintCfg_PushBlockMode:
-	eMOVZX	ax, BYTE [di+DPT.bSetBlock]
+PushResetStatus:
+	eMOVZX	ax, BYTE [di+DPT.bReset]
 	push	ax
 
 ;--------------------------------------------------------------------
-; BootMenuPrintCfg_PushAddressingMode
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;		ES:BX:	Ptr to BOOTNFO
-;		CS:SI:	Ptr to IDEVARS
-;	Returns:
-;		Nothing (jumps to next push below)
-;	Corrupts registers:
-;		AX, DX
-;--------------------------------------------------------------------
-BootMenuPrintCfg_PushAddressingMode:
-	mov		dx, bx				; Backup BX to DX
-	mov		bx, MASK_DPT_ADDR	; Load addressing mode mask
-	and		bl, [di+DPT.bFlags]	; Addressing mode now in BX
-	push	WORD [cs:bx+.rgszAddressingModeString]
-	mov		bx, dx
-	jmp		SHORT .NextPush
-ALIGN WORD_ALIGN
-.rgszAddressingModeString:
-	dw	g_szLCHS
-	dw	g_szPCHS
-	dw	g_szLBA28
-	dw	g_szLBA48
-ALIGN JUMP_ALIGN
-.NextPush:
-
-;--------------------------------------------------------------------
 ; Prints formatted configuration string from parameters pushed to stack.
 ;
@@ -217,8 +216,7 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, DX, SI
+;		AX, SI, DI
 ;--------------------------------------------------------------------
 BootMenuPrintCfg_ValuesFromStack:
 	mov		si, g_szCfgFormat
-	mov		dh, 14						; 14 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
+	jmp		PrintNullTerminatedStringFromCSSIandSetCF
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootPrint.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootPrint.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootPrint.asm	(revision 88)
@@ -1,3 +1,3 @@
-; Project name	:	IDE BIOS
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for printing boot related strings.
 
@@ -6,6 +6,4 @@
 
 ;--------------------------------------------------------------------
-; Prints trying to boot string.
-;
 ; BootPrint_TryToBootFromDL
 ;	Parameters:
@@ -15,36 +13,26 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, SI, DI
+;		AX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 BootPrint_TryToBootFromDL:
-	push	dx
-	ePUSH_T	ax, BootPrint_PopDxAndReturn	; Return address
+	push	bp
+	mov		bp, sp
 
-	xor		dh, dh				; Translated drive number to DX
-	push	dx					; Push translated drive number
+	mov		ax, g_szHardDrv
+	test	dl, 80h
+	eCMOVZ	ax, g_szFloppyDrv
+	push	ax					; "Hard Drive" or "Floppy Drive"
+
 	call	DriveXlate_ToOrBack
 	push	dx					; Push untranslated drive number
-
-	mov		ax, g_szFloppyDrv	; Assume "Floppy Drive"
-	test	dl, 80h				; Hard Disk?
-	jz		SHORT .PushHardOrFloppy
-	add		ax, BYTE g_szHardDrv - g_szFloppyDrv
-.PushHardOrFloppy:
-	push	ax
+	call	DriveXlate_ToOrBack
+	push	dx					; Push translated drive number
 
 	mov		si, g_szTryToBoot
-	mov		dh, 6				; 6 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
-
-ALIGN JUMP_ALIGN
-BootPrint_PopDxAndReturn:
-	pop		dx
-	ret
+	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
 
 
 ;--------------------------------------------------------------------
-; Prints message that valid boot sector has been found.
-;
 ; BootPrint_BootSectorLoaded
 ;	Parameters:
@@ -53,18 +41,15 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, SI
+;		AX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 BootPrint_BootSectorLoaded:
-	push	dx
-	ePUSH_T	ax, BootPrint_PopDxAndReturn	; Return address
-
+	push	bp
+	mov		bp, sp
+	ePUSH_T	ax, g_szBootSector
 	ePUSH_T	ax, g_szFound
-	jmp		SHORT BootPrint_MsgCodeShared
-
+	jmp		SHORT PrintBootSectorResult
 
 ;--------------------------------------------------------------------
-; Prints message that first sector is not boot sector.
-;
 ; BootPrint_FirstSectorNotBootable
 ;	Parameters:
@@ -73,19 +58,18 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, DX, SI
+;		AX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 BootPrint_FirstSectorNotBootable:
+	push	bp
+	mov		bp, sp
+	ePUSH_T	ax, g_szBootSector
 	ePUSH_T	ax, g_szNotFound
-BootPrint_MsgCodeShared:
-	ePUSH_T	ax, g_szBootSector
+PrintBootSectorResult:
 	mov		si, g_szSectRead
-	mov		dh, 4				; 4 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
+	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
 
 
 ;--------------------------------------------------------------------
-; Prints error code for failed first sector read attempt.
-;
 ; BootPrint_FailedToLoadFirstSector
 ;	Parameters:
@@ -94,11 +78,12 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, DX, SI
+;		AX, CX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 BootPrint_FailedToLoadFirstSector:
+	push	bp
+	mov		bp, sp
 	eMOVZX	cx, ah				; Error code to CX
 	push	cx					; Push INT 13h error code
 	mov		si, g_szReadError
-	mov		dh, 2				; 2 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
+	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	AH25h_HDrvID.asm
-; Project name	:	IDE BIOS
-; Created date	:	24.10.2009
-; Last update	:	14.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=25h, Get Drive Information.
 
@@ -91,5 +87,4 @@
 	mov		al, HCMD_ID_DEV				; Load Identify Device command to AL
 	out		dx, al						; Output command
-	call	SoftDelay_BeforePollingStatusRegister
 	call	HStatus_WaitDrqDefTime		; Wait until ready to transfer (no IRQ!)
 	jc		SHORT .Return				; Return if error
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 88)
@@ -1,8 +1,3 @@
-; File name		:	AHDh_HReset.asm
-; Project name	:	IDE BIOS
-; Created date	:	9.12.2007
-; Last update	:	14.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
 
@@ -94,12 +89,12 @@
 	or		al, FLG_IDE_CTRL_SRST		; Set Reset bit
 	call	HDrvSel_OutputDeviceControlByte
-	mov		cx, 5						; Delay at least 5us
-	call	SoftDelay_us
+	mov		ax, 5						; Delay at least 5us
+	call	Delay_MicrosecondsFromAX
 
 	; HSR1: Clear_wait
-	and		al, ~FLG_IDE_CTRL_SRST		; Clear Reset bit
+	mov		al, [di+DPT.bDrvCtrl]		; Load value for ACR
 	out		dx, al						; End Reset
-	mov		cx, 2000					; Delay at least 2ms
-	call	SoftDelay_us
+	mov		ax, 2000					; Delay at least 2ms
+	call	Delay_MicrosecondsFromAX
 
 	; HSR2: Check_status
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCapacity.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCapacity.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCapacity.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	HCapacity.asm
-; Project name	:	IDE BIOS
-; Created date	:	16.3.2010
-; Last update	:	3.8.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for hard disk capacity calculations.
 
@@ -47,121 +43,2 @@
 	xor		bx, bx			; Zero BX for 48-bit sector count
 	ret
-
-
-;--------------------------------------------------------------------
-; Converts sector count to hard disk size.
-;
-; HCapacity_ConvertSectorCountToSize:
-;	Parameters:
-;		BX:DX:AX:	Total sector count
-;	Returns:
-;		AX:			Size in magnitude
-;		SI:			Tenths
-;		CX:			Magnitude character:
-;						'k' = *1024   B = kiB
-;						'M' = *1024 kiB = MiB
-;						'G' = *1024 MiB = GiB
-;						'T' = *1024 GiB = TiB
-;						'P' = *1024 TiB = PiB
-;	Corrupts registers:
-;		BX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-HCapacity_ConvertSectorCountToSize:
-	call	HCapacity_ConvertSectorCountToKiB
-	mov		cx, 1					; Magnitude is 1 for kiB
-ALIGN JUMP_ALIGN
-.MagnitudeLoop:
-	test	bx, bx					; Bits 32...47 in use?
-	jnz		SHORT .ShiftByMagnitude	;  If so, jump to shift
-	test	dx, dx					; Bits 16...31 in use?
-	jnz		SHORT .ShiftByMagnitude	;  If so, jump to shift
-	cmp		ax, 10000				; 5 digits needed?
-	jb		SHORT .ShiftComplete	;  If less, all done
-ALIGN JUMP_ALIGN
-.ShiftByMagnitude:
-	call	HCapacity_ShiftForNextMagnitude
-	jmp		SHORT .MagnitudeLoop
-ALIGN JUMP_ALIGN
-.ShiftComplete:
-	mov		bx, cx					; Copy shift count to BX
-	mov		cl, [cs:bx+.rgbMagnitudeToChar]
-	jmp		SHORT HCapacity_ConvertSizeRemainderToTenths
-ALIGN WORD_ALIGN
-.rgbMagnitudeToChar:	db	" kMGTP"
-
-;--------------------------------------------------------------------
-; Converts 48-bit sector count to size in kiB.
-;
-; HCapacity_ConvertSectorCountToKiB:
-;	Parameters:
-;		BX:DX:AX:	Total sector count
-;	Returns:
-;		BX:DX:AX:	Total size in kiB
-;		CF:			Remainder from division
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-HCapacity_ConvertSectorCountToKiB:
-HCapacity_DivideSizeByTwo:
-	shr		bx, 1					; Divide sector count by 2...
-	rcr		dx, 1					; ...to get disk size in...
-	rcr		ax, 1					; ...kiB
-	ret
-
-;--------------------------------------------------------------------
-; Divides size by 1024 and increments magnitude.
-;
-; HCapacity_ShiftForNextMagnitude:
-;	Parameters:
-;		BX:DX:AX:	Size in magnitude
-;		CX:			Magnitude (0=B, 1=kiB, 2=MiB...)
-;	Returns:
-;		BX:DX:AX:	Size in magnitude
-;		SI:			Remainder (0...1023)
-;		CX:			Magnitude (1=kiB, 2=MiB...)
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-HCapacity_ShiftForNextMagnitude:
-	push	cx
-	xor		si, si					; Zero remainder
-	mov		cl, 10					; Divide by 1024
-ALIGN JUMP_ALIGN
-.ShiftLoop:
-	call	HCapacity_DivideSizeByTwo
-	rcr		si, 1					; Update remainder
-	loop	.ShiftLoop
-	eSHR_IM	si, 6					; Remainder to SI beginning
-	pop		cx
-	inc		cx						; Increment shift count
-	ret
-
-;--------------------------------------------------------------------
-; Converts remainder from HCapacity_ShiftForNextMagnitude to tenths.
-;
-; HCapacity_ConvertSizeRemainderToTenths:
-;	Parameters:
-;		BX:DX:AX:	Size in magnitude
-;		SI:			Remainder from last magnitude division (0...1023)
-;	Returns:
-;		BX:DX:AX:	Size in magnitude
-;		SI:			Tenths
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-HCapacity_ConvertSizeRemainderToTenths:
-	push	dx
-	push	ax
-
-	mov		ax, 10
-	mul		si					; DX:AX = remainder * 10
-	eSHR_IM	ax, 10				; Divide AX by 1024
-	xchg	si, ax				; SI = tenths
-
-	pop		ax
-	pop		dx
-	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCommand.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCommand.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCommand.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	HCommand.asm
-; Project name	:	IDE BIOS
-; Created date	:	28.3.2010
-; Last update	:	16.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for outputting IDE commands and parameters.
 
@@ -113,3 +109,3 @@
 	out		dx, al
 	mov		al, ah						; Restore sector count to AL
-	jmp		SoftDelay_BeforePollingStatusRegister
+	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HDrvSel.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HDrvSel.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HDrvSel.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	HDrvSel.asm
-; Project name	:	IDE BIOS
-; Created date	:	25.2.2010
-; Last update	:	13.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for selecting Master or Slave drive.
 
@@ -60,5 +56,4 @@
 
 	; Wait until drive is ready to accept commands
-	call	SoftDelay_BeforePollingStatusRegister
 	call	HStatus_WaitRdyDefTime
 	pop		cx
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	HStatus.asm
-; Project name	:	IDE BIOS
-; Created date	:	15.12.2009
-; Last update	:	23.8.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	IDE Status Register polling functions.
 
@@ -176,5 +172,5 @@
 ALIGN JUMP_ALIGN
 HStatus_PollBsyAndFlg:
-	call	SoftDelay_InitTimeout				; Initialize timeout counter
+	call	InitializeTimeoutWithTicksInCL		; Initialize timeout counter
 	in		al, dx								; Discard contents for first read
 												; (should read Alternate Status Register)
@@ -188,5 +184,5 @@
 ALIGN JUMP_ALIGN
 .UpdateTimeout:
-	call	SoftDelay_UpdTimeout				; Update timeout counter
+	call	SetCFifTimeout
 	jnc		SHORT .PollLoop						; Loop if time left (sets CF on timeout)
 	jmp		HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit
@@ -210,5 +206,5 @@
 ALIGN JUMP_ALIGN
 HStatus_PollBsy:
-	call	SoftDelay_InitTimeout				; Initialize timeout counter
+	call	InitializeTimeoutWithTicksInCL		; Initialize timeout counter
 	in		al, dx								; Discard contents for first read
 												; (should read Alternate Status Register)
@@ -218,7 +214,52 @@
 	test	al, FLG_IDE_ST_BSY					; Controller busy?
 	jz		SHORT GetErrorCodeFromPollingToAH	;  If not, jump to check errors
-	call	SoftDelay_UpdTimeout				; Update timeout counter
+	call	SetCFifTimeout						; Update timeout counter
 	jnc		SHORT .PollLoop						; Loop if time left (sets CF on timeout)
 ALIGN JUMP_ALIGN
 GetErrorCodeFromPollingToAH:
 	jmp		HError_ProcessErrorsAfterPollingBSY
+
+
+;--------------------------------------------------------------------
+; InitializeTimeoutWithTicksInCL
+;	Parameters:
+;		CL:		Timeout value in system timer ticks
+;		DS:		Segment to RAMVARS
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		CX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+InitializeTimeoutWithTicksInCL:
+	push	bx
+	xchg	cx, ax
+
+	xor		ah, ah		; Timeout ticks now in AX
+	mov		bx, RAMVARS.wTimeoutCounter
+	call	TimerTicks_InitializeTimeoutFromAX
+
+	xchg	ax, cx		; Restore AX
+	pop		bx
+	ret
+
+;--------------------------------------------------------------------
+; SetCFifTimeout
+;	Parameters:
+;		DS:		Segment to RAMVARS
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		CX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+SetCFifTimeout:
+	push	bx
+	xchg	cx, ax
+
+	mov		bx, RAMVARS.wTimeoutCounter
+	call	TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
+
+	xchg	ax, cx		; Restore AX
+	pop		bx
+	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int18h.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int18h.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int18h.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	Int18h.asm
-; Project name	:	IDE BIOS
-; Created date	:	6.1.2010
-; Last update	:	25.3.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 18h BIOS functions (ROM boot and Boot error).
 
@@ -24,4 +20,4 @@
 Int18h_BootError:
 	mov		si, g_sz18hCallback
-	call	PrintString_FromCS		; No need to clean stack
+	call	PrintNullTerminatedStringFromCSSIandSetCF
 	jmp		Int19hMenu_Display		; Return to boot menu
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 88)
@@ -1,3 +1,3 @@
-; Project name	:	IDE BIOS
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for printing drive detection strings.
 
@@ -14,12 +14,15 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, DX, SI
+;		AX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 DetectPrint_RomFoundAtSegment:
-	push	cs
-	ePUSH_T	ax, ROMVARS.szTitle
+	push	bp
+
 	mov		si, g_szRomAt
-	jmp		SHORT DetectPrint_4BytesPushedToStack
+	mov		bp, sp
+	ePUSH_T	ax, ROMVARS.szTitle			; Bios title string
+	push	cs							; BIOS segment
+	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
 
 
@@ -34,5 +37,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, DX, SI
+;		AX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -50,19 +53,21 @@
 ; DetectPrint_StartingDriveDetect
 ;	Parameters:
-;		AX:		Offset to "Master" or "Slave" string
+;		CS:AX:	Ptr to "Master" or "Slave" string
 ;		CS:BP:	Ptr to IDEVARS
 ;	Returns:
 ;		Nothing
 ;	Corrupts registers:
-;		AX, CX, DX, SI
+;		AX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 DetectPrint_StartingDriveDetect:
-	push	WORD [cs:bp+IDEVARS.wPort]
-	push	ax
+	push	bp
+
+	mov		si, [cs:bp+IDEVARS.wPort]
+	mov		bp, sp
+	push	ax							; Push "Master" or "Slave"
+	push	si							; Push port number
 	mov		si, g_szDetect
-DetectPrint_4BytesPushedToStack:
-	mov		dh, 4						; 4 bytes pushed to stack
-	jmp		PrintString_JumpToFormat
+	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
 
 
@@ -79,14 +84,25 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, DX, SI
+;		AX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 DetectPrint_DriveNameOrNotFound:
+	push	di
 	jc		SHORT .PrintDriveNotFound
+	push	bx
+
 	lea		si, [bx+BOOTNFO.szDrvName]
-	call	PrintString_FromES
-	jmp		Print_Newline
+	mov		bx, es
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
+	CALL_DISPLAY_LIBRARY PrintNewlineCharacters
+
+	pop		bx
+	pop		di
+	ret
+
 ALIGN JUMP_ALIGN
 .PrintDriveNotFound:
 	mov		si, g_szNotFound
-	jmp		PrintString_FromCS
+	call	PrintNullTerminatedStringFromCSSIandSetCF
+	pop		di
+	ret
Index: unk/XTIDE_Universal_BIOS/Src/Initialization/PrintString.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/PrintString.asm	(revision 87)
+++ 	(revision )
@@ -1,67 +1,0 @@
-; Project name	:	IDE BIOS
-; Description	:	Functions for printing strings used in this IDE BIOS.
-
-; Section containing code
-SECTION .text
-
-;--------------------------------------------------------------------
-; Prints string with formatting parameters.
-; Do not call PrintString_JumpToFormat!!! Jump there only!
-;
-; PrintString_JumpToFormat
-;	Parameters:
-;		DH:		Number of bytes pushed to stack
-;		CS:SI:	Ptr to string to format
-;		Stack:	Parameters for formatting placeholders.
-;				Parameter for first placeholder must be pushed last
-;				(to top of stack).
-;				High word must be pushed first for 32-bit parameters.
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, CX, DX, SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-PrintString_JumpToFormat:
-	mov		cx, ds				; Backup DS
-	push	cs					; Push string segment...
-	pop		ds					; ...and pop it to DS
-	mov		dl, ' '				; Min length character
-	call	Print_Format
-	mov		ds, cx				; Restore DS
-	eMOVZX	ax, dh				; Bytes in stack
-	add		sp, ax				; Clean stack
-	ret
-
-
-;--------------------------------------------------------------------
-; Prints STOP terminated string from wanted segment.
-;
-; PrintString_FromCS
-; PrintString_FromES
-; PrintString_FromDS
-;	Parameters:
-;		SI:		Offset to string to print
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-PrintString_FromCS:
-	push	ds
-	push	cs					; Push string segment here...
-	SKIP2B	ax					; mov ax, <next 2 bytes/instructions>
-PrintString_FromES:
-	push	ds
-	push	es					; ...or here...
-	pop		ds					; ...and pop it to DS
-	call	PrintString_FromDS
-	pop		ds
-	ret
-
-ALIGN JUMP_ALIGN
-PrintString_FromDS:
-	mov		dx, si				; DS:DX now points to string
-	PRINT_STR_LEN
-	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 88)
@@ -13,6 +13,6 @@
 
 ; Included .inc files
-%include "emulate.inc"			; Must be included first!
-%include "macros.inc"			; For generic macros
+%include "AssemblyLibrary.inc"	; Assembly Library. Must be included first!
+%include "macros.inc"			; General purpose macros
 %include "BiosData.inc"			; For BIOS Data area equates
 %include "Interrupts.inc"		; For interrupt equates
@@ -38,16 +38,16 @@
 	at	ROMVARS.bRomSize,	db	CNT_ROM_BLOCKS	; ROM size in 512B blocks
 	at	ROMVARS.rgbJump, 	jmp	Initialize_FromMainBiosRomSearch
-	at	ROMVARS.rgbDate,	db	"11/28/10"		; Build data (mm/dd/yy)
-	at	ROMVARS.rgbSign,	db	"XTIDE110"		; Signature for flash program
+	at	ROMVARS.rgbDate,	db	"01/27/11"		; Build data (mm/dd/yy)
+	at	ROMVARS.rgbSign,	db	"XTIDE120"		; Signature for flash program
 	at	ROMVARS.szTitle
 		db	"-=XTIDE Universal BIOS"
 %ifdef USE_AT
-		db	" (AT)=-",STOP
+		db	" (AT)=-",NULL
 %elifdef USE_186
-		db	" (XT+)=-",STOP
+		db	" (XT+)=-",NULL
 %else
-		db	" (XT)=-",STOP
+		db	" (XT)=-",NULL
 %endif
-	at	ROMVARS.szVersion,	db	"v1.1.5 (11/28/10)",STOP
+	at	ROMVARS.szVersion,	db	"v1.2.0_wip (01/27/11)",NULL
 
 ;---------------------------;
@@ -58,5 +58,4 @@
 	at	ROMVARS.bIdeCnt,		db	3						; Number of supported controllers
 	at	ROMVARS.bBootDrv,		db	80h						; Boot Menu default drive
-	at	ROMVARS.bBootMnuH,		db	20						; Boot Menu maximum height
 	at	ROMVARS.bBootDelay,		db	30						; Boot Menu selection delay (secs)
 	at	ROMVARS.bBootLdrType,	db	BOOTLOADER_TYPE_MENU	; Boot loader type
@@ -91,5 +90,4 @@
 	at	ROMVARS.bIdeCnt,		db	1						; Number of supported controllers
 	at	ROMVARS.bBootDrv,		db	80h						; Boot Menu default drive
-	at	ROMVARS.bBootMnuH,		db	20						; Boot Menu maximum height
 	at	ROMVARS.bBootDelay,		db	30						; Boot Menu selection delay (secs)
 	at	ROMVARS.bBootLdrType,	db	BOOTLOADER_TYPE_MENU	; Boot loader type
@@ -108,12 +106,6 @@
 
 ; Include .asm files (static data and libraries)
+%include "AssemblyLibrary.asm"
 %include "Strings.asm"			; For BIOS message strings
-%include "math.asm"				; For Math library
-%include "string.asm"			; For String library
-%include "print.asm"			; For Print library
-%include "keys.asm"				; For keyboard library (required by menu library)
-%include "menu.asm"				; For menu library
-%include "PrintString.asm"		; Customized printing for this BIOS
-%include "SoftDelay.asm"		; For software delay loops
 
 ; Include .asm files (Initialization and drive detection)
@@ -178,3 +170,3 @@
 
 ; Fill with zeroes until size is what we want
-times (CNT_ROM_BLOCKS*512)-($-$$) db 0
+;times (CNT_ROM_BLOCKS*512)-($-$$) db 0
Index: unk/XTIDE_Universal_BIOS/Src/SoftDelay.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/SoftDelay.asm	(revision 87)
+++ 	(revision )
@@ -1,148 +1,0 @@
-; File name		:	SoftDelay.asm
-; Project name	:	IDE BIOS
-; Created date	:	22.9.2007
-; Last update	:	13.4.2010
-; Author		:	Tomi Tilli
-; Description	:	Software delay loops for I/O timeout and other loops.
-
-; Section containing code
-SECTION .text
-
-;--------------------------------------------------------------------
-; There should be at least 400ns delay between outputting
-; IDE command / drive selection and reading IDE Status Register.
-;
-; SoftDelay_BeforePollingStatusRegister
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN						; Cycles required
-SoftDelay_BeforePollingStatusRegister:	; 8088 | 286 | 386 | 486
-	push	cx							;   15 |   3 |   2 |   1
-	mov		cx, 2						;    4 |   2 |   2 |   1
-.DelayLoop:
-	loop	.DelayLoop					;      |  10 |  12 |   6
-	pop		cx							;    8 |   5 |   4 |   4
-	ret									;   20 |  11m|  10m|   5
-
-
-;--------------------------------------------------------------------
-; Initializes timeout counter. Timeouts are implemented using system
-; timer ticks. First tick might take 0...54.9ms and remaining ticks
-; will occur at 54.9ms intervals. Use delay of two (or more) ticks to
-; ensure at least 54.9ms wait.
-;
-; SoftDelay_InitTimeout
-;	Parameters:
-;		CL:		Number of system timer ticks before timeout
-;		DS:		Segment to RAMVARS
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		CX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-SoftDelay_InitTimeout:
-	mov		[RAMVARS.bEndTime], cl		; Store timeout ticks
-	push	ds
-	LOAD_BDA_SEGMENT_TO	ds, cx
-	mov		cl, [BDA.dwTimerTicks]		; Load current time lowest byte
-	pop		ds
-	add		[RAMVARS.bEndTime], cl		; Timeout to end time
-	sti									; Enable interrupts
-	ret
-
-
-;--------------------------------------------------------------------
-; Updates timeout counter. Timeout counter can be
-; initialized with SoftDelay_InitTimeout.
-;
-; SoftDelay_UpdTimeout
-;	Parameters:
-;		DS:		Segment to RAMVARS
-;	Returns:
-;		CF:		Set if timeout
-;				Cleared if time left
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-SoftDelay_UpdTimeout:
-	push	ax
-	push	ds
-	LOAD_BDA_SEGMENT_TO	ds, ax
-	mov		al, [BDA.dwTimerTicks]		; Load current time lowest byte
-	pop		ds
-
-	cmp		al, [RAMVARS.bEndTime]		; End time reached?
-	pop		ax
-	je		SHORT .ReturnTimeout
-	clc
-	ret
-.ReturnTimeout:
-	stc
-	ret
-
-
-;--------------------------------------------------------------------
-; Microsecond delay.
-; Current implementation uses BIOS event wait services that are not
-; available on XT systems. Calling overhead should be enough so it does
-; not matter for IDE waits. On AT+ the delay will be at least 1ms since
-; RTC resolution is 977 microsecs.
-;
-; SoftDelay_us
-;	Parameters:
-;		CX:		Number of microsecs to wait
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		CX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-SoftDelay_us:
-	push	dx
-	push	ax
-
-	xor		dx, dx						; Zero DX
-	xchg	cx, dx						; Microsecs now in CX:DX
-	mov		ah, 86h						; Event Wait
-	int		INTV_SYSTEM_SERVICES
-
-	pop		ax
-	pop		dx
-	mov		cx, 2						; Prepare to wait 2 timer ticks
-	jc		SHORT SoftDelay_TimerTicks	; Unsupported or busy
-	ret
-
-
-;--------------------------------------------------------------------
-; Timer tick delay.
-; One tick is about 54.9ms but first tick may occur anytime between
-; 0...54.9ms!
-;
-; SoftDelay_TimerTicks
-;	Parameters:
-;		CX:		Number of timer ticks to wait
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		CX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-SoftDelay_TimerTicks:
-	push	ds
-	push	ax
-	LOAD_BDA_SEGMENT_TO	ds, ax
-	add		cx, [BDA.dwTimerTicks]		; CX to end time
-	sti									; Enable interrupts
-.DelayLoop:
-	cmp		cx, [BDA.dwTimerTicks]		; Wait complete?
-	jne		SHORT .DelayLoop			;  If not, loop
-	pop		ax
-	pop		ds
-	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Strings.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Strings.asm	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/Src/Strings.asm	(revision 88)
@@ -1,7 +1,3 @@
-; File name		:	Strings.asm
-; Project name	:	IDE BIOS
-; Created date	:	4.12.2007
-; Last update	:	9.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Strings and equates for BIOS messages.
 
@@ -10,44 +6,41 @@
 
 ; POST drive detection strings
-g_szRomAt:		db	"%s @ %x",CR,LF,STOP
-g_szMaster:		db	"Master",STOP
-g_szSlave:		db	"Slave ",STOP
-g_szDetect:		db	"IDE %s at %x: ",STOP			; IDE Master at 1F0h:
-g_szNotFound:	db	"not found",CR,LF,STOP
+g_szRomAt:		db	"%s @ %x",CR,LF,NULL
+g_szMaster:		db	"Master",NULL
+g_szSlave:		db	"Slave ",NULL
+g_szDetect:		db	"IDE %s at %x: ",NULL			; IDE Master at 1F0h:
+g_szNotFound:	db	"not found",CR,LF,NULL
 
 ; Boot loader strings
-g_szFloppyDrv:	db	"Floppy Drive",STOP
-g_szHardDrv:	db	" Hard Drive ",STOP
-g_szTryToBoot:	db	"Booting from %s %x",175,"%x ... ",STOP
-g_szBootSector:	db	"Boot Sector",STOP
-g_szFound:		db	"found",STOP
-g_szSectRead:	db	"%s %s!",CR,LF,STOP
-g_szReadError:	db	"Error %x!",CR,LF,STOP
-g_sz18hCallback:db	"Boot menu callback via INT 18h",STOP
+g_szFloppyDrv:	db	"Floppy Drive",NULL
+g_szHardDrv:	db	" Hard Drive ",NULL
+g_szTryToBoot:	db	"Booting from %s %x",175,"%x ... ",NULL
+g_szBootSector:	db	"Boot Sector",NULL
+g_szFound:		db	"found",NULL
+g_szSectRead:	db	"%s %s!",CR,LF,NULL
+g_szReadError:	db	"Error %x!",CR,LF,NULL
+g_sz18hCallback:db	"Boot menu callback via INT 18h",NULL
 
 ; Boot menu bottom of screen strings
-g_szFDD:		db	"FDD",STOP
-g_szHDD:		db	"HDD",STOP
-g_szBottomScrn:	db	"%c to %c boots from %s with %s mappings",CR,LF,STOP
-
-; Boot Menu title strings
-g_szTitleLn3:	db	"Copyright 2009-2010 by Tomi Tilli",STOP
+g_szFDD:		db	"FDD",NULL
+g_szHDD:		db	"HDD",NULL
+g_szBottomScrn:	db	"%c to %c boots from %s with %s mappings",CR,LF,NULL
 
 ; Boot Menu menuitem strings
-g_szFDLetter:	db	"%s %c",STOP
-g_szforeignHD:	db	"Foreign Hard Disk",STOP
-g_szRomBoot:	db	"ROM Boot",STOP
+g_szFDLetter:	db	"%s %c",NULL
+g_szforeignHD:	db	"Foreign Hard Disk",NULL
+g_szRomBoot:	db	"ROM Boot",NULL
 
 ; Boot Menu information strings
-g_szCapacity:	db	"Capacity : ",STOP
-g_szSizeSingle:	db	"%s%u.%u %ciB",STOP
-g_szSizeDual:	db	"%s%u.%u %ciB / %u.%u %ciB",STOP
-g_szCfgHeader:	db	"Addr.", T_V, "Block", T_V, "Bus",   T_V, "IRQ",   T_V, "Reset", STOP
-g_szCfgFormat:	db	"%s"   , T_V, "%5u",   T_V, "%c%2u", T_V, " %c%c", T_V, "%5x",   STOP
-g_szLCHS:		db	"L-CHS",STOP
-g_szPCHS:		db	"P-CHS",STOP
-g_szLBA28:		db	"LBA28",STOP
-g_szLBA48:		db	"LBA48",STOP
-g_szFddUnknown:	db	"%sUnknown",STOP
-g_szFddSizeOr:	db	"%s5",172,22h," or 3",171,22h," DD",STOP
-g_szFddSize:	db	"%s%c%c",22h,", %u kiB",STOP	; 3½", 1440 kiB
+g_szCapacity:	db	"Capacity : ",NULL
+g_szSizeSingle:	db	"%s%u.%u %ciB",NULL
+g_szSizeDual:	db	"%s%u.%u %ciB / %u.%u %ciB",NULL
+g_szCfgHeader:	db	"Addr.",SINGLE_VERTICAL,"Block",SINGLE_VERTICAL,"Bus",  SINGLE_VERTICAL,"IRQ",  SINGLE_VERTICAL,"Reset",NULL
+g_szCfgFormat:	db	"%s"   ,SINGLE_VERTICAL,"%5u",  SINGLE_VERTICAL,"%c%2u",SINGLE_VERTICAL," %c%c",SINGLE_VERTICAL,"%5x",  NULL
+g_szLCHS:		db	"L-CHS",NULL
+g_szPCHS:		db	"P-CHS",NULL
+g_szLBA28:		db	"LBA28",NULL
+g_szLBA48:		db	"LBA48",NULL
+g_szFddUnknown:	db	"%sUnknown",NULL
+g_szFddSizeOr:	db	"%s5",172,22h," or 3",171,22h," DD",NULL
+g_szFddSize:	db	"%s%c%c",22h,", %u kiB",NULL	; 3½", 1440 kiB
Index: /trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- /trunk/XTIDE_Universal_BIOS/makefile	(revision 87)
+++ /trunk/XTIDE_Universal_BIOS/makefile	(revision 88)
@@ -41,6 +41,19 @@
 HEADERS += Src/Initialization/
 HEADERS += Src/Libraries/
-HEADERS += Src/Libraries/menu/
 HEADERS += Src/VariablesAndDPTs/
+
+# Subdirectories where library files are:
+LIBS = ../Assembly_Library/Inc/
+LIBS += ../Assembly_Library/Src/
+LIBS += ../Assembly_Library/Src/Display/
+LIBS += ../Assembly_Library/Src/File/
+LIBS += ../Assembly_Library/Src/Keyboard/
+LIBS += ../Assembly_Library/Src/Menu/
+LIBS += ../Assembly_Library/Src/Menu/Dialog/
+LIBS += ../Assembly_Library/Src/String/
+LIBS += ../Assembly_Library/Src/Time/
+LIBS += ../Assembly_Library/Src/Util/
+LIBS += ../XTIDE_Universal_BIOS/Inc/
+HEADERS += $(LIBS)
 
 
@@ -48,7 +61,7 @@
 # Assembler preprocessor defines.                               #
 #################################################################
-DEFINES =
-DEFINES_XT = 
-DEFINES_XTPLUS = USE_186
+DEFINES = INCLUDE_MENU_LIBRARY EXCLUDE_BIT_UTILS EXCLUDE_SORT_UTILS
+DEFINES_XT = ELIMINATE_CGA_SNOW
+DEFINES_XTPLUS = ELIMINATE_CGA_SNOW USE_186
 DEFINES_AT = USE_186 USE_286 USE_AT
 
