home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / pastalk.zip / TALKER.ASM < prev    next >
Assembly Source File  |  1989-04-23  |  3KB  |  103 lines

  1. title    Talker
  2. ;        Modified from TPSPCH.ARC found on CompuServe IBMPro forum, DL 5
  3. ;        David Neal Dubois
  4. ;        Michael Day
  5. ;        released to public domain by authors 
  6. ;        as of 22 April 1989
  7.  
  8. ideal
  9. model tpascal
  10. codeseg
  11. public Talker
  12.  
  13. ; Outputs sound sample beginning at address Start, and continuing for
  14. ; Count bytes.
  15.  
  16. proc Talker far Start:dword,Count:word,Speed:word,Resolve:word,Sound:word
  17.             uses DS
  18.  
  19.       in    Al, 61h              ; Save state of speaker
  20.       push  AX
  21.       mov   AH,AL
  22.       and   AH,0FFH-3            ; weed out the speaker control bits
  23.  
  24.       mov   ES, [ Speed ]        ; Get speed delay 
  25.       lds   SI, [ Start ]        ; Get address of Start
  26.       mov   DI, [ Count ]        ; Get count
  27.       mov   BX, [ Resolve ]      ; resolution of speech
  28.       mov   CX, [ Sound ]        ; generate sound or cal only?
  29.       cmp   BL, 3                ; 1 or 2 is OK
  30.       jb    OutByteX             ; 3 becomes 4
  31.       cmp   BL,6                 ; 4 is OK
  32.       jb    OutByte4
  33.       mov   BL,8                 ; anything else becomes 8
  34.       jmp   OutByteX
  35.  
  36. OutByte4:
  37.       mov   BL, 4                ; must be 1, 2, 4, or 8 only
  38. OutByteX:
  39.       cmp   CL, 0                ; 0 = no sound
  40.       jz    NoByte               ; nz = do sound
  41.  
  42. OutByte:
  43.       lodsb                      ; Get a byte
  44.       mov   DH, AL               ; save it in DH
  45.       mov   DL, 8                ; DL will hold number of bits left in byte
  46.       rol   DH, 1                ; Position first bit to output
  47.  
  48. OutBit:
  49.       mov   AL, DH               ; Move into AL
  50.       and   AL, 02h              ; Leave only that bit
  51.       or    AL, AH               ; Set speaker's other mystery bits
  52.       out   61h, AL              ; Send to speaker
  53.  
  54.       mov   CX, ES               ; Wait
  55. Blah: loop  Blah
  56.  
  57.       mov   CL, BL
  58.       rol   DH, CL               ; Get next bit to output
  59.       sub   DL, BL               ; All bits done in this byte?
  60.       jnz   OutBit               ; no: Process next bit
  61.  
  62.       dec   DI                   ; All bytes done?
  63.       jnz   OutByte              ; no: Process next byte
  64.  
  65.       jmp TalkDone               ; all done
  66.  
  67. NoByte:
  68.       lodsb                      ; Get a byte
  69.       mov   DH, AL               ; save it in DH
  70.       mov   DL, 8                ; DL will hold number of bits left in byte
  71.       rol   DH, 1                ; Position first bit to output
  72.  
  73. NoBit:
  74.       mov   AL, DH               ; Move into AL
  75.       and   AL, 02h              ; Leave only that bit
  76.       or    AL, AH               ; Set speaker's other mystery bits
  77.       in    AL, 61h              ; dummy input from speaker for timming
  78.  
  79.       mov   CX, ES               ; Wait
  80. NoBlah: loop  NoBlah
  81.  
  82.       mov   CL, BL
  83.       rol   DH, CL               ; Get next bit to output
  84.       sub   DL, BL               ; All bits done in this byte?
  85.       jnz   NoBit               ; no: Process next bit
  86.  
  87.       dec   DI                   ; All bytes done?
  88.       jnz   NoByte              ; no: Process next byte
  89.  
  90.  
  91.  
  92. TalkDone:
  93.       pop   AX                   ; Restore state of speaker
  94.       out   61h, AL
  95.  
  96.       ret
  97. endp  Talker
  98.  
  99. ends
  100. end
  101.  
  102.  
  103.