001package jmri.jmrix.loconet.sdf;
002
003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
004
005/**
006 *
007 * @author Bob Jacobsen Copyright (C) 2007, 2010
008 */
009@SuppressFBWarnings(value = "MS_OOI_PKGPROTECT") // Don't worry about malicious code changing constants
010public interface SdfConstants {
011
012    /* **********************
013     * Constants
014     ** **********************/
015//-------------------
016    int TRUE = 1;
017    int FALSE = 0;
018    int[] trueFalseCodes = new int[]{TRUE, FALSE};
019    String[] trueFalseNames = new String[]{"TRUE", "FALSE"}; // NOI18N
020
021// TRIGGER values
022// sound TRIGGER PREMPT control bits
023// SPECIAL trigs: POL,0,0,0-0,s,s,s  0-7 are special trigs
024// FN trigger format: POL,0,0,B-B,b,b,b    BB 1 of 3 bytes 01,10,11 (24 fns), bbb is bit adr#
025    int NORMAL = 0;   // (complete .WAV frag/preempt higher/trigger true)
026
027    int ZAP = 0x01; // value for ZAP on PREMPT
028    int RUN_WHILE_TRIG = 0x02; // mask/binary values
029    int NO_PREEMPT_TRIG = 0x04;
030    int NOT_TRIG = 0x80; // 12/13/04, in TRIG argument now
031
032// 3 ls bits of INITIATE CMD 1ST byte
033    int CMD_ZAP_BIT = 0; // 1=END immed if PREMPTED, 0=finish current .wav frag before END
034    int RUN_WHILE_TRIG_BIT = 1; // 1=persistent while TRIGGER is valid, 0=run once
035    int NO_PREEMPT_TRIG_BIT = 2;
036
037    int NOT_TRIG_BIT = 7; // POL bit in TRIG byte 1=reverse POL
038
039    int[] premptCodes = new int[]{ZAP, RUN_WHILE_TRIG, NO_PREEMPT_TRIG, NOT_TRIG}; // NORMAL matches all (is zero), so left off
040    int[] premptMasks = premptCodes;             // just check 1 bits
041    String[] premptNames = new String[]{"ZAP", "RUN_WHILE_TRIG", "NO_PREEMPT_TRIG", "NOT_TRIG", "NORMAL"}; // NOI18N
042
043//----------
044// TRIGGER initiate CODES
045    int TRIG_NEVER = 0x00; // 0 is INACTIVE entry (NULL,not a valid INITIATE coding)
046    int TRIG_MODE_CHNG = 0x01;
047    int TRIG_MATH = 0x02; // math result trigger
048    int TRIG_DISTANCE = 0x03; // have new increment of distance, use for FUEL low alarm, maintenance ETC
049
050    int TRIG_SPD_INC = 0x04; // have SPD increase
051    int TRIG_SPD_DEC = 0x05; // have SPD decrease
052    int TRIG_CAM = 0x06; // TRIG on CAM event, either H/W input or AUTO-chuff,
053    int TRIG_NOT_TRIG = 0x07; // brk/loop SPECIAL, a.k.a. "loop_till_init_TRIG"
054
055// -------
056// F1-F28 and F0 map into 3 BYTES of static trig state/fn state bits
057// these triggers preCODED for fast TRIG bit adr   POL,0,BBB,bbb:   BB=byte,bbb=bit adr
058// Mapped to internal allocations
059    int MOVE_BIT = 6;    // moving BIT
060    int MVFN_MASK = 0x1F; // direct FN bits
061
062    int TRIG_SF1 = 0x08; // F1 change event
063    int TRIG_SF2 = 0x09; // byte 1, bit1
064    int TRIG_SF3 = 0x0A;
065    int TRIG_SF4 = 0x0B;
066
067    int TRIG_SF0 = 0x0C; // headlight/F0 state
068    int TRIG_DIRNOW_CHNG = 0x0D; // have DIR_NOW changed
069    int TRIG_MOVING = 0x0E; // SPD = Non-Zero
070    int TRIG_SND_ACTV11 = 0x0F; // DECODER is SPD addressed within CV11 time
071
072// ----------
073    int TRIG_SF5 = 0x10; // byte 2,bit0
074    int TRIG_SF6 = 0x11;
075    int TRIG_SF7 = 0x12;
076    int TRIG_SF8 = 0x13;
077
078    int TRIG_SF13 = 0x14; // BYTE 2, bit 4,
079    int TRIG_SF14 = 0x15;
080    int TRIG_SF15 = 0x16;
081    int TRIG_SF16 = 0x17;
082
083// ---------
084    int TRIG_SF9 = 0x18; // byte 3 bit 0
085    int TRIG_SF10 = 0x19;
086    int TRIG_SF11 = 0x1A;
087    int TRIG_SF12 = 0x1B;
088
089    int TRIG_SF17 = 0x1C; // byte 3, bit 4
090    int TRIG_SF18 = 0x1D;
091    int TRIG_SF19 = 0x1E;
092    int TRIG_SF20 = 0x1F;
093
094//
095    int TRIG_SF21 = 0x20; // expanded FUNCTIONS
096    int TRIG_SF22 = 0x21;
097    int TRIG_SF23 = 0x22;
098    int TRIG_SF24 = 0x23;
099
100    int TRIG_SF25 = 0x24;
101    int TRIG_SF26 = 0x25;
102    int TRIG_SF27 = 0x26;
103    int TRIG_SF28 = 0x27;
104
105//
106//----------------FIRST 8 bsc regs reserved
107    int TRIG_BSC0 = 0x28; // expanded FUNCTIONS
108    int TRIG_BSC1 = 0x29;
109    int TRIG_BSC2 = 0x2A;
110    int TRIG_BSC3 = 0x2B;
111
112    int TRIG_BSC4 = 0x2C;
113    int TRIG_BSC5 = 0x2D;
114    int TRIG_BSC6 = 0x2E;
115    int TRIG_BSC7 = 0x2F;
116
117//------------------
118//these trig lines both REPORT the external inputs to decoder, and CAN also be SET/RESET by SDF trigger commands
119// and can be read back by TRANSPONDING as external ALARMS etc
120    int TRIG_IN_BASE = 0x50;
121
122    int TRIG_IN_0 = TRIG_IN_BASE + 0; // input 0 trig, CAM input if not assigned to STEAM chuf
123    int TRIG_IN_1 = TRIG_IN_BASE + 1;
124    int TRIG_IN_2 = TRIG_IN_BASE + 2;
125    int TRIG_IN_3 = TRIG_IN_BASE + 3;
126
127    int TRIG_IN_4 = TRIG_IN_BASE + 4;
128    int TRIG_IN_5 = TRIG_IN_BASE + 5;
129    int TRIG_IN_6 = TRIG_IN_BASE + 6;
130    int TRIG_IN_7 = TRIG_IN_BASE + 7;
131
132    int TRIG_NOTCH_CHNG = TRIG_IN_7 + 1;   // when notch changes
133    int TRIG_TIME_16PPS = TRIG_IN_7 + 2;   // 16 per sec/64mS rate
134    int TRIG_FACTORY_CVRESET = TRIG_IN_7 + 3; // have CV8=8/9 request, USER definable CV values
135    int TRIG_OPSPROGWR_CV = TRIG_IN_7 + 4; // have OPSPROG action
136
137//--------------- SCATTER TRIGGER codes, ON/OFF phase per SCATTER task
138    int SCAT_TRIG_BASE = 0x60;
139
140    int TRIG_SCAT0 = SCAT_TRIG_BASE + 0; // scatter CHNL0, phase A sel NOT_TRIG_BIT
141    int TRIG_SCAT1 = SCAT_TRIG_BASE + 1;
142    int TRIG_SCAT2 = SCAT_TRIG_BASE + 2;
143    int TRIG_SCAT3 = SCAT_TRIG_BASE + 3;
144    int TRIG_SCAT4 = SCAT_TRIG_BASE + 4; // has visible WORK register
145    int TRIG_SCAT5 = SCAT_TRIG_BASE + 5; // has visible WORK register
146    int TRIG_SCAT6 = SCAT_TRIG_BASE + 6; // has visible WORK register
147    int TRIG_SCAT7 = SCAT_TRIG_BASE + 7; // has visible WORK register
148
149// ===============================
150//  encoded TRIGGER values related to SPEED_STATE code
151    int T_SS_BASE = 0x70; // 0x20 ;base TRIG code for this STATE logic
152    int TSPD = T_SS_BASE;  // base TRIG code for this STATE logic
153
154    int T_SPD_MUTE = TSPD + 0;
155    int T_SPD_TURNON = TSPD + 1;
156    int T_SPD_IDLE = TSPD + 2;
157    int T_SPD_ACCEL1 = TSPD + 3;
158
159    int T_SPD_ACC_CHNG = TSPD + 4;  // 1st GEN parallel/series chng
160    int T_SPD_ACCEL2 = TSPD + 5;
161    int T_SPD_IDLEXIT = TSPD + 6;  // leaving IDLE state
162    int T_SPD_RUN = TSPD + 7;
163
164    int T_SPD_DECEL1 = TSPD + 8;
165    int T_SPD_DEC_CHNG = TSPD + 9;
166    int T_SPD_DECEL2 = TSPD + 10;
167// T_SPD_DIR_CHNG =     TSPD+11   ;       (Commented in original Digitrax file)
168
169    int T_SPD_DEC_IDLE = TSPD + 11;
170    int T_SPD_TURNOFF = TSPD + 12;
171    int T_SPD_DEC_SP1 = TSPD + 13;
172    int T_SPD_DEC_SP2 = TSPD + 14;
173    int T_SPD_DIR_CHNG = TSPD + 15;
174
175    @SuppressFBWarnings(value = "MS_MUTABLE_ARRAY")  // known to be mutable, OK by convention
176    int[] triggerCodes = new int[]{
177        TRIG_NEVER, TRIG_MODE_CHNG, TRIG_MATH, TRIG_DISTANCE,
178        TRIG_SPD_INC, TRIG_SPD_DEC, TRIG_CAM, TRIG_NOT_TRIG,
179        TRIG_SF0, TRIG_SF1, TRIG_SF2, TRIG_SF3, TRIG_SF4,
180        TRIG_SF5, TRIG_SF6, TRIG_SF7, TRIG_SF8,
181        TRIG_SF9, TRIG_SF10, TRIG_SF11, TRIG_SF12,
182        TRIG_SF13, TRIG_SF14, TRIG_SF15, TRIG_SF16,
183        TRIG_SF17, TRIG_SF18, TRIG_SF19, TRIG_SF20,
184        TRIG_DIRNOW_CHNG, TRIG_MOVING, TRIG_SND_ACTV11,
185        TRIG_SF21, TRIG_SF22, TRIG_SF23, TRIG_SF24,
186        TRIG_SF25, TRIG_SF26, TRIG_SF27, TRIG_SF28,
187        TRIG_BSC0, TRIG_BSC1, TRIG_BSC2, TRIG_BSC3,
188        TRIG_BSC4, TRIG_BSC5, TRIG_BSC6, TRIG_BSC7,
189        TRIG_IN_0, TRIG_IN_1, TRIG_IN_2, TRIG_IN_3,
190        TRIG_IN_4, TRIG_IN_5, TRIG_IN_6, TRIG_IN_7,
191        TRIG_NOTCH_CHNG, TRIG_TIME_16PPS, TRIG_FACTORY_CVRESET, TRIG_OPSPROGWR_CV,
192        TRIG_SCAT0, TRIG_SCAT1, TRIG_SCAT2, TRIG_SCAT3,
193        TRIG_SCAT4, TRIG_SCAT5, TRIG_SCAT6, TRIG_SCAT7,
194        T_SPD_MUTE, T_SPD_TURNON, T_SPD_IDLE, T_SPD_ACCEL1,
195        T_SPD_ACC_CHNG, T_SPD_ACCEL2, T_SPD_IDLEXIT, T_SPD_RUN,
196        T_SPD_DECEL1, T_SPD_DEC_CHNG, T_SPD_DECEL2,
197        T_SPD_DEC_IDLE, T_SPD_TURNOFF, T_SPD_DEC_SP1, T_SPD_DEC_SP2, T_SPD_DIR_CHNG
198
199    };
200
201    String[] triggerNames = new String[]{
202        "TRIG_NEVER", "TRIG_MODE_CHNG", "TRIG_MATH", "TRIG_DISTANCE", // NOI18N
203        "TRIG_SPD_INC", "TRIG_SPD_DEC", "TRIG_CAM", "TRIG_NOT_TRIG", // NOI18N
204        "TRIG_SF0", "TRIG_SF1", "TRIG_SF2", "TRIG_SF3", "TRIG_SF4", // NOI18N
205        "TRIG_SF5", "TRIG_SF6", "TRIG_SF7", "TRIG_SF8", // NOI18N
206        "TRIG_SF9", "TRIG_SF10", "TRIG_SF11", "TRIG_SF12", // NOI18N
207        "TRIG_SF13", "TRIG_SF14", "TRIG_SF15", "TRIG_SF16", // NOI18N
208        "TRIG_SF17", "TRIG_SF18", "TRIG_SF19", "TRIG_SF20", // NOI18N
209        "TRIG_DIRNOW_CHNG", "TRIG_MOVING", "TRIG_SND_ACTV11", // NOI18N
210        "TRIG_SF21", "TRIG_SF22", "TRIG_SF23", "TRIG_SF24", // NOI18N
211        "TRIG_SF25", "TRIG_SF26", "TRIG_SF27", "TRIG_SF28", // NOI18N
212        "TRIG_BSC0", "TRIG_BSC1", "TRIG_BSC2", "TRIG_BSC3", // NOI18N
213        "TRIG_BSC4", "TRIG_BSC5", "TRIG_BSC6", "TRIG_BSC7", // NOI18N
214        "TRIG_IN_0", "TRIG_IN_1", "TRIG_IN_2", "TRIG_IN_3", // NOI18N
215        "TRIG_IN_4", "TRIG_IN_5", "TRIG_IN_6", "TRIG_IN_7", // NOI18N
216        "TRIG_NOTCH_CHNG", "TRIG_TIME_16PPS", "TRIG_FACTORY_CVRESET", "TRIG_OPSPROGWR_CV", // NOI18N
217        "TRIG_SCAT0", "TRIG_SCAT1", "TRIG_SCAT2", "TRIG_SCAT3", // NOI18N
218        "TRIG_SCAT4", "TRIG_SCAT5", "TRIG_SCAT6", "TRIG_SCAT7", // NOI18N
219        "T_SPD_MUTE", "T_SPD_TURNON", "T_SPD_IDLE", "T_SPD_ACCEL1", // NOI18N
220        "T_SPD_ACC_CHNG", "T_SPD_ACCEL2", "T_SPD_IDLEXIT", "T_SPD_RUN", // NOI18N
221        "T_SPD_DECEL1", "T_SPD_DEC_CHNG", "T_SPD_DECEL2", // NOI18N
222        "T_SPD_DEC_IDLE", "T_SPD_TURNOFF", // NOI18N
223        "T_SPD_DEC_SP1", "T_SPD_DEC_SP2", "T_SPD_DIR_CHNG" // NOI18N
224
225    };
226
227    /**
228     * Human-readable form of trigger constants for use in SdfEditor
229     */
230    @SuppressFBWarnings(value = "MS_MUTABLE_ARRAY")  // known to be mutable, OK by convention
231    String[] editorTriggerNames = new String[]{
232        "TRIG_NEVER", "TRIG_MODE_CHNG", "TRIG_MATH", "TRIG_DISTANCE", // NOI18N
233        "TRIG_SPD_INC", "TRIG_SPD_DEC", "TRIG_CAM", "TRIG_NOT_TRIG", // NOI18N
234        "Function 0 On", "Function 1 On", "Function 2 On", "Function 3 On", // NOI18N
235        "Function 4 On", "Function 5 On", "Function 6 On", "Function 7 On", // NOI18N
236        "Function 8 On", "Function 9 On", "Function 10 On", "Function 11 On", // NOI18N
237        "Function 12 On", "Function 13 On", "Function 14 On", "Function 15 On", // NOI18N
238        "Function 16 On", "Function 17 On", "Function 18 On", "Function 19 On", // NOI18N
239        "Function 20 On", // NOI18N
240        "TRIG_DIRNOW_CHNG", "TRIG_MOVING", "TRIG_SND_ACTV11", // NOI18N
241        "Function 21 On", "Function 22 On", "Function 23 On", "Function 24 On", // NOI18N
242        "Function 25 On", "Function 26 On", "Function 27 On", "Function 28 On", // NOI18N
243        "TRIG_BSC0", "TRIG_BSC1", "TRIG_BSC2", "TRIG_BSC3", // NOI18N
244        "TRIG_BSC4", "TRIG_BSC5", "TRIG_BSC6", "TRIG_BSC7", // NOI18N
245        "TRIG_IN_0", "TRIG_IN_1", "TRIG_IN_2", "TRIG_IN_3", // NOI18N
246        "TRIG_IN_4", "TRIG_IN_5", "TRIG_IN_6", "TRIG_IN_7", // NOI18N
247        "TRIG_NOTCH_CHNG", "TRIG_TIME_16PPS", "TRIG_FACTORY_CVRESET", "TRIG_OPSPROGWR_CV", // NOI18N
248        "TRIG_SCAT0", "TRIG_SCAT1", "TRIG_SCAT2", "TRIG_SCAT3", // NOI18N
249        "TRIG_SCAT4", "TRIG_SCAT5", "TRIG_SCAT6", "TRIG_SCAT7", // NOI18N
250        "T_SPD_MUTE", "T_SPD_TURNON", "T_SPD_IDLE", "T_SPD_ACCEL1", // NOI18N
251        "T_SPD_ACC_CHNG", "T_SPD_ACCEL2", "T_SPD_IDLEXIT", "T_SPD_RUN", // NOI18N
252        "T_SPD_DECEL1", "T_SPD_DEC_CHNG", "T_SPD_DECEL2", // NOI18N
253        "T_SPD_DEC_IDLE", "T_SPD_TURNOFF", // NOI18N
254        "T_SPD_DEC_SP1", "T_SPD_DEC_SP2", "T_SPD_DIR_CHNG" // NOI18N
255
256    };
257
258///============================BREAK/LOOP logic during a .WAV playback==================
259// WAVBRK modify flags
260    int loop_STD = 0x00; // default is NO loop logic modification
261    int loop_GLOBAL = 0x10; // assert to loop and UP 1 level...
262    int loop_INVERT = 0x08; // invert/FALSE POL of loop to generate WAV BREAK condition
263
264    int[] wavebrkCodes = new int[]{
265        loop_GLOBAL, loop_INVERT
266    };
267    int[] wavebrkMasks = wavebrkCodes;
268
269    String[] wavebrkNames = new String[]{
270        "loop_GLOBAL", "loop_INVERT", "loop_STD" // NOI18N
271    };
272
273    int loop_GLOBAL_BIT = 4; // bit # assert to loop and UP 1 level...
274    int loop_INVERT_BIT = 3; // bit # invert (NOT/FALSE) Polarity of loop condition/evaluation
275
276// --------- 32 loop event codes
277    int loop_MASK = 0x1F; // mask for VALID BRK rng-5bits
278
279// disable loop- just run/playback .WAV file from SOUND flash or other source
280    int no_loop = 0; // RUN to completeion of WAV segmenT
281
282//--------------
283// codes that imply LOOPING of current HANDLE WAV seg till loop WAV BREAK CONDITON met
284    int loop_till_NEVER = TRIG_NEVER; // same as "no_loop", RUN to completion of WAV segmenT
285
286    int loop_till_cam = TRIG_CAM; // loop on CAM event, either H/W input or AUTO-chuff,
287    int loop_till_init_TRIG = TRIG_NOT_TRIG; // loop until INITIATE TRIGGER condition NOT met
288
289// FUNCTION change events
290    int loop_till_F1 = TRIG_SF1; // F1 change event
291    int loop_till_F2 = TRIG_SF2;
292    int loop_till_F3 = TRIG_SF3;
293    int loop_till_F4 = TRIG_SF4;
294
295    int loop_till_F0 = TRIG_SF0; // headlight
296    int loop_till_DIRNOW_CHNG = TRIG_DIRNOW_CHNG; // have DIR_NOW changed
297    int loop_till_MOVING = TRIG_MOVING; // SPD = Non-Zero
298    int loop_till_SND_ACTV11 = TRIG_SND_ACTV11; // DECODER is addressed within CV11 time
299
300    int loop_till_F5 = TRIG_SF5;
301    int loop_till_F6 = TRIG_SF6;
302    int loop_till_F7 = TRIG_SF7;
303    int loop_till_F8 = TRIG_SF8;
304
305    int loop_till_F9 = TRIG_SF9;
306    int loop_till_F10 = TRIG_SF10;
307    int loop_till_F11 = TRIG_SF11;
308    int loop_till_F12 = TRIG_SF12;
309
310// ONLY scatter CHNLS 4-7 [also WORK visibles] can be used for TIMED loop break conditions
311    int loop_till_SCAT4 = 0x1C; // scatter CHNL4, phase A/B selected by loop_INVERT_BIT
312    int loop_till_SCAT5 = 0x1D;
313    int loop_till_SCAT6 = 0x1E;
314    int loop_till_SCAT7 = 0x1F;
315
316    int[] loopCodes = new int[]{
317        loop_till_cam, loop_till_init_TRIG, // loop_till_NEVER is same as no_loop
318        loop_till_DIRNOW_CHNG, loop_till_MOVING, loop_till_SND_ACTV11,
319        loop_till_F0,
320        loop_till_F1,
321        loop_till_F2, loop_till_F3, loop_till_F4, loop_till_F5,
322        loop_till_F6, loop_till_F7, loop_till_F8, loop_till_F9,
323        loop_till_F10, loop_till_F11, loop_till_F12,
324        loop_till_SCAT4, loop_till_SCAT5, loop_till_SCAT6, loop_till_SCAT7
325    };
326    int[] loopMasks = loopCodes;
327
328    @SuppressFBWarnings(value = "MS_MUTABLE_ARRAY")  // known to be mutable, OK by convention
329    String[] loopNames = new String[]{
330        "loop_till_cam", "loop_till_init_TRIG", // NOI18N
331        "loop_till_DIRNOW_CHNG", "loop_till_MOVING", "loop_till_SND_ACTV11", // NOI18N
332        "loop_till_F0", // NOI18N
333        "loop_till_F1", // NOI18N
334        "loop_till_F2", "loop_till_F3", "loop_till_F4", "loop_till_F5", // NOI18N
335        "loop_till_F6", "loop_till_F7", "loop_till_F8", "loop_till_F9", // NOI18N
336        "loop_till_F10", "loop_till_F11", "loop_till_F12", // NOI18N
337        "loop_till_SCAT4", "loop_till_SCAT5", "loop_till_SCAT6", "loop_till_SCAT7", // NOI18N
338        "no_loop" // NOI18N
339    };
340
341//----------------
342    int DELAY_GLOBAL = 0x01;
343    int DELAY_CV = 0x80; // delay fron SND_CV range
344    int DELAY_THIS = 0x00; // immed data
345
346//----------
347// for TEST trigger OPC
348    int TRIG_TRUE = 0x01;
349    int TRIG_FALSE = 0x00;
350    int ABOVE = 0x02; // this bit forces eval above on SPD state trigs
351
352    int[] trigLogicCodes = new int[]{
353        TRIG_TRUE
354    };
355    int[] trigLogicMasks = loopCodes;
356
357    String[] trigLogicNames = new String[]{
358        "TRIG_TRUE", "TRIG_FALSE" // NOI18N
359    };
360
361    int SK_SENS_BIT = 0;
362    int ABOVE_BIT = 1;
363
364//=====================================================================
365// load MODIFY COMMAND arg/VALUES- allows USER maximal configurability/customization in SDF files
366// 4byte CMD  1110-mmmm, ARG1,ARG2,ARG3
367//---------------------
368// modifier control REG command types
369// mmmm target embedded in LOAD MODIFY CMD to direct what following 3 ARG bytes will be loaded TO
370    int MTYPE_TIME = 0; // MODIFY timer
371    int MTYPE_GAIN = 1; // setup a GAIN modify task for current SOUND chain
372    int MTYPE_PITCH = 2; // setup a PITCH modify task for current SOUND chain
373    int MTYPE_BLEND = 3; // setup BLEND logic task
374
375// undefined NOW
376    int MTYPE_SCATTER = 4; // preset a SCATTER channel/task
377    int MTYPE_SNDCV = 5; // modify under MASK SNDCV,ARG1=SNDCV#,ARG2=DATA,ARG3=1bit=chng mask
378    int MTYPE_WORK_IMMED = 6; // modify WORK reg immed data
379    int MTYPE_WORK_INDIRECT = 7; // modify WORK reg indirect from SCV [selectable sound CV] or other WORK reg
380
381    int[] modControlCodes = new int[]{
382        MTYPE_TIME, MTYPE_GAIN, MTYPE_PITCH, MTYPE_BLEND,
383        MTYPE_SCATTER, MTYPE_SNDCV, MTYPE_WORK_IMMED, MTYPE_WORK_INDIRECT
384    };
385    String[] modControlNames = new String[]{
386        "MTYPE_TIME", "MTYPE_GAIN", "MTYPE_PITCH", "MTYPE_BLEND", // NOI18N
387        "MTYPE_SCATTER", "MTYPE_SNDCV", "MTYPE_WORK_IMMED", "MTYPE_WORK_INDIRECT" // NOI18N
388    };
389
390// ---------------
391// values for MATH functions on WORK regs
392    int FMATH_LODE = 0x00; // load DATA,,MATH_FLAG SET shows whole WORK is ZERO- DEFAULT task
393    int FMATH_AND = 0x20; // use to CLR bit(s),MATH_FLAG SET shows whole WORK is ZERO
394    int FMATH_OR = 0x40; // use to SET  bit(S), MATH FLAG SET shows whole WORK is 1's
395    int FMATH_XOR = 0x60; // use to flip bit(s), MATH FLAG SET if all flipped bits are now 0
396
397//;FMATH_ADD EQU 0x80 ;add signed value  (commented out in original Digitrax file)
398    int FMATH_INTEGRATE = 0xA0; // add signed value to WORK,MATH_FLAG SET if over/underflo,or clamp LIMIT
399    int FMATH_TEST_ZERO = 0xC0; // see if WORK under MASK is ZERO, if ZERO set MATH bit
400
401// -----1111----------------
402// FIRST modify ARG- COMMAND
403    int GCMD_NONE = 0x00; // NO gain MODIFY task RUN
404    int GCMD_MASK = 0xE0; // 3 ms bits 1st CMD decode
405
406    static final int[] arg1ModCodes = new int[]{
407        FMATH_LODE, FMATH_AND, FMATH_OR, FMATH_XOR, FMATH_INTEGRATE, FMATH_TEST_ZERO, GCMD_MASK
408    };
409    static final String[] arg1ModNames = new String[]{
410        "FMATH_LODE", "FMATH_AND", "FMATH_OR", "FMATH_XOR", "FMATH_INTEGRATE", "FMATH_TEST_ZERO", "GCMD_MASK" // NOI18N
411    };
412
413// 32 analog ARGS 3/21
414// TYPE 8 GAIN
415    int IMMED_GAIN_MODIFY = 0x80; // set new GAIN to [CV# 6 bit offset in ARG1] *CV58 , CV120 base
416    int ANALOG_GAIN_MODIFY = 0xA0; // modify INIT GAIN by analog chnl in 5 ls bits
417    // AUX1=  AUX2=dither coding
418
419    int FCMD_NONE = 0x00; // NO PITCH MODIFY task RUN
420    int FCMD_MASK = 0xE0; // 3 ms bits 1st CMD decode
421
422// type 8 PITCH
423    int CV_PITCH_MODIFY = 0x80; // set new PITCH to [CV# 6 bit offset in ARG1] , CV120 base
424    int ANALOG_PITCH_MODIFY = 0xA0; // modify INIT PITCH by analog chnl in 5 ls bits
425    // AUX1=  AUX2=dither coding
426
427//==================
428// 32 predefined user visible WORK/STATE regs, use these defined values
429// first 16 WORK visible reg address codes.
430    int WORK_SPEED = 0x00; // SOUND target PWM/SPD
431    int WORK_NOTCH = 0x01; // CHNL# for NOTCH Modified spd info, MODUL0 8
432    int WORK_SERVO = 0x02;
433    int WORK_MVOLTS = 0x03;
434
435    int WORK_USER_LINES = 0x05;
436    int WORK_TIMEBASE = 0x06; // 64mS cntr, ROLL=16 SECS
437    int WORK_STATUS_BITS = 0x07; // PRIMARY decoder STATUS bits
438
439    int WORK_GLBL_GAIN = 0x08; // FULL gain authority
440    int WORK_GAIN_TRIM = 0x09; // signed (bit7) gain trim +/- 25%
441    int WORK_PITCH_TRIM = 0x0A; // signed (bit7) pitch trim +/- 25%
442    int WORK_SPEED_DELTA = 0x0B; // unsigned SPEED change
443
444// SECOND 16 WORK  visible reg address codes
445    int WORK_SCATTER4 = 0x10; // VISIBLE working SCATTER reg
446    int WORK_SCATTER5 = 0x11; // VISIBLE working SCATTER reg
447    int WORK_SCATTER6 = 0x12; // VISIBLE working SCATTER reg
448    int WORK_SCATTER7 = 0x13; // VISIBLE working SCATTER reg
449
450    int WORK_ACHNL_7F = 0x14; // DT400 VARIABLE whistle CHNL
451    int WORK_ACHNL_7E = 0x15;
452    int WORK_SKAT_FAST = 0x16;
453    int WORK_SKAT_SLOW = 0x17;
454
455    int WORK_DISTANCE = 0x18;
456    int WORK_PEAK_SPD = 0x19;
457    int WORK_USER_0 = 0x1A; // user  REG
458    int WORK_USER_1 = 0x1B; // user  REG
459
460    int WORK_USER_2 = 0x1C; // user  REG
461    int WORK_USER_3 = 0x1D; // user  REG
462    int WORK_USER_4 = 0x1E; // user  REG
463    int WORK_USER_5 = 0x1F; // user  REG
464
465    int[] workRegCodes = new int[]{
466        WORK_SPEED, WORK_NOTCH, WORK_SERVO, WORK_MVOLTS,
467        WORK_USER_LINES, WORK_TIMEBASE, WORK_STATUS_BITS,
468        WORK_GLBL_GAIN, WORK_GAIN_TRIM, WORK_PITCH_TRIM, WORK_SPEED_DELTA,
469        WORK_SCATTER4, WORK_SCATTER5, WORK_SCATTER6, WORK_SCATTER7,
470        WORK_ACHNL_7F, WORK_ACHNL_7E, WORK_SKAT_FAST, WORK_SKAT_SLOW,
471        WORK_DISTANCE, WORK_PEAK_SPD, WORK_USER_0, WORK_USER_1,
472        WORK_USER_2, WORK_USER_3, WORK_USER_4, WORK_USER_5
473    };
474
475    String[] workRegNames = new String[]{
476        "WORK_SPEED", "WORK_NOTCH", "WORK_SERVO", "WORK_MVOLTS", // NOI18N
477        "WORK_USER_LINES", "WORK_TIMEBASE", "WORK_STATUS_BITS", // NOI18N
478        "WORK_GLBL_GAIN", "WORK_GAIN_TRIM", "WORK_PITCH_TRIM", "WORK_SPEED_DELTA", // NOI18N
479        "WORK_SCATTER4", "WORK_SCATTER5", "WORK_SCATTER6", "WORK_SCATTER7", // NOI18N
480        "WORK_ACHNL_7F", "WORK_ACHNL_7E", "WORK_SKAT_FAST", "WORK_SKAT_SLOW", // NOI18N
481        "WORK_DISTANCE", "WORK_PEAK_SPD", "WORK_USER_0", "WORK_USER_1", // NOI18N
482        "WORK_USER_2", "WORK_USER_3", "WORK_USER_4", "WORK_USER_5" // NOI18N
483    };
484
485// ---------------------
486// WORK_STATUS_BITS register bit definitions. data is VOLATILE
487    int WKSB_ANALOG_BIT = 0; // 1=is in ANALOG mode [STATUS mirror]
488    int WKSB_ANALOG_MASK = 0x01; // bit involved
489
490    int WKSB_DIRNOW_BIT = 1; // 1= rev direction ?[STATUS mirror]
491    int WKSB_DIRNOW_MASK = 0x02; // bit involved
492
493    int WKSB_RUN_BIT = 2; // 0= stop motor PWM, non-primemover sounds RUN
494    int WKSB_RUN_MASK = 0x04; // bit involved
495
496    int WKSB_ACEL_BIT = 3; // 1= is ACCEL state
497    int WKSB_ACEL_MASK = 0x08; // bit involved
498
499    int WKSB_SPDDELTA_BIT = 4; // 1= change SPD by unsigned SPD_DELTA work REG only
500    int WKSB_SPDDELTA_MASK = 0x10; // bit involved
501
502    int WKSB_MATH_BIT = 7; // result from last MODIFY math action (can test with
503    int WKSB_MATH_MASK = 0x80; // bit involved
504
505    int[] workStatusBitCodes = new int[]{
506        WKSB_ANALOG_MASK, WKSB_DIRNOW_MASK, WKSB_RUN_MASK, WKSB_ACEL_MASK, WKSB_SPDDELTA_MASK, WKSB_MATH_MASK
507    };
508    String[] workStatusBitNames = new String[]{
509        "WKSB_ANALOG_MASK", "WKSB_DIRNOW_MASK", "WKSB_RUN_MASK", "WKSB_ACEL_MASK", "WKSB_SPDDELTA_MASK", "WKSB_MATH_MASK" // NOI18N
510    };
511
512//========================
513// SCATTER commands as arg bytes in MTYPE_SCATTER
514// is MODIFY SCTR command  -  1110-0100, cccc-XAAA, aaaa-aaaa, bbbb-bbbb, AAA is 1 of 8 scat tasks/chnls
515// is SCTR_PERIOD command  -  1110-0100, 0001-PAAA, Srrr-rrrr, IIIw-wwww,
516// AAA is 1 of 8 scat tasks/chnls,  P=WORK scatter POLARITY,
517// S=1 is SOUNDCV src  [0x80=CV141 etc], S=0 rrr-rrrr is RATE in approx 1 sec counts, rate=0 is CNTR hold...
518// III=scatter intensity- 000=no SCATTER, w-wwww is a WORK reg# as SCATTER vary data src
519// cccc is 16 SCATTER command modes, dddd and eeee are ARG Regs for run modes
520    int SCAT_CMD_PERIOD = 0x20; // command for PERIODIC event, SCALABLE scatter speedup on WORK reg INC
521    int SCAT_CMD_PERIOD_REV = 0x28; // command for PERIODIC event, with SCALABLE scatter slowdn on WORK reg INC
522
523    int SCAT_CMD_SAWTOOTH = 0x30;
524    int SCAT_CMD_SAWTOOTH_REV = 0x38;
525
526    int[] scatCommandCodes = new int[]{
527        SCAT_CMD_PERIOD, SCAT_CMD_PERIOD_REV, SCAT_CMD_SAWTOOTH, SCAT_CMD_SAWTOOTH_REV};
528    String[] scatCommandNames = new String[]{
529        "SCAT_CMD_PERIOD", "SCAT_CMD_PERIOD_REV", "SCAT_CMD_SAWTOOTH", "SCAT_CMD_SAWTOOTH_REV"}; // NOI18N
530
531    int SCAT_PERIOD_POLARITY_BIT = 3; // 1= reverse WORK influence
532    int SKATTER_INCREMENT = 8; // phase INCREMENT
533
534    int SCAT_CHNL0 = 0x00; // SCATTER task0
535    int SCAT_CHNL1 = 0x01; // SCATTER task1
536    int SCAT_CHNL2 = 0x02; // SCATTER task2
537    int SCAT_CHNL3 = 0x03; // SCATTER task3
538    int SCAT_CHNL4 = 0x04; // SCATTER task4- visible WORK reg
539    int SCAT_CHNL5 = 0x05; // SCATTER task5- visible WORK reg
540    int SCAT_CHNL6 = 0x06; // SCATTER task6- visible WORK reg
541    int SCAT_CHNL7 = 0x07; // SCATTER task7- visible WORK reg
542
543    int[] scatChannelCodes = new int[]{
544        SCAT_CHNL0, SCAT_CHNL1, SCAT_CHNL2, SCAT_CHNL3, SCAT_CHNL4, SCAT_CHNL5, SCAT_CHNL6, SCAT_CHNL7};
545    String[] scatChannelNames = new String[]{
546        "SCAT_CHNL0", "SCAT_CHNL1", "SCAT_CHNL2", "SCAT_CHNL3", "SCAT_CHNL4", "SCAT_CHNL5", "SCAT_CHNL6", "SCAT_CHNL7"}; // NOI18N
547
548    int SINTEN_IMMED = 0xE0; // use WORK# as immediate data
549    int SINTEN_HIGH = 0xC0;
550    int SINTEN_MID = 0x60; // mid scatter intensity
551    int SINTEN_LOW = 0x40;
552    int SINTEN_MIN = 0x20;
553    int SINTEN_OFF = 0x00;
554
555    int[] sintenCodes = new int[]{
556        SINTEN_IMMED, SINTEN_HIGH, SINTEN_MID, SINTEN_LOW, SINTEN_MIN, SINTEN_OFF};
557    String[] sintenNames = new String[]{
558        "SINTEN_IMMED", "SINTEN_HIGH", "SINTEN_MID", "SINTEN_LOW", "SINTEN_MIN", "SINTEN_OFF"}; // NOI18N
559
560// ======================
561    int DEFAULT_GLBL_GAIN = 0xC0;
562    int MERGE_ALL_MASK = 0; // any 0 bit is involved
563
564// ----2222--------------
565// 2ND modify ARG
566    int SNDCV_SRC = 0x80; // this bit set chngs from IMMED to SND_CV to control EFFECT span
567    int SNDCV_SRC_BIT = 7; // 1=ls 7 bits SCV#, 0=ls 7 bits immed arg data
568
569// ls 7 bit ARGS
570    int MAXG_NONE = 0x00; // value of 0 means no scaling, SRC is 100% GAIN
571    int MAXP_NONE = 0x00; // value of 0 means no scaling, SRC is 100% PITCH
572
573// ----3333--------------
574// 3RD modify ARG
575//;MPUSH  EQU 0x80  ;this bit forces LEVEL OVERIDE
576    int DITHER = 0x80; // value to change to DITHER mode
577    int SUMG = 0x40;
578
579    int MIN_DITH = 0x00;
580    int LOW_DITH = 0x20;
581    int MID_DITH = 0x40;
582    int MAX_DITH = 0x60;
583
584// ;MPUSH_BIT EQU 7  (commendted out in the original Digitrax file)
585    int DITHER_BIT = 7;
586    int SUM_BIT = 6; // 1=add ARG1/2 variation,0=multiply
587    int MG1_BIT = 5; // these code meaning of LO nibble
588    int MG0_BIT = 4;
589
590// for CMDS 8/9 ls nibble ARG3 is scaling factor to set CV/IMMED data control SPAN
591    int SCALE_F = 0x0F;
592    int SCALE_C = 0x0C;
593    int SCALE_8 = 0x08;
594    int SCALE_6 = 0x06;
595    int SCALE_5 = 0x05;
596    int SCALE_4 = 0x04;
597    int SCALE_2 = 0x02;
598
599    int[] arg3ModCodes = new int[]{
600        DITHER,
601        LOW_DITH, MID_DITH, MAX_DITH, // MIN_DITH is zero, a no-op
602        SCALE_F, SCALE_C, SCALE_8, SCALE_6, SCALE_5, SCALE_4, SCALE_2
603    };
604    int[] arg3ModMasks = new int[]{
605        DITHER,
606        0x60, 0x60, 0x60,
607        0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F
608    };
609    String[] arg3ModNames = new String[]{
610        "DITHER", // NOI18N
611        "LOW_DITH", "MID_DITH", "MAX_DITH", // NOI18N
612        "SCALE_F", "SCALE_C", "SCALE_8", "SCALE_6", "SCALE_5", "SCALE_4", "SCALE_2" // NOI18N
613    };
614
615// DITHER ????
616    int DITHERG_WHISTLE = 0x00;
617    int DITHERP_WHISTLE = 0x00;
618
619    int DITHERG_DIESEL = 0x00;
620    int DITHERP_DIESEL = 0x00;
621
622    int DITHERG_NONE = 0x00;
623    int DITHERP_NONE = 0x00;
624
625// THE FOLLOWING ARE PRESENT, BUT WITH CURRENT VALUES ARE NOT PARTICULARLY USEFUL
626    int[] ditherGCodes = new int[]{
627        DITHERG_DIESEL, DITHERG_WHISTLE, DITHERG_NONE
628    };
629    String[] ditherGNames = new String[]{
630        "DITHERG_DIESEL", "DITHERG_WHISTLE", "DITHERG_NONE" // NOI18N
631    };
632    int[] ditherPCodes = new int[]{
633        DITHERP_DIESEL, DITHERP_WHISTLE, DITHERP_NONE
634    };
635    String[] ditherPNames = new String[]{
636        "DITHERP_DIESEL", "DITHERP_WHISTLE", "DITHERP_NONE" // NOI18N
637    };
638
639// BLEND logic commnds
640// 1110-BLEND, BLEND_CMDS, BLEND_GAIN_ARG, BLEND_FASE_ARG
641// BLEND cmds bit encoding
642    int BLEND_TGTMASK = 0xC0; // 2 ms bits control Blend target
643    int BLEND_FASEMASK = 0x38; // 3  bits FASE_BLEND type, 000=inactive
644    int BLEND_GAINMASK = 0x07; // 3 ls bits GAIN_BLEND type, 000=inactive
645
646// MODE0 with ARG=0 is INACTIVE BLEND
647    int BLEND_CURRENT_CHNL = 0x00 & BLEND_TGTMASK;
648    int BLEND_ALL = 0x40 & BLEND_TGTMASK;
649
650    int BLEND_GAIN0 = 0x00 & BLEND_GAINMASK; // STD logic 0 blend
651    int BLEND_GAIN1 = 0x01 & BLEND_GAINMASK; // alt logic 1 blend
652
653    int BLEND_FASE0 = 0x00 & BLEND_FASEMASK; // STD logic 0 blend
654    int BLEND_FASE1 = 0x08 & BLEND_FASEMASK; // alt logic 1 blend
655
656    int[] blendArg1Codes = new int[]{
657        BLEND_CURRENT_CHNL, BLEND_ALL,
658        BLEND_GAIN0, BLEND_GAIN1,
659        BLEND_FASE0, BLEND_FASE1
660    };
661    int[] blendArg1Masks = new int[]{
662        BLEND_TGTMASK, BLEND_TGTMASK,
663        BLEND_GAINMASK, BLEND_GAINMASK,
664        BLEND_FASEMASK, BLEND_FASEMASK
665    };
666    String[] blendArg1Names = new String[]{
667        "BLEND_CURRENT_CHNL", "BLEND_ALL", // NOI18N
668        "BLEND_GAIN0", "BLEND_GAIN1", // NOI18N
669        "BLEND_FASE0", "BLEND_FASE1" // NOI18N
670    };
671
672    int BLENDG_DSL_ACCEL0 = 0x04; // GAIN rate for loaded DIESEL
673    int BLENDF_DSL_ACCEL0 = 0x02; // FASE rate for loaded DIESEL
674
675    int BLENDG_DSL_ACCEL1 = 0x06; // GAIN rate for loaded DIESEL
676    int BLENDF_DSL_ACCEL1 = 0x05; // GAIN rate for unloading DIESEL
677
678    int BLENDG_DSL_DECEL0 = 0x09; // GAIN rate for unloading DIESEL
679    int BLENDF_DSL_DECEL0 = 0x07; // FASE rate for unloading DIESEL
680
681    int[] blendArg2Codes = new int[]{
682        BLENDG_DSL_ACCEL0, BLENDG_DSL_ACCEL1, BLENDG_DSL_ACCEL1};
683    String[] blendArg2Names = new String[]{
684        "BLENDG_DSL_ACCEL0", "BLENDG_DSL_ACCEL1", "BLENDG_DSL_ACCEL1"}; // NOI18N
685    int[] blendArg3Codes = new int[]{
686        BLENDF_DSL_ACCEL0, BLENDF_DSL_ACCEL1, BLENDF_DSL_ACCEL1};
687    String[] blendArg3Names = new String[]{
688        "BLENDF_DSL_ACCEL0", "BLENDF_DSL_ACCEL1", "BLENDF_DSL_ACCEL1"}; // NOI18N
689
690// COMPARE CMD control bits
691    int TARGET_DATA = 0x00; // second COMPARE ARG is WORK reg or SCV
692    int IMMED_DATA = 0x04; // second COMPARE ARG is IMMEDIATE 8 bit DATA
693
694    int SKIP_SAME = 0x00;
695    int SKIP_RSVD = 0x01; //reserved CONDITION code
696    int SKIP_LESS = 0x02;
697    int SKIP_GRTR = 0x03;
698
699    int COMP_ALL = 0x00; // 1 bits= do not include
700    int COMP_7LSB = 0X80;
701
702// define fixed CV locations
703    int SNDCV_CONFIGA = 0x80; // CV129= config byte
704    int SNDCV_CONFIGB = 0x81; //CV130= config byte
705    int SCV_DCONFIG = 0x82; // CV131= diesel config
706    int SCV_NOTCH = 0x83; // CV132= typ DIESEL NOTCH rate byte
707    int SNDCV_STEAM = 0x84; // CV133= typ steam CAM config byte, x80=EXT or 1-127=DRIVER dia in inches
708    int SCV_STGEAR = 0x85; // CV134= steam gear ratio trim
709    int SCV_MUTE_VOL = 0x86; // CV135= vol level when MUTE action is triggered, e.g. F8=ON
710    int SCV_MAIN_PITCH = 0x87; // CV136
711    int SCV_137 = 0x88;
712    int SCV_138 = 0x89; // SCV138=
713    int SCV_DISTANCE_RATE = 0x8A; // SCV139= mask for controlling DISTANCE rate event/trigger
714    int SCV_FREEFORM = 0x8B; // SCV_140, here the SCV's are SDF defined
715
716    static final int[] fixedCVCodes = new int[]{
717        SNDCV_CONFIGA, SNDCV_CONFIGB, SCV_DCONFIG, SCV_NOTCH,
718        SNDCV_STEAM, SCV_STGEAR, SCV_MUTE_VOL, SCV_MAIN_PITCH,
719        SCV_137, SCV_138, SCV_DISTANCE_RATE, SCV_FREEFORM
720    };
721    static final String[] fixedCVNames = new String[]{
722        "SNDCV_CONFIGA", "SNDCV_CONFIGB", "SCV_DCONFIG", "SCV_NOTCH", // NOI18N
723        "SNDCV_STEAM", "SCV_STGEAR", "SCV_MUTE_VOL", "SCV_MAIN_PITCH", // NOI18N
724        "SCV_137", "SCV_138", "SCV_DISTANCE_RATE", "SCV_FREEFORM" // NOI18N
725    };
726
727// CV133, SNDCV_STEAM /DRIVER size bit7=1 means EXTERNAL INPUT_0 generates a special CAM code as well
728    static int STEAM_CAM_BIT = 7;
729
730// =======end of FIXED DATA assignments==============
731// =================
732// USER choices
733// SCAT_AIRCOMP_RATE EQU 25  ;AIR compressor about 2 mins, above 128 is SNDCV foR RATE ARG
734// SCAT_DRIER_RATE  EQU 10  ;about 10 secs for DRIER
735// SCAT_WATERPUMP_RATE EQU 100
736// SCAT_COAL_RATE  EQU 120
737// specific DFLT values to scale MAX ranges
738    int MAXG_WHISTLE = 0x6A;
739    int MAXP_WHISTLE = 0x07;
740    int MAXG_DIESEL = 0x1C;
741    int MAXP_DIESEL = 0x3E;
742    int MAXG_STEAM = 0x1C;
743    int MAXP_STEAM = 0x7E; // was 3E- make more explosive!
744
745// VALUES ARE SUCH THAT WE CAN'T TELL STEAM FROM DIESEL WHEN DISASSMEMLING
746    int[] maxPCodes = new int[]{
747        MAXP_WHISTLE, MAXP_DIESEL, MAXP_STEAM
748    };
749    String[] maxPNames = new String[]{
750        "MAXP_WHISTLE", "MAXP_DIESEL", "MAXP_STEAM" // NOI18N
751    };
752
753    int[] maxGCodes = new int[]{
754        MAXG_WHISTLE, MAXG_DIESEL, MAXG_STEAM
755    };
756    String[] maxGNames = new String[]{
757        "MAXG_WHISTLE", "MAXG_DIESEL", "MAXG_STEAM" // NOI18N
758    };
759
760}