Index: trunk/BIOS_Drive_Information_Tool/Src/Main.asm
===================================================================
--- trunk/BIOS_Drive_Information_Tool/Src/Main.asm	(revision 416)
+++ trunk/BIOS_Drive_Information_Tool/Src/Main.asm	(revision 424)
@@ -28,4 +28,5 @@
 %include "EBIOS.inc"			; From XTIDE Universal BIOS
 FLG_DRVNHEAD_DRV	EQU	(1<<4)	; Required by CustomDPT.inc
+%include "Romvars.inc"			; From XTIDE Universal BIOS
 %include "CustomDPT.inc"		; From XTIDE Universal BIOS
 
@@ -41,6 +42,7 @@
 ; Include library and other sources
 %include "AssemblyLibrary.asm"
-%include "LbaAssist.asm"		; From XTIDE Universal BIOS
+%include "AtaGeometry.asm"		; From XTIDE Universal BIOS
 %include "Strings.asm"
+%include "AtaInfo.asm"
 %include "Bios.asm"
 %include "Print.asm"
@@ -55,4 +57,5 @@
 	call	Print_SetCharacterOutputToSTDOUT
 
+	; Display program name and version
 	mov		si, g_szProgramName
 	call	Print_NullTerminatedStringFromSI
@@ -65,5 +68,13 @@
 
 
-
+;--------------------------------------------------------------------
+; ReadAndDisplayAllHardDrives
+;	Parameters:
+;		Nothing
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except segments
+;--------------------------------------------------------------------
 ReadAndDisplayAllHardDrives:
 	call	Bios_GetNumberOfHardDrivesToDX
@@ -73,5 +84,4 @@
 	jmp		SHORT .DisplayFirstDrive
 
-ALIGN JUMP_ALIGN
 .DisplayNextDriveFromDL:
 	mov		si, g_szPressAnyKey
@@ -80,15 +90,19 @@
 
 .DisplayFirstDrive:
+	; Display drive number
 	mov		si, g_szHeaderDrive
 	call	Print_DriveNumberFromDLusingFormatStringInSI
 
+	; Display ATA information read from drive
 	mov		si, g_szAtaInfoHeader
 	call	Print_NullTerminatedStringFromSI
-	call	DisplayAtaInformationForDriveDL
-
+	call	AtaInfo_DisplayAtaInformationForDriveDL
+
+	; Display INT 13h AH=08h and AH=15h information
 	mov		si, g_szOldInfoHeader
 	call	Print_NullTerminatedStringFromSI
 	call	DisplayOldInt13hInformationForDriveDL
 
+	; Display EBIOS information
 	mov		si, g_szNewInfoHeader
 	call	Print_NullTerminatedStringFromSI
@@ -101,101 +115,18 @@
 
 
-ALIGN JUMP_ALIGN
-DisplayAtaInformationForDriveDL:
-	push	cx
-	push	dx
-
-	call	Bios_ReadAtaInfoFromDriveDLtoBX
-	call	Print_ErrorMessageFromAHifError
-	jc		SHORT .SkipAtaInfoSinceError
-
-	call	Print_NameFromAtaInfoInBX
-
-	mov		cx, [bx+ATA1.wCylCnt]
-	mov		dx, [bx+ATA1.wHeadCnt]
-	mov		ax, [bx+ATA1.wSPT]
-	call	Print_CHSfromCXDXAX
-
-	test	WORD [bx+ATA1.wFields], A1_wFields_54to58
-	jz		SHORT .SkipChsSectors
-	mov		si, g_szChsSectors
-	call	Print_NullTerminatedStringFromSI
-	mov		si, bx
-	mov		ax, [si+ATA1.dwCurSCnt]
-	mov		dx, [si+ATA1.dwCurSCnt+2]
-	xor		bx, bx
-	call	Print_TotalSectorsFromBXDXAX
-	mov		bx, si
-.SkipChsSectors:
-
-	test	WORD [bx+ATA1.wCaps], A1_wCaps_LBA
-	jz		SHORT .SkipLBA28
-	mov		si, g_szLBA28
-	call	Print_NullTerminatedStringFromSI
-	mov		si, bx
-	mov		ax, [si+ATA1.dwLBACnt]
-	mov		dx, [si+ATA1.dwLBACnt+2]
-	xor		bx, bx
-	call	Print_TotalSectorsFromBXDXAX
-	mov		bx, si
-.SkipLBA28:
-
-	test	WORD [bx+ATA6.wSetSup83], A6_wSetSup83_LBA48
-	jz		SHORT .SkipLBA48
-	mov		si, g_szLBA48
-	call	Print_NullTerminatedStringFromSI
-	mov		si, bx
-	mov		ax, [bx+ATA6.qwLBACnt]
-	mov		dx, [bx+ATA6.qwLBACnt+2]
-	mov		bx, [bx+ATA6.qwLBACnt+4]
-	call	Print_TotalSectorsFromBXDXAX
-	mov		bx, si
-.SkipLBA48:
-
-	; Print L-CHS generated by XTIDE Universal BIOS
-	mov		ax, g_szXTUBversion
-	mov		si, g_szXTUB
-	call	Print_VersionStringFromAXusingFormatStringInSI
-	call	DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
-
-.SkipAtaInfoSinceError:
-	pop		dx
-	pop		cx
-	ret
-
-
-ALIGN JUMP_ALIGN
-DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX:
-	test	WORD [bx+ATA1.wCaps], A1_wCaps_LBA
-	jz		SHORT .LbaNotSupported
-	test	WORD [bx+ATA6.wSetSup83], A6_wSetSup83_LBA48
-	jz		SHORT .LoadLba28SectorCount
-
-	; Load LBA48 Sector Count
-	mov		ax, [bx+ATA6.qwLBACnt]
-	mov		dx, [bx+ATA6.qwLBACnt+2]
-	mov		bx, [bx+ATA6.qwLBACnt+4]
-	jmp		SHORT .ConvertLbaToLCHS
-.LoadLba28SectorCount:
-	mov		ax, [bx+ATA1.dwLBACnt]
-	mov		dx, [bx+ATA1.dwLBACnt+2]
-	xor		bx, bx
-
-.ConvertLbaToLCHS:
-	call	LbaAssist_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH
-	LIMIT_LBA_CYLINDERS_IN_DXAX_TO_LCHS_CYLINDERS
-	xchg	cx, ax
-	eMOVZX	dx, bl
-	eMOVZX	ax, bh
-	call	Print_CHSfromCXDXAX
-.LbaNotSupported:
-	ret
-
-
-ALIGN JUMP_ALIGN
+;--------------------------------------------------------------------
+; DisplayOldInt13hInformationForDriveDL
+;	Parameters:
+;		DL:		Drive Number
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except CX and DX
+;--------------------------------------------------------------------
 DisplayOldInt13hInformationForDriveDL:
 	push	cx
 	push	dx
 
+	; Print L-CHS from AH=08h
 	call	Bios_ReadOldInt13hParametersFromDriveDL
 	call	Print_ErrorMessageFromAHifError
@@ -203,4 +134,5 @@
 	call	Print_CHSfromCXDXAX
 
+	; Print total sector count from AH=15h
 	mov		si, g_szSectors
 	call	Print_NullTerminatedStringFromSI
@@ -210,4 +142,5 @@
 	call	Print_ErrorMessageFromAHifError
 	jc		SHORT .SkipOldInt13hSinceError
+
 	xchg	ax, dx
 	mov		dx, cx
@@ -220,9 +153,18 @@
 
 
-ALIGN JUMP_ALIGN
+;--------------------------------------------------------------------
+; DisplayNewInt13hInformationFromDriveDL
+;	Parameters:
+;		DL:		Drive Number
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except CX and DX
+;--------------------------------------------------------------------
 DisplayNewInt13hInformationFromDriveDL:
 	push	cx
 	push	dx
 
+	; Display EBIOS version
 	call	Bios_ReadEbiosVersionFromDriveDL
 	call	Print_ErrorMessageFromAHifError
@@ -230,8 +172,10 @@
 	call	Print_EbiosVersionFromBXandExtensionsFromCX
 
+	; Display drive info from AH=48h
 	call	Bios_ReadEbiosInfoFromDriveDLtoDSSI
 	call	Print_ErrorMessageFromAHifError
 	jc		SHORT .SkipNewInt13hSinceError
 
+	; Display CHS
 	test	WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
 	jz		SHORT .SkipEbiosCHS
@@ -242,4 +186,5 @@
 .SkipEbiosCHS:
 
+	; Display total sector count
 	push	si
 	mov		si, g_szSectors
@@ -251,7 +196,8 @@
 	call	Print_TotalSectorsFromBXDXAX
 
+	; Display sector size
 	mov		ax, [si+EDRIVE_INFO.wSectorSize]
 	mov		si, g_szNewSectorSize
-	call	Print_SectorSizeFromAXusingFormatStringInSI
+	call	Print_FormatStringFromSIwithParameterInAX
 
 .SkipNewInt13hSinceError:
