Loading

code from frosch (2016)

  1.     item(booster_wagon ...)
  2.     {
  3.     }
  4.      
  5.     // return power, as computed in TEMP(0)
  6.     switch (..., power_final, [ LOAD_TEMP(0) ] ) {
  7.       return
  8.     }
  9.      
  10.     // check vehicle at position 1 from front, and add 400 if booster
  11.     switch (..., power_check_1, [
  12.     STORE_TEMP(2, 0x10F),
  13.     STORE_TEMP(LOAD_TEMP(0) + (var[0x61, 0, 0xFFFF, 0xC6] == booster_wagon ? 400 : 0), 0)
  14.     ] {
  15.       default: power_final
  16.     }
  17.      
  18.     // check vehicle at position 1 from back, and add 400 if booster
  19.     switch (..., power_check_2, [
  20.     STORE_TEMP(position_in_consist_from_end - 1, 0x10F),
  21.     STORE_TEMP(LOAD_TEMP(0) + (var[0x61, 0, 0xFFFF, 0xC6] == booster_wagon ? 400 : 0), 0)
  22.     ] {
  23.       default: power_check_1
  24.     }
  25.      
  26.     // check vehicle at position 2 from front, and add 100 if booster
  27.     switch (..., power_check_3, [
  28.     STORE_TEMP(2, 0x10F),
  29.     STORE_TEMP(LOAD_TEMP(0) + (var[0x61, 0, 0xFFFF, 0xC6] == booster_wagon ? 100 : 0), 0)
  30.     ] {
  31.       default: power_check_2
  32.     }
  33.      
  34.     // check vehicle at position 2 from back, and add 100 if booster
  35.     switch (..., power_check_4, [
  36.     STORE_TEMP(position_in_consist_from_end - 2, 0x10F),
  37.     STORE_TEMP(LOAD_TEMP(0) + (var[0x61, 0, 0xFFFF, 0xC6] == booster_wagon ? 100 : 0), 0)
  38.     ] {
  39.       default: power_check_3
  40.     }
  41.      
  42.     // basic power is 2000 + 200 per booster vehicle
  43.     switch (..., power_switch, [
  44.     STORE_TEMP(2000 + count_veh_id(booster_wagon) * 200, 0),
  45.     train_length
  46.     ])
  47.     {
  48.      1..2: power_final; // no wagons, no bonus
  49.      3: power_check_1; // one wagon
  50.      4: power_check_2; // two wagons
  51.      5: power_check_3; // three wagons
  52.      default: power_check_4; // four or more wagons
  53.     }
  54.      
  55.     item(engine ...)
  56.     {
  57.     power: power_switch;
  58.     }

Comments