Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 152)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 155)
@@ -22,5 +22,5 @@
 	call	Device_OutputALtoIdeControlBlockRegisterInDL
 	mov		ax, HSR0_RESET_WAIT_US
-	call	HTimer_DelayMicrosecondsFromAX
+	call	Timer_DelayMicrosecondsFromAX
 
 	; HSR1: Clear_wait
@@ -31,5 +31,5 @@
 	call	Device_OutputALtoIdeControlBlockRegisterInDL
 	mov		ax, HSR1_RESET_WAIT_US
-	call	HTimer_DelayMicrosecondsFromAX
+	call	Timer_DelayMicrosecondsFromAX
 
 	; HSR2: Check_status
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 152)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 155)
@@ -381,5 +381,5 @@
 	eSEG	es			; Source is ES segment
 	rep
-	db		6Fh			; OUTSW
+	db		6Fh			; OUTSW (we want this in XT build)
 	ret
 
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeWait.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeWait.asm	(revision 152)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeWait.asm	(revision 155)
@@ -53,7 +53,7 @@
 ;--------------------------------------------------------------------
 IdeWait_PollStatusFlagInBLwithTimeoutInBH:
-	eMOVZX	cx, bh		; Timeout ticks now in CX
 	mov		ah, bl
-	call	HTimer_InitializeTimeoutWithTicksInCX
+	mov		cl, bh
+	call	Timer_InitializeTimeoutWithTicksInCL
 	and		ah, ~FLG_STATUS_BSY
 	jz		SHORT PollBsyOnly
@@ -82,5 +82,5 @@
 	jnz		SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
 .UpdateTimeout:
-	call	HTimer_SetCFifTimeout
+	call	Timer_SetCFifTimeout
 	jnc		SHORT .PollLoop						; Loop if time left
 	call	IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
@@ -110,5 +110,5 @@
 	test	al, FLG_STATUS_BSY					; Controller busy?
 	jz		SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
-	call	HTimer_SetCFifTimeout				; Update timeout counter
+	call	Timer_SetCFifTimeout				; Update timeout counter
 	jnc		SHORT .PollLoop						; Loop if time left (sets CF on timeout)
 	jmp		SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm	(revision 152)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm	(revision 155)
@@ -50,5 +50,5 @@
 
 	push	bx
-	call	HAddress_OldInt13hAddressToIdeAddress
+	call	Address_OldInt13hAddressToIdeAddress
 	call	AccessDPT_GetDriveSelectByteToAL
 	or		al, bh			; AL now has Drive and Head Select Byte
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Timer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Timer.asm	(revision 155)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Timer.asm	(revision 155)
@@ -0,0 +1,118 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	Timeout and delay functions for INT 13h services.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; Timer_InitializeTimeoutWithTicksInCL
+;	Parameters:
+;		CL:		Timeout value in system timer ticks
+;		DS:		Segment to RAMVARS
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		CX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Timer_InitializeTimeoutWithTicksInCL:
+	mov		[RAMVARS.bTimeoutTicksLeft], cl		; Ticks until timeout
+	call	ReadTimeFromBdaToCX
+	mov		[RAMVARS.bLastTimeoutUpdate], cl	; Start time
+	ret
+
+
+;--------------------------------------------------------------------
+; Timer_SetCFifTimeout
+;	Parameters:
+;		DS:		Segment to RAMVARS
+;	Returns:
+;		CF:		Set if timeout
+;				Cleared if time left
+;	Corrupts registers:
+;		CX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Timer_SetCFifTimeout:
+	call	ReadTimeFromBdaToCX
+	cmp		cl, [RAMVARS.bLastTimeoutUpdate]
+	je		SHORT .StillPollingTheSameTick
+	mov		[RAMVARS.bLastTimeoutUpdate], cl
+	sub		BYTE [RAMVARS.bTimeoutTicksLeft], 1	; DEC does not update CF
+.StillPollingTheSameTick:
+	ret
+
+
+;--------------------------------------------------------------------
+; Delay is always at least one millisecond since
+; RTC resolution is 977 microsecs.
+;
+; Timer_DelayMicrosecondsFromAX
+;	Parameters:
+;		AX:		Number of microsecs to wait
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+Timer_DelayMicrosecondsFromAX:
+%ifndef USE_AT
+	mov		ax, 2
+	; Fall to Delay_TimerTicksFromAX
+%else
+	push	dx
+	push	cx
+
+	xor		cx, cx
+	xchg	dx, ax						; Microsecs now in CX:DX
+	mov		ah, EVENT_WAIT
+	int		BIOS_SYSTEM_INTERRUPT_15h
+	sti									; XT BIOSes return with interrupt disabled
+
+	pop		cx
+	pop		dx
+	mov		ax, 1								; Prepare to wait 1 timer tick
+	jc		SHORT Timer_DelayTimerTicksFromAX	; Event Wait was unsupported or busy
+	ret
+%endif
+
+
+;--------------------------------------------------------------------
+; First tick might take 0...54.9 ms and remaining ticks
+; will occur at 54.9 ms intervals.
+;
+; Timer_DelayTimerTicksFromAX
+;	Parameters:
+;		AX:		Number of timer ticks to wait
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+Timer_DelayTimerTicksFromAX:
+	sti								; Make sure that interrupts are enabled
+	call	ReadTimeFromBdaToCX
+	add		ax, cx					; AX = end time
+.WaitLoop:
+	call	ReadTimeFromBdaToCX
+	cmp		cx, ax
+	jne		SHORT .WaitLoop			; Loop until end time is reached
+	ret
+
+
+;--------------------------------------------------------------------
+; ReadTimeFromBdaToCX
+;	Parameters
+;		Nothing
+;	Returns:
+;		CX:		System time in 54.9 ms ticks
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+ReadTimeFromBdaToCX:
+	push	ds
+	LOAD_BDA_SEGMENT_TO	ds, cx
+	mov		cx, [BDA.dwTimerTicks]	; Read low WORD only
+	pop		ds
+	ret
