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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed Oct 28 19:59:11 CET 2009


Revision: 45478
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45478&view=rev
Author:   m_kiewitz
Date:     2009-10-28 18:59:11 +0000 (Wed, 28 Oct 2009)

Log Message:
-----------
SCI/newgui: Cleanup

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

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-28 18:21:27 UTC (rev 45477)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-28 18:59:11 UTC (rev 45478)
@@ -42,29 +42,12 @@
 
 namespace Sci {
 
-// Graph subfunctions
-enum {
-	K_GRAPH_GET_COLORS_NR = 2,
-	// 3 - SET PALETTE VIA RESOURCE
-	K_GRAPH_DRAW_LINE = 4,
-	// 5 - NOP
-	// 6 - DRAW PATTERN
-	K_GRAPH_SAVE_BOX = 7,
-	K_GRAPH_RESTORE_BOX = 8,
-	K_GRAPH_FILL_BOX_BACKGROUND = 9,
-	K_GRAPH_FILL_BOX_FOREGROUND = 10,
-	K_GRAPH_FILL_BOX_ANY = 11,
-	K_GRAPH_UPDATE_BOX = 12,
-	K_GRAPH_REDRAW_BOX = 13,
-	K_GRAPH_ADJUST_PRIORITY = 14
-};
-
-void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv) {
+void _k_dirloop(reg_t object, uint16 angle, EngineState *s, int argc, reg_t *argv) {
 	SegManager *segMan = s->_segMan;
-	int view = GET_SEL32V(segMan, obj, view);
-	int signal = GET_SEL32V(segMan, obj, signal);
-	int loop;
-	int maxloops;
+	GuiResourceId viewId = GET_SEL32V(segMan, object, view);
+	uint16 signal = GET_SEL32V(segMan, object, signal);
+	int16 loopNo;
+	int16 maxLoops;
 	bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
 
 	if (signal & kSignalDoesntTurn)
@@ -74,33 +57,33 @@
 
 	if (!oldScriptHeader) {
 		if (angle < 45)
-			loop = 3;
+			loopNo = 3;
 		else if (angle < 136)
-			loop = 0;
+			loopNo = 0;
 		else if (angle < 225)
-			loop = 2;
+			loopNo = 2;
 		else if (angle < 316)
-			loop = 1;
+			loopNo = 1;
 		else
-			loop = 3;
+			loopNo = 3;
 	} else {
 		if (angle >= 330 || angle <= 30)
-			loop = 3;
+			loopNo = 3;
 		else if (angle <= 150)
-			loop = 0;
+			loopNo = 0;
 		else if (angle <= 210)
-			loop = 2;
+			loopNo = 2;
 		else if (angle < 330)
-			loop = 1;
-		else loop = 0xffff;
+			loopNo = 1;
+		else loopNo = -1;
 	}
 
-	maxloops = s->_gui->getLoopCount(view);
+	maxLoops = s->_gui->getLoopCount(viewId);
 
-	if ((loop > 1) && (maxloops < 4))
+	if ((loopNo > 1) && (maxLoops < 4))
 		return;
 
-	PUT_SEL32V(segMan, obj, loop, loop);
+	PUT_SEL32V(segMan, object, loop, loopNo);
 }
 
 static reg_t kSetCursorSci0(EngineState *s, int argc, reg_t *argv) {
@@ -200,6 +183,23 @@
 	*destRect = Common::Rect(x, y, x1, y1);
 }
 
+// Graph subfunctions
+enum {
+	K_GRAPH_GET_COLORS_NR = 2,
+	// 3 - SET PALETTE VIA RESOURCE
+	K_GRAPH_DRAW_LINE = 4,
+	// 5 - NOP
+	// 6 - DRAW PATTERN
+	K_GRAPH_SAVE_BOX = 7,
+	K_GRAPH_RESTORE_BOX = 8,
+	K_GRAPH_FILL_BOX_BACKGROUND = 9,
+	K_GRAPH_FILL_BOX_FOREGROUND = 10,
+	K_GRAPH_FILL_BOX_ANY = 11,
+	K_GRAPH_UPDATE_BOX = 12,
+	K_GRAPH_REDRAW_BOX = 13,
+	K_GRAPH_ADJUST_PRIORITY = 14
+};
+
 reg_t kGraph(EngineState *s, int argc, reg_t *argv) {
 	int16 x = 0, y = 0, x1 = 0, y1 = 0;
 	uint16 flags;
@@ -371,18 +371,19 @@
 	return make_reg(0, !canBeHere);
 }
 
+// TODO: This should go into SciGui
 reg_t kIsItSkip(EngineState *s, int argc, reg_t *argv) {
-	int view = argv[0].toSint16();
-	int loop = argv[1].toSint16();
-	int cel = argv[2].toSint16();
-	int y = argv[3].toUint16();
-	int x = argv[4].toUint16();
+	GuiResourceId viewId = argv[0].toSint16();
+	int16 loopNo = argv[1].toSint16();
+	int16 celNo = argv[2].toSint16();
+	int16 y = argv[3].toUint16();
+	int16 x = argv[4].toUint16();
 
-	SciGuiView *tmpView = new SciGuiView(s->resMan, NULL, NULL, view);
-	sciViewCelInfo *celInfo = tmpView->getCelInfo(loop, cel);
+	SciGuiView *tmpView = new SciGuiView(s->resMan, NULL, NULL, viewId);
+	sciViewCelInfo *celInfo = tmpView->getCelInfo(loopNo, celNo);
 	x = CLIP<int>(x, 0, celInfo->width - 1);
 	y = CLIP<int>(y, 0, celInfo->height - 1);
-	byte *celData = tmpView->getBitmap(loop, cel);
+	byte *celData = tmpView->getBitmap(loopNo, celNo);
 	int result = (celData[y * celInfo->width + x] == celInfo->clearKey);
 	delete tmpView;
 
@@ -390,40 +391,40 @@
 }
 
 reg_t kCelHigh(EngineState *s, int argc, reg_t *argv) {
-	int view = argv[0].toSint16();
-	int loop = argv[1].toSint16();
-	int cel = (argc >= 3) ? argv[2].toSint16() : 0;
+	GuiResourceId viewId = argv[0].toSint16();
+	int16 loopNo = argv[1].toSint16();
+	int16 celNo = (argc >= 3) ? argv[2].toSint16() : 0;
 
-	return make_reg(0, s->_gui->getCelHeight(view, loop, cel));
+	return make_reg(0, s->_gui->getCelHeight(viewId, loopNo, celNo));
 }
 
 reg_t kCelWide(EngineState *s, int argc, reg_t *argv) {
-	int view = argv[0].toSint16();
-	int loop = argv[1].toSint16();
-	int cel = (argc >= 3) ? argv[2].toSint16() : 0;
+	GuiResourceId viewId = argv[0].toSint16();
+	int16 loopNo = argv[1].toSint16();
+	int16 celNo = (argc >= 3) ? argv[2].toSint16() : 0;
 
-	return make_reg(0, s->_gui->getCelWidth(view, loop, cel));
+	return make_reg(0, s->_gui->getCelWidth(viewId, loopNo, celNo));
 }
 
 reg_t kNumLoops(EngineState *s, int argc, reg_t *argv) {
 	SegManager *segMan = s->_segMan;
-	reg_t obj = argv[0];
-	int view = GET_SEL32V(segMan, obj, view);
-	int loopCount = s->_gui->getLoopCount(view);
+	reg_t object = argv[0];
+	GuiResourceId viewId = GET_SEL32V(segMan, object, view);
+	int16 loopCount = s->_gui->getLoopCount(viewId);
 
-	debugC(2, kDebugLevelGraphics, "NumLoops(view.%d) = %d\n", view, loopCount);
+	debugC(2, kDebugLevelGraphics, "NumLoops(view.%d) = %d\n", viewId, loopCount);
 
 	return make_reg(0, loopCount);
 }
 
 reg_t kNumCels(EngineState *s, int argc, reg_t *argv) {
 	SegManager *segMan = s->_segMan;
-	reg_t obj = argv[0];
-	int view = GET_SEL32V(segMan, obj, view);
-	int loop = GET_SEL32V(segMan, obj, loop);
-	int celCount = s->_gui->getCelCount(view, loop);
+	reg_t object = argv[0];
+	GuiResourceId viewId = GET_SEL32V(segMan, object, view);
+	int16 loopNo = GET_SEL32V(segMan, object, loop);
+	int16 celCount = s->_gui->getCelCount(viewId, loopNo);
 
-	debugC(2, kDebugLevelGraphics, "NumCels(view.%d, %d) = %d\n", view, loop, celCount);
+	debugC(2, kDebugLevelGraphics, "NumCels(view.%d, %d) = %d\n", viewId, loopNo, celCount);
 
 	return make_reg(0, celCount);
 }
@@ -453,7 +454,7 @@
 
 void _k_view_list_free_backgrounds(EngineState *s, ViewObject *list, int list_nr);
 
-#define K_DRAWPIC_FLAGS_MIRRORED				(1 << 14)
+#define K_DRAWPIC_FLAGS_MIRRORED			(1 << 14)
 #define K_DRAWPIC_FLAGS_ANIMATIONBLACKOUT	(1 << 15)
 
 reg_t kDrawPic(EngineState *s, int argc, reg_t *argv) {
@@ -1034,8 +1035,7 @@
 	// (320x240 resolution, although the intro in KQ6 is 320x200).
 	// Refer to http://en.wikipedia.org/wiki/Mode_X
 
-	warning("STUB: SetVideoMode %d", argv[0].toUint16());
-
+	//warning("STUB: SetVideoMode %d", argv[0].toUint16());
 	return s->r_acc;
 }
 

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-28 18:21:27 UTC (rev 45477)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-28 18:59:11 UTC (rev 45478)
@@ -667,26 +667,26 @@
 	// FIXME!
 }
 
-int16 SciGui::getCelWidth(int view, int loop, int cel) {
-	SciGuiView *tmpView = new SciGuiView(_s->resMan, _screen, _palette, view);
-	sciViewCelInfo *celInfo = tmpView->getCelInfo(loop, cel);
-	int16 width = celInfo->width;
+int16 SciGui::getCelWidth(GuiResourceId viewId, int16 loopNo, int16 celNo) {
+	SciGuiView *tmpView = new SciGuiView(_s->resMan, _screen, _palette, viewId);
+	sciViewCelInfo *celInfo = tmpView->getCelInfo(loopNo, celNo);
+	int16 celWidth = celInfo->width;
 	delete tmpView;
 
-	return width;
+	return celWidth;
 }
 
-int16 SciGui::getCelHeight(int view, int loop, int cel) {
-	SciGuiView *tmpView = new SciGuiView(_s->resMan, _screen, _palette, view);
-	sciViewCelInfo *celInfo = tmpView->getCelInfo(loop, cel);
-	int16 height = celInfo->height;
+int16 SciGui::getCelHeight(GuiResourceId viewId, int16 loopNo, int16 celNo) {
+	SciGuiView *tmpView = new SciGuiView(_s->resMan, _screen, _palette, viewId);
+	sciViewCelInfo *celInfo = tmpView->getCelInfo(loopNo, celNo);
+	int16 celHeight = celInfo->height;
 	delete tmpView;
 
-	return height;
+	return celHeight;
 }
 
-int16 SciGui::getLoopCount(int view) {
-	SciGuiView *tmpView = new SciGuiView(_s->resMan, _screen, _palette, view);
+int16 SciGui::getLoopCount(GuiResourceId viewId) {
+	SciGuiView *tmpView = new SciGuiView(_s->resMan, _screen, _palette, viewId);
 	if (!tmpView)
 		return -1;
 
@@ -696,12 +696,12 @@
 	return loopCount;
 }
 
-int16 SciGui::getCelCount(int view, int loop) {
-	SciGuiView *tmpView = new SciGuiView(_s->resMan, _screen, _palette, view);
+int16 SciGui::getCelCount(GuiResourceId viewId, int16 loopNo) {
+	SciGuiView *tmpView = new SciGuiView(_s->resMan, _screen, _palette, viewId);
 	if (!tmpView)
 		return -1;
 
-	uint16 celCount = tmpView->getLoopInfo(loop)->celCount;
+	uint16 celCount = tmpView->getLoopInfo(loopNo)->celCount;
 	delete tmpView;
 
 	return celCount;

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-28 18:21:27 UTC (rev 45477)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-28 18:59:11 UTC (rev 45478)
@@ -124,11 +124,11 @@
 	virtual void setCursorPos(Common::Point pos);
 	virtual void moveCursor(Common::Point pos);
 
-	int16 getCelWidth(int view, int loop, int cel);
-	int16 getCelHeight(int view, int loop, int cel);
+	virtual int16 getCelWidth(GuiResourceId viewId, int16 loopNo, int16 celNo);
+	virtual int16 getCelHeight(GuiResourceId viewId, int16 loopNo, int16 celNo);
 
-	int16 getLoopCount(int view);
-	int16 getCelCount(int view, int loop);
+	virtual int16 getLoopCount(GuiResourceId viewId);
+	virtual int16 getCelCount(GuiResourceId viewId, int16 loopNo);
 
 	virtual bool debugUndither(bool flag);
 	virtual bool debugShowMap(int mapNo);
@@ -148,7 +148,6 @@
 	virtual void addToPicSetPicNotValid();
 
 	SciGuiGfx *_gfx;
-//	SciGuiresources *_resources;
 	SciGuiWindowMgr *_windowMgr;
 	SciGuiAnimate *_animate;
 	SciGuiControls *_controls;


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