
;
; It's disk drive BIOS extender for functions 5xh.
;---------------------------------------------------------------
;Version! Description
;---------------------------------------------------------------
;  2.32	! Removed `DI' Disabled	Interupt instruction in	HDRIVER6
;	! function load	sectors.
;	! Fixed	bug waiting slave device in AUTOIDE.

;
;INT_ADRESS	EQU	#C124
;INT_PAGE	EQU	#C126
;INT_ID	EQU	#C127
;BIOS	EQU	#3FD0
;	DS	#3FD0,#FF


DRV_VERSION:
	LD	HL,0
	LD	BC,0
	LD	DE,Disk_subsystem_ver_hex
	AND	A
	RET 

DRV_LIST:																; ????? что за функция и куда указывает IX
	IN	A,(SLOT3)
	PUSH	AF
	PUSH	IY
	LD	A,SYS_PAGE
	OUT	(SLOT3),A	; !TODO сделать структурой
	LD	(IX+0),#04	; DB	0	;LEN			;!HARDCODE
	LD	(IX+1),#00	; DB	0	;FDD COUNT
	LD	(IX+2),#00	; DB	0	;HDD COUNT
	LD	(IX+3),#00	; DB	0	;CDROM COUNT
;				; BLOCK	28,0	;RESERVED		;!TODO сделать RAMDRIVE тут?
	LD	(IX+4),#00	; END FLAG

;Calculating FDD devices
	LD	HL,FDD_INI_TABLE.FDD_0
	INC	(IX+1)
	LD	B,8
	LD	A,#FF
.TFD0:
	CP	(HL)
	INC	HL
	JR	NZ,.YYYFD0
	DJNZ	.TFD0
	DEC	(IX+1)
.YYYFD0:
	LD	HL,FDD_INI_TABLE.FDD_1
	INC	(IX+1)
	LD	B,8
	LD	A,#FF
.TFD1:
	CP	(HL)
	INC	HL
	JR	NZ,.YYYFD1
	DJNZ	.TFD1
	DEC	(IX+1)
.YYYFD1:
;Calculating IDE devices
	LD	IY,IDE.INIT_TBL_IDE0
	LD	A,(IY+IDE.HDD_INIT_TABLE.DriveType)	;IDE TYPE 1-HDD, 2-CD-ROM
	CP	#FF
	JR	Z,.ABSIDE0
	CP	IDE.Device.HDD
	JR	NZ,.NOT_HD0
	INC	(IX+2)
.NOT_HD0:
	CP	IDE.Device.CDROM
	JR	NZ,.NOT_CD0
	INC	(IX+3)
.NOT_CD0:
.ABSIDE0:
	LD	IY,IDE.INIT_TBL_IDE1
	LD	A,(IY+IDE.HDD_INIT_TABLE.DriveType)	;IDE TYPE 1-HDD, 2-CD-ROM
	CP	#FF
	JR	Z,.ABSIDE1
	CP	IDE.Device.HDD
	JR	NZ,.NOT_HD1
	INC	(IX+2)
.NOT_HD1:
	CP	IDE.Device.CDROM
	JR	NZ,.NOT_CD1
	INC	(IX+3)
.NOT_CD1:
.ABSIDE1:
	LD	IY,IDE.INIT_TBL_IDE2
	LD	A,(IY+IDE.HDD_INIT_TABLE.DriveType)	;IDE TYPE 1-HDD, 2-CD-ROM
	CP	#FF
	JR	Z,.ABSIDE2
	CP	IDE.Device.HDD
	JR	NZ,.NOT_HD2
	INC	(IX+2)
.NOT_HD2:
	CP	IDE.Device.CDROM
	JR	NZ,.NOT_CD2
	INC	(IX+3)
.NOT_CD2:
.ABSIDE2:
	LD	IY,IDE.INIT_TBL_IDE3
	LD	A,(IY+IDE.HDD_INIT_TABLE.DriveType)	;IDE TYPE 1-HDD, 2-CD-ROM
	CP	#FF
	JR	Z,.check_exit
	CP	IDE.Device.HDD
	JR	NZ,.NOT_HD3
	INC	(IX+2)
.NOT_HD3:
	CP	IDE.Device.CDROM
	JR	NZ,.check_exit
	INC	(IX+3)
.check_exit:
	POP	IY
	POP	AF
	OUT	(SLOT3),A
	XOR	A
	RET 

	INCLUDE	'EXTENDED/FDD_DRIVER_2.asm'
        INCLUDE 'EXTENDED/RAM_DISK_DRIVER_1.asm'
	INCLUDE	'EXTENDED/IDE/HDD_DRV.asm'
	INCLUDE	'EXTENDED/IDE/CD_DRV.asm'
	INCLUDE	'EXTENDED/IDE/SHARED.asm'


        ;DISPLAY "                       EXTENDED end addr: ", /A, $
;