diff options
-rw-r--r-- | backends/platform/gp2x/events.cpp | 2 | ||||
-rw-r--r-- | backends/platform/gp2x/gp2x-common.h | 26 | ||||
-rw-r--r-- | backends/platform/gp2x/gp2x-hw.cpp | 2 | ||||
-rw-r--r-- | backends/platform/gp2x/gp2x-mem.cpp | 2 | ||||
-rw-r--r-- | backends/platform/gp2x/gp2x-mem.h | 1 | ||||
-rw-r--r-- | backends/platform/gp2x/gp2x.cpp | 45 | ||||
-rw-r--r-- | backends/platform/gp2x/graphics.cpp | 225 | ||||
-rw-r--r-- | backends/platform/gp2x/module.mk | 2 |
8 files changed, 87 insertions, 218 deletions
diff --git a/backends/platform/gp2x/events.cpp b/backends/platform/gp2x/events.cpp index 8cd034d2d5..bc9a4ff26c 100644 --- a/backends/platform/gp2x/events.cpp +++ b/backends/platform/gp2x/events.cpp @@ -93,7 +93,7 @@ void OSystem_GP2X::fillMouseEvent(Common::Event &event, int x, int y) { if (!_overlayVisible) { event.mouse.x /= _videoMode.scaleFactor; event.mouse.y /= _videoMode.scaleFactor; - if (_videoMode.aspectRatio) + if (_videoMode.aspectRatioCorrection) event.mouse.y = aspect2Real(event.mouse.y); } } diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h index 7341b0646f..4e6421f353 100644 --- a/backends/platform/gp2x/gp2x-common.h +++ b/backends/platform/gp2x/gp2x-common.h @@ -42,18 +42,7 @@ namespace Audio { } enum { - GFX_NORMAL = 0, - GFX_DOUBLESIZE = 1, - GFX_TRIPLESIZE = 2, - GFX_2XSAI = 3, - GFX_SUPER2XSAI = 4, - GFX_SUPEREAGLE = 5, - GFX_ADVMAME2X = 6, - GFX_ADVMAME3X = 7, - GFX_HQ2X = 8, - GFX_HQ3X = 9, - GFX_TV2X = 10, - GFX_DOTMATRIX = 11 + GFX_NORMAL = 0 }; @@ -248,7 +237,7 @@ protected: bool setup; bool fullscreen; - bool aspectRatio; + bool aspectRatioCorrection; int mode; int scaleFactor; @@ -274,16 +263,11 @@ protected: bool _modeChanged; int _screenChangeCount; - /** True if aspect ratio correction is enabled. */ - bool _adjustAspectRatio; - - /** True if zoom on mouse is enabled. (only set by > 240 high games) */ + /* True if zoom on mouse is enabled. (only set by > 240 high games) */ bool _adjustZoomOnMouse; - //_adjustZoomOnMouse = false; enum { NUM_DIRTY_RECT = 100, - MAX_MOUSE_W = 80, MAX_MOUSE_H = 80, MAX_SCALING = 3 @@ -332,7 +316,7 @@ protected: // mouse KbdMouse _km; bool _mouseVisible; - bool _mouseDrawn; + bool _mouseNeedsRedraw; byte *_mouseData; SDL_Rect _mouseBackup; MousePos _mouseCurState; @@ -419,7 +403,7 @@ protected: bool saveScreenshot(const char *filename); int effectiveScreenHeight() const { - return (_videoMode.aspectRatio ? real2Aspect(_videoMode.screenHeight) : _videoMode.screenHeight) + return (_videoMode.aspectRatioCorrection ? real2Aspect(_videoMode.screenHeight) : _videoMode.screenHeight) * _videoMode.scaleFactor; } diff --git a/backends/platform/gp2x/gp2x-hw.cpp b/backends/platform/gp2x/gp2x-hw.cpp index 38799ea7ad..2dc5b4f579 100644 --- a/backends/platform/gp2x/gp2x-hw.cpp +++ b/backends/platform/gp2x/gp2x-hw.cpp @@ -56,7 +56,7 @@ enum { VOLUME_UP = 2, VOLUME_CHANGE_RATE = 8, VOLUME_MIN = 0, - VOLUME_INITIAL = 70, + VOLUME_INITIAL = 60, VOLUME_MAX = 100 }; diff --git a/backends/platform/gp2x/gp2x-mem.cpp b/backends/platform/gp2x/gp2x-mem.cpp index ec73922bf7..97a34ffb6a 100644 --- a/backends/platform/gp2x/gp2x-mem.cpp +++ b/backends/platform/gp2x/gp2x-mem.cpp @@ -37,7 +37,7 @@ #include <unistd.h> #include <string.h> -#include "gp2x-mem.h" +#include "backends/platform/gp2x/gp2x-mem.h" void SetClock (unsigned c) { diff --git a/backends/platform/gp2x/gp2x-mem.h b/backends/platform/gp2x/gp2x-mem.h index 2b64cdb802..24b2a3f569 100644 --- a/backends/platform/gp2x/gp2x-mem.h +++ b/backends/platform/gp2x/gp2x-mem.h @@ -35,7 +35,6 @@ extern "C" { #endif - // Use Squidge's MMU patch rather then myown (his is neater). // The effect if not that great but cacheing the upper RAM is no bad thing (tm) ;). diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp index 3d416f8415..21a047b345 100644 --- a/backends/platform/gp2x/gp2x.cpp +++ b/backends/platform/gp2x/gp2x.cpp @@ -131,8 +131,6 @@ void OSystem_GP2X::initBackend() { ConfMan.registerDefault("savepath", savePath); - _savefile = new DefaultSaveFileManager(savePath); - #ifdef DUMP_STDOUT // The GP2X has a serial console but most users do not use this so we // output all our STDOUT and STDERR to files for debug purposes. @@ -186,9 +184,9 @@ void OSystem_GP2X::initBackend() { ConfMan.registerDefault("aspect_ratio", true); /* Up default volume values as we use a seperate system level volume anyway. */ - ConfMan.registerDefault("music_volume", 220); - ConfMan.registerDefault("sfx_volume", 220); - ConfMan.registerDefault("speech_volume", 220); + ConfMan.registerDefault("music_volume", 192); + ConfMan.registerDefault("sfx_volume", 192); + ConfMan.registerDefault("speech_volume", 192); ConfMan.registerDefault("autosave_period", 3 * 60); // Trigger autosave every 3 minutes - On low batts 4 mins is about your warning time. memset(&_oldVideoMode, 0, sizeof(_oldVideoMode)); @@ -199,7 +197,7 @@ void OSystem_GP2X::initBackend() { _videoMode.mode = GFX_NORMAL; _videoMode.scaleFactor = 1; _scalerProc = Normal1x; - _videoMode.aspectRatio = ConfMan.getBool("aspect_ratio"); + _videoMode.aspectRatioCorrection = ConfMan.getBool("aspect_ratio"); _scalerType = 0; _modeFlags = 0; _adjustZoomOnMouse = false; @@ -210,17 +208,13 @@ void OSystem_GP2X::initBackend() { _joystick = SDL_JoystickOpen(joystick_num); } + _savefile = new DefaultSaveFileManager(); // Create and hook up the mixer, if none exists yet (we check for this to // allow subclasses to provide their own). if (_mixer == 0) { setupMixer(); } - // Setup the keymapper with backend's set of keys - // NOTE: must be done before creating TimerManager - // to avoid race conditions in creating EventManager - setupKeymapper(); - // Create and hook up the timer manager, if none exists yet (we check for // this to allow subclasses to provide their own). if (_timer == 0) { @@ -241,27 +235,6 @@ void OSystem_GP2X::initBackend() { /* Set Default hardware mixer volume to a preset level (VOLUME_INITIAL). This is done to 'reset' volume level if set by other apps. */ GP2X_HW::mixerMoveVolume(0); - // Set Default hardware mixer volume to a plesent level. - // This is done to 'reset' volume level if set by other apps. - - //if (SDL_GP2X_MouseType() == 0) { - // // No mouse, F100 default state. - // _gp2xInputType = 0; - // displayMessageOnOSD("F100 GP2X Found"); - //} - - //if (SDL_GP2X_MouseType() == 1) { - // // USB mouse found. - // _gp2xInputType = 1; - // displayMessageOnOSD("USB Mouse Found"); - //} - - //if (SDL_GP2X_MouseType() == 2) { - // // F200 touch screen found. - F200 default state. - // _gp2xInputType = 2; - // displayMessageOnOSD("Touch Screen Found"); - //} - OSystem::initBackend(); _inited = true; @@ -275,7 +248,7 @@ OSystem_GP2X::OSystem_GP2X() _overlayscreen(0), _tmpscreen2(0), _samplesPerSec(0), _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0), - _mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseSurface(0), + _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0), _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true), _joystick(0), _currentShakePos(0), _newShakePos(0), @@ -434,7 +407,7 @@ bool OSystem_GP2X::getFeatureState(Feature f) { case kFeatureFullscreenMode: return false; case kFeatureAspectRatioCorrection: - return _videoMode.aspectRatio; + return _videoMode.aspectRatioCorrection; case kFeatureAutoComputeDirtyRects: return _modeFlags & DF_WANT_RECT_OPTIM; default: @@ -458,12 +431,12 @@ void OSystem_GP2X::quit() { free(_cursorPalette); free(_mouseData); - delete _savefile; delete _timer; SDL_ShowCursor(SDL_ENABLE); SDL_Quit(); delete getEventManager(); + delete _savefile; #ifdef DUMP_STDOUT printf("%s\n", "Debug: STDOUT and STDERR text files closed."); @@ -610,7 +583,7 @@ void OSystem_GP2X::setupMixer() { _samplesPerSec = SAMPLES_PER_SEC; //Quick EVIL Hack - DJWillis - _samplesPerSec = 11025; +// _samplesPerSec = 11025; // Determine the sample buffer size. We want it to store enough data for // about 1/16th of a second. Note that it must be a power of two. diff --git a/backends/platform/gp2x/graphics.cpp b/backends/platform/gp2x/graphics.cpp index a77afd88b7..229f840d11 100644 --- a/backends/platform/gp2x/graphics.cpp +++ b/backends/platform/gp2x/graphics.cpp @@ -37,7 +37,7 @@ #include "graphics/surface.h" static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { - {"GP2X Graphics Mode", "1x", GFX_NORMAL}, + {"Fullscreen", "1x", GFX_NORMAL}, {0, 0, 0} }; @@ -50,14 +50,7 @@ static ScalerProc *scalersMagn[3][3] = { }; static const int s_gfxModeSwitchTable[][4] = { - { GFX_NORMAL, GFX_DOUBLESIZE, GFX_TRIPLESIZE, -1 }, - { GFX_NORMAL, GFX_ADVMAME2X, GFX_ADVMAME3X, -1 }, - { GFX_NORMAL, GFX_HQ2X, GFX_HQ3X, -1 }, - { GFX_NORMAL, GFX_2XSAI, -1, -1 }, - { GFX_NORMAL, GFX_SUPER2XSAI, -1, -1 }, - { GFX_NORMAL, GFX_SUPEREAGLE, -1, -1 }, - { GFX_NORMAL, GFX_TV2X, -1, -1 }, - { GFX_NORMAL, GFX_DOTMATRIX, -1, -1 } + { GFX_NORMAL } }; static int cursorStretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY); @@ -95,10 +88,10 @@ OSystem::TransactionError OSystem_GP2X::endGFXTransaction(void) { errors |= kTransactionFullscreenFailed; _videoMode.fullscreen = _oldVideoMode.fullscreen; - } else if (_videoMode.aspectRatio != _oldVideoMode.aspectRatio) { + } else if (_videoMode.aspectRatioCorrection != _oldVideoMode.aspectRatioCorrection) { errors |= kTransactionAspectRatioFailed; - _videoMode.aspectRatio = _oldVideoMode.aspectRatio; + _videoMode.aspectRatioCorrection = _oldVideoMode.aspectRatioCorrection; } else if (_videoMode.mode != _oldVideoMode.mode) { errors |= kTransactionModeSwitchFailed; @@ -114,7 +107,7 @@ OSystem::TransactionError OSystem_GP2X::endGFXTransaction(void) { } if (_videoMode.fullscreen == _oldVideoMode.fullscreen && - _videoMode.aspectRatio == _oldVideoMode.aspectRatio && + _videoMode.aspectRatioCorrection == _oldVideoMode.aspectRatioCorrection && _videoMode.mode == _oldVideoMode.mode && _videoMode.screenWidth == _oldVideoMode.screenWidth && _videoMode.screenHeight == _oldVideoMode.screenHeight) { @@ -190,45 +183,6 @@ bool OSystem_GP2X::setGraphicsMode(int mode) { case GFX_NORMAL: newScaleFactor = 1; break; -#ifndef DISABLE_SCALERS - case GFX_DOUBLESIZE: - newScaleFactor = 2; - break; - case GFX_TRIPLESIZE: - newScaleFactor = 3; - break; - - case GFX_2XSAI: - newScaleFactor = 2; - break; - case GFX_SUPER2XSAI: - newScaleFactor = 2; - break; - case GFX_SUPEREAGLE: - newScaleFactor = 2; - break; - case GFX_ADVMAME2X: - newScaleFactor = 2; - break; - case GFX_ADVMAME3X: - newScaleFactor = 3; - break; -#ifndef DISABLE_HQ_SCALERS - case GFX_HQ2X: - newScaleFactor = 2; - break; - case GFX_HQ3X: - newScaleFactor = 3; - break; -#endif - case GFX_TV2X: - newScaleFactor = 2; - break; - case GFX_DOTMATRIX: - newScaleFactor = 2; - break; -#endif // DISABLE_SCALERS - default: warning("unknown gfx mode %d", mode); return false; @@ -246,7 +200,6 @@ bool OSystem_GP2X::setGraphicsMode(int mode) { return true; } - void OSystem_GP2X::setGraphicsModeIntern() { Common::StackLock lock(_graphicsMutex); ScalerProc *newScalerProc = 0; @@ -255,44 +208,6 @@ void OSystem_GP2X::setGraphicsModeIntern() { case GFX_NORMAL: newScalerProc = Normal1x; break; -#ifndef DISABLE_SCALERS - case GFX_DOUBLESIZE: - newScalerProc = Normal2x; - break; - case GFX_TRIPLESIZE: - newScalerProc = Normal3x; - break; - - case GFX_2XSAI: - newScalerProc = _2xSaI; - break; - case GFX_SUPER2XSAI: - newScalerProc = Super2xSaI; - break; - case GFX_SUPEREAGLE: - newScalerProc = SuperEagle; - break; - case GFX_ADVMAME2X: - newScalerProc = AdvMame2x; - break; - case GFX_ADVMAME3X: - newScalerProc = AdvMame3x; - break; -#ifndef DISABLE_HQ_SCALERS - case GFX_HQ2X: - newScalerProc = HQ2x; - break; - case GFX_HQ3X: - newScalerProc = HQ3x; - break; -#endif - case GFX_TV2X: - newScalerProc = TV2x; - break; - case GFX_DOTMATRIX: - newScalerProc = DotMatrix; - break; -#endif // DISABLE_SCALERS default: error("Unknown gfx mode %d", _videoMode.mode); @@ -353,18 +268,28 @@ bool OSystem_GP2X::loadGFXMode() { _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400) - _videoMode.aspectRatio = false; + _videoMode.aspectRatioCorrection = false; - if (_videoMode.aspectRatio) + if (_videoMode.aspectRatioCorrection) _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); hwW = _videoMode.screenWidth * _videoMode.scaleFactor; - hwH = effectiveScreenHeight(); + + if (_videoMode.screenHeight == 200) { + hwH = 240; + } else if (_videoMode.screenHeight == 400) { + hwH = 480; + } else { + hwH = _videoMode.screenHeight; + } + + printf ("Game Screen Height: %d\n", hwH); // - // Create the surface that contains the 8 bit game data + // Create the surface that contains the game data // - _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 8, 0, 0, 0, 0); + + _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, hwH, 8, 0, 0, 0, 0); if (_screen == NULL) error("allocating _screen failed"); @@ -372,9 +297,7 @@ bool OSystem_GP2X::loadGFXMode() { // Create the surface that contains the scaled graphics in 16 bit mode // - _hwscreen = SDL_SetVideoMode(hwW, hwH, 16, - _videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE - ); + _hwscreen = SDL_SetVideoMode(hwW, hwH, 16, SDL_SWSURFACE | SDL_NOFRAME | SDL_FULLSCREEN); if (_hwscreen == NULL) { // DON'T use error(), as this tries to bring up the debug // console, which WON'T WORK now that _hwscreen is hosed. @@ -395,12 +318,6 @@ bool OSystem_GP2X::loadGFXMode() { // Create the surface used for the graphics in 16 bit before scaling, and also the overlay // - // Distinguish 555 and 565 mode - if (_hwscreen->format->Rmask == 0x7C00) - InitScalers(555); - else - InitScalers(565); - // Need some extra bytes around when using 2xSaI _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth + 3, _videoMode.screenHeight + 3, 16, @@ -462,6 +379,12 @@ bool OSystem_GP2X::loadGFXMode() { _km.delay_time = 25; _km.last_time = 0; + // Distinguish 555 and 565 mode + if (_hwscreen->format->Rmask == 0x7C00) + InitScalers(555); + else + InitScalers(565); + return true; } @@ -571,7 +494,7 @@ void OSystem_GP2X::internUpdateScreen() { if (_currentShakePos != _newShakePos) { SDL_Rect blackrect = {0, 0, _videoMode.screenWidth * _videoMode.scaleFactor, _newShakePos * _videoMode.scaleFactor}; - if (_videoMode.aspectRatio && !_overlayVisible) + if (_videoMode.aspectRatioCorrection && !_overlayVisible) blackrect.h = real2Aspect(blackrect.h - 1) + 1; SDL_FillRect(_hwscreen, &blackrect, 0); @@ -627,6 +550,11 @@ void OSystem_GP2X::internUpdateScreen() { scale1 = 1; } + // Add the area covered by the mouse cursor to the list of dirty rects if + // we have to redraw the mouse. + if (_mouseNeedsRedraw) + undrawMouse(); + // Force a full redraw if requested if (_forceFull) { _numDirtyRects = 1; @@ -634,12 +562,10 @@ void OSystem_GP2X::internUpdateScreen() { _dirtyRectList[0].y = 0; _dirtyRectList[0].w = width; _dirtyRectList[0].h = height; - } else - undrawMouse(); + } // Only draw anything if necessary - if (_numDirtyRects > 0) { - + if (_numDirtyRects > 0 || _mouseNeedsRedraw) { SDL_Rect *r; SDL_Rect dst; uint32 srcPitch, dstPitch; @@ -647,7 +573,7 @@ void OSystem_GP2X::internUpdateScreen() { for (r = _dirtyRectList; r != lastRect; ++r) { dst = *r; - dst.x++; // Shift rect by one since 2xSai needs to acces the data around + 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) @@ -674,7 +600,7 @@ void OSystem_GP2X::internUpdateScreen() { orig_dst_y = dst_y; dst_y = dst_y * scale1; - if (_videoMode.aspectRatio && !_overlayVisible) + if (_videoMode.aspectRatioCorrection && !_overlayVisible) dst_y = real2Aspect(dst_y); assert(scalerProc != NULL); @@ -687,10 +613,8 @@ void OSystem_GP2X::internUpdateScreen() { r->w = r->w * scale1; r->h = dst_h * scale1; -#ifndef DISABLE_SCALERS - if (_videoMode.aspectRatio && orig_dst_y < height && !_overlayVisible) + if (_videoMode.aspectRatioCorrection && orig_dst_y < height && !_overlayVisible) r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1); -#endif } SDL_UnlockSurface(srcSurf); SDL_UnlockSurface(_hwscreen); @@ -710,14 +634,11 @@ void OSystem_GP2X::internUpdateScreen() { // Finally, blit all our changes to the screen SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); - } else { - drawMouse(); - if (_numDirtyRects) - SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); } _numDirtyRects = 0; _forceFull = false; + _mouseNeedsRedraw = false; } bool OSystem_GP2X::saveScreenshot(const char *filename) { @@ -740,18 +661,14 @@ void OSystem_GP2X::setFullscreenMode(bool enable) { } void OSystem_GP2X::setAspectRatioCorrection(bool enable) { - if ((_videoMode.screenHeight == 200 && _videoMode.aspectRatio != enable) || - _transactionMode == kTransactionActive) { - - Common::StackLock lock(_graphicsMutex); + Common::StackLock lock(_graphicsMutex); - if (_oldVideoMode.setup && _oldVideoMode.aspectRatio == enable) - return; + if (_oldVideoMode.setup && _oldVideoMode.aspectRatioCorrection == enable) + return; - if (_transactionMode == kTransactionActive) { - _videoMode.aspectRatio = enable; - _transactionDetails.needHotswap = true; - } + if (_transactionMode == kTransactionActive) { + _videoMode.aspectRatioCorrection = enable; + _transactionDetails.needHotswap = true; } } @@ -776,12 +693,12 @@ void OSystem_GP2X::copyRectToScreen(const byte *src, int pitch, int x, int y, in Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends -// assert(x >= 0 && x < _screenWidth); -// assert(y >= 0 && y < _screenHeight); -// assert(h > 0 && y + h <= _screenHeight); -// assert(w > 0 && x + w <= _screenWidth); + assert(x >= 0 && x < _videoMode.screenWidth); + assert(y >= 0 && y < _videoMode.screenHeight); + assert(h > 0 && y + h <= _videoMode.screenHeight); + assert(w > 0 && x + w <= _videoMode.screenWidth); - if (((long)src & 3) == 0 && pitch == _videoMode.screenWidth && x == 0 && y == 0 && + if (IS_ALIGNED(src, 4) && pitch == _videoMode.screenWidth && x == 0 && y == 0 && w == _videoMode.screenWidth && h == _videoMode.screenHeight && _modeFlags & DF_WANT_RECT_OPTIM) { /* Special, optimized case for full screen updates. * It tries to determine what areas were actually changed, @@ -923,7 +840,7 @@ void OSystem_GP2X::addDirtyRect(int x, int y, int w, int h, bool realCoordinates h = height - y; } - if (_videoMode.aspectRatio && !_overlayVisible && !realCoordinates) { + if (_videoMode.aspectRatioCorrection && !_overlayVisible && !realCoordinates) { makeRectStretchable(x, y, w, h); } @@ -982,7 +899,7 @@ void OSystem_GP2X::makeChecksums(const byte *buf) { void OSystem_GP2X::addDirtyRgnAuto(const byte *buf) { assert(buf); - assert(((long)buf & 3) == 0); + assert(IS_ALIGNED(buf, 4)); /* generate a table of the checksums */ makeChecksums(buf); @@ -1115,7 +1032,7 @@ void OSystem_GP2X::showOverlay() { // Since resolution could change, put mouse to adjusted position // Fixes bug #1349059 x = _mouseCurState.x * _videoMode.scaleFactor; - if (_videoMode.aspectRatio) + if (_videoMode.aspectRatioCorrection) y = real2Aspect(_mouseCurState.y) * _videoMode.scaleFactor; else y = _mouseCurState.y * _videoMode.scaleFactor; @@ -1139,7 +1056,7 @@ void OSystem_GP2X::hideOverlay() { // Fixes bug #1349059 x = _mouseCurState.x / _videoMode.scaleFactor; y = _mouseCurState.y / _videoMode.scaleFactor; - if (_videoMode.aspectRatio) + if (_videoMode.aspectRatioCorrection) y = aspect2Real(y); warpMouse(x, y); @@ -1172,7 +1089,7 @@ void OSystem_GP2X::clearOverlay() { (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _videoMode.screenWidth, _videoMode.screenHeight); #ifndef DISABLE_SCALERS - if (_videoMode.aspectRatio) + if (_videoMode.aspectRatioCorrection) stretch200To240((uint8 *)_overlayscreen->pixels, _overlayscreen->pitch, _videoMode.overlayWidth, _videoMode.screenHeight * _videoMode.scaleFactor, 0, 0, 0); #endif @@ -1259,12 +1176,14 @@ bool OSystem_GP2X::showMouse(bool visible) { bool last = _mouseVisible; _mouseVisible = visible; + _mouseNeedsRedraw = true; return last; } void OSystem_GP2X::setMousePos(int x, int y) { if (x != _mouseCurState.x || y != _mouseCurState.y) { + _mouseNeedsRedraw = true; _mouseCurState.x = x; _mouseCurState.y = y; } @@ -1273,7 +1192,7 @@ void OSystem_GP2X::setMousePos(int x, int y) { void OSystem_GP2X::warpMouse(int x, int y) { int y1 = y; - if (_adjustAspectRatio && !_overlayVisible) + if (_videoMode.aspectRatioCorrection && !_overlayVisible) y1 = real2Aspect(y); if (_mouseCurState.x != x || _mouseCurState.y != y) { @@ -1342,6 +1261,8 @@ void OSystem_GP2X::blitCursor() { if (!_mouseOrigSurface || !_mouseData) return; + _mouseNeedsRedraw = true; + w = _mouseCurState.w; h = _mouseCurState.h; @@ -1422,7 +1343,7 @@ void OSystem_GP2X::blitCursor() { int rH1 = rH; // store original to pass to aspect-correction function later - if (_videoMode.aspectRatio && _cursorTargetScale == 1) { + if (_videoMode.aspectRatioCorrection && _cursorTargetScale == 1) { rH = real2Aspect(rH - 1) + 1; _mouseCurState.rHotY = real2Aspect(_mouseCurState.rHotY); } @@ -1453,20 +1374,17 @@ void OSystem_GP2X::blitCursor() { ScalerProc *scalerProc; - // If possible, use the same scaler for the cursor as for the rest of - // the game. This only works well with the non-blurring scalers so we - // actually only use the 1x, 1.5x, 2x and AdvMame scalers. - - if (_cursorTargetScale == 1 && (_videoMode.mode == GFX_DOUBLESIZE || _videoMode.mode == GFX_TRIPLESIZE)) - scalerProc = _scalerProc; - else + if (_cursorTargetScale == 1 && _videoMode.screenWidth > 320) { + scalerProc = scalersMagn[_cursorTargetScale + 1][_videoMode.scaleFactor + 1]; + } else { scalerProc = scalersMagn[_cursorTargetScale - 1][_videoMode.scaleFactor - 1]; + } scalerProc((byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch + 2, _mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch, _mouseCurState.w, _mouseCurState.h); - if (_videoMode.aspectRatio && _cursorTargetScale == 1) + if (_videoMode.aspectRatioCorrection && _cursorTargetScale == 1) cursorStretch200To240((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, rW, rH1, 0, 0, 0); SDL_UnlockSurface(_mouseSurface); @@ -1506,9 +1424,8 @@ void OSystem_GP2X::undrawMouse() { // When we switch bigger overlay off mouse jumps. Argh! // This is intended to prevent undrawing offscreen mouse - if (!_overlayVisible && (x >= _videoMode.screenWidth || y >= _videoMode.screenHeight)) { + if (!_overlayVisible && (x >= _videoMode.screenWidth || y >= _videoMode.screenHeight)) return; - } if (_mouseBackup.w != 0 && _mouseBackup.h != 0) addDirtyRect(x, y, _mouseBackup.w, _mouseBackup.h); @@ -1575,7 +1492,7 @@ void OSystem_GP2X::drawMouse() { dst.y += _currentShakePos; } - if (_videoMode.aspectRatio && !_overlayVisible) + if (_videoMode.aspectRatioCorrection && !_overlayVisible) dst.y = real2Aspect(dst.y); dst.x = scale * dst.x - _mouseCurState.rHotX; @@ -1584,7 +1501,6 @@ void OSystem_GP2X::drawMouse() { dst.h = _mouseCurState.rH; // Hacking about with the zoom around mouse pointer stuff. - if (_adjustZoomOnMouse == true){ zoomdst.w = (tmpScreenWidth / 2); @@ -1623,7 +1539,6 @@ void OSystem_GP2X::drawMouse() { SDL_GP2X_Display(&zoomdst); }; - // Note that SDL_BlitSurface() and addDirtyRect() will both perform any // clipping necessary @@ -1730,10 +1645,10 @@ void OSystem_GP2X::handleScalerHotkeys(const SDL_KeyboardEvent &key) { // Ctrl-Alt-a toggles aspect ratio correction if (key.keysym.sym == 'a') { beginGFXTransaction(); - setFeatureState(kFeatureAspectRatioCorrection, !_videoMode.aspectRatio); + setFeatureState(kFeatureAspectRatioCorrection, !_videoMode.aspectRatioCorrection); endGFXTransaction(); char buffer[128]; - if (_videoMode.aspectRatio) + if (_videoMode.aspectRatioCorrection) sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d", _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h diff --git a/backends/platform/gp2x/module.mk b/backends/platform/gp2x/module.mk index 58dfd24ee6..50a771219a 100644 --- a/backends/platform/gp2x/module.mk +++ b/backends/platform/gp2x/module.mk @@ -6,8 +6,6 @@ MODULE_OBJS := \ events.o \ graphics.o \ gp2x.o \ -# gp2x-options.o \ -# overload_help.o \ MODULE_DIRS += \ backends/platform/gp2x/ |