home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / dsp / dspgroup / sound.arc / PLAY8LIN.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-01-23  |  1.1 KB  |  74 lines

  1. ; Play a huge buffer containing 8-bit linear samples out the D/A port
  2. ;
  3. ; play8lin(base,buf,cnt)
  4. ; int base;
  5. ; huge char *buf;
  6. ; long cnt;
  7. include lmacros.h
  8.  
  9.     assume    ds:dataseg
  10.  
  11.     procdef    play8lin,<<baseio,word>,<buf,ptr>,<cntlo,word>,<cnthi,word>>
  12.  
  13.     cli
  14.     push    es
  15.     push    si
  16.     push    bx
  17.     push    cx
  18.     push    dx
  19. ; Initialize pointer and count
  20.     ldptr    si,buf,es    ; es:si is data buffer pointer
  21.     mov    cx,cntlo    ; bx:cx is buffer size
  22.     mov    bx,cnthi
  23.  
  24. ; Wait for "clock" from TMS320 program to change
  25. cwait:    mov    dx,baseio
  26.     add    dx,4
  27.     mov    ah,oldclk
  28. sloop:    in    al,dx
  29.     cmp    al,ah
  30.     beq    sloop
  31.     mov    oldclk,al
  32.  
  33. ; Get next sample from buffer
  34.     mov    al,es:[si]
  35.     inc    si
  36.     cmp    si,0    ; si wraparound?
  37.     jne    nowrap
  38.     mov    dx,es
  39.     add    dx,1000H
  40.     mov    es,dx
  41.  
  42. ; Left shift sample 4 places for 12-bit D/A, and send it
  43. nowrap:    shl    ax,1
  44.     shl    ax,1
  45.     shl    ax,1
  46.     shl    ax,1
  47.     mov    dx,baseio
  48.     out    dx,ax
  49.  
  50. ; decrement count, drop through if done
  51.     dec    cx
  52.     cmp    cx,0ffffh
  53.     jne    nobump
  54.     dec    bx
  55. nobump:    cmp    bx,0    ; bx == 0 ?
  56.     jne    cwait
  57.     cmp    cx,0    ; cx == 0 ?
  58.     jne    cwait
  59.  
  60.     pop    dx
  61.     pop    cx
  62.     pop    bx
  63.     pop    si
  64.     pop    es
  65.     sti
  66.     pret
  67.  
  68. dataseg    segment
  69. oldclk    db    1
  70. dataseg ends
  71.  
  72.  
  73.     end
  74.