home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: Midwin Amiga / Lowe_MidwinAmiga.adf / goddad.s < prev    next >
Encoding:
Text File  |  1978-04-18  |  21.3 KB  |  1,289 lines

  1.  
  2.     ;    DRIVER AND MUSIC REMAIN COPYRIGHT D.LOWE 
  3.  
  4.     ;         GODFATHER THEME MUSIC
  5.  
  6.  
  7.     ; 
  8.     ; I think I have commented everything you need to know
  9.     ; to get it running but dont hesitate to ring if something
  10.     ; is unclear.
  11.  
  12.  
  13.     ;        DAVE LOWE.....0723  870648
  14.  
  15.  
  16. ;        **************************
  17.  
  18.     section issA,code_c    ;must be in low memory for dma access
  19.                 ;DEVPAC PSEUDO OP ..CAN BE DELETED
  20.  
  21.  
  22. ;*****************************************
  23.  
  24.         ;  ALL EQUs
  25.  
  26. a00  equ  508*2
  27. bb00  equ  480*2
  28. b00  equ  453*2
  29.  
  30. c003  equ  127
  31.  
  32. bb03  equ  480*2
  33. b03  equ  453*2
  34.  
  35. c04  equ  428*2
  36. db04  equ  404*2
  37. d04 equ  381*2
  38. eb04  equ  360*2
  39. e04  equ  339*2
  40. f04  equ  320*2
  41. gb04  equ  302*2
  42. g04  equ  285*2
  43. ab04 equ 269*2
  44. a04  equ  508
  45. bb04  equ  480
  46. b04  equ  453
  47.  
  48. c05  equ  428
  49. db05  equ  404
  50. d05  equ  381
  51. eb05  equ  360
  52. e05  equ  339
  53. f05  equ  320
  54. gb05  equ  302
  55. g05  equ  285
  56. ab05 equ 269
  57. a05  equ  254
  58. bb05  equ  240
  59. b05  equ  226
  60.  
  61. c06  equ  214
  62. db06  equ  202
  63. d06  equ  190
  64. eb06  equ  180
  65. e06  equ  170
  66. f06  equ  160
  67. gb06  equ  151
  68. g06  equ  143
  69. ab06 equ 135
  70. a06  equ  127
  71. bb06  equ  480*2
  72. b06  equ  453*2
  73.  
  74. c07  equ  428*2
  75. db07  equ  404*2
  76. d07 equ  381*2
  77. eb07  equ  360*2
  78. e07  equ  339*2
  79. f07  equ  320*2
  80. gb07  equ  302*2
  81. g07  equ  285*2
  82. ab07 equ 269*2
  83. a07  equ  508
  84. bb07  equ  480
  85. b07  equ  453
  86.  
  87. c08  equ  428
  88. db08  equ  404
  89. d08  equ  381
  90. eb08  equ  360
  91. e08  equ  339
  92. f08  equ  320
  93. gb08  equ  302
  94. g08  equ  285
  95. ab08 equ 269
  96. a08  equ  254
  97. bb08  equ  240
  98. b08  equ  226
  99.  
  100.  
  101. v equ 0
  102.  
  103. no_loop equ 0
  104. loop equ 0
  105. chann1reg   equ $dff0a0    
  106. chann2reg   equ $dff0b0
  107. chann3reg   equ $dff0c0
  108. chann4reg   equ $dff0d0
  109. dmacon     equ $dff096
  110. int_bf_int   equ   $dff01e
  111. int_bf_w    equ   $dff09a
  112. vhposr     equ   $dff006
  113. in_line    equ   0
  114. new_snd    equ   4
  115. end_song     equ   1
  116. end_patt    equ   8
  117. new_env    equ   12
  118. pbend     equ   16
  119.  
  120. ;cr  equ   16
  121. ;tq1 equ 7
  122. ;tq2 equ 6
  123. ;tq equ 8
  124. ;q equ cr/2
  125. ;sq equ q/2
  126.  
  127. hi: equ 223
  128. lo:  equ 446
  129.  
  130. r22    equ 134
  131. r20    equ 179        ;correctum
  132. r19    equ 150
  133. r18    equ 178
  134. r17    equ 200
  135. r16:    equ 227        ;correctum
  136. r15:    equ 249
  137. r13:    equ 305
  138. r12:    equ 333
  139. r11:    equ 361
  140. r10:    equ 389
  141. r9:    equ 419
  142. r8:    equ 446
  143. r7:    equ 446+112
  144. r6:    equ 446+223
  145. r5:    equ 446+223+112
  146. r4:    equ 446*2
  147. r3:    equ 446*3
  148. r2:    equ 446*4
  149. r1:    equ 446*8
  150.  
  151.  
  152. filter: equ $bfe001
  153. filter_on equ 44
  154. filter_off equ 48
  155.  
  156. modon     equ   20
  157. pboff     equ   24
  158. modoff     equ   28
  159. rest     equ 32
  160. end_fxp  equ 36
  161. end_fx3  equ 36
  162. end_fx4  equ 40
  163. acc    equ 52
  164. repeat    equ 56
  165. down      equ   1
  166. up       equ   2
  167.  
  168. ;***************************************************************
  169.  
  170.  
  171.  ;    THIS IS THE CONTROL SECTION FOR TESTING AS A STAND ALONE PRG. 
  172.  
  173.     ;       AND CAN BE DELETED WHEN NOT REQUIRED
  174.  
  175.  
  176.     jsr select_new_song
  177.  
  178. testloop:
  179.     jsr delay    ;wait for scan line  at 50hz on pal
  180.  
  181.     jsr driver
  182.  
  183.         bra testloop
  184.  
  185.  
  186. delay:
  187.     tst.w fxtimer
  188.     bne no_test
  189.     clr.l d0
  190.     move.b $bfe001,d0
  191.     btst #6,d0
  192.     bne no_test1
  193.     move.w #10,fxtimer
  194.     bra testfx4
  195. no_test
  196.     subq #1,fxtimer
  197. no_test1
  198.     clr.l d0
  199.         move.w vhposr,d0
  200.         andi.w #%1111111100000000,d0
  201.         cmpi.w #%1111111100000000,d0
  202.  
  203.     bne no_test1
  204.     rts
  205.  
  206. testfx4:  
  207.  
  208.     ;jsr    kill_chip
  209.     ;move.w #1,int_disable
  210.     clr.l d0
  211.     move.b $bfe001,d0
  212.     btst #6,d0
  213.     beq testfx4
  214.  
  215.     move.l song_buffer,d0
  216.     addq.l #1,d0
  217.     cmp.l    #18,d0
  218.     bne nores
  219.     move.l #1,d0
  220. nores    move.l d0,song_buffer
  221.     jsr    select_new_song
  222.  
  223.  
  224.     ;move.l fx_last,d0
  225.     ;move.l d0,fx_kill
  226.  
  227.     ;jsr kill_loopfx        ;only one fx at a time
  228.  
  229.  
  230. no_k
  231.         move.l fx_no,fx_number
  232.     move.l fx_no,fx_last
  233.     addq.l #1,fx_no
  234.     ;move.l    max_fx,d0
  235.         cmp.l fx_no,d0
  236.     bne noreset
  237.     move.l #1,fx_no    
  238. noreset: 
  239.     jsr set_up_fx
  240.     bra no_test    
  241.  
  242. fxtc:          dc.w 10
  243. fx_no:         dc.l  1
  244. fx_last        dc.l  0
  245.  
  246.  
  247. ;        END OF CONTROL (DELETABLE) SECTION
  248.  
  249. ;**********************************************************
  250.  
  251. ; --------------------------------------------------------------
  252.  
  253. ;    MAIN VARIABLES TO BE ACCESSED BY PROGRAMMER DURING RUNTIME
  254.  
  255.  
  256. fx_number:     dc.l 0 ;     number of fx required here...see list
  257. fx_kill        dc.l 0 ;     number of fx to kill/only needed for looped fx
  258.  
  259. song_buffer     dc.l 1 ;     number of piece of music required here ie.1 to 5
  260.  
  261. music_disable:  dc.w 0 ;     1 = disable music
  262. fx_disable:     dc.w 1 ;     1 = disable fx  (currently disabled)
  263.  
  264. ;    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  265.  
  266. ;  THESE VARIABLES ARE USED INTERNALLY BY THE DRIVER
  267. fxr1         dc.l 0  
  268. fxr2         dc.l 0  
  269. fxr3         dc.l 0  
  270. fxr4         dc.l 0  
  271. fxc1        dc.l 0
  272. fxc2          dc.l 0
  273. fxc3        dc.l 0
  274. fxc4          dc.l 0
  275. fx1_flag    dc.w 0
  276. fx2_flag    dc.w 0
  277. fx3_flag    dc.w 0
  278. fx4_flag    dc.w 0
  279. fxtimer        dc.w 0
  280. gen        dc.w 0
  281. int_disable    dc.w 0
  282. altpf         dc.w 0
  283. kill_flag    dc.w 0
  284. ;  *******************************************************
  285.  
  286. ;  CALL THIS SUBROUTINE TO SET UP THE REQIURED FX
  287. ;  on entry it requires the fx number to be in "fx_number"(see above)
  288. ;  
  289.  
  290. set_up_fx
  291.     movem.l d5/a2,-(a7)    ;save used registers
  292.     move.l #1,d0
  293.     cmp fx_number,d0
  294.     bne check3        ;engine to 4
  295.  
  296.     tst.l fxc4
  297.     bne check3
  298. use4:    
  299.     move.w #%0000000000001000,d5
  300.     lea chann4reg,a2
  301.     jsr end_fx4p
  302.     move.l fx_number,fxr4
  303.     move.l fx_number,fxc4
  304.     move.l #0,fx_number
  305.     bra no_fx
  306. check3:    tst.l fxc3
  307.     bne check2
  308. use3:
  309.     move.w #%0000000000000100,d5
  310.     lea chann3reg,a2
  311.     jsr end_fx3p
  312.     move.l fx_number,fxr3
  313.     move.l fx_number,fxc3
  314.     move.l #0,fx_number
  315.     bra no_fx
  316. check2:    tst.l fxc2
  317.     bne check1
  318. use2:
  319.     move.w #%0000000000000010,d5
  320.     lea chann2reg,a2
  321.     jsr end_fx2p
  322.     move.l fx_number,fxr2
  323.     move.l fx_number,fxc2
  324.     move.l #0,fx_number
  325.     bra no_fx
  326. check1:    tst.l fxc1
  327.     bne use3
  328. use1:
  329.     move.u   2
  330.  
  331. ;***************************************************************
  332.  
  333.  
  334.  ;    THIS IS THE CONTROL SECTION FOR TESTING AS A STAND ALONE PRG. 
  335.  
  336.     ;       AND CAN BE DELETED WHEN NOT REQUIRED
  337.  
  338.  
  339.     jsr select_new_song
  340.  
  341. testloop:
  342.     jsr delay    ;wait for scan line  at 50hz on pal
  343.  
  344.     jsr driver
  345.  
  346.         bra testloop
  347.  
  348.  
  349. delay:
  350.     tst.w fxtimer
  351.     bne no_test
  352.     clr.l d0
  353.     move.b $bfe001,d0
  354.     btst #6,d0
  355.     bne no_test1
  356.     move.w #10,fxtimer
  357.     bra testfx4
  358. no_test
  359.     subq #1,fxtimer
  360. no_test1
  361.     clr.l d0
  362.         move.w v
  363.     jsr end_fx1p
  364.     bra error
  365. k2    cmp.l fxc2,d5
  366.     bne k3
  367.     move.w #%0000000000000010,d5
  368.     lea chann2reg,a2
  369.     jsr end_fx2p
  370.     bra error
  371. k3    cmp.l fxc3,d5
  372.     bne k4
  373.     move.w #%0000000000000100,d5
  374.     lea chann3reg,a2
  375.     jsr end_fx3p
  376.     bra error
  377. k4    cmp.l fxc4,d5
  378.     bne error
  379.     move.w #%0000000000001000,d5
  380.     lea chann2reg,a2
  381.     jsr end_fx4p
  382. error
  383.     clr.l fx_kill
  384.     movem.l (a7)+,d5/a2    ;restore registers
  385.     rts
  386. ;*************************************************
  387.  
  388.     ; CALL HERE TO KILL ANY SOUND for whatever reason
  389.  
  390. kill_chip:
  391.     move.w #%0000000000001111,dmacon
  392.     move.l rest_data,chann1reg
  393.     move.l rest_data,chann2reg
  394.     move.l rest_data,chann3reg
  395.     move.l rest_data,chann4reg
  396.     move.w #16,chann1reg+4    
  397.     move.w #16,chann2reg+4    
  398.     move.w #16,chann3reg+4    
  399.     move.w #16,chann4reg+4    
  400.     move.w #0,chann1reg+8
  401.     move.w #0,chann2reg+8
  402.     move.w #0,chann3reg+8
  403.     move.w #0,chann4reg+8
  404.     move.w #1,chann1reg+6
  405.     move.w #1,chann2reg+6
  406.     move.w #1,chann3reg+6
  407.     move.w #1,chann4reg+6
  408.     move.l #0,fxr1
  409.     move.l #0,fxr2
  410.     move.l #0,fxr3
  411.     move.l #0,fxr4
  412.     move.w #0,fx1_flag
  413.     move.w #0,fx2_flag
  414.     move.w #0,fx3_flag
  415.     move.w #0,fx4_flag
  416.     move.l #0,fxc1
  417.     move.l #0,fxc2
  418.     move.l #0,fxc3
  419.     move.l #0,fxc4
  420.     rts
  421. ;****************************************
  422.  
  423. ;  CALL HERE TO SELECT WHICH PIECE OF MUSIC TO PLAY
  424. ;  AFTER PLACING NUMBER (1 to 3) IN "SONG_BUFFER"..see above
  425. ;  a call to this routine will initiliase the driver/kill any sound etc.      
  426. ;  make sure this routine has been called before running the interrupt
  427. ;  driven section....see below
  428.  
  429. select_new_song:
  430.  
  431.     move.w #1,int_disable
  432.     movem.l d0/d1/a0/a1,-(a7)    ;save used registers
  433.     move.w music_disable,gen
  434.     move.w #1,music_disable
  435.         jsr kill_chip           
  436.     clr.l d0
  437.         move.w #204,d0
  438.         lea gvars,a0
  439. clloop: clr.w (a0)+        
  440.         dbra  d0,clloop
  441.     tst.l song_buffer
  442.     beq no_song
  443.         move.l song_buffer,d1
  444.     add.l d1,d1
  445.      add.l d1,d1
  446.      add.l d1,d1
  447.      add.l d1,d1
  448.         LEA  SONG_TABLE-16,A1
  449.         add.l d1,a1      
  450.         MOVE.L (A1)+,WSONG1    
  451.         move.l (a1)+,wsong2    
  452.         move.l (a1)+,wsong3
  453.     move.l (a1),wsong4
  454.         MOVE.L #pstart,PATTR1
  455.         MOVE.L #pstart,PATTR2
  456.         MOVE.L #pstart,PATTR3
  457.     move.l #pstart,pattr4
  458.         move.l #sstart,songr1
  459.         MOVE.L #sstart,SONGR2
  460.         MOVE.L #sstart,SONGR3
  461.     move.l #sstart,songr4
  462. no_song
  463.     move.w #1,ch1vars
  464.     move.w #2,ch2vars
  465.     move.w #3,ch3vars
  466.     move.w #4,ch4vars
  467.     move.w #6,ch4fxvars
  468.     move.w #5,ch3fxvars
  469.     move.w #7,ch2fxvars
  470.     move.w #8,ch1fxvars
  471.     move.w gen,music_disable
  472.     clr.w int_disable
  473.     movem.l (a7)+,d0/d1/a0/a1    ;restore registers
  474.         rts
  475.  
  476. ;**************************************************
  477.  
  478. ;  CALL HERE ON A 50hz INTERRUPT DURING RUNTIME
  479. ;  TO PLAY FX AND TUNES
  480.  
  481. driver:  
  482.     tst.w int_disable
  483.     beq process_data
  484.     rts        
  485. process_data
  486.     movem.l d0-d6/a0-a6,-(a7)    ;save used registers
  487.  
  488.  
  489. ch1:
  490.     tst.w fx_disable
  491.     bne test_music1
  492.     tst.l fxr1
  493.     bne   ch1j1
  494.     tst.l fxc1
  495.     beq test_music1
  496.     bra ch1j3
  497. ch1j2    jsr run_dummy1
  498.     jsr run_fx1
  499.     bra ch2
  500. ch1j1
  501.     jsr set_up1
  502. ch1j3    tst.w music_disable    
  503.     beq ch1j2
  504.     jsr run_fx1
  505.     bra ch2
  506. test_music1
  507.     tst.w music_disable
  508.     bne ch2
  509.     jsr run_music1
  510.     bra ch2
  511.     ;***********************
  512.  
  513.     ; channel 1 subroutines
  514.  
  515. run_dummy1    
  516.      lea ch1vars,a0
  517.      lea dummy_reg,a2 
  518.      move.w #0,d5 
  519.      jsr sect1    
  520.     rts
  521.  
  522. set_up1    
  523.          move.l fxr1,d0
  524.          add d0,d0
  525.          add d0,d0
  526.          lea  fxjump_table-4,A1
  527.      add.l d0,a1
  528.          move.l (a1),currfx1
  529.       clr.l fxr1
  530.      clr.w fxintc1
  531.       rts
  532.   
  533.      
  534. run_fx1
  535.     lea ch1fxvars,a0
  536.        lea chann1reg,a2
  537.       move.w #%0000000000000001,d5 
  538.      move.w #%1000001000000001,d1 
  539.      jsr sect1
  540.     rts
  541.  
  542. run_music1
  543.     lea ch1vars,a0
  544.        lea chann1reg,a2
  545.       move.w #%0000000000000001,d5 
  546.       move.w #%1000001000000001,d1 
  547.       jsr sect1     
  548.     rts
  549.  
  550.     ;  **************************
  551. ch2
  552.     tst.w fx_disable
  553.     bne test_music2
  554.     tst.l fxr2
  555.     bne   ch2j1
  556.     tst.l fxc2
  557.     beq test_music2
  558.     bra ch2j3
  559. ch2j2    jsr run_dummy2
  560.     jsr run_fx2
  561.     bra ch3
  562. ch2j1
  563.     jsr set_up2
  564. ch2j3    tst.w music_disable    
  565.     beq ch2j2
  566.     jsr run_fx2
  567.     bra ch3
  568.  
  569. test_music2
  570.     tst.w music_disable
  571.     bne ch3
  572.     jsr run_music2
  573.     bra ch3
  574.     ;***********************
  575.     ; channel 2 subroutines
  576. run_dummy2    
  577.      lea ch2vars,a0
  578.      lea dummy_reg,a2 
  579.      move.w #0,d5 
  580.      jsr sect1    
  581.     rts
  582.  
  583. set_up2    
  584.          move.l fxr2,d0
  585.          add d0,d0
  586.          add d0,d0
  587.          lea  fxjump_table-4,A1
  588.      add.l d0,a1
  589.          move.l (a1),currfx2
  590.       clr.l fxr2
  591.      clr.w fxintc2
  592.       rts
  593.   
  594.      
  595. run_fx2
  596.     lea ch2fxvars,a0
  597.        lea chann2reg,a2
  598.       move.w #%0000000000000010,d5 
  599.      move.w #%1000001000000010,d1 
  600.      jsr sect1
  601.     rts
  602.  
  603. run_music2
  604.     lea ch2vars,a0
  605.        lea chann2reg,a2
  606.       move.w #%0000000000000010,d5 
  607.       move.w #%1000001000000010,d1 
  608.       jsr sect1     
  609.     rts
  610.  
  611.     ;  **************************
  612.  
  613. ch3:
  614.     tst.w fx_disable
  615.     bne test_music3
  616.     tst.l fxr3
  617.     bne   ch3j1
  618.     tst.l fxc3
  619.     beq test_music3
  620.     bra ch3j3
  621. ch3j2    jsr run_dummy3
  622.     jsr run_fx3
  623.     bra ch4
  624. ch3j1
  625.     jsr set_up3
  626. ch3j3    tst.w music_disable    
  627.     beq ch3j2
  628.     jsr run_fx3
  629.     bra ch4
  630.  
  631. test_music3
  632.     tst.w music_disable
  633.     bne c1  equ  428*2
  634. db01  equ  404*2
  635. d01 equ  381*2
  636. eb01  equ  360*2
  637. e01  equ  339*2
  638. f01  equ  320*2
  639. gb01  equ  302*2
  640. g01  equ  285*2
  641. ab01 equ 269*2
  642. a01  equ  508
  643. bb01  equ  480
  644. b01  equ  453
  645.  
  646. c02  equ  428
  647. db02  equ  404
  648. d02  equ  381
  649. eb02  equ  360
  650. e02  equ  339
  651. f02  equ  320
  652. gb02  equ  302
  653. g02  equ  285
  654. ab02 equ 269
  655. a02  equ  254
  656. bb02  equ  240
  657. b02  equ  226
  658.  
  659. c03  equ  214
  660. db03  equ  202
  661. d03  equ  190
  662. eb03  equ  180
  663. e03  equ  170
  664. f03  equ  160
  665. gb03  equ  151
  666. g03  equ  143
  667. ab03 equ 135
  668. a_music3
  669.     lea ch3vars,a0
  670.        lea chann3reg,a2
  671.       move.w #%0000000000000100,d5 
  672.       move.w #%1000001000000100,d1 
  673.       jsr sect1     
  674.     rts
  675.  
  676.     ;  **************************
  677.  
  678. ch4:
  679.     tst.w fx_disable
  680.     bne test_music4
  681.     tst.l fxr4
  682.     bne   ch4j1
  683.     tst.l fxc4
  684.     beq test_music4
  685.     bra ch4j3
  686. ch4j2    jsr run_dummy4
  687.     jsr run_fx4
  688.     bra no4
  689. ch4j1
  690.     jsr set_up4
  691. ch4j3    tst.w music_disable    
  692.     beq ch4j2
  693.     jsr run_fx4
  694.     bra no4
  695.  
  696. test_music4
  697.     tst.w music_disable
  698.     bne no4
  699.     jsr run_music4
  700. no4    
  701.     movem.l (a7)+,d0-d6/a0-a6    ;restore registers
  702.     rts
  703.  
  704.     ;***********************
  705.  
  706.     ; channel 4 subroutines
  707.  
  708. run_dummy4    
  709.      lea ch4vars,a0
  710.      lea dummy_reg,a2 
  711.      move.w #0,d5 
  712.      jsr sect1    
  713.     rts
  714.  
  715. set_up4    
  716.          move.l fxr4,d0
  717.          add d0,d0
  718.          add d0,d0
  719.          lea  fxjump_table-4,A1
  720.      add.l d0,a1
  721.          move.l (a1),currfx4
  722.       clr.l fxr4
  723.      clr.w fxintc4
  724.       rts
  725.   
  726.      
  727. run_fx4
  728.     lea ch4fxvars,a0
  729.        lea chann4reg,a2
  730.       move.w #%0000000000001000,d5 
  731.      move.w #%1000001000001000,d1 
  732.      jsr sect1
  733.     rts
  734.  
  735. run_music4
  736.     lea ch4vars,a0
  737.        lea chann4reg,a2
  738.       move.w #%0000000000001000,d5 
  739.       move.w #%1000001000001000,d1 
  740.       jsr sect1     
  741.     rts
  742.     ;  **************************
  743.  
  744. sect1: tst.w 0(a0)
  745.     bne s1j1
  746.     rts
  747.  
  748. s1j1:    tst.w 2(a0)
  749.         beq sect3       
  750.         cmpi.w #1,2(a0)
  751.         beq sect4
  752.  
  753.         cmpi.w #3,4(a0)    
  754.         beq part2       
  755.     
  756. mode_switch:  subq.w #1,2(a0)     
  757.  
  758. check_effects: clr.w altpf      
  759.         move.w 6(a0),d2    
  760.         tst.w 8(a0)      
  761.         beq check_mod
  762.         tst.w 14(a0)      
  763.         beq cont_bend
  764.         subq.w #1,14(a0)
  765.         bra check_mod
  766. cont_bend:   addq.w #1,altpf    
  767.         move.w 10(a0),d3    
  768.         move.w 12(a0),d4    
  769.         cmpi.w #1,8(a0)
  770.         beq pbup
  771.     
  772.         sub.w d3,d2
  773.         cmp.w d2,d4
  774.         bcs check_mod
  775.         bra fbend
  776.  
  777. pbup:     add.w d3,d2
  778.         cmp.w d2,d4
  779.         bcc check_mod
  780. fbend:     move.w d4,d2
  781.         clr.w 8(a0)      
  782. check_mod:   tst.w 16(a0)
  783.         beq send_alt_pitch
  784.    
  785.  
  786.     tst.w  58(a0)
  787.     beq st_ok
  788.     subq.w #1,58(a0)
  789.     bra send_alt_pitch
  790. st_ok:
  791.         tst.w 50(a0)
  792.         beq cont_mod
  793.         subq #1,50(a0)
  794.         bra send_alt_pitch
  795. cont_mod:    move.w 52(a0),50(a0)  
  796.         addq #1,altpf
  797.         cmpi #3,16(a0)
  798.         bcc addmod
  799.     
  800.         move.w 56(a0),d3 
  801.         sub.w d3,d2
  802.         addq.w #1,16(a0)  
  803.         bra send_alt_pitch
  804. addmod:
  805.  
  806.         move.w 54(a0),d3 
  807.         add.w d3,d2
  808.         addq.w #1,16(a0)
  809.         cmpi.w #5,16(a0)
  810.        bne send_alt_pitch
  811.         move.w #1,16(a0)  
  812.  
  813. send_alt_pitch: tst.w altpf
  814.         beq send_env
  815.         move.w d2,6(a0)  
  816.         move.w d2,6(a2)  
  817.  
  818. send_env: 
  819.  
  820.     cmpi #6,(a0)
  821.     beq norm_env    
  822.     cmpi #5,(a0)
  823.     bne do_env_check
  824.  
  825.     tst.w fx4_flag
  826.     beq norm_env
  827.     bra low_vol
  828.  
  829. do_env_check:
  830.     move.w fx3_flag,d0
  831.     or.w fx4_flag,d0
  832.     cmpi.w  #0,d0
  833.     beq norm_env
  834. low_vol:    
  835.     move.l 18(a0),a1    
  836.         cmpi.w #255,(a1)
  837.         beq evj1
  838.     move.w (a1)+,d0
  839. evj2:    sub.w  62(a0),d0
  840.     bcc no_over
  841.     move.w 0,d0
  842. no_over:
  843.         move.w d0,8(a2) 
  844.     bra fint        
  845.  
  846. evj1:   subq.l #2,a1
  847.     move.w (a1)+,d0
  848.     bra evj2
  849.  
  850. norm_env:
  851.     move.l 18(a0),a1    
  852.         cmpi.w #255,(a1)
  853.         beq env_finished
  854.     cmpi.w #1,66(a0)    
  855.     bne    no_acc 
  856.  
  857.     clr.l d0
  858.     move.w (a1)+,d0
  859.     add.w 64(a0),d0    
  860.     move.w d0,8(a2)    
  861.     move.l a1,18(a0)
  862.     rts        
  863.  
  864. no_acc:
  865. resu:   move.w (a1)+,8(a2)   
  866. fint:   move.l a1,18(a0)    
  867.     rts
  868.  
  869. env_finished:
  870.      subq.l #2,a1    
  871.      bra resu
  872.  
  873.  
  874. one_shot_note: move.w #3,4(a0)     
  875.         move.l 38(a0),(a2)
  876.         move.w 42(a0),4(a2)
  877.  
  878.  
  879.         move.w d1,dmacon     
  880.         bra send_env
  881.  
  882.  
  883. part2:                         
  884.         move.l 44(a0),(a2)
  885.         move.w 48(a0),4(a2)
  886.         subq.w #1,2(a0)      
  887.         move.w #1,4(a0)
  888.         bra check_effects
  889.  
  890. sect3:
  891.     move.w #1,6(a2)    ;period
  892.     move.w d5,dmacon  ;dma off
  893.     move.w    #10,d0
  894. loopd    
  895.     dbra  d0,loopd    
  896.  
  897.  
  898.  
  899.  
  900.     move.w 0,66(a0)    
  901.  
  902.     move.l 22(a0),a1  
  903. control_ret: move.w (a1)+,d0  
  904.     cmpi.w #100,d0   
  905.     bls sect5   
  906.   
  907. acc_note:
  908.     move.w d0,6(a0)  
  909.     move.w d0,6(a2)  
  910.     move.w (a1)+,2(a0) 
  911.     subq.w #1,2(a0)  
  912.     move.l a1,22(a0)  
  913.     move.l 34(a0),18(a0) 
  914.     move.w 60(a0),58(a0) 
  915.  
  916.  
  917.     tst.w 16(a0)
  918.     beq no_mod_res
  919.     move.w #1,16(a0)
  920. no_mod_res:
  921.     cmpi.w #0,4(a0)
  922.     beq do_loop
  923.     bra one_shot_note    
  924.  
  925.  
  926. do_loop:    move.w d1,dmacon   
  927.         bra send_env
  928.  
  929. do_rest:
  930.     move.w (a1)+,2(a0) 
  931.     subq.w #1,2(a0)  
  932.     move.l a1,22(a0)  
  933.     move.l  #rest_env,18(a0)
  934.  
  935.         move.w #0,8(a2)
  936.         bra send_env
  937.    
  938. sect4:
  939.         cmpi.w #0,4(a0)
  940.         beq noof
  941.     
  942.        ;move.w d5,dmacon   
  943. noof:  subq.w #1,2(a0)
  944.         bra check_effects
  945.    
  946. sect5:     move.l #jump_table,a3
  947.         move.l (a3,d0),a4
  948.         jmp (a4)
  949.  
  950. jump_table: 
  951.     dc.l  in_line_data
  952.         dc.l  nsound
  953.         dc.l  patt_end
  954.         dc.l  get_env
  955.         dc.l  check_pbend
  956.         dc.l  do_mod
  957.         dc.l  bend_off
  958.         dc.l  mod_off
  959.         dc.l  do_rest
  960.         dc.l  end_fx
  961.         dc.l  end_fx
  962.     dc.l  s_f_on
  963.     dc.l  s_f_off
  964.     dc.l  w #%0000000000000001,d5
  965.     lea chann1reg,a2
  966.     jsr end_fx1p
  967.     move.l fx_number,fxr1
  968.     move.l fx_number,fxc1
  969.     move.l #0,fx_number
  970. no_fx
  971.     movem.l (a7)+,d5/a2    ;restore registers
  972.     rts
  973.  
  974. ;*************************************************
  975. ;          CALL HERE TO KILL ANY LOOPED FX...
  976. ;       after putting the number of the fx you want to kill
  977. ;            into fx_kill
  978.  
  979. kill_loopfx
  980.  
  981.     movem.l d5/a2,-(a7)    ;save used registers
  982.     move.l fx_kill,d5
  983.     cmp.l fxc1,d5
  984.     bne k2
  985.     move.w #%0000000000000001,d5
  986.     lea chann1reg,a2       move.l (a3),46(a0)
  987.         jmp control_ret
  988.  
  989. patt_end:
  990.  
  991.         move.l 26(a0),a1    
  992.         cmpi.l #0,(a1)     
  993.         beq song_control
  994.         addq.l #4,26(a0)    
  995.         move.l (a1),a1     
  996.         jmp control_ret
  997. get_env: 
  998.        move.l (a1)+,a4 
  999.     move.l (a4)+,62(a0)    
  1000.     
  1001.     move.l  a4,34(a0)    
  1002.     
  1003.         bra control_ret
  1004.  
  1005. check_pbend:
  1006.      move.l (a1)+,8(a0)
  1007.         move.l (a1)+,12(a0)
  1008.         bra control_ret
  1009.  
  1010. do_mod:    move.w #1,16(a0)  
  1011.         move.l (a1)+,50(a0)
  1012.         move.l (a1)+,54(a0)
  1013.         move.l (a1)+,58(a0)
  1014.         bra control_ret
  1015.  
  1016. bend_off:   clr.w 8(a0)
  1017.         bra control_ret
  1018.  
  1019. mod_off:    clr.w 16(a0)
  1020.         bra control_ret
  1021.  
  1022.  
  1023. end_fx:    
  1024.     cmpi.w #6,(a0)
  1025.     beq end_fx4p
  1026.     cmpi.w #5,(a0)
  1027.     beq end_fx3p
  1028.     cmpi.w #7,(a0)
  1029.     beq end_fx2p
  1030.  
  1031. end_fx1p:
  1032.     rts
  1033.  
  1034. end_fx2p:
  1035.         rts
  1036.  
  1037.  
  1038. end_fx3p:
  1039.     rts
  1040.  
  1041. end_fx4p:
  1042.         rts
  1043.  
  1044. set_acc: move.w #1,66(a0) 
  1045.     bra control_ret
  1046.  
  1047. song_control:
  1048.         addq.l #4,a1
  1049.         move.l 30(a0),26(a0)
  1050.         move.l 26(a0),a1
  1051.         addq.l #4,26(a0)
  1052.         move.l (a1),a1
  1053.         jmp control_ret
  1054.  
  1055.  
  1056.     ;"""""""""""""""""""""""""""""""""""""""""""""""""
  1057.  
  1058.     ;;; DATA
  1059.  
  1060. song_table:
  1061.     dc.l s1,s2,s3,s4    ;1  Main theme        L
  1062.  
  1063.  
  1064. ;************************************************************
  1065. gvars:
  1066. ch1vars     
  1067.     dc.w 0     
  1068.         dc.w 0,0,0,0,0,0,0,0,0,0     
  1069. pattr1: dc.l 0    
  1070. songr1: dc.l 0    
  1071. wsong1: dc.l 0   
  1072.         dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0   
  1073.  
  1074. ch2vars     
  1075.     dc.w 0     
  1076.         dc.w 0,0,0,0,0,0,0,0,0,0     
  1077. pattr2: dc.l 0    
  1078. songr2: dc.l 0    
  1079. wsong2: dc.l 0    
  1080.         dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0   
  1081.  
  1082. ch3vars 
  1083.     dc.w 0     
  1084.         dc.w 0,0,0,0,0,0,0,0,0,0     
  1085. pattr3: dc.l 0    
  1086. songr3: dc.l 0    
  1087. wsong3: dc.l 0    
  1088.         dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0   
  1089.  
  1090. ch4vars 
  1091.     dc.w 0     
  1092.         dc.w 0,0,0,0,0,0,0,0,0,0     
  1093. pattr4: dc.l 0    
  1094. songr4: dc.l 0    
  1095. wsong4: dc.l 0    
  1096.         dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0   
  1097.  
  1098.  
  1099. ch1fxvars 
  1100. fxintc1:
  1101. currfx1:
  1102.  
  1103. ch2fxvars 
  1104. fxintc2:
  1105. currfx2:
  1106.  
  1107.  
  1108. ch3fxvars
  1109. fxintc3:
  1110. currfx3:
  1111.  
  1112. ch4fxvars 
  1113. fxintc4:
  1114. currfx4:
  1115.     dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0    
  1116. ;************************************************************
  1117.  
  1118. dummy_reg dc.l 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1119.         dc.l  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1120.         dc.l  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1121.         dc.l  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1122. ;************************************************************
  1123.  
  1124.  
  1125.  
  1126. ;       fx patterns here
  1127.  
  1128. fxjump_table:  
  1129.  
  1130.  
  1131. ;*******************************************************************
  1132.  
  1133. sstart: dc.l 0,end_song
  1134.  
  1135. pstart: dc.w end_patt
  1136.  
  1137.  
  1138.  
  1139.  
  1140. ;restful loop
  1141.  
  1142. s1:
  1143.     dc.l    p20
  1144.       dc.l     0,end_song
  1145. s2:
  1146.     dc.l    p20
  1147.         DC.L    0,end_song
  1148. s3:
  1149.     dc.l    pr
  1150.     dc.l     0,end_song
  1151. s4:
  1152.     dc.l    pr,pr,pr,pr
  1153.     dc.l     0,end_song
  1154.  
  1155.  
  1156. CR      set 32
  1157. tcr1     set 13
  1158. tcr2     set 14
  1159. Q       set cr/2
  1160. tq1      set 4
  1161. tq2      set 5
  1162. ;tsq     set 3
  1163. ;tsq2     set 2
  1164. SQ      set cr/4
  1165. ;m       set 254
  1166. ;rest     set $fd00
  1167. ;dcr      set cr+q
  1168. ;dq      set q+sq
  1169. ;dsq      set sq+(sq/2)
  1170. ;sb      set cr*4
  1171. ;min      set cr*2
  1172. ;dm      set min+cr
  1173.  
  1174.  
  1175.  
  1176.  
  1177. pcr:
  1178.       dc.w rest,cr
  1179.       dc.w end_patt
  1180. pr:
  1181.       dc.w rest,cr*4
  1182.       dc.w end_patt
  1183. prf:
  1184.       dc.w rest,cr*1000
  1185.       dc.w end_patt
  1186. pr35:
  1187.     dc.w rest,35
  1188.     dc.w end_patt
  1189. pra:
  1190.     dc.w rest,q*7
  1191.     dc.w end_patt
  1192. pqr:
  1193.       dc.w rest,q
  1194.       dc.w end_patt
  1195.  
  1196. ;*********************************************
  1197.         ;  GODFATHER MUSIC
  1198.  
  1199.  
  1200. p20    
  1201.       dc.w new_env
  1202.     dc.l org_env
  1203.       dc.w new_snd
  1204.       dc.l shak
  1205.     dc.w    filter_on
  1206.     dc.w     db03,cr*2,c03,q,db03,q,d03,cr*2-2,rest,2,db03,cr,db03,q,a02,q*11
  1207.     dc.w     db03,cr*2,c03,q,db03,q,d03,cr*2-2,rest,2,db03,cr,db03,q,ab02,q*11
  1208.     dc.w    db03,cr*2,c03,q,db03,q,e03,cr*2,db03,cr,c03,cr*2,eb03,cr,db03,cr*3
  1209.     dc.w    a02,cr,ab02,cr,a02,cr,db03,cr*2,c03,cr,ab02,q*19
  1210.  
  1211.     dc.w end_patt
  1212.  
  1213. p20a    
  1214.       dc.w new_env
  1215.     dc.l org_env
  1216.       dc.w new_snd
  1217.       dc.l shak
  1218.     dc.w    filter_on
  1219.     dc.w     db03,cr*2-2,c03,q,db03,q,d03,cr*2,db03,cr,db03,q,a02,q*11
  1220.     dc.w     db03,cr*2,c03,q,db03,q,d03,cr*2,db03,cr,db03,q,ab02,q*11
  1221.     dc.w    db03,cr*2,c03,q,db03,q,e03,cr*2,db03,cr,c03,cr*2,eb03,cr,db03,cr*3
  1222.     dc.w    a02,cr,ab02,cr,a02,cr,db03,cr*2,c03,cr,ab02,q*19+2
  1223.  
  1224.     dc.w end_patt
  1225.  
  1226.  
  1227. ;****************************************************************
  1228.  
  1229.  
  1230.  
  1231. shak
  1232.         dc.w 1  
  1233.              dc.l shakd
  1234.              dc.w 37782/2 
  1235.         dc.l restd
  1236.              dc.w 16/2 
  1237.  
  1238. restd:
  1239. rest_data:
  1240.              dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1241.              dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1242.              dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1243.              dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1244.  
  1245. sine_datad:
  1246.              dc.w 127,100,50,25,0,-25,-50,-100,-127
  1247.              dc.w -127,-100,-50,-25,0,25,50,100,127
  1248.  
  1249.  
  1250. org_env:        dc.w 0,0,55,255
  1251. rest_env:        dc.w 0,0,0,0,0,0,0,0,255
  1252.  
  1253.  
  1254. ;**************************************************
  1255. shakd            incbin df1:flugel.sam
  1256.  
  1257. ;*************************************************
  1258.  
  1259.  
  1260.  
  1261.     end
  1262.  
  1263.  
  1264. filter_on
  1265.     dc.w     db03,cr*2-2,c03,q,db03,q,d03,cr*2,db03,cr,db03,q,a02,q*11
  1266.     dc.w     db03,cr*2,c03,q,db03,q,d03,cr*2,db03,cr,db03,q,ab02,q*11
  1267.     dc.w    db03,cr*2,c03,q,dbh4
  1268.     jsr run_music3
  1269.     bra ch4
  1270.  
  1271.     ;***********************
  1272.  
  1273.     ; channel 3 subroutines
  1274.  
  1275. run_dummy3    
  1276.      lea ch3vars,a0
  1277.      lea dummy_reg,a2 
  1278.      move.w #0,d5 
  1279.      jsr sect1    
  1280.     rts
  1281.  
  1282. set_up3    
  1283.          move.l fxr3,d0
  1284.          add d0,d0
  1285.          add d0,d0
  1286.          lea  fxjump_table-4,A1
  1287.      add.l d0,a1
  1288.          move.l (a1),currfx3
  1289.       clr.l fxr3