home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / SOUND.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.9 KB  |  79 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.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #pragma inline
  19. #include <dos.h>
  20.  
  21. /*-----------------------------------------------------------------------*
  22.  
  23. Name            sound - outputs a sound of a specified frequency to the
  24.                         speaker
  25.  
  26. Usage           void sound(unsigned frequency)
  27.  
  28. Prototype in    dos.h
  29.  
  30. Description     outputs a sound of a specified frequency to the speaker
  31.  
  32. *------------------------------------------------------------------------*/
  33. void sound(unsigned frequency)
  34. {
  35. asm     mov     bx,  frequency
  36. asm     mov     ax,  34DDh
  37. asm     mov     dx,  0012h
  38. asm     cmp     dx,  bx
  39. asm     jnb     stop
  40. asm     div     bx
  41. asm     mov     bx,  ax
  42. asm     in      al,  61h
  43. asm     test    al,  3
  44. asm     jne     j1
  45. asm     or      al,  3
  46. asm     out     61h, al
  47. asm     mov     al,  0B6h
  48. asm     out     43h, al
  49. j1:
  50. asm     mov     al,  bl
  51. asm     out     42h, al
  52. asm     mov     al,  bh
  53. asm     out     42h, al
  54. stop: ;
  55. }
  56.  
  57.  
  58. /*-----------------------------------------------------------------------*
  59.  
  60. Name            nosound - turns off the speaker
  61.  
  62. Usage           void nosound(void)
  63.  
  64. Prototype in    dos.h
  65.  
  66. Description     turns the speaker off
  67.  
  68. *------------------------------------------------------------------------*/
  69.  
  70. void nosound(void)
  71. /* Turns the speaker off */
  72. {
  73. asm     in      al,61H
  74. asm     and     al, 0fcH
  75. asm     out     61H, al
  76.  
  77. /*      outportb(0x61, inportb(0x61) & 0xfc); */
  78. } /* nosound */
  79.