home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / teseract / source / tsdobeep.asm < prev    next >
Encoding:
Assembly Source File  |  1988-10-02  |  5.9 KB  |  154 lines

  1. IFNDEF TP4
  2.         PAGE 60,132
  3. ;----------------------------------------------------------------------------
  4. SUBTTL  TesSeRact Revision Level 1
  5. ;-----------------------------------------------------------------------------
  6. ;   TesSeRact(tm) -- A Library of Routines for Creating Ram-Resident (TSR)
  7. ;                    programs for the IBM PC and compatible Personal
  8. ;                    Computers.
  9. ;
  10. ;The software, documentation and source code are: 
  11. ;       Copyright (C) 1986, 1987, 1988 Tesseract Development Team
  12. ;       All Rights Reserved 
  13. ;       c/o Chip Rabinowitz
  14. ;       Innovative Data Concepts
  15. ;       2084 Woodlawn Avenue
  16. ;       Glenside, PA 19038
  17. ;       1-215-884-3373
  18. ;
  19. ;-----------------------------------------------------------------------------
  20. ;   This product supports the TesSeRact Standard for Ram-Resident Program 
  21. ;   Communication.  For information about TesSeRact, contact the TesSeRact 
  22. ;   Development Team at:
  23. ;       Compuserve:    70731,20
  24. ;       MCIMAIL:       315-5415
  25. ;   This MCIMAIL Account has been provided to the TesSeRact Development
  26. ;   Team by Borland International, Inc.  The TesSeRact Development Team
  27. ;   is in no way associated with Borland International, Inc.
  28. ;-----------------------------------------------------------------------------
  29.  
  30. INCLUDE TESS.INC
  31. INCLUDE mixed.inc
  32.  
  33. .MODEL small
  34. .CODE
  35.  
  36. ENDIF
  37.  
  38. IFNDEF ASMCOM
  39.  
  40. hProc <TESSBEEP FAR>  <USES SI,DI>
  41.         call    error_beep
  42.         hRet
  43. hEndp
  44.  
  45. ENDIF
  46.  
  47. ;*** ERROR_BEEP *************************************************************
  48. ;  This routines sends a beep-beep to the speaker; it is called when        *
  49. ;      Ringmaster determines it cannot pop up for any reason whatsoever.    *
  50. ;                                                                           *
  51. ;  Registers Modified:                                                      *
  52. ;      AX, BX, CX, DX trashed; all others unmodified                        *
  53. ;************************************************************************CR*/
  54. IFDEF ASMCOM
  55.  
  56. PUBLIC TESSBEEP
  57. TESSBEEP:
  58.  
  59. ENDIF
  60.  
  61. error_beep proc near
  62.         pushf
  63.         sti
  64.         mov     cx,420h                 ;start at high C
  65.  
  66. sound_again:
  67.         mov     dx,12h
  68.         mov     ax,34dch
  69.         div     cx
  70.         call    speakeron
  71. s10:
  72.         mov     ax,1                    ;put counter into delay loop
  73.         call    timer
  74.  
  75.         cmp     cx,300h                 ;are we at middle C?
  76.         je      exit_sound
  77.  
  78.         sub     cx,30h
  79.  
  80.         jmp     short sound_again
  81.  
  82. exit_sound:
  83.         xor     ax,ax
  84.         call    speakeron
  85.  
  86.         POPFF
  87.         ret
  88. error_beep endp
  89.  
  90. ;*** SPEAKERON **************************************************************
  91. ;  Routine to turn the speaker on or off at the appropriate frequency       *
  92. ;      (passed in AX).  If AX is zero (0), the speaker is turned off;       *
  93. ;      otherwise, the speaker is set to the appropriate pitch.              *
  94. ;                                                                           *
  95. ;  Registers Modified:                                                      *
  96. ;      AX trashed; all others unchanged                                     *
  97. ;************************************************************************CR*/
  98. speakeron proc near
  99.         push    ax                      ;save frequency
  100.         in      al,61h                  ;get current port setting
  101.         and     al,0fch                 ;setting to turn off speaker
  102.         out     61h,al                  ;turn off speaker
  103.         mov     al,10110110b
  104.         out     43h,al
  105.         pop     ax                      ;recover frequency
  106.         cmp     ax,0                    ;is it = 0?
  107.         je      sp10                    ;if yes, just exit
  108.         out     42h,al                  ;output low order byte to port first
  109.         mov     al,ah                   ;prepare high order byte for out instruction
  110.         out     42h,al                  ;output high order byte to timer port
  111.         in      al,61h                  ;get current port setting
  112.         or      al,3                    ;turn on two low order bits for speaker on
  113.                                         ;under control of timer port
  114.         out     61h,al                  ;turn speaker on
  115. sp10:
  116.         ret
  117. speakeron endp
  118.  
  119. ;*** TIMER ******************************************************************
  120. ; Provide a timed delay of 1/18.2 second intervals.  Delay count is passed  *
  121. ;     to the function in the AX register.  Maximum delay possible is        *
  122. ;     approximately 14 (255/18.2) seconds.                                  *
  123. ;                                                                           *
  124. ; Registers Modified:                                                       *
  125. ;    AX, BX, DX trashed; All others preserved                               *
  126. ;************************************************************************CR*/
  127. timer   proc    near
  128.         push    di                      ; save registers
  129.         push    cx
  130.         or      ax,ax                   ; make sure we have a value
  131.         jz      tout
  132.         mov     di,ax                   ; save counter
  133.         xor     ah,ah                   ; see what ticker says first
  134.         int     1Ah                     ; CX:DX is starting point.
  135.         mov     bx,dx                   ; save initial low order count
  136. tloop:
  137.         xor     ah,ah                   ; function to get timer
  138.         int     1Ah                     ; get timer tiks to CX:DX
  139.         cmp     bx,dx                   ; see if low order has changed
  140.         jz      tloop                   ; if not get it again
  141.         mov     bx,dx                   ; update bx with new low order count
  142.         dec     di                      ; --interval
  143.         jnz     tloop                   ; if not down to 0
  144. tout:
  145.         pop     cx
  146.         pop     di
  147.         ret
  148.         timer   endp
  149.  
  150.  
  151. ENDIT
  152.