home *** CD-ROM | disk | FTP | other *** search
/ The Equalizer BBS / equalizer-bbs-collection_2004.zip / equalizer-bbs-collection / DEMOSCENE-STUFF / BKISSSRC.ZIP / MUSGUS.ASM < prev    next >
Assembly Source File  |  1993-12-14  |  6KB  |  172 lines

  1. SoundFile       db      'MUSGUS.INF',0      ;filename of the driver to load
  2. Music           dd      0                   ;far ptr to the driver in memory
  3. MusBuf          dd      0                   ;far ptr to the driver's temp buf
  4. MMus            SMus    <>
  5. PM_struc        PM      <>
  6. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  7. proc            MUS_GetInfo
  8.                 mov bx,9                    ;return status in MMus block
  9.                 mov cx,1
  10.                 mov si,seg MMus
  11.                 mov di,offset MMus
  12.                 call [dword cs:Music]
  13.                 ret
  14. endp            MUS_GetInfo
  15. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  16. proc            MUS_SetInfo
  17.                 mov bx,0Ah                  ;update settings from MMus block
  18.                 mov si,seg MMus
  19.                 mov di,offset MMus
  20.                 call [dword cs:Music]
  21.                 ret
  22. endp            MUS_SetInfo
  23. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  24. ;returns:       CARRY set if error
  25. proc            MUS_LoadSoundDriver
  26.                 ;make sure a driver is not loaded yet
  27.                 mov ax,[word cs:Music+0]
  28.                 or ax,[word cs:Music+2]
  29.                 jnz @@Error
  30.  
  31.                 ;reset all of our variables
  32.                 mov [cs:@@Handle],0
  33.                 mov [cs:@@Segment],0
  34.                 mov [cs:@@Segment2],0
  35.  
  36.                 ;open up the file
  37.                 push ds
  38.                 mov ax,3D00h
  39.                 mov dx,cs
  40.                 mov ds,dx
  41.                 mov dx,offset SoundFile
  42.                 int 21h
  43.                 pop ds
  44.                 jc @@Error
  45.                 mov [cs:@@Handle],ax
  46.  
  47.                 ;find the length of the driver
  48.                 mov ax,4202h
  49.                 mov bx,[cs:@@Handle]
  50.                 xor cx,cx
  51.                 xor dx,dx
  52.                 int 21h
  53.                 mov [cs:@@Size],ax
  54.  
  55.                 ;allocate memory for the driver
  56.                 mov ah,48h
  57.                 mov bx,[cs:@@Size]
  58.                 add bx,15
  59.                 shr bx,4
  60.                 int 21h
  61.                 jc @@Error
  62.                 mov [cs:@@Segment],ax
  63.  
  64.                 ;allocate 4K for the driver's temporary buffer
  65.                 mov ah,48h
  66.                 mov bx,(4096/16)
  67.                 int 21h
  68.                 jc @@Error
  69.                 mov [cs:@@Segment2],ax
  70.  
  71.                 ;move the file pointer back to the beginning
  72.                 mov ax,4200h
  73.                 mov bx,[cs:@@Handle]
  74.                 xor cx,cx
  75.                 xor dx,dx
  76.                 int 21h
  77.  
  78.                 ;read in the driver
  79.                 push ds
  80.                 mov ah,3Fh
  81.                 mov bx,[cs:@@Handle]
  82.                 mov cx,[cs:@@Size]
  83.                 mov ds,[cs:@@Segment]
  84.                 mov dx,0
  85.                 int 21h
  86.                 pop ds
  87.  
  88.                 ;close the file
  89.                 mov ah,3Eh
  90.                 mov bx,[cs:@@Handle]
  91.                 int 21h
  92.  
  93.                 ;return with success
  94.                 mov ax,[cs:@@Segment]
  95.                 mov [word cs:Music+2],ax
  96.                 mov [word cs:Music+0],0
  97.                 mov ax,[cs:@@Segment2]
  98.                 mov [word cs:MusBuf+2],ax
  99.                 mov [word cs:MusBuf+0],0
  100.                 clc
  101.                 ret
  102.  
  103. @@Error:        cmp [cs:@@Handle],0
  104.                 jz @@Error1
  105.                 mov ah,3Eh
  106.                 mov bx,[cs:@@Handle]
  107.                 int 21h
  108. @@Error1:       cmp [cs:@@Segment],0
  109.                 jz @@Error2
  110.                 push es
  111.                 mov ah,49h
  112.                 mov es,[cs:@@Segment]
  113.                 int 21h
  114.                 pop es
  115. @@Error2:       cmp [cs:@@Segment2],0
  116.                 jz @@Error3
  117.                 push es
  118.                 mov ah,49h
  119.                 mov es,[cs:@@Segment2]
  120.                 int 21h
  121.                 pop es
  122. @@Error3:       stc
  123.                 ret
  124. @@Handle        dw      0
  125. @@Segment       dw      0
  126. @@Segment2      dw      0
  127. @@Size          dw      0
  128. endp            MUS_LoadSoundDriver
  129. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  130. ;returns:       CARRY set on error
  131. proc            MUS_FreeSoundDriver
  132.                 ;make sure a driver is loaded first
  133.                 mov ax,[word cs:Music+0]
  134.                 or ax,[word cs:Music+2]
  135.                 jz @@Error
  136.  
  137.                 ;stop playing (if it is)
  138.                 mov bx,5                    ;stop playing
  139.                 call [dword ptr cs:Music]
  140.  
  141.                 ;deinitialize the driver
  142.                 mov bx,1                    ;close down player
  143.                 call [dword ptr cs:Music]
  144.  
  145.                 ;free the memory associated with the driver
  146.                 push es
  147.                 mov ah,49h
  148.                 mov es,[word cs:Music+2]
  149.                 int 21h
  150.                 pop es
  151.                 mov [word cs:Music+0],0
  152.                 mov [word cs:Music+2],0
  153.  
  154.                 ;free the memory associated with the driver's temp buffer
  155.                 push es
  156.                 mov ah,49h
  157.                 mov es,[word cs:MusBuf+2]
  158.                 int 21h
  159.                 pop es
  160.                 mov [word cs:MusBuf+2],0
  161.                 mov [word cs:MusBuf+0],0
  162.  
  163.                 ;return with success
  164.                 clc
  165.                 ret
  166.  
  167. @@Error:        ;return with error
  168.                 stc
  169.                 ret
  170. endp            MUS_FreeSoundDriver
  171. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  172.