diff options
Diffstat (limited to 'backends/graphics/gph/gph-graphics.cpp')
-rw-r--r-- | backends/graphics/gph/gph-graphics.cpp | 150 |
1 files changed, 53 insertions, 97 deletions
diff --git a/backends/graphics/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp index 82a32203fb..a0c1d9ad2b 100644 --- a/backends/graphics/gph/gph-graphics.cpp +++ b/backends/graphics/gph/gph-graphics.cpp @@ -36,7 +36,7 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { }; GPHGraphicsManager::GPHGraphicsManager(SdlEventSource *sdlEventSource) - : SurfaceSdlGraphicsManager(sdlEventSource) { + : SurfaceSdlGraphicsManager(sdlEventSource) { } const OSystem::GraphicsMode *GPHGraphicsManager::getSupportedGraphicsModes() const { @@ -138,10 +138,10 @@ void GPHGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *f _videoMode.screenWidth = w; _videoMode.screenHeight = h; - if (w > 320 || h > 240){ + if (w > 320 || h > 240) { setGraphicsMode(GFX_HALF); setGraphicsModeIntern(); - _sdlEventSource->toggleMouseGrab(); + _eventSource->toggleMouseGrab(); } _videoMode.overlayWidth = 320; @@ -161,9 +161,9 @@ void GPHGraphicsManager::drawMouse() { int width, height; int hotX, hotY; - if (_videoMode.mode == GFX_HALF && !_overlayVisible){ - dst.x = _mouseCurState.x/2; - dst.y = _mouseCurState.y/2; + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { + dst.x = _mouseCurState.x / 2; + dst.y = _mouseCurState.y / 2; } else { dst.x = _mouseCurState.x; dst.y = _mouseCurState.y; @@ -230,9 +230,9 @@ void GPHGraphicsManager::undrawMouse() { if (!_overlayVisible && (x >= _videoMode.screenWidth || y >= _videoMode.screenHeight)) return; - if (_mouseBackup.w != 0 && _mouseBackup.h != 0){ - if (_videoMode.mode == GFX_HALF && !_overlayVisible){ - addDirtyRect(x*2, y*2, _mouseBackup.w*2, _mouseBackup.h*2); + if (_mouseBackup.w != 0 && _mouseBackup.h != 0) { + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { + addDirtyRect(x * 2, y * 2, _mouseBackup.w * 2, _mouseBackup.h * 2); } else { addDirtyRect(x, y, _mouseBackup.w, _mouseBackup.h); } @@ -252,8 +252,8 @@ void GPHGraphicsManager::internUpdateScreen() { // If the shake position changed, fill the dirty area with blackness if (_currentShakePos != _newShakePos || - (_mouseNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { - SDL_Rect blackrect = {0, 0, _videoMode.screenWidth * _videoMode.scaleFactor, _newShakePos * _videoMode.scaleFactor}; + (_mouseNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { + SDL_Rect blackrect = {0, 0, _videoMode.screenWidth *_videoMode.scaleFactor, _newShakePos *_videoMode.scaleFactor}; if (_videoMode.aspectRatioCorrection && !_overlayVisible) blackrect.h = real2Aspect(blackrect.h - 1) + 1; @@ -269,8 +269,8 @@ void GPHGraphicsManager::internUpdateScreen() { // screen surface accordingly. if (_screen && _paletteDirtyEnd != 0) { SDL_SetColors(_screen, _currentPalette + _paletteDirtyStart, - _paletteDirtyStart, - _paletteDirtyEnd - _paletteDirtyStart); + _paletteDirtyStart, + _paletteDirtyEnd - _paletteDirtyStart); _paletteDirtyEnd = 0; @@ -326,6 +326,9 @@ void GPHGraphicsManager::internUpdateScreen() { _dirtyRectList[0].y = 0; _dirtyRectList[0].w = width; _dirtyRectList[0].h = height; + + // HACK: Make sure the full hardware screen is wiped clean. + SDL_FillRect(_hwscreen, NULL, 0); } // Only draw anything if necessary @@ -337,8 +340,8 @@ void GPHGraphicsManager::internUpdateScreen() { for (r = _dirtyRectList; r != lastRect; ++r) { dst = *r; - dst.x++; // Shift rect by one since 2xSai needs to access the data around - dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. + dst.x++; // Shift rect by one since 2xSai needs to access the data around + dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0) error("SDL_BlitSurface failed: %s", SDL_GetError()); @@ -374,11 +377,11 @@ void GPHGraphicsManager::internUpdateScreen() { assert(scalerProc != NULL); if ((_videoMode.mode == GFX_HALF) && (scalerProc == DownscaleAllByHalf)) { - if (dst_x%2==1){ + if (dst_x % 2 == 1) { dst_x--; dst_w++; } - if (dst_y%2==1){ + if (dst_y % 2 == 1) { dst_y--; dst_h++; } @@ -388,14 +391,14 @@ void GPHGraphicsManager::internUpdateScreen() { dst_y = dst_y / 2; scalerProc((byte *)srcSurf->pixels + (src_x * 2 + 2) + (src_y + 1) * srcPitch, srcPitch, - (byte *)_hwscreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h); + (byte *)_hwscreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h); } else { scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, (byte *)_hwscreen->pixels + r->x * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h); } } - if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf){ + if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf) { r->w = r->w / 2; r->h = dst_h / 2; } else { @@ -419,7 +422,7 @@ void GPHGraphicsManager::internUpdateScreen() { // This is necessary if shaking is active. if (_forceFull) { _dirtyRectList[0].y = 0; - _dirtyRectList[0].h = (_videoMode.mode == GFX_HALF) ? effectiveScreenHeight()/2 : effectiveScreenHeight(); + _dirtyRectList[0].h = (_videoMode.mode == GFX_HALF) ? effectiveScreenHeight() / 2 : effectiveScreenHeight(); } drawMouse(); @@ -439,7 +442,7 @@ void GPHGraphicsManager::internUpdateScreen() { } void GPHGraphicsManager::showOverlay() { - if (_videoMode.mode == GFX_HALF){ + if (_videoMode.mode == GFX_HALF) { _mouseCurState.x = _mouseCurState.x / 2; _mouseCurState.y = _mouseCurState.y / 2; } @@ -447,89 +450,41 @@ void GPHGraphicsManager::showOverlay() { } void GPHGraphicsManager::hideOverlay() { - if (_videoMode.mode == GFX_HALF){ + if (_videoMode.mode == GFX_HALF) { _mouseCurState.x = _mouseCurState.x * 2; _mouseCurState.y = _mouseCurState.y * 2; } SurfaceSdlGraphicsManager::hideOverlay(); } +bool GPHGraphicsManager::loadGFXMode() { -//bool GPHGraphicsManager::loadGFXMode() { - - -// _videoMode.overlayWidth = 320; -// _videoMode.overlayHeight = 240; -// _videoMode.fullscreen = true; -// -// /* Forcefully disable aspect ratio correction for games -// that start with a native 240px height resolution -// This corrects games with non-standard resolutions -// such as MM Nes (256x240). -// */ -// if(_videoMode.screenHeight == 240) { -// _videoMode.aspectRatioCorrection = false; -// } - -// debug("Game ScreenMode = %d*%d", _videoMode.screenWidth, _videoMode.screenHeight); -// if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) { -// _videoMode.aspectRatioCorrection = false; -// setGraphicsMode(GFX_HALF); -// debug("GraphicsMode set to HALF"); -// } else { -// setGraphicsMode(GFX_NORMAL); -// debug("GraphicsMode set to NORMAL"); -// } - - -// if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) { -// //_videoMode.overlayWidth = _videoMode.screenWidth / 2; -// //_videoMode.overlayHeight = _videoMode.screenHeight / 2; -// _videoMode.overlayWidth = 320; -// _videoMode.overlayHeight = 240; -// _videoMode.fullscreen = true; -// } else { -// -// _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; -// _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; -// -// if (_videoMode.aspectRatioCorrection) -// _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); -// -// //_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; -// //_videoMode.hardwareHeight = effectiveScreenHeight(); -// _videoMode.hardwareWidth = 320; -// _videoMode.hardwareHeight = 240; -// -// } - -// return SurfaceSdlGraphicsManager::loadGFXMode(); -//} + // We don't offer anything other than fullscreen on GPH devices so let’s not even pretend. + _videoMode.fullscreen = true; + + // Set the hardware stats to match the LCD. + _videoMode.hardwareWidth = 320; + _videoMode.hardwareHeight = 240; + + if (_videoMode.screenHeight != 200) + _videoMode.aspectRatioCorrection = false; -bool GPHGraphicsManager::loadGFXMode() { if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) { _videoMode.aspectRatioCorrection = false; setGraphicsMode(GFX_HALF); -// printf("GFX_HALF\n"); } else { setGraphicsMode(GFX_NORMAL); -// printf("GFX_NORMAL\n"); } if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) { _videoMode.overlayWidth = _videoMode.screenWidth / 2; _videoMode.overlayHeight = _videoMode.screenHeight / 2; - _videoMode.fullscreen = true; } else { - _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; if (_videoMode.aspectRatioCorrection) _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); - - _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; - _videoMode.hardwareHeight = effectiveScreenHeight(); } return SurfaceSdlGraphicsManager::loadGFXMode(); } @@ -542,9 +497,13 @@ bool GPHGraphicsManager::hasFeature(OSystem::Feature f) { void GPHGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { switch (f) { - case OSystem::kFeatureAspectRatioCorrection: + case OSystem::kFeatureAspectRatioCorrection: setAspectRatioCorrection(enable); break; + case OSystem::kFeatureCursorPalette: + _cursorPaletteDisabled = !enable; + blitCursor(); + break; default: break; } @@ -554,8 +513,10 @@ bool GPHGraphicsManager::getFeatureState(OSystem::Feature f) { assert(_transactionMode == kTransactionNone); switch (f) { - case OSystem::kFeatureAspectRatioCorrection: + case OSystem::kFeatureAspectRatioCorrection: return _videoMode.aspectRatioCorrection; + case OSystem::kFeatureCursorPalette: + return !_cursorPaletteDisabled; default: return false; } @@ -571,7 +532,7 @@ SurfaceSdlGraphicsManager::VideoState *GPHGraphicsManager::getVideoMode() { void GPHGraphicsManager::warpMouse(int x, int y) { if (_mouseCurState.x != x || _mouseCurState.y != y) { - if (_videoMode.mode == GFX_HALF && !_overlayVisible){ + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { x = x / 2; y = y / 2; } @@ -579,21 +540,16 @@ void GPHGraphicsManager::warpMouse(int x, int y) { SurfaceSdlGraphicsManager::warpMouse(x, y); } -void GPHGraphicsManager::adjustMouseEvent(const Common::Event &event) { - if (!event.synthetic) { - Common::Event newEvent(event); - newEvent.synthetic = true; - if (!_overlayVisible) { - if (_videoMode.mode == GFX_HALF) { - newEvent.mouse.x *= 2; - newEvent.mouse.y *= 2; - } - newEvent.mouse.x /= _videoMode.scaleFactor; - newEvent.mouse.y /= _videoMode.scaleFactor; - if (_videoMode.aspectRatioCorrection) - newEvent.mouse.y = aspect2Real(newEvent.mouse.y); +void GPHGraphicsManager::transformMouseCoordinates(Common::Point &point) { + if (!_overlayVisible) { + if (_videoMode.mode == GFX_HALF) { + point.x *= 2; + point.y *= 2; } - g_system->getEventManager()->pushEvent(newEvent); + point.x /= _videoMode.scaleFactor; + point.y /= _videoMode.scaleFactor; + if (_videoMode.aspectRatioCorrection) + point.y = aspect2Real(point.y); } } |