RESET_DRIVE     EQU     0
VERIFY_SECTORS  EQU     4
WRITE_SECTORS   EQU     3
READ_SECTORS    EQU     2





;EDX=file size
;esi points to tracks/sectors/heads info for disk size.
get_disk_params proc near


        lea     esi, HST_LOOKUP_TABLE
        sub     esi, 8
keep_looking:
        add     esi, 8
        cmp     dword ptr cs:[esi],-1
        jz      not_found
        cmp     edx, dword ptr cs:[esi]
        jnz     keep_looking
        add     esi, 4                  ; point to tracks/sectors/heads
        mov     ebx, cs:[esi]           ; load it into EBX


        ; copy diskette parameters to start of image data in high memory.

        mov     edi, DISK_START         ;
        mov     gs:[edi], edx           ; save disk image size
        add     edi, 4
        mov     gs:[edi], ebx           ; save disk image params.
        add     edi, 4

        ret
not_found:

        push    cs
        pop     ds
        lea     dx, unknown_size
        mov     ah, 9
        int     21h
        mov     ax, 4c05h                ;errorlevel 5, weird disk size
        int     21h

unknown_size  db  "Error: Unknown diskette image size.",13,10,"$"

        
;                       size       tracks        sectors    heads
HST_LOOKUP_TABLE dd     SIZE160K, (40 shl 16) + (8  shl 8) + 1
                 dd     SIZE180K, (40 shl 16) + (9  shl 8) + 1 
                 dd     SIZE200K, (40 shl 16) + (10 shl 8) + 1
                 dd     SIZE320K, (40 shl 16) + (8  shl 8) + 2
                 dd     SIZE360K, (40 shl 16) + (9  shl 8) + 2
                 dd     SIZE400K, (40 shl 16) + (10 shl 8) + 2
                 dd     SIZE720K, (80 shl 16) + (9  shl 8) + 2
                 dd     -1
get_disk_params endp
