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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed Jan 6 14:05:15 CET 2010


Revision: 47075
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47075&view=rev
Author:   m_kiewitz
Date:     2010-01-06 13:05:14 +0000 (Wed, 06 Jan 2010)

Log Message:
-----------
SCI: making most of the variables in screen class private (some of it was needed for old gui)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel32.cpp
    scummvm/trunk/engines/sci/graphics/cursor.cpp
    scummvm/trunk/engines/sci/graphics/font.cpp
    scummvm/trunk/engines/sci/graphics/gfx.cpp
    scummvm/trunk/engines/sci/graphics/gui.cpp
    scummvm/trunk/engines/sci/graphics/gui.h
    scummvm/trunk/engines/sci/graphics/menu.cpp
    scummvm/trunk/engines/sci/graphics/picture.cpp
    scummvm/trunk/engines/sci/graphics/screen.h
    scummvm/trunk/engines/sci/graphics/transitions.cpp
    scummvm/trunk/engines/sci/graphics/windowmgr.cpp

Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -646,31 +646,7 @@
 
 reg_t kUpdateScreenItem(EngineState *s, int argc, reg_t *argv) {
 	reg_t viewObj = argv[0];
-	uint16 viewId = GET_SEL32V(s->_segMan, viewObj, view);
-	uint16 loopNo = GET_SEL32V(s->_segMan, viewObj, loop);
-	uint16 celNo = GET_SEL32V(s->_segMan, viewObj, cel);
-	uint16 leftPos = GET_SEL32V(s->_segMan, viewObj, x);
-	uint16 topPos = GET_SEL32V(s->_segMan, viewObj, y);
-	int16 priority = GET_SEL32V(s->_segMan, viewObj, priority);
-	//int16 control = 0;
-	
-	// Theoretically, leftPos and topPos should be sane
-	// Apparently, sometimes they're not, therefore I'm adding some sanity checks here so that 
-	// the hack underneath does not try and draw cels outside the screen coordinates
-	if (leftPos >= s->_gui->getScreenWidth()) {
-		warning("kUpdateScreenItem: invalid left position (%d), resetting to 0", leftPos);
-		leftPos = 0;
-	}
 
-	if (topPos >= s->_gui->getScreenHeight()) {
-		warning("kUpdateScreenItem: invalid top position (%d), resetting to 0", topPos);
-		topPos = 0;
-	}
-
-	// HACK: just draw the view on screen
-	if (viewId != 0xffff)
-		s->_gui->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0);
-
 	//warning("kUpdateScreenItem, object %04x:%04x, view %d, loop %d, cel %d, pri %d", PRINT_REG(viewObj), viewId, loopNo, celNo, priority);
 	return NULL_REG;
 }

Modified: scummvm/trunk/engines/sci/graphics/cursor.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/cursor.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/cursor.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -41,8 +41,8 @@
 
 	_upscaledHires = _screen->getUpscaledHires();
 	// center mouse cursor
-	setPosition(Common::Point(_screen->_displayWidth / 2, _screen->_displayHeight / 2));
-	setMoveZone(Common::Rect(0, 0, _screen->_displayWidth, _screen->_displayHeight));
+	setPosition(Common::Point(_screen->getDisplayWidth() / 2, _screen->getDisplayHeight() / 2));
+	setMoveZone(Common::Rect(0, 0, _screen->getDisplayWidth(), _screen->getDisplayHeight()));
 
 	_isVisible = true;
 }
@@ -109,7 +109,7 @@
 
 	// Now find out what colors we are supposed to use
 	colorMapping[0] = 0; // Black is hardcoded
-	colorMapping[1] = _screen->_colorWhite; // White is also hardcoded
+	colorMapping[1] = _screen->getColorWhite(); // White is also hardcoded
 	colorMapping[2] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR;
 	colorMapping[3] = _palette->matchColor(&_palette->_sysPalette, 170, 170, 170); // Grey
 	

Modified: scummvm/trunk/engines/sci/graphics/font.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/font.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/font.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -79,8 +79,8 @@
 }
 
 void Font::draw(Screen *screen, int16 chr, int16 top, int16 left, byte color, bool greyedOutput) {
-	int charWidth = MIN<int>(getCharWidth(chr), screen->_width - left);
-	int charHeight = MIN<int>(getCharHeight(chr), 200 - top);
+	int charWidth = MIN<int>(getCharWidth(chr), screen->getWidth() - left);
+	int charHeight = MIN<int>(getCharHeight(chr), screen->getHeight() - top);
 	byte b = 0, mask = 0xFF;
 	int y = top;
 

Modified: scummvm/trunk/engines/sci/graphics/gfx.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gfx.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/gfx.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -64,8 +64,8 @@
 	_menuPort = new Port(0xFFFF);
 	OpenPort(_menuPort);
 	_text->SetFont(0);
-	_menuPort->rect = Common::Rect(0, 0, _screen->_width, _screen->_height);
-	_menuBarRect = Common::Rect(0, 0, _screen->_width, 9);
+	_menuPort->rect = Common::Rect(0, 0, _screen->getWidth(), _screen->getHeight());
+	_menuBarRect = Common::Rect(0, 0, _screen->getWidth(), 9);
 }
 
 void Gfx::purgeCache() {
@@ -322,7 +322,7 @@
 
 	// do we add to a picture? if not -> clear screen with white
 	if (!addToFlag)
-		ClearScreen(_screen->_colorWhite);
+		ClearScreen(_screen->getColorWhite());
 
 	picture->draw(animationNr, mirroredFlag, addToFlag, paletteId);
 	delete picture;
@@ -426,7 +426,7 @@
 			_priorityBands[y]--;
 	}
 	// We fill space that is left over with the highest band
-	for (y = _priorityBottom; y < _screen->_height; y++)
+	for (y = _priorityBottom; y < _screen->getHeight(); y++)
 		_priorityBands[y] = _priorityBandCount;
 }
 

Modified: scummvm/trunk/engines/sci/graphics/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -254,7 +254,7 @@
 	_text->Size(rect, text, -1, width);
 	rect.moveTo(_gfx->GetPort()->curLeft, _gfx->GetPort()->curTop);
 	if (getSciVersion() >= SCI_VERSION_1_LATE) {
-		_gfx->Move(rect.right <= _screen->_width ? 0 : _screen->_width - rect.right, rect.bottom <= _screen->_height ? 0 : _screen->_width - rect.bottom);
+		_gfx->Move(rect.right <= _screen->getWidth() ? 0 : _screen->getWidth() - rect.right, rect.bottom <= _screen->getHeight() ? 0 : _screen->getWidth() - rect.bottom);
 		rect.moveTo(_gfx->GetPort()->curLeft, _gfx->GetPort()->curTop);
 	}
 
@@ -775,7 +775,7 @@
 	pos.y = CLIP<int16>(pos.y, _windowMgr->_picWind->rect.top, _windowMgr->_picWind->rect.bottom - 1);
 	pos.x = CLIP<int16>(pos.x, _windowMgr->_picWind->rect.left, _windowMgr->_picWind->rect.right - 1);
 
-	if (pos.x > _screen->_width || pos.y > _screen->_height) {
+	if (pos.x > _screen->getWidth() || pos.y > _screen->getHeight()) {
 		warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x);
 		return;
 	}
@@ -817,14 +817,6 @@
 void SciGui::portraitUnload(uint16 portraitId) {
 }
 
-uint16 SciGui::getScreenWidth() {
-	return _screen->_displayWidth;
-}
-
-uint16 SciGui::getScreenHeight() {
-	return _screen->_displayHeight;
-}
-
 #ifdef ENABLE_SCI32
 void SciGui::addScreenItem(reg_t object) {
 	_screenItems.push_back(object);
@@ -895,12 +887,12 @@
 				// Theoretically, leftPos and topPos should be sane
 				// Apparently, sometimes they're not, therefore I'm adding some sanity checks here so that 
 				// the hack underneath does not try and draw cels outside the screen coordinates
-				if (leftPos >= getScreenWidth()) {
+				if (leftPos >= _screen->getWidth()) {
 					warning("kAddScreenItem: invalid left position (%d), resetting to 0", leftPos);
 					leftPos = 0;
 				}
 	
-				if (topPos >= getScreenHeight()) {
+				if (topPos >= _screen->getHeight()) {
 					warning("kAddScreenItem: invalid top position (%d), resetting to 0", topPos);
 					topPos = 0;
 				}

Modified: scummvm/trunk/engines/sci/graphics/gui.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.h	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/gui.h	2010-01-06 13:05:14 UTC (rev 47075)
@@ -149,9 +149,6 @@
 	virtual void portraitShow(Common::String resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
 	virtual void portraitUnload(uint16 portraitId);
 
-	virtual uint16 getScreenWidth();
-	virtual uint16 getScreenHeight();
-
 #ifdef ENABLE_SCI32
 	// SCI32
 	virtual void addScreenItem(reg_t object);

Modified: scummvm/trunk/engines/sci/graphics/menu.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/menu.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/menu.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -285,7 +285,7 @@
 	GuiMenuList::iterator listEnd = _list.end();
 
 	// Hardcoded black on white
-	_gfx->FillRect(_gfx->_menuBarRect, 1, _screen->_colorWhite);
+	_gfx->FillRect(_gfx->_menuBarRect, 1, _screen->getColorWhite());
 	_gfx->PenColor(0);
 	_gfx->MoveTo(8, 1);
 
@@ -503,7 +503,7 @@
 	// Do the drawing
 	_gfx->FillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, 0);
 	_menuRect.left++; _menuRect.right--; _menuRect.bottom--;
-	_gfx->FillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, _screen->_colorWhite);
+	_gfx->FillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, _screen->getColorWhite());
 
 	_menuRect.left += 8;
 	topPos = _menuRect.top + 1;
@@ -564,7 +564,7 @@
 	_barSaveHandle = _gfx->BitsSave(_gfx->_menuBarRect, SCI_SCREEN_MASK_VISUAL);
 
 	_gfx->PenColor(0);
-	_gfx->BackColor(_screen->_colorWhite);
+	_gfx->BackColor(_screen->getColorWhite());
 
 	drawBar();
 	drawMenu(0, curItemEntry->menuId);

Modified: scummvm/trunk/engines/sci/graphics/picture.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/picture.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/picture.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -81,8 +81,8 @@
 
 void SciGuiPicture::reset() {
 	int16 x, y;
-	for (y = _gfx->GetPort()->top; y < _screen->_height; y++) {
-		for (x = 0; x < _screen->_width; x++) {
+	for (y = _gfx->GetPort()->top; y < _screen->getHeight(); y++) {
+		for (x = 0; x < _screen->getWidth(); x++) {
 			_screen->putPixel(x, y, SCI_SCREEN_MASK_ALL, 255, 0, 0);
 		}
 	}
@@ -273,7 +273,7 @@
 	//  SCI1.1 games use color 0 as transparency and SCI1 games use color 255 as transparency. Sierra SCI seems to paint
 	//  the whole data to screen and wont skip over transparent pixels. So this will actually make it work like Sierra
 	if (!_addToFlag)
-		clearColor = _screen->_colorWhite;
+		clearColor = _screen->getColorWhite();
 
 	ptr = celBitmap;
 	if (!_mirroredFlag) {
@@ -367,7 +367,7 @@
 
 void SciGuiPicture::drawVectorData(byte *data, int dataSize) {
 	byte pic_op;
-	byte pic_color = _screen->_colorDefaultVectorData;
+	byte pic_color = _screen->getColorDefaultVectorData();
 	byte pic_priority = 255, pic_control = 255;
 	int16 x = 0, y = 0, oldx, oldy;
 	byte EGApalettes[PIC_EGAPALETTE_TOTALSIZE] = {0};
@@ -671,7 +671,7 @@
 
 	// This logic was taken directly from sierra sci, floodfill will get aborted on various occations
 	if (screenMask & SCI_SCREEN_MASK_VISUAL) {
-		if ((color == _screen->_colorWhite) || (searchColor != _screen->_colorWhite))
+		if ((color == _screen->getColorWhite()) || (searchColor != _screen->getColorWhite()))
 			return;
 	} else if (screenMask & SCI_SCREEN_MASK_PRIORITY) {
 		if ((priority == 0) || (searchPriority != 0))
@@ -957,7 +957,7 @@
 	rect.top = y; rect.left = x;
 	rect.setHeight((size*2)+1); rect.setWidth((size*2)+2);
 	_gfx->OffsetRect(rect);
-	rect.clip(_screen->_width, _screen->_height);
+	rect.clip(_screen->getWidth(), _screen->getHeight());
 
 	if (code & SCI_PATTERN_CODE_RECTANGLE) {
 		// Rectangle

Modified: scummvm/trunk/engines/sci/graphics/screen.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/screen.h	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/screen.h	2010-01-06 13:05:14 UTC (rev 47075)
@@ -46,6 +46,13 @@
 	Screen(ResourceManager *resMan, int16 width = 320, int16 height = 200, bool upscaledHires = false);
 	~Screen();
 
+	uint16 getWidth() { return _width; };
+	uint16 getHeight() { return _height; };
+	uint16 getDisplayWidth() { return _displayWidth; };
+	uint16 getDisplayHeight() { return _displayHeight; };
+	byte getColorWhite() { return _colorWhite; };
+	byte getColorDefaultVectorData() { return _colorDefaultVectorData; };
+
 	void copyToScreen();
 	void copyFromScreen(byte *buffer);
 	void copyRectToScreen(const Common::Rect &rect);
@@ -83,6 +90,10 @@
 
 	void debugShowMap(int mapNo);
 
+	int _picNotValid; // possible values 0, 1 and 2
+	int _picNotValidSci11; // another variable that is used by kPicNotValid in sci1.1
+
+private:
 	uint16 _width;
 	uint16 _height;
 	uint _pixels;
@@ -90,13 +101,9 @@
 	uint16 _displayHeight;
 	uint _displayPixels;
 
-	int _picNotValid; // possible values 0, 1 and 2
-	int _picNotValidSci11; // another variable that is used by kPicNotValid in sci1.1
-
 	byte _colorWhite;
 	byte _colorDefaultVectorData;
 
-private:
 	void bitsRestoreScreen(Common::Rect rect, byte *&memoryPtr, byte *screen);
 	void bitsRestoreDisplayScreen(Common::Rect rect, byte *&memoryPtr);
 	void bitsSaveScreen(Common::Rect rect, byte *screen, byte *&memoryPtr);
@@ -105,7 +112,6 @@
 	bool _unditherState;
 	int16 _unditherMemorial[SCI_SCREEN_UNDITHERMEMORIAL_SIZE];
 
-public:	// HACK. TODO: make private
 	// these screens have the real resolution of the game engine (320x200 for SCI0/SCI1/SCI11 games, 640x480 for SCI2 games)
 	//  SCI0 games will be dithered in here at any time
 	byte *_visualScreen;
@@ -115,7 +121,7 @@
 	// this screen is the one that is actually displayed to the user. It may be 640x480 for japanese SCI1 games
 	//  SCI0 games may be undithered in here. Only read from this buffer for Save/ShowBits usage.
 	byte *_displayScreen;
-private:
+
 	Common::Rect getScaledRect(Common::Rect rect);
 
 	ResourceManager *_resMan;

Modified: scummvm/trunk/engines/sci/graphics/transitions.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/transitions.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/transitions.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -102,7 +102,7 @@
 };
 
 void Transitions::init() {
-	_oldScreen = new byte[_screen->_displayHeight * _screen->_displayWidth];
+	_oldScreen = new byte[_screen->getDisplayHeight() * _screen->getDisplayWidth()];
 
 	if (getSciVersion() >= SCI_VERSION_1_LATE)
 		_translationTable = NULL;
@@ -170,7 +170,7 @@
 	// Now we do the actual transition to the new screen
 	doTransition(_number, false);
 
-	if (picRect.bottom != _screen->_height) {
+	if (picRect.bottom != _screen->getHeight()) {
 		// TODO: this is a workaround for lsl6 not showing menubar when playing
 		//  There is some new code in the sierra sci in ShowPic that seems to do something similar to this
 		_screen->copyToScreen();
@@ -305,10 +305,10 @@
 
 	do {
 		mask = (mask & 1) ? (mask >> 1) ^ 0xB400 : mask >> 1;
-		if (mask >= _screen->_width * _screen->_height)
+		if (mask >= _screen->getWidth() * _screen->getHeight())
 			continue;
-		pixelRect.left = mask % _screen->_width; pixelRect.right = pixelRect.left + 1;
-		pixelRect.top = mask / _screen->_width;	pixelRect.bottom = pixelRect.top + 1;
+		pixelRect.left = mask % _screen->getWidth(); pixelRect.right = pixelRect.left + 1;
+		pixelRect.top = mask / _screen->getWidth();	pixelRect.bottom = pixelRect.top + 1;
 		pixelRect.clip(_picRect);
 		if (!pixelRect.isEmpty())
 			copyRectToScreen(pixelRect, blackoutFlag);
@@ -403,7 +403,7 @@
 	Common::Rect newScreenRect = _picRect;
 
 	_screen->copyFromScreen(_oldScreen);
-	screenWidth = _screen->_displayWidth; screenHeight = _screen->_displayHeight;
+	screenWidth = _screen->getDisplayWidth(); screenHeight = _screen->getDisplayHeight();
 
 	oldScreenPtr = _oldScreen + _picRect.left + _picRect.top * screenWidth;
 

Modified: scummvm/trunk/engines/sci/graphics/windowmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/windowmgr.cpp	2010-01-06 12:55:51 UTC (rev 47074)
+++ scummvm/trunk/engines/sci/graphics/windowmgr.cpp	2010-01-06 13:05:14 UTC (rev 47075)
@@ -71,14 +71,14 @@
 	_gfx->OpenPort(_wmgrPort);
 	_gfx->SetPort(_wmgrPort);
 	_gfx->SetOrigin(0, offTop);
-	_wmgrPort->rect.bottom = _screen->_height - offTop;
-	_wmgrPort->rect.right = _screen->_width;
+	_wmgrPort->rect.bottom = _screen->getHeight() - offTop;
+	_wmgrPort->rect.right = _screen->getWidth();
 	_wmgrPort->rect.moveTo(0, 0);
 	_wmgrPort->curTop = 0;
 	_wmgrPort->curLeft = 0;
 	_windowList.push_front(_wmgrPort);
 
-	_picWind = NewWindow(Common::Rect(0, offTop, _screen->_width, _screen->_height), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true);
+	_picWind = NewWindow(Common::Rect(0, offTop, _screen->getWidth(), _screen->getHeight()), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true);
 }
 
 int16 WindowMgr::isFrontWindow(Window *pWnd) {


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