[Scummvm-cvs-logs] SF.net SVN: scummvm:[34746] scummvm/trunk/engines/made
john_doe at users.sourceforge.net
john_doe at users.sourceforge.net
Sat Oct 4 23:40:14 CEST 2008
Revision: 34746
http://scummvm.svn.sourceforge.net/scummvm/?rev=34746&view=rev
Author: john_doe
Date: 2008-10-04 21:40:14 +0000 (Sat, 04 Oct 2008)
Log Message:
-----------
- Declared all stack functions as inline
- Sleep some ms after 500 opcodes to reduce CPU load
- Fixed odd bug in LGoP2 where text disappeared quickly without waiting for user input by returning 0x38 in sfShowPage
Modified Paths:
--------------
scummvm/trunk/engines/made/script.cpp
scummvm/trunk/engines/made/scriptfuncs.cpp
Modified: scummvm/trunk/engines/made/script.cpp
===================================================================
--- scummvm/trunk/engines/made/script.cpp 2008-10-04 18:54:06 UTC (rev 34745)
+++ scummvm/trunk/engines/made/script.cpp 2008-10-04 21:40:14 UTC (rev 34746)
@@ -30,6 +30,7 @@
#include "made/script.h"
#include "made/database.h"
#include "made/scriptfuncs.h"
+#include "made/screen.h"
namespace Made {
@@ -44,47 +45,47 @@
ScriptStack::~ScriptStack() {
}
-int16 ScriptStack::top() {
+inline int16 ScriptStack::top() {
return _stack[_stackPos];
}
-int16 ScriptStack::pop() {
+inline int16 ScriptStack::pop() {
if (_stackPos == kScriptStackSize)
error("ScriptStack::pop() Stack underflow");
return _stack[_stackPos++];
}
-void ScriptStack::push(int16 value) {
+inline void ScriptStack::push(int16 value) {
if (_stackPos == 0)
error("ScriptStack::push() Stack overflow");
_stack[--_stackPos] = value;
}
-void ScriptStack::setTop(int16 value) {
+inline void ScriptStack::setTop(int16 value) {
_stack[_stackPos] = value;
}
-int16 ScriptStack::peek(int16 index) {
+inline int16 ScriptStack::peek(int16 index) {
return _stack[index];
}
-void ScriptStack::poke(int16 index, int16 value) {
+inline void ScriptStack::poke(int16 index, int16 value) {
_stack[index] = value;
}
-void ScriptStack::alloc(int16 count) {
+inline void ScriptStack::alloc(int16 count) {
_stackPos -= count;
}
-void ScriptStack::free(int16 count) {
+inline void ScriptStack::free(int16 count) {
_stackPos += count;
}
-void ScriptStack::setStackPos(int16 stackPtr) {
+inline void ScriptStack::setStackPos(int16 stackPtr) {
_stackPos = stackPtr;
}
-int16 *ScriptStack::getStackPtr() {
+inline int16 *ScriptStack::getStackPtr() {
return &_stack[_stackPos];
}
@@ -187,6 +188,9 @@
}
void ScriptInterpreter::runScript(int16 scriptObjectIndex) {
+
+ uint32 opcodeSleepCounter = 0;
+
_vm->_quit = false;
_runningScriptObjectIndex = scriptObjectIndex;
@@ -194,19 +198,27 @@
_codeBase = _vm->_dat->getObject(_runningScriptObjectIndex)->getData();
_codeIp = _codeBase;
-
+
while (!_vm->_quit) {
_vm->handleEvents();
byte opcode = readByte();
+
if (opcode >= 1 && opcode <= _commandsMax) {
debug(4, "[%04X:%04X] %s", _runningScriptObjectIndex, (uint) (_codeIp - _codeBase), _commands[opcode - 1].desc);
(this->*_commands[opcode - 1].proc)();
} else {
warning("ScriptInterpreter::runScript(%d) Unknown opcode %02X", _runningScriptObjectIndex, opcode);
}
-
+
+ /* We sleep a little after 500 opcodes to reduce the CPU load.
+ */
+ if (++opcodeSleepCounter > 500) {
+ _vm->_screen->updateScreenAndWait(5);
+ opcodeSleepCounter = 0;
+ }
+
}
}
Modified: scummvm/trunk/engines/made/scriptfuncs.cpp
===================================================================
--- scummvm/trunk/engines/made/scriptfuncs.cpp 2008-10-04 18:54:06 UTC (rev 34745)
+++ scummvm/trunk/engines/made/scriptfuncs.cpp 2008-10-04 21:40:14 UTC (rev 34746)
@@ -195,7 +195,10 @@
int16 ScriptFunctions::sfShowPage(int16 argc, int16 *argv) {
_vm->_screen->show();
- return 0;
+ // NOTE: We need to return something != 0 here or some game scripts won't
+ // work correctly. The actual meaning of this value is unknown to me.
+ // 0x38 was found out by analyzing debug output of the original engine.
+ return 0x38;
}
int16 ScriptFunctions::sfPollEvent(int16 argc, int16 *argv) {
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