Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 592)
@@ -200,8 +200,12 @@
 %ifdef MODULE_IRQ
 	test	BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN
+%ifdef USE_386
+	jnz		IdeWait_IRQorStatusFlagInBLwithTimeoutInBH
+%else
 	jz		SHORT .PollStatusFlagInsteadOfWaitIrq
 	jmp		IdeWait_IRQorStatusFlagInBLwithTimeoutInBH
 .PollStatusFlagInsteadOfWaitIrq:
 %endif
+%endif ; MODULE_IRQ
 	jmp		IdeWait_PollStatusFlagInBLwithTimeoutInBH
 
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm	(revision 592)
@@ -121,5 +121,5 @@
 	jnz		SHORT .ChangeTo32bitDevice
 
-	and		BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_IORDY	; No IORDY supported if need to limit
+	and		[di+DPT.bFlagsHigh], ah		; Mask off FLGH_DPT_IORDY if IORDY not supported
 	MIN_U	[di+DPT_ADVANCED_ATA.bPioMode], al
 	mov		[di+DPT_ADVANCED_ATA.wMinPioCycleTime], bx
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm	(revision 592)
@@ -147,5 +147,5 @@
 	lds		di, [bp+MEMPIOVARS.fpDPT]			; DPT now in DS:DI
 %ifdef USE_386
-	movzx	cx, BYTE [bp+MEMPIOVARS.bSectorsDone]
+	movzx	cx, [bp+MEMPIOVARS.bSectorsDone]
 %else
 	mov		ch, 0								; Preserve CF
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 592)
@@ -97,5 +97,7 @@
 	sti									; Enable interrupts
 %endif
+%ifdef CLD_NEEDED
 	cld									; String instructions to increment pointers
+%endif
 	ePUSHA
 	push	ds
@@ -193,6 +195,10 @@
 
 	; Push old INT 13h handler and restore registers
+%ifdef USE_386
+	push	DWORD [RAMVARS.fpOldI13h]
+%else
 	push	WORD [RAMVARS.fpOldI13h+2]
 	push	WORD [RAMVARS.fpOldI13h]
+%endif
 	mov		bx, [bp+IDEPACK.intpack+INTPACK.bx]
 	mov		di, [bp+IDEPACK.intpack+INTPACK.di]
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm	(revision 592)
@@ -126,5 +126,5 @@
 	mov		cx, NUMBER_OF_IDEVARS
 
-.loop:
+.Loop:
 	call	FindDPT_MasterOrSingleForIdevarsOffsetInDL
 	jc		SHORT .ControllerNotAvailable
@@ -162,4 +162,4 @@
 .ControllerNotAvailable:
 	add		dl, IDEVARS_size							; move Idevars pointer forward
-	loop	.loop
+	loop	.Loop
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 592)
@@ -121,7 +121,7 @@
 	;
 	; Also note that some machines, noteably the Olivetti M24 (also known as
-	; the AT&T PC6300 and Xerox 6060), have hardware errors in the BIU logic,
-	; resulting in reversed byte ordering.  Therefore, XTCF_8BIT_PIO_MODE is
-	; the default transfer mode for best system compatibility.
+	; the AT&T PC6300 or Xerox 6060 or Logabax Persona 1600), have hardware errors
+	; in the BIU logic, resulting in reversed byte ordering.  Therefore,
+	; XTCF_8BIT_PIO_MODE is the default transfer mode for best system compatibility.
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm	(revision 592)
@@ -46,5 +46,5 @@
 
 	mov		BYTE [bp+IDEPACK.intpack+INTPACK.ah], EBIOS_VERSION
-	mov		WORD [bp+IDEPACK.intpack+INTPACK.bx], 0AA55h
+	not		WORD [bp+IDEPACK.intpack+INTPACK.bx]	; 55AAh = AA55h
 
 %ifdef MODULE_COMPATIBLE_TABLES
@@ -75,11 +75,19 @@
 ;--------------------------------------------------------------------
 AH41h_GetSupportBitsToCX:
+%ifdef USE_AT	; Always in Full mode
+%ifndef MODULE_8BIT_IDE OR MODULE_SERIAL
+	mov		cx, ENHANCED_DRIVE_ACCESS_SUPPORT | ENHANCED_DISK_DRIVE_SUPPORT
+%else
+	mov		cx, ENHANCED_DRIVE_ACCESS_SUPPORT
+	cmp		BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_ATA
+	jae		SHORT .DoNotSetEDDflag
+	or		cl, ENHANCED_DISK_DRIVE_SUPPORT
+%endif
+%else ; ~USE_AT
 	mov		cx, ENHANCED_DRIVE_ACCESS_SUPPORT
 
 	; DPTE needs buffer from RAM so do not return it in lite mode
-%ifndef USE_AT
 	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
 	jz		SHORT .DoNotSetEDDflag
-%endif
 
 %ifdef MODULE_8BIT_IDE OR MODULE_SERIAL
@@ -91,4 +99,5 @@
 
 	or		cl, ENHANCED_DISK_DRIVE_SUPPORT	; AH=48h returns DPTE
+%endif ; USE_AT
 .DoNotSetEDDflag:
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 592)
@@ -110,12 +110,12 @@
 	and		al, MASKL_DPT_TRANSLATEMODE
 
-;;; 0: ADDRESSING_MODE_NORMAL
+;;; 0: TRANSLATEMODE_NORMAL
 	jz		SHORT DoNotConvertLCHS
 
-;;; 1: ADDRESSING_MODE_LARGE
+;;; 1: TRANSLATEMODE_LARGE
 	test	al, FLGL_DPT_ASSISTED_LBA
 	jz		SHORT ConvertLargeModeLCHStoPCHS
 
-;;; 2: ADDRESSING_MODE_ASSISTED_LBA
+;;; 2: TRANSLATEMODE_ASSISTED_LBA
 	; Fall to ConvertAssistedLBAModeLCHStoLBARegisterValues
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm	(revision 592)
@@ -30,5 +30,7 @@
 Int19h_BootLoaderHandler:
 	sti											; Enable interrupts
+%ifdef CLD_NEEDED
 	cld											; String instructions to increment pointers
+%endif
 %ifdef MODULE_VERY_LATE_INIT
 	LOAD_BDA_SEGMENT_TO	ds, ax					; Load BDA segment (zero) to DS
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm	(revision 592)
@@ -60,6 +60,6 @@
 ;		AX:		ID WORD specific for detected controller
 ;	Returns:
-;		AL:		Max supported PIO mode
-;		AH:		FLGH_DPT_IORDY if IORDY supported, zero otherwise
+;		AL:		Max supported PIO mode (only if ZF set)
+;		AH:		~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set)
 ;		BX:		Min PIO cycle time (only if ZF set)
 ;		ZF:		Set if PIO limit necessary
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/PDC20x30.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/PDC20x30.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/PDC20x30.asm	(revision 592)
@@ -127,5 +127,5 @@
 
 	; PDC20230C and PDC20630 clears the bit we set at the beginning
-	in		al, dx
+	in		al, dx	; 1F2h
 	dec		dx
 	dec		dx		; Base port
@@ -139,6 +139,6 @@
 ;		AX:		ID WORD specific for detected controller
 ;	Returns:
-;		AL:		Max supported PIO mode
-;		AH:		FLGH_DPT_IORDY if IORDY supported, zero otherwise
+;		AL:		Max supported PIO mode (only if ZF set)
+;		AH:		~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set)
 ;		BX:		Min PIO cycle time (only if ZF set)
 ;		ZF:		Set if PIO limit necessary
@@ -148,9 +148,8 @@
 ;--------------------------------------------------------------------
 PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX:
-	cmp		ah, ID_PDC20630
-	je		SHORT .Return		; No need to limit anything
-	mov		ax, 2				; Limit PIO to 2 for ID_PDC20230
+	cmp		ah, ID_PDC20230
+	jne		SHORT .Return							; No need to limit anything for ID_PDC20630
+	mov		ax, (~FLGH_DPT_IORDY & 0FFh) << 8 | 2	; Limit PIO to 2 for ID_PDC20230
 	mov		bx, PIO_2_MIN_CYCLE_TIME_NS
-	stc
 .Return:
 	ret
@@ -206,7 +205,9 @@
 ;--------------------------------------------------------------------
 SetSpeedForDriveInCX:
-	eMOVZX	bx, BYTE [di+DPT_ADVANCED_ATA.bPioMode]
-	MIN_U	bl, 2	; Limit to PIO2
-	mov		bl, [cs:bx+.rgbPioModeToPDCspeedValue]
+	mov		bx, .rgbPioModeToPDCspeedValue
+	mov		al, [di+DPT_ADVANCED_ATA.bPioMode]
+	MIN_U	al, 2	; Limit to PIO2
+	cs xlat
+	xchg	bx, ax
 
 	add		dx, BYTE SECTOR_NUMBER_REGISTER
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm	(revision 592)
@@ -131,6 +131,6 @@
 ;		AH:		QDI Vision Controller ID
 ;	Returns:
-;		AL:		Max supported PIO mode
-;		AH:		FLGH_DPT_IORDY if IORDY supported, zero otherwise
+;		AL:		Max supported PIO mode (only if ZF set)
+;		AH:		~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set)
 ;		BX:		Min PIO Cycle Time (only if ZF set)
 ;		ZF:		Set if PIO limit necessary
@@ -142,6 +142,5 @@
 	cmp		ah, ID_QD6500
 	jne		SHORT .NoNeedToLimitForQD6580
-
-	mov		ax, 2	; Limit to PIO 2 because QD6500 does not support IORDY
+	mov		ax, (~FLGH_DPT_IORDY & 0FFh) << 8 | 2	; Limit to PIO 2 because QD6500 does not support IORDY
 	mov		bx, PIO_2_MIN_CYCLE_TIME_NS
 .NoNeedToLimitForQD6580:
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 592)
@@ -104,5 +104,5 @@
 ;		DX:		User defined P-CHS to L-CHS translate mode
 ;	Corrupts registers:
-;		AX, BX, CX
+;		AX, BX
 ;--------------------------------------------------------------------
 AtaID_ModifyESSIforUserDefinedLimitsAndReturnTranslateModeInDX:
@@ -113,8 +113,8 @@
 	pop		ds
 
-	; Load User Defined CHS or LBA to CX:AX
-	mov		dx, [bx+DRVPARAMS.wFlags]
+	; Load User Defined CHS or LBA to BX:AX
+	mov		dl, [bx+DRVPARAMS.wFlags]			; Only load the flags we actually need
 	mov		ax, [bx+DRVPARAMS.wCylinders]		; Or .dwMaximumLBA
-	mov		cx, [bx+DRVPARAMS.wHeadsAndSectors]	; Or .dwMaximumLBA+2
+	mov		bx, [bx+DRVPARAMS.wHeadsAndSectors]	; Or .dwMaximumLBA+2
 
 	push	es
@@ -127,7 +127,7 @@
 	; Apply new CHS and disable LBA (we also want to set CHS addressing)
 	mov		[si+ATA1.wCylCnt], ax
-	eMOVZX	ax, cl
+	eMOVZX	ax, bl
 	mov		[si+ATA1.wHeadCnt], ax
-	mov		al, ch
+	mov		al, bh
 	mov		[si+ATA1.wSPT], ax
 	and		BYTE [si+ATA1.wCaps+1], ~(A1_wCaps_LBA>>8)
@@ -140,5 +140,5 @@
 
 	; Apply new LBA and disable LBA48
-	cmp		cx, [si+ATA1.dwLBACnt+2]
+	cmp		bx, [si+ATA1.dwLBACnt+2]
 	ja		SHORT .NoUserDefinedLBA		; Do not set larger than drive
 	jb		SHORT .StoreNewLBA
@@ -147,5 +147,5 @@
 .StoreNewLBA:
 	mov		[si+ATA1.dwLBACnt], ax
-	mov		[si+ATA1.dwLBACnt+2], cx
+	mov		[si+ATA1.dwLBACnt+2], bx
 	and		BYTE [si+ATA6.wSetSup83+1], ~(A6_wSetSup83_LBA48>>8)
 .NoUserDefinedLBA:
@@ -173,13 +173,18 @@
 AtaID_GetMaxPioModeToAXandMinCycleTimeToCX:
 	; Get PIO mode and cycle time for PIO 0...2
-	mov		bx, [es:si+ATA1.bPioMode]
-	mov		ax, bx					; AH = 0, AL = PIO mode 0, 1 or 2
-	eSHL_IM	bx, 1					; Shift for WORD lookup
+%ifdef USE_386
+	movzx	ax, [es:si+ATA1.bPioMode]	; AH = 0, AL = PIO mode 0, 1 or 2
+%else
+	mov		al, [es:si+ATA1.bPioMode]
+	cbw
+%endif
+	mov		bx, ax
+	eSHL_IM	bx, 1						; Shift for WORD lookup
 	mov		cx, [cs:bx+.rgwPio0to2CycleTimeInNanosecs]
 
 	; Check if IORDY is supported
 	test	BYTE [es:si+ATA2.wCaps+1], A2_wCaps_IORDY >> 8
-	jz		SHORT .ReturnPioTimings	; No PIO 3 or higher if no IORDY
-	mov		ah, FLGH_DPT_IORDY
+	jz		SHORT .ReturnPioTimings		; No PIO 3 or higher if no IORDY
+	mov		ah, FLGH_DPT_IORDY			; *FIXME* Actually, CF specification v4.1 says that use of IORDY is invalid for PIO modes 5 and 6.
 
 	; Check if Advanced PIO modes are supported (3 and above)
@@ -187,10 +192,10 @@
 	jz		SHORT .ReturnPioTimings
 
-	; Get Advanced PIO mode
-	; (Hard Disks supports up to 4 but CF cards can support 5 and 6)
-	mov		bl, [es:si+ATA2.bPIOSupp]
+	; Get Advanced PIO mode (Hard Disks supports up to 4 but CF cards can support 5 and 6)
+	or		bh, [es:si+ATA2.bPIOSupp]
+	jz		SHORT .ReturnPioTimings
 .CheckNextFlag:
 	inc		ax
-	shr		bl, 1
+	shr		bh, 1
 	jnz		SHORT .CheckNextFlag
 	MIN_U	al, 6						; Make sure not above lookup tables
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 592)
@@ -150,6 +150,12 @@
 	push	bp
 	mov		bp, sp
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+%if DRVDETECTINFO.szDrvName = 0
+	push	bx
+%else
 	lea		si, [bx+DRVDETECTINFO.szDrvName]
 	push	si
+%endif
+%endif
 	mov		si, g_szDriveName
 	jmp		SHORT DetectPrint_FormatCSSIfromParamsInSSBP
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 592)
@@ -190,16 +190,8 @@
 	LOAD_BDA_SEGMENT_TO	ds, ax
 	mov		al, [BDA.wEquipment]	; Load Equipment WORD low byte
+	and		al, 0C1h				; Leave bits 7..6 and 0
+	eAAM	64
+	add		al, ah					; AL = Floppy Drive count
 	pop		ds
-
-%ifdef USE_UNDOC_INTEL
-	and		al, 0C1h
-	eAAM	64
-%else
-	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
-%endif ; USE_UNDOC_INTEL
-
-	add		al, ah					; AL = Floppy Drive count
 %endif ; USE_AT
 
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 592)
@@ -239,8 +239,8 @@
 .ClearBitFrom8259MaskRegister:
 	push	cx
-	xchg	ax, cx				; IRQ index to CL
+	xchg	cx, ax				; IRQ index to CL
+	in		al, dx				; Read Interrupt Mask Register
 	mov		ch, ~1				; Load bit mask to be rotated
 	rol		ch, cl				; Rotate mask to correct position for clearing
-	in		al, dx				; Read Interrupt Mask Register
 	and		al, ch				; Clear wanted bit
 	out		dx, al				; Write modified Interrupt Mask Register
Index: trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 592)
@@ -32,5 +32,5 @@
 
 	; We must define included libraries before including "AssemblyLibrary.inc".
-%define	EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS	; Exclude unused library functions
+%define	EXCLUDE_FROM_XUB					; Exclude unused library functions
 %ifdef MODULE_BOOT_MENU
 	%define MENUEVENT_INLINE_OFFSETS		; Only one menu required, save space and inline offsets
@@ -81,4 +81,5 @@
 %ifdef MODULE_BOOT_MENU
 	at	ROMVARS.wBootTimeout,	dw	BOOT_MENU_DEFAULT_TIMEOUT
+	at	ROMVARS.pColorTheme,	dw	ColorTheme				; Offset to the ATTRIBUTE_CHARS struc that holds the color theme
 %endif
 	at	ROMVARS.bIdeCnt,		db	2						; Number of supported controllers
@@ -105,5 +106,5 @@
 	at	ROMVARS.ideVars2+IDEVARS.wControlBlockPort,	dw	DEVICE_ATA_TERTIARY_PORTCTRL
 	at	ROMVARS.ideVars2+IDEVARS.bDevice,			db	DEVICE_16BIT_ATA
-	at	ROMVARS.ideVars2+IDEVARS.bIRQ,				db	0
+	at	ROMVARS.ideVars2+IDEVARS.bIRQ,				db	0	; Should be 11 on the GSI Inc. Model 2C
 	at	ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	dw	DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
 	at	ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	dw	DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
@@ -112,5 +113,5 @@
 	at	ROMVARS.ideVars3+IDEVARS.wControlBlockPort,	dw	DEVICE_ATA_QUATERNARY_PORTCTRL
 	at	ROMVARS.ideVars3+IDEVARS.bDevice,			db	DEVICE_16BIT_ATA
-	at	ROMVARS.ideVars3+IDEVARS.bIRQ,				db	0
+	at	ROMVARS.ideVars3+IDEVARS.bIRQ,				db	0	; Should be 10 on the GSI Inc. Model 2C
 	at	ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	dw	DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
 	at	ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	dw	DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
@@ -127,4 +128,5 @@
 %ifdef MODULE_BOOT_MENU
 	at	ROMVARS.wBootTimeout,	dw	BOOT_MENU_DEFAULT_TIMEOUT
+	at	ROMVARS.pColorTheme,	dw	ColorTheme				; Offset to the ATTRIBUTE_CHARS struc that holds the color theme
 %endif
 	at	ROMVARS.bIdeCnt,		db	1
@@ -301,4 +303,5 @@
 
 
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 ; Although it's very unlikely to happen, we give warnings for builds that cannot be automatically checksummed due to the size being too large.
 ; In some cases it's theoretically possible to checksum the build anyway (manually) which is why these are warnings and not errors.
@@ -309,5 +312,6 @@
 		%endif
 	%endif
-%elif ($-$$) = BIOS_SIZE			; A large build.
+%elif ($-$$) = BIOS_SIZE			; A large or tiny build.
 	%warning "This build is too large to be auto-checksummed!"
 %endif
+%endif
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuEvent.asm	(revision 592)
@@ -141,5 +141,5 @@
 
 	; Store default Menuitem (=default drive to boot from)
-	eMOVZX	dx, BYTE [cs:ROMVARS.bBootDrv]
+	eMOVZX	dx, [cs:ROMVARS.bBootDrv]
 	call	GetMenuitemToDXforDriveInDL
 	mov		[bp+MENUINIT.wHighlightedItem], dx
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrint.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrint.asm	(revision 592)
@@ -54,5 +54,5 @@
 	test	dl, dl
 	js		SHORT .go
-	mov		bl, ((g_szFloppyDrv)-$$ & 0xff)			; and revisit the earlier assumption...
+	mov		bl, (g_szFloppyDrv - $$) & 0xff			; and revisit the earlier assumption...
 
 .go:
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm	(revision 592)
@@ -63,6 +63,10 @@
 	;; with AL clear, and so we exchange AL and AH after the multiply for the final result.
 	;;
+%ifdef USE_186
+	imul	ax, g_szAddressingModes_Displacement << (8-TRANSLATEMODE_FIELD_POSITION)
+%else
 	mov		cx, g_szAddressingModes_Displacement << (8-TRANSLATEMODE_FIELD_POSITION)
 	mul		cx
+%endif
 	xchg	al, ah		; AL = always zero after above multiplication
 	add		ax, g_szAddressingModes
Index: trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 592)
@@ -407,5 +407,5 @@
 	sbb		di, BYTE 1				; Sub CF if Floppy Drive
 	xchg	ax, cx
-	mov		[es:di], al
+	stosb
 	stc								; Valid hotkey scancode returned in AL
 
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 592)
@@ -114,8 +114,104 @@
 	; slower. The speed difference doesn't matter on AT systems.
 .UseAssistedLBA:
-	call	GetSectorCountToDXAXfromCHSinAXBLBH
-	call	ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
-	xor		cx, cx		; No bits to shift
+	; Fall to GetSectorCountToDXAXfromCHSinAXBLBH
+
+
+;--------------------------------------------------------------------
+; GetSectorCountToDXAXfromCHSinAXBLBH
+;	Parameters:
+;		AX:		Number of cylinders (1...16383)
+;		BL:		Number of heads (1...255)
+;		BH:		Number of sectors per track (1...63)
+;	Returns:
+;		DX:AX:	Total number of CHS addressable sectors
+;	Corrupts registers:
+;		BX
+;--------------------------------------------------------------------
+GetSectorCountToDXAXfromCHSinAXBLBH:
+	xchg	ax, bx
+	mul		ah			; AX = Heads * Sectors per track
+	mul		bx
+	; Fall to ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
+
+
+;--------------------------------------------------------------------
+; LBA assist calculation (or Assisted LBA)
+;
+; This algorithm translates P-CHS sector count up to largest possible
+; L-CHS sector count (1024, 255, 63). Note that INT 13h interface allows
+; 256 heads but DOS supports up to 255 head. That is why BIOSes never
+; use 256 heads.
+;
+; L-CHS parameters generated here require the drive to use LBA addressing.
+;
+; Here is the algorithm:
+; If cylinders > 8192
+;  Variable CH = Total CHS Sectors / 63
+;  Divide (CH - 1) by 1024 and add 1
+;  Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads.
+;  Divide CH by the number of heads. This is the value to be used for the number of cylinders.
+;
+; ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
+;	Parameters:
+;		DX:AX:	Total number of P-CHS sectors for CHS addressing
+;				(max = 16383 * 16 * 63 = 16,514,064)
+;	Returns:
+;		AX:		Number of cylinders (?...1027)
+;		BL:		Number of heads (16, 32, 64, 128 or 255)
+;		BH:		Number of sectors per track (always 63)
+;		CX:		Number of bits shifted (0)
+;		DL:		TRANSLATEMODE_ASSISTED_LBA
+;	Corrupts registers:
+;		DH
+;--------------------------------------------------------------------
+ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
+	; Value CH = Total sector count / 63
+	; Max = 16,514,064 / 63 = 262128
+	mov		cx, LBA_ASSIST_SPT			; CX = 63
+
+	; --- Math_DivDXAXbyCX inlined (and slightly modified) since it's only used here
+	xor		bx, bx
+	xchg	bx, ax
+	xchg	dx, ax
+	div		cx
+	xchg	ax, bx
+	div		cx
+	mov		dx, bx
+	; ---
+
+	push	ax
+	push	dx							; Value CH stored for later use
+
+	; BX:DX:AX = Value CH - 1
+	; Max = 262128 - 1 = 262127
+	xor		bx, bx
+	sub		ax, BYTE 1
+	sbb		dx, bx
+
+	; AX = Number of heads = ((Value CH - 1) / 1024) + 1
+	; Max = (262127 / 1024) + 1 = 256
+	call	Size_DivideSizeInBXDXAXby1024	; Preserves CX and returns with BH cleared
+	pop		dx
+	inc		ax							; + 1
+
+	; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest)
+	; Max = 255
+	mov		bl, 16						; Min number of heads
+.CompareNextValidNumberOfHeads:
+	cmp		ax, bx
+	jbe		SHORT .NumberOfHeadsNowInBX
+	eSHL_IM	bx, 1						; Double number of heads
+	jpo		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
+	dec		bx							;  If so, limit heads to 255
+.NumberOfHeadsNowInBX:
+
+	; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads
+	; Max = 262128 / 255 = 1027
+	pop		ax							; Value CH back to DX:AX
+	div		bx
+
+	xchg	bh, cl						; Sectors per Track to BH, zero to CL (CX)
 	mov		dl, TRANSLATEMODE_ASSISTED_LBA
+ReturnLCHSinAXBLBH:
 	ret
 
@@ -136,22 +232,4 @@
 	mov		bl, [es:si+ATA1.wHeadCnt]	; Heads (1...16)
 	mov		bh, [es:si+ATA1.wSPT]		; Sectors per Track (1...63)
-	ret
-
-
-;--------------------------------------------------------------------
-; GetSectorCountToDXAXfromCHSinAXBLBH
-;	Parameters:
-;		AX:		Number of cylinders (1...16383)
-;		BL:		Number of heads (1...255)
-;		BH:		Number of sectors per track (1...63)
-;	Returns:
-;		DX:AX:	Total number of CHS addressable sectors
-;	Corrupts registers:
-;		BX
-;--------------------------------------------------------------------
-GetSectorCountToDXAXfromCHSinAXBLBH:
-	xchg	ax, bx
-	mul		ah			; AX = Heads * Sectors per track
-	mul		bx
 	ret
 
@@ -175,4 +253,8 @@
 ;  Do a standard ECHS translation
 ;
+; *FIXME* The above algorithm seems to be conflicting with info found here
+; https://web.archive.org/web/20000817071418/http://www.firmware.com:80/support/bios/over4gb.htm
+; which says that Revised ECHS is used when the cylinder count is > 8191.
+;
 ; ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL:
 ;	Parameters:
@@ -183,5 +265,5 @@
 ;		BL:		Number of L-CHS heads (?...240)
 ;		CX:		Number of bits shifted (0...3)
-;		DX:		ADDRESSING_MODE_NORMAL or ADDRESSING_MODE_LARGE
+;		DX:		TRANSLATEMODE_NORMAL or TRANSLATEMODE_LARGE
 ;	Corrupts registers:
 ;		Nothing
@@ -271,72 +353,2 @@
 	ret
 
-
-;--------------------------------------------------------------------
-; LBA assist calculation (or Assisted LBA)
-;
-; This algorithm translates P-CHS sector count up to largest possible
-; L-CHS sector count (1024, 255, 63). Note that INT 13h interface allows
-; 256 heads but DOS supports up to 255 head. That is why BIOSes never
-; use 256 heads.
-;
-; L-CHS parameters generated here require the drive to use LBA addressing.
-;
-; Here is the algorithm:
-; If cylinders > 8192
-;  Variable CH = Total CHS Sectors / 63
-;  Divide (CH  1) by 1024 and add 1
-;  Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads.
-;  Divide CH by the number of heads. This is the value to be used for the number of cylinders.
-;
-; ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
-;	Parameters:
-;		DX:AX:	Total number of P-CHS sectors for CHS addressing
-;				(max = 16383 * 16 * 63 = 16,514,064)
-;	Returns:
-;		AX:		Number of cylinders (?...1027)
-;		BL:		Number of heads (16, 32, 64, 128 or 255)
-;		BH:		Number of sectors per track (always 63)
-;	Corrupts registers:
-;		CX, DX
-;--------------------------------------------------------------------
-ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
-	; Value CH = Total sector count / 63
-	; Max = 16,514,064 / 63 = 262128
-	mov		cx, LBA_ASSIST_SPT			; CX = 63
-	call	Math_DivDXAXbyCX			; Preserves CX
-	push	dx
-	push	ax							; Value CH stored for later use
-
-	; BX:DX:AX = Value CH - 1
-	; Max = 262128 - 1 = 262127
-	xor		bx, bx
-	sub		ax, BYTE 1
-	sbb		dx, bx
-
-	; AX = Number of heads = ((Value CH - 1) / 1024) + 1
-	; Max = (262127 / 1024) + 1 = 256
-	call	Size_DivideSizeInBXDXAXby1024	; Preserves CX
-	inc		ax							; + 1
-
-	; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest)
-	; Max = 255
-	mov		cl, 16						; Min number of heads
-.CompareNextValidNumberOfHeads:
-	cmp		ax, cx
-	jbe		SHORT .NumberOfHeadsNowInCX
-	eSHL_IM	cx, 1						; Double number of heads
-	jpo		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
-	dec		cx							;  If so, limit heads to 255
-.NumberOfHeadsNowInCX:
-	mov		bx, cx						; Number of heads are returned in BL
-	mov		bh, LBA_ASSIST_SPT			; Sectors per Track
-
-	; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads
-	; Max = 262128 / 255 = 1027
-	pop		ax
-	pop		dx							; Value CH back to DX:AX
-	div		cx
-
-	; Return L-CHS
-ReturnLCHSinAXBLBH:
-	ret
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/DrvDetectInfo.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/DrvDetectInfo.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/DrvDetectInfo.asm	(revision 592)
@@ -46,8 +46,10 @@
 
 	add		si, BYTE ATA1.strModel				; DS:SI now points drive name (Clears CF)
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 %if DRVDETECTINFO.szDrvName = 0
 	mov		di, bx
 %else
 	lea		di, [bx+DRVDETECTINFO.szDrvName]	; ES:DI now points to name destination
+%endif
 %endif
 	mov		cx, MAX_HARD_DISK_NAME_LENGTH / 2	; Max number of WORDs allowed
@@ -78,14 +80,19 @@
 ;--------------------------------------------------------------------
 DriveDetectInfo_ConvertDPTtoBX:
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
 %if DPT_DRVDETECTINFO_SIZE_MULTIPLIER = 2
 %if BOOTVARS.rgDrvDetectInfo & 1					; Should never be odd but better safe than sorry
-	lea		ax, [di-RAMVARS_size]
-	eSHL_IM	ax, 1
-	add		ax, BOOTVARS.rgDrvDetectInfo
+	lea		bx, [di-RAMVARS_size]
+	eSHL_IM	bx, 1
+	add		bx, BOOTVARS.rgDrvDetectInfo
 %else
-	lea		ax, [di-RAMVARS_size+(BOOTVARS.rgDrvDetectInfo/2)]
-;	eSHL_IM	ax, 1									; *FIXME* For some reason this will cause NASM to crap itself.
-	shl		ax, 1									; So this will have to suffice for now.
+	lea		bx, [di-RAMVARS_size+(BOOTVARS.rgDrvDetectInfo/2)]
+	eSHL_IM	bx, 1
 %endif
+%else
+%ifdef USE_186
+	lea		bx, [di-RAMVARS_size]
+	imul	bx, DPT_DRVDETECTINFO_SIZE_MULTIPLIER
+	add		bx, BOOTVARS.rgDrvDetectInfo
 %else
 	lea		ax, [di-RAMVARS_size]					; subtract off base of DPTs
@@ -93,5 +100,7 @@
 	mul		bl
 	add		ax, BOOTVARS.rgDrvDetectInfo			; add base of DRVDETECTINFO
+	xchg	bx, ax
 %endif
-	xchg	bx, ax
+%endif
+%endif
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 591)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 592)
@@ -31,20 +31,9 @@
 ;		DS:		RAMVARS segment
 ;	Corrupts registers:
-;		AX, CX, DI
+;		AX, CX, DX, DI
 ;--------------------------------------------------------------------
 RamVars_Initialize:
 	push	es
-	; Fall to .StealMemoryForRAMVARS
 
-;--------------------------------------------------------------------
-; .StealMemoryForRAMVARS
-;	Parameters:
-;		Nothing
-;	Returns:
-;		DS:		RAMVARS segment
-;	Corrupts registers:
-;		AX, CL
-;--------------------------------------------------------------------
-.StealMemoryForRAMVARS:
 %ifndef USE_AT
 	mov		ax, LITE_MODE_RAMVARS_SEGMENT
@@ -56,27 +45,16 @@
 	mov		al, [cs:ROMVARS.bStealSize]
 	sub		[BDA.wBaseMem], ax
-	mov		ax, [BDA.wBaseMem]
 %ifdef USE_186
-	shl		ax, 6						; Segment to first stolen kB (*=40h)
+	imul	ax, [BDA.wBaseMem], 64
 %else
-	mov		cl, 6
-	shl		ax, cl
+	mov		al, 64
+	mul		WORD [BDA.wBaseMem]
 %endif
-	; Fall to .InitializeRamvars
 
-;--------------------------------------------------------------------
-; .InitializeRamvars
-;	Parameters:
-;		AX:		RAMVARS segment
-;	Returns:
-;		DS:		RAMVARS segment
-;	Corrupts registers:
-;		AX, CX, DI, ES
-;--------------------------------------------------------------------
 .InitializeRamvars:
+	xor		di, di
 	mov		ds, ax
 	mov		es, ax
 	mov		cx, RAMVARS_size
-	xor		di, di
 	call	Memory_ZeroESDIwithSizeInCX
 	mov		WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE
@@ -121,6 +99,10 @@
 .GetStolenSegmentToDS:
 	LOAD_BDA_SEGMENT_TO	ds, di
+;%ifdef USE_186
+;	imul	di, [BDA.wBaseMem], 64	; 2 bytes less but slower, especially on 386/486 processors
+;%else
 	mov		di, [BDA.wBaseMem]		; Load available base memory size in kB
 	eSHL_IM	di, 6					; Segment to first stolen kB (*=40h)
+;%endif
 ALIGN JUMP_ALIGN
 .LoopStolenKBs:
