home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 1 / Mecomp-CD.iso / amiga / player / ahi / developer / drivers / toccata / asmfuncs.a next >
Text File  |  1996-11-01  |  5KB  |  235 lines

  1.  
  2.     incdir    include:
  3.     include    exec/memory.i
  4.     include    lvo/exec_lib.i
  5.     include    devices/ahi.i
  6.     include    libraries/ahi_sub.i
  7.     include    libraries/toccata.i
  8.     include    libraries/toccata_lib.i
  9.     include    utility/hooks.i
  10.     include    toccata.i
  11.     include    macros.i
  12.  
  13.     XDEF    _intAHIsub_Disable
  14.     XDEF    _intAHIsub_Enable
  15.     XDEF    _intAHIsub_Update
  16.     XDEF    _intAHIsub_SetVol
  17.     XDEF    _intAHIsub_SetFreq
  18.     XDEF    _intAHIsub_SetSound
  19.     XDEF    _intAHIsub_SetEffect
  20.     XDEF    _intAHIsub_LoadSound
  21.     XDEF    _intAHIsub_UnloadSound
  22.  
  23.     XDEF    _RecordFunc
  24.  
  25.     XDEF    _PlayFuncMono
  26.     XDEF    _PlayFuncStereo
  27.  
  28.     XREF    _ToccataBase
  29.  
  30. *******************************************************************************
  31.  
  32. ;in:
  33. * a2    struct AHI_AudioCtrl
  34. _intAHIsub_Disable:
  35.     push    a6
  36.     move.l    4.w,a6
  37.     call    Disable
  38.     pop    a6
  39.     rts
  40.  
  41. ;in:
  42. * a2    struct AHI_AudioCtrl
  43. _intAHIsub_Enable:
  44.     push    a6
  45.     move.l    4.w,a6
  46.     call    Enable
  47.     pop    a6
  48.     rts
  49.  
  50.  
  51. * Unused functions
  52.  
  53. _intAHIsub_SetVol:
  54. _intAHIsub_SetFreq:
  55. _intAHIsub_SetSound:
  56. _intAHIsub_SetEffect:
  57. _intAHIsub_LoadSound:
  58. _intAHIsub_UnloadSound:
  59.     moveq    #AHIS_UNKNOWN,d0
  60. _intAHIsub_Update:
  61.     rts
  62.  
  63.  
  64. *******************************************************************************
  65.  
  66. ;in:
  67. * d0    size
  68. * a0    buffer
  69. * a1    AudioCtrl
  70. _RecordFunc:
  71.     pushm    a2/a3
  72.     move.l    a1,a2
  73.     move.l    ahiac_DriverData(a2),a1
  74.  
  75. * Update dd->t_RecMessage->ahirm_Length:
  76.     move.l    t_RecMessage(a1),a3
  77.     lsr.l    #2,d0                ;bytes => samples
  78.     move.l    d0,ahirm_Length(a3)
  79.  
  80. * Copy sample buffer
  81.     move.l    t_RecBuffer(a1),a3
  82.     lsr.l    #1,d0
  83.     bcs    .1
  84.     subq.l    #1,d0
  85.     bmi    .exit
  86. .loop
  87.     move.l    (a0)+,(a3)+
  88. .1
  89.     move.l    (a0)+,(a3)+
  90.     dbf    d0,.loop
  91.  
  92. * Call the SamplerFunc Hook
  93.     move.l    t_RecMessage(a1),a1
  94.     move.l    ahiac_SamplerFunc(a2),a0
  95.     move.l    h_Entry(a0),a3
  96.     jsr    (a3)
  97. .exit
  98.     moveq    #TRUE,d0
  99.     popm    a2/a3
  100.     rts
  101.  
  102. *******************************************************************************
  103.  
  104. TocSamplesCnt    EQUR    d7
  105. TocBuffer    EQUR    a6
  106.  
  107. *
  108. * These functions fills the Toccata buffer with the mixed output. Since
  109. * the Toccata buffer is not the same size as the mixing buffer, the mixing
  110. * routine may have to be called several times each interrupt. Or if the mixing
  111. * buffer is larger than the Toccata buffer, it may not be called at all.
  112. *
  113. * The routines are not very well commented, but they should be pretty stright-
  114. * forward once you know what they actually do.
  115. *
  116.  
  117. ;in:
  118. * d0    scratch
  119. * d1    scratch
  120. * a0    scratch
  121. * a1    ato_SoftIntData
  122. * a5    scratch
  123. _PlayFuncMono:
  124.     pushm    d7/a2-a3/a6
  125.     move.l    a1,a2                ;a2 is later used as Hook object
  126.     move.l    ahiac_DriverData(a2),a5
  127.  
  128. * Swap Toccata buffer buffers and get pointer to one of them.
  129.     move.l    t_SampBuffer1(a5),TocBuffer
  130.     move.l    t_SampBuffer2(a5),t_SampBuffer1(a5)
  131.     move.l    TocBuffer,t_SampBuffer2(a5)
  132.  
  133. * TocSamplesCnt is number of samples left in Toccata buffer to fill.
  134.     move.l    t_TocSamples(a5),TocSamplesCnt
  135.  
  136. * t_MixSamplesCnt is uncopied samples left in mixing buffer
  137. .loop
  138.     tst.l    t_MixSamplesCnt(a5)
  139.     bne    .fillTocBuffer
  140.  
  141. * There are no unplayed samples in the mixing buffer. Fill it again!
  142.     move.l    ahiac_PlayerFunc(a2),a0
  143.     suba.l    a1,a1
  144.     move.l    h_Entry(a0),a3
  145.     jsr    (a3)                ;Call Player Hook
  146.     move.l    ahiac_MixerFunc(a2),a0
  147.     move.l    t_MixBuffer(a5),a1
  148.     move.l    h_Entry(a0),a3
  149.     jsr    (a3)                ;Call Mixer Hook
  150.  
  151.     move.l    ahiac_BuffSamples(a2),t_MixSamplesCnt(a5)
  152.     move.l    t_MixBuffer(a5),t_MixBufferPtr(a5)
  153.  
  154. .fillTocBuffer
  155.     move.l    t_MixSamplesCnt(a5),d0
  156.     sub.l    d0,TocSamplesCnt
  157.     bpl    .1
  158.     add.l    TocSamplesCnt,d0
  159.     moveq    #0,TocSamplesCnt
  160. .1
  161. * d0 is now how many samples should be copied before either the Toccata buffer
  162. * is full or the mixing is empty.
  163.  
  164.     sub.l    d0,t_MixSamplesCnt(a5)
  165.  
  166. * t_MixBufferPtr is the address (in the mixing buffer) where the next untouched
  167. * sample is located.
  168.     move.l    t_MixBufferPtr(a5),a0
  169.     lsr.l    #1,d0                ;Just unrolling...
  170.     bcs    .2
  171.     subq.l    #1,d0
  172. .transferLoop
  173.     move.w    (a0)+,(TocBuffer)+
  174. .2
  175.     move.w    (a0)+,(TocBuffer)+
  176.     dbf    d0,.transferLoop
  177.     move.l    a0,t_MixBufferPtr(a5)        ;Update pointer till next time
  178.     tst.l    TocSamplesCnt            ;Is Toccata buffer full now?
  179.     bne    .loop                ;Nope, loop.
  180.  
  181.     popm    d7/a2-a3/a6
  182.     rts
  183.  
  184.  
  185. _PlayFuncStereo:
  186.     pushm    d7/a2-a3/a6
  187.     move.l    a1,a2
  188.     move.l    ahiac_DriverData(a2),a5
  189.  
  190.     move.l    t_SampBuffer1(a5),TocBuffer
  191.     move.l    t_SampBuffer2(a5),t_SampBuffer1(a5)
  192.     move.l    TocBuffer,t_SampBuffer2(a5)
  193.  
  194.     move.l    t_TocSamples(a5),TocSamplesCnt
  195.  
  196. .loop
  197.     tst.l    t_MixSamplesCnt(a5)
  198.     bne    .fillTocBuffer
  199.  
  200.     move.l    ahiac_PlayerFunc(a2),a0
  201.     suba.l    a1,a1
  202.     move.l    h_Entry(a0),a3
  203.     jsr    (a3)
  204.     move.l    ahiac_MixerFunc(a2),a0
  205.     move.l    t_MixBuffer(a5),a1
  206.     move.l    h_Entry(a0),a3
  207.     jsr    (a3)
  208.  
  209.     move.l    ahiac_BuffSamples(a2),t_MixSamplesCnt(a5)
  210.     move.l    t_MixBuffer(a5),t_MixBufferPtr(a5)
  211.  
  212. .fillTocBuffer
  213.     move.l    t_MixSamplesCnt(a5),d0
  214.     sub.l    d0,TocSamplesCnt
  215.     bpl    .1
  216.     add.l    TocSamplesCnt,d0
  217.     moveq    #0,TocSamplesCnt
  218. .1
  219.     sub.l    d0,t_MixSamplesCnt(a5)
  220.     move.l    t_MixBufferPtr(a5),a0
  221.     lsr.l    #1,d0
  222.     bcs    .2
  223.     subq.l    #1,d0
  224. .transferLoop
  225.     move.l    (a0)+,(TocBuffer)+        ; 2 WORDs == left and right data
  226. .2
  227.     move.l    (a0)+,(TocBuffer)+
  228.     dbf    d0,.transferLoop
  229.     move.l    a0,t_MixBufferPtr(a5)
  230.     tst.l    TocSamplesCnt
  231.     bne    .loop
  232.  
  233.     popm    d7/a2-a3/a6
  234.     rts
  235.