home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / SOUND3.ASM < prev    next >
Assembly Source File  |  1994-11-15  |  1KB  |  75 lines

  1.     page    66,132
  2. ;******************************** SOUND3.ASM *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11.     extrn    sound_flag:byte
  12. .list
  13.  
  14. comment 
  15. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  SOUND  )
  16. make_sound - make sound for number of milliseconds.
  17. ;
  18. ; inputs:  bx = frequency in HZ
  19. ;          dx = timer ticks
  20. ; outputs: none
  21. ;
  22. ; note:  Each timer tick is about 1/5 of a second.
  23. ;* * * * * * * * * * * * * *
  24. 
  25.     public    make_sound
  26. make_sound    proc    far
  27.     apush    ax,bx,dx,es
  28.     cmp    cs:sound_flag,0
  29.     je    sound_exit        ;jmp if sound is off
  30.     push    dx
  31.     xor    ax,ax
  32.     mov    es,ax
  33.     mov    ax,word ptr es:[46ch]
  34. timer_wait_1:    
  35.     cmp    ax,word ptr es:[46ch]
  36.     je    timer_wait_1
  37.  
  38.     mov    al,10110110b
  39.     out    43h,al
  40.     mov    dx,12h
  41.     mov    ax,2870h
  42.     cmp    bx,37
  43.     jb    sound_exit
  44.     div    bx
  45.  
  46.     out    42h,al
  47.     mov    al,ah
  48.     out    42h,al
  49.  
  50.     in    al,61h
  51.     or    al,3
  52.     out    61h,al
  53. ;
  54. ; delay
  55. ;
  56.     pop    dx    
  57. timer_wait_2:
  58.     mov    ax,word ptr es:[46ch]
  59. timer_wait_3:
  60.     cmp    ax,word ptr es:[46ch]
  61.     je    timer_wait_3
  62.     dec    dx
  63.     jnz    timer_wait_2
  64.  
  65.     in    al,61h
  66.     and    al,0fch
  67.     out    61h,al
  68. sound_exit:
  69.     apop    es,dx,bx,ax
  70.     retf
  71. make_sound    endp
  72.  
  73. LIBSEG    ENDS
  74.     end
  75.