aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/fncmodules.cpp29
-rw-r--r--src/core/fncmodules.hpp6
-rw-r--r--src/core/fncwrapper.cpp8
-rw-r--r--src/core/fncwrapper.hpp2
-rw-r--r--src/core/vmrunner.cpp9
-rw-r--r--src/core/vmrunner.hpp4
6 files changed, 28 insertions, 30 deletions
diff --git a/src/core/fncmodules.cpp b/src/core/fncmodules.cpp
index 6ae2570..14d2f48 100644
--- a/src/core/fncmodules.cpp
+++ b/src/core/fncmodules.cpp
@@ -1,36 +1,29 @@
-#include <cstdarg>
#include "smmath.hpp"
#include "bullet.hpp"
#include "scriptshared.hpp"
#include "vmrunner.hpp"
-Idata randr(Idata a,...)
+extern callStack<Idata> callStk;
+Idata randr()
{
Idata ret;ret.type=1;
- va_list val;
- va_start(val,a);
extern blrScriptVM *vm;
- ret.r()=vm->re->nextDouble(a.r(),va_arg(val,Idata).r());
- va_end(val);
+ ret.r()=(float)vm->re->nextDouble((float&)callStk.pop().r(),(float&)callStk.pop().r());
return ret;
}
-Idata randi(Idata a,...)
+Idata randi()
{
Idata ret;ret.type=0;
- va_list val;
- va_start(val,a);
extern blrScriptVM *vm;
- ret.i()=vm->re->nextInt(a.i(),va_arg(val,Idata).i());
- va_end(val);
+ ret.i()=vm->re->nextInt(callStk.pop().i(),callStk.pop().i());
return ret;
}
-Idata createBullet(Idata x,...)
+Idata createBullet()
{
- Idata y,bs,rad;
- va_list val;
- va_start(val,x);
- y=va_arg(val,Idata);
- bs=va_arg(val,Idata);
- rad=va_arg(val,Idata);
+ Idata x,y,bs,rad;
+ x=callStk.pop();
+ y=callStk.pop();
+ bs=callStk.pop();
+ rad=callStk.pop();
extern bulletManager *bmInstance;
int i=bmInstance->allocBullet<bulletBase>();
bmInstance->getHandle(i)->init();
diff --git a/src/core/fncmodules.hpp b/src/core/fncmodules.hpp
index fe8eccf..b36eeb6 100644
--- a/src/core/fncmodules.hpp
+++ b/src/core/fncmodules.hpp
@@ -1,4 +1,4 @@
#include "scriptshared.hpp"
-extern Idata randr(Idata a,...);
-extern Idata randi(Idata a,...);
-extern Idata createBullet(Idata x,...);
+extern Idata randr();
+extern Idata randi();
+extern Idata createBullet();
diff --git a/src/core/fncwrapper.cpp b/src/core/fncwrapper.cpp
index b1dd4d7..0927541 100644
--- a/src/core/fncwrapper.cpp
+++ b/src/core/fncwrapper.cpp
@@ -1,15 +1,15 @@
#include "vmrunner.hpp"
#include "fncmodules.hpp"
-extern blrScriptVM *vm;
extern callStack<Idata> callStk;
+extern blrScriptVM *vm;
extern unsigned getHash(const char *s);
void callFnc(const char* fnc)
{
if(getHash(fnc)==getHash("randi"))
- randi(callStk.pop(),callStk.pop());
+ vm->vmSetRetVald(randi().i());
if(getHash(fnc)==getHash("randr"))
- randr(callStk.pop(),callStk.pop());
+ vm->vmSetRetValf(randr().r());
if(getHash(fnc)==getHash("createBullet"))
- createBullet(callStk.pop(),callStk.pop(),callStk.pop(),callStk.pop());
+ vm->vmSetRetValf(createBullet().i());
if(callStk.empty())callStk.clear();
}
diff --git a/src/core/fncwrapper.hpp b/src/core/fncwrapper.hpp
index 8d1c8b6..d8796b4 100644
--- a/src/core/fncwrapper.hpp
+++ b/src/core/fncwrapper.hpp
@@ -1 +1 @@
-
+extern void callFnc(const char* fnc);
diff --git a/src/core/vmrunner.cpp b/src/core/vmrunner.cpp
index 4da775b..7cad11a 100644
--- a/src/core/vmrunner.cpp
+++ b/src/core/vmrunner.cpp
@@ -1,5 +1,6 @@
#include "vmrunner.hpp"
#include "coreshared.hpp"
+#include "fncwrapper.hpp"
#include <cstdlib>
blrScriptVM *vm;
callStack<Idata> callStk;
@@ -115,7 +116,7 @@ int blrScriptVM::loadLSBFromMemory(const char *ptr,DWORD size)
return 0;
}
int blrScriptVM::getInstCount(){return pinst;}
-void blrScriptVM::runFunction(const char *fncnym)
+void blrScriptVM::vmRunFunction(const char *fncnym)
{
int nymhash=getHash(fncnym),cur=0;pinst=0;
for(int i=0;i<fncnt;++i)if(nymhash==fncent[i].hash){cur=fncent[i].pos;break;}
@@ -137,8 +138,8 @@ void blrScriptVM::runFunction(const char *fncnym)
callStk.push(fetchData(inst[cur].para1));
break;
case 0x02:
- //callFnc(inst[cur].para1.fnc);
- //callstk.clear();
+ callFnc(inst[cur].para1.fnc);
+ //callStk.clear();
//printf("stubbed call %s\n",inst[cur].para1.fnc);
break;
case 0x03:
@@ -274,6 +275,8 @@ void blrScriptVM::runFunction(const char *fncnym)
if(!jmp)++cur;
}
}
+void blrScriptVM::vmSetRetValf(float v){rr[102].r()=v;}
+void blrScriptVM::vmSetRetVald(int v){ir[100].i()=v;}
void blrScriptVM::vmInit(unsigned int seed)
{
for(int i=0;i<103;++i)rr[i].type=1;
diff --git a/src/core/vmrunner.hpp b/src/core/vmrunner.hpp
index d9d9a59..2dec71f 100644
--- a/src/core/vmrunner.hpp
+++ b/src/core/vmrunner.hpp
@@ -40,7 +40,9 @@ public:
blrScriptVM(){ic=fncnt=pinst=0;}
int loadLSBFromMemory(const char* ptr,DWORD size);
int getInstCount();
- void runFunction(const char *fncnym);
+ void vmRunFunction(const char *fncnym);
+ void vmSetRetValf(float v);
+ void vmSetRetVald(int v);
void vmInit(unsigned int seed);
void vmDeinit();
};