[Scummvm-cvs-logs] CVS: scummvm/saga sthread.cpp,1.24,1.25

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Sun Sep 19 07:50:02 CEST 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22554

Modified Files:
	sthread.cpp 
Log Message:
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.


Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- sthread.cpp	26 Aug 2004 23:28:10 -0000	1.24
+++ sthread.cpp	19 Sep 2004 14:49:00 -0000	1.25
@@ -199,6 +199,10 @@
 		}
 	}
 
+	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 @@
 		}
 
 		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 @@
 		// 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);





More information about the Scummvm-git-logs mailing list