;**************************************************************
;***    EMS5B3.ASM                                          ***
;***                                                        ***
;***    function        EMS_Ems.allocAltMapRegs40(          ***
;***                        var alt_map:    Byte)           ***
;***                        : Boolean;                      ***
;***                                                        ***
;***    Returns alt map set number (0 if none available)    ***
;***                                                        ***
;***    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@allocAltMapRegs40

        .code

EMS_Ems@allocAltMapRegs40 proc altMap:Far Ptr Word, self:DWord

        mov     ax,AllocAltMapRegs40
        int     Ems           

        or      ah,ah                   ; Set flags
        jnz     error

        mov     al,bl                   ; Alternate register set #
        xor     ah,ah                   ; Zero extend to word
        les     bx,altMap               ; Return the alternate reg set #
        mov     es:[bx],ax

        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@allocAltMapRegs40 endp          ; End of procedure

        end                             ; End of source file

