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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed Oct 7 22:58:33 CEST 2009


Revision: 44756
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44756&view=rev
Author:   m_kiewitz
Date:     2009-10-07 20:58:33 +0000 (Wed, 07 Oct 2009)

Log Message:
-----------
SCI/newgui: kDrawPic cleanup, addToFlag inverse detection currently not working needs fixing

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_gfx.cpp
    scummvm/trunk/engines/sci/gui/gui_gfx.h
    scummvm/trunk/engines/sci/gui/gui_picture.cpp
    scummvm/trunk/engines/sci/gui/gui_picture.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-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-07 20:58:33 UTC (rev 44756)
@@ -906,22 +906,30 @@
 
 reg_t kDrawPic(EngineState *s, int argc, reg_t *argv) {
 	GuiResourceId pictureId = argv[0].toUint16();
-	uint16 flags = 0;
-	uint16 style = 1;
+	int16 flags = 0;
+	int16 animationNr = -1;
+	bool mirroredFlag = false;
+	bool addToFlag = false;
 	int16 EGApaletteNo = 0; // default needs to be 0
 
-	if (argc >= 2)
-		style = argv[1].toUint16();
+	if (argc >= 2) {
+		flags = argv[1].toSint16();
+		animationNr = flags & 0xFF;
+		if (flags & K_DRAWPIC_FLAG_MIRRORED)
+			mirroredFlag = true;
+	}
 	if (argc >= 3) {
-		if (!s->_kernel->usesOldGfxFunctions())
-			flags = !argv[2].toUint16();
-		else
-			flags = argv[2].toUint16();
+		// FIXME: usesOldGfxFunctions() seems to be butchered, cause sq3 has it set, but uses bit 0 correctly
+		//if (!s->_kernel->usesOldGfxFunctions())
+		//	flags = !argv[2].toUint16();
+		//else
+		if (!argv[2].isNull())
+			addToFlag = true;
 	}
 	if (argc >= 4)
 		EGApaletteNo = argv[3].toUint16();
 
-	s->gui->drawPicture(pictureId, style, flags, EGApaletteNo);
+	s->gui->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
 
 	return s->r_acc;
 }

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-07 20:58:33 UTC (rev 44756)
@@ -251,15 +251,14 @@
 	_screen->copyToScreen();
 }
 
-void SciGui::drawPicture(GuiResourceId pictureId, uint16 style, uint16 flags, int16 EGApaletteNo) {
-	bool addToFlag = flags ? true : false;
+void SciGui::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
 	GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind);
 
 	if (_windowMgr->isFrontWindow(_windowMgr->_picWind)) {
-		_gfx->drawPicture(pictureId, style, addToFlag, EGApaletteNo);
+		_gfx->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
 	} else {
 		_windowMgr->BeginUpdate(_windowMgr->_picWind);
-		_gfx->drawPicture(pictureId, style, addToFlag, EGApaletteNo);
+		_gfx->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
 		_windowMgr->EndUpdate(_windowMgr->_picWind);
 	}
 	_screen->copyToScreen();

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-07 20:58:33 UTC (rev 44756)
@@ -60,7 +60,7 @@
 	virtual void textColors(int argc, reg_t *argv);
 
 	virtual void drawStatus(const char *text, int16 colorPen, int16 colorBack);
-	virtual void drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 flags, int16 EGApaletteNo);
+	virtual void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
 	virtual void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo);
 	virtual void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
 	virtual void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite);

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-07 20:58:33 UTC (rev 44756)
@@ -994,7 +994,7 @@
 	}
 }
 
-void SciGuiGfx::drawPicture(GuiResourceId pictureId, uint16 style, bool addToFlag, GuiResourceId paletteId) {
+void SciGuiGfx::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId) {
 	SciGuiPicture *picture;
 
 	picture = new SciGuiPicture(_s, this, _screen, _palette, pictureId);
@@ -1005,7 +1005,7 @@
 		else
 			ClearScreen(15);
 	}
-	picture->draw(style, addToFlag, paletteId);
+	picture->draw(animationNr, mirroredFlag, addToFlag, paletteId);
 }
 
 void SciGuiGfx::drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo) {

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-07 20:58:33 UTC (rev 44756)
@@ -101,7 +101,7 @@
 	void Draw_String(const char *text);
 	void Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control);
 	
-	void drawPicture(GuiResourceId pictureId, uint16 style, bool addToFlag, GuiResourceId paletteId);
+	void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId);
 	void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo);
 
 	int16 onControl(uint16 screenMask, Common::Rect rect);

Modified: scummvm/trunk/engines/sci/gui/gui_picture.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_picture.cpp	2009-10-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/gui/gui_picture.cpp	2009-10-07 20:58:33 UTC (rev 44756)
@@ -53,8 +53,9 @@
 	return _resourceId;
 }
 
-void SciGuiPicture::draw(uint16 style, bool addToFlag, int16 EGApaletteNo) {
-	_style = style;
+void SciGuiPicture::draw(int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
+	_animationNr = animationNr;
+	_mirroredFlag = mirroredFlag;
 	_addToFlag = addToFlag;
 	_EGApaletteNo = EGApaletteNo;
 	_priority = 0;
@@ -518,15 +519,15 @@
 	byte byte = data[curPos++];
 	x = data[curPos++] + ((byte & 0xF0) << 4);
 	y = data[curPos++] + ((byte & 0x0F) << 8);
-	if (_style & PIC_STYLE_MIRRORED) x = 319 - x;
+	if (_mirroredFlag) x = 319 - x;
 }
 
 void SciGuiPicture::vectorGetRelCoords(byte *data, int &curPos, int16 &x, int16 &y) {
 	byte byte = data[curPos++];
 	if (byte & 0x80) {
-		x -= ((byte >> 4) & 7) * (_style & PIC_STYLE_MIRRORED ? -1 : 1);
+		x -= ((byte >> 4) & 7) * (_mirroredFlag ? -1 : 1);
 	} else {
-		x += (byte >> 4) * (_style & PIC_STYLE_MIRRORED ? -1 : 1);
+		x += (byte >> 4) * (_mirroredFlag ? -1 : 1);
 	}
 	if (byte & 0x08) {
 		y -= (byte & 7);
@@ -544,9 +545,9 @@
 	}
 	byte = data[curPos++];
 	if (byte & 0x80) {
-		x -= (128 - (byte & 0x7F)) * (_style & PIC_STYLE_MIRRORED ? -1 : 1);
+		x -= (128 - (byte & 0x7F)) * (_mirroredFlag ? -1 : 1);
 	} else {
-		x += byte * (_style & PIC_STYLE_MIRRORED ? -1 : 1);
+		x += byte * (_mirroredFlag ? -1 : 1);
 	}
 }
 
@@ -556,192 +557,4 @@
 	}
 }
 
-#if 0
-void SciGuiGfx::Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control) {
-
-void SciGuiPicture::vectorFloodFillRecursive(byte *data, int &curPos, int16 &x, int16 &y) {
-
-void FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, byte *bounds,
-	int legalcolor, int legalmask, int color, int priority, int drawenable, int sci_titlebar_size) {
-	int linewidth = pic->mode->scaleFactor * 320;
-	int miny = pic->mode->scaleFactor * sci_titlebar_size;
-	int maxy = pic->mode->scaleFactor * 200;
-	int xl, xr;
-	int oldytotal = y * linewidth;
-
-	do {
-		int ytotal = oldytotal + (linewidth * dy);
-		int xcont;
-		int state;
-
-		y += dy;
-
-		if (y < miny || y >= maxy) {
-			error("ABRT on failed initial assertion!");
-			return;
-		}
-#  define proj_xl_bound 0
-#  define proj_xr_bound 319
-
-		// Now we have the projected limits, get the real ones:
-
-		xl = (old_xl > proj_xl_bound) ? old_xl : proj_xl_bound;
-		if (!IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) { // go left as far as possible
-			while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y + 1, bounds[ytotal + xl - 1])))
-				--xl;
-		} else // go right until the fillable area starts
-			while (xl < proj_xr_bound && (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])))
-				++xl;
-
-
-		if ((xl > proj_xr_bound)
-		        || (xl > old_xr)) {
-			error("ABRT because xl > xr_bound");
-			return;
-		}
-
-		xr = (xl > old_xl) ? xl : old_xl;
-		while (xr < proj_xr_bound && (!IS_BOUNDARY(xr + 1, y + 1, bounds[ytotal + xr + 1])))
-			++xr;
-
-		PRINT_DEBUG1("%d> -> ", xr);
-
-		if (IS_BOUNDARY(xl, y + 1,  bounds[ytotal + xl])) {
-			error("ABRT because xl illegal");
-			return;
-		}
-
-		if (drawenable & GFX_MASK_VISUAL)
-			memset(pic->visual_map->index_data + ytotal + xl, color, xr - xl + 1);
-
-		if (drawenable & GFX_MASK_PRIORITY)
-			memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1);
-
-
-		// Check whether we need to recurse on branches in the same direction
-		state = 0;
-		xcont = xr + 1;
-		while (xcont <= old_xr) {
-			if (IS_BOUNDARY(xcont, y + 1, bounds[ytotal + xcont]))
-				state = xcont;
-			else if (state) { // recurse
-				vectorFloodFillRecursive(pic, state, xcont, y - dy, dy, bounds, legalcolor,
-				                        legalmask, color, priority, drawenable, sci_titlebar_size);
-				state = 0;
-			}
-			++xcont;
-		}
-
-		// Check whether we need to recurse on backward branches:
-		// left
-		if (xl < old_xl - 1) {
-			state = 0;
-			for (xcont = old_xl - 1; xcont >= xl; xcont--) {
-				if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont]))
-					state = xcont;
-				else if (state) { // recurse
-					vectorFloodFillRecursive(pic, xcont, state, y, -dy, bounds,
-					                        legalcolor, legalmask, color, priority, drawenable,
-					                        sci_titlebar_size);
-					state = 0;
-				}
-			}
-		}
-
-		// right
-		if (xr > old_xr + 1) {
-			state = 0;
-			for (xcont = old_xr + 1; xcont <= xr; xcont++) {
-				if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont]))
-					state = xcont;
-				else if (state) { // recurse
-					vectorFloodFillRecursive(pic, state, xcont, y, -dy, bounds,
-					                        legalcolor, legalmask, color, priority, drawenable,
-					                        sci_titlebar_size);
-					state = 0;
-				}
-			}
-		}
-
-		oldytotal = ytotal;
-		old_xl = xl;
-		old_xr = xr;
-
-	} while (1);
-}
-
-void SciGuiPicture::vectorFloodFillRecursive(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, int control, int drawenable,
-	int sci_titlebar_size) {
-	int linewidth = pic->mode->scaleFactor * 320;
-	int x, y;
-	int xl, xr;
-	int ytotal;
-	int bitmask;
-	byte *bounds = NULL;
-	int legalcolor, legalmask;
-	int original_drawenable = drawenable; // Backup, since we need the unmodified value
-					      // for filling the aux and control map
-
-	// Restrict drawenable not to restrict itself to zero
-	if (pic->control_map->index_data[y_200 * 320 + x_320] != 0)
-		drawenable &= ~GFX_MASK_CONTROL;
-
-	if (color == 0xff)
-		drawenable &= ~GFX_MASK_VISUAL;
-
-	if (priority == 0) {
-		drawenable &= ~GFX_MASK_PRIORITY;
-		original_drawenable &= ~GFX_MASK_PRIORITY;
-	}
-
-	AUXBUF_FILL(pic, x_320, y_200, original_drawenable, (drawenable & GFX_MASK_CONTROL) ? control : 0,
-	            sci_titlebar_size);
-
-	x = x_320;
-	y = y_200;
-
-	ytotal = y * linewidth;
-
-	if (!drawenable)
-		return;
-
-	if (drawenable & GFX_MASK_VISUAL) {
-		bounds = pic->visual_map->index_data;
-		legalmask = 0x0ff0;
-		legalcolor = 0xff;
-	} else if (drawenable & GFX_MASK_PRIORITY) {
-		bounds = pic->priority_map->index_data;
-		legalcolor = 0;
-		legalmask = 0x0f0f;
-	} else {
-		legalcolor = 0;
-		legalmask = 0x0f0f;
-	}
-
-	if (!bounds || IS_BOUNDARY(x, y, bounds[ytotal + x]))
-		return;
-
-	if (bounds) {
-		xl = x;
-		while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y, bounds[ytotal + xl -1])))
-			--xl;
-
-		while (x < proj_xr_bound && (!IS_BOUNDARY(x + 1, y, bounds[ytotal + x + 1])))
-			++x;
-		xr = x;
-
-		if (drawenable & GFX_MASK_VISUAL)
-			memset(pic->visual_map->index_data + ytotal + xl, color, xr - xl + 1);
-
-		if (drawenable & GFX_MASK_PRIORITY)
-			memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1);
-
-		vectorFloodFillRecursive(pic, xl, xr, y, -1, bounds, legalcolor, legalmask, color, priority, drawenable,
-		                        sci_titlebar_size);
-		vectorFloodFillRecursive(pic, xl, xr, y, + 1, bounds, legalcolor, legalmask, color, priority, drawenable,
-		                        sci_titlebar_size);
-	}
-}
-#endif
-
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui/gui_picture.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_picture.h	2009-10-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/gui/gui_picture.h	2009-10-07 20:58:33 UTC (rev 44756)
@@ -28,15 +28,13 @@
 
 namespace Sci {
 
-#define PIC_STYLE_MIRRORED 0x4000
-
 class SciGuiPicture {
 public:
 	SciGuiPicture(EngineState *state, SciGuiGfx *gfx, SciGuiScreen *screen, SciGuiPalette *palette, GuiResourceId resourceId);
 	~SciGuiPicture();
 
 	GuiResourceId getResourceId();
-	void draw(uint16 style, bool addToFlag, int16 EGApaletteNo);
+	void draw(int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
 
 private:
 	void initData(GuiResourceId resourceId);
@@ -59,7 +57,8 @@
 	int16 _resourceId;
 	Resource *_resource;
 
-	uint16 _style;
+	int16 _animationNr;
+	bool _mirroredFlag;
 	bool _addToFlag;
 	int16 _EGApaletteNo;
 	byte _priority;

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-07 20:58:33 UTC (rev 44756)
@@ -497,11 +497,10 @@
 	gfxop_update(s->gfx_state);
 }
 
-void SciGui32::drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 flags, int16 EGApaletteNo) {
+void SciGui32::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
 	drawn_pic_t dp;
 	gfx_color_t transparent = s->wm_port->_bgcolor;
 	int picFlags = DRAWPIC01_FLAG_FILL_NORMALLY;
-	bool add_to_pic = flags;
 
 	dp.nr = pictureId;
 	if (EGApaletteNo != -1) {
@@ -510,7 +509,7 @@
 		dp.palette = 0;
 	}
 
-	if (showStyle & K_DRAWPIC_FLAG_MIRRORED)
+	if (mirroredFlag)
 		picFlags |= DRAWPIC1_FLAG_MIRRORED;
 
 	gfxop_disable_dirty_frames(s->gfx_state);
@@ -522,7 +521,7 @@
 	s->old_screen = gfxop_grab_pixmap(s->gfx_state, gfx_rect(0, 10, 320, 190));
 
 	debugC(2, kDebugLevelGraphics, "Drawing pic.%03d\n", pictureId);
-	if (add_to_pic) {
+	if (addToFlag) {
 		gfxop_add_to_pic(s->gfx_state, dp.nr, picFlags, dp.palette);
 	} else {
 		gfxop_new_pic(s->gfx_state, dp.nr, picFlags, dp.palette);
@@ -546,7 +545,7 @@
 
 	s->pic_priority_table = gfxop_get_pic_metainfo(s->gfx_state);
 
-	s->pic_animate = showStyle & 0xff; // The animation used during kAnimate() later on
+	s->pic_animate = animationNr; // The animation used during kAnimate() later on
 
 	s->dyn_views = NULL;
 	s->drop_views = NULL;

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-07 20:38:35 UTC (rev 44755)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-07 20:58:33 UTC (rev 44756)
@@ -53,7 +53,7 @@
 	void textColors(int argc, reg_t *argv);
 
 	void drawStatus(const char *text, int16 colorPen, int16 colorBack);
-	void drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 flags, int16 EGApaletteNo);
+	void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
 	void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo);
 	void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
 	void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite);


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