home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: Super Street …ghter II PC Format Disk 2 / Lowe_SuperStreetFighterIIPCFormatDisk2.img / TSPEECH_.S < prev    next >
Encoding:
Text File  |  1995-12-06  |  23.7 KB  |  1,437 lines

  1.  
  2.  
  3.  
  4.     ;    DRIVER AND MUSIC REMAIN COPYRIGHT D.LOWE 
  5.  
  6.     ;       DRIVER TO RUN RELOCATABLE DATA BLK
  7.     ;
  8.     ;  .....fade only affects music in this version
  9.  
  10.  
  11.  
  12.     ;    devpac source code file... no macros.
  13.  
  14.     ;    The data blocks can go anywhere in chip
  15.     ;    memory but the  base address must be passed 
  16.     ;    to the driver in A0...and call setup
  17.     ;    Everything else is the same....
  18.     ;    fx are in the same order in every data blk
  19.  
  20.  
  21.     ;    It must be assembled with SYMBOLS CASE independent.
  22.  
  23.     ;       dont hesitate to ring with any problems
  24.  
  25.  
  26.  
  27.     ;        DAVE LOWE.....0723  870648
  28.  
  29.  
  30.  
  31. ;        **************************
  32.  
  33.     section issA,code_c    ;must be in low memory for dma access
  34.                 ;DEVPAC PSEUDO OP ..CAN BE DELETED
  35.  
  36.  
  37. ;*****************************************
  38.  
  39.  
  40.                 ; zero to step tunes on mouse button
  41.                 ; can be deleted..not essential
  42.  
  43.         ;  ALL EQUs
  44.  
  45.  
  46.  
  47.  
  48.  
  49. v equ 0
  50.  
  51. no_loop equ 0
  52. loop equ 0
  53. chann1reg   equ $dff0a0    
  54. chann2reg   equ $dff0b0
  55. chann3reg   equ $dff0c0
  56. chann4reg   equ $dff0d0
  57. dmacon     equ $dff096
  58. int_bf_int   equ   $dff01e
  59. int_bf_w    equ   $dff09a
  60. vhposr     equ   $dff006
  61. in_line    equ   0
  62. new_snd    equ   4
  63. end_song     equ   1
  64. end_patt    equ   8
  65. new_env    equ   12
  66. pbend     equ   16
  67.  
  68.  
  69.  
  70. hi: equ 223
  71. lo:  equ 446
  72.  
  73. r22    equ 134
  74. r20    equ 179        ;correctum
  75. r19    equ 150
  76. r18    equ 178
  77. r17    equ 200
  78. r16:    equ 227        ;correctum
  79. r15:    equ 249
  80. r14    equ 280
  81. r13:    equ 305
  82. r12:    equ 333
  83. r11:    equ 361
  84. r10:    equ 389
  85. r9:    equ 419
  86. r8:    equ 446
  87. r7:    equ 446+112
  88. r6:    equ 446+223
  89. r5:    equ 446+223+112
  90. r4:    equ 446*2
  91. r3:    equ 446*3
  92. r2:    equ 446*4
  93. r1:    equ 446*8
  94.  
  95.  
  96. filter: equ $bfe001
  97. filter_on equ 44
  98. filter_off equ 48
  99.  
  100. modon     equ   20
  101. pboff     equ   24
  102. modoff     equ   28
  103. rest     equ 32
  104. end_fxp  equ 36
  105. end_fx3  equ 36
  106. end_fx4  equ 40
  107. acc    equ 52
  108. repeat    equ 56
  109. down      equ   1
  110. up       equ   2
  111.  
  112. fx    equ 0
  113.  
  114.  
  115.  
  116. ;**************************************************************************
  117. ;**************************************************************************
  118.  
  119.  
  120.  ;    THIS IS THE CONTROL SECTION FOR TESTING AS A STAND ALONE PRG. 
  121.  
  122.     ;       AND CAN BE DELETED WHEN NOT REQUIRED
  123.  
  124.  
  125.     lea music_data_blk,a0
  126.     jsr set_up_music_address
  127.  
  128.     lea fx_data_blk,a0
  129.     jsr set_up_fx_address
  130.  
  131.  
  132.  
  133.     move.l    #1,song_buffer
  134.     jsr select_new_song    ;set up tune..numnber 1
  135.  
  136. testloop:
  137.     jsr delay    ;wait for scan line  at 50hz on pal
  138.     tst.w endf
  139.     beq noend
  140.     jsr kill_chip
  141.  
  142.     rts        ;finish
  143.  
  144. endf    dc.w 0
  145.  
  146. noend
  147.     jsr driver    ;run driver at 50 hz for testing
  148.  
  149.         bra testloop    ;loop back
  150.  
  151. finish    
  152.     move.w #1,endf
  153.     rts
  154.  
  155. ;--------
  156.  
  157.         ;these are all routines used during test/stand alone
  158.         ;        assembly
  159.  
  160. delay:
  161.     tst.w fxtimer
  162.     bne no_test
  163.     clr.l d0
  164.     move.b $bfe001,d0
  165.     btst #6,d0
  166.     bne no_test1
  167.     move.w #10,fxtimer
  168.     bra testfx4
  169. no_test
  170.     subq #1,fxtimer
  171. no_test1
  172.     clr.l d0
  173.         move.w vhposr,d0
  174.         andi.w #%1111111100000000,d0
  175.         cmpi.w #%1111111100000000,d0
  176.  
  177.     bne no_test1
  178.     rts
  179.  
  180. testfx4:  
  181.  
  182.     clr.l d0
  183.     move.b $bfe001,d0
  184.     btst #6,d0
  185.     beq testfx4
  186.  
  187.     move.l song_buffer,d0
  188.     addq.l #1,d0
  189.     cmp.l    max_songs,d0
  190.     bne nores
  191.     move.l #1,d0
  192. nores    move.l d0,song_buffer
  193.  
  194.  
  195. ;-----------------------------
  196.  
  197.     ifeq    demo
  198.     bra finish            ;end on mouse button
  199.     endc
  200.  
  201. ;----------------------------
  202.  
  203.     ifeq    select_tunes
  204.     ;jsr    select_new_song        ;new song on mouse button
  205.     endc
  206. ;--------------------------
  207.  
  208.                     ;run fx on mouse button
  209.     move.l fx_last,d0
  210.     move.l d0,fx_kill
  211.  
  212.     ;jsr kill_loopfx            ;use only one fx at a time
  213.                     ;for testing
  214.  
  215. no_k
  216.         move.l fx_no,fx_number
  217.     move.l fx_no,fx_last
  218.     addq.l #1,fx_no
  219.     move.l    max_fx,d0
  220.         cmp.l fx_no,d0
  221.     bne noreset
  222.     move.l #1,fx_no    
  223. noreset: 
  224.  
  225.  
  226.     ;ifne    select_tunes
  227.  
  228.     jsr set_up_fx
  229.  
  230.     ;endc
  231.  
  232.     bra no_test    
  233.  
  234. fxtc:          dc.w 10
  235. fx_no:         dc.l  1
  236. fx_last        dc.l  0
  237. ;max_songs    dc.l  10
  238. ;max_fx        dc.l  19
  239.  
  240. ;        END OF CONTROL (DELETABLE) SECTION
  241.  
  242. ;********************************************************************
  243. ;********************************************************************
  244.  
  245. ;    MAIN VARIABLES TO BE ACCESSED BY PROGRAMMER DURING RUNTIME
  246.  
  247.  
  248. fx_number:     dc.l 0 ;     number of fx required here
  249.  
  250.  
  251. fx_kill        dc.l 0 ;     number of fx to kill/used mainly
  252.                ;     to kill looping fx
  253.  
  254.  
  255. song_buffer     dc.l 0 ;     number of piece of music required here ie.1 to ?               ;     currently playing beach background..see list
  256.  
  257. music_disable:  dc.w 1 ;     1 = disable music
  258.  
  259. fx_disable:     dc.w 0 ;     1 = disable fx
  260.  
  261.  
  262. fade:        dc.w 0 ;      0 to 64..0 = full volume/64 = off
  263.  
  264.  
  265. ;    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  266.  
  267. ;  THESE VARIABLES ARE USED INTERNALLY BY THE DRIVER
  268. fxr1         dc.l 0  
  269. fxr2         dc.l 0  
  270. fxr3         dc.l 0  
  271. fxr4         dc.l 0  
  272. fxc1        dc.l 0
  273. fxc2          dc.l 0
  274. fxc3        dc.l 0
  275. fxc4          dc.l 0
  276. fx1_flag    dc.w 0
  277. fx2_flag    dc.w 0
  278. fx3_flag    dc.w 0
  279. fx4_flag    dc.w 0
  280. fxtimer        dc.w 0
  281. gen        dc.w 0
  282. int_disable    dc.w 0
  283. altpf         dc.w 0
  284. kill_flag    dc.w 0
  285. mode        dc.w 0
  286.  
  287. music_base_address    dc.l 0
  288. fx_base_address        dc.l 0
  289. bank1_base_address    dc.l 0
  290. bank2_base_address    dc.l 0
  291. jingles_base_address    dc.l 0
  292. curr_base_address    dc.l 0
  293.  
  294.  
  295. tempo_counter    dc.l 0
  296. song_tempo    dc.l 0
  297. play_flag    dc.w    0
  298.  
  299.  
  300. ;*********************************
  301. set_up_music_address:
  302.     move.l a0,music_base_address
  303.     rts
  304.  
  305. set_up_fx_address:
  306.     move.l a0,fx_base_address
  307.     rts
  308.  
  309.  
  310. ;  *******************************************************
  311.  
  312. ;  CALL THIS SUBROUTINE TO SET UP THE REQIURED FX
  313. ;  on entry it requires the fx number to be in "fx_number"(see above)
  314.  
  315.  
  316. set_up_fx
  317.     movem.l d5/a2,-(a7)    ;save used registers
  318.  
  319.     tst.l fxc4
  320.     bne check3
  321. use4:    
  322.     move.w #%0000000000001000,d5
  323.     lea chann4reg,a2
  324.     jsr end_fx4p
  325.     move.l fx_number,fxr4
  326.     move.l fx_number,fxc4
  327.     move.l #0,fx_number
  328.     bra no_fx
  329. check3:    tst.l fxc3
  330.     bne check2
  331. use3:
  332.     move.w #%0000000000000100,d5
  333.     lea chann3reg,a2
  334.     jsr end_fx3p
  335.     move.l fx_number,fxr3
  336.     move.l fx_number,fxc3
  337.     move.l #0,fx_number
  338.     bra no_fx
  339. check2:    tst.l fxc2
  340.     bne check1
  341. use2:
  342.     move.w #%0000000000000010,d5
  343.     lea chann2reg,a2
  344.     jsr end_fx2p
  345.     move.l fx_number,fxr2
  346.     move.l fx_number,fxc2
  347.     move.l #0,fx_number
  348.     bra no_fx
  349. check1:    tst.l fxc1
  350.     bne use3
  351. use1:
  352.     move.w #%0000000000000001,d5
  353.     lea chann1reg,a2
  354.     jsr end_fx1p
  355.     move.l fx_number,fxr1
  356.     move.l fx_number,fxc1
  357.     move.l #0,fx_number
  358. no_fx
  359.     movem.l (a7)+,d5/a2    ;restore registers
  360.     rts
  361.  
  362. ;*************************************************
  363. ;          CALL HERE TO KILL ANY FX...
  364. ;       after putting the number of the fx you want to kill
  365. ;            into fx_kill
  366.  
  367. kill_loopfx
  368.  
  369.     movem.l d5/a2,-(a7)    ;save used registers
  370.     move.l fx_kill,d5
  371.     cmp.l fxc1,d5
  372.     bne k2
  373.     move.w #%0000000000000001,d5
  374.     lea chann1reg,a2
  375.     jsr end_fx1p
  376.     bra error
  377. k2    cmp.l fxc2,d5
  378.     bne k3
  379.     move.w #%0000000000000010,d5
  380.     lea chann2reg,a2
  381.     jsr end_fx2p
  382.     bra error
  383. k3    cmp.l fxc3,d5
  384.     bne k4
  385.     move.w #%0000000000000100,d5
  386.     lea chann3reg,a2
  387.     jsr end_fx3p
  388.     bra error
  389. k4    cmp.l fxc4,d5
  390.     bne error
  391.     move.w #%0000000000001000,d5
  392.     lea chann2reg,a2
  393.     jsr end_fx4p
  394. error
  395.     clr.l fx_kill
  396.     movem.l (a7)+,d5/a2    ;restore registers
  397.     rts
  398. ;*************************************************
  399.  
  400.     ; CALL HERE TO KILL ANY SOUNDS LEFT ON CHIP
  401.  
  402. kill_chip:
  403.     move.w #%0000000000001111,dmacon
  404.     move.l arest_data,chann1reg
  405.     move.l arest_data,chann2reg
  406.     move.l arest_data,chann3reg
  407.     move.l arest_data,chann4reg
  408.     move.w #16,chann1reg+4    
  409.     move.w #16,chann2reg+4    
  410.     move.w #16,chann3reg+4    
  411.     move.w #16,chann4reg+4    
  412.     move.w #0,chann1reg+8
  413.     move.w #0,chann2reg+8
  414.     move.w #0,chann3reg+8
  415.     move.w #0,chann4reg+8
  416.     move.w #1,chann1reg+6
  417.     move.w #1,chann2reg+6
  418.     move.w #1,chann3reg+6
  419.     move.w #1,chann4reg+6
  420.     move.l #0,fxr1
  421.     move.l #0,fxr2
  422.     move.l #0,fxr3
  423.     move.l #0,fxr4
  424.     move.w #0,fx1_flag
  425.     move.w #0,fx2_flag
  426.     move.w #0,fx3_flag
  427.     move.w #0,fx4_flag
  428.     move.l #0,fxc1
  429.     move.l #0,fxc2
  430.     move.l #0,fxc3
  431.     move.l #0,fxc4
  432.     rts
  433.  
  434. arestd:
  435. arest_data:
  436.     dc.w    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  437.  
  438.  
  439.  
  440. ;****************************************
  441.  
  442. ;  CALL HERE TO SELECT WHICH PIECE OF MUSIC TO PLAY
  443. ;  AFTER PLACING NUMBER (1 to ?) IN "SONG_BUFFER"..see above
  444. ;  a call to this routine will initiliase the driver/kill any sound etc.      
  445. ;  make sure this routine has been called before running the interrupt
  446. ;  driven section....see below
  447.  
  448. select_new_song:
  449.  
  450.     move.w #1,int_disable
  451.     movem.l d0/d1/a0/a1,-(a7)    ;save used registers
  452.     move.w music_disable,gen
  453.     move.w #1,music_disable
  454.         jsr kill_chip           
  455.     clr.l d0
  456.         move.w #204,d0
  457.         lea gvars,a0
  458. clloop: clr.w (a0)+        
  459.         dbra  d0,clloop
  460.     tst.l song_buffer
  461.     beq no_song
  462.         move.l song_buffer,d1
  463.     add.l d1,d1
  464.      add.l d1,d1
  465.      add.l d1,d1
  466.      add.l d1,d1
  467.      add.l d1,d1
  468.  
  469. ;-----------------
  470.     movea.l (music_base_address),a1
  471.     move.w (a1),d0        ;word offset to song_table
  472.     lea (a1,d0),a1
  473.     sub.l #32,a1
  474. ;-----------------
  475.         ;LEA  SONG_TABLE-16,A1
  476.  
  477.         add.l d1,a1         ;a1 points to song table in data blk     
  478.  
  479.  
  480.     movea.l (music_base_address),a2    ;sort tempo
  481.         MOVE.L (A1)+,(song_tempo)
  482. ;        ---------------------------------
  483.  
  484.     movea.l (music_base_address),a2
  485.         MOVE.L (A1)+,d0
  486.     add.l d0,a2
  487.     move.l a2,wsong1    
  488.  
  489.     movea.l (music_base_address),a2
  490.         MOVE.L (A1)+,d0
  491.     add.l d0,a2
  492.     move.l a2,wsong2    
  493.  
  494.     movea.l (music_base_address),a2
  495.         MOVE.L (A1)+,d0
  496.     add.l d0,a2
  497.     move.l a2,wsong3
  498.  
  499.     movea.l (music_base_address),a2
  500.         MOVE.L (A1),d0
  501.     add.l d0,a2
  502.     move.l a2,wsong4    
  503.  
  504.  
  505.  
  506.  
  507.         MOVE.L #pstart,PATTR1
  508.         MOVE.L #pstart,PATTR2
  509.         MOVE.L #pstart,PATTR3
  510.     move.l #pstart,pattr4
  511.         move.l #sstart,songr1
  512.         MOVE.L #sstart,SONGR2
  513.         MOVE.L #sstart,SONGR3
  514.     move.l #sstart,songr4
  515. no_song
  516.     move.w #1,ch1vars
  517.     move.w #2,ch2vars
  518.     move.w #3,ch3vars
  519.     move.w #4,ch4vars
  520.     move.w #6,ch4fxvars
  521.     move.w #5,ch3fxvars
  522.     move.w #7,ch2fxvars
  523.     move.w #8,ch1fxvars
  524.     move.w gen,music_disable
  525.     clr.w int_disable
  526.     movem.l (a7)+,d0/d1/a0/a1    ;restore registers
  527.         rts
  528.  
  529.  
  530. sstart:        dc.l 0,1
  531. pstart:        dc.w 8
  532.  
  533.  
  534.  
  535. ;**************************************************
  536.  
  537.         ;This is the interrupt routine
  538.  
  539.  
  540. ;  CALL HERE ON A 50hz INTERRUPT DURING RUNTIME
  541. ;  TO PLAY FX AND TUNES
  542.  
  543. driver:  
  544.     tst.w int_disable
  545.     beq process_data
  546.     rts        
  547. ;------------------------------
  548.  
  549. process_data
  550.  
  551.     move.l #1,d0
  552.     add.l (tempo_counter),d0
  553.     move.l d0,(tempo_counter)
  554.     cmp.l (song_tempo),d0
  555.     bls process_data1
  556.  
  557.     move.w #1,play_flag    ;inhibit music play this frame
  558.     clr.l tempo_counter
  559.  
  560.  
  561. process_data1
  562.  
  563.     movem.l d0-d6/a0-a6,-(a7)    ;save used registers
  564.  
  565.  
  566. ch1:
  567.     tst.w fx_disable
  568.     bne test_music1
  569.     tst.l fxr1
  570.     bne   ch1j1
  571.     tst.l fxc1
  572.     beq test_music1
  573.     bra ch1j3
  574. ch1j2    jsr run_dummy1
  575.     jsr run_fx1
  576.     bra ch2
  577. ch1j1
  578.     jsr set_up1
  579. ch1j3    tst.w music_disable    
  580.     beq ch1j2
  581.     jsr run_fx1
  582.     bra ch2
  583. test_music1
  584.     tst.w music_disable
  585.     bne ch2
  586.     jsr run_music1
  587.     bra ch2
  588.     ;***********************
  589.  
  590.     ; channel 1 subroutines
  591.  
  592. run_dummy1    
  593.  
  594.  
  595.  
  596.     tst.w play_flag
  597.     beq rd1
  598.     rts
  599. rd1
  600.  
  601.     move.l (music_base_address),(curr_base_address)
  602.  
  603.  
  604.      lea ch1vars,a0
  605.      lea dummy_reg,a2 
  606.      move.w #0,d5 
  607.      jsr sect1    
  608.     rts
  609.  
  610. set_up1    
  611.  
  612.     movea.l (fx_base_address),a1
  613.     
  614.     move.w 2(a1),d0
  615.     add.w d0,a1
  616.     sub.l #4,a1
  617.                 ;a1 points to table in data blk
  618.          move.l fxr1,d0
  619.          add d0,d0
  620.          add d0,d0
  621.      add.l d0,a1
  622.     move.l (a1),d0
  623.     
  624.     move.l (fx_base_address),a1
  625.     
  626.     add.l d0,a1
  627.     move.l a1,currfx1    ;store address
  628.       clr.l fxr1
  629.      clr.w fxintc1
  630.       rts
  631.   
  632.      
  633. run_fx1
  634.     move.l (fx_base_address),(curr_base_address)
  635.  
  636.  
  637.     lea ch1fxvars,a0
  638.        lea chann1reg,a2
  639.       move.w #%0000000000000001,d5 
  640.      move.w #%1000000000000001,d1 
  641.  
  642.     move.w    #1,mode
  643.      jsr sect1
  644.     rts
  645.  
  646. run_music1
  647.  
  648.     tst.w play_flag
  649.     beq rm1
  650.     rts
  651. rm1
  652.     move.l (music_base_address),(curr_base_address)
  653.  
  654.  
  655.     lea ch1vars,a0
  656.        lea chann1reg,a2
  657.       move.w #%0000000000000001,d5 
  658.       move.w #%1000000000000001,d1 
  659.     move.w    #0,mode
  660.       jsr sect1     
  661.     rts
  662.  
  663.     ;  **************************
  664. ch2
  665.     tst.w fx_disable
  666.     bne test_music2
  667.     tst.l fxr2
  668.     bne   ch2j1
  669.     tst.l fxc2
  670.     beq test_music2
  671.     bra ch2j3
  672. ch2j2    jsr run_dummy2
  673.     jsr run_fx2
  674.     bra ch3
  675. ch2j1
  676.     jsr set_up2
  677. ch2j3    tst.w music_disable    
  678.     beq ch2j2
  679.     jsr run_fx2
  680.     bra ch3
  681.  
  682. test_music2
  683.     tst.w music_disable
  684.     bne ch3
  685.     jsr run_music2
  686.     bra ch3
  687.     ;***********************
  688.     ; channel 2 subroutines
  689. run_dummy2    
  690.  
  691.     tst.w play_flag
  692.     beq rd2
  693.     rts
  694. rd2
  695.  
  696.     move.l (music_base_address),(curr_base_address)
  697.  
  698.      lea ch2vars,a0
  699.      lea dummy_reg,a2 
  700.      move.w #0,d5 
  701.      jsr sect1    
  702.     rts
  703.  
  704. set_up2    
  705.  
  706. ;---------------------
  707.     movea.l (fx_base_address),a1
  708.     move.w 2(a1),d0
  709.     add.w d0,a1
  710.     sub.l #4,a1
  711.  
  712. ;-----------------------
  713.          move.l fxr2,d0
  714.          add d0,d0
  715.          add d0,d0
  716.  
  717.          ;lea  fxjump_table-4,A1
  718.      add.l d0,a1
  719. ;------------------------
  720.     move.l (a1),d0
  721.     move.l (fx_base_address),a1
  722.     add.l d0,a1
  723.     move.l a1,currfx2    ;store address
  724. ;------------------------
  725.       clr.l fxr2
  726.      clr.w fxintc2
  727.       rts
  728.   
  729.      
  730. run_fx2
  731.  
  732.     move.l (fx_base_address),(curr_base_address)
  733.  
  734.  
  735.     lea ch2fxvars,a0
  736.        lea chann2reg,a2
  737.       move.w #%0000000000000010,d5 
  738.      move.w #%1000000000000010,d1 
  739.     move.w    #1,mode
  740.      jsr sect1
  741.     rts
  742.  
  743. run_music2
  744.     tst.w play_flag
  745.     beq rm2
  746.     rts
  747. rm2
  748.     move.l (music_base_address),(curr_base_address)
  749.  
  750.     lea ch2vars,a0
  751.        lea chann2reg,a2
  752.       move.w #%0000000000000010,d5 
  753.       move.w #%1000000000000010,d1 
  754.     move.w    #0,mode
  755.       jsr sect1     
  756.     rts
  757.  
  758.     ;  **************************
  759.  
  760. ch3:
  761.     tst.w fx_disable
  762.     bne test_music3
  763.     tst.l fxr3
  764.     bne   ch3j1
  765.     tst.l fxc3
  766.     beq test_music3
  767.     bra ch3j3
  768. ch3j2    jsr run_dummy3
  769.     jsr run_fx3
  770.     bra ch4
  771. ch3j1
  772.     jsr set_up3
  773. ch3j3    tst.w music_disable    
  774.     beq ch3j2
  775.     jsr run_fx3
  776.     bra ch4
  777.  
  778. test_music3
  779.     tst.w music_disable
  780.     bne ch4
  781.     jsr run_music3
  782.     bra ch4
  783.  
  784.     ;***********************
  785.  
  786.     ; channel 3 subroutines
  787.  
  788. run_dummy3    
  789.     tst.w play_flag
  790.     beq rd3
  791.     rts
  792. rd3
  793.  
  794.     move.l (music_base_address),(curr_base_address)
  795.  
  796.      lea ch3vars,a0
  797.      lea dummy_reg,a2 
  798.      move.w #0,d5 
  799.      jsr sect1    
  800.     rts
  801.  
  802. set_up3    
  803.  
  804. ;---------------------
  805.     movea.l (fx_base_address),a1
  806.     move.w 2(a1),d0
  807.     add.w d0,a1
  808.     sub.l #4,a1
  809. ;-----------------------
  810.          move.l fxr3,d0
  811.          add d0,d0
  812.          add d0,d0
  813.          ;lea  fxjump_table-4,A1
  814.      add.l d0,a1
  815. ;------------------------
  816.     move.l (a1),d0
  817.     move.l (fx_base_address),a1
  818.     add.l d0,a1
  819.     move.l a1,currfx3    ;store address
  820. ;------------------------
  821.       clr.l fxr3
  822.      clr.w fxintc3
  823.       rts
  824.   
  825.      
  826. run_fx3
  827.     move.l (fx_base_address),(curr_base_address)
  828.  
  829.     lea ch3fxvars,a0
  830.        lea chann3reg,a2
  831.       move.w #%0000000000000100,d5 
  832.      move.w #%1000000000000100,d1 
  833.     move.w    #1,mode
  834.      jsr sect1
  835.     rts
  836.  
  837. run_music3
  838.  
  839.     tst.w play_flag
  840.     beq rm3
  841.     rts
  842. rm3
  843.  
  844.     move.l (music_base_address),(curr_base_address)
  845.  
  846.     lea ch3vars,a0
  847.        lea chann3reg,a2
  848.       move.w #%0000000000000100,d5 
  849.       move.w #%1000000000000100,d1 
  850.     move.w    #0,mode
  851.       jsr sect1     
  852.     rts
  853.  
  854.     ;  **************************
  855.  
  856. ch4:
  857.     tst.w fx_disable
  858.     bne test_music4
  859.     tst.l fxr4
  860.     bne   ch4j1
  861.     tst.l fxc4
  862.     beq test_music4
  863.     bra ch4j3
  864. ch4j2    jsr run_dummy4
  865.     jsr run_fx4
  866.     bra no4
  867. ch4j1
  868.     jsr set_up4
  869. ch4j3    tst.w music_disable    
  870.     beq ch4j2
  871.     jsr run_fx4
  872.     bra no4
  873.  
  874. test_music4
  875.     tst.w music_disable
  876.     bne no4
  877.     jsr run_music4
  878. no4    
  879.  
  880.     clr.w play_flag            ;inhibit music tempo play
  881.  
  882.     movem.l (a7)+,d0-d6/a0-a6    ;restore registers
  883.     rts
  884.  
  885.     ;***********************
  886.  
  887.     ; channel 4 subroutines
  888.  
  889. run_dummy4    
  890.  
  891.     tst.w play_flag
  892.     beq rd4
  893.     rts
  894. rd4
  895.  
  896.  
  897.     move.l (music_base_address),(curr_base_address)
  898.  
  899.      lea ch4vars,a0
  900.      lea dummy_reg,a2 
  901.      move.w #0,d5 
  902.      jsr sect1    
  903.     rts
  904.  
  905. set_up4    
  906.     jsr sort_fx_bank    ;move.l (fx_base_address),a1
  907.     
  908.     move.w 2(a1),d0
  909.     add.w d0,a1
  910.     sub.l #4,a1        ;pointer to jumptable
  911.         move.l fxr4,d0
  912.         add d0,d0
  913.         add d0,d0
  914.     add.l d0,a1        ;pointer to fx offset within table
  915.     move.l (a1),d0
  916.  
  917.     move.l (fx_base_address),a1
  918.  
  919.     add.l d0,a1
  920.     move.l a1,currfx4    ;store address
  921.      clr.l fxr4
  922.     clr.w fxintc4
  923.      rts
  924.   
  925.      
  926. run_fx4
  927.  
  928.     move.l (fx_base_address),(curr_base_address)
  929.  
  930.     lea ch4fxvars,a0
  931.        lea chann4reg,a2
  932.       move.w #%0000000000001000,d5 
  933.      move.w #%1000001000001000,d1 
  934.     move.w    #1,mode
  935.      jsr sect1
  936.     rts
  937.  
  938. run_music4
  939.  
  940.     tst.w play_flag
  941.     beq rm4
  942.     rts
  943. rm4
  944.     move.l (music_base_address),(curr_base_address)
  945.  
  946.  
  947.     lea ch4vars,a0
  948.        lea chann4reg,a2
  949.       move.w #%0000000000001000,d5 
  950.       move.w #%1000001000001000,d1 
  951.     move.w    #0,mode
  952.       jsr sect1     
  953.     rts
  954. ;---------------------------------------
  955.  
  956. fx_bank        dc.w 0
  957.  
  958. sort_fx_bank:            ;fx_bank contains bank ident
  959.                 ;0 = gen fx
  960.                 ;1 = speech bank1
  961.                 ;2 = speech bank 2
  962.  
  963.     tst.w fx_bank
  964.     beq    set_gen
  965.     cmp.w #1,fx_bank
  966.     rts
  967.  
  968. set_gen
  969.     move.l (fx_base_address),a1
  970.     rts
  971.  
  972.  
  973.     ;  **************************
  974.  
  975. sect1: tst.w (a0)
  976.     bne s1j1
  977.     rts
  978.  
  979. s1j1:    tst.w 2(a0)
  980.         beq sect3       
  981.         cmpi.w #1,2(a0)
  982.         beq sect4
  983.  
  984.         cmpi.w #3,4(a0)    
  985.         beq part2       
  986.     
  987. mode_switch:  subq.w #1,2(a0)     
  988.  
  989. check_effects: clr.w altpf      
  990.         move.w 6(a0),d2    
  991.         tst.w 8(a0)      
  992.         beq check_mod
  993.         tst.w 14(a0)      
  994.         beq cont_bend
  995.         subq.w #1,14(a0)
  996.         bra check_mod
  997. cont_bend:   addq.w #1,altpf    
  998.         move.w 10(a0),d3    
  999.         move.w 12(a0),d4    
  1000.         cmpi.w #1,8(a0)
  1001.         beq pbup
  1002.     
  1003.         sub.w d3,d2
  1004.         cmp.w d2,d4
  1005.         bcs check_mod
  1006.         bra fbend
  1007.  
  1008. pbup:     add.w d3,d2
  1009.         cmp.w d2,d4
  1010.         bcc check_mod
  1011. fbend:     move.w d4,d2
  1012.         clr.w 8(a0)      
  1013. check_mod:   tst.w 16(a0)
  1014.         beq send_alt_pitch
  1015.    
  1016.  
  1017.     tst.w  58(a0)
  1018.     beq st_ok
  1019.     subq.w #1,58(a0)
  1020.     bra send_alt_pitch
  1021. st_ok:
  1022.         tst.w 50(a0)
  1023.         beq cont_mod
  1024.         subq #1,50(a0)
  1025.         bra send_alt_pitch
  1026. cont_mod:    move.w 52(a0),50(a0)  
  1027.         addq #1,altpf
  1028.         cmpi #3,16(a0)
  1029.         bcc addmod
  1030.     
  1031.         move.w 56(a0),d3 
  1032.         sub.w d3,d2
  1033.         addq.w #1,16(a0)  
  1034.         bra send_alt_pitch
  1035. addmod:
  1036.  
  1037.         move.w 54(a0),d3 
  1038.         add.w d3,d2
  1039.         addq.w #1,16(a0)
  1040.         cmpi.w #5,16(a0)
  1041.        bne send_alt_pitch
  1042.         move.w #1,16(a0)  
  1043.  
  1044. send_alt_pitch: tst.w altpf
  1045.         beq send_env
  1046.         move.w d2,6(a0)  
  1047.         move.w d2,6(a2)  
  1048.  
  1049. send_env: 
  1050.  
  1051. do_env_check:
  1052.  
  1053. norm_env:
  1054.     move.l 18(a0),a1    
  1055.         cmpi.w #255,(a1)
  1056.         beq env_finished
  1057.     ;cmpi.w #1,66(a0)    
  1058.     ;bne    no_acc 
  1059.  
  1060. resu    clr.l d0
  1061.     move.w (a1)+,d0
  1062.     ;sub.w 64(a0),d0    
  1063.  
  1064.             ;test for mode here
  1065.     tst.w mode
  1066.     bne sete
  1067.  
  1068.     sub.w fade,d0
  1069.     bcc sete
  1070.  
  1071.  
  1072.     move.w #0,d0
  1073.  
  1074.  
  1075. sete    move.w d0,8(a2)    
  1076.     move.l a1,18(a0)
  1077.     rts        
  1078.  
  1079.  
  1080. no_acc:
  1081. ;resu:  
  1082. no_off
  1083.     ;move.w (a1)+,d0
  1084.     sub.w fade,d0
  1085.     bcc sete2
  1086.     move.w #0,d0
  1087. sete2    move.w d0,8(a2)
  1088.      move.w (a1)+,8(a2)
  1089.    
  1090. fint:   move.l a1,18(a0)    
  1091.     rts
  1092.  
  1093. env_finished:
  1094.     subq.l #2,a1    
  1095.     bra resu
  1096.     rts
  1097.  
  1098.  
  1099.  
  1100. one_shot_note: move.w #3,4(a0)     
  1101.         move.l 38(a0),(a2)
  1102.         move.w 42(a0),4(a2)
  1103.         move.w d1,dmacon     
  1104.         bra send_env
  1105.  
  1106.  
  1107. part2:                         
  1108.         move.l 44(a0),(a2)
  1109.         move.w 48(a0),4(a2)
  1110.         subq.w #1,2(a0)      
  1111.         move.w #1,4(a0)
  1112.         bra check_effects
  1113.  
  1114. sect3:
  1115.     move.w #0,66(a0)    
  1116.  
  1117.     move.l 22(a0),a1  
  1118. control_ret: move.w (a1)+,d0  
  1119.     cmpi.w #100,d0   
  1120.     bls sect5   
  1121.   
  1122. acc_note:
  1123.     move.w d0,6(a0)  
  1124.     move.w d0,6(a2)  
  1125.     move.w (a1)+,2(a0) 
  1126.     subq.w #1,2(a0)  
  1127.     move.l a1,22(a0)  
  1128.     move.l 34(a0),18(a0) 
  1129.     move.w 60(a0),58(a0) 
  1130.  
  1131.  
  1132.     tst.w 16(a0)
  1133.     beq no_mod_res
  1134.     move.w #1,16(a0)
  1135. no_mod_res:
  1136.     cmpi.w #0,4(a0)
  1137.     beq do_loop
  1138.     bra one_shot_note    
  1139.  
  1140.  
  1141. do_loop:    move.w d1,dmacon   
  1142.         bra send_env
  1143.  
  1144. do_rest:
  1145.     move.w (a1)+,2(a0) 
  1146.     subq.w #1,2(a0)  
  1147.     move.l a1,22(a0)  
  1148.     move.l  #drest_env,18(a0)
  1149.  
  1150.         move.w #0,8(a2)
  1151.         bra send_env
  1152.    
  1153. sect4:
  1154.         cmpi.w #0,4(a0)
  1155.         beq noof
  1156.         move.w d5,dmacon   
  1157. noof:     subq.w #1,2(a0)
  1158.         bra check_effects
  1159.    
  1160. sect5:     move.l #jump_table,a3
  1161.         move.l (a3,d0),a4
  1162.         jmp (a4)
  1163.  
  1164. jump_table: 
  1165.     dc.l  in_line_data
  1166.         dc.l  nsound
  1167.         dc.l  patt_end
  1168.         dc.l  get_env
  1169.         dc.l  check_pbend
  1170.         dc.l  do_mod
  1171.         dc.l  bend_off
  1172.         dc.l  mod_off
  1173.         dc.l  do_rest
  1174.         dc.l  end_fx
  1175.         dc.l  end_fx
  1176.     dc.l  s_f_on
  1177.     dc.l  s_f_off
  1178.     dc.l  set_acc
  1179.     dc.l  rept
  1180.  
  1181. in_line_data:
  1182.  
  1183.         nop
  1184.         rts
  1185.  
  1186. rept:
  1187.     move.l (a1),d0
  1188.     move.l (curr_base_address),a1
  1189.     add.l    d0,a1
  1190.     bra control_ret
  1191.  
  1192. s_f_on: 
  1193.     bclr #1,filter
  1194.     bra control_ret
  1195. s_f_off:
  1196.     bset #1,filter
  1197.     bra control_ret
  1198.  
  1199. nsound:
  1200. ;----------------------------
  1201.     move.l (a1)+,d0        ;sound offset
  1202.     move.l (curr_base_address),a3
  1203.     add.l d0,a3
  1204. ;----------------------------
  1205.         ;move.l (a1)+,a3     
  1206.  
  1207.         cmpi.w #0,(a3)
  1208.         bne one_shot_sound
  1209.  
  1210. xxx
  1211.         move.w (a3)+,4(a0)        ;length    
  1212.  
  1213. ;-----------------
  1214.     move.l (curr_base_address),a6
  1215.     move.l (a3)+,d0
  1216.     add.l d0,a6
  1217.     move.l a6,(a2)
  1218. ;--------------------
  1219.         ;move.l (a3)+,(a2)     
  1220.  
  1221.         move.w (a3),4(a2)    
  1222.         jmp control_ret
  1223.  
  1224. one_shot_sound:
  1225.         move.w (a3)+,4(a0)        ;type of sound
  1226. ;-----------
  1227.     move.l (curr_base_address),a6
  1228.     move.l (a3)+,d0
  1229.     add.l d0,a6
  1230.     move.l a6,38(a0)        ;address sample 1
  1231. ;---------------
  1232.         move.w (a3)+,42(a0)        ;length sample 1
  1233. ;---------------------
  1234.     move.l (curr_base_address),a6
  1235.     move.l (a3)+,d0
  1236.     add.l d0,a6
  1237.     move.l a6,44(a0)
  1238.  
  1239. ;---------------------
  1240.     ;add.l #4,a3
  1241.         move.w (a3),48(a0)
  1242.         jmp control_ret
  1243.  
  1244. patt_end:
  1245.  
  1246.         move.l 26(a0),a1    
  1247.         cmpi.l #0,(a1)     
  1248.         beq song_control        ;end of song
  1249.         addq.l #4,26(a0)            ;get next pattern address
  1250. ;-----------------------
  1251.     move.l (a1),d0        ;offset
  1252.     move.l (curr_base_address),a1
  1253.     add.l d0,a1        ;new pattern
  1254.  
  1255. ;------------------------
  1256.         ;move.l (a1),a1     
  1257.         jmp control_ret
  1258. get_env:
  1259. ;-----------------------
  1260.     move.l (a1)+,d0        ;env offset
  1261.     move.l (curr_base_address),a4
  1262.     add.l d0,a4     
  1263. ;--------------------------
  1264.     ;move.l (a1)+,a4 
  1265.  
  1266.     move.l (a4)+,62(a0)    
  1267.     
  1268.     move.l  a4,34(a0)    
  1269.     
  1270.         bra control_ret
  1271.  
  1272. check_pbend:
  1273.      move.l (a1)+,8(a0)
  1274.         move.l (a1)+,12(a0)
  1275.         bra control_ret
  1276.  
  1277. do_mod:    move.w #1,16(a0)  
  1278.         move.l (a1)+,50(a0)
  1279.         move.l (a1)+,54(a0)
  1280.         move.l (a1)+,58(a0)
  1281.         bra control_ret
  1282.  
  1283. bend_off:   clr.w 8(a0)
  1284.         bra control_ret
  1285.  
  1286. mod_off:    clr.w 16(a0)
  1287.         bra control_ret
  1288.  
  1289.  
  1290. end_fx:    
  1291.     cmpi.w #6,(a0)
  1292.     beq end_fx4p
  1293.     cmpi.w #5,(a0)
  1294.     beq end_fx3p
  1295.     cmpi.w #7,(a0)
  1296.     beq end_fx2p
  1297.  
  1298. end_fx1p:
  1299.         move.w d5,dmacon   
  1300.     move.w  #1,chann1reg+6
  1301.     move.w #0,8(a2)
  1302.     move.l #0,fxc1
  1303.     rts
  1304.  
  1305. end_fx2p:
  1306.     move.w d5,dmacon 
  1307.     move.w  #1,chann2reg+6
  1308.         move.w #0,8(a2) 
  1309.     move.l #0,fxc2
  1310.         rts
  1311.  
  1312.  
  1313. end_fx3p:
  1314.         move.w d5,dmacon   
  1315.     move.w  #1,chann3reg+6
  1316.     move.w #0,8(a2)
  1317.     move.l #0,fxc3
  1318.     rts
  1319.  
  1320. end_fx4p:
  1321.     move.w d5,dmacon 
  1322.     move.w  #1,chann4reg+6
  1323.         move.w #0,8(a2) 
  1324.     move.l #0,fxc4
  1325.         rts
  1326.  
  1327. set_acc: move.w #1,66(a0) 
  1328.     bra control_ret
  1329.  
  1330. song_control:
  1331.         addq.l #4,a1
  1332.         move.l 30(a0),26(a0)
  1333.         move.l 26(a0),a1
  1334.         addq.l #4,26(a0)
  1335. ;------------------
  1336.     move.l (curr_base_address),a6
  1337.     move.l (a1),d0
  1338.     add.l d0,a6
  1339.     move.l a6,a1
  1340. ;-----------------------
  1341.         ;move.l (a1),a1
  1342.         jmp control_ret
  1343.  
  1344.  
  1345.     ;"""""""""""""""""""""""""""""""""""""""""""""""""
  1346. ;************************************************************
  1347. gvars:
  1348. ch1vars     
  1349.     dc.w 0     
  1350.         dc.w 0,0,0,0,0,0,0,0,0,0     
  1351. pattr1: dc.l 0    
  1352. songr1: dc.l 0    
  1353. wsong1: dc.l 0   
  1354.         dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0   
  1355.  
  1356. ch2vars     
  1357.     dc.w 0     
  1358.         dc.w 0,0,0,0,0,0,0,0,0,0     
  1359. pattr2: dc.l 0    
  1360. songr2: dc.l 0    
  1361. wsong2: dc.l 0    
  1362.         dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0   
  1363.  
  1364. ch3vars 
  1365.     dc.w 0     
  1366.         dc.w 0,0,0,0,0,0,0,0,0,0     
  1367. pattr3: dc.l 0    
  1368. songr3: dc.l 0    
  1369. wsong3: dc.l 0    
  1370.         dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0   
  1371.  
  1372. ch4vars 
  1373.     dc.w 0     
  1374.         dc.w 0,0,0,0,0,0,0,0,0,0     
  1375. pattr4: dc.l 0    
  1376. songr4: dc.l 0    
  1377. wsong4: dc.l 0    
  1378.         dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0   
  1379.  
  1380.  
  1381. ch1fxvars 
  1382.     dc.w 0     
  1383. fxintc1:
  1384.     dc.w 0,0,0,0,0,0,0,0,0,0     
  1385. currfx1:
  1386.     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    
  1387.  
  1388. ch2fxvars 
  1389.     dc.w 0     
  1390. fxintc2:
  1391.     dc.w 0,0,0,0,0,0,0,0,0,0     
  1392. currfx2:
  1393.     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    
  1394.  
  1395.  
  1396. ch3fxvars
  1397.     dc.w 0     
  1398. fxintc3:
  1399.     dc.w 0,0,0,0,0,0,0,0,0,0     
  1400. currfx3:
  1401.     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    
  1402.  
  1403. ch4fxvars 
  1404.     dc.w 0     
  1405. fxintc4:
  1406.     dc.w 0,0,0,0,0,0,0,0,0,0     
  1407. currfx4:
  1408.     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    
  1409. ;************************************************************
  1410.  
  1411. drest_env    dc.w  0,0,0,0,0,0,0,0,255
  1412.  
  1413.  
  1414.  
  1415. dummy_reg dc.l 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1416.         dc.l  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1417.         dc.l  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1418.         dc.l  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1419.         dc.l  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1420.         dc.l  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1421.  
  1422.     even
  1423.  
  1424. fx_data_blk:    ;test place for getting the general fx data blk in
  1425.  
  1426.     ;incbin c:sf2d/gfx.bin
  1427.  
  1428. music_data_blk: ;test place for music data blk
  1429.  
  1430.     ;end
  1431.  
  1432.  
  1433.  
  1434. ;*****************************************************
  1435.  
  1436.  
  1437.