Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 148)
@@ -4,27 +4,4 @@
 ; Section containing code
 SECTION .text
-
-;--------------------------------------------------------------------
-; Macro that prints drive and function number.
-; Used only for debugging.
-;
-; DEBUG_PRINT_DRIVE_AND_FUNCTION
-;	Parameters:
-;		AH:		INT 13h function number
-;		DL:		Drive number
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-%macro DEBUG_PRINT_DRIVE_AND_FUNCTION 0
-	push	dx
-	push	ax
-	mov		al, dl
-	call	Print_IntHexW
-	pop		ax
-	pop		dx
-%endmacro
-
 
 ;--------------------------------------------------------------------
@@ -32,8 +9,44 @@
 ; Jumps to specific function defined in AH.
 ;
-; Int13h_Jump
+; Note to developers: Do not make recursive INT 13h calls!
+;
+; Int13h_DiskFunctionsHandler
 ;	Parameters:
 ;		AH:		Bios function
 ;		DL:		Drive number
+;		Other:	Depends on function
+;	Returns:
+;		Depends on function
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Int13h_DiskFunctionsHandler:
+	sti									; Enable interrupts
+	SAVE_AND_GET_INTPACK_TO_SSBP
+
+	call	RamVars_GetSegmentToDS
+	call	DriveXlate_ToOrBack
+	mov		[RAMVARS.xlateVars+XLATEVARS.bXlatedDrv], dl
+	call	RamVars_IsFunctionHandledByThisBIOS
+	jnc		SHORT Int13h_DirectCallToAnotherBios
+	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
+
+	; Jump to correct BIOS function
+JumpToBiosFunctionInAH:
+	cmp		ah, 25h						; Valid BIOS function?
+	ja		SHORT Int13h_UnsupportedFunction
+	eMOVZX	bx, ah
+	shl		bx, 1
+	jmp		[cs:bx+g_rgw13hFuncJump]	; Jump to BIOS function
+
+
+;--------------------------------------------------------------------
+; Int13h_UnsupportedFunction
+; Int13h_DirectCallToAnotherBios
+;	Parameters:
+;		DL:		Translated drive number
+;		DS:		RAMVARS segment
+;		SS:BP:	Ptr to INTPACK
+;		BX, DI:	Corrupted on Int13h_DiskFunctionsHandler
+;		Other:	Function specific INT 13h parameters 
 ;	Returns:
 ;		Depends on function
@@ -42,174 +55,103 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-Int13h_DiskFunctions:
-	; Save registers
-	sti									; Enable interrupts
-	push	ds							; Store DS
-	push	di							; Store DI
-
-	;DEBUG_PRINT_DRIVE_AND_FUNCTION
+Int13h_UnsupportedFunction:
+Int13h_DirectCallToAnotherBios:
+	call	ExchangeCurrentInt13hHandlerWithOldInt13hHandler
+	mov		bx, [bp+INTPACK.bx]
+	mov		di, [bp+INTPACK.di]
+	mov		ds, [bp+INTPACK.ds]
+	push	WORD [bp+INTPACK.flags]
+	popf
+	push	bp
+	mov		bp, [bp+INTPACK.bp]
+	int		BIOS_DISK_INTERRUPT_13h	; Can safely do as much recursion as it wants
+
+	; Store returned values to INTPACK
+	pop		bp	; Standard INT 13h functions never uses BP as return register
+%ifdef USE_386
+	mov		[bp+INTPACK.gs], gs
+	mov		[bp+INTPACK.fs], fs
+%endif
+	mov		[bp+INTPACK.es], es
+	mov		[bp+INTPACK.ds], ds
+	mov		[bp+INTPACK.di], di
+	mov		[bp+INTPACK.si], si
+	mov		[bp+INTPACK.bx], bx
+	mov		[bp+INTPACK.dh], dh
+	mov		[bp+INTPACK.cx], cx
+	mov		[bp+INTPACK.ax], ax
+	pushf
+	pop		WORD [bp+INTPACK.flags]
 	call	RamVars_GetSegmentToDS
-	call	DriveXlate_WhenEnteringInt13h
-	call	RamVars_IsFunctionHandledByThisBIOS
-	jnc		SHORT Int13h_DirectCallToAnotherBios
-	;DEBUG_PRINT_DRIVE_AND_FUNCTION
-
-	; Jump to correct BIOS function
-	cmp		ah, 25h						; Valid BIOS function?
-	ja		SHORT Int13h_UnsupportedFunction
-	mov		di, ax
-%ifndef USE_186	; This uses 9 bytes less and is about 5 cycles faster
-	mov		al, ah						; Copy bits in AH to AL and then
-	shl		al, 1						; shift them "back" 1 step
-	and		al, 7Eh						; AND them (clears the MSB)
-	cbw									; Clear AH using sign extension
-	xchg	di, ax						; and finally swap DI with AX
-%else
-	eSHR_IM	di, 7						; Shift function to DI...
-	and		di, BYTE 7Eh				; ...and prepare for word lookup
-%endif
-	jmp		[cs:di+g_rgw13hFuncJump]	; Jump to BIOS function
-
-
-;--------------------------------------------------------------------
-; Directs call to another INT13h function whose pointer is
-; stored to RAMVARS.
-;
-; Int13h_DirectCallToAnotherBios
-;	Parameters:
-;		AH:		Bios function
+	cmp		dl, [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv]
+	je		SHORT .ExchangeInt13hHandlers
+	mov		[bp+INTPACK.dl], dl		; Something is returned in DL
+ALIGN JUMP_ALIGN
+.ExchangeInt13hHandlers:
+	call	ExchangeCurrentInt13hHandlerWithOldInt13hHandler
+	; Fall to Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
+
+
+;--------------------------------------------------------------------
+; Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
+; Int13h_ReturnFromHandlerWithoutStoringErrorCode
+;	Parameters:
+;		AH:		BIOS Error code
+;		SS:BP:	Ptr to INTPACK
+;	Returns:
+;		All registers are loaded from INTPACK
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH:
+	call	HError_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
+Int13h_ReturnFromHandlerWithoutStoringErrorCode:
+	or		WORD [bp+INTPACK.flags], FLG_FLAGS_IF	; Return with interrupts enabled
+	mov		sp, bp									; Now we can exit anytime
+	RESTORE_INTPACK_FROM_SSBP
+
+
+;--------------------------------------------------------------------
+; Int13h_CallPreviousInt13hHandler
+;	Parameters:
+;		AH:		INT 13h function to call
 ;		DL:		Drive number
 ;		DS:		RAMVARS segment
-;		DI:		Corrupted
-;		Stack from top to down:
-;				Original DI
-;				Original DS
 ;	Returns:
 ;		Depends on function
 ;	Corrupts registers:
-;		Flags
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-Int13h_UnsupportedFunction:
-Int13h_DirectCallToAnotherBios:
-	; Temporarily store original DI and DS from stack to RAMVARS
-	pop		WORD [RAMVARS.wI13hDI]
-	pop		WORD [RAMVARS.wI13hDS]
-
-	; Special return processing required if target function
-	; returns something in DL
-	mov		di, Int13h_ReturnFromAnotherBiosWithValueInDL
-	call	DriveXlate_DoesFunctionReturnSomethingInDL
-	jc		SHORT .PushIretAddress
-	add		di, BYTE Int13h_ReturnFromAnotherBios - Int13h_ReturnFromAnotherBiosWithValueInDL
-.PushIretAddress:
-	pushf								; Push FLAGS to simulate INT
-	push	cs							; Push return segment
-	push	di							; Push return offset
-
-	; "Return" to another INT 13h with original DI and DS
-	push	WORD [RAMVARS.fpOldI13h+2]	; Segment
-	push	WORD [RAMVARS.fpOldI13h]	; Offset
-	lds		di, [RAMVARS.dwI13DIDS]
-	cli									; Disable interrupts as INT would
-	retf
-
-
-;--------------------------------------------------------------------
-; Int13h_CallPreviousInt13hHandler
-;	Parameters:
-;		AH:		Bios function
+;		BX, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Int13h_CallPreviousInt13hHandler:
+	push	di
+	call	ExchangeCurrentInt13hHandlerWithOldInt13hHandler
+	int		BIOS_DISK_INTERRUPT_13h
+	call	ExchangeCurrentInt13hHandlerWithOldInt13hHandler
+	pop		di
+	ret
+
+
+;--------------------------------------------------------------------
+; ExchangeCurrentInt13hHandlerWithOldInt13hHandler
+;	Parameters:
 ;		DS:		RAMVARS segment
-;		Other:	Depends on function to call
-;	Returns:
-;		Depends on function to call
+;	Returns:
+;		Nothing
 ;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-Int13h_CallPreviousInt13hHandler:
-	pushf								; Push flags to simulate INT
-	cli									; Disable interrupts since INT does that
-	call	FAR [RAMVARS.fpOldI13h]
-	sti
+;		DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+ExchangeCurrentInt13hHandlerWithOldInt13hHandler:
+	push	es
+	LOAD_BDA_SEGMENT_TO	es, di
+	mov		di, [RAMVARS.fpOldI13h]
+	xchg	di, [es:BIOS_DISK_INTERRUPT_13h*4]
+	mov		[RAMVARS.fpOldI13h], di
+	mov		di, [RAMVARS.fpOldI13h+2]
+	xchg	di, [es:BIOS_DISK_INTERRUPT_13h*4+2]
+	mov		[RAMVARS.fpOldI13h+2], di
+	pop		es
 	ret
 
-
-;--------------------------------------------------------------------
-; Int13h_ReturnFromAnotherBiosWithValueInDL
-; Int13h_ReturnFromAnotherBios
-;	Parameters:
-;		AH:		Error code
-;		DL:		Drive number (only on Int13h_ReturnFromAnotherBios)
-;		CF:		Error status
-;	Returns:
-;		Depends on function
-;	Corrupts registers:
-;		Nothing (not even FLAGS)
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-Int13h_ReturnFromAnotherBiosWithValueInDL:
-	push	ds
-	push	di
-	pushf								; Store return flags
-	call	RamVars_GetSegmentToDS
-	call	DriveXlate_WhenLeavingInt13hWithReturnValueInDL
-	jmp		SHORT Int13h_Leave
-
-ALIGN JUMP_ALIGN
-Int13h_ReturnFromAnotherBios:
-	push	ds
-	push	di
-	pushf								; Store return flags
-	call	RamVars_GetSegmentToDS
-	call	DriveXlate_WhenLeavingInt13h
-	jmp		SHORT Int13h_Leave
-
-
-;--------------------------------------------------------------------
-; Returns from any BIOS function implemented by this BIOS.
-;
-; Int13h_ReturnWithValueInDL
-; Int13h_PopXRegsAndReturn
-; Int13h_PopDiDsAndReturn
-;	Parameters:
-;		DL:		Drive number (not Int13h_ReturnWithoutSwappingDrives)
-;		DS:		RAMVARS segment
-;	Returns:
-;		Depends on function
-;	Corrupts registers:
-;		Nothing (not even FLAGS)
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-Int13h_ReturnWithValueInDL:
-	pushf
-	call	DriveXlate_WhenLeavingInt13hWithReturnValueInDL
-	jmp		SHORT Int13h_LeaveAfterStoringErrorCodeToBDA
-
-ALIGN JUMP_ALIGN
-Int13h_PopXRegsAndReturn:
-	pop		bx							; Pop old AX to BX
-	mov		al, bl						; Restore AL
-	pop		bx
-	pop		cx
-	pop		dx
-	; Fall to Int13h_PopDiDsAndReturn
-
-ALIGN JUMP_ALIGN
-Int13h_PopDiDsAndReturn:
-	pushf
-	call	DriveXlate_WhenLeavingInt13h
-	; Fall to Int13h_LeaveAfterStoringErrorCodeToBDA
-
-Int13h_LeaveAfterStoringErrorCodeToBDA:
-	LOAD_BDA_SEGMENT_TO	ds, di
-	mov		[BDA.bHDStatus], ah
-	; Fall to Int13h_Leave
-
-Int13h_Leave:
-	popf
-	pop		di
-	pop		ds
-	retf	2
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 148)
@@ -10,23 +10,14 @@
 ; AH0h_HandlerForDiskControllerReset
 ;	Parameters:
-;		AH:		Bios function 0h
-;		DL:		Drive number (ignored so all drives are reset)
+;		DL:		Translated Drive number (ignored so all drives are reset)
 ;				If bit 7 is set all hard disks and floppy disks reset.
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h return status (from drive requested in DL)
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH0h_HandlerForDiskControllerReset:
-	push	dx
-	push	cx
-	push	bx
-	push	ax
-
 	eMOVZX	bx, dl						; Copy requested drive to BL, zero BH to assume no errors
 	call	ResetFloppyDrivesWithInt40h
@@ -35,10 +26,7 @@
 	call	ResetForeignHardDisks
 	call	AH0h_ResetHardDisksHandledByOurBIOS
-ALIGN JUMP_ALIGN
 .SkipHardDiskReset:
-	mov		ah, bh						; Copy error code to AH
-	xor		al, al						; Zero AL...
-	cmp		al, bh						; ...and set CF if error
-	jmp		Int13h_PopXRegsAndReturn
+	mov		ah, bh
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 
 
@@ -57,5 +45,5 @@
 	and		dl, 7Fh						; Clear hard disk bit
 	xor		ah, ah						; Disk Controller Reset
-	int		INTV_FLOPPY_FUNC
+	int		BIOS_DISKETTE_INTERRUPT_40h
 	jmp		SHORT BackupErrorCodeFromTheRequestedDriveToBH
 
@@ -96,5 +84,4 @@
 	jnc		SHORT .Return				; Return what was in BL unmodified
 	mov		dl, 80h
-ALIGN JUMP_ALIGN
 .Return:
 	ret
@@ -171,7 +158,4 @@
 BackupErrorCodeFromTheRequestedDriveToBH:
 	cmp		dl, bl				; Requested drive?
-	jne		SHORT .Return
-	mov		bh, ah
-ALIGN JUMP_ALIGN
-.Return:
+	eCMOVE	bh, ah
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH10h_HReady.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH10h_HReady.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH10h_HReady.asm	(revision 148)
@@ -1,7 +1,3 @@
-; File name		:	AH10h_HReady.asm
-; Project name	:	IDE BIOS
-; Created date	:	9.12.2007
-; Last update	:	12.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=10h, Check Drive Ready.
 
@@ -14,25 +10,14 @@
 ; AH10h_HandlerForCheckDriveReady
 ;	Parameters:
-;		AH:		Bios function 10h
-;		DL:		Drive number (8xh)
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h return status
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH10h_HandlerForCheckDriveReady:
-	; Save registers
-	push	dx
-	push	cx
-	push	bx
-	push	ax
-
-	; Wait until drive is ready
-	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
 	call	HStatus_WaitRdyDefTime
-	jmp		Int13h_PopXRegsAndReturn
+	xor		ah, ah
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm	(revision 148)
@@ -1,8 +1,3 @@
-; File name		:	AH11h_HRecal.asm
-; Project name	:	IDE BIOS
-; Created date	:	28.9.2007
-; Last update	:	14.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=11h, Recalibrate.
 
@@ -15,26 +10,18 @@
 ; AH11h_HandlerForRecalibrate
 ;	Parameters:
-;		AH:		Bios function 11h
-;		DL:		Drive number
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Returns with INTPACK in SS:BP:
 ;		AH:		BIOS Error code
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH11h_HandlerForRecalibrate:
-	push	dx
-	push	cx
-	push	bx
-	push	ax
 %ifndef USE_186
 	call	AH11h_RecalibrateDrive
-	jmp		Int13h_PopXRegsAndReturn
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %else
-	push	Int13h_PopXRegsAndReturn
+	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 	; Fall through to AH11h_RecalibrateDrive
 %endif
@@ -42,12 +29,8 @@
 
 ;--------------------------------------------------------------------
-; Int 13h function AH=11h, Recalibrate.
-;
 ; AH11h_HRecalibrate
 ;	Parameters:
-;		DL:		Drive number
-;		DS:		RAMVARS segment
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;	Returns:
-;		DS:DI:	Ptr to DPT
 ;		AH:		BIOS Error code
 ;		CF:		0 if succesfull, 1 if error
@@ -55,5 +38,4 @@
 ;		AL, BX, CX, DX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 AH11h_RecalibrateDrive:
 	; Recalibrate command is optional, vendor specific and not even
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm	(revision 148)
@@ -10,9 +10,8 @@
 ; AH15h_HandlerForReadDiskDriveSize
 ;	Parameters:
-;		AH:		Bios function 15h
-;		DL:		Drive number
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Returns with INTPACK in SS:BP:
 ;		If succesfull:
 ;			AH:		3 (Hard disk accessible)
@@ -23,19 +22,13 @@
 ;			CX:DX:	0
 ;			CF:		1
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH15h_HandlerForReadDiskDriveSize:
-	push	bx
-	push	ax
+	call	HCapacity_GetSectorCountFromOurAH08h		; Sector count to DX:AX
+	mov		[bp+INTPACK.cx], dx							; HIWORD to CX
+	mov		[bp+INTPACK.dx], ax							; LOWORD to DX
 
-	call	HCapacity_GetSectorCountFromOurAH08h; Sector count to DX:AX (clears CF)
-	mov		cx, dx								; HIWORD to CX
-	xchg	dx, ax								; LOWORD to DX
-
-	pop		ax
-	pop		bx
-	mov		ah, 3								; Type code = Hard disk
-	jmp		Int13h_ReturnWithValueInDL
+	xor		ah, ah
+	call	HError_SetErrorCodeToIntpackInSSBPfromAH	; Store success to BDA and CF
+	mov		BYTE [bp+INTPACK.ah], 3						; Type code = Hard disk
+	jmp		Int13h_ReturnFromHandlerWithoutStoringErrorCode
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm	(revision 148)
@@ -10,24 +10,15 @@
 ; AH1h_HandlerForReadDiskStatus
 ;	Parameters:
-;		AH:		Bios function 1h
-;		DL:		Drive number (8xh)
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h floppy return status
 ;		CF:		0 if AH = RET_HD_SUCCESS, 1 otherwise (error)
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH1h_HandlerForReadDiskStatus:
-	push	ds
-
-	LOAD_BDA_SEGMENT_TO	ds, di
-	mov		ah, [BDA.bHDLastSt]		; Last error to AH
-	cmp		ah, 1					; Set CF if error code is zero
-	cmc								; Invert CF
-
-	pop		ds
-	jmp		Int13h_PopDiDsAndReturn
+	LOAD_BDA_SEGMENT_TO	ds, ax, !
+	xchg	ah, [BDA.bHDLastSt]		; Load and clear last error
+	call	HError_SetErrorCodeToIntpackInSSBPfromAH
+	jmp		Int13h_ReturnFromHandlerWithoutStoringErrorCode
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm	(revision 148)
@@ -1,7 +1,3 @@
-; File name		:	AH23h_HFeatures.asm
-; Project name	:	IDE BIOS
-; Created date	:	28.12.2009
-; Last update	:	12.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=23h,
 ;					Set Controller Features Register.
@@ -15,29 +11,47 @@
 ; AH23h_HandlerForSetControllerFeatures
 ;	Parameters:
-;		AH:		Bios function 23h
+;		AL, CX:	Same as in INTPACK
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Parameters on INTPACK in SS:BP:
 ;		AL:		Feature Number (parameter to Features Register = subcommand)
-;		DL:		Drive number (8xh)
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Parameter registers are undocumented, specific for this BIOS:
+;	(Parameter registers are undocumented, there are specific for this BIOS):
 ;		BH:		Parameter to Sector Count Register (subcommand specific)
 ;		BL:		Parameter to Sector Number Register (subcommand specific)
 ;		CL:		Parameter to Low Cylinder Register (subcommand specific)
 ;		CH:		Parameter to High Cylinder Register (subcommand specific)
+;	Returns with INTPACK in SS:BP:
+;		AH:		Int 13h return status
+;		CF:		0 if succesfull, 1 if error
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+AH23h_HandlerForSetControllerFeatures:
+%ifndef USE_186
+	call	AH23h_SetControllerFeatures
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
+%else
+	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
+	; Fall through to AH23h_SetControllerFeatures
+%endif
+
+
+;--------------------------------------------------------------------
+; AH23h_SetControllerFeatures
+;	Parameters:
+;		AL:		Feature Number (parameter to Features Register = subcommand)
+;		BH:		Parameter to Sector Count Register (subcommand specific)
+;		BL:		Parameter to Sector Number Register (subcommand specific)
+;		CL:		Parameter to Low Cylinder Register (subcommand specific)
+;		CH:		Parameter to High Cylinder Register (subcommand specific)
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;	Returns:
 ;		AH:		Int 13h return status
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
 ;	Corrupts registers:
-;		Flags
+;		AX, BX, CX, DX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-AH23h_HandlerForSetControllerFeatures:
-	push	dx
-	push	cx
-	push	bx
-	push	ax
-	push	si
-
+AH23h_SetControllerFeatures:
 	; Backup AL and BH to SI
 	mov		ah, bh
@@ -45,7 +59,6 @@
 
 	; Select Master or Slave and wait until ready
-	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
 	call	HDrvSel_SelectDriveAndDisableIRQ
-	jc		SHORT .Return				; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH
 
 	; Output Feature Number
@@ -66,6 +79,5 @@
 	call	HCommand_OutputSectorCountAndCommand
 
-	call	HStatus_WaitBsyDefTime		; Wait until drive ready
-.Return:
-	pop		si
-	jmp		Int13h_PopXRegsAndReturn
+	jmp		HStatus_WaitBsyDefTime		; Wait until drive ready
+.ReturnWithErrorCodeInAH:
+	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 148)
@@ -1,8 +1,3 @@
-; File name		:	AH24h_HSetBlocks.asm
-; Project name	:	IDE BIOS
-; Created date	:	28.12.2009
-; Last update	:	14.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=24h, Set Multiple Blocks.
 
@@ -15,27 +10,21 @@
 ; AH24h_HandlerForSetMultipleBlocks
 ;	Parameters:
-;		AH:		Bios function 24h
+;		AL:		Same as in INTPACK
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Parameters on INTPACK in SS:BP:
 ;		AL:		Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128)
-;		DL:		Drive number
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h return status
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH24h_HandlerForSetMultipleBlocks:
-	push	dx
-	push	cx
-	push	bx
-	push	ax
 %ifndef USE_186
 	call	AH24h_SetBlockSize
-	jmp		Int13h_PopXRegsAndReturn
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %else
-	push	Int13h_PopXRegsAndReturn
+	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 	; Fall through to AH24h_SetBlockSize
 %endif
@@ -48,12 +37,10 @@
 ;	Parameters:
 ;		AL:		Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128)
-;		DL:		Drive number
-;		DS:		RAMVARS segment
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;	Returns:
-;		DS:DI:	Ptr to DPT
 ;		AH:		Int 13h return status
 ;		CF:		0 if succesfull, 1 if error
 ;	Corrupts registers:
-;		AL, BX, CX, DX, DI
+;		AL, BX, CX, DX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -61,7 +48,6 @@
 	; Select Master or Slave and wait until ready
 	mov		bl, al								; Backup block size
-	call	FindDPT_ForDriveNumber				; DS:DI now points to DPT
 	call	HDrvSel_SelectDriveAndDisableIRQ	; Select drive and wait until ready
-	jc		SHORT .Return						; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH		; Return if error
 
 	; Output block size and command
@@ -80,4 +66,4 @@
 .DisableBlockMode:
 	mov		BYTE [di+DPT.bSetBlock], 1			; Disable block mode
-.Return:
+.ReturnWithErrorCodeInAH:
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 148)
@@ -10,31 +10,22 @@
 ; AH25h_HandlerForGetDriveInformation
 ;	Parameters:
-;		AH:		Bios function 25h
-;		DL:		Drive number
+;		ES:		Same as in INTPACK
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Parameters on INTPACK in SS:BP:
 ;		ES:BX:	Ptr to buffer to receive 512-byte drive information
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
-;		ES:BX:	Ptr to 512-byte buffer to receive drive Information
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h return status
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH25h_HandlerForGetDriveInformation:
-	push	dx
-	push	cx
-	push	bx
-	push	ax
-	push	es
-
 	; Wait until previously selected drive is ready
-	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
 	call	HDrvSel_SelectDriveAndDisableIRQ
-	jc		SHORT .Return				; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH		; Return if error
 
 	; Get drive information
+	mov		bx, [bp+INTPACK.bx]
 	call	HPIO_NormalizeDataPointer
 	push	bx
@@ -45,7 +36,6 @@
 	pop		di							; Pop buffer offset to DI
 	call	AH25h_GetDriveInfo			; Get drive information
-.Return:
-	pop		es
-	jmp		Int13h_PopXRegsAndReturn
+.ReturnWithErrorCodeInAH:
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 
 
@@ -87,5 +77,5 @@
 	eCMOVE	cl, B_TIMEOUT_RESET			;  If so, load long timeout
 	call	HStatus_WaitRdy				; Wait until ready to accept commands
-	jc		SHORT .Return				; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH
 
 	; Output command
@@ -93,5 +83,5 @@
 	out		dx, al						; Output command
 	call	HStatus_WaitDrqDefTime		; Wait until ready to transfer (no IRQ!)
-	jc		SHORT .Return				; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH
 
 	; Transfer data
@@ -102,5 +92,5 @@
 	call	HStatus_WaitRdyDefTime		; Wait until drive ready
 
-.Return:
+.ReturnWithErrorCodeInAH:
 	pop		bx
 	pop		dx
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm	(revision 148)
@@ -1,7 +1,3 @@
-; File name		:	AH2h_HRead.asm
-; Project name	:	IDE BIOS
-; Created date	:	27.9.2007
-; Last update	:	24.8.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=2h, Read Disk Sectors.
 
@@ -14,5 +10,9 @@
 ; AH2h_HandlerForReadDiskSectors
 ;	Parameters:
-;		AH:		Bios function 2h
+;		AL, CX, DH, ES:	Same as in INTPACK
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Parameters on INTPACK in SS:BP:
 ;		AL:		Number of sectors to read (1...255)
 ;		CH:		Cylinder number, bits 7...0
@@ -20,15 +20,9 @@
 ;				Bits 5...0:	Starting sector number (1...63)
 ;		DH:		Starting head number (0...255)
-;		DL:		Drive number (8xh)
 ;		ES:BX:	Pointer to buffer recieving data
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h/40h floppy return status
-;		AL:		Burst error length if AH=11h, undefined otherwise
+;		AL:		Burst error length if AH returns 11h, undefined otherwise
 ;		CF:		0 if successfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -37,29 +31,19 @@
 	jz		SHORT AH2h_ZeroCntErr		;  If so, return with error
 
-	; Save registers
-	push	dx
-	push	cx
-	push	bx
-	push	ax
-
 	; Select sector or block mode command
-	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
 	mov		ah, HCMD_READ_SECT			; Load sector mode command
 	cmp		BYTE [di+DPT.bSetBlock], 1	; Block mode enabled?
-	jbe		SHORT .XferData				;  If not, jump to transfer
-	mov		ah, HCMD_READ_MUL			; Load block mode command
+	eCMOVA	ah, HCMD_READ_MUL			; Load block mode command
 
 	; Transfer data
-ALIGN JUMP_ALIGN
-.XferData:
 	call	HCommand_OutputCountAndLCHSandCommand
-	jc		SHORT .Return				; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH
+	mov		bx, [bp+INTPACK.bx]
 	call	HPIO_ReadBlock				; Read data from IDE-controller
-.Return:
-	jmp		Int13h_PopXRegsAndReturn
+.ReturnWithErrorCodeInAH:
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 
 ; Invalid sector count (also for AH=3h and AH=4h)
 AH2h_ZeroCntErr:
 	mov		ah, RET_HD_INVALID			; Invalid value passed
-	stc									; Set CF since error
-	jmp		Int13h_PopDiDsAndReturn
+	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 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm	(revision 148)
@@ -1,7 +1,3 @@
-; File name		:	AH3h_HWrite.asm
-; Project name	:	IDE BIOS
-; Created date	:	13.10.2007
-; Last update	:	12.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=3h, Write Disk Sectors.
 
@@ -14,5 +10,9 @@
 ; AH3h_HandlerForWriteDiskSectors
 ;	Parameters:
-;		AH:		Bios function 3h
+;		AL, CX, DH, ES:	Same as in INTPACK
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Parameters on INTPACK in SS:BP:
 ;		AL:		Number of sectors to write
 ;		CH:		Cylinder number, bits 7...0
@@ -20,14 +20,8 @@
 ;				Bits 5...0:	Starting sector number (1...63)
 ;		DH:		Starting head number (0...255)
-;		DL:		Drive number (8xh)
 ;		ES:BX:	Pointer to source data
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h/40h floppy return status
 ;		CF:		0 if successfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -36,23 +30,14 @@
 	jz		SHORT AH2h_ZeroCntErr		;  If so, return with error
 
-	; Save registers
-	push	dx
-	push	cx
-	push	bx
-	push	ax
-
 	; Select sector or block mode command
-	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
 	mov		ah, HCMD_WRITE_SECT			; Load sector mode command
 	cmp		BYTE [di+DPT.bSetBlock], 1	; Block mode enabled?
-	jbe		SHORT .XferData				;  If not, jump to transfer
-	mov		ah, HCMD_WRITE_MUL			; Load block mode command
+	eCMOVA	ah, HCMD_WRITE_MUL			; Load block mode command
 
 	; Transfer data
-ALIGN JUMP_ALIGN
-.XferData:
 	call	HCommand_OutputCountAndLCHSandCommand
-	jc		SHORT .Return				; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH
+	mov		bx, [bp+INTPACK.bx]
 	call	HPIO_WriteBlock				; Write data to IDE-controller
-.Return:
-	jmp		Int13h_PopXRegsAndReturn
+.ReturnWithErrorCodeInAH:
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 148)
@@ -1,8 +1,3 @@
-; File name		:	AH4h_HVerify.asm
-; Project name	:	IDE BIOS
-; Created date	:	13.10.2007
-; Last update	:	14.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=4h, Verify Disk Sectors.
 
@@ -15,5 +10,9 @@
 ; AH4h_HandlerForVerifyDiskSectors
 ;	Parameters:
-;		AH:		Bios function 4h
+;		AL, CX, DH:	Same as in INTPACK
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Parameters on INTPACK in SS:BP:
 ;		AL:		Number of sectors to verify
 ;		CH:		Cylinder number, bits 7...0
@@ -21,14 +20,7 @@
 ;				Bits 5...0:	Starting sector number (1...63)
 ;		DH:		Starting head number (0...255)
-;		DL:		Drive number
-;		ES:BX:	Pointer to source data (not used)
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h/40h floppy return status
 ;		CF:		0 if successfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -36,44 +28,10 @@
 	test	al, al						; Invalid sector count?
 	jz		SHORT AH2h_ZeroCntErr		;  If so, return with error
-	push	dx
-	push	cx
-	push	bx
-	push	ax
-%ifndef USE_186
-	call	AH4h_VerifySectors
-	jmp		Int13h_PopXRegsAndReturn
-%else
-	push	Int13h_PopXRegsAndReturn
-	; Fall through to AH4h_VerifySectors
-%endif
 
-
-;--------------------------------------------------------------------
-; Verifies hard disk sectors.
-;
-; AH4h_VerifySectors
-;	Parameters:
-;		AL:		Number of sectors to verify
-;		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)
-;		DL:		Drive number
-;		DS:		RAMVARS segment
-;	Returns:
-;		DS:DI:	Ptr to DPT
-;		AH:		Int 13h/40h floppy return status
-;		CF:		0 if successfull, 1 if error
-;	Corrupts registers:
-;		AL, BX, CX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-AH4h_VerifySectors:
-	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
 	mov		ah, HCMD_VERIFY_SECT		; Load command to AH
 	call	HCommand_OutputCountAndLCHSandCommand
-	jc		SHORT .Return				; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH
 	mov		bx, di						; DS:BX now points to DPT
-	jmp		HStatus_WaitIrqOrRdy		; Wait for IRQ or RDY
-.Return:
-	ret
+	call	HStatus_WaitIrqOrRdy		; Wait for IRQ or RDY
+.ReturnWithErrorCodeInAH:
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm	(revision 148)
@@ -10,9 +10,8 @@
 ; AH8h_HandlerForReadDiskDriveParameters
 ;	Parameters:
-;		AH:		Bios function 8h
-;		DL:		Drive number
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Returns with INTPACK in SS:BP:
 ;		CH:		Maximum cylinder number, bits 7...0
 ;		CL:		Bits 7...6: Cylinder number bits 9...8
@@ -22,7 +21,4 @@
 ;		AH:		Int 13h/40h floppy return status
 ;		CF:		0 if successfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -30,18 +26,17 @@
 	call	RamVars_IsDriveHandledByThisBIOS
 	jnc		SHORT .GetDriveParametersForForeignHardDiskInDL
+	call	AH8h_GetDriveParameters
+	jmp		SHORT .ReturnAfterStoringValuesToIntpack
 
-	push	bx
-	call	AH8h_GetDriveParameters
-	pop		bx
-	jmp		Int13h_ReturnWithValueInDL
-
-ALIGN JUMP_ALIGN
 .GetDriveParametersForForeignHardDiskInDL:
 	call	Int13h_CallPreviousInt13hHandler
 	jc		SHORT .ReturnErrorFromPreviousInt13hHandler
 	call	RamVars_GetCountOfKnownDrivesToDL
-	jmp		Int13h_ReturnWithValueInDL
+.ReturnAfterStoringValuesToIntpack:
+	mov		[bp+INTPACK.cx], cx
+	mov		[bp+INTPACK.dx], dx
+	xor		ah, ah
 .ReturnErrorFromPreviousInt13hHandler:
-	jmp		Int13h_PopDiDsAndReturn
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 
 
@@ -51,6 +46,5 @@
 ; AH8h_GetDriveParameters
 ;	Parameters:
-;		DL:		Drive number
-;		DS:		RAMVARS segment
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;	Returns:
 ;		CH:		Maximum cylinder number, bits 7...0
@@ -59,23 +53,16 @@
 ;		DH:		Maximum head number (0...255)
 ;		DL:		Number of drives
-;		DS:DI:	Ptr to DPT
-;		AH:		Int 13h/40h floppy return status
-;		CF:		0 if successfull, 1 if error
 ;	Corrupts registers:
-;		AL, BX
+;		AX, BX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH8h_GetDriveParameters:
-	call	FindDPT_ForDriveNumber
 	call	AccessDPT_GetLCHSfromPCHS	; AX=sectors, BX=cylinders, DX=heads
-	call	AH8h_PackReturnValues
-	xor		ax, ax						; Clear AH and CF
-	ret
-
+	; Fall to .PackReturnValues
 
 ;--------------------------------------------------------------------
 ; Packs L-CHS values to INT 13h, AH=08h return values.
 ;
-; AH8h_PackReturnValues
+; .PackReturnValues
 ;	Parameters:
 ;		AX:		Number of L-CHS sectors per track (1...63)
@@ -92,6 +79,5 @@
 ;		AX, BX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-AH8h_PackReturnValues:
+.PackReturnValues:
 	dec		bx						; Cylinder count to last cylinder
 	dec		dx						; Head count to max head number
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 148)
@@ -1,8 +1,3 @@
-; File name		:	AH9h_HInit.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=9h, Initialize Drive Parameters.
 
@@ -15,26 +10,18 @@
 ; AH9h_HandlerForInitializeDriveParameters
 ;	Parameters:
-;		AH:		Bios function 9h
-;		DL:		Drive number
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h return status
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH9h_HandlerForInitializeDriveParameters:
-	push	dx
-	push	cx
-	push	bx
-	push	ax
 %ifndef USE_186
 	call	AH9h_InitializeDriveForUse
-	jmp		Int13h_PopXRegsAndReturn
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %else
-	push	Int13h_PopXRegsAndReturn
+	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 	; Fall through to AH9h_InitializeDriveForUse
 %endif
@@ -46,20 +33,16 @@
 ; AH9h_InitializeDriveForUse
 ;	Parameters:
-;		DL:		Drive number
-;		DS:		RAMVARS segment
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;	Returns:
-;		DS:DI:	Ptr to DPT
 ;		AH:		Int 13h return status
 ;		CF:		0 if succesfull, 1 if error
 ;	Corrupts registers:
-;		AL, BX
+;		AL, BX, DX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AH9h_InitializeDriveForUse:
-	push	dx
 	push	cx
 
 	; Try to select drive and wait until ready
-	call	FindDPT_ForDriveNumber
 	or		BYTE [di+DPT.bReset], MASK_RESET_ALL		; Everything uninitialized
 	call	HDrvSel_SelectDriveAndDisableIRQ
@@ -76,19 +59,15 @@
 .RecalibrateDrive:
 	call	AH11h_RecalibrateDrive
-	mov		dl, [di+DPT.bDrvNum]		; Restore DL
 	jc		SHORT .InitializeBlockMode
 	and		BYTE [di+DPT.bReset], ~FLG_RESET_nRECALIBRATE
 
 	; Initialize block mode transfers
-ALIGN JUMP_ALIGN
 .InitializeBlockMode:
 	call	AH9h_InitializeBlockMode
-	;mov		dl, [di+DPT.bDrvNum]		; Restore DL
 	jc		SHORT .ReturnNotSuccessfull
-	and		BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK
+	and		BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK	; Keeps CF clear
 
 .ReturnNotSuccessfull:
 	pop		cx
-	pop		dx
 	ret
 
@@ -135,5 +114,4 @@
 ; AH9h_InitializeBlockMode
 ;	Parameters:
-;		DL:		Drive number
 ;		DS:DI:	Ptr to DPT
 ;	Returns:
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm	(revision 148)
@@ -10,30 +10,24 @@
 ; AHCh_HandlerForSeek
 ;	Parameters:
-;		AH:		Bios function Ch
+;		CX, DH:	Same as in INTPACK
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Parameters on INTPACK in SS:BP:
 ;		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)
-;		DL:		Drive number
-;	Parameters loaded by Int13h_Jump:
-;		DS:		RAMVARS segment
-;	Returns:
+;	Returns with INTPACK in SS:BP:
 ;		AH:		BIOS Error code
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AHCh_HandlerForSeek:
-	push	dx
-	push	cx
-	push	bx
-	push	ax
 %ifndef USE_186
 	call	AHCh_SeekToCylinder
-	jmp		Int13h_PopXRegsAndReturn
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %else
-	push	Int13h_PopXRegsAndReturn
+	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 	; Fall through to AHCh_SeekToCylinder
 %endif
@@ -41,6 +35,4 @@
 
 ;--------------------------------------------------------------------
-; Seeks to a cylinder.
-;
 ; AHCh_SeekToCylinder
 ;	Parameters:
@@ -49,8 +41,6 @@
 ;				Bits 5...0:	Starting sector number (1...63)
 ;		DH:		Starting head number (0...255)
-;		DL:		Drive Number
-;		DS:		RAMVARS segment
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;	Returns:
-;		DS:DI:	Ptr to DPT
 ;		AH:		BIOS Error code
 ;		CF:		0 if succesfull, 1 if error
@@ -58,12 +48,10 @@
 ;		AL, BX, CX, DX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 AHCh_SeekToCylinder:
-	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
 	mov		ax, HCMD_SEEK<<8			; Load cmd to AH, AL=zero sector cnt
 	call	HCommand_OutputCountAndLCHSandCommand
-	jc		SHORT .Return				; Return if error
+	jc		SHORT .ReturnWithErrorCodeInAH
 	mov		bx, di						; DS:BX now points to DPT
 	jmp		HStatus_WaitIrqOrRdy		; Wait for IRQ or RDY
-.Return:
+.ReturnWithErrorCodeInAH:
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 148)
@@ -10,12 +10,10 @@
 ; AHDh_HandlerForResetHardDisk
 ;	Parameters:
-;		AH:		Bios function Dh
-;		DL:		Drive number
-;	Returns:
+;		DL:		Translated Drive number
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		SS:BP:	Ptr to INTPACK
+;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h return status
 ;		CF:		0 if succesfull, 1 if error
-;		IF:		1
-;	Corrupts registers:
-;		Flags
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -23,7 +21,7 @@
 %ifndef USE_186
 	call	AHDh_ResetDrive
-	jmp		Int13h_PopDiDsAndReturn
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %else
-	push	Int13h_PopDiDsAndReturn
+	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 	; Fall through to AHDh_ResetDrive
 %endif
@@ -41,12 +39,10 @@
 ;		CF:		0 if succesfull, 1 if error
 ;	Corrupts registers:
-;		DI
+;		AL, CX, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 AHDh_ResetDrive:
 	push	dx
-	push	cx
 	push	bx
-	push	ax
 
 	call	FindDPT_ForDriveNumber		; DS:DI now points to DPT
@@ -60,8 +56,5 @@
 	call	AHDh_InitializeMasterAndSlave
 
-	pop		bx							; Pop old AX
-	mov		al, bl						; Restore AL
 	pop		bx
-	pop		cx
 	pop		dx
 	ret
@@ -90,5 +83,5 @@
 	call	HDrvSel_OutputDeviceControlByte
 	mov		ax, 5						; Delay at least 5us
-	call	HTimer_MicrosecondsFromAX
+	call	HTimer_DelayMicrosecondsFromAX
 
 	; HSR1: Clear_wait
@@ -96,5 +89,5 @@
 	out		dx, al						; End Reset
 	mov		ax, 2000					; Delay at least 2ms
-	call	HTimer_MicrosecondsFromAX
+	call	HTimer_DelayMicrosecondsFromAX
 
 	; 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 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCapacity.asm	(revision 148)
@@ -13,4 +13,5 @@
 ;		DL:		Drive number
 ;		DS:		RAMVARS segment
+;		DS:DI:	Ptr to DPT (HCapacity_GetSectorCountFromOurAH08h)
 ;	Returns:
 ;		DX:AX:	Total sector count
@@ -21,17 +22,14 @@
 ALIGN JUMP_ALIGN
 HCapacity_GetSectorCountFromForeignAH08h:
-	mov		ah, 08h			; Get Drive Parameters
+	mov		ah, GET_DRIVE_PARAMETERS
 	call	Int13h_CallPreviousInt13hHandler
-	jmp		SHORT HCapacity_ConvertAH08hReturnValuesToSectorCount
+	jmp		SHORT ConvertAH08hReturnValuesToSectorCount
 
 ALIGN JUMP_ALIGN
 HCapacity_GetSectorCountFromOurAH08h:
-	push	di
 	call	AH8h_GetDriveParameters
-	pop		di
-	; Fall to HCapacity_ConvertAH08hReturnValuesToSectorCount
+	; Fall to ConvertAH08hReturnValuesToSectorCount
 
-ALIGN JUMP_ALIGN
-HCapacity_ConvertAH08hReturnValuesToSectorCount:
+ConvertAH08hReturnValuesToSectorCount:
 	call	HAddress_ExtractLCHSFromBiosParams
 	xor		ax, ax			; Zero AX
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HDrvSel.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HDrvSel.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HDrvSel.asm	(revision 148)
@@ -4,4 +4,29 @@
 ; Section containing code
 SECTION .text
+
+;--------------------------------------------------------------------
+; Selects Master or Slave drive and disables interrupts. Interrupts should
+; be disabled for commands that do not transfer data.
+; This function returns after drive is ready to accept commands.
+;
+; HDrvSel_SelectDriveAndDisableIRQ
+;	Parameters:
+;		DS:DI:	Ptr to DPT
+;	Returns:
+;		AH:		BIOS Error code
+;		CF:		0 if drive selected successfully
+;				1 if any error
+;	Corrupts registers:
+;		AL
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+HDrvSel_SelectDriveAndDisableIRQ:
+	push	bx
+	mov		al, [di+DPT.bDrvCtrl]	; Load Device Control Byte
+	or		al, FLG_IDE_CTRL_nIEN	; Disable interrupts
+	call	HDrvSel_SelectDriveAndSetControlByte
+	pop		bx
+	ret
+
 
 ;--------------------------------------------------------------------
@@ -81,27 +106,2 @@
 	out		dx, al							; Output Device Control byte
 	ret
-
-
-;--------------------------------------------------------------------
-; Selects Master or Slave drive and disables interrupts. Interrupts should
-; be disabled for commands that do not transfer data.
-; This function returns after drive is ready to accept commands.
-;
-; HDrvSel_SelectDriveAndDisableIRQ
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;	Returns:
-;		AH:		BIOS Error code
-;		CF:		0 if drive selected successfully
-;				1 if any error
-;	Corrupts registers:
-;		AL
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-HDrvSel_SelectDriveAndDisableIRQ:
-	push	bx
-	mov		al, [di+DPT.bDrvCtrl]	; Load Device Control Byte
-	or		al, FLG_IDE_CTRL_nIEN	; Disable interrupts
-	call	HDrvSel_SelectDriveAndSetControlByte
-	pop		bx
-	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm	(revision 148)
@@ -1,3 +1,3 @@
-; Project name	:	IDE BIOS
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Error checking functions for BIOS Hard disk functions.
 
@@ -6,6 +6,5 @@
 
 ;--------------------------------------------------------------------
-; HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit
-; HError_ProcessErrorsAfterPollingBSY
+; HError_GetErrorCodeToAHforTimeoutWhenPolling
 ;	Parameters:
 ;		DS:		RAMVARS segment
@@ -18,7 +17,6 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit:
-	call	HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
-	call	GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
+HError_GetErrorCodeToAHforTimeoutWhenPolling:
+	call	HError_GetErrorCodeToAHafterPolling
 	jc		SHORT .ReturnErrorCodeInAH
 	mov		ah, RET_HD_TIMEOUT			; Force timeout since no actual error...
@@ -28,6 +26,17 @@
 
 
+;--------------------------------------------------------------------
+; HError_GetErrorCodeToAHafterPolling
+;	Parameters:
+;		DS:		RAMVARS segment
+;	Returns:
+;		AH:		BIOS error code
+;		CF:		Set if error
+;				Cleared if no error
+;	Corrupts registers:
+;		AL
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-HError_ProcessErrorsAfterPollingBSY:
+HError_GetErrorCodeToAHafterPolling:
 %ifndef USE_186
 	call	HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
@@ -131,2 +140,31 @@
 	db	RET_HD_BADSECTOR	; Bit7=BBK, Bad Block Detected
 	db	RET_HD_STATUSERR	; When Error Register is zero
+
+
+;--------------------------------------------------------------------
+; HError_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
+; HError_SetErrorCodeToIntpackInSSBPfromAH
+;	Parameters:
+;		AH:		BIOS error code (00h = no error)
+;		SS:BP:	Ptr to INTPACK
+;	Returns:
+;		SS:BP:	Ptr to INTPACK with error condition set
+;	Corrupts registers:
+;		DS, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+HError_SetErrorCodeToBdaAndToIntpackInSSBPfromAH:
+	; Store error code to BDA
+	LOAD_BDA_SEGMENT_TO	ds, di
+	mov		[BDA.bHDLastSt], ah
+
+	; Store error code to INTPACK
+HError_SetErrorCodeToIntpackInSSBPfromAH:
+	mov		[bp+INTPACK.ah], ah
+	test	ah, ah
+	jnz		SHORT .SetCFtoIntpack
+	and		BYTE [bp+INTPACK.flags], ~FLG_FLAGS_CF
+	ret
+.SetCFtoIntpack:
+	or		BYTE [bp+INTPACK.flags], FLG_FLAGS_CF
+	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm	(revision 148)
@@ -8,5 +8,5 @@
 ; HIRQ_WaitForIRQ
 ;	Parameters:
-;		DS:		RAMVARS segment
+;		DS:BX:	Ptr to DPT
 ;	Returns:
 ;		CF:		Set if wait done by operating system
@@ -36,10 +36,9 @@
 
 	LOAD_BDA_SEGMENT_TO	ds, ax, !		; Zero AX
+	mov		ah, OS_HOOK_DEVICE_BUSY		; Hard disk busy (AX=9000h)
 	cli									; Disable interrupts
 	cmp		al, [BDA.bHDTaskFlg]		; Task flag already set?
 	jc		SHORT .ReturnFromWaitNotify	;  If so, skip OS notification
-
-	mov		ah, 90h						; Hard disk busy (AX=9000h)
-	int		INTV_SYSTEM_SERVICES		; OS hook, device busy
+	int		BIOS_SYSTEM_INTERRUPT_15h	; OS hook, device busy
 	jnc		SHORT .ReturnFromWaitNotify	; CF cleared, BIOS handles waiting
 
@@ -106,6 +105,6 @@
 
 	; Issue Int 15h, function AX=9100h (Interrupt ready)
-	mov		ax, 9100h					; Interrupt ready, device 0 (HD)
-	int		INTV_SYSTEM_SERVICES
+	mov		ax, OS_HOOK_DEVICE_POST<<8	; Interrupt ready, device 0 (HD)
+	int		BIOS_SYSTEM_INTERRUPT_15h
 
 	pop		ax							; Restore AX
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm	(revision 148)
@@ -21,7 +21,7 @@
 ALIGN JUMP_ALIGN
 HStatus_WaitIrqOrRdy:
-	call	HIRQ_WaitForIRQ
+	call	HIRQ_WaitForIRQ			; For OS hook (we still need error processing)
 	jnc		SHORT .PollRdySinceNoWaitingOnOsHook
-	jmp		HError_ProcessErrorsAfterPollingBSY
+	jmp		HError_GetErrorCodeToAHafterPolling
 
 ALIGN JUMP_ALIGN
@@ -48,5 +48,5 @@
 	call	HIRQ_WaitForIRQ
 	jnc		SHORT .PollDrqSinceNoWaitingOnOsHook
-	jmp		HError_ProcessErrorsAfterPollingBSY
+	jmp		HError_GetErrorCodeToAHafterPolling
 
 ALIGN JUMP_ALIGN
@@ -185,6 +185,6 @@
 .UpdateTimeout:
 	call	HTimer_SetCFifTimeout
-	jnc		SHORT .PollLoop							; Loop if time left (sets CF on timeout)
-	jmp		HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit
+	jnc		SHORT .PollLoop							; Loop if time left
+	jmp		HError_GetErrorCodeToAHforTimeoutWhenPolling
 
 ;--------------------------------------------------------------------
@@ -218,3 +218,3 @@
 ALIGN JUMP_ALIGN
 GetErrorCodeFromPollingToAH:
-	jmp		HError_ProcessErrorsAfterPollingBSY
+	jmp		HError_GetErrorCodeToAHafterPolling
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HTimer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HTimer.asm	(revision 143)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HTimer.asm	(revision 148)
@@ -45,5 +45,5 @@
 ; RTC resolution is 977 microsecs.
 ;
-; HTimer_MicrosecondsFromAX
+; HTimer_DelayMicrosecondsFromAX
 ;	Parameters:
 ;		AX:		Number of microsecs to wait
@@ -53,5 +53,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-HTimer_MicrosecondsFromAX:
+HTimer_DelayMicrosecondsFromAX:
 %ifndef USE_AT
 	mov		ax, 1
@@ -62,13 +62,13 @@
 
 	xor		cx, cx
-	xchg	dx, ax							; Microsecs now in CX:DX
+	xchg	dx, ax						; Microsecs now in CX:DX
 	mov		ah, EVENT_WAIT
 	int		BIOS_SYSTEM_INTERRUPT_15h
-	sti										; XT BIOSes return with interrupt disabled
+	sti									; XT BIOSes return with interrupt disabled
 
 	pop		cx
 	pop		dx
-	mov		ax, 1							; Prepare to wait 1 timer tick
-	jc		SHORT HTimer_TimerTicksFromAX	; Event Wait was unsupported or busy
+	mov		ax, 1								; Prepare to wait 1 timer tick
+	jc		SHORT HTimer_DelayTimerTicksFromAX	; Event Wait was unsupported or busy
 	ret
 %endif
@@ -79,5 +79,5 @@
 ; will occur at 54.9 ms intervals.
 ;
-; HTimer_TimerTicksFromAX
+; HTimer_DelayTimerTicksFromAX
 ;	Parameters:
 ;		AX:		Number of timer ticks to wait
@@ -87,5 +87,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-HTimer_TimerTicksFromAX:
+HTimer_DelayTimerTicksFromAX:
 	sti								; Make sure that interrupts are enabled
 	call	ReadTimeFromBdaToCX
