home *** CD-ROM | disk | FTP | other *** search
- ; Play a huge buffer containing 8-bit linear samples out the D/A port
- ;
- ; play8lin(base,buf,cnt)
- ; int base;
- ; huge char *buf;
- ; long cnt;
- include lmacros.h
-
- assume ds:dataseg
-
- procdef play8lin,<<baseio,word>,<buf,ptr>,<cntlo,word>,<cnthi,word>>
-
- cli
- push es
- push si
- push bx
- push cx
- push dx
- ; Initialize pointer and count
- ldptr si,buf,es ; es:si is data buffer pointer
- mov cx,cntlo ; bx:cx is buffer size
- mov bx,cnthi
-
- ; Wait for "clock" from TMS320 program to change
- cwait: mov dx,baseio
- add dx,4
- mov ah,oldclk
- sloop: in al,dx
- cmp al,ah
- beq sloop
- mov oldclk,al
-
- ; Get next sample from buffer
- mov al,es:[si]
- inc si
- cmp si,0 ; si wraparound?
- jne nowrap
- mov dx,es
- add dx,1000H
- mov es,dx
-
- ; Left shift sample 4 places for 12-bit D/A, and send it
- nowrap: shl ax,1
- shl ax,1
- shl ax,1
- shl ax,1
- mov dx,baseio
- out dx,ax
-
- ; decrement count, drop through if done
- dec cx
- cmp cx,0ffffh
- jne nobump
- dec bx
- nobump: cmp bx,0 ; bx == 0 ?
- jne cwait
- cmp cx,0 ; cx == 0 ?
- jne cwait
-
- pop dx
- pop cx
- pop bx
- pop si
- pop es
- sti
- pret
-
- dataseg segment
- oldclk db 1
- dataseg ends
-
-
- end
-