home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: Garfield In Game Music And FX(ST) / Lowe_GarfieldInGameMusicAndFX(ST).adf / eliteIItn.bak next >
Encoding:
Text File  |  2000-01-01  |  38.1 KB  |  2,447 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.     ;         ELITEII/FRONTIERS TEST SOURCE
  7.  
  8.  
  9.     ; DAVID
  10.     ;The place to insert your call for a new song
  11.     ; is called song_select
  12.     ; all the tunes branch there on ending except
  13.     ; The title tune now has a section tagged on the front
  14.     ; that runs straight into the main piece....song 10
  15.     ; it fades itself in
  16.     ; and plays for app. 23 seconds......
  17.  
  18.     ; you can still run tune 2 on its own if you wish
  19.     ; using song 2
  20.     ; An fx that is retriggered before it ends a previous
  21.     ; call is now only turned off in the interrupt section
  22.     ; so it should cure the click problem on the lazers etc.
  23.  
  24.     ;the wind fx requires you to kill it using kill_fx
  25.     ;and the duplicate one will now be out of sync.
  26.  
  27.  
  28.  
  29.     ;there is now a fade_up routine and a fade_out routine
  30.     ;they require the fade  rate (1 to 50)to be held in
  31.     ;d0 when calling..(this is the number of frames before
  32.     ;increasing or decreasing the value in FADE by #1)
  33.  
  34.  
  35.     ; I am not sure if you want a small gap on the end of the
  36.     ;tunes or to go straight into whatever is selected
  37.     ;at present I have implemented it both ways on different
  38.     ;tunes so you can try it and see.(its very easy to set
  39.     ;up either way....(give me a call)
  40.  
  41.  
  42.     ; the fxjump table now contains more fx and is fully
  43.     ;labelled
  44.  
  45.  
  46.     ; It must be assembled with SYMBOLS CASE independent.
  47.  
  48.     ; dont hesitate to ring with any problems
  49.  
  50.     ;        DAVE LOWE.....0723  870648
  51.  
  52. ;        **************************
  53.  
  54.     section issA,code_c    ;must be in low memory for dma access
  55.                 ;DEVPAC PSEUDO OP ..CAN BE DELETED
  56.  
  57.  
  58. ;*****************************************
  59.  
  60.         ;  ALL EQUs
  61.  
  62. a00  equ  508*2
  63. bb00  equ  480*2
  64. b00  equ  453*2
  65. c01  equ  428*2
  66. db01  equ  404*2
  67. d01 equ  381*2
  68. eb01  equ  360*2
  69. e01  equ  339*2
  70. f01  equ  320*2
  71. gb01  equ  302*2
  72. g01  equ  285*2
  73. ab01 equ 269*2
  74. a01  equ  508
  75. bb01  equ  480
  76. b01  equ  453
  77.  
  78. c02  equ  428
  79. db02  equ  404
  80. d02  equ  381
  81. eb02  equ  360
  82. e02  equ  339
  83. f02  equ  320
  84. gb02  equ  302
  85. g02  equ  285
  86. ab02 equ 269
  87. a02  equ  254
  88. bb02  equ  240
  89. b02  equ  226
  90.  
  91. c03  equ  214
  92. db03  equ  202
  93. d03  equ  190
  94. eb03  equ  180
  95. e03  equ  170
  96. f03  equ  160
  97. gb03  equ  151
  98. g03  equ  143
  99. ab03 equ 135
  100. a03  equ  127
  101.  
  102. bb03  equ  480*2
  103. b03  equ  453*2
  104.  
  105. c04  equ  428*2
  106. db04  equ  404*2
  107. d04 equ  381*2
  108. eb04  equ  360*2
  109. e04  equ  339*2
  110. f04  equ  320*2
  111. gb04  equ  302*2
  112. g04  equ  285*2
  113. ab04 equ 269*2
  114. a04  equ  508
  115. bb04  equ  480
  116. b04  equ  453
  117.  
  118. c05  equ  428
  119. db05  equ  404
  120. d05  equ  381
  121. eb05  equ  360
  122. e05  equ  339
  123. f05  equ  320
  124. gb05  equ  302
  125. g05  equ  285
  126. ab05 equ 269
  127. a05  equ  254
  128. bb05  equ  240
  129. b05  equ  226
  130.  
  131. c06  equ  214
  132. db06  equ  202
  133. d06  equ  190
  134. eb06  equ  180
  135. e06  equ  170
  136. f06  equ  160
  137. gb06  equ  151
  138. g06  equ  143
  139. ab06 equ 135
  140. a06  equ  127
  141. bb06  equ  480*2
  142. b06  equ  453*2
  143.  
  144. c07  equ  428*2
  145. db07  equ  404*2
  146. d07 equ  381*2
  147. eb07  equ  360*2
  148. e07  equ  339*2
  149. f07  equ  320*2
  150. gb07  equ  302*2
  151. g07  equ  285*2
  152. ab07 equ 269*2
  153. a07  equ  508
  154. bb07  equ  480
  155. b07  equ  453
  156.  
  157. c08  equ  428
  158. db08  equ  404
  159. d08  equ  381
  160. eb08  equ  360
  161. e08  equ  339
  162. f08  equ  320
  163. gb08  equ  302
  164. g08  equ  285
  165. ab08 equ 269
  166. a08  equ  254
  167. bb08  equ  240
  168. b08  equ  226
  169.  
  170.  
  171. v equ 0
  172.  
  173. no_loop equ 0
  174. loop equ 0
  175. chann1reg   equ $dff0a0    
  176. chann2reg   equ $dff0b0
  177. chann3reg   equ $dff0c0
  178. chann4reg   equ $dff0d0
  179. dmacon     equ $dff096
  180. int_bf_int   equ   $dff01e
  181. int_bf_w    equ   $dff09a
  182. vhposr     equ   $dff006
  183. in_line    equ   0
  184. new_snd    equ   4
  185. end_song     equ   1
  186. end_patt    equ   8
  187. new_env    equ   12
  188. pbend     equ   16
  189.  
  190.  
  191.  
  192. hi: equ 223
  193. lo:  equ 446
  194.  
  195. r22    equ 134
  196. r20    equ 179        ;correctum
  197. r19    equ 150
  198. r18    equ 178
  199. r17    equ 200
  200. r16:    equ 227        ;correctum
  201. r15:    equ 249
  202. r14    equ 280
  203. r13:    equ 305
  204. r12:    equ 333
  205. r11:    equ 361
  206. r10:    equ 389
  207. r9:    equ 419
  208. r8:    equ 446
  209. r7:    equ 446+112
  210. r6:    equ 446+223
  211. r5:    equ 446+223+112
  212. r4:    equ 446*2
  213. r3:    equ 446*3
  214. r2:    equ 446*4
  215. r1:    equ 446*8
  216.  
  217.  
  218. filter: equ $bfe001
  219. filter_on equ 44
  220. filter_off equ 48
  221.  
  222. modon     equ   20
  223. pboff     equ   24
  224. modoff     equ   28
  225. rest     equ 32
  226. end_fxp  equ 36
  227. end_fx3  equ 36
  228. end_fx4  equ 40
  229. acc    equ 52
  230. repeat    equ 56
  231. play_new_tune  equ 60  
  232. down      equ   1
  233. up       equ   2
  234.  
  235. ;***************************************************************
  236.  
  237.  
  238.  ;    THIS IS THE CONTROL SECTION FOR TESTING AS A STAND ALONE PRG. 
  239.  
  240.     ;       AND CAN BE DELETED WHEN NOT REQUIRED
  241.  
  242.     ;bra test_engine
  243.     jsr select_new_song    ;select first song and initiliase
  244.  
  245. testloop:
  246.     jsr delay    ;wait for scan line  at 50hz on pal
  247.  
  248.  
  249.     ;move.l #10,fx_number         every frame lazer test
  250.     ;move.w #64,d1
  251.     ;jsr set_up_fx
  252.  
  253.  
  254.     ;jsr test_fade
  255.     ;jsr en2    ;a test engine call
  256.     jsr driver    ;call music every interrupt
  257.  
  258.  
  259.     ;move.l #10,fx_number
  260.     ;move.w #64,d1
  261.     ;jsr set_up_fx    
  262.  
  263.         bra testloop    ;loop back
  264.  
  265. ;**************************************
  266.  
  267.                 ;dff00c  joystick port 1
  268.             ; bit1 right switch
  269.             ; bit9 left
  270.             ; bit 1 xor bit 0 for pulled back
  271.             ; 9 xor 8 for forward
  272.  
  273.  
  274.  
  275.  
  276. delay:
  277.     tst.w fxtimer
  278.     ;bne no_test
  279.     clr.l d0
  280.     move.b $bfe001,d0        ;
  281.     btst #6,d0
  282.     bne no_test1
  283.     move.w #10,fxtimer
  284.     bra testfx4
  285. no_test
  286.     subq #1,fxtimer
  287. no_test1
  288.     clr.l d0
  289.         move.w vhposr,d0
  290.         andi.w #%1111111100000000,d0
  291.         cmpi.w #%1111111100000000,d0
  292.  
  293.     bne no_test1
  294.     rts
  295.  
  296. testfx4:  
  297.  
  298.     ;jsr    kill_chip
  299.     ;move.w #1,int_disable
  300.     clr.l d0
  301.     move.b $bfe001,d0
  302.     btst #6,d0
  303.     beq testfx4
  304.  
  305.     move.l song_buffer,d0
  306.     addq.l #1,d0
  307.     cmp.l    #11,d0            ; 10 tunes in this test
  308.                     ; 8 = silence
  309.     bne nores    
  310.     move.l #1,d0
  311.  
  312. ;*******************************        HOW TO PLAY A NEW TUNE
  313.  
  314. nores    move.l d0,song_buffer
  315.  
  316.     ;jsr    select_new_song        ;this call sets up the tune
  317.                     ;number in the song buffer
  318.                     ;make sure music is enabled (see below)
  319.                     ;call is currently commented off
  320.                     ;so you can play fx over one tune
  321.  
  322.  
  323. ;*******************************    HOW TO KILL ANY LOOPED FX
  324.  
  325.     move.l fx_last,d0
  326.     move.l d0,fx_kill    ;  used on this demo
  327.  
  328.     ;jsr kill_loopfx    ; used to kill any  fx..not engines
  329.  
  330.  
  331. no_k
  332.         move.l fx_no,fx_number
  333.     move.l fx_no,fx_last
  334.     addq.l #1,fx_no
  335.     move.l    max_fx,d0
  336.         cmp.l fx_no,d0
  337.     bne noreset
  338.     move.l #39,fx_no    
  339. noreset: 
  340.  
  341. ;;**********************************  HOW TO PLAY AN FX ON THE
  342.                     ; NEXT 50th
  343.                     ; place fx number required in fx_no
  344.                     ; and do this call
  345.                     ; fx must be enabled...(see below)
  346.  
  347. ;test_fade
  348.      move.w #64,d1
  349.     ;sub.w #1,d1
  350.     ;cmp #0,d1
  351.     ;bgt novr    
  352.     ;move #64,testv
  353.     ;move.w #64,d1
  354. ;novr    ;move.w d1,testv
  355.     ;move.w d1,fade
  356.     
  357.             ; test vol for variable vol fx
  358.  
  359.  
  360.     ;cmp.l #31,fx_number
  361.     ;bne no_kill
  362.     ;jsr kill_all_fx
  363.     ;rts
  364.  
  365. no_kill
  366.  
  367.     cmp.l #37,fx_number
  368.     beq nof            ;duplicate infinite wind
  369.  
  370.  
  371.     cmp.l #14,fx_number
  372.     beq twinfx
  373.     jsr set_up_fx
  374.     ;jsr en2
  375.  
  376.     ;jsr kill_engine
  377.  
  378. nof    rts
  379.  
  380. twinfx  jsr set_up_fx
  381.     move.l #37,fx_number
  382.     jsr set_up_fx
  383.     rts
  384.  
  385.  
  386.  
  387. testv    dc.w 64
  388.  
  389. ;***************************************************************
  390.         
  391.  
  392.         ;;TEST ROUTINES SETTING UP AND UPDATING
  393.         ;; TWO DIFFERENT ENGINES
  394.  
  395.                 ;d0 = engine type 1 to 3
  396.                 ;d1 = engine vol
  397.                 ;d2 = engine rate
  398.                 ;d3 = engine seed (ident number)
  399.                 ;  up to word value 
  400.  
  401.  
  402. test_engines
  403.  
  404.     tst.w ref
  405.     beq doe1
  406.     rts
  407.  
  408. ref    dc.w 0
  409.  
  410. doe1
  411.     move.w #1,ref
  412.     move.w #1,d0
  413.     move.w test_vol,d1
  414.     tst.w d1
  415.     beq nosub
  416.     ;sub.w #1,d1
  417. nosub    move.w d1,test_vol
  418.     move.w test_rate,d2
  419.     cmp.w #130,d2
  420.     blt nosubx
  421.     sub.w #20,d2
  422. nosubx    
  423.     ;move.w d2,test_rate
  424.     move.w #101,d3
  425.  
  426. jjj1    jsr engines
  427.     rts
  428.  
  429. en2    
  430.  
  431. test_fade
  432.  
  433.     tst.w tek
  434.     bne fo
  435.  
  436.     add.w #1,en2x
  437.     cmp.w #10,en2x
  438.     blt fo
  439.  
  440.     clr.w en2x
  441.     move.w #3,d0        ;run 2nd engine
  442.     move.w #20,d1
  443.     move.w #400,d2
  444.     move.w #50,d3
  445.  
  446. ;test_fade
  447.  
  448.  
  449.      ;move.w testv,d1
  450.     ;sub.w #1,d1
  451.     ;cmp #0,d1
  452.     ;bgt novr    
  453.     ;move #0,testv
  454.     ;move.w #0,d1
  455. novr    ;move.w d1,testv
  456.     ;move.w d1,fade
  457.  
  458.     jsr engines
  459. fo    rts
  460.  
  461.  
  462.  
  463. kill_engine
  464.  
  465.     move.w #1,tek
  466.     move.w #3,d0        
  467.     move.w #1,d1    ;vol to 1
  468.     move.w #400,d2
  469.     move.w #50,d3
  470.     jsr engines
  471.     rts
  472.  
  473.  
  474.  
  475. en2x        dc.w 0
  476. test_rate    dc.w 500
  477. test_vol    dc.w 60
  478. tek        dc.w 0
  479.  
  480. ;***********************************
  481.  
  482.                 ; variables used by the test section
  483. tflag        dc.w 0
  484. fxtc:          dc.w 10        ; ignore them !!!!!
  485. fx_no:         dc.l  5
  486. fx_last        dc.l  5
  487.  
  488.  
  489. ;        END OF CONTROL (DELETABLE) SECTION
  490.  
  491. ;**********************************************************
  492.  
  493. ; --------------------------------------------------------------
  494.  
  495. ;    MAIN VARIABLES TO BE ACCESSED BY PROGRAMMER DURING RUNTIME
  496.  
  497.  
  498. fx_number:     dc.l 0 ;     number of fx required here...
  499. fx_kill        dc.l 0 ;     number of fx to kill/only needed for looped fx
  500.  
  501. song_buffer     dc.l 10;     number of piece of music required here ie.1 to 10
  502.  
  503. music_disable:  dc.w 0 ;     1 = disable music
  504. fx_disable:     dc.w 0 ;     1 = disable fx  (currently disabled)
  505.  
  506. fade         dc.w 0;      to fade music/fx out increase the
  507.             ; value in this location from 0 to 64
  508.             ; 0 = normal vol 64= silent.
  509.  
  510. ;    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  511.  
  512. ;  THESE VARIABLES ARE USED INTERNALLY BY THE DRIVER
  513. fxr1         dc.l 0  
  514. fxr2         dc.l 0  
  515. fxr3         dc.l 0  
  516. fxr4         dc.l 0  
  517. fxc1        dc.l 0
  518. fxc2          dc.l 0
  519. fxc3        dc.l 0
  520. fxc4          dc.l 0
  521. fxce1        dc.w 0
  522. fxce2        dc.w 0
  523. fxce3        dc.w 0
  524. fxce4        dc.w 0
  525. fx1_flag    dc.w 0
  526. fx2_flag    dc.w 0
  527. fx3_flag    dc.w 0
  528. fx4_flag    dc.w 0
  529. fx_c_used    dc.w 0
  530. fxtimer        dc.w 0
  531. gen        dc.w 0
  532. int_disable    dc.w 0
  533. altpf         dc.w 0
  534. kill_flag    dc.w 0
  535. fx_mode        dc.w 0
  536. existing_fx    dc.w 0
  537. channel_to_use  dc.w 0
  538. fflag        dc.w 0
  539. ftimer        dc.w 0        ;temp counter
  540. frate        dc.w 0
  541. mode        dc.w 0
  542.  
  543. ;  *******************************************************
  544.  
  545. ;  CALL THIS SUBROUTINE TO SET UP THE REQUIRED FX
  546. ;  on entry it requires the fx number to be in "fx_number"(see above)
  547.  
  548. ;********************
  549. ;        move.w #204,d0
  550. ;        lea gvars,a0
  551. ;clloop: clr.w (a0)+        
  552. ;        dbra  d0,clloop
  553. ;************************
  554. set_up_fx
  555.                 ;d1 holds vol for certain fx
  556.     move.w #1,int_disable
  557.  
  558.     movem.l d0/d1/d2/d5/a0/a2,-(a7)    ;save used registers
  559.     clr.w existing_fx        ;flag
  560.     clr.w channel_to_use        ;channel to use
  561.  
  562. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  563.                 ;test for fx already running on a channel
  564.                 ;and if so then store which channel
  565.     move.l fxc4,d0
  566.     move.w #4,channel_to_use
  567.     cmp.l fx_number,d0
  568.     beq set_e_flag            
  569.  
  570.     move.l fxc3,d0
  571.     move.w #3,channel_to_use
  572.     cmp.l fx_number,d0
  573.     beq set_e_flag            
  574.  
  575.     move.l fxc2,d0
  576.     move.w #2,channel_to_use
  577.     cmp.l fx_number,d0
  578.     beq set_e_flag            
  579.  
  580.     move.l fxc1,d0
  581.     move.w #1,channel_to_use
  582.     cmp.l fx_number,d0
  583.     beq set_e_flag            
  584.  
  585.     bra new_fx
  586.  
  587.         ;  fx already on a channel
  588. set_e_flag
  589.     move.w #1,existing_fx
  590.  
  591.     cmp.l #35,fx_number
  592.     beq check35
  593.  
  594.     cmp.l #36,fx_number
  595.     beq check36
  596.  
  597.     cmp.l #5,fx_number        ;vv test
  598.     blt fixed_vol            ;engine
  599.     cmp.l #13,fx_number
  600.     bgt test_for_loop
  601.                 ;this is a variable vol existing fx            
  602.                 ;is it louder than the existing fx ??
  603.         
  604.     move.l fx_number,d2
  605.     cmp.l #5,d2
  606.     bne isevv6
  607.     cmp.w vv1,d1
  608.     blt no_fx        ;too quiet so drop it
  609.     bra new_fx
  610.  
  611. isevv6
  612.     cmp.l #6,d2
  613.     bne isevv7
  614.     cmp.w vv2,d1
  615.     blt no_fx        ;too quiet so drop it
  616.     bra new_fx
  617.  
  618. isevv7
  619.     cmp.l #7,d2
  620.     bne isevv8
  621.     cmp.w vv3,d1
  622.     blt no_fx        ;too quiet so drop it
  623.     bra new_fx
  624.  
  625. isevv8
  626.     cmp.l #8,d2
  627.     bne isevv9
  628.     cmp.w vv4,d1
  629.     blt no_fx        ;too quiet so drop it
  630.     bra new_fx
  631.  
  632.  
  633. isevv9    cmp.l #9,d2
  634.     bne isevv10
  635.     cmp.w vv5,d1
  636.     blt no_fx        ;too quiet so drop it
  637.     bra new_fx
  638.     
  639. isevv10
  640.     cmp.l #10,d2
  641.     bne isevv11
  642.     cmp.w vv6,d1
  643.     blt no_fx        ;too quiet so drop it
  644.     bra new_fx
  645.  
  646. isevv11
  647.     cmp.l #11,d2
  648.     bne isevv12
  649.     cmp.w vv7,d1
  650.     blt no_fx        ;too quiet so drop it
  651.     bra new_fx
  652.  
  653. isevv12
  654.     cmp.l #12,d2
  655.     bne isevv13
  656.     cmp.w vv8,d1
  657.     blt no_fx        ;too quiet so drop it
  658.     bra new_fx
  659.  
  660. isevv13
  661.     cmp.w vv8,d1
  662.     blt no_fx        ;too quiet so drop it
  663.     bra new_fx
  664.  
  665. check35
  666.     cmp.w vv10,d1
  667.     blt no_fx
  668.     bra new_fx
  669.  
  670. check36
  671.  
  672.     cmp.w vv11,d1
  673.     blt no_fx
  674.  
  675. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  676. new_fx
  677.     cmp.l #35,fx_number
  678.     beq write35
  679.  
  680.     cmp.l #36,fx_number
  681.     beq write36
  682.  
  683.     cmp.l #5,fx_number
  684.     blt fixed_vol
  685.     cmp.l #13,fx_number
  686.     bgt test_for_loop
  687.                 ;variable vol fx
  688.     move.l fx_number,d2
  689.     cmp.l #5,d2
  690.     beq writevv1
  691.     cmp.l #6,d2
  692.     beq writevv2
  693.     cmp.l #7,d2
  694.     beq writevv3
  695.     cmp.l #8,d2
  696.     beq writevv4
  697.     cmp.l #9,d2
  698.     beq writevv5
  699.     cmp.l #10,d2
  700.     beq writevv6
  701.     cmp.l #11,d2
  702.     beq writevv7
  703.  
  704.     lea vv8,a0    ;write12 and 13
  705.     bra wv
  706.  
  707. writevv7
  708.     lea vv7,a0
  709.     bra wv
  710. writevv6
  711.     lea vv6,a0
  712.     bra wv
  713. writevv5
  714.     lea vv5,a0
  715.     bra wv
  716. writevv4
  717.     lea vv4,a0
  718.     bra wv
  719. writevv3
  720.     lea vv3,a0
  721.     bra wv
  722. writevv2
  723.     lea vv2,a0
  724.     bra wv
  725. writevv1
  726.     lea vv1,a0
  727.  
  728. wv    move.w d1,(a0)    
  729.     bra fixed_vol
  730.  
  731. write35
  732.     lea vv10,a0
  733.     bra wv
  734.  
  735. write36
  736.     lea vv11,a0
  737.     bra wv
  738.  
  739.  
  740.  
  741. ; ............................
  742. test_for_loop
  743.     cmp.l #17,fx_number
  744.     bgt fixed_vol
  745.  
  746.     move.l fx_number,d2
  747.                 ;is this fx already running
  748.     cmp.l fxc4,d2
  749.     beq is_on
  750.     cmp.l fxc3,d2
  751.     beq is_on
  752.     cmp.l fxc2,d2
  753.     beq is_on
  754.     cmp.l fxc1,d2
  755.     beq is_on
  756.                 ;fx not already on
  757.     bra set_loop_counters    ;so set it up and run it
  758.  
  759. is_on
  760.     cmp.l #14,d2        ;wind ?
  761.     bne cl2
  762.     move.w #2,loopc1    ;reset timer
  763.     bra no_fx
  764.  
  765. cl2
  766.     cmp.l #15,d2        ;space_stat ?
  767.     bne cl3
  768.     move.w #1,loopc2    ;reset timer
  769.     bra no_fx
  770.  
  771. cl3
  772.     cmp.l #16,d2        ;factories?
  773.     bne cl4
  774.     move.w #2,loopc3    ;reset timer
  775.     bra no_fx
  776.  
  777. cl4
  778.     cmp.l #17,d2        ;fuelscoop?
  779.     bne fixed_vol
  780.     move.w #2,loopc4    ;reset timer
  781.     bra no_fx
  782.  
  783. set_loop_counters
  784.  
  785.     cmp.l #14,d2        ;wind ?
  786.     bne cl2x
  787.     move.w #1,loopc1    ;reset timer
  788.     bra fixed_vol
  789.  
  790. cl2x
  791.     cmp.l #15,d2        ;space_stat ?
  792.     bne cl3x
  793.     move.w #1,loopc2    ;reset timer
  794.     bra fixed_vol
  795.  
  796. cl3x
  797.     cmp.l #16,d2        ;factories?
  798.     bne cl4x
  799.     move.w #2,loopc3    ;reset timer
  800.     bra fixed_vol
  801.  
  802. cl4x
  803.     cmp.l #17,d2        ;fuelscoop?
  804.     bne no_fx
  805.     move.w #2,loopc4    ;reset timer
  806.  
  807.  
  808. ;..............................
  809. fixed_vol
  810.  
  811.  
  812.     cmp.l #31,fx_number
  813.     beq use4        ;ship die to 4
  814.  
  815.  
  816.     tst.w existing_fx
  817.     beq sort_channel
  818.                 ;find channel to overwrite existing fx on
  819.  
  820.     cmp.w #4,channel_to_use
  821.     beq    use4
  822.     cmp.w #3,channel_to_use
  823.     beq    use3
  824.     cmp.w #2,channel_to_use
  825.     beq    use2
  826.     bra     use1
  827. ;     ****************
  828.  
  829.  
  830. sort_channel
  831.     tst.l fxc4
  832.     bne check3
  833.     tst.w fxce4
  834.     bne check3
  835.  
  836. use4:    
  837.     move.w #%0000000000001000,d5
  838.     lea chann4reg,a2
  839.     ;jsr end_fx4p
  840.     ;move.l #0,fxc4
  841.  
  842. ch4xx    move.w #32,d0
  843.     lea fxintc4,a0
  844. cfx4l:  clr.w (a0)+    
  845.     dbra d0,cfx4l
  846.  
  847.  
  848.     move.l fx_number,fxr4
  849.     move.l fx_number,fxc4
  850.     move.l #0,fx_number
  851.     move.w #4,fx_c_used        ;channel used
  852.     bra no_fx
  853.  
  854.  
  855. check3:    tst.l fxc3
  856.     bne check2
  857.     tst.w fxce3
  858.     bne check2
  859. use3:
  860.     move.w #%0000000000000100,d5
  861.     lea chann3reg,a2
  862.     ;jsr end_fx3p
  863.     ;move.l #0,fxc3
  864.  
  865. ch3xx    move.w #32,d0
  866.     lea fxintc3,a0
  867. cfx3l:  clr.w (a0)+    
  868.     dbra d0,cfx3l
  869.     move.l fx_number,fxr3
  870.     move.l fx_number,fxc3
  871.     move.l #0,fx_number
  872.     move.w #3,fx_c_used        ;channel used
  873.     bra no_fx
  874.  
  875.  
  876.  
  877.  
  878. check2:    tst.l fxc2
  879.     bne check1
  880.     tst.w fxce2
  881.     bne check1
  882. use2:
  883.     move.w #%0000000000000010,d5
  884.     lea chann2reg,a2
  885.     ;jsr end_fx2p
  886.     ;move.l #0,fxc2
  887.  
  888. ch2xx    move.w #32,d0
  889.     lea fxintc2,a0
  890. cfx2l:  clr.w (a0)+    
  891.     dbra d0,cfx2l
  892.  
  893.     move.l fx_number,fxr2
  894.     move.l fx_number,fxc2
  895.     move.l #0,fx_number
  896.     move.w #2,fx_c_used        ;channel used
  897.     bra no_fx
  898. check1:    tst.l fxc1
  899.     bne  no_room
  900.     tst.w fxce1
  901.     bne no_room
  902.  
  903.  
  904. use1
  905.     move.w #%0000000000000001,d5
  906.     lea chann1reg,a2
  907.     ;jsr end_fx1p
  908.     ;move.l #0,fxc1
  909.  
  910. ch1xx    move.w #32,d0
  911.     lea fxintc1,a0
  912. cfx1l:  clr.w (a0)+    
  913.     dbra d0,cfx1l
  914.  
  915.     move.l fx_number,fxr1
  916.     move.l fx_number,fxc1
  917.     move.l #0,fx_number
  918.     move.w #1,fx_c_used        ;channel used
  919.  
  920. no_fx
  921.     clr.w int_disable
  922.     movem.l (a7)+,d5/d2/d1/d0/a2/a0    ;restore registers
  923.     rts
  924. no_room
  925.     tst.w fx_mode
  926.     beq  overwrite            ;actual fx
  927.  
  928.     move.w #255,fx_c_used        ; no channel used
  929.     bra no_fx
  930.  
  931.  
  932.  
  933. overwrite
  934.     tst.w fxce4
  935.     bne oc3
  936.     bra use4
  937. oc3    tst.w fxce3
  938.     bne oc2
  939.     bra use3
  940. oc2    tst.w fxce2
  941.     bne oc1
  942.     bra use2
  943. oc1    tst.w fxce1
  944.     bne use1
  945.     bra use1
  946.  
  947. ;*************************************************
  948. ;          CALL HERE TO KILL ANY FX...
  949. ;       after putting the number of the fx you want to kill
  950. ;            into fx_kill
  951.  
  952. kill_loopfx
  953.  
  954.     movem.l d5/a2,-(a7)    ;save used registers
  955.     move.l fx_kill,d5
  956.     cmp.l fxc1,d5
  957.     bne k2
  958.     move.w #%0000000000000001,d5
  959.     lea chann1reg,a2
  960.     jsr end_fx1p
  961.     bra error
  962. k2    cmp.l fxc2,d5
  963.     bne k3
  964.     move.w #%0000000000000010,d5
  965.     lea chann2reg,a2
  966.     jsr end_fx2p
  967.     bra error
  968. k3    cmp.l fxc3,d5
  969.     bne k4
  970.     move.w #%0000000000000100,d5
  971.     lea chann3reg,a2
  972.     jsr end_fx3p
  973.     bra error
  974. k4    cmp.l fxc4,d5
  975.     bne error
  976.     move.w #%0000000000001000,d5
  977.     lea chann4reg,a2
  978.     jsr end_fx4p
  979. error
  980.     clr.l fx_kill
  981.     movem.l (a7)+,d5/a2    ;restore registers
  982.     rts
  983. ;************************************************
  984.  
  985.     ;CALL HERE TO KILL ALL FX
  986.  
  987. kill_all_fx:
  988.  
  989.     movem.l d5/a0,-(a7)    ;save used registers
  990.  
  991.     move.w #%0000000000001000,d5
  992.     lea chann4reg,a2
  993.     jsr end_fx4p
  994.     move.w #32,d0
  995.     lea fxintc4,a0
  996. cfx4lx:  clr.w (a0)+    
  997.     dbra d0,cfx4lx
  998.  
  999.     move.w #%0000000000000100,d5
  1000.     lea chann3reg,a2
  1001.     jsr end_fx3p
  1002.     move.w #32,d0
  1003.     lea fxintc3,a0
  1004. cfx3lx:  clr.w (a0)+    
  1005.     dbra d0,cfx3lx
  1006.  
  1007.     move.w #%0000000000000010,d5
  1008.     lea chann2reg,a2
  1009.     jsr end_fx2p
  1010.     move.w #32,d0
  1011.     lea fxintc2,a0
  1012. cfx2lx:  clr.w (a0)+    
  1013.     dbra d0,cfx2lx
  1014.  
  1015.     move.w #%0000000000000001,d5
  1016.     lea chann1reg,a2
  1017.     jsr end_fx1p
  1018.     move.w #32,d0
  1019.     lea fxintc1,a0
  1020. cfx1lx:  clr.w (a0)+    
  1021.     dbra d0,cfx1lx
  1022.  
  1023.     movem.l (a7)+,d5/a0    ;restore registers
  1024.     rts
  1025.  
  1026.  
  1027. ;*************************************************
  1028.  
  1029.     ; CALL HERE TO KILL ANY SOUND for whatever reason
  1030.  
  1031. kill_chip:
  1032.     move.w #%0000000000001111,dmacon
  1033.     move.l rest_data,chann1reg
  1034.     move.l rest_data,chann2reg
  1035.     move.l rest_data,chann3reg
  1036.     move.l rest_data,chann4reg
  1037.     move.w #16,chann1reg+4    
  1038.     move.w #16,chann2reg+4    
  1039.     move.w #16,chann3reg+4    
  1040.     move.w #16,chann4reg+4    
  1041.     move.w #0,chann1reg+8
  1042.     move.w #0,chann2reg+8
  1043.     move.w #0,chann3reg+8
  1044.     move.w #0,chann4reg+8
  1045.     move.w #1,chann1reg+6
  1046.     move.w #1,chann2reg+6
  1047.     move.w #1,chann3reg+6
  1048.     move.w #1,chann4reg+6
  1049.     move.l #0,fxr1
  1050.     move.l #0,fxr2
  1051.     move.l #0,fxr3
  1052.     move.l #0,fxr4
  1053.     move.w #0,fx1_flag
  1054.     move.w #0,fx2_flag
  1055.     move.w #0,fx3_flag
  1056.     move.w #0,fx4_flag
  1057.     move.l #0,fxc1
  1058.     move.l #0,fxc2
  1059.     move.l #0,fxc3
  1060.     move.l #0,fxc4
  1061.     clr.w fx_mode
  1062.     rts
  1063.  
  1064. ;*******************************
  1065.  
  1066.             ;d0 holds fade rate value 0 to 50
  1067. fade_up    
  1068.     move.w #1,fflag    ;set flag for up
  1069.     move.w d0,frate
  1070.     move.w #64,fade        ;fade value to max
  1071.     rts
  1072.  
  1073. fade_out
  1074. fade_down
  1075.     move.w #2,fflag    ;set flag for up
  1076.     move.w d0,frate
  1077.     move.w #0,fade        ;fade value to max
  1078.     rts
  1079.  
  1080.  
  1081. ;*****************************
  1082. engines
  1083.     movem.l d4/d5/d6/a2/a0/a1,-(a7)    ;save used registers
  1084.  
  1085.     ;ENGINE RUNTIME ROUTINES
  1086.  
  1087.                 ;d0 = engine type 1 to 3
  1088.                 ;d1 = engine vol
  1089.                 ;d2 = engine rate
  1090.                 ;d3 = engine seed (ident number)
  1091.  
  1092.                 ;check engine has legal volume
  1093.     tst.w d1
  1094.     beq end_engine        ;drop it
  1095.     cmp.w #64,d1
  1096.     bgt end_engine
  1097.  
  1098.  
  1099.         ;decide if engine is new
  1100.     lea engine1_vars,a1
  1101.     tst.w (a1)
  1102.     beq ten2
  1103.     cmp.w engine1_seed,d3
  1104.  
  1105.     beq existing_engine  
  1106. ten2
  1107.     lea engine2_vars,a1
  1108.     tst.w (a1)
  1109.     beq ten3
  1110.     cmp.w engine2_seed,d3
  1111.     beq existing_engine  
  1112. ten3
  1113.     lea engine3_vars,a1
  1114.     tst.w (a1)
  1115.     beq ten4
  1116.     cmp.w engine3_seed,d3
  1117.     beq existing_engine  
  1118. ten4
  1119.     lea engine4_vars,a1
  1120.     tst.w (a1)
  1121.     beq setup_engine
  1122.     cmp.w engine4_seed,d3
  1123.     beq existing_engine  
  1124.                 ;engine not already in range
  1125.                 ;so find if spare channel available
  1126.  
  1127. setup_engine
  1128.     cmp.w #1,d0                     
  1129.     bne sej1
  1130.     lea engine1p,a0
  1131.     bra set_p
  1132. sej1    cmp.w #2,d0     
  1133.     bne sej3                
  1134.     lea engine2p,a0
  1135.     bra set_p
  1136. sej3    lea engine3p,a0
  1137. set_p
  1138.                 ;a0 = engine type address    
  1139.     tst engine1_vars    
  1140.     bne te2
  1141. ue1    lea engine1_vars,a1
  1142.     lea current_engine1_fx,a2
  1143.     move.l #1,d6
  1144.     bra do_set_up
  1145. te2
  1146.     tst engine2_vars    
  1147.     bne te3
  1148. ue2    lea engine2_vars,a1
  1149.     lea current_engine2_fx,a2
  1150.     move.l #2,d6
  1151.     bra do_set_up
  1152. te3
  1153.     tst engine3_vars    
  1154.     bne te4
  1155. ue3    lea engine3_vars,a1
  1156.     lea current_engine3_fx,a2
  1157.     move.l #3,d6
  1158.     bra do_set_up
  1159. te4
  1160.     tst engine4_vars    
  1161.     bne test_vols
  1162. ue4    lea engine4_vars,a1
  1163.     lea current_engine4_fx,a2
  1164.     move.l #4,d6
  1165.     bra do_set_up
  1166.  
  1167. test_vols            ;all channels running so
  1168.                 ;find current smallest vol
  1169.     move.w #1,d5
  1170.     move.w engine1_vol,d4
  1171.     cmp engine2_vol,d4
  1172.     blt test3        ;1 is smaller than 2
  1173.     move.w #2,d5
  1174.     move.w engine2_vol,d4
  1175. test3
  1176.     cmp engine3_vol,d4    
  1177.     blt test4        ;1 or 2 is smaller
  1178.     move.w #3,d5
  1179.     move.w engine3_vol,d4
  1180. test4
  1181.     cmp engine4_vol,d4
  1182.     blt vol_test_d
  1183.     move.w #4,d5
  1184.     move.w engine4_vol,d4
  1185. vol_test_d            ;smallest vol engine number in d5
  1186.                 ;its volume in d4
  1187.           cmp.w d1,d4         ;cmp new vol
  1188.     bgt end_engine        ;drop new engine fx.......    
  1189.     cmp.w #1,d5        
  1190.     beq ue1
  1191.     cmp.w #2,d5        
  1192.     beq ue2
  1193.     cmp.w #3,d5        
  1194.     beq ue3
  1195.     bra ue4
  1196.  
  1197. do_set_up
  1198.     jsr pass_p        ;write paramters to vars
  1199.  
  1200.  
  1201.                 ; write parameters to fx pattern
  1202.     move.l a0,8(a2)
  1203.     move.w d2,12(a2)                
  1204.     move.w #200,14(a2)    ;2 second min    
  1205.     move.w d1,20(a2)
  1206.  
  1207.     move.l d6,(fx_number)
  1208.  
  1209.     move.w #1,(fx_mode)
  1210.     jsr set_up_fx
  1211.     clr.w (fx_mode)    
  1212.                 ;d0 = amiga channel used
  1213.     cmp #255,fx_c_used
  1214.     beq end_engine        ;no free channels
  1215.     move.w fx_c_used,14(a1)    ;channel to vars
  1216.     move.w fx_c_used,d0
  1217.     cmp.w #4,d0
  1218.     bne re3    
  1219.     clr.l fxc4
  1220.     move.w #1,fxce4
  1221.     bra end_engine
  1222.  
  1223. re3
  1224.     cmp.w #3,d0
  1225.     bne re2    
  1226.     clr.l fxc3
  1227.     move.w #1,fxce3
  1228.     bra end_engine
  1229.  
  1230. re2
  1231.     cmp.w #2,d0
  1232.     bne re1    
  1233.     clr.l fxc2
  1234.     move.w #1,fxce2
  1235.     bra end_engine
  1236.  
  1237. re1
  1238.     clr.l fxc1
  1239.     move.w #1,fxce1
  1240.  
  1241. end_engine
  1242.     movem.l (a7)+,d5/d4/d6/a2/a1/a0    ;restore registers
  1243.     rts
  1244.  
  1245. ;                        """"""""""""""""""""""""""""""
  1246. existing_engine
  1247.     jsr passpj1
  1248.     jsr update_engine
  1249.     bra end_engine
  1250.  
  1251. pass_p                ;a1 = which engine vars to use/d5=1 to 4
  1252.                 ;a0 = address of type parameters
  1253.  
  1254.     move.w #1,(a1)        ;reset flag/count to 1
  1255.  
  1256.             ;first turn off the engine already on this channel
  1257.     move.w 14(a1),d4
  1258.     cmp.w #4,d4
  1259.     bne pj1
  1260.     clr.w fxce4    
  1261.     bra passpj1
  1262. pj1    cmp.w #3,d4
  1263.     bne pj2
  1264.     clr.w fxce3    
  1265.     bra passpj1
  1266. pj2    cmp.l #2,d4
  1267.     bne pj3
  1268.     clr.w fxce2    
  1269.     bra passpj1
  1270. pj3    clr.w fxce1    
  1271.  
  1272. passpj1    
  1273.  
  1274.         ;pass engine parameters to engine vars    
  1275.     move.w #1,(a1)        ;set on/off flag
  1276.     move.w d0,2(a1)
  1277.     move.w d1,4(a1)
  1278.     move.w d2,6(a1)
  1279.     move.w d3,8(a1)
  1280.     move.l a0,10(a1)
  1281.     clr.w 16(a1)
  1282.     rts
  1283.  
  1284. update_engine        ; (a0)= engine vars
  1285.             ;only used after driver has set sample running
  1286.         
  1287.     move.l a1,a0
  1288.     clr.w 16(a0)        ;timer to 0
  1289. update2
  1290.     move.w 14(a0),d0    ;amiga channel
  1291.     cmp.w #4,d0
  1292.     bne uej1
  1293.     tst.l fxc4
  1294.     bne off_engine
  1295.     lea chann4reg,a1
  1296.     bra write_engine
  1297.  
  1298. uej1    cmp.w #3,d0
  1299.     bne uej2
  1300.     tst.l fxc3
  1301.     bne off_engine
  1302.     lea chann3reg,a1
  1303.     bra write_engine
  1304.  
  1305. uej2    cmp.w #2,d0
  1306.     bne uej3
  1307.     tst.l fxc2
  1308.     bne off_engine
  1309.     lea chann2reg,a1
  1310.     bra write_engine
  1311. uej3
  1312.     tst.l fxc1
  1313.     bne off_engine
  1314.     lea chann1reg,a1
  1315.     bra write_engine
  1316.  
  1317. off_engine
  1318.     clr.w (a0)        ;flag to off
  1319.     clr.w 8(a0)        ;seed to 0
  1320.     rts
  1321.  
  1322. write_engine        ;a1 points to registers
  1323.     move.w 4(a0),8(a1)    ;vol to chip
  1324.     move.w 6(a0),6(a1)    ;rate to chip
  1325.     rts
  1326.  
  1327.  
  1328.  
  1329. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  1330.             ;current engine pattern buffer
  1331.  
  1332. current_engine1_fx
  1333.               dc.w new_env
  1334.            dc.l current_engine1_env
  1335.               dc.w new_snd
  1336.           dc.l 0            ;+8    ;paramters
  1337.  
  1338.         dc.w    0        ;+12   rate
  1339.         dc.w    0        ;+ 14 duration
  1340.         
  1341.  
  1342.       dc.w end_fxp
  1343.  
  1344. current_engine1_env:    dc.w 0,0,255    ;+20 vol
  1345.  
  1346.  
  1347. current_engine2_fx
  1348.       dc.w new_env
  1349.       dc.l current_engine2_env
  1350.       dc.w new_snd
  1351.       dc.l 0
  1352.  
  1353. ce2_rate    dc.w    0
  1354. ce2_time    dc.w    0        ;1 sec max without refresh    
  1355.         
  1356.  
  1357.       dc.w end_fxp
  1358.  
  1359. current_engine2_env:    dc.w 0,0,255
  1360.  
  1361.  
  1362. current_engine3_fx
  1363.       dc.w new_env
  1364.        dc.l current_engine3_env
  1365.       dc.w new_snd
  1366.       dc.l 0
  1367.  
  1368. ce3_rate    dc.w    0
  1369. ce3_time    dc.w    0        ;1 sec max without refresh    
  1370.         
  1371.  
  1372.       dc.w end_fxp
  1373.  
  1374. current_engine3_env:    dc.w 0,0,255
  1375.  
  1376.  
  1377. current_engine4_fx
  1378.       dc.w new_env
  1379.       dc.l current_engine4_env
  1380.       dc.w new_snd
  1381.       dc.l 0
  1382.  
  1383. ce4_rate    dc.w    0
  1384. ce4_time    dc.w    0        ;1 sec max without refresh    
  1385.         
  1386.  
  1387.       dc.w end_fxp
  1388.  
  1389. current_engine4_env:    dc.w 0,0,255
  1390.  
  1391.  
  1392. engine1_vars    dc.w 0        ;on off flag
  1393. engine1_type    dc.w 0
  1394. engine1_vol    dc.w 0
  1395. engine1_rate    dc.w 0
  1396. engine1_seed    dc.w 0        ;+8
  1397. engine1_type_p    dc.l 0        ;address of type 1 to 3
  1398. acu1        dc.w 0        ;amiga channel used
  1399. e1timer        dc.w 0
  1400.  
  1401.  
  1402. engine2_vars    dc.w 0
  1403. engine2_type    dc.w 0
  1404. engine2_vol    dc.w 0
  1405. engine2_rate    dc.w 0
  1406. engine2_seed    dc.w 0
  1407. engine2_type_p    dc.l 0
  1408. acu2        dc.w 0        ;amiga channel used
  1409. e2timer        dc.w 0
  1410.  
  1411.  
  1412. engine3_vars    dc.w 0
  1413. engine3_type    dc.w 0
  1414. engine3_vol    dc.w 0
  1415. engine3_rate    dc.w 0
  1416. engine3_seed    dc.w 0
  1417. engine3_type_p    dc.l 0
  1418. acu3        dc.w 0        ;amiga channel used
  1419. e3timer        dc.w 0
  1420.  
  1421.  
  1422. engine4_vars    dc.w 0
  1423. engine4_type    dc.w 0
  1424. engine4_vol    dc.w 0
  1425. engine4_rate    dc.w 0
  1426. engine4_seed    dc.w 0
  1427. engine4_type_p    dc.l 0
  1428. acu4        dc.w 0        ;amiga channel used
  1429. e4timer        dc.w 0
  1430.  
  1431.  
  1432. ;****************************************
  1433.  
  1434. ;  CALL HERE TO SELECT WHICH PIECE OF MUSIC TO PLAY
  1435. ;  AFTER PLACING NUMBER (1 to ?) IN "SONG_BUFFER"..see above
  1436. ;  a call to this routine will initiliase the driver/kill any sound etc.      
  1437. ;  make sure this routine has been called before running the interrupt
  1438. ;  driven section....see below
  1439.  
  1440. start_timer    dc.w 0
  1441.  
  1442. select_new_song:
  1443.  
  1444.     move.w #1,int_disable
  1445.     movem.l d0/d1/a0/a1,-(a7)    ;save used registers
  1446.     move.w music_disable,gen
  1447.     move.w #1,music_disable
  1448.         jsr kill_chip           
  1449.     clr.l d0
  1450.         move.w #204,d0
  1451.         lea gvars,a0
  1452. clloop: clr.w (a0)+        
  1453.         dbra  d0,clloop
  1454.     tst.l song_buffer
  1455.     beq no_song
  1456.         move.l song_buffer,d1
  1457.     add.l d1,d1
  1458.      add.l d1,d1
  1459.      add.l d1,d1
  1460.      add.l d1,d1
  1461.         LEA  SONG_TABLE-16,A1
  1462.         add.l d1,a1      
  1463.         MOVE.L (A1)+,WSONG1    
  1464.         move.l (a1)+,wsong2    
  1465.         move.l (a1)+,wsong3
  1466.     move.l (a1),wsong4
  1467.         MOVE.L #pstart,PATTR1
  1468.         MOVE.L #pstart,PATTR2
  1469.         MOVE.L #pstart,PATTR3
  1470.     move.l #pstart,pattr4
  1471.         move.l #sstart,songr1
  1472.         MOVE.L #sstart,SONGR2
  1473.         MOVE.L #sstart,SONGR3
  1474.     move.l #sstart,songr4
  1475. no_song
  1476.     move.w #1,ch1vars
  1477.     move.w #2,ch2vars
  1478.     move.w #3,ch3vars
  1479.     move.w #4,ch4vars
  1480.     move.w #6,ch4fxvars
  1481.     move.w #5,ch3fxvars
  1482.     move.w #7,ch2fxvars
  1483.     move.w #8,ch1fxvars
  1484.     move.w gen,music_disable
  1485.     clr.w int_disable
  1486.     clr.w fade
  1487.     clr.w fflag
  1488.     clr.w engine1_vars
  1489.     clr.w engine2_vars
  1490.     clr.w engine3_vars
  1491.     clr.w engine4_vars
  1492.     clr.w fxce1
  1493.     clr.w fxce2
  1494.     clr.w fxce3
  1495.     clr.w fxce4
  1496.  
  1497.     cmp.l #10,song_buffer        ;intro tagged piece
  1498.     bne no_sps
  1499.     move.w #12,d0     
  1500.     jsr fade_up
  1501. no_sps
  1502.     movem.l (a7)+,d0/d1/a0/a1    ;restore registers
  1503.         rts
  1504.  
  1505. ;**************************************************
  1506.  
  1507. ;  CALL HERE ON A 50hz INTERRUPT DURING RUNTIME
  1508. ;  TO PLAY FX AND TUNES
  1509.  
  1510. driver:  
  1511.  
  1512.     tst.w int_disable
  1513.     beq process_data
  1514.     rts        
  1515. process_data
  1516.     movem.l d0-d6/a0-a6,-(a7)    ;save used registers
  1517.  
  1518. ;******************************
  1519.                 ;fade section
  1520.     tst.w fflag
  1521.     beq proj1
  1522.     cmp.w #1,fflag
  1523.     bne tfo
  1524.     move.w ftimer,d0
  1525.     add.w #1,d0
  1526.     move.w d0,ftimer
  1527.     cmp.w frate,d0
  1528.     bne proj1
  1529.     sub.w #1,fade
  1530.     clr.w ftimer
  1531.     tst.w fade
  1532.     bne proj1
  1533.     clr.w fflag
  1534.     bra proj1
  1535. tfo
  1536.     move.w ftimer,d0
  1537.     add.w #1,d0
  1538.     move.w d0,ftimer
  1539.     cmp.w frate,d0
  1540.     bne proj1
  1541.     add.w #1,fade
  1542.     clr.w ftimer
  1543.     cmp.w #64,fade
  1544.     bne proj1
  1545.     clr.w fflag
  1546.  
  1547. ;*******************************
  1548. proj1
  1549.     lea engine1_vars,a0
  1550.     tst.w (a0)
  1551.     beq tt2
  1552.     add.w #1,16(a0)
  1553.     cmp.w #51,16(a0)
  1554.     blt tt2
  1555.     sub.w #1,4(a0)
  1556.     jsr update2
  1557.  
  1558. tt2
  1559.  
  1560.     lea engine2_vars,a0
  1561.     tst.w (a0)
  1562.     beq tt3
  1563.     add.w #1,16(a0)
  1564.     cmp.w #51,16(a0)
  1565.     blt tt3
  1566.     sub.w #1,4(a0)
  1567.     jsr update2
  1568.  
  1569. tt3
  1570.     lea engine3_vars,a0
  1571.     tst.w (a0)
  1572.     beq tt4
  1573.     add.w #1,16(a0)
  1574.     cmp.w #51,16(a0)
  1575.     blt tt4
  1576.     sub.w #1,4(a0)
  1577.     jsr update2
  1578. tt4
  1579.     lea engine4_vars,a0
  1580.     tst.w (a0)
  1581.     beq etf
  1582.     add.w #1,16(a0)
  1583.     cmp.w #51,16(a0)
  1584.     blt etf
  1585.     sub.w #1,4(a0)
  1586.     jsr update2
  1587.  
  1588. etf
  1589.  
  1590. ;^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1591.         ;service engine vars
  1592.         ; if an engine volume is at 0 then turn it off
  1593.  
  1594.     lea engine1_vars,a0
  1595.     tst.w (a0)
  1596.     beq tev2        ;no engine here
  1597.     cmp.w #1,4(a0)        ;vol at 0
  1598.     bgt tev2
  1599. rb    clr.w (a0)
  1600.     clr.w 8(a0)
  1601.     clr.w 16(a0)
  1602.     move.w acu1,d0
  1603.     jsr clear_amiga_channel
  1604.  
  1605.  
  1606. tev2
  1607.     lea engine2_vars,a0
  1608.     tst.w (a0)
  1609.     beq tev3        ;no engine here
  1610.  
  1611.     cmp.w #1,4(a0)        ;vol at 0
  1612.     bgt tev3
  1613.     clr.w (a0)
  1614.     clr.w 8(a0)
  1615.     clr.w 16(a0)
  1616.     move.w acu2,d0
  1617.     jsr clear_amiga_channel
  1618.  
  1619. tev3
  1620.     lea engine3_vars,a0
  1621.     tst.w (a0)
  1622.     beq tev4        ;no engine here
  1623.     cmp.w #1,4(a0)        ;vol at 0
  1624.     bgt tev4
  1625.     clr.w (a0)
  1626.     clr.w 8(a0)
  1627.     clr.w 16(a0)
  1628.     move.w acu3,d0
  1629.     jsr clear_amiga_channel
  1630. tev4
  1631.     lea engine4_vars,a0
  1632.     tst.w (a0)
  1633.     beq ch1            ;no engine here
  1634.     cmp.w #1,4(a0)        ;vol at 0
  1635.     bne ch1
  1636.     clr.w (a0)
  1637.     clr.w 8(a0)
  1638.     clr.w 16(a0)
  1639.     move.w acu4,d0
  1640.     jsr clear_amiga_channel
  1641.     bra ch1
  1642.  
  1643. clear_amiga_channel
  1644.     cmp.w #4,d0
  1645.     bne cac2
  1646.     clr.w fxce4
  1647.       move.w #%0000000000001000,d5 
  1648.     lea chann4reg,a2
  1649.     jsr end_fx4p
  1650.  
  1651.     rts
  1652. cac2    cmp.w #3,d0
  1653.     bne cac3
  1654.     clr.w fxce3
  1655.       move.w #%0000000000000100,d5 
  1656.     lea chann3reg,a2
  1657.     jsr end_fx3p
  1658.  
  1659.     rts
  1660. cac3    cmp.w #2,d0
  1661.     bne cac4
  1662.     clr.w fxce2
  1663.       move.w #%0000000000000010,d5 
  1664.     lea chann2reg,a2
  1665.     jsr end_fx2p
  1666.     rts
  1667.  
  1668. cac4    cmp.w #1,d0
  1669.     bne cac5
  1670.     clr.w fxce1
  1671.       move.w #%0000000000000001,d5 
  1672.     lea chann1reg,a2
  1673.     jsr end_fx1p
  1674. cac5    rts
  1675.  
  1676.  
  1677.  
  1678. ;^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1679.  
  1680. ch1:
  1681.     tst.w fx_disable
  1682.     bne test_music1
  1683.     tst.l fxr1
  1684.     bne   ch1j1
  1685.  
  1686.     tst.l fxc1
  1687.     beq test_music1
  1688.     bra ch1j3
  1689. ch1j2    jsr run_dummy1
  1690.     jsr run_fx1
  1691.     bra ch2
  1692. ch1j1
  1693.     jsr set_up1
  1694. ch1j3    tst.w music_disable    
  1695.     beq ch1j2
  1696.     jsr run_fx1
  1697.     bra ch2
  1698. test_music1
  1699.  
  1700.     tst.w fxce1
  1701.     beq noe1
  1702.     jsr run_dummy1
  1703.     bra ch2
  1704.  
  1705.  
  1706. noe1
  1707.     tst.w music_disable
  1708.     bne ch2
  1709.     jsr run_music1
  1710.     bra ch2
  1711.     ;***********************
  1712.  
  1713.     ; channel 1 subroutines
  1714.  
  1715. run_dummy1    
  1716.     move.w #1,mode
  1717.      lea ch1vars,a0
  1718.      lea dummy_reg,a2 
  1719.      move.w #0,d5 
  1720.      move.w #0,d1
  1721.      jsr sect1    
  1722.     rts
  1723.  
  1724. set_up1    
  1725.  
  1726.         jsr endc_fx1p
  1727.  
  1728.          move.l fxr1,d0
  1729.          add d0,d0
  1730.          add d0,d0
  1731.          lea  fxjump_table-4,A1
  1732.      add.l d0,a1
  1733.          move.l (a1),currfx1
  1734.       clr.l fxr1
  1735.      clr.w fxintc1
  1736.       rts
  1737.   
  1738.      
  1739. run_fx1
  1740.     move.w #0,mode
  1741.  
  1742.     lea ch1fxvars,a0
  1743.        lea chann1reg,a2
  1744.       move.w #%0000000000000001,d5 
  1745.      move.w #%1000001000000001,d1 
  1746.      jsr sect1
  1747.     rts
  1748.  
  1749. run_music1
  1750.     move.w #1,mode
  1751.  
  1752.     lea ch1vars,a0
  1753.        lea chann1reg,a2
  1754.       move.w #%0000000000000001,d5 
  1755.       move.w #%1000001000000001,d1 
  1756.       jsr sect1     
  1757.     rts
  1758.  
  1759.     ;  **************************
  1760. ch2
  1761.     tst.w fx_disable
  1762.     bne test_music2
  1763.     tst.l fxr2
  1764.     bne   ch2j1
  1765.     tst.l fxc2
  1766.     beq test_music2
  1767.     bra ch2j3
  1768.  
  1769. ch2j2    jsr run_dummy2
  1770.     jsr run_fx2
  1771.     bra ch3
  1772. ch2j1
  1773.     jsr set_up2
  1774. ch2j3    tst.w music_disable    
  1775.     beq ch2j2
  1776.     jsr run_fx2
  1777.     bra ch3
  1778.  
  1779. test_music2
  1780.  
  1781.  
  1782.     tst.w fxce2
  1783.     beq noe2
  1784.     jsr run_dummy2
  1785.     bra ch3
  1786.  
  1787.  
  1788. noe2
  1789.  
  1790.  
  1791.     tst.w music_disable
  1792.     bne ch3
  1793.     jsr run_music2
  1794.     bra ch3
  1795.     ;***********************
  1796.     ; channel 2 subroutines
  1797. run_dummy2    
  1798.     move.w #1,mode
  1799.  
  1800.      lea ch2vars,a0
  1801.      lea dummy_reg,a2 
  1802.      move.w #0,d5 
  1803.      move.w #0,d1
  1804.      jsr sect1    
  1805.     rts
  1806.  
  1807. set_up2    
  1808.  
  1809.     jsr endc_fx2p
  1810.  
  1811.  
  1812.          move.l fxr2,d0
  1813.          add d0,d0
  1814.          add d0,d0
  1815.          lea  fxjump_table-4,A1
  1816.      add.l d0,a1
  1817.          move.l (a1),currfx2
  1818.       clr.l fxr2
  1819.      clr.w fxintc2
  1820.       rts
  1821.   
  1822.      
  1823. run_fx2
  1824.     move.w #0,mode
  1825.  
  1826.     lea ch2fxvars,a0
  1827.        lea chann2reg,a2
  1828.       move.w #%0000000000000010,d5 
  1829.      move.w #%1000001000000010,d1 
  1830.      jsr sect1
  1831.     rts
  1832.  
  1833. run_music2
  1834.     move.w #1,mode
  1835.  
  1836.     lea ch2vars,a0
  1837.        lea chann2reg,a2
  1838.       move.w #%0000000000000010,d5 
  1839.       move.w #%1000001000000010,d1 
  1840.       jsr sect1     
  1841.     rts
  1842.  
  1843.     ;  **************************
  1844.  
  1845. ch3:
  1846.     tst.w fx_disable
  1847.     bne test_music3
  1848.     tst.l fxr3
  1849.     bne   ch3j1
  1850.     tst.l fxc3
  1851.     beq test_music3
  1852.     bra ch3j3
  1853. ch3j2    jsr run_dummy3
  1854.     jsr run_fx3
  1855.     bra ch4
  1856. ch3j1
  1857.     jsr set_up3
  1858. ch3j3    tst.w music_disable    
  1859.     beq ch3j2
  1860.     jsr run_fx3
  1861.     bra ch4
  1862.  
  1863. test_music3
  1864.  
  1865.  
  1866.     tst.w fxce3
  1867.     beq noe3
  1868.     jsr run_dummy3
  1869.     bra ch4
  1870.  
  1871.  
  1872. noe3
  1873.  
  1874.  
  1875.  
  1876.     tst.w music_disable
  1877.     bne ch4
  1878.     jsr run_music3
  1879.     bra ch4
  1880.  
  1881.     ;***********************
  1882.  
  1883.     ; channel 3 subroutines
  1884.  
  1885. run_dummy3    
  1886.     move.w #1,mode
  1887.  
  1888.      lea ch3vars,a0
  1889.      lea dummy_reg,a2 
  1890.      move.w #0,d5 
  1891.      move.w #0,d1
  1892.      jsr sect1    
  1893.     rts
  1894.  
  1895. set_up3    
  1896.  
  1897.     jsr endc_fx3p
  1898.  
  1899.  
  1900.          move.l fxr3,d0
  1901.          add d0,d0
  1902.          add d0,d0
  1903.          lea  fxjump_table-4,A1
  1904.      add.l d0,a1
  1905.          move.l (a1),currfx3
  1906.       clr.l fxr3
  1907.      clr.w fxintc3
  1908.       rts
  1909.   
  1910.      
  1911. run_fx3
  1912.     move.w #0,mode
  1913.  
  1914.     lea ch3fxvars,a0
  1915.        lea chann3reg,a2
  1916.       move.w #%0000000000000100,d5 
  1917.      move.w #%1000001000000100,d1 
  1918.      jsr sect1
  1919.     rts
  1920.  
  1921. run_music3
  1922.     move.w #1,mode
  1923.  
  1924.     lea ch3vars,a0
  1925.        lea chann3reg,a2
  1926.       move.w #%0000000000000100,d5 
  1927.       move.w #%1000001000000100,d1 
  1928.       jsr sect1     
  1929.     rts
  1930.  
  1931.     ;  **************************
  1932.  
  1933. ch4:
  1934.     tst.w fx_disable
  1935.     bne test_music4
  1936.     tst.l fxr4
  1937.     bne   ch4j1
  1938.     tst.l fxc4
  1939.     beq test_music4
  1940.     bra ch4j3
  1941. ch4j2    jsr run_dummy4
  1942.     jsr run_fx4
  1943.     bra no4
  1944. ch4j1
  1945.     jsr set_up4
  1946. ch4j3    tst.w music_disable    
  1947.     beq ch4j2
  1948.     jsr run_fx4
  1949.     bra no4
  1950.  
  1951. test_music4
  1952.  
  1953.  
  1954.     tst.w fxce4
  1955.     beq noe4
  1956.     jsr run_dummy4
  1957.     bra no4
  1958.  
  1959.  
  1960. noe4
  1961.     tst.w music_disable
  1962.     bne no4
  1963.     jsr run_music4
  1964. no4    
  1965.     movem.l (a7)+,d0-d6/a0-a6    ;restore registers
  1966.     rts
  1967.  
  1968.     ;***********************
  1969.  
  1970.     ; channel 4 subroutines
  1971.  
  1972. run_dummy4    
  1973.     move.w #1,mode
  1974.  
  1975.      lea ch4vars,a0
  1976.      lea dummy_reg,a2 
  1977.      move.w #0,d5 
  1978.      move.w #0,d1
  1979.      jsr sect1    
  1980.     rts
  1981.  
  1982. set_up4    
  1983.  
  1984.     jsr endc_fx4p
  1985.  
  1986.  
  1987.          move.l fxr4,d0
  1988.          add d0,d0
  1989.          add d0,d0
  1990.          lea  fxjump_table-4,A1
  1991.      add.l d0,a1
  1992.          move.l (a1),currfx4
  1993.       clr.l fxr4
  1994.      clr.w fxintc4
  1995.       rts
  1996.   
  1997.      
  1998. run_fx4
  1999.  
  2000.     move.w #0,mode
  2001.  
  2002.     lea ch4fxvars,a0
  2003.        lea chann4reg,a2
  2004.       move.w #%0000000000001000,d5 
  2005.      move.w #%1000001000001000,d1 
  2006.      jsr sect1
  2007.     rts
  2008.  
  2009. run_music4
  2010.  
  2011.     move.w #1,mode
  2012.  
  2013.     lea ch4vars,a0
  2014.        lea chann4reg,a2
  2015.       move.w #%0000000000001000,d5 
  2016.       move.w #%1000001000001000,d1 
  2017.       jsr sect1     
  2018.     rts
  2019.     ;  **************************
  2020.  
  2021. sect1: 
  2022.     ;tst.w 0(a0)
  2023.     ;bne s1j1
  2024.     ;rts
  2025.  
  2026. s1j1:    tst.w 2(a0)
  2027.         beq sect3       
  2028.         cmpi.w #1,2(a0)
  2029.         beq sect4
  2030.  
  2031.         cmpi.w #3,4(a0)    
  2032.         beq part2       
  2033.     
  2034. mode_switch:  subq.w #1,2(a0)     
  2035.  
  2036. check_effects: clr.w altpf      
  2037.         move.w 6(a0),d2    
  2038.         tst.w 8(a0)      
  2039.         beq check_mod
  2040.         tst.w 14(a0)      
  2041.         beq cont_bend
  2042.         subq.w #1,14(a0)
  2043.         bra check_mod
  2044. cont_bend:   addq.w #1,altpf    
  2045.         move.w 10(a0),d3    
  2046.         move.w 12(a0),d4    
  2047.         cmpi.w #1,8(a0)
  2048.         beq pbup
  2049.     
  2050.         sub.w d3,d2
  2051.         cmp.w d2,d4
  2052.         bcs check_mod
  2053.         bra fbend
  2054.  
  2055. pbup:     add.w d3,d2
  2056.         cmp.w d2,d4
  2057.         bcc check_mod
  2058. fbend:     move.w d4,d2
  2059.         clr.w 8(a0)      
  2060. check_mod:   tst.w 16(a0)
  2061.         beq send_alt_pitch
  2062.    
  2063.  
  2064.     tst.w  58(a0)
  2065.     beq st_ok
  2066.     subq.w #1,58(a0)
  2067.     bra send_alt_pitch
  2068. st_ok:
  2069.         tst.w 50(a0)
  2070.         beq cont_mod
  2071.         subq #1,50(a0)
  2072.         bra send_alt_pitch
  2073. cont_mod:    move.w 52(a0),50(a0)  
  2074.         addq #1,altpf
  2075.         cmpi #3,16(a0)
  2076.         bcc addmod
  2077.     
  2078.         move.w 56(a0),d3 
  2079.         sub.w d3,d2
  2080.         addq.w #1,16(a0)  
  2081.         bra send_alt_pitch
  2082. addmod:
  2083.  
  2084.         move.w 54(a0),d3 
  2085.         add.w d3,d2
  2086.         addq.w #1,16(a0)
  2087.         cmpi.w #5,16(a0)
  2088.        bne send_alt_pitch
  2089.         move.w #1,16(a0)  
  2090.  
  2091. send_alt_pitch: tst.w altpf
  2092.         beq send_env
  2093.         move.w d2,6(a0)  
  2094.         move.w d2,6(a2)  
  2095.  
  2096. send_env: 
  2097.  
  2098. do_env_check:
  2099.  
  2100. norm_env:
  2101.     tst.w mode
  2102.     beq fxenv
  2103.  
  2104.     move.l 18(a0),a1    
  2105.         cmpi.w #255,(a1)
  2106.         beq env_finished
  2107.  
  2108. resu    clr.l d0
  2109.     move.w (a1)+,d0
  2110.     sub.w fade,d0
  2111.     bcc sete
  2112.     move.w #0,d0
  2113. sete    move.w d0,8(a2)    
  2114.     move.l a1,18(a0)
  2115.     rts        
  2116.  
  2117. env_finished:
  2118.     subq.l #2,a1    
  2119.     bra resu
  2120.  
  2121. fxenv
  2122.     move.l 18(a0),a1    
  2123.         cmpi.w #255,(a1)
  2124.         beq env_finishedx
  2125.  
  2126. resux    clr.l d0
  2127.     move.w (a1)+,d0
  2128.     move.w d0,8(a2)    
  2129.     move.l a1,18(a0)
  2130.     rts        
  2131.  
  2132. env_finishedx:
  2133.     subq.l #2,a1    
  2134.     bra resux
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141. one_shot_note: move.w #3,4(a0)     
  2142.         move.l 38(a0),(a2)
  2143.         move.w 42(a0),4(a2)
  2144.         move.w d1,dmacon     
  2145.         bra send_env
  2146.  
  2147.  
  2148. part2:                         
  2149.         move.l 44(a0),(a2)
  2150.         move.w 48(a0),4(a2)
  2151.         subq.w #1,2(a0)      
  2152.         move.w #1,4(a0)
  2153.         bra check_effects
  2154.  
  2155. sect3:
  2156.     move.w 0,66(a0)    
  2157.  
  2158.     move.l 22(a0),a1  
  2159. control_ret: move.w (a1)+,d0  
  2160.     cmpi.w #100,d0   
  2161.     bls sect5   
  2162.   
  2163. acc_note:
  2164.     move.w d0,6(a0)  
  2165.     move.w d0,6(a2)  
  2166.     move.w (a1)+,2(a0) 
  2167.     subq.w #1,2(a0)  
  2168.     move.l a1,22(a0)  
  2169.     move.l 34(a0),18(a0) 
  2170.     move.w 60(a0),58(a0) 
  2171.  
  2172.  
  2173.     tst.w 16(a0)
  2174.     beq no_mod_res
  2175.     move.w #1,16(a0)
  2176. no_mod_res:
  2177.     cmpi.w #0,4(a0)
  2178.     beq do_loop
  2179.     bra one_shot_note    
  2180.  
  2181.  
  2182. do_loop:    move.w d1,dmacon   
  2183.         bra send_env
  2184.  
  2185. do_rest:
  2186.     move.w (a1)+,2(a0) 
  2187.     subq.w #1,2(a0)  
  2188.     move.l a1,22(a0)  
  2189.     move.l  #rest_env,18(a0)
  2190.  
  2191.         move.w #0,8(a2)
  2192.         bra send_env
  2193.    
  2194. sect4:
  2195.         cmpi.w #0,4(a0)
  2196.         beq noof
  2197.         move.w d5,dmacon   
  2198. noof:     subq.w #1,2(a0)
  2199.         bra check_effects
  2200.    
  2201. sect5:     move.l #jump_table,a3
  2202.         move.l (a3,d0),a4
  2203.         jmp (a4)
  2204.  
  2205. jump_table: 
  2206.     dc.l  in_line_data
  2207.         dc.l  nsound
  2208.         dc.l  patt_end
  2209.         dc.l  get_env
  2210.         dc.l  check_pbend
  2211.         dc.l  do_mod
  2212.         dc.l  bend_off
  2213.         dc.l  mod_off
  2214.         dc.l  do_rest
  2215.         dc.l  end_fx
  2216.         dc.l  end_fx
  2217.     dc.l  s_f_on
  2218.     dc.l  s_f_off
  2219.     dc.l  set_acc
  2220.     dc.l  rept
  2221.     dc.l  song_select
  2222.  
  2223.  
  2224. in_line_data:
  2225.  
  2226.         nop
  2227.         rts
  2228.  
  2229. rept:
  2230.  
  2231.     tst.w (a1)
  2232.     bne round_again
  2233.  
  2234.     add.l #6,a1
  2235.     move.l (a1),a1
  2236.     bra control_ret
  2237.  
  2238. round_again
  2239.     subq.w #1,(a1)    ;decrease counter
  2240.     add.l #2,a1
  2241.     move.l (a1),a1
  2242.     bra control_ret
  2243.  
  2244. s_f_on: 
  2245.     bclr #1,filter
  2246.     bra control_ret
  2247. s_f_off:
  2248.     bset #1,filter
  2249.     bra control_ret
  2250.  
  2251. nsound:    move.l (a1)+,a3     
  2252.         cmpi.w #0,(a3)
  2253.         bne one_shot_sound
  2254.         move.w (a3)+,4(a0)    
  2255.         move.l (a3)+,(a2)     
  2256.         move.w (a3),4(a2)    
  2257.         jmp control_ret
  2258.  
  2259. one_shot_sound:
  2260.         move.w (a3)+,4(a0)
  2261.         move.l (a3)+,38(a0)   
  2262.         move.l (a3)+,42(a0)
  2263.         move.l (a3),46(a0)
  2264.         jmp control_ret
  2265.  
  2266. patt_end:
  2267.         move.l 26(a0),a1    
  2268.         cmpi.l #0,(a1)     
  2269.         beq song_control
  2270.         addq.l #4,26(a0)    
  2271.         move.l (a1),a1     
  2272.         jmp control_ret
  2273. get_env: 
  2274.     move.l (a1)+,a4 
  2275.  
  2276.     move.l (a4)+,62(a0)    
  2277.     
  2278.     move.l  a4,34(a0)    
  2279.     
  2280.         bra control_ret
  2281.  
  2282. check_pbend:
  2283.      move.l (a1)+,8(a0)
  2284.         move.l (a1)+,12(a0)
  2285.         bra control_ret
  2286.  
  2287. do_mod:    move.w #1,16(a0)  
  2288.         move.l (a1)+,50(a0)
  2289.         move.l (a1)+,54(a0)
  2290.         move.l (a1)+,58(a0)
  2291.         bra control_ret
  2292.  
  2293. bend_off:   clr.w 8(a0)
  2294.         bra control_ret
  2295.  
  2296. mod_off:    clr.w 16(a0)
  2297.         bra control_ret
  2298.  
  2299.  
  2300. end_fx:    
  2301.     cmpi.w #6,(a0)
  2302.     beq end_fx4p
  2303.  
  2304.     cmpi.w #5,(a0)
  2305.     beq end_fx3p
  2306.  
  2307.     cmpi.w #7,(a0)
  2308.     beq end_fx2p
  2309.  
  2310.     cmpi.w #8,(a0)
  2311.     beq end_fx1p
  2312.     rts
  2313.  
  2314. end_fx1p:
  2315.         move.w #%0000000000000001,dmacon   
  2316.     move.w  #1,chann1reg+6
  2317.     move.w #0,chann1reg+8
  2318.     move.l #0,fxc1
  2319.     rts
  2320.  
  2321. end_fx2p:
  2322.     move.w #%0000000000000010,dmacon 
  2323.     move.w  #1,chann2reg+6
  2324.         move.w #0,chann2reg+8 
  2325.     move.l #0,fxc2
  2326.         rts
  2327.  
  2328.  
  2329. end_fx3p:
  2330.         move.w #%0000000000000100,dmacon   
  2331.     move.w  #1,chann3reg+6
  2332.     move.w #0,chann3reg+8
  2333.     move.l #0,fxc3
  2334.     rts
  2335.  
  2336. end_fx4p:
  2337.  
  2338.     move.w #%0000000000001000,dmacon 
  2339.     move.w  #1,chann4reg+6
  2340.         move.w #0,chann4reg+8
  2341.     move.l #0,fxc4
  2342.         rts
  2343.  
  2344.  
  2345. endc_fx1p:
  2346.         move.w #%0000000000000001,dmacon   
  2347.     move.w  #1,chann1reg+6
  2348.     move.w #0,chann1reg+8
  2349.     ;move.l #0,fxc1
  2350.     rts
  2351.  
  2352. endc_fx2p:
  2353.     move.w #%0000000000000010,dmacon 
  2354.     move.w  #1,chann2reg+6
  2355.         move.w #0,chann2reg+8 
  2356.     ;move.l #0,fxc2
  2357.         rts
  2358.  
  2359.  
  2360. endc_fx3p:
  2361.         move.w #%0000000000000100,dmacon   
  2362.     move.w  #1,chann3reg+6
  2363.     move.w #0,chann3reg+8
  2364.     ;move.l #0,fxc3
  2365.     rts
  2366.  
  2367. endc_fx4p:
  2368.  
  2369.     move.w #%0000000000001000,dmacon 
  2370.     move.w  #1,chann4reg+6
  2371.         move.w #0,chann4reg+8
  2372.     ;move.l #0,fxc4
  2373.         rts
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381. set_acc: move.w #1,66(a0) 
  2382.     bra control_ret
  2383.  
  2384. song_control:            ;these instructions reset the
  2385.         addq.l #4,a1
  2386.         move.l 30(a0),26(a0)    ;song pointers to the start for looping
  2387.         move.l 26(a0),a1
  2388.         addq.l #4,26(a0)
  2389.         move.l (a1),a1
  2390.         jmp control_ret            ;dont change this
  2391.  
  2392.  
  2393.     ;"""""""""""""""""""""""""""""""""""""""""""""""""
  2394. song_select:
  2395.  
  2396.             ;A CALL HERE TO A ROUTINE THAT SELECTED
  2397.             ;A NEW TUNE/PLACED THE NUMBER IN SONG_BUFFER
  2398.             ;AND CALLED select_new_song WOULD START
  2399.              ;A DIFFERENT TUNE
  2400.             
  2401.             ;test code only..replace with your own
  2402.  
  2403.  
  2404.     move.l song_buffer,d0
  2405.     addq.l #1,d0
  2406.     cmp.l    #10,d0            ; 9 tunes in this test
  2407.     bne noresx    
  2408.     move.l #1,d0
  2409. noresx    move.l d0,song_buffer
  2410.  
  2411.     jsr    select_new_song        ;this call sets up the new tune
  2412.  
  2413.     rts
  2414.  
  2415.  
  2416. ;-----------------------------------------------
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.     ;;; DATA
  2428.  
  2429. song_table:
  2430.  
  2431.     dc.l     s1,s2,s3,s4            ;hall of m kings
  2432.     dc.l     s5,s6,s7,s8            ;title tune
  2433.     dc.l    sbaba1,sbaba2,sbaba3,sbaba4    ;baba yaga
  2434.     dc.l    sgg1,sgg2,sgg3,sgg4        ;great gates
  2435.     dc.l    bds1,bds2,bds3,bds4        ;blue danube
  2436.     dc.l    jalt1,jalt2,jalt3,jalt4        ;alternative to jupiter
  2437.     dc.l    rvs1,rvs2,rvs3,rvs4        ;ride valkries
  2438.     dc.l     ssilent,ssilent,ssilent,ssilent ;silent    
  2439.     dc.l    bm1,bm2,bm3,bm4            ;b mountain
  2440.     dc.l    intro5,intro6,intro7,intro8
  2441.  
  2442. ;************************************************************
  2443. gvars:
  2444. ch1vars     
  2445.     dc.w 0     
  2446.         dc.w 0,0,0,0,0,0,0,0,0,0     
  2447. pattr1: dc.l