diff options
-rw-r--r-- | saga/gfx.cpp | 26 | ||||
-rw-r--r-- | saga/gfx.h | 2 | ||||
-rw-r--r-- | saga/render.cpp | 30 | ||||
-rw-r--r-- | saga/render.h | 5 | ||||
-rw-r--r-- | saga/sfuncs.cpp | 51 |
5 files changed, 98 insertions, 16 deletions
diff --git a/saga/gfx.cpp b/saga/gfx.cpp index 17d3117817..7f5f7319df 100644 --- a/saga/gfx.cpp +++ b/saga/gfx.cpp @@ -986,6 +986,32 @@ int Gfx::blackToPal(SURFACE *surface, PALENTRY *src_pal, double percent) { return SUCCESS; } +void Gfx::palToBlackWait(SURFACE *surface, PALENTRY *src_pal, int duration) { + uint32 start_time = _vm->_system->getMillis(); + uint32 cur_time; + + do { + cur_time = _vm->_system->getMillis(); + + palToBlack(surface, src_pal, (double) (cur_time - start_time) / duration); + _vm->_system->updateScreen(); + _vm->_system->delayMillis(50); + } while (cur_time < start_time + duration); +} + +void Gfx::blackToPalWait(SURFACE *surface, PALENTRY *src_pal, int duration) { + uint32 start_time = _vm->_system->getMillis(); + uint32 cur_time; + + do { + cur_time = _vm->_system->getMillis(); + + blackToPal(surface, src_pal, (double) (cur_time - start_time) / duration); + _vm->_system->updateScreen(); + _vm->_system->delayMillis(50); + } while (cur_time < start_time + duration); +} + void Gfx::showCursor(bool state) { updateCursor(); g_system->showMouse(state); diff --git a/saga/gfx.h b/saga/gfx.h index 25a054ddd8..ba5607189b 100644 --- a/saga/gfx.h +++ b/saga/gfx.h @@ -107,6 +107,8 @@ public: int getCurrentPal(PALENTRY *src_pal); int palToBlack(SURFACE *surface, PALENTRY *src_pal, double percent); int blackToPal(SURFACE *surface, PALENTRY *src_pal, double percent); + void palToBlackWait(SURFACE *surface, PALENTRY *src_pal, int duration); + void blackToPalWait(SURFACE *surface, PALENTRY *src_pal, int duration); void updateCursor() { setCursor(getWhite()); } void showCursor(bool state); diff --git a/saga/render.cpp b/saga/render.cpp index bf71d71ef4..63956c6a3d 100644 --- a/saga/render.cpp +++ b/saga/render.cpp @@ -122,20 +122,22 @@ int Render::drawScene() { bg_pt.x = 0; bg_pt.y = 0; - // Display scene background - _vm->_scene->draw(backbuf_surface); - - // Display scene maps, if applicable - if (getFlags() & RF_OBJECTMAP_TEST) { - if (_vm->_scene->_objectMap) - _vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, _vm->_gfx->getWhite(), _vm->_gfx->getBlack()); - if (_vm->_scene->_actionMap) - _vm->_scene->_actionMap->draw(backbuf_surface, _vm->_gfx->matchColor(RGB_RED)); + if (!(_flags & RF_PLACARD)) { + // Display scene background + _vm->_scene->draw(backbuf_surface); + + // Display scene maps, if applicable + if (getFlags() & RF_OBJECTMAP_TEST) { + if (_vm->_scene->_objectMap) + _vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, _vm->_gfx->getWhite(), _vm->_gfx->getBlack()); + if (_vm->_scene->_actionMap) + _vm->_scene->_actionMap->draw(backbuf_surface, _vm->_gfx->matchColor(RGB_RED)); + } + + // Draw queued actors + _vm->_actor->drawActors(); } - // Draw queued actors - _vm->_actor->drawActors(); - // Draw queued text strings _vm->_scene->getInfo(&scene_info); @@ -211,6 +213,10 @@ void Render::setFlag(unsigned int flag) { _flags |= flag; } +void Render::clearFlag(unsigned int flag) { + _flags &= ~flag; +} + void Render::toggleFlag(unsigned int flag) { _flags ^= flag; } diff --git a/saga/render.h b/saga/render.h index 8d58eba292..e0b20118b6 100644 --- a/saga/render.h +++ b/saga/render.h @@ -37,7 +37,8 @@ enum RENDER_FLAGS { RF_TEXT_TEST = 0x04, RF_OBJECTMAP_TEST = 0x08, RF_RENDERPAUSE = 0x10, - RF_GAMEPAUSE = 0x20 + RF_GAMEPAUSE = 0x20, + RF_PLACARD = 0x40 }; struct BUFFER_INFO { @@ -57,6 +58,7 @@ public: int drawScene(void); unsigned int getFlags(void); void setFlag(unsigned int); + void clearFlag(unsigned int); void toggleFlag(unsigned int); unsigned int getFrameCount(void); unsigned int resetFrameCount(void); @@ -85,7 +87,6 @@ private: unsigned int _fps; unsigned int _framecount; unsigned int _flags; - int _mode; }; } // End of namespace Saga diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp index 500742acc3..bdbad2a562 100644 --- a/saga/sfuncs.cpp +++ b/saga/sfuncs.cpp @@ -29,9 +29,11 @@ #include "saga/actor.h" #include "saga/animation.h" #include "saga/console.h" +#include "saga/font.h" #include "saga/interface.h" #include "saga/music.h" #include "saga/objectdata.h" +#include "saga/render.h" #include "saga/sound.h" #include "saga/sndres.h" @@ -920,13 +922,58 @@ int Script::SF_simulSpeech2(SCRIPTFUNC_PARAMS) { // Script function #48 (0x30) int Script::SF_placard(SCRIPTFUNC_PARAMS) { - debug(1, "stub: SF_placard()"); + GAME_DISPLAYINFO disp_info; + SURFACE *back_buf = _vm->_gfx->getBackBuffer(); + PALENTRY cur_pal[PAL_ENTRIES]; + PALENTRY *pal; + + _vm->getDisplayInfo(&disp_info); + + _vm->_gfx->showCursor(false); + _vm->_gfx->getCurrentPal(cur_pal); + _vm->_gfx->palToBlackWait(back_buf, cur_pal, PALETTE_FADE_DURATION); + + _vm->_interface->setStatusText(""); + + Rect rect(disp_info.logical_w, disp_info.scene_h); + drawRect(back_buf, &rect, 138); + + // TODO: Draw the text at the correct spot. This is (probably) just a + // close approximation. + _vm->textDraw(MEDIUM_FONT_ID, back_buf, getString(thread->pop()), + disp_info.logical_w / 2, disp_info.scene_h / 2, + _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), + FONT_OUTLINE | FONT_CENTERED); + + _vm->_render->setFlag(RF_PLACARD); + _vm->_render->drawScene(); + + _vm->_scene->getBGPal(&pal); + _vm->_gfx->blackToPalWait(back_buf, pal, PALETTE_FADE_DURATION); + return SUCCESS; } // Script function #49 (0x31) int Script::SF_placardOff(SCRIPTFUNC_PARAMS) { - debug(1, "stub: SF_placardOff()"); + SURFACE *back_buf = _vm->_gfx->getBackBuffer(); + PALENTRY cur_pal[PAL_ENTRIES]; + PALENTRY *pal; + + // Fade down + _vm->_gfx->showCursor(false); + _vm->_gfx->getCurrentPal(cur_pal); + _vm->_gfx->palToBlackWait(back_buf, cur_pal, PALETTE_FADE_DURATION); + + _vm->_render->clearFlag(RF_PLACARD); + _vm->_render->drawScene(); + + // Fade up + _vm->_scene->getBGPal(&pal); + + _vm->_gfx->showCursor(true); + _vm->_gfx->blackToPalWait(back_buf, pal, PALETTE_FADE_DURATION); + return SUCCESS; } |