Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 229)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 233)
@@ -22,37 +22,41 @@
 
 .DriveDetectLoop:							; Loop through IDEVARS
-	mov		si, g_szDetect					; Setup standard print string
+	push	cx
+
+	mov		cx, g_szDetectMaster
+	mov		bh, MASK_DRVNHEAD_SET								; Select Master drive
+	call	StartDetectionWithDriveSelectByteInBHandStringInAX	; Detect and create DPT + BOOTNFO
+
+	mov		cx, g_szDetectSlave
+	mov		bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV  
+	call	StartDetectionWithDriveSelectByteInBHandStringInAX
+		
+	pop		cx
+
+	add		bp, BYTE IDEVARS_size			; Point to next IDEVARS
+
 %ifdef MODULE_SERIAL		
-	cmp		byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
-	jnz		.DriveNotSerial					; Special print string for serial drives
-	mov		si, g_szDetectCOM
-.DriveNotSerial:
+	jcxz	.done							; Set to zero on .ideVarsSerialAuto iteration (if any)
 %endif
-
-	call	.DetectDrives_WithIDEVARS		; Detect Master and Slave
-	add		bp, BYTE IDEVARS_size			; Point to next IDEVARS
+		
 	loop	.DriveDetectLoop
 
 %ifdef MODULE_SERIAL		
 ;
-; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we have a connection)
-; Note that XLATEVARS.bLastSerial is zero'd in RamVars_Initialize, called in Initialize_AutoDetectDrives;
-; bLastSerial it set in the detection code of SerialCommand.asm
+; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection)
 ;
-	cmp		byte [RAMVARS.xlateVars+XLATEVARS.bLastSerial],cl 	; cx = zero after the loop above
-																; less instruction bytes than using immediate
-	jnz		.done												  
-		
+	call	FindDPT_ToDSDIforSerialDevice
+	jc		.done
+
+	mov		bp, ROMVARS.ideVarsSerialAuto	; Point to our special IDEVARS sructure, just for serial scans		
+				
 	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							
+	jnz		.DriveDetectLoop							
+%endif
 
-	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
+.done:
 	ret
-%endif
 
 %if FLG_ROMVARS_SERIAL_SCANDETECT != 8
@@ -60,41 +64,10 @@
 %endif
 
-;--------------------------------------------------------------------
-; Detects IDE hard disks by using information from IDEVARS.
-;
-; DetectDrives_WithIDEVARS
-;	Parameters:
-;		CS:BP:		Ptr to IDEVARS
-;		DS:			RAMVARS segment
-;		ES:			Zero (BDA segment)
-;       SI:		    Ptr to template string
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX, DX, SI, DI
-;--------------------------------------------------------------------
-.DetectDrives_WithIDEVARS:
-	push	cx
-
-	push	si		
-	mov		ax, g_szMaster
-	mov		bh, MASK_DRVNHEAD_SET								; Select Master drive
-	call	StartDetectionWithDriveSelectByteInBHandStringInAX	; Detect and create DPT + BOOTNFO
-	pop		si
-
-	mov		ax, g_szSlave
-	mov		bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
-	call	StartDetectionWithDriveSelectByteInBHandStringInAX
-	pop		cx
-		
-.done:	
-	ret
-
 		
 ;--------------------------------------------------------------------
 ; StartDetectionWithDriveSelectByteInBHandStringInAX
 ;	Parameters:
-;		AX:		Offset to "Master" or "Slave" string
 ;		BH:		Drive Select byte for Drive and Head Register
+;		CX:		Offset to "Master" or "Slave" string
 ;		CS:BP:	Ptr to IDEVARS for the drive
 ;		DS:		RAMVARS segment
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 229)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 233)
@@ -30,5 +30,5 @@
 ; DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
 ;	Parameters:
-;		CS:AX:	Ptr to "Master" or "Slave" string
+;		CS:CX:	Ptr to "Master" or "Slave" string
 ;		CS:BP:	Ptr to IDEVARS
 ;       SI:		Ptr to template string 
@@ -39,30 +39,63 @@
 ;--------------------------------------------------------------------
 DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP:
-	push	bp
-	mov		di, [cs:bp+IDEVARS.wPort]
-%ifdef MODULE_SERIAL
-	mov		cx, [cs:bp+IDEVARS.wSerialPackedPrintBaud]
-%endif
+
+	mov		ax, [cs:bp+IDEVARS.wPort]    	; for IDE: AX=port address, DH=.bDevice
+	mov		dx, [cs:bp+IDEVARS.bDevice-1]   ; for Serial: AL=port address>>2, AH=baud rate
+											;			  DL=COM number character, DH=.bDevice
+
+	push	bp								; setup stack for call to 
+	mov		bp, sp							; BootMenuPrint_FormatCSSIfromParamsInSSBP
+
+	push 	cx								; Push "Master" or "Slave"
 		
-	mov		bp, sp
+	mov		cl, (g_szDetectPort-$$) & 0xff	; Setup print string for standard IDE
+											; Note that we modify only the low order bits of CX a lot here,
+											; saving code space rather than reloading CX completely.
+											; This optimization requires that all the g_szDetect* strings are
+											; on the same 256 byte page, which is checked in strings.asm.
 
-	push 	ax							; Push "Master" or "Slave"
+	cmp		dx, DEVICE_SERIAL_PORT << 8  	; Check if this is a serial device, 
+										 	; And also check if DL is zero, check with the jz below
+											; This optimization requires that DEVICE_SERIAL_PORT be 
+											; the highest value in the DEVICE_* series, ensuring that
+											; anything less in the high order bits is a different device.
+
+	jl		.pushAndPrint					; CX = string to print, AX = port address, DX won't be used
+
+	mov		cl, (g_szDetectCOM-$$) & 0xff	; Setup print string for COM ports
+	push	cx								; And push now.  We use the fact that format strings can contain
+											; themselves format strings.
+
+	push	dx								; Push COM number character
+				
+ 	mov		cl, (g_szDetectCOMAuto-$$) & 0xff	; Setup secondary print string for "Auto"
 		
-	push	di							; Push Port address or COM port number
+	jz		.pushAndPrint					; CX = string to print, AX and DX won't be used
+		
+	mov		cl, (g_szDetectCOMLarge-$$) & 0xff	; Setup secondary print string for "COMn/xx.yK"
 
-%ifdef MODULE_SERIAL
-;
-; Print baud rate from .wSerialPackedPrintBaud, in two parts - %u and then %c
-; 
-	mov		ax,cx						; Unpack baud rate number
-	and		ax,DEVICE_SERIAL_PRINTBAUD_NUMBERMASK
-	push	ax
+	mov		al,ah							; baud rate divisor to AL
+	cbw										; clear AH, AL will always be less than 128
+	xchg	si,ax							; move AX to SI for divide
+	mov		ax,1152							; baud rate to displa is 115200/divisor, the "00" is handled
+											; in the print strings
+	xor		dx,dx							; clear top 16-bits of dividend
+	div		si								; and divide...  Now AX = baud rate/100, DX = 0 (always a clean divide)
+		
+	mov		si,10							; Now separate the whole portion from the fractional for "K" display
+	div		si								; and divide...  Now AX = baud rate/1000, DX = low order digit
+		
+	cmp		ax,si							; <= 10: "2400", "9600", etc.; >10: "19.2K", "38.4K", etc.
+	jae		.pushAndPrint
 
-	mov		al,ch						; Unpack baud rate postfix ('0' or 'K')
-	eSHR_IM	al,2				        ; also effectively masks off the postfix
-	add		al,DEVICE_SERIAL_PRINTBAUD_POSTCHARADD
-	push	ax
-%endif
-						
+	mov		cl, (g_szDetectCOMSmall-$$) & 0xff	; Setup secondary print string for "COMn/XXy00"
+		
+.pushAndPrint:	
+	push	cx								; Push print string
+	push	ax								; Push high order digits, or port address, or N/A
+	push	dx								; Push low order digit, or N/A
+
+	mov		si, g_szDetectOuter				; Finally load SI with wrapper string "IDE %s at %s: "
+
 	jmp		short DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay	
 
@@ -92,2 +125,3 @@
 
 
+
