#include #include #include #include "VirtualMachine.h" #include "simulation/Simulation.h" #include "graphics/Renderer.h" namespace vm { #define ARG(n) (Get(RP + ((2 + n) * sizeof(word)))) #define TRAPDEF(f) int VirtualMachine::trap##f() TRAPDEF(sin) { Push(sin(ARG(0).float4)); } TRAPDEF(cos) { Push(cos(ARG(0).float4)); } TRAPDEF(atan2) { Push(atan2(ARG(0).float4, ARG(1).float4)); } TRAPDEF(sqrt) { Push(sqrt(ARG(0).float4)); } TRAPDEF(floor) { Push(floor(ARG(0).float4)); } TRAPDEF(ceil) { Push(ceil(ARG(0).float4)); } TRAPDEF(print) { char *text; text = (char*)(ram) + ARG(0).int4; printf("%s", text); } TRAPDEF(error) { char *msg; msg = (char*)(ram) + ARG(0).int4; printf("%s", msg); End(); } TRAPDEF(partCreate) { Push(sim->create_part(ARG(0).int4, ARG(1).int4, ARG(2).int4, ARG(3).int4)); } TRAPDEF(partChangeType) { sim->part_change_type(ARG(0).int4, ARG(1).int4, ARG(2).int4, ARG(3).int4); } }