Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 257)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 258)
@@ -22,6 +22,4 @@
 	eMOVZX	bx, dl						; Copy requested drive to BL, zero BH to assume no errors
 	call	ResetFloppyDrivesWithInt40h
-	test	bl, bl
-	jns		SHORT .SkipHardDiskReset
 	call	ResetForeignHardDisks
 	call	AH0h_ResetHardDisksHandledByOurBIOS
@@ -64,6 +62,24 @@
 	xor		ah, ah						; Disk Controller Reset
 	call	Int13h_CallPreviousInt13hHandler
-	jmp		SHORT BackupErrorCodeFromTheRequestedDriveToBH
-
+;;; fall-through to BackupErrorCodeFromTheRequestedDriveToBH
+
+
+;--------------------------------------------------------------------
+; BackupErrorCodeFromTheRequestedDriveToBH
+;	Parameters:
+;		AH:		Error code from the last resetted drive
+;		DL:		Drive last resetted
+;		BL:		Requested drive (DL when entering AH=00h)
+;	Returns:
+;		BH:		Backuped error code
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BackupErrorCodeFromTheRequestedDriveToBH:
+	cmp		dl, bl				; Requested drive?
+	eCMOVE	bh, ah
+	ret
+		
 
 ;--------------------------------------------------------------------
@@ -82,5 +98,5 @@
 	mov		dl, bl
 	call	RamVars_IsDriveHandledByThisBIOS
-	jnc		SHORT .Return				; Return what was in BL unmodified
+	jc		SHORT .Return				; Return what was in BL unmodified
 	mov		dl, 80h
 .Return:
@@ -101,8 +117,7 @@
 ALIGN JUMP_ALIGN
 AH0h_ResetHardDisksHandledByOurBIOS:
-	mov		dh, [RAMVARS.bDrvCnt]		; Load drive count to DH
+	mov		dx, [RAMVARS.wDrvCntAndFirst]	; DL = drive number, DH = drive count
 	test	dh, dh
 	jz		SHORT .AllDrivesReset		; Return if no drives
-	mov		dl, [RAMVARS.bFirstDrv]		; Load number of our first drive
 	add		dh, dl						; DH = one past last drive to reset
 ALIGN JUMP_ALIGN
@@ -114,6 +129,27 @@
 	jb		SHORT .DriveResetLoop		;  If not, reset next drive
 .AllDrivesReset:
-	ret
-
+%ifdef MODULE_SERIAL_FLOPPY
+;
+; "Reset" emulatd serial floppy drives, if any.  There is nothing to actually do for this reset,
+; but record the proper error return code if one of these floppy drives is the drive requested.
+;
+	call	RamVars_UnpackFlopCntAndFirstToAL
+
+	cbw													; Clears AH (there are flop drives) or ffh (there are not)
+														; Either AH has success code (flop drives are present)
+														; or it doesn't matter because we won't match drive ffh
+
+	cwd													; clears DX (there are flop drives) or ffffh (there are not)
+
+	adc		dl, al										; second drive (CF set) if present
+														; If no drive is present, this will result in ffh which 
+														; won't match a drive
+	call	BackupErrorCodeFromTheRequestedDriveToBH
+	mov		dl, al										; We may end up doing the first drive twice (if there is
+	jmp		BackupErrorCodeFromTheRequestedDriveToBH	; only one drive), but doing it again is not harmful.
+%else
+	ret
+%endif
+		
 ;--------------------------------------------------------------------
 ; .BackupErrorCodeFromMasterOrSlaveToBH
@@ -144,4 +180,5 @@
 	ret
 
+		
 ;--------------------------------------------------------------------
 ; GetBasePortToCX
@@ -167,18 +204,2 @@
 
 
-;--------------------------------------------------------------------
-; BackupErrorCodeFromTheRequestedDriveToBH
-;	Parameters:
-;		AH:		Error code from the last resetted drive
-;		DL:		Drive last resetted
-;		BL:		Requested drive (DL when entering AH=00h)
-;	Returns:
-;		BH:		Backuped error code
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-BackupErrorCodeFromTheRequestedDriveToBH:
-	cmp		dl, bl				; Requested drive?
-	eCMOVE	bh, ah
-	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm	(revision 257)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm	(revision 258)
@@ -15,5 +15,6 @@
 ;	Returns with INTPACK:
 ;		If succesfull:
-;			AH:		3 (Hard disk accessible)
+;			AH:		Hard Disk: 3 (Hard disk accessible)
+;                   Floppy:    1 (Floppy disk, without change detection)
 ;			CX:DX:	Total number of sectors
 ;			CF:		0
@@ -25,11 +26,28 @@
 ALIGN JUMP_ALIGN
 AH15h_HandlerForReadDiskDriveSize:
+%ifdef MODULE_SERIAL_FLOPPY
+	mov		cl, 1										; 1 = floppy disk, no change detection
+				
+	test	dl,dl										; DO NOT store the sector count if this is a 
+	jns		.FloppyDrive								; floppy disk, some OS's depend on this not 
+														; happening for floppies in order to boot.
+%endif
+		
 	call	AH15h_GetSectorCountToBXDXAX
-	mov		[bp+IDEPACK.intpack+INTPACK.cx], dx	; HIWORD to CX
-	mov		[bp+IDEPACK.intpack+INTPACK.dx], ax	; LOWORD to DX
+	mov		[bp+IDEPACK.intpack+INTPACK.cx], dx			; HIWORD to CX
+	xchg	[bp+IDEPACK.intpack+INTPACK.dx], ax			; LOWORD to DX, AL gets drive number
 
-	xor		ah, ah
-	call	Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH	; Store success to BDA and CF
-	mov		BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3				; Type code = Hard disk
+	xor		ah, ah		
+%ifdef MODULE_SERIAL_FLOPPY				
+	mov		cl, 3										; 3 = Hard Disk Accessible
+.FloppyDrive:
+		
+	call	Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber	; Store success to BDA and CF		
+	mov		BYTE [bp+IDEPACK.intpack+INTPACK.ah], cl
+%else
+	call	Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH	; Store success to BDA and CF		
+	mov		BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3
+%endif		
+		
 	jmp		Int13h_ReturnFromHandlerWithoutStoringErrorCode
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm	(revision 257)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm	(revision 258)
@@ -20,5 +20,17 @@
 AH1h_HandlerForReadDiskStatus:
 	LOAD_BDA_SEGMENT_TO	ds, ax, !
+
+%ifdef MODULE_SERIAL_FLOPPY
+	test	dl, dl
+	jns		.HardDisk
+	mov		ah, [BDA.bFDRetST]		; Unlike for hard disks below, floppy version does not clear the status
+	jmp		.done
+.HardDisk:	
+%endif
+		
 	xchg	ah, [BDA.bHDLastSt]		; Load and clear last error
+									; Note that AH is cleared with the LOAD_BDA_SEGMENT above
+				
+.done:
 	call	Int13h_SetErrorCodeToIntpackInSSBPfromAH
 	jmp		Int13h_ReturnFromHandlerWithoutStoringErrorCode
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm	(revision 257)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm	(revision 258)
@@ -40,2 +40,3 @@
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAHandTransferredSectorsFromCL
 %endif
+
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm	(revision 257)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm	(revision 258)
@@ -14,4 +14,5 @@
 ;		SS:BP:	Ptr to IDEPACK
 ;	Returns with INTPACK:
+;       BL:     Drive Type (for floppies only)
 ;		CH:		Maximum cylinder number, bits 7...0
 ;		CL:		Bits 7...6: Cylinder number bits 9...8
@@ -19,23 +20,52 @@
 ;		DH:		Maximum head number (0...255)
 ;		DL:		Number of drives
+;       ES:DI:  Floppy DPT (for floppies only)
 ;		AH:		Int 13h/40h floppy return status
 ;		CF:		0 if successfull, 1 if error
 ;--------------------------------------------------------------------
 AH8h_HandlerForReadDiskDriveParameters:
+
 	call	RamVars_IsDriveHandledByThisBIOS
-	jnc		SHORT .GetDriveParametersForForeignHardDiskInDL
+	jnc		SHORT .OurDrive
+
+	call	Int13h_CallPreviousInt13hHandler
+	jnc		SHORT .MidGame
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
+		
+.OurDrive:		
 	call	AH8h_GetDriveParameters
-	jmp		SHORT .ReturnAfterStoringValuesToIntpack
 
-.GetDriveParametersForForeignHardDiskInDL:
-	call	Int13h_CallPreviousInt13hHandler
-	jc		SHORT .ReturnErrorFromPreviousInt13hHandler
-	call	RamVars_GetCountOfKnownDrivesToDL
-.ReturnAfterStoringValuesToIntpack:
+%ifdef MODULE_SERIAL_FLOPPY
+	push	cs							; setup registers if we are a floppy drive, in all cases
+	pop		es							; if it is not a floppy drive, these values will not be put in INTPACK
+	mov		di, AH8h_FloppyDPT
+%endif
+	;; fall-through
+		
+.MidGame:		
+	call	RamVars_GetCountOfKnownDrivesToAX		; assume hard disk for now, will discard if for floppies
+
+	test	byte [bp+IDEPACK.intpack+INTPACK.dl], 080h
+	jnz		.Done
+		
+	mov		[bp+IDEPACK.intpack+INTPACK.bl], bl
+
+	mov		[bp+IDEPACK.intpack+INTPACK.es], es
+	mov		[bp+IDEPACK.intpack+INTPACK.di], di		
+
+	call	FloppyDrive_GetCountToAX
+
+.Done:	
+	mov		ah, dh
+		
 	mov		[bp+IDEPACK.intpack+INTPACK.cx], cx
-	mov		[bp+IDEPACK.intpack+INTPACK.dx], dx
+	xchg	[bp+IDEPACK.intpack+INTPACK.dx], ax		; recover DL for BDA last status byte determination
+
 	xor		ah, ah
-.ReturnErrorFromPreviousInt13hHandler:
+%ifdef MODULE_SERIAL_FLOPPY
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH_ALHasDriveNumber			
+%else
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
+%endif
 
 
@@ -51,5 +81,4 @@
 ;				Bits 5...0:	Maximum sector number (1...63)
 ;		DH:		Maximum head number (0...255)
-;		DL:		Number of drives
 ;	Corrupts registers:
 ;		AX, BX
@@ -73,5 +102,4 @@
 ;				Bits 5...0:	Maximum sector number (1...63)
 ;		DH:		Maximum head number (0...255)
-;		DL:		Number of drives
 ;	Corrupts registers:
 ;		AX, BX
@@ -85,3 +113,61 @@
 	or		cl, bh					; CL bits 0...5 = Sectors per track
 	mov		dh, bl					; DH = Maximum head number
-	jmp		RamVars_GetCountOfKnownDrivesToDL
+		
+%ifdef MODULE_SERIAL_FLOPPY
+	mov		bl,[di+DPT.bFlagsHigh]
+	eSHR_IM	bl,FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION
+%endif		
+	ret
+
+%ifdef MODULE_SERIAL_FLOPPY
+;
+; Floppy Disk Parameter Table.  There is no way to specify more than one of these
+; for any given system, so no way to make this drive or media specific.
+; So we return fixed values out of the ROM for callers might be expecting this information.
+;
+; On AT systems, we return the information for a 1.44 MB disk, 
+; and on XT systems, we return the information for a 360 KB disk.
+;
+AH8h_FloppyDPT:
+%ifdef USE_AT
+	db		0ah << 4 | 0fh			; Offset 0: Drive timings, 1.44MB values
+%else
+	db		0dh << 4 | 0fh			; Offset 0: Drive timings, 360KB values
+%endif
+
+	db		1h << 1 | 0				; Offset 1: Typical values of 1 for head load time
+									;           DMA used (although it actually is not, but is more restrctive)
+	db		25h						; Offset 2: Inactiviy motor turn-off delay, 
+									; 			Typical value of 25h for 2 second delay
+	db		02h						; Offset 3: Sector size, always 512
+
+%ifdef USE_AT
+	db		12h						; Offset 4: Sectors per track, 1.44MB value
+	db		1bh						; Offset 5: Sector gap, 1.44MB value
+%else
+	db		09h						; Offset 4: Sectors per track, 360KB value
+	db		2ah						; Offset 5: Sector gap, 360KB value
+%endif
+
+	db		0ffh					; Offset 6: Data length
+
+%ifdef USE_AT
+	db		6ch						; Offset 7: Format gap length, 1.44MB value
+%else
+	db		50h						; Offset 7: Format gap length, 360KB value
+%endif
+
+	db		0f6h					; Offset 8: Fill byte for format
+	db		0fh						; Offset 9: Head setting time
+	db		08h						; Offset A: Wait for motor startpu time
+
+%ifdef USE_AT
+	db		79						; Offset B: Maximum track number, 1.44MB value
+	db		0						; Offset C: Data transfer rate, 1.44MB value
+	db		4						; Offset D: Diskette CMOS drive type, 1.44MB value
+%else
+	db		39						; Offset B: Maximum track number, 360KB value
+	db		80h						; Offset C: Data transfer rate, 360KB value
+	db		1						; Offset D: Diskette CMOS drive type, 360KB value
+%endif
+%endif
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 257)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 258)
@@ -43,4 +43,14 @@
 	push	cx
 
+%ifdef MODULE_SERIAL
+	; 
+	; no need to do this for serial deveices, and we use the DPT_RESET flag bits
+	; to store the drive type for serial floppy drives (MODULE_SERIAL_FLOPPY)
+	;
+	xor		ah, ah
+	test	byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE	; Clears CF
+	jnz		.ReturnNotSuccessfull
+%endif
+		
 	; Try to select drive and wait until ready
 	or		BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET		; Everything uninitialized
