Ticket #8353: overlay.v4.diff

File overlay.v4.diff, 25.0 KB (added by sev-, 19 years ago)

Scaled overlay v4 patch

  • backends/sdl/events.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/events.cpp,v
    retrieving revision 1.16
    diff -u -r1.16 events.cpp
     
    6868        _km.y = y;
    6969
    7070        // Adjust for the screen scaling
    71         event.mouse.x /= _scaleFactor;
    72         event.mouse.y /= _scaleFactor;
     71        if (!_overlayVisible) {
     72                event.mouse.x /= _scaleFactor;
     73                event.mouse.y /= _scaleFactor;
     74        } else {
     75                event.mouse.x = event.mouse.x / _scaleFactor * _overlayScale;
     76                event.mouse.y = event.mouse.y / _scaleFactor * _overlayScale;
     77        }
    7378
    7479        // Optionally perform aspect ratio adjusting
    7580        if (_adjustAspectRatio)
  • backends/sdl/graphics.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/graphics.cpp,v
    retrieving revision 1.29
    diff -u -r1.29 graphics.cpp
     
    6666        _transactionMode = kTransactionActive;
    6767
    6868        _transactionDetails.modeChanged = false;
    69         _transactionDetails.wChanged = false;
    70         _transactionDetails.hChanged = false;
     69        _transactionDetails.sizeChanged = false;
    7170        _transactionDetails.arChanged = false;
    7271        _transactionDetails.fsChanged = false;
    7372
     
    8382        if (_transactionDetails.modeChanged)
    8483                setGraphicsMode(_transactionDetails.mode);
    8584
    86         if (_transactionDetails.wChanged || _transactionDetails.hChanged)
    87                 initSize(_transactionDetails.w, _transactionDetails.h);
     85        if (_transactionDetails.sizeChanged)
     86                initSize(_transactionDetails.w, _transactionDetails.h,
     87                                 _transactionDetails.overlayScale);
    8888
    8989        if (_transactionDetails.arChanged)
    9090                setAspectRatioCorrection(_transactionDetails.ar);
     
    9292        if (_transactionDetails.needUnload) {
    9393                unloadGFXMode();
    9494                loadGFXMode();
     95                clearOverlay();
    9596        } else {
    9697                if (!_transactionDetails.fsChanged)
    9798                        if (_transactionDetails.needHotswap)
     
    168169                return false;
    169170        }
    170171
     172        // Do not let switch to lesser than overlay size resolutions
     173        if (_screenWidth * newScaleFactor < _overlayWidth) {
     174                if (_scaleFactor == 1) { // Force 2x mode
     175                        mode = GFX_DOUBLESIZE;
     176                        newScaleFactor = 2;
     177                        newScalerProc = Normal2x;
     178                } else
     179                        return false;
     180        }
     181
    171182        _mode = mode;
    172183        _scalerProc = newScalerProc;
    173184
     
    226237        return _mode;
    227238}
    228239
    229 void OSystem_SDL::initSize(uint w, uint h) {
     240void OSystem_SDL::initSize(uint w, uint h, int overlayScale) {
    230241        // Avoid redundant res changes
    231242        if ((int)w == _screenWidth && (int)h == _screenHeight &&
     243                 (int)overlayScale == _overlayScale &&
    232244                _transactionMode != kTransactionCommit)
    233245                return;
    234246
     
    238250        if (h != 200)
    239251                _adjustAspectRatio = false;
    240252
     253        if (overlayScale != -1) {
     254                _overlayScale = overlayScale;
     255                if (w != 320)
     256                        _overlayScale = 1;
     257
     258                _overlayWidth = w * _overlayScale;
     259                _overlayHeight = h * _overlayScale;
     260        }
     261
    241262        _cksumNum = (_screenWidth * _screenHeight / (8 * 8));
    242263
    243264        if (_transactionMode == kTransactionActive) {
    244265                _transactionDetails.w = w;
    245                 _transactionDetails.wChanged = true;
    246266                _transactionDetails.h = h;
    247                 _transactionDetails.hChanged = true;
     267                _transactionDetails.overlayScale = _overlayScale;
     268                _transactionDetails.sizeChanged = true;
    248269
    249270                _transactionDetails.needUnload = true;
    250271
     
    257278        if (_transactionMode != kTransactionCommit) {
    258279                unloadGFXMode();
    259280                loadGFXMode();
     281
     282                // if initSize() gets called in the middle, overlay is not transparent
     283                clearOverlay();
    260284        }
    261285}
    262286
     
    264288        _forceFull = true;
    265289        _modeFlags |= DF_UPDATE_EXPAND_1_PIXEL;
    266290
    267         _tmpscreen = NULL;
    268        
    269291        //
    270292        // Create the surface that contains the 8 bit game data
    271293        //
     
    312334                InitScalers(565);
    313335       
    314336        // Need some extra bytes around when using 2xSaI
    315         _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE,
    316                                                 _screenWidth + 3,
    317                                                 _screenHeight + 3,
    318                                                 16,
    319                                                 _hwscreen->format->Rmask,
    320                                                 _hwscreen->format->Gmask,
    321                                                 _hwscreen->format->Bmask,
    322                                                 _hwscreen->format->Amask);
     337        _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth + 3, _screenHeight + 3, 16, 0, 0, 0, 0);
    323338
    324339        if (_tmpscreen == NULL)
    325340                error("allocating _tmpscreen failed");
    326        
     341
     342        _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, 0, 0, 0, 0);
     343
     344        if (_overlayscreen == NULL)
     345                error("allocating _overlayscreen failed");
     346
     347        _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth + 3, _overlayHeight + 3, 16, 0, 0, 0, 0);
     348
     349        if (_tmpscreen2 == NULL)
     350                error("allocating _tmpscreen2 failed");
     351
    327352#ifdef USE_OSD
    328353        _osdSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA,
    329354                                                _hwscreen->w,
     
    361386                _tmpscreen = NULL;
    362387        }
    363388
     389        if (_tmpscreen2) {
     390                SDL_FreeSurface(_tmpscreen2);
     391                _tmpscreen2 = NULL;
     392        }
     393
     394        if (_overlayscreen) {
     395                SDL_FreeSurface(_overlayscreen);
     396                _overlayscreen = NULL;
     397        }
     398
    364399#ifdef USE_OSD
    365400        if (_osdSurface) {
    366401                SDL_FreeSurface(_osdSurface);
     
    373408        if (!_screen)
    374409                return;
    375410
    376         // Keep around the old _screen & _tmpscreen so we can restore the screen data
     411        // Keep around the old _screen & _overlayscreen so we can restore the screen data
    377412        // after the mode switch.
    378413        SDL_Surface *old_screen = _screen;
    379         SDL_Surface *old_tmpscreen = _tmpscreen;
     414        SDL_Surface *old_overlayscreen = _overlayscreen;
    380415
    381416        // Release the HW screen surface
    382417        SDL_FreeSurface(_hwscreen);
    383418
     419        SDL_FreeSurface(_tmpscreen);
     420        SDL_FreeSurface(_tmpscreen2);
     421
    384422#ifdef USE_OSD
    385423        // Release the OSD surface
    386424        SDL_FreeSurface(_osdSurface);
     
    394432
    395433        // Restore old screen content
    396434        SDL_BlitSurface(old_screen, NULL, _screen, NULL);
    397         SDL_BlitSurface(old_tmpscreen, NULL, _tmpscreen, NULL);
    398        
     435        SDL_BlitSurface(old_overlayscreen, NULL, _overlayscreen, NULL);
     436
    399437        // Free the old surfaces
    400438        SDL_FreeSurface(old_screen);
    401         SDL_FreeSurface(old_tmpscreen);
     439        SDL_FreeSurface(old_overlayscreen);
    402440
    403441        // Update cursor to new scale
    404442        blitCursor();
     
    419457}
    420458
    421459void OSystem_SDL::internUpdateScreen() {
     460        SDL_Surface *srcSurf, *origSurf;
     461        int height, width;
     462        ScalerProc *scalerProc;
     463        int scale1, scale2;
     464
    422465        assert(_hwscreen != NULL);
    423466
    424467        // If the shake position changed, fill the dirty area with blackness
     
    467510        }
    468511#endif
    469512
    470         undrawMouse();
     513        if (!_overlayVisible) {
     514                origSurf = _screen;
     515                srcSurf = _tmpscreen;
     516                width = _screenWidth;
     517                height = _screenHeight;
     518                scalerProc = _scalerProc;
     519                scale1 = _scaleFactor;
     520                scale2 = 1;
     521        } else {
     522                origSurf = _overlayscreen;
     523                srcSurf = _tmpscreen2;
     524                width = _overlayWidth;
     525                height = _overlayHeight;
     526                scalerProc = scalersMagn[_overlayScale-1][_scaleFactor-1];
     527
     528                scale1 = _scaleFactor;
     529                scale2 = _overlayScale;
     530        }
    471531
    472532        // Force a full redraw if requested
    473533        if (_forceFull) {
    474534                _numDirtyRects = 1;
    475535                _dirtyRectList[0].x = 0;
    476536                _dirtyRectList[0].y = 0;
    477                 _dirtyRectList[0].w = _screenWidth;
    478                 _dirtyRectList[0].h = _screenHeight;
    479         }
     537                _dirtyRectList[0].w = width;
     538                _dirtyRectList[0].h = height;
     539        } else
     540                undrawMouse();
    480541
    481542        // Only draw anything if necessary
    482543        if (_numDirtyRects > 0) {
     
    486547                uint32 srcPitch, dstPitch;
    487548                SDL_Rect *lastRect = _dirtyRectList + _numDirtyRects;
    488549
    489                 if (_scalerProc == Normal1x && !_adjustAspectRatio) {
    490                         SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen;
     550                if (scalerProc == Normal1x && !_adjustAspectRatio && 0) {
    491551                        for (r = _dirtyRectList; r != lastRect; ++r) {
    492552                                dst = *r;
    493553                               
    494                                 if (_overlayVisible) {
    495                                         // FIXME: I don't understand why this is necessary...
    496                                         dst.x--;
    497                                         dst.y--;
    498                                 }
    499554                                dst.y += _currentShakePos;
    500                                 if (SDL_BlitSurface(target, r, _hwscreen, &dst) != 0)
     555                                if (SDL_BlitSurface(origSurf, r, _hwscreen, &dst) != 0)
    501556                                        error("SDL_BlitSurface failed: %s", SDL_GetError());
    502557                        }
    503558                } else {
    504                         if (!_overlayVisible) {
    505                                 for (r = _dirtyRectList; r != lastRect; ++r) {
    506                                         dst = *r;
    507                                         dst.x++;        // Shift rect by one since 2xSai needs to acces the data around
    508                                         dst.y++;        // any pixel to scale it, and we want to avoid mem access crashes.
    509                                         if (SDL_BlitSurface(_screen, r, _tmpscreen, &dst) != 0)
    510                                                 error("SDL_BlitSurface failed: %s", SDL_GetError());
    511                                 }
     559                        for (r = _dirtyRectList; r != lastRect; ++r) {
     560                                dst = *r;
     561                                dst.x++;        // Shift rect by one since 2xSai needs to acces the data around
     562                                dst.y++;        // any pixel to scale it, and we want to avoid mem access crashes.
     563
     564                                if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0)
     565                                        error("SDL_BlitSurface failed: %s", SDL_GetError());
    512566                        }
    513567
    514                         SDL_LockSurface(_tmpscreen);
     568                        SDL_LockSurface(srcSurf);
    515569                        SDL_LockSurface(_hwscreen);
    516570
    517                         srcPitch = _tmpscreen->pitch;
     571                        srcPitch = srcSurf->pitch;
    518572                        dstPitch = _hwscreen->pitch;
    519573
    520574                        for (r = _dirtyRectList; r != lastRect; ++r) {
    521575                                register int dst_y = r->y + _currentShakePos;
    522576                                register int dst_h = 0;
    523577                                register int orig_dst_y = 0;
     578                                register int rx1 = r->x * scale1 / scale2;
    524579
    525                                 if (dst_y < _screenHeight) {
     580                                if (dst_y < height) {
    526581                                        dst_h = r->h;
    527                                         if (dst_h > _screenHeight - dst_y)
    528                                                 dst_h = _screenHeight - dst_y;
     582                                        if (dst_h > height - dst_y)
     583                                                dst_h = height - dst_y;
    529584
    530                                         dst_y *= _scaleFactor;
     585                                        orig_dst_y = dst_y;
     586                                        dst_y = dst_y * scale1 / scale2;
    531587
    532                                         if (_adjustAspectRatio) {
    533                                                 orig_dst_y = dst_y;
     588                                        if (_adjustAspectRatio)
    534589                                                dst_y = real2Aspect(dst_y);
     590
     591                                        if (scale1 == 3 && scale2 == 2 && _overlayVisible) {
     592                                                if (r->y % 2)
     593                                                        r->y--;
     594                                                dst_y -= dst_y % 3;
    535595                                        }
    536596
    537                                         _scalerProc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
    538                                                 (byte *)_hwscreen->pixels + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h);
     597                                        scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
     598                                                           (byte *)_hwscreen->pixels + rx1 * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h);
    539599                                }
    540 
    541                                 r->x *= _scaleFactor;
     600                               
     601                                r->x = rx1;
    542602                                r->y = dst_y;
    543                                 r->w *= _scaleFactor;
    544                                 r->h = dst_h * _scaleFactor;
     603                                r->w = r->w * scale1 / scale2;
     604                                r->h = dst_h * scale1 / scale2;
    545605
    546                                 if (_adjustAspectRatio && orig_dst_y / _scaleFactor < _screenHeight)
    547                                         r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y);
     606                                if (_adjustAspectRatio && orig_dst_y < height)
     607                                        r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1 / scale2);
    548608                        }
    549                         SDL_UnlockSurface(_tmpscreen);
     609                        SDL_UnlockSurface(srcSurf);
    550610                        SDL_UnlockSurface(_hwscreen);
    551611                }
    552612
     
    564624                        SDL_BlitSurface(_osdSurface, 0, _hwscreen, 0);
    565625                }
    566626#endif
    567                
    568627                // Finally, blit all our changes to the screen
    569628                SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList);
    570629        } else {
     
    730789        if (_forceFull)
    731790                return;
    732791
    733         if (mouseRect) {
    734                 SDL_Rect *r = &_dirtyRectList[_numDirtyRects++];
    735                 r->x = x;
    736                 r->y = y;
    737                 r->w = w;
    738                 r->h = h;
    739                 return;
    740         }
     792        if (mouseRect) {
     793                SDL_Rect *r = &_dirtyRectList[_numDirtyRects++];
     794                r->x = x;
     795                r->y = y;
     796                r->w = w;
     797                r->h = h;
     798                return;
     799        }
     800
     801        int height, width;
     802
     803        if (!_overlayVisible) {
     804                width = _screenWidth;
     805                height = _screenHeight;
     806        } else {
     807                width = _overlayWidth;
     808                height = _overlayHeight;
     809        }
    741810
    742811        if (_numDirtyRects == NUM_DIRTY_RECT)
    743812                _forceFull = true;
     
    762831                        y=0;
    763832                }
    764833
    765                 if (w > _screenWidth - x) {
    766                         w = _screenWidth - x;
     834                if (w > width - x) {
     835                        w = width - x;
    767836                }
    768837
    769                 if (h > _screenHeight - y) {
    770                         h = _screenHeight - y;
     838                if (h > height - y) {
     839                        h = height - y;
    771840                }
    772841
    773                 if (_adjustAspectRatio)
     842                if (_adjustAspectRatio) {
    774843                        makeRectStretchable(x, y, w, h);
     844                        if (_scaleFactor == 3 && _overlayScale == 2 && _overlayVisible) {
     845                                if (y % 2)
     846                                        y++;
     847                        }
     848                }
    775849       
    776850                r->x = x;
    777851                r->y = y;
     
    9311005        assert (_transactionMode == kTransactionNone);
    9321006
    9331007        _overlayVisible = false;
     1008        clearOverlay();
    9341009        _forceFull = true;
    9351010}
    9361011
    9371012void OSystem_SDL::clearOverlay() {
    938         assert (_transactionMode == kTransactionNone);
     1013        //assert (_transactionMode == kTransactionNone);
    9391014
    940         if (!_overlayVisible)
    941                 return;
    942        
    9431015        Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
    9441016       
     1017        if (!_overlayVisible)
     1018                return;
     1019
    9451020        // Clear the overlay by making the game screen "look through" everywhere.
    9461021        SDL_Rect src, dst;
    9471022        src.x = src.y = 0;
     
    9511026        if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0)
    9521027                error("SDL_BlitSurface failed: %s", SDL_GetError());
    9531028
     1029        SDL_LockSurface(_tmpscreen);
     1030        SDL_LockSurface(_overlayscreen);
     1031        if (_overlayScale == _scaleFactor) {
     1032                _scalerProc((byte *)(_tmpscreen->pixels) + _tmpscreen->pitch + 2,
     1033                                        _tmpscreen->pitch, (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _screenWidth, _screenHeight);
     1034        } else {
     1035                // Quality is degraded here. It is possible to run one-less scaler here, but is it
     1036                // really needed? Quality will anyway be degraded because of 1.5x scaler.
     1037                (scalersMagn[0][_overlayScale-1])((byte *)(_tmpscreen->pixels) + _tmpscreen->pitch + 2,
     1038                                          _tmpscreen->pitch, (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _screenWidth, _screenHeight);
     1039        }
     1040        SDL_UnlockSurface(_tmpscreen);
     1041        SDL_UnlockSurface(_overlayscreen);
     1042
    9541043        _forceFull = true;
    9551044}
    9561045
    9571046void OSystem_SDL::grabOverlay(OverlayColor *buf, int pitch) {
    9581047        assert (_transactionMode == kTransactionNone);
    9591048
    960         if (!_overlayVisible)
    961                 return;
    962 
    963         if (_tmpscreen == NULL)
     1049        if (_overlayscreen == NULL)
    9641050                return;
    9651051
    966         if (SDL_LockSurface(_tmpscreen) == -1)
     1052        if (SDL_LockSurface(_overlayscreen) == -1)
    9671053                error("SDL_LockSurface failed: %s", SDL_GetError());
    9681054
    969         byte *src = (byte *)_tmpscreen->pixels + _tmpscreen->pitch + 2; // Offset by one row, one column
    970         int h = _screenHeight;
     1055        byte *src = (byte *)_overlayscreen->pixels;
     1056        int h = _overlayHeight;
    9711057        do {
    972                 memcpy(buf, src, _screenWidth*2);
    973                 src += _tmpscreen->pitch;
     1058                memcpy(buf, src, _overlayWidth*2);
     1059                src += _overlayscreen->pitch;
    9741060                buf += pitch;
    9751061        } while (--h);
    9761062
    977         SDL_UnlockSurface(_tmpscreen);
     1063        SDL_UnlockSurface(_overlayscreen);
    9781064}
    9791065
    9801066void OSystem_SDL::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
    9811067        assert (_transactionMode == kTransactionNone);
    9821068
    983         if (!_overlayVisible)
    984                 return;
    985 
    986         if (_tmpscreen == NULL)
     1069        if (_overlayscreen == NULL)
    9871070                return;
    9881071
    9891072        // Clip the coordinates
     
    9981081                y = 0;
    9991082        }
    10001083
    1001         if (w > _screenWidth - x) {
    1002                 w = _screenWidth - x;
     1084        if (w > _overlayWidth - x) {
     1085                w = _overlayWidth - x;
    10031086        }
    10041087
    1005         if (h > _screenHeight-y) {
    1006                 h = _screenHeight - y;
     1088        if (h > _overlayHeight - y) {
     1089                h = _overlayHeight - y;
    10071090        }
    10081091
    10091092        if (w <= 0 || h <= 0)
     
    10131096        _cksumValid = false;
    10141097        addDirtyRect(x, y, w, h);
    10151098
    1016         if (SDL_LockSurface(_tmpscreen) == -1)
     1099        if (SDL_LockSurface(_overlayscreen) == -1)
    10171100                error("SDL_LockSurface failed: %s", SDL_GetError());
    10181101
    1019         byte *dst = (byte *)_tmpscreen->pixels + (y + 1) * _tmpscreen->pitch + (x + 1) * 2;
     1102        byte *dst = (byte *)_overlayscreen->pixels + y * _overlayscreen->pitch + x * 2;
    10201103        do {
    10211104                memcpy(dst, buf, w * 2);
    1022                 dst += _tmpscreen->pitch;
     1105                dst += _overlayscreen->pitch;
    10231106                buf += pitch;
    10241107        } while (--h);
    10251108
    1026         SDL_UnlockSurface(_tmpscreen);
     1109        SDL_UnlockSurface(_overlayscreen);
    10271110}
    10281111
    10291112OverlayColor OSystem_SDL::RGBToColor(uint8 r, uint8 g, uint8 b) {
    1030         return SDL_MapRGB(_tmpscreen->format, r, g, b);
     1113        return SDL_MapRGB(_overlayscreen->format, r, g, b);
    10311114}
    10321115
    10331116void OSystem_SDL::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) {
    1034         SDL_GetRGB(color, _tmpscreen->format, &r, &g, &b);
     1117        SDL_GetRGB(color, _overlayscreen->format, &r, &g, &b);
    10351118}
    10361119
    10371120
     
    10611144
    10621145void OSystem_SDL::warpMouse(int x, int y) {
    10631146        if (_mouseCurState.x != x || _mouseCurState.y != y) {
    1064                 SDL_WarpMouse(x * _scaleFactor, y * _scaleFactor);
     1147                if (_overlayVisible)
     1148                        SDL_WarpMouse(x * _scaleFactor / _overlayScale, y * _scaleFactor / _overlayScale);
     1149                else
     1150                        SDL_WarpMouse(x * _scaleFactor, y * _scaleFactor);
    10651151
    10661152                // SDL_WarpMouse() generates a mouse movement event, so
    10671153                // setMousePos() would be called eventually. However, the
     
    12351321}
    12361322
    12371323void OSystem_SDL::undrawMouse() {
     1324        // When we switch bigger overlay off mouse jumps. Argh!
     1325        // this intended to prevent undrawing offscreen mouse
     1326        if (!_overlayVisible)
     1327                if (_adjustAspectRatio) {
     1328                        if (_mouseBackup.x > _screenWidth || aspect2Real(_mouseBackup.y) > _screenHeight)
     1329                                return;
     1330                } else {
     1331                        if (_mouseBackup.x > _screenWidth || _mouseBackup.y > _screenHeight)
     1332                                return;
     1333                }
     1334
    12381335        if (_mouseBackup.w) {
    12391336                if (_adjustAspectRatio)
    12401337                        addDirtyRect(_mouseBackup.x, aspect2Real(_mouseBackup.y), _mouseBackup.w,
    1241                                                    _mouseBackup.h);
     1338                                                 _mouseBackup.h);
    12421339                else
    12431340                        addDirtyRect(_mouseBackup.x, _mouseBackup.y, _mouseBackup.w,
    1244                                                    _mouseBackup.h);
     1341                                                 _mouseBackup.h);
    12451342        }
    12461343}
    12471344
     
    12501347                _mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
    12511348                return;
    12521349        }
    1253  
     1350
    12541351        SDL_Rect src, dst;
    12551352        bool scale;
     1353        int scale1, scale2;
     1354        int width, height;
     1355
     1356        if (!_overlayVisible) {
     1357                scale1 = _scaleFactor;
     1358                scale2 = 1;
     1359                width = _screenWidth;
     1360                height = _screenHeight;
     1361        } else {
     1362                scale1 = _scaleFactor;
     1363                scale2 = _overlayScale;
     1364                width = _overlayWidth;
     1365                height = _overlayHeight;
     1366        }
    12561367
    12571368        scale = (_scaleFactor > _cursorTargetScale);
    12581369
     
    12671378        int dx, dy;
    12681379 
    12691380        dx = dst.x; dy = dst.y;
    1270         dx = scale ? dst.x * _scaleFactor / _cursorTargetScale : dst.x;
    1271         dy = scale ? dst.y * _scaleFactor / _cursorTargetScale : dst.y;
    1272         if (_adjustAspectRatio)
    1273                 dy = real2Aspect(dy);
     1381        dx = scale ? dst.x * scale1 / scale2 / _cursorTargetScale : dst.x;
     1382        dy = scale ? dst.y * scale1 / scale2 / _cursorTargetScale : dst.y;
    12741383
    12751384        if (dst.x < 0) {
    12761385                dst.w += dx;
     
    12841393        }
    12851394
    12861395        // Quick check to see if anything has to be drawn at all
    1287         if (dst.w <= 0 || dst.h <= 0)
     1396        if (dst.w <= 0 || dst.h <= 0 || dst.x >= width || dst.y >= height)
    12881397                return;
    12891398 
    12901399        src.w = dst.w;
     
    12921401 
    12931402        if (_adjustAspectRatio)
    12941403                dst.y = real2Aspect(dst.y);
    1295  
     1404
     1405        // special case for 1o5x scaler to prevent backgound shaking
     1406        if (scale1 == 3 && scale2 == 2) {
     1407                if (dst.x % 2)
     1408                        dst.x--;
     1409                if (dst.y % 2)
     1410                        dst.y--;
     1411        }
     1412
    12961413        _mouseBackup.x = dst.x;
    12971414        _mouseBackup.y = dst.y;
    12981415        _mouseBackup.w = dst.w;
    12991416        _mouseBackup.h = dst.h;
    1300  
    1301         dst.x *= _scaleFactor;
    1302         dst.y *= _scaleFactor;
    1303  
     1417
     1418        dst.x = dst.x * scale1 / scale2;
     1419        dst.y = dst.y * scale1 / scale2;
     1420
    13041421        if (SDL_BlitSurface(_mouseSurface, &src, _hwscreen, &dst) != 0)
    13051422                error("SDL_BlitSurface failed: %s", SDL_GetError());
    1306  
     1423
    13071424        addDirtyRect(dst.x, dst.y, dst.w, dst.h, true);
    13081425}
    13091426
  • backends/sdl/sdl-common.h

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
    retrieving revision 1.74
    diff -u -r1.74 sdl-common.h
     
    5858
    5959        // Set the size of the video bitmap.
    6060        // Typically, 320x200
    61         virtual void initSize(uint w, uint h); // overloaded by CE backend
     61        virtual void initSize(uint w, uint h, int overlayScale); // overloaded by CE backend
    6262
    6363        // Set colors of the palette
    6464        void setPalette(const byte *colors, uint start, uint num);
     
    142142        virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
    143143        virtual int16 getHeight();
    144144        virtual int16 getWidth();
     145        virtual int16 getOverlayHeight()  { return _overlayHeight; }
     146        virtual int16 getOverlayWidth()   { return _overlayWidth; }
     147        virtual int ScreenToOverlayX(int x) { return x * _overlayScale; }
     148        virtual int ScreenToOverlayY(int y) { return y * _overlayScale; }
     149        virtual int OverlayToScreenX(int x) { return x / _overlayScale; }
     150        virtual int OverlayToScreenY(int y) { return y / _overlayScale; }
    145151
    146152        // Methods that convert RGB to/from colors suitable for the overlay.
    147153        virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b);
     
    187193        SDL_Surface *_screen;
    188194        int _screenWidth, _screenHeight;
    189195
    190         // temporary screen (for scalers/overlay)
     196        // temporary screen (for scalers)
    191197        SDL_Surface *_tmpscreen;
     198        SDL_Surface *_tmpscreen2;
     199
     200        // overlay
     201        SDL_Surface *_overlayscreen;
     202        int _overlayWidth, _overlayHeight;
     203        int _overlayScale;
    192204        bool _overlayVisible;
    193205
    194206        // Audio
     
    214226                int mode;
    215227                bool modeChanged;
    216228                int w;
    217                 bool wChanged;
    218229                int h;
    219                 bool hChanged;
     230                int overlayScale;
     231                bool sizeChanged;
    220232                bool fs;
    221233                bool fsChanged;
    222234                bool ar;
  • backends/sdl/sdl.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
    retrieving revision 1.80
    diff -u -r1.80 sdl.cpp
     
    9797        _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
    9898#endif
    9999        _hwscreen(0), _screen(0), _screenWidth(0), _screenHeight(0),
    100         _tmpscreen(0), _overlayVisible(false),
     100        _tmpscreen(0), _overlayVisible(false), _overlayScale(1),
     101        _overlayscreen(0), _tmpscreen2(0),
    101102        _samplesPerSec(0),
    102103        _cdrom(0), _scalerProc(0), _modeChanged(false), _dirtyChecksums(0),
    103104        _mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseSurface(0),
  • base/main.cpp

    RCS file: /cvsroot/scummvm/scummvm/base/main.cpp,v
    retrieving revision 1.70
    diff -u -r1.70 main.cpp
     
    223223                // Set the user specified graphics mode (if any).
    224224                system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
    225225       
    226                 // GUI is (currently) always running at 320x200
    227                 system.initSize(320, 200);
     226                // Make GUI 640 x 400
     227                system.initSize(320, 200, 2);
    228228        system.endGFXTransaction();
    229229
    230230       
  • common/system.h

    RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
    retrieving revision 1.88
    diff -u -r1.88 system.h
     
    216216         * @param width         the new virtual screen width
    217217         * @param height        the new virtual screen height
    218218         */
    219         virtual void initSize(uint width, uint height) = 0;
     219        virtual void initSize(uint width, uint height, int overlayScale = -1) = 0;
    220220
    221221        /**
    222222         * Begin a new GFX transaction, which is a sequence of GFX mode changes.
     
    351351        virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) = 0;
    352352        virtual int16 getOverlayHeight()  { return getHeight(); }
    353353        virtual int16 getOverlayWidth()   { return getWidth(); }
     354        virtual int ScreenToOverlayX(int x) { return x; }
     355        virtual int ScreenToOverlayY(int y) { return y; }
     356        virtual int OverlayToScreenX(int x) { return x; }
     357        virtual int OverlayToScreenY(int y) { return y; }
    354358
    355359        /**
    356360        * Convert the given RGB triplet into an OverlayColor. A OverlayColor can
     
    517521                /**
    518522                 * The mouse coordinates, in virtual screen coordinates. Only valid
    519523                 * for mouse events.
    520                  * Virtual screen coordinatest means: the coordinate system of the
     524                 * Virtual screen coordinates means: the coordinate system of the
    521525                 * screen area as defined by the most recent call to initSize().
    522526                 */
    523527                Common::Point mouse;
  • gui/newgui.cpp

    RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
    retrieving revision 1.101
    diff -u -r1.101 newgui.cpp
     
    8585                kDefaultGUIHeight = 200
    8686        };
    8787
    88         _scaleFactor = MIN(_system->getWidth() / kDefaultGUIWidth, _system->getHeight() / kDefaultGUIHeight);
     88        _scaleFactor = MIN(_system->getOverlayWidth() / kDefaultGUIWidth, _system->getOverlayHeight() / kDefaultGUIHeight);
    8989
    9090        // Pick the font depending on the scale factor.
    9191        if (_scaleFactor == 1)
  • scumm/scumm.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
    retrieving revision 1.345
    diff -u -r1.345 scumm.cpp
     
    11561156        _system->beginGFXTransaction();
    11571157                initCommonGFX(detector);
    11581158                if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
    1159                         _system->initSize(Common::kHercW, Common::kHercH);
     1159                        _system->initSize(Common::kHercW, Common::kHercH, 1);
    11601160                        _features |= GF_DEFAULT_TO_1X_SCALER;
    11611161                        _system->setGraphicsMode("1x");
    11621162                } else {
    1163                         _system->initSize(_screenWidth, _screenHeight);
     1163                        _system->initSize(_screenWidth, _screenHeight, 2);
     1164                        if (_features & GF_DEFAULT_TO_1X_SCALER)
     1165                                _system->setGraphicsMode("1x");
    11641166                }
    11651167
    11661168                // FIXME: All this seems a dirty hack to me. We already
    11671169                // have this check in constructor
    11681170                if (_heversion >= 71) {
    11691171                        _features |= GF_DEFAULT_TO_1X_SCALER;
    1170                         _system->setGraphicsMode("1x");
    11711172                }
     1173
    11721174        _system->endGFXTransaction();
    11731175
    11741176        int cd_num = ConfMan.getInt("cdrom");