Simon

Untitled

Sep 10th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.09 KB | None | 0 0
  1. #include "simulation/Elements.h"
  2. #include "virtualmachine/VirtualMachine.h"
  3. //#TPT-Directive ElementClass Element_TEST PT_TEST 255
  4. static vm::VirtualMachine * vMachine;
  5. Element_TEST::Element_TEST()
  6. {
  7.     Identifier = "DEFAULT_PT_TEST";
  8.     Name = "TEST";
  9.     Colour = PIXPACK(0x407020);
  10.     MenuVisible = 1;
  11.     MenuSection = SC_POWDERS;
  12.     Enabled = 1;
  13.    
  14.     Advection = 0.4f;
  15.     AirDrag = 0.01f * CFDS;
  16.     AirLoss = 0.99f;
  17.     Loss = 0.95f;
  18.     Collision = 0.0f;
  19.     Gravity = 0.4f;
  20.     Diffusion = 0.00f;
  21.     HotAir = 0.000f * CFDS;
  22.     Falldown = 1;
  23.    
  24.     Flammable = 0;
  25.     Explosive = 0;
  26.     Meltable = 0;
  27.     Hardness = 0;
  28.    
  29.     Weight = 90;
  30.    
  31.     Temperature = R_TEMP+4.0f   +273.15f;
  32.     HeatConduct = 251;
  33.     Description = "Heavy particles. Fissile. Generates neutrons under pressure.";
  34.    
  35.     State = ST_SOLID;
  36.     Properties = TYPE_PART|PROP_NEUTPENETRATE|PROP_RADIOACTIVE;
  37.    
  38.     LowPressure = IPL;
  39.     LowPressureTransition = NT;
  40.     HighPressure = IPH;
  41.     HighPressureTransition = NT;
  42.     LowTemperature = ITL;
  43.     LowTemperatureTransition = NT;
  44.     HighTemperature = ITH;
  45.     HighTemperatureTransition = NT;
  46.    
  47.     Update = &Element_TEST::update;
  48.  
  49.     vMachine = new vm::VirtualMachine(2);
  50.     vMachine->LoadProgram("test.qvm");
  51. }
  52.  
  53. //#TPT-Directive ElementHeader Element_TEST static int update(UPDATE_FUNC_ARGS)
  54. int Element_TEST::update(UPDATE_FUNC_ARGS)
  55. {
  56.     vm::word w;
  57.     int argAddr = 0, argCount = 5;
  58.     vMachine->sim = sim;
  59.  
  60.     /* Set up call. */
  61.     vMachine->OpPUSH(w);  //Pointless null in stack
  62.     w.int4 = (argCount + 2) * sizeof(vm::word);
  63.     vMachine->OpENTER(w);
  64.     argAddr = 8;
  65.  
  66.     //Arguments
  67.     w.int4 = i; vMachine->Marshal(argAddr, w); argAddr += 4;
  68.     w.int4 = x; vMachine->Marshal(argAddr, w); argAddr += 4;
  69.     w.int4 = y; vMachine->Marshal(argAddr, w); argAddr += 4;
  70.     w.int4 = nt; vMachine->Marshal(argAddr, w); argAddr += 4;
  71.     w.int4 = surround_space; vMachine->Marshal(argAddr, w); argAddr += 4;
  72.  
  73.     w.int4 = 0;
  74.     vMachine->Push(w);
  75.  
  76.     vMachine->OpCALL(w);
  77.     vMachine->Run();
  78.     w.int4 = (argCount + 2) * sizeof(vm::word);
  79.     vMachine->OpLEAVE(w);
  80.     vMachine->OpPOP(w);   //Pop pointless null
  81.     vMachine->End();
  82.     return 0;
  83. }
  84.  
  85.  
  86. Element_TEST::~Element_TEST() {}
Advertisement
Add Comment
Please, Sign In to add comment