Ticket #8159: ratio800_2.diff

File ratio800_2.diff, 14.6 KB (added by SF/cigaes, 21 years ago)

scaler a bit more optimized

  • backends/sdl/sdl-common.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
    retrieving revision 1.32
    diff -u -r1.32 sdl-common.cpp
     
    423423
    424424void OSystem_SDL_Common::warp_mouse(int x, int y) {
    425425        if (_mouseCurState.x != x || _mouseCurState.y != y)
    426                 SDL_WarpMouse(x * _scaleFactor, y * _scaleFactor);
     426                SDL_WarpMouse(x * _scaleFactor_hmul / _scaleFactor_hdiv,
     427                        y * _scaleFactor_vmul / _scaleFactor_vdiv);
    427428}
    428429       
    429430void OSystem_SDL_Common::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {
     
    624625                        km.x = event->mouse.x = ev.motion.x;
    625626                        km.y = event->mouse.y = ev.motion.y;
    626627
    627                         event->mouse.x /= _scaleFactor;
    628                         event->mouse.y /= _scaleFactor;
     628                        event->mouse.x *= _scaleFactor_hdiv;
     629                        event->mouse.x /= _scaleFactor_hmul;
     630                        event->mouse.y *= _scaleFactor_vdiv;
     631                        event->mouse.y /= _scaleFactor_vmul;
    629632
    630633                        return true;
    631634
     
    644647                                break;
    645648                        km.x = event->mouse.x = ev.motion.x;
    646649                        km.y = event->mouse.y = ev.motion.y;
    647                         event->mouse.x /= _scaleFactor;
    648                         event->mouse.y /= _scaleFactor;
     650                        event->mouse.x *= _scaleFactor_hdiv;
     651                        event->mouse.x /= _scaleFactor_hmul;
     652                        event->mouse.y *= _scaleFactor_vdiv;
     653                        event->mouse.y /= _scaleFactor_vmul;
    649654
    650655                        return true;
    651656
     
    658663                                break;
    659664                        event->mouse.x = ev.button.x;
    660665                        event->mouse.y = ev.button.y;
    661                         event->mouse.x /= _scaleFactor;
    662                         event->mouse.y /= _scaleFactor;
     666                        event->mouse.x *= _scaleFactor_hdiv;
     667                        event->mouse.x /= _scaleFactor_hmul;
     668                        event->mouse.y *= _scaleFactor_vdiv;
     669                        event->mouse.y /= _scaleFactor_vmul;
    663670                        return true;
    664671
    665672                case SDL_JOYBUTTONDOWN:
  • backends/sdl/sdl-common.h

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
    retrieving revision 1.15
    diff -u -r1.15 sdl-common.h
     
    125125
    126126protected:
    127127        typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
    128                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     128                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
    129129
    130130        OSystem_SDL_Common();
    131131        virtual ~OSystem_SDL_Common();
     
    150150        };
    151151
    152152        bool _forceFull; // Force full redraw on next update_screen
    153         int _scaleFactor;
     153        int _scaleFactor_hmul;
     154        int _scaleFactor_hdiv;
     155        int _scaleFactor_vmul;
     156        int _scaleFactor_vdiv;
    154157        int _mode;
    155158        bool _full_screen;
    156159        uint32 _mode_flags;
  • backends/sdl/sdl.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
    retrieving revision 1.21
    diff -u -r1.21 sdl.cpp
     
    8484       
    8585        switch(_mode) {
    8686        case GFX_2XSAI:
    87                 _scaleFactor = 2;
     87                _scaleFactor_hmul = _scaleFactor_vmul = 2;
     88                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    8889                _scaler_proc = _2xSaI;
    8990                break;
    9091        case GFX_SUPER2XSAI:
    91                 _scaleFactor = 2;
     92                _scaleFactor_hmul = _scaleFactor_vmul = 2;
     93                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    9294                _scaler_proc = Super2xSaI;
    9395                break;
    9496        case GFX_SUPEREAGLE:
    95                 _scaleFactor = 2;
     97                _scaleFactor_hmul = _scaleFactor_vmul = 2;
     98                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    9699                _scaler_proc = SuperEagle;
    97100                break;
    98101        case GFX_ADVMAME2X:
    99                 _scaleFactor = 2;
     102                _scaleFactor_hmul = _scaleFactor_vmul = 2;
     103                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    100104                _scaler_proc = AdvMame2x;
    101105                break;
    102106        case GFX_TV2X:
    103                 _scaleFactor = 2;
     107                _scaleFactor_hmul = _scaleFactor_vmul = 2;
     108                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    104109                _scaler_proc = TV2x;
    105110                break;
    106111
     112        case GFX_RATIO800:
     113                _scaleFactor_hmul = 5;
     114                _scaleFactor_hdiv = 2;
     115                _scaleFactor_vmul = 3;
     116                _scaleFactor_vdiv = 1;
     117                _scaler_proc = Ratio800;
     118                break;
     119
    107120        case GFX_DOUBLESIZE:
    108                 _scaleFactor = 2;
     121                _scaleFactor_hmul = _scaleFactor_vmul = 2;
     122                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    109123                _scaler_proc = Normal2x;
    110124                break;
    111125
     
    114128                        warning("full screen in useless in triplesize mode, reverting to normal mode");
    115129                        goto normal_mode;
    116130                }
    117                 _scaleFactor = 3;
     131                _scaleFactor_hmul = _scaleFactor_vmul = 3;
     132                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    118133                _scaler_proc = Normal3x;
    119134                break;
    120135
    121136        case GFX_NORMAL:
    122137normal_mode:;
    123                 _scaleFactor = 1;
     138                _scaleFactor_hmul = _scaleFactor_vmul = 1;
     139                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    124140                _scaler_proc = Normal1x;
    125141                break;
    126142        default:
    127143                error("unknown gfx mode");
    128                 _scaleFactor = 1;
     144                _scaleFactor_hmul = _scaleFactor_vmul = 1;
     145                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    129146                _scaler_proc = NULL;
    130147        }
    131148
     
    140157        //
    141158        // Create the surface that contains the scaled graphics in 16 bit mode
    142159        //
    143         _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16,
     160        _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor_hmul / _scaleFactor_hdiv, _screenHeight * _scaleFactor_vmul / _scaleFactor_vdiv, 16,
    144161                _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
    145162        );
    146163        if (_hwscreen == NULL)
     
    169186                error("_tmpscreen failed");
    170187       
    171188        // keyboard cursor control, some other better place for it?
    172         km.x_max = _screenWidth * _scaleFactor - 1;
    173         km.y_max = _screenHeight * _scaleFactor - 1;
     189        km.x_max = _screenWidth * _scaleFactor_hmul / _scaleFactor_hdiv - 1;
     190        km.y_max = _screenHeight * _scaleFactor_vmul / _scaleFactor_vdiv - 1;
    174191        km.delay_time = 25;
    175192        km.last_time = 0;
    176193
     
    231248
    232249        // If the shake position changed, fill the dirty area with blackness
    233250        if (_currentShakePos != _newShakePos) {
    234                 SDL_Rect blackrect = {0, 0, _screenWidth*_scaleFactor, _newShakePos*_scaleFactor};
     251                /* ratio: FIXME */
     252                SDL_Rect blackrect = {0, 0, _screenWidth*_scaleFactor_hmul / _scaleFactor_hdiv, _newShakePos*_scaleFactor_vmul / _scaleFactor_vdiv};
    235253                SDL_FillRect(_hwscreen, &blackrect, 0);
    236254
    237255                _currentShakePos = _newShakePos;
     
    297315                                if (dst_h > _screenHeight - dst_y)
    298316                                        dst_h = _screenHeight - dst_y;
    299317                               
    300                                 dst_y *= _scaleFactor;
     318                                dst_y *= _scaleFactor_vmul;
     319                                dst_y /= _scaleFactor_vdiv;
    301320                               
    302321                                _scaler_proc((byte*)_tmpscreen->pixels + (r->x*2+2) + (r->y+1)*srcPitch, srcPitch, NULL,
    303                                         (byte*)_hwscreen->pixels + r->x*2*_scaleFactor + dst_y*dstPitch, dstPitch, r->w, dst_h);
     322                                        (byte*)_hwscreen->pixels + (r->x*_scaleFactor_hmul / _scaleFactor_hdiv) * 2 + dst_y*dstPitch, dstPitch, r->x, r->y, r->w, dst_h);
    304323                        }
    305324                       
    306                         r->x *= _scaleFactor;
     325                        r->w = (r->x + r->w) * _scaleFactor_hmul / _scaleFactor_hdiv;
     326                        r->x *= _scaleFactor_hmul;
     327                        r->x /= _scaleFactor_hdiv;
     328                        r->w -= r->x;
     329                        r->h = (r->y + r->h) * _scaleFactor_vmul / _scaleFactor_vdiv;
    307330                        r->y = dst_y;
    308                         r->w *= _scaleFactor;
    309                         r->h = dst_h * _scaleFactor;
     331                        r->h -= r->y;
    310332                }
    311333               
    312334                SDL_UnlockSurface(_tmpscreen);
     
    316338                // This is necessary if shaking is active.
    317339                if (_forceFull) {
    318340                        _dirty_rect_list[0].y = 0;
    319                         _dirty_rect_list[0].h = _screenHeight * _scaleFactor;
     341                        _dirty_rect_list[0].h = _screenHeight * _scaleFactor_vmul / _scaleFactor_vdiv;
    320342                }
    321343
    322344                // Finally, blit all our changes to the screen
  • common/gameDetector.cpp

    RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v
    retrieving revision 1.66
    diff -u -r1.66 gameDetector.cpp
     
    4747        "\t-p<path>   - look for game in <path>\n"
    4848        "\t-x[<num>]  - load this savegame (default: 0 - autosave)\n"
    4949        "\t-f         - fullscreen mode\n"
    50         "\t-g<mode>   - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x,tv2x)\n"
     50        "\t-g<mode>   - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x,tv2x,ratio800)\n"
    5151        "\t-e<mode>   - set music engine (see README for details)\n"
    5252        "\t-a         - specify game is amiga version\n"
    5353        "\t-q<lang>   - specify language (en,de,fr,it,pt,es,ja,zh,ko,hb)\n"
     
    184184        {"supereagle", "SuperEagle", GFX_SUPEREAGLE},
    185185        {"advmame2x", "AdvMAME2x", GFX_ADVMAME2X},
    186186        {"tv2x", "TV2x", GFX_TV2X},
     187        {"ratio800", "Ratio800", GFX_RATIO800},
    187188        {0, 0}
    188189};
    189190
  • common/scaler.cpp

    RCS file: /cvsroot/scummvm/scummvm/common/scaler.cpp,v
    retrieving revision 1.6
    diff -u -r1.6 scaler.cpp
     
    146146#define GREEN_MASK555 0x03E003E0
    147147
    148148void Super2xSaI(uint8 *srcPtr, uint32 srcPitch,
    149                                                                 uint8 *deltaPtr, uint8 *dstPtr, uint32 dstPitch, int width, int height)
     149                                                                uint8 *deltaPtr, uint8 *dstPtr, uint32 dstPitch,
     150            int x, int y, int width, int height)
    150151{
    151152        uint16 *bP;
    152153        uint8 *dP;
     
    265266}
    266267
    267268void SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
    268                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height)
     269                                                                uint8 *dstPtr, uint32 dstPitch,
     270            int x, int y, int width, int height)
    269271{
    270272        uint8 *dP;
    271273        uint16 *bP;
     
    385387}
    386388
    387389void _2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
    388                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height)
     390                                                uint8 *dstPtr, uint32 dstPitch,
     391            int x, int y, int width, int height)
    389392{
    390393        uint8 *dP;
    391394        uint16 *bP;
     
    582585        return (result & redblueMask) | ((result >> 16) & greenMask);
    583586}
    584587
     588/* not used */
    585589void Scale_2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 * /* deltaPtr */ ,
    586590                                                                 uint8 *dstPtr, uint32 dstPitch,
    587                                                                  uint32 dstWidth, uint32 dstHeight, int width, int height)
     591                                                                 uint32 dstWidth, uint32 dstHeight,
     592            int x, int y, int width, int height)
    588593{
    589594        uint8 *dP;
    590595        uint16 *bP;
     
    716721}
    717722
    718723void AdvMame2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
    719                                                         int width, int height)
     724            int x, int y, int width, int height)
    720725{
    721726        unsigned int nextlineSrc = srcPitch / sizeof(short);
    722727        short *p = (short *)srcPtr;
     
    748753
    749754
    750755void Normal1x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
    751                                                         int width, int height)
     756            int x, int y, int width, int height)
    752757{
    753758        while (height--) {
    754759                memcpy(dstPtr, srcPtr, 2 * width);
     
    758763}
    759764
    760765void Normal2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
    761                                                         int width, int height)
     766            int x, int y, int width, int height)
    762767{
    763768        uint8 *r;
    764769
     
    778783}
    779784
    780785void Normal3x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
    781                                                         int width, int height)
     786            int x, int y, int width, int height)
    782787{
    783788        uint8 *r;
    784789        uint32 dstPitch2 = dstPitch * 2;
     
    805810}
    806811
    807812void TV2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
    808                                         int width, int height)
     813            int x, int y, int width, int height)
    809814{
    810815        unsigned int nextlineSrc = srcPitch / sizeof(uint16);
    811816        uint16 *p = (uint16 *)srcPtr;
     
    828833                }
    829834                p += nextlineSrc;
    830835                q += nextlineDst << 1;
     836        }
     837}
     838
     839void Ratio800(uint8 *srcPtr, uint32 srcPitch, uint8 *null, uint8 *dstPtr, uint32 dstPitch,
     840            int x, int y, int width, int height)
     841{
     842        unsigned int nextlineSrc = srcPitch / sizeof(uint16);
     843        uint16 *p = (uint16 *)srcPtr;
     844
     845        unsigned int nextlineDst = dstPitch / sizeof(uint16);
     846        uint16 *q0 = (uint16 *)dstPtr;
     847        uint16 *q;
     848
     849        int i, j;
     850        uint16 c;
     851
     852        for(i = 0; i < height; i++) {
     853            q = q0;
     854            for(j = 0; j < width; j++) {
     855                c = *p;
     856                if((j ^ x) & 1) {
     857                    q[0] = q[nextlineDst] = q[nextlineDst * 2] =
     858                        INTERPOLATE(c, p[-1]);
     859                    q++;
     860                }
     861                p++;
     862                q[0] = q[nextlineDst] = q[nextlineDst * 2] =
     863                q[1] = q[nextlineDst + 1] = q[nextlineDst * 2 + 1] =
     864                    c;
     865                q += 2;
     866            }
     867            p += nextlineSrc - width;
     868            q0 += nextlineDst * 3;
    831869        }
    832870}
  • common/scaler.h

    RCS file: /cvsroot/scummvm/scummvm/common/scaler.h,v
    retrieving revision 1.2
    diff -u -r1.2 scaler.h
     
    2323
    2424extern int Init_2xSaI (uint32 BitFormat);
    2525extern void _2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr, uint8 *dstPtr,
    26                                                 uint32 dstPitch, int width, int height);
     26                                                uint32 dstPitch, int x, int y, int width, int height);
    2727extern void Super2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
    28                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     28                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
    2929extern void SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
    30                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     30                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
    3131extern void AdvMame2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null,
    32                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     32                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
    3333extern void Normal1x(uint8 *srcPtr, uint32 srcPitch, uint8 *null,
    34                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     34                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
    3535extern void Normal2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null,
    36                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     36                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
    3737extern void Normal3x(uint8 *srcPtr, uint32 srcPitch, uint8 *null,
    38                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     38                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
    3939extern void TV2x(uint8 *srcPtr, uint32 srcPitch, uint8 *null,
    40                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     40                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
     41extern void Ratio800(uint8 *srcPtr, uint32 srcPitch, uint8 *null,
     42                                                                uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height);
    4143
    4244#endif
  • common/system.h

    RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
    retrieving revision 1.19
    diff -u -r1.19 system.h
     
    223223        GFX_SUPER2XSAI = 4,
    224224        GFX_SUPEREAGLE = 5,
    225225        GFX_ADVMAME2X = 6,
    226         GFX_TV2X = 7
     226        GFX_TV2X = 7,
     227        GFX_RATIO800 = 8
    227228};
    228229
    229230