From 31413d871bb336aa4ca6d86a577074e875a05e94 Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Mon, 29 May 2006 17:40:31 +0000 Subject: get rid of _overlayScale svn-id: r22750 --- backends/psp/osys_psp.cpp | 63 +++++++++++++++++++++----------------------- backends/psp/osys_psp.h | 5 ++-- backends/psp/osys_psp_gu.cpp | 30 +++++++++++---------- 3 files changed, 49 insertions(+), 49 deletions(-) (limited to 'backends/psp') diff --git a/backends/psp/osys_psp.cpp b/backends/psp/osys_psp.cpp index 8b9242299f..56d7e270b1 100644 --- a/backends/psp/osys_psp.cpp +++ b/backends/psp/osys_psp.cpp @@ -59,7 +59,7 @@ const OSystem::GraphicsMode OSystem_PSP::s_supportedGraphicsModes[] = { }; -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 @@ int OSystem_PSP::getGraphicsMode() const } 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 @@ void OSystem_PSP::updateScreen() { } 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::hideOverlay () 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 @@ void OSystem_PSP::copyRectToOverlay (const OverlayColor *buf, int pitch, int x, 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 @@ bool OSystem_PSP::pollEvent(Event &event) { 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 { diff --git a/backends/psp/osys_psp.h b/backends/psp/osys_psp.h index b5e16df86d..937a6e1889 100644 --- a/backends/psp/osys_psp.h +++ b/backends/psp/osys_psp.h @@ -45,7 +45,8 @@ public: protected: uint16 _screenWidth; uint16 _screenHeight; - uint16 _overlayScale; + uint16 _overlayWidth; + uint16 _overlayHeight; byte *_offscreen; OverlayColor *_overlayBuffer; uint16 _palette[256]; @@ -81,8 +82,8 @@ public: bool setGraphicsMode(const char *name); virtual int getGraphicsMode() const; virtual void initSize(uint width, uint height); - virtual int16 getHeight(); virtual int16 getWidth(); + virtual int16 getHeight(); 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(); diff --git a/backends/psp/osys_psp_gu.cpp b/backends/psp/osys_psp_gu.cpp index 1cee404655..8ba36bdc20 100644 --- a/backends/psp/osys_psp_gu.cpp +++ b/backends/psp/osys_psp_gu.cpp @@ -136,15 +136,16 @@ void OSystem_PSP_GU::initSize(uint width, uint height) { 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 @@ OSystem_PSP_GU::updateScreen() 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 @@ OSystem_PSP_GU::updateScreen() { 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; -- cgit v1.2.3