diff options
author | Torbjörn Andersson | 2004-10-16 07:46:52 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2004-10-16 07:46:52 +0000 |
commit | cebce0f5361cc58a4b6c232d042d2daebb2b4088 (patch) | |
tree | 743b49b6db138d9506f3367dd3df1412f6e1c78b /saga | |
parent | 4840c16c1b40146ce4268e3599f6ab3115b51ce4 (diff) | |
download | scummvm-rg350-cebce0f5361cc58a4b6c232d042d2daebb2b4088.tar.gz scummvm-rg350-cebce0f5361cc58a4b6c232d042d2daebb2b4088.tar.bz2 scummvm-rg350-cebce0f5361cc58a4b6c232d042d2daebb2b4088.zip |
Introduced script events to fix the "actors appear before fade-out" bug.
There are some minor music-related changes here as well, but that's just
cleanup.
svn-id: r15567
Diffstat (limited to 'saga')
-rw-r--r-- | saga/events.cpp | 26 | ||||
-rw-r--r-- | saga/events.h | 9 | ||||
-rw-r--r-- | saga/scene.cpp | 89 |
3 files changed, 75 insertions, 49 deletions
diff --git a/saga/events.cpp b/saga/events.cpp index 4bf1c354d3..99cd2e5f9f 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -261,6 +261,7 @@ int Events::handleImmediate(R_EVENT *event) { break; } break; + case R_SCRIPT_EVENT: case R_BG_EVENT: case R_INTERFACE_EVENT: handleOneShot(event); @@ -280,6 +281,7 @@ int Events::handleImmediate(R_EVENT *event) { int Events::handleOneShot(R_EVENT *event) { R_SURFACE *back_buf; + R_SCRIPT_THREAD *sthread; static SCENE_BGINFO bginfo; @@ -311,7 +313,9 @@ int Events::handleOneShot(R_EVENT *event) { _vm->_sndRes->playVoice(event->param); break; case R_MUSIC_EVENT: - _vm->_music->play(event->param, event->param2); + _vm->_music->stop(); + if (event->op == EVENT_PLAY) + _vm->_music->play(event->param, event->param2); break; case R_BG_EVENT: { @@ -384,6 +388,26 @@ int Events::handleOneShot(R_EVENT *event) { break; } break; + case R_SCRIPT_EVENT: + debug(0, "Starting start script #%d", event->param); + + sthread = _vm->_script->SThreadCreate(); + if (sthread == NULL) { + _vm->_console->print("Thread creation failed."); + break; + } + + sthread->threadVars[kVarAction] = TO_LE_16(event->param2); + sthread->threadVars[kVarObject] = TO_LE_16(event->param3); + sthread->threadVars[kVarWithObject] = TO_LE_16(event->param4); + sthread->threadVars[kVarActor] = TO_LE_16(event->param5); + + _vm->_script->SThreadExecute(sthread, event->param); + + if (event->op == EVENT_BLOCKING) + _vm->_script->SThreadCompleteThread(); + + break; default: break; } diff --git a/saga/events.h b/saga/events.h index 0c5d21a087..85d46329f9 100644 --- a/saga/events.h +++ b/saga/events.h @@ -52,7 +52,8 @@ enum R_EVENT_CODES { R_TRANSITION_EVENT, R_INTERFACE_EVENT, R_CONSOLE_EVENT, - R_ACTOR_EVENT + R_ACTOR_EVENT, + R_SCRIPT_EVENT }; enum R_EVENT_OPS { @@ -79,6 +80,9 @@ enum R_EVENT_OPS { EVENT_DEACTIVATE, // ACTOR events EVENT_MOVE = 1, + // SCRIPT events + EVENT_BLOCKING = 1, + EVENT_NONBLOCKING = 2, // CONTINUOUS events // PALETTE events @@ -100,6 +104,9 @@ struct R_EVENT { int op; // Event operation long param; // Optional event parameter long param2; + long param3; + long param4; + long param5; void *data; // Optional event data long time; // Elapsed time until event long duration; // Duration of event diff --git a/saga/scene.cpp b/saga/scene.cpp index 2bf0ccd110..e104b8e7f4 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -530,6 +530,21 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC event.duration = 0; q_event = _vm->_events->chain(q_event, &event); + // Start the scene pre script, but stay with black palette + if (_desc.startScriptNum > 0) { + event.type = R_ONESHOT_EVENT; + event.code = R_SCRIPT_EVENT; + event.op = EVENT_BLOCKING; + event.time = 0; + event.param = _desc.startScriptNum; + event.param2 = 0; // Action + event.param3 = _sceneNumber; // Object + event.param4 = 0; // With Object - TODO: should be 'entrance' + event.param5 = 0; // Actor + + _vm->_events->chain(q_event, &event); + } + // Fade in from black to the scene background palette event.type = R_IMMEDIATE_EVENT; event.code = R_PAL_EVENT; @@ -946,9 +961,26 @@ int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) { switch (param) { case SCENE_BEGIN: - _vm->_music->stop(); _vm->_sound->stopVoice(); + if (_desc.musicRN >= 0) { + event.type = R_ONESHOT_EVENT; + event.code = R_MUSIC_EVENT; + event.param = _desc.musicRN; + event.param2 = R_MUSIC_DEFAULT; + event.op = EVENT_PLAY; + event.time = 0; + + _vm->_events->queue(&event); + } else { + event.type = R_ONESHOT_EVENT; + event.code = R_MUSIC_EVENT; + event.op = EVENT_STOP; + event.time = 0; + + _vm->_events->queue(&event); + } + // Set scene background event.type = R_ONESHOT_EVENT; event.code = R_BG_EVENT; @@ -978,56 +1010,19 @@ int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) { _vm->_anim->setFlag(0, ANIM_LOOP); _vm->_anim->play(0, 0); - // Start scene scripts - if (_desc.startScriptNum > 0) { - R_SCRIPT_THREAD *_startScriptThread; - - debug(0, "Starting start script #%d", _desc.startScriptNum); - - _startScriptThread = _vm->_script->SThreadCreate(); - if (_startScriptThread == NULL) { - _vm->_console->print("Thread creation failed."); - break; - } - - _startScriptThread->threadVars[kVarAction] = 0; - _startScriptThread->threadVars[kVarObject] = TO_LE_16(_sceneNumber); - _startScriptThread->threadVars[kVarWithObject] = 0; // TOTO: entrance - _startScriptThread->threadVars[kVarActor] = 0; - - _vm->_script->SThreadExecute(_startScriptThread, _desc.startScriptNum); - _vm->_script->SThreadCompleteThread(); - } - - if (_desc.musicRN >= 0) { + // Start the scene main script + if (_desc.sceneScriptNum > 0) { event.type = R_ONESHOT_EVENT; - event.code = R_MUSIC_EVENT; - event.param = _desc.musicRN; - event.param2 = R_MUSIC_DEFAULT; - event.op = EVENT_PLAY; + event.code = R_SCRIPT_EVENT; + event.op = EVENT_NONBLOCKING; event.time = 0; + event.param = _desc.sceneScriptNum; + event.param2 = 0; // Action + event.param3 = _sceneNumber; // Object + event.param4 = 0; // With Object - TODO: should be 'entrance' + event.param5 = 0; // Actor - TODO: should be VERB_ENTER _vm->_events->queue(&event); - } else - _vm->_music->stop(); - - if (_desc.sceneScriptNum > 0) { - R_SCRIPT_THREAD *_sceneScriptThread; - - debug(0, "Starting scene script #%d", _desc.sceneScriptNum); - - _sceneScriptThread = _vm->_script->SThreadCreate(); - if (_sceneScriptThread == NULL) { - _vm->_console->print("Thread creation failed."); - break; - } - - _sceneScriptThread->threadVars[kVarAction] = 0; - _sceneScriptThread->threadVars[kVarObject] = TO_LE_16(_sceneNumber); - _sceneScriptThread->threadVars[kVarWithObject] = 0; // TODO: entrance - _sceneScriptThread->threadVars[kVarActor] = 0; // TODO: VERB_ENTER - - _vm->_script->SThreadExecute(_sceneScriptThread, _desc.sceneScriptNum); } debug(0, "Scene started"); |