[Scummvm-cvs-logs] SF.net SVN: scummvm:[42188] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Mon Jul 6 20:49:52 CEST 2009
Revision: 42188
http://scummvm.svn.sourceforge.net/scummvm/?rev=42188&view=rev
Author: dkasak13
Date: 2009-07-06 18:49:51 +0000 (Mon, 06 Jul 2009)
Log Message:
-----------
Set up GPL functions properly (the math evaluator now calls the handler if its implemented).
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
scummvm/branches/gsoc2009-draci/engines/draci/script.h
Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.cpp 2009-07-06 18:15:50 UTC (rev 42187)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.cpp 2009-07-06 18:49:51 UTC (rev 42188)
@@ -114,31 +114,32 @@
{"-", &Script::operSub }
};
+ /** Functions used by the mathematical evaluator */
+ static const GPL2Function gplFunctions[] = {
+ { "Not", NULL },
+ { "Random", NULL },
+ { "IsIcoOn", NULL },
+ { "IsIcoAct", NULL },
+ { "IcoStat", NULL },
+ { "ActIco", NULL },
+ { "IsObjOn", NULL },
+ { "IsObjOff", NULL },
+ { "IsObjAway", NULL },
+ { "ObjStat", NULL },
+ { "LastBlock", NULL },
+ { "AtBegin", NULL },
+ { "BlockVar", NULL },
+ { "HasBeen", NULL },
+ { "MaxLine", NULL },
+ { "ActPhase", NULL },
+ { "Cheat", NULL },
+ };
+
_commandList = gplCommands;
_operatorList = gplOperators;
+ _functionList = gplFunctions;
}
-/** Functions used by the mathematical evaluator */
-Common::String functions[] = {
- "F_Not",
- "F_Random",
- "F_IsIcoOn",
- "F_IsIcoAct",
- "F_IcoStat",
- "F_ActIco",
- "F_IsObjOn",
- "F_IsObjOff",
- "F_IsObjAway",
- "F_ObjStat",
- "F_LastBlock",
- "F_AtBegin",
- "F_BlockVar",
- "F_HasBeen",
- "F_MaxLine",
- "F_ActPhase",
- "F_Cheat"
-};
-
/** Type of mathematical object */
enum mathExpressionObject {
kMathEnd,
@@ -223,7 +224,11 @@
GameObject *obj = _vm->_game->getObject(objID);
- _vm->_anims->play(animID);
+ int visiblethingy = obj->_visible ? 1 << 7 : 0x00;
+ int thingy = (obj->_location + 1) | visiblethingy;
+
+ if ( ((objID == 0) || (obj->_visible)) && (obj->_location == _vm->_game->_currentRoom._roomNum))
+ _vm->_anims->play(animID);
}
/**
@@ -235,12 +240,13 @@
Common::Stack<int> stk;
mathExpressionObject obj;
GPL2Operator oper;
+ GPL2Function func;
// Read in initial math object
obj = (mathExpressionObject)reader.readUint16LE();
int value;
- int op1, op2, res;
+ int arg1, arg2, res;
while (1) {
if (obj == kMathEnd) {
@@ -263,20 +269,20 @@
case kMathOperator:
value = reader.readUint16LE();
- op1 = stk.pop();
- op2 = stk.pop();
+ arg1 = stk.pop();
+ arg2 = stk.pop();
// Fetch operator
oper = _operatorList[value-1];
// Calculate result
- res = (this->*(oper._handler))(op1, op2);
+ res = (this->*(oper._handler))(arg1, arg2);
// Push result
stk.push(res);
debugC(3, kDraciBytecodeDebugLevel, "\t\t%d %s %d (res: %d)",
- op1, oper._name.c_str(), op2, res);
+ arg1, oper._name.c_str(), arg2, res);
break;
case kMathVariable:
@@ -287,14 +293,29 @@
case kMathFunctionCall:
value = reader.readUint16LE();
-
- stk.pop();
- // FIXME: Pushing dummy value for now, but should push return value
- stk.push(0);
+ // Fetch function
+ func = _functionList[value-1];
+
+ // If not yet implemented
+ if (func._handler == NULL) {
+ stk.pop();
- debugC(3, kDraciBytecodeDebugLevel, "\t\tfunction: %s",
- functions[value-1].c_str());
+ // FIXME: Pushing dummy value for now, but should push return value
+ stk.push(0);
+
+ debugC(3, kDraciBytecodeDebugLevel, "\t\tcall: %s (not implemented)",
+ func._name.c_str());
+ } else {
+ arg1 = stk.pop();
+
+ // Calculate result
+ res = (this->*(func._handler))(arg1);
+
+ debugC(3, kDraciBytecodeDebugLevel, "\t\tcall: %s(%d) (res: %d)",
+ func._name.c_str(), arg1, res);
+ }
+
break;
}
Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.h 2009-07-06 18:15:50 UTC (rev 42187)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.h 2009-07-06 18:49:51 UTC (rev 42188)
@@ -44,6 +44,7 @@
typedef void (Script::* GPLHandler)(Common::Queue<int> &);
typedef int (Script::* GPLOperatorHandler)(int, int);
+typedef int (Script::* GPLFunctionHandler)(int);
/**
* Represents a single command in the GPL scripting language bytecode.
@@ -65,6 +66,11 @@
GPLOperatorHandler _handler;
};
+struct GPL2Function {
+ Common::String _name;
+ GPLFunctionHandler _handler;
+};
+
/**
* A convenience data type that holds both the actual bytecode and the
* length of the bytecode. Passed to Script::run().
@@ -89,6 +95,7 @@
/** List of all GPL commands. Initialised in the constructor. */
const GPL2Command *_commandList;
const GPL2Operator *_operatorList;
+ const GPL2Function *_functionList;
void load(Common::Queue<int> ¶ms);
void start(Common::Queue<int> ¶ms);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list