Source

firs / templates / template_secondary_action23_B.pnfo

The default branch has multiple heads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
// Action2/3-chain for cargo processing at secondary industries
// ------------------------------------------------------------
// This is a template for combinatory cargos
//
// Each cargo contributes a certain amount to a production ratio n / 8
// ! Total for all cargos cannot exceed 8 
//
// For each cargo, the regular production cb checks number of cycles since cargo was last delivered.
// If cargo delivered within last n cycles, production contribution for that cargo is added to total (n to be be based on testing)
// Output for this cycle is then calculated for all input cargo using current ratio.
//
// For gameplay benefit, this makes certain allowances against realism and the exact timings of deliveries etc.
// - we assume that certain internal processes at the industry are the cause of the varying ratio (boilers being lit for example).

// This code attempts to handle insane amounts of input cargo, but if any given input cargo exceeds limits, some will be discarded.

// How to use:
// Add to the top of a primary industry a few #define lines. For example:
//#define THIS_INDUSTRY                 IND_MACHINESHOP
//#define THIS_NUM_INPUT_CARGOS         \d03      // range 01-03
//#define THIS_NUM_OUTPUT_CARGOS        \d02      // range 01-02
// - production ratios each cargo: !! total for all cargos cannot exceed 8 -
//#define THIS_PROD_RATIO_CARGO_IN_1    \d01      // do not set to 0 - used for division
//#define THIS_PROD_RATIO_CARGO_IN_2    \d01      // do not set to 0 - used for division
//#define THIS_PROD_RATIO_CARGO_IN_3    \d01      // do not set to 0 - used for division
// - end ratios -
//#define THIS_STR_INFO_CB38            STR_INFO_MACHINESHOP

// then add as the 2nd last line, prior to the end of the climate availability label
// #include "../../templates/template_secondary_action23_B.pnfo"

// In principle you can also add the defines immediately above this #define line...

// Preferred action 2 ID ranges, to keep life simple...
//   production code	00-0F, A0-AF,	B0-BF
//   misc branching, handle callbacks etc	C0-CF
//   monthly / random production change	D0-DF
//   texts	E0-FF
//   industry location permissibility (CB 28)  10-1F  (NB CB 28 is not templated - handled on a per-industry basis)
//   industry availability (CB 22) 20
//   generally unused and available	2A-9F

// Persistent storage used (not guaranteed to be up to date, but it's a starting point for making sense of this)
// 01,02,03: prod. ratios cargo 1,2,3 (dynamic value between 0 and 8, total all 3 cannot exceed 8)
// 04,05,06: store production from each of cargo 1,2,3
// 07,08,09: store amounts used of each cargo 1,2,3
// 0A, 0B: output amounts for output cargo 1,2 (second often not needed, but code handles both cases)
// 0C: total production ratio all cargos summed (value between 0 and 8)
// 0D,0E,0F:  'combinatory production ticker' cargo 1,2,3 

//3 input cargos
//if 2 output cargos
//  50:50 distribution to output cargos C1 output = 50% total input, C2 output = 50% total input
//if 1 output cargo, 100% distribution!

// !! there may be flawed logic here; if production ratio is < 8, I think too much / not enough input cargo may be used.  Needs checking.

// production code 
//!! case of 0 output cargo? - probably a different template...
-1 * 0 02 0A 00 //production cb, 1 output cargo 
	01 //version
	07  08  09 //<subtract-in-1..3>
	0A  0B //<add-out-1..2>
	00 //don't repeat

-1 * 0 02 0A AC //where one cargo produced, all of production goes in register 0A, register 0B is zeroed
    89 // 
      1A 20 \dx00 // create 0
      10 1A 20 \dx0B //store in persistent storage (for debug only, can be commented if not in use)
      \2sto 1A 20 \dx0B //store in register
      0F
      7D 0A 20  \dxFFFFFFFF //get stored amount for total cargo output
      10 1A 20 \dx0A //store in persistent storage (for debug only, can be commented if not in use)
      \2sto 1A 00 \dx0A //store in register
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       00 00  00 00 00 00  00 00 00 00
     00 00 //default

-1 * 0 02 0A AB //where two cargos produced, industry output is split 50:50
    89 // 
      7D 0A 20  \dxFFFFFFFF //get stored amount for total cargo output
      \2/ 1A 20 THIS_NUM_OUTPUT_CARGOS
      10 1A 20 \dx0A //store in persistent storage (for debug only, can be commented if not in use)
      \2sto 1A 20 \dx0A //store in register
      10 1A 20 \dx0B //store in persistent storage (for debug only, can be commented if not in use)
      \2sto 1A 00 \dx0B //store in register
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       00 00  00 00 00 00  00 00 00 00
     00 00 //default

-1 * 0 02 0A AA //how many output cargos do we have?  branch accordingly (branching easier than advanced varaction 2 here)
    89 // 
      1A 00 THIS_NUM_OUTPUT_CARGOS 
    \b1 //range
       AB 00  \d02  \d02
     AC 00 //default

//!! not really sure what is going on with A9, seems to duplicate AA - AC section of chain?
// i.e. for two cargos, the 50:50 split is done twice.
// possibly it's just the comment on A9 that is misleading....

-1 * 0 02 0A A9 //add up total cargo produced...for this industry output is split 50:50, so only bother setting one register
    89 // 
      7C 04 20  \dxFFFFFFFF //get stored amount for production from cargo 1
      \2+ 7C 05 20  \dxFFFFFFFF //get stored amount for production from cargo 2
      \2+ 7C 06 20  \dxFFFFFFFF //get stored amount for production from cargo 3 
      10 1A 20 \dx0A //store in persistent storage (for debug only, can be commented if not in use)
      \2sto 1A 00 \dx0A //store in register
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       AA 00  00 00 00 00  00 00 00 00
     AA 00 //default

-1 * 0 02 0A A8 //calculate amount of input cargo actually processed
    89 // 
      7C 06 20  \dxFFFFFFFF //get stored amount for production from cargo 3
      \2/ 7C 0C 20  \dxFFFFFFFF //divide production amount by production ratio 
      \2* 1A 20 \d08 // multiply result by 8
      \2sto 1A 20 \dx09 //store in register
      0F  
      42 20  \dxFFFFFFFF //get cargo 3 waiting 
      \2- 7D 09 20  \dxFFFFFFFF //subtract cargo waiting from amount to be used (is any remaindered?)
      \2+ 7D 09 20  \dxFFFFFFFF //add result to amount to be used (to clear any remainder)
      10 1A 20 \dx09 //store in persistent storage (for debug only, can be commented if not in use)
      \2sto 1A 00 \dx09 //store in register
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A9 00  00 00 00 00  00 00 00 00
     A9 00 //default

-1 * 0 02 0A A7 //calculate amount of input cargo actually processed
    89 // 
      7C 05 20  \dxFFFFFFFF //get stored amount for production from cargo 2
      \2/ 7C 0C 20  \dxFFFFFFFF //divide production amount by production ratio 
      \2* 1A 20 \d08 // multiply result by 8
      \2sto 1A 20 \dx08 //store in register
      0F  
      41 20  \dxFFFFFFFF //get cargo 2 waiting 
      \2- 7D 08 20  \dxFFFFFFFF //subtract cargo waiting from amount to be used (is any remaindered?)
      \2+ 7D 08 20  \dxFFFFFFFF //add result to amount to be used (to clear any remainder)
      10 1A 20 \dx08 //store in persistent storage (for debug only, can be commented if not in use)
      \2sto 1A 00 \dx08 //store in register
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A8 00  00 00 00 00  00 00 00 00
     A8 00 //default

-1 * 0 02 0A A6 //calculate amount of input cargo actually processed
    89 // 
      7C 04 20  \dxFFFFFFFF //get stored amount for production from cargo 1
      \2/ 7C 0C 20  \dxFFFFFFFF //divide production amount by production ratio 
      \2* 1A 20 \d08 // multiply result by 8
      \2sto 1A 20 \dx07 //store in register
      0F  
      40 20  \dxFFFFFFFF //get cargo 1 waiting 
      \2- 7D 07 20  \dxFFFFFFFF //subtract cargo waiting from amount to be used (is any remaindered?)
      \2+ 7D 07 20  \dxFFFFFFFF //add result to amount to be used (to clear any remainder)
      10 1A 20 \dx07 //store in persistent storage (for debug only, can be commented if not in use)
      \2sto 1A 00 \dx07 //store in register
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A7 00  00 00 00 00  00 00 00 00
     A7 00 //default

-1 * 0 02 0A A5 //store lower value of: (cargo waiting divided by prod ratio for cargo) or (output limit for produced cargo) 
    89 // 
      42 20  \dxFFFFFFFF // cargo waiting
      \2/ 1A 20  \d08 //divide cargo waiting by 8
      \2* 7C 0C 20  \dxFFFFFFFF //multiply cargo waiting by production ratio to get calculated production value 
      \2< 7C 00 20  \dxFFFFFFFF //result = min(calculated production value, output limit for produced cargo)
      10 1A 00 \dx06 //store in persistent storage (could use ordinary register, but this is easier to debug)
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A6 00  00 00 00 00  00 00 00 00
     A6 00 //default

-1 * 0 02 0A A4 //store lower value of: (cargo waiting divided by prod ratio for cargo) or (output limit for produced cargo) 
    89 // 
      41 20  \dxFFFFFFFF // cargo waiting 
      \2/ 1A 20  \d08 //divide cargo waiting by 8
      \2* 7C 0C 20  \dxFFFFFFFF //multiply cargo waiting by production ratio to get calculated production value
      \2< 7C 00 20  \dxFFFFFFFF //result = min(calculated production value, output limit for produced cargo)
      10 1A 00 \dx05 //store in persistent storage (could use ordinary register, but this is easier to debug)
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A5 00  00 00 00 00  00 00 00 00
     A5 00 //default

-1 * 0 02 0A A3 //store lower value of: (cargo waiting divided by prod ratio for cargo) or (output limit for produced cargo) 
    89 // 
      40 20  \dxFFFFFFFF // cargo waiting 
      \2/ 1A 20  \d08 //divide cargo waiting by 8
      \2* 7C 0C 20  \dxFFFFFFFF //multiply cargo waiting by production ratio to get calculated production value 
      \2< 7C 00 20  \dxFFFFFFFF //result = min(calculated production value, output limit for produced cargo)
      10 1A 00 \dx04 //store in persistent storage (could use ordinary register, but this is easier to debug)
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A4 00  00 00 00 00  00 00 00 00
     A4 00 //default

-1 * 0 02 0A A2 // set total production ratio
    89 // 
      1A 20  \d00 // create 00 
      \2+ 7C 01 20  \dxFFFFFFFF //add prod ratio for cargo 1   
      \2+ 7C 02 20  \dxFFFFFFFF //add prod ratio for cargo 2   
      \2+ 7C 03 20  \dxFFFFFFFF //add prod ratio for cargo 3   
      10 1A 00 \dx0C //store in persistent storage (could use ordinary register, but this is easier to debug)
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A3 00  00 00 00 00  00 00 00 00
     A3 00     


-1 * 0 02 0A BE //case no cargo 3 delivered recently
    89 // using type 89 because register IDs are better specified as double words
      1A 20  \d00 //set 0 for production ratio cargo 3
      10  1A 20 \dx03 // store in persistent storage
      0F // renum gets sad about passing 0 to the range check, so create 1 and pass that instead <roll>   
      1A 00 \d01 //create value 1
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A2 00  00 00 00 00  00 00 00 00
     A2 00

-1 * 0 02 0A BD //case some cargo 3 delivered recently
    89 // using type 89 because register IDs are better specified as double words
      1A 20  THIS_PROD_RATIO_CARGO_IN_3 //set positive value for production ratio cargo 3
      10  1A 20 \dx03 // store in persistent storage
      0F
      1A 20  \d01 //create value 1
      \2+ 7C 0F 20  \dxFFFFFFFF //add to 'combinatory production ticker' for cargo 3   
      10  1A 00 \dx0F // store in persistent storage
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       A2 00  00 00 00 00  00 00 00 00
     A2 00

-1 * 0 02 0A BC //check if some cargo 3 delivered recently - in last 8(?check?) production cycles
    89 // 
      7c  0F 00 \dxFFFFFFFF //get 'combinatory production ticker' value from storage.    
    \b1 //range
       BD 00  \d00  NUM_PROD_CYCLES_INVENTORY_HELD_FOR
     BE 00 //default

-1 * 0 02 0A BB //case some cargo 3 waiting
    89 // using type 89 because register IDs are better specified as double words
      1A 20  \d00 //set 0 for 'combinatory production ticker' cargo 3
      10 1A 20 \dx0F //store in persistent storage
      0F // renum gets sad about passing 0 to the range check, so create 1 and pass that instead <roll>   
      1A 00 \d01 //create value 1
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       BD 00  00 00 00 00  00 00 00 00
     BD 00
     
-1 * 0 02 0A BA //check cargo waiting 3 
    85 // 
      42 00  \wxFFFF 
    \b1 //range
       BC 00  \w00 \w00 //no cargo waiting
     BB 00 //some cargo waiting
     
       
-1 * 0 02 0A B9 //case no cargo 2 delivered recently
    89 // using type 89 because register IDs are better specified as double words
      1A 20  \d00 //set 0 for production ratio cargo 2
      10  1A 20 \dx02 // store in persistent storage
      0F // renum gets sad about passing 0 to the range check, so create 1 and pass that instead <roll>   
      1A 00 \d01 //create value 1
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       BA 00  00 00 00 00  00 00 00 00
     BA 00

-1 * 0 02 0A B8 //case some cargo 2 delivered recently
    89 // using type 89 because register IDs are better specified as double words
      1A 20  THIS_PROD_RATIO_CARGO_IN_2 //set positive value for production ratio cargo 2
      10  1A 20 \dx02 // store in persistent storage
      0F
      1A 20  \d01 //create value 1
      \2+ 7C 0E 20  \dxFFFFFFFF //add to 'combinatory production ticker' for cargo 2   
      10  1A 00 \dx0E // store in persistent storage
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       BA 00  00 00 00 00  00 00 00 00
     BA 00

-1 * 0 02 0A B7 //check if some cargo 2 delivered recently - in last 8(?check?) production cycles
    89 // 
      7c  0E 00 \dxFFFFFFFF //get 'combinatory production ticker' value from storage.    
    \b1 //range
       B8 00  \d00  NUM_PROD_CYCLES_INVENTORY_HELD_FOR
     B9 00 //default

-1 * 0 02 0A B6 //case some cargo 2 waiting
    89 // using type 89 because register IDs are better specified as double words
      1A 20  \d00 //set 0 for 'combinatory production ticker' cargo 2
      10 1A 20 \dx0E //store in persistent storage
      0F // renum gets sad about passing 0 to the range check, so create 1 and pass that instead <roll>   
      1A 00 \d01 //create value 1
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       B8 00  00 00 00 00  00 00 00 00
     B8 00
     
-1 * 0 02 0A B5 //check cargo waiting 2 
    85 // 
      41 00  \wxFFFF 
    \b1 //range
       B7 00  \w00 \w00 //no cargo waiting
     B6 00 //some cargo waiting

       
-1 * 0 02 0A B4 //case no cargo 2 delivered recently
    89 // using type 89 because register IDs are better specified as double words
      1A 20  \d00 //set 0 for production ratio cargo 1
      10  1A 20 \dx01 // store in persistent storage
      0F // renum gets sad about passing 0 to the range check, so create 1 and pass that instead <roll>   
      1A 00 \d01 //create value 1
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       B5 00  00 00 00 00  00 00 00 00
     B5 00

-1 * 0 02 0A B3 //case some cargo 1 delivered recently
    89 // using type 89 because register IDs are better specified as double words
      1A 20  THIS_PROD_RATIO_CARGO_IN_1 //set positive value for production ratio cargo 1
      10  1A 20 \dx01 // store in persistent storage
      0F
      1A 20  \d01 //create value 1
      \2+ 7C 0D 20  \dxFFFFFFFF //add to 'combinatory production ticker' for cargo 1   
      10  1A 00 \dx0D // store in persistent storage
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       B5 00  00 00 00 00  00 00 00 00
     B5 00

-1 * 0 02 0A B2 //check if some cargo 1 delivered recently - in last 8(?check?) production cycles
    89 // 
      7c  0D 00 \dxFFFFFFFF
    \b1 //range
       B3 00  \d00  NUM_PROD_CYCLES_INVENTORY_HELD_FOR
     B4 00 //default

-1 * 0 02 0A B1 //case some cargo 1 waiting
    89 // using type 89 because register IDs are better specified as double words
      1A 20  \d00 //set 0 for 'combinatory production ticker' cargo 1
      10 1A 20 \dx0D //store in persistent storage
      0F // renum gets sad about passing 0 to the range check, so create 1 and pass that instead <roll>   
      1A 00 \d01 //create value 1
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       B3 00  00 00 00 00  00 00 00 00
     B3 00
     
-1 * 0 02 0A B0 //check cargo waiting 1 
    85 // 
      40 00  \wxFFFF 
    \b1 //range
       B2 00  \w00 \w00 //no cargo waiting
     B1 00 //some cargo waiting


// PROVIDE DEBUG INFO TO INDUSTRY WINDOW 
//Remember text stack is LIFO (like array.pop) - put values to render first in highest registers
-1 * 0 02 0A FF //store one values to text stack for debugging
    89 // 
      7c 0F 20 \dxffff
      \2ror 1a 20 \d16
      \2| 7c 0E 20 \dxffff
      \2sto 1a 00 \dx105
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       STR_INFO_DEBUG_3 80  00 00 00 00  00 00 00 00
     STR_INFO_DEBUG_3 80 //default

-1 * 0 02 0A FE //store two values to text stack for debugging
    89 // 
      7c 0D 20 \dxffff
      \2ror 1a 20 \d16
      \2| 7c 0C 20 \dxffff
      \2sto 1a 00 \dx104
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       FF 00  00 00 00 00  00 00 00 00
     FF 00 //default

-1 * 0 02 0A FD //store two values to text stack for debugging
    89 // 
      7c 0B 20 \dxffff
      \2ror 1a 20 \d16
      \2| 7c 0A 20 \dxffff
      \2sto 1a 00 \dx103
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       FE 00  00 00 00 00  00 00 00 00
     FE 00 //default

-1 * 0 02 0A FC //store two values to text stack for debugging
    89 // 
      7c 09 20 \dxffff
      \2ror 1a 20 \d16
      \2| 7c 08 20 \dxffff
      \2sto 1a 00 \dx102
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       FD 00  00 00 00 00  00 00 00 00
     FD 00 //default
     
-1 * 0 02 0A FB //store two values to text stack for debugging
    89 // 
      7c 07 20 \dxffff
      \2ror 1a 20 \d16
      \2| 7c 03 20 \dxffff
      \2sto 1a 00 \dx101
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       FC 00  00 00 00 00  00 00 00 00
     FC 00 //default

-1 * 0 02 0A FA //store two values to text stack for debugging
    89
      7c 02 20 \dxffff  
      \2ror 1a 20 \d16
      \2| 7c 01 20 \dxffff
      \2sto 1a 00 \dx100
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       FB 00  00 00 00 00  00 00 00 00
     FB 00 //default

-1 * 0 02 0A F0 //
    81 // 
      7F DEBUG_PARAMETER 00 DEBUG_PARAMETER_INDUSTRY_TEXT_BIT // check if first bit is set for debug parameter
    \b1 //range
       FA 00  DEBUG_PARAMETER_INDUSTRY_TEXT_BIT  DEBUG_PARAMETER_INDUSTRY_TEXT_BIT
     THIS_STR_INFO_CB3A 80 //default

// !! the logic for output limit is flawed.  This assumes limit is FF FF; when 2 output cargos are split 50:50, output limit before split is 2 * FF FF
// TTDPatch wiki for production callback: "results are clamped to the allowed range (0..32767 for incoming cargo amounts, 0..65535 for outgoing cargo amounts)."
-1 * 0 02 0A C1 //store output limit for produced cargo (as units of output cargo) to use when processing each input cargo
    89 // using type 89 because register IDs are better specified as double words
      1A 20  \dxFFFF // create a value (constant 1A); total production limit is FF FF per output cargo
      \2/ 1a 20 THIS_NUM_INPUT_CARGOS // divide by number of input cargos for this industry (exclude production-boosting cargos from input cargo count)
      10  1A 00 \dx00 // store in persistent storage
    \b1 //range (stay out of the nvar=0 bear pit by checking one range, but returning same for both)
       B0 00  00 00 00 00  00 00 00 00
     B0 00
     
// handle cb 22 industry availability
#include "industry_availability_check.pnfo"     

// handle callbacks
-1 * 0 02 0A C0 //-1 * 0 0A <set-id>
	85 0C //<type> <variable> word-access callback
	00 FF FF //no shift, no mask
	\b3 //number of ranges to check
    20 00   22 00   22 00 //industry availability cb 22
	  THIS_STR_INFO_CB38 80   38 00   38 00 ////cb 38 display additional text in fund window
	  F0 00   3A 00   3A 00 //cb 3A (industry window)
	C1 00 //default

// industry action 3 attach varaction2 chain to industry
-1 * 0 03 0A 01 THIS_INDUSTRY 00 \wxC0 //-1 * 0 03 09 <n-ids> <id> 00 <def-cid>	

#undef THIS_INDUSTRY
#undef THIS_STR_INFO_CB3A
#undef THIS_STR_INFO_CB38
#undef THIS_NUM_INPUT_CARGOS
#undef THIS_NUM_OUTPUT_CARGOS
#undef THIS_PROD_RATIO_CARGO_IN_1
#undef THIS_PROD_RATIO_CARGO_IN_2
#undef THIS_PROD_RATIO_CARGO_IN_3