Index: /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc	(revision 155)
@@ -21,6 +21,7 @@
 struc RAMVARS
 	.fpOldI13h			resb	4	; Far pointer to old INT 13h handler
-	.wTimeoutCounter	resb	2
 	.wSignature			resb	2	; Sign for finding stolen 1 kiB
+	.bTimeoutTicksLeft	resb	1
+	.bLastTimeoutUpdate	resb	1
 
 	.wDrvCntAndFirst:
@@ -64,5 +65,5 @@
 endstruc
 
-EXTRA_WORDS_TO_RESERVE_FOR_INTPACK	EQU	((IDEPACK_size - INTPACK_size) / 2)
+EXTRA_BYTES_FOR_INTPACK		EQU	(IDEPACK_size - INTPACK_size)
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 155)
@@ -304,10 +304,10 @@
 
 	; Get and push L-CHS size
-	mov		[RAMVARS.wTimeoutCounter], dl		; Store drive number
+	mov		[RAMVARS.bTimeoutTicksLeft], dl		; Store drive number
 	call	AH15h_GetSectorCountToDXAX
 	call	ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
 
 	; Get and push total LBA size
-	mov		dl, [RAMVARS.wTimeoutCounter]		; Restore drive number
+	mov		dl, [RAMVARS.bTimeoutTicksLeft]		; Restore drive number
 	call	BootInfo_GetTotalSectorCount
 	call	ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 154)
+++ /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 154)
+++ /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 154)
+++ /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 154)
+++ /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
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 155)
@@ -23,5 +23,5 @@
 	sti									; Enable interrupts
 	cld									; String instructions to increment pointers
-	SAVE_AND_GET_INTPACK_WITH_EXTRA_WORDS_TO_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK
+	CREATE_FRAME_INTPACK_TO_SSBP	EXTRA_BYTES_FOR_INTPACK
 
 	call	RamVars_GetSegmentToDS
@@ -33,5 +33,4 @@
 
 	; Jump to correct BIOS function
-JumpToBiosFunctionInAH:
 	cmp		ah, 25h						; Valid BIOS function?
 	ja		SHORT Int13h_UnsupportedFunction
@@ -109,5 +108,5 @@
 	or		WORD [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_IF	; Return with interrupts enabled
 	mov		sp, bp									; Now we can exit anytime
-	RESTORE_INTPACK_WITH_EXTRA_WORDS_FROM_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK
+	RESTORE_FRAME_INTPACK_FROM_SSBP		EXTRA_BYTES_FOR_INTPACK
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm	(revision 155)
@@ -59,5 +59,5 @@
 
 ConvertAH08hReturnValuesToSectorCount:
-	call	HAddress_ExtractLCHSparametersFromOldInt13hAddress
+	call	Address_ExtractLCHSparametersFromOldInt13hAddress
 	xor		ax, ax			; Zero AX
 	inc		cx				; Max cylinder number to cylinder count
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm	(revision 155)
@@ -15,5 +15,5 @@
 ;		SS:BP:	Ptr to IDEPACK
 ;	Parameters on INTPACK:
-;		AL:		Number of sectors to read (1...255, 0=256)
+;		AL:		Number of sectors to read (1...255)
 ;		CH:		Cylinder number, bits 7...0
 ;		CL:		Bits 7...6: Cylinder number bits 9 and 8
@@ -28,4 +28,5 @@
 ALIGN JUMP_ALIGN
 AH2h_HandlerForReadDiskSectors:
+	call	AH2h_ExitInt13hIfSectorCountInIntpackIsZero
 	mov		ah, COMMAND_READ_SECTORS	; Load sector mode command
 	test	WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED
@@ -40,2 +41,23 @@
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %endif
+
+
+;--------------------------------------------------------------------
+; AH2h_ExitInt13hIfSectorCountInIntpackIsZero
+;	Parameters:
+;		SS:BP:	Ptr to IDEPACK
+;	Parameters on INTPACK:
+;		AL:		Number of sectors to transfer (1...255)
+;	Returns:
+;		Nothing (does not return if error)
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+AH2h_ExitInt13hIfSectorCountInIntpackIsZero:
+	cmp		BYTE [bp+IDEPACK.intpack+INTPACK.al], 0
+	je		SHORT .InvalidSectorCount
+	ret
+.InvalidSectorCount:
+	mov		ah, RET_HD_INVALID
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm	(revision 155)
@@ -27,5 +27,5 @@
 ALIGN JUMP_ALIGN
 AH3h_HandlerForWriteDiskSectors:
-	; Prepare parameters
+	call	AH2h_ExitInt13hIfSectorCountInIntpackIsZero
 	mov		ah, COMMAND_WRITE_SECTORS	; Load sector mode command
 	test	WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 155)
@@ -26,5 +26,6 @@
 ALIGN JUMP_ALIGN
 AH4h_HandlerForVerifyDiskSectors:
-	mov		ah, COMMAND_WRITE_SECTORS
+	call	AH2h_ExitInt13hIfSectorCountInIntpackIsZero
+	mov		ah, COMMAND_VERIFY_SECTORS
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
 %ifdef USE_186
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Address.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Address.asm	(revision 155)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Address.asm	(revision 155)
@@ -0,0 +1,154 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	Functions for address translations.
+
+; Section containing code
+SECTION .text
+
+; Jump table for conversion functions
+ALIGN WORD_ALIGN
+g_rgfnAddressTranslation:
+	dw		DoNotConvertLCHS					; 0, ADDR_DPT_LCHS
+	dw		ConvertLCHStoPCHS					; 1, ADDR_DPT_PCHS
+	dw		ConvertLCHStoLBARegisterValues		; 2, ADDR_DPT_LBA28
+	dw		ConvertLCHStoLBARegisterValues		; 3, ADDR_DPT_LBA48
+
+
+;--------------------------------------------------------------------
+; Address_OldInt13hAddressToIdeAddress
+;	Parameters:
+;		CH:		Cylinder number, bits 7...0
+;		CL:		Bits 7...6: Cylinder number bits 9 and 8
+;				Bits 5...0:	Starting sector number (1...63)
+;		DH:		Starting head number (0...255)
+;		DS:DI:	Ptr to DPT
+;	Returns:
+;		BL:		LBA Low Register / Sector Number Register (LBA 7...0)
+;		CL:		LBA Mid Register / Low Cylinder Register (LBA 15...8)
+;		CH:		LBA High Register / High Cylinder Register (LBA 23...16)
+;		BH:		Drive and Head Register (LBA 27...24)
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Address_OldInt13hAddressToIdeAddress:
+	call	AccessDPT_GetAddressingModeForWordLookToBX
+	push	WORD [cs:bx+g_rgfnAddressTranslation]		; Push return address
+	; Fall to Address_ExtractLCHSparametersFromOldInt13hAddress
+
+;---------------------------------------------------------------------
+; Address_ExtractLCHSparametersFromOldInt13hAddress
+;	Parameters:
+;		CH:		Cylinder number, bits 7...0
+;		CL:		Bits 7...6: Cylinder number bits 9 and 8
+;				Bits 5...0:	Sector number
+;		DH:		Head number
+;	Returns:
+;		BL:		Sector number (1...63)
+;		BH:		Head number (0...255)
+;		CX:		Cylinder number (0...1023)
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+Address_ExtractLCHSparametersFromOldInt13hAddress:
+	mov		bl, cl				; Copy sector number...
+	and		bl, 3Fh				; ...and limit to 1...63
+	sub		cl, bl				; Remove from cylinder number high
+	eROL_IM	cl, 2				; High bits to beginning
+	mov		bh, dh				; Copy Head number
+	xchg	cl, ch				; Cylinder number now in CX
+	ret
+
+
+;---------------------------------------------------------------------
+; Converts LCHS parameters to IDE P-CHS parameters.
+; PCylinder	= (LCylinder << n) + (LHead / PHeadCount)
+; PHead		= LHead % PHeadCount
+; PSector	= LSector
+;
+; Address_ConvertLCHStoPCHS:
+;	Parameters:
+;		BL:		Sector number (1...63)
+;		BH:		Head number (0...255)
+;		CX:		Cylinder number (0...1023)
+;		DS:DI:	Ptr to Disk Parameter Table
+;	Returns:
+;		BL:		Sector number (1...63)
+;		BH:		Head number (0...15)
+;		CX:		Cylinder number (0...16382)
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+ConvertLCHStoPCHS:
+	; LHead / PHeadCount and LHead % PHeadCount
+	eMOVZX	ax, bh					; Copy L-CHS Head number to AX
+	div		BYTE [di+DPT.bPchsHeads]; AL = LHead / PHeadCount, AH = LHead % PHeadCount
+	mov		bh, ah					; Copy P-CHS Head number to BH
+	xor		ah, ah					; AX = LHead / PHeadCount
+
+	; (LCylinder << n) + (LHead / PHeadCount)
+	mov		dx, cx					; Copy L-CHS Cylinder number to DX
+	mov		cl, [di+DPT.wFlags]		; Load shift count
+	and		cl, MASK_DPT_CHS_SHIFT_COUNT
+	shl		dx, cl					; DX = LCylinder << n
+	add		ax, dx					; AX = P-CHS Cylinder number
+	mov		cx, ax					; Copy P-CHS Cylinder number to CX
+DoNotConvertLCHS:
+	ret
+
+
+;---------------------------------------------------------------------
+; Converts LCHS parameters to 28-bit LBA address.
+; Only 24-bits are used since LHCS to LBA28 conversion has 8.4GB limit.
+; LBA = ((cylToSeek*headsPerCyl+headToSeek)*sectPerTrack)+sectToSeek-1
+;
+; Returned address is in same registers that
+; Address_DoNotConvertLCHS and Address_ConvertLCHStoPCHS returns.
+;
+; ConvertLCHStoLBARegisterValues:
+;	Parameters:
+;		BL:		Sector number (1...63)
+;		BH:		Head number (0...255)
+;		CX:		Cylinder number (0...1023)
+;		DS:DI:	Ptr to Disk Parameter Table
+;	Returns:
+;		BL:		LBA Low Register / Sector Number Register (LBA 7...0)
+;		CL:		LBA Mid Register / Low Cylinder Register (LBA 15...8)
+;		CH:		LBA High Register / High Cylinder Register (LBA 23...16)
+;		BH:		Drive and Head Register (LBA 27...24)
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+ConvertLCHStoLBARegisterValues:
+	; cylToSeek*headsPerCyl (18-bit result)
+	mov		ax, cx					; Copy Cylinder number to AX
+	eMOVZX	dx, BYTE [di+DPT.bLchsHeads]
+	mul		dx						; DX:AX = cylToSeek*headsPerCyl
+
+	; +=headToSeek (18-bit result)
+	add		al, bh					; Add Head number to DX:AX
+	adc		ah, dh					; DH = Zero after previous multiplication
+	adc		dl, dh
+
+	; *=sectPerTrack (18-bit by 6-bit multiplication with 24-bit result)
+	eMOVZX	cx, BYTE [di+DPT.bPchsSectors]	; Load Sectors per Track
+	xchg	ax, dx					; Hiword to AX, loword to DX
+	mul		cl						; AX = hiword * Sectors per Track
+	mov		bh, al					; Backup hiword * Sectors per Track
+	xchg	ax, dx					; Loword back to AX
+	mul		cx						; DX:AX = loword * Sectors per Track
+	add		dl, bh					; DX:AX = (cylToSeek*headsPerCyl+headToSeek)*sectPerTrack
+
+	; +=sectToSeek-1 (24-bit result)
+	xor		bh, bh					; Sector number now in BX
+	dec		bx						; sectToSeek-=1
+	add		ax, bx					; Add to loword
+	adc		dl, bh					; Add possible carry to byte2, BH=zero
+
+	; Copy DX:AX to proper return registers
+	xchg	bx, ax					; BL = Sector Number Register (LBA 7...0)
+	mov		cl, bh					; Low Cylinder Register (LBA 15...8)
+	mov		ch, dl					; High Cylinder Register (LBA 23...16)
+	mov		bh, dh					; Drive and Head Register (LBA 27...24)
+	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 155)
@@ -119,9 +119,9 @@
 
 
-; Include .asm files (static data and libraries)
+; Libraries and data
 %include "AssemblyLibrary.asm"
 %include "Strings.asm"			; For BIOS message strings
 
-; Include .asm files (Initialization and drive detection)
+; Initialization and drive detection
 %include "Initialize.asm"		; For BIOS initialization
 %include "Interrupts.asm"		; For Interrupt initialization
@@ -135,5 +135,5 @@
 %include "DetectPrint.asm"		; For printing drive detection strings
 
-; Include .asm files (boot menu)
+; Boot menu
 %include "BootMenu.asm"			; For Boot Menu operations
 %include "BootMenuEvent.asm"	; For menu library event handling
@@ -144,11 +144,5 @@
 %include "BootMenuPrintCfg.asm"	; For printing hard disk configuration
 
-; Include .asm files (general drive accessing)
-%include "DriveXlate.asm"		; For swapping drive numbers
-%include "HAddress.asm"			; For sector address translations
-%include "HTimer.asm"			; For timeout and delay
-
-; Include .asm files (Interrupt handlers)
-%include "Int13h.asm"			; For Int 13h, Disk functions
+; Boot loader
 %ifndef USE_AT
 	%include "Int19hLate.asm"	; For late initialization
@@ -156,5 +150,26 @@
 %include "Int19hMenu.asm"		; For Int 19h, Boot Loader for Boot Menu
 
-; Include .asm files (Hard Disk BIOS functions)
+; For all device types
+%include "Device.asm"
+%include "Idepack.asm"
+%include "Timer.asm"			; For timeout and delay
+
+; IDE Device support
+%include "IdeCommand.asm"
+%include "IdeDPT.asm"
+%include "IdeIO.asm"
+%include "IdeIrq.asm"
+%include "IdeTransfer.asm"
+%include "IdeWait.asm"
+%include "IdeError.asm"			; Must be included after IdeWait.asm
+
+; Serial Port Device support
+%include "SerialCommand.asm"
+%include "SerialDPT.asm"
+
+; INT 13h Hard Disk BIOS functions
+%include "DriveXlate.asm"		; For swapping drive numbers
+%include "Address.asm"			; For sector address translations
+%include "Int13h.asm"			; For Int 13h, Disk functions
 %include "AH0h_HReset.asm"		; Required by Int13h_Jump.asm
 %include "AH1h_HStatus.asm"		; Required by Int13h_Jump.asm
@@ -172,19 +187,4 @@
 %include "AH24h_HSetBlocks.asm"	; Required by Int13h_Jump.asm
 %include "AH25h_HDrvID.asm"		; Required by Int13h_Jump.asm
-%include "Device.asm"
-%include "Idepack.asm"
-
-; IDE Device support
-%include "IdeCommand.asm"
-%include "IdeDPT.asm"
-%include "IdeIO.asm"
-%include "IdeIrq.asm"
-%include "IdeTransfer.asm"
-%include "IdeWait.asm"
-%include "IdeError.asm"			; Must be included after IdeWait.asm
-
-; Serial Port Device support
-%include "SerialCommand.asm"
-%include "SerialDPT.asm"
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 155)
@@ -123,5 +123,5 @@
 ;				Cleared if function belongs to some other BIOS
 ;	Corrupts registers:
-;		DI
+;		Nothing
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
Index: /trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- /trunk/XTIDE_Universal_BIOS/makefile	(revision 154)
+++ /trunk/XTIDE_Universal_BIOS/makefile	(revision 155)
@@ -38,5 +38,4 @@
 HEADERS += Src/Handlers/
 HEADERS += Src/Handlers/Int13h/
-HEADERS += Src/Handlers/Int13h/Common/
 HEADERS += Src/Device/
 HEADERS += Src/Device/IDE/
