home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 191_01 / soundint.asz < prev    next >
Text File  |  1986-05-25  |  7KB  |  193 lines

  1. ;
  2. ;    SOUNDINT.ASM            (Aztec version)                 06 Feb 86
  3. ;
  4. ;   /* ------------------------------------------------------------ */
  5. ;   /*      This is a portion of the SOUND EFFECTS LIBRARY.         */
  6. ;   /*                                                              */
  7. ;   /*      Copyright (C) 1986 by Paul Canniff.                     */
  8. ;   /*      All rights reserved.                                    */
  9. ;   /*                                                              */
  10. ;   /*      This library has been placed into the public domain     */
  11. ;   /*      by the author.  Use is granted for non-commercial       */
  12. ;   /*      pusposes, or as an IMBEDDED PORTION of a commercial     */
  13. ;   /*      product.                                                */
  14. ;   /*                                                              */
  15. ;   /*      Paul Canniff                                            */
  16. ;   /*      PO Box 1056                                             */
  17. ;   /*      Marlton, NJ 08053                                       */
  18. ;   /*                                                              */
  19. ;   /*      CompuServe ID: 73047,3715                               */
  20. ;   /*                                                              */
  21. ;   /* ------------------------------------------------------------ */
  22. ;
  23. ; -------------------------------------------------------------------------
  24. ;    Define IBM PC ports used to control speakers
  25. ;
  26. KBCTL      EQU     61H        ;Keyboard control port (controls speaker too)
  27. SPKTMR     EQU     42H        ;8253 Timer address
  28. SPKCTL     EQU     43H        ;8253 Timer address
  29. ;
  30. ; -------------------------------------------------------------------------
  31. ;    Set up macros for segment values, etc.
  32. ;
  33. ;
  34. codeseg segment para public 'code'
  35. dataseg segment para public 'data'
  36. dummy   DW      0
  37. dataseg ends
  38.     assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg
  39. ;
  40. ;
  41. LPROG   EQU     0
  42. ;
  43.     IF    LPROG
  44. ARGS    EQU    6                       ;Bytes on stack before args 
  45.     ELSE
  46. ARGS    EQU    4                       ;Bytes on stack before args
  47.     ENDIF
  48. ;
  49. ; -------------------------------------------------------------------------
  50. ;
  51.         IF      LPROG
  52.     EXTRN    sound_out_:FAR          
  53.     EXTRN    sound_done_:FAR
  54.         ENDIF
  55. ;
  56. CODESEG SEGMENT BYTE PUBLIC 'code'
  57. ;
  58.         IF      LPROG EQ 0
  59.     EXTRN    sound_out_:NEAR          
  60.     EXTRN    sound_done_:NEAR
  61.         ENDIF
  62. ;
  63.     PUBLIC    snd_irh_
  64.     PUBLIC    snd_giv_
  65.     PUBLIC    snd_siv_
  66.     PUBLIC    snd_brk_
  67. ;
  68. ;
  69. ;
  70. snd_irh_ PROC   FAR
  71.     STI                             ; Enable interrupts
  72.     PUSH    DS                      ;\
  73.     PUSH    ES                      ; \
  74.     PUSH    SI                      ;  \
  75.     PUSH    DI                      ;   \
  76.     PUSH    BP                      ; Save all registers
  77.     PUSH    AX                      ;   /
  78.     PUSH    BX                      ;  /
  79.     PUSH    CX                      ; /
  80.     PUSH    DX                      ;/
  81.     MOV    AX,SEG dummy            ;\
  82.     MOV    ES,AX                   ; Load expected segment values
  83.     MOV    DS,AX                   ;/
  84.     CALL    sound_out_              ; Call the real code
  85.     POP    DX                      ;\
  86.     POP    CX                      ; \
  87.     POP    BX                      ;  \
  88.     POP    AX                      ;   \
  89.     POP    BP                      ; Restore all registers
  90.     POP    DI                      ;   /
  91.     POP    SI                      ;  /
  92.     POP    ES                      ; /
  93.     POP    DS                      ;/
  94.         INT     61H                     ; Call previous INT vector
  95.     IRET                            ; Return
  96. snd_irh_ ENDP
  97. ;
  98. ;
  99.     IF    LPROG
  100. snd_giv_ PROC   FAR
  101.     ELSE
  102. snd_giv_ PROC   NEAR
  103.     ENDIF
  104.     PUSH    BP                      ;Save frame pointer
  105.     MOV    BP,SP                   ;Make new frame pointer
  106.     PUSH    ES                      ;Preserve ES, just in case
  107.     XOR    AX,AX                   ;Zero ES register so it will
  108.     MOV    ES,AX                   ;   point to low memory
  109.     MOV    BX,[BP+ARGS]            ;Make BX into proper offset,
  110.     SHL    BX,1                    ;   which is the vector number
  111.     SHL    BX,1                    ;   times 4 (2 shifts)
  112.     PUSHF                           ;Save INT flag
  113.     CLI                             ;Disable interrupts
  114.     MOV    DX,ES:[BX+2]            ;Get the high ...
  115.         MOV     AX,ES:[BX]              ; ... and low words of vector
  116.     POPF                            ;Restore INT flag
  117.     POP    ES                      ;Preserve ES, just in case
  118.     POP    BP                      ;Restore caller's frame
  119.     RET
  120. snd_giv_ ENDP
  121. ;
  122. ;
  123.     IF    LPROG
  124. snd_siv_ PROC   FAR
  125.     ELSE
  126. snd_siv_ PROC   NEAR
  127.     ENDIF
  128.     PUSH    BP                      ;Save frame pointer
  129.     MOV    BP,SP                   ;Make new frame pointer
  130.     PUSH    ES                      ;Preserve ES, just in case
  131.     XOR    AX,AX                   ;Zero ES register so it will
  132.     MOV    ES,AX                   ;   point to low memory
  133.     MOV    BX,[BP+ARGS]            ;Make BX into proper offset,
  134.     SHL    BX,1                    ;   which is the vector number
  135.     SHL    BX,1                    ;   times 4 (2 shifts)
  136.     PUSHF                           ;Save INT flag
  137.     CLI                             ;Disable interrupts
  138.     MOV    AX,[BP+ARGS+2]          ;Get low word of vector 
  139.     MOV    ES:[BX],AX              ;   and install it.
  140.     MOV    AX,[BP+ARGS+4]          ;Get high word of vector
  141.     MOV    ES:[BX+2],AX            ;   and install it.
  142.     POPF                            ;Restore INT flag
  143.     POP    ES                      ;Preserve ES, just in case
  144.     POP    BP                      ;Restore caller's frame
  145.     RET
  146. snd_siv_ ENDP
  147. ;
  148. ;
  149. snd_brk_ PROC   FAR
  150.     STI
  151.     PUSH    DS                      ;\
  152.     PUSH    ES                      ; \
  153.     PUSH    SI                      ;  \
  154.     PUSH    DI                      ;   \
  155.     PUSH    BP                      ; Save all registers
  156.     PUSH    AX                      ;   /
  157.     PUSH    BX                      ;  /
  158.     PUSH    CX                      ; /
  159.     PUSH    DX                      ;/
  160.     MOV    AX,SEG dummy            ;\
  161.     MOV    ES,AX                   ; Load expected segment values
  162.     MOV    DS,AX                   ;/
  163.     CALL    sound_done_             ; Tidy up loose ends
  164.         CLC                             ; Clear Carry (see above desc.)
  165.     INT     23H                     ; Call the real handler
  166.     POP    DX                      ;\
  167.     POP    CX                      ; \
  168.     POP    BX                      ;  \
  169.     POP    AX                      ;   \
  170.     POP    BP                      ; Restore all registers
  171.     POP    DI                      ;   /
  172.     POP    SI                      ;  /
  173.     POP    ES                      ; /
  174.     POP    DS                      ;/
  175.         JC      abort                   ; Abort if handler set carry flag
  176. ;
  177. cont:   IRET                            ; Continue, use IRET
  178. ;
  179. abort:  POPF                            ; Get flags off stack
  180.         STC                             ; Pass "abort" message back to DOS
  181.         RET                             ; Long return to DOS
  182. snd_brk_ ENDP
  183. ;
  184. ;
  185. codeseg    ends
  186.     END
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.