[Scummvm-cvs-logs] SF.net SVN: scummvm: [22750] scummvm/trunk/backends/psp

joostp at users.sourceforge.net joostp at users.sourceforge.net
Mon May 29 10:54:05 CEST 2006


Revision: 22750
Author:   joostp
Date:     2006-05-29 10:40:31 -0700 (Mon, 29 May 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22750&view=rev

Log Message:
-----------
get rid of _overlayScale

Modified Paths:
--------------
    scummvm/trunk/backends/psp/osys_psp.cpp
    scummvm/trunk/backends/psp/osys_psp.h
    scummvm/trunk/backends/psp/osys_psp_gu.cpp
Modified: scummvm/trunk/backends/psp/osys_psp.cpp
===================================================================
--- scummvm/trunk/backends/psp/osys_psp.cpp	2006-05-29 17:37:59 UTC (rev 22749)
+++ scummvm/trunk/backends/psp/osys_psp.cpp	2006-05-29 17:40:31 UTC (rev 22750)
@@ -59,7 +59,7 @@
 };
 
 
-OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _offscreen(0), _overlayBuffer(0), _overlayVisible(false), _shakePos(0), _mouseBuf(0), _prevButtons(0), _lastPadCheck(0), _padAccel(0) {
+OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0), _overlayHeight(0), _offscreen(0), _overlayBuffer(0), _overlayVisible(false), _shakePos(0), _mouseBuf(0), _prevButtons(0), _lastPadCheck(0), _padAccel(0) {
 
 	memset(_palette, 0, sizeof(_palette));
 
@@ -121,28 +121,25 @@
 }
 
 void OSystem_PSP::initSize(uint width, uint height) {
-	_screenWidth = width;
-	_screenHeight = height;
+	_overlayWidth = _screenWidth = width;
+	_overlayHeight = _screenHeight = height;
 	_offscreen = (byte *)malloc(width * height);
 
-	// TODO: Fixme. This is not neede anymore
-	_overlayScale = 1;
-
-	_overlayBuffer = (OverlayColor *)malloc(width * height * sizeof(OverlayColor));
+	_overlayBuffer = (OverlayColor *)malloc(_overlayWidth * _overlayHeight * sizeof(OverlayColor));
 	bzero(_offscreen, width * height);
-	bzero(_overlayBuffer, width * height);
+	clearOverlay();
 
 	_mouseVisible = false;
 }
 
-int16 OSystem_PSP::getHeight() {
-	return _screenHeight;
-}
-
 int16 OSystem_PSP::getWidth() {
 	return _screenWidth;
 }
 
+int16 OSystem_PSP::getHeight() {
+	return _screenHeight;
+}
+
 void OSystem_PSP::setPalette(const byte *colors, uint start, uint num) {
 	const byte *b = colors;
 
@@ -203,10 +200,10 @@
 	}
 
 	if(_overlayVisible) {
-		for (int i = 0; i < _screenHeight * _overlayScale; ++i) {
-			for (int j = 0; j < _screenWidth * _overlayScale; ++j) {
+		for (int i = 0; i < _screenHeight; ++i) {
+			for (int j = 0; j < _screenWidth; ++j) {
 
-				OverlayColor pixel = _overlayBuffer[(i * _screenWidth +j)];
+				OverlayColor pixel = _overlayBuffer[(i * _overlayWidth +j)];
 
 				if(pixel & 0x8000)
 					putPixel(xStart + j, yStart + i, pixel);
@@ -257,14 +254,14 @@
 void OSystem_PSP::clearOverlay ()
 {
 	PSPDebugTrace("clearOverlay\n");
-	bzero(_overlayBuffer, _screenWidth * _overlayScale * _screenHeight * _overlayScale * sizeof(OverlayColor));
+	bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor));
 }
 
 void OSystem_PSP::grabOverlay (OverlayColor *buf, int pitch)
 {
 }
 
-void OSystem_PSP::copyRectToOverlay (const OverlayColor *buf, int pitch, int x, int y, int w, int h)
+void OSystem_PSP::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h)
 {
 	PSPDebugTrace("copyRectToOverlay\n");
 	
@@ -281,38 +278,38 @@
 		y = 0;
 	}
 
-	if (w > _screenWidth*_overlayScale - x) {
-		w = _screenWidth*_overlayScale - x;
+	if (w > _overlayWidth - x) {
+		w = _overlayWidth - x;
 	}
 
-	if (h > _screenHeight*_overlayScale - y) {
-		h = _screenHeight*_overlayScale - y;
+	if (h > _overlayHeight - y) {
+		h = _overlayHeight - y;
 	}
 
 	if (w <= 0 || h <= 0)
 		return;
 
 	
-	OverlayColor *dst = _overlayBuffer +( y * _screenWidth * _overlayScale + x);
+	OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x);
 	if (_screenWidth == pitch && pitch == w) {
-		memcpy(dst, buf, h * _overlayScale * w * _overlayScale * sizeof(OverlayColor));
+		memcpy(dst, buf, h * w * sizeof(OverlayColor));
 	} else {
 		do {
-			memcpy(dst, buf, w * _overlayScale * sizeof(OverlayColor));
+			memcpy(dst, buf, w * sizeof(OverlayColor));
 			buf += pitch;
-			dst += _screenWidth * _overlayScale;
+			dst += _overlayWidth;
 		} while (--h);
 	}
 }
 
-int16 OSystem_PSP::getOverlayHeight()
+int16 OSystem_PSP::getOverlayWidth()
 {
-	return getHeight() * _overlayScale;
+	return _overlayWidth;
 }
 
-int16 OSystem_PSP::getOverlayWidth()
+int16 OSystem_PSP::getOverlayHeight()
 {
-	return getWidth() * _overlayScale;
+	return _overlayHeight;
 }
 
 OverlayColor OSystem_PSP::RGBToColor(uint8 r, uint8 g, uint8 b)
@@ -496,16 +493,16 @@
 							newY -= -analogStepAmountY - (-analogStepAmountY - 1);
 			}
 			else {
-				newX += analogStepAmountX >> ((_screenWidth == 640 || (_overlayVisible && _overlayScale > 1)) ? 2 : 3);
-				newY += analogStepAmountY >> ((_screenWidth == 640 || (_overlayVisible && _overlayScale > 1)) ? 2 : 3);
+				newX += analogStepAmountX >> ((_screenWidth == 640) ? 2 : 3);
+				newY += analogStepAmountY >> ((_screenWidth == 640) ? 2 : 3);
 			}
 
 			if (newX < 0) newX = 0;
 			if (newY < 0) newY = 0;
 			if(_overlayVisible)
 			{
-				if (newX >= _screenWidth*_overlayScale) newX = _screenWidth*_overlayScale - 1;
-				if (newY >= _screenHeight*_overlayScale) newY = _screenHeight*_overlayScale - 1;		
+				if (newX >= _overlayWidth) newX = _overlayWidth - 1;
+				if (newY >= _overlayHeight) newY = _overlayHeight - 1;		
 			}
 			else
 			{

Modified: scummvm/trunk/backends/psp/osys_psp.h
===================================================================
--- scummvm/trunk/backends/psp/osys_psp.h	2006-05-29 17:37:59 UTC (rev 22749)
+++ scummvm/trunk/backends/psp/osys_psp.h	2006-05-29 17:40:31 UTC (rev 22750)
@@ -45,7 +45,8 @@
 protected:
 	uint16	_screenWidth;
 	uint16	_screenHeight;
-	uint16	_overlayScale;
+	uint16  _overlayWidth;
+	uint16  _overlayHeight;
 	byte	*_offscreen;
 	OverlayColor  *_overlayBuffer;
 	uint16  _palette[256];
@@ -81,8 +82,8 @@
 	bool setGraphicsMode(const char *name);
 	virtual int getGraphicsMode() const;
 	virtual void initSize(uint width, uint height);
+	virtual int16 getWidth();
 	virtual int16 getHeight();
-	virtual int16 getWidth();
 	virtual void setPalette(const byte *colors, uint start, uint num);
 	virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
 	virtual void updateScreen();

Modified: scummvm/trunk/backends/psp/osys_psp_gu.cpp
===================================================================
--- scummvm/trunk/backends/psp/osys_psp_gu.cpp	2006-05-29 17:37:59 UTC (rev 22749)
+++ scummvm/trunk/backends/psp/osys_psp_gu.cpp	2006-05-29 17:40:31 UTC (rev 22750)
@@ -136,15 +136,16 @@
 	PSPDebugTrace("initSize\n");
 	_screenWidth = width;
 	_screenHeight = height;
+
+	_overlayWidth = width;	//PSP_SCREEN_WIDTH
+	_overlayHeight = height; //PSP_SCREEN_HEIGHT
+
 //	_offscreen = (byte *)offscreen256;
 	_overlayBuffer = (OverlayColor *)0x44000000 + PSP_FRAME_SIZE;
 
-	// FIXME: This is not needed anymore
-	_overlayScale = 1;
-
-	_offscreen = (unsigned byte *)_overlayBuffer+_screenWidth*_screenHeight*sizeof(OverlayColor);
+	_offscreen = (unsigned byte *)_overlayBuffer + _overlayWidth * _overlayHeight * sizeof(OverlayColor);
 	bzero(_offscreen, width * height);
-	bzero(_overlayBuffer, width * height);
+	clearOverlay();
 	_kbdClut[0] = 0xffff;
 	_kbdClut[246] = 0x4ccc;
 	_kbdClut[247] = 0x0000;
@@ -341,21 +342,22 @@
 		vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
 		vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
 		vertices[0].u = 0.5; vertices[0].v = 0.5;
-		vertices[1].u = _screenWidth*_overlayScale-0.5; vertices[1].v = _screenHeight*_overlayScale-0.5;
+		vertices[1].u = _overlayWidth-0.5; vertices[1].v = _overlayHeight-0.5;
 		sceGuTexMode(GU_PSM_5551, 0, 0, 0); // 16-bit image
 		sceGuAlphaFunc(GU_GREATER,0,0xff);
 		sceGuEnable(GU_ALPHA_TEST);
-		if(_overlayScale==2 || _screenWidth == 640)
-			sceGuTexImage(0, 512, 512, _screenWidth*_overlayScale, _overlayBuffer);
+		if (_overlayWidth == 640)
+			sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer);
 		else
-			sceGuTexImage(0, 512, 256, _screenWidth*_overlayScale, _overlayBuffer);
+			sceGuTexImage(0, 512, 256, _overlayWidth, _overlayBuffer);
+
 		sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); 
 		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices);
 		// need to render twice for textures > 512
-		if(_overlayScale==2 || _screenWidth == 640)
+		if( _overlayWidth == 640)
 		{
-			sceGuTexImage(0, 512, 512, _screenWidth*_overlayScale, _overlayBuffer+512);
-			vertices[0].u = 512 + 0.5; vertices[1].v = _screenHeight * _overlayScale - 0.5;
+			sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer+512);
+			vertices[0].u = 512 + 0.5; vertices[1].v = _overlayHeight - 0.5;
 			vertices[0].x = PSP_SCREEN_WIDTH*512/640; vertices[0].y = 0; vertices[0].z = 0;
 			sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices);
 		}
@@ -384,8 +386,8 @@
 		{
 			float scalex, scaley;
 
-			scalex = (float)PSP_SCREEN_WIDTH/(_screenWidth*_overlayScale);
-			scaley = (float)PSP_SCREEN_HEIGHT/(_screenHeight*_overlayScale);
+			scalex = (float)PSP_SCREEN_WIDTH/_overlayWidth;
+			scaley = (float)PSP_SCREEN_HEIGHT/_overlayHeight;
 
 			vertices[0].x = mX*scalex; vertices[0].y = mY*scaley; vertices[0].z = 0;
 			vertices[1].x = vertices[0].x+_mouseWidth*scalex; vertices[1].y = vertices[0].y + _mouseHeight*scaley; vertices[0].z = 0;


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