Index: trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 500)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 501)
@@ -55,24 +55,4 @@
 %else					; IDE
 	Device_FinalizeDPT		EQU		IdeDPT_Finalize
-%endif
-
-
-;--------------------------------------------------------------------
-; Device_ResetMasterAndSlaveController
-;	Parameters:
-;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;	Returns:
-;		AH:		INT 13h Error Code
-;		CF:		Cleared if success, Set if error
-;	Corrupts registers:
-;		AL, BX, CX, DX
-;--------------------------------------------------------------------
-%ifdef MODULE_SERIAL	; IDE + Serial
-Device_ResetMasterAndSlaveController:
-	TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE	ReturnSuccessForSerialPort
-	jmp		IdeCommand_ResetMasterAndSlaveController
-
-%else					; IDE
-	Device_ResetMasterAndSlaveController	EQU		IdeCommand_ResetMasterAndSlaveController
 %endif
 
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 500)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 501)
@@ -20,35 +20,4 @@
 ; Section containing code
 SECTION .text
-
-;--------------------------------------------------------------------
-; IdeCommand_ResetMasterAndSlaveController
-;	Parameters:
-;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;	Returns:
-;		AH:		INT 13h Error Code
-;		CF:		Cleared if success, Set if error
-;	Corrupts registers:
-;		AL, BX, CX, DX
-;--------------------------------------------------------------------
-IdeCommand_ResetMasterAndSlaveController:
-	; HSR0: Set_SRST
-	call	AccessDPT_GetDeviceControlByteToAL
-	or		al, FLG_DEVCONTROL_SRST | FLG_DEVCONTROL_nIEN	; Set Reset bit
-	OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER		DEVICE_CONTROL_REGISTER_out
-	mov		ax, HSR0_RESET_WAIT_US
-	call	Timer_DelayMicrosecondsFromAX
-
-	; HSR1: Clear_wait
-	call	AccessDPT_GetDeviceControlByteToAL
-	or		al, FLG_DEVCONTROL_nIEN
-	and		al, ~FLG_DEVCONTROL_SRST						; Clear reset bit
-	OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER		DEVICE_CONTROL_REGISTER_out
-	mov		ax, HSR1_RESET_WAIT_US
-	call	Timer_DelayMicrosecondsFromAX
-
-	; HSR2: Check_status
-	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MAXIMUM, FLG_STATUS_BSY)
-	jmp		IdeWait_PollStatusFlagInBLwithTimeoutInBH
-
 
 ;--------------------------------------------------------------------
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm	(revision 500)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm	(revision 501)
@@ -77,5 +77,5 @@
 
 .ShlRegisterIndexInDX:
-	eSHL_IM	dx, 1
+	shl		dx, 1
 	; Fall to .InputToALfromRegisterInDX
 
@@ -98,12 +98,10 @@
 ;--------------------------------------------------------------------
 IdeIO_OutputALtoIdeControlBlockRegisterInDL:
-	; Note! We do not need to reverse A0 and A3 for XTIDE rev 2 since
-	; the only Control Block Register we access is DEVICE_CONTROL_REGISTER_out
-	; at offset 6 (0110b).
 	xor		dh, dh	; IDE Register index now in DX
 
 	mov		bl, [di+DPT_ATA.bDevice]
 	cmp		bl, DEVICE_8BIT_XTIDE_REV2
-	jbe		SHORT .OutputALtoControlBlockRegisterInDX	; Standard IDE controllers and XTIDE rev 1
+	je		SHORT .ReverseA0andA3fromRegisterIndexInDX
+	jb		SHORT .OutputALtoControlBlockRegisterInDX	; Standard IDE controllers and XTIDE rev 1
 
 %ifdef MODULE_8BIT_IDE_ADVANCED
@@ -117,7 +115,16 @@
 %endif
 
+.ReverseA0andA3fromRegisterIndexInDX:
+	; We cannot use lookup table since A3 will be always set because
+	; Control Block Registers start from Command Block + 8h. We can do
+	; a small trick since we only access Device Control Register at
+	; offset 6h: Always clear A3 and set A0.
+	add		dx, [cs:bx+IDEVARS.wControlBlockPort]
+	xor		dl, 1001b						; Clear A3, Set A0
+	jmp		SHORT OutputALtoPortInDX
+
 .ShlRegisterIndexInDX:
 	add		dl, XTCF_CONTROL_BLOCK_OFFSET
-	eSHL_IM	dx, 1
+	shl		dx, 1
 	jmp		SHORT OutputALtoRegisterInDX
 
@@ -163,5 +170,5 @@
 	ret
 %endif
-		
+
 .ReverseA0andA3fromRegisterIndexInDX:
 	mov		bx, dx
@@ -170,5 +177,5 @@
 
 .ShlRegisterIndexInDX:
-	eSHL_IM	dx, 1
+	shl		dx, 1
 	; Fall to OutputALtoRegisterInDX
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 500)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 501)
@@ -38,14 +38,6 @@
 ;--------------------------------------------------------------------
 AH0h_HandlerForDiskControllerReset:
-	; Reset Floppy Drives with INT 40h
 	xor		bx, bx						; Zero BH to assume no errors
 	or		bl, dl						; Copy requested drive to BL
-	eCMOVS	dl, bh						; Reset Floppy Drive(s) with 00h since DL has Hard Drive number
-
-	xor		ah, ah						; Disk Controller Reset
-	int		BIOS_DISKETTE_INTERRUPT_40h
-	call	BackupErrorCodeFromTheRequestedDriveToBH
-	; We do not reset Hard Drives if DL was 0xh on entry
-
 
 %ifdef MODULE_SERIAL_FLOPPY
@@ -69,13 +61,13 @@
 %endif
 
-	; Reset foreign Hard Drives (those handled by other BIOSes)
+	; Reset foreign Floppy and Hard Drives (those handled by other BIOSes)
+	call	ResetForeignDrives
 	test	bl, bl										; If we were called with a floppy disk, then we are done,
 	jns		SHORT .SkipHardDiskReset					; don't do hard disks.
-	call	ResetForeignHardDisks
 
 	; Resetting our hard disks will modify dl and bl to be idevars offset based instead of drive number based,
 	; such that this call must be the last in the list of reset routines called.
 	;
-	; This needs to happen after ResetForeignHardDisks, as that call may have set the error code for 80h,
+	; This needs to happen after ResetForeignDrives, as that call may have set the error code for 80h,
 	; and we need to override that value if we are xlate'd into 80h with one of our drives.
 	;
@@ -88,7 +80,7 @@
 
 ;--------------------------------------------------------------------
-; ResetForeignHardDisks
+; ResetForeignDrives
 ;	Parameters:
-;		BL:		Requested Hard Drive (DL when entering AH=00h)
+;		BL:		Requested Floppy or Hard Drive (DL when entering AH=00h)
 ;		DS:		RAMVARS segment
 ;	Returns:
@@ -97,5 +89,5 @@
 ;		AX, DL
 ;--------------------------------------------------------------------
-ResetForeignHardDisks:
+ResetForeignDrives:
 	; If there are drives after our drives, those are already reset
 	; since our INT 13h was called by some other BIOS.
@@ -103,6 +95,6 @@
 	; There could be more in chain but let the previous one handle them.
 	mov		dl, [RAMVARS.bFirstDrv]
-	or		dl, 80h					; We may not have our drives at all!
-	MIN_U	dl, bl					; BL is always Hard Drive number
+	or		dl, 80h					; We may not have our drives at all so change 0 to 80h!
+	MIN_U	dl, bl
 
 	xor		ah, ah					; Disk Controller Reset
@@ -135,4 +127,5 @@
 ; ResetHardDisksHandledByOurBIOS
 ;	Parameters:
+;		BL:		Requested drive (DL when entering AH=00h)
 ;		DS:DI:	Ptr to DPT for requested drive
 ;				If DPT pointer is not available, or error result in BH won't be used anyway,
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 500)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 501)
@@ -65,8 +65,4 @@
 	call	Interrupts_UnmaskInterruptControllerForDriveInDSDI
 %endif
-	call	Device_ResetMasterAndSlaveController
-	;jc		SHORT .ReturnError					; CF would be set if slave drive present without master
-												; (error register has special values after reset)
-
 	; Initialize Master and Slave drives
 	call	AccessDPT_GetIdevarsToCSBX
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 500)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 501)
@@ -63,4 +63,9 @@
 	mov		ax, [es:BIOS_DISK_INTERRUPT_13h*4]	; Load old INT 13h offset
 	mov		[RAMVARS.fpOldI13h], ax				; Store old INT 13h offset
+
+	; NOTE! Installing INT 40h handler is currently uncommented to test
+	; if it is really needed. I suspect that it is not. Many bytes can be
+	; saved if INT 40h related code can be removed.
+%if 0
 
 	; Only store INT 13h handler to 40h if 40h is not already installed.
@@ -72,4 +77,5 @@
 	mov		[es:BIOS_DISKETTE_INTERRUPT_40h*4+2], dx	; Store old INT 13h segment
 .Int40hAlreadyInstalled:
+%endif ; 0
 
 	mov		al, BIOS_DISK_INTERRUPT_13h			; INT 13h interrupt vector offset
