diff options
author | Martin Kiewitz | 2009-10-11 08:52:23 +0000 |
---|---|---|
committer | Martin Kiewitz | 2009-10-11 08:52:23 +0000 |
commit | 0b1a8dea2deaa996b7229f637c0c9795443d4301 (patch) | |
tree | 5f0d5c8b21ab7505cf382982e8b96f6ba1096284 /engines | |
parent | 67c7d49729da0aecc8d308d731e8323110afd1c5 (diff) | |
download | scummvm-rg350-0b1a8dea2deaa996b7229f637c0c9795443d4301.tar.gz scummvm-rg350-0b1a8dea2deaa996b7229f637c0c9795443d4301.tar.bz2 scummvm-rg350-0b1a8dea2deaa996b7229f637c0c9795443d4301.zip |
SCI/newgui: kShakeScreen partially implemented
svn-id: r44897
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 38 | ||||
-rw-r--r-- | engines/sci/gui/gui.cpp | 14 | ||||
-rw-r--r-- | engines/sci/gui/gui.h | 2 | ||||
-rw-r--r-- | engines/sci/gui/gui_helpers.h | 3 | ||||
-rw-r--r-- | engines/sci/gui/gui_screen.cpp | 4 | ||||
-rw-r--r-- | engines/sci/gui/gui_screen.h | 2 | ||||
-rw-r--r-- | engines/sci/gui32/gui32.cpp | 37 | ||||
-rw-r--r-- | engines/sci/gui32/gui32.h | 2 |
8 files changed, 67 insertions, 35 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index c7f7e123d7..5f3d56d250 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -1544,43 +1544,11 @@ reg_t kAnimate(EngineState *s, int argc, reg_t *argv) { return s->r_acc; } -#define SHAKE_DOWN 1 -#define SHAKE_RIGHT 2 - reg_t kShakeScreen(EngineState *s, int argc, reg_t *argv) { - int shakes = (argc > 0) ? argv[0].toSint16() : 1; - int directions = (argc > 1) ? argv[1].toSint16() : 1; - gfx_pixmap_t *screen = gfxop_grab_pixmap(s->gfx_state, gfx_rect(0, 0, 320, 200)); - int i; - - if (directions & ~3) - debugC(2, kDebugLevelGraphics, "ShakeScreen(): Direction bits are %x (unknown)\n", directions); - - gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen); - - for (i = 0; i < shakes; i++) { - int shake_down = (directions & SHAKE_DOWN) ? 10 : 0; - int shake_right = (directions & SHAKE_RIGHT) ? 10 : 0; - - if (directions & SHAKE_DOWN) - gfxop_draw_box(s->gfx_state, gfx_rect(0, 0, 320, 10), s->ega_colors[0], s->ega_colors[0], GFX_BOX_SHADE_FLAT); + int16 shakeCount = (argc > 0) ? argv[0].toUint16() : 1; + int16 directions = (argc > 1) ? argv[1].toUint16() : 1; - if (directions & SHAKE_RIGHT) - gfxop_draw_box(s->gfx_state, gfx_rect(0, 0, 10, 200), s->ega_colors[0], s->ega_colors[0], GFX_BOX_SHADE_FLAT); - - gfxop_draw_pixmap(s->gfx_state, screen, gfx_rect(0, 0, 320 - shake_right, 200 - shake_down), - Common::Point(shake_right, shake_down)); - - gfxop_update(s->gfx_state); - gfxop_sleep(s->gfx_state, 50); - - gfxop_draw_pixmap(s->gfx_state, screen, gfx_rect(0, 0, 320, 200), Common::Point(0, 0)); - gfxop_update(s->gfx_state); - gfxop_sleep(s->gfx_state, 50); - } - - gfxop_free_pixmap(s->gfx_state, screen); - gfxop_update(s->gfx_state); + s->_gui->shakeScreen(shakeCount, directions); return s->r_acc; } diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index 5cd5ee5119..914ee9ddcc 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -397,6 +397,20 @@ void SciGui::paletteAnimate(int fromColor, int toColor, int speed) { _palette->animate(fromColor, toColor, speed); } +void SciGui::shakeScreen(uint16 shakeCount, uint16 directions) { + while (shakeCount--) { + if (directions & SCI_SHAKE_DIRECTION_VERTICAL) + _screen->setVerticalShakePos(10); + // TODO: horizontal shakes + g_system->updateScreen(); + wait(3); + if (directions & SCI_SHAKE_DIRECTION_VERTICAL) + _screen->setVerticalShakePos(0); + g_system->updateScreen(); + wait(3); + } +} + uint16 SciGui::onControl(byte screenMask, Common::Rect rect) { GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind); uint16 result; diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index 246bb1d167..5f44184855 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -85,6 +85,8 @@ public: virtual void paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette); virtual void paletteAnimate(int fromColor, int toColor, int speed); + virtual void shakeScreen(uint16 shakeCount, uint16 directions); + virtual uint16 onControl(byte screenMask, Common::Rect rect); virtual void animate(reg_t listReference, bool cycle, int argc, reg_t *argv); virtual void addToPicList(reg_t listReference, int argc, reg_t *argv); diff --git a/engines/sci/gui/gui_helpers.h b/engines/sci/gui/gui_helpers.h index 294b0ebcc2..cc4ac961e6 100644 --- a/engines/sci/gui/gui_helpers.h +++ b/engines/sci/gui/gui_helpers.h @@ -32,6 +32,9 @@ namespace Sci { +#define SCI_SHAKE_DIRECTION_VERTICAL 1 +#define SCI_SHAKE_DIRECTION_HORIZONTAL 2 + typedef int GuiResourceId; // is a resource-number and -1 means no parameter given typedef reg_t GuiMemoryHandle; typedef int16 GuiViewLoopNo; diff --git a/engines/sci/gui/gui_screen.cpp b/engines/sci/gui/gui_screen.cpp index 0e0a1ed170..606ad2ef09 100644 --- a/engines/sci/gui/gui_screen.cpp +++ b/engines/sci/gui/gui_screen.cpp @@ -215,6 +215,10 @@ void SciGuiScreen::setPalette(GuiPalette*pal) { g_system->setPalette(bpal, 0, 256); } +void SciGuiScreen::setVerticalShakePos(uint16 shakePos) { + g_system->setShakePos(shakePos); +} + // Currently not really done, its supposed to be possible to only dither _visualScreen void SciGuiScreen::dither(bool addToFlag) { int y, x; diff --git a/engines/sci/gui/gui_screen.h b/engines/sci/gui/gui_screen.h index 5d46fd0f6e..daafdc31ff 100644 --- a/engines/sci/gui/gui_screen.h +++ b/engines/sci/gui/gui_screen.h @@ -60,6 +60,8 @@ public: void setPalette(GuiPalette*pal); + void setVerticalShakePos(uint16 shakePos); + void dither(bool addToFlag); void unditherSetState(bool flag); int16 *unditherGetMemorial(); diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index 1b19e67c67..4a509b00b6 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -751,6 +751,43 @@ void SciGui32::paletteAnimate(int fromColor, int toColor, int speed) { //warning("STUB"); } +#define SHAKE_DOWN 1 +#define SHAKE_RIGHT 2 + +void SciGui32::shakeScreen(uint16 shakeCount, uint16 directions) { + gfx_pixmap_t *screen = gfxop_grab_pixmap(s->gfx_state, gfx_rect(0, 0, 320, 200)); + int i; + + if (directions & ~3) + debugC(2, kDebugLevelGraphics, "ShakeScreen(): Direction bits are %x (unknown)\n", directions); + + gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen); + + for (i = 0; i < shakeCount; i++) { + int shake_down = (directions & SHAKE_DOWN) ? 10 : 0; + int shake_right = (directions & SHAKE_RIGHT) ? 10 : 0; + + if (directions & SHAKE_DOWN) + gfxop_draw_box(s->gfx_state, gfx_rect(0, 0, 320, 10), s->ega_colors[0], s->ega_colors[0], GFX_BOX_SHADE_FLAT); + + if (directions & SHAKE_RIGHT) + gfxop_draw_box(s->gfx_state, gfx_rect(0, 0, 10, 200), s->ega_colors[0], s->ega_colors[0], GFX_BOX_SHADE_FLAT); + + gfxop_draw_pixmap(s->gfx_state, screen, gfx_rect(0, 0, 320 - shake_right, 200 - shake_down), + Common::Point(shake_right, shake_down)); + + gfxop_update(s->gfx_state); + gfxop_sleep(s->gfx_state, 50); + + gfxop_draw_pixmap(s->gfx_state, screen, gfx_rect(0, 0, 320, 200), Common::Point(0, 0)); + gfxop_update(s->gfx_state); + gfxop_sleep(s->gfx_state, 50); + } + + gfxop_free_pixmap(s->gfx_state, screen); + gfxop_update(s->gfx_state); +} + uint16 SciGui32::onControl(byte screenMask, Common::Rect rect) { gfx_map_mask_t map = (gfx_map_mask_t)screenMask; rect_t gfxrect = gfx_rect(rect.left, rect.top + 10, rect.width(), rect.height()); diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h index 01e6e2d73b..2408593448 100644 --- a/engines/sci/gui32/gui32.h +++ b/engines/sci/gui32/gui32.h @@ -76,6 +76,8 @@ public: void paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette); void paletteAnimate(int fromColor, int toColor, int speed); + void shakeScreen(uint16 shakeCount, uint16 directions); + uint16 onControl(byte screenMask, Common::Rect rect); void animate(reg_t castListReference, bool cycle, int argc, reg_t *argv); void addToPicList(reg_t listReference, int argc, reg_t *argv); |