home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / mods / misc / benrpl.lha / BenRPL.s < prev   
Encoding:
Text File  |  1992-09-02  |  34.5 KB  |  1,449 lines

  1.  
  2.     SECTION    BenReplay,CODE
  3.  
  4.     movem.l    d1-a6,-(sp)
  5.  
  6.     move.l    (execbase).w,a6
  7.     jsr    forbid(a6)
  8.  
  9.     move.w    $dff01c,d0
  10.     or.w    #$8000,d0
  11.     move.w    d0,OldIntena
  12.     move.w    #$7fff,$dff09a
  13.     move.w    #$e020,$dff09a
  14.  
  15.     bsr.w    Br_GetVBR
  16.  
  17.     lea    Mod,a0
  18.     bsr.w    Br_Init
  19.     beq.b    End
  20.     bsr.w    Br_Start
  21.  
  22.     move.w    #1,Br_FadeVolume    ; Fade in
  23.  
  24. Click:    btst    #6,$bfe001
  25.     bne.b    Click
  26.  
  27.     move.w    #-1,Br_FadeVolume    ; Fade end
  28. .Wait:
  29.     tst.w    Br_MasterVolume
  30.     bne.b    .Wait
  31.  
  32.     bsr.w    Br_End
  33.  
  34. End:
  35.     move.w    OldIntena(pc),$dff09a
  36.  
  37.     move.l    (execbase).w,a6
  38.     jsr    permit(a6)
  39.  
  40.     movem.l    (sp)+,d1-a6
  41.     rts
  42.  
  43. OldIntena:    dc.w    0
  44.  
  45. forbid        = -30-102
  46. permit        = -30-108
  47. execbase    = 4
  48.  
  49.     *********************************************************
  50.     *              * BEN REPLAY V1.0 beta *        *
  51.     *               Release date :            *
  52.     *            25.11.94, 20:35 pm...        *
  53.     *        Coded by BEN from Melting Pot        *
  54.     *********************************************************
  55.  
  56.     *********************************************************
  57.     *                            *
  58.     * This replay supports :                *
  59.     *                            *
  60.     *    - Finetuned samples                *
  61.     *    - Master volume control    with fade        *
  62.     *    - CIA Timing                    *
  63.     *    - VBR anywhere and PC independant...        *
  64.     *    0  -                  Arpeggio        *
  65.     *    12 -            Slide Tune Up/Down        *
  66.     *    3  -               Tone Portamento        *
  67.     *    4  -        Vibrato (a bit crashed...)        *
  68.     *    5  -         Portamento + Volume Slide        *
  69.     *    6  -        Vibrato + Volume Slide        *
  70.     *    9  -             Sample Offset        *
  71.     *    A  -              Volume Slide        *
  72.     *    B  -             Pattern Break        *
  73.     *    C  -                Set Volume        *
  74.     *    D  -             Jump Position        *
  75.     *    F  -                 Set Speed        *
  76.     *    E0 -                Set Filter        *
  77.     *    E12-           Fine Slide Tune Up/Down        *
  78.     *    E6 -              Loop Pattern        *
  79.     *    E9 -               Retrig Note        *
  80.     *    EAB-           Fine Volume Up/Down        *
  81.     *    EC -                  Note Cut        *
  82.     *    ED -                Note Delay        *
  83.     *    EE -             Pattern Delay        *
  84.     *                            *
  85.     *     All other effects will NEVER be implemented    *
  86.     *      because nobody uses them, and I don't want    *
  87.     *       to have more and more headaches...        *
  88.     *                            *
  89.     *    It takes about 4 scans maximum on A1200...    *
  90.     *    and much better if you've got some real FAST...    *
  91.     *                            *
  92.     *    This replay is a freeware, but if you like    *
  93.     *      it and you use it, or if you find bugs, just    *
  94.     *      write a nice letter (anything that looks like    *
  95.     *    paper) and you'll certainly get an answer.    *
  96.     *    In fact, this is a sort of PostCardware...    *
  97.     *    Anyway, you will be registered, by the will    *
  98.     *    of God...                    *
  99.     *      You also may send money... (joke, coz        *
  100.     *     I really hate those democoders who sell their    *
  101.     *      routines and other stuffs... Just lamers...)    *
  102.     *      At least, I think there are still many bugs,    *
  103.     *    so SEND me bugs report PLEEEEEAAAASE !!!    *
  104.     *                            *
  105.     *        Write to:                *
  106.     *            Benjamin LEGROS            *
  107.     *           106 rue Alexandre DETROY        *
  108.     *           59650 VILLENEUVE D'ASCQ        *
  109.     *                FRANCE            *
  110.     *                            *
  111.     * La direction décline tout responsabilité dans le cas    *
  112.     * de dommages causés par la présente routine, due à une    *
  113.     *     utilisation abusive de drogues et autres    *
  114.     *    hallucinogènes. Nous vous prions de bien vouloir    *
  115.     *     tirer la chasse d'eau en partant, et nous vous    *
  116.     *         souhaitons un agréable voyage...        *
  117.     *                            *
  118.     *                To be continued...    *
  119.     *                            *
  120.     *********************************************************
  121.  
  122.     *********************************************************
  123.     *                            *
  124.     *        How to use it ??            *
  125.     *    First, just BSR Br_Init after putting the    *
  126.     *     31 SAMPLES PROTRACKER module address in    *
  127.     *    a0 (lea    mod,a0)...                *
  128.     *    Then, when you want the module to start,    *
  129.     *    just BSR Br_Start. As it use CIA timing,    *
  130.     *    you don't have to execute the replay each    *
  131.     *     vblank... But you MUSTN'T USE TIMERS A        *
  132.     *   of the CIA-B, coz I use timer A... (anyway, don't    *
  133.     *    use CIA...)                    *
  134.     *     By the way, you have to set Level6 and master    *
  135.     *        interruptionbits in Intena ($9A).        *
  136.     *       To stop the replay, just BSR Br_End.        *
  137.     *                            *
  138.     *    You can momently stop the replay by setting    *
  139.     *     Br_PlayEna to 0. Restart the replay using    *
  140.     *    BSR Br_Start...                    *
  141.     *                            *
  142.     *     The volume control option is enabled by    *
  143.     *     setting the Br_MasterVolumeControl option    *
  144.     *    to 1 And then, move Br_MasterVolume from 0 to 64    *
  145.     *                            *
  146.     *    Br_Voice should be used if your module use    *
  147.     *      1, 2 or 3 channels (like games using SFX...)    *
  148.     *    For speedup reasons, you MUST use lower channels    *
  149.     *     (channels 1&2 for 2 channels module), and you    *
  150.     *    MUSTN'T use any effect on non-played channel(s)    *
  151.     *                            *
  152.     *      To make this routine play-able on A4000 where    *
  153.     *    VBR may be anywhere in (FAST)ram, just check    *
  154.     *        it and put it in Br_VBR, or simply call    *
  155.     *        BSR_GetVBR...                *
  156.     *                            *
  157.     *     The Converted Module player is also available    *
  158.     *            Write me !!            *
  159.     *                            *
  160.     *********************************************************
  161.  
  162. Br_MasterVolumeControl        = 1
  163. Br_Volume            = 0
  164. Br_Voice            = 4
  165. Br_TempoInit            = 125
  166. Br_FrameValue            = 14290*125    ; Frame time in CIA ticks*125
  167. Br_ReplayTime            = $180*2+180    ; about A1200 value...
  168.  
  169. *****************************************************************************
  170. Br_Start:********************************************************************
  171.     movem.l    a2/a3,-(sp)
  172.     lea    Br_Play(pc),a3
  173.     move.l    Br_VBR(pc),a2
  174.     move.w    #$400,$dff096
  175.     move.l    a3,$78(a2)
  176.     move.w    #$e020,$dff09a
  177.  
  178.     lea    $bfd000,a3
  179.  
  180.     move.b    #$7e,$d00(a3)    ; disable all timings & alarms
  181.     move.b    #$08,$e00(a3)    ; one-shot mode
  182.     move.b    #(Br_FrameValue/Br_TempoInit-Br_ReplayTime)>>8,$500(a3)    ; high
  183.     move.b    #(Br_FrameValue/Br_TempoInit-Br_ReplayTime)&$ff,$400(a3); Low
  184.  
  185. .Wait:    btst    #0,$d00(a3)    ; Repeat until no alarm A
  186.     beq.b    .Wait
  187.     move.b    #$81,$d00(a3)    ; init Timer A
  188.     move.w    #$2000,$dff09c
  189.  
  190. .Wbl1:    cmp.b    #$ff,$dff006    ; Wait good sync
  191.     bne.b    .Wbl1        ; for modules using VBLANK timer...
  192. .Wbl2:    cmp.b    #$0,$dff006    ; (tempo=125)
  193.     bne.b    .Wbl2
  194. .Wbl3:    cmp.b    #$0,$dff006
  195.     beq.b    .Wbl3
  196. .Wbl4:    cmp.b    #$0,$dff006
  197.     bne.b    .Wbl4
  198.     move.b    #$19,$e00(a3)    ; Start CIA
  199.     movem.l    (sp)+,a2/a3
  200.     rts
  201.  
  202. *****************************************************************************
  203. Br_Play:*********************************************************************
  204.     movem.l    d0-a6,-(sp)
  205.     tst.b    $bfdd00
  206.     lea    Br_Infos(pc),a0
  207.     tst.w    (a0)
  208.     beq.w    Br_DontPlay
  209.     move.l    #$80000000,Br_DMACON-Br_Infos(a0)
  210.     move.l    Br_Pattern(pc),a1
  211.     lea    Br_ChannelInfo(pc),a2
  212.     lea    Br_SampleInfos(pc),a3
  213.     lea    Br_EffectNo(pc),a6
  214.     lea    $dff0a0,a5
  215.     move.w    #$400,$096-$0a0(a5)    ; Force blitter priority
  216.     moveq    #1,d6            ; DMA
  217.     moveq    #Br_Voice-1,d7
  218.  
  219.     tst.w    Br_Counter-Br_Infos(a0)
  220.     bne.w    Br_PlayOldNote
  221.  
  222. Br_PlayNewNote:
  223.     moveq    #0,d5    ; Sample Check
  224.  
  225.     move.b    (a1),d0                ; D0 = Sample
  226.     move.w    (a1)+,d1            ; D1 = Note
  227.     beq.b    .Br_PlayNewCheckEffect
  228.  
  229.     ext.w    d0                *** Check SampleDatas ***
  230.     beq.b    .Br_PlayNewDontChangeVolume
  231.     subq.w    #1,d0
  232.     lsl.w    #5,d0
  233.     move.w    d0,Br_ChOldSample(a2)
  234.     move.l    a3,d2
  235.     lea    Br_ChVol+1(a2),a4
  236.     lea    Br_SplVol(a3,d0.w),a3
  237.     move.b    (a3)+,(a4)+        ; Volume
  238.     move.l    (a3)+,(a4)+        ; Address
  239.     move.l    (a3)+,(a4)+        ; RepeatPoint
  240.     move.l    (a3)+,(a4)+        ; Length & Loop
  241.     move.l    d2,a3
  242.  
  243. .Br_PlayNewDontChangeVolume:            *** Check period & address ***
  244.     and.w    #$ff,d1
  245.     beq.b    .Br_PlayNewCheckEffect
  246.  
  247.     move.w    Br_ChOldSample(a2),d0
  248.     clr.w    Br_ChPortDest(a2)
  249.     subq.w    #2,d1
  250.     move.w    d1,Br_ChNote(a2)
  251.     move.l    Br_SplFineTablePtr(a3,d0.w),a4
  252.     move.w    (a2),Br_ChPortSource(a2) ; Br_ChPer
  253.     move.w    (a4,d1.w),(a2) ; Br_ChPer
  254.  
  255.     tst.w    Br_PtrnDelay-Br_Infos(a0)    ; Si pattern delay, pas jouer
  256.     bne.b    .Br_PlayNewCheckEffect        ; nouveau sample, mais garde
  257.                         ; la periode et autres...
  258.  
  259.     moveq    #-1,d5    ; Test ok
  260.  
  261. .Br_PlayNewCheckEffect:                *** Check effect ***
  262.     move.b    (a1),d0                ; D0 = Effect
  263.     ext.w    d0
  264.     move.w    (a1)+,d1            ; D1 = Command
  265.     move.w    d1,Br_ChEff(a2)
  266.     beq.b    .Br_PlayNewCheckNoEffect
  267.     move.w    .Br_EffectTable1(pc,d0.w),d0
  268.     jsr    (a6,d0.w)            ; A6 = Br_EffectNo
  269.     bra.b    .Br_PlayNewCheckNoEffect
  270.  
  271. .Br_EffectTable1:    ; Effets à la 1ère frame
  272.     dc.w    Br_PrepArpeggio-Br_EffectNo    ; 0-Arpeggio
  273.     dc.w    Br_EffectNo-Br_EffectNo        ; 1-Tune Up
  274.     dc.w    Br_EffectNo-Br_EffectNo        ; 2-Tune Down
  275.     dc.w    Br_PrepPortamento-Br_EffectNo    ; 3-Portamento
  276.     dc.w    Br_PrepVibrato-Br_EffectNo    ; 4-Vibrato
  277.     dc.w    Br_PrepPortVolSlide-Br_EffectNo    ; 5-Portamento + Volume Slide
  278.     dc.w    Br_PrepVibrVolSlide-Br_EffectNo    ; 6-Vibrato + Volume Slide
  279.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 7 Tremolo
  280.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 8 
  281.     dc.w    Br_SampleOffset-Br_EffectNo    ; 9-Sample Offset
  282.     dc.w    Br_EffectNo-Br_EffectNo        ; A-Volume Slide
  283.     dc.w    Br_BreakSong-Br_EffectNo    ; B-Break Song
  284.     dc.w    Br_SetVolume-Br_EffectNo    ; C-Set Volume
  285.     dc.w    Br_BreakPattern-Br_EffectNo    ; D-Break Pattern
  286.     dc.w    Br_ECommands1-Br_EffectNo    ; E Others
  287.     dc.w    Br_SetSpeed-Br_EffectNo        ; F-Set Speed
  288.  
  289. .Br_PlayNewCheckNoEffect:
  290.     tst.w    d5    ; Check ok?
  291.     beq.b    .Br_PlayDontResetRegisters
  292.     bpl.b    .Br_PlayNoPer        ; Delay
  293.     move.w    d6,$dff096            ; DMACON
  294.     or.w    d6,Br_DMACON-Br_Infos(a0)
  295.     move.l    Br_ChAdr(a2),(a5)
  296.     move.w    Br_ChLen(a2),4(a5)
  297. ;    bra.b    .Br_PlayPer        ; <-----.
  298. .Br_PlayDontResetRegisters:        ;       |
  299. ;    move.b    Br_ChEff(a2),d0        ; <- Pas utile...
  300. ;    or.b    #%100,d0        ; <-----|
  301. ;    cmp.b    #12,d0            ; <-----|
  302. ;    beq.b    .Br_PlayNoPer        ; <-----'
  303. .Br_PlayPer:
  304.     move.w    (a2),6(a5) ; Br_ChPer
  305. .Br_PlayNoPer:
  306.     IFNE    Br_MasterVolumeControl
  307.     move.w    Br_ChVol(a2),d0
  308.     mulu.w    Br_MasterVolume-Br_Infos(a0),d0
  309.     lsr.w    #6,d0
  310.     move.w    d0,8(a5)
  311.     ELSE
  312.     move.w    Br_ChVol(a2),8(a5)
  313.     ENDC
  314.  
  315.     lea    16(a5),a5
  316.     lea    64(a2),a2
  317.     add.w    d6,d6            ; next DMA channel
  318.     dbf    d7,Br_PlayNewNote
  319.  
  320.     move.w    Br_Speed(pc),Br_Counter-Br_Infos(a0)
  321.  
  322.     bra.b    Br_PlayCheckCounter
  323.  
  324. Br_PlayOldNote:
  325.     move.w    Br_ChEff(a2),d1
  326.     beq.b    .Br_PlayOldDontCheck
  327.     move.b    Br_ChEff(a2),d0
  328.     ext.w    d0
  329.     move.w    .Br_EffectTable2(pc,d0.w),d0
  330.     jsr    (a6,d0.w)            ; A6 = Br_EffectNo
  331.     bra.b    .Br_PlayOldDontCheck
  332.  
  333. .Br_EffectTable2:    ; Effets à chaque frame
  334.     dc.w    Br_Arpeggio-Br_EffectNo        ; 0 Arpeggio
  335.     dc.w    Br_TuneUp-Br_EffectNo        ; 1 Tune Up
  336.     dc.w    Br_TuneDown-Br_EffectNo        ; 2 Tune Down
  337.     dc.w    Br_Portamento-Br_EffectNo    ; 3 Portamento
  338.     dc.w    Br_Vibrato-Br_EffectNo        ; 4 Vibrato
  339.     dc.w    Br_PortVolSlide-Br_EffectNo    ; 5 Portamento + Volume Slide
  340.     dc.w    Br_VibrVolSlide-Br_EffectNo    ; 6 Vibrato + Volume Slide
  341.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 7 Tremolo
  342.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 8 
  343.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 9 Sample Offset
  344.     dc.w    Br_VolumeSlide-Br_EffectNo    ; A Volume Slide
  345.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; B Break Song
  346.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; C Set Volume
  347.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; D Break Pattern
  348.     dc.w    Br_ECommands2-Br_EffectNo    ; E Others
  349.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; F Set Speed
  350.  
  351. .Br_PlayOldDontCheck:
  352.     IFNE    Br_MasterVolumeControl
  353.     move.w    Br_ChVol(a2),d0
  354.     mulu.w    Br_MasterVolume-Br_Infos(a0),d0
  355.     lsr.w    #6,d0
  356.     move.w    d0,8(a5)
  357.     ENDC
  358.  
  359.     lea    64(a2),a2
  360.     lea    16(a5),a5
  361.     add.w    d6,d6
  362.     dbf    d7,Br_PlayOldNote
  363.  
  364. Br_PlayCheckCounter:
  365.     IFNE    Br_MasterVolumeControl
  366.     move.w    Br_MasterVolume(pc),d0
  367.     add.w    Br_FadeVolume(pc),d0
  368.     bge.b    .Br_PlayCheckFadeDown
  369.     clr.w    d0
  370.     bra.b    .Br_PlayCheckFadeUp
  371. .Br_PlayCheckFadeDown:
  372.     cmp.w    #64,d0
  373.     ble.b    .Br_PlayCheckFadeUp
  374.     moveq    #64,d0
  375. .Br_PlayCheckFadeUp:
  376.     move.w    d0,Br_MasterVolume-Br_Infos(a0)
  377.     ENDC
  378.  
  379.     subq.w    #1,Br_Counter-Br_Infos(a0)
  380.     bne.w    .Br_PlayEnd
  381.  
  382.     tst.w    Br_PtrnDelay-Br_Infos(a0)
  383.     beq.b    .Br_PlayPatternNotDelayed
  384.     subq.w    #1,Br_PtrnDelay-Br_Infos(a0)
  385.     beq.b    .Br_PlayPatternNotDelayed
  386.     bra.w    .Br_PlayEnd
  387.  
  388. .Br_PlayPatternNotDelayed:
  389.     tst.l    Br_Break-Br_Infos(a0)
  390.     bne.b    .Br_PlayCheckBreak
  391.  
  392.     add.l    #16,Br_Pattern-Br_Infos(a0)
  393.     addq.w    #1,Br_Note-Br_Infos(a0)
  394.     cmp.w    #64,Br_Note-Br_Infos(a0)
  395.     bne.w    .Br_PlayEnd
  396.     clr.w    Br_Note-Br_Infos(a0)
  397.     move.w    Br_Position(pc),d0
  398.     addq.w    #1,d0
  399.     cmp.b    Br_MaxPos(pc),d0
  400.     blt.b    .Br_PlayNotBottomOfSong
  401.     moveq    #0,d0
  402. .Br_PlayNotBottomOfSong:
  403.     move.w    d0,Br_Position-Br_Infos(a0)
  404.     bra.b    .Br_PlayCalcNewAddress
  405.  
  406. .Br_PlayCheckBreak:
  407.     move.w    #0,Br_Note-Br_Infos(a0)
  408.     tst.w    Br_Break-Br_Infos(a0)
  409.     beq.b    .Br_PlayBreakSong
  410.     move.w    Br_Break(pc),d1
  411.     clr.w    Br_Break-Br_Infos(a0)
  412.     not.w    d1            ; D1=New Note
  413.     cmp.w    #63,d1
  414.     ble.b    .Br_PlayTopOfPattern
  415.     moveq    #63,d1
  416. .Br_PlayTopOfPattern:
  417.     move.w    d1,Br_Note-Br_Infos(a0)
  418.     tst.w    Br_BreakSng-Br_Infos(a0)
  419.     bne.b    .Br_PlayBreakSong
  420.     move.w    Br_Position(pc),d0    ; la song n'a pas été coupée, alors
  421.     addq.w    #1,d0            ; on avance de 1 position
  422.     cmp.b    Br_MaxPos(pc),d0
  423.     blt.b    .Br_PlayBreakBottom
  424.     moveq    #0,d0
  425. .Br_PlayBreakBottom:
  426.     move.w    d0,Br_Position-Br_Infos(a0)
  427.     bra.b    .Br_PlayCalcNewAddress
  428.  
  429. .Br_PlayBreakSong:
  430.     move.w    Br_BreakSng(pc),d0
  431.     clr.w    Br_BreakSng-Br_Infos(a0)
  432.     not.w    d0            ; D0=New Pos
  433.     cmp.b    Br_MaxPos(pc),d0
  434.     blt.b    .Br_PlayBreakSongBottom
  435.     moveq    #0,d0
  436. .Br_PlayBreakSongBottom:
  437.     move.w    d0,Br_Position-Br_Infos(a0)
  438. .Br_PlayCalcNewAddress:
  439.     move.l    Br_Module(pc),a1
  440.     lea    952(a1),a1
  441.     move.b    (a1,d0.w),d0
  442.     ext.w    d0
  443.     ext.l    d0
  444.     lsl.l    #8,d0
  445.     lsl.l    #2,d0
  446.     add.l    Br_Song(pc),d0
  447.     move.w    Br_Note(pc),d1
  448.     ext.l    d1
  449.     lsl.w    #4,d1
  450.     move.l    d0,Br_LoopStartAdr-Br_Infos(a0)
  451.     add.l    d1,d0
  452.     move.l    d0,Br_Pattern-Br_Infos(a0)
  453.     clr.w    Br_LoopStartPos-Br_Infos(a0)
  454. .Br_PlayEnd:
  455.     lea    $bfd400,a0
  456.     move.b    #$01,$500-$400(a0)
  457.     move.b    #$80,(a0)
  458.     move.l    Br_VBR(pc),a2
  459.     lea    Br_Int1(pc),a3
  460.     move.l    a3,$78(a2)
  461.     move.b    #$19,$e00-$400(a0)
  462. Br_DontPlay:
  463.     movem.l    (sp)+,d0-a6
  464.     move.w    #$2000,$dff09c
  465.     rte
  466.  
  467. ****************************************************************************
  468. ******************************************* Br Interrupts ******************
  469. Br_Int1:tst.w    $bfdd00
  470.     move.l    a0,-(sp)
  471.     move.l    Br_VBR(pc),a0
  472.     add.l    #Br_Int2-Br_Int1,$78(a0)
  473.     lea    $dff096,a0
  474.     move.w    Br_DMACON(pc),(a0)
  475.     move.b    #$19,$bfde00
  476.     move.w    #$2000,$9c-$96(a0)
  477.     move.l    (sp)+,a0
  478.     rte
  479.  
  480. Br_Int2:movem.l    d0/a2/a6,-(sp)
  481.     lea    $dff0a0,a6
  482.     lea    Br_ChannelInfo+Br_ChRP(pc),a2
  483.     move.l    (a2),(a6)
  484.     move.w    Br_ChRLen-Br_ChRP(a2),$4(a6)
  485.     move.l    64(a2),$10(a6)
  486.     move.w    Br_ChRLen-Br_ChRP+64(a2),$14(a6)
  487.     move.l    128(a2),$20(a6)
  488.     move.w    Br_ChRLen-Br_ChRP+128(a2),$24(a6)
  489.     move.l    192(a2),$30(a6)
  490.     move.w    Br_ChRLen-Br_ChRP+192(a2),$34(a6)
  491.     move.l    Br_VBR(pc),a2
  492.     add.l    #Br_Play-Br_Int2,$78(a2)
  493.     move.w    Br_CIATimer(pc),d0        ; CIA init
  494.     lea    $bfd000,a2
  495.     tst.w    $d00(a2)
  496.     move.b    d0,$400(a2)
  497.     rol.w    #8,d0
  498.     move.b    d0,$500(a2)
  499.     move.b    #$19,$e00(a2)
  500.     move.w    #$2000,$09c-$0a0(a6)
  501.     movem.l    (sp)+,d0/a2/a6
  502.     rte
  503.  
  504. ****************************************************************************
  505. ****************************************** Br Effects **********************
  506. Br_ECommands1:                ; E Check    *
  507.     move.w    d1,d0
  508.     and.w    #$f,d1
  509.     lsr.b    #4,d0
  510.     ext.w    d0
  511.     add.w    d0,d0
  512.     move.w    Br_E_EffectTable1(pc,d0.w),d0
  513.     jmp    (a6,d0.w)            ; A6 = Br_EffectNo
  514. Br_E_EffectTable1:
  515.     dc.w    Br_SetFilter-Br_EffectNo    ; 0-Filter
  516.     dc.w    Br_FineTuneUp-Br_EffectNo    ; 1-FineTune Up
  517.     dc.w    Br_FineTuneDown-Br_EffectNo    ; 2-FineTune Down
  518.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 3
  519.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 4
  520.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 5
  521.     dc.w    Br_LoopPattern-Br_EffectNo    ; 6 Loop
  522.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 7
  523.     dc.w    Br_CheckEvent-Br_EffectNo    ; 8
  524.     dc.w    Br_PrepRetrigNote-Br_EffectNo    ; 9-Retrig Note
  525.     dc.w    Br_FineVolumeUp-Br_EffectNo    ; A-FineVolume Up
  526.     dc.w    Br_FineVolumeDown-Br_EffectNo    ; B-FineVolume Down
  527.     dc.w    Br_EffectNo-Br_EffectNo        ; C-NoteCut
  528.     dc.w    Br_PrepDelayNote-Br_EffectNo    ; D-NoteDelay
  529.     dc.w    Br_PatternDelay-Br_EffectNo    ; E PatternDelay
  530.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; F
  531.  
  532. Br_ECommands2:                ; E Check    *
  533.     move.w    d1,d0
  534.     and.w    #$f,d1
  535.     lsr.b    #4,d0
  536.     ext.w    d0
  537.     add.w    d0,d0
  538.     move.w    Br_E_EffectTable2(pc,d0.w),d0
  539.     jmp    (a6,d0.w)            ; A6 = Br_EffectNo
  540. Br_E_EffectTable2:
  541.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 0 Filter
  542.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 1 FineTune Up
  543.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 2 FineTune Down
  544.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 3
  545.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 4
  546.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 5
  547.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 6 Loop
  548.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 7
  549.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 8
  550.     dc.w    Br_RetrigNote-Br_EffectNo    ; 9 Retrig Note
  551.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; A FineVolume Up
  552.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; B FineVolume Down
  553.     dc.w    Br_NoteCut-Br_EffectNo        ; C NoteCut
  554.     dc.w    Br_DelayNote-Br_EffectNo    ; D NoteDelay
  555.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; E PatternDelay
  556.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; F
  557.  
  558. Br_EffectNo:
  559.     rts
  560.  
  561. Br_EffectDisconnect:
  562.     clr.w    Br_ChEff(a2)
  563.     rts
  564.  
  565. Br_PrepArpeggio:            ; 0
  566.     move.b    d1,d0
  567.     and.w    #$f,d1
  568.     add.w    d1,d1
  569.     add.w    Br_ChNote(a2),d1
  570.     lsr.b    #4,d0
  571.     ext.w    d0
  572.     add.w    d0,d0
  573.     add.w    Br_ChNote(a2),d0
  574.     move.w    Br_ChOldSample(a2),d2
  575.     move.l    Br_SplFineTablePtr(a3,d2.w),a4
  576.     move.w    (a4,d0.w),Br_ChArp1(a2)
  577.     move.w    (a4,d1.w),Br_ChArp2(a2)
  578.     move.w    (a2),Br_ChArp3(a2) ; Br_ChPer
  579.     rts
  580.  
  581. Br_Arpeggio:                ; 0
  582.     move.w    Br_ChArp1(a2),d0
  583.     move.w    d0,6(a5)
  584.     move.l    Br_ChArp2(a2),Br_ChArp1(a2)
  585.     move.w    d0,Br_ChArp3(a2)
  586.     rts
  587.  
  588. Br_TuneUp:                ; 1
  589.     and.w    #$ff,d1
  590.     move.w    (a2),d0 ; Br_ChPer
  591.     sub.w    d1,d0
  592.     cmp.w    #107,d0
  593.     bgt.b    .Br_TuneUp_0
  594.     move.w    #108,d0
  595.     clr.w    Br_ChEff(a2)
  596. .Br_TuneUp_0:
  597.     move.w    d0,(a2) ; Br_ChPer
  598.     move.w    d0,6(a5)
  599.     rts
  600.  
  601. Br_TuneDown:                ; 2
  602.     and.w    #$ff,d1
  603.     move.w    (a2),d0    ; Br_ChPer
  604.     add.w    d1,d0
  605.     cmp.w    #908,d0
  606.     blt.b    .Br_TuneDown_0
  607.     move.w    #907,d0
  608.     clr.w    Br_ChEff(a2)
  609. .Br_TuneDown_0:
  610.     move.w    d0,(a2)    ; Br_ChPer
  611.     move.w    d0,6(a5)
  612.     rts
  613.  
  614. Br_PrepPortamento:            ; 3
  615.     tst.b    d1
  616.     beq.b    .Br_PrepPortamento_0
  617.     move.b    d1,Br_ChPortamento+1(a2)
  618. .Br_PrepPortamento_0:
  619.     tst.w    d5                ; Si on joue une nouvelle
  620.     beq.b    .Br_PrepPortamento_1        ; note, il faut swapper les
  621.     move.w    (a2),Br_ChPortDest(a2)        ; périodes, car la nouvelle
  622.     move.w    Br_ChPortSource(a2),(a2)    ; note est la DESTINATION
  623.     moveq    #0,d5                ; Et pas de nouveau sample...
  624. .Br_PrepPortamento_1:
  625.     rts
  626.  
  627. Br_Portamento:                ; 3
  628.     move.w    Br_ChPortDest(a2),d1
  629.     beq.b    .Br_NoPortamento
  630.     move.w    (a2),d2    ; Br_ChPer
  631.     cmp.w    d1,d2
  632.     beq.b    .Br_NoPortamento
  633.     blt.b    .Br_Portamento_1    ; Si Periode<Destina0, Sub Portam,Per
  634. .Br_Portamento_0:
  635.     sub.w    Br_ChPortamento(a2),d2
  636.     cmp.w    d1,d2
  637.     bgt.b    .Br_EndPortamento
  638.     move.w    d1,d2
  639.     clr.w    Br_ChEff(a2)
  640.     bra.b    .Br_EndPortamento
  641. .Br_Portamento_1:
  642.     add.w    Br_ChPortamento(a2),d2
  643.     cmp.w    d1,d2
  644.     blt.b    .Br_EndPortamento
  645.     move.w    d1,d2
  646.     clr.w    Br_ChEff(a2)
  647. .Br_EndPortamento:
  648.     move.w    d2,(a2)    ; Br_ChPer
  649.     move.w    d2,6(a5)
  650. .Br_NoPortamento:
  651.     rts
  652.  
  653. Br_PrepVibrato:                ; 4
  654.     move.w    d1,d0
  655.     and.b    #$f,d1            ; D1 = VibratoDepth
  656.     beq.b    .Br_PrepVibrato_0
  657.     move.b    d1,Br_ChVibratoDepth+1(a2)
  658. .Br_PrepVibrato_0:
  659.     lsr.b    #4,d0            ; D0 = VibratoSpeed
  660.     ext.w    d0
  661.     add.w    d0,d0
  662.     beq.b    .Br_PrepVibrato_1
  663.     move.w    d0,Br_ChVibratoSpeed(a2)
  664. .Br_PrepVibrato_1:
  665.     rts
  666.  
  667. Br_Vibrato:                ; 4
  668.     move.w    Br_ChVibratoPos(a2),d0
  669.     lea    Br_VibratoTable(pc),a4
  670.     move.w    (a4,d0.w),d1
  671.     muls.w    Br_ChVibratoDepth(a2),d1
  672.     lsr.l    #7,d1
  673.     add.w    (a2),d1
  674.     move.w    d1,6(a5)
  675.     add.w    Br_ChVibratoSpeed(a2),d0
  676.     and.w    #126,d0
  677.     move.w    d0,Br_ChVibratoPos(a2)
  678.     rts
  679.  
  680. Br_PrepPortVolSlide:            ; 5
  681.     clr.w    d1
  682.     bra.w    Br_PrepPortamento
  683.  
  684. Br_PortVolSlide:            ; 5
  685.     move.b    d1,d0
  686.     beq.b    .Br_NoVolumeSlide
  687.     and.w    #$f,d0
  688.     move.w    Br_ChVol(a2),d2
  689.     lsr.b    #4,d1
  690.     ext.w    d1
  691.     bne.b    .Br_VolumeSlideUp
  692.     sub.w    d0,d2
  693.     bge.b    .Br_VolumeSlideEnd
  694.     clr.w    Br_ChVol(a2)
  695.     IFEQ    Br_MasterVolumeControl
  696.     move.w    #0,8(a5)
  697.     ENDC
  698.     bra.b    .Br_NoVolumeSlide
  699. .Br_VolumeSlideUp:
  700.     add.w    d1,d2
  701.     cmp.w    #64,d2
  702.     ble.b    .Br_VolumeSlideEnd
  703.     moveq    #64,d0
  704.     move.w    d0,Br_ChVol(a2)
  705.     IFEQ    Br_MasterVolumeControl
  706.     move.w    d0,8(a5)
  707.     ENDC
  708.     bra.b    .Br_NoVolumeSlide
  709. .Br_VolumeSlideEnd:
  710.     move.w    d2,Br_ChVol(a2)
  711.     IFEQ    Br_MasterVolumeControl
  712.     move.w    d2,8(a5)
  713.     ENDC
  714. .Br_NoVolumeSlide:
  715.     move.w    Br_ChPortDest(a2),d1
  716.     beq.b    .Br_NoPortamento
  717.     move.w    (a2),d2    ; Br_ChPer
  718.     cmp.w    d1,d2
  719.     beq.b    .Br_NoPortamento
  720.     blt.b    .Br_Portamento_1    ; Si Periode<Destina0, Sub Portam,Per
  721. .Br_Portamento_0:
  722.     sub.w    Br_ChPortamento(a2),d2
  723.     cmp.w    d1,d2
  724.     bgt.b    .Br_EndPortamento
  725.     move.w    d1,d2
  726.     bra.b    .Br_EndPortamento
  727. .Br_Portamento_1:
  728.     add.w    Br_ChPortamento(a2),d2
  729.     cmp.w    d1,d2
  730.     blt.b    .Br_EndPortamento
  731.     move.w    d1,d2
  732. .Br_EndPortamento:
  733.     move.w    d2,(a2)    ; Br_ChPer
  734.     move.w    d2,6(a5)
  735. .Br_NoPortamento:
  736.     rts
  737.  
  738. Br_PrepVibrVolSlide:            ; 6
  739.     clr.w    d1
  740.     bra.w    Br_PrepVibrato
  741.  
  742. Br_VibrVolSlide:            ; 6
  743.     move.b    d1,d0
  744.     beq.b    .Br_NoVolumeSlide
  745.     and.w    #$f,d0
  746.     move.w    Br_ChVol(a2),d2
  747.     lsr.b    #4,d1
  748.     ext.w    d1
  749.     bne.b    .Br_VolumeSlideUp
  750.     sub.w    d0,d2
  751.     bge.b    .Br_VolumeSlideEnd
  752.     clr.w    Br_ChVol(a2)
  753.     IFEQ    Br_MasterVolumeControl
  754.     move.w    #0,8(a5)
  755.     ENDC
  756.     bra.b    .Br_NoVolumeSlide
  757. .Br_VolumeSlideUp:
  758.     add.w    d1,d2
  759.     cmp.w    #64,d2
  760.     ble.b    .Br_VolumeSlideEnd
  761.     moveq    #64,d0
  762.     move.w    d0,Br_ChVol(a2)
  763.     IFEQ    Br_MasterVolumeControl
  764.     move.w    d0,8(a5)
  765.     ENDC
  766.     bra.b    .Br_NoVolumeSlide
  767. .Br_VolumeSlideEnd:
  768.     move.w    d2,Br_ChVol(a2)
  769.     IFEQ    Br_MasterVolumeControl
  770.     move.w    d2,8(a5)
  771.     ENDC
  772. .Br_NoVolumeSlide:
  773.     bra.w    Br_Vibrato
  774.  
  775. Br_SampleOffset:            ; 9
  776.     and.w    #$ff,d1
  777.     beq.b    .Br_SampleOffset_0
  778.     lsl.w    #7,d1
  779.     move.w    d1,Br_ChSampleOffset(a2)
  780.     bra.b    .Br_SampleOffset_01
  781. .Br_SampleOffset_0:
  782.     move.w    Br_ChSampleOffset(a2),d1
  783. .Br_SampleOffset_01:
  784.     ext.l    d1
  785.     moveq    #0,d0
  786.     move.l    Br_ChAdr(a2),d2
  787.     move.l    d2,d4
  788.     move.w    Br_ChLen(a2),d0
  789.     add.w    d0,d0
  790.     add.l    d0,d2            ; D2 = Sample MaxAddress
  791.     sub.w    d1,Br_ChLen(a2)        ; New SampleLength
  792.     add.w    d1,d1
  793.     add.l    d1,d4
  794.     move.l    d4,Br_ChAdr(a2)        ; D0 = Sample New StartAddress
  795.     cmp.l    d4,d2
  796.     bgt.b    .Br_SampleOffset_1
  797.     move.l    Br_ChRP(a2),Br_ChAdr(a2)
  798.     move.w    Br_ChRLen(a2),Br_ChLen(a2)
  799. .Br_SampleOffset_1:
  800.     clr.w    Br_ChEff(a2)
  801.     rts
  802.  
  803. Br_VolumeSlide:                ; A
  804.     move.b    d1,d0
  805.     beq.b    .Br_NoVolumeSlide
  806.     and.w    #$f,d0
  807.     move.w    Br_ChVol(a2),d2
  808.     lsr.b    #4,d1
  809.     ext.w    d1
  810.     bne.b    .Br_VolumeSlideUp
  811.     sub.w    d0,d2
  812.     bge.b    .Br_VolumeSlideEnd
  813.     clr.w    Br_ChVol(a2)
  814.     IFEQ    Br_MasterVolumeControl
  815.     move.w    #0,8(a5)
  816.     ENDC
  817.     clr.w    Br_ChEff(a2)
  818.     rts
  819. .Br_VolumeSlideUp:
  820.     add.w    d1,d2
  821.     cmp.w    #64,d2
  822.     ble.b    .Br_VolumeSlideEnd
  823.     moveq    #64,d0
  824.     move.w    d0,Br_ChVol(a2)
  825.     IFEQ    Br_MasterVolumeControl
  826.     move.w    d0,8(a5)
  827.     ENDC
  828.     clr.w    Br_ChEff(a2)
  829.     rts
  830. .Br_VolumeSlideEnd:
  831.     move.w    d2,Br_ChVol(a2)
  832.     IFEQ    Br_MasterVolumeControl
  833.     move.w    d2,8(a5)
  834.     ENDC
  835. .Br_NoVolumeSlide:
  836.     rts
  837.  
  838. Br_BreakSong:                ; B
  839.     and.w    #$ff,d1
  840.     not.w    d1
  841.     move.w    d1,Br_BreakSng-Br_Infos(a0)
  842.     clr.w    Br_ChEff(a2)
  843.     rts
  844.  
  845. Br_SetVolume:                ; C
  846.     move.b    d1,Br_ChVol+1(a2)
  847.     clr.w    Br_ChEff(a2)
  848.     rts
  849.  
  850. Br_BreakPattern:            ; D
  851.     move.w    d1,d0
  852.     lsr.b    #4,d0
  853.     ext.w    d0
  854.     and.w    #$f,d1
  855.     mulu.w    #10,d0
  856.     add.w    d1,d0
  857.     not.w    d0
  858.     move.w    d0,Br_Break-Br_Infos(a0)
  859.     clr.w    Br_ChEff(a2)
  860.     rts
  861.  
  862. Br_SetSpeed:                ; F
  863.     tst.b    d1
  864.     bne.b    .Br_SetSpeed_0
  865.     clr.w    (a0)
  866.     rts
  867. .Br_SetSpeed_0:
  868.     cmp.b    #31,d1
  869.     bhi.b    .Br_SetCIATiming
  870.     move.b    d1,Br_Speed+1-Br_Infos(a0)
  871.     clr.w    Br_ChEff(a2)
  872.     rts
  873. .Br_SetCIATiming:
  874.     move.l    #Br_FrameValue,d0
  875.     and.w    #$ff,d1
  876.     divu.w    d1,d0
  877.     sub.w    #Br_ReplayTime,d0
  878.     move.w    d1,Br_Tempo-Br_Infos(a0)
  879.     move.w    d0,Br_CIATimer-Br_Infos(a0)
  880.     clr.w    Br_ChEff(a2)
  881.     rts
  882.  
  883. Br_SetFilter                ; E0
  884.     tst.b    d1
  885.     beq.b    .Br_FilterOn
  886. .Br_FilterOff:
  887.     bset    #1,$bfe001
  888.     clr.w    Br_ChEff(a2)
  889.     rts
  890. .Br_FilterOn:
  891.     bclr    #1,$bfe001
  892.     clr.w    Br_ChEff(a2)
  893.     rts
  894.  
  895. Br_FineTuneUp:                ; E1
  896.     move.w    (a2),d0    ; Br_ChPer
  897.     sub.w    d1,d0
  898.     cmp.w    #107,d0
  899.     bgt.b    .Br_FineTuneUp_0
  900.     move.w    #108,d0
  901. .Br_FineTuneUp_0:
  902.     move.w    d0,(a2)    ; Br_ChPer
  903.     clr.w    Br_ChEff(a2)
  904.     rts
  905.  
  906. Br_FineTuneDown:            ; E2
  907.     move.w    (a2),d0    ; Br_ChPer
  908.     add.w    d1,d0
  909.     cmp.w    #908,d0
  910.     blt.b    .Br_FineTuneDown_0
  911.     move.w    #907,d0
  912. .Br_FineTuneDown_0:
  913.     move.w    d0,(a2)    ; Br_ChPer
  914.     clr.w    Br_ChEff(a2)
  915.     rts
  916.  
  917. Br_LoopPattern:                ; E6    *
  918.     clr.w    Br_ChEff(a2)
  919.     tst.w    Br_LoopTest-Br_Infos(a0)
  920.     bne.b    .Br_EndLoop
  921.     not.w    Br_LoopTest-Br_Infos(a0)
  922.     tst.b    d1
  923.     beq.b    .Br_PrepLoop
  924.     tst.w    Br_LoopPatternVal-Br_Infos(a0)    ; Y-a-t'il une boucle en cours?
  925.     beq.b    .Br_InitLoop
  926.     subq.w    #1,Br_LoopPatternVal-Br_Infos(a0)
  927.     beq.b    .Br_EndLoop
  928.     move.l    Br_LoopStartAdr(pc),Br_Pattern-Br_Infos(a0)
  929.     move.w    Br_LoopStartPos(pc),Br_Note-Br_Infos(a0)
  930. .Br_EndLoop:
  931.     rts
  932. .Br_InitLoop:
  933.     move.w    d1,Br_LoopPatternVal-Br_Infos(a0)
  934.     move.l    Br_LoopStartAdr(pc),Br_Pattern-Br_Infos(a0)
  935.     move.w    Br_LoopStartPos(pc),Br_Note-Br_Infos(a0)
  936.     rts
  937.  
  938. .Br_PrepLoop:
  939.     move.l    Br_Pattern(pc),Br_LoopStartAdr-Br_Infos(a0)
  940.     sub.l    #16,Br_LoopStartAdr-Br_Infos(a0)
  941.     move.w    Br_Note(pc),Br_LoopStartPos-Br_Infos(a0)
  942.     subq.w    #1,Br_LoopStartPos-Br_Infos(a0)
  943. .Br_PrepNoLoop:
  944.     rts
  945.  
  946. Br_CheckEvent:                ; E8
  947.     lea    Br_EventTable(pc),a4    ; Fonction usable for synchro
  948.     add.w    d1,d1            ; demo parts... Just check the
  949.     move.w    #-1,(a4,d1.w)        ; good event in your own code, and
  950.     clr.w    Br_ChEff(a2)        ; jump if ok... You should put E8x in
  951.     rts                ; your module where you wanna break...
  952.  
  953. Br_PrepRetrigNote:            ; E9
  954.     or.b    #$90,d1
  955.     move.b    d1,Br_ChTempValue(a2)
  956.     rts
  957.  
  958. Br_RetrigNote:                ; E9    *
  959.     subq.b    #1,d1
  960.     bne.b    .Br_RetrigNote_0
  961.     move.w    d6,$dff096            ; DMACON
  962.     or.w    d6,Br_DMACON-Br_Infos(a0)
  963.     move.l    Br_ChAdr(a2),(a5)
  964.     move.w    Br_ChLen(a2),4(a5)
  965.     move.b    Br_ChTempValue(a2),Br_ChCommand(a2)
  966.     rts
  967. .Br_RetrigNote_0:
  968.     subq.b    #1,Br_ChCommand(a2)
  969.     rts
  970.  
  971. Br_FineVolumeUp:            ; EA
  972.     move.w    Br_ChVol(a2),d2
  973.     add.w    d1,d2
  974.     cmp.w    #64,d2
  975.     ble.b    .Br_FineVolumeUp_0
  976.     moveq    #64,d2
  977. .Br_FineVolumeUp_0:
  978.     move.w    d2,Br_ChVol(a2)
  979.     IFEQ    Br_MasterVolumeControl
  980.     move.w    d2,8(a5)
  981.     ENDC
  982.     clr.w    Br_ChEff(a2)
  983.     rts
  984.  
  985. Br_FineVolumeDown:            ; EB
  986.     move.w    Br_ChVol(a2),d2
  987.     sub.w    d1,d2
  988.     bge.b    .Br_FineVolumeDown_0
  989.     moveq    #0,d2
  990. .Br_FineVolumeDown_0:
  991.     move.w    d2,Br_ChVol(a2)
  992.     IFEQ    Br_MasterVolumeControl
  993.     move.w    d2,8(a5)
  994.     ENDC
  995.     clr.w    Br_ChEff(a2)
  996.     rts
  997.  
  998. Br_NoteCut:                ; EC
  999.     subq.w    #1,d1
  1000.     bne.b    .Br_NoteCut_0
  1001.     clr.w    Br_ChVol(a2)
  1002.     IFEQ    Br_MasterVolumeControl
  1003.     move.w    #0,8(a5)
  1004.     ENDC
  1005.     clr.w    Br_ChEff(a2)
  1006.     rts
  1007. .Br_NoteCut_0:
  1008.     subq.b    #1,Br_ChCommand(a2)
  1009.     rts
  1010.  
  1011. Br_PrepDelayNote:            ; ED    *
  1012.     moveq    #1,d5
  1013.     tst.b    d1
  1014.     beq.b    Br_DoDelay
  1015.     rts
  1016.  
  1017. Br_DelayNote:
  1018.     subq.b    #1,d1
  1019.     bne.b    Br_DelayNote_0
  1020. Br_DoDelay:
  1021.     move.w    d6,$dff096            ; DMACON
  1022.     or.w    d6,Br_DMACON-Br_Infos(a0)
  1023.     move.w    (a2),6(a5)
  1024.     move.l    Br_ChAdr(a2),(a5)
  1025.     move.w    Br_ChLen(a2),4(a5)
  1026.     IFEQ    Br_MasterVolumeControl
  1027.     move.w    Br_ChVol(a2),8(a5)
  1028.     ENDC
  1029.     clr.w    Br_ChEff(a2)
  1030.     rts
  1031. Br_DelayNote_0:
  1032.     subq.b    #1,Br_ChCommand(a2)
  1033.     rts
  1034.  
  1035. Br_PatternDelay:            ; EE
  1036.     tst.w    Br_PtrnDelay-Br_Infos(a0)
  1037.     bne.b    .Br_PatternDelayIsAlreadyActive
  1038.     addq.w    #1,d1
  1039.     move.w    d1,Br_PtrnDelay-Br_Infos(a0)
  1040. .Br_PatternDelayIsAlreadyActive:
  1041.     clr.w    Br_ChEff(a2)
  1042.     rts
  1043.  
  1044. ******************************************************************************
  1045. Br_Init:**********************************************************************
  1046.     movem.l    d1-a6,-(sp)
  1047.     moveq    #0,d0
  1048.     lea    Br_Infos(pc),a1
  1049.     move.l    a0,Br_Module-Br_Infos(a1)
  1050.     clr.w    (a1)
  1051.     cmp.l    #'M.K.',1080(a0)    ; Si module 31 samples, Ok, joue
  1052.     beq.w    .Br_InitOk
  1053.     cmp.l    #'Fuck',1080(a0)    ; Si pas module déjà converti...
  1054.     bne.w    .Br_InitEnd        ; mange ton bras.
  1055. .Br_InitOk:
  1056.     subq.w    #1,(a1)
  1057.  
  1058.     bset    #1,$bfe001
  1059.  
  1060.     move.w    $dff002,d0
  1061.     or.w    #$8000,d0
  1062.     move.w    d0,Br_OldDMACON-Br_Infos(a1)
  1063.  
  1064.     move.w    #$000f,$dff096
  1065.  
  1066.     move.b    950(a0),Br_MaxPos-Br_Infos(a1)
  1067.  
  1068.     moveq    #0,d0
  1069.     moveq    #127,d7
  1070.     lea    952(a0),a2
  1071. .Br_InitFindMaxPat:            ; trouver la pattern maximale
  1072.     cmp.b    (a2)+,d0
  1073.     bge.b    .Br_InitNotMaxPat
  1074.     move.b    -1(a2),d0
  1075. .Br_InitNotMaxPat:
  1076.     dbf    d7,.Br_InitFindMaxPat
  1077.  
  1078.     move.b    d0,Br_MaxPat-Br_Infos(a1)
  1079.  
  1080.     addq.l    #4,a2            ; A2 = SongData pointer
  1081.  
  1082.     move.l    a2,Br_Song-Br_Infos(a1)
  1083.  
  1084.     moveq    #0,d1            ; Yes, go somewhere else...
  1085.     move.b    d0,d1
  1086.     addq.w    #1,d1
  1087.     lsl.l    #8,d1
  1088.     lsl.l    #2,d1
  1089.     move.l    a2,a4
  1090.     add.l    d1,a4
  1091.  
  1092.     cmp.l    #'Fuck',1080(a0)    ; Module has already been converted?
  1093.     beq.b    .Br_InitPatEnd        ; No, convert
  1094.  
  1095. .Br_InitCheckPat:
  1096.  
  1097.     move.w    (a2),d1
  1098.     move.w    d1,d2
  1099.     lsr.w    #8,d2        ; D2 = Sample
  1100.     and.b    #$f0,d2
  1101.  
  1102.     move.w    2(a2),d3
  1103.     move.w    d3,d4        ; D4 = Effet + Commande
  1104.     and.w    #$0fff,d4    
  1105.     eor.w    d4,d3
  1106.     rol.w    #4,d3
  1107.     or.b    d3,d2
  1108.  
  1109.     move.w    #$ff00,d5
  1110.     and.w    d4,d5
  1111.     add.w    d5,d5
  1112.     cmp.w    #($c*2)<<8,d5
  1113.     bne.b    .Br_InitNotSetVolume
  1114.     cmp.b    #64,d4
  1115.     bls.b    .Br_InitNotSetVolume
  1116.     moveq    #64,d4
  1117. .Br_InitNotSetVolume:
  1118.     move.b    d4,d5
  1119.  
  1120. .Br_InitTestNote:
  1121.     and.w    #$0fff,d1    ; D1 = Note
  1122.     beq.b    .Br_InitPutToSong
  1123.  
  1124.     lea    Br_Period0-Br_Infos(a1),a3
  1125.     moveq    #0,d3
  1126. .Br_InitFindGoodNote:
  1127.     addq.w    #1,d3
  1128.     cmp.w    #37,d3
  1129.     bge.b    .Br_InitNoteFoundOrNot
  1130.     cmp.w    (a3)+,d1
  1131.     bne.b    .Br_InitFindGoodNote
  1132. .Br_InitNoteFoundOrNot:
  1133.     add.b    d3,d3
  1134.     move.b    d3,d1
  1135.  
  1136. .Br_InitPutToSong:
  1137.     move.b    d2,(a2)+
  1138.     move.b    d1,(a2)+
  1139.     move.w    d5,(a2)+
  1140.     cmp.l    a2,a4
  1141.     bne.b    .Br_InitCheckPat
  1142. .Br_InitPatEnd:
  1143.  
  1144.     move.l    a4,a2
  1145.     move.l    a2,Br_Sample-Br_Infos(a1)
  1146.  
  1147.     move.l    #'Fuck',1080(a0)    ; the Army
  1148.  
  1149.     move.w    #0,$dff0a8
  1150.     move.w    #0,$dff0b8
  1151.     move.w    #0,$dff0c8
  1152.     move.w    #0,$dff0d8
  1153.  
  1154.     move.w    #$000f,$dff096
  1155.  
  1156.     moveq    #30,d7
  1157.     lea    42(a0),a3
  1158.     lea    Br_SampleInfos(pc),a4
  1159.  
  1160. .Br_InitSampleInit:
  1161.     move.l    a2,Br_SplAdr(a4)    ; Sample Start Address
  1162.     moveq    #0,d0
  1163.     move.b    2(a3),d0
  1164.     move.b    d0,(a4)        ; Finetune
  1165.     move.b    3(a3),Br_SplVol(a4)    ; Volume
  1166.  
  1167.     lea    Br_Period0(pc),a5
  1168.     mulu.w    #36*2,d0
  1169.     lea    (a5,d0.w),a5
  1170.     move.l    a5,Br_SplFineTablePtr(a4)
  1171.  
  1172.     moveq    #0,d0
  1173.     move.w    4(a3),d0
  1174.     add.l    d0,d0
  1175.     add.l    a2,d0
  1176.     move.l    d0,Br_SplRP(a4)        ; RepeatPoint address
  1177.  
  1178.     moveq    #0,d1
  1179.     move.w    6(a3),d1
  1180.     move.w    d1,Br_SplRLen(a4)    ; RepeatLen
  1181.  
  1182.     tst.w    (a3)
  1183.     beq.b    .Br_InitSampleInit_0
  1184.  
  1185.     cmp.l    d0,a2
  1186.     beq.b    .Br_InitSampleInit_1
  1187.  
  1188. .Br_InitSampleInit_0:
  1189.     add.l    d1,d1
  1190.     add.l    d1,d0            ; EndLoop Address
  1191.     sub.l    a2,d0
  1192.     lsr.l    #1,d0
  1193.     move.w    d0,Br_SplLen(a4)    ; FirstPass Len
  1194.     bra.b    .Br_InitSampleInit_2
  1195.  
  1196. .Br_InitSampleInit_1:
  1197.     move.w    (a3),Br_SplLen(a4)    ; FirstPass Len
  1198.  
  1199. .Br_InitSampleInit_2:
  1200.     moveq    #0,d0
  1201.     move.w    (a3),d0            ; Look for next Sample address
  1202.     add.l    d0,d0
  1203.     add.l    d0,a2
  1204.  
  1205.     lea    32(a4),a4
  1206.     lea    30(a3),a3
  1207.     dbf    d7,.Br_InitSampleInit
  1208.  
  1209.     move.w    #Br_TempoInit,Br_Tempo-Br_Infos(a1)
  1210.  move.w    #(Br_FrameValue/Br_TempoInit)-Br_ReplayTime,Br_CIATimer-Br_Infos(a1)
  1211.     move.w    #6,Br_Speed-Br_Infos(a1)
  1212.  
  1213.     move.w    Br_StartPos(pc),Br_Position-Br_Infos(a1)
  1214.     move.w    Br_StartNote(pc),Br_Note-Br_Infos(a1)
  1215.     clr.w    Br_Counter-Br_Infos(a1)
  1216.     clr.l    Br_Break-Br_Infos(a1)
  1217.     clr.l    Br_PtrnDelay-Br_Infos(a1)
  1218.  
  1219.     move.w    Br_Position(pc),d0    ; Init pattern pointer
  1220.     add.w    #952,d0
  1221.     move.b    (a0,d0.w),d0
  1222.     ext.w    d0
  1223.     ext.l    d0
  1224.     lsl.l    #8,d0
  1225.     lsl.l    #2,d0
  1226.     add.l    Br_Song(pc),d0
  1227.     move.w    Br_Note(pc),d1
  1228.     ext.l    d1
  1229.     lsl.w    #4,d1
  1230.     add.l    d1,d0
  1231.     move.l    d0,Br_Pattern-Br_Infos(a1)
  1232.     move.l    d0,Br_LoopStartAdr-Br_Infos(a1)
  1233.     clr.w    Br_LoopStartPos-Br_Infos(a1)
  1234.  
  1235.     move.l    Br_VBR(pc),a4
  1236.     move.l    $78(a4),Br_Old78-Br_Infos(a1)
  1237.  
  1238.     lea    Br_EventTable(pc),a4
  1239.     REPT    4
  1240.     clr.l    (a4)+
  1241.     ENDR
  1242.  
  1243.     lea    Br_ChannelInfo+64*4(pc),a0
  1244.     moveq    #0,d0
  1245.     moveq    #0,d1
  1246.     moveq    #0,d2
  1247.     moveq    #0,d3
  1248.     moveq    #0,d4
  1249.     moveq    #0,d5
  1250.     moveq    #0,d6
  1251.     moveq    #0,d7
  1252.  
  1253.     REPT    8
  1254.     movem.l    d0-d7,-(a0)
  1255.     ENDR
  1256.  
  1257.     moveq    #-1,d0
  1258. .Br_InitEnd:
  1259.     movem.l    (sp)+,d1-a6
  1260.     rts
  1261.  
  1262. *****************************************************************************
  1263. Br_End:**********************************************************************
  1264.     move.l    a0,-(sp)
  1265.     lea    Br_Infos,a0
  1266.     moveq    #0,d0
  1267.     move.w    d0,(a0)
  1268.     move.w    Br_OldDMACON(pc),$dff096
  1269.     move.l    Br_VBR(pc),a0
  1270.     move.l    Br_Old78(pc),$78(a0)
  1271.     move.w    d0,$dff0a8
  1272.     move.w    d0,$dff0b8
  1273.     move.w    d0,$dff0c8
  1274.     move.w    d0,$dff0d8
  1275.     move.l    (sp)+,a0
  1276.     rts
  1277.  
  1278. *****************************************************************************
  1279. Br_GetVBR:******************************  Get VBR procedure by XANN *********
  1280.     MOVEM.L    D0/A0/A5-A6,-(SP)    ; Only usable under DOS...
  1281.     LEA    Br_VBR(PC),A0
  1282.     MOVE.L    4.W,A6
  1283.     BTST    #0,296+1(A6)        ; AttnFlags.W >= 'Mc68010' ?
  1284.     BEQ.B    .Mc68000
  1285.     LEA    .StoreVBR(PC),A5
  1286.     PEA    .Mc680X0(PC)        ; Return Address for SV()'s RTS
  1287.     JMP    -30(A6)            ; Supervisor
  1288.  
  1289. .StoreVBR:
  1290.     Dc.L    $4E7A0801        ; MOVEC VBR,D0
  1291.     RTE
  1292.  
  1293. .Mc680X0:
  1294.     MOVE.L    D0,(A0)            ; Store VBR in [VectorBase].L
  1295. .Mc68000:
  1296.     MOVEM.L    (SP)+,D0/A0/A5-A6
  1297.     RTS
  1298.  
  1299. *****************************************************************************
  1300. ****************************************** Br Control Variables *************
  1301.  
  1302. Br_Infos:        dc.w    0    ; Status
  1303. Br_MaxPos:        dc.b    0
  1304. Br_MaxPat:        dc.b    0
  1305. Br_Module:        dc.l    0
  1306. Br_Song:        dc.l    0    ; Song address
  1307. Br_Sample:        dc.l    0    ; Samples start address
  1308. Br_Pattern:        dc.l    0    ; Pointeur sur la pattern
  1309. Br_Counter:        dc.w    0    ; Compteur de frame
  1310. Br_Position:        dc.w    0    ; Position dans la SONG
  1311. Br_Note:        dc.w    0    ; Position dans la PATTERN
  1312. Br_Break:        dc.w    0
  1313. Br_BreakSng:        dc.w    0
  1314. Br_DMACON:        dc.w    0
  1315. Br_LoopTest:        dc.w    0
  1316. Br_OldDMACON:        dc.w    0
  1317. Br_Old78:        dc.l    0
  1318. Br_VBR:            dc.l    0
  1319. Br_PtrnDelay:        dc.w    0
  1320. Br_LoopPatternVal:    dc.w    0
  1321. Br_LoopStartPos:    dc.w    0
  1322. Br_LoopStartAdr:    dc.l    0
  1323.  
  1324.             IFNE    Br_MasterVolumeControl
  1325. Br_MasterVolume:    dc.w    Br_Volume
  1326. Br_FadeVolume:        dc.w    0
  1327.             ENDC
  1328. Br_Speed:        dc.w    6
  1329. Br_Tempo:        dc.w    Br_TempoInit
  1330. Br_CIATimer:        dc.w    (Br_FrameValue/Br_TempoInit)-Br_ReplayTime
  1331.  
  1332. Br_StartPos:        dc.w    0
  1333. Br_StartNote:        dc.w    0
  1334.  
  1335. ;Br_ChPer        = 0    ; w    Offset
  1336. Br_ChVol        = 2    ; w
  1337. Br_ChAdr        = 4    ; l
  1338. Br_ChRP            = 8    ; l
  1339. Br_ChLen        = 12    ; w
  1340. Br_ChRLen        = 14    ; w
  1341. Br_ChEff        = 16    ; b
  1342. Br_ChCommand        = 17    ; b
  1343. Br_ChTempValue        = 18    ; w
  1344. Br_ChNote        = 20    ; w
  1345. Br_ChOldSample        = 22    ; w
  1346. Br_ChPortamento        = 24    ; w
  1347. Br_ChSampleOffset    = 26    ; w
  1348. Br_ChPortSource        = 28    ; w
  1349. Br_ChPortDest        = 30    ; w
  1350. Br_ChArp1        = 32    ; w
  1351. Br_ChArp2        = 34    ; w
  1352. Br_ChArp3        = 36    ; w
  1353. Br_ChVibratoSpeed    = 38    ; w
  1354. Br_ChVibratoDepth    = 40    ; w
  1355. Br_ChVibratoPos        = 42    ; w
  1356. Br_ChannelInfo:        ds.b    64*4    ; DS CLEAR option would be better...
  1357.  
  1358. ;Br_SplFine        = 0    ; b    Offset
  1359. Br_SplVol        = 1    ; b
  1360. Br_SplAdr        = 2    ; l
  1361. Br_SplRP        = 6    ; l
  1362. Br_SplLen        = 10    ; w
  1363. Br_SplRLen        = 12    ; w
  1364. Br_SplFineTablePtr    = 14    ; l
  1365. Br_SampleInfos:        ds.b    32*31
  1366.  
  1367. Br_Period0:
  1368.     dc.w    856,808,762,720,678,640,604,570,538,508,480,453
  1369.     dc.w    428,404,381,360,339,320,302,285,269,254,240,226
  1370.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  1371.  
  1372.     dc.w    850,802,757,715,674,637,601,567,535,505,477,450
  1373.     dc.w    425,401,379,357,337,318,300,284,268,253,239,225
  1374.     dc.w    213,201,189,179,169,159,150,142,134,126,119,113
  1375.  
  1376.     dc.w    844,796,752,709,670,632,597,563,532,502,474,447
  1377.     dc.w    422,398,376,355,335,316,298,282,266,251,237,224
  1378.     dc.w    211,199,188,177,167,158,149,141,133,125,118,112
  1379.  
  1380.     dc.w    838,791,746,704,665,628,592,559,528,498,470,444
  1381.     dc.w    419,395,373,352,332,314,296,280,264,249,235,222
  1382.     dc.w    209,198,187,176,166,157,148,140,132,125,118,111
  1383.  
  1384.     dc.w    832,785,741,699,660,623,588,555,524,495,467,441
  1385.     dc.w    416,392,370,350,330,312,294,278,262,247,233,220
  1386.     dc.w    208,196,185,175,165,156,147,139,131,124,117,110
  1387.  
  1388.     dc.w    826,779,736,694,655,619,584,551,520,491,463,437
  1389.     dc.w    413,390,368,347,328,309,292,276,260,245,232,219
  1390.     dc.w    206,195,184,174,164,155,146,138,130,123,116,109
  1391.  
  1392.     dc.w    820,774,730,689,651,614,580,547,516,487,460,434
  1393.     dc.w    410,387,365,345,325,307,290,274,258,244,230,217
  1394.     dc.w    205,193,183,172,163,154,145,137,129,122,115,109
  1395.  
  1396.     dc.w    814,768,725,684,646,610,575,543,513,484,457,431
  1397.     dc.w    407,384,363,342,323,305,288,272,256,242,228,216
  1398.     dc.w    204,192,181,171,161,152,144,136,128,121,114,108
  1399.  
  1400.     dc.w    907,856,808,762,720,678,640,604,570,538,508,480
  1401.     dc.w    453,428,404,381,360,339,320,302,285,269,254,240
  1402.     dc.w    226,214,202,190,180,170,160,151,143,135,127,120
  1403.  
  1404.     dc.w    900,850,802,757,715,675,636,601,567,535,505,477
  1405.     dc.w    450,425,401,379,357,337,318,300,284,268,253,238
  1406.     dc.w    225,212,200,189,179,169,159,150,142,134,126,119
  1407.  
  1408.     dc.w    894,844,796,752,709,670,632,597,563,532,502,474
  1409.     dc.w    447,422,398,376,355,335,316,298,282,266,251,237
  1410.     dc.w    223,211,199,188,177,167,158,149,141,133,125,118
  1411.  
  1412.     dc.w    887,838,791,746,704,665,628,592,559,528,498,470
  1413.     dc.w    444,419,395,373,352,332,314,296,280,264,249,235
  1414.     dc.w    222,209,198,187,176,166,157,148,140,132,125,118
  1415.  
  1416.     dc.w    881,832,785,741,699,660,623,588,555,524,494,467
  1417.     dc.w    441,416,392,370,350,330,312,294,278,262,247,233
  1418.     dc.w    220,208,196,185,175,165,156,147,139,131,123,117
  1419.  
  1420.     dc.w    875,826,779,736,694,655,619,584,551,520,491,463
  1421.     dc.w    437,413,390,368,347,328,309,292,276,260,245,232
  1422.     dc.w    219,206,195,184,174,164,155,146,138,130,123,116
  1423.  
  1424.     dc.w    868,820,774,730,689,651,614,580,547,516,487,460
  1425.     dc.w    434,410,387,365,345,325,307,290,274,258,244,230
  1426.     dc.w    217,205,193,183,172,163,154,145,137,129,122,115
  1427.  
  1428.     dc.w    862,814,768,725,684,646,610,575,543,513,484,457
  1429.     dc.w    431,407,384,363,342,323,305,288,272,256,242,228
  1430.     dc.w    216,203,192,181,171,161,152,144,136,128,121,114
  1431.  
  1432. Br_VibratoTable:    
  1433.     dc.w    0,24,49,74,97,120,141,161
  1434.     dc.w    180,197,212,224,235,244,250,253
  1435.     dc.w    255,253,250,244,235,224,212,197
  1436.     dc.w    180,161,141,120,97,74,49,24
  1437.     dc.w    0,-24,-49,-74,-97,-120,-141,-161
  1438.     dc.w    -180,-197,-212,-224,-235,-244,-250,-253
  1439.     dc.w    -255,-253,-250,-244,-235,-224,-212,-197
  1440.     dc.w    -180,-161,-141,-120,-97,-74,-49,-24
  1441.  
  1442. Br_EventTable:
  1443.     ds.w    16
  1444. Br_Length=*-Br_Start
  1445.  
  1446.     SECTION    Module,DATA_C
  1447. Mod:    incdir    modules:
  1448.     incbin    mod.Your_Module
  1449.