Index: trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 604)
+++ trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc	(revision 605)
@@ -40,5 +40,5 @@
 
 struc HOTKEYVARS
-	.fpPrevTimerHandler	resb	4		; Previous 1Ch timer handler
+	.fpPrevTimerHandler	resb	4		; Previous 08h timer handler
 	.wTimeWhenDisplayed	resb	2		; System time (ticks) when Hotkey bar was first displayed
 	.wFddAndHddLetters:
Index: trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc	(revision 604)
+++ trunk/XTIDE_Universal_BIOS/Inc/ModuleDependency.inc	(revision 605)
@@ -53,7 +53,7 @@
 %endif
 
-%ifdef MODULE_WIN95_CMOS_HACK
+%ifdef MODULE_WIN9X_CMOS_HACK
 	%ifndef USE_386
-		%error "MODULE_WIN95_CMOS_HACK requires USE_386!"
+		%error "MODULE_WIN9X_CMOS_HACK requires USE_386!"
 	%endif
 %endif
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 604)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 605)
@@ -84,5 +84,5 @@
 
 STANDARD_CONTROL_BLOCK_OFFSET			EQU		200h
-XTIDE_CONTROL_BLOCK_OFFSET				EQU		8h		; for XTIDE, A3 is used to control selected register (CS0 vs CS1)...
+XTIDE_CONTROL_BLOCK_OFFSET				EQU		8h		; For XTIDE, A3 is used to control selected register (CS0 vs CS1)...
 XTCF_CONTROL_BLOCK_OFFSET				EQU		10h		; ...and for XT-CF (all variants), it's A4
 ADP50L_CONTROL_BLOCK_OFFSET				EQU		10h
@@ -183,10 +183,8 @@
 ; Bit defines for ROMVARS.wFlags
 FLG_ROMVARS_FULLMODE					EQU	(1<<0)	; Full operating mode (steals base RAM, supports EBIOS etc.)
-FLG_ROMVARS_IGNORE_MOTHERBOARD_DRIVES	EQU	(1<<1)	; Ignores drives configured in motherboard BIOS setup.
-													; For now it is a hack to get Windows 95 IDE drivers working
-													; but it will be needed later when XTUB supports dynamic drive overlay.
-													; Because of that this must be included into AT builds and cannot be a
-													; module (any AT or 386 must be installable to the hard drive so
-													; there won't be need for even more different builds).
+FLG_ROMVARS_CLEAR_BDA_HD_COUNT			EQU	(1<<1)	; This flag has two purposes; * Removes the system BIOS "dummy" drive
+													; so that Windows 9x protected mode drivers can be used with XUB drives.
+													; * Some computers (Zenith Z-171 and Z-161) do not clear the BDA hard
+													; drive count which causes it to increment on each warm boot.
 FLG_ROMVARS_SERIAL_SCANDETECT 			EQU	(1<<3)	; Scan COM ports at the end of drive detection.  Can also be invoked
 													; by holding down the ALT key at the end of drive detection.
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 604)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 605)
@@ -97,7 +97,11 @@
 	;call	HotkeyBar_UpdateDuringDriveDetection
 
+	push	ds
+	push	es
+	pop		ds
+
 .WaitUntilTimeToCloseHotkeyBar:
-	call	TimerTicks_ReadFromBdaToAX
-	sub		ax, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wTimeWhenDisplayed]
+	mov		ax, [BDA.dwTimerTicks]
+	sub		ax, [BOOTVARS.hotkeyVars+HOTKEYVARS.wTimeWhenDisplayed]
 	cmp		ax, MIN_TIME_TO_DISPLAY_HOTKEY_BAR
 	jb		SHORT .WaitUntilTimeToCloseHotkeyBar
@@ -105,9 +109,11 @@
 	; Restore system timer tick handler since hotkeys are no longer needed
 	cli
-	mov		ax, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler]
-	mov		[es:BIOS_SYSTEM_TIMER_TICK_INTERRUPT_08h*4], ax
-	mov		ax, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler+2]
-	mov		[es:BIOS_SYSTEM_TIMER_TICK_INTERRUPT_08h*4+2], ax
+	mov		ax, [BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler]
+	mov		[BIOS_SYSTEM_TIMER_TICK_INTERRUPT_08h*4], ax
+	mov		ax, [BOOTVARS.hotkeyVars+HOTKEYVARS.fpPrevTimerHandler+2]
+	mov		[BIOS_SYSTEM_TIMER_TICK_INTERRUPT_08h*4+2], ax
 	sti
+
+	pop		ds
 %endif
 	; Fall to .ResetAllDrives
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 604)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 605)
@@ -70,5 +70,5 @@
 ;
 	call	FindDPT_ToDSDIforSerialDevice	; Does not modify AX
-	jnc		.AddHardDisks
+	jnc		SHORT .AddHardDisks
 
 	mov		bp, ROMVARS.ideVarsSerialAuto	; Point to our special IDEVARS structure, just for serial scans
@@ -76,5 +76,5 @@
 %ifdef MODULE_HOTKEYS
 	cmp		al, COM_DETECT_HOTKEY_SCANCODE	; Set by last call to ScanHotkeysFromKeyBufferAndStoreToBootvars above
-	je		.DriveDetectLoop
+	je		SHORT .DriveDetectLoop
 %endif
 
@@ -82,5 +82,5 @@
 	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_SCANDETECT
-	jnz		.DriveDetectLoop
+	jnz		SHORT .DriveDetectLoop
 %endif ; MODULE_SERIAL
 
@@ -96,34 +96,30 @@
 ;
 
-; Here we might want to replace BIOS configured drives with the ones we detected.
-; Primary reason is to support dynamic overlay feature in the future. Second reason
-; is a hack to get Windows 95 to load its built-in protected mode IDE driver.
+; This is a hack to get Windows 9x to load its built-in protected mode IDE driver.
 ;
 ; The Windows hack has two parts. First part is to try to alter CMOS address 12h as that
-; is what Windows 95 driver reads to detect IDE drives. Altering is not possible on all
+; is what Windows 9x driver reads to detect IDE drives. Altering is not possible on all
 ; systems since CMOS has a checksum but its location is not standardized. We will first
 ; try to detect valid checksum. If it succeeds, then it is safe to assume this system
 ; has compatible CMOS and we can alter it.
-; If verify fails, we do the more dirty hack to zero BDA drive count. Then Windows 95 works
+; If verify fails, we do the more dirty hack to zero BDA drive count. Then Windows 9x works
 ; as long as user has configured at least one drive in the BIOS setup.
-
-%ifdef USE_AT	; FLG_ROMVARS_IGNORE_MOTHERBOARD_DRIVES is for AT builds only
-%ifdef MODULE_WIN95_CMOS_HACK
+%ifdef MODULE_WIN9X_CMOS_HACK
 	mov		dl, HARD_DISK_TYPES
 	call	CMOS_ReadFromIndexInDLtoAL
 	test	al, 0F0h
-	jnz		SHORT .ClearBdaDriveCount		; CMOS byte 12h is ready for Windows 95
+	jnz		SHORT .ClearBdaDriveCount		; CMOS byte 12h is ready for Windows 9x
 	call	CMOS_Verify10hTo2Dh				; Can we modify CMOS?
 	jnz		SHORT .ClearBdaDriveCount		; Unsupported BIOS, use plan B
 
 	; Now we can alter CMOS location 12h. Award BIOS locks if we set drive 0 type to Fh
-	; (but accept changes to drive type 1). Windows 95 requires that the drive 0 type is
+	; (but accept changes to drive type 1). Windows 9x requires that the drive 0 type is
 	; non zero and ignores drive 1 type. So if we only set drive 1, then Award BIOS
-	; won't give problems but Windows 95 stays in MS-DOS compatibility mode.
+	; won't give problems but Windows 9x stays in MS-DOS compatibility mode.
 	;
 	; For Award BIOSes we could set the Drive 0 type to 1 and then clear the BDA drive count.
-	; So essentially we could automatically do what user needs to do manually to get Windows 95
+	; So essentially we could automatically do what user needs to do manually to get Windows 9x
 	; working on Award BIOSes. However, I think that should be left to do manually since
-	; there may be SCSI drives on the system or FLG_ROMVARS_IGNORE_MOTHERBOARD_DRIVES could
+	; there may be SCSI drives on the system or FLG_ROMVARS_CLEAR_BDA_HD_COUNT could
 	; be intentionally cleared and forcing the dummy drive might cause only trouble.
 
@@ -147,15 +143,24 @@
 	call	CMOS_StoreNewChecksumFor10hto2Dh
 .ClearBdaDriveCount:
-%endif ; MODULE_WIN95_CMOS_HACK
-
-	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_IGNORE_MOTHERBOARD_DRIVES
-	jz		SHORT .ContinueInitialization
-	mov		BYTE [es:BDA.bHDCount], 0		; Set hard disk count to zero
-.ContinueInitialization:
-%endif ; USE_AT
+%endif ; MODULE_WIN9X_CMOS_HACK
 
 	mov		cx, [RAMVARS.wDrvCntAndFlopCnt]	; Our count of hard disks
 	mov		al, [es:BDA.bHDCount]
-	add		[es:BDA.bHDCount], cl			; Add our drives to the system count
+%ifndef MODULE_MFM_COMPATIBILITY
+	; This is excluded when MODULE_MFM_COMPATIBILITY is included because it doesn't make sense to use both at the same time anyway.
+	; Note that the option to "Remove other hard drives" is still visible in XTIDECFG.COM for builds including MODULE_MFM_COMPATIBILITY.
+	; Changing that option just won't do anything. We might want to remove the option for builds that contain MODULE_MFM_COMPATIBILITY
+	; but that would require a ROMVARS flag that is probably better spent on other things.
+	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_CLEAR_BDA_HD_COUNT	; Clears CF
+	jz		SHORT .ContinueInitialization
+%ifdef USE_UNDOC_INTEL
+	salc
+%else
+	xor		al, al
+%endif
+.ContinueInitialization:
+%endif ; MODULE_MFM_COMPATIBILITY
+	add		cl, al
+	mov		[es:BDA.bHDCount], cl			; Update the system count
 	or		al, 80h							; Or in hard disk flag
 	mov		[RAMVARS.bFirstDrv], al			; Store first drive number
@@ -177,5 +182,5 @@
 	add		al, ch							; Add our drives to existing drive count
 	cmp		al, 3							; For BDA, max out at 4 drives (ours is zero based)
-	jb		.MaxBDAFloppiesExceeded
+	jb		SHORT .MaxBDAFloppiesExceeded
 	mov		al, 3
 .MaxBDAFloppiesExceeded:
Index: trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 604)
+++ trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 605)
@@ -78,5 +78,5 @@
 %ifdef USE_AT
 %ifdef USE_386
-	at	ROMVARS.wFlags,			dw	FLG_ROMVARS_FULLMODE | FLG_ROMVARS_IGNORE_MOTHERBOARD_DRIVES | MASK_ROMVARS_INCLUDED_MODULES
+	at	ROMVARS.wFlags,			dw	FLG_ROMVARS_FULLMODE | FLG_ROMVARS_CLEAR_BDA_HD_COUNT | MASK_ROMVARS_INCLUDED_MODULES
 %else
 	at	ROMVARS.wFlags,			dw	FLG_ROMVARS_FULLMODE | MASK_ROMVARS_INCLUDED_MODULES
@@ -192,5 +192,5 @@
 
 	%include "AssemblyLibrary.asm"
-%ifdef MODULE_WIN95_CMOS_HACK
+%ifdef MODULE_WIN9X_CMOS_HACK
 	%include "CMOS.asm"				; This belongs in the Assembly Library
 %endif
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 604)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 605)
@@ -220,6 +220,6 @@
 ;		C. the serial server always returns floppy drives last
 ;
-	adc		byte [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt], 0
-	jnz		.AllDone
+	adc		BYTE [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt], 0
+	jnz		SHORT .AllDone
 %else ; ~MODULE_SERIAL_FLOPPY
 ;
@@ -228,5 +228,5 @@
 ; floppies are supported, so it is important to still fail here if a floppy is seen during the drive scan.
 ;
-	jc		.AllDone
+	jc		SHORT .AllDone
 %endif ; MODULE_SERIAL_FLOPPY
 %endif ; MODULE_SERIAL
Index: trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- trunk/XTIDE_Universal_BIOS/makefile	(revision 604)
+++ trunk/XTIDE_Universal_BIOS/makefile	(revision 605)
@@ -29,5 +29,5 @@
 # MODULE_VERY_LATE_INIT       Initialize on INT 13h if our INT 19h handler is not called           #
 # MODULE_POWER_MANAGEMENT     Power Management support                                             #
-# MODULE_WIN95_CMOS_HACK      Hack for Windows 95 compatibility                                    #
+# MODULE_WIN9X_CMOS_HACK      Hack for Windows 9x compatibility                                    #
 # MODULE_MFM_COMPATIBILITY    Restores BDA drive count for MFM controllers that expect to be the   #
 #                             only hard drive controller on the system                             #
@@ -119,5 +119,5 @@
 
 DEFINES_XT_TINY = MODULE_STRINGS_COMPRESSED MODULE_8BIT_IDE NO_ATAID_VALIDATION CLD_NEEDED
-DEFINES_386 = $(DEFINES_AT) USE_386 MODULE_ADVANCED_ATA MODULE_WIN95_CMOS_HACK
+DEFINES_386 = $(DEFINES_AT) USE_386 MODULE_ADVANCED_ATA MODULE_WIN9X_CMOS_HACK
 DEFINES_386_LARGE = $(DEFINES_386) $(DEFINES_COMMON_LARGE)
 
