TIP: Click on subject to list as thread! ANSI
echo: locuser
to: Frank Malcolm
from: Brenton Vettoretti
date: 1997-02-18 02:01:12
subject: What next, Messy DOS ?

;***************************************************************************
;                                                                          *
;   Copyright (C) 1983,1984 by Microsoft Inc.                              *
;                                                                          *
;***************************************************************************

        TITLE   SYSTEM - InquireSystem procedure to return info about devices

include system.inc

sBegin  CODE        ; Beginning of code segment
assumes CS,CODE

;
; InquireSystem(what,which) - returns pecific information
;       what is the code for the device
;       which specifies which one of those devices
;
;   WHAT = 0        Timer resolution
;       Return the resolution of the timer specified by the which
;       parameter in DX:AX.  Windows always uses which == 0
;
;   WHAT = 1        Disk Drive Information (Drive A = 0)
;       which is the disk drive
;       ax = 0 means the drive does not exist.  if dx != 0 then the drive
;       maps to the drive in dx instead (AX = 1)
;       ax = 1 means the drive is the same as ax=0 except if it is a
;       phantom drive it is fixed media
;       ax = 2 means the drive is removable media
;       ax = 3 means the drive is fixed media
;
;   WHAT = 2        Enable/Disable one drive logic
;       which = 0 means disable, which  0 means enable
;       This code enables/disables the RAM BIOS message:
;       "Please insert disk for drive B:"
;
externNP        SystemInit
externW         AT_DOS30

                public  pOneDrive
pOneDrive       label   dword
                dw      0,1             ; 1 = not initialized yet

globalB         oneDrivePatch,0
globalB         oneDriveFlag,0
globalD         prevInt13proc,0

cProc   InquireSystem,
    parmW   what
    parmW   which
cBegin
        mov     ax,what
;---------------------------------------
;
;  Timer information
;
        or      ax,ax
        jnz     is1
        mov     dx,res_high
        mov     ax,res_low
        jmp     ISDone
;---------------------------------------
;
;  Drive information
;
is1:    dec     ax              ; ax = 1?
        jnz     is5

        int     11h             ; get equipment word
        mov     cl,6
        shr     ax,cl
        and     al,00000011b    ; isolate drive count
        cbw
        or      ax,ax           ; just one floppy on system?
        jnz     IS4             ; no, continue
                                ; AX must be zero
        mov     dx,1            ; B maps to A in single drive system
        cmp     which,1         ; does he want info about drive B?
        jz      ISDoneV         ; drive b is a phantom drive, ax is 0
        inc     ax              ; pretend we have two floppies...

IS4:    cmp     ax,which
        mov     cx,FIXED
        jb      ISCheck
        mov     cx,REMOVEABLE
ISCheck:
        mov     ah,19H          ; get the current disk
        int     21h
        mov     bx,Which        ; try to set to this disk
        cmp     al,bl           ; already there?
        jz      is4a            ; just exit

        push    ax
        mov     dx,bx
        mov     ah,0eH          ; set to new disk
        int     21h
        mov     ah,19H          ; get the current disk
        int     21h
        mov     bh,al
        pop     dx
        mov     ah,0eH          ; restore current disk
        int     21H

        cmp     bh,bl           ; if bogus disk, return error
        jnz     is9
is4a:   xchg    ax,cx           ; AX = type of drive
        xor     dx,dx           ; Indicate no remapping
IsDoneV:
        jmp     short ISDone
;---------------------------------------------------
;
;  Single Floppy enable/disable
;
is5:    dec     ax                      ; floppy enable disable?
        jnz     is9

is5a:   les     bx,cs:[pOneDrive]
        mov     ax,es
        cmp     ax,1                    ; initialized, but not found?
        jb      is9                     ; yes, quit
        ja      is5b
        call    SystemInit
        jmp     is5a

is5b:   cmp     which,0                 ; 0=disable
        jnz     is6
;
;  Disable A:/B: message
;
        mov     ax,0EBH                         ; stick in 'jmp short'
        xchg    byte ptr es:[bx],al
        mov     cs:[oneDrivePatch],al           ; Save what was there
        xor     ax,ax
        mov     es,ax
        xchg    al,byte ptr es:[SingleDrive]    ; set to drive A
        mov     cs:[oneDriveFlag],al            ; remember previous setting
;
;  This is a long story.  There is a bug in the IBM PC AT INT 13H ROM code.
;  IBM DOS 3.10 has a work around for the problem, but DOS 3.00 does not.
;  If an interrupt service routine takes along time while a disk read or write
;  is proceeding it may complete too early.  Windows fixes this problem with
;  the following weirdness
        mov     ah,30H                  ; get dos version
        int     21H
        cmp     ax,0003H                ; is it DOS 3.00?
        jnz     is9                     ; nope
        mov     ax,0F000H
        mov     es,ax
        cmp     byte ptr es:[0FFFEH],0FCH ; is it an AT?
        jnz     is9                       ; nope..
        call    HookInt13
        jmp     short is9
;
;   Enable A:/B: message
;
is6:    mov     al,cs:[oneDrivePatch]
        mov     es:[bx],al
        xor     ax,ax
        mov     es,ax
        mov     al,cs:[oneDriveFlag]
        mov     byte ptr es:[SingleDrive],al  ; restore to correct drive
;
; If we stuck in an INT 13H handler, take it out
;
        lds     dx,cs:[prevInt13Proc]
        mov     cx,ds
        jcxz    is9
        mov     ax,2513H
        int     21H

is9:    xor     dx,dx
        xor     ax,ax
ISDone:
cEnd    Inquire


        int     21h
        mov     word ptr cs:[prevInt13proc  ],bx
        mov     word ptr cs:[prevInt13proc+2],es
        push    cs
        pop     ds
        mov     dx,codeOffset Int13Handler
        mov     ax,2513H
        int     21H
        ret


Int13Handler    proc    far
        cmp     ah,2                    ; function 2 through...
        jb      i13x
        cmp     ah,12                   ; function 12?
        ja      i13x
        test    dl,80H                  ; on a hard disk?
        jz      i13x                    ; nope...
        mov     byte ptr cs:[AT_DOS30],0
        sti
        pushf
        call    cs:[prevInt13proc]
        mov     byte ptr cs:[AT_DOS30],1
        ret     2

i13x:   jmp     cs:[prevInt13Proc]
Int13Handler    endp
sEnd    CODE            ; End of code segment
END
@EOT:

---
* Origin: TestPoint (3:711/934.7)
SEEN-BY: 711/934 712/610
@PATH: 711/934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.