[Scummvm-cvs-logs] SF.net SVN: scummvm:[44897] scummvm/trunk/engines/sci

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sun Oct 11 10:52:24 CEST 2009


Revision: 44897
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44897&view=rev
Author:   m_kiewitz
Date:     2009-10-11 08:52:23 +0000 (Sun, 11 Oct 2009)

Log Message:
-----------
SCI/newgui: kShakeScreen partially implemented

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui.h
    scummvm/trunk/engines/sci/gui/gui_helpers.h
    scummvm/trunk/engines/sci/gui/gui_screen.cpp
    scummvm/trunk/engines/sci/gui/gui_screen.h
    scummvm/trunk/engines/sci/gui32/gui32.cpp
    scummvm/trunk/engines/sci/gui32/gui32.h

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-11 08:15:25 UTC (rev 44896)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-11 08:52:23 UTC (rev 44897)
@@ -1544,43 +1544,11 @@
 	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;
+	int16 shakeCount = (argc > 0) ? argv[0].toUint16() : 1;
+	int16 directions = (argc > 1) ? argv[1].toUint16() : 1;
 
-	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);
-
-		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;
 }
 

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-11 08:15:25 UTC (rev 44896)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-11 08:52:23 UTC (rev 44897)
@@ -397,6 +397,20 @@
 	_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;

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-11 08:15:25 UTC (rev 44896)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-11 08:52:23 UTC (rev 44897)
@@ -85,6 +85,8 @@
 	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);

Modified: scummvm/trunk/engines/sci/gui/gui_helpers.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_helpers.h	2009-10-11 08:15:25 UTC (rev 44896)
+++ scummvm/trunk/engines/sci/gui/gui_helpers.h	2009-10-11 08:52:23 UTC (rev 44897)
@@ -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;

Modified: scummvm/trunk/engines/sci/gui/gui_screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-11 08:15:25 UTC (rev 44896)
+++ scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-11 08:52:23 UTC (rev 44897)
@@ -215,6 +215,10 @@
 	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;

Modified: scummvm/trunk/engines/sci/gui/gui_screen.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-11 08:15:25 UTC (rev 44896)
+++ scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-11 08:52:23 UTC (rev 44897)
@@ -60,6 +60,8 @@
 
 	void setPalette(GuiPalette*pal);
 
+	void setVerticalShakePos(uint16 shakePos);
+
 	void dither(bool addToFlag);
 	void unditherSetState(bool flag);
 	int16 *unditherGetMemorial();

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-11 08:15:25 UTC (rev 44896)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-11 08:52:23 UTC (rev 44897)
@@ -751,6 +751,43 @@
 	//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());

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-11 08:15:25 UTC (rev 44896)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-11 08:52:23 UTC (rev 44897)
@@ -76,6 +76,8 @@
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list