Index: trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 200)
@@ -65,9 +65,4 @@
 ADDRESSING_MODE_LBA48			EQU		3	; 48-bit LBA Addressing Mode
 
-%macro CustomDPT_GetUnshiftedAddressModeToALZF 0
-	mov		al, [di+DPT.bFlagsLow]
-	and		al, MASKL_DPT_ADDRESSING_MODE
-%endmacro
-
 ; Number of Sectors per Track is fixed to 63 for LBA assist calculation.
 ; 1024 cylinders, 256 heads, 63 sectors = 8.4 GB limit (but DOS does not support more than 255 heads)
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 200)
@@ -100,9 +100,17 @@
 ;   baud rate = b, where 00 = 2400, 01 = 9600, 10 = 38.4K, 11 = 115.2K
 ;
-DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTMASK		EQU		0fch
-DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTBITS		EQU		03fh
-DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT	EQU		240h
-DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDMASK		EQU		3h
-DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDBITS		EQU		3h
+; 240h/2400baud corresponds to 0 for a PackedPortAndBaud value, which is reserved (in case we need
+; it to know if a value has been set).  Which is why ..._MINPORT is 248h.
+;
+DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTMASK			EQU		0fch
+DEVICE_SERIAL_PACKEDPORTANDBAUD_PORTBITS			EQU		03fh
+DEVICE_SERIAL_PACKEDPORTANDBAUD_PORT_FIELD_POSITION	EQU		2
+DEVICE_SERIAL_PACKEDPORTANDBAUD_STARTINGPORT		EQU		240h
+DEVICE_SERIAL_PACKEDPORTANDBAUD_MINPORT				EQU		248h		; minimum port value that the user can set
+DEVICE_SERIAL_PACKEDPORTANDBAUD_MAXPORT				EQU		438h		; or (..._PORTMASK << 1) + ..._STARTINGPORT
+
+DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDMASK			EQU		3h
+DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUDBITS			EQU		3h
+DEVICE_SERIAL_PACKEDPORTANDBAUD_BAUD_FIELD_POSITION	EQU		0
 
 ; Defines for IDEVARS.wSerialPrintBaud
Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm	(revision 200)
@@ -254,4 +254,5 @@
 ;	Returns:
 ;		BP:		Popped from stack
+;		CF:		Set since menu event was handled successfully		
 ;	Corrupts registers:
 ;		AX, DI
Index: trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 200)
@@ -54,5 +54,5 @@
 ;--------------------------------------------------------------------
 .PushAddressingMode:
-	CustomDPT_GetUnshiftedAddressModeToALZF
+	AccessDPT_GetUnshiftedAddressModeToALZF
 	;; 
 	;; This multiply both shifts the addressing mode bits down to low order bits, and 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 200)
@@ -79,5 +79,5 @@
 	push	dx							; Store base port address
 	xor		cx, cx						; Assume no errors
-	call	FindDPT_ToDSDIForIdeMasterAtPortDX
+	FindDPT_ToDSDIForIdeMasterAtPortDX
 	jnc		SHORT .InitializeSlave		; Master drive not present
 	call	AH9h_InitializeDriveForUse
@@ -85,5 +85,5 @@
 .InitializeSlave:
 	pop		dx							; Restore base port address
-	call	FindDPT_ToDSDIForIdeSlaveAtPortDX
+	FindDPT_ToDSDIForIdeSlaveAtPortDX
 	jnc		SHORT .CombineErrors		; Slave drive not present
 	call	AH9h_InitializeDriveForUse
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 200)
@@ -87,5 +87,5 @@
 		call	Address_ExtractLCHSparametersFromOldInt13hAddress
 			
-		CustomDPT_GetUnshiftedAddressModeToALZF
+		AccessDPT_GetUnshiftedAddressModeToALZF
 		
 ;;; 0: ADDR_DPT_LCHS		
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 200)
@@ -20,9 +20,10 @@
 	call	RamVars_GetIdeControllerCountToCX
 	mov		bp, ROMVARS.ideVars0			; CS:BP now points to first IDEVARS
-.DriveDetectLoop:
-	mov		si, g_szDetect
+
+.DriveDetectLoop:							; Loop through IDEVARS
+	mov		si, g_szDetect					; Setup standard print string
 %ifdef MODULE_SERIAL
 	cmp		byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
-	jnz		.DriveNotSerial
+	jnz		.DriveNotSerial					; Special print string for serial drives
 	mov		si, g_szDetectCOM
 .DriveNotSerial:
@@ -31,11 +32,14 @@
 	add		bp, BYTE IDEVARS_size			; Point to next IDEVARS
 	loop	.DriveDetectLoop
+		
 %ifdef MODULE_SERIAL
-	mov		al,[cs:ROMVARS.wFlags]
-	or		al,[es:BDA.bKBFlgs1]
-	and		al,8		; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
-	jz		.done
-	mov		bp, ROMVARS.ideVarsSerialAuto
-	mov		si, g_szDetectCOMAuto
+	call	FindDPT_ToDSDIforSerialDevice	; Did we already find any serial drives? 
+	jc		.done							; Yes, do not scan
+	mov		al,[cs:ROMVARS.wFlags]			; Configurator set to always scan?
+	or		al,[es:BDA.bKBFlgs1]			; Or, did the user hold down the ALT key?
+	and		al,8							; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
+	jz		.done							
+	mov		bp, ROMVARS.ideVarsSerialAuto	; Point to our special IDEVARS sructure, just for serial scans
+	mov		si, g_szDetectCOMAuto			; Special, special print string for serial drives during a scan
 ;;; fall-through					
 %else
@@ -44,5 +48,5 @@
 
 %if FLG_ROMVARS_SERIAL_SCANDETECT != 8
-%error "DetectDrives is currently coded to assume that FLG_ROMVARS_SERIAL_ALWAYSDETECT is the same bit as the ALT key code in the BDA.  Changes in the code will be needed if these values are no longer the same."
+%error "DetectDrives is currently coded to assume that FLG_ROMVARS_SERIAL_SCANDETECT is the same bit as the ALT key code in the BDA.  Changes in the code will be needed if these values are no longer the same."
 %endif
 
@@ -70,8 +74,23 @@
 	pop		si
 
+%ifdef MODULE_SERIAL
+;
+; This block of code checks to see if we found a master during a serial drives scan.  If no master
+; was found, there is no point in scanning for a slave as the server will not return a slave without a master,
+; as there is very little point given the drives are emulated.  Performing the slave scan will take 
+; time to rescan all the COM port and baud rate combinations.
+;
+	jnc		.masterFound
+	pop		cx
+	jcxz	.done		; note that CX will only be zero after the .DriveDetectLoop, indicating a serial scan
+	push	cx
+.masterFound:
+%endif
+		
 	mov		ax, g_szSlave
 	mov		bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
 	call	StartDetectionWithDriveSelectByteInBHandStringInAX
 	pop		cx
+		
 .done:	
 	ret
@@ -87,5 +106,7 @@
 ;		ES:		Zero (BDA segment)
 ;	Returns:
-;		Nothing
+;		CF:		Set on failure, Clear on success
+;               Note that this is set in the last thing both cases
+;               do: printing the drive name, or printing "Not Found"
 ;	Corrupts registers:
 ;		AX, BX, CX, DX, SI, DI
@@ -150,5 +171,5 @@
 ;		Nothing
 ;	Returns:
-;		Nothing
+;		CF:     Set (from BootMenuPrint_NullTerminatedStringFromCSSIandSetCF)
 ;	Corrupts registers:
 ;		AX, SI
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 200)
@@ -88,4 +88,5 @@
 	pop		bx
 	pop		di
+	clc							; return success up through DetectDrives
 	ret
 
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 200)
@@ -124,2 +124,24 @@
 .ReturnPointerToDRVPARAMS:
 	ret
+
+;--------------------------------------------------------------------
+; AccessDPT_GetUnshiftedAddressModeToALZF
+;	Parameters:
+;		DS:DI:	Ptr to Disk Parameter Table
+;	Returns:
+;		AL:		Addressing Mode (L-CHS, P-CHS, LBA28, LBA48) 
+;               unshifted (still shifted where it is in bFlagsLow)
+;       ZF:     Set based on value in AL
+;	Corrupts registers:
+;		AL
+;--------------------------------------------------------------------
+; 
+; Converted to a macro since only called in two places, and the call/ret overhead 
+; is not worth it for these two instructions (4 bytes total)
+;
+%macro AccessDPT_GetUnshiftedAddressModeToALZF 0
+	mov		al, [di+DPT.bFlagsLow]
+	and		al, MASKL_DPT_ADDRESSING_MODE
+%endmacro
+
+		
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 199)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 200)
@@ -50,5 +50,4 @@
 	ret
 
-
 ;--------------------------------------------------------------------
 ; Finds Disk Parameter Table for
@@ -67,15 +66,20 @@
 ;	Corrupts registers:
 ;		SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-FindDPT_ToDSDIForIdeMasterAtPortDX:
+;
+; Converted to macros since there is only once call site for each of these
+;
+;--------------------------------------------------------------------
+	
+%macro FindDPT_ToDSDIForIdeMasterAtPortDX 0
 	mov		si, IterateToMasterAtPortCallback
-	jmp		SHORT IterateAllDPTs
-
-ALIGN JUMP_ALIGN
-FindDPT_ToDSDIForIdeSlaveAtPortDX:
+	call	IterateAllDPTs
+%endmacro
+
+%macro FindDPT_ToDSDIForIdeSlaveAtPortDX 0
 	mov		si, IterateToSlaveAtPortCallback
-	jmp		SHORT IterateAllDPTs
-
+	call	IterateAllDPTs
+%endmacro
+
+		
 ;--------------------------------------------------------------------
 ; Iteration callback for finding DPT using
@@ -113,4 +117,6 @@
 	jne		SHORT ReturnWrongDPT
 	mov		dl, ch								; Return drive number in DL
+
+ReturnRightDPT:
 	stc											; Set CF since wanted DPT
 	ret
@@ -118,7 +124,8 @@
 
 ;--------------------------------------------------------------------
-; IterateToDptWithInterruptInServiceFlagSet
+; IterateToDptWithFlagsHighSet:
 ;	Parameters:
 ;		DS:DI:	Ptr to DPT to examine
+;       AL:     Bit in bFlagsHigh to test
 ;	Returns:
 ;		CF:		Set if wanted DPT found
@@ -128,16 +135,15 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-IterateToDptWithInterruptInServiceFlagSet:
-	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INTERRUPT_IN_SERVICE
-	jz		SHORT ReturnWrongDPT
-	stc										; Set CF since wanted DPT
-	ret
+IterateToDptWithFlagsHighSet:
+	test	BYTE [di+DPT.bFlagsHigh], al	; Clears CF (but we need the clc below anyway callers above)
+	jnz		SHORT ReturnRightDPT
+
 ReturnWrongDPT:
 	clc										; Clear CF since wrong DPT
 	ret
 
-
 ;--------------------------------------------------------------------
 ; FindDPT_ToDSDIforInterruptInService
+; FindDPT_ToDSDIforSerialDevice
 ;	Parameters:
 ;		DS:		RAMVARS segment
@@ -147,11 +153,21 @@
 ;				Cleared if DPT not found
 ;	Corrupts registers:
-;		SI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
+;		SI, AX, BX (for SerialDevice only)
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+		
+%ifdef MODULE_SERIAL
+FindDPT_ToDSDIforSerialDevice:	
+	mov		al, FLGH_DPT_SERIAL_DEVICE
+
+	SKIP2B	bx
+%endif
+		
+; do not align due to SKIP2B above
 FindDPT_ToDSDIforInterruptInService:
-	mov		si, IterateToDptWithInterruptInServiceFlagSet
+	mov		al, FLGH_DPT_INTERRUPT_IN_SERVICE
+
+	mov		si, IterateToDptWithFlagsHighSet
 	; Fall to IterateAllDPTs
-
 
 ;--------------------------------------------------------------------
@@ -166,6 +182,5 @@
 ;		DS:DI:		Ptr to wanted DPT (if found)
 ;		CF:			Set if wanted DPT found
-;					Cleared if DPT not found
-;					Unchanged if no drives
+;					Cleared if DPT not found, or no DPTs present
 ;	Corrupts registers:
 ;		Nothing unless corrupted by callback function
@@ -175,5 +190,5 @@
 	push	cx
 	mov		cx, [RAMVARS.wDrvCntAndFirst]
-	jcxz	.AllDptsIterated			; Return if no drives
+	jcxz	.NotFound					; Return if no drives
 	mov		di, RAMVARS_size			; Point DS:DI to first DPT
 ALIGN JUMP_ALIGN
@@ -185,4 +200,5 @@
 	dec		cl							; Decrement drives left
 	jnz		SHORT .LoopWhileDPTsLeft
+.NotFound:		
 	clc									; Clear CF since DPT not found
 ALIGN JUMP_ALIGN
