diff options
Diffstat (limited to 'saga')
-rw-r--r-- | saga/console.cpp | 1 | ||||
-rw-r--r-- | saga/scene.cpp | 10 | ||||
-rw-r--r-- | saga/script_mod.h | 1 | ||||
-rw-r--r-- | saga/sthread.cpp | 9 | ||||
-rw-r--r-- | saga/sthread.h | 2 | ||||
-rw-r--r-- | saga/xref.txt | 5 |
6 files changed, 26 insertions, 2 deletions
diff --git a/saga/console.cpp b/saga/console.cpp index bb7af21bdb..0a98db90c6 100644 --- a/saga/console.cpp +++ b/saga/console.cpp @@ -245,6 +245,7 @@ int Console::print(const char *fmt_str, ...) { va_start(argptr, fmt_str); ret_val = vsprintf(vsstr_p, fmt_str, argptr); _vm->_console->addLine(&_scrollback, _lineMax, vsstr_p); + debug(0, vsstr_p); va_end(argptr); _linePos = 0; diff --git a/saga/scene.cpp b/saga/scene.cpp index f2ee344099..35cfa99066 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -949,7 +949,17 @@ int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) { _vm->_anim->play(0, 0); if (_desc.startScriptNum > 0) { + R_SCRIPT_THREAD *_startScriptThread; + debug(0, "Starting start script #%d", _desc.startScriptNum); + + _startScriptThread= STHREAD_Create(); + if (_startScriptThread == NULL) { + _vm->_console->print("Thread creation failed."); + break; + } + STHREAD_Execute(_startScriptThread, _desc.startScriptNum); + STHREAD_completeThread(); } debug(0, "Scene started"); diff --git a/saga/script_mod.h b/saga/script_mod.h index 6dfb53116a..8a7e907c50 100644 --- a/saga/script_mod.h +++ b/saga/script_mod.h @@ -49,6 +49,7 @@ int STHREAD_ExecThreads(int msec); int STHREAD_HoldSem(R_SEMAPHORE *sem); int STHREAD_ReleaseSem(R_SEMAPHORE *sem); int STHREAD_DebugStep(); +void STHREAD_completeThread(void); } // End of namespace Saga diff --git a/saga/sthread.cpp b/saga/sthread.cpp index 5de0d81a06..3eaeca0113 100644 --- a/saga/sthread.cpp +++ b/saga/sthread.cpp @@ -95,6 +95,11 @@ int STHREAD_ExecThreads(int msec) { return R_SUCCESS; } +void STHREAD_completeThread(void) { + for (int i = 0; i < 40 && (ys_dll_head(_vm->_script->threadList()) != NULL); i++) + STHREAD_ExecThreads(0); +} + int STHREAD_SetEntrypoint(R_SCRIPT_THREAD *thread, int ep_num) { R_SCRIPT_BYTECODE *bytecode; int max_entrypoint; @@ -218,11 +223,13 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { } saved_offset = thread->i_offset; - debug(2, "Executing thread offset: %lu", thread->i_offset); + MemoryReadStream readS(GetReadPtr(thread), GetReadLen(thread)); in_char = readS.readByte(); + debug(0, "Executing thread offset: %lu (%x)", thread->i_offset, in_char); + switch (in_char) { // Align (ALGN) case 0x01: diff --git a/saga/sthread.h b/saga/sthread.h index c3ef69b120..06e201e490 100644 --- a/saga/sthread.h +++ b/saga/sthread.h @@ -30,7 +30,7 @@ namespace Saga { -#define STHREAD_DEF_INSTR_COUNT 7 +#define STHREAD_DEF_INSTR_COUNT 8 struct R_SEMAPHORE { int hold_count; diff --git a/saga/xref.txt b/saga/xref.txt index eb81a22904..71c5c432b1 100644 --- a/saga/xref.txt +++ b/saga/xref.txt @@ -46,3 +46,8 @@ Scene.c resInfo->entryScript _desc.sceneScriptNum resInfo->preScript _desc.startScriptNum resInfo->backgroundMusic _desc.musicRN + +Interp.c +======== + dispatchThreads() STHREAD_ExecThreads() + runThread() STHREAD_completeThread() |