aboutsummaryrefslogtreecommitdiff
path: root/saga/sthread.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-09-19 14:49:00 +0000
committerTorbjörn Andersson2004-09-19 14:49:00 +0000
commitc1671bdbca90ee590f2fbc1641c5f90d5762db38 (patch)
tree3bced54c90ff09736bf7facf743b4a1b80f2eb3f /saga/sthread.cpp
parent9ec7b57f9bf4ace710bb8136650eef48bc282f61 (diff)
downloadscummvm-rg350-c1671bdbca90ee590f2fbc1641c5f90d5762db38.tar.gz
scummvm-rg350-c1671bdbca90ee590f2fbc1641c5f90d5762db38.tar.bz2
scummvm-rg350-c1671bdbca90ee590f2fbc1641c5f90d5762db38.zip
Update the script's program counter in a more sane way. The opening script
runs for much longer now, but - unsurprisingly - it doesn't work yet. svn-id: r15192
Diffstat (limited to 'saga/sthread.cpp')
-rw-r--r--saga/sthread.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index 7469d47a53..623640a922 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -199,6 +199,10 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
}
}
+ MemoryReadStream scriptS(currentScript()->bytecode->bytecode_p, currentScript()->bytecode->bytecode_len);
+
+ scriptS.seek(thread->i_offset);
+
for (instr_count = 0; instr_count < instr_limit; instr_count++) {
if ((!thread->executing) || (thread->sem.hold_count)) {
break;
@@ -214,9 +218,6 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
}
saved_offset = thread->i_offset;
-
- MemoryReadStream scriptS(SThreadGetReadPtr(thread), SThreadGetReadLen(thread));
-
in_char = scriptS.readByte();
debug(0, "Executing thread offset: %lu (%x)", thread->i_offset, in_char);
@@ -752,6 +753,8 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
// Set instruction offset only if a previous instruction didn't branch
if (saved_offset == thread->i_offset) {
thread->i_offset = scriptS.pos();
+ } else {
+ scriptS.seek(thread->i_offset);
}
if (unhandled) {
_vm->_console->print(S_ERROR_PREFIX "%X: Unhandled opcode.\n", thread->i_offset);