;**************************************************************
;***    EMS5D1.ASM                                          ***
;***                                                        ***
;***    function        EMS_Ems.disableEmmOSFuncs40(        ***
;***                        a1:             Word;           ***
;***                        a2:             Word;           ***
;***                        var a3:         Word;           ***
;***                        var a4:         Word)           ***
;***                        : Boolean;                      ***
;***                                                        ***
;***    Enable EMM operating system functions               ***
;***                                                        ***
;***    Returns 0 if no error or an error code.             ***
;***                                                        ***
;***                                                        ***
;***                                                        ***
;***    (Ems Version 4.0)                                   ***
;**************************************************************

        .model  large,pascal   

        include emsdefs.asm 

        extrn   errno:WORD  

;
;   Define entry point
;
        public  EMS_Ems@disableEmmOSFuncs40

        .code

EMS_Ems@disableEmmOSFuncs40 proc accessKey:Far Ptr DWord, self:DWord

        les     bx,accessKey            ; Get the access key address
        mov     cx,es:[bx]              ; CX gets access key LO
        mov     bx,es:[bx+2]            ; BX gets access key HI

        mov     ax,DisableEmmOSFuncs40  ; Do the EMS call
        int     Ems           

        or      ah,ah                   ; Set flags
        jnz     error

        mov     ax,bx                   ; Returned access key HI
        les     bx,accessKey            ; Return the values
        mov     es:[bx],cx              ; Access key LO
        mov     es:[bx+2],ax            ; Access key HI

        xor     ax,ax                   ; Return OK
        ret         

error:
        mov     al,ah                   ; AL gets error code
        xor     ah,ah                   ; Zero extend
        mov     errno,ax                ; Save in errno too
        ret

EMS_Ems@disableEmmOSFuncs40 endp        ; End of procedure

        end                             ; End of source file
