home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / audio / streplay33.801.lzh / Source / play.asm < prev    next >
Assembly Source File  |  1991-11-24  |  11KB  |  485 lines

  1.         section "play",CODE
  2.         include "exec/types.i"
  3.         include "libraries/dos.i"
  4.         include "streplay_lib.i"
  5.  
  6.         xdef    mt_start
  7.         xdef    mt_brems
  8.                 xref    libbase
  9.                 xref    .UnLoadModule
  10.  
  11. call    MACRO
  12.         xref    _LVO\1
  13.         jsr     _LVO\1(a6)
  14.         ENDM
  15.  
  16.         even
  17. mt_start:
  18.         movem.l d2-d7/a2-a6,-(sp)
  19.         bsr     mt_init
  20.         move.l  4,a6
  21.         lea     intnode(pc),a1
  22.         moveq   #5,d0
  23.         call    AddIntServer
  24.         movem.l (sp)+,d2-d7/a2-a6
  25.         rts
  26.  
  27. mt_brems:
  28.         movem.l d2-d7/a2-a6,-(sp)
  29.         lea     intnode(pc),a1
  30.         moveq   #5,d0
  31.         move.l  4,a6
  32.         call    RemIntServer
  33.         bsr     mt_end
  34.         movem.l (sp)+,d2-d7/a2-a6
  35.         rts
  36.  
  37.  
  38. intnode:
  39.         dc.l    0,0
  40.         dc.b    2,0
  41.         dc.l    intname,0,mt_call
  42. intname:
  43.         dc.b    "STReplay_Lib Interrupt",0
  44.         even
  45.  
  46. mt_init:
  47.         moveq   #6,d0
  48.         bsr inits
  49.         move.l  strb_Module(a6),a0
  50.         move.l  a0,mt_data
  51.         move.l    strb_OnlyOnce(a6),mt_onlyonce
  52.         add.l   #$03b8,a0
  53.         moveq   #$7f,d0
  54.         moveq   #0,d1
  55. mt_init1:
  56.         move.l  d1,d2
  57.         subq.w  #1,d0
  58. mt_init2:
  59.         move.b  (a0)+,d1
  60.         cmp.b   d2,d1
  61.         bgt     mt_init1
  62.         dbf     d0,mt_init2
  63.         addq.b  #1,d2
  64.  
  65. mt_init3:
  66.         move.l  mt_data(pc),a0
  67.         lea     mt_sample1(pc),a1
  68.         asl.l   #8,d2
  69.         asl.l   #2,d2
  70.         add.l   #$438,d2
  71.         add.l   a0,d2
  72.         moveq   #$1e,d0
  73. mt_init4:
  74.         move.l  d2,(a1)+
  75.         moveq   #0,d1
  76.         move.w  42(a0),d1
  77.         asl.l   #1,d1
  78.         add.l   d1,d2
  79.         add.l   #$1e,a0
  80.         dbf     d0,mt_init4
  81.  
  82.         lea     mt_sample1(PC),a0
  83.         moveq   #0,d0
  84. mt_clear:
  85.         move.l  0(a0,d0.w),a1
  86.         clr.l   (a1)
  87.         addq.w  #4,d0
  88.         cmp.w   #$7c,d0
  89.         bne     mt_clear
  90.  
  91.         clr.w   $dff0a8
  92.         clr.w   $dff0b8
  93.         clr.w   $dff0c8
  94.         clr.w   $dff0d8
  95.         clr.l   mt_partnrplay
  96.         clr.l   mt_partnote
  97.         clr.l   mt_partpoint
  98.  
  99.         move.l  mt_data(pc),a0
  100.         move.b  $3b6(a0),mt_maxpart+1
  101.         rts
  102.  
  103. ; call 'mt_end' to switch the sound off
  104.  
  105. mt_end: clr.w   $dff0a8
  106.         clr.w   $dff0b8
  107.         clr.w   $dff0c8
  108.         clr.w   $dff0d8
  109.         move.w  #$f,$dff096
  110.         rts
  111.  
  112. ; the playroutine - call this every frame
  113.  
  114. mt_call:
  115.         movem.l d2-d7/a2-a6,-(sp)
  116.         bsr.s   mt_music
  117.         movem.l (sp)+,d2-d7/a2-a6
  118.         rts
  119.  
  120. mt_music:
  121.         addq.w  #1,mt_counter
  122. mt_cool: cmp.w  #6,mt_counter
  123.         bne     mt_notsix
  124.         clr.w   mt_counter
  125.         bra     mt_rout2
  126.  
  127. mt_notsix:
  128.         lea     mt_aud1temp(PC),a6
  129.         tst.b   3(a6)
  130.         beq     mt_arp1
  131.         lea     $dff0a0,a5
  132.         bsr     mt_arprout
  133. mt_arp1: lea    mt_aud2temp(PC),a6
  134.         tst.b   3(a6)
  135.         beq     mt_arp2
  136.         lea     $dff0b0,a5
  137.         bsr     mt_arprout
  138. mt_arp2: lea    mt_aud3temp(PC),a6
  139.         tst.b   3(a6)
  140.         beq     mt_arp3
  141.         lea     $dff0c0,a5
  142.         bsr     mt_arprout
  143. mt_arp3: lea    mt_aud4temp(PC),a6
  144.         tst.b   3(a6)
  145.         beq     mt_arp4
  146.         lea     $dff0d0,a5
  147.         bra     mt_arprout
  148. mt_arp4: rts
  149.  
  150. mt_arprout:
  151.         move.b  2(a6),d0
  152.         and.b   #$0f,d0
  153.         tst.b   d0
  154.         beq     mt_arpegrt
  155.         cmp.b   #$01,d0
  156.         beq     mt_portup
  157.         cmp.b   #$02,d0
  158.         beq     mt_portdwn
  159.         cmp.b   #$0a,d0
  160.         beq     mt_volslide
  161.         rts
  162.  
  163. mt_portup:
  164.         moveq   #0,d0
  165.         move.b  3(a6),d0
  166.         sub.w   d0,22(a6)
  167.         cmp.w   #$71,22(a6)
  168.         bpl     mt_ok1
  169.         move.w  #$71,22(a6)
  170. mt_ok1: move.w  22(a6),6(a5)
  171.         rts
  172.  
  173. mt_portdwn:
  174.         moveq   #0,d0
  175.         move.b  3(a6),d0
  176.         add.w   d0,22(a6)
  177.         cmp.w   #$538,22(a6)
  178.         bmi     mt_ok2
  179.         move.w  #$538,22(a6)
  180. mt_ok2: move.w  22(a6),6(a5)
  181.         rts
  182.  
  183. mt_volslide:
  184.         moveq   #0,d0
  185.         move.b  3(a6),d0
  186.         lsr.b   #4,d0
  187.         tst.b   d0
  188.         beq     mt_voldwn
  189.         add.w   d0,18(a6)
  190.         cmp.w   #64,18(a6)
  191.         bmi     mt_ok3
  192.         move.w  #64,18(a6)
  193. mt_ok3: move.w  18(a6),8(a5)
  194.         rts
  195. mt_voldwn:
  196.         moveq   #0,d0
  197.         move.b  3(a6),d0
  198.         and.b   #$0f,d0
  199.         sub.w   d0,18(a6)
  200.         bpl     mt_ok4
  201.         clr.w   18(a6)
  202. mt_ok4: move.w  18(a6),8(a5)
  203.         rts
  204.  
  205. mt_arpegrt:
  206.         move.w  mt_counter(PC),d0
  207.         cmp.w   #1,d0
  208.         beq     mt_loop2
  209.         cmp.w   #2,d0
  210.         beq     mt_loop3
  211.         cmp.w   #3,d0
  212.         beq     mt_loop4
  213.         cmp.w   #4,d0
  214.         beq     mt_loop2
  215.         cmp.w   #5,d0
  216.         beq     mt_loop3
  217.         rts
  218.  
  219. mt_loop2:
  220.         moveq   #0,d0
  221.         move.b  3(a6),d0
  222.         lsr.b   #4,d0
  223.         bra     mt_cont
  224. mt_loop3:
  225.         moveq   #$00,d0
  226.         move.b  3(a6),d0
  227.         and.b   #$0f,d0
  228.         bra     mt_cont
  229. mt_loop4:
  230.         move.w  16(a6),d2
  231.         bra     mt_endpart
  232. mt_cont:
  233.         add.w   d0,d0
  234.         moveq   #0,d1
  235.         move.w  16(a6),d1
  236.         and.w   #$fff,d1
  237.         lea     mt_arpeggio(PC),a0
  238. mt_loop5:
  239.         move.w  0(A0,d0),d2
  240.         cmp.w   (a0),d1
  241.         beq     mt_endpart
  242.         addq.l  #2,a0
  243.         bra     mt_loop5
  244. mt_endpart:
  245.         move.w  d2,6(a5)
  246.         rts
  247.  
  248. mt_rout2:
  249.         move.l  mt_data(pc),a0
  250.         move.l  a0,a3
  251.         add.l   #$0c,a3
  252.         move.l  a0,a2
  253.         add.l   #$3b8,a2
  254.         add.l   #$43c,a0
  255.         move.l  mt_partnrplay(PC),d0
  256.         moveq   #0,d1
  257.         move.b  0(A2,d0),d1
  258.         asl.l   #8,d1
  259.         asl.l   #2,d1
  260.         add.l   mt_partnote(PC),d1
  261.         move.l  d1,mt_partpoint
  262.         clr.w   mt_dmacon
  263.  
  264.         lea     $dff0a0,a5
  265.         lea     mt_aud1temp(PC),a6
  266.         bsr     mt_playit
  267.         lea     $dff0b0,a5
  268.         lea     mt_aud2temp(PC),a6
  269.         bsr     mt_playit
  270.         lea     $dff0c0,a5
  271.         lea     mt_aud3temp(PC),a6
  272.         bsr     mt_playit
  273.         lea     $dff0d0,a5
  274.         lea     mt_aud4temp(PC),a6
  275.         bsr     mt_playit
  276.         move.w  #$01f4,d0
  277. mt_rls: dbf     d0,mt_rls
  278.  
  279.         move.w  #$8000,d0
  280.         or.w    mt_dmacon,d0
  281.         move.w  d0,$dff096
  282.  
  283.         lea     mt_aud4temp(PC),a6
  284.         cmp.w   #1,14(a6)
  285.         bne     mt_voice3
  286.         move.l  10(a6),$dff0d0
  287.         move.w  #1,$dff0d4
  288. mt_voice3:
  289.         lea     mt_aud3temp(PC),a6
  290.         cmp.w   #1,14(a6)
  291.         bne     mt_voice2
  292.         move.l  10(a6),$dff0c0
  293.         move.w  #1,$dff0c4
  294. mt_voice2:
  295.         lea     mt_aud2temp(PC),a6
  296.         cmp.w   #1,14(a6)
  297.         bne     mt_voice1
  298.         move.l  10(a6),$dff0b0
  299.         move.w  #1,$dff0b4
  300. mt_voice1:
  301.         lea     mt_aud1temp(PC),a6
  302.         cmp.w   #1,14(a6)
  303.         bne     mt_voice0
  304.         move.l  10(a6),$dff0a0
  305.         move.w  #1,$dff0a4
  306. mt_voice0:
  307.         move.l  mt_partnote(PC),d0
  308.         add.l   #$10,d0
  309.         move.l  d0,mt_partnote
  310.         cmp.l   #$400,d0
  311.         bne     mt_stop
  312. mt_higher:
  313.         clr.l   mt_partnote
  314.         addq.l  #1,mt_partnrplay
  315.         moveq   #0,d0
  316.         move.w  mt_maxpart(PC),d0
  317.         move.l  mt_partnrplay(PC),d1
  318.         cmp.l   d0,d1
  319.         bne     mt_stop
  320.  
  321.                 move.l    mt_onlyonce,d1
  322.                 tst.l    d1
  323.                 beq    repeatit
  324.  
  325.                 move.l    libbase,a6
  326.         bra    .UnLoadModule
  327. endless:
  328.                 bra endless
  329.  
  330. repeatit:
  331.         clr.l   mt_partnrplay
  332. mt_stop: tst.w  mt_status
  333.         beq     mt_stop2
  334.         clr.w   mt_status
  335.         bra     mt_higher
  336. mt_stop2:
  337.         rts
  338.  
  339. mt_playit:
  340.         move.l  0(A0,d1.l),(a6)
  341.         addq.l  #4,d1
  342.         moveq   #0,d2
  343.         move.b  2(a6),d2
  344.         and.b   #$f0,d2
  345.         lsr.b   #4,d2
  346.  
  347.         move.b  (a6),d0
  348.         and.b   #$f0,d0
  349.         or.b    d0,d2
  350.         tst.b   d2
  351.         beq     mt_nosamplechange
  352.  
  353.         moveq   #0,d3
  354.         lea     mt_samples(PC),a1
  355.         move.l  d2,d4
  356.         asl.l   #2,d2
  357.         mulu    #$1e,d4
  358.         move.l  0(A1,d2),4(a6)
  359.         move.w  0(A3,d4.l),8(a6)
  360.         move.w  2(A3,d4.l),18(a6)
  361.         move.w  4(A3,d4.l),d3
  362.         tst.w   d3
  363.         beq     mt_displace
  364.         move.l  4(a6),d2
  365.         add.l   d3,d2
  366.         move.l  d2,4(a6)
  367.         move.l  d2,10(a6)
  368.         move.w  6(a3,d4.l),8(a6)
  369.         move.w  6(a3,d4.l),14(a6)
  370.         move.w  18(a6),8(a5)
  371.         bra     mt_nosamplechange
  372.  
  373. mt_displace:
  374.         move.l  4(a6),d2
  375.         add.l   d3,d2
  376.         move.l  d2,10(a6)
  377.         move.w  6(a3,d4.l),14(a6)
  378.         move.w  18(a6),8(a5)
  379. mt_nosamplechange:
  380.         move.w  (a6),d0
  381.         and.w   #$fff,d0
  382.         tst.w   d0
  383.         beq     mt_retrout
  384.         move.w  (a6),16(a6)
  385.         move.w  20(a6),$dff096
  386.         move.l  4(a6),(a5)
  387.         move.w  8(a6),4(a5)
  388.         move.w  (a6),d0
  389.         and.w   #$fff,d0
  390.         move.w  d0,6(a5)
  391.         move.w  20(a6),d0
  392.         or.w    d0,mt_dmacon
  393.  
  394. mt_retrout:
  395.         tst.w   (a6)
  396.         beq     mt_nonewper
  397.         move.w  (a6),22(a6)
  398.  
  399. mt_nonewper:
  400.         move.b  2(a6),d0
  401.         and.b   #$0f,d0
  402.         cmp.b   #$0b,d0
  403.         beq     mt_posjmp
  404.         cmp.b   #$0c,d0
  405.         beq     mt_setvol
  406.         cmp.b   #$0d,d0
  407.         beq     mt_break
  408.         cmp.b   #$0e,d0
  409.         beq     mt_setfil
  410.         cmp.b   #$0f,d0
  411.         beq     mt_setspeed
  412.         rts
  413.  
  414. mt_posjmp:
  415.         not.w   mt_status
  416.         moveq   #0,d0
  417.         move.b  3(a6),d0
  418.         subq.b  #1,d0
  419.         move.l  d0,mt_partnrplay
  420.         rts
  421.  
  422. mt_setvol:
  423.         move.b  3(a6),8(a5)
  424.         rts
  425.  
  426. mt_break:
  427.         not.w   mt_status
  428.         rts
  429.  
  430. mt_setfil:
  431.         moveq   #0,d0
  432.         move.b  3(a6),d0
  433.         and.b   #1,d0
  434.         rol.b   #1,d0
  435.         and.b   #$fd,$bfe001
  436.         or.b    d0,$bfe001
  437.         rts
  438.  
  439. mt_setspeed:
  440.         move.b  3(a6),d0
  441.         and.b   #$0f,d0
  442.         beq     mt_back
  443. inits:  clr.w   mt_counter
  444.         move.b  d0,mt_cool+3
  445. mt_back: rts
  446.  
  447. mt_aud1temp:
  448.         ds.w    10
  449.         dc.w    1
  450.         ds.w    2
  451. mt_aud2temp:
  452.         ds.w    10
  453.         dc.w    2
  454.         ds.w    2
  455. mt_aud3temp:
  456.         ds.w    10
  457.         dc.w    4
  458.         ds.w    2
  459. mt_aud4temp:
  460.         ds.w    10
  461.         dc.w    8
  462.         ds.w    2
  463.  
  464. mt_partnote:    dc.l    0
  465. mt_partnrplay:  dc.l    0
  466. mt_counter:     dc.w    0
  467. mt_partpoint:   dc.l    0
  468. mt_samples:     dc.l    0
  469. mt_sample1:     ds.l    31
  470. mt_maxpart:     dc.w    0
  471. mt_dmacon:      dc.w    0
  472. mt_status:      dc.w    0
  473. mt_onlyonce:        dc.w        0
  474.  
  475. mt_arpeggio:
  476.         dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c
  477.         dc.w $023a,$021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d
  478.         dc.w $0168,$0153,$0140,$012e,$011d,$010d,$00fe,$00f0
  479.         dc.w $00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097
  480.         dc.w $008f,$0087,$007f,$0078,$0071,$0000,$0000,$0000
  481.     even
  482. mt_data:        dc.l    0
  483.  
  484.         END
  485.