;	[]===========================================================[]
;
;	NOTICE: THIS PROGRAM BELONGS TO AWARD SOFTWARE INTERNATIONAL(R)
;	        INC. IT IS CONSIDERED A TRADE SECRET AND IS NOT TO BE 	
;	        DIVULGED OR USED BY PARTIES WHO HAVE NOT RECEIVED	
;	        WRITTEN AUTHORIZATION FROM THE OWNER.
;
; 	[]===========================================================[]
;

;----------------------------------------------------------------------------
;Rev	Date	 Name	Description
;----------------------------------------------------------------------------
;R31	04/19/99 ADS	Fixed if Floppy set "NONE" ,don't reset floppy .
;R26D	12/29/98 KVN	Fixed display EPA pattern abnormally by R26C when
;			BIOS.CFG define "Graphics_post"
;R26C	12/21/98 KVN	Fixed display EPA pattern abnormally when define
;			"NOT_USE_CBROM_EPALOGO"
;R30	05/07/98 DRS	This function depends on New_Swap_Fdd_Method
;			The new method is Drive A exists or Drive B exists , 
;			the Floppy Swap function is available.
;R29A	12/19/97 KVN	Fixed display wrong award logo if define "Graphics_post"
;R29	12/18/97 LAW	change "EPA_LOGO_Use_Graphics" with "FULL_SCREEN_LOGO"
;			switch to "Graphics_post"
;R28	11/25/97 LAW	change Award_Mark_Font for define "EPA_LOGO_Use_Graphics"
;R27	11/17/97 KVN	Don't seek floppy B in POST stage if drive B type is
;			NONE
;R26B	10/08/97 KVN	Fixed R26A coding to function normaly
;R26A	10/02/97 KVN	Fixed R26 code for choise fpinstall locate at XGROUP or
;			EGROUP
;R26	08/28/97 KVN	Remove FPINSTAL.ASM to XGROUP from EGROUP to reduce
;			compressed size for 2M BIOS code overflow (i.e. system
;			BIOS compressed code cover to decompress code)
;R25	06/17/97 LAW	added "FDC_FIFO_SELECTABLE" for Winbond 83877/83977...
;			use BorderWare Firewall Server install hang at boot
;R24	05/26/97 DNL	Add "Support_1_FDD" definition
;R23	05/21/97 LAW	add "AMITECH_LOGO" always define "NOT_USE_CBROM_EPALOGO"
;R22	05/13/97 LAW	Move EpaLogo data and Award_Mark_Font use cbrom include.
;			Befor the special EpaLogo must define "NOT_USE_CBROM_EPALOGO"
;R21	12/24/96 RAX	Add "No_seek_Floppy" define for notebook if define
;			"HIDE_STD_ITEMS" will always Seek
;R20	09/12/96 LAW	Added "Fdd_install_flag_selectable" for test Windows
;			logo fdd disable Free IRQ6
;R19	08/08/96 KVN	Added customer EPA LOGO support
;R18	07/23/96 LAW	Fixed setting FDD 3 mode FLAG wrong When Swap FDD disk
;R17    07/23/96 LAW    delete enable FDD 3 mode code
;R16	04/02/96 RCH	Hide some standard items for special customer (ECS)
;			"floppy seek","boot up speed" & "typematic rate"
;R15	02/16/96 KVN	Fixed AWARD logo display wrong
;R13A	01/26/96 RCH	WINDOW v3.1 have a bug, if the bit 0 of HARDWARE was
;			clear , system can not access HDD under icon "RECORD"
;			when no FDD installed. In order to fix this bug,
;			this bit still set even no FDD installed. But if
;			customer insist to fix WIN 95 FDD reporting as "R13"
;			said, we can define "PATCH_WIN95_NO_FDD".		
;R14	12/21/95 RAY	Some customer need to release IRQ 6 if FDD error
;			This switch is special for ECS.
;R13	12/08/95 RCH	Clear bit 0 of HARDWARE if no FDD installed. if this 
;			bit set , WIN95 always show "5.25" FDD" icon even
;			no FDD installed, if clear , show "Removable Disk"
;			instead.
;R12	12/05/95 RCH	Microsoft use "FINDIRQ" to check "IN USE" IRQs by
;			checking mask byte of 8259 and strongly request
;			to release IRQ 6 if no FDD installed. but this cause
;			AHA-1542B can not boot for non-FDD system, this
;			is Adaptec's bug and they don't want to fix it.
;			so if customer insisted , you can define 
;			"FIX_NO_FDD_FOR_AHA1542" to fix it but will failed
;			with Microsoft testing.
;R11	12/05/95 RCH	Need to set FIFO for FDD controller even FDC seek is
;			disabled.
;R10	11/03/95 KVN	Added floppy 3 mode 1.2Mb format
;R09	09/06/95 KVN	Added floppy write protect function
;R08	09/04/95 KVN	Added floppy 3 mode auto switch
;R07	06/24/94 KVN	Remove EPA and award logo from pmkernal.asm for reduse
;			E8000h code size
;R06	08/22/95 DNL	Kill duplicate codes
;R05	08/09/95 RCH	Don't turn on IRQ 8 , because FDD don't use it no more
;R04	06/30/95 AVN	Change Define To Support No FIFO.
;R02A	06/19/95 KVN	Fix AHA-1542B can't boot if IRQ 6 to be disabled so
;			always enable IRQ 6 even none floppy type
;R03	06/13/95 KVN	Reduce Post_func_call and F000_call code size
;R02	03/23/95 RCH	Don't turn IRQ mask if no FDD installed, otherwise
;			system can not enter power down mode if IRQ 6 is
;			monitored by chipset
;Rvv	02/28/95 AVN	Added Onboard I/O Detect by Auto.
;R01	12/27/94 RCH	The "assume" for ES should followed by DS , otherwise
;			the complier will reference DS instead of ES.
;R00	08/24/83 KVN	Fixed up when cold or warm boot after format diskette
;			and once again format it then fail.
		PAGE	56,132
		TITLE	FPINSTAL 
;R06.386
.386P						;R06
;		+-----------------------+
;		|			|
;		|    386 ROM/BIOS 	|
;		|			|
;		+-----------------------+


.XLIST
ENABLE_288_SUPPORT	EQU	1
ENABLE_FDC_FIFO		EQU	1	; (2.88 needs FIFO to avoid slow DMA errors)
FDC_FIFO_THRES		EQU	8	; (FIFO threshold set to mid value)

CMOS_FD_288		EQU	5	; (CMOS value for 2.88, can be changed)
		INCLUDE BIOS.CFG

		INCLUDE	BTROMSEG.EQU		;R26B
		INCLUDE	COMMON.EQU		;R26B
		INCLUDE	POST.EQU

		INCLUDE 8259.EQU
		INCLUDE 82077.EQU

IFDEF AUTO_CFG_FLOPPY							;R02B
		INCLUDE	AUTO_CFG.EXT					;R02B
ENDIF ;AUTO_CFG_FLOPPY							;R02B

		INCLUDE POST.EXT
		INCLUDE ATORGS.EXT
		INCLUDE ADISK.EXT

		INCLUDE COMMON.MAC
ifndef	HIDE_STD_ITEMS						;R16
		extrn	FdcSeek_Item:near
endif;	HIDE_STD_ITEMS						;R16
;R06		extrn	GetItem_Value:near
.LIST


;Rvv  - start
ifdef	AUTO_CFG_IO
		extrn	AUTO_IO_Item:near
		extrn	IO_CHIP_FUNC_DISABLE:near
		extrn	AUTO_CFG_IO_FDC:near
endif;	AUTO_CFG_IO
;Rvv - end

G_RAM		SEGMENT	USE16 AT 40H
		INCLUDE	G_RAM.INC
G_RAM		ENDS

;R03		extrn	F000_func_end:Near	;128k
;R03		extrn	F000_VECT:Near		;128k
		extrn	F000_call_proc:near	;R03
		extrn	F000_VECT:near		;R06
		extrn	RET_E_SEG:near		;R06
ifndef FPINSTALL_IN_XGROUP			;R26A
		extrn	F000_GetItem_Value:near	;R06
endif ;FPINSTALL_IN_XGROUP			;R26A
		extrn	GetItem_Value:near	;R26B
;R08 start
ifdef	FDD_3_Mode
		extrn	DRIVE_MODE_ITEM:near
		extrn	DRIVE_A_ITEM:near
ifndef	Support_1_FDD				;R24
		extrn	DRIVE_B_ITEM:near
endif	;Support_1_FDD				;R24
		extrn	Set_FDD_3_mode:near		;R10
ifndef	Support_1_FDD				;R24
		extrn	SwapFloppy_Item:near		;R18
endif	;Support_1_FDD				;R24
endif	;FDD_3_Mode
;R08 end
;R09 start
ifdef	Support_FDD_Write_Protect
		extrn	Fdd_Wt_Protect_Item:near
endif	;Support_FDD_Write_Protect
;R09 end

;R20 - start
ifdef	Fdd_install_flag_selectable
		extrn	Windows_select_Item:Near
endif	;Fdd_install_flag_selectable
;R20 - end

ifdef	FDC_FIFO_SELECTABLE				;R25
		extrn	FDC_FIFO_Item:Near		;R25
endif;	FDC_FIFO_SELECTABLE				;R25

;R26A start
ifdef FPINSTALL_IN_XGROUP
XGROUP		GROUP	XCODE
XCODE		SEGMENT	USE16 PARA PUBLIC 'XCODE'
		ASSUME	CS:XGROUP,DS:G_RAM,ES:XGROUP
else ;FPINSTALL_IN_XGROUP
;R26A end
EGROUP		GROUP	ECODE
ECODE		SEGMENT	USE16 PARA PUBLIC 'ECODE'
		ASSUME	CS:EGROUP,DS:G_RAM,ES:EGROUP
endif ;FPINSTALL_IN_XGROUP				;R26A

		PUBLIC	FP_INSTALL
FP_INSTALL	PROC	NEAR
		push	ds

		mov	ax,G_RAM
		mov	ds,ax
		assume	ds:G_RAM

		mov	byte ptr FLOPPY_ERROR[bp], 0		; turn off errors

		test	Hardware,1		; is cmos good, or no drives?
		jz	do_aux

IFDEF AUTO_CFG_FLOPPY										;R02B
		call	Auto_Cfg_Floppy_Disable			; force default fixed off	;R02B
ENDIF ;AUTO_CFG_FLOPPY										;R02B

;Rvv - start
ifdef	AUTO_CFG_IO
		mov	si,offset AUTO_IO_Item
;R06		F000_Call GetItem_Value
		Call	F000_GetItem_Value		;R06
		test	al,al
		jz	fdc_cfg_exit			; JMP If not AUTO
		mov	al,02h				; Disable FDC Port
		F000_Call IO_CHIP_FUNC_DISABLE
fdc_cfg_exit:
endif;	AUTO_CFG_IO
;Rvv - end

;R08 start
ifdef	FDD_3_Mode
;R18 - start
ifdef	Support_1_FDD				;R24
		mov	ch,FloppyA_3_mode	;R24
else	;Support_1_FDD				;R24
		mov	si,offset SWAPFloppy_Item	;get swapfloppy item
		call	F000_GetItem_Value		;Yes or No
		mov	ch,FloppyA_3_mode
		mov	cl,FloppyB_3_mode
		or	al,al
		jz	short @F			;No,don't swap fdd 3
		mov	cl,FloppyA_3_mode		;mode flag
		mov	ch,FloppyB_3_mode
@@:
endif	;Support_1_FDD				;R24
;R18 - end
		mov	si,offset DRIVE_MODE_ITEM
		call	F000_GetItem_Value
;R10		or	al,al
;R10		jz	short @F
;R10		or	byte ptr ds:FDD_VERIFY_CMD_FLAG,Floppy_3_mode
;R10 start
		test	al,1
		jz	short @F
;R18		or	byte ptr ds:FDD_VERIFY_CMD_FLAG,FloppyA_3_mode
		or	byte ptr ds:FDD_VERIFY_CMD_FLAG,ch	;R18
@@:
ifndef	Support_1_FDD				;R24
		test	al,2
		jz	short @F
;R18		or	byte ptr ds:FDD_VERIFY_CMD_FLAG,FloppyB_3_mode
		or	byte ptr ds:FDD_VERIFY_CMD_FLAG,cl	;R18
@@:
endif	;Support_1_FDD				;R24
;R10 end
		mov	si,offset DRIVE_A_ITEM
		call	F000_GetItem_Value
		cmp	al,2			;R10 ;Is 1.2 MB floppy type?
		je	short @F		;R10 ;Yes,jump
		cmp	al,4			;Is 1.44 MB floppy type?
		je	short @F		;Yes,jump
;R10 start
		and	byte ptr ds:FDD_VERIFY_CMD_FLAG,not FloppyA_3_mode
@@:
;R10 end
ifndef	Support_1_FDD				;R24
		mov	si,offset DRIVE_B_ITEM
		call	F000_GetItem_Value
		cmp	al,2			;R10 ;Is 1.2 MB floppy type?
		je	short @F		;R10 ;Yes,jump
		cmp	al,4			;Is 1.44 MB floppy type?
		je	short @F		;Yes,jump
;R10		and	byte ptr ds:FDD_VERIFY_CMD_FLAG,not Floppy_3_mode
		and	byte ptr ds:FDD_VERIFY_CMD_FLAG,not FloppyB_3_mode	;R10
@@:
endif	;Support_1_FDD				;R24

;R17;R10 start
;R17		xor	al,al			;Disable 3 mode
;R17		test	byte ptr ds:FDD_VERIFY_CMD_FLAG,(FloppyA_3_mode+FloppyB_3_mode)
;R17		jz	short @F
;R17		mov	al,1
;R17@@:
;R17		F000_call	Set_FDD_3_mode
;R17;R10 end
endif	;FDD_3_Mode
;R08 end
;R09 start
ifdef	Support_FDD_Write_Protect
		and	G_RAM:[POST_FLAG],not Fdd_Wt_Protect_Status
		lea	si,Fdd_Wt_Protect_Item
		call	F000_GetItem_Value
		or	al,al
		jz	short @F
		or	G_RAM:[POST_FLAG],Fdd_Wt_Protect_Status
@@:
endif	;Support_FDD_Write_Protect
;R09 end

;	Set speed control

		mov	al,2
		mov	dx,FDC_CTRL_IN		; SET SPEED CONTROL FOR NO COMBO
		out	dx,al
		IODELAY

;R02 - start
;R02A		test	byte ptr FLOPPY_TYPE[bp],0ffH	; no floppy installed ?
;R02A		jz	short No_Fdd_Attach
		cli
;R02 - end

;	Enable floppy IRQ

		in	al,A8259+1
		and	al,0bbh			; enable fdc and slave int
		IODELAY
		out	A8259+1,al
		
;R05		in	al,B8259+1
;R05		and	al,0feh			; enable cmos chip
;R05		IODELAY
;R05		out	B8259+1,al
;R02ANo_Fdd_Attach:					;R02

		sti

;[]-------------------------------------------------------------[]
;Rvv - start
ifdef	AUTO_CFG_IO
		push	si
		mov	si,offset AUTO_IO_Item
;R06		F000_Call GetItem_Value
		Call	F000_GetItem_Value		;R06
		pop	si
		test	al,al
		jnz	Seek_Always_Done		; JMP If not AUTO
endif;	AUTO_CFG_IO
;Rvv - end

;R25 - start
ifdef	FDC_FIFO_SELECTABLE
		push	si
		mov	si,offset FDC_FIFO_Item
		Call	F000_GetItem_Value
		pop	si
		mov	FDC_FIFO_FLAG[bp], al
endif;	FDC_FIFO_SELECTABLE
;R25 - end

ifndef	HIDE_STD_ITEMS						;R16

;Check floopy seek or not
		push	si
		mov	si,offset FdcSeek_Item
;R06		F000_Call GetItem_Value
		Call	F000_GetItem_Value		;R06
		or	al,al		    	; quick POST?
		pop	si
		jnz	short @F
   
;Set drive capacity
;1. check Drive A		
		xor	ah,ah
		mov	al,FLOPPY_TYPE[bp]	; read diskette drive type byte
		and	al,0f0h
		jz	short Set_DriveB
		cmp	al,10h			; 360K?
		je	short Low_CapA
		or	ah,1			; set 80 tracks
		cmp	al,30h			; 720k drive?
		je	short Low_CapA
		or	ah,2
		jmp	short Set_DriveB
Low_CapA:
		or	ah,4			; set invalid bit
Set_DriveB:
ifndef	Support_1_FDD				;R24
;2. Check Drive B
		mov	al,FLOPPY_TYPE[bp]	; read diskette drive type byte
		and	al,0fh
		jz	short No_DriveB
		cmp	al,1h			; 360K?
		je	short Low_CapB
		or	ah,10h			; set 80 tracks
		cmp	al,3h			; 720k drive?
		je	short Low_CapB
		or	ah,20h
		jmp	short No_DriveB
Low_CapB:
		or	ah,40h			; set invalid bit

No_DriveB:
endif	;Support_1_FDD				;R24
		
		or	byte ptr DCAPABILITY,ah
		mov	byte ptr MOST_RECENT_RATE,81h	;R00

;R11 - start
IFDEF	ENABLE_288_SUPPORT
		F000_call	FD_Perp_Mode		; set perpendicular mode based on CMOS
;R25 - start
ifdef	FDC_FIFO_SELECTABLE
		mov	al, FDC_FIFO_FLAG[bp]
		or	al, al
		jz	short No_enable_FDC_FIFO1
		F000_call	FD_FIFO_Mode		; enable FD controller FIFO
	No_enable_FDC_FIFO1:
else;	FDC_FIFO_SELECTABLE
;R25 -end
IFNDEF	DISABLE_FDC_FIFO						
		F000_call	FD_FIFO_Mode		; enable FD controller FIFO
ENDIF;	DISABLE_FDC_FIFO						
endif;	FDC_FIFO_SELECTABLE				;R25
ENDIF	;ENABLE_288_SUPPORT
;R11 - end

		jmp	Skip_Floppy 	   	; yes
@@:
;R21 - start
else;	HIDE_STD_ITEMS
ifdef	NO_SEEK_Floppy
;Set drive capacity
;1. check Drive A		
		xor	ah,ah
		mov	al,FLOPPY_TYPE[bp]	; read diskette drive type byte
		and	al,0f0h
		jz	short Set_DriveB
		cmp	al,10h			; 360K?
		je	short Low_CapA
		or	ah,1			; set 80 tracks
		cmp	al,30h			; 720k drive?
		je	short Low_CapA
		or	ah,2
		jmp	short Set_DriveB
Low_CapA:
		or	ah,4			; set invalid bit
Set_DriveB:
ifndef	Support_1_FDD				;R24
;2. Check Drive B
		mov	al,FLOPPY_TYPE[bp]	; read diskette drive type byte
		and	al,0fh
		jz	short No_DriveB
		cmp	al,1h			; 360K?
		je	short Low_CapB
		or	ah,10h			; set 80 tracks
		cmp	al,3h			; 720k drive?
		je	short Low_CapB
		or	ah,20h
		jmp	short No_DriveB
Low_CapB:
		or	ah,40h			; set invalid bit

No_DriveB:
endif	;Support_1_FDD				;R24
		
		or	byte ptr DCAPABILITY,ah
		mov	byte ptr MOST_RECENT_RATE,81h	;R00

;R11 - start
IFDEF	ENABLE_288_SUPPORT
		F000_call	FD_Perp_Mode		; set perpendicular mode based on CMOS
;R25 - start
ifdef	FDC_FIFO_SELECTABLE
		mov	al, FDC_FIFO_FLAG[bp]
		or	al, al
		jz	short No_enable_FDC_FIFO2
		F000_call	FD_FIFO_Mode		; enable FD controller FIFO
	No_enable_FDC_FIFO2:
else;	FDC_FIFO_SELECTABLE
;R25 -end
IFNDEF	DISABLE_FDC_FIFO						
		F000_call	FD_FIFO_Mode		; enable FD controller FIFO
ENDIF;	DISABLE_FDC_FIFO						
endif;	FDC_FIFO_SELECTABLE				;R25
ENDIF	;ENABLE_288_SUPPORT
;R11 - end
		jmp	Skip_Floppy 	   	; yes
endif	;NO_SEEK_Floppy
;R21 - end
endif;	HIDE_STD_ITEMS						;R16

;Rvv - start
ifdef	AUTO_CFG_IO
Seek_Always_Done:
endif;	AUTO_CFG_IO
;Rvv - end
;[]-------------------------------------------------------------[]

;
;	Try to reset the floppy subsystem
;
try_reset_flpy:								   
;R31 - strat
		cmp	byte ptr FLOPPY_TYPE[bp],0	; set floppy none
		je	Skip_Floppy 	   	; yes
;R31 - end
		xor	ax,ax
		mov	dl,ah
		int	13h			; reset floppy
		jnc	short do_diskette_poi
IFDEF AUTO_CFG_FLOPPY
;
;	If we get an error trying to initialize the floppy then
;	we try an enable the on-board/secondary floppy controller.
;	If no error, we try to initialize normally otherwise we
;	fail normally.
;
		call	Auto_Cfg_Floppy_Init	; try to initialize 2ndary controller
		jc	short fail_reset_flpy	; skip if error
		xor	ax,ax			; else try normal reset
		mov	dl,ah
		int	13h			; reset floppy
		jnc	short do_diskette_poi

fail_reset_flpy:
ENDIF ;AUTO_CFG_FLOPPY

;Rvv  - start
ifdef	AUTO_CFG_IO
		F000_call AUTO_CFG_IO_FDC
; try reset floppy:								   
		xor	ax,ax			; else try normal reset
		mov	dl,ah
		int	13h			; reset floppy
		jnc	short do_diskette_poi
endif;	AUTO_CFG_IO
;Rvv - end

;
;	Mark that we've had a floppy controller error.
;
		or	byte ptr FLOPPY_ERROR[bp], UNABLE_FLOPPY_RESET
		or	byte ptr CMOS_STATUS[bp], EQUIP_STATUS

		jmp	short do_aux

DO_DISKETTE_POI:
		CALL	DISKETTE_POI		; initializes floppy system.

IFDEF	ENABLE_288_SUPPORT

;		Failure of either of these routines,
;		(carry set on exit) should indicate
;		a POST Floppy Error.

		F000_call	FD_Perp_Mode		; set perpendicular mode based on CMOS
  IFDEF ONLY_288_CONTROLLER						
		jnc	short FP_288_1		; skip no error, else signal error
		or	byte ptr FLOPPY_ERROR[bp], FLOPPY_TYPE_MISMATCH
		or	byte ptr CMOS_STATUS[bp], EQUIP_STATUS
FP_288_1:
  ENDIF ;ONLY_288_CONTROLLER						

;R25 - start
ifdef	FDC_FIFO_SELECTABLE
		mov	al, FDC_FIFO_FLAG[bp]
		or	al, al
		jz	short No_enable_FDC_FIFO3
		F000_call	FD_FIFO_Mode		; enable FD controller FIFO
	No_enable_FDC_FIFO3:
else;	FDC_FIFO_SELECTABLE
;R25 -end
IFNDEF	DISABLE_FDC_FIFO						;R04
;R04 IFDEF	ENABLE_FDC_FIFO
		F000_call	FD_FIFO_Mode		; enable FD controller FIFO
endif;	DISABLE_FDC_FIFO				;R25
endif;	FDC_FIFO_SELECTABLE				;R25
ifdef	DISABLE_FDC_FIFO				;R25
    IFDEF ONLY_288_CONTROLLER						
		jnc	short FP_288_2		; skip no error, else signal error
		or	byte ptr FLOPPY_ERROR[bp], FLOPPY_TYPE_MISMATCH
		or	byte ptr CMOS_STATUS[bp], EQUIP_STATUS
FP_288_2:
    ENDIF ;ONLY_288_CONTROLLER						
;R04 ENDIF	;ENABLE_FDC_FIFO
ENDIF;	DISABLE_FDC_FIFO						;R04

ENDIF	;ENABLE_288_SUPPORT

;
;	Check for mismatch floppy drives
;

DO_AUX:
		mov	al,FLOPPY_TYPE[bp]	; read diskette drive type byte
		mov	ah,al			; save diskette byte

		and	al,0f0h			; first drive

		cmp	al,20h
		jbe	short do_aux1

		sub	ah,20h			
		cmp	ah,20h			
		jbe	short Do_Aux1		

		and	ah,0fh
		or	ah,20h

DO_AUX1:
		mov	al,ah
		and	al,0fh

		cmp	al,2			; 2nd drive
		jbe	short do_aux2

		sub	al,02h			
		sub	ah,02h
		cmp	al,02h	
		jbe	short Do_Aux2

		and	ah,0f0h
		or	ah,2

DO_AUX2:
		xor	al,al			; assume no drive

		test	ah,11110000b		; drive A selected by setup?
		jz	short Snd_Drive

		test	DCapability,0fh		; look for first drive
		jz	short snd_drive

		mov	al,20h			; assume 96 tpi

		test	DCapability,1		; 80 tracks drive ?
		jnz	short snd_drive

		mov	al,10h			; set to 40 tracks

snd_drive:
		test	ah,00001111b		; drive B selected by setup?
		jz	short Ck_Drive

		test	DCapability,0f0h	; look for 2nd drive
		jz	short ck_drive		; final check

		or	al,2			; assume hi cap drive

		test	DCapability,10h		; 80 tracks ?
		jnz	short ck_drive

		and	al,0f0h
		or	al,1			; set to 40 tracks drive

ck_drive:
		cmp	al,ah			; see if match with cmos
		je	short skip_floppy	; jump if so

;
;	Mark that we have an error, and the error type...
;

		or	byte ptr FLOPPY_ERROR[bp], FLOPPY_TYPE_MISMATCH
		or	byte ptr CMOS_STATUS[bp], EQUIP_STATUS

skip_floppy:
		or	Hardware,1		; R06

;R12 - start
;R13 ifndef	FIX_NO_FDD_FOR_AHA1542

ifdef	FDD_ERROR_RELEASE_IRQ6				;R14
		cmp	byte ptr FLOPPY_ERROR[bp], 0	;R14
		jne	short Go_Release_IRQ6		;R14
ENDIF	;FDD_ERROR_RELEASE_IRQ6				;R14

		test	byte ptr FLOPPY_TYPE[bp],0ffH	; no floppy installed ?
		jnz	short No_Release_IRQ6		;R14
;R14		jnz	short No_Fdd_Attach

Go_Release_IRQ6:					;R14
;R20 - start
ifdef	Fdd_install_flag_selectable
		push	si
		mov	si,offset Windows_Select_Item
		call	F000_GetItem_Value
		pop	si
		or	al,al
		jz	short @F
		and	byte ptr Hardware,NOT 1	;set no FDD installed
	@@:
else	;Fdd_install_flag_selectable
;R20 - end
ifdef	PATCH_WIN95_NO_FDD				;R13A
		and	byte ptr Hardware,NOT 1	;set no FDD installed	;R13
endif;	PATCH_WIN95_NO_FDD				;R13A
endif	;Fdd_install_flag_selectable			;R20

ifndef	FIX_NO_FDD_FOR_AHA1542			;R13

;  Mask IRQ 6 for FDC controller

		cli
		in	al,A8259+1
		NEWIODELAY
		or	al,040H		; mask IRQ 6
		out	A8259+1,al
		
;R14No_Fdd_Attach:					
endif;	FIX_NO_FDD_FOR_AHA1542

No_Release_IRQ6:					;R14

;R12 - end
		
		pop	ds
		ret
FP_INSTALL	ENDP

;[]==================================================================[]
;
;  DISKETTE_POI:  
;	
;	Power on initialization for Floppy diskettes.
;
; Input: NONE
;Output: Variables initialized, drives determined, etc.
;
;Author: Award
;Date:   10/02/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM  | 02-Oct-90  | Update for 4.0
;
;[]==================================================================[]

		ALIGN	4
		PUBLIC	DISKETTE_POI
DISKETTE_POI	PROC	NEAR

		pusha
		push	es
		push	ds
		cld

		mov	ax,0f000h
;128k		mov	ax,cs
		mov	ds,ax			; cs = ds
;128k		ASSUME	DS:DGROUP
		ASSUME	DS:NOTHING		;R01

		mov	ax,G_RAM
		mov	es,ax			; es = G_RAM
		ASSUME	ES:G_RAM


; 	Clear 0:43E to 0:448

		mov	di,offset G_RAM:NEED_RECAL	
		mov	cx,(offset G_RAM:FDC_RET_END - offset G_RAM:NEED_RECAL) + 1
		xor	ax,ax
		rep	stosb

; 	Clear 0:48f to 0:495

		mov	di,offset G_RAM:DCAPABILITY	
		mov	cx,offset G_RAM:CURCYL - OFFSET G_RAM:DCAPABILITY + 2	; (495H-48FH)+1
		rep	stosb

;	Set up Xfre rate

		and	G_RAM:[XFER_INFO],NOT 0CCH	; Clear xfer rate bits, don't touch COMBO controller bit.
		or	G_RAM:[XFER_INFO],88h		; Set to xfer rate of 250 kbs

		mov	al,02h				; and make controller match it.
		mov	dx,FDC_CTRL_IN
		out	dx,al

;	Reset drives

;R06		F000_call	ResetDrives
		call	F000_ResetDrives		;R06

ifNdef	New_Swap_Fdd_Method				;R30

		xor	al,al
;R06		F000_call	Get_TPI			; determine values for DCAPABILITY
		call	F000_Get_TPI			;R06

		test	byte ptr FLOPPY_TYPE[bp],0fh	;R27 check CMOS drive B have set?
		jz	short @F			;R27
		mov	al,1				; current_media.
;R06		F000_call	Get_TPI
		call	F000_Get_TPI			;R06
@@:							;R27

;R30 -start
else	;New_Swap_Fdd_Method				

		mov	bl,byte ptr FLOPPY_TYPE[bp]

		;Check Drive A ...
		test	bl,0F0h
		jz	short Not_DriveA

		push	bx
		xor	al,al
		call	F000_Get_TPI			
		pop	bx

	Not_DriveA:

		;Check Drive B ...
		test	bl,0Fh
		jz	short Not_DriveB
		mov	al,1
		call	F000_Get_TPI			

	Not_DriveB:

endif	;New_Swap_Fdd_Method				
;R30 -end

;R06		F000_call	ResetDrives
		call	F000_ResetDrives		;R06

		mov	al,2				; get TPI will turn on drive motors so we need to shorten time
		F000_call	Get_Parm
		mov	G_RAM:[MOTOR_OFF_WAIT],al

		pop	ds
		pop	es
		popa

		ret
DISKETTE_POI	ENDP

;R06 - start
F000_Get_TPI:
		F000_call	Get_TPI
		ret
F000_ResetDrives:
		F000_call	ResetDrives
		ret
;R06 - end

;R26D;R26C start
;R26Difdef FPINSTALL_IN_XGROUP
;R26DF000_GetItem_Value:
;R26D	F000_call	GetItem_Value
;R26D	ret
;R26DXCODE		ENDS
;R26D
;R26DEGROUP		GROUP	ECODE
;R26DECODE		SEGMENT	USE16 PARA PUBLIC 'ECODE'
;R26D		ASSUME	CS:EGROUP,DS:G_RAM,ES:EGROUP
;R26Dendif ;FPINSTALL_IN_XGROUP
;R26D;R26C end
;R23 - start
ifdef	AMITECH_LOGO
NOT_USE_CBROM_EPALOGO		EQU	1
endif;	AMITECH_LOGO
;R23 - end

;R26D start
ifdef NOT_USE_CBROM_EPALOGO
ifdef FPINSTALL_IN_XGROUP
F000_GetItem_Value:
	F000_call	GetItem_Value
	ret
XCODE		ENDS

EGROUP		GROUP	ECODE
ECODE		SEGMENT	USE16 PARA PUBLIC 'ECODE'
		ASSUME	CS:EGROUP,DS:G_RAM,ES:EGROUP
endif ;FPINSTALL_IN_XGROUP
endif ;NOT_USE_CBROM_EPALOGO
;R26D end

;R07 start
ifndef NO_EPA_LOGO
		public	EPA_pattern
EPA_pattern	Label	Near
ifdef	NOT_USE_CBROM_EPALOGO			;R22
		include	EPALOGO.INC	;R19
;R19		DB	088h,000h,054h,000h,0,007,0FFh,0FFh,0C0h,0,013,03Fh,0FFh,0FFh,0FFh,0,012,003h,0FFh,0,002
;R19		DB	03Fh,0F0h,0,011,01Fh,0C0h,0,003,0FEh,0,011,0FCh,0,004,00Fh,0C0h
;R19		DB	0,009,003h,0E0h,0,004,001h,0F0h,0,009,01Fh,0,006,03Eh,0,009
;R19		DB	07Ch,0,006,00Fh,080h,0,007,001h,0F0h,0,006,003h,0E0h,0,007,003h
;R19		DB	0C0h,0,007,0F0h,0,007,00Fh,0,008,03Ch,0,007,01Ch,0,008,00Eh
;R19		DB	0,007,078h,0,008,007h,080h,0,006,0E0h,0,008,001h,0C0h,0,005
;R19		DB	003h,0C0h,0,009,0F0h,0,005,007h,0,010,038h,0,005,00Eh,0,010
;R19		DB	01Ch,0,005,01Ch,0,010,00Eh,0,005,038h,0,010,007h,0,005,070h
;R19		DB	0,010,023h,080h,0,004,0E0h,0,010,021h,0C0h,0,003,001h,0C0h,0,010
;R19		DB	070h,0E0h,0,003,003h,080h,0,010,070h,070h,0,003,007h,0,011,0F8h
;R19		DB	038h,0,003,00Eh,0,011,0F8h,01Ch,0,003,00Ch,0,011,0D8h,00Ch,0,003
;R19		DB	018h,0,010,001h,0DCh,006h,0,003,038h,0,010,001h,08Ch,007h,0,003
;R19		DB	030h,0,010,003h,08Eh,003h,0,003,060h,0,010,003h,00Eh,001h,080h,0,002
;R19		DB	0E0h,0,010,003h,006h,001h,080h,0,002,0C0h,0,010,007h,007h,0,001
;R19		DB	0C0h,0,001,001h,080h,0,010,006h,007h,0,001,060h,0,001,001h,080h
;R19		DB	0,010,006h,003h,0,001,060h,0,001,003h,0,011,00Eh,003h,080h,0,002
;R19		DB	003h,0,011,00Ch,001h,080h,0,002,006h,0,011,01Ch,001h,0C0h,0,002
;R19		DB	006h,0,009,07Fh,0FFh,0FCh,001h,0FFh,0FFh,0F0h,00Ch,0,009,0FFh,0FFh,0F8h
;R19		DB	0,001,0FFh,0FFh,0F8h,00Ch,0,009,07Fh,0FFh,0F8h,0,001,0FFh,0FFh,0F0h
;R19		DB	01Ch,0,014,001h,0E0h,018h,0,012,01Ch,0,001,003h,0C0h,018h,0,012
;R19		DB	078h,0,001,007h,080h,030h,0,008,080h,0,001,060h,001h,0E0h,0,001
;R19		DB	00Fh,0,001,030h,0,002,03Ch,0,004,003h,0E0h,0,001,060h,00Fh,0,002
;R19		DB	01Eh,0,001,030h,0,002,0E6h,0,004,006h,070h,020h,0E0h,038h,0,002
;R19		DB	03Ch,0,001,030h,0,001,001h,086h,0,003,066h,00Ch,060h,0E1h,0C0h,0E0h
;R19		DB	0,002,078h,0,001,060h,0,001,003h,004h,0,003,04Eh,018h,0C3h,0C1h
;R19		DB	0C3h,080h,0,002,0F0h,0,001,060h,0,001,006h,00Ch,0,002,060h,0DEh
;R19		DB	031h,08Fh,0C3h,08Eh,0,002,001h,0E0h,0,001,060h,0,001,00Ch,008h,0,001
;R19		DB	001h,0F0h,0F3h,023h,01Dh,087h,0B8h,0,002,003h,0C0h,0,001,060h,0,001
;R19		DB	018h,018h,060h,003h,021h,0E1h,0E6h,0F1h,08Dh,0F3h,080h,0,001,007h,080h,0,001
;R19		DB	060h,0,001,030h,030h,066h,006h,063h,0C0h,0FDh,0C1h,019h,0C3h,080h,0,001
;R19		DB	007h,0,002,0C0h,0,001,060h,060h,0CEh,004h,0C6h,0C0h,083h,081h,033h,083h
;R19		DB	0,002,003h,0,002,0C0h,0,001,040h,0C1h,0DEh,00Dh,08Dh,080h,0C7h,081h
;R19		DB	0E7h,007h,0,002,003h,080h,0,001,0C0h,0,001,0C1h,083h,096h,00Fh,019h
;R19		DB	080h,07Fh,0,001,09Eh,007h,0,002,003h,080h,0,001,0C0h,0,001,087h
;R19		DB	007h,0E6h,00Eh,031h,0,001,00Dh,0,001,032h,007h,0,002,003h,080h,0,001
;R19		DB	0C0h,001h,08Ch,00Fh,0C6h,03Ch,0E3h,0,001,01Bh,0,001,066h,006h,0,002
;R19		DB	001h,080h,0,001,0C0h,001h,038h,019h,087h,0FFh,080h,0,001,022h,0,001
;R19		DB	0C4h,00Eh,0,001,078h,001h,0C0h,0,002,003h,0E0h,033h,083h,0C2h,0,002
;R19		DB	066h,001h,08Ch,00Eh,001h,0FEh,001h,0C0h,0,001,010h,01Fh,080h,063h,0,004
;R19		DB	044h,001h,00Ch,00Eh,003h,0FFh,001h,0C0h,0,001,01Fh,0FEh,001h,0C3h,0,004
;R19		DB	0CCh,003h,008h,01Ch,00Fh,087h,0C0h,0E0h,0,001,00Fh,0E2h,003h,002h,0,003
;R19		DB	001h,088h,006h,018h,01Ch,01Eh,001h,0E0h,0E0h,0,002,003h,00Eh,0,004,001h
;R19		DB	098h,004h,010h,01Ch,07Ch,0,001,0F8h,0E0h,0,002,001h,0F8h,0,004,001h
;R19		DB	010h,00Ch,030h,018h,0F0h,0,001,03Ch,060h,0,003,060h,0,004,003h,030h
;R19		DB	008h,020h,03Bh,0E0h,0,001,01Fh,070h,0,008,003h,060h,018h,060h,03Fh,080h
;R19		DB	0,001,007h,0F0h,0,008,003h,0C0h,010h,040h,03Fh,0,002,003h,0F0h,0,008
;R19		DB	003h,080h,010h,0C0h,07Ch,0,003,0F8h,0,010,019h,080h,070h,0,003,038h
;R19		DB	0,010,00Fh,0,058,03Fh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
;R19		DB	0FFh,0FFh,0FFh,0FFh,0FFh,0FEh,0,051,01Fh,078h,040h,078h,0E4h,010h,045h,0F7h
;R19		DB	039h,010h,079h,0E7h,0D1h,07Dh,017h,0DFh,078h,010h,044h,040h,045h,014h,010h,044h
;R19		DB	042h,045h,090h,045h,014h,011h,041h,091h,010h,044h,010h,044h,0E0h,045h,014h,010h
;R19		DB	044h,042h,045h,090h,045h,014h,011h,041h,091h,010h,044h,01Eh,078h,0A0h,079h,014h
;R19		DB	010h,044h,042h,045h,050h,079h,0E7h,08Ah,079h,051h,01Eh,078h,010h,041h,0F0h,041h
;R19		DB	014h,010h,044h,042h,045h,030h,041h,044h,00Ah,041h,031h,010h,050h,010h,041h,010h
;R19		DB	041h,014h,010h,044h,042h,045h,030h,041h,024h,004h,041h,031h,010h,048h,01Fh,041h
;R19		DB	010h,040h,0E7h,0DFh,038h,047h,039h,010h,041h,017h,0C4h,07Dh,011h,01Fh,044h
endif;	NOT_USE_CBROM_EPALOGO				;R22
endif ;NO_EPA_LOGO
;

Use_Award_Mark_Font	=	0			;R28
;R29ifdef	EPA_LOGO_Use_Graphics				;R28
;R29Use_Award_Mark_Font	=	1			;R28
;R29endif;	EPA_LOGO_Use_Graphics				;R28
ifdef	Graphics_Post					;R29
Use_Award_Mark_Font	=	1			;R29
EPA_LOGO_Use_Graphics	=	1			;R29A
endif;	Graphics_Post					;R29
ifdef	NOT_USE_CBROM_EPALOGO				;R28
Use_Award_Mark_Font	=	1			;R28
endif;	NOT_USE_CBROM_EPALOGO				;R28
		public	Award_Mark_Font
Award_Mark_Font	Label	Near
if	Use_Award_Mark_Font				;R28
;R28ifdef	NOT_USE_CBROM_EPALOGO			;R22
ifdef	EPA_LOGO_Use_Graphics				;R28
		db	00000000b			;R28
endif;	EPA_LOGO_Use_Graphics				;R28
		db	00000111b
		db	00011111b
		db	00011111b
		db	00111111b
		db	00111111b
		db	01111111b
		db	01111111b
		db	01111111b
		db	00111111b
		db	00111111b
		db	00011111b
		db	00011111b
		db	00000111b
		db	00000000b			;R15
ifdef	EPA_LOGO_Use_Graphics				;R28
		db	00000000b			;R28

		db	00000000b			;R28
endif;	EPA_LOGO_Use_Graphics				;R28
		db	10000000b
		db	11100000b
		db	11100000b
		db	11110000b
		db	11110000b
		db	11111000b
		db	11111000b
		db	11111000b
		db	11110000b
		db	11110000b
		db	11100000b
		db	11100000b
		db	10000000b
		db	00000000b			;R15
		db	00000000b

ifdef	EPA_LOGO_Use_Graphics				;R28
		db	00000011b			;R28
		db	00000111b			;R28
endif;	EPA_LOGO_Use_Graphics				;R28
		db	00001110b
		db	00011101b
		db	00111101b
		db	01111011b
		db	11111011b
		db	00000111b
		db	00000111b
		db	00001111b
		db	00001111b
		db	00011110b
		db	00011000b
		db	00100000b
		db	00000000b			;R15
		db	00000000b

ifdef	EPA_LOGO_Use_Graphics				;R28
		db	01111111b			;R28
		db	01111111b			;R28
endif;	EPA_LOGO_Use_Graphics				;R28
		db	11111111b
		db	11111111b
		db	11111111b
		db	11111111b
		db	11111111b
		db	11111111b
		db	11101111b
		db	11000111b
		db	00000011b
		db	00000011b
		db	00000011b
		db	00000001b
		db	00000000b			;R15
		db	00000000b

ifdef	EPA_LOGO_Use_Graphics				;R28
		db	11110000b			;R28
		db	11110000b			;R28
endif;	EPA_LOGO_Use_Graphics				;R28
		db	11100000b
		db	11100000b
		db	11100000b
		db	11000000b
		db	11000000b
		db	11000000b
		db	10000000b
		db	10000000b
		db	10000000b
		db	00000000b
		db	00000000b
		db	00000000b
		db	00000000b			;R15
ifdef	EPA_LOGO_Use_Graphics				;R28
		db	00000000b			;R28
endif;	EPA_LOGO_Use_Graphics				;R28
;R07 end
;R28endif;	NOT_USE_CBROM_EPALOGO				;R22
endif;	Use_Award_Mark_Font				;R28

;R26C;R26A start
;R26Cifdef FPINSTALL_IN_XGROUP
;R26CF000_GetItem_Value:
;R26C	F000_call	GetItem_Value
;R26C	ret
;R26CXCODE		ENDS
;R26Celse ;FPINSTALL_IN_XGROUP
;R26C;R26A end
;R26DECODE		ENDS
;R26Cendif ;FPINSTALL_IN_XGROUP				;R26A

;R26D start
ifndef NOT_USE_CBROM_EPALOGO
ifdef FPINSTALL_IN_XGROUP
F000_GetItem_Value:
	F000_call	GetItem_Value
	ret
XCODE		ENDS
else ;FPINSTALL_IN_XGROUP
ECODE		ENDS
endif ;FPINSTALL_IN_XGROUP
endif ;NOT_USE_CBROM_EPALOGO
;R26D end
		END

