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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Fri Oct 9 15:15:37 CEST 2009


Revision: 44825
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44825&view=rev
Author:   m_kiewitz
Date:     2009-10-09 13:15:37 +0000 (Fri, 09 Oct 2009)

Log Message:
-----------
SCI/newgui: support for priority bands, kCoordPri kPriCoord implemented, priority band picture support also added

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/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-09 12:28:11 UTC (rev 44824)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-09 13:15:37 UTC (rev 44825)
@@ -585,15 +585,15 @@
 }
 
 reg_t kCoordPri(EngineState *s, int argc, reg_t *argv) {
-	int y = argv[0].toSint16();
+	int16 y = argv[0].toSint16();
 
-	return make_reg(0, _find_view_priority(s, y));
+	return make_reg(0, s->_gui->coordinateToPriority(y));
 }
 
 reg_t kPriCoord(EngineState *s, int argc, reg_t *argv) {
-	int priority = argv[0].toSint16();
+	int16 priority = argv[0].toSint16();
 
-	return make_reg(0, _find_priority_band(s, priority));
+	return make_reg(0, s->_gui->priorityToCoordinate(priority));
 }
 
 void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv) {

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-09 12:28:11 UTC (rev 44824)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-09 13:15:37 UTC (rev 44825)
@@ -112,6 +112,14 @@
 	*y = *y + curPort->top;
 }
 
+int16 SciGui::coordinateToPriority(int16 y) {
+	return _gfx->CoordinateToPriority(y);
+}
+
+int16 SciGui::priorityToCoordinate(int16 priority) {
+	return _gfx->PriorityToCoordinate(priority);
+}
+
 reg_t SciGui::newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title) {
 	GuiWindow *wnd = NULL;
 

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-09 12:28:11 UTC (rev 44824)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-09 13:15:37 UTC (rev 44825)
@@ -51,6 +51,9 @@
 	virtual reg_t getPort();
 	virtual void globalToLocal(int16 *x, int16 *y);
 	virtual void localToGlobal(int16 *x, int16 *y);
+	virtual int16 coordinateToPriority(int16 y);
+	virtual int16 priorityToCoordinate(int16 priority);
+
 	virtual reg_t newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title);
 	virtual void disposeWindow(uint16 windowPtr, int16 arg2);
 

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-09 12:28:11 UTC (rev 44824)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-09 13:15:37 UTC (rev 44825)
@@ -65,6 +65,15 @@
 	SetFont(0);
 	_menuPort->rect = Common::Rect(0, 0, _screen->_width, _screen->_height);
 	_menuRect = Common::Rect(0, 0, _screen->_width, 9);
+
+	// Initialize priority bands
+	if (_s->usesOldGfxFunctions()) {
+		_priorityBandCount = 15;
+		PriorityBandsInit(42, 200);
+	} else {
+		_priorityBandCount = 14;
+		PriorityBandsInit(42, 190);
+	}
 }
 
 GuiPort *SciGuiGfx::SetPort(GuiPort *newPort) {
@@ -571,14 +580,14 @@
 }
 
 // Update (part of) screen
-void SciGuiGfx::ShowBits(const Common::Rect &r, uint16 flags) {
+void SciGuiGfx::ShowBits(const Common::Rect &r, uint16 screenMask) {
 	Common::Rect rect(r.left, r.top, r.right, r.bottom);
 	rect.clip(_curPort->rect);
 	if (rect.isEmpty()) // nothing to show
 		return;
 
 	OffsetRect(rect);
-	assert((flags&0x8000) == 0);
+	assert((screenMask & 0x8000) == 0);
 	_screen->copyToScreen();
 //	_system->copyRectToScreen(GetSegment(flags) + _baseTable[rect.top] + rect.left, 320, rect.left, rect.top, rect.width(), rect.height());
 //	_system->updateScreen();
@@ -1064,6 +1073,50 @@
 		return value;
 }
 
+void SciGuiGfx::PriorityBandsInit(int16 top, int16 bottom) {
+	double bandSize;
+	int16 y;
+
+	_priorityTop = top;
+	_priorityBottom = bottom;
+	bandSize = (_priorityBottom - _priorityTop) / _priorityBandCount;
+
+	memset(_priorityBands, 0, _priorityTop);
+	for (y = _priorityTop; y < _priorityBottom; y++)
+		_priorityBands[y] = (byte)(1 + (y - _priorityTop) / bandSize);
+}
+
+void SciGuiGfx::PriorityBandsInit(byte *data) {
+	int i = 0, inx;
+	byte priority = 0;
+
+	for (inx = 0; inx < 14; inx++) {
+		priority = *data++;
+		while (i < priority)
+			_priorityBands[i++] = inx;
+	}
+	while (i < 200)
+		_priorityBands[i++] = inx;
+}
+
+byte SciGuiGfx::CoordinateToPriority(int16 y) {
+	if (y < _priorityTop) 
+		return _priorityBands[_priorityTop];
+	if (y > _priorityBottom)
+		return _priorityBands[_priorityBottom];
+	return _priorityBands[y];
+}
+
+int16 SciGuiGfx::PriorityToCoordinate(byte priority) {
+	int16 y;
+	if (priority <= _priorityBandCount) {
+		for (y = 0; y <= _priorityBottom; y++)
+			if (_priorityBands[y] == priority)
+				return y;
+	}
+	return _priorityBottom;
+}
+
 void SciGuiGfx::AnimateDisposeLastCast() {
 	// FIXME
 	//if (!_lastCast->first.isNull())
@@ -1311,7 +1364,7 @@
 			// arr1[i] = 1;
 			if ((signal[listNr] & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
 				rect = celRect[listNr];
-				//rect.top = CLIP<int16>(PriCoord(zs[i]) - 1, rect.top, rect.bottom - 1);  
+				rect.top = CLIP<int16>(PriorityToCoordinate(z[listNr]) - 1, rect.top, rect.bottom - 1);  
 				FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
 			}
 		}
@@ -1425,7 +1478,7 @@
 	GuiViewLoopNo loopNo;
 	GuiViewCelNo celNo;
 	int16 x, y, z, priority;
-	uint16 paletteNo;
+	uint16 paletteNo, signal;
 	Common::Rect celRect;
 
 	while (curNode) {
@@ -1440,22 +1493,22 @@
 		z = GET_SEL32V(curObject, z);
 		priority = GET_SEL32V(curObject, priority);
 		if (priority == -1)
-			priority = 0; //CoordPri(y);
+			priority = CoordinateToPriority(y);
 		paletteNo = GET_SEL32V(curObject, palette);
+		signal = GET_SEL32V(curObject, signal);
 
 		// Get the corresponding view
 		view = new SciGuiView(_s->resMan, _screen, _palette, viewId);
 
 		// Create rect according to coordinates and given cel
-		view->getCelRect(loopNo, celNo, x, y, z, &celRect);
+		view->getCelRect(loopNo, celNo, x, y, priority, &celRect);
 
 		// draw corresponding cel
 		drawCel(viewId, loopNo, celNo, celRect.left, celRect.top, z, paletteNo);
-// FIXME find out what 17 is and implement this as well
-//		if ((obj.getProperty(17) & 0x4000) == 0) {
-//			rect.top = CLIP<int16>(PriCoord(prio) - 1, rect.top, rect.bottom - 1);
-//			_gfx->RFillRect(rect, 4, 0, 0, 0xF);
-//		}
+		if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
+			celRect.top = CLIP<int16>(PriorityToCoordinate(priority) - 1, celRect.top, celRect.bottom - 1);
+			FillRect(celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+		}
 
 		curAddress = curNode->succ;
 		curNode = _s->_segMan->lookupNode(curAddress);

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-09 12:28:11 UTC (rev 44824)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-09 13:15:37 UTC (rev 44825)
@@ -100,6 +100,12 @@
 	void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo);
 
 	int16 onControl(uint16 screenMask, Common::Rect rect);
+
+	void PriorityBandsInit(int16 top, int16 bottom);
+	void PriorityBandsInit(byte *data);
+	byte CoordinateToPriority(int16 y);
+	int16 PriorityToCoordinate(byte priority);
+
 	void AnimateDisposeLastCast();
 	void AnimateInvoke(List *list, int argc, reg_t *argv);
 	void AnimateFill(List *list, byte &oldPicNotValid);
@@ -144,6 +150,10 @@
 	int _textColorsCount;
 	uint16 *_textColors;
 
+	// Priority Bands related variables
+	int16 _priorityTop, _priorityBottom, _priorityBandCount;
+	byte _priorityBands[200];
+
 	// Animate* related variables
 	List *_lastCast;
 

Modified: scummvm/trunk/engines/sci/gui/gui_picture.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_picture.cpp	2009-10-09 12:28:11 UTC (rev 44824)
+++ scummvm/trunk/engines/sci/gui/gui_picture.cpp	2009-10-09 13:15:37 UTC (rev 44825)
@@ -483,15 +483,11 @@
 					curPos += size;
 					break;
 				case PIC_OPX_VGA_PRIORITY_TABLE_EQDIST:
-					//FIXME
-					//g_sci->InitPri(READ_LE_UINT16(ptr), READ_LE_UINT16(ptr + 2));
-					debug(5, "DrawPic::InitPri %d %d",
-						READ_LE_UINT16(data + curPos), READ_LE_UINT16(data + curPos + 2));
+					_gfx->PriorityBandsInit(READ_LE_UINT16(data + curPos), READ_LE_UINT16(data + curPos + 2));
 					curPos += 4;
 					break;
 				case PIC_OPX_VGA_PRIORITY_TABLE_EXPLICIT:
-					//FIXME
-					//g_sci->PriBands(ptr);
+					_gfx->PriorityBandsInit(data + curPos);
 					curPos += 14;
 					break;
 				default:

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-09 12:28:11 UTC (rev 44824)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-09 13:15:37 UTC (rev 44825)
@@ -166,6 +166,14 @@
 	*y = *y + s->port->zone.y;
 }
 
+int16 SciGui32::coordinateToPriority(int16 y) {
+	return _find_view_priority(s, y);
+}
+
+int16 SciGui32::priorityToCoordinate(int16 priority) {
+	return _find_priority_band(s, priority);
+}
+
 reg_t SciGui32::newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title) {
 	GfxPort *window;
 	int x, y, xl, yl;

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-09 12:28:11 UTC (rev 44824)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-09 13:15:37 UTC (rev 44825)
@@ -43,6 +43,9 @@
 	reg_t getPort();
 	void globalToLocal(int16 *x, int16 *y);
 	void localToGlobal(int16 *x, int16 *y);
+	int16 coordinateToPriority(int16 y);
+	int16 priorityToCoordinate(int16 priority);
+
 	reg_t newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title);
 	void disposeWindow(uint16 windowPtr, int16 arg2);
 


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