001package jmri.jmrix.nce;
002
003/**
004 * Contains the map for the command station and memory parts
005 * The default values are for the older serial command station.
006 *
007 * @author Bob Jacobsen Copyright (C) 2001
008 * @author Ken Cameron Copyright (C) 2013, 2023
009 * 
010 */
011public class NceCmdStationMemory {
012    
013    /*
014     * give addr for cab data base
015     */
016    public int getCabAddr() {
017        return 0x8800;
018    }
019    
020    /*
021     * give cab data size
022     */
023    public int getCabSize() {
024        return 0x100;
025    }
026    /*
027     * give min cab id
028     */
029    public int getCabMin() {
030        return 1;    // min number for cab memory slot
031    }
032    
033    /*
034     * give max cab id
035     */
036    public int getCabMax() {
037        return 63;    // max number for cab memory slot
038    }
039    
040    /*
041     * give addr computer cab
042     */
043    public int getCompCabAddr() {
044        return 0xED00; // start of computer cab context page, PowerPro/CS2
045    }
046    
047    /*
048     * give addr consist head
049     */
050    public int getConsistHeadAddr() {
051        return 0xF500;  // start of NCE CS Consist Head memory
052    }
053    
054    /*
055     * give size of consist head table
056     */
057    public int getConsistHeadSize() {
058        return 0x0100;  // size of NCE CS Consist Head memory
059    }
060
061    /*
062     * give addr of consist data
063     */
064    public int getConsistAddr() {
065        return getConsistHeadAddr();    // mostly for the page needed by the USB
066    }
067    
068    /*
069     * give addr consist tail
070     */
071    public int getConsistTailAddr() {
072        return 0xF600;  // start of NCE CS Consist Tail memory
073    }
074    
075    /*
076     * give size of consist tail table
077     */
078    public int getConsistTailSize() {
079        return 0x0100;  // size of NCE CS Consist Tail memory
080    }
081    
082    /*
083     * give addr consist middle
084     */
085    public int getConsistMidAddr() {
086        return 0xF700;  // start of NCE CS Consist Middle memory
087    }
088
089    /*
090     * give addr consist middle
091     */
092    public int getConsistMidEntries() {
093        return 4;       // how many middle Consist entries/consist
094    }
095    
096    /*
097     * give size of consist mid table
098     */
099    public int getConsistMidSize() {
100        return 0x0400;  // size of NCE CS Consist Middle memory
101    }
102    
103    /*
104     * give minimum consist number
105     */
106    public int getConsistMin() {
107        return 0;
108    }
109    
110    /*
111     * give maximum consist number
112     */
113    public int getConsistMax() {
114        return 127;
115    }
116
117    /*
118     * give consist num lines
119     */
120    public int getConsistNumLines() {
121        return 96;   // number of lines in the file
122    }
123
124    /*
125     * give addr macro table
126     */
127    public int getMacroAddr() {
128        return 0xC800; // start of NCE CS Macro memory 
129    }
130    
131    /*
132     * give number of macro limit
133     */
134    public int getMacroLimit() {
135        return 256; // there are 256 possible macros
136    }
137    
138    /*
139     * give size of macro entry
140     */
141    public int getMacroSize() {
142        return 20;  // 20 bytes per macro
143    }
144
145    /*
146     * give accessory memory address (AIU status)
147     */
148    public int getAccyMemAddr() {
149        return 0xEC00;
150    }
151
152    /*
153     * give accessory memory size (AIU status)
154     */
155    public int getAccyMemSize() {
156        return 0x100;
157    }
158    
159    /*
160     * give the AIU flag address
161     */
162    public int getAiuFlagAddr() {
163        return 0xDC15;
164    }
165    
166    /*
167     * give base addr for clock operations
168     */
169    public int getClockAddr() {
170        return 0xDC00;
171    }
172
173    public static int CAB_LINE_1 = 0;  // start of first line for cab display
174    public static int CAB_LINE_2 = 16;  // start of second line for cab display
175    //public static int CAB_SIZE = 256;  // Each cab has 256 bytes
176    public static int CAB_CURR_SPEED = 32; // NCE cab speed
177    public static int CAB_ADDR_H = 33;   // loco address, high byte
178    public static int CAB_ADDR_L = 34;   // loco address, low byte
179    public static int CAB_FLAGS = 35;  // FLAGS
180    public static int CAB_FUNC_L = 36;  // Function keys low
181    public static int CAB_FUNC_H = 37;  // Function keys high
182    public static int CAB_ALIAS = 38;  // Consist address
183    
184    /*
185     * give cab index functions 13-20
186     */
187    public int getCabIdxFunct13_20() {
188        return 82; // Function keys 13 - 30
189    }
190    
191    /*
192     * give cab index functions 21-28
193     */
194    public int getCabIdxFunct21_28() {
195        return 83; // Function keys 21 - 28
196    }
197    
198    /*
199     * give cab index for cab status
200     */
201    public int getCabIdxFlag1() {
202        return 101;  // NCE flag 1
203    }
204
205    public static int FLAGS_MASK_CONSIST_REAR = 0x80;      // bit 7 set if CAB_ADDR_x is rear loco
206    public static int FLAGS1_CABTYPE_DISPLAY = 0x00; // bit 0=0, bit 7=0;
207    public static int FLAGS1_CABTYPE_NODISP = 0x01; // bit 0=1, bit 7=0;
208    public static int FLAGS1_CABTYPE_USB = 0x80;  // bit 0=0, bit 7=1;
209    public static int FLAGS1_CABTYPE_AIU = 0x81;  // bit 0=1, bit 7=1;
210    public static int FLAGS1_CABISACTIVE = 0x02;          // if cab is active
211    public static int FLAGS1_MASK_CABTYPE = 0x81;         // Only bits 0 and 7.
212    public static int FLAGS1_MASK_CABISACTIVE = 0x02; // if cab is active
213
214    public static final int FUNC_L_F0 = 0x10;  // F0 or headlight
215    public static final int FUNC_L_F1 = 0x01;  // F1
216    public static final int FUNC_L_F2 = 0x02;  // F2
217    public static final int FUNC_L_F3 = 0x04;  // F3
218    public static final int FUNC_L_F4 = 0x08;  // F4
219
220    public static final int FUNC_H_F5 = 0x01;  // F5
221    public static final int FUNC_H_F6 = 0x02;  // F6
222    public static final int FUNC_H_F7 = 0x04;  // F7
223    public static final int FUNC_H_F8 = 0x08;  // F8
224    public static final int FUNC_H_F9 = 0x10;  // F9
225    public static final int FUNC_H_F10 = 0x20;  // F10
226    public static final int FUNC_H_F11 = 0x40;  // F11
227    public static final int FUNC_H_F12 = 0x80;  // F12
228
229    public static final int FUNC_H_F13 = 0x01;  // F13
230    public static final int FUNC_H_F14 = 0x02;  // F14
231    public static final int FUNC_H_F15 = 0x04;  // F15
232    public static final int FUNC_H_F16 = 0x08;  // F16
233    public static final int FUNC_H_F17 = 0x10;  // F17
234    public static final int FUNC_H_F18 = 0x20;  // F18
235    public static final int FUNC_H_F19 = 0x40;  // F10
236    public static final int FUNC_H_F20 = 0x80;  // F20
237
238    public static final int FUNC_H_F21 = 0x01;  // F21
239    public static final int FUNC_H_F22 = 0x02;  // F22
240    public static final int FUNC_H_F23 = 0x04;  // F23
241    public static final int FUNC_H_F24 = 0x08;  // F24
242    public static final int FUNC_H_F25 = 0x10;  // F25
243    public static final int FUNC_H_F26 = 0x20;  // F26
244    public static final int FUNC_H_F27 = 0x40;  // F27
245    public static final int FUNC_H_F28 = 0x80;  // F28
246
247    public static final int FUNC_H_F29 = 0x01;  // F29
248    public static final int FUNC_H_F30 = 0x02;  // F30
249    public static final int FUNC_H_F31 = 0x04;  // F31
250    public static final int FUNC_H_F32 = 0x08;  // F32
251    public static final int FUNC_H_F33 = 0x10;  // F33
252    public static final int FUNC_H_F34 = 0x20;  // F34
253    public static final int FUNC_H_F35 = 0x40;  // F35
254    public static final int FUNC_H_F36 = 0x80;  // F36
255
256    public static final int FUNC_H_F37 = 0x01;  // F37
257    public static final int FUNC_H_F38 = 0x02;  // F38
258    public static final int FUNC_H_F39 = 0x04;  // F39
259    public static final int FUNC_H_F40 = 0x08;  // F40
260    public static final int FUNC_H_F41 = 0x10;  // F41
261    public static final int FUNC_H_F42 = 0x20;  // F42
262    public static final int FUNC_H_F43 = 0x40;  // F43
263    public static final int FUNC_H_F44 = 0x80;  // F44
264
265    public static final int FUNC_H_F45 = 0x01;  // F45
266    public static final int FUNC_H_F46 = 0x02;  // F46
267    public static final int FUNC_H_F47 = 0x04;  // F47
268    public static final int FUNC_H_F48 = 0x08;  // F48
269    public static final int FUNC_H_F49 = 0x10;  // F49
270    public static final int FUNC_H_F50 = 0x20;  // F50
271    public static final int FUNC_H_F51 = 0x40;  // F51
272    public static final int FUNC_H_F52 = 0x80;  // F52
273
274    public static final int FUNC_H_F53 = 0x01;  // F53
275    public static final int FUNC_H_F54 = 0x02;  // F54
276    public static final int FUNC_H_F55 = 0x04;  // F55
277    public static final int FUNC_H_F56 = 0x08;  // F56
278    public static final int FUNC_H_F57 = 0x10;  // F57
279    public static final int FUNC_H_F58 = 0x20;  // F58
280    public static final int FUNC_H_F59 = 0x40;  // F59
281    public static final int FUNC_H_F60 = 0x80;  // F60
282
283    public static final int FUNC_H_F61 = 0x01;  // F61
284    public static final int FUNC_H_F62 = 0x02;  // F62
285    public static final int FUNC_H_F63 = 0x04;  // F63
286    public static final int FUNC_H_F64 = 0x08;  // F64
287    public static final int FUNC_H_F65 = 0x10;  // F65
288    public static final int FUNC_H_F66 = 0x20;  // F66
289    public static final int FUNC_H_F67 = 0x40;  // F67
290    public static final int FUNC_H_F68 = 0x80;  // F68
291}
292
293