Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 86)
+++ 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 86)
+++ 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 86)
+++ 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 86)
+++ 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 86)
+++ 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 86)
+++ 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 86)
+++ 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
