;#####################################################
;     Wave Race 64  Sound Effect Sequence
;
;  first date:1996/04/01 
;
;#####################################################

#include "neos64.def"

;****************
;* Macro Define *
;****************   

;--------------------------------------
;  BANKS
;--------------------------------------

#define BANK_TEST    0
#define BANK_SYS     1
#define BANK_DJ      2
#define BANK_CHEER   3
#define BANK_WAVE    4
#define BANK_OBJECT  5
#define BANK_ANA     6
#define BANK_VSVOICE 7
#define BANK_PLVOICE 8

#define PRG_BOOST    0


#define PRG_BOOST2   0
#define PRG_ENGINE2  1
#define PRG_ENEENGINE      16
#define PRG_ENEENGINE2     16
#define PRG_ENEENGINE3     16

#define PRG_LANDWATER      18


#define PRG_WAVE1    8

#define PRG_PERCUSSION 127


#define PERC_CRASH1	 8
#define PERC_CRASH2	 9
#define PRG_TOUCH_FANCE  19




;****************
;* GROUP TRACK  *
;****************   

_Start
;   tempochg,250
;   tempoofs,+50		;TEMPO=300 (250+50)
   defpause,$20
   pausevolume,60

   volumemode,_VOLCHG_FADEIN_,100
   volumechg,127

   tempochg,200			;2process / 1 Vframe
   allocsub,$ffff		;Track 0-7 ,89,,10-11,13-15

;------------------------------ First Needs 
   opensub , 15, _SYSTEM_SE
   opensub , 12, _VOICE_SE
   opensub , 11, _CHEER_SE
   opensub , 10, _PLVOICE_SE
   

;   gr_portread,PORT0
;   jump0,@_Nowait
    gr_load,#0
    gr_portwrite,PORT0
;   waitw,100

@_Nowait
;------------------------------ Players 
   opensub , 0, _Engine1_Level
   opensub , 2, _Engine1_Action

   opensub , 3, _Engine2_Level
   opensub , 5, _Engine2_Action

;------------------------------ Triggers

;  opensub , 6, _Crash
   opensub , 7, _Object_Se



;------------15  (Used by System se )
;------------14  (Used by System se )
;------------13  (Used by System se )



@_Wait   
   wait,16
   jump, @_Wait
   FIN


#include "engine1.se"	;sub0, 2
#include "engine2.se"	;sub3, 5

#include "object.se"	;sub 7	bank 5	


#include "plvoice.se"   ;sub10
#include "cheer.se"	;sub11
#include "voice.se"	;sub12
#include "system.se"	;sub13-15



   
;************************************
;* SUB TRACK 5: Trigger Sound       *
;************************************   

_Crash
   panmode,1
   spanpow,127
   SR_LOAD, #64  
   SR_PORTWRITE,PORT5 		;Pan input port init
   bankchg,BANK_TEST
   Amode
   svolume,127
@_Wait1
   return
   sr_portread,0
   jumpN,@_Wait1
   tblset,@_calltable
   closenote,0
   sr_calltbl
   jump,@_Wait1
   

@_calltable
#label _BUOY,_CRASH1,_CRASH2,_FANCE


_FANCE
   vibdepth,0
   Prg,PRG_TOUCH_FANCE
   SR_PORTREAD,PORT5 
   SR_STORE,0,@_Pan(+1)
@_Pan
   span,0			;value will overwrite
   opennote,0,@_Note
@_End_or_ChangeWait
   wait,32			; 8 frame
   sr_portread,0
   jumpN,@_Return
   sr_portwrite,4		;Temp Copy 
   sr_sbc,3			;Fance value ? 
   jump0,@_End_or_ChangeWait	;Ok,continue fance touch level.
   sr_portread,4		;Temp Copy 
   sr_portwrite,0		;next frame, input 
@_Return
   closenote,0
   fin

@_Note
   velo,127
   dgate,0
   tieon
@_Loop
   cn4, 16			;Velo 127,Gate Max 
   jump,@_Loop


   
_BUOY
   vibdelay,0
   vibdepthmv,16,64,2
   vibpitch,127
   Prg,130
   envelope ,@_Env

   SR_PORTREAD,PORT5 
   SR_STORE,0,@_Pan(+1)
@_Pan
   span,0			;value will overwrite
   opennote,0,@_Note
   fin

@_Note
   velo,127
   dgate,0
   tieon
   sweepfrom,$83,DN1,254
   fn2, 16			;Velo 127,Gate Max 
   gn3, 102			;Velo 127,Gate Max 
   fin
  
#evenw
@_Env
#word	 1, 32000 ,64, 0, 0, 0


_CRASH1
   sr_load,PERC_CRASH1
_CRASH_K
   sr_store,0,@_Notenum
   prg,127
   vibdepth,0
   sr_portread,PORT5
   sr_store,0,@_Pan(+1)
@_Pan
   span,0			;value will overwrite
   opennote,0,@_Note
   fin
     
@_Note
   velo,127
   dgate,0
@_Notenum
   p00w,240			;Velo 127,Gate Max 
   fin
 
_CRASH2
   sr_load,PERC_CRASH2
   jump,_CRASH_K
      
   

