home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / mus / delitracker-2.01.lha / DeliTracker / Files / developer.lha / Developer / Examples / FC1.3.s next >
Text File  |  1994-04-15  |  21KB  |  922 lines

  1.  
  2.     incdir    "Includes:"
  3.     include    "misc/DeliPlayer.i"
  4.  
  5. ;
  6. ;
  7.     SECTION Player,Code
  8. ;
  9. ;
  10.  
  11.     PLAYERHEADER PlayerTagArray
  12.  
  13.     dc.b '$VER: Future Composer 1.0-1.3 player module V2.2 (15 Mar 94)',0
  14.     even
  15.  
  16. PlayerTagArray
  17.     dc.l    DTP_RequestDTVersion,16
  18.     dc.l    DTP_PlayerVersion,02<<16+20
  19.     dc.l    DTP_PlayerName,PName
  20.     dc.l    DTP_Creator,CName
  21.     dc.l    DTP_Check2,Chk
  22.     dc.l    DTP_CheckLen,ChkLen
  23.     dc.l    DTP_Flags,PLYF_SONGEND
  24.     dc.l    DTP_Interrupt,Int
  25.     dc.l    DTP_InitPlayer,InitPlay
  26.     dc.l    DTP_EndPlayer,EndPlay
  27.     dc.l    DTP_InitSound,InitSnd
  28.     dc.l    DTP_EndSound,RemSnd
  29.     dc.l    DTP_Volume,SetVol
  30.     dc.l    DTP_Balance,SetVol
  31.     dc.l    TAG_DONE
  32.  
  33. *-----------------------------------------------------------------------*
  34. ;
  35. ; Player/Creatorname und lokale Daten
  36.  
  37. PName    dc.b 'FutureComposer_1.3',0
  38. CName    dc.b 'SuperSero of the Superions,',10
  39.     dc.b 'adapted by Delirium',0
  40.     even
  41. MODULE        dc.l 0
  42. fc_songend    dc.l 0
  43.  
  44. fc_SndLVol    dc.w 0
  45. fc_SndRVol    dc.w 0
  46.  
  47. *-----------------------------------------------------------------------*
  48. ;
  49. ;Interrupt für Replay
  50.  
  51. Int
  52.     movem.l    d2-d7/a2-a6,-(sp)
  53.     jsr    PLAY                ; DudelDiDum
  54.     movem.l    (sp)+,d2-d7/a2-a6
  55.     rts
  56.  
  57. *-----------------------------------------------------------------------*
  58. ;
  59. ; Testet auf Modul
  60.  
  61. Chk                        ; FC 1.3 ?
  62.     move.l    dtg_ChkData(a5),a0
  63.     move.l    (a0),d0
  64.     subi.l    #"SMOD",d0
  65.     rts
  66.  
  67. ChkLen = *-Chk
  68.  
  69. *-----------------------------------------------------------------------*
  70. ;
  71. ; Init Player
  72.  
  73. InitPlay
  74.     moveq    #0,d0
  75.     move.l    dtg_GetListData(a5),a0        ; Function
  76.     jsr    (a0)
  77.     move.l    a0,MODULE
  78.  
  79.     move.l    dtg_SongEnd(a5),fc_songend    ; store Songend FunctionPtr
  80.  
  81.     move.l    dtg_AudioAlloc(a5),a0        ; Function
  82.     jsr    (a0)                ; returncode is already set !
  83.     rts
  84.  
  85. *-----------------------------------------------------------------------*
  86. ;
  87. ; End Player
  88.  
  89. EndPlay
  90.     move.l    dtg_AudioFree(a5),a0        ; Function
  91.     jsr    (a0)
  92.     rts
  93.  
  94. *-----------------------------------------------------------------------*
  95. ;
  96. ; Init Sound
  97.  
  98. InitSnd
  99.     jsr    INIT_MUSIC            ; Init Sound
  100.     rts
  101.  
  102. *-----------------------------------------------------------------------*
  103. ;
  104. ; Remove Sound
  105.  
  106. RemSnd
  107.     jsr     END_MUSIC            ; End Sound
  108.     rts
  109.  
  110. *-----------------------------------------------------------------------*
  111. ;
  112. ; Copy Volume and Balance Data to internal buffer
  113.  
  114. SetVol
  115.     move.w    dtg_SndLBal(a5),d0
  116.     mulu    dtg_SndVol(a5),d0
  117.     lsr.w    #6,d0
  118.     move.w    d0,fc_SndLVol            ; Left Volume
  119.  
  120.     move.w    dtg_SndRBal(a5),d0
  121.     mulu    dtg_SndVol(a5),d0
  122.     lsr.w    #6,d0
  123.     move.w    d0,fc_SndRVol            ; Right Volume
  124.     rts
  125.  
  126. *-----------------------------------------------------------------------*
  127. ;
  128. ; FUTURE COMPOSER-Replay 1.0-1.3
  129.  
  130. ;
  131. ;
  132.     SECTION    Replay,Code_C
  133. ;
  134. ;
  135.  
  136. ***************************************************************
  137. **  Amiga FUTURE COMPOSER V1.0 / 1.2 / 1.3   Replay routine  **
  138. ***************************************************************
  139.  
  140.  
  141. END_MUSIC:
  142.     clr.w onoff
  143.     clr.l $dff0a6
  144.     clr.l $dff0b6
  145.     clr.l $dff0c6
  146.     clr.l $dff0d6
  147.     move.w #$000f,$dff096
  148. ;    bclr #1,$bfe001
  149.     rts
  150.  
  151. INIT_MUSIC:
  152.     move.w #1,onoff
  153. ;    bset #1,$bfe001
  154.     move.l MODULE,a0
  155.     lea 100(a0),a1
  156.     move.l a1,SEQpoint
  157.     move.l a0,a1
  158.     add.l 8(a0),a1
  159.     move.l a1,PATpoint
  160.     move.l a0,a1
  161.     add.l 16(a0),a1
  162.     move.l a1,FRQpoint
  163.     move.l a0,a1
  164.     add.l 24(a0),a1
  165.     move.l a1,VOLpoint
  166.     move.l 4(a0),d0
  167.     divu #13,d0
  168.  
  169.     lea 40(a0),a1
  170.     lea SOUNDINFO+4(pc),a2
  171.     moveq #10-1,d1
  172. initloop:
  173.     move.w (a1)+,(a2)+
  174.     move.l (a1)+,(a2)+
  175.     addq.w #4,a2
  176.     dbf d1,initloop
  177.     moveq #0,d2
  178.     move.l a0,d1
  179.     add.l 32(a0),d1
  180.     sub.l #WAVEFORMS,d1
  181.     lea SOUNDINFO(pc),a0
  182.     move.l d1,(a0)+
  183.     moveq #9-1,d3
  184. initloop1:
  185.     move.w (a0),d2
  186.     add.l d2,d1
  187.     add.l d2,d1
  188.     addq.w #6,a0
  189.     move.l d1,(a0)+
  190.     dbf d3,initloop1
  191.  
  192.     move.l SEQpoint(pc),a0
  193.     moveq #0,d2
  194.     move.b 12(a0),d2        ;Get replay speed
  195.     bne.s speedok
  196.     move.b #3,d2            ;Set default speed
  197. speedok:
  198.     move.w d2,respcnt        ;Init repspeed counter
  199.     move.w d2,repspd
  200. INIT2:
  201.     clr.w audtemp
  202.     clr.w spdtemp
  203.     move.w #$000f,$dff096        ;Disable audio DMA
  204.     move.w #$0780,$dff09a        ;Disable audio IRQ
  205.     moveq #0,d7
  206.     mulu #13,d0
  207.     moveq #4-1,d6            ;Number of soundchannels-1
  208.     lea V1data(pc),a0        ;Point to 1st voice data area
  209.     lea SILENT(pc),a1
  210.     lea o4a0c8(pc),a2
  211. initloop2:
  212.     move.l a1,10(a0)
  213.     move.l a1,18(a0)
  214.     clr.l 14(a0)
  215.     clr.b 45(a0)
  216.     clr.b 47(a0)
  217.     clr.w 8(a0)
  218.     clr.l 48(a0)
  219.     move.b #$01,23(a0)
  220.     move.b #$01,24(a0)
  221.     clr.b 25(a0)
  222.     clr.l 26(a0)
  223.     clr.w 30(a0)
  224.     moveq #$00,d3
  225.     move.w (a2)+,d1
  226.     move.w (a2)+,d3
  227.     divu #$0003,d3
  228.     move.b d3,32(a0)
  229.     mulu #$0003,d3
  230.     andi.l #$00ff,d3
  231.     andi.l #$00ff,d1
  232.     addi.l #$dff0a0,d1
  233.     move.l d1,a6
  234.     move.l #$0000,(a6)
  235.     move.w #$0100,4(a6)
  236.     move.w #$0000,6(a6)
  237.     move.w #$0000,8(a6)
  238.     move.l d1,60(a0)
  239.     clr.w 64(a0)
  240.     move.l SEQpoint(pc),(a0)
  241.     move.l SEQpoint(pc),52(a0)
  242.     add.l d0,52(a0)
  243.     add.l d3,52(a0)
  244.     add.l d7,(a0)
  245.     add.l d3,(a0)
  246.     move.w #$000d,6(a0)
  247.     move.l (a0),a3
  248.     move.b (a3),d1
  249.     andi.l #$00ff,d1
  250.     lsl.w #6,d1
  251.     move.l PATpoint(pc),a4
  252.     adda.w d1,a4
  253.     move.l a4,34(a0)
  254.     clr.l 38(a0)
  255.     move.b #$01,33(a0)
  256.     move.b #$02,42(a0)
  257.     move.b 1(a3),44(a0)
  258.     move.b 2(a3),22(a0)
  259.     clr.b 43(a0)
  260.     clr.b 45(a0)
  261.     clr.w 56(a0)
  262.     adda.w #$004a,a0    ;Point to next voice's data area
  263.     dbf d6,initloop2
  264.     rts
  265.  
  266.  
  267. PLAY:
  268.     lea pervol(pc),a6
  269.     tst.w onoff
  270.     bne.s music_on
  271.     rts
  272. music_on:
  273.     subq.w #1,respcnt        ;Decrease replayspeed counter
  274.     bne.s nonewnote
  275.     move.w repspd(pc),respcnt    ;Restore replayspeed counter
  276.     lea V1data(pc),a0        ;Point to voice1 data area
  277.     bsr new_note
  278.     lea V2data(pc),a0        ;Point to voice2 data area
  279.     bsr new_note
  280.     lea V3data(pc),a0        ;Point to voice3 data area
  281.     bsr new_note
  282.     lea V4data(pc),a0        ;Point to voice4 data area
  283.     bsr new_note
  284. nonewnote:
  285.     clr.w audtemp
  286.     lea V1data(pc),a0
  287.     bsr effects
  288.     move.w d0,(a6)+
  289.     move.w d1,(a6)+
  290.     lea V2data(pc),a0
  291.     bsr effects
  292.     move.w d0,(a6)+
  293.     move.w d1,(a6)+
  294.     lea V3data(pc),a0
  295.     bsr effects
  296.     move.w d0,(a6)+
  297.     move.w d1,(a6)+
  298.     lea V4data(pc),a0
  299.     bsr effects
  300.     move.w d0,(a6)+
  301.     move.w d1,(a6)+
  302.     lea pervol(pc),a6
  303.     move.w audtemp(pc),d0
  304.     ori.w #$8000,d0            ;Set/clr bit = 1
  305.     move.w d0,-(a7)
  306.     moveq #0,d1
  307.     move.l start1(pc),d2        ;Get samplepointers
  308.     move.w offset1(pc),d1        ;Get offset
  309.     add.l d1,d2            ;Add offset
  310.     move.l start2(pc),d3
  311.     move.w offset2(pc),d1
  312.     add.l d1,d3
  313.     move.l start3(pc),d4
  314.     move.w offset3(pc),d1
  315.     add.l d1,d4
  316.     move.l start4(pc),d5
  317.     move.w offset4(pc),d1
  318.     add.l d1,d5
  319.     move.w ssize1(pc),d0        ;Get sound lengths
  320.     move.w ssize2(pc),d1
  321.     move.w ssize3(pc),d6
  322.     move.w ssize4(pc),d7
  323.     move.w (a7)+,$dff096        ;Enable audio DMA
  324. chan1:
  325.     lea V1data(pc),a0
  326.     tst.w 72(a0)
  327.     beq.s chan2
  328.     subq.w #1,72(a0)
  329.     cmpi.w #1,72(a0)
  330.     bne.s chan2
  331.     clr.w 72(a0)
  332.     move.l d2,$dff0a0        ;Set soundstart
  333.     move.w d0,$dff0a4        ;Set soundlength
  334. chan2:
  335.     lea V2data(pc),a0
  336.     tst.w 72(a0)
  337.     beq.s chan3
  338.     subq.w #1,72(a0)
  339.     cmpi.w #1,72(a0)
  340.     bne.s chan3
  341.     clr.w 72(a0)
  342.     move.l d3,$dff0b0
  343.     move.w d1,$dff0b4
  344. chan3:
  345.     lea V3data(pc),a0
  346.     tst.w 72(a0)
  347.     beq.s chan4
  348.     subq.w #1,72(a0)
  349.     cmpi.w #1,72(a0)
  350.     bne.s chan4
  351.     clr.w 72(a0)
  352.     move.l d4,$dff0c0
  353.     move.w d6,$dff0c4
  354. chan4:
  355.     lea V4data(pc),a0
  356.     tst.w 72(a0)
  357.     beq.s setpervol
  358.     subq.w #1,72(a0)
  359.     cmpi.w #1,72(a0)
  360.     bne.s setpervol
  361.     clr.w 72(a0)
  362.     move.l d5,$dff0d0
  363.     move.w d7,$dff0d4
  364. setpervol:
  365.     lea $dff0a6,a5
  366.     move.w (a6)+,(a5)    ;Set period
  367.     move.w (a6)+,d0        ; added
  368.     mulu fc_SndLVol,d0    ; by
  369.     lsr.w #6,d0        ; Delirium
  370.     move.w d0,2(a5)        ;Set volume
  371.  
  372.     move.w (a6)+,16(a5)    ;Set period
  373.     move.w (a6)+,d0        ; added
  374.     mulu fc_SndRVol,d0    ; by
  375.     lsr.w #6,d0        ; Delirium
  376.     move.w d0,18(a5)    ;Set volume
  377.  
  378.     move.w (a6)+,32(a5)    ;Set period
  379.     move.w (a6)+,d0        ; added
  380.     mulu fc_SndRVol,d0    ; by
  381.     lsr.w #6,d0        ; Delirium
  382.     move.w d0,34(a5)    ;Set volume
  383.  
  384.     move.w (a6)+,48(a5)    ;Set period
  385.     move.w (a6)+,d0        ; added
  386.     mulu fc_SndLVol,d0    ; by
  387.     lsr.w #6,d0        ; Delirium
  388.     move.w d0,50(a5)    ;Set volume
  389.     rts
  390.  
  391. new_note:
  392.     moveq #0,d5
  393.     move.l 34(a0),a1
  394.     adda.w 40(a0),a1
  395.     cmp.w #64,40(a0)
  396.     bne samepat
  397.     move.l (a0),a2
  398.     adda.w 6(a0),a2        ;Point to next sequence row
  399.     cmpa.l 52(a0),a2    ;Is it the end?
  400.     bne.s notend
  401.     move.l    fc_songend,a2
  402.     jsr    (a2)        ; signal songend to DeliTracker
  403.     move.w d5,6(a0)        ;yes!
  404.     move.l (a0),a2        ;Point to first sequence
  405. notend:
  406.     moveq #1,d1
  407.     addq.b #1,spdtemp
  408.     cmpi.b #5,spdtemp
  409.     bne.s nonewspd
  410.     move.b d1,spdtemp
  411.     move.b 12(a2),d1    ;Get new replay speed
  412.     beq.s nonewspd
  413.     move.w d1,respcnt    ;store in counter
  414.     move.w d1,repspd
  415. nonewspd:
  416.     move.b (a2),d1        ;Pattern to play
  417.     move.b 1(a2),44(a0)    ;Transpose value
  418.     move.b 2(a2),22(a0)    ;Soundtranspose value
  419.  
  420.     move.w d5,40(a0)
  421.     lsl.w #6,d1
  422.     add.l PATpoint(pc),d1    ;Get pattern pointer
  423.     move.