Sprinter-Core/src/bios/exp/EXTENDED/IDE/shared.asm
2025-01-03 19:16:54 +10:00

98 lines
1.7 KiB
NASM
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;[x] 18/12/2023. ¤®¡ ¢«¥­¨¥/¤®¯¨«¨¢ ­¨¥ API CD-ROM (ATAPI)
;=======================================================================
; ‚室: A - ­®¬¥à ãáâனá⢠
SELECT_DRIVE:
AND #0F
LD IY,IDE.INIT_TBL_IDE0
JR Z,.channel
DEC A
LD IY,IDE.INIT_TBL_IDE1
;R02
JR Z,.channel
DEC A
LD IY,IDE.INIT_TBL_IDE2
JR Z,.channel
DEC A
LD IY,IDE.INIT_TBL_IDE3
;
JR Z,.channel
LD A,BIOS.Error.BadNumber
SCF
RET
;
.channel:
EXX
IN A,(SLOT3)
PUSH AF
LD A,SYS_PAGE
OUT (SLOT3),A
;
LD A,(IY+IDE.HDD_INIT_TABLE.DRV_Flags)
AND 1
LD A,IDE.Chanel.Secondary
JR NZ,.device
LD A,IDE.Chanel.Primary
.device:
OUT (IDE.Chanel.Set),A ;R02
LD C,(IY+IDE.HDD_INIT_TABLE.DriveType)
LD B,(IY+IDE.HDD_INIT_TABLE.DRV_Flags)
POP AF
OUT (SLOT3),A ;¢®§¢à â áâà ­¨æë
;
LD A,C
EXX
CP C
EXX
SCF
LD A,BIOS.Error.BadNumber
RET NZ
;
LD A,B
AND #F0
LD BC,IDE.Write.DeviceHead
OUT (C),A
EXX
RET
;
; NODRIVE:
; LD A,BIOS.Error.BadDrvNumber
; SCF
; RET
;=======================================================================
;=======================================================================
;Function: Detect Disk
; A - Disk
; - Type
;Return: CF=0 - A=Drive type
; CF=1 - drive not present, A=#02
DRV_DETECT:
CP #84 ;!HARDCODE max IDE drives (#80,#81,#82,#83)
CCF
JR C,.error
LD HL,IDE.INIT_TBL_IDE0.DriveType
AND 3
JR Z,.get_param
LD HL,IDE.INIT_TBL_IDE1.DriveType
DEC A
JR Z,.get_param
LD HL,IDE.INIT_TBL_IDE2.DriveType
DEC A
JR Z,.get_param
LD HL,IDE.INIT_TBL_IDE3.DriveType
.get_param:
IN A,(SLOT3)
LD B,A
LD A,SYS_PAGE
OUT (SLOT3),A
LD A,(HL)
CP C ; compare Type
LD C,SLOT3
OUT (C),B
RET Z
SCF
.error: LD A,BIOS.Error.BadNumber
RET