From ec0dfa27e888461ec85012fa23d5a26e30f0e813 Mon Sep 17 00:00:00 2001 From: Savely Skresanov Date: Sat, 15 Sep 2012 21:31:55 +0700 Subject: [PATCH] Hooked more functions to VM. --- src/virtualmachine/Syscalls.cpp | 14 ++++++++++---- src/virtualmachine/Syscalls.inl | 2 ++ tptlibrary/file.c | 10 +++++++++- tptlibrary/tpt_syscalls.asm | 2 ++ tptlibrary/tpt_syscalls.h | 2 ++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/virtualmachine/Syscalls.cpp b/src/virtualmachine/Syscalls.cpp index 692d4d010..876fe5201 100644 --- a/src/virtualmachine/Syscalls.cpp +++ b/src/virtualmachine/Syscalls.cpp @@ -71,10 +71,16 @@ namespace vm TRAPDEF(pmapData) { - int xarg, yarg; - yarg = ARG(0).int4; - xarg = ARG(1).int4; + Push(sim->pmap[ARG(1).int4][ARG(0).int4]); + } - Push(sim->pmap[yarg][xarg]); + TRAPDEF(deletePart) + { + sim->delete_part(ARG(0).int4, ARG(1).int4, ARG(2).int4); + } + + TRAPDEF(killPart) + { + sim->kill_part(ARG(0).int4); } } diff --git a/src/virtualmachine/Syscalls.inl b/src/virtualmachine/Syscalls.inl index 5281fb3a1..75455c182 100644 --- a/src/virtualmachine/Syscalls.inl +++ b/src/virtualmachine/Syscalls.inl @@ -10,3 +10,5 @@ TRAPDEF(-8, print) TRAPDEF(-9, partCreate) TRAPDEF(-10, partChangeType) TRAPDEF(-11, pmapData) +TRAPDEF(-12, deletePart) +TRAPDEF(-13, killPart) diff --git a/tptlibrary/file.c b/tptlibrary/file.c index b3ad2781e..67f2ca1c9 100644 --- a/tptlibrary/file.c +++ b/tptlibrary/file.c @@ -2,6 +2,14 @@ int update_TEST(int i, int x, int y, int nt, int ss) { - partCreate(-1, x, y-1, 2); + int k, j, index; + + for(k=-1; k<2; k++) + for(j=-1; j<2; j++) + { + index = pmapData(x+k, y+j); + if ((index&0xFF) == 2) + killPart(index>>8); + } return 0; } diff --git a/tptlibrary/tpt_syscalls.asm b/tptlibrary/tpt_syscalls.asm index 2da262704..fd8658582 100644 --- a/tptlibrary/tpt_syscalls.asm +++ b/tptlibrary/tpt_syscalls.asm @@ -12,3 +12,5 @@ equ print -8 equ partCreate -9 equ partChangeType -10 equ pmapData -11 +equ deletePart -12 +equ killPart -13 diff --git a/tptlibrary/tpt_syscalls.h b/tptlibrary/tpt_syscalls.h index a3adf418a..f72aeb583 100644 --- a/tptlibrary/tpt_syscalls.h +++ b/tptlibrary/tpt_syscalls.h @@ -14,5 +14,7 @@ void error(char * message); int partCreate(int i, int x, int y, int type); void partChangeType(int i, int x, int y, int type); int pmapData(int x, int y); +void deletePart(int x, int y, int flags); +void killPart(int i); #endif