summaryrefslogtreecommitdiff
path: root/src/virtualmachine/Syscalls.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-09 19:03:27 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-09 19:03:27 (GMT)
commit369ba2ecedc77649eddc63a011025c02dd85706a (patch)
treece4b5db08f07c26f6fcfb469cf32f7d2f266a024 /src/virtualmachine/Syscalls.cpp
parentb44ac1bb7dbe59170251dc6d38421c45e00bea9f (diff)
downloadpowder-369ba2ecedc77649eddc63a011025c02dd85706a.zip
powder-369ba2ecedc77649eddc63a011025c02dd85706a.tar.gz
More VM syscalls
Diffstat (limited to 'src/virtualmachine/Syscalls.cpp')
-rw-r--r--src/virtualmachine/Syscalls.cpp64
1 files changed, 51 insertions, 13 deletions
diff --git a/src/virtualmachine/Syscalls.cpp b/src/virtualmachine/Syscalls.cpp
index 5358833..bc88fb2 100644
--- a/src/virtualmachine/Syscalls.cpp
+++ b/src/virtualmachine/Syscalls.cpp
@@ -1,33 +1,71 @@
-#include "VirtualMachine.h"
#include <cstdio>
#include <cstdlib>
+#include <cmath>
+#include "VirtualMachine.h"
+#include "simulation/Simulation.h"
+#include "graphics/Renderer.h"
namespace vm
{
- #define ARG(n) (Get<int4_t>(RP + ((2 + n) * sizeof(word))))
+ #define ARG(n) (Get(RP + ((2 + n) * sizeof(word))))
#define TRAPDEF(f) int VirtualMachine::trap##f()
- TRAPDEF(Print)
+ TRAPDEF(sin)
{
+ Push<float4_t>(sin(ARG(0).float4));
+ }
- char *text;
+ TRAPDEF(cos)
+ {
+ Push<float4_t>(cos(ARG(0).float4));
+ }
+
+ TRAPDEF(atan2)
+ {
+ Push<float4_t>(atan2(ARG(0).float4, ARG(1).float4));
+ }
+
+ TRAPDEF(sqrt)
+ {
+ Push<float4_t>(sqrt(ARG(0).float4));
+ }
+
+ TRAPDEF(floor)
+ {
+ Push<float4_t>(floor(ARG(0).float4));
+ }
- //crumb("SYSCALL Print [%d]\n", ARG(0));
- text = (char*)(ram) + ARG(0);
- //crumb("PRINTING [%s]\n", text);
+ TRAPDEF(ceil)
+ {
+ Push<float4_t>(ceil(ARG(0).float4));
+ }
+
+
+ TRAPDEF(print)
+ {
+ char *text;
+ text = (char*)(ram) + ARG(0).int4;
printf("%s", text);
- return 0;
}
- TRAPDEF(Error)
+ TRAPDEF(error)
{
char *msg;
-
- msg = (char*)(ram) + ARG(0);
+ msg = (char*)(ram) + ARG(0).int4;
printf("%s", msg);
- PC = romSize + 1;
- return 0;
+ End();
+ }
+
+
+ TRAPDEF(partCreate)
+ {
+ Push<int4_t>(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);
}
} \ No newline at end of file