; Sample/Test program
; for TR-CENTRAL INT 18h DPARAM (get disk parameters) function call...
; ¸ ERDOGAN TAN (28/12/2000)

;ÄÄÄÄÄÄÄÄÄÄ CODE_SEG_1  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

CODE_SEG_1	segment para public
		assume  CS:CODE_SEG_1, DS:CODE_SEG_1, SS:CODE_SEG_1, ES:CODE_SEG_1

		org	100h

proc_start	proc	far

start:
                push cs
                pop ds

repeat_dparam_read:
                mov si, offset Press_Any_Key
                call proc_print_msg

                xor ah, ah              ; "Press any key to continue"
                int 16h

                call proc_clear_screen

                mov ax, 01A1h
                mov bx, 0700h           ; Get/Return MDT Address
                int 18h
                jc short end_of_dparam

                push cs
                pop es
                mov di, offset Dparam_Buffer

                cmp ax, 3800h
                jnz loc_error
                and dx, dx
                jnz loc_error

                mov si, ax
                mov ds, dx

                add si, 256             ; DISK Parameter Tables Location

                mov cx, 128
                rep movsw
                push cs
                pop ds
                mov si, offset Dparam_Buffer

                mov cx, 8

dparam_drive_check:
                push cx
                push si

                call proc_fill_info_fields

                mov si, offset Disk_Info
                call proc_print_msg

                mov si, offset Press_Any_Key
                call proc_print_msg

                xor ah, ah              ; "Press any key to continue"
                int 16h

                call proc_clear_screen

                pop si
                add si, 32
                pop cx

                loop dparam_drive_check
end_of_dparam:
                int 20h

proc_fill_info_fields:
                mov al, byte ptr [SI]
                call proc_hex
                mov word ptr [DS_SI], ax

                mov al, byte ptr [SI]+1
                call proc_hex
                mov word ptr [DS_SI_1], ax

                mov al, byte ptr [SI]+3
                call proc_hex
                mov word ptr [DS_SI_2], ax
                mov al, byte ptr [SI]+2
                call proc_hex
                mov word ptr [DS_SI_2]+2, ax

                mov al, byte ptr [SI]+5
                call proc_hex
                mov word ptr [DS_SI_4], ax
                mov al, byte ptr [SI]+4
                call proc_hex
                mov word ptr [DS_SI_4]+2, ax

                mov al, byte ptr [SI]+7
                call proc_hex
                mov word ptr [DS_SI_6], ax
                mov al, byte ptr [SI]+6
                call proc_hex
                mov word ptr [DS_SI_6]+2, ax

                mov al, byte ptr [SI]+9
                call proc_hex
                mov word ptr [DS_SI_8], ax
                mov al, byte ptr [SI]+8
                call proc_hex
                mov word ptr [DS_SI_8]+2, ax

                mov ax, word ptr [SI]+10
                cmp ax, 3030h
                jnb short pass_reset_ax
                mov ax, 3030h
pass_reset_ax:
                mov word ptr [DS_SI_10], ax

                mov al, byte ptr [SI]+13
                call proc_hex
                mov word ptr [DS_SI_12], ax
                mov al, byte ptr [SI]+12
                call proc_hex
                mov word ptr [DS_SI_12]+2, ax
                mov al, byte ptr [SI]+15
                call proc_hex
                mov word ptr [DS_SI_14], ax
                mov al, byte ptr [SI]+14
                call proc_hex
                mov word ptr [DS_SI_14]+2, ax

                mov al, byte ptr [SI]+17
                call proc_hex
                mov word ptr [DS_SI_16], ax
                mov al, byte ptr [SI]+16
                call proc_hex
                mov word ptr [DS_SI_16]+2, ax

                mov al, byte ptr [SI]+19
                call proc_hex
                mov word ptr [DS_SI_18], ax
                mov al, byte ptr [SI]+18
                call proc_hex
                mov word ptr [DS_SI_18]+2, ax

                mov al, byte ptr [SI]+21
                call proc_hex
                mov word ptr [DS_SI_20], ax
                mov al, byte ptr [SI]+20
                call proc_hex
                mov word ptr [DS_SI_20]+2, ax

                mov al, byte ptr [SI]+23
                call proc_hex
                mov word ptr [DS_SI_22], ax
                mov al, byte ptr [SI]+22
                call proc_hex
                mov word ptr [DS_SI_22]+2, ax

                mov al, byte ptr [SI]+25
                call proc_hex
                mov word ptr [DS_SI_24], ax
                mov al, byte ptr [SI]+24
                call proc_hex
                mov word ptr [DS_SI_24]+2, ax

                mov al, byte ptr [SI]+27
                call proc_hex
                mov word ptr [DS_SI_26], ax
                mov al, byte ptr [SI]+26
                call proc_hex
                mov word ptr [DS_SI_26]+2, ax
                mov al, byte ptr [SI]+29
                call proc_hex
                mov word ptr [DS_SI_28], ax
                mov al, byte ptr [SI]+28
                call proc_hex
                mov word ptr [DS_SI_28]+2, ax

                mov al, byte ptr [SI]+31
                call proc_hex
                mov word ptr [DS_SI_30], ax
                mov al, byte ptr [SI]+30
                call proc_hex
                mov word ptr [DS_SI_30]+2, ax

                retn

proc_dparam:
                retn

proc_clear_screen:
                mov ah, 0Fh 
                int 10h
                mov ah, 0
                int 10h

                retn

proc_hex:
                mov bl, al
                mov ax, 01a1h
                mov bh, 4
                int 18h

                retn

proc_print_msg:
                mov ax, 01A1h
                xor bx, bx
                int 18h

                retn

loc_error:
                mov si, offset Error
                call proc_print_msg

                int 20h

Disk_Info:
                db 7
                db "TR-DOS DISK PARAMETER TABLE"
                db 0Dh, 0Ah, 0Dh, 0Ah
                db "Disk Drive Number: "
DS_SI:          dw 3030h
                db 'h'
                db 0Dh, 0Ah
                db "Total Drives: "
DS_SI_1:        dw 3030h
                db 'h'
                db 0Dh, 0Ah
                db "Bytes per Sector: "
DS_SI_2:        dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Sectors per Track: "
DS_SI_4:        dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Heads: "
DS_SI_6:        dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Cylinders: "
DS_SI_8:        dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Error Code: "
DS_SI_10:       dw 3030h
                db 'h'
                db 0Dh, 0Ah
                db "Current Sector: "
DS_SI_14:       dd 30303030h
                db 'h:'
DS_SI_12:       dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Sector Count: "
DS_SI_16:       dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Buffer Segment: "
DS_SI_20:       dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Buffer Offset: "
DS_SI_18:       dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "BIOS DPT Segment: "
DS_SI_24:       dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "BIOS DPT Offset: "
DS_SI_22:       dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Total Sectors: "
DS_SI_28:       dd 30303030h
                db 'h:'
DS_SI_26:       dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db "Reserved Word: "
DS_SI_30:       dd 30303030h
                db 'h'
                db 0Dh, 0Ah, 0
Press_Any_Key:
                db 0Dh, 0Ah 
                db "Press any key to continue ..."
                db 0Dh, 0Ah, 0
Error:
                db 0Dh, 0Ah
                db "Error !"
                db 0Dh, 0Ah, 0

Dparam_Buffer:
                db 256 dup(0)

proc_start	endp

CODE_SEG_1	ends

		end	start

