home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / s / scrd_asm.zip / ADLTEST.ASM < prev    next >
Assembly Source File  |  1992-06-19  |  5KB  |  170 lines

  1. comment *
  2.  
  3.         Purpose:
  4.         Test if Adlib API works
  5.  
  6.         Author:
  7.         Yousuf J. Khan
  8.  
  9.         *
  10. include adlib.inc
  11.  
  12. .model tiny
  13. .data
  14. crlf    equ     13,10
  15. crlfe   equ     crlf,"$"
  16. noadl           db      "No AdLib card", crlfe
  17. yadl            db      "Found AdLib", crlfe
  18. sbport          dw      ?       ;address where SB port was found
  19. nosb            db      "No SoundBlaster card", crlfe
  20. ysb             db      "SoundBlaster found at port "
  21. address         db      4 dup(" "),"h", crlfe
  22. noise           db      "Where's that noise coming from?",crlfe
  23. presskey        db      "Press any key to stop noise", crlfe
  24. .code
  25.         org     100h
  26. start:
  27.         extrn   detect_adlib:near
  28.         call    detect_adlib            ;procedure returns AX=1
  29.         cmp     ax, 1                   ; if AdLib present
  30.         je      short sb_detect
  31.         lea     dx, noadl
  32.         mov     ah, 9
  33.         int     21h
  34.         mov     ax, 4c01h               ;exit, errorlevel 1
  35.         int     21h
  36. sb_detect:
  37.         lea     dx, yadl
  38.         mov     ah, 9
  39.         int     21h
  40.         extrn   detect_sb:near
  41.         lea     di, sbport      ;where to store i/o address
  42.         call    detect_sb
  43.         cmp     ax, 1           ;if SB present, AX=1
  44.         jne     short no_sb_found
  45.         mov     ax, [di]        ;load hex num to convert
  46.         lea     di, address     ;where ASCII will be stored (4 bytes)
  47.         call    hex2text        ;convert to hex num to text num
  48.         lea     dx, ysb
  49.         mov     ah, 9
  50.         int     21h
  51.         jmp     short initcard  ;start initializing card
  52. no_sb_found:
  53.         lea     dx, nosb
  54.         mov     ah, 9
  55.         int     21h
  56. initcard:
  57.         extrn   adlibinit:near  ;procedure to initialize all
  58.         call    adlibinit       ; AdLib registers to zero
  59.         extrn   sbdelay:near    ;proc to add i/o wait states
  60.         ;
  61.         ;let's start making noise
  62.         ;
  63.         lea     dx, noise
  64.         mov     ah, 9
  65.         int     21h
  66.         .radix 16
  67.         ;Set the modulator's multiple to 1
  68.         setadlib        20, 01
  69.         ;Set the modulator's level to about 40 dB
  70.         setadlib        40, 10
  71.         ;Modulator attack:  quick;   decay:   long
  72.         setadlib        60, 0F0
  73.         ;Modulator sustain: medium;  release: medium
  74.         setadlib        80, 77
  75.         ;Set voice frequency's LSB (it'll be a D#)
  76.         setadlib        0A0, 98
  77.         ;Set the carrier's multiple to 1
  78.         setadlib        23, 01
  79.         ;Set the carrier to maximum volume (about 47 dB)
  80.         setadlib        43, 00
  81.         ;Carrier attack:  quick;   decay:   long
  82.         setadlib        63, 0F0
  83.         ;Carrier sustain: medium;  release: medium
  84.         setadlib        83, 77
  85.         ;Turn the voice on; set the octave and freq MSB
  86.         setadlib        0B0, 31
  87.         .radix 10
  88.         ;
  89.         ;wait till key pressed
  90.         ;
  91.         lea     dx, presskey    ;print string interrupt
  92.         mov     ah, 9
  93.         int     21h
  94.         mov     ah, 7           ;direct STDIN input interrupt
  95.         int     21h
  96.         ;
  97.         ;let's turn off the noise by running the init over again
  98.         ;
  99.         call    adlibinit       ;calling init to turn off sound
  100.         mov     ax, 4c00h       ;exit, errorlevel 0
  101.         int     21h
  102.  
  103. hex2text        proc    near
  104. comment *
  105.  
  106.         Purpose:
  107.         To convert a true hex number to an ASCII hex number
  108.  
  109.         Entry:
  110.         AX: hex num to convert
  111.         DI: start address to store converted ASCII number
  112.  
  113.         Exit:
  114.         DI-> points to where last ASCII number stored
  115.  
  116.         *
  117.         push    dx              ;save DX
  118.         xor     dx, dx
  119.         push    bx              ;save BX
  120.         mov     bx, 1000h
  121.         div     bx              ;divide by 1000h
  122.         call    hexascii
  123.         mov     ax, dx          ;move remainder in
  124.         xor     dx, dx
  125.         mov     bx, 100h
  126.         div     bx              ;div by 100h
  127.         inc     di
  128.         call    hexascii
  129.         mov     ax, dx          ;move remainder in
  130.         xor     dx, dx
  131.         mov     bx, 10h
  132.         div     bx              ;div by 10h
  133.         inc     di
  134.         call    hexascii
  135.         mov     ax, dx
  136.         inc     di
  137.         call    hexascii
  138.         pop     bx              ;restore BX
  139.         pop     dx              ;restore DX
  140.         ret
  141.         endp
  142.  
  143. hexascii        proc    near
  144. comment *
  145.  
  146.         Purpose:
  147.         A subprocedure for internal use by HEX2TEXT procedure only
  148.  
  149.         Entry:
  150.         AL: byte value to convert to ASCII
  151.         DI: pointer to store ASCII to
  152.  
  153.         Exit:
  154.         AL: destroyed
  155.         [DI]: location modified
  156.  
  157.         *
  158.         cmp     al, 0Ah
  159.         jb      numerical
  160.         sub     al, 0Ah
  161.         add     al, "A"
  162.         jmp     short store
  163. numerical:
  164.         add     al, "0"
  165. store:
  166.         mov     [di], al
  167.         ret
  168.         endp
  169.         end     start
  170.