Sprinter-BIOS/bios/exp/EXTENDED/IDE/shared.asm
2026-05-19 19:48:28 +10:00

123 lines
2.5 KiB
NASM
Raw Permalink 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 - ­®¬¥à ãáâனá⢠, C - DriveType
; ‚ë室: A - MediaParameters, C - DriveType
; ­¥ ¯®àâ¨â L
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 NZ,.error
;
.channel: EXX
IN A,(SLOT3)
PUSH AF
LD A,SYS_PAGE
OUT (SLOT3),A
;
LD H,(IY + IDE.HDD_INIT_TABLE.MediaParameters)
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
RRA
LD A,IDE.Chanel.Secondary
JR C,.device
LD A,IDE.Chanel.Primary
.device: OUT (IDE.Chanel.Set),A ;R02
LD A,B
AND #F0
LD BC,IDE.Write.DeviceHead
OUT (C),A
;
.del_me: LD A,high IDE.Read.Status
IN A,(low IDE.Read.Status)
AND IDE.CtrlByte.Busy
; â¥áâ¨à®¢ ­¨¥ § ¤¥à¦¥ª
;JR NZ,.del_me
JR Z,.notBusy
LD B,32
DJNZ $
;
.notBusy: LD A,H
EXX
RET
;
.error: LD A,BIOS.Error.BadNumber
SCF
RET
;=======================================================================
;=======================================================================
; next page in mem block
CHANGE_MEM_BLK: LD HL,#C000
IN A,(SLOT3)
EX AF,AF' ;>-----------> \
LD A,SYS_PAGE
OUT (SLOT3),A
LD D,high SYS_PAGE.RAM_TABLE
LD E,XH
LD A,(DE)
LD XH,A
EX AF,AF' ;<-----------< /
OUT (SLOT3),A
RET
;=======================================================================
;=======================================================================
;Function: Detect Disk
; A - Disk
; - Type
;Return: CF=0 - A=Drive type, H=MediaParameters
; CF=1 - drive not present, A=#02
;DRV_DETECT: CP #84 ;!HARDCODE max IDE drives (#80,#81,#82,#83)
; CCF
; JR C,.error
; ;
; LD IX,IDE.INIT_TBL_IDE0
; AND 3
; JR Z,.get_param
; LD IX,IDE.INIT_TBL_IDE1
; DEC A
; JR Z,.get_param
; LD IX,IDE.INIT_TBL_IDE2
; DEC A
; JR Z,.get_param
; LD IX,IDE.INIT_TBL_IDE3
; .get_param: IN A,(SLOT3)
; LD B,A
; LD A,SYS_PAGE
; OUT (SLOT3),A
; ;
; LD H,(IX + IDE.HDD_INIT_TABLE.MediaParameters)
; LD A,(IX + IDE.HDD_INIT_TABLE.DriveType)
; CP C ; compare Type
; LD C,SLOT3
; OUT (C),B
; RET Z
; SCF
; .error: LD A,BIOS.Error.BadNumber
; RET