home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / SOUND.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.1 KB  |  80 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - sound.cas
  3.  *
  4.  * function(s)
  5.  *      sound   - outputs a sound of a specified frequency to the speaker
  6.  *      nosound - turns off the speaker
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*[]------------------------------------------------------------[]*/
  10. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19. #pragma inline
  20. #include <dos.h>
  21.  
  22. /*-----------------------------------------------------------------------*
  23.  
  24. Name        sound - outputs a sound of a specified frequency to the
  25.             speaker
  26.  
  27. Usage        void sound(unsigned frequency)
  28.  
  29. Prototype in    dos.h
  30.  
  31. Description    outputs a sound of a specified frequency to the speaker
  32.  
  33. *------------------------------------------------------------------------*/
  34. void sound(unsigned frequency)
  35. {
  36. asm    mov    bx,  frequency
  37. asm    mov    ax,  34DDh
  38. asm    mov    dx,  0012h
  39. asm    cmp    dx,  bx
  40. asm    jnb    stop
  41. asm    div    bx
  42. asm    mov    bx,  ax
  43. asm    in    al,  61h
  44. asm    test    al,  3
  45. asm    jne    j1
  46. asm    or    al,  3
  47. asm    out    61h, al
  48. asm    mov    al,  0B6h
  49. asm    out    43h, al
  50. j1:
  51. asm    mov    al,  bl
  52. asm    out    42h, al
  53. asm    mov    al,  bh
  54. asm    out    42h, al
  55. stop: ;
  56. }
  57.  
  58.  
  59. /*-----------------------------------------------------------------------*
  60.  
  61. Name        nosound - turns off the speaker
  62.  
  63. Usage        void nosound(void)
  64.  
  65. Prototype in    dos.h
  66.  
  67. Description    turns the speaker off
  68.  
  69. *------------------------------------------------------------------------*/
  70.  
  71. void nosound(void)
  72. /* Turns the speaker off */
  73. {
  74. asm    in    al,61H
  75. asm    and    al, 0fcH
  76. asm    out    61H, al
  77.  
  78. /*    outportb(0x61, inportb(0x61) & 0xfc); */
  79. } /* nosound */
  80.