aboutsummaryrefslogtreecommitdiff
path: root/engines/prince
diff options
context:
space:
mode:
authorKamil Zbróg2013-11-02 02:02:53 +0000
committerKamil Zbróg2013-11-02 02:02:53 +0000
commit9250a6f6f8804fec74704ea9e01bdb6d8af7d0ed (patch)
treee626cba7ef9b5089349ec128177acc25eec40df2 /engines/prince
parentcb31768e3df03b7ed0f5740ee7c46e8987a54154 (diff)
downloadscummvm-rg350-9250a6f6f8804fec74704ea9e01bdb6d8af7d0ed.tar.gz
scummvm-rg350-9250a6f6f8804fec74704ea9e01bdb6d8af7d0ed.tar.bz2
scummvm-rg350-9250a6f6f8804fec74704ea9e01bdb6d8af7d0ed.zip
PRINCE: More intro cleanup
Diffstat (limited to 'engines/prince')
-rw-r--r--engines/prince/prince.cpp10
-rw-r--r--engines/prince/script.cpp40
-rw-r--r--engines/prince/script.h1
3 files changed, 36 insertions, 15 deletions
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 98bf4b7178..5910ca5e35 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -495,6 +495,8 @@ void PrinceEngine::mainLoop() {
//CursorMan.showMouse(true);
while (!shouldQuit()) {
+ uint32 currentTime = _system->getMillis();
+
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
@@ -524,9 +526,13 @@ void PrinceEngine::mainLoop() {
_script->step();
drawScreen();
-
- _system->delayMillis(10);
+ // Calculate the frame delay based off a desired frame time
+ int delay = 1000/15 - int32(_system->getMillis() - currentTime);
+ // Ensure non-negative
+ delay = delay < 0 ? 0 : delay;
+ _system->delayMillis(delay);
+
_cameraX = _newCameraX;
}
}
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 5e2b095b65..b3fdf3536d 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -36,7 +36,8 @@ namespace Prince {
static const uint16 NUM_OPCODES = 144;
Script::Script(PrinceEngine *vm) :
- _code(NULL), _stacktop(0), _vm(vm), _opcodeNF(false) {
+ _code(NULL), _stacktop(0), _vm(vm), _opcodeNF(false),
+ _waitFlag(0) {
}
Script::~Script() {
@@ -59,15 +60,17 @@ bool Script::loadFromStream(Common::SeekableReadStream &stream) {
void Script::debugScript(const char *s, ...) {
char buf[STRINGBUFLEN];
- va_list va;
+ va_list va;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
Common::String str = Common::String::format("@0x%04X: ", _lastInstruction);
- str += Common::String::format("op %02d: ", _lastOpcode);
- debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
+ str += Common::String::format("op %04d: ", _lastOpcode);
+ //debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
+
+ debug("PrinceEngine::Script %s %s", str.c_str(), buf);
}
void Script::step() {
@@ -86,7 +89,7 @@ void Script::step() {
error("Trying to execute unknown opcode %s", dstr.c_str());
- debugScript("%s", dstr.c_str());
+ debugScript("");
// Execute the current opcode
OpcodeFunc op = _opcodes[_lastOpcode];
@@ -246,8 +249,21 @@ void Script::O__WAIT() {
debugScript("O__WAIT pause %d", pause);
- _opcodeNF = 1;
-
+ if (_waitFlag == 0) {
+ // set new wait flag value and continue
+ _waitFlag = pause;
+ _opcodeNF = 1;
+ _currentInstruction -= 4;
+ return;
+ }
+
+ --_waitFlag;
+
+ if (_waitFlag > 0) {
+ _opcodeNF = 1;
+ _currentInstruction -= 4;
+ return;
+ }
}
void Script::O_UPDATEOFF() {
@@ -331,8 +347,8 @@ void Script::O_COMPARE() {
value = val;
}
- debugScript("O_COMPARE flagId 0x%04X (%s), value %d ?= %d", flagId, Flags::getFlagName(flagId), value, _flags[flagId - 0x8000]);
- _result = (_flags[flagId - 0x8000] == value);
+ _result = !(_flags[flagId - 0x8000] == value);
+ debugScript("O_COMPARE flagId 0x%04X (%s), value %d == %d (%d)", flagId, Flags::getFlagName(flagId), value, _flags[flagId - 0x8000], _result);
}
void Script::O_JUMPZ() {
@@ -550,7 +566,6 @@ void Script::O_WAITTEXT() {
if (slot & 0x8000) {
slot = _flags[slot - 0x8000];
}
- //debugScript("O_WAITTEXT slot %d", slot);
Text &text = _vm->_textSlots[slot];
if (text._time) {
_opcodeNF = 1;
@@ -582,7 +597,7 @@ void Script::O_GETCHAR() {
debugScript("O_GETCHAR %04X (%s) %02x", flagId, Flags::getFlagName(flagId), _flags[flagId - 0x8000]);
- _string++;
+ ++_string;
}
void Script::O_SETDFLAG() {}
@@ -603,7 +618,6 @@ void Script::O_PRINTAT() {
++_string;
}
++_string;
- debug("O_PRINTAT %x", *_string);
}
void Script::O_ZOOMIN() {}
@@ -723,7 +737,7 @@ void Script::O_SETBACKANIMDATA() {
void Script::O_VIEWFLC() {
uint16 animNr = readScript16bits();
- debugScript("O_VIEWFLC animNr %d", animNr);
+ debug("O_VIEWFLC animNr %d", animNr);
_vm->loadAnim(animNr, false);
}
diff --git a/engines/prince/script.h b/engines/prince/script.h
index 68b44cb1e3..de8db0bfb5 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -59,6 +59,7 @@ private:
uint32 _stack[_STACK_SIZE];
uint8 _stacktop;
uint8 _savedStacktop;
+ uint32 _waitFlag;
const byte * _string;
uint32 _currentString;