home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Sound / DelfAIFF / src / PCM.a56 < prev    next >
Text File  |  1999-10-01  |  2KB  |  139 lines

  1.  
  2. ;Delfina object DSP56K_PCM
  3. ;memory map (for Amiga access)
  4. ;
  5. ; prog
  6. ;   0 .. init (x1=mono, x0=/, y1=freq, y0=/)
  7. ;  +2 .. mute (x1=/, x0=/, y1=/, y0=/)
  8. ;  +4 .. DelfModule
  9. ;
  10. ; xdata
  11. ;   /
  12. ;
  13. ; ydata
  14. ;   0 .. amybuf (Amiga read)
  15.  
  16.  
  17.  
  18.  
  19. DELFINA_SAMPLES    equ    2046
  20.  
  21.  
  22.     include 'delfequ.inc'
  23.  
  24.     org    p:
  25.  
  26. int_key
  27.  
  28. ;->prog
  29.     jmp    init
  30.  
  31. ;->prog+2
  32.     jmp    mute
  33.  
  34.  
  35. ;->prog+4
  36.  
  37. ;***********************************
  38. ;* play routine
  39. ;*
  40. ;* r1=list of play buffers
  41.  
  42.     move    y:(r1),r4        ;r4=output buf
  43.     move    #rateconv,r3        ;r3=rateconv structure
  44.     move    r4,r7            ;r7=copy of r4
  45.     move    x:bufptr,r6        ;r6=old bufptr
  46.  
  47.     movec    #DELFINA_SAMPLES*2-1,m2 ;m2=input buffer mask
  48.     jsr    <delf_playrate        ;rate conversion
  49.  
  50.     move    y:mono,b
  51.     tst    b    r7,r0
  52.     jeq    not_mono
  53.  
  54.     movec    #$ffff,m7
  55.     move    x:(r0)+,a
  56.     rep    #127
  57.     move    x:(r0)+,a    a,y:(r7)+
  58.     move    a,y:(r7)+
  59. not_mono
  60.  
  61. ; Double buffering. We compare old bufptr (in r6) and new bufptr (in r2).
  62. ; If they are in different halves of the buffer then interrupt Amiga.
  63.     move    r6,y1            ;y1=old pointer
  64.     move    y:buf2,b        ;b= start of buf2
  65.     cmp    y1,b    r2,y0        ;y0=new pointer
  66.     jle    dbuf_buf2
  67.     cmp    y0,b    y:buf1,x0
  68.     jgt    dbuf_skip
  69. dbuf_int
  70.     move    x0,y:amybuf        ;tell amiga the new buffer
  71.     move    #int_key,a0
  72.     move    #causeqw,r0
  73.     jmp    <delf_causeq        ;interrupt and exit
  74. dbuf_buf2
  75.     cmp    y0,b    b,x0
  76.     jgt    dbuf_int
  77. dbuf_skip
  78.     rts
  79.  
  80.  
  81.  
  82. ;***********************************
  83. ;* init stuff
  84. ;*
  85. ;* x1=mono
  86. ;* x0=/
  87. ;* y1=freq
  88. ;* y0=/
  89. init
  90.     move    #buf,x0
  91.     move    #DELFINA_SAMPLES,a
  92.     add    x0,a    x0,x:bufptr
  93.     move    x0,y:buf1
  94.     move    a,y:buf2
  95.     move    x1,y:mono
  96.     move    y1,x:freq
  97.  
  98.     rts
  99.  
  100.  
  101. ;***********************************
  102. ;* clear current buffer (pause mode)
  103. ;*
  104. ;* x1=/
  105. ;* x0=/
  106. ;* y1=/
  107. ;* y0=/
  108. mute
  109.     clr    a    y:amybuf,r0
  110.     move    a,x0
  111.     move    r0,r4
  112.     do    #DELFINA_SAMPLES,mute_loop    ;interruptable
  113.     move    a,x:(r0)+    a,y:(r4)+
  114. mute_loop
  115.     rts
  116.  
  117.  
  118.  
  119.  
  120.     org    l:
  121.     align    4096        ;must be >= DELFINA_SAMPLES*2
  122. buf    ds    DELFINA_SAMPLES*2
  123.  
  124.  
  125.     org    x:
  126. causeqw    dc    0,0
  127. rateconv
  128. freq    dc    0
  129. bufptr    dc    0
  130.     ds    4
  131.     
  132.     org    y:
  133. ;->ydata
  134. amybuf    dc    0        ;!!!! Amiga fills this buffer
  135.  
  136. mono    dc    0        ;playing in mono?
  137. buf1    dc    0        ;buffer1
  138. buf2    dc    0        ;buffer2 = buffer1 + DELFINA_SAMPLES
  139.