home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 1199.dms / 1199.adf / pd30.s < prev    next >
Text File  |  1991-06-07  |  19KB  |  986 lines

  1. ;REQUESTER TEST
  2. execbase    =4
  3. openlib        =-408
  4. closelib    =-414
  5. dmacon        =$96
  6. cop1lc        =$80
  7. copjmp1        =$88
  8. openlibrary    =-30-552
  9. forbid        =-30-102
  10. permit        =-30-108
  11. open        =-30
  12. read        =-42
  13. close        =-36
  14. mode_old    =1005
  15. startlist    =38
  16. custom        =$dff000
  17. bplcon0        =$100
  18. bplcon1        =$102
  19. bplcon2        =$104
  20. bpl1pth        =$0e0
  21. bpl1mod        =$108
  22. bpl2mod        =$10a
  23. diwstrt        =$08e
  24. diwstop        =$090
  25. ddfstrt        =$092
  26. ddfstop        =$094
  27. color00        =$180
  28. color01        =$182
  29. color17        =$1a2
  30. color18        =$1a4
  31. color19        =$1a6
  32. vhposr        =$006
  33.  
  34. opendos:
  35.     move.l    execbase,a6        ;open the dos library
  36.     lea    dosname(pc),a1        ;name of library
  37.     moveq    #0,d0            ;existing file
  38.     jsr    openlib(a6)        ;open library
  39.     move.l    d0,dosbase        ;store base address 
  40.  
  41. openint:                ;open intuition library
  42.     lea    intname(pc),a1        ;name of library
  43.     moveq    #0,d0            ;existing file
  44.     jsr    openlib(a6)        ;open it
  45.     move.l    d0,intbase        ;store base address
  46. taskoff:
  47.     jsr    forbid(a6)        ;muti-tasking off    
  48.  
  49. copbuild:                ;make bitplane copperlist
  50.     move.l    #bitmap,d2        ;bit plane address no 1
  51.     moveq    #1,d4            ;2 planes=2 loops to run
  52.     move.l    cladr,a0        ;copper list address in a0
  53.     move.l    d2,d1            ;1st bit plane address in d1
  54.     move.w    #bpl1pth,d3        ;first register to d3
  55. makecl:
  56.     move.w    d3,(a0)+        ;bplxpth ins ram
  57.     addq.w    #2,d3            ;next register
  58.     swap     d1
  59.     move.w    d1,(a0)+        ;hi word of plane address
  60.     move.w    d3,(a0)+        ;bplxptl ins ram
  61.     addq.w    #2,d3            ;next register
  62.     swap    d1
  63.     move.w    d1,(a0)+        ;lo word of plane address
  64.     add.l    #10240,d1        ;plane size for next address
  65.     dbf    d4,makecl        ;continue untill end
  66.     bsr    cop0build        ;display etc
  67.     jmp     joy2            ;go and check firbutton etc
  68.  
  69. cop0build:        
  70.     
  71.     lea    sprtno,a1         ;make sprite0 copperlist
  72.     move.l    (a1),d1            ;sprite0 address
  73.     moveq    #0,d4            ;0=1 sprites -1 loop to run
  74.     move.l    cladr0,a0        ;copper list address in a0
  75.     move.w    #$120,d3        ;high byte to d3
  76.     bsr.s    makecl0
  77.     add.l    #168,(a1)
  78.     move.l    (a1),d1
  79.     moveq    #0,d4
  80.     bsr.s    makecl0
  81.     add.l    #168,(a1)
  82.     move.l    (a1),d1
  83.     moveq    #0,d4
  84.     bsr.s    makecl0
  85.     add.l    #168,(a1)
  86.     move.l    (a1),d1
  87.     moveq    #0,d4
  88.     bsr.s    makecl0
  89.     move.l    #sprite47,d1
  90.     moveq    #3,d4
  91.     bsr.s    makecl0
  92.     bra.s    copset
  93. makecl0:
  94.     move.w    d3,(a0)+        ;spr0pth stored in ram
  95.     addq.w    #2,d3            ;next register
  96.     swap    d1
  97.     move.w    d1,(a0)+        ;high word of address
  98.     move.w    d3,(a0)+        ;spr0ptl stored in ram
  99.     addq.w    #2,d3            ;next register
  100.     swap    d1
  101.     move.w    d1,(a0)+        ;lo word of address
  102.     dbf    d4,makecl0        ;continue till all done
  103.     rts                ;return done
  104.     
  105. copset:                    ;initialise copper list
  106.     lea    custom,a5        ;register base address
  107.     move.l    cladr,cop1lc(a5)    ;address of copper list
  108.     move.w    #$2981,diwstrt(a5)    ;upper left of screen
  109.     move.w    #$29c1,diwstop(a5)    ;lower right of screen
  110.                     ;ddfs's set for low res
  111.     move.w    #$0038,ddfstrt(a5)    ;start of bit plane dma
  112.     move.w    #$00d0,ddfstop(a5)    ;end of bit plane dma
  113.                     ;0010 (10)=2 bit planes
  114.     move.w    #%0010001000000000,bplcon0(a5)    ;no of planes (2)
  115.     clr.w    bplcon1(a5)        ;no scrolling ?
  116.     clr.w    bplcon2(a5)        ;priority makes no diffrence
  117.     clr.w    bpl1mod(a5)        ;modulo for all planes=null?
  118.     clr.w    bpl2mod(a5)        ;same
  119.     clr.w    copjmp1(a5)        ;load copper list to pc    
  120.     rts                ;end of display
  121.     
  122. enda:    
  123.     move.l    #grname,a1        ;set for open library
  124.     clr.l    d0            ;existing file
  125.     jsr    openlib(a6)        ;open graphics library
  126.     move.l    d0,a4            ;address of graphics base
  127.     move.l    d0,grbase        ;store base address
  128.     move.l    startlist(a4),cop1lc(a5)    ;old copperlist
  129.     clr.w    copjmp1(a5)        ;load into pc
  130.     move.w    #$83e0,dmacon(a5)    ;all dma on
  131.     jsr    permit(a6)        ;enable muti-tasking
  132.  
  133. endb:
  134.     move.l    execbase,a6
  135.     move.l    dosbase(pc),a1        ;close dos.library
  136.     jsr    closelib(a6)
  137.     move.l    intbase(pc),a1        ;close intuition library
  138.     jsr    closelib(a6)
  139.     move.l    grbase(pc),a1        ;close graphics library
  140.     jsr    closelib(a6)
  141.     rts                ;all done finished
  142.  
  143. dosname:
  144.     dc.b    'dos.library',0,0
  145.     even
  146. dosbase:
  147.     blk.l    1,0
  148. intname:
  149.     dc.b    "intuition.library",0
  150.     even    
  151. intbase:
  152.     blk.l    1,0
  153. grname:
  154.     dc.b    "graphics.library",0
  155.     even
  156. grbase:
  157.     blk.l    1,0
  158. cladr:    
  159.     dc.l    list
  160. cladr0:
  161.     dc.l    list0
  162. list:    
  163.     blk.l    4,0    ;BITPLANE COPPER LIST (2*2planes=4)
  164. list0:
  165.     blk.l    16,0    ;SPRITE COPPER LIST (2*8sprites=16 lwords)
  166. list2:            
  167.             ;COLOR MAP COPPER LIST
  168.     dc.w    $0180,$0000,$0182,$0555,$0184,$0E52,$0186,$0AAA
  169.     dc.w    $0188,$0455,$018A,$0500,$018C,$0060,$018E,$0000
  170.     dc.w    $0190,$0000,$0192,$0000,$0194,$0000,$0196,$0006
  171.     dc.w    $0198,$0000,$019A,$0400,$019C,$0000,$019E,$0500
  172.     dc.w    $01A0,$0000,$01A2,$0f00,$01A4,$0fff,$01A6,$00bf
  173.     dc.w    $01A8,$0000,$01AA,$0f00,$01AC,$0fff,$01AE,$00bf
  174.     dc.w    $01B0,$0000,$01B2,$0000,$01B4,$0000,$01B6,$0000
  175.     dc.w    $01B8,$0000,$01BA,$0000,$01BC,$0000,$01BE,$0000
  176.     dc.w    $ffff,$fffe    
  177. bitmap:
  178.     blk.b    20480,0        ;BIT PLANE INFORMATION    (2 planes)
  179.     even
  180. sprtno:
  181.     dc.l    sprites
  182. sprites:
  183.     blk.b    15456,0            ;sprites A to 20 info 
  184.     even
  185. sprites1:
  186.     blk.b    3360,0            ;sprites 21 to 25 info
  187.     even
  188. sprites2:
  189.     blk.b    5376,0            ;sprites a to g eqalizer
  190.     even
  191. sprite47:
  192.     blk.l    42,0            ;4-7 dummy sprite info
  193.     even
  194. store:
  195.     dc.l    sprites
  196. count:
  197.     blk.l    1,0
  198. joy2:
  199.     btst    #6,$bfe001
  200.     beq.L    out
  201.  
  202. delay:
  203.     move.l    #12000,d1
  204. loop1:    
  205.     sub.l    #1,d1
  206.     cmp.l    #0,d1
  207.     bne.s    loop1
  208. checkcount:
  209.     lea    store,a0
  210.     move.l    (a0),a0
  211.     move.l    a0,sprtno
  212.     add.l    #672,a0
  213.     move.l    a0,store
  214.     move.l    count,d0
  215. at1:    cmp.l    #22,d0
  216.     beq.s    cntup
  217.     add.l    #1,count
  218.     cmp.l    #3,d0            ;intro sprite?
  219.     bgt.s    rebeam            ;no so display next
  220.     move.l    #300000,d1        ;intro frame
  221. loop2:                    ;delay next frame
  222.     sub.l    #1,d1            ;decrement count
  223.     cmp.l    #0,d1            ;end of delay?
  224.     bne.s    loop2            ;nope then next decrement
  225.     cmp.l    #3,d0            ;is this the 3rd screen
  226.     beq.s    setmus            ;yes go and run music
  227. rebeam:
  228.     bsr.s    beamcheck        ;check beam postion
  229.     jsr    cop0build        ;go and display sprite
  230.     bra.s    joy2            ;re-check fire button
  231. beamcheck:
  232.     lea    custom,a1        ;check the beam position
  233.     move.b    vhposr(a1),d6        ;
  234.     cmp.b    #$24,d6            ;on last line ?
  235.     bne.s    beamcheck            ;nope then re-check
  236.     rts                ;return 
  237.     
  238. cntup:                    ;top sprite reached
  239.                     
  240.     move.l    #4,count        ;reset counter
  241.     move.l    #23,at1+2
  242.     lea    sprites+2016,a0        ;set sprite pointer to start
  243.     move.l    a0,store        ;store for future recall
  244.     bra.s    rebeam            ;go and display next jobby
  245. out:
  246.     bsr.L    stopmus            ;end this part/stop mus
  247.     bsr.s    scr3set            ;transfer new music etc
  248.     bra.s    changecol        ;goto next section
  249. setmus:
  250.     bsr.L    gomus            ;go and set up music
  251.     bra.s    rebeam            ;return to check beam pos
  252.  
  253. scr3set:
  254.     lea    mt_data1,a0        ;copy new music to data
  255.     move.l    mtpoint,a1        ;pointer to go to
  256.     move.l    #61004,d0        ;number of bytes to copy
  257. copy:
  258.     move.b    (a0)+,(a1)+
  259.     dbf    d0,copy
  260.     rts
  261.  
  262. changecol:    
  263.     bsr.s    beamcheck        ;check beam position
  264.     move.w    #$0f90,list2+70        ;set up copper colors
  265.     move.w    #$01f0,list2+74        ;for new screen
  266.     move.w    #$0f90,list2+86
  267.     move.w    #$01f0,list2+90
  268.     bsr.L    gomus            ;restart music
  269.         
  270. screen3:
  271.     lea    sprites1,a0        ;set sprites pointer
  272.     move.l    a0,store        ;pointer in store
  273.     move.l    #0,count        ;reset counter to zero
  274.     move.l    #0,newdo
  275. nextspr:
  276.     lea    store,a0        ;get stored pointer
  277.     move.l    (a0),a0            ;from store
  278.     move.l    a0,sprtno        ;save to pointer
  279.     move.l    count,d0        ;get counter
  280.     cmp.l    newdo,d0        ;is new reqd same?
  281.     beq.s    update            ;yes so display same
  282.     add.l    #672,a0            ;setup next sprite
  283.     move.l    a0,store        ;save for next display run
  284.     add.l    #1,count        ;increment counter
  285.     cmp.l    #5,count        ;check counter number
  286.     beq.s    screen3            ;reset if > last sprite
  287. update:
  288.     bsr.L    beamcheck        ;check beam position
  289.     jsr    cop0build        ;display sprite
  290.  
  291. next1:
  292.     bsr.L    beamcheck        ;check beam position
  293.     move.l    #8000,d1        ;load delay to check
  294. next2:
  295.     sub.l    #1,d1            ;count down delay
  296.     bne.s    next2            ;not finished yet
  297. next3:
  298.     btst    #6,$bfe001        ;left button?
  299.     beq.s    addspr            ;yes so update sprite
  300.     btst    #10,$dff016        ;right button?
  301.     beq.s    options            ;yes so goto options
  302.     bra.s    nextspr            ;no buttons so re-display
  303. addspr:
  304.     cmp.l    #0,olddo        ;check button delay=0?
  305.     beq.s    incdo            ;yes so new press
  306.     sub.l    #1,olddo        ;no so dec counter
  307.     cmp.l    #0,olddo        ;is counter at zero?
  308.     bne.L    nextspr            ;no so display as is
  309.     add.l    #1,newdo        ;yes so update display    
  310.     bra.L    nextspr            ;and display new sprite
  311. incdo:
  312.     add.l    #2,olddo        ;set button delay
  313.     bra.L    nextspr            ;and display old jobbie
  314. options:
  315.     move.l    count,d0        ;check which sprite display
  316.     cmp.l    #0,d0            ;up when right button
  317.     beq.s    music0            ;was hit?
  318.     cmp.l    #1,d0            ;and select music
  319.     beq.s    music1            ;accordingly
  320.     cmp.l    #2,d0
  321.     beq.s    music2
  322.     cmp.l    #3,d0
  323.     beq.s    music3
  324.     cmp.l    #4,d0            ;check quit displayed
  325.     beq.s    quit            ;yes so quit
  326.     bra.L    nextspr            ;no selection re-display
  327. quit:
  328.     bsr.L    stopmus
  329.     jmp    enda    
  330. olddo:
  331.     blk.l    1,0
  332. newdo:    
  333.     blk.l    1,0
  334. filehd:
  335.     blk.l    1,0
  336. mus0:
  337.     dc.b    "music0",0
  338.     even
  339. mus1:
  340.     dc.b    "music1",0
  341.     even
  342. mus2:
  343.     dc.b    "music2",0
  344.     even
  345. mus3:
  346.     dc.b    "music3",0
  347.     even
  348. music0:
  349.     move.l    #mus0,d1
  350.     bra.s    loader
  351. music1:
  352.     move.l    #mus1,d1
  353.     bra.s    loader
  354. music2:
  355.     move.l    #mus2,d1
  356.     bra.s    loader
  357. music3:
  358.     move.l    #mus3,d1
  359.     bra.s    loader
  360.  
  361. loader:
  362.     move.l    #mode_old,d2        ;load data from disk
  363.     move.l    dosbase,a6        ;filename in d1
  364.     jsr    open(a6)
  365.     move.l    d0,filehd
  366.     move.l    #$ffffff,d3        ;size of file        
  367.     move.l    #mt_data1,d2        ;destination address
  368.     move.l    dosbase,a6
  369.     move.l    filehd(pc),d1
  370.     jsr    read(a6)
  371.     move.l    d0,d6
  372.     move.l    dosbase,a6
  373.     move.l    filehd(pc),d1
  374.     jsr    close(a6)
  375.     bsr.L    stopmus            ;stop soundtrack
  376.     bsr.L    scr3set            ;copy new music to buffer
  377.     bsr.L    gomus            ;restart soundtrack
  378.     bra.s    graphic            ;next screen
  379.  
  380. ec1:                    ;graphic eqalizer counters
  381.     blk.l    1,0            ;holds time value
  382. ec2:                    ;higher the newer
  383.     blk.l    1,0
  384. ec3:
  385.     blk.l    1,0
  386. ec4:
  387.     blk.l    1,0
  388.  
  389. graphic:
  390.     bsr    beamcheck    
  391.     move.w    #$0f00,list2+70
  392.     move.w    #$0ff0,list2+74
  393.     move.w    #$00f0,list2+78
  394.     move.w    #$0f00,list2+86
  395.     move.w    #$0ff0,list2+90
  396.     move.w    #$00f0,list2+94
  397.     bsr.L    cop1info
  398. graphica:
  399.     move.l    #8000,d0
  400. loop3:
  401.     sub.l    #1,d0
  402.     cmp.l    #0,d0
  403.     bne.s    loop3
  404.     btst    #6,$bfe001
  405.     beq.s    back
  406.     lea    ec1,a1
  407.     bsr.s    deceqalizer    
  408.     lea    ec2,a1
  409.     bsr.s    deceqalizer
  410.     lea    ec3,a1
  411.     bsr.s    deceqalizer
  412.     lea    ec4,a1
  413.     bsr.s    deceqalizer
  414.     bsr.s    cop1info
  415.     bra.s    graphica
  416. back:
  417.     bsr    beamcheck
  418.     move.w    #$0f90,list2+70
  419.     move.w    #$01f0,list2+74
  420.     move.w    #$00bf,list2+78
  421.     move.w    #$0f90,list2+86
  422.     move.w    #$01f0,list2+90
  423.     move.w    #$00bf,list2+94
  424.     bra    nextspr
  425. deceqalizer:
  426.     move.l    (a1),d0
  427.     cmp.l    #0,d0
  428.     beq.s    nodec
  429.     sub.l    #1,d0
  430.     move.l    d0,(a1)
  431. nodec:
  432.     rts
  433.  
  434. cop1info:
  435.     jsr    beamcheck
  436.     move.l    cladr0,a0
  437.     move.w    #$120,d3
  438.     lea    sprites2,a1        ;base sprite info value
  439.     lea    ec1,a2            ;get display value
  440.     bsr.s    cop1build        ;make that copper
  441.     lea    sprites2+168,a1
  442.     lea    ec2,a2
  443.     bsr.s    cop1build
  444.     lea    sprites2+336,a1
  445.     lea    ec3,a2
  446.     bsr.s    cop1build
  447.     lea    sprites2+504,a1
  448.     lea    ec4,a2
  449.     bsr.s    cop1build
  450.     move.l    #sprite47,d1
  451.     moveq    #3,d4
  452.     jsr    makecl0    
  453.     jmp    copset
  454.  
  455. cop1build:
  456.     move.l    (a2),d0            ;value in display
  457.     mulu    #672,d0            ;multiply by next block 
  458.     add.l    d0,a1            ;add to base value
  459.     move.l    a1,d1            ;transfer
  460.     moveq    #0,d4            ;number of runs = 0
  461.     jsr    makecl0            ;go to it !
  462.     rts
  463.  
  464. ;NOISETRACKER INTERUPT PLAY ROUTINE
  465. ;A.R. NELSON 1990 
  466. mtpoint:
  467.     dc.l    mt_data
  468. gomus:
  469.     bsr    mt_init            ;set up music etc
  470.     lea    inter(pc),a1
  471.     moveq    #5,d0
  472.     move.l    4,a6
  473.     jsr    -168(a6)
  474.     rts                 ;music up and running
  475. stopmus:
  476.     move.l    4,a6            ;stop music etc
  477.     moveq    #32,d0
  478.     lea    inter(pc),a1
  479.     jsr    -174(a6)
  480.     move.w    #$f,$dff096
  481.     clr.l    d0
  482.     rts                ;music stopped return
  483. mt_init:lea    mt_data(pc),a0
  484.     move.l    a0,a1
  485.     add.l    #$3b8,a1
  486.     moveq    #$7f,d0
  487.     moveq    #0,d1
  488. mt_loop:move.l    d1,d2
  489.     subq.w    #1,d0
  490. mt_lop2:move.b    (a1)+,d1
  491.     cmp.b    d2,d1
  492.     bgt.s    mt_loop
  493.     dbf    d0,mt_lop2
  494.     addq.b    #1,d2
  495.     lea    mt_samplestarts(pc),a1
  496.     asl.l    #8,d2
  497.     asl.l    #2,d2
  498.     add.l    #$43c,d2
  499.     add.l    a0,d2
  500.     move.l    d2,a2
  501.     moveq    #$1e,d0
  502. mt_lop3:clr.l    (a2)
  503.     move.l    a2,(a1)+
  504.     moveq    #0,d1
  505.     move.w    42(a0),d1
  506.     asl.l    #1,d1
  507.     add.l    d1,a2
  508.     add.l    #$1e,a0
  509.     dbf    d0,mt_lop3
  510.     or.b    #$2,$bfe001
  511.     move.b    #$6,mt_speed
  512.     clr.w    $dff0a8
  513.     clr.w    $dff0b8
  514.     clr.w    $dff0c8
  515.     clr.w    $dff0d8
  516.     clr.b    mt_songpos
  517.     clr.b    mt_counter
  518.     clr.w    mt_pattpos
  519.     rts
  520. mt_end:    clr.w    $dff0a8
  521.     clr.w    $dff0b8
  522.     clr.w    $dff0c8
  523.     clr.w    $dff0d8
  524.     move.w    #$f,$dff096
  525.     rts
  526. spadgewirq:
  527.     movem.l    d0-d7/a0-a6,-(a7)
  528.     bsr    mt_music
  529.     movem.l    (a7)+,d0-d7/a0-a6
  530.     moveq    #0,d0
  531.     rts
  532. mt_music:
  533.     movem.l    d0-d4/a0-a3/a5-a6,-(a7)
  534.     lea    mt_data(pc),a0
  535.     addq.b    #$1,mt_counter
  536.     move.b    mt_counter,D0
  537.     cmp.b    mt_speed,D0
  538.     blt.s    mt_nonew
  539.     clr.b    mt_counter
  540.     bra.L    mt_getnew
  541.  
  542. mt_nonew:
  543.     lea    mt_voice1(pc),a6
  544.     lea    $dff0a0,a5
  545.     bsr.L    mt_checkcom
  546.     lea    mt_voice2(pc),a6
  547.     lea    $dff0b0,a5
  548.     bsr.L    mt_checkcom
  549.     lea    mt_voice3(pc),a6
  550.     lea    $dff0c0,a5
  551.     bsr.L    mt_checkcom
  552.     lea    mt_voice4(pc),a6
  553.     lea    $dff0d0,a5
  554.     bsr.L    mt_checkcom
  555.     bra.L    mt_endr
  556.  
  557. mt_arpeggio:
  558.     moveq    #0,d0
  559.     move.b    mt_counter,d0
  560.     divs    #$3,d0
  561.     swap    d0
  562.     cmp.w    #$0,d0
  563.     beq.s    mt_arp2
  564.     cmp.w    #$2,d0
  565.     beq.s    mt_arp1
  566.  
  567.     moveq    #0,d0
  568.     move.b    $3(a6),d0
  569.     lsr.b    #4,d0
  570.     bra.s    mt_arp3
  571. mt_arp1:moveq    #0,d0
  572.     move.b    $3(a6),d0
  573.     and.b    #$f,d0
  574.     bra.s    mt_arp3
  575. mt_arp2:move.w    $10(a6),d2
  576.     bra.s    mt_arp4
  577. mt_arp3:asl.w    #1,d0
  578.     moveq    #0,d1
  579.     move.w    $10(a6),d1
  580.     lea    mt_periods(pc),a0
  581.     moveq    #$24,d7
  582. mt_arploop:
  583.     move.w    (a0,d0.w),d2
  584.     cmp.w    (a0),d1
  585.     bge.s    mt_arp4
  586.     addq.l    #2,a0
  587.     dbf    d7,mt_arploop
  588.     rts
  589. mt_arp4:move.w    d2,$6(a5)
  590.     rts
  591.  
  592. mt_getnew:
  593.     lea    mt_data(pc),a0
  594.     move.l    a0,a3
  595.     move.l    a0,a2
  596.     add.l    #$c,a3
  597.     add.l    #$3b8,a2
  598.     add.l    #$43c,a0
  599.  
  600.     moveq    #0,d0
  601.     move.l    d0,d1
  602.     move.b    mt_songpos,d0
  603.     move.b    (a2,d0.w),d1
  604.     asl.l    #8,d1
  605.     asl.l    #2,d1
  606.     add.w    mt_pattpos,d1
  607.     clr.w    mt_dmacon
  608.  
  609.     lea    $dff0a0,a5
  610.     lea    mt_voice1(pc),a6
  611.     bsr.s    mt_playvoice
  612.     lea    $dff0b0,a5
  613.     lea    mt_voice2(pc),a6
  614.     bsr.s    mt_playvoice
  615.     lea    $dff0c0,a5
  616.     lea    mt_voice3(pc),a6
  617.     bsr.s    mt_playvoice
  618.     lea    $dff0d0,a5
  619.     lea    mt_voice4(pc),a6
  620.     bsr.s    mt_playvoice
  621.     bra.L    mt_setdma
  622.  
  623. mt_playvoice:
  624.     move.l    (a0,d1.l),(a6)
  625.     addq.l    #4,d1
  626.     moveq    #0,d2
  627.     move.b    $2(a6),d2
  628.     and.b    #$f0,d2
  629.     lsr.b    #4,d2
  630.     move.b    (a6),d0
  631.     and.b    #$f0,d0
  632.     or.b    d0,d2
  633.     tst.b    d2
  634.     beq.s    mt_setregs
  635.     moveq    #0,d3
  636.     lea    mt_samplestarts(pc),a1
  637.     move.l    d2,d4
  638.     subq.l    #$1,d2
  639.     asl.l    #2,d2
  640.     mulu    #$1e,d4
  641.     move.l    (a1,d2.l),$4(a6)
  642.     move.w    (a3,d4.l),$8(a6)
  643.     move.w    $2(a3,d4.l),$12(a6)
  644.     move.w    $4(a3,d4.l),d3
  645.     tst.w    d3
  646.     beq.s    mt_noloop
  647.     move.l    $4(a6),d2
  648.     asl.w    #1,d3
  649.     add.l    d3,d2
  650.     move.l    d2,$a(a6)
  651.     move.w    $4(a3,d4.l),d0
  652.     add.w    $6(a3,d4.l),d0
  653.     move.w    d0,8(a6)
  654.     move.w    $6(a3,d4.l),$e(a6)
  655.     move.w    $12(a6),$8(a5)
  656.     bra.s    mt_setregs
  657. mt_noloop:
  658.     move.l    $4(a6),d2
  659.     add.l    d3,d2
  660.     move.l    d2,$a(a6)
  661.     move.w    $6(a3,d4.l),$e(a6)
  662.     move.w    $12(a6),$8(a5)
  663. mt_setregs:
  664.     move.w    (a6),d0
  665.     and.w    #$fff,d0
  666.     beq.L    mt_checkcom2
  667.     move.b    $2(a6),d0
  668.     and.b    #$F,d0
  669.     cmp.b    #$3,d0
  670.     bne.s    mt_setperiod
  671.     bsr.L    mt_setmyport
  672.     bra.L    mt_checkcom2
  673. mt_setperiod:
  674. chan:
  675.     move.l    #8,d0
  676.     cmp.l    #$dff0a0,a5
  677.     beq.s    chan1
  678.     cmp.l    #$dff0b0,a5
  679.     beq.s    chan2
  680.     cmp.l    #$dff0c0,a5
  681.     beq.s    chan3
  682.     cmp.l    #$dff0d0,a5
  683.     beq.s    chan4
  684.     bra.s    non
  685. chan1:
  686.     move.l    d0,ec1
  687.     bra.s    non
  688. chan2:
  689.     move.l    d0,ec2
  690.     bra.s    non
  691. chan3:
  692.     move.l    d0,ec3
  693.     bra.s    non
  694. chan4:
  695.     move.l    d0,ec4
  696. non:
  697.  
  698.     move.w    (a6),$10(a6)
  699.     and.w    #$fff,$10(a6)
  700.     move.w    $14(a6),d0
  701.     move.w    d0,$dff096
  702.     clr.b    $1b(a6)
  703.  
  704.     move.l    $4(a6),(a5)
  705.     move.w    $8(a6),$4(a5)
  706.     move.w    $10(a6),d0
  707.     and.w    #$fff,d0
  708.     move.w    d0,$6(a5)
  709.     move.w    $14(a6),d0
  710.     or.w    d0,mt_dmacon
  711.     bra.L    mt_checkcom2
  712.  
  713. mt_setdma:
  714.     move.w    #$12c,d0
  715. mt_wait:dbf    d0,mt_wait
  716.     move.w    mt_dmacon,d0
  717.     or.w    #$8000,d0
  718.     move.w    d0,$dff096
  719.     move.w    #$12c,d0
  720. mt_wai2:dbf    d0,mt_wai2
  721.     lea    $dff000,a5
  722.     lea    mt_voice4(pc),a6
  723.     move.l    $a(a6),$d0(a5)
  724.     move.w    $e(a6),$d4(a5)
  725.     lea    mt_voice3(pc),a6
  726.     move.l    $a(a6),$c0(a5)
  727.     move.w    $e(a6),$c4(a5)
  728.     lea    mt_voice2(pc),a6
  729.     move.l    $a(a6),$b0(a5)
  730.     move.w    $e(a6),$b4(a5)
  731.     lea    mt_voice1(pc),a6
  732.     move.l    $a(a6),$a0(a5)
  733.     move.w    $e(a6),$a4(a5)
  734.  
  735.     add.w    #$10,mt_pattpos
  736.     cmp.w    #$400,mt_pattpos
  737.     bne.s    mt_endr
  738. mt_nex:    clr.w    mt_pattpos
  739.     clr.b    mt_break
  740.     addq.b    #1,mt_songpos
  741.     and.b    #$7f,mt_songpos
  742.     move.b    mt_songpos,d1
  743.     cmp.b    mt_data+$3b6,d1
  744.     bne.s    mt_endr
  745.     clr.b    mt_songpos
  746. mt_endr:tst.b    mt_break
  747.     bne.s    mt_nex
  748.     movem.l    (a7)+,d0-d4/a0-a3/a5-a6
  749.     rts
  750.  
  751. mt_setmyport:
  752.     move.w    (a6),d2
  753.     and.w    #$fff,d2
  754.     move.w    d2,$18(a6)
  755.     move.w    $10(a6),d0
  756.     clr.b    $16(a6)
  757.     cmp.w    d0,d2
  758.     beq.s    mt_clrport
  759.     bge.s    mt_rt
  760.     move.b    #$1,$16(a6)
  761.     rts
  762. mt_clrport:
  763.     clr.w    $18(a6)
  764. mt_rt:    rts
  765.  
  766. mt_myport:
  767.     move.b    $3(a6),d0
  768.     beq.s    mt_myslide
  769.     move.b    d0,$17(a6)
  770.     clr.b    $3(a6)
  771. mt_myslide:
  772.     tst.w    $18(a6)
  773.     beq.s    mt_rt
  774.     moveq    #0,d0
  775.     move.b    $17(a6),d0
  776.     tst.b    $16(a6)
  777.     bne.s    mt_mysub
  778.     add.w    d0,$10(a6)
  779.     move.w    $18(a6),d0
  780.     cmp.w    $10(a6),d0
  781.     bgt.s    mt_myok
  782.     move.w    $18(a6),$10(a6)
  783.     clr.w    $18(a6)
  784. mt_myok:move.w    $10(a6),$6(a5)
  785.     rts
  786. mt_mysub:
  787.     sub.w    d0,$10(a6)
  788.     move.w    $18(a6),d0
  789.     cmp.w    $10(a6),d0
  790.     blt.s    mt_myok
  791.     move.w    $18(a6),$10(a6)
  792.     clr.w    $18(a6)
  793.     move.w    $10(a6),$6(a5)
  794.     rts
  795.  
  796. mt_vib:    move.b    $3(a6),d0
  797.     beq.s    mt_vi
  798.     move.b    d0,$1a(a6)
  799.  
  800. mt_vi:    move.b    $1b(a6),d0
  801.     lea    mt_sin(pc),a4
  802.     lsr.w    #$2,d0
  803.     and.w    #$1f,d0
  804.     moveq    #0,d2
  805.     move.b    (a4,d0.w),d2
  806.     move.b    $1a(a6),d0
  807.     and.w    #$f,d0
  808.     mulu    d0,d2
  809.     lsr.w    #$6,d2
  810.     move.w    $10(a6),d0
  811.     tst.b    $1b(a6)
  812.     bmi.s    mt_vibmin
  813.     add.w    d2,d0
  814.     bra.s    mt_vib2
  815. mt_vibmin:
  816.     sub.w    d2,d0
  817. mt_vib2:move.w    d0,$6(a5)
  818.     move.b    $1a(a6),d0
  819.     lsr.w    #$2,d0
  820.     and.w    #$3c,d0
  821.     add.b    d0,$1b(a6)
  822.     rts
  823.  
  824. mt_nop:    move.w    $10(a6),$6(a5)
  825.     rts
  826.  
  827. mt_checkcom:
  828.     move.w    $2(a6),d0
  829.     and.w    #$fff,d0
  830.     beq.s    mt_nop
  831.     move.b    $2(a6),d0
  832.     and.b    #$f,d0
  833.     tst.b    d0
  834.     beq.L    mt_arpeggio
  835.     cmp.b    #$1,d0
  836.     beq.s    mt_portup
  837.     cmp.b    #$2,d0
  838.     beq.L    mt_portdown
  839.     cmp.b    #$3,d0
  840.     beq.L    mt_myport
  841.     cmp.b    #$4,d0
  842.     beq.L    mt_vib
  843.     move.w    $10(a6),$6(a5)
  844.     cmp.b    #$a,d0
  845.     beq.s    mt_volslide
  846.     rts
  847.  
  848. mt_volslide:
  849.     moveq    #0,d0
  850.     move.b    $3(a6),d0
  851.     lsr.b    #4,d0
  852.     tst.b    d0
  853.     beq.s    mt_voldown
  854.     add.w    d0,$12(a6)
  855.     cmp.w    #$40,$12(a6)
  856.     bmi.s    mt_vol2
  857.     move.w    #$40,$12(a6)
  858. mt_vol2:move.w    $12(a6),$8(a5)
  859.     rts
  860.  
  861. mt_voldown:
  862.     moveq    #0,d0
  863.     move.b    $3(a6),d0
  864.     and.b    #$f,d0
  865.     sub.w    d0,$12(a6)
  866.     bpl.s    mt_vol3
  867.     clr.w    $12(a6)
  868. mt_vol3:move.w    $12(a6),$8(a5)
  869.     rts
  870.  
  871. mt_portup:
  872.     moveq    #0,d0
  873.     move.b    $3(a6),d0
  874.     sub.w    d0,$10(a6)
  875.     move.w    $10(a6),d0
  876.     and.w    #$fff,d0
  877.     cmp.w    #$71,d0
  878.     bpl.s    mt_por2
  879.     and.w    #$f000,$10(a6)
  880.     or.w    #$71,$10(a6)
  881. mt_por2:move.w    $10(a6),d0
  882.     and.w    #$fff,d0
  883.     move.w    d0,$6(a5)
  884.     rts
  885.  
  886. mt_portdown:
  887.     clr.w    d0
  888.     move.b    $3(a6),d0
  889.     add.w    d0,$10(a6)
  890.     move.w    $10(a6),d0
  891.     and.w    #$fff,d0
  892.     cmp.w    #$358,d0
  893.     bmi.s    mt_por3
  894.     and.w    #$f000,$10(a6)
  895.     or.w    #$358,$10(a6)
  896. mt_por3:move.w    $10(a6),d0
  897.     and.w    #$fff,d0
  898.     move.w    d0,$6(a5)
  899.     rts
  900.  
  901. mt_checkcom2:
  902.     move.b    $2(a6),d0
  903.     and.b    #$f,d0
  904.     cmp.b    #$e,d0
  905.     beq.s    mt_setfilt
  906.     cmp.b    #$d,d0
  907.     beq.s    mt_pattbreak
  908.     cmp.b    #$b,d0
  909.     beq.s    mt_posjmp
  910.     cmp.b    #$c,d0
  911.     beq.s    mt_setvol
  912.     cmp.b    #$f,d0
  913.     beq.s    mt_setspeed
  914.     rts
  915.  
  916. mt_setfilt:
  917.     move.b    $3(a6),d0
  918.     and.b    #$1,d0
  919.     asl.b    #$1,d0
  920.     and.b    #$fd,$bfe001
  921.     or.b    d0,$bfe001
  922.     rts
  923. mt_pattbreak:
  924.     not.b    mt_break
  925.     rts
  926. mt_posjmp:
  927.     move.b    $3(a6),d0
  928.     subq.b    #$1,d0
  929.     move.b    d0,mt_songpos
  930.     not.b    mt_break
  931.     rts
  932. mt_setvol:
  933.     cmp.b    #$40,$3(a6)
  934.     ble.s    mt_vol4
  935.     move.b    #$40,$3(a6)
  936. mt_vol4:move.b    $3(a6),$8(a5)
  937.     rts
  938. mt_setspeed:
  939.     move.b    $3(a6),d0
  940.     and.w    #$1f,d0
  941.     beq.s    mt_rts2
  942.     clr.b    mt_counter
  943.     move.b    d0,mt_speed
  944. mt_rts2:rts
  945.  
  946. mt_sin:
  947. dc.b $00,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
  948. dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61,$4a,$31,$18
  949.  
  950. mt_periods:
  951. dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c,$023a,$021a,$01fc,$01e0
  952. dc.w $01c5,$01ac,$0194,$017d,$0168,$0153,$0140,$012e,$011d,$010d,$00fe
  953. dc.w $00f0,$00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097,$008f,$0087
  954. dc.w $007f,$0078,$0071,$0000,$0000
  955.  
  956. mt_speed:    dc.b    $6
  957. mt_songpos:    dc.b    $0
  958. mt_pattpos:    dc.w    $0
  959. mt_counter:    dc.b    $0
  960.  
  961. mt_break:    dc.b    $0
  962. mt_dmacon:    dc.w    $0
  963. mt_samplestarts:blk.l    $1f,0
  964. mt_voice1:    blk.w    10,0
  965.         dc.w    $1
  966.         blk.w    3,0
  967. mt_voice2:    blk.w    10,0
  968.         dc.w    $2
  969.         blk.w    3,0
  970. mt_voice3:    blk.w    10,0
  971.         dc.w    $4
  972.         blk.w    3,0
  973. mt_voice4:    blk.w    10,0
  974.         dc.w    $8
  975.         blk.w    3,0
  976. inter:
  977.         dc.l    0,0
  978.         dc.b    2,127
  979.         dc.l    0,0
  980.         dc.l    spadgewirq
  981. mt_data:
  982.         blk.b    67414,0
  983. mt_data1:
  984.         blk.b    61004,0
  985. done:
  986.