diff options
author | Eugene Sandulenko | 2004-08-11 22:27:39 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-08-11 22:27:39 +0000 |
commit | 94b377ce739c0640fe3f6ef70c087f7637bb73d1 (patch) | |
tree | 028f254ebae5225b7c0d045f09e21e3ddeedc249 /saga | |
parent | ee70457667b7480226b3af3bf3047e098a0344c5 (diff) | |
download | scummvm-rg350-94b377ce739c0640fe3f6ef70c087f7637bb73d1.tar.gz scummvm-rg350-94b377ce739c0640fe3f6ef70c087f7637bb73d1.tar.bz2 scummvm-rg350-94b377ce739c0640fe3f6ef70c087f7637bb73d1.zip |
Handle fades in scene load routine.
Introduce immediate events.
svn-id: r14558
Diffstat (limited to 'saga')
-rw-r--r-- | saga/events.cpp | 64 | ||||
-rw-r--r-- | saga/events.h | 4 | ||||
-rw-r--r-- | saga/ihnm_introproc.cpp | 8 | ||||
-rw-r--r-- | saga/ite_introproc.cpp | 178 | ||||
-rw-r--r-- | saga/saga.cpp | 2 | ||||
-rw-r--r-- | saga/scene.cpp | 60 | ||||
-rw-r--r-- | saga/scene.h | 10 |
7 files changed, 154 insertions, 172 deletions
diff --git a/saga/events.cpp b/saga/events.cpp index 9e8815b898..b4ce6e43d1 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -94,6 +94,10 @@ int Events::handleEvents(long msec) { result = handleInterval(event_p); break; + case R_IMMEDIATE_EVENT: + result = handleImmediate(event_p); + break; + default: result = R_EVENT_INVALIDCODE; warning("Invalid event code encountered"); @@ -218,6 +222,62 @@ int Events::handleContinuous(R_EVENT *event) { return R_EVENT_CONTINUE; } +int Events::handleImmediate(R_EVENT *event) { + double event_pc = 0.0; // Event completion percentage + bool event_done = false; + + R_SURFACE *back_buf; + + event_pc = ((double)event->duration - event->time) / event->duration; + + if (event_pc >= 1.0) { + // Cap percentage to 100 + event_pc = 1.0; + event_done = true; + } + + if (event_pc < 0.0) { + // Event not signaled, skip it + return R_EVENT_BREAK; + } else if (!(event->code & R_SIGNALED)) { + // Signal event + event->code |= R_SIGNALED; + event_pc = 0.0; + } + + switch (event->code & R_EVENT_MASK) { + case R_PAL_EVENT: + switch (event->op) { + case EVENT_BLACKTOPAL: + back_buf = _vm->_gfx->getBackBuffer(); + _vm->_gfx->blackToPal(back_buf, (PALENTRY *)event->data, event_pc); + break; + + case EVENT_PALTOBLACK: + back_buf = _vm->_gfx->getBackBuffer(); + _vm->_gfx->palToBlack(back_buf, (PALENTRY *)event->data, event_pc); + break; + default: + break; + } + break; + case R_BG_EVENT: + case R_INTERFACE_EVENT: + handleOneShot(event); + event_done = true; + break; + default: + break; + + } + + if (event_done) { + return R_EVENT_DELETE; + } + + return R_EVENT_BREAK; +} + int Events::handleOneShot(R_EVENT *event) { R_SURFACE *back_buf; @@ -388,6 +448,7 @@ int Events::initializeEvent(R_EVENT *event) { case R_ONESHOT_EVENT: break; case R_CONTINUOUS_EVENT: + case R_IMMEDIATE_EVENT: event->time += event->duration; break; case R_INTERVAL_EVENT: @@ -462,6 +523,9 @@ int Events::processEventTime(long msec) { event_p->time -= msec; event_count++; + if (event_p->type == R_IMMEDIATE_EVENT) + break; + if (event_count > R_EVENT_WARNINGCOUNT) { warning("Event list exceeds %u", R_EVENT_WARNINGCOUNT); } diff --git a/saga/events.h b/saga/events.h index 06cc3095fe..0c5d21a087 100644 --- a/saga/events.h +++ b/saga/events.h @@ -30,7 +30,8 @@ namespace Saga { enum R_EVENT_TYPES { R_ONESHOT_EVENT, R_CONTINUOUS_EVENT, - R_INTERVAL_EVENT + R_INTERVAL_EVENT, + R_IMMEDIATE_EVENT }; enum R_EVENT_FLAGS { @@ -132,6 +133,7 @@ class Events { int handleContinuous(R_EVENT * event); int handleOneShot(R_EVENT * event); int handleInterval(R_EVENT * event); + int handleImmediate(R_EVENT *event); int processEventTime(long msec); int initializeEvent(R_EVENT * event); diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp index 79f179b7a2..63ebd8dd08 100644 --- a/saga/ihnm_introproc.cpp +++ b/saga/ihnm_introproc.cpp @@ -87,10 +87,10 @@ R_SCENE_DESC IHNM_IntroMovie4Desc = { }; R_SCENE_QUEUE IHNM_IntroList[] = { - {0, &IHNM_IntroMovie1Desc, BY_DESC, IHNM_IntroMovieProc1, 0} , - {0, &IHNM_IntroMovie2Desc, BY_DESC, IHNM_IntroMovieProc2, 0} , - {0, &IHNM_IntroMovie3Desc, BY_DESC, IHNM_IntroMovieProc3, 0} , - {0, &IHNM_IntroMovie4Desc, BY_DESC, IHNM_HateProc, 0} + {0, &IHNM_IntroMovie1Desc, BY_DESC, IHNM_IntroMovieProc1, 0, SCENE_NOFADE}, + {0, &IHNM_IntroMovie2Desc, BY_DESC, IHNM_IntroMovieProc2, 0, SCENE_NOFADE}, + {0, &IHNM_IntroMovie3Desc, BY_DESC, IHNM_IntroMovieProc3, 0, SCENE_NOFADE}, + {0, &IHNM_IntroMovie4Desc, BY_DESC, IHNM_HateProc, 0, SCENE_NOFADE} }; int IHNM_StartProc() { diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index 84c5c665c8..ab95beb659 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -53,7 +53,6 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info); int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO *scene_info); int ITE_IntroFairePathProc(int param, R_SCENE_INFO *scene_info); int ITE_IntroFaireTentProc(int param, R_SCENE_INFO *scene_info); -int initialScene(int param, R_SCENE_INFO *scene_info); static R_INTRO_DIALOGUE IntroDiag[] = { { @@ -124,15 +123,15 @@ static R_INTRO_DIALOGUE IntroDiag[] = { }; R_SCENE_QUEUE ITE_IntroList[] = { - {ITE_INTRO_ANIM_SCENE, NULL, BY_RESOURCE, ITE_IntroAnimProc, 0}, - {ITE_CAVE_SCENE_1, NULL, BY_RESOURCE, ITE_IntroCave1Proc, 0}, - {ITE_CAVE_SCENE_2, NULL, BY_RESOURCE, ITE_IntroCave2Proc, 0}, - {ITE_CAVE_SCENE_3, NULL, BY_RESOURCE, ITE_IntroCave3Proc, 0}, - {ITE_CAVE_SCENE_4, NULL, BY_RESOURCE, ITE_IntroCave4Proc, 0}, - {ITE_VALLEY_SCENE, NULL, BY_RESOURCE, ITE_IntroValleyProc, 0}, - {ITE_TREEHOUSE_SCENE, NULL, BY_RESOURCE, ITE_IntroTreeHouseProc, 0}, - {ITE_FAIREPATH_SCENE, NULL, BY_RESOURCE, ITE_IntroFairePathProc, 0}, - {ITE_FAIRETENT_SCENE, NULL, BY_RESOURCE, ITE_IntroFaireTentProc, 0} + {ITE_INTRO_ANIM_SCENE, NULL, BY_RESOURCE, ITE_IntroAnimProc, 0, SCENE_NOFADE}, + {ITE_CAVE_SCENE_1, NULL, BY_RESOURCE, ITE_IntroCave1Proc, 0, SCENE_FADE_NO_INTERFACE}, + {ITE_CAVE_SCENE_2, NULL, BY_RESOURCE, ITE_IntroCave2Proc, 0, SCENE_NOFADE}, + {ITE_CAVE_SCENE_3, NULL, BY_RESOURCE, ITE_IntroCave3Proc, 0, SCENE_NOFADE}, + {ITE_CAVE_SCENE_4, NULL, BY_RESOURCE, ITE_IntroCave4Proc, 0, SCENE_NOFADE}, + {ITE_VALLEY_SCENE, NULL, BY_RESOURCE, ITE_IntroValleyProc, 0, SCENE_FADE_NO_INTERFACE}, + {ITE_TREEHOUSE_SCENE, NULL, BY_RESOURCE, ITE_IntroTreeHouseProc, 0, SCENE_NOFADE}, + {ITE_FAIREPATH_SCENE, NULL, BY_RESOURCE, ITE_IntroFairePathProc, 0, SCENE_NOFADE}, + {ITE_FAIRETENT_SCENE, NULL, BY_RESOURCE, ITE_IntroFaireTentProc, 0, SCENE_NOFADE} }; int ITE_StartProc() { @@ -153,7 +152,8 @@ int ITE_StartProc() { first_scene.load_flag = BY_SCENE; first_scene.scene_n = gs_desc.first_scene; first_scene.scene_skiptarget = 1; - first_scene.scene_proc = initialScene; + first_scene.scene_proc = NULL; + first_scene.fadeType = SCENE_FADE; _vm->_scene->queueScene(&first_scene); @@ -242,49 +242,18 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { int voice_pad = 50; R_TEXTLIST_ENTRY text_entry; R_TEXTLIST_ENTRY *entry_p; - PALENTRY *pal; - static PALENTRY current_pal[R_PAL_ENTRIES]; int i; int font_flags = FONT_OUTLINE | FONT_CENTERED; switch (param) { case SCENE_BEGIN: - // Fade to black out of the intro DG/NWC logo animation - _vm->_gfx->getCurrentPal(current_pal); - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; - event.op = EVENT_PALTOBLACK; - event.time = 0; - event.duration = PALETTE_FADE_DURATION; - event.data = current_pal; - q_event = _vm->_events->queue(&event); - - // Display scene background, but stay with black palette - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; - event.op = EVENT_DISPLAY; - event.param = NO_SET_PALETTE; - event.time = 0; - q_event = _vm->_events->chain(q_event, &event); - - // Fade in from black to the scene background palette - _vm->_scene->getBGPal(&pal); - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; - event.op = EVENT_BLACKTOPAL; - event.time = 0; - event.duration = PALETTE_FADE_DURATION; - event.data = pal; - - q_event = _vm->_events->chain(q_event, &event); - // Begin palette cycling animation for candles event.type = R_ONESHOT_EVENT; event.code = R_PALANIM_EVENT; event.op = EVENT_CYCLESTART; event.time = 0; - q_event = _vm->_events->chain(q_event, &event); + q_event = _vm->_events->queue(&event); // Queue narrator dialogue list text_entry.color = 255; @@ -648,8 +617,6 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { R_TEXTLIST_ENTRY *entry_p; R_EVENT event; R_EVENT *q_event; - PALENTRY *pal; - static PALENTRY current_pal[R_PAL_ENTRIES]; int i; const INTRO_CREDIT credits[] = { @@ -672,38 +639,6 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { switch (param) { case SCENE_BEGIN: - - // Fade to black out of the cave - _vm->_gfx->getCurrentPal(current_pal); - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; - event.op = EVENT_PALTOBLACK; - event.time = 0; - event.duration = PALETTE_FADE_DURATION; - event.data = current_pal; - - q_event = _vm->_events->queue(&event); - - // Display ITE title screen background - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; - event.op = EVENT_DISPLAY; - event.param = NO_SET_PALETTE; - event.time = 0; - - q_event = _vm->_events->chain(q_event, &event); - - // Fade in from black to the scene background palette - _vm->_scene->getBGPal(&pal); - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; - event.op = EVENT_BLACKTOPAL; - event.time = 0; - event.duration = PALETTE_FADE_DURATION; - event.data = pal; - - q_event = _vm->_events->chain(q_event, &event); - debug(0, "Beginning animation playback."); // Begin title screen background animation @@ -719,7 +654,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_PLAY; event.time = 0; - q_event = _vm->_events->chain(q_event, &event); + q_event = _vm->_events->queue(&event); // Pause animation before logo event.type = R_ONESHOT_EVENT; @@ -729,13 +664,13 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.param2 = ANIM_PAUSE; event.time = 3000; - q_event = _vm->_events->queue(&event); + q_event = _vm->_events->chain(q_event, &event); // Display logo event.type = R_CONTINUOUS_EVENT; event.code = R_TRANSITION_EVENT; event.op = EVENT_DISSOLVE_BGMASK; - event.time = 3000; + event.time = 0; event.duration = LOGO_DISSOLVE_DURATION; q_event = _vm->_events->chain(q_event, &event); @@ -744,7 +679,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.type = R_CONTINUOUS_EVENT; event.code = R_TRANSITION_EVENT; event.op = EVENT_DISSOLVE; - event.time = 3000; + event.time = 1000; event.duration = LOGO_DISSOLVE_DURATION; q_event = _vm->_events->chain(q_event, &event); @@ -755,7 +690,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_CLEARFLAG; event.param = 0; event.param2 = ANIM_PAUSE; - event.time = 3000 + LOGO_DISSOLVE_DURATION; + event.time = 0; q_event = _vm->_events->chain(q_event, &event); @@ -763,7 +698,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.code = R_ANIM_EVENT; event.op = EVENT_FRAME; event.param = 0; - event.time = 3000 + LOGO_DISSOLVE_DURATION; + event.time = LOGO_DISSOLVE_DURATION; q_event = _vm->_events->chain(q_event, &event); @@ -1067,81 +1002,4 @@ int ITE_IntroFaireTentProc(int param, R_SCENE_INFO *scene_info) { return 0; } -int initialScene(int param, R_SCENE_INFO *scene_info) { - R_EVENT event; - R_EVENT *q_event; - int delay_time = 0; - static PALENTRY current_pal[R_PAL_ENTRIES]; - PALENTRY *pal; - - switch (param) { - case SCENE_BEGIN: - _vm->_music->stop(); - _vm->_sound->stopVoice(); - - // Fade palette to black from intro scene - _vm->_gfx->getCurrentPal(current_pal); - - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; - event.op = EVENT_PALTOBLACK; - event.time = 0; - event.duration = PALETTE_FADE_DURATION; - event.data = current_pal; - - delay_time += PALETTE_FADE_DURATION; - - q_event = _vm->_events->queue(&event); - - // Activate user interface - event.type = R_ONESHOT_EVENT; - event.code = R_INTERFACE_EVENT; - event.op = EVENT_ACTIVATE; - event.time = 0; - - q_event = _vm->_events->chain(q_event, &event); - - // Set first scene background w/o changing palette - event.type = R_ONESHOT_EVENT; - event.code = R_BG_EVENT; - event.op = EVENT_DISPLAY; - event.param = NO_SET_PALETTE; - event.time = 0; - - q_event = _vm->_events->chain(q_event, &event); - - // Fade in to first scene background palette - _vm->_scene->getBGPal(&pal); - - event.type = R_CONTINUOUS_EVENT; - event.code = R_PAL_EVENT; - event.op = EVENT_BLACKTOPAL; - event.time = delay_time; - event.duration = PALETTE_FADE_DURATION; - event.data = pal; - - q_event = _vm->_events->chain(q_event, &event); - - event.code = R_PALANIM_EVENT; - event.op = EVENT_CYCLESTART; - event.time = 0; - - q_event = _vm->_events->chain(q_event, &event); - - _vm->_anim->setFlag(0, ANIM_LOOP); - _vm->_anim->play(0, delay_time); - - debug(0, "Scene started"); - break; - case SCENE_END: - break; - default: - warning("Scene::initialScene(): Illegal scene procedure parameter"); - break; - } - - return 0; -} - - } // End of namespace Saga diff --git a/saga/saga.cpp b/saga/saga.cpp index e6a9af6ea6..a8987af35c 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -233,7 +233,7 @@ void SagaEngine::go() { } // Per frame processing _render->drawScene(); - _system->delay_msecs(0); + _system->delay_msecs(10); } } diff --git a/saga/scene.cpp b/saga/scene.cpp index 0218a2fb01..d77a2938ba 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -205,7 +205,7 @@ int Scene::startScene() { scene_qdat = (R_SCENE_QUEUE *)ys_dll_get_data(node); assert(scene_qdat != NULL); - loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc); + loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc, scene_qdat->fadeType); return R_SUCCESS; } @@ -245,7 +245,7 @@ int Scene::nextScene() { scene_qdat = (R_SCENE_QUEUE *)ys_dll_get_data(node); assert(scene_qdat != NULL); - loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc); + loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc, scene_qdat->fadeType); return R_SUCCESS; } @@ -295,7 +295,7 @@ int Scene::skipScene() { ys_dll_delete(node); } endScene(); - loadScene(skip_qdat->scene_n, skip_qdat->load_flag, skip_qdat->scene_proc, skip_qdat->scene_desc); + loadScene(skip_qdat->scene_n, skip_qdat->load_flag, skip_qdat->scene_proc, skip_qdat->scene_desc, skip_qdat->fadeType); } // Search for a scene to skip to @@ -321,7 +321,7 @@ int Scene::changeScene(int scene_num) { } endScene(); - loadScene(scene_num, BY_SCENE, defaultScene, NULL); + loadScene(scene_num, BY_SCENE, defaultScene, NULL, false); return R_SUCCESS; } @@ -408,7 +408,7 @@ int Scene::getInfo(R_SCENE_INFO *si) { return R_SUCCESS; } -int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *scene_desc_param) { +int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *scene_desc_param, int fadeType) { R_SCENE_INFO scene_info; uint32 res_number = 0; int result; @@ -494,6 +494,51 @@ int Scene::loadScene(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SC _sceneLoaded = true; + if (fadeType == SCENE_FADE || fadeType == SCENE_FADE_NO_INTERFACE) { + R_EVENT event; + R_EVENT *q_event; + static PALENTRY current_pal[R_PAL_ENTRIES]; + + // Fade to black out + _vm->_gfx->getCurrentPal(current_pal); + event.type = R_IMMEDIATE_EVENT; + event.code = R_PAL_EVENT; + event.op = EVENT_PALTOBLACK; + event.time = 0; + event.duration = PALETTE_FADE_DURATION; + event.data = current_pal; + q_event = _vm->_events->queue(&event); + + if (fadeType != SCENE_FADE_NO_INTERFACE) { + // Activate user interface + event.type = R_IMMEDIATE_EVENT; + event.code = R_INTERFACE_EVENT; + event.op = EVENT_ACTIVATE; + event.time = 0; + event.duration = 0; + q_event = _vm->_events->chain(q_event, &event); + } + + // Display scene background, but stay with black palette + event.type = R_IMMEDIATE_EVENT; + event.code = R_BG_EVENT; + event.op = EVENT_DISPLAY; + event.param = NO_SET_PALETTE; + event.time = 0; + event.duration = 0; + q_event = _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; + event.op = EVENT_BLACKTOPAL; + event.time = 0; + event.duration = PALETTE_FADE_DURATION; + event.data = _bg.pal; + + q_event = _vm->_events->chain(q_event, &event); + } + if (scene_proc == NULL) { _sceneProc = defaultScene; } else { @@ -872,6 +917,9 @@ int defaultScene(int param, R_SCENE_INFO *scene_info) { switch (param) { case SCENE_BEGIN: + _vm->_music->stop(); + _vm->_sound->stopVoice(); + // Set scene background event.type = R_ONESHOT_EVENT; event.code = R_BG_EVENT; @@ -896,6 +944,8 @@ int defaultScene(int param, R_SCENE_INFO *scene_info) { event.time = 0; _vm->_events->queue(&event); + + debug(0, "Scene started"); break; case SCENE_END: break; diff --git a/saga/scene.h b/saga/scene.h index 895ee88206..6fa1fa118e 100644 --- a/saga/scene.h +++ b/saga/scene.h @@ -134,12 +134,19 @@ struct SCENE_ANIMINFO { SCENE_ANIMINFO *next; }; +enum SCENE_FADE_TYPES { + SCENE_NOFADE = 0, + SCENE_FADE = 1, + SCENE_FADE_NO_INTERFACE = 2 +}; + struct R_SCENE_QUEUE { uint32 scene_n; R_SCENE_DESC *scene_desc; int load_flag; R_SCENE_PROC *scene_proc; int scene_skiptarget; + int fadeType; }; class Scene { @@ -171,7 +178,8 @@ class Scene { void sceneChangeCmd(int argc, char *argv[]); private: - int loadScene(int scene, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *); + int loadScene(int scene, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *, + int fadeIn); int loadSceneDescriptor(uint32 res_number); int loadSceneResourceList(uint32 res_number); int processSceneResources(); |