home *** CD-ROM | disk | FTP | other *** search
/ Fujiology Archive / fujiology_archive_v1_0.iso / !FALCON / ABSTRACT / MEGPL116.ZIP / MGPL-116 / REPLAY / MGT-PLAY.ASM next >
Assembly Source File  |  1995-08-24  |  14KB  |  641 lines

  1. ;***********************************************************************
  2. ;***********                                         ***********
  3. ;***********                                         ***********
  4. ;***********          DSP-Replay MegaTracker v1.1             ***********
  5. ;***********                                         ***********
  6. ;***********                                         ***********
  7. ;***********           by Simplet / FATAL DESIGN             ***********
  8. ;***********                                         ***********
  9. ;***********************************************************************
  10.  
  11. ; The circular sample buffer must begin to an address multiple
  12. ; of the the first power of 2 greater than its size
  13. ; If you want an 50Hz VBL/Timer as maximum frequency,
  14. ; The size must be greater than :
  15. ; 2*984 for 49.1Khz, 2*656 for 32.8KHz, 2*492 for 24.5KHz, etc...
  16.  
  17. PBC        equ        $ffe0            ; Port B Control Register
  18. PCC        equ        $ffe1            ; Port C Control register
  19. HCR        equ        $ffe8            ; Host Control Register
  20. HSR        equ        $ffe9            ; Host Status Register
  21. HRX        equ        $ffeb            ; Host Receive Register
  22. HTX        equ        $ffeb            ; Host Transmit Register
  23. CRA        equ        $ffec            ; SSI Control Register A
  24. CRB        equ        $ffed            ; SSI Control Register B
  25. SSISR    equ        $ffee            ; SSI Status Register
  26. TX        equ        $ffef            ; SSI Serial Transmit data/shift register
  27. BCR        equ        $fffe            ; Port A Bus Control Register
  28. IPR        equ        $ffff            ; Interrupt Priority Register
  29.  
  30. ;    Host Control Register Bit Flags
  31.  
  32. HCIE        equ        2                ; Host Command Interrupt Enable
  33.  
  34. ;    Host Status Register Bit Flags
  35.  
  36. HRDF        equ        0                ; Host Receive Data Full
  37. HTDE        equ        1                ; Host Transmit Data Empty
  38.  
  39.  
  40.         org        p:$0
  41.         jmp        >Start
  42.  
  43.         org        p:$10
  44.         jsr        >Spl_Out
  45.         org        p:$12
  46.         jsr        >Spl_Out
  47.  
  48.         org        p:$26
  49.         jsr        >SoundTrack_Rout
  50.         org        p:$28
  51.         jsr        >Clear_Sample_Buffer
  52.  
  53. ; Interrupt Routine that plays the sound with the SSI
  54.  
  55.         org        p:$40
  56.  
  57. Spl_Out    jset        #<2,X:<<SSISR,Right_Out    ; detect the second transfer
  58.  
  59. Left_Out    movep    Y:(r7),X:<<TX
  60.         rti
  61. Right_Out    movep    X:(r7)+,X:<<TX
  62.         rti
  63.  
  64. ;
  65. ; It Begins here :
  66. ;
  67.  
  68. Start    movep    #1,X:<<PBC            ; Port B in Host
  69.         movep    #$1f8,X:<<PCC            ; Port C in SSI
  70.         movep    #$4100,X:<<CRA            ; 1 voice 16 bits Stereo
  71.         movep    #$5800,X:<<CRB            ; enable X-mit IT
  72.         movep    #$3800,X:<<IPR            ; SSI at IPL 3
  73.                                     ; and Host at IPL 2
  74.         bset        #<HCIE,X:<<HCR            ; enable Host Command ITs
  75.  
  76. ; Initialisation of Registers
  77.  
  78.         move        #-1,m0
  79.         move        #2048-1,m7
  80.         move        m0,m1
  81.         move        m7,m2
  82.         move        m0,m3
  83.         move        m0,m4
  84.         move        m0,m5
  85.         move        m7,m6
  86.  
  87. ; Clears the sample buffer
  88.         jsr        <Clear_Sample_Buffer
  89.  
  90. ; Verify the connexion with the 030
  91.  
  92. Conct_Get    jclr        #<HRDF,X:<<HSR,Conct_Get
  93.         movep    X:<<HRX,x0
  94.  
  95. Conct_Snd    jclr        #<HTDE,X:<<HSR,Conct_Snd
  96.         movep    #12345678,X:<<HTX
  97.  
  98. ; Enable interrupts (IPL0) and waits
  99.         move        #Sample_Buffer,r7
  100.         andi        #<%11111100,mr
  101. Loop        jmp        <Loop
  102.  
  103. ;
  104. ; Sound-Tracker Routine in Host Command
  105. ;
  106.  
  107. SoundTrack_Rout
  108.         jclr        #<HTDE,X:<<HSR,SoundTrack_Rout
  109.         movep    #'MGT',X:<<HTX
  110.  
  111.         move        #<Length,r0
  112.  
  113.         move        X:<Old_Adr,x0            ; Number of Samples
  114.         move        x0,X:<Calc_Adr            ; to calculate = Current Pos
  115.         move        r7,a                    ; - Old Position
  116.         sub        x0,a            r7,X:Old_Adr
  117.         jpl        <Length_Ok
  118.         move        #>2048,x0                ; Warning Modulo !
  119.         add        x0,a
  120. Length_Ok    move        a,X:(r0)+                ; Sample Length
  121.  
  122. ; Gets the Master Volumes
  123.         move        #>$0000ff,x1
  124.         move        #>$008000,y1
  125.  
  126. Get_MVol    jclr        #<HRDF,X:<<HSR,Get_MVol
  127.         movep    X:<<HRX,a
  128.         and        x1,a            a,x0
  129.         mpy        y1,x0,a        a,X:(r0)+        ; Right Master Volume
  130.         move                    a,X:(r0)+        ; Left Master Volume
  131.  
  132. Get_GVol    jclr        #<HRDF,X:<<HSR,Get_GVol
  133.         movep    X:<<HRX,X:(r0)+            ; Global Volume
  134.  
  135. ; Gets the number of Voices
  136.  
  137. Get_NbV    jclr        #<HRDF,X:<<HSR,Get_NbV
  138.         movep    X:<<HRX,y0
  139.         move        #>1024,x0
  140.         mpy        x0,y0,a    #>2,b
  141.         add        y0,b        a0,x0        ; b = Nb Voies + 2 voies FX
  142.  
  143.         move        #>1,a
  144.         andi        #<$fe,ccr                ; Cancel Carry Bit
  145.         Rep        #<24
  146.         div        x0,a                    ; a0 = 1 / (1024 * Nb Voices)
  147.         move        a0,X:(r0)
  148.  
  149. ; Clears the sample-buffer before mixing
  150.         clr        a        X:Calc_Adr,r6
  151.  
  152.         move        X:Length,x0
  153.         Do        x0,Clear_Sample
  154.         move        a,L:(r6)+
  155. Clear_Sample
  156.  
  157. ; Mix All Voices
  158.         move        #Voices_Frac,r1
  159.  
  160.         Do        b,Mix_All_Voices_Loop
  161.  
  162. ; Calls the 030
  163. Request    jclr        #<HTDE,X:<<HSR,Request
  164.         movep    #-1,X:<<HTX
  165.  
  166. ; Receives the voices' info
  167.  
  168. Receive_Voice
  169.         move        #<Voice_Vol_R,r0
  170.         move        #>$0000ff,x1
  171.         move        #>$000080,y0
  172.         move        #>$008000,y1
  173. Receive_Pan
  174.         jclr        #<HRDF,X:<<HSR,Receive_Pan
  175.         movep    X:<<HRX,a
  176.         tst        a
  177.         jeq        <Next_Voice
  178.         and        x1,a            a1,x0
  179.         mpy        y1,x0,a        a1,X:(r0)+    ; Voice Right Volume
  180.         and        x1,a            X:<Length,b
  181.         mpy        y0,x0,a        a1,X:(r0)+    ; Voice Left Volume
  182.         lsl        b            a1,X:(r0)+    ; Voice Attributes
  183. Receive_Volume
  184.         jclr        #<HRDF,X:<<HSR,Receive_Volume
  185.         movep    X:<<HRX,X:(r0)+            ; Sample Volume
  186. Receive_Frequence
  187.         jclr        #<HRDF,X:<<HSR,Receive_Frequence
  188.         movep    X:<<HRX,a                    ; Sample Frequence
  189.         tst        a        a,x0
  190.         jne        <Receive_Ordinary_Voice
  191.  
  192. ; The sample frequency is greater than the replay frequency
  193.  
  194.         jsr        <Treat_030_Voice
  195.         jmp        <Next_Voice
  196.  
  197. ; The sample frequency is lower than the replay frequency
  198.  
  199. Receive_Ordinary_Voice
  200.         clr        b            b,x1
  201.         move        X:(r1),b0                    ; Frac Part
  202.         mac        x0,x1,b        x0,X:(r0)
  203. Send_Length
  204.         jclr        #<HTDE,X:<<HSR,Send_Length    ; Length of Sample
  205.         movep    b,X:<<HTX                    ; played in this frame
  206.  
  207.         jsr        <Treat_Ordinary_Voice
  208.  
  209. Next_Voice
  210.         lua        (r1)+,r1
  211. Mix_All_Voices_Loop
  212.  
  213. ; It's Finished for this time
  214. Send_End    jclr        #<HTDE,X:<<HSR,Send_End
  215.         movep    #0,X:<<HTX
  216.         rti
  217.  
  218.  
  219. ; Routine that mixes a new voice on the left channel
  220.  
  221. Mix_Voice_Left
  222.         move        #Sample,r0
  223.         move        X:<Calc_Adr,r6        ; Adress
  224.         move        X:<Voice_Vol_L,x1    ; Left Volume
  225.  
  226.         move        #>2,y0
  227.         move        X:<Voice_Freq,y1    ; Frequence
  228.         move        r0,b
  229.         move        X:(r1),b0            ; Frac
  230.  
  231.         Do        X:<Length,Mix_Voice_Left_Loop
  232.  
  233.         mac        y0,y1,b        Y:(r6),a        X:(r0),x0
  234.         mac        x0,x1,a        b,r0
  235.         move                    a,Y:(r6)+
  236.  
  237. Mix_Voice_Left_Loop
  238.         move        b0,X:(r1)            ; Frac
  239.         rts
  240.  
  241. ; Routine that mixes a new voice on the right channel
  242.  
  243. Mix_Voice_Right
  244.         move        #Sample,r0
  245.         move        X:<Calc_Adr,r6        ; Adress
  246.         move        X:<Voice_Vol_R,y1    ; Right Volume
  247.  
  248.         move        #>2,x0
  249.         move        X:<Voice_Freq,x1    ; Frequence
  250.         move        r0,a
  251.         move        X:(r1),a0            ; Frac
  252.  
  253.         Do        X:<Length,Mix_Voice_Right_Loop
  254.  
  255.         mac        x0,x1,a        X:(r6),b        Y:(r0),y0
  256.         mac        y0,y1,b        a,r0
  257.         move                    b,X:(r6)+
  258.  
  259. Mix_Voice_Right_Loop
  260.         move        a0,X:(r1)            ; Frac
  261.         rts
  262.  
  263. ; Routine that mixes a new voice on both channels
  264.  
  265. Mix_Voice    move        #Sample,r0
  266.         move        X:<Calc_Adr,r6        ; Adress
  267.         move        #<Voice_Vol_R,r4    ; Right Volume
  268.         move        r6,r2
  269.         move        X:(r4)+,x1
  270.         move        X:<Voice_Freq,y1    ; Frequence
  271.  
  272.         move        #>2,x0
  273.         move        r0,b
  274.         move        X:(r1),b0            ; Frac
  275.  
  276.         Do        X:<Length,Mix_Voice_Loop
  277.  
  278.         mac        x0,y1,b        X:(r6),a        Y:(r0),y0
  279.         mac        y0,x1,a        X:(r4)-,x1
  280.         move                    Y:(r2),a        a,X:(r6)+
  281.         mac        y0,x1,a        b,r0
  282.         move                    X:(r4)+,x1    a,Y:(r2)+
  283.  
  284. Mix_Voice_Loop
  285.         move        b0,X:(r1)            ; Frac
  286.         rts
  287.  
  288. ; The sample frequency is greater than the replay frequency
  289. ; then the 030 sends us only the necessary amount of samples
  290. ; by making the frequency calc, and the DSP only mix it
  291.  
  292. Treat_030_Voice
  293.         jsr        <Calc_Volumes
  294.  
  295.         move        #>$000080,x1
  296.  
  297.         move        X:<Length,b
  298.         move        #>1,x0
  299.         sub        x0,b        X:<Calc_Adr,r6
  300.  
  301.         move        X:<Voice_Atrbts,a
  302.         btst        #<2,a
  303.         jcs        <Treat_030_16_Bits_Voice
  304.         btst        #<3,a
  305.         jcs        <Treat_030_8_Bits_Stereo_Voice
  306.  
  307. Treat_030_8_Bits_Mono_Voice
  308.         move        X:<Length,b
  309.         add        x0,b
  310.         lsr        b
  311.         sub        x0,b        b,y0
  312.         jclr        #<HTDE,X:<<HSR,Treat_030_8_Bits_Mono_Voice
  313.         movep    b,X:<<HTX
  314.  
  315.         move        #>$008000,y1
  316.         move        r6,r2
  317.         move        #<Voice_Vol_R,r5
  318.         move        #<Dummy,r3
  319.  
  320.         move        Y:-(r2),a
  321.  
  322.         Do        y0,Treat_030_8_Bits_Mono_Voice_Loop
  323.  
  324.         jclr        #<HRDF,X:<<HSR,*
  325.         movep    X:<<HRX,Y:(r3)
  326.  
  327.         move                    X:(r5)+,x0    Y:(r3),y0
  328.         mpy        y0,x1,a        X:(r6),b        a,Y:(r2)+
  329.         move        a0,y0
  330.         mac        y0,x0,b        X:(r5)-,x0    Y:(r2),a
  331.         mac        y0,x0,a        b,X:(r6)+
  332.  
  333.         move                    X:(r5)+,x0    Y:(r3),y0
  334.         mpy        y0,y1,a        X:(r6),b        a,Y:(r2)+
  335.         move        a0,y0
  336.         mac        y0,x0,b        X:(r5)-,x0    Y:(r2),a
  337.         mac        y0,x0,a        b,X:(r6)+
  338.  
  339. Treat_030_8_Bits_Mono_Voice_Loop
  340.         rts
  341.  
  342. Treat_030_8_Bits_Stereo_Voice
  343.         jclr        #<HTDE,X:<<HSR,Treat_030_8_Bits_Stereo_Voice
  344.         movep    b,X:<<HTX
  345.  
  346.         move        #>$008000,y1
  347.         move        r6,r2
  348.         move        #<Voice_Vol_L,r5
  349.         move        #<Dummy,r3
  350.  
  351.         move        #>$7fffff,y0
  352.         move        X:-(r6),x0
  353.         Do        X:Length,Treat_030_8_Bits_Stereo_Voice_Loop
  354.  
  355.         jclr        #<HRDF,X:<<HSR,*
  356.         movep    X:<<HRX,Y:(r3)
  357.         mac        y0,x0,b        X:(r5)-,x0    Y:(r3),y0
  358.         mpy        y0,x1,a        Y:(r2),b        b,X:(r6)+
  359.         move        a0,y0
  360.         mac        y0,x0,b        X:(r5)+,x0    Y:(r3),y0
  361.         mpy        y0,y1,a        X:(r6),b        b,Y:(r2)+
  362.         move        a0,y0
  363.  
  364. Treat_030_8_Bits_Stereo_Voice_Loop
  365.         mac        y0,x0,b
  366.         move        b,X:(r6)+
  367.         rts
  368.  
  369. Treat_030_16_Bits_Voice
  370.         btst        #<3,a
  371.         jcs        <Treat_030_16_Bits_Stereo_Voice
  372.  
  373. Treat_030_16_Bits_Mono_Voice
  374.         jclr        #<HTDE,X:<<HSR,Treat_030_16_Bits_Mono_Voice
  375.         movep    b,X:<<HTX
  376.  
  377.         move        X:<Voice_Vol_L,y0
  378.         move        X:<Voice_Vol_R,y1
  379.  
  380.         Do        X:Length,Treat_030_16_Bits_Mono_Voice_Loop
  381.  
  382.         jclr        #<HRDF,X:<<HSR,*
  383.         movep    X:<<HRX,x0
  384.         mpy        x0,x1,a        Y:(r6),b
  385.         move        a0,x0
  386.         mac        x0,y0,b        X:(r6),a
  387.         mac        x0,y1,a        b,Y:(r6)
  388.         move                    a,X:(r6)+
  389. Treat_030_16_Bits_Mono_Voice_Loop
  390.         rts
  391.  
  392. Treat_030_16_Bits_Stereo_Voice
  393.         jclr        #<HTDE,X:<<HSR,Treat_030_16_Bits_Stereo_Voice
  394.         movep    b,X:<<HTX
  395.  
  396.         move        X:<Voice_Vol_L,y0
  397.         move        X:<Voice_Vol_R,y1
  398.  
  399.         Do        X:Length,Treat_030_16_Bits_Stereo_Voice_Loop
  400.  
  401.         jclr        #<HRDF,X:<<HSR,*
  402.         movep    X:<<HRX,x0
  403.         mpy        x0,x1,a        Y:(r6),b
  404.         move        a0,x0
  405.         mac        x0,y0,b        X:(r6),a
  406.         jclr        #<HRDF,X:<<HSR,*
  407.         movep    X:<<HRX,x0
  408.         mpy        x0,x1,b        b,Y:(r6)
  409.         move        b0,x0
  410.         mac        x0,y1,a
  411.         move                    a,X:(r6)+
  412. Treat_030_16_Bits_Stereo_Voice_Loop
  413.         rts
  414.  
  415.  
  416. ; Routine that calculates the Volumes
  417.  
  418. Calc_Volumes
  419.         move        #<Voice_Vol_R,r0
  420.         move        X:<Voice_Volume,x0
  421.         move        X:<Global_Vol,x1
  422.         mpy        x0,x1,a            X:<Nb_Voices,x1
  423.         move        a0,x0
  424.         mpy        x0,x1,a
  425.         move        a,x0                ; Global Volume / 1024
  426.                                 ; * Voice Volume / Nb Voices
  427.  
  428.         move        X:(r0)+,y0
  429.         mpy        x0,y0,a
  430.         asr        a        X:<Master_Vol_R,y1
  431.         move        a0,y0
  432.         mpy        y0,y1,a    X:(r0)-,y0
  433.         mpy        x0,y0,b    a0,X:(r0)+
  434.         asr        b        X:<Master_Vol_L,y1
  435.         move        b0,y0
  436.         mpy        y0,y1,b
  437.         move        b0,X:(r0)
  438.         rts
  439.  
  440. ; The sample frequency is lower than the replay frequency
  441. ; we receive the sample in DSP memory
  442. ; and makes the frequency calcul and mix it
  443.  
  444. Treat_Ordinary_Voice
  445.         move        X:<Voice_Atrbts,a
  446.         btst        #<3,a
  447.         jcs        <Treat_Stereo_Voice
  448.  
  449. Treat_Mono_Voice
  450.         move        X:<Voice_Vol_L,a
  451.         tst        a
  452.         jeq        <Treat_Mono_Right_Voice
  453.         move        X:<Voice_Vol_R,a
  454.         tst        a
  455.         jeq        <Treat_Mono_Left_Voice
  456.  
  457.         jsr        <Receive_Y_Samples
  458.         jsr        <Calc_Volumes
  459.         jmp        <Mix_Voice
  460.  
  461. Treat_Mono_Left_Voice
  462.         jsr        <Receive_X_Samples
  463.         jsr        <Calc_Volumes
  464.         jmp        <Mix_Voice_Left
  465.  
  466. Treat_Mono_Right_Voice
  467.         jsr        <Receive_Y_Samples
  468.         jsr        <Calc_Volumes
  469.         jmp        <Mix_Voice_Right
  470.  
  471. Treat_Stereo_Voice
  472.         jsr        <Receive_Stereo_Samples
  473.         jsr        <Calc_Volumes
  474.         jsr        <Mix_Voice_Left
  475.         jmp        <Mix_Voice_Right
  476.  
  477.  
  478. ; Routines that receive 8/16 bits mono samples in X memory
  479.  
  480. Receive_X_Samples
  481.         move        X:<Voice_Atrbts,a
  482.         btst        #<2,a
  483.         jcs        <Receive_X_Samples_16
  484.  
  485. Receive_X_Samples_8
  486.         move        #Sample+1,r0
  487.         move        #>$ff0000,x1
  488.  
  489.         move        #>1,a
  490.         addr        a,b            #3,n0
  491.  
  492.         Do        b,Receive_X_Loop_8
  493. Receive_X_Sample_8
  494.         jclr        #<HRDF,X:<<HSR,Receive_X_Sample_8
  495.         movep    X:<<HRX,x0
  496.         mpy        y0,x0,a
  497.         mpy        y1,x0,a        a0,b
  498.         and        x1,b            a0,X:(r0)-
  499.         move        b1,X:(r0)+n0
  500. Receive_X_Loop_8
  501.         rts
  502.  
  503. Receive_X_Samples_16
  504.         move        #>1,a
  505.         add        a,b            #Sample,r0
  506.  
  507.         Do        b,Receive_X_Loop_16
  508. Receive_X_Sample_16
  509.         jclr        #<HRDF,X:<<HSR,Receive_X_Sample_16
  510.         movep    X:<<HRX,x0
  511.         mpy        y0,x0,a
  512.         move        a0,X:(r0)+
  513. Receive_X_Loop_16
  514.         rts
  515.  
  516. ; Routines that receive 8/16 bits mono samples in Y memory
  517.  
  518. Receive_Y_Samples
  519.         move        X:<Voice_Atrbts,a
  520.         btst        #<2,a
  521.         jcs        <Receive_Y_Samples_16
  522.  
  523. Receive_Y_Samples_8
  524.         move        #Sample+1,r0
  525.         move        #>$ff0000,x1
  526.  
  527.         move        #>1,a
  528.         addr        a,b            #3,n0
  529.  
  530.         Do        b,Receive_Y_Loop_8
  531. Receive_Y_Sample_8
  532.         jclr        #<HRDF,X:<<HSR,Receive_Y_Sample_8
  533.         movep    X:<<HRX,x0
  534.         mpy        y0,x0,a
  535.         mpy        y1,x0,a        a0,b
  536.         and        x1,b            a0,Y:(r0)-
  537.         move        b1,Y:(r0)+n0
  538. Receive_Y_Loop_8
  539.         rts
  540.  
  541. Receive_Y_Samples_16
  542.         move        #>1,a
  543.         add        a,b            #Sample,r0
  544.  
  545.         Do        b,Receive_Y_Loop_16
  546. Receive_Y_Sample_16
  547.         jclr        #<HRDF,X:<<HSR,Receive_Y_Sample_16
  548.         movep    X:<<HRX,x0
  549.         mpy        y0,x0,a
  550.         move        a0,Y:(r0)+
  551. Receive_Y_Loop_16
  552.         rts
  553.  
  554. ; Routines that receive 8/16 bits stereo samples
  555.  
  556. Receive_Stereo_Samples
  557.         move        X:<Voice_Atrbts,a
  558.         btst        #<2,a
  559.         jcs        <Receive_Stereo_Samples_16
  560.  
  561. Receive_Stereo_Samples_8
  562.         move        #>$ff0000,x1
  563.         move        #>1,a
  564.         add        a,b            #Sample,r0
  565.  
  566.         Do        b,Receive_Stereo_Loop_8
  567. Receive_Stereo_Sample_8
  568.         jclr        #<HRDF,X:<<HSR,Receive_Stereo_Sample_8
  569.         movep    X:<<HRX,x0
  570.         mpy        y0,x0,a
  571.         mpy        y1,x0,a        a0,b
  572.         and        x1,b            a0,X:(r0)        ; Right
  573.         move        b1,Y:(r0)+                ; Left
  574. Receive_Stereo_Loop_8
  575.         rts
  576.  
  577. Receive_Stereo_Samples_16
  578.         move        #>1,a
  579.         add        a,b            #Sample,r0
  580.  
  581.         Do        b,Receive_Stereo_Loop_16
  582. Receive_Left_Sample_16
  583.         jclr        #<HRDF,X:<<HSR,Receive_Left_Sample_16
  584.         movep    X:<<HRX,x0
  585.         mpy        y0,x0,a
  586.         move        a0,Y:(r0)
  587. Receive_Right_Sample_16
  588.         jclr        #<HRDF,X:<<HSR,Receive_Right_Sample_16
  589.         movep    X:<<HRX,x0
  590.         mpy        y0,x0,a
  591.         move        a0,X:(r0)+
  592. Receive_Stereo_Loop_16
  593.         rts
  594.  
  595. ;
  596. ; Clears the sample buffer
  597. ;
  598.  
  599. Clear_Sample_Buffer
  600.         move        a,X:<Save_a
  601.         move        r0,X:<Save_r0
  602.         clr        a        #Sample_Buffer,r0
  603.         Do        #<2048,Clear_Sample_Buffer_Loop
  604.         move        a,L:(r0)+
  605. Clear_Sample_Buffer_Loop
  606.         move        X:<Save_a,a
  607.         move        X:<Save_r0,r0
  608.         rti
  609.  
  610. ; Data Zone
  611.  
  612.             org        X:0
  613.  
  614. Old_Adr        DC        Sample_Buffer
  615. Calc_Adr        DS        1
  616. Length        DS        1
  617. Master_Vol_R    DS        1
  618. Master_Vol_L    DS        1
  619. Global_Vol    DS        1
  620. Nb_Voices        DS        1
  621. Voice_Vol_R    DS        1
  622. Voice_Vol_L    DS        1
  623. Voice_Atrbts    DS        1
  624. Voice_Volume    DS        1
  625. Voice_Freq    DS        1
  626. Voices_Frac    DS        34
  627. Save_r0        DS        1
  628. Save_a        DS        1
  629.  
  630.             org        Y:0
  631.  
  632. Dummy        DS        1
  633.  
  634.             org        L:6*2048
  635.  
  636. Sample_Buffer    DS        2048
  637.  
  638. Sample        DS        1500
  639.  
  640.             END
  641.