Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	25.3.2010
-; Last update	:	3.8.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Displays Boot Menu.
 
@@ -31,6 +32,6 @@
 	call	BootMenu_Enter			; Get selected menuitem index to CX
 	call	BootMenuPrint_ClearScreen
-	cmp		cx, BYTE 0				; -1 if nothing selected (ESC pressed)
-	jl		SHORT BootMenu_DisplayAndReturnSelection
+	test	cx, cx					; -1 if nothing selected (ESC pressed)
+	js		SHORT BootMenu_DisplayAndReturnSelection
 	call	BootMenu_CheckAndConvertHotkeyToMenuitem
 	jc		SHORT .SetDriveTranslationForHotkey
Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	26.3.2010
-; Last update	:	3.8.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Functions for printing boot menu strings.
 
@@ -43,14 +44,13 @@
 ;		DH:		Cursor Y coordinate
 ;	Corrupts registers:
-;		AX
+;		Nothing
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 BootMenuPrint_GetCoordinatesForBottomStrings:
 	mov		dx, 1800h				; (0, 24)
-	xor		ax, ax					; Zero AX
-	sub		al, bl					; Set CF if any floppy drives
-	sbb		dh, 0					; Decrement Y-coordinate if necessary
-	sub		ah, bh					; Set CF if any hard disks
-	sbb		dh, 0					; Decrement Y-coordinate if necessary
+	cmp		dl, bl					; Set CF if any floppy drives
+	sbb		dh, dl					; Decrement Y-coordinate if necessary
+	cmp		dl, bh					; Set CF if any hard disks
+	sbb		dh, dl					; Decrement Y-coordinate if necessary
 	ret
 
Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	1.4.2010
-; Last update	:	12.4.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Functions to access BOOTVARS struct.
 
@@ -66,5 +67,12 @@
 	cli									; Disable interrupts
 	LOAD_BDA_SEGMENT_TO	ss, sp
-	eLSS	sp, ss:BOOTVARS.dwPostStack
+;	eLSS	sp, ss:BOOTVARS.dwPostStack	; Expanded macro to remove
+										; unneeded CLI instruction
+%ifndef USE_386
+	mov		sp, [ss:BOOTVARS.dwPostStack]
+	mov		ss, [ss:BOOTVARS.dwPostStack+2]
+%else
+	lss		sp, [ss:BOOTVARS.dwPostStack]
+%endif
 	sti									; Enable interrupts
 	jmp		ax
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	21.9.2007
-; Last update	:	24.8.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h BIOS functions (Floppy and Hard disk).
 
@@ -63,6 +64,14 @@
 	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
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	27.9.2007
-; Last update	:	24.8.2010
-; Author		:	Tomi Tilli
+; Last update	:	13.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h function AH=0h, Disk Controller Reset.
 
@@ -98,9 +99,8 @@
 	mov		dl, bl
 	call	RamVars_IsDriveHandledByThisBIOS
-	jc		SHORT .GetFirstDriveForForeignBios
-	ret		; Return what was in BL unmodified
+	jnc		SHORT .Return				; Return what was in BL unmodified
+	mov		dl, 80h
 ALIGN JUMP_ALIGN
-.GetFirstDriveForForeignBios:
-	mov		dl, 80h
+.Return:
 	ret
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	28.9.2007
-; Last update	:	29.7.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h function AH=11h, Recalibrate.
 
@@ -31,6 +32,11 @@
 	push	bx
 	push	ax
+%ifndef USE_186
 	call	AH11h_RecalibrateDrive
 	jmp		Int13h_PopXRegsAndReturn
+%else
+	push	Int13h_PopXRegsAndReturn
+	; Fall through to AH11h_RecalibrateDrive
+%endif
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH14h_HDiag.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH14h_HDiag.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH14h_HDiag.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	28.9.2007
-; Last update	:	24.8.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h function AH=14h, Controller Internal Diagnostic.
 
@@ -31,9 +32,8 @@
 	mov		al, [di+DPT.bReset]			; Load reset byte to AL
 	test	al, al						; Any error?
-	jnz		SHORT .ReturnError
+	mov		ah, RET_HD_RESETFAIL		; Assume there was an error
+	stc
+	jnz		SHORT .Return
 	xor		ah, ah						; Zero AH and CF since success
+.Return:
 	jmp		Int13h_PopDiDsAndReturn
-.ReturnError:
-	mov		ah, RET_HD_RESETFAIL
-	stc
-	jmp		Int13h_PopDiDsAndReturn
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	28.12.2009
-; Last update	:	12.4.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h function AH=24h, Set Multiple Blocks.
 
@@ -32,6 +33,11 @@
 	push	bx
 	push	ax
+%ifndef USE_186
 	call	AH24h_SetBlockSize
 	jmp		Int13h_PopXRegsAndReturn
+%else
+	push	Int13h_PopXRegsAndReturn
+	; Fall through to AH24h_SetBlockSize
+%endif
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	13.10.2007
-; Last update	:	13.4.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h function AH=4h, Verify Disk Sectors.
 
@@ -39,6 +40,11 @@
 	push	bx
 	push	ax
+%ifndef USE_186
 	call	AH4h_VerifySectors
 	jmp		Int13h_PopXRegsAndReturn
+%else
+	push	Int13h_PopXRegsAndReturn
+	; Fall through to AH4h_VerifySectors
+%endif
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	9.12.2007
-; Last update	:	1.8.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h function AH=9h, Initialize Drive Parameters.
 
@@ -31,6 +32,11 @@
 	push	bx
 	push	ax
+%ifndef USE_186
 	call	AH9h_InitializeDriveForUse
 	jmp		Int13h_PopXRegsAndReturn
+%else
+	push	Int13h_PopXRegsAndReturn
+	; Fall through to AH9h_InitializeDriveForUse
+%endif
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	13.12.2007
-; Last update	:	12.4.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h function AH=Ch, Seek.
 
@@ -35,6 +36,11 @@
 	push	bx
 	push	ax
+%ifndef USE_186
 	call	AHCh_SeekToCylinder
 	jmp		Int13h_PopXRegsAndReturn
+%else
+	push	Int13h_PopXRegsAndReturn
+	; Fall through to AHCh_SeekToCylinder
+%endif
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	9.12.2007
-; Last update	:	24.8.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
 
@@ -25,6 +26,11 @@
 ALIGN JUMP_ALIGN
 AHDh_HandlerForResetHardDisk:
+%ifndef USE_186
 	call	AHDh_ResetDrive
 	jmp		Int13h_PopDiDsAndReturn
+%else
+	push	Int13h_PopDiDsAndReturn
+	; Fall through to AHDh_ResetDrive
+%endif
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 83)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 84)
@@ -2,6 +2,7 @@
 ; Project name	:	IDE BIOS
 ; Created date	:	3.8.2007
-; Last update	:	28.11.2010
-; Author		:	Tomi Tilli
+; Last update	:	14.1.2011
+; Author		:	Tomi Tilli,
+;				:	Krister Nordvall (optimizations)
 ; Description	:	Int 19h BIOS functions (Boot Strap Loader).
 
@@ -118,5 +119,4 @@
 	dec		di								; Decrement retry counter
 	jnz		SHORT .ReadRetryLoop			; Loop while retries left
-	stc
 ALIGN JUMP_ALIGN
 .Return:
