Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 529)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 530)
@@ -58,28 +58,36 @@
 .SkipEddConfigurationParameters:
 	mov		[si+EDRIVE_INFO.wSize], cx
-	mov		WORD [si+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS | FLG_CHS_INFORMATION_IS_VALID
+	mov		WORD [si+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS
 
 	; Store total sector count
 	mov		[si+EDRIVE_INFO.qwTotalSectors], ax
-	xor		ax, ax									; Return with success
 	mov		[si+EDRIVE_INFO.qwTotalSectors+2], dx
 	mov		[si+EDRIVE_INFO.qwTotalSectors+4], bx
-	mov		[si+EDRIVE_INFO.qwTotalSectors+6], ax	; Always zero
+	xor		cx, cx
+	mov		[si+EDRIVE_INFO.qwTotalSectors+6], cx	; Always zero
 	mov		WORD [si+EDRIVE_INFO.wSectorSize], 512
 
-	; Store P-CHS
+	; Store P-CHS. Based on phoenix specification this is returned only if
+	; total sector count is 15,482,880 or less.
+	sub		ax, 4001h
+	sbb		dx, 0ECh
+	sbb		bx, cx		; Zero
+	jnc		SHORT .ReturnWithSuccess	; More than EC4000h
+	or		WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
+
 	eMOVZX	dx, BYTE [es:di+DPT.bPchsHeads]
-	xor		ax, ax									; Also a return code
 	mov		[si+EDRIVE_INFO.dwHeads], dx
-	mov		[si+EDRIVE_INFO.dwHeads+2], ax
+	mov		[si+EDRIVE_INFO.dwHeads+2], cx
 
 	mov		dl, [es:di+DPT.bPchsSectorsPerTrack]
 	mov		[si+EDRIVE_INFO.dwSectorsPerTrack], dx
-	mov		[si+EDRIVE_INFO.dwSectorsPerTrack+2], ax
+	mov		[si+EDRIVE_INFO.dwSectorsPerTrack+2], cx
 
 	mov		dx, [es:di+DPT.wPchsCylinders]
 	mov		[si+EDRIVE_INFO.dwCylinders], dx
-	mov		[si+EDRIVE_INFO.dwCylinders+2], ax
+	mov		[si+EDRIVE_INFO.dwCylinders+2], cx
 
+.ReturnWithSuccess:
+	xor		ax, ax
 .ReturnWithError:
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 529)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 530)
@@ -22,5 +22,4 @@
 SECTION .text
 
-%ifdef COPY_13H_HANDLER_TO_40H
 ;--------------------------------------------------------------------
 ; Checks is floppy drive handler installed to interrupt vector 40h.
@@ -36,36 +35,16 @@
 ;--------------------------------------------------------------------
 FloppyDrive_IsInt40hInstalled:
-	cmp		WORD [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], 0C000h	; Any ROM segment?
-%ifdef USE_AT	; No need to verify on XT systems.
-	jb		SHORT .Int40hHandlerIsNotInstalled
-	call	.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
-.Int40hHandlerIsNotInstalled:
-%endif
-	cmc
-	ret
-
-;--------------------------------------------------------------------
-; .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
-;	Parameters:
-;		Nothing
-;	Returns:
-;		CF:		Cleared if INT 40h is installed
-;				Set if INT 40h is not installed
-;	Corrupts registers:
-;		BX, CX, DI
-;--------------------------------------------------------------------
 %ifdef USE_AT
-.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
 	push	es
 	push	dx
 	push	ax
 
-	call	.LoadInt40hVerifyParameters
+	call	LoadInt40hVerifyParameters
 	int		BIOS_DISK_INTERRUPT_13h
 	jc		SHORT .Int40hIsInstalled	; Maybe there are not any floppy drives at all
-	push	es
-	push	di
+	push	es							; Drive Parameter Table segment
+	push	di							; Drive Parameter Table offset
 
-	call	.LoadInt40hVerifyParameters
+	call	LoadInt40hVerifyParameters
 	int		BIOS_DISKETTE_INTERRUPT_40h
 
@@ -83,8 +62,13 @@
 	pop		dx
 	pop		es
+
+%else ; if XT build
+	cmp		WORD [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], 0C000h	; Any ROM segment? (set CF if not)
+%endif ; USE_AT
+	cmc
 	ret
 
 ;--------------------------------------------------------------------
-; .LoadInt40hVerifyParameters
+; LoadInt40hVerifyParameters
 ;	Parameters:
 ;		Nothing
@@ -96,13 +80,12 @@
 ;		DH
 ;--------------------------------------------------------------------
-.LoadInt40hVerifyParameters:
-	mov		ah, 08h				; Get Drive Parameters
-	cwd							; Floppy drive 0
+%ifdef USE_AT
+LoadInt40hVerifyParameters:
+	mov		ah, GET_DRIVE_PARAMETERS
+	cwd						; Floppy drive 0
 	mov		di, dx
-	mov		es, dx				; ES:DI = 0000:0000h to guard against BIOS bugs
+	mov		es, dx			; ES:DI = 0000:0000h to guard against BIOS bugs
 	ret
 %endif
-
-%endif ; COPY_13H_HANDLER_TO_40H
 
 
@@ -130,5 +113,5 @@
 %ifdef MODULE_BOOT_MENU
 FloppyDrive_GetType:
-	mov		ah, 08h			; Get Drive Parameters
+	mov		ah, GET_DRIVE_PARAMETERS
 	xor		bx, bx			; FLOPPY_TYPE_525_OR_35_DD when function not supported
 	int		BIOS_DISKETTE_INTERRUPT_40h
@@ -151,5 +134,5 @@
 	js		.UseBIOSorBDA				; We didn't add in any drives, counts here are not valid
 
-	adc		al,1						; adds in the drive count bit, and adds 1 for count vs. 0-index,
+	adc		al ,1						; adds in the drive count bit, and adds 1 for count vs. 0-index,
 	jmp		.FinishCalc					; need to clear AH on the way out, and add in minimum drive numbers
 
@@ -165,13 +148,7 @@
 	ret
 
-FloppyDrive_GetCountFromBIOS_or_BDA:
-	push	es
 
 ;--------------------------------------------------------------------
-; Reads Floppy Drive Count from BIOS.
-; Does not work on most XT systems. Call .GetCountFromBDA
-; if this function fails.
-;
-; .GetCountFromBIOS
+; FloppyDrive_GetCountFromBIOS_or_BDA
 ;	Parameters:
 ;		Nothing
@@ -181,8 +158,13 @@
 ;				Set if BIOS function not supported
 ;	Corrupts registers:
-;		ES
+;		AH, ES
 ;--------------------------------------------------------------------
+FloppyDrive_GetCountFromBIOS_or_BDA:
+	push	es
+
+; Reads Floppy Drive Count from BIOS.
+; Does not work on most XT systems. Call .GetCountFromBDA
+; if this function fails.
 %ifdef USE_AT
-.GetCountFromBIOS:
 	push	di
 	push	bx
@@ -190,5 +172,5 @@
 	push	dx
 
-	mov		ah, 08h					; Get Drive Parameters
+	mov		ah, GET_DRIVE_PARAMETERS
 	cwd								; Floppy Drive 00h
 	int		BIOS_DISKETTE_INTERRUPT_40h
@@ -199,26 +181,14 @@
 	pop		bx
 	pop		di
-%endif
 
-;--------------------------------------------------------------------
 ; Reads Floppy Drive Count (0...4) from BIOS Data Area.
 ; This function should be used only if .GetCountFromBIOS fails.
-;
-; .GetCountFromBDA
-;	Parameters:
-;		Nothing
-;	Returns:
-;		AL:		Number of Floppy Drives
-;	Corrupts registers:
-;		AH, ES
-;--------------------------------------------------------------------
-%ifndef USE_AT
-.GetCountFromBDA:
+%else ; ifndef USE_AT
 	LOAD_BDA_SEGMENT_TO	es, ax
-	mov		al, [es:BDA.wEquipment]			; Load Equipment WORD low byte
-	mov		ah, al							; Copy it to AH
-	and		ax, 0C001h						; Leave bits 15..14 and 0
-	eROL_IM	ah, 2							; EW low byte bits 7..6 to 1..0
-	add		al, ah							; AL = Floppy Drive count
+	mov		al, [es:BDA.wEquipment]	; Load Equipment WORD low byte
+	mov		ah, al					; Copy it to AH
+	and		ax, 0C001h				; Leave bits 15..14 and 0
+	eROL_IM	ah, 2					; EW low byte bits 7..6 to 1..0
+	add		al, ah					; AL = Floppy Drive count
 %endif
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 529)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 530)
@@ -64,8 +64,7 @@
 	mov		[RAMVARS.fpOldI13h], ax				; Store old INT 13h offset
 
-%ifdef COPY_13H_HANDLER_TO_40H
 	; Only store INT 13h handler to 40h if 40h is not already installed.
 	; At least AMI BIOS for 286 stores 40h handler by itself and calls
-	; 40h from 13h. That system locks to infinite loop if we copy 13h to 40h.
+	; 40h from 13h. That system locks to infinite loop if we blindly copy 13h to 40h.
 	call	FloppyDrive_IsInt40hInstalled
 	jc		SHORT .Int40hAlreadyInstalled
@@ -73,5 +72,4 @@
 	mov		[es:BIOS_DISKETTE_INTERRUPT_40h*4+2], dx	; Store old INT 13h segment
 .Int40hAlreadyInstalled:
-%endif ; COPY_13H_HANDLER_TO_40H
 
 	mov		al, BIOS_DISK_INTERRUPT_13h			; INT 13h interrupt vector offset
Index: /trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- /trunk/XTIDE_Universal_BIOS/makefile	(revision 529)
+++ /trunk/XTIDE_Universal_BIOS/makefile	(revision 530)
@@ -29,5 +29,4 @@
 #                                                                                                  #
 # Not modules but these affect the assembly:                                                       #
-# COPY_13H_HANDLER_TO_40H     Copies existing INT 13h handler to 40h if necessary                  #
 # ELIMINATE_CGA_SNOW          Prevents CGA snowing at the cost of a few bytes                      #
 # RELOCATE_INT13H_STACK **    Relocates INT 13h stack to beginning of stolen conventional memory   #
@@ -102,5 +101,5 @@
 DEFINES_COMMON_LARGE = MODULE_BOOT_MENU MODULE_8BIT_IDE_ADVANCED
 
-DEFINES_XT = $(DEFINES_COMMON) ELIMINATE_CGA_SNOW MODULE_8BIT_IDE_ADVANCED COPY_13H_HANDLER_TO_40H
+DEFINES_XT = $(DEFINES_COMMON) ELIMINATE_CGA_SNOW MODULE_8BIT_IDE_ADVANCED
 DEFINES_XTPLUS = $(DEFINES_COMMON) $(DEFINES_XT) USE_186
 DEFINES_AT = $(DEFINES_COMMON) USE_AT USE_286 MODULE_IRQ MODULE_ADVANCED_ATA
@@ -114,5 +113,5 @@
 
 DEFINES_ALL_FEATURES = MODULE_8BIT_IDE MODULE_8BIT_IDE_ADVANCED MODULE_ADVANCED_ATA MODULE_EBIOS MODULE_BOOT_MENU MODULE_HOTKEYS MODULE_IRQ MODULE_SERIAL MODULE_SERIAL_FLOPPY MODULE_STRINGS_COMPRESSED MODULE_FEATURE_SETS
-DEFINES_ALL_FEATURES += COPY_13H_HANDLER_TO_40H ELIMINATE_CGA_SNOW RELOCATE_INT13H_STACK RESERVE_DIAGNOSTIC_CYLINDER
+DEFINES_ALL_FEATURES += ELIMINATE_CGA_SNOW RELOCATE_INT13H_STACK RESERVE_DIAGNOSTIC_CYLINDER
 
 
