Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 95)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 96)
@@ -19,12 +19,12 @@
 BootMenuPrint_TitleStrings:
 	mov		si, ROMVARS.szTitle
-	call	PrintNullTerminatedStringFromCSSIandSetCF
-	call	BootMenuPrint_Newline
+	call	BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
+	CALL_DISPLAY_LIBRARY PrintNewlineCharacters
 	mov		si, ROMVARS.szVersion
-	jmp		PrintNullTerminatedStringFromCSSIandSetCF
-
-
-;--------------------------------------------------------------------
-; BootMenuPrint_Newline
+	jmp		BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
+
+
+;--------------------------------------------------------------------
+; BootMenuPrint_ClearScreen
 ;	Parameters:
 ;		Nothing
@@ -35,52 +35,7 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-BootMenuPrint_Newline:
-	CALL_DISPLAY_LIBRARY PrintNewlineCharacters
-	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
 
@@ -155,5 +110,5 @@
 .HardDiskMenuitemForForeignDrive:
 	mov		si, g_szforeignHD
-	jmp		PrintNullTerminatedStringFromCSSIandSetCF
+	jmp		BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
 
 
@@ -365,5 +320,5 @@
 
 ;--------------------------------------------------------------------
-; PrintNullTerminatedStringFromCSSIandSetCF
+; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
 ;	Parameters:
 ;		CS:SI:	Ptr to NULL terminated string to print
@@ -374,5 +329,5 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-PrintNullTerminatedStringFromCSSIandSetCF:
+BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
 	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
 	stc
Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 95)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 96)
@@ -20,56 +20,12 @@
 ALIGN JUMP_ALIGN
 BootMenuPrintCfg_ForOurDrive:
-	call	BootMenuPrintCfg_HeaderAndChangeLine
+	mov		si, g_szCfgHeader
+	call	BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
 	call	BootMenuPrintCfg_GetPointers
-	call	BootMenuPrintCfg_PushAndFormatCfgString
-	jmp		BootMenuPrint_Newline
+	; Fall to PushAndFormatCfgString
 
 
 ;--------------------------------------------------------------------
-; Prints configuration header and changes for printing values.
-;
-; BootMenuPrintCfg_HeaderAndChangeLine
-;	Parameters:
-;		Nothing
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, SI, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrintCfg_HeaderAndChangeLine:
-	mov		si, g_szCfgHeader
-	call	PrintNullTerminatedStringFromCSSIandSetCF
-	jmp		BootMenuPrint_Newline
-
-
-;--------------------------------------------------------------------
-; Return all necessary pointers to drive information structs.
-;
-; BootMenuPrintCfg_GetPointers
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;	Returns:
-;		DS:DI:	Ptr to DPT
-;		ES:BX:	Ptr to BOOTNFO
-;		CS:SI:	Ptr to IDEVARS
-;	Corrupts registers:
-;		AX, DL
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BootMenuPrintCfg_GetPointers:
-	mov		dl, [di+DPT.bDrvNum]		; Load Drive number to DL
-	call	BootInfo_GetOffsetToBX		; ES:BX now points...
-	LOAD_BDA_SEGMENT_TO	es, ax			; ...to BOOTNFO
-	mov		al, [di+DPT.bIdeOff]
-	xchg	si, ax						; CS:SI now points to IDEVARS
-	ret
-
-
-;--------------------------------------------------------------------
-; Pushes all string formatting parameters and prints
-; formatted configuration string.
-;
-; BootMenuPrintCfg_PushAndFormatCfgString
+; PushAndFormatCfgString
 ;	Parameters:
 ;		DS:DI:	Ptr to DPT
@@ -82,7 +38,6 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-BootMenuPrintCfg_PushAndFormatCfgString:
+PushAndFormatCfgString:
 	push	bp
-
 	mov		bp, sp
 	; Fall to first push below
@@ -97,12 +52,12 @@
 ;		Nothing (jumps to next push below)
 ;	Corrupts registers:
-;		AX, DX
+;		AX
 ;--------------------------------------------------------------------
 PushAddressingMode:
-	mov		dx, bx				; Backup BX to DX
+	xchg	ax, bx
 	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
+	xchg	bx, ax
 	jmp		SHORT .NextPush
 ALIGN WORD_ALIGN
@@ -208,7 +163,5 @@
 
 ;--------------------------------------------------------------------
-; Prints formatted configuration string from parameters pushed to stack.
-;
-; BootMenuPrintCfg_ValuesFromStack
+; PrintValuesFromStack
 ;	Parameters:
 ;		Stack:	All formatting parameters
@@ -218,5 +171,26 @@
 ;		AX, SI, DI
 ;--------------------------------------------------------------------
-BootMenuPrintCfg_ValuesFromStack:
+PrintValuesFromStack:
 	mov		si, g_szCfgFormat
-	jmp		PrintNullTerminatedStringFromCSSIandSetCF
+	jmp		BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
+
+
+;--------------------------------------------------------------------
+; BootMenuPrintCfg_GetPointers
+;	Parameters:
+;		DS:DI:	Ptr to DPT
+;	Returns:
+;		DS:DI:	Ptr to DPT
+;		ES:BX:	Ptr to BOOTNFO
+;		CS:SI:	Ptr to IDEVARS
+;	Corrupts registers:
+;		AX, DL
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootMenuPrintCfg_GetPointers:
+	mov		dl, [di+DPT.bDrvNum]		; Load Drive number to DL
+	call	BootInfo_GetOffsetToBX		; ES:BX now points...
+	LOAD_BDA_SEGMENT_TO	es, ax			; ...to BOOTNFO
+	mov		al, [di+DPT.bIdeOff]
+	xchg	si, ax						; CS:SI now points to IDEVARS
+	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootSector.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootSector.asm	(revision 96)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootSector.asm	(revision 96)
@@ -0,0 +1,110 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	Reading and jumping to boot sector.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; BootSector_TryToLoadFromDriveDL
+;	Parameters:
+;		DL:		Drive to boot from (translated, 00h or 80h)
+;		DS:		RAMVARS segment
+;	Returns:
+;		ES:BX:	Ptr to boot sector (if successfull)
+;		CF:		Set if boot sector loaded succesfully
+;				Cleared if failed to load boot sector
+;	Corrupts registers:
+;		AX, CX, DH, DI, (DL if failed to read boot sector)
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BootSector_TryToLoadFromDriveDL:
+	call	BootPrint_TryToBootFromDL
+	call	LoadFirstSectorFromDriveDL
+	jc		SHORT .FailedToLoadFirstSector
+
+	test	dl, 80h
+	jz		SHORT .AlwaysBootFromFloppyDriveForBooterGames
+	cmp		WORD [es:bx+510], 0AA55h		; Valid boot sector?
+	jne		SHORT .FirstHardDiskSectorNotBootable
+.AlwaysBootFromFloppyDriveForBooterGames:
+	mov		bx, g_szFound
+	call	BootPrint_BootSectorResultStringFromBX
+	stc
+	ret
+.FailedToLoadFirstSector:
+	call	BootPrint_FailedToLoadFirstSector
+	clc
+	ret
+.FirstHardDiskSectorNotBootable:
+	mov		bx, g_szNotFound
+	call	BootPrint_BootSectorResultStringFromBX
+	clc
+	ret
+
+;--------------------------------------------------------------------
+; LoadFirstSectorFromDriveDL
+;	Parameters:
+;		DL:		Drive to boot from (translated, 00h or 80h)
+;	Returns:
+;		AH:		INT 13h error code
+;		ES:BX:	Ptr to boot sector (if successfull)
+;		CF:		Cleared if read successfull
+;				Set if any error
+;	Corrupts registers:
+;		AL, CX, DH, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+LoadFirstSectorFromDriveDL:
+	LOAD_BDA_SEGMENT_TO	es, bx				; ES:BX now points to...
+	mov		bx, BOOTVARS.rgbBootSect		; ...boot sector location
+	mov		di, BOOT_READ_RETRY_TIMES		; Initialize retry counter
+ALIGN JUMP_ALIGN
+.ReadRetryLoop:
+	call	.ResetBootDriveFromDL
+	call	.LoadFirstSectorFromDLtoESBX
+	jnc		SHORT .Return
+	dec		di								; Decrement retry counter
+	jnz		SHORT .ReadRetryLoop			; Loop while retries left
+ALIGN JUMP_ALIGN
+.Return:
+	ret
+
+;--------------------------------------------------------------------
+; .ResetBootDriveFromDL
+;	Parameters:
+;		DL:		Drive to boot from (translated, 00h or 80h)
+;	Returns:
+;		AH:		INT 13h error code
+;		CF:		Cleared if read successfull
+;				Set if any error
+;	Corrupts registers:
+;		AL
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.ResetBootDriveFromDL:
+	xor		ax, ax							; AH=0h, Disk Controller Reset
+	test	dl, 80h							; Floppy drive?
+	eCMOVNZ	ah, 0Dh							; AH=Dh, Reset Hard Disk (Alternate reset)
+	int		INTV_DISK_FUNC
+	ret
+
+;--------------------------------------------------------------------
+; .LoadFirstSectorFromDLtoESBX
+;	Parameters:
+;		DL:		Drive to boot from (translated, 00h or 80h)
+;		ES:BX:	Destination buffer for boot sector
+;	Returns:
+;		AH:		INT 13h error code
+;		ES:BX:	Ptr to boot sector
+;		CF:		Cleared if read successfull
+;				Set if any error
+;	Corrupts registers:
+;		AL, CX, DH
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.LoadFirstSectorFromDLtoESBX:
+	mov		ax, 0201h						; Read 1 sector
+	mov		cx, 1							; Cylinder 0, Sector 1
+	xor		dh, dh							; Head 0
+	int		INTV_DISK_FUNC
+	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm	(revision 95)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm	(revision 96)
@@ -62,6 +62,4 @@
 	cli									; Disable interrupts
 	LOAD_BDA_SEGMENT_TO	ss, sp
-;	eLSS	sp, ss:BOOTVARS.dwPostStack	; Expanded macro to remove
-										; unneeded CLI instruction
 %ifndef USE_386
 	mov		sp, [ss:BOOTVARS.dwPostStack]
