     TITLE   	"single scheme- Base Steam COAL FIRED SDF2.0 Decoder Series6 w/WHISTLE SELECTIONS"
----------------------------------------------------------------------------
NYC X-660Steam     Plow 	
SP7c4x6d30_ .SPJ Version 7.0
PROJECT_ID:  239  3/16/23
ASM:		SP7c4x6d30.asm	TEMPLATE
SDF:		SP7c4x6d30.SDF
BASE CODE:	SP7c4x6d30 -- Steam Rotary Plow, 4 Channel, SDF Version 2.0
MEMORY:	2 Mega bytes required
SDF3.0:	Requires -- 	 #INCLUDE	../SFX3p0_snd_cmd.INC
					and	 #INCLUDE	../SFX3p0_snd_macs.inc
DMF:		Requires -- 	SW Ver 8 OR newer
SOUND SET:	 Steam      Plow 44KHz
CHANNELS:	4
SERIES:	6
Author:  John McMasters
	Custom sound scheme. MAR, 2023 NOT for resale.
	(C) Copyright John McMasters 2023, used with permission.
CV60=0=STEAM SOUND SCHEME
reuse base code for each scheme:
DO NOT use hyphens in replacement arguments (above) or file names. Use underscores instead.
see <ENTER HERE> in ASM file -- Modify these constants for your custom model 

----------------------------------------------------------------------------
     NYC X-660      Plow	Steam Coal Fired
 
 Specifications:
 
 ALCO PLOW
 X-660

----------------------------------------------------------------------------
	INTRODUCTION
 ----------------------------------------------------------------------------
  This is the Sound Definition Language (SDL) file for a project that can be
  used for a 16bit premium 2mb sound decoder for a typical steam locomotive. 

Features:
	Bells -- bells may be chained to play for simulation of rope pulls, bell 5 is 3 part sound.
	Estop -- F14 will trigger shutdown
	Auto Vary Notch	--	motor sounds vary: idle blip, load sensing
	Horns/Whistles -- Selectable, playable, signal toots, automatic front and rear horn for commuter application
		Grade crossing horn plays rear horn sounds going backwards
		Analog Playable Horn/whistle/horn (horn runs that had the transition to higher pressure/ very loud modes)
	Brake Interlock	-- F3 will lock motor at standstill until released
		Integrated automatic braking sounds on F3
		All brakes are controlled by F3 (formerly F3) so that servo motor decoder braking could be syncronized
		EStop  on F8 On with F3 on shut-down	(disables motor movement until F8 OFF)
	4 CHANNELS (1 primary/motor, 2 high priority/whistle/horn, 3 braking bell/air/fan/misc, secondary motor/articulated, auxilary/road/blowers/pumps, CLANKS,SNIFTER,SLIPS/road, blowers/pumps)
 	Auto rod clank cyl blow down (steam cocks open)
 	Coast after deceleration for variable cycles depending on speed
 	Coal grate,  Coal chute,
 	Water Tank Fill, Stoker, shovel, Steam Greaser, Oil Pump, Empty Ash Pan
	Function-activated cylinder cocks sound effect at any speed step
	Manual chuff mode (equivalent to setting the steam throttle i.e. johnson bar
	with F6+ and F7- as well as automatic...)
	High Speed Rod Noise

COLD STARTUP FUNCTIONS:
	Play Startup Sounds: F3 + F4 and then release F4...
	The following Function Keys will SKIP STARTUP Sounds and begin with RUN sounds:
	F8, F0, F1, F2, F6, F4	
 ----------------------------------------------------------------------------
	DESIGN NOTES 
 ----------------------------------------------------------------------------
NOTE: Make sure that the model CV133 Steam Chuff/CAM config, 128=>EXT cam, 1-127=>DRIVER dia in inches[63]
	and CV134 Gear ratio are adjusted so that THERE ARE 4 STANDARD NON-ARTICULATED
		CHUFFS PER REVOLUTION.

SET -- SCALE_MIN,2,0	Range Volume Scale 1-14 to a value between 2-15
						Drifting volume will diminish to this level.

Limits:
	One SPJ project SDF of multiple schemes can run up to 64Kbytes of code.
	A single scheme has a 4Kbyte GOTO instruction branch range. (e.g. 2K 2-byte or 1K 4-byte instructions)
	That means that a BRANCH_TO an address beyond the range limit will not execute...

Changes and Bug Fixes:
	1) Fixed Bell Select so that bell 5 will play 2/7/17
	2) Add pitch vary to coupler sounds so that hard coupling will be different v4.0 5/24/16
	3) Vary auto grade crossing 6/25/16
	4) Revise Horn at speed 8/30/16
	5) Fixed Horn Selector so that playable bit7 works properly 	2/6/17
	6) Fixed Bell Select so that bell 5 will play 2/7/17
	7) Play long startup loop on COLD start 2/7/17
	8) Add VARY_LOAD routines 5/23/17
	9) v6.2 High Speed Rod Noise 1/30/20

Other Changes:
1) Use F3 for braking sound and integration to motor control. 
	E.G. When F3 is on unit will slow to a motor locked state. 
	Slowing is qualified by momentum CV3,4 (tested with both =30)
2) changed base motor volume scale from 8-15 to 11-15 Run1-5
	 (not necessary to make Run6-8 louder, idle may be <11 )
3) renamed SCV_BRAKE_VOLUME to SCV_PLOW_VOLUME and created  CV180  DIESEL DYNAMIC brake volume
	renamed CV144 to SCV_BRK_VOLUME
4) added CV161-189 (see doc)
5) since locomotive stops on F3 now -- the coupler sound cannot be on F3
		move coupler clash to the internals of direction change
		play coupler when F3 is ON and direction changes...
		revise tests for F3 related to auto coupler...
6) add handles for AIR_LETOFF, BRAKE_RELEASE, COUPLER_DISCONNECT
7) revise motor scale to vary for load	3/9/17 
8) revise (NOOP) notch scale volume to one line 3/9/17
9) revised NOTCH_UP_VAL =16 from 32 -- to smooth notch response
10) split brakes sound into 3parts -- play loop during braking
11) revise handle names and INC code names to make code handles different
	from sound handles E.G. GP38_ in code vs _EGP38_ handle
	This allows the use of a base code template to revise types of
	schemes (EMD diesel, ALCO diesel, Steam, etc.)
12) add ALCO Stumble at idle to RS1
13) revise horns to 4part handles 3/13/17
14) add play GEN1_TRANSITION 3/18/17
15) fix horn play by adding "	LOAD_MODIFIER	MTYPE_GAIN,IMMED_GAIN_MODIFY,SCV_HORNWHISTLE_VOLUME,SCALE_15	default VOLUME"
	to each begin play routine ?gain should remain set at default? but does not???
16) rename and sort horns handles 0-9 3/20/17
17) revise  3/29/17
18) review and revise extended CVs for compatibility 4/1/17
19) revise for VARY_HNDL_INX steam chuffs 4/2/17 removed 4/3
20) revise F2 HORN_DELAY in all schemes so that gain is set after 4/4/17
21) add disable for F3 braking to stop 4/5/17
22) fix braking loop invert 4/5/17 in all 8 schemes
23) apply disables to:
		CV187	0-254 [16]  is BIT values to disable additional features 
		bit3 disable Servo Motor Lock on F3			=8
		bit4 disable Startup Muted					=16
24) remove loop from hard brake routine 4/6/17
25) revise horn/whistle scale back to SCALE_15	4/7/17
26) revise braking and chuffs again 4/9/17
27) finish set generate F8 4/13/17
28) add playable horn/whistle interlock so that each F2 horn/whistle may have max gain set 4/13/17
29) improve playable control remove interlock 4/17/17
30) Build full feature diesel project – revise notching to use native work notch.
31) Improve short horn when F3 ON and F2 trig
32) Revert F3/F3 to coupler/braking
33) rewrite notch value code to use WORK_CUR_NOTCH and delta 
34) remove NOTCH_VALUE0_9		EQU WORK_USER_1 	 used to save Notch Difference	0-7
35) use CV170	Cutoff Speed LOW	speed when braking skipped	4-39	[12]
36) Improve short horn when F3 ON and F2 trig
37) Fix horn7, horn3 4/30/17
38) Replace all ,IMMED_DATA,SCV_ with ,TARGET_DATA,SCV_	5/1/17
39) Fix CV187 desc, CV189 init 	5/7/17
40) Fix WORK_NOTCH,IMMED_DATA to COMP_ALL since leftmost bits are being compared...
41) Fix F6 DELTA, RANDOM BLOWOFF, SLIP
42) Revise F5 for open cylinder cocks 1/31/18 (was F4)
----------------------------------
NOTES:
 notch volume routine is improved when the volume scale is set by
	other external events (deceleration, start from standing, acceleration, etc.)
	VARY_LOAD is used to implement the effect

----------------------------------
     FUNCTION KEYS DEFINED:   
----------------------------------
(A) Function Key Usage: 
F0- Lights  [disables start-up sounds when on during initialization]
F1- Bell 	Bell5 is 3part (Bells1-4 may be chained)
F2- Whistle	CV150 selects Horn/Whistle type	(Playable when bit7 of CV150 is on)	-- Shorter sounds when F9 ON
F3- Coupler 	--	Use for start-up -- F3 on + F4 on to cold start (release F4 to end fuel prime)
F4- PLOW ON
F5- Steam Blowdown / Steam Safety Blowoff.../Steam Waterpump turbine
F6- Light function
F7- Wheel Squeal (continuous when moving) [Disables bell on F1]
F8-  Mute control/Start-up	[F8 to OFF is muted to CV volume, 
		F8 ON, set REG volume]
		On the initial push of F8 the sound comes up. 
		A secondary push raises the sound again to normal levels.
		ES- top  on F8 On with F3 on shut-down	(disables motor movement until OFF)
F9- UnCouple / Coupler disconnect	[Auto-coupler/brake set by  CV151 max spd]
		Lift ring and connect plays with F9 when F9 is ON
		Long train consist brake sounds with F20 ON
		Steam Wheel Slip on start-up (Enable) /auto coupler
		(disables toots on F9) [Leave on for auto toots]
F10- BRAKE TO STOP -- Usage:
			Independent Brake/Train Brake	[Leave F9 OFF for auto brakes] 
			[F10 on will enable servo motor stop.]
			Toggle OFF plays directional toots WHEN F9 ON
		1) Slow servo motor to stop using CV3,CV4 momentum values (where
			larger value (30) takes longer to slow/accelerate)
		2) Lock motor at standstill to simulate engine brake set. Servo
			will not resume until F10 is toggled off.
		3) While brake is set toggle F9 on to begin uncoupling. F9 will play 
			lift ring noise in preparation for disconnect. 
		4) Releasing the brake and advancing the throttle will play coupler
			disconnect when F11 is already on.
		Brake rate is determined by BEMF and CV3,4
	 	Auto Coupler coupler clank and BRAKE if F9 is ON,  is dir chng and last PK spd below e.g. CV151
			[Auto-coupler/brake set by  CV151 max spd] F9 ON for un-coupler
			[Leave F9 on for auto coupler]	
			EStop  on F8 On with F3 on Shutdown	(disables servo motor movement until OFF)
			Toggle OFF plays directional toots WHEN F11 OFF
 	F10 OFF -- Release Brake [not F3 Apply else Release] / Long train consist brake sounds on F20
F11- Allow SUSTAIN horn on F2
F12- Coupler / Coupler disconnect	[Autocoupler/brake set by  CV151 max spd]
		Lift ring and connect plays with F9 when F11 is ON
		Long train consist brake sounds with F20 ON
		Steam Wheel Slip on start-up (Enable) /auto coupler
		(disables toots on F9) [Leave on for auto toots]
F13- Coal Fill / Compressor/Air features disable     
		F13 ON =disable AIR sound/FEATURES, trig BLOWOFF/HNDL_FAST_DRYER1 then compressor ONE time
		[F13 OFF enables pop-off, DRYER and compressor]
F15- EStop when moving and shut-down	(disables motor movement until OFF)
F16- Water Fill
F17- Shovel Coal
F18- Sanding
F19- Short Air Let Off	/Long train consist brake sounds on F9
	  Steam=Safety Blowoff
F20- Steam -- Coal Grate Shaker, Empty Ash Pan
F21- Steam=Greaser
F22- LIGHT BOILER	  
F23- HEAT UP -- TURN ON BLOWER	  
F24- Reverser -- Johnson Bar -- FWD or REV 
F25- Safety 
F26- Notch UP 	Leave on for increased load
		Leave F26 OFF to use run trim option: [will increment 
		notches on acceleration events 
		F27 will decrement run trim.
F27- Notch down	-- Leave ON for decreased load
		Toggle F27 ON Is notch down for EVENT, 
			integrate -VE in SPEED_DELTA
		F27 will decrement run trim (i.e., use to select lower trim value).
		Steam=Wheel-slip, when CV155 is not 0 and F9 ON
F28- Notch 8
F29- Alt Grade Crossing
F30- Force Startup
F31- Generator
F32- 
	==================================  
	Many sound levels have been reduced so that horn/whistle is much louder.
	Global Gain in the project has been maximized to help. Some low volume 
	levels may need increases on your model.

	==================================  
(B) Sound FX defined CV's: 	[decoder CV8=8  reset value in brackets]
CV3   Momentum acceleration rate, 0-31, 31=max, (F3 uses after braking to stop) [30]
CV4   Momentum deceleration rate, 0-31, 31=max, (F3 uses for braking to stop) [30]
CV7 Version ID 51=Older decoders, 16=Newer SFX2 decoders
SCV_RESET (CV8)  Reset Decoder values to factory =129=Digitrax
SCV_19  Advanced Consist [0]
SCV_21  Advanced Consist F0-F8 [248] 
SCV_22  Advanced Consist F3-F12 [52] 
CV23  Acceleration Mass 0-255 [30] 
CV24  Deceleration Mass 0-255 [30] 
CV58  Master Volume, 0-15, 0= max, (F8 used for Mute) [11] 
CV60  Scheme select CV, 0=Diesel 1=Steam	[0]
CV64  Logic select CV, 0=Aux Logic output 64=Normal LED outputs	[64]
CV121 Sound Project SDF Version 0,4,8,16	Read Only Value
CV122 Product TYpe, 12 = Digitrax SFX sound decoder 	Read Only Value
CV123 Hardware Version, 64= SDXH166 type decoder	Read Only Value. May vary based on SFX2 decoder loaded into.
CV132 Engine Notch rate		64-255	[127]
CV133 Steam Chuff/CAM config, 128=>EXT cam, 1-127=>DRIVER dia in inches [60]
CV134 Steam gear ratio trim, 32=100% ratio,	[41]
CV135 vol level when MUTE action is triggered, e.g. F8=ON	[30]
CV139 Set to trigger distance event	0-64	[30]
User configurable SoundCV's:
CV140 PRIME mover Diesel/chuff exhaust vol 0-64	[50]
CV141 Bell Volume							0-64	[36]
CV142 WHISTLE/HORN vol						0-64	[42]
CV143 POPOFF AIR feature volume, DRYER, compressor, brake release Air sounds Volume 0-64 [49]
CV144 Engine brake volume 0-64	[55]
CV145 Miscellaneous volume 0-64	[51] 
CV146 Delay (24mS counts) between Bells 1-100	[01] 
CV147 Time between DRYER cycles Users normally reset DRYER rate to 10 or more[27] 
CV148 Time between Airpump/Compressor cycles	[30] 
CV149 Airpump/Compressor run time				[52] 
CV150 Horn/Whistle Selector,0=std ,  1/7 =Alternate, +128 for Playable volume [0]
			HORN SELECTED CV150:
						Decimal	HEX			Bit
											7654 3210
				1		0		0x00		0000 0000
				2		1		0x01		0000 0001
				3		2		0x02		0000 0010
				4		3		0x03		0000 0011
				5		4		0x04		0000 0100
				6		5		0x05		0000 0101
				7		6		0x06		0000 0110
				PLAYABLE:
				1		128		0x80		1000 0000
				2		129		0x81		1000 0001
				3		130		0x82		1000 0010
				4		131		0x83		1000 0011
				5		132		0x84		1000 0100
						Decimal	HEX			Bit
CV151 speed limit FOR AUTOMATIC COUPLER/BRAKE on DIR chng. about 1/2MPH per unit
CV152 defines USER code for this SDF
CV153 is SUB id
CV154 Delay brake apply / speed at which brake sounds begin to play	1-100 [12] 
CV155 Notching mode 0=AUTO, 1=SEMIAUTO, 2=MANUAL NOTCHES	[01] /STEAM Slip Mode: 0=AUTO, 1=SEMIAUTO, 2=MANUAL 						[01]
CV156 delay for HORN start in 27mS VALUES
CV157 is FOR bell selection 
	BELL SELECTED CV157:
						Decimal	HEX			Bit
											7654 3210
				1		0		0x00		0000 0000
				2		1		0x01		0000 0001
				3		2		0x02		0000 0010
				4		3		0x03		0000 0011
				5		4		0x04		0000 0100
CV158 DIGITRAX RESERVED
CV159 Grate Shaker Volume				0-64	[64]
CV160 VARIANT id or project version		0-254	[000]
CV161 Initial Idle Trim 				4-32	[32]
CV162 Water Injector Volume				0-64	[25]
CV163 Safety Run Time/ how often to check boiler pressure		0-64	[32]
CV164 Level in the guage/ Water Pump Cycle Time, percent full	0-64	 [19]
CV165 add fuel to firebox at 150lbs/ Stoker/oil pump run time	0-254	[20]	
CV166 Cutoff Speed for wheel slip chuffs				4-9	[9]
CV167 Cutoff Speed for Auto Cyl. blow down			0-64	[7]
CV168 Stoker Volume									0-64	[32]
CV169 Cutoff Speed for high speed chuffs			40-99	[48]	
CV170 Cutoff Speed LOW	skips brake sounds			4-39	[12]
CV171 AUX GEN VOLUME								0-64	[40]
CV172 FAN MOTOR VOLUME								0-64	[30]
CV173 STEAM blowdown volume							0-64	[50]
CV174 AIR DRYER Air sounds Volume 					0-64	[49] 
CV175 Air compressor volume							0-64	[40]
CV176 TRACTION MOTOR VOLUME							0-64	[60]			
CV177 Coupler Slack Volume							0-64	[31]
CV178 Steam Boiler Volume							0-64	[40]
CV179 PLOW VOLUME 				0-64	[55]
CV180 Steam blow down/Safety vol					0-64	[59]
CV181 Power Reverser volume							0-64	[40]
CV182 brake release Air sounds Volume 				0-64 	[32] 
CV183 Water fill/Coal fill Volume						0-64	[54]
CV184 Steam cock blow down threshold 					1-64	[24]
CV185 bit values to disable features1:					0-128	[0]
		bit0 disable  HEP diesel =0 AUX GEN	=1			=1		
		bit1 disable hard automatic braking 			=2
		bit2 disable start up sounds					=4
		bit3 disable Fans								=8
		bit4 disable toots on direction change			=16
		bit5 disable grade crossing random play 		=32
		bit6 disable bell								=64
		bit7 fuel prime once for Gen1 diesels OR multiple start warning bells Gen2	=128
CV186 bit values to disable additional features2 		0-128	[0]
		bit0 enable Diesel Low Idle=1		Disabled=0	=1=Enabled
		bit1 disable Chain bells 						1-4	=2
		bit2 disable STOKER change to SHOVEL			=4
		bit3 disable AUTO VARY NOTCH					=8
		bit4 disable Shaft Driven Compressor 			=16
		bit5 disable ALCO Idle Stumble=32 Disable=0		=32
		bit6 disable Auto REAR horn signals: 0=Off, 64=On	=64
		bit7 disable Dual Prime Movers		0=Off 128=Dual On
CV187 bit values to disable additional features3 	0-128 [0]
		bit0 disable Short Opt Horn/whistle	 Enabled=0,   =1=disabled
		bit1 disable DEMO ALL HornS/whistles Enabled=on=0,=2=disabled
		bit2 disable Bell on Idle Exit				=4
		bit3 disable Motor Lock on F3				=8
		bit4 disable Start up Muted					=16
		bit5 disable Dynamic BRAKES					=32
		bit6 disable 								=64
		bit7 disable Auto Wheel Slip				=128
CV188	BIT values to disable additional features4	0-254 [0] 
		bit0 disable Traction Motor 		= 1 Disabled
		bit1 disable 2								=2
		bit2 disable 3								=4
		bit3 disable 4								=8
		bit4 disable 5								=16
		bit5 disable 6								=32
		bit6 disable 7								=64
		bit7 disable 8								=128
CV189 Water Alarm Volume							0-64	[45]
CV190 Cutoff Speed for high speed chuffs			40-99	[48]	
CV191 Drift Volume									0-64	[20]							
CV192 Cutoff Speed for LONG HORN					4-9	[9]
CV193 Sound Project TYPE
Possible Values are :
	:			Decimal	HEX			Bit
	:								7654 3210
	:	1		0		0x00		0000 0000		Steam Coal
	:	2		1		0x01		0000 0001		Steam Oil
	:	3		2		0x02		0000 0010		Steam Coal  Articulated
	:	4		3		0x03		0000 0011		Steam Oil Articulated	
	:	5		4		0x04		0000 0100		Steam Geared	
	:	9		8		0x08		0000 1000		Steam non-fired	
	:	81		80		0x50		0101 0000		Gas Carbody / Doodlebug
	:	127		128		0x80		1000 0000		Diesel
	:	145		144		0x90		1001 0000		Diesel Carbody	
	:	193		192		0xC0		1100 0000		Diesel Dual Motor (startup Linked)	
	:	225		224		0xE0		1110 0000		Diesel Dual Motor (startup un-Linked)
	:	241		240		0xF0		1111 0000		Diesel Boxcab
	:	137		136		0x88		1000 1000		Traction
CV194 Sound Project Memory Required [1=512kb, 2=1024kb, 3=8mb, 4=4mb, 8=8mb, 16=16mb].
CV195 Sound Project JMRI Definition(0-255)
CV201 RESERVED
CV202 RESERVED
CV203 Decoder Memory Available (read only) [1=512kb, 2=1024kb, 3=8mb, 4=4mb, 8=8mb, 16=16mb].
		
V5.01 Fix: AND, OR BIT FLIP FLOPS AND COMPARES: 7/18/17
		  MASK_COMPARE 	USER_INTLK_BITS,IMMED_DATA,CYLTURBINE_MASK4,~CYLTURBINE_MASK4,SKIP_SAME	TEST BIT4 FOR TRUE WHEN SET=ON / SKIP_LESSSKIP_GRTR  		
		  LOAD_MODIFIER	MTYPE_WORK_IMMED,FMATH_OR+USER_INTLK_BITS,CYLTURBINE_MASK4,MERGE_ALL_MASK	OR=SETtheBit bit4	OPEN CYLCOCK INTERLOCK
		  LOAD_MODIFIER	MTYPE_WORK_IMMED,FMATH_AND+USER_INTLK_BITS,~CYLTURBINE_MASK4,MERGE_ALL_MASK	AND=FLIPtheBit bit4	OPEN CYLCOCK INTERLOCK
v5.02 Fix: START_MASK1 7/21/17
v5.3 3/20/18 add more definition CVs 199-203, change QUILL back to SUSTAIN2


(C) General Notes
Project sounds are amplified to the limit. When lower power is supplied while on
a test bench using SoundLoader louder sounds will exceed the speaker output range (see formula). 
Running at full power on the main track in real use, sound levels may be increase significantly.
This project was tested at Master Volume CV58=11. Horn Volume was tested at CV142>50. 
Prime mover Volume was tested at CV140>50. However,
Default Master Volume CV58=9 THIS SHOULD BE 7 OR LESS FOR TESTING WITH SOUNDLOADER - JohnM 3/23/17

Set CV60 to 0 for this project.
The SDXH166 16bit series2 SFX decoders allow downloading of 8,12 and 16 bit wave files and up to 4 
voices defined in the SDF project definition embedded in SPJ file. 

For CV155=01 ["Semi_automatic Notching"] when CV60=0 to 5 (Diesel),  the Prime mover lowest Notch setting is set by
the current throttle speed setting. F6 (ON) can increase the Notch and F7 (ON) will decrease the Prime mover
to the minimum notch set by current throttle setting.

Cam triggered exhaust sounds (e.g. steam) are only configured for 8 or 16 bit wav file downloads.
RS1 sound courtesy of R  Schramm, some Bells/Horns courtesy Matt Donnelly, some prime movers by C Brown and P Knowles 
Many sounds (EMD 645E NT, P42) are derived courtesy of jointedrail com, used by permission  Additional sounds courtesy John McMasters
Other contributors may include Mike Cyr/Justin Cordell and other Digitrax contributors and employees and contractors 
Balance of sounds recorded by Digitrax Inc  All sounds used by permission 
