home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Sound / DelfMPEG / src / PCM.a56 < prev    next >
Text File  |  1999-10-27  |  3KB  |  162 lines

  1. ;*****************************************************************************
  2. ;
  3. ;    DelfMPEG - MPEG audio player for Delfina DSP
  4. ;    Copyright (C) 1999  Michael Henke
  5. ;
  6. ;    This program is free software; you can redistribute it and/or modify
  7. ;    it under the terms of the GNU General Public License as published by
  8. ;    the Free Software Foundation; either version 2 of the License, or
  9. ;    (at your option) any later version.
  10. ;
  11. ;    This program is distributed in the hope that it will be useful,
  12. ;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;    GNU General Public License for more details.
  15. ;
  16. ;    You should have received a copy of the GNU General Public License
  17. ;    along with this program; if not, write to the Free Software
  18. ;    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. ;
  20. ;*****************************************************************************
  21.  
  22.  
  23.  
  24.  
  25. ;Delfina object DSP56K_PCM
  26. ;memory map (for Amiga access)
  27. ;
  28. ; prog
  29. ;   0 .. init (x1=mono, x0=/, y1=freq, y0=/)
  30. ;  +2 .. mute (x1=/, x0=/, y1=/, y0=/)
  31. ;  +4 .. DelfModule
  32. ;
  33. ; xdata
  34. ;   /
  35. ;
  36. ; ydata
  37. ;   0 .. amybuf (Amiga read)
  38.  
  39.  
  40.  
  41.  
  42. DELFINA_SAMPLES    equ    1152
  43.  
  44.  
  45.     include 'delfequ.inc'
  46.  
  47.     org    p:
  48.  
  49. int_key
  50.  
  51. ;->prog
  52.     jmp    init
  53.  
  54. ;->prog+2
  55.     jmp    mute
  56.  
  57.  
  58. ;->prog+4
  59.  
  60. ;***********************************
  61. ;* play routine
  62. ;*
  63. ;* r1=list of play buffers
  64.  
  65.     move    y:(r1),r4        ;r4=output buf
  66.     move    #rateconv,r3        ;r3=rateconv structure
  67.     move    r4,r7            ;r7=copy of r4
  68.     move    x:bufptr,r6        ;r6=old bufptr
  69.  
  70.     movec    #DELFINA_SAMPLES*2-1,m2 ;m2=input buffer mask
  71.     jsr    <delf_playrate        ;rate conversion
  72.  
  73.     move    y:mono,b
  74.     tst    b    r7,r0
  75.     jeq    not_mono
  76.  
  77.     movec    #$ffff,m7
  78.     move    x:(r0)+,a
  79.     rep    #127
  80.     move    x:(r0)+,a    a,y:(r7)+
  81.     move    a,y:(r7)+
  82. not_mono
  83.  
  84. ; Double buffering. We compare old bufptr (in r6) and new bufptr (in r2).
  85. ; If they are in different halves of the buffer then interrupt Amiga.
  86.     move    r6,y1            ;y1=old pointer
  87.     move    y:buf2,b        ;b= start of buf2
  88.     cmp    y1,b    r2,y0        ;y0=new pointer
  89.     jle    dbuf_buf2
  90.     cmp    y0,b    y:buf1,x0
  91.     jgt    dbuf_skip
  92. dbuf_int
  93.     move    x0,y:amybuf        ;tell amiga the new buffer
  94.     move    #int_key,a0
  95.     move    #causeqw,r0
  96.     jmp    <delf_causeq        ;interrupt and exit
  97. dbuf_buf2
  98.     cmp    y0,b    b,x0
  99.     jgt    dbuf_int
  100. dbuf_skip
  101.     rts
  102.  
  103.  
  104.  
  105. ;***********************************
  106. ;* init stuff
  107. ;*
  108. ;* x1=mono
  109. ;* x0=/
  110. ;* y1=freq
  111. ;* y0=/
  112. init
  113.     move    #buf,x0
  114.     move    #DELFINA_SAMPLES,a
  115.     add    x0,a    x0,x:bufptr
  116.     move    x0,y:buf1
  117.     move    a,y:buf2
  118.     move    x1,y:mono
  119.     move    y1,x:freq
  120.  
  121.     rts
  122.  
  123.  
  124. ;***********************************
  125. ;* clear current buffer (pause mode)
  126. ;*
  127. ;* x1=/
  128. ;* x0=/
  129. ;* y1=/
  130. ;* y0=/
  131. mute
  132.     clr    a    y:amybuf,r0
  133.     move    a,x0
  134.     move    r0,r4
  135.     do    #DELFINA_SAMPLES,mute_loop    ;interruptable
  136.     move    a,x:(r0)+    a,y:(r4)+
  137. mute_loop
  138.     rts
  139.  
  140.  
  141.  
  142.  
  143.     org    l:
  144.     align    4096        ;must be >= DELFINA_SAMPLES*2
  145. buf    ds    DELFINA_SAMPLES*2
  146.  
  147.  
  148.     org    x:
  149. causeqw    dc    0,0
  150. rateconv
  151. freq    dc    0
  152. bufptr    dc    0
  153.     ds    4
  154.     
  155.     org    y:
  156. ;->ydata
  157. amybuf    dc    0        ;!!!! Amiga fills this buffer
  158.  
  159. mono    dc    0        ;playing in mono?
  160. buf1    dc    0        ;buffer1
  161. buf2    dc    0        ;buffer2 = buffer1 + DELFINA_SAMPLES
  162.