aboutsummaryrefslogtreecommitdiff
path: root/saga/script.h
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-09-23 06:46:44 +0000
committerTorbjörn Andersson2004-09-23 06:46:44 +0000
commitc7338cccdb211fde6c6deb45b6168dd97de58989 (patch)
treeabfdc708742ee5084de0c303f0ceca68ec167082 /saga/script.h
parentbe1ab48a57d45315941c5b8396357aa65bf2dd0b (diff)
downloadscummvm-rg350-c7338cccdb211fde6c6deb45b6168dd97de58989.tar.gz
scummvm-rg350-c7338cccdb211fde6c6deb45b6168dd97de58989.tar.bz2
scummvm-rg350-c7338cccdb211fde6c6deb45b6168dd97de58989.zip
Replaced the standard stack with a custom-made. In the original SAGA engine
it appears that scripts are allowed to access the stack like any other memory area, so it's probably important that our stacks behave as closely to the original as possible. I don't know if this implementation does that yet, but it's a start. svn-id: r15240
Diffstat (limited to 'saga/script.h')
-rw-r--r--saga/script.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/saga/script.h b/saga/script.h
index 9baf427faa..11f3e877ff 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -28,7 +28,6 @@
#include "saga/text.h"
#include "saga/yslib.h"
-#include "common/stack.h"
namespace Saga {
@@ -45,8 +44,6 @@ namespace Saga {
#define R_SCRIPT_STRINGLIMIT 255
#define R_TAB " "
-#define R_DEF_THREAD_STACKSIZE 16
-
#define S_ERROR_PREFIX "SError: "
#define S_WARN_PREFIX "SWarning: "
@@ -80,7 +77,33 @@ struct R_SCRIPT_THREAD {
unsigned long i_offset; // Instruction offset
R_SEMAPHORE sem;
- Common::Stack<SDataWord_T> *stack;
+
+ // The scripts are allowed to access the stack like any other memory
+ // area. It's therefore probably quite important that our stacks work
+ // the same as in the original interpreter.
+
+ SDataWord_T stackBuf[64];
+
+ int stackPtr;
+ int framePtr;
+
+ SDataWord_T stackTop() {
+ return stackBuf[stackPtr];
+ }
+
+ int stackSize() {
+ return ARRAYSIZE(stackBuf) - stackPtr - 1;
+ }
+
+ void push(SDataWord_T n) {
+ assert(stackPtr > 0);
+ stackBuf[--stackPtr] = n;
+ }
+
+ SDataWord_T pop() {
+ assert(stackPtr < ARRAYSIZE(stackBuf));
+ return stackBuf[stackPtr++];
+ }
};
struct R_PROC_TBLENTRY {