;------------------------------------
;   sub 0: _Engine1_Level
;   sub 1: _Engine1_Trig
;   sub 2: _Engine1_Action
;------------------------------------

#define BANK_SPLASH 4

#define PRG_ENGINE1_NOWATER  0	;L2 nowater
#define PRG_ENGINE1_L2  1	;L2 onwater
#define PRG_ENGINE1_KARAMAWARI 2	;L2 nowater

;**************************
;  Engine Sound 1
;**************************

_Engine1_Level
 	Amode
	initpitch
;  		     pause,mono,pri,trs, pan,pow,fxmix,line
	multiparamset, $f0 ,$02, 15 , 0 , 64, 127,  16 ,  1

        panmode,1

;   priority,15
;   spanpow,127	
;   monomode,2	;	limit in sub & note mono
;   pausestatus,$f0
;   fxline,1
;   fxmix,16
;   vibdepth,64
;   vibpitch,96
;   vibdelay,0
  
   sr_load,#0
   sr_portwrite,PORT6	;velocity default 0
  
   bprg, 	 BANK_TEST,	 PRG_ENGINE1_L2
   svolume,60

@_WAIT
   waith,8
   sr_portread  ,PORT0
   jumpN, @_WAIT
   sr_portwrite ,PORT4
   allocvoice,3				;Level
@_REOPEN
   opennote,0,_Engine1_Level_Note		;Level Engine
   opennote,1,_Engine1B_Level_Note		;Level Engine

@_ACTIVE
   waith,8
   sr_portread, PORT5
   sr_store,0,_Engine1_PowerL(+1)
   sr_store,0,_Engine1_PowerH(+1)

   sr_portread, PORT6
   jump0,@_Jump_Jet
   jumpN,@_Touch_Jet

@_VeloStore
   sr_store,0, _WaterJet_Velo(+1)

   sr_portread  ,PORT4			; Engine Stop Signal
   jumpP, @_ACTIVE
@_STOP
   closenote,0
   closenote ,1
  deallocvoice
   jump,@_WAIT

;...........................................	Jump Routine: Prg change.
@_Jump_Jet
   prg ,	 PRG_ENGINE1_KARAMAWARI
   sr_load,#127
   jump,@_VeloStore
      
;...........................................	Touch Routine: Prg change.
@_Touch_Jet
   prg ,	 PRG_ENGINE1_L2
   sr_load,#127
   jump,@_VeloStore


;===== Low Engine =====

;_Engine1_Level_Note
;   nprg ,	 PRG_ENGINE1_L1
;   sweepfrom,$85,cn1,255	; A->B , Hokan 
;   TGATE,15
;   tieon
;   VELO,100
;@_Loop
;   gn4,16
;   jump,@_Loop

;===== Low Engine  =====


_Engine1_Level_Note
   nprg ,	 PRG_ENGINE1_NOWATER
;   sweepfrom,$85,cn1,255	; A->B , Hokan 
   TGATE,15
   tieon

_Engine1_PowerL
@_Loop
   ntrans,0
   VELO,117
   cn4,8
  bra,@_Loop
 




;===== High Engine & Water (switching) =====


_Engine1B_Level_Note
   sweepfrom,$85,cn1,255	; A->B , Hokan 
   TGATE,15
   tieon

_WaterJet_Velo
   VELO,100
_Engine1_PowerH
   ntrans,0
   cn4,8
  bra,_WaterJet_Velo
 







;----------------------------------------
;  Engine1 Action
;----------------------------------------

_Engine1_Action
   Bmode
   initpitch
;  		     pause,mono,pri,trs, pan,pow,fxmix,line
	multiparamset, $f0 ,$00, 10 , 0 , 64, 64, 32 ,  1

    panmode,1
    svolume,127

;   pausestatus,$f0
;   monomode,0	;	no limit
;   fxline,1
;   fxmix,32	;default
;   spanpow,64			;Change with span ?
;   span,64
;   priority,10


@_openwait
   waith,8

   sr_portread ,PORT0
   jumpN,@_opensplash

   sr_store,0,@_Note
   sr_portread ,PORT5		; Action Velo
   sr_store,0,@_Note(+3)	; PORT 5:Velocity 

   bankchg,BANK_TEST
   prg,	PRG_PERCUSSION
   opennote, 0,@_Note

   jump ,@_openwait

   

@_opensplash

   sr_portread ,PORT1
   jumpN,@_openwait
 
    sr_portwrite,PORT7		;Stack

;Req->PercNum
    sr_extbl,_Splash_Vtable
    sr_store,0,@_Note2_Note
;Req->PanNum
    sr_portread,PORT7
    sr_and,#$03
    sr_extbl,_Splash_Ptable
    sr_store,0,@_Note2_Pan(+1)	
    
    sr_portread ,PORT6		; Splash Velo
    sr_store,0,@_Note2_Note(+3)	; PORT 6:Velocity 	

    bprg,BANK_SPLASH, PRG_PERCUSSION

    opennote, 1,@_Note2

   jump,@_openwait



@_Note
   p00b0w, 320,127,0		;Velo 127,Gate Max 
   fin
   
@_Note2
@_Note2_Pan
   npan,0
   killpan	   
@_Note2_Note
   p00b0w, 320,90,0		;Splash Only. 
   fin


_Splash_Vtable
#byte	0,0,0,0
#byte	1,1,1,1
#byte	2,2,2,2
#byte	3,3,3,3
#byte	4,4,4,4

_Splash_Ptable
#byte	0,64,127,0
