home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / sound / digpak / drvinst.asm < prev    next >
Encoding:
Assembly Source File  |  1994-02-06  |  2.0 KB  |  68 lines

  1. ONSTACK STRUC
  2.    OLDBP   DW ?
  3.    RETADDR DD ?
  4.    DRIVEROFS  DW ?
  5.    DRIVERSEG  DW ?
  6. ONSTACK ENDS
  7.  
  8. CODE SEGMENT PARA PUBLIC 
  9.      ASSUME CS:CODE
  10.      PUBLIC LoadSoundDriver
  11.      PUBLIC UnloadSoundDriver
  12.  
  13. ;; Local data area for calling into a loadable sound driver.
  14. LoadAddress     dw      0,0     ; Allocate memory load address.
  15. LoadSeg dw      0       ; Segment driver was loaded into.
  16. LABEL   InstallDriver   DWORD
  17. InstOff dw      0200h   ; Offset of first jump.
  18. InstSeg dw      ?       ; Segment of audio driver.
  19. LABEL   DeInstallDriver DWORD
  20. DeInstOff dw    0203h   ; Offset of deinstall jump
  21. DeInstSeg dw    ?       ; Segment of audio driver.
  22.  
  23. ; FUNCTION LoadSoundDriver(Driver : Pointer) : BOOLEAN;  // Load a sound driver by filename, 1 success 0 fail.
  24. LoadSoundDriver PROC FAR
  25.         PUSH BP
  26.         MOV BP,SP
  27.         mov     ax,[BP].DRIVEROFS
  28.         and     ax,0Fh
  29.         jnz     @@FREE          ; not paragraph aligned.
  30.  
  31.         mov     ax,[BP].DRIVEROFS
  32.         shr     ax,1
  33.         shr     ax,1
  34.         shr     ax,1
  35.         shr     ax,1
  36.         add     ax,[BP].DRIVERSEG
  37.         mov     [cs:LoadSeg],ax ; Save load segment.
  38.  
  39.         mov     ax,[cs:LoadSeg] ; Save segment loaded at.
  40.         sub     ax,10h          ; Less 10 paragraphs for the org 100h
  41.         mov     [cs:InstSeg],ax
  42.         mov     [cs:DeInstSeg],ax
  43.         call    [cs:InstallDriver]      ; Install the driver.
  44.         or      ax,ax           ; Installed ok?
  45.         jz      @@OK1
  46. @@FREE:
  47.         xor     ax,ax
  48.         mov     [cs:LoadSeg],ax
  49.         jmp     short @@EXT     ; Exit with error.
  50. @@OK1:  mov     al,1            ; Success!
  51. @@EXT:
  52.         POP BP 
  53.         ret 4
  54. LoadSoundDriver  ENDP
  55.  
  56.  
  57. UnloadSoundDriver PROC FAR
  58.         cmp     [cs:LoadSeg],0     ; Ever load a sound driver?
  59.         je      @@NOT           ; no, leave.
  60.         call    [cs:DeInstallDriver]       ; Do indirect call to deinstall the driver.
  61.         mov     [cs:LoadSeg],0  ; Zero load seg out.
  62. @@NOT:
  63.         ret
  64. UnLoadSoundDriver  ENDP
  65.  
  66. CODE    ends
  67.         end
  68.