;LAST UPDATE: 27.02.2021 savelij
VIEW_CHS EQU 0
HDD_DETECTOR LD IX,.HDDDETECT
RST8 _WINW
LD HL,ADR_CAT
RST8 _COM_DEV,_COMHDDN,_DEV_INIT
LD A,H
AND A
JR Z,.MASTER_FOUND
DEC A
CALL Z,.CDDVDFOUNDM
JR Z,.SLAVE
PUSH HL
LD HL,.MASTERNONE
RST8 _PRINT_MESSAGE
POP HL
JR .SLAVE
.MASTER_FOUND LD C,1
CALL .HDD_INFO
.SLAVE LD A,L
AND A
JR Z,.SLAVE_FOUND
DEC A
CALL Z,.CDDVDFOUNDS
JP Z,.ENDTEST
LD HL,.SLAVENONE
RST8 _PRINT_MESSAGE
JR .ENDTEST
.SLAVE_FOUND LD C,2
CALL .HDD_INFO
.ENDTEST LD HL,.TXTANYKEY
RST8 _PRINT_MESSAGE
.WAITENTER EI
HALT
BIT 5,(IY+1)
JR Z,.WAITENTER
LD A,(LAST_K)
CP 0X0D
JR NZ,.WAITENTER
JP RESTART
.HDD_INFO PUSH HL
DEC C
LD HL,.MASTERFOUND
JR Z,.HDDI1
LD HL,.SLAVEFOUND
.HDDI1 RST8 _PRINT_MESSAGE
LD A,C
EX AF,AF'
LD HL,ADR_CAT
RST8 _COM_DEV,_COMHDDN,_DEV_READID
LD HL,ADR_CAT+46
PUSH HL
LD B,0X18
.MF01 LD A,(HL)
INC HL
LD E,(HL)
DEC HL
LD (HL),E
INC HL
LD (HL),A
INC HL
DJNZ .MF01
LD HL,ADR_CAT+46+42
IF VIEW_CHS
LD (HL),"\r"
INC HL
ENDIF
LD (HL),0
POP HL
RST8 _PRINT_MESSAGE ;имя винта
IF VIEW_CHS
LD HL,.CHS
RST8 _PRINT_MESSAGE
LD HL,ADR_CAT+0X200
LD DE,(ADR_CAT + 1 * WORD) ;количество цилиндров
RST8 _MATH,_HEX2DECTXT
RST8 _PRINT_MESSAGE
LD A,"/"
RST8 _PRINT_A
LD DE,(ADR_CAT + 3 * WORD) ;количество головок
RST8 _MATH,_HEX1DECTXT
RST8 _PRINT_MESSAGE
LD A,"/"
RST8 _PRINT_A
LD DE,(ADR_CAT + 6 * WORD) ;количество секторов
RST8 _MATH,_HEX1DECTXT
RST8 _PRINT_MESSAGE
ENDIF
LD HL,.TXTSIZE
RST8 _PRINT_MESSAGE
LD IXL,0 ; текст "MB"
; LD HL,.NEWLINE
; RST8 _PRINT_MESSAGE
; проверка бита поддержки LBA48
LD HL,(ADR_CAT + 83 * WORD)
LD A,H
AND %00000100 ; бит 10 в слове 83
JR Z,.LBA28
; для LBA48
.LBA48
LD HL,(ADR_CAT + 100 * WORD + 1); размер в секторах /256
LD DE,(ADR_CAT + 101 * WORD + 1)
LD BC,(ADR_CAT + 102 * WORD + 1)
LD B,3
CALL .DIV_LBA
LD A,C
AND A
JR Z,.L3
LD IXL,1 ; текст "GB"
LD B,2
LD L,H
LD H,E
LD E,D
LD D,C
LD C,0
CALL .DIV_LBA
JR .L3
; для LBA28
.LBA28
LD HL,(ADR_CAT + 60 * WORD + 1)
LD DE,(ADR_CAT + 61 * WORD + 1) ; размер в LBA секторах
LD BC,3 << 8 + 0
CALL .DIV_LBA
.L3 LD B,D
LD C,E
EX DE,HL
LD HL,ADR_CAT+0X200
RST8 _MATH,_HEX4DECTXT
RST8 _PRINT_MESSAGE
LD A,IXL
AND A
LD HL,.TXTMB
JR Z,.L4
LD HL,.TXTGB
.L4 RST8 _PRINT_MESSAGE
POP HL
RET
.DIV_LBA
.L1 SRL C
RR D
RR E
RR H
RR L
DJNZ .L1
RET
.CDDVDFOUNDS PUSH HL
LD HL,.SLAVECDDVD
JR .CDDVDFOUND
.CDDVDFOUNDM PUSH HL
LD HL,.MASTERCDDVD
.CDDVDFOUND PUSH AF
RST8 _PRINT_MESSAGE
POP AF
POP HL
RET
.HDDDETECT DB 0,0,24,32,0X07,0X1F,%01010000,0
DW 0,0,.TXTHDDDET,0,0,0
.TXTHDDDET DB "\1\x17\XFF\3HDD detector\r\0"
.TXTSIZE DB "\rSize:\0"
.TXTMB DB " MB\r\0"
.TXTGB DB " GB\r\0"
.MASTERFOUND DB "\rHDD master found\r\0"
.SLAVEFOUND DB "\rHDD slave found\r\0"
.MASTERNONE DB "\rHDD master not found\r\0"
.SLAVENONE DB "\rHDD slave not found\r\0"
.MASTERCDDVD DB "\rCD/DVD-ROM master found\r\0"
.SLAVECDDVD DB "\rCD/DVD-ROM slave found\r\0"
.CHS DB "C/H/S: \0"
.NEWLINE DB "\r\0"
.TXTANYKEY DB "\x16\x17\0\3Press ENTER to main menu\0"