Index: trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 98)
+++ trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc	(revision 99)
@@ -1,7 +1,3 @@
-; File name		:	CustomDPT.inc
-; Project name	:	IDE BIOS
-; Created date	:	23.3.2010
-; Last update	:	10.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Defines for DPT structs containing custom
 ;					Disk Parameter Table used by this BIOS.
@@ -15,4 +11,5 @@
 	; General Disk Parameter Table related
 	.bSize		resb	1	; Size of DPT (with extensions) in bytes
+	.wDrvNumAndFlags:
 	.bDrvNum	resb	1	; Drive number
 	.bFlags		resb	1	; DPT and Drive related flags
@@ -26,4 +23,5 @@
 	; IDE related
 	.wPCyls		resb	2	; Number of P-CHS (IDE) Cylinders (1...16383)
+	.wHeadsAndSectors:
 	.bPHeads	resb	1	; Number of P-CHS (IDE) Heads (1...16)
 	.bPSect		resb	1	; Number of P-CHS (IDE) Sectors per Track (1...63)
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 98)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 99)
@@ -54,7 +54,7 @@
 	.wFlags			resb	2	; Drive flags
 	.wCylinders		resb	2	; User specified cylinders (1...16383)
-	.wSectAndHeads:
+	.wHeadsAndSectors:
+	.bHeads			resb	1	; User specified Heads (1...16)
 	.bSect			resb	1	; User specified Sectors per track (1...63)
-	.bHeads			resb	1	; User specified Heads (1...16)
 endstruc
 
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 98)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 99)
@@ -1,7 +1,3 @@
-; File name		:	AtaID.asm
-; Project name	:	IDE BIOS
-; Created date	:	6.4.2010
-; Last update	:	9.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for accessing ATA information read with
 ;					IDENTIFY DEVICE command.
@@ -11,6 +7,4 @@
 
 ;--------------------------------------------------------------------
-; Returns P-CHS values from ATA information.
-;
 ; AtaID_GetPCHS
 ;	Parameters:
@@ -18,20 +12,17 @@
 ;	Returns:
 ;		AX:		Number of user specified P-CHS cylinders
-;		BL:		Number of user specified P-CHS sectors per track
-;		BH:		Number of user specified P-CHS heads
+;		BH:		Number of user specified P-CHS sectors per track
+;		BL:		Number of user specified P-CHS heads
 ;	Corrupts registers:
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 AtaID_GetPCHS:
 	mov		ax, [es:si+ATA1.wCylCnt]	; Cylinders (1...16383)
-	mov		bh, [es:si+ATA1.wHeadCnt]	; Heads (1...16)
-	mov		bl, [es:si+ATA1.wSPT]		; Sectors per Track (1...63)
+	mov		bl, [es:si+ATA1.wHeadCnt]	; Heads (1...16)
+	mov		bh, [es:si+ATA1.wSPT]		; Sectors per Track (1...63)
 	ret
 
 
 ;--------------------------------------------------------------------
-; Returns total number of available sectors from ATA information.
-;
 ; AtaID_GetTotalSectorCount
 ;	Parameters:
@@ -42,18 +33,19 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 AtaID_GetTotalSectorCount:
+	push	ds
+
+	push	es
+	pop		ds
 	xor		bx, bx
-	test	WORD [es:si+ATA1.wCaps], A1_wCaps_LBA
-	jz		SHORT AtaID_GetChsSectorCount
-	; Fall to AtaID_GetLbaSectorCount
+	test	WORD [si+ATA1.wCaps], A1_wCaps_LBA
+	jz		SHORT .GetChsSectorCount
+	; Fall to .GetLbaSectorCount
 
 ;--------------------------------------------------------------------
-; Returns total number of available sectors for LBA addressing.
-;
-; AtaID_GetLbaSectorCount
+; .GetLbaSectorCount
 ;	Parameters:
 ;		BX:		Zero
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;		DS:SI:	Ptr to 512-byte ATA information read from the drive
 ;	Returns:
 ;		BX:DX:AX:	48-bit sector count
@@ -61,24 +53,22 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
-AtaID_GetLbaSectorCount:
-	test	WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48
+.GetLbaSectorCount:
+	test	WORD [si+ATA6.wSetSup83], A6_wSetSup83_LBA48
 	jz		SHORT .GetLba28SectorCount
-	mov		ax, [es:si+ATA6.qwLBACnt]
-	mov		dx, [es:si+ATA6.qwLBACnt+2]
-	mov		bx, [es:si+ATA6.qwLBACnt+4]
+	mov		ax, [si+ATA6.qwLBACnt]
+	mov		dx, [si+ATA6.qwLBACnt+2]
+	mov		bx, [si+ATA6.qwLBACnt+4]
+	pop		ds
 	ret
-ALIGN JUMP_ALIGN
 .GetLba28SectorCount:
-	mov		ax, [es:si+ATA1.dwLBACnt]
-	mov		dx, [es:si+ATA1.dwLBACnt+2]
+	mov		ax, [si+ATA1.dwLBACnt]
+	mov		dx, [si+ATA1.dwLBACnt+2]
+	pop		ds
 	ret
 
 ;--------------------------------------------------------------------
-; Returns total number of available sectors for P-CHS addressing.
-;
-; AtaID_GetChsSectorCount
+; .GetChsSectorCount
 ;	Parameters:
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;		DS:SI:	Ptr to 512-byte ATA information read from the drive
 ;	Returns:
 ;		DX:AX:	24-bit sector count
@@ -86,8 +76,8 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-AtaID_GetChsSectorCount:
-	mov		al, [es:si+ATA1.wSPT]		; AL=Sectors per track
-	mul		BYTE [es:si+ATA1.wHeadCnt]	; AX=Sectors per track * number of heads
-	mul		WORD [es:si+ATA1.wCylCnt]	; DX:AX=Sectors per track * number of heads * number of cylinders
+.GetChsSectorCount:
+	mov		al, [si+ATA1.wSPT]		; AL=Sectors per track
+	mul		BYTE [si+ATA1.wHeadCnt]	; AX=Sectors per track * number of heads
+	mul		WORD [si+ATA1.wCylCnt]	; DX:AX=Sectors per track * number of heads * number of cylinders
+	pop		ds
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm	(revision 98)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm	(revision 99)
@@ -1,7 +1,3 @@
-; File name		:	DriveXlate.asm
-; Project name	:	IDE BIOS
-; Created date	:	15.3.2010
-; Last update	:	24.8.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for swapping drive letters.
 
@@ -100,46 +96,39 @@
 DriveXlate_SwapFloppyDriveOrHardDisk:
 	test	dl, 80h							; Hard disk?
-	jnz		SHORT DriveXlate_SwapHardDisk	; If so, jump to swap
-	; Fall to DriveXlate_SwapFloppyDrive
-
-;--------------------------------------------------------------------
-; Swaps Floppy Drive number.
-;
-; DriveXlate_SwapFloppyDrive
-;	Parameters:
-;		DL:		Drive number to be possibly swapped
-;		DS:		RAMVARS segment
-;	Returns:
-;		DL:		Translated drive number
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
-DriveXlate_SwapFloppyDrive:
+	jnz		SHORT .SwapHardDisk	; If so, jump to swap
+	; Fall to .SwapFloppyDrive
+
+;--------------------------------------------------------------------
+; .SwapFloppyDrive
+;	Parameters:
+;		DL:		Drive number to be possibly swapped
+;		DS:		RAMVARS segment
+;	Returns:
+;		DL:		Translated drive number
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+.SwapFloppyDrive:
 	eMOVZX	ax, BYTE [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
-	jmp		SHORT DriveXlate_SwapDrive
-
-;--------------------------------------------------------------------
-; Swaps Hard Disk number.
-;
-; DriveXlate_SwapHardDisk
-;	Parameters:
-;		DL:		Drive number to be possibly swapped
-;		DS:		RAMVARS segment
-;	Returns:
-;		DL:		Translated drive number
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-DriveXlate_SwapHardDisk:
+	jmp		SHORT SwapDrive
+
+;--------------------------------------------------------------------
+; .SwapHardDisk
+;	Parameters:
+;		DL:		Drive number to be possibly swapped
+;		DS:		RAMVARS segment
+;	Returns:
+;		DL:		Translated drive number
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.SwapHardDisk:
 	mov		ah, 80h
 	mov		al, BYTE [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
-	; Fall to DriveXlate_SwapDrive
-
-;--------------------------------------------------------------------
-; Swaps Hard Disk or Floppy Drive number.
-;
-; DriveXlate_SwapDrive
+	; Fall to SwapDrive
+
+;--------------------------------------------------------------------
+; SwapDrive
 ;	Parameters:
 ;		AL:		Drive number to swap to 00h/80h
@@ -151,6 +140,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
-DriveXlate_SwapDrive:
+SwapDrive:
 	cmp		ah, dl				; Swap DL from 00h/80h to xxh?
 	je		SHORT .SwapToXXhInAL
@@ -201,38 +189,10 @@
 DriveXlate_SetDriveToSwap:
 	test	dl, 80h				; Floppy drive?
-	jnz		SHORT DriveXlate_SetHardDiskToSwap
-	; Fall to DriveXlate_SetFloppyDriveToSwap
-
-;--------------------------------------------------------------------
-; Stores floppy drive to be swapped.
-;
-; DriveXlate_SetFloppyDriveToSwap
-;	Parameters:
-;		DL:		Drive to swap to 00h
-;		DS:		RAMVARS segment
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------	
-ALIGN JUMP_ALIGN
-DriveXlate_SetFloppyDriveToSwap:
+	jnz		SHORT .SetHardDiskToSwap
+.SetFloppyDriveToSwap:
 	mov		[RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
 	ret
-
-;--------------------------------------------------------------------
-; Stores hard disk to be swapped.
-;
-; DriveXlate_SetHardDiskToSwap
-;	Parameters:
-;		DL:		Drive to swap to 80h
-;		DS:		RAMVARS segment
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------	
-ALIGN JUMP_ALIGN
-DriveXlate_SetHardDiskToSwap:
+ALIGN JUMP_ALIGN
+.SetHardDiskToSwap:
 	mov		[RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 98)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 99)
@@ -18,9 +18,12 @@
 ;		BX, CX, DI
 ;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
 FloppyDrive_IsInt40hInstalled:
 	cmp		WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h	; Any ROM segment?
 	jb		SHORT .Int40hHandlerIsNotInstalled
+%ifdef USE_AT
 	call	.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
+%else
+	clc		; INT 40h installed. No need to verify on XT systems.
+%endif
 .Int40hHandlerIsNotInstalled:
 	cmc
@@ -37,5 +40,5 @@
 ;		BX, CX, DI
 ;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
+%ifdef USE_AT
 .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
 	push	es
@@ -45,7 +48,7 @@
 	call	.LoadInt40hVerifyParameters
 	int		INTV_DISK_FUNC
-	jc		SHORT .AH08hNotSupported	; AH=08h not supported on XTs but that doesn't
-	push	es							; matter since INT 40h does not need to be verified
-	push	di							; on XTs
+	jc		SHORT .Int40hIsInstalled	; Maybe there are not any floppy drives at all
+	push	es
+	push	di
 
 	call	.LoadInt40hVerifyParameters
@@ -58,8 +61,5 @@
 	mov		dx, es
 	cmp		cx, dx						; Difference in segments?
-	jne		SHORT .Int40hNotInstalled
-.AH08hNotSupported:
-	clc
-	jmp		SHORT .Int40hIsInstalled
+	je		SHORT .Int40hIsInstalled
 .Int40hNotInstalled:
 	stc
@@ -81,5 +81,4 @@
 ;		DH
 ;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
 .LoadInt40hVerifyParameters:
 	mov		ah, 08h				; Get Drive Parameters
@@ -88,4 +87,5 @@
 	mov		es, dx				; ES:DI = 0000:0000h to guard against BIOS bugs
 	ret
+%endif
 
 
@@ -133,9 +133,9 @@
 FloppyDrive_GetCount:
 	push	es
+%ifdef USE_AT
 	call	FloppyDrive_GetCountFromBIOS
-	jnc		SHORT .CompareToUserMinimum
+%else
 	call	FloppyDrive_GetCountFromBDA
-ALIGN JUMP_ALIGN
-.CompareToUserMinimum:
+%endif
 	MAX_U	cl, [cs:ROMVARS.bMinFddCnt]
 	xor		ch, ch
@@ -159,4 +159,5 @@
 ;		CH, ES
 ;--------------------------------------------------------------------
+%ifdef USE_AT
 ALIGN JUMP_ALIGN
 FloppyDrive_GetCountFromBIOS:
@@ -176,4 +177,5 @@
 	pop		di
 	ret
+%endif
 
 
@@ -190,4 +192,5 @@
 ;		CH, ES
 ;--------------------------------------------------------------------
+%ifndef USE_AT
 ALIGN JUMP_ALIGN
 FloppyDrive_GetCountFromBDA:
@@ -199,2 +202,3 @@
 	add		cl, ch							; CL = Floppy Drive count
 	ret
+%endif
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 98)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 99)
@@ -1,7 +1,3 @@
-; File name		:	AccessDPT.asm
-; Project name	:	IDE BIOS
-; Created date	:	16.3.2010
-; Last update	:	26.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for accessing DPT data.
 
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 98)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 99)
@@ -1,7 +1,3 @@
-; File name		:	CreateDPT.asm
-; Project name	:	IDE BIOS
-; Created date	:	12.3.2010
-; Last update	:	26.4.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Functions for creating Disk Parameter Table.
 
@@ -26,332 +22,200 @@
 ;				Set if any error
 ;	Corrupts registers:
-;		AX, CX, BX, DH
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
+;		AX, BX, CX, DH
+;--------------------------------------------------------------------
 CreateDPT_FromAtaInformation:
 	call	FindDPT_ForNewDrive		; Get new DPT to DS:DI
-	call	CreateDPT_Initialize
-	call	CreateDPT_StoreDriveControlByte
-	call	CreateDPT_StorePCHS
-	call	CreateDPT_StoreLCHS
-	call	CreateDPT_StoreAddressing
-	call	CreateDPT_StoreBlockMode
-	call	CreateDPT_StoreEBIOSSupport
-	jmp		CreateDPT_StoreDriveNumberAndUpdateDriveCount
-
-
-;--------------------------------------------------------------------
-; Initializes empty DPT by storing initial values that are not
-; read from ATA information.
-;
-; CreateDPT_Initialize
-;	Parameters:
-;		BH:		Drive Select byte for Drive and Head Register
-;		DS:DI:	Ptr to Disk Parameter Table
-;		CS:BP:	Ptr to IDEVARS for the controller
-;	Returns:
-;		CF:		Cleared if DPT parameters stored successfully
-;				Set if any error
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_Initialize:
-	xor		ax, ax						; Clear AX and CF
+	; Fall to .InitializeDPT
+
+;--------------------------------------------------------------------
+; .InitializeDPT
+;	Parameters:
+;		BH:		Drive Select byte for Drive and Head Register
+;		DS:DI:	Ptr to Disk Parameter Table
+;		CS:BP:	Ptr to IDEVARS for the controller
+;	Returns:
+;		AX:		Zero
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+.InitializeDPT:
+	xor		ax, ax
 	mov		BYTE [di+DPT.bSize], DPT_size
-	mov		BYTE [di+DPT.bDrvNum], al
-	mov		BYTE [di+DPT.bFlags], al
+	mov		[di+DPT.wDrvNumAndFlags], ax
 	mov		BYTE [di+DPT.bReset], MASK_RESET_ALL
-	mov		WORD [di+DPT.bIdeOff], bp
-	mov		BYTE [di+DPT.bDrvSel], bh
-	ret
-
-
-;--------------------------------------------------------------------
-; Stores Drive Control Byte for Device Control Register.
-;
-; CreateDPT_StoreDriveControlByte
-;	Parameters:
-;		BH:		Drive Select byte for Drive and Head Register
-;		DS:DI:	Ptr to Disk Parameter Table
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
-;		CS:BP:	Ptr to IDEVARS for the controller
-;	Returns:
-;		CF:		Cleared if DPT parameters stored successfully
-;				Set if any error
+	mov		[di+DPT.bIdeOff], bp
+	mov		[di+DPT.bDrvSel], bh
+	; Fall to .StoreDriveControlByte
+
+;--------------------------------------------------------------------
+; .StoreDriveControlByte
+;	Parameters:
+;		AX:		Zero
+;		BH:		Drive Select byte for Drive and Head Register
+;		DS:DI:	Ptr to Disk Parameter Table
+;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;		CS:BP:	Ptr to IDEVARS for the controller
+;	Returns:
+;		Nothing
 ;	Corrupts registers:
 ;		AX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_StoreDriveControlByte:
-	xor		ax, ax							; Zero AX
-	cmp		BYTE [cs:bp+IDEVARS.bIRQ], 0	; Interrupts enabled?
+.StoreDriveControlByte:
+	cmp		BYTE [cs:bp+IDEVARS.bIRQ], al	; Interrupts enabled?
 	jne		SHORT .CheckHeadCount
 	or		al, FLG_IDE_CTRL_nIEN			; Disable interrupts
-ALIGN JUMP_ALIGN
 .CheckHeadCount:
 	cmp		BYTE [es:si+ATA1.wHeadCnt], 8	; 1...8 heads?
-	jbe		SHORT .StoreDriveControlByte
+	jbe		SHORT .StoreDrvCtrlByteToDPT
 	or		al, FLG_IDE_CTRL_O8H			; Over 8 heads (pre-ATA)
-ALIGN JUMP_ALIGN
-.StoreDriveControlByte:
+.StoreDrvCtrlByteToDPT:
 	mov		[di+DPT.bDrvCtrl], al
-	clc
-	ret
-
-
-;--------------------------------------------------------------------
-; Stores P-CHS values from ATA information or user specified values to DPT.
-;
-; CreateDPT_StorePCHS
-;	Parameters:
-;		BH:		Drive Select byte for Drive and Head Register
-;		DS:DI:	Ptr to Disk Parameter Table
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
-;		CS:BP:	Ptr to IDEVARS for the controller
-;	Returns:
-;		CF:		Cleared if DPT parameters stored successfully
-;				Set if any error
-;	Corrupts registers:
-;		AX, BX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_StorePCHS:
-	call	CreateDPT_GetUserOrAtaPCHS
-	mov		[di+DPT.wPCyls], ax
-	mov		[di+DPT.bPHeads], bh
-	mov		[di+DPT.bPSect], bl
-	clc
-	ret
-
-;--------------------------------------------------------------------
-; Returns user specified P-CHS or values read from ATA information.
-;
-; CreateDPT_GetUserOrAtaPCHS
-;	Parameters:
-;		BH:		Drive Select byte for Drive and Head Register
-;		DS:DI:	Ptr to Disk Parameter Table
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
-;		CS:BP:	Ptr to IDEVARS for the controller
-;	Returns:
-;		AX:		Number of P-CHS cylinders
-;		BL:		Number of P-CHS sectors per track
-;		BH:		Number of P-CHS heads
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_GetUserOrAtaPCHS:
-	mov		ax, FLG_DRVPARAMS_USERCHS	; User specified CHS?
+	; Fall to .StorePCHS
+
+;--------------------------------------------------------------------
+; .StorePCHS
+;	Parameters:
+;		AH:		Zero
+;		BH:		Drive Select byte for Drive and Head Register
+;		DS:DI:	Ptr to Disk Parameter Table
+;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;		CS:BP:	Ptr to IDEVARS for the controller
+;	Returns:
+;		AX:		P-CHS cylinders
+;		BL:		P-CHS heads
+;		BH:		P-CHS sectors
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+.StorePCHS:
+	mov		al, FLG_DRVPARAMS_USERCHS	; User specified CHS?
 	call	AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
-	jnz		SHORT CreateDPT_GetUserSpecifiedPCHS
-	jmp		AtaID_GetPCHS
-
-;--------------------------------------------------------------------
-; Returns user specified P-CHS values from ROMVARS.
-;
-; CreateDPT_GetUserSpecifiedPCHS
-;	Parameters:
-;		DS:DI:	Ptr to Disk Parameter Table
-;		CS:BP:	Ptr to IDEVARS for the controller
-;	Returns:
-;		AX:		Number of user specified P-CHS cylinders
-;		BL:		Number of user specified P-CHS sectors per track
-;		BH:		Number of user specified P-CHS heads
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_GetUserSpecifiedPCHS:
+	jnz		SHORT .GetUserSpecifiedPCHS
+	call	AtaID_GetPCHS				; Get from ATA information
+	jmp		SHORT .StorePCHStoDPT
+
+.GetUserSpecifiedPCHS:
 	call	AccessDPT_GetPointerToDRVPARAMStoCSBX
 	mov		ax, [cs:bx+DRVPARAMS.wCylinders]
-	mov		bx, [cs:bx+DRVPARAMS.wSectAndHeads]
+	mov		bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]
 	or		BYTE [di+DPT.bFlags], FLG_DPT_USERCHS
-	ret
-
-
-;--------------------------------------------------------------------
-; Stores L-CHS values by converting from P-CHS values if necessary.
-;
-; CreateDPT_StoreLCHS
-;	Parameters:
-;		DS:DI:	Ptr to Disk Parameter Table
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
-;	Returns:
-;		CF:		Cleared if DPT parameters stored successfully
-;				Set if any error
-;	Corrupts registers:
-;		AX, CX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_StoreLCHS:
-	mov		cx, [di+DPT.wPCyls]			; P-CHS Cylinders (1...16383)
-	eMOVZX	dx, BYTE [di+DPT.bPHeads]	; P-CHS Heads (1...16)
-	call	CreateDPT_ShiftPCHtoLCH
-	test	dh, dh						; 256 heads?
-	jz		SHORT .StoreToDPT			;  If less, no correction needed
-	dec		dx							; Limit to 255 heads since DOS does not support 256 heads
-ALIGN JUMP_ALIGN
-.StoreToDPT:
-	mov		[di+DPT.bShLtoP], al
-	mov		[di+DPT.wLHeads], dx
-	clc
-	ret
-
-;--------------------------------------------------------------------
-; Returns L-CHS values from P-CHS values.
-; Sectors per track is always the same for both addressing modes.
-;
-; CreateDPT_ShiftPCHtoLCH:
-;	Parameters:
-;		CX:		Number of P-CHS cylinders (1...16383)
-;		DX:		Number of P-CHS heads (1...16)
-;	Returns:
-;		AL:		Number of bits shifted
-;		CX:		Number of L-CHS cylinders (1...1024)
-;		DX:		Number of L-CHS heads (1...256)
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_ShiftPCHtoLCH:
-	xor		al, al				; Zero AL
-ALIGN JUMP_ALIGN
+
+.StorePCHStoDPT:
+	mov		[di+DPT.wPCyls], ax
+	mov		[di+DPT.wHeadsAndSectors], bx
+	; Fall to .StoreLCHS
+
+;--------------------------------------------------------------------
+; .StoreLCHS
+;	Parameters:
+;		AX:		P-CHS cylinders
+;		BL:		P-CHS heads
+;		DS:DI:	Ptr to Disk Parameter Table
+;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX
+;--------------------------------------------------------------------
+.StoreLCHS:
+	xor		bh, bh						; BX = P-CHS Heads (1...16)
+	xor		cx, cx
 .ShiftLoop:
-	cmp		cx, 1024			; Need to shift?
-	jbe		SHORT .Return		;  If not, return
-	inc		ax					; Increment shift count
-	shr		cx, 1				; Halve cylinders
-	shl		dx, 1				; Double heads
+	cmp		ax, 1024					; Need to shift?
+	jbe		SHORT .LimitHeadsTo255		;  If not, return
+	inc		cx							; Increment shift count
+	shr		ax, 1						; Halve cylinders
+	shl		bx, 1						; Double heads
 	jmp		SHORT .ShiftLoop
-ALIGN JUMP_ALIGN
-.Return:
-	ret
-
-
-;--------------------------------------------------------------------
-; Stores addressing information (L-CHS, P-CHS, LBA28 or LBA48).
-;
-; CreateDPT_StoreAddressing
-;	Parameters:
-;		DS:DI:	Ptr to Disk Parameter Table
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
-;	Returns:
-;		CF:		Cleared if DPT parameters stored successfully
-;				Set if any error
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_StoreAddressing:
+
+.LimitHeadsTo255:
+	test	bh, bh						; 256 heads?
+	jz		SHORT .StoreLCHStoDPT		;  If less, no correction needed
+	dec		bx							; Limit to 255 heads since DOS does not support 256 heads
+.StoreLCHStoDPT:
+	mov		[di+DPT.bShLtoP], cl
+	mov		[di+DPT.wLHeads], bx
+	; Fall to .StoreAddressing
+
+;--------------------------------------------------------------------
+; .StoreAddressing
+;	Parameters:
+;		DS:DI:	Ptr to Disk Parameter Table
+;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+.StoreAddressing:
 	cmp		WORD [di+DPT.wPCyls], 1024		; L-CHS possible? (no translation needed)
-	jbe		SHORT .Return					;  If so, nothing needs to be changed
+	jbe		SHORT .StoreBlockMode			;  If so, nothing needs to be changed
 	test	BYTE [di+DPT.bFlags], FLG_DPT_USERCHS
-	jnz		SHORT .StorePCHS				; Use user defined P-CHS
+	jnz		SHORT .StorePCHSaddressing		; Use user defined P-CHS
 	test	WORD [es:si+ATA1.wCaps], A2_wCaps_LBA
-	jz		SHORT .StorePCHS				; Use P-CHS since LBA not supported
+	jz		SHORT .StorePCHSaddressing		; Use P-CHS since LBA not supported
 	test	WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48
-	jz		SHORT .StoreLBA28				; Use LBA-28 since LBA-48 not supported
+	jz		SHORT .StoreLBA28addressing		; Use LBA-28 since LBA-48 not supported
 	or		BYTE [di+DPT.bFlags], ADDR_DPT_LBA48<<1
-ALIGN JUMP_ALIGN
-.StoreLBA28:
+.StoreLBA28addressing:
 	or		BYTE [di+DPT.bFlags], ADDR_DPT_LBA28<<1
 	or		BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA
-	ret
-ALIGN JUMP_ALIGN
-.StorePCHS:
+	jmp		SHORT .StoreBlockMode
+.StorePCHSaddressing:
 	or		BYTE [di+DPT.bFlags], ADDR_DPT_PCHS<<1
-ALIGN JUMP_ALIGN
-.Return:
-	clc
-	ret
-
-
-;--------------------------------------------------------------------
-; Stores Block Mode information.
-;
-; CreateDPT_StoreBlockMode
-;	Parameters:
-;		DS:DI:	Ptr to Disk Parameter Table
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
-;	Returns:
-;		CF:		Cleared if DPT parameters stored successfully
-;				Set if any error
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_StoreBlockMode:
+	; Fall to .StoreBlockMode
+
+;--------------------------------------------------------------------
+; .StoreBlockMode
+;	Parameters:
+;		DS:DI:	Ptr to Disk Parameter Table
+;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+.StoreBlockMode:
 	mov		al, 1						; Minimum block size is 1 sector
 	mov		ah, [es:si+ATA1.bBlckSize]	; Load max block size in sectors
 	mov		[di+DPT.wSetAndMaxBlock], ax
-	ret
-
-
-;--------------------------------------------------------------------
-; Stores variables required by EBIOS functions.
-;
-; CreateDPT_StoreEBIOSSupport
-;	Parameters:
-;		DS:DI:	Ptr to Disk Parameter Table
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
-;	Returns:
-;		CF:		Cleared if DPT parameters stored successfully
-;				Set if any error
+	; Fall to .StoreEBIOSSupport
+
+;--------------------------------------------------------------------
+; .StoreEBIOSSupport
+;	Parameters:
+;		DS:DI:	Ptr to Disk Parameter Table
+;		ES:SI:	Ptr to 512-byte ATA information read from the drive
+;	Returns:
+;		Nothing
 ;	Corrupts registers:
 ;		AX, BX, DX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_StoreEBIOSSupport:
-	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE	; (clears CF)
-	jz		SHORT .DoNotSupportEBIOS	; No EBIOS support since small DPTs needed
+.StoreEBIOSSupport:
+	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
+	jz		SHORT .StoreDriveNumberAndUpdateDriveCount	; No EBIOS support since small DPTs needed
+
 	mov		bl, [di+DPT.bFlags]
-	and		bx, BYTE MASK_DPT_ADDR		; Addressing mode (clears CF)
-	jmp		[cs:bx+.rgwAddrJmp]			; Jump to handle addressing mode
-ALIGN WORD_ALIGN
+	and		bx, BYTE MASK_DPT_ADDR						; Addressing mode
+	jmp		[cs:bx+.rgwAddrJmp]							; Jump to handle addressing mode
 .rgwAddrJmp:
-	dw		.DoNotSupportEBIOS			; ADDR_DPT_LCHS
-	dw		.DoNotSupportEBIOS			; ADDR_DPT_PCHS
-	dw		.SupportForLBA28			; ADDR_DPT_LBA28
-	dw		.SupportForLBA48			; ADDR_DPT_LBA48
-ALIGN JUMP_ALIGN
-.DoNotSupportEBIOS:
-	ret
-ALIGN JUMP_ALIGN
+	dw		.StoreDriveNumberAndUpdateDriveCount		; ADDR_DPT_LCHS
+	dw		.StoreDriveNumberAndUpdateDriveCount		; ADDR_DPT_PCHS
+	dw		.SupportForLBA28							; ADDR_DPT_LBA28
+	dw		.SupportForLBA48							; ADDR_DPT_LBA48
+
 .SupportForLBA28:
 	sub		BYTE [di+DPT.bSize], 2		; Only 4 bytes for sector count
-ALIGN JUMP_ALIGN
 .SupportForLBA48:
 	add		BYTE [di+DPT.bSize], EBDPT_size - DPT_size
 	or		BYTE [di+DPT.bFlags], FLG_DPT_EBIOS
-	; Fall to CreateDPT_StoreEbiosSectorCount
-
-;--------------------------------------------------------------------
-; Stores EBIOS total sector count for LBA addressing.
-;
-; CreateDPT_StoreEbiosSectorCount
-;	Parameters:
-;		DS:DI:	Ptr to Disk Parameter Table
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
-;	Returns:
-;		CF:		Cleared if DPT parameters stored successfully
-;				Set if any error
-;	Corrupts registers:
-;		AX, BX, DX
-;--------------------------------------------------------------------
-;ALIGN JUMP_ALIGN
-CreateDPT_StoreEbiosSectorCount:
 	call	AtaID_GetTotalSectorCount
 	mov		[di+EBDPT.twCapacity], ax
 	mov		[di+EBDPT.twCapacity+2], dx
 	mov		[di+EBDPT.twCapacity+4], bx
-	clc
-	ret
-
-
-;--------------------------------------------------------------------
-; Stores number for drive and updates drive count.
-;
-; CreateDPT_StoreDriveNumberAndUpdateDriveCount
+	; Fall to .StoreDriveNumberAndUpdateDriveCount
+
+;--------------------------------------------------------------------
+; .StoreDriveNumberAndUpdateDriveCount
 ;	Parameters:
 ;		DS:DI:	Ptr to Disk Parameter Table
@@ -365,6 +229,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CreateDPT_StoreDriveNumberAndUpdateDriveCount:
+.StoreDriveNumberAndUpdateDriveCount:
 	; Make sure that more drives can be accepted
 	mov		dl, [es:BDA.bHDCount]	; Load number of hard disks
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 98)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 99)
@@ -171,6 +171,4 @@
 
 ;--------------------------------------------------------------------
-; Increments hard disk count to RAMVARS.
-;
 ; RamVars_IncrementHardDiskCount
 ;	Parameters:
@@ -182,5 +180,4 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 RamVars_IncrementHardDiskCount:
 	inc		BYTE [RAMVARS.bDrvCnt]		; Increment drive count to RAMVARS
@@ -188,5 +185,4 @@
 	ja		SHORT .Return				;  If so, return
 	mov		[RAMVARS.bFirstDrv], dl		; Store first drive number
-ALIGN JUMP_ALIGN
 .Return:
 	ret
@@ -242,11 +238,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------	
-ALIGN JUMP_ALIGN
 RamVars_GetIdeControllerCountToCX:
-	mov		cx, 1					; Assume lite mode (one controller)
-	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
-	jz		SHORT .Return
-	mov		cl, [cs:ROMVARS.bIdeCnt]
-ALIGN JUMP_ALIGN, ret
-.Return:
-	ret
+	eMOVZX	cx, BYTE [cs:ROMVARS.bIdeCnt]
+	ret
