Ticket #8159: scummvm-ratio800-0.4.0.diff

File scummvm-ratio800-0.4.0.diff, 14.3 KB (added by SF/cigaes, 21 years ago)

up-to-date version for 0.4.0

  • backends/sdl/sdl-common.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
    retrieving revision 1.45
    diff -u -r1.45 sdl-common.cpp
     
    456456
    457457void OSystem_SDL_Common::warp_mouse(int x, int y) {
    458458        if (_mouseCurState.x != x || _mouseCurState.y != y)
    459                 SDL_WarpMouse(x * _scaleFactor, y * _scaleFactor);
     459                SDL_WarpMouse(x * _scaleFactor_hmul / _scaleFactor_hdiv,
     460                        y * _scaleFactor_vmul / _scaleFactor_vdiv);
    460461}
    461462       
    462463void OSystem_SDL_Common::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {
     
    656657                        km.x = event->mouse.x = ev.motion.x;
    657658                        km.y = event->mouse.y = ev.motion.y;
    658659
    659                         event->mouse.x /= _scaleFactor;
    660                         event->mouse.y /= _scaleFactor;
     660                        event->mouse.x *= _scaleFactor_hdiv;
     661                        event->mouse.x /= _scaleFactor_hmul;
     662                        event->mouse.y *= _scaleFactor_vdiv;
     663                        event->mouse.y /= _scaleFactor_vmul;
    661664
    662665                        return true;
    663666
     
    676679                                break;
    677680                        km.x = event->mouse.x = ev.button.x;
    678681                        km.y = event->mouse.y = ev.button.y;
    679                         event->mouse.x /= _scaleFactor;
    680                         event->mouse.y /= _scaleFactor;
     682                        event->mouse.x *= _scaleFactor_hdiv;
     683                        event->mouse.x /= _scaleFactor_hmul;
     684                        event->mouse.y *= _scaleFactor_vdiv;
     685                        event->mouse.y /= _scaleFactor_vmul;
    681686
    682687                        return true;
    683688
     
    690695                                break;
    691696                        event->mouse.x = ev.button.x;
    692697                        event->mouse.y = ev.button.y;
    693                         event->mouse.x /= _scaleFactor;
    694                         event->mouse.y /= _scaleFactor;
     698                        event->mouse.x *= _scaleFactor_hdiv;
     699                        event->mouse.x /= _scaleFactor_hmul;
     700                        event->mouse.y *= _scaleFactor_vdiv;
     701                        event->mouse.y /= _scaleFactor_vmul;
    695702                        return true;
    696703
    697704                case SDL_JOYBUTTONDOWN:
     
    794801                        }
    795802                        event->mouse.x = km.x;
    796803                        event->mouse.y = km.y;
    797                         event->mouse.x /= _scaleFactor;
    798                         event->mouse.y /= _scaleFactor;
     804                        event->mouse.x *= _scaleFactor_hdiv;
     805                        event->mouse.x /= _scaleFactor_hmul;
     806                        event->mouse.y *= _scaleFactor_vdiv;
     807                        event->mouse.y /= _scaleFactor_vmul;
    799808                        return true;
    800809
    801810                case SDL_VIDEOEXPOSE:
  • backends/sdl/sdl-common.h

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
    retrieving revision 1.20
    diff -u -r1.20 sdl-common.h
     
    124124        static OSystem *create(int gfx_mode, bool full_screen);
    125125
    126126protected:
    127         typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch,
    128                                                                 uint8 *dstPtr, uint32 dstPitch, int width, int height);
     127        typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, 
     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.28
    diff -u -r1.28 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        case GFX_DOTMATRIX:
    107                 _scaleFactor = 2;
     112                _scaleFactor_hmul = _scaleFactor_vmul = 2;
     113                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    108114                _scaler_proc = DotMatrix;
    109115                break;
    110116
     117        case GFX_RATIO800:
     118                _scaleFactor_hmul = 5;
     119                _scaleFactor_hdiv = 2;
     120                _scaleFactor_vmul = 3;
     121                _scaleFactor_vdiv = 1;
     122                _scaler_proc = Ratio800;
     123                break;
     124
    111125        case GFX_DOUBLESIZE:
    112                 _scaleFactor = 2;
     126                _scaleFactor_hmul = _scaleFactor_vmul = 2;
     127                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    113128                _scaler_proc = Normal2x;
    114129                break;
    115130
     
    118133                        warning("full screen in useless in triplesize mode, reverting to normal mode");
    119134                        goto normal_mode;
    120135                }
    121                 _scaleFactor = 3;
     136                _scaleFactor_hmul = _scaleFactor_vmul = 3;
     137                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    122138                _scaler_proc = Normal3x;
    123139                break;
    124140
    125141        case GFX_NORMAL:
    126142normal_mode:;
    127                 _scaleFactor = 1;
     143                _scaleFactor_hmul = _scaleFactor_vmul = 1;
     144                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    128145                _scaler_proc = Normal1x;
    129146                break;
    130147        default:
    131148                error("unknown gfx mode");
    132                 _scaleFactor = 1;
     149                _scaleFactor_hmul = _scaleFactor_vmul = 1;
     150                _scaleFactor_hdiv = _scaleFactor_vdiv = 1;
    133151                _scaler_proc = NULL;
    134152        }
    135153
     
    143161        //
    144162        // Create the surface that contains the scaled graphics in 16 bit mode
    145163        //
    146         _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16,
     164        _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor_hmul / _scaleFactor_hdiv, _screenHeight * _scaleFactor_vmul / _scaleFactor_vdiv, 16,
    147165                _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
    148166        );
    149167        if (_hwscreen == NULL)
     
    172190                error("_tmpscreen failed");
    173191
    174192        // keyboard cursor control, some other better place for it?
    175         km.x_max = _screenWidth * _scaleFactor - 1;
    176         km.y_max = _screenHeight * _scaleFactor - 1;
     193        km.x_max = _screenWidth * _scaleFactor_hmul / _scaleFactor_hdiv - 1;
     194        km.y_max = _screenHeight * _scaleFactor_vmul / _scaleFactor_vdiv - 1;
    177195        km.delay_time = 25;
    178196        km.last_time = 0;
    179197}
     
    234252
    235253        // If the shake position changed, fill the dirty area with blackness
    236254        if (_currentShakePos != _newShakePos) {
    237                 SDL_Rect blackrect = {0, 0, _screenWidth * _scaleFactor, _newShakePos * _scaleFactor};
     255                /* ratio: FIXME */
     256                SDL_Rect blackrect = {0, 0, _screenWidth * _scaleFactor_hmul / _scaleFactor_hdiv, _newShakePos * _scaleFactor_vmul / _scaleFactor_vdiv};
    238257                SDL_FillRect(_hwscreen, &blackrect, 0);
    239258
    240259                _currentShakePos = _newShakePos;
     
    300319                if (_scaler_proc != Normal1x) {
    301320                        SDL_LockSurface(_tmpscreen);
    302321                        SDL_LockSurface(_hwscreen);
    303 
     322               
    304323                        srcPitch = _tmpscreen->pitch;
    305324                        dstPitch = _hwscreen->pitch;
    306 
     325               
    307326                        for(r = _dirty_rect_list; r != last_rect; ++r) {
    308327                                register int dst_y = r->y + _currentShakePos;
    309328                                register int dst_h = 0;
     
    312331                                        if (dst_h > _screenHeight - dst_y)
    313332                                                dst_h = _screenHeight - dst_y;
    314333
    315                                                 dst_y *= _scaleFactor;
     334                                                dst_y *= _scaleFactor_vmul;
     335                                                dst_y /= _scaleFactor_vdiv;
    316336
    317337                                                _scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
    318                                                 (byte *)_hwscreen->pixels + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h);
     338                                                (byte *)_hwscreen->pixels + (r->x * _scaleFactor_hmul / _scaleFactor_hdiv) * 2 + dst_y*dstPitch, dstPitch, r->x, r->y, r->w, dst_h);
    319339                                }
    320340                       
    321                                 r->x *= _scaleFactor;
     341                                r->w = (r->x + r->w) * _scaleFactor_hmul / _scaleFactor_hdiv;
     342                                r->x *= _scaleFactor_hmul;
     343                                r->x /= _scaleFactor_hdiv;
     344                                r->w -= r->x;
     345                                r->h = (r->y + r->h) * _scaleFactor_vmul / _scaleFactor_vdiv;
    322346                                r->y = dst_y;
    323                                 r->w *= _scaleFactor;
    324                                 r->h = dst_h * _scaleFactor;
     347                                r->h -= r->y;
    325348                        }
    326349
    327350                        SDL_UnlockSurface(_tmpscreen);
     
    332355                // This is necessary if shaking is active.
    333356                if (_forceFull) {
    334357                        _dirty_rect_list[0].y = 0;
    335                         _dirty_rect_list[0].h = _screenHeight * _scaleFactor;
     358                        _dirty_rect_list[0].h = _screenHeight * _scaleFactor_vmul / _scaleFactor_vdiv;
    336359                }
    337360
    338361                // Finally, blit all our changes to the screen
  • common/gameDetector.cpp

    RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v
    retrieving revision 1.88
    diff -u -r1.88 gameDetector.cpp
     
    4949        "\t-p<path>   - look for game in <path>\n"
    5050        "\t-x[<num>]  - load this savegame (default: 0 - autosave)\n"
    5151        "\t-f         - fullscreen mode\n"
    52         "\t-g<mode>   - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x,tv2x,dotmatrix)\n"
     52        "\t-g<mode>   - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x,tv2x,dotmatrix,ratio800)\n"
    5353        "\t-e<mode>   - set music engine (see README for details)\n"
    5454        "\t-a         - specify game is amiga version\n"
    5555        "\t-q<lang>   - specify language (en,de,fr,it,pt,es,ja,zh,ko,hb)\n"
     
    9292        {"advmame2x", "AdvMAME2x", GFX_ADVMAME2X},
    9393        {"tv2x", "TV2x", GFX_TV2X},
    9494        {"dotmatrix", "DotMatrix", GFX_DOTMATRIX},
     95        {"ratio800", "Ratio800", GFX_RATIO800},
    9596#else
    9697        {"flipping", "Page Flipping", GFX_FLIPPING},
    9798        {"dbuffer", "Double Buffer", GFX_DOUBLEBUFFER},
  • common/scaler.cpp

    RCS file: /cvsroot/scummvm/scummvm/common/scaler.cpp,v
    retrieving revision 1.11
    diff -u -r1.11 scaler.cpp
     
    155155#define RED_MASK555 0x7C007C00
    156156#define GREEN_MASK555 0x03E003E0
    157157
    158 void Super2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
     158void Super2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height) {
    159159        uint16 *bP;
    160160        uint8 *dP;
    161161        uint32 inc_bP;
     
    271271        }
    272272}
    273273
    274 void SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
     274void SuperEagle(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height) {
    275275        uint8 *dP;
    276276        uint16 *bP;
    277277        uint32 inc_bP;
     
    388388        }
    389389}
    390390
    391 void _2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
     391void _2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int x, int y, int width, int height) {
    392392        uint8 *dP;
    393393        uint16 *bP;
    394394        uint32 inc_bP;
     
    583583// it seems to allow for arbitrary scale factors, not just 2x... hence I leave this in
    584584// for now, as that seems to be a very useful feature
    585585void Scale_2xSaI(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
    586                                                                  uint32 dstWidth, uint32 dstHeight, int width, int height) {
     586                                                                 uint32 dstWidth, uint32 dstHeight, int x, int y, int width, int height) {
    587587        uint8 *dP;
    588588        uint16 *bP;
    589589
     
    714714}
    715715
    716716void AdvMame2x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
    717                                                          int width, int height) {
     717                                                         int x, int y, int width, int height) {
    718718        unsigned int nextlineSrc = srcPitch / sizeof(uint16);
    719719        uint16 *p = (uint16 *)srcPtr;
    720720
     
    747747}
    748748
    749749void Normal1x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
    750                                                         int width, int height) {
     750                                                        int x, int y, int width, int height) {
    751751        while (height--) {
    752752                memcpy(dstPtr, srcPtr, 2 * width);
    753753                srcPtr += srcPitch;
     
    756756}
    757757
    758758void Normal2x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
    759                                                         int width, int height) {
     759                                                        int x, int y, int width, int height) {
    760760        uint8 *r;
    761761
    762762        while (height--) {
     
    775775}
    776776
    777777void Normal3x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
    778                                                         int width, int height) {
     778                                                        int x, int y, int width, int height) {
    779779        uint8 *r;
    780780        uint32 dstPitch2 = dstPitch * 2;
    781781        uint32 dstPitch3 = dstPitch * 3;
     
    801801}
    802802
    803803void TV2x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
    804                                         int width, int height) {
     804                                        int x, int y, int width, int height) {
    805805        unsigned int nextlineSrc = srcPitch / sizeof(uint16);
    806806        uint16 *p = (uint16 *)srcPtr;
    807807
     
    831831}
    832832
    833833void DotMatrix(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
    834                                         int width, int height)
     834                                        int x, int y, int width, int height)
    835835{
    836836        unsigned int nextlineSrc = srcPitch / sizeof(uint16);
    837837        uint16 *p = (uint16 *)srcPtr;
     
    849849                }
    850850                p += nextlineSrc;
    851851                q += nextlineDst << 1;
     852        }
     853}
     854
     855void Ratio800(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
     856                                        int x, int y, int width, int height)
     857{
     858        unsigned int nextlineSrc = srcPitch / sizeof(uint16);
     859        uint16 *p = (uint16 *)srcPtr;
     860
     861        unsigned int nextlineDst = dstPitch / sizeof(uint16);
     862        uint16 *q0 = (uint16 *)dstPtr;
     863        uint16 *q;
     864
     865        int i, j;
     866        uint16 c;
     867
     868        for(i = 0; i < height; i++) {
     869            q = q0;
     870            for(j = 0; j < width; j++) {
     871                c = *p;
     872                if((j ^ x) & 1) {
     873                    q[0] = q[nextlineDst] = q[nextlineDst * 2] =
     874                        INTERPOLATE(c, p[-1]);
     875                    q++;
     876                }
     877                p++;
     878                q[0] = q[nextlineDst] = q[nextlineDst * 2] =
     879                q[1] = q[nextlineDst + 1] = q[nextlineDst * 2 + 1] =
     880                    c;
     881                q += 2;
     882            }
     883            p += nextlineSrc - width;
     884            q0 += nextlineDst * 3;
    852885        }
    853886}
  • common/scaler.h

    RCS file: /cvsroot/scummvm/scummvm/common/scaler.h,v
    retrieving revision 1.7
    diff -u -r1.7 scaler.h
     
    2525
    2626#define DECLARE_SCALER(x)       \
    2727        extern void x(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, \
    28                                         uint32 dstPitch, int width, int height)
     28                                        uint32 dstPitch, int x, int y, int width, int height)
    2929
    3030DECLARE_SCALER(_2xSaI);
    3131DECLARE_SCALER(Super2xSaI);
     
    3636DECLARE_SCALER(Normal3x);
    3737DECLARE_SCALER(TV2x);
    3838DECLARE_SCALER(DotMatrix);
     39DECLARE_SCALER(Ratio800);
    3940
    4041
    4142enum {
     
    4849        GFX_ADVMAME2X = 6,
    4950        GFX_TV2X = 7,
    5051        GFX_DOTMATRIX = 8,
     52        GFX_RATIO800 = 9,
    5153       
    5254        GFX_FLIPPING = 100,     // Palmos
    5355        GFX_DOUBLEBUFFER = 101  // Palmos