home *** CD-ROM | disk | FTP | other *** search
/ YPA: Your Privacy Assured / YPA.ISO / other_goodies / music / ep154b_1.dms / ep154b_1.adf / EagleplayerDeveloper / Examples / SoundFX2.0.s < prev    next >
Text File  |  1995-01-17  |  18KB  |  909 lines

  1. ;***************************************************************
  2. ;*    Sound FX 2.0 Moduleplayer for Eagleplayer/Delitracker    *
  3. ;*    SoundFX  = Modified Soundtracker !!                      *
  4. ;*    adapted by Buggs of DEFECT                               *
  5. ;***************************************************************
  6.     ;
  7.     incdir    include:
  8.     include    misc/EaglePlayer.i
  9.  
  10.     SECTION    0,Code
  11. test    =    0
  12.     ifne    test
  13.     lea    mod,a0
  14.     move.l    a0,fx_data
  15.     bsr    getinfos
  16.     endc
  17.  
  18.     PLAYERHEADER    Tags
  19.     dc.b '$VER: SoundFX 2.0 Eagleplayer V1.1 (Aug/29/93)',0,0
  20. Tags
  21.     dc.l    DTP_RequestDTVersion,$ffff
  22.     dc.l    EP_PlayerVersion,4
  23.     dc.l    DTP_Volume,SetVoices
  24.     dc.l    DTP_Balance,SetVoices
  25.     dc.l    EP_Voices,SetVoices
  26.  
  27.     dc.l    DTP_PlayerVersion,3
  28.     dc.l    DTP_PlayerName,Player
  29.     dc.l    DTP_Creator,Creator
  30.  
  31.     dc.l    DTP_Check2,testmod
  32.  
  33.     dc.l    DTP_Interrupt,Playsong
  34.  
  35.     dc.l    DTP_InitSound,InitSnd
  36.     dc.l    DTP_EndSound,PlayDisable
  37.  
  38.     dc.l    DTP_InitPlayer,InitPlay
  39.     dc.l    DTP_EndPlayer,EndPlay
  40.  
  41.     dc.l    DTP_NextPatt,FX_NextPattern
  42.     dc.l    DTP_PrevPatt,FX_BackPattern
  43.     dc.l    EP_Getpositionnr,FX_Getposnr
  44.  
  45.     dc.l    EP_flags,EPB_Volvoices!EPB_Packable!EPB_Save!EPB_restart!EPB_songend!EPB_Volume!EPB_Balance!EPB_Voices!EPB_Analyzer!EPB_Prevpatt!EPB_Nextpatt
  46.  
  47.     dc.l    EP_StructInit,StrukInit
  48.  
  49.     dc.l    EP_Get_ModuleInfo,GetInfos
  50.  
  51.     dc.l    0
  52. ;=================== Player/Creatorname und lokale Daten ===============
  53.  
  54. Player    dc.b     `SoundFX 2.0`,0
  55. Creator    dc.b     `C.Haller and C.A.Weber,`,10
  56.     dc.b    `adapted by Buggs of DEFECT`,0,0
  57.  
  58. DTBASE        dc.l    0
  59. FX_Data:    dc.l    0
  60.  
  61. FX_VolVoice1    dc.w    1
  62. FX_VolVoice2    dc.w    1
  63. FX_VolVoice3    dc.w    1
  64. FX_VolVoice4    dc.w    1
  65.  
  66. FX_Structadr    ds.b    ups_sizeof
  67.  
  68. FX_InfoBuffer:    
  69.     dc.l    MI_Samples,0            ;4
  70.     dc.l    MI_MaxSamples,15        ;12
  71.     dc.l    MI_Length,0            ;20
  72.     dc.l    MI_Pattern,0            ;28
  73.     dc.l    MI_SongSize,0            ;36
  74.     dc.l    MI_SamplesSize,0        ;44
  75.     dc.l    MI_Calcsize,0            ;52
  76.     dc.l    0
  77.     cnop    0,4
  78. ;================ Struktur ⁿbergeben =====================================
  79. Strukinit:
  80.     lea    FX_StructAdr(pc),a0
  81. Return    rts
  82. ;=======================================================================
  83. FX_NextPattern:
  84.     clr.w    Break
  85.     clr.l    PosCounter        ;PatternPos l÷schen
  86.  
  87.     addq.l    #$01,TrackPos        ;Position erh÷hen
  88.  
  89.     move.w    AnzPatt(pc),d0        ;AnzahlPosition
  90.     move.l    TrackPos(pc),d1        ;Aktuelle Pos
  91.     cmp.w    d0,d1            ;Ende?
  92.     bne.s    .NoEndPattern        ;nein!
  93.  
  94.     move.l    a2,-(sp)
  95.     move.l    dtbase(Pc),a2
  96.     move.l    DTG_Songend(a2),a2
  97.     jsr    (A2)
  98.     move.l    (sp)+,a2
  99.  
  100.     clr.l    TrackPos        ;ja/ Sound von vorne
  101. .NoEndPattern
  102.     move.l    trackpos(pc),d0
  103.     rts
  104. ;=========================================================================
  105. FX_Backpattern
  106.     lea    trackpos(pc),a0
  107.     clr.w    Break-trackpos(a0)
  108.     clr.l    PosCounter-trackpos(a0)    ;PatternPos l÷schen
  109.  
  110.     subq.l    #1,(a0)        ;Position erh÷hen
  111.     bge.s    .ok
  112.  
  113.     moveq    #0,d0
  114.     move.w    AnzPatt(pc),d0        ;AnzahlPosition
  115.     subq.l    #1,d0
  116.     move.l    d0,(a0)
  117. .ok
  118.     move.l    (a0),d0
  119.     rts
  120. ;==========================================================================
  121. FX_GetPosNr:
  122.     move.l    Trackpos(pc),d0
  123.     rts
  124. ;================ Daten in die Userprogramm-Struktur ⁿbergeben ===========
  125. GetPera6
  126.     move.l    d0,-(sp)
  127.     move.w    (A6),d0
  128.     bsr    fx_getper
  129.     move.l    (sp)+,d0
  130.     rts
  131. GetPerd2
  132.     move.l    d0,-(sp)
  133.     move.w    d2,d0
  134.     bsr    fx_getper
  135.     move.l    (sp)+,d0
  136.     rts
  137. fx_getper
  138.     move.l    a1,-(sp)
  139.  
  140.     lea    FX_Structadr(pc),a1    ;1.Kanal
  141.     cmp.l    #$dff0a0,a5
  142.     beq.s    .yes
  143.     lea    FX_Structadr+ups_modulo(pc),a1    ;2.Kanal
  144.     cmp.l    #$dff0b0,a5
  145.     beq.s    .yes
  146.     lea    FX_Structadr+ups_modulo*2(pc),a1    ;3.Kanal
  147.     cmp.l    #$dff0c0,a5
  148.     beq.s    .yes
  149.     lea    FX_Structadr+ups_modulo*3(pc),a1    ;4.Kanal
  150. .yes
  151.     and.w    #$EFFF,d0
  152.     move.w    d0,UPS_Voice1per(a1)
  153.     move.l    (sp)+,a1
  154.     rts
  155. ;=======================================================================
  156. Getvoice:
  157.     movem.l    d1/a1,-(sp)
  158.  
  159.     lea    FX_Structadr(pc),a1    ;1.Kanal
  160.     cmp.l    #$dff0a0,a4
  161.     beq.s    .yes
  162.     lea    FX_Structadr+ups_modulo(pc),a1    ;2.Kanal
  163.     cmp.l    #$dff0b0,a4
  164.     beq.s    .yes
  165.     lea    FX_Structadr+ups_modulo*2(pc),a1    ;3.Kanal
  166.     cmp.l    #$dff0c0,a4
  167.     beq.s    .yes
  168.     lea    FX_Structadr+ups_modulo*3(pc),a1    ;4.Kanal
  169. .yes
  170.     move.w    8(a6),UPS_Voice1Len(a1)    ;SamplelΣnge
  171.     move.l    4(a6),UPS_Voice1Adr(a1)    ;Sampleadresse
  172.     move.w    (a6),d1
  173.     and.w    #$EFFF,d1
  174.     move.w    d1,UPS_Voice1Per(a1)
  175.  
  176.     moveq    #0,d1
  177.     cmp.w    #1,14(a6)        ;Repeat on ?
  178.     bhi.s    .ok
  179.     moveq    #1,d1            ;nein,Repeat "off" setzen
  180. .ok    move.w    d1,UPS_Voice1Repeat(a1)
  181.  
  182.     move.w    8(a6),UPS_Voice1len(a1)    ;LΣnge/2
  183.  
  184.     movem.l    (sp)+,d1/a1
  185.     rts
  186. *-----------------------------------------------------------------------*
  187. *        d0 Bit 0-3 = Set Voices Bit=1 Voice on            *
  188. SetVoices:    lea    FX_StructAdr+UPS_DmaCon(pc),a0
  189.         move.w    EPG_Voices(a5),(a0)                ;Voices retten
  190.         lea    FX_VolVoice1(pc),a1
  191.         move.l    EPG_Voice1Vol(a5),(a1)
  192.         move.l    EPG_Voice3Vol(a5),4(a1)
  193.  
  194.         lea    FX_StructAdr+UPS_Voice1Vol(pc),a0
  195.         lea    $dff0a0,a4
  196.         moveq    #3,d1
  197. .SetNew        moveq    #0,d3
  198.         move.w    (a0),d3
  199.         bsr.s    FX_SetVoices
  200.         moveq    #UPS_Modulo,d3
  201.         add.l    d3,a0
  202.         addq.l    #8,a4
  203.         addq.l    #8,a4
  204.         dbf    d1,.SetNew
  205.         rts
  206.  
  207. *-----------------------------------------------------------------------*
  208. FX_SetVoices:    movem.l    a0/d3,-(a7)
  209.         and.w    #$7f,d3
  210.         lea    FX_StructAdr(pc),a0
  211.         cmp.l    #$dff0a0,a4            ;Left Volume
  212.         bne.s    .NoVoice1
  213.         move.w    d3,UPS_Voice1Vol(a0)
  214.         mulu.w    FX_VolVoice1(pc),d3
  215.         bra.b    .SetIt
  216. .NoVoice1:    cmp.l    #$dff0b0,a4            ;Right Volume
  217.         bne.s    .NoVoice2
  218.         move.w    d3,UPS_Voice2Vol(a0)
  219.         mulu.w    FX_VolVoice2(pc),d3
  220.         bra.b    .SetIt
  221. .NoVoice2:    cmp.l    #$dff0c0,a4            ;Right Volume
  222.         bne.s    .NoVoice3
  223.         move.w    d3,UPS_Voice3Vol(a0)
  224.         mulu.w    FX_VolVoice3(pc),d3
  225.         bra.b    .SetIt
  226. .NoVoice3:    move.w    d3,UPS_Voice4Vol(a0)
  227.         mulu.w    FX_VolVoice4(pc),d3
  228. .SetIt:        lsr.w    #6,d3
  229.         move.w    d3,8(a4)
  230. .Return:    movem.l    (a7)+,a0/d3
  231.         rts
  232. ;=======================================================================
  233. Testmod
  234.     move.l    dtg_ChkData(a5),a0
  235.     move.l    124(a0),d0
  236.     sub.l    #'SO31',d0
  237.     rts
  238. ;=======================================================================
  239. InitPlay
  240.     moveq    #0,d0
  241.     move.l    dtg_GetListData(a5),a0
  242.     jsr    (a0)
  243.     move.l    a5,dtbase
  244.     move.l    a0,FX_Data
  245.  
  246.     move.l    dtg_AudioAlloc(a5),a0
  247.     jmp    (a0)
  248. ;=======================================================================
  249. EndPlay
  250.     clr.l    fx_data
  251.  
  252.     move.l    dtg_AudioFree(a5),a0
  253.     jmp    (a0)
  254. ;=======================================================================
  255. Getinfos:
  256.     lea    FX_infobuffer(pc),a0
  257.  
  258.     move.l    FX_Data(pc),d0
  259.     beq    .rts
  260.     move.l    d0,a1        Zeiger auf SongDaten
  261.     moveq    #0,d2
  262.     move.b    $0432(a1),d2
  263.     move.l    d2,20(a0)        LΣnge des Sounds
  264.  
  265.     lea    $0434(a1),a2
  266.  
  267.     subq.w    #$01,d2
  268.  
  269.     moveq    #$00,d1
  270.     moveq    #$00,d0
  271. .SongLenLoop
  272.     move.b    (a2)+,d0        Patternnummer holen
  273.     cmp.b    d0,d1            ist es die h÷chste ?
  274.     bhi.s    .LenHigher        nein!
  275.     move.b    d0,d1            ja
  276. .LenHigher
  277.     dbf    d2,.SongLenLoop
  278.     move.l    d1,d0            Hoechste BlockNummer nach d0
  279.     addq.w    #$01,d0            plus 1
  280.     move.l    d0,28(a0)        Numpatts
  281.     mulu    #$0400,d0        Laenge eines Block
  282.  
  283.     add.l    #$4b8,d0        Vorblock
  284.     move.l    d0,36(a0)        Songlen
  285.     move.l    d0,52(a0)        Calclen
  286.  
  287.     lea    $90+$16(a1),a1        1. Sample LΣnge
  288.     moveq    #$1e,d0
  289.     moveq    #0,d2
  290.     moveq    #0,d3
  291. .numsam
  292.     moveq    #0,d1
  293.     move.w    (a1),d1
  294.     cmp.w    #2,d1
  295.     blo.s    .wei
  296.     addq.w    #1,d2
  297.     add.l    d1,d1
  298.     add.l    d1,d3
  299. .wei    add.w    #30,a1
  300.     dbf    d0,.numsam
  301.  
  302.     move.l    d3,44(a0)        ;SamplelΣnge
  303.     add.l    d3,52(a0)        ;GesamtlΣnge
  304.     move.l    d2,4(a0)        ;Anzahl
  305. .rts    rts
  306. ;=======================================================================
  307. InitSnd
  308.     move.l    fx_data(pc),a0
  309.     move.w    128(a0),dtg_Timer(a5)
  310.  
  311. ****************************************************************************
  312. *                                       *
  313. *                                       *
  314. *          Sound Abspiel Routine zu Sound FX               *
  315. *                                       *
  316. *                                       *
  317. ****************************************************************************
  318.  
  319. ;--------------------------------------------------------------------
  320.  
  321. StartSound
  322.     movem.l    d0-d7/a0-a6,-(sp)
  323.     move.l    a0,SongPointer        ;Zeiger auf SongDaten
  324.     moveq    #$00,d0
  325.     move.b    $0432(a0),d0
  326.     move.w    d0,AnzPatt
  327.  
  328.     bsr    SongLen            ;LΣnge der Songdaten berechnen
  329.     add.l    d0,a0
  330.     lea    $04B8(a0),a0
  331.  
  332.     move.l    SongPointer(pc),a2
  333.     lea    Instruments(pc),a1    ;Tabelle auf Samples
  334.     moveq    #$1E,d7            ;31 Instrumente
  335. CalcIns
  336.     move.l    a0,(a1)+        ;Startadresse des Instr.
  337.     add.l    (a2)+,a0        ;berechnen un speichern
  338.     dbra    d7,CalcIns
  339.     bsr    PlayInit        ;Loop Bereich setzen
  340.     bsr    PlayEnable        ;Player erlauben
  341.     movem.l    (sp)+,d0-d7/a0-a6
  342.     rts
  343.  
  344. SongLen
  345.     movem.l    d1-d7/a0-a6,-(sp)
  346.     move.l    SongPointer(pc),a0
  347.     lea    $0434(a0),a0
  348.     move.w    AnzPatt(pc),d2        ;wieviel Positions
  349.     subq.w    #$01,d2
  350.     moveq    #$00,d1
  351.     moveq    #$00,d0
  352. SongLenLoop
  353.     move.b    (a0)+,d0        ;Patternnummer holen
  354.     cmp.b    d0,d1            ;ist es die h÷chste ?
  355.     bhi.s    LenHigher        ;nein!
  356.     move.b    d0,d1            ;ja
  357. LenHigher
  358.     dbra    d2,SongLenLoop
  359.     move.l    d1,d0            ;Hoechste BlockNummer nach d0
  360.     addq.w    #$01,d0            ;plus 1
  361.     mulu    #$0400,d0        ;Laenge eines Block
  362.     movem.l    (sp)+,d1-d7/a0-a6
  363.     rts
  364.  
  365. PlayInit
  366.     move.l    d0,-(sp)
  367.     lea    Instruments(pc),a0    ;Zeiger auf instr.Tabelle
  368.     moveq    #$1E,d7            ;31 Instrumente
  369. InitLoop
  370.     move.l    (a0)+,a1        ;Zeiger holen
  371.     move.l    a1,d0
  372.     beq.s    InitLoop2
  373.  
  374.     clr.l    (a1)            ;erstes Longword l÷schen
  375. InitLoop2
  376.     dbra    d7,InitLoop
  377.     move.l    (sp)+,d0
  378.     rts
  379.  
  380. PlayEnable
  381.     lea    $00DFF000,a0
  382.     move.l    d0,-(sp)
  383.     move.w    #$FFFF,PlayLock        ;player zulassen
  384.     moveq    #$00,d0
  385.     move.w    d0,$00A8(a0)
  386.     move.w    d0,$00B8(a0)
  387.     move.w    d0,$00C8(a0)
  388.     move.w    d0,$00D8(a0)
  389.     clr.w    Timer            ;zahler auf 0
  390.     clr.l    TrackPos        ;zeiger auf pos
  391.     clr.l    PosCounter        ;zeiger innehalb des pattern
  392.     move.l    (sp)+,d0
  393.     rts
  394.  
  395. ;--------------------------------------------------------------------
  396.  
  397. PlayDisable
  398.     lea    $00DFF000,a0
  399.     clr.w    PlayLock        ;player sperren
  400.     move.l    d0,-(sp)
  401.     moveq    #$00,d0
  402.     move.w    d0,$00A8(a0)
  403.     move.w    d0,$00B8(a0)
  404.     move.w    d0,$00C8(a0)
  405.     move.w    d0,$00D8(a0)
  406.     move.w    #$000F,$0096(a0)
  407.     move.l    (sp)+,d0
  408.     rts
  409.  
  410. PlaySong                ;HauptAbspielRoutine
  411.     movem.l    d0-d7/a0-a6,-(sp)
  412.     lea    FX_StructAdr(pc),a0
  413.     move.w    #UPSB_Adr!UPSB_LEN!UPSB_Per!UPSB_Vol!UPSB_DMACON,UPS_Flags(a0)
  414.     clr.w    UPS_Voice1per(a0)
  415.     clr.w    UPS_Voice2per(a0)
  416.     clr.w    UPS_Voice3per(a0)
  417.     clr.w    UPS_Voice4per(a0)
  418.     move.w    #1,UPS_Enabled(A0)
  419.  
  420.     addq.w    #$01,Timer        ;zΣhler erh÷hen
  421.     cmp.w    #$0006,Timer        ;schon 6?
  422.     bne.s    CheckEffects        ;wenn nicht -> effekte
  423.     clr.w    Timer            ;sonst zΣhler l÷schen
  424.     bsr    PlaySound        ;und sound spielen
  425.  
  426.     lea    FX_StructAdr(pc),a0
  427.     clr.w    UPS_Enabled(A0)
  428.  
  429.     movem.l    (sp)+,d0-d7/a0-a6
  430.     rts
  431.  
  432. CheckEffects
  433.     moveq    #$03,d7            ;4 kanΣle
  434.     lea    ChannelData0(pc),a6    ;zeiger auf daten fⁿr 0
  435.     lea    $00DFF0A0,a3
  436. EffLoop
  437.     bsr.s    MakeEffekts        ;Effekt spielen
  438.     add.w    #$0010,a3        ;nΣchster Kanal
  439.     add.w    #$0024,a6        ;NΣchste KanalDaten
  440.     dbra    d7,EffLoop
  441.  
  442.     lea    FX_StructAdr(pc),a0
  443.     clr.w    UPS_Enabled(A0)
  444.  
  445.     movem.l    (sp)+,d0-d7/a0-a6
  446.     rts
  447.  
  448. MakeEffekts
  449.     move.w    $0016(a6),d0
  450.     beq.s    NoStep
  451.     bmi.s    StepItUp
  452.     add.w    d0,$0018(a6)
  453.     move.w    $0018(a6),d0
  454.     move.w    d0,$0010(a6)
  455.     move.w    $001A(a6),d1
  456.     cmp.w    d0,d1
  457.     bhi.s    StepOk
  458.     clr.w    $0016(a6)
  459.     move.w    d1,d0
  460.     move.w    d0,$0010(a6)
  461. StepOk
  462.     move.w    d0,$0006(a3)
  463.     move.w    d0,$0018(a6)
  464.     bsr    fx_getper
  465.     rts
  466.  
  467. StepItUp
  468.     add.w    d0,$0018(a6)
  469.     move.w    $0018(a6),d0
  470.     move.w    d0,$0010(a6)
  471.     move.w    $001A(a6),d1
  472.     cmp.w    d0,d1
  473.     blt.s    StepOk2
  474.     clr.w    $0016(a6)
  475.     move.w    d1,d0
  476.     move.w    d0,$0010(a6)
  477. StepOk2
  478.     move.w    d0,$0006(a3)
  479.     move.w    d0,$0018(a6)
  480.     bsr    fx_getper
  481.     rts
  482.  
  483. NoStep
  484.     move.b    $0002(a6),d0
  485.     and.w    #$000F,d0
  486.     tst.w    d0
  487.     beq.s    NoEff
  488.     subq.w    #$01,d0
  489.     lsl.w    #$02,d0
  490.     lea    EffTable(pc),a0
  491.     move.l    $00(a0,d0.w),d0
  492.     beq.s    NoEff
  493.     move.l    d0,a0
  494.     jsr    (a0)
  495. NoEff
  496.     rts
  497.  
  498. EffTable
  499.     dc.l    appreggiato
  500.     dc.l    pitchbend
  501.     dc.l    LedOn
  502.     dc.l    LedOff
  503.     dc.l    0
  504.     dc.l    0
  505.     dc.l    SetStepUp
  506.     dc.l    SetStepDown
  507.     dc.l    0
  508.     dc.l    0
  509.     dc.l    0
  510.     dc.l    0
  511.     dc.l    0
  512.     dc.l    0
  513.     dc.l    0
  514.  
  515. LedOn
  516. LedOff
  517. ;    bset    #$01,$00BFE001
  518.     rts
  519.  
  520. ;LedOff
  521. ;    bclr    #$01,$00BFE001
  522. ;    rts
  523.  
  524. SetStepDown
  525.     st    d4
  526.     bra.s    StepFinder
  527.  
  528. SetStepUp
  529.     moveq    #$00,d4
  530. StepFinder
  531.     clr.w    $0016(a6)
  532.     move.w    $0010(a6),$0018(a6)
  533.     move.b    $0003(a6),d2
  534.     and.w    #$000F,d2
  535.     tst.w    d4
  536.     beq.s    NoNegIt
  537.     neg.w    d2
  538. NoNegIt
  539.     move.w    d2,$0016(a6)
  540.     moveq    #$00,d2
  541.     move.b    $0003(a6),d2
  542.     lsr.w    #$04,d2
  543.     move.w    $0010(a6),d0
  544.     lea    NoteTable(pc),a0
  545. StepUpFindLoop
  546.     move.w    (a0),d1
  547.     cmp.w    #$FFFF,d1
  548.     beq.s    EndStepUpFind
  549.     cmp.w    d1,d0
  550.     beq.s    StepUpFound
  551.     addq.w    #$02,a0
  552.     bra.s    StepUpFindLoop
  553.  
  554. StepUpFound
  555.     add.w    d2,d2
  556.     tst.w    d4
  557.     bne.s    NoNegStep
  558.     neg.w    d2
  559. NoNegStep
  560.     move.w    $00(a0,d2.w),d0
  561.     move.w    d0,$001A(a6)
  562.     rts
  563.  
  564. EndStepUpFind
  565.     move.w    d0,$001A(a6)
  566.     rts
  567.  
  568. appreggiato
  569.     lea    ArpeTable(pc),a0
  570.     moveq    #$00,d0
  571.     move.w    Timer(pc),d0
  572.     subq.w    #$01,d0
  573.     lsl.w    #$02,d0
  574.     move.l    $00(a0,d0.w),a0
  575.     jmp    (a0)
  576.  
  577. ArpeTable
  578.     dc.l    Arpe1
  579.     dc.l    Arpe2
  580.     dc.l    Arpe3
  581.     dc.l    Arpe2
  582.     dc.l    Arpe1
  583.  
  584. Arpe4
  585.     add.w    d0,d0
  586.     move.w    $0010(a6),d1
  587.     lea    NoteTable(pc),a0
  588. Arpe5
  589.     move.w    $00(a0,d0.l),d2
  590.     tst.w    (a0)
  591.     bmi.s    Arpe7
  592.     cmp.w    (a0),d1
  593.     beq.s    Arpe6
  594.     addq.w    #$02,a0
  595.     bra.s    Arpe5
  596.  
  597. Arpe1
  598.     moveq    #$00,d0
  599.     move.b    $0003(a6),d0
  600.     lsr.b    #$04,d0
  601.     bra.s    Arpe4
  602.  
  603. Arpe2
  604.     moveq    #$00,d0
  605.     move.b    $0003(a6),d0
  606.     and.b    #$0F,d0
  607.     bra.s    Arpe4
  608.  
  609. Arpe3
  610.     move.w    $0010(a6),d2
  611. Arpe6
  612.     move.w    d2,$0006(a3)
  613.     bsr    getperd2
  614.     rts
  615.  
  616. Arpe7
  617.     move.w    #$00F0,$00DFF180
  618.     rts
  619.  
  620. pitchbend
  621.     moveq    #$00,d0
  622.     move.b    $0003(a6),d0
  623.     lsr.b    #$04,d0
  624.     tst.b    d0
  625.     beq.s    pitch2
  626.     move.w    (a6),d1
  627.     and.w    #$1000,d1
  628.     and.w    #$EFFF,(a6)
  629.     add.w    d0,(a6)
  630.     move.w    (a6),d0
  631.     move.w    d0,$0006(a3)
  632.     or.w    d1,(a6)
  633.     bsr    fx_getper
  634.     rts
  635.  
  636. pitch2
  637.     moveq    #$00,d0
  638.     move.b    $0003(a6),d0
  639.     and.b    #$0F,d0
  640.     tst.b    d0
  641.     beq.s    pitch3
  642.     move.w    (a6),d1
  643.     and.w    #$1000,d1
  644.     and.w    #$EFFF,(a6)
  645.     sub.w    d0,(a6)
  646.     move.w    (a6),d0
  647.     move.w    d0,$0006(a3)
  648.     or.w    d1,(a6)
  649.     bsr    fx_getper
  650. pitch3
  651.     rts
  652.  
  653. PlaySound
  654.     move.l    SongPointer(pc),a0    ;Zeiger auf SongFile
  655.     lea    $0434(a0),a2        ;Zeiger auf Patterntab.
  656.     lea    $0090(a0),a3        ;Zeiger auf Instr.Daten
  657.     lea    $04B8(a0),a0        ;Zeiger auf BlockDaten
  658.     move.l    TrackPos(pc),d0        ;Postionzeiger
  659.     moveq    #$00,d1
  660.     move.b    $00(a2,d0.l),d1
  661.     moveq    #$0A,d7
  662.     lsl.l    d7,d1            ;*1024 / lΣnge eines Pattern
  663.     add.l    PosCounter(pc),d1    ;Offset ins Pattern
  664.     clr.w    DmaCon
  665.     lea    $00DFF0A0,a4
  666.     lea    ChannelData0(pc),a6    ;Daten fⁿr Kanal0
  667.     moveq    #$03,d7            ;4 KanΣle
  668. SoundHandleLoop
  669.     bsr    PlayNote        ;aktuelle Note spielen
  670.     add.w    #$0010,a4        ;nΣchster Kanal
  671.     add.w    #$0024,a6        ;nΣchste Daten
  672.     dbra    d7,SoundHandleLoop
  673.     move.w    DmaCon(pc),d0
  674.     and.w    #$000F,d0
  675.     or.w    #$8000,d0
  676.     move.w    d0,$00DFF096
  677.     bsr    Delay
  678.     lea    ChannelData3(pc),a6
  679.     lea    $00DFF0D0,a4
  680.     moveq    #$03,d7
  681. SetRegsLoop
  682.     move.l    $000A(a6),(a4)        ;Adresse
  683.     move.w    $000E(a6),$0004(a4)    ;LΣnge
  684.     sub.w    #$0024,a6        ;nΣchste Daten
  685.     sub.w    #$0010,a4        ;nΣchster Kanal
  686.     dbra    d7,SetRegsLoop
  687.     tst.w    PlayLock
  688.     beq.s    NoEndPattern
  689.     tst.w    Break
  690.     beq.s    NoBreakPattern
  691.     move.l    #$000003F0,PosCounter
  692.     clr.w    Break
  693. NoBreakPattern
  694.     add.l    #$00000010,PosCounter    ;PatternPos erh÷hen
  695.     cmp.l    #$00000400,PosCounter    ;schon Ende ?
  696.     blt.s    NoEndPattern
  697.     clr.l    PosCounter        ;PatternPos l÷schen
  698.     tst.b    PlayLock
  699.     beq.s    NoAddPos
  700.     addq.l    #$01,TrackPos        ;Position erh÷hen
  701. NoAddPos
  702.     move.w    AnzPatt(pc),d0        ;AnzahlPosition
  703.     move.l    TrackPos(pc),d1        ;Aktuelle Pos
  704.     cmp.w    d0,d1            ;Ende?
  705.     bne.s    NoEndPattern        ;nein!
  706.  
  707.     move.l    a2,-(sp)
  708.     move.l    dtbase(Pc),a2
  709.     move.l    DTG_Songend(a2),a2
  710.     jsr    (A2)
  711.     move.l    (sp)+,a2
  712.  
  713.     clr.l    TrackPos        ;ja/ Sound von vorne
  714. NoEndPattern
  715.     rts
  716.  
  717. PlayNote
  718.     tst.b    $0014(a6)
  719.     bne.s    NoGetNote
  720.     clr.l    (a6)
  721.     tst.w    PlayLock
  722.     beq.s    NoGetNote
  723.     move.l    $00(a0,d1.l),(a6)
  724. NoGetNote
  725.     addq.w    #$04,d1
  726.     moveq    #$00,d2
  727.     cmp.w    #$FFFD,(a6)
  728.     beq    NoInstr2
  729.     move.b    $0002(a6),d2
  730.     and.b    #$F0,d2
  731.     lsr.b    #$04,d2
  732.     btst    #$04,(a6)
  733.     beq.s    PlayInstr
  734.     add.b    #$10,d2
  735. PlayInstr
  736.     tst.b    d2
  737.     beq    NoInstr2
  738.     lea    Instruments(pc),a1
  739.     subq.w    #$01,d2
  740.     move.w    d2,d4
  741.     lsl.w    #$02,d2
  742.     mulu    #$001E,d4
  743.     move.l    $00(a1,d2.w),$0004(a6)
  744.     move.w    $16(a3,d4.l),$0008(a6)
  745.     move.w    $18(a3,d4.l),$0012(a6)
  746.     moveq    #$00,d3
  747.     move.w    $1A(a3,d4.l),d3
  748.     tst.w    d3
  749.     beq.s    NoRepeat
  750.     move.l    $0004(a6),d2
  751.     add.l    d3,d2
  752.     move.l    d2,$000A(a6)
  753.     move.w    $1C(a3,d4.w),$000E(a6)
  754.     move.w    $0012(a6),d3
  755.     bra.s    NoInstr
  756. NoRepeat
  757.     move.l    $0004(a6),d2
  758.     add.l    d3,d2
  759.     move.l    d2,$000A(a6)
  760.     move.w    $1C(a3,d4.l),$000E(a6)
  761.     move.w    $0012(a6),d3
  762. NoInstr
  763.     move.b    $0002(a6),d2
  764.     and.w    #$000F,d2
  765.     cmp.b    #$05,d2
  766.     beq.s    ChangeUpVolume
  767.     cmp.b    #$06,d2
  768.     bne.s    SetVolume2
  769.     moveq    #$00,d2
  770.     move.b    $0003(a6),d2
  771.     sub.w    d2,d3
  772.     tst.w    d3
  773.     bpl.s    SetVolume2
  774.     clr.w    d3
  775.     bra.s    SetVolume2
  776.  
  777. ChangeUpVolume
  778.     moveq    #$00,d2
  779.     move.b    $0003(a6),d2
  780.     add.w    d2,d3
  781.     tst.w    d3
  782.     cmp.w    #$0040,d3
  783.     ble.s    SetVolume2
  784.     moveq    #$40,d3
  785. SetVolume2
  786.     bsr    fx_setvoices
  787. ;    move.w    d3,$0008(a4)
  788. NoInstr2
  789.     cmp.w    #$FFFD,(a6)
  790.     bne.s    NoPic
  791.     clr.w    $0002(a6)
  792.     bra.s    NoNote
  793.  
  794. NoPic
  795.     tst.w    (a6)
  796.     beq.s    NoNote
  797.     clr.w    $0016(a6)
  798.     move.w    (a6),d0
  799.     and.w    #$EFFF,d0
  800.     move.w    d0,$0010(a6)
  801.     move.w    $0014(a6),d0
  802.     ext.w    d0
  803.     move.w    d0,$00DFF096
  804.     bsr    Delay
  805.     cmp.w    #$FFFE,(a6)
  806.     bne.s    NoStop
  807.     move.w    #$0000,$0008(a4)
  808.     bra.s    Super
  809.  
  810. NoStop
  811.     cmp.w    #$FFFC,(a6)
  812.     bne.s    NoBreak
  813.     st    Break
  814.     and.w    #$EFFF,(a6)
  815.     bra    EndNote
  816.  
  817. NoPic2
  818.     and.w    #$EFFF,(a6)
  819.     bra.s    NoNote
  820. NoBreak
  821.     cmp.w    #$FFFB,(a6)
  822.     beq.s    NoPic2
  823.  
  824.     move.l    $0004(a6),(a4)
  825.     move.w    $0008(a6),$0004(a4)
  826.     bsr    getvoice
  827.  
  828.     move.w    (a6),d0
  829.     and.w    #$EFFF,d0
  830.     move.w    d0,$0006(a4)
  831. Super
  832.     move.w    $0014(a6),d0
  833.     ext.w    d0
  834.     or.w    d0,DmaCon
  835. NoNote
  836.     clr.b    $0014(a6)
  837. EndNote
  838.     rts
  839.  
  840. Delay
  841.     movem.l    d0-d1,-(sp)
  842.     moveq    #7,d0
  843. .wait1
  844.     move.b    $dff006,d1
  845. .wait2
  846.     cmp.b    $dff006,d1
  847.     beq.s    .wait2
  848.  
  849.     dbf    d0,.wait1
  850.  
  851.     movem.l    (sp)+,d0-d1
  852.     rts
  853.  
  854. ;--------------------------------------------------------------------
  855.  
  856. ChannelData0    dcb.b    $14,0            ;Daten fⁿr Note
  857.         dc.w    $0001
  858.         dcb.b    $0E,0
  859.  
  860. ChannelData1    dcb.b    $14,0            ;u.s.w
  861.         dc.w    $0002
  862.         dcb.b    $0E,0
  863.  
  864. ChannelData2    dcb.b    $14,0            ;etc.
  865.         dc.w    $0004
  866.         dcb.b    $0E,0
  867.  
  868. ChannelData3    dcb.b    $14,0            ;a.s.o
  869.         dc.w    $0008
  870.         dcb.b    $0E,0
  871.  
  872. Instruments    dcb.l 31,0            ;Zeiger auf die 31 Instrumente
  873.  
  874. PosCounter    dc.l 0                ;Offset ins Pattern
  875.  
  876. TrackPos    dc.l 0                ;Position Counter
  877.  
  878. Break        dc.w 0                ;Flag fuer 'Pattern abbrechen'
  879.  
  880. Timer        dc.w 0                ;ZΣhler 0-5
  881.  
  882. DmaCon        dc.w 0                ;Zwischenspeicher fⁿr DmaCon
  883.  
  884. AnzPatt        dc.w 0                ;Anzahl Positions
  885.  
  886. PlayLock    dc.w 0                ;Flag fuer 'Sound erlaubt'
  887.  
  888. SongPointer    dc.l 0
  889.  
  890.     dc.w    $0434,$0434,$0434,$0434,$0434,$0434,$0434,$0434,$0434,$0434
  891.     dc.w    $0434,$0434,$0434,$0434,$0434,$0434,$0434,$0434,$0434,$0434
  892. NoteTable
  893.     dc.w    $0434,$03F8,$03C0,$038A,$0358,$0328,$02FA,$02D0,$02A6,$0280
  894.     dc.w    $025C,$023A,$021A,$01FC,$01E0,$01C5,$01AC,$0194,$017D,$0168
  895.     dc.w    $0153,$0140,$012E,$011D,$010D,$00FE,$00F0,$00E2,$00D6,$00CA
  896.     dc.w    $00BE,$00B4,$00AA,$00A0,$0097,$008F,$0087,$007F,$0078,$0071
  897.     dc.w    $0071,$0071,$0071,$0071,$0071,$0071,$0071,$0071,$0071,$0071
  898.     dc.w    $0071,$0071,$0071,$0071,$0071,$0071,$0071,$0071,$0071,$0071
  899.     dc.w    $0071,$0071,$0071,$0071,$0071,$0071,$FFFF
  900.  
  901.     ifne    test
  902. mod
  903.     incdir    vr0:
  904.     incbin    SFX20.Coloris
  905.     endc
  906.  
  907.     end
  908.  
  909.