home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / dse-src5.dms / in.adf / replay5.s < prev    next >
Encoding:
Text File  |  1990-05-07  |  6.6 KB  |  428 lines

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